<!-- Modal -->

<div id="dispenseMedicationModal-{{ page_obj.start_index|add:forloop.counter0 }}" class="modal fade" role="dialog">
  
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header ">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h5 class="modal-title">
            <span class="text text-danger">
                <i class="fa fa-print"></i> Dispense Medication: {{wrapped.object.schedule.subject_identifier}}
            </span>
        </h5>
      </div>
      <form id="form-dispense" method="post" action="{% url dispensing_form_url_name wrapped.object.schedule.subject_identifier wrapped.appointment_id %}?">
      <input type='hidden' name='csrfmiddlewaretoken' value='{{ csrf_token }}'/>
      <input type='hidden' name='timepoint_id' value='{{ csrf_token }}'/>
      <input type='hidden' name='action' value='print_selected'/>
      <div class="modal-body">
                <div class="panel-group">
                    <div class="panel-heading">
                      <h5 class="panel-title">
                        <a role="button" href="#">
                        <small>
                        <b>Start: </b>{{wrapped.object.appt_datetime | date:"Y-m-d"}} 
                        <b>End: </b>{{wrapped.dispense_appt_describe.end_date | date:"Y-m-d"}} 
                        {{wrapped.dispense_appt_describe.start_day}}-{{wrapped.dispense_appt_describe.end_day}}
                        <b>Next Appt:</b> 
                            {% if wrapped.object.next_appt_datetime %} 
                                {{wrapped.object.next_appt_datetime | date:"Y-m-d" }}
                            {% else %}
                                <small>No future appt for this schedule.</small>
                            {%endif%}
                       </small>
                        </a>
                      </h5>
                    </div>
                  <div class="panel panel-default">
                     <div class="list-group">
                         {% for prescription in wrapped.prescriptions %}
                               <a class="list-group-item" href="#">
	                                <div class="checkbox">
	                                  <label>
	                                    <input type="checkbox" value="{{prescription.id}}" name="med_{{forloop.counter}}">
	                                         <span class="text text-info">
	                                            <b>Name:</b> {{prescription.description}}
	                                         </span> 
	                                         <span class="text text-info">
                                                <b></b>
                                             </span>
                                             
                                             <span class="text text-info">
                                                <b>, BW: </b>{{prescription.weight}} in Kg
                                             </span>
                                             <span class="text text-info">
                                                <b>, Required Quantity:</b> {{prescription.result}} {{prescription.category}}(s)
                                             </span>
	                                    </label>
	                                </div>
                                </a>
                        {% endfor %}
                        </div>            
                    </div>
                </div>
            </div>
            
      <div class="modal-footer">
         <button class="btn btn-default" type="submit">
            <i class="fa fa-print"></i> Select All
        </button>
        <button class="btn btn-warning" type="submit">
            <i class="fa fa-print"></i> Print Selected
        </button>
      </div>
    </form>
    </div>
  </div>
</div>