<div class="breadcrumb">
    <h1>Review</h1>
    <ul>
        <li><a href="<?php echo SITE_URL.ADMIN_DIR ?>">Dashboard</a></li>
        <li>Review list</li>
    </ul>
</div>
<div class="separator-breadcrumb border-top"></div>

<form action="" method="post" id="searchFrm" name="searchFrm">
    <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="review_patient_uniqueId">Patient External Id</label>
                            <input type="text" class="form-control" name="review_patient_uniqueId" id="review_patient_uniqueId">
                        </div>

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

                        <div class="col-md-2 mt-3 mt-md-0">
                            <label for="review_text">Review Text</label>
                            <input type="text" class="form-control" name="review_text" id="review_text">
                        </div>
                        <!-- <div class="col-md-2 mt-3 mt-md-0">
                            <label for="review_patient_id">Patient Name</label>
                            <input type="text" class="form-control" id="review_patient_name" name="review_patient_name">
                        </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="review_clinic_id">Clinic</label>
                            <select class="form-control" id="review_clinic_id" name="review_clinic_id" multiple name="review_clinic_id[]">
                                <!-- <option value="">Select Clinic</option> -->
                                <?php
                                    $clinicObj = new clinic();
                                    $fields = array('clinic_id','clinic_name');
                                    $where = array("clinic_status="=>'1');
                                    $clinicArg = array("fields"=>$fields,"where"=>$where);
                                    $clinicDetails = $clinicObj->getAllRecords($clinicArg);
                                    foreach($clinicDetails as $ckey => $value_clinic)
                                    { ?>
                                        <option value="<?php echo $value_clinic->clinic_id; ?>"><?php echo $value_clinic->clinic_name; ?></option>
                                    <?php } ?>
                            </select>
                        </div>

                        <div class="col-md-2 mt-3 mt-md-0">
                            <label for="review_rate">Rate</label>
                            <select class="form-control" id="review_rate" name="review_rate">
                                <option value="">Select rate</option>
                                <?php
                                    $reviewObj = new review();
                                    $fields = array('review_id','review_rate');
                                    $groupBy = array('review_rate');
                                    $reviewArg = array('fields'=>$fields,'groupBy'=>$groupBy);
                                    $reviewDetail = $reviewObj->getAllRecords($reviewArg);
                                    foreach($reviewDetail as $rkey => $rvalue)
                                    { ?>
                                        <option value="<?php echo $rvalue->review_rate; ?>"><?php echo $rvalue->review_rate; ?></option>
                                   <?php }
                                ?>
                            </select>
                        </div>   
                        <div class="col-md-2 mt-3 mt-md-0">
                            <label for="review_app_status">Appoinment Status</label>
                            <select class="form-control" id="review_app_status" name="review_app_status">
                                <option value="">Select Status</option>
                                <option value="requested">Requested</option>
                                <option value="schedule">Schedule</option>
                                <option value="completed">Completed</option>
                                <option value="cancelled">Cancelled</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" 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>Patient Info</th>
                                <th>Appoimnent Info</th>
                                <th>Clinic Info</th>
                                <th>Provider Info</th>
                                <th>Review Info</th>
                                <!-- <th>Month/Year/Status</th> -->
                            </tr>
                        </thead>
                    </table>
                  </form>
                </div>
            </div>
        </div>
    </div>
</div>

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

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

    $('#review_clinic_id').multiselect({
            columns: 1,
            placeholder: 'Select Clinic',
            search: true,
            selectAll: true
    });

    $('#list').DataTable( { 
          "ajax": "reviewlist.php?act=load",
          "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."
          }
          
    } );

    $("#searchFrm").on('submit',function(e){

            e.preventDefault();

            var review_app_uniqueId = $("#review_app_uniqueId").val();
            var clinic_id = $("#review_clinic_id").val();
            //var patient_name = $("#review_patient_name").val();
            var review_text = $("#review_text").val();
            var review_rate = $("#review_rate").val();
            var review_app_status = $("#review_app_status").val();
            var patient_firstname = $("#patient_firstname").val();
            var patient_lastname = $("#patient_lastname").val();
            var review_patient_uniqueId = $("#review_patient_uniqueId").val();

            $("#list").DataTable().destroy();
            $("#list").DataTable({

                    "ajax":"reviewlist.php?act=load&review_app_uniqueId="+review_app_uniqueId+"&firstname="+patient_firstname+"&review_text="+review_text+"&review_rate="+review_rate+"&clinic_id="+clinic_id+"&review_app_status="+review_app_status+"&lastname="+patient_lastname+"&review_patient_uniqueId="+review_patient_uniqueId,
                    "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>