<script type="text/javascript">
//$(document).ready(function(){
    /*$("#frm-clinicsetting").submit(function(e){
            if(!validate_practice()){
                e.preventDefault();
            }
            $("#status_msg").show();
            $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button> Updated successfully...</div>");
            $("#status_msg_td").html(msg);
            return false; 
            //hideMessage();
    });*/

    /*$('#frm-clinicsetting').on('submit',function (e) {
            e.preventDefault();
              $.ajax({
                type: 'post',
                url: 'clinic_setting.php?act=setting',
                data: $('#frm-clinicsetting').serialize(),
                success: function () {
                    $("#status_msg").show();
                    $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button> Updated successfully...</div>");
                    //$("#status_msg_td").html(msg);
                    hideMessage();
                }
              });
        });*/
//});
/*function validate_practice(){
    var practicename = $("#practice_name");var practicenamemsg = $("#msg_practice_name");
    var practice_xcare_id = $("#xcare_id");var xcare_idmsg = $("#msg_xcare_id");
    var pullguarantors = $("#pullguarantors_name");var pullguarantorsmsg = $("#msg_pullguarantors_name");
    var pullPatients = $("#PullPatients_name");var pullPatientsmsg = $("#msg_PullPatients_name");
    var pullAppointments = $("#PullAppointments_name");var pullAppointmentsmsg = $("#msg_PullAppointments_name");
    
    if(practicename.val()==''){practicename.addClass('error');practicename.focus();practicenamemsg.html('Please enter practice name').show();
            return false;
    }else
    {
        practicename.removeClass('error');
        practicenamemsg.hide();
    }
        
    if(practice_xcare_id.val()=='')
    {
        practice_xcare_id.addClass('error');
        practice_xcare_id.focus();
        xcare_idmsg.html('Please select xcareId').show();
        return false;
    }else
    {
        practice_xcare_id.removeClass('error');
        xcare_idmsg.hide();
    }

    if(pullguarantors.val()=='')
    {
          pullguarantors.addClass('error');
          pullguarantors.focus();
          pullguarantorsmsg.html('Please select guarantor').show();
          return false;
    }else
    {   
        pullguarantors.removeClass('error');
        pullguarantorsmsg.hide();
    }

    if(pullPatients.val()=='')
    {
          pullPatients.addClass('error');
          pullPatients.focus();
          pullPatientsmsg.html('Please select patient').show();
          return false;
    }else
    {   
        pullPatients.removeClass('error');
        pullPatientsmsg.hide();
    }

    

    if(pullAppointments.val()=='')
    {
        pullAppointments.addClass('error');
        pullAppointments.focus();
        pullAppointmentsmsg.html('Please select appoinment').show();
        return false;
    }else
    {   
        pullAppointments.removeClass('error');
        pullAppointmentsmsg.hide();
    }
    return true;
}*/

</script>
<div class="breadcrumb">
    <h1>Clinic Overdue</h1>
    <ul>
        <li><a href="<?php echo SITE_URL.ADMIN_DIR ?>">Dashboard</a></li>
        <li><a href="<?php echo SITE_URL.ADMIN_DIR ?>/cliniclist.php">Clinic Overdue</a></li>
    </ul>
</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="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Clinic Overdue</div>
                <form action="" id='frm-clinicoverdue' method="post" enctype="multipart/form-data">
                    
                    <div class="row">

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdueval"><span class="asterisk"></span></label>
                            <input type="hidden" class="form-control" id="clinic_overdueval_6" name="clinic_overdueval_6" value="0-6" placeholder="Enter Initiation days">
                            <br/>
                            <span><b>0-6</b></span>
                        </div>

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_initiation_days">Initiation days <span class="asterisk">*</span></label>
                            <input type="text" class="form-control" id="clinic_initiation_days_6" name="clinic_initiation_days_6" value="<?php echo $initiation_days_6; ?>" placeholder="Enter Initiation days">
                            <div class="invalid-tooltip" id="msg_clinic_initiation_days_6"></div>
                        </div>
                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdue_status">Status <span class="asterisk">*</span></label>
                            <select id="clinic_overdue_status_6" name="clinic_overdue_status_6" class="form-control" multiple name="clinic_overdue_status_6[]">
                                <!-- <option value="">Select Status</option> -->
                                <option value="requested" <?php echo (in_array("requested",$status_6))?"selected='selected'":""  ?> >Requested</option>
                                <option value="scheduled" <?php echo (in_array("scheduled",$status_6))?"selected='selected'":""  ?> >Scheduled</option>
                                <option value="completed" <?php echo (in_array("completed",$status_6))?"selected='selected'":""  ?> >Completed</option>
                                <option value="cancelled" <?php echo (in_array("cancelled",$status_6))?"selected='selected'":""  ?> >Cancelled</option>
                                <option value="waitlist" <?php echo (in_array("waitlist",$status_6))?"selected='selected'":""  ?> >Waitlist</option>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_overdue_status_6"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_category">Procedure Category </label>
                            <select id="clinic_procedure_category_6" name="clinic_procedure_category_6" class="form-control" multiple name="clinic_procedure_category_6[]">
                                <?php
                                    $procedure_codeObj = new procedure_code();
                                    $where = "procedure_code_clinic_id = '".$_REQUEST['clinic_id']."' and procedure_code_category != ''";
                                    $groupBy = array("procedure_code_category");
                                    $procedurecodeArg    = array('where' => $where,'groupBy'=>$groupBy);
                                    $categoryDetails = $procedure_codeObj->getAllRecords($procedurecodeArg);
                                    ?>
                                    <!-- <option value="0">Select Category</option> -->
                                    <?php
                                    foreach ($categoryDetails as $key => $categoryvalue) 
                                    { ?>
                                       <option value="<?php echo $categoryvalue->procedure_code_category; ?>" <?php echo (in_array($categoryvalue->procedure_code_category,$procedure_category_6))?"selected='selected'":""  ?>  ><?php echo $categoryvalue->procedure_code_category; ?></option>
                                                             
                                    <?php } ?>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_category_6"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_code_6">Procedure Code <?php echo $pr; ?> </label>
                            <select id="clinic_procedure_code_6" name="clinic_procedure_code_6" class="form-control" multiple name="clinic_procedure_code_6[]">
                                <!-- <option value="">Select Code</option> -->
                                <?php if($codeDetails_6){
                                        foreach($codeDetails_6 as $c6key => $cvalue)
                                        { ?>
                                            <option value="<?php echo $cvalue->procedure_code_sikkaId; ?>" <?php echo (in_array($cvalue->procedure_code_sikkaId,$procedure_code_6))?"selected='selected'":""  ?>  ><?php echo $cvalue->procedure_code_sikkaId; ?></option>
                                        <?php }
                                      }
                                 ?> 
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_code_6"></div>
                        </div>
                    </div>

                    <div class="row">

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdueval"><span class="asterisk"></span></label>
                            <input type="hidden" class="form-control" id="clinic_overdueval_12" name="clinic_overdueval_12" value="7-12" placeholder="Enter Initiation days">
                            <br/>
                            <span><b>7-12</b></span>
                        </div>

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_initiation_days_12">Initiation days <span class="asterisk">*</span></label>
                            <input type="text" class="form-control" id="clinic_initiation_days_12" name="clinic_initiation_days_12" value="<?php echo $initiation_days_12; ?>" placeholder="Enter Initiation days">
                            <div class="invalid-tooltip" id="msg_clinic_initiation_days_12"></div>
                        </div>
                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdue_status_12">Status <span class="asterisk">*</span></label>
                            <select id="clinic_overdue_status_12" name="clinic_overdue_status_12" class="form-control" multiple name="clinic_overdue_status_12[]">
                                <!-- <option value="">Select Status</option> -->
                                <option value="requested" <?php echo (in_array("requested",$status_12))?"selected='selected'":""  ?> >Requested</option>
                                <option value="scheduled" <?php echo (in_array("scheduled",$status_12))?"selected='selected'":""  ?> >Scheduled</option>
                                <option value="completed" <?php echo (in_array("completed",$status_12))?"selected='selected'":""  ?> >Completed</option>
                                <option value="cancelled" <?php echo (in_array("cancelled",$status_12))?"selected='selected'":""  ?> >Cancelled</option>
                                <option value="waitlist" <?php echo (in_array("waitlist",$status_12))?"selected='selected'":""  ?> >Waitlist</option>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_overdue_status_12"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_category_12">Procedure Category </label>
                            <select id="clinic_procedure_category_12" name="clinic_procedure_category_12" class="form-control" multiple name="clinic_procedure_category_12[]">
                                <?php
                                    $procedure_codeObj = new procedure_code();
                                    $where = "procedure_code_clinic_id = '".$_REQUEST['clinic_id']."' and procedure_code_category != ''";
                                    $groupBy = array("procedure_code_category");
                                    $procedurecodeArg    = array('where' => $where,'groupBy'=>$groupBy);
                                    $categoryDetails = $procedure_codeObj->getAllRecords($procedurecodeArg);
                                    ?>
                                    <!-- <option value="0">Select Category</option> -->
                                    <?php
                                    foreach ($categoryDetails as $key => $categoryvalue) 
                                    { ?>
                                       <option value="<?php echo $categoryvalue->procedure_code_category; ?>" <?php echo (in_array($categoryvalue->procedure_code_category,$procedure_category_12))?"selected='selected'":""  ?>  ><?php echo $categoryvalue->procedure_code_category; ?></option>
                                                             
                                    <?php } ?>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_category_12"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_code_12">Procedure Code <?php echo $pr; ?> </label>
                            <select id="clinic_procedure_code_12" name="clinic_procedure_code_12" class="form-control" multiple name="clinic_procedure_code_12[]">
                                <!-- <option value="">Select Code</option> -->
                                <?php if($codeDetails_12){
                                        foreach($codeDetails_12 as $c12key => $cvalue)
                                        { ?>
                                            <option value="<?php echo $cvalue->procedure_code_sikkaId; ?>" <?php echo (in_array($cvalue->procedure_code_sikkaId,$procedure_code_12))?"selected='selected'":""  ?>  ><?php echo $cvalue->procedure_code_sikkaId; ?></option>
                                        <?php }
                                      }
                                 ?>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_code_12"></div>
                        </div>
                    </div>

                    <div class="row">

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdueval"><span class="asterisk"></span></label>
                            <input type="hidden" class="form-control" id="clinic_overdueval_18" name="clinic_overdueval_18" value="13-18" placeholder="Enter Initiation days">
                            <br/>
                            <span><b>13-18</b></span>
                        </div>

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_initiation_days_18">Initiation days <span class="asterisk">*</span></label>
                            <input type="text" class="form-control" id="clinic_initiation_days_18" name="clinic_initiation_days_18" value="<?php echo $initiation_days_18; ?>" placeholder="Enter Initiation days">
                            <div class="invalid-tooltip" id="msg_clinic_initiation_days_18"></div>
                        </div>
                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdue_status_18">Status <span class="asterisk">*</span></label>
                            <select id="clinic_overdue_status_18" name="clinic_overdue_status_18" class="form-control" multiple name="clinic_overdue_status_18[]">
                                <!-- <option value="">Select Status</option> -->
                                <option value="requested" <?php echo (in_array("requested",$status_18))?"selected='selected'":""  ?> >Requested</option>
                                <option value="scheduled" <?php echo (in_array("scheduled",$status_18))?"selected='selected'":""  ?> >Scheduled</option>
                                <option value="completed" <?php echo (in_array("completed",$status_18))?"selected='selected'":""  ?> >Completed</option>
                                <option value="cancelled" <?php echo (in_array("cancelled",$status_18))?"selected='selected'":""  ?> >Cancelled</option>
                                <option value="waitlist" <?php echo (in_array("waitlist",$status_18))?"selected='selected'":""  ?> >Waitlist</option>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_overdue_status_18"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_category_18">Procedure Category </label>
                            <select id="clinic_procedure_category_18" name="clinic_procedure_category_18" class="form-control" multiple name="clinic_procedure_category_18[]">
                                <?php
                                    $procedure_codeObj = new procedure_code();
                                    $where = "procedure_code_clinic_id = '".$_REQUEST['clinic_id']."' and procedure_code_category != ''";
                                    $groupBy = array("procedure_code_category");
                                    $procedurecodeArg    = array('where' => $where,'groupBy'=>$groupBy);
                                    $categoryDetails = $procedure_codeObj->getAllRecords($procedurecodeArg);
                                    ?>
                                    <!-- <option value="0">Select Category</option> -->
                                    <?php
                                    foreach ($categoryDetails as $key => $categoryvalue) 
                                    { ?>
                                       <option value="<?php echo $categoryvalue->procedure_code_category; ?>" <?php echo (in_array($categoryvalue->procedure_code_category,$procedure_category_18))?"selected='selected'":""  ?>  ><?php echo $categoryvalue->procedure_code_category; ?></option>
                                                             
                                    <?php } ?>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_category_18"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_code_18">Procedure Code <?php echo $pr; ?> </label>
                            <select id="clinic_procedure_code_18" name="clinic_procedure_code_18" class="form-control" multiple name="clinic_procedure_code_18[]">
                                <!-- <option value="">Select Code</option> -->
                                <?php if($codeDetails_18){
                                        foreach($codeDetails_18 as $c18key => $cvalue)
                                        { ?>
                                            <option value="<?php echo $cvalue->procedure_code_sikkaId; ?>" <?php echo (in_array($cvalue->procedure_code_sikkaId,$procedure_code_18))?"selected='selected'":""  ?>  ><?php echo $cvalue->procedure_code_sikkaId; ?></option>
                                        <?php }
                                      }
                                 ?>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_code_18"></div>
                        </div>
                    </div>

                    <div class="row">

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdueval"><span class="asterisk"></span></label>
                            <input type="hidden" class="form-control" id="clinic_overdueval_24" name="clinic_overdueval_24" value="19-24" placeholder="Enter Initiation days">
                            <br/>
                            <span><b>19-24</b></span>
                        </div>

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_initiation_days_24">Initiation days <span class="asterisk">*</span></label>
                            <input type="text" class="form-control" id="clinic_initiation_days_24" name="clinic_initiation_days_24" value="<?php echo $initiation_days_24; ?>" placeholder="Enter Initiation days">
                            <div class="invalid-tooltip" id="msg_clinic_initiation_days_24"></div>
                        </div>
                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdue_status_24">Status <span class="asterisk">*</span></label>
                            <select id="clinic_overdue_status_24" name="clinic_overdue_status_24" class="form-control" multiple name="clinic_overdue_status_24[]">
                                <!-- <option value="">Select Status</option> -->
                                <option value="requested" <?php echo (in_array("requested",$status_24))?"selected='selected'":""  ?> >Requested</option>
                                <option value="scheduled" <?php echo (in_array("scheduled",$status_24))?"selected='selected'":""  ?> >Scheduled</option>
                                <option value="completed" <?php echo (in_array("completed",$status_24))?"selected='selected'":""  ?> >Completed</option>
                                <option value="cancelled" <?php echo (in_array("cancelled",$status_24))?"selected='selected'":""  ?> >Cancelled</option>
                                <option value="waitlist" <?php echo (in_array("waitlist",$status_24))?"selected='selected'":""  ?> >Waitlist</option>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_overdue_status_24"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_category_24">Procedure Category </label>
                            <select id="clinic_procedure_category_24" name="clinic_procedure_category_24" class="form-control" multiple name="clinic_procedure_category_24[]">        
                            <?php
                            foreach ($categoryDetails as $key => $categoryvalue) 
                            { ?>
                               <option value="<?php echo $categoryvalue->procedure_code_category; ?>" <?php echo (in_array($categoryvalue->procedure_code_category,$procedure_category_24))?"selected='selected'":""  ?>  ><?php echo $categoryvalue->procedure_code_category; ?></option>
                                                     
                            <?php } ?>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_category_24"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_code_24">Procedure Code <?php echo $pr; ?> </label>
                            <select id="clinic_procedure_code_24" name="clinic_procedure_code_24" class="form-control" multiple name="clinic_procedure_code_24[]">
                                <!-- <option value="">Select Code</option> -->
                                <?php if($codeDetails_24){
                                        foreach($codeDetails_24 as $c24key => $cvalue)
                                        { ?>
                                            <option value="<?php echo $cvalue->procedure_code_sikkaId; ?>" <?php echo (in_array($cvalue->procedure_code_sikkaId,$procedure_code_24))?"selected='selected'":""  ?>  ><?php echo $cvalue->procedure_code_sikkaId; ?></option>
                                        <?php }
                                      }
                                 ?>

                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_code_24"></div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-md-12">
                            <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Submit">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">New Patient Status</div>
                <form action="" id='frm-clinicpatientstatus' method="post" enctype="multipart/form-data">
                    
                    <div class="row">

                        

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_patient_status">Status </label>
                            <select id="clinic_patient_status" name="clinic_patient_status" class="form-control" multiple name="clinic_patient_status[]">
                                <!-- <option value="">Select Status</option> -->
                                <option value="requested" <?php echo (in_array("requested",$clinic_patient_status))?"selected='selected'":""  ?> >Requested</option>
                                <option value="scheduled" <?php echo (in_array("scheduled",$clinic_patient_status))?"selected='selected'":""  ?> >Scheduled</option>
                                <option value="completed" <?php echo (in_array("completed",$clinic_patient_status))?"selected='selected'":""  ?> >Completed</option>
                                <option value="cancelled" <?php echo (in_array("cancelled",$clinic_patient_status))?"selected='selected'":""  ?> >Cancelled</option>
                                <option value="waitlist" <?php echo (in_array("waitlist",$clinic_patient_status))?"selected='selected'":""  ?> >Waitlist</option>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_patient_status"></div>
                        </div>
                        
                    </div>

                    <div class="row">
                        <div class="col-md-12">
                            <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Submit">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script src="./assets/js/jquery.multiselect.js"></script>
<link rel="stylesheet" href="./assets/styles/css/jquery.multiselect.css">
<script type="text/javascript">
$(document).ready(function(){

    $('#clinic_overdue_status_6').multiselect({
            columns: 1,
            placeholder: 'Select Status',
            search: true,
            //selectAll: true
    });

    $('#clinic_overdue_status_12').multiselect({
            columns: 1,
            placeholder: 'Select Status',
            search: true,
            //selectAll: true
    });

    $('#clinic_overdue_status_18').multiselect({
            columns: 1,
            placeholder: 'Select Status',
            search: true,
            //selectAll: true
    });

    $('#clinic_overdue_status_24').multiselect({
            columns: 1,
            placeholder: 'Select Status',
            search: true,
            //selectAll: true
    });

    $('#clinic_procedure_category_6').multiselect({
            columns: 1,
            placeholder: 'Select Category',
            search: true,
            //selectAll: true
    });

    $('#clinic_procedure_category_12').multiselect({
            columns: 1,
            placeholder: 'Select Category',
            search: true,
            //selectAll: true
    });


    $('#clinic_procedure_category_18').multiselect({
            columns: 1,
            placeholder: 'Select Category',
            search: true,
            //selectAll: true
    });


    $('#clinic_procedure_category_24').multiselect({
            columns: 1,
            placeholder: 'Select Category',
            search: true,
            //selectAll: true
    });

    $('#clinic_procedure_code_6').multiselect({
            columns: 1,
            placeholder: 'Select Code',
            search: true,
            //selectAll: true
    });


    $('#clinic_procedure_code_12').multiselect({
            columns: 1,
            placeholder: 'Select Code',
            search: true,
            //selectAll: true
    });


    $('#clinic_procedure_code_18').multiselect({
            columns: 1,
            placeholder: 'Select Code',
            search: true,
            //selectAll: true
    });

    $('#clinic_procedure_code_24').multiselect({
            columns: 1,
            placeholder: 'Select Code',
            search: true,
            //selectAll: true
    });

    $('#clinic_patient_status').multiselect({
            columns: 1,
            placeholder: 'Select Status',
            search: true,
            //selectAll: true
    });
    

    $("#clinic_procedure_category_6").on('change',function(){
        var clinic_id = <?php echo $_REQUEST['clinic_id'] ?>;
        var clinic_procedure_category_6 = $("#clinic_procedure_category_6").val();
        console.log(clinic_procedure_category_6);
        
        $.ajax({
                  url: "clinic_overdue.php?act=getprocedurecode&procedure_code="+clinic_procedure_category_6+"&clinic_id="+clinic_id,
                  type: "POST",
                 // dataType: 'json',
                  //cache: false,
                  //data: ({clinic_id: ClinicId}),
                  success: function(data)
                  {  
                    
                    $('#clinic_procedure_code_6').empty()
                    $("#clinic_procedure_code_6").html(data);  
                    $('#clinic_procedure_code_6').multiselect('reload');
                    /*$('#clinic_procedure_code_6').empty();
                    $.each(data, function(index, value) 
                    {
                        $("#clinic_procedure_code_6").append('<option value="' + value.procedure_code_sikkaId + '"'  +
                        '>' + value.procedure_code_sikkaId+ '</option>');
                        $('#clinic_procedure_code_6').multiselect('reload');
                    });*/
                  }
             });
    });

    $("#clinic_procedure_category_12").on('change',function(){
        var clinic_id = <?php echo $_REQUEST['clinic_id'] ?>;
        var clinic_procedure_category_12 = $("#clinic_procedure_category_12").val();
        //console.log(clinic_procedure_category_12);
        
        $.ajax({
                  url: "clinic_overdue.php?act=getprocedurecode&procedure_code="+clinic_procedure_category_12+"&clinic_id="+clinic_id,
                  type: "POST",
                 // dataType: 'json',
                  //cache: false,
                  //data: ({clinic_id: ClinicId}),
                  success: function(data)
                  {  
                    
                    $('#clinic_procedure_code_12').empty()
                    $("#clinic_procedure_code_12").html(data);  
                    $('#clinic_procedure_code_12').multiselect('reload');
                    /*$('#clinic_procedure_code_6').empty();
                    $.each(data, function(index, value) 
                    {
                        $("#clinic_procedure_code_6").append('<option value="' + value.procedure_code_sikkaId + '"'  +
                        '>' + value.procedure_code_sikkaId+ '</option>');
                        $('#clinic_procedure_code_6').multiselect('reload');
                    });*/
                  }
             });
    });

    $("#clinic_procedure_category_18").on('change',function(){
        var clinic_id = <?php echo $_REQUEST['clinic_id'] ?>;
        var clinic_procedure_category_18 = $("#clinic_procedure_category_18").val();
        //console.log(clinic_procedure_category_18);
        
        $.ajax({
                  url: "clinic_overdue.php?act=getprocedurecode&procedure_code="+clinic_procedure_category_18+"&clinic_id="+clinic_id,
                  type: "POST",
                 // dataType: 'json',
                  //cache: false,
                  //data: ({clinic_id: ClinicId}),
                  success: function(data)
                  {  
                    
                    $('#clinic_procedure_code_18').empty()
                    $("#clinic_procedure_code_18").html(data);  
                    $('#clinic_procedure_code_18').multiselect('reload');
                    /*$('#clinic_procedure_code_6').empty();
                    $.each(data, function(index, value) 
                    {
                        $("#clinic_procedure_code_6").append('<option value="' + value.procedure_code_sikkaId + '"'  +
                        '>' + value.procedure_code_sikkaId+ '</option>');
                        $('#clinic_procedure_code_6').multiselect('reload');
                    });*/
                  }
             });
    });

    $("#clinic_procedure_category_24").on('change',function(){
        var clinic_id = <?php echo $_REQUEST['clinic_id'] ?>;
        var clinic_procedure_category_24 = $("#clinic_procedure_category_24").val();
        //console.log(clinic_procedure_category_24);
        
        $.ajax({
                  url: "clinic_overdue.php?act=getprocedurecode&procedure_code="+clinic_procedure_category_24+"&clinic_id="+clinic_id,
                  type: "POST",
                 // dataType: 'json',
                  //cache: false,
                  //data: ({clinic_id: ClinicId}),
                  success: function(data)
                  {  
                    
                    $('#clinic_procedure_code_24').empty()
                    $("#clinic_procedure_code_24").html(data);  
                    $('#clinic_procedure_code_24').multiselect('reload');
                    /*$('#clinic_procedure_code_6').empty();
                    $.each(data, function(index, value) 
                    {
                        $("#clinic_procedure_code_6").append('<option value="' + value.procedure_code_sikkaId + '"'  +
                        '>' + value.procedure_code_sikkaId+ '</option>');
                        $('#clinic_procedure_code_6').multiselect('reload');
                    });*/
                  }
             });
    });
    
    $( "#frm-clinicoverdue" ).on( "submit", function(e) {
        e.preventDefault();
        
        var clinicId = <?php echo $_REQUEST['clinic_id'] ?>;

        var clinic_overdueval_6 = $("#clinic_overdueval_6").val();
        var clinic_overdueval_12 = $("#clinic_overdueval_12").val();
        var clinic_overdueval_18 = $("#clinic_overdueval_18").val();
        var clinic_overdueval_24 = $("#clinic_overdueval_24").val();

        var clinic_initiation_days_6 = $("#clinic_initiation_days_6").val();
        var clinic_initiation_days_12 = $("#clinic_initiation_days_12").val();
        var clinic_initiation_days_18 = $("#clinic_initiation_days_18").val();
        var clinic_initiation_days_24 = $("#clinic_initiation_days_24").val();

        var clinic_overdue_status_6 = $("#clinic_overdue_status_6").val();
        var clinic_overdue_status_12 = $("#clinic_overdue_status_12").val();
        var clinic_overdue_status_18 = $("#clinic_overdue_status_18").val();
        var clinic_overdue_status_24 = $("#clinic_overdue_status_24").val();

        var clinic_procedure_category_6 = $("#clinic_procedure_category_6").val();
        var clinic_procedure_category_12 = $("#clinic_procedure_category_12").val();
        var clinic_procedure_category_18 = $("#clinic_procedure_category_18").val();
        var clinic_procedure_category_24 = $("#clinic_procedure_category_24").val();
        var clinic_procedure_code_6 = $("#clinic_procedure_code_6").val();
        var clinic_procedure_code_12 = $("#clinic_procedure_code_12").val();
        var clinic_procedure_code_18 = $("#clinic_procedure_code_18").val();
        var clinic_procedure_code_24 = $("#clinic_procedure_code_24").val();

        if($("#clinic_initiation_days_6").val()=='')
        {
              $("#clinic_initiation_days_6").addClass('error');
              $("#clinic_initiation_days_6").focus();
              $("#msg_clinic_initiation_days_6").html('Please input initiation days').show();
              return false;
        }else if($("#clinic_overdue_status_6").val()=='')
        {
          if(clinic_initiation_days_6 !='')
          {
              $("#clinic_initiation_days_6").removeClass('error');
              $("#msg_clinic_initiation_days_6").hide();
          }

          $("#clinic_overdue_status_6").addClass('error');
          $("#clinic_overdue_status_6").focus();
          $("#msg_clinic_overdue_status_6").html('Please input select status').show();
          return false;
        }else if($("#clinic_initiation_days_12").val()=='')
        {
          if(clinic_overdue_status_6 !='')
          {
              $("#clinic_overdue_status_6").removeClass('error');
              $("#msg_clinic_overdue_status_6").hide();
          }

          $("#clinic_initiation_days_12").addClass('error');
          $("#clinic_initiation_days_12").focus();
          $("#msg_clinic_initiation_days_12").html('Please input initiation days').show();
          return false;
        }else if($("#clinic_overdue_status_12").val()=='')
        {
          if(clinic_initiation_days_12 !='')
          {
              $("#clinic_initiation_days_12").removeClass('error');
              $("#msg_clinic_initiation_days_12").hide();
          }

          $("#clinic_overdue_status_12").addClass('error');
          $("#clinic_overdue_status_12").focus();
          $("#msg_clinic_overdue_status_12").html('Please select status').show();
          return false;
        }else if($("#clinic_initiation_days_18").val()=='')
        {
          if(clinic_overdue_status_12 !='')
          {
              $("#clinic_overdue_status_12").removeClass('error');
              $("#msg_clinic_overdue_status_12").hide();
          }

          $("#clinic_initiation_days_18").addClass('error');
          $("#clinic_initiation_days_18").focus();
          $("#msg_clinic_initiation_days_18").html('Please input initiation days').show();
          return false;
        }else if($("#clinic_overdue_status_18").val()=='')
        {
          if(clinic_initiation_days_18 !='')
          {
              $("#clinic_initiation_days_18").removeClass('error');
              $("#msg_clinic_initiation_days_18").hide();
          }

          $("#clinic_overdue_status_18").addClass('error');
          $("#clinic_overdue_status_18").focus();
          $("#msg_clinic_overdue_status_18").html('Please select status').show();
          return false;
        }else if($("#clinic_initiation_days_24").val()=='')
        {
          if(clinic_overdue_status_18 !='')
          {
              $("#clinic_overdue_status_18").removeClass('error');
              $("#msg_clinic_overdue_status_18").hide();
          }

          $("#clinic_initiation_days_24").addClass('error');
          $("#clinic_initiation_days_24").focus();
          $("#msg_clinic_initiation_days_24").html('Please input initiation days').show();
          return false;
        }else if($("#clinic_overdue_status_24").val()=='')
        {
          if(clinic_initiation_days_24 !='')
          {
              $("#clinic_initiation_days_24").removeClass('error');
              $("#msg_clinic_initiation_days_24").hide();
          }

          $("#clinic_overdue_status_24").addClass('error');
          $("#clinic_overdue_status_24").focus();
          $("#msg_clinic_overdue_status_24").html('Please select status').show();
          return false;
        }else{
            console.log("else");
            if(clinic_overdue_status_24 !='')
            {
                $("#clinic_overdue_status_24").removeClass('error');
                $("#msg_clinic_overdue_status_24").hide();
            }
            $(".loader-bubble").show();

            $.ajax({      
                  url: "clinic_overdue.php",
                  data: 
                  { 
                      act:"load",
                      clinicId:clinicId,clinic_overdueval_6:clinic_overdueval_6,clinic_overdueval_12:clinic_overdueval_12,clinic_overdueval_18:clinic_overdueval_18,clinic_overdueval_24:clinic_overdueval_24,clinic_initiation_days_6:clinic_initiation_days_6,clinic_initiation_days_12:clinic_initiation_days_12,clinic_initiation_days_18:clinic_initiation_days_18,clinic_initiation_days_24:clinic_initiation_days_24,
                          clinic_overdue_status_6:clinic_overdue_status_6,
                          clinic_overdue_status_12:clinic_overdue_status_12,
                          clinic_overdue_status_18:clinic_overdue_status_18,
                          clinic_overdue_status_24:clinic_overdue_status_24,
                          clinic_procedure_category_6:clinic_procedure_category_6,clinic_procedure_category_12:clinic_procedure_category_12,clinic_procedure_category_18:clinic_procedure_category_18,
                          clinic_procedure_category_24:clinic_procedure_category_24,
                          clinic_procedure_code_6:clinic_procedure_code_6,
                          clinic_procedure_code_12:clinic_procedure_code_12,
                          clinic_procedure_code_18:clinic_procedure_code_18,
                          clinic_procedure_code_24:clinic_procedure_code_24,
                  },
                  method: 'POST',
                  success: function(data){
                      $(".loader-bubble").hide();
                      /*$("#alert_msg").hide();
                      $("#alert_msg").html(data);*/

                      $("#status_msg").show();
                      $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button> Updated successfully...</div>");
                      hideMessage();
                      
                  }
            });

        }
        console.log(clinicId);
        return false;
    });

    $( "#frm-clinicpatientstatus" ).on( "submit", function(e) {
        e.preventDefault();

        var clinicId = <?php echo $_REQUEST['clinic_id'] ?>;
        var clinic_patient_status = $("#clinic_patient_status").val();
        if($("#clinic_patient_status").val()=='')
        {
              $("#clinic_patient_status").addClass('error');
              $("#clinic_patient_status").focus();
              $("#msg_clinic_patient_status").html('Please select status').show();
              return false;
        }else{
            if(clinic_patient_status !='')
            {
                $("#clinic_patient_status").removeClass('error');
                $("#msg_clinic_patient_status").hide();
            }
            $(".loader-bubble").show();

            $.ajax({      
                  url: "clinic_overdue.php",
                  data: 
                  { 
                      act:"patient_status",
                      clinicId:clinicId,clinic_patient_status:clinic_patient_status,
                  },
                  method: 'POST',
                  success: function(data){
                      $(".loader-bubble").hide();
                      /*$("#alert_msg").hide();
                      $("#alert_msg").html(data);*/

                      $("#status_msg").show();
                      $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button> Updated successfully...</div>");
                      hideMessage();
                      
                  }
            });
        }
    });
});
</script>