<!-- 선 -->
{% macro m_hr() %}
<hr style="width: 100%; margin-left:0px; margin-right:0px; margin-top:5px; margin-bottom:5px">
{% endmacro %}

<!-- 굵은 선 -->
{% macro m_hr_black() %}
  <hr style="width: 100%; color: black; height: 2px; background-color:black;" />
{% endmacro %}


{% macro m_color(text, color) %}
  <span style="color:{{color}}; font-weight:bold;">{{text}}</span>
{% endmacro %}



{% macro m_row_start(padding='10', align='center') %}
  <div class="row" style="padding:{{ padding}}px; align-items:{{align}};">
{% endmacro %}

{% macro m_row_end() %}
  </div>
{% endmacro %}

<!-- 탭 -->
{% macro m_tab_head_start() %}
    <div class="nav nav-tabs" id="nav-tab" role="tablist">
{% endmacro %}

{% macro m_tab_head_end() %}
    </div>
{% endmacro %}

{% macro m_tab_head(name, title, active) %}
  {% if active %}
    <a class="nav-item nav-link active" id="tab_{{name}}" data-toggle="tab" href="#{{name}}" role="tab">{{title}}</a>
  {% else %}
  <a class="nav-item nav-link" id="tab_{{name}}" data-toggle="tab" href="#{{name}}" role="tab">{{title}}</a>
  {% endif %}
{% endmacro %}
<!----------------------------------------------------------------->


<!-- SETTING -->
<!-- SETTING -->
<!-- SETTING -->

<!-- SETTING  기본 틀-->
{% macro setting_top(left='', padding='10') %}
  <div class='row' style="padding-top: {{padding}}px; padding-bottom:{{padding}}px; align-items: center;">
    <div class='col-sm-3 set-left'>
    {% if left != '' %}
      <strong>{{ left }}</strong>
    {% endif %}
    </div>
    <div class='col-sm-9'>
{% endmacro %}

{% macro setting_bottom(desc=None, padding_top='5') %}
  {% if desc is not none %}
    <div style="padding-left:20px; padding-top:{{padding_top}}px;">
    <em>
    {% if desc is string %}
      {{ desc }}      
    {% elif desc is iterable %}
      {% for d in desc %}
       {{ d }}<br>
      {% endfor %}
    {% endif %}
    </em>
    </div>
  {% endif %}
    </div>
  </div>
{% endmacro %}


<!-- 텍스트 -->
{% macro setting_input_text(id, left, value='', col='9', placeholder='', desc='', type='text', disabled=False) %}
  {{ setting_top(left) }}
    <div class="input-group col-sm-{{ col }}">
      <input id="{{ id }}" name="{{ id }}" type="{{ type }}" class="form-control form-control-sm" 
        {% if placeholder != '' %}
          placeholder="{{ placeholder }}" 
        {% endif %}
      value="{{ value }}"
      {% if disabled %}
        disabled
      {% endif %}
      >
    </div>
  {{ setting_bottom(desc) }}
{% endmacro %}


<!-- 텍스트 + 버튼 -->
{% macro setting_input_text_and_buttons(id, left, buttons, value='', col='9', placeholder='', desc='', type='text', disabled=False) %}
  {{ setting_top(left) }}
    <div class="input-group col-sm-{{ col }}">
      <input id="{{ id }}" name="{{ id }}" type="{{ type }}" class="form-control form-control-sm" 
        {% if placeholder != '' %}
          placeholder="{{ placeholder }}" 
        {% endif %}
      value="{{ value }}"
      {% if disabled %}
        disabled
      {% endif %}
      >
      <div class="btn-group btn-group-sm flex-wrap mr-2" role="group" style="padding-left:5px; padding-top:0px">
        {% for b in buttons %}
          <button id="{{b[0]}}" class="btn btn-sm btn-outline-primary" 
          {% if b|length > 2 %}
            {% for d in b[2] %}
              data-{{d[0]}}="{{d[1]}}""
            {% endfor %}
          {% endif %}
          >{{b[1]}}</button>
        {% endfor %}
      </div>
    </div>
  {{ setting_bottom(desc) }}
{% endmacro %}


<!-- TEXTAREA -->
{% macro setting_input_textarea(id, left, value='', col='9', row='3', desc='', disabled=False) %}
  {{ setting_top(left) }}
  <div class="input-group col-sm-{{col}}">
    <textarea id="{{id}}" name="{{id}}" class="col-md-12" rows="{{row}}" 
      {% if disabled %}
        disabled
      {% endif %}
    >{{ value }}</textarea>
  </div>  
  {{ setting_bottom(desc) }}
{% endmacro %}

{% macro setting_input_textarea_wide(id, left, value='', col='12', row='3', desc='', disabled=False, padding='10') %}
  <div class='row' style="padding-top: {{padding}}px; padding-bottom:{{padding}}px; align-items: center;">
    <div class='col-sm-12'>
      {% if left != '' %}
        <div class="input-group col-sm-{{col}}">
          <strong>{{ left }}</strong>
        </div>
      {% endif %}
      <div class="input-group col-sm-{{col}}">
        <textarea id="{{id}}" name="{{id}}" class="col-md-12" rows="{{row}}" 
          {% if disabled %}
            disabled
          {% endif %}
        >{{ value }}</textarea>
      </div>  
      {% if desc is not none %}
        <div style="padding-left:20px; padding-top:{{padding_top}}}px;">
        <em>
        {% if desc is string %}
          {{ desc }}      
        {% elif desc is iterable %}
          {% for d in desc %}
          {{ d }}<br>
          {% endfor %}
        {% endif %}
        </em>
        </div>
      {% endif %}
    </div>
  </div>
{% endmacro %}


{% macro setting_input_textarea_and_buttons(id, left, buttons, value='', col='9', row='3', desc='', disabled=False) %}
  {{ setting_top(left) }}
  <div class="input-group col-sm-{{col}}">
    <div class="col-md-12">
      <div class="row">
        <textarea id="{{id}}" name="{{id}}" class="col-md-12" rows="{{row}}" 
          {% if disabled %}
            disabled
          {% endif %}
        >{{ value }}</textarea>
        </div>
      <div class="row" style="padding:5px;"></div>
      <div class="row">
        {% for b in buttons %}
          <button id="{{b[0]}}" class="btn btn-sm btn-outline-primary" 
          {% if b|length > 2 %}
            {% for d in b[2] %}
              data-{{d[0]}}="{{d[1]}}""
            {% endfor %}
          {% endif %}
          >{{b[1]}}</button>
        {% endfor %}
      </div>
    </div>
  </div>
  {{ setting_bottom(desc) }}
{% endmacro %}
<!-- TEXTAREA -->



<!-- 라디오버튼 -->
{% macro setting_radio_with_value(id, title, radios, value=None, desc=None, disabled=False) %}
  {{ setting_top(title) }}
    <div class="input-group col-sm-9">
    {% for r in radios %}
      <div class="custom-control custom-radio custom-control-inline">
        {% if value == r[0] %}
        <input id="{{id}}{{loop.index0}}" type="radio" class="custom-control-input" name="{{id}}" value="{{r[0]}}" checked {% if disabled %} disabled {% endif %}>
        {% else %}
        <input id="{{id}}{{loop.index0}}" type="radio" class="custom-control-input" name="{{id}}" value="{{r[0]}}" {% if disabled %} disabled {% endif %}>
        {% endif %}
        <label class="custom-control-label" for="{{id}}{{loop.index0}}">{{r[1]}}</label>
      </div>
    {% endfor %}
    </div>
  {{ setting_bottom(desc) }}
{% endmacro %}


<!-- 버튼 그룹. 그룹화 -->
{% macro setting_buttons(buttons, left='', desc='', padding='10') %}
  {{ setting_top(left, padding) }}
    <div class="input-group col-sm-9">
      <div class="btn-group btn-group-sm flex-wrap mr-2" role="group">
      {% for b in buttons %}
        <button id="{{b[0]}}" class="btn btn-sm btn-outline-primary" 
        {% if b|length > 2 %}
          {% for d in b[2] %}
            data-{{d[0]}}="{{d[1]}}""
          {% endfor %}
        {% endif %}
        >{{b[1]}}</button>
      {% endfor %}
      </div>
    </div> 
  {{ setting_bottom(desc) }}
{% endmacro %}

<!-- 히든. 윈도우 경로 같은 경우 js에서 접근시 \\ 문제 발생
  value로 셋하고 가져옴
-->
{% macro setting_input_hidden(id, value) %}
  <input id="{{ id }}" name="{{ id }}" value="{{ value}}" type="hidden">
{% endmacro %}


<!-- 스케쥴링 작동 버튼-->
{% macro setting_global_scheduler_button(is_include, is_running, id='scheduler', left='스케쥴링 작동', desc=['On : 스케쥴링 시작','Off : 스케쥴링 중지']) %}
{{ setting_top(left) }}
<div class="input-group col-sm-3">
  {% if is_include == 'True' %}
  <input id="globalSchedulerSwitchBtn" name="globalSchedulerSwitchBtn" class="form-control form-control-sm" type="checkbox" data-toggle="toggle" checked>
  {% else %}
  <input id="globalSchedulerSwitchBtn" name="globalSchedulerSwitchBtn" class="form-control form-control-sm" type="checkbox" data-toggle="toggle">
  {% endif %}
  {% if is_running == 'True' %}
    <span style="padding-left:10px; padding-top: 8px;">동작중</span>
  {% else %}    
    {% if is_include == 'True' %}
      <span style="padding-left:10px; padding-top: 8px;">대기중</span>
    {% endif %}  
  {% endif %}    
</div>
{{ setting_bottom(desc) }}
{% endmacro %}







<!-- NOT SETTING -->
<!-- NOT SETTING -->
<!-- NOT SETTING -->
<!-- 버튼 그룹 -->
{% macro m_button_group(buttons) %}
  <div class="btn-group btn-group-sm flex-wrap mr-2" role="group">
    {% for b in buttons %}
      <button id="{{b[0]}}" class="btn btn-sm btn-outline-primary" 
        {% if b|length > 2 %}
          {% for d in b[2] %}
            data-{{d[0]}}="{{d[1]}}""
          {% endfor %}
        {% endif %}
        >{{b[1]}}</button>
    {% endfor %}
  </div>
{% endmacro %}



<!-- INFO -->
<!-- INFO -->
<!-- INFO -->
<!-- 일반 텍스트 -->
{% macro info_text(id, left, value='', desc=None) %}
  {{ setting_top(left) }}
    <div style="padding-left:20px; padding-top:-5px;">
      <span id={{id}}>{{value}}</span>
    </div>
  {{ setting_bottom(desc, padding_top='-5') }}
{% endmacro %}

{% macro info_text_go(id, left, value='', desc=None, padding=10) %}
  {{ setting_top(left, padding) }}
    <div style="padding-left:20px; padding-top:-5px;">
      <span id={{id}}><a href="{{value}}" target="_blank">{{value}}</a></span>
    </div>
  {{ setting_bottom(desc, padding_top='-5') }}
{% endmacro %}

{% macro info_text_go_buttons(id, left, buttons, value='', desc=None) %}
  {{ setting_top(left) }}
    <div style="padding-left:20px; padding-top:-5px;">
      <span id={{id}}><a href="{{value}}" target="_blank">{{value}}</a></span>
      <div class="btn-group btn-group-sm flex-wrap mr-2" role="group" style="padding-left:5px; padding-top:0px">
      {% for b in buttons %}
        <button id="{{b[0]}}" class="btn btn-sm btn-outline-primary" 
        {% if b|length > 2 %}
          {% for d in b[2] %}
            data-{{d[0]}}="{{d[1]}}""
          {% endfor %}
        {% endif %}
        >{{b[1]}}</button>
      {% endfor %}
      </div>
    </div>
  {{ setting_bottom(desc, padding_top='-5') }}
{% endmacro %}

<!-- 일반 텍스트 + 버튼 -->
{% macro info_text_and_buttons(id, left, buttons, value='', desc=None) %}
  {{ setting_top(left) }}
    <div style="padding-left:20px; padding-top:-5px;">
      <span id={{id}}>{{value}}</span>
      <div class="btn-group btn-group-sm flex-wrap mr-2" role="group" style="padding-left:5px; padding-top:0px">
        {% for b in buttons %}
          <button id="{{b[0]}}" class="btn btn-sm btn-outline-primary py-0 style='font-size: 0.8em;'" 
          {% if b|length > 2 %}
            {% for d in b[2] %}
              data-{{d[0]}}="{{d[1]}}"
            {% endfor %}
          {% endif %}
        >{{b[1]}}</button>
      {% endfor %}
      </div>
    </div>

  {{ setting_bottom(desc, padding_top='-5') }}
{% endmacro %}



<!-- SELECT Dummy 
option을 script로 넣을 때 사용
예: 시스템 - 전체로그
-->
{% macro setting_select_empty(id, title, col='9', desc=None, value=None) %}
  {{ setting_top(title) }}
  <div class="input-group col-sm-{{col}}">
    <div id="{{id}}_div" name="{{id}}_div"></div>
  </div>
  {{ setting_bottom(desc) }}
{% endmacro %}























<!-- 삭제해야함 --------------------------------------------------------->
<!--
{% macro setting_radio(id, title, radios, value=None, desc=None, disabled=False) %}
  {{ setting_top(title) }}
    <div class="input-group col-sm-9">
    {% for r in radios %}
      <div class="custom-control custom-radio custom-control-inline">
        {% if value|int == loop.index0 %}
        <input id="{{id}}{{loop.index0}}" type="radio" class="custom-control-input" name="{{id}}" value="{{loop.index0}}" checked {% if disabled %} disabled {% endif %}>
        {% else %}
        <input id="{{id}}{{loop.index0}}" type="radio" class="custom-control-input" name="{{id}}" value="{{loop.index0}}" {% if disabled %} disabled {% endif %}>
        {% endif %}
        <label class="custom-control-label" for="{{id}}{{loop.index0}}">{{r}}</label>
      </div>
    {% endfor %}
    </div>
  {{ setting_bottom(desc) }}
{% endmacro %}
-->

<!--  그룹화 하지 않음.. 삭제-->
<!--
{% macro setting_button(buttons, left='', desc='') %}
  {{ setting_top(left) }}
    <div class="input-group col-sm-9">
    {% for b in buttons %}
      {% if not loop.first %}
      <span class='text-left' style="padding-left:5px; padding-top:0px">
      {% endif %}
      <button id="{{b[0]}}" class="btn btn-sm btn-outline-primary">{{b[1]}}</button>
      </span>  
    {% endfor %}
    </div> 
  {{ setting_bottom(desc) }}
{% endmacro %}
-->
<!----------------------------------------------------------------->














































































































{% macro setting_input_int(id, left, value='', min='', max='', placeholder='', desc=None) %}
  {{ setting_top(left) }}
      <div class="input-group col-sm-3">
        <input id="{{ id }}" name="{{ id }}" type="number" class="form-control form-control-sm" 
          {% if min != '' %}
            min="{{ min }}" 
          {% endif %}
          {% if max != '' %}
            max="{{ max }}" 
          {% endif %}
          {% if placeholder != '' %}
            placeholder="{{ placeholder }}" 
          {% endif %}
        value="{{ value }}">
      </div>
  {{ setting_bottom(desc) }}
{% endmacro %}



<!-- 토글버튼형식 -->
{% macro setting_checkbox(id, left, value, desc='') %}
  {{ setting_top(left) }}
      <div class="input-group col-sm-3">
        {% if value == 'True' or value == 'true' or value == 'On' %}
        <input id="{{ id }}" name="{{ id }}" class="form-control form-control-sm" type="checkbox" data-toggle="toggle" checked>
        {% else %}
        <input id="{{ id }}" name="{{ id }}" class="form-control form-control-sm" type="checkbox" data-toggle="toggle">
        {% endif %}
      </div>
  {{ setting_bottom(desc) }}
{% endmacro %}

<!-- 일반적인 체크박스 -->
{% macro setting_default_checkbox(id, left, label, value, desc='') %}
  {{ setting_top(left) }}
    <div class="input-group col-sm-9">
      <div class="form-check">
      {% if value == 'True' or value == 'true' or value == 'On' %}
        <input type="checkbox" class="form-check-input" id="{{ id }}" name="{{ id }}" checked>
      {% else %}
        <input type="checkbox" class="form-check-input" id="{{ id }}" name="{{ id }}">
      {% endif %}
      <label class="form-check-label" for="{{ id }}">{{ label }}</label>
      </div>
    </div>
  {{ setting_bottom(desc) }}
{% endmacro %}

<!-- 스케쥴러 스위치 체크박스 전용-->
{% macro setting_scheduler_switch(left='스케쥴링 작동', desc=['On : 스케쥴링 시작','Off : 스케쥴링 중지'], is_include='False', is_running='False') %}
  {{ setting_top(left) }}
    <div class="input-group col-sm-3">
      {% if is_include == 'True' %}
      <input id="scheduler_swtich_btn" name="scheduler_swtich_btn" class="form-control form-control-sm" type="checkbox" data-toggle="toggle" checked>
      {% else %}
      <input id="scheduler_swtich_btn" name="scheduler_swtich_btn" class="form-control form-control-sm" type="checkbox" data-toggle="toggle">
      {% endif %}
      {% if is_running == 'True' %}
        <span style="padding-left:10px; padding-top: 8px;">동작중</span>
      {% else %}    
        {% if is_include == 'True' %}
          <span style="padding-left:10px; padding-top: 8px;">대기중</span>
        {% endif %}  
      {% endif %}    
    </div>
  {{ setting_bottom(desc) }}
{% endmacro %}








<!-- 
한줄에 버튼만 표시. 버튼에 key, value를 넣을 수 있음
macros.setting_button_with_info([['toggle_btn', 'Toggle', [{'key':'category', 'value':'advanced'}]]], left='고급설정', desc=None)-->
{% macro setting_button_with_info(buttons, left='', desc='') %}
  {{ setting_top(left) }}
    <div class="input-group col-sm-9">
    {% for b in buttons %}
      {% if not loop.first %}
      <span class='text-left' style="padding-left:5px; padding-top:0px">
      {% endif %}
      
      <button id="{{b[0]}}" class="btn btn-sm btn-outline-primary" 
      {% for d in b[2] %}
        data-{{d[0]}}="{{d[1]}}""
      {% endfor %}
      >{{b[1]}}</button>
      </span>  
    {% endfor %}
    </div> 
  {{ setting_bottom(desc) }}
{% endmacro %}





<!-- select  -->
{% macro setting_select(id, title, options, col='9', desc=None, value=None) %}
  {{ setting_top(title) }}
  <div class="input-group col-sm-{{col}}">
    <select id="{{id}}" name="{{id}}" class="form-control form-control-sm">
      {% for item in options %}
        {% if value is not none and value == item[0] %}
        <option value="{{ item[0] }}" selected>{{item[1]}}</option>
        {% else %}
        <option value="{{ item[0] }}">{{item[1]}}</option>
        {% endif %}
            
      {% endfor %}
    </select>
  </div>
  {{ setting_bottom(desc) }}
{% endmacro %}

{% macro select(id, options, col='3', value=None) %}
  <div class="input-group col-sm-{{col}}" style="padding-left:0px; padding-top:0px">
    
    <select id="{{id}}" name="{{id}}" class="form-control form-control-sm">
      {% for item in options %}
        {% if value is not none and value == item[0] %}
        <option value="{{ item[0] }}" selected>{{item[1]}}</option>
        {% else %}
        <option value="{{ item[0] }}">{{item[1]}}</option>
        {% endif %}
            
      {% endfor %}
    </select>
  </div>
{% endmacro %}


<!-- select + 버튼  -->
{% macro setting_select_and_buttons(id, title, options, buttons, col='9', desc=None, value=None) %}
  {{ setting_top(title) }}
  <div class="input-group col-sm-{{col}}">
    <select id="{{id}}" name="{{id}}" class="form-control form-control-sm">
      {% for item in options %}
        {% if value is not none and value == item[0] %}
        <option value="{{ item[0] }}" selected>{{item[1]}}</option>
        {% else %}
        <option value="{{ item[0] }}">{{item[1]}}</option>
        {% endif %}
            
      {% endfor %}
    </select>
    <div class="btn-group btn-group-sm flex-wrap mr-2" role="group" style="padding-left:5px; padding-top:0px">
      {% for b in buttons %}
        <button id="{{b[0]}}" class="btn btn-sm btn-outline-primary" 
        {% if b|length > 2 %}
          {% for d in b[2] %}
            data-{{d[0]}}="{{d[1]}}""
          {% endfor %}
        {% endif %}
        >{{b[1]}}</button>
      {% endfor %}
    </div>
  </div>
  {{ setting_bottom(desc) }}
{% endmacro %}












<!--progress-bar-striped progress-bar-animated-->
{% macro setting_progress(id, left='', desc='') %}
  {{ setting_top(left) }}
  <div class="col-sm-9">
    <div class="progress" style="height: 25px;">
      <div id="{{id}}" class="progress-bar" style="background-color:yellow"></div>
      <div id="{{id}}_label" class="justify-content-center d-flex w-100 position-absolute" style="margin-top:3px"></div>
    </div>
  </div>
  {{ setting_bottom(desc) }}
{% endmacro %}


<!-- 스케쥴링 작동 버튼-->
{% macro setting_scheduler_button(is_include, is_running, id='scheduler', left='스케쥴링 작동', desc=['On : 스케쥴링 시작','Off : 스케쥴링 중지']) %}
{{ setting_top(left) }}
<div class="input-group col-sm-3">
  {% if is_include == 'True' %}
  <input id="scheduler" name="scheduler" class="form-control form-control-sm" type="checkbox" data-toggle="toggle" checked>
  {% else %}
  <input id="scheduler" name="scheduler" class="form-control form-control-sm" type="checkbox" data-toggle="toggle">
  {% endif %}
  {% if is_running == 'True' %}
    <span style="padding-left:10px; padding-top: 8px;">동작중</span>
  {% else %}    
    {% if is_include == 'True' %}
      <span style="padding-left:10px; padding-top: 8px;">대기중</span>
    {% endif %}  
  {% endif %}    
</div>
{{ setting_bottom(desc) }}
{% endmacro %}




{% macro setting_global_scheduler_sub_button(is_include, is_running, id='scheduler', left='스케쥴링 작동', desc=['On : 스케쥴링 시작','Off : 스케쥴링 중지']) %}
{{ setting_top(left) }}
<div class="input-group col-sm-3">
  {% if is_include == 'True' %}
  <input id="global_scheduler_sub" name="global_scheduler_sub" class="form-control form-control-sm" type="checkbox" data-toggle="toggle" checked>
  {% else %}
  <input id="global_scheduler_sub" name="global_scheduler_sub" class="form-control form-control-sm" type="checkbox" data-toggle="toggle">
  {% endif %}
  {% if is_running == 'True' %}
    <span style="padding-left:10px; padding-top: 8px;">동작중</span>
  {% else %}    
    {% if is_include == 'True' %}
      <span style="padding-left:10px; padding-top: 8px;">대기중</span>
    {% endif %}  
  {% endif %}    
</div>
{{ setting_bottom(desc) }}
{% endmacro %}

{% macro setting_global_scheduler_sublogic_button(is_include, is_running, id='scheduler', left='스케쥴링 작동', desc=['On : 스케쥴링 시작','Off : 스케쥴링 중지']) %}
{{ setting_top(left) }}
<div class="input-group col-sm-3">
  {% if is_include == 'True' %}
  <input id="global_scheduler_sublogic" name="global_scheduler_sublogic" class="form-control form-control-sm" type="checkbox" data-toggle="toggle" checked>
  {% else %}
  <input id="global_scheduler_sublogic" name="global_scheduler_sublogic" class="form-control form-control-sm" type="checkbox" data-toggle="toggle">
  {% endif %}
  {% if is_running == 'True' %}
    <span style="padding-left:10px; padding-top: 8px;">동작중</span>
  {% else %}    
    {% if is_include == 'True' %}
      <span style="padding-left:10px; padding-top: 8px;">대기중</span>
    {% endif %}  
  {% endif %}    
</div>
{{ setting_bottom(desc) }}
{% endmacro %}





{% macro m_col(width, html, align='left') %}
<div class="col-sm-{{width}}" style="text-align:{{align}}; word-break:break-all;">{{html}}</div>
{% endmacro %}

{% macro m_col_wide(width, html, align='left') %}
<div class="col-sm-{{width}}" style="padding:0px; margin:0px; text-align:{{align}}; word-break:break-all;">{{html}}</div>
{% endmacro %}

{% macro m_strong(html) %}
  <strong>{{html}}</strong>
{% endmacro %}


{% macro m_hr_head_top() %}
<div class="d-inline-block"></div>
<hr style="width: 100%; margin:0px; background-color:#808080;">
{% endmacro %}

{% macro m_hr_head_bottom() %}
  <hr style="width: 100%; margin:0px; margin-bottom:10px; margin-top:2px; background-color:#808080; height:2px" />
{% endmacro %}

{% macro m_button(id, text) %}
  <button id="{{id}}" name="{{id}}" class="btn btn-sm btn-outline-primary">{{text}}</button>
{% endmacro %}





{% macro m_tab_content_start(name, active) %}
  {% if active %}
    <div class="tab-pane fade show active" id="{{name}}" role="tabpanel">
  {% else %}
    <div class="tab-pane fade show" id="{{name}}" role="tabpanel">
  {% endif %}
{% endmacro %}

{% macro m_tab_content_end() %}
  </div>
{% endmacro %}





{% macro m_modal_start(id, title, size) %}
<!-- Modal -->
<div class="modal fade" id="{{id}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog {{size}}">
    <div class="modal-content">
      
      <div class="modal-header">
        <h4 class="modal-title" id="{{id}}_title">{{title}}</h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      </div>
      <div class="modal-body" id="modal_body" style="word-break:break-all;">
{% endmacro %}

{% macro m_modal_end() %}
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">닫기</button>
      </div>
      <div class="loading" id="modal_loading">
        <img src="/static/img/loading.gif" />
      </div>
    </div>
  </div>
</div>
<!-- Modal end -->
{% endmacro %}


{% macro m_modal_start2(id, title, size) %}
<!-- Modal -->
<div class="modal fade" id="{{id}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog {{size}}">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title" id="{{id}}_title">{{title}}</h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      </div>
      <div class="loading" id="modal_loading">
        <img src="/static/img/loading.gif" />
      </div>
{% endmacro %}      
      
{% macro m_modal_end2() %}      
    </div>
  </div>
</div>
<!-- Modal end -->
{% endmacro %}






{% macro row_start(padding='10') %}
  <div class='row' style="padding-top: {{padding}}px; padding-bottom:{{padding}}px; align-items: center;">
{% endmacro %}

{% macro row_end() %}
  </div>
{% endmacro %}

{% macro label(text='', width='1', padding='5') %}
  <span class='col-md-{{width}} set-left' style='padding-top: {{padding}}px; padding-bottom:{{padding}}px; align-items: center;'>
    <strong>{{ text }}</strong>
  </span>
{% endmacro %}

<!-- 텍스트 + 버튼 -->
{% macro input_text_and_buttons(id, left, buttons, value='', col1='1', col2='9', col3='2', placeholder='', desc='', type='text', disabled=False) %}
  <div class='row' style="padding-top: 0px; padding-bottom:0px; align-items: left;">
    <div class="col-sm-{{col1}}" style="padding-top: 5px; text-align:right;">
      {% if left != '' %}
        <span><strong>{{ left }}</strong></span>
      {% endif %}
    </div>
    <div class="col-sm-{{ col2 }}">
      <input id="{{ id }}" name="{{ id }}" type="{{ type }}" class="form-control form-control-sm" 
        {% if placeholder != '' %}
          placeholder="{{ placeholder }}" 
        {% endif %}
        value="{{ value }}"
        {% if disabled %}
          disabled
        {% endif %}
      >
    </div>
    <div class="col-sm-{{ col3 }}">
      <div class="btn-group btn-group-sm flex-wrap mr-2" role="group" style="padding-left:5px; padding-top:0px">
        {% for b in buttons %}
        <button id="{{b[0]}}" class="btn btn-sm btn-outline-primary" 
        {% if b|length > 2 %}
          {% for d in b[2] %}
            data-{{d[0]}}="{{d[1]}}""
          {% endfor %}
        {% endif %}
        >{{b[1]}}</button>
      {% endfor %}
      </div>
    </div>

      {% if desc is not none %}
        <div style="padding-left:20px; padding-top:{{padding_top}}}px;">
        <em>
        {% if desc is string %}
          {{ desc }}      
        {% elif desc is iterable %}
          {% for d in desc %}
            {{ d }}<br>
          {% endfor %}
        {% endif %}
        </em>
        </div>
      {% endif %}

  </div>
{% endmacro %}


















































<!-- 다른이름으로 정의함. 나중에 삭제 -->
{% macro buttons(buttons, left='', desc='') %}
  {{ setting_top(left) }}
    <div class="input-group col-sm-9">
      <div class="btn-group btn-group-sm flex-wrap mr-2" role="group">
      {% for b in buttons %}
        <button id="{{b[0]}}" class="btn btn-sm btn-outline-primary">{{b[1]}}</button>
      {% endfor %}
      </div>
    </div> 
  {{ setting_bottom(desc) }}
{% endmacro %}