<div class="breadcrumb">
    <h1>Sign-in Change Logs</h1>
    <ul>
        <li><a href="<?php echo SITE_URL.ADMIN_DIR ?>">Dashboard</a></li>
        <li>Sign-in Change Logs list</li>
    </ul>
</div>
<div class="separator-breadcrumb border-top"></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>

<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_patient_fullname">
                        <label for="patient_fullname">Patient Name</label>
                        <input type="text" class="form-control" name="patient_fullname" id="patient_fullname"  />
                    </div> -->

                    <div class="col-md-2 mt-3 mt-md-0"  id="div_patient_id">
                        <label for="patient_id">Patient Id</label>
                        <input type="text" class="form-control" name="patient_id" id="patient_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_firstname">
                        <label for="patient_firstname">First Name</label>
                        <input type="text" class="form-control" name="patient_firstname" id="patient_firstname"  />
                    </div>


                    <div class="col-md-2 mt-3 mt-md-0"  id="div_patient_lastname">
                        <label for="patient_lastname">Last Name</label>
                        <input type="text" class="form-control" name="patient_lastname" id="patient_lastname"  />
                    </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="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>Id</th>
                                <th>Old Email/Phone</th>
                                <th>New Email/Phone</th>
                                <th>Patient Detail</th>
                                <th>Action</th>
                                <th>Mode</th>
                                <th>Change Date</th>
                            </tr>
                        </thead>
                    </table>
                  </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="application/javascript">
   $(document).ready(function() {
     $('#list').DataTable( { 
          "ajax": "patientloginchanges.php?act=load",
          "processing": true,
          "serverSide": true,
          "pageLength": 25,
                "aaSorting": [],
                "aoColumnDefs": [
                    { 'bSortable': false, 'aTargets': [1,2,3,4,5,6] }
                ],
          language: {
              "processing" : "<div class='loader-bubble loader-bubble-primary m-5'></div>",
              "sEmptyTable" :  "No records found."
          }
          
      });

     $( "form" ).on( "submit", function(e) {
        e.preventDefault();
        
        //var patient_fullname = $("#patient_fullname").val();
        var patient_id = $("#patient_id").val();
        var patient_external_id = $("#patient_external_id").val();
        var patient_firstname = $("#patient_firstname").val();
        var patient_lastname = $("#patient_lastname").val();

        $('#list').DataTable().destroy();
          $('#list').DataTable( { 
            "ajax": "patientloginchanges.php?act=load&firstname="+patient_firstname+"&patient_id="+patient_id+"&lastname="+patient_lastname+"&patient_external_id="+patient_external_id,
            "processing": true,
            "serverSide": true,
            "pageLength": 25,
                  "aaSorting": [],
                  "aoColumnDefs": [
                      { 'bSortable': false, 'aTargets': [1,2,3,4,5,6] }
                  ],
            language: {
                "processing" : "<div class='loader-bubble loader-bubble-primary m-5'></div>",
                "sEmptyTable" :  "No records found."
            }
            
        } );

      });
    });
</script>