{% include '@dashnex/modal/support.twig' %}
{% include '@p1tm/modals/discard.twig' %}
{% include '@p1tm/curation-schedule/modals/cron-help.twig' %}

<header class="dashnex-frame-header">
	<h2 class="pull-left">Curation</h2>

	<div class="dashnex-frame-actions">
		<div id="ptm-action-buttons">
			<button type="button" class="btn btn-default" data-toggle="modal" data-target="#p1tm-discard-modal">Discard</button>
			<button id="p1tm-curator-save-changes" class="btn btn-primary">Save</button>
		</div>
		<div class="dashnex-frame-loader-container">
			<img id="ptm-loader" class="" src="{{ asset( 'p1tm', '/img/ajax-loader.gif' ) }}">
		</div>
		<button type="button" class="btn btn-info dashnex-frame-popover-btn">Help!</button>
	</div>

	<div class="clearfix"></div>
</header>

<div class="dashnex-frame-popover">
	<div class="dashnex-frame-popover-arrow"></div>
	<h3 class="dashnex-frame-popover-title">Help!</h3>
	<div class="dashnex-frame-popover-content">
        <p>
            <a href="javascript:void(0);" id="p1tm-cron-help">How do I setup a cron job?</a>
        </p>
		<p>
			<a href="http://www.dashnex.com" target="_blank">Take me to the
				membership site.</a>
		</p>
		<p>
			<a id="show-support-modal-btn" href="#">I need to email support.</a>
		</p>
	</div>
</div>

<div class="ptm-container">
  <form id="p1tm-curator-schedule-form">
    <table class="table table-bordered">
      <thead>
        <tr>
	  <th class="p1tm-siloName">Silo Name</th>
	  <th>Status</th>
	  <th>Frequency</th>
	  <th>Next Post Date</th>
        </tr>
      </thead>
      <tbody>
        {% for silo in silo_schedules %}
          <tr>
            <td>{{ silo.silo.siloKeyword }}</td>
            <td>
              <div class="btn-group btn-toggle">
                <button
                  class="btn btn-sm btn-default{% if silo.schedule.isEnabled %} btn-primary active{% endif %}"
                  data-value="{{ silo.silo.id }}"
                  >ON</button>
                <button
                  class="btn btn-sm btn-default p1tm-off{% if not silo.schedule.isEnabled %} btn-primary active{% endif %}"
                  data-value="{{ silo.silo.id }}"
                  >OFF</button>
                <input type="hidden"
                       value="{% if silo.schedule.isEnabled %}1{% else %}0{% endif %}"
                       name="p1tm-curator-status-{{ silo.silo.id }}"
                       class="p1tm-curator-status"
                       >
              </div>
            </td>
            <td>
              <select class="form-control p1tm-select" name="p1tm-curator-frequency-{{ silo.silo.id }}">
                {% for inc in 1..7 %}
                  <option {% if silo.schedule.dayIncrement == inc %}selected="selected"{% endif %}>{{ inc }}</option>
                {% endfor %}
              </select>
            </td>
            <td>
              <input type="text"
                     class="form-control p1tm-datepicker"
                     {% if silo.schedule.nextPostDate %}
                     value="{{ silo.schedule.nextPostDate|date( "d/m/Y" ) }}"
                     {% else %}
                     value="{{ date()|date( "d/m/Y" ) }}"
                     {% endif %}
                     name="p1tm-curator-date-{{ silo.silo.id }}"
                     >
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </form>
</div>
