<div class="breadcrumb">
    <h1>Overdue History</h1>
    <ul>
        <li><a href="<?php echo SITE_URL.ADMIN_DIR ?>">Dashboard</a></li>
        <li>Overdue History list</li>
    </ul>
</div>


<form action="" method="post">
<div class="row">
    <div class="col-lg-12 col-md-12">
        <div class="card mb-5">
            <div class="card-body">
                <div class="row row-xs">
                    
                    <div class="col-md-2 mt-3 mt-md-0"  id="div_clinic_id">
                        <label for="clinic_id">Clinic Id</label>
                        <select class="form-control" id="clinic_id" name="clinic_id" required="true">
                            
                            <option value="0">Select Clinic</option>
                            <?php
                                  $clinicobj = new clinic;
                                  $fields = array('clinic_id,clinic_name');
                                  $clinicArg = array("fields"=>$fields);
                                  $clinicdata = $clinicobj->getAllRecords($clinicArg);
                                  foreach ($clinicdata as $ckey => $clinic_value) 
                                    { 
                                      ?>
                                        <option value="<?php echo $clinic_value->clinic_id; ?>"><?php echo $clinic_value->clinic_name; ?></option>
                                <?php } ?>
                        </select>
                    </div>

                    <div class="col-md-2 mt-3 mt-md-0"  id="div_appoinmnet_id">
                        <label for="appoinmnet_id">Appoinmnet Id</label>
                        <input type="text" class="form-control" name="appoinmnet_id" id="appoinmnet_id" />
                    </div>

                    <div class="col-md-2 mt-3 mt-md-0"  id="div_patient_external_id">
                        <label for="patient_external_id">Patient External Id</label>
                        <input type="text" class="form-control" name="patient_external_id" id="patient_external_id" />
                    </div>

                    <!-- <div class="col-md-2 mt-3 mt-md-0"  id="div_patient_name">
                        <label for="patient_name">Patient Name</label>
                        <input type="text" class="form-control" name="patient_name" id="patient_name" />
                    </div> -->

                    <div class="col-md-2 mt-3 mt-md-0"  id="div_dependant_firstname">
                        <label for="dependant_firstname">Patient First Name</label>
                        <input type="text" class="form-control" name="dependant_firstname" id="dependant_firstname"  />
                    </div>


                    <div class="col-md-2 mt-3 mt-md-0"  id="div_dependant_lastname">
                        <label for="dependant_lastname">Patient Last Name</label>
                        <input type="text" class="form-control" name="dependant_lastname" id="dependant_lastname"  />
                    </div>

                    <div class="col-md-2 mt-3 mt-md-0"  id="div_overdue_type">
                        <label for="overdue_type">Overdue Type</label>
                        <select class="form-control" name="overdue_type" id="overdue_type">
                            <option value="">Select Type</option>
                            <option value="0To6">0-6</option>
                            <option value="7To12">7-12</option>
                            <option value="13To18">13-18</option>
                            <option value="19To24">19-24</option>
                        </select>
                    </div>

                    <div class="col-md-2 mt-3 mt-md-0"  id="div_search_appointment_date">
                        <label for="search_appointment_date">Appointment Date</label>
                        <input type="date" class="form-control" name="search_appointment_date" id="search_appointment_date" />
                        <div class="invalid-tooltip" id="msg_search_appointment_date"></div>
                    </div>

                    <div class="col-md-2 mt-3 mt-md-0"  id="div_search_overdue_date">
                        <label for="search_overdue_date">Overdue Date</label>
                        <input type="date" class="form-control" name="search_overdue_date" id="search_overdue_date" />
                        <div class="invalid-tooltip" id="msg_search_overdue_date"></div>
                    </div>


                    <div class="col-md-2 mt-3 mt-md-0">
                        <label for="">&nbsp;</label>
                        <button type="submit" name="submit" class="btn btn-primary btn-block">Search</button>
                    </div>
                    <div class="col-md-2 mt-3 mt-md-0">
                        <label for="">&nbsp;</label>
                        <button type="reset" name="reset" class="btn btn-primary btn-block" onClick="window.location.reload()">Reset</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</form>

<div class="separator-breadcrumb border-top"></div>

<div class="row mb-4">
  <div class="col-md-6">
        <!-- <select id="act" name="act" class="form-control maction">
          <option value="">Multiple action</option>              
          <option value="activate_all">Activate selected</option>
          <option value="inactivate_all">Inactivate selected</option>
          <option value="delete_all">Delete selected</option>
        </select>
        <button type="button" class="btn btn-primary m-1" onclick="return validate_all();">Apply</button> -->
  </div> 
</div>     
<div class="widget-body">
    <div class="portlet-body">
                        
    <?php echo (isset($successMsg) && $successMsg!='') ? "<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button>".base64_decode($successMsg)."</div>" : '' ; ?>
    <?php echo (isset($failedMsg) && $failedMsg!='') ? "<div class='alert alert-danger'><button data-dismiss='alert' class='close' type='button'>×</button>".base64_decode($failedMsg)."</div>" : '' ?>
   
    <div id="status_msg" style="display: none;"><div class="alert alert-success"><button data-dismiss='alert' class='close' type='button'>×</button>&nbsp;</div></div>
    <div id="alert_msg" style="display: none;"><div class="alert alert-danger"><button data-dismiss='alert' class='close' type='button'>×</button>&nbsp;</div></div>

    </div>
</div>

<div class="row mb-4">
    <div class="col-md-12 mb-4">
        <div class="card text-left">

            <div class="card-body">
                <div class="table-responsive">
                  <form id="listFrm" name="listFrm" action="" method="post">       
                    <input type="hidden" id="action" name="action" value="">
                    <table id="list" class="display table table-striped table-bordered" style="width:100%">
                        <thead>
                            <tr>
                                <th>Xcare Id</th>
                                <th>Overdue Details</th>
                                <th>Patient Details</th>
                                <th>Guarantor Details</th>
                            </tr>
                        </thead>
                    </table>
                  </form>
                </div>
            </div>
        </div>
    </div>
</div>

<link href="./assets/styles/css/select2.min.css" rel="stylesheet" />
<script src="./assets/js/select2.min.js"></script>

<style type="text/css">
.select2 {
  width: 150px !important;
}
</style>

<script type="application/javascript">
   $(document).ready(function() {

    $("#clinic_id").select2({
          tags: true
      });

    /*var cliniId = $("#clinic_id").val();
    
     $('#list').DataTable( { 
          "ajax": "appointmentloglistdata.php?act=load&clinic_id="+cliniId,
          "processing": true,
          "serverSide": true,
          "pageLength": 25,
                "aaSorting": [],
                "aoColumnDefs": [
                    { 'bSortable': false, 'aTargets': [0] }
                ],
          language: {
              "processing" : "<div class='loader-bubble loader-bubble-primary m-5'></div>",
                    "sEmptyTable" :  "No records found."
          }
          
      });*/
    

      $( "form" ).on( "submit", function(e) {
        e.preventDefault();
        var cliniId = $("#clinic_id").val();
        
        var appoinmnetId = $("#appoinmnet_id").val();
        //var patient_fullname = $("#patient_name").val();
        var dependant_firstname = $("#dependant_firstname").val();
        var dependant_lastname = $("#dependant_lastname").val();
        var search_appointment_date = $("#search_appointment_date").val();
        var search_overdue_date = $("#search_overdue_date").val();
        var overdue_type = $("#overdue_type").val();
        var patient_external_id = $("#patient_external_id").val();

        $('#list').DataTable().destroy();
          $('#list').DataTable( { 
            "ajax": "overduelist.php?act=load&clinic_id="+cliniId+"&overdue_appointment_id="+appoinmnetId+"&firstname="+dependant_firstname+"&lastname="+dependant_lastname+"&search_appointment_date="+search_appointment_date+"&search_overdue_date="+search_overdue_date+"&overdue_type="+overdue_type+"&patient_external_id="+patient_external_id,
            "processing": true,
            "serverSide": true,
            "pageLength": 25,
                  "aaSorting": [],
                  "aoColumnDefs": [
                      { 'bSortable': false, 'aTargets': [0] }
                  ],
            language: {
                "processing" : "<div class='loader-bubble loader-bubble-primary m-5'></div>",
                "sEmptyTable" :  "No records found."
            }
            
        } );

      });
    });
</script>
