
<div class="breadcrumb">
    <h1>Patient Log List</h1>
    <ul>
        <li><a href="<?php echo SITE_URL.ADMIN_DIR ?>">Dashboard</a></li>
        <li>Patient Log list</li>
    </ul>
</div>
<div class="separator-breadcrumb border-top"></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">
                        <label for="log_id">Select Patient</label>
                        <select class="form-control" id="patient_log_id" name="patient_log_id" required>
                            <option value="">Select Patient</option>
                            <?php
                                  $patientobj = new patient;
                                  $fields = array('patient_id','patient_fname','patient_lname','patient_unique_id');
                                  $patientArg = array("fields"=>$fields);
                                  $patientdata = $patientobj->getAllRecords($patientArg);
                                  foreach ($patientdata as $pkey => $patient_value) 
                                    { ?>
                                        <option value="<?php echo $patient_value->patient_unique_id; ?>"><?php echo w::d($patient_value->patient_fname)." ".w::d($patient_value->patient_lname); ?></option>
                              <?php }
                            ?>

                        </select>
                    </div>
                    <div class="col-md-2  mt-3 mt-md-0">
                        <label for="log_file_name">Select File</label>
                        <select class="form-control" id="log_file_name" name="log_file_name" required="true">
                            <option value="">Select File</option>
                        </select>
                    </div>
                    
                    <div class="col-md-2 mt-3 mt-md-0">
                        <label for="">&nbsp;</label>
                        <button type="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" class="btn btn-primary btn-block" onClick="window.location.reload()">Reset</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</form>

<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>Sr.No</th>
                                <th>Log Data</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: 160px !important;
}
</style>

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

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

        $('#patient_log_id').on('change', function() {
            //alert( this.value );
            var patientlogId = this.value;
            if(patientlogId != '')
            {
                $('#div_search_value_data').hide();
                $.ajax({
                      url: "patientloglist.php",
                      data: { act:"logfileget",
                            patientlogId:patientlogId },
                      method: 'POST',
                      success: function(data)
                      {
                          $("#log_file_name").html(data);
                      }
                });
            }else{
                $("#log_file_name").html('');
            }
        });

        
        $( "form" ).on( "submit", function(e) 
        {
            e.preventDefault();
            var patientlogId = $("#patient_log_id").val();
            var logfileName = $("#log_file_name").val();
            

            $('#list').DataTable().destroy();
              $('#list').DataTable( { 
                "ajax": {
                "url": "patientloglist.php",
                "type": "POST",
                "data": {
                    "act":"load",
                    "patientlogId": patientlogId,
                    "logfilename":logfileName,
                    }
                },
                "processing": true,
                "serverSide": true,
                "bFilter": false,
                //"bPaginate": false,
                "pageLength": 25,
                      "aaSorting": [],
                      "aoColumnDefs": [
                          { 'bSortable': false, 'aTargets': [] }
                      ],
                language: {
                    "processing" : "<div class='loader-bubble loader-bubble-primary m-5'></div>",
                    "sEmptyTable" :  "No records found."
                }
            });
        });
    
} ); 
</script>