<form name="fitness_form_employee" id="fitness_form_employee" enctype="multipart/form-data" action="#" method="post"
    role="form-horizontal">
    <div class="row">
        <div class="col-xs-12 widget-container-col" id="widget-container-col-1">
            <div class="widget-box box box-warning" id="widget-box-1">
                <div class="widget-header">
                   
                    <h5 class="widget-title"> Fitness Form
                        Patient - <?= $patient_name ?> <i style="margin-left:10px; cursor: pointer; " class="fa fa-user" target="_blank" id="profile_link" onclick="open_dashboard(<?= $emp_id ?>)"></i> 
                    </h5>

                    <div class="widget-toolbar">

                        <div class="clearfix">
                            <div class="pull-right tableTools-container">
                                <div class="dt-buttons btn-overlap btn-group">

                                    <a class=" forwardButton dt-button buttons-csv buttons-html5 btn btn-white btn-primary btn-bold save_button"
                                        onclick="$('#forward_status').val('<?= $__STATUS_DOCTOR_ATTENDED ?>');"
                                        id='forwardButton' tabindex="0" aria-controls="dynamic-table"
                                        data-original-title="" title=""><span><i
                                                class="fa fa-floppy-o  bigger-110 blue"></i> <span>Approve &
                                                Close</span></span></a>

                                    <input type="hidden" class="form-control" id="forward_status" name="forward_status">
                                    <input type="hidden" class="form-control" name="sickness_id" id="sickness_id"
                                value="<?= $sickness_id ?>" required />

                                    
                                    <a class="dt-button buttons-print btn btn-white btn-primary btn-bold"
                                        onclick="exporttopdf();" tabindex="0" aria-controls="dynamic-table"
                                        data-original-title="" title=""><span><i
                                                class="fa fa-print bigger-110 grey"></i> <span
                                                class="hidden">Print</span></span></a>

                                    <a class="dt-button buttons-print btn btn-white btn-primary btn-bold"
                                        data-action="fullscreen" tabindex="0" aria-controls="dynamic-table"
                                        data-original-title="Maximize" title="Maximize"><span><i
                                                class="fa fa fa-expand bigger-110 grey"></i> <span
                                                class="hidden">Maximize</span></span></a>
                                    <input type="hidden" name="attendedStatus" id="attendedStatus"
                                        <?php if ($rolecode == 'DOC') { ?>
                                        value="<?php echo $__STATUS_DOCTOR_ATTENDED ?>" 
                                        <?php  } ?>
                                        <?php if ($rolecode == 'RCP'|| in_array('RCP',$Rolecodes)) { ?>
                                        value="<?php echo $__STATUS_RECEPTIONIST_ATTENDED ?>" 
                                        <?php  } ?> />
                                    <input type="hidden" name="doctor_last_attended" id="doctor_last_attended"
                                        <?php if ($rolecode == 'DOC') { ?> 
                                            value="<?php echo  $_SESSION['user_id'] ?>"
                                        <?php  } else { ?>
                                             value="<?php echo $row['doctor_last_attended'] ?>"
                                        <?php  } ?> />
                                </div>
                            </div>
                        </div>

                    </div>
                </div>

                <div class="panel-body">

                    <div class="row">
                        <div class="col-sm-3">
                            <label class="control-label" for="appointment_id"><strong style="font-size: 11px">Fitness
                                    No:</strong></label>
                            <?php
							if (isset($past_ticket_no)) {
								$ticket_no = $past_ticket_no;
							} else {
								$ticket_no = creatingTicketNoFitness();
							}

							?>
                            <input id="ticket_no" type="hidden" name="ticket_no" value="<?php echo $ticket_no ?>" />

                            <div class="input-group col-sm-12">
                                <?php echo $ticket_no ?>
                                <input type="hidden" name="emp_id" id="emp_id" value="<?= $emp_id ?>">
                            </div>

                        </div>
                        <input class="  form-control" name="certificate_type" id="certificate_type"
                            placeholder="Certificate Type" type='hidden' value="<?= $certificate_type?>">
                        <!-- <select class="  form-control" name="certificate_type" id="certificate_type"
                            placeholder="Certificate Type" value="" hidden required>
                            <option value="" selected disabled>PLEASE SELECT CERTIFICATION TYPE </option>
                            <option value="rest" <?php if ($certificate_type =="rest") {
													echo "selected";
												} ?>>REST CERTIFICATE</option>
                            <option value="duty" <?php if ($certificate_type =="duty") {
													echo "selected";
												} ?>>DUTY CERTIFICATE</option>
                            <option value="fitness" <?php if ($certificate_type=="fitness") {
													echo "selected";
												} ?>>FITNESS CERTIFICATE</option>
                            <option value="experience" <?php if ($certificate_type == "experience") {
													echo "selected";
												} ?>>EXPERIENCE CERTIFICATION</option>
                        </select> -->


                        <!-- <div class="col-sm-3">
							<label class="control-label" for="appointment_date"><strong
								style="font-size: 11px">Token No</strong></label>

							<div class="input-group">
								<input id="token_no" name="token_no" type="text"
									value="<?php echo $row['token_no'] ?>" />
									
							</div>

						</div> -->



                        <div class="col-sm-3">
                            <label for="role">Appointment Date</label>
                            <div class="input-group col-sm-12">
                                <input class="form-control" name="sickness_date" id="sickness_date" type="datetime-local" value="<?= $row['sickness_date']?>" /> 
                                <!-- <span
                                    class="input-group-addon"> <i class="fa fa-calendar bigger-110"></i>
                                </span> -->
                            </div>
                        </div>

                        <div class="col-sm-3">
                            <label for="role">Approval Date</label>
                            <div class="input-group col-sm-12">
                                <input class="form-control" name="approval_date" id="approval_date" type="date" value="<?= $row['approval_date'] ?>" /> 
                                <!-- <span
                                    class="input-group-addon"> <i class="fa fa-calendar bigger-110"></i>
                                </span> -->
                            </div>
                        </div>


                        <div class="col-sm-3">
                            <label class="control-label" for="followup_to_opd"><strong style="font-size: 11px">Follow up
                                    to(if Applicable)</strong></label>

                            <div class="input-group col-sm-12">
                                <?php if ($rolecode != 'DOC' && $row['doctor_attended_flag'] == 'Y') { ?>

                                <?php echo ($row['followup_to_opd'] == '0') ? "None" : $row['followup_to_opd'] ?>
                                <input type="hidden" id="followup_to_opd" name="followup_to_opd"
                                    value="<?php echo $row['followup_to_opd'] ?>" />
                                <?php  } else { ?>
                                <select class="form-control col-sm-12" id="followup_to_opd" name="followup_to_opd">
                                    <option value="">None</option>
                                    <?php

										$sql = "select CONCAT(ticket_no,' ',DATE_FORMAT(appointment_date,'%d-%b-%Y %l:%i %p ')) as nameCol,appointment_id from employee_appointment where  emp_id ='$flex_opd_id' order by appointment_date";

										error_log("odddddd" . $sql);

										$resultSet = mysqli_query($conn, $sql);

										while ($row1 = mysqli_fetch_array($resultSet)) {



											echo "<option value='" . $row1['appointment_id'] . "' selected=selected>" . $row1['nameCol'] . "</option>";
										} ?>

                                </select>

                            </div>
                            <?php } ?>

                        </div>




                    </div>
                    <div class="space-6"></div>
                    <div class="row">
                        <div class="form-group col-sm-3 ">
                            <label for="role">Treatment Start Date</label>


                            <div class="input-group col-sm-12">
                                <input class="form-control" name="from_date" id="from_date" type="date" value="<?= $row['from_date']?>" />
                                <!-- <span class="input-group-addon">
                                    <i class="fa fa-calendar bigger-110"></i>
                                </span> -->
                            </div>
                        </div>


                        <div class="form-group col-sm-3">
                            <label for="role">Treatment End Date </label>
                            <div class="input-group col-sm-12">
                                <input class="form-control" name="to_date" id="to_date" type="date" value="<?=$row['to_date']?>" /> 
                                <!-- <span
                                    class="input-group-addon"> <i class="fa fa-calendar bigger-110"></i>
                                </span> -->
                            </div>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="role">Unfit From Date</label> <input type="hidden" class="form-control"
                                name="sickness_id" id="sickness_id" value="<?php echo $row['sickness_id'] ?>"
                                required />

                            <div class="input-group col-sm-12">
                                <input class="form-control" name="date_absent" id="date_absent" type="date" value="<?=$row['date_absent']?>" /> 
                                <!-- <span class="input-group-addon">
                                    <i class="fa fa-calendar bigger-110"></i>
                                </span> -->
                            </div>
                        </div>

                        <div class="form-group col-sm-3">
                            <label for="role">Unfit to Date</label>

                            <div class="input-group col-sm-12">
                                <input class="form-control" name="date_absent_to" id="date_absent_to" type="date" value="<?=$row['date_absent_to']?>" />
                                <!-- <span class="input-group-addon">
                                    <i class="fa fa-calendar bigger-110"></i>
                                </span> -->
                            </div>
                        </div>

                    </div>

                    <div class="space-6"></div>
                    <!-- <div class="row">
						<div class="form-group col-sm-3 ">
							<label for="role">Justifiable From Date</label>


							<div class="input-group">
								<input class="form-control" name="justifiable_from" id="justifiable_from" type="text" /> <span class="input-group-addon">
									<i class="fa fa-calendar bigger-110"></i>
								</span>
							</div>
						</div>


						<div class="form-group col-sm-3">
							<label for="role">Justifiable To Date </label>
							<div class="input-group">
								<input class="form-control" name="justifiable_to" id="justifiable_to" type="text" /> <span class="input-group-addon">
									<i class="fa fa-calendar bigger-110"></i>
								</span>
							</div>
						</div>
						<div class="form-group col-sm-3">
							<label for="role">Not Justifiable From Date</label>

							<div class="input-group">
								<input class="form-control" name="date_not_just" id="date_not_just" type="text" /> <span class="input-group-addon">
									<i class="fa fa-calendar bigger-110"></i>
								</span>
							</div>
						</div>
						<div class="form-group col-sm-3">
							<label for="sickness">Not Justifiable To Date</label>

							<div class="input-group">
								<input class="form-control" name="date_not_just_to" id="date_not_just_to" type="text" /> <span class="input-group-addon">
									<i class="fa fa-calendar bigger-110"></i>
								</span>
							</div>
						</div>
					</div> -->

                    <div class="space-6"></div>

                    <div class="row">

                        <div class="form-group col-sm-3">
                            <label for="sickness">Date of Rejoining</label>

                            <div class="input-group col-sm-12">
                                <input class="form-control" name="date_return" id="date_return" type="date"  value="<?php echo $row['date_return'] ?>"/> 
                                <!-- <span
                                    class="input-group-addon">
                                    <i class="fa fa-calendar bigger-110"></i>
                                </span> -->
                            </div>
                        </div>

                        <div class="form-group col-sm-3">

                            <label for="sickness">You Told the Dispensary About The Sickness</label>

                            <input type="text" class="form-control" name="des_dis" id="des_dis" placeholder=""
                                value="YES" required />


                        </div>

                        <div class="form-group col-sm-3">

                            <label for="sickness">Do You Think You Got Sick Because of Work</label>

                            <select class="form-control" name="des_sick" id="des_sick" placeholder="" value=""
                                required />

                            <!-- <option value="" disabled selected>SELECT</option> -->

                            <option value="YES" <?php if (strcmp($des_sick, 'YES') == 0) {
													echo "selected";
												} ?>>YES</option>
                            <option value="NO" <?php if (strcmp($des_sick, 'NO') == 0) {
													echo "selected";
												} ?>>NO</option>

                            </select>


                        </div>

                        <div class="form-group col-sm-3">

                            <label for="sickness">What Can Be Done To Prevent It In Future</label>

                            <input type="text" class="form-control" name="des_future" id="des_future" placeholder=""
                                value="<?php echo $row['des_future'] ?>" required />


                        </div>


                    </div>


                    <div class="space-6"></div>


                    <div class="row">

                    <div class="col-sm-3">
                        <div class="form-group">
                            <label class="control-label" for="ailment"><strong
                                    style="font-size:11px">Diagnosis</strong></label>


                            <div class="input-group">
                                <!-- <input name="ailment[]" type="hidden" data-placeholder="Ailments"
                                    value="<?php //echo $existingAilmentList; ?>"> -->
                                <input type="text" class="form-control" id="ailment_new" name="ailment_new"
                                    data-placeholder="Ailments">
                            </div>



                        </div>
                    </div>


                        <div class="form-group col-sm-3">
                            <label class="control-label" for="ailment_system"><strong style="font-size: 11px">Body
                                    System</strong></label> 
                                    <select class="chosen-select form-control"
                                id="ailment_system_new" name="ailment_system_new" data-placeholder="Ailment System">
                                <option value="">Select Body System</option>
                                <?php echo generateOptionForMultiple('ailment_system', 'ailment_sys_name', 'ailment_sys_id', $row['ailment_system'], ''); ?>
                            </select>
                        </div>




                        <div class="form-group col-sm-3">
                            <label for="sickness">Doctor reference no.</label>
                            <input class="form-control" name="doc_ref_no" value="<?php echo $row['doctor_reference_no'] ?>"
                                id="doc_ref_no" required />
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="sickness">Treatment Agency</label> <input type="text" class="form-control"
                                name="agency" id="agency" value="<?php echo $row['agency'] ?>"
                                placeholder="Enter Agency" required />
                        </div>

                    </div>

                    <!-- <div class="row">
                        <div class="form-group col-sm-3">
                            <label for="sickness">Weight (KG)</label> <input type="text" class="form-control"
                                name="weight" id="weight" placeholder="" value="<?php echo $weight ?>" required />
                        </div>

                        <div class="form-group col-sm-3">
                            <label for="sickness">B.P</label> <input type="text" class="form-control" name="bp" id="bp"
                                placeholder="" value="<?php echo $bp ?>" required />
                        </div>

                        <div class="form-group col-sm-3">
                            <label for="sickness">Pulse</label> <input type="text" class="form-control" name="pulse"
                                id="pulse" placeholder="" value="<?php echo $pulse ?>" required />
                        </div>


                        <div class="form-group col-sm-3">
                            <label for="sickness">Chest : Un-Expanded (CM)</label> <input type="text"
                                class="form-control" name="ch_uex" id="ch_uex" placeholder=""
                                value="<?php echo $chest_uex ?>" required />
                        </div>


                    </div>


                    <div class="row">

                        <div class="form-group col-sm-3">
                            <label for="sickness">Chest : Expanded (CM)</label> <input type="text" class="form-control"
                                name="ch_ex" id="ch_ex" placeholder="" value="<?php echo $chest_ex ?>" required />
                        </div>


                        <div class="form-group col-sm-3">
                            <label>Blood Group</label>

                            <select class="form-control" name="blood_group" id="blood_group">
                                <option disabled selected>Please
                                    select option</option>
                                <?php echo generateOption('blood_group', 'type', 'type', $blood, ''); ?>
                            </select>
                        </div>



                        <div class="form-group col-sm-3">
                            <label for="sickness">Nose</label> <input type="text" class="form-control" name="nose"
                                id="nose" placeholder="" value="<?php echo $nose ?>" required />
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="sickness">Throat</label> <input type="text" class="form-control" name="throat"
                                id="throat" placeholder="" value="<?php echo $throat ?>" required />
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="sickness">R.S</label> <input type="text" class="form-control" name="rs" id="rs"
                                placeholder="" value="<?php echo $rs ?>" required />
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="sickness">C.V.S</label> <input type="text" class="form-control" name="cvs"
                                id="cvs" placeholder="" value="<?php echo $cvs ?>" required />
                        </div>

                        <div class="form-group col-sm-3">
                            <label for="sickness">C.N.S</label> <input type="text" class="form-control" name="cns"
                                id="cns" placeholder="" value="<?php echo $cns ?>" required />
                        </div>
                    

                        <div class="form-group col-sm-3">
                            <label for="sickness">Height (CM)</label> <input type="text" class="form-control"
                                name="height" id="height" placeholder="" value="<?php echo $height ?>" required />
                        </div>
                    </div> -->

                    <div class="row">

                        <div class="form-group col-sm-3">
                            <label for="sickness">Health Status</label>
                            <select class="form-control" name="des" id="des" placeholder="" required >


                            <option value="NORMAL" <?php if (strcmp($des, 'NORMAL') == 0) {
														echo "selected";
													} ?>>Normal</option>
                            <option value="WEAK" <?php if (strcmp($des, 'WEAK') == 0) {
														echo "selected";
													} ?>>Weak</option>
                            <option value="SICK" <?php if (strcmp($des, 'SICK') == 0) {
														echo "selected";
													} ?>>Sick</option>

                            </select>
                        </div>

                        <div class="form-group col-sm-3">
                            <label for="sickness">Approval Status</label>
                            <select class="form-control" name="approval_status" id="approval_status">
                                <option value="APPROVED"
                                    <?php if ($row['fitness_status'] == 'APPROVED') { ?>selected<?php  } ?>>Approved fit
                                </option>
                                <option value="REVIEW"
                                    <?php if ($row['fitness_status'] == 'REVIEW') { ?>selected<?php  } ?>>Temporary
                                    unfit-review later</option>
                                <option value="REJECTED"
                                    <?php if ($row['fitness_status'] == 'REJECTED') { ?>selected<?php  } ?>>Unfit
                                </option>
                                <option value="ROLE CHANGE SUGGESTED"
                                    <?php if ($row['fitness_status'] == 'ROLE CHANGE SUGGESTED') { ?>selected<?php  } ?>>
                                    Role Change Suggested </option>

                                <option value="RETURN BACK TO WORK" <?php if ($row['fitness_status'] == 'RETURN BACK TO WORK') { ?>selected<?php } ?>>Return Back To Work</option>
                            </select>
                        </div>

                        <div class="form-group col-sm-3">
                            <label for="sickness">Approval Remarks</label> <textarea class="form-control" name="remarks"
                                id="remarks" placeholder="Approval Remarks" required
                                maxlength="500"><?php echo $row['comments'] ?></textarea>
                        </div>

                        <div class="form-group col-sm-3">
                            <label for="sickness">Purpose of issue Certificate</label> <textarea class="form-control"
                                name="purpose" id="purpose" placeholder="Purpose of issue Certificate" required
                                maxlength="500"><?php echo $row['purpose'] ?></textarea>
                        </div>

                    </div>

                </div>
            </div>
        </div>
    </div>

</fo>
<form id="pdfform" target="_blank">
    <input type="hidden" id="flex_sickness_id" value="<?php echo $row['sickness_id'] ?>" name="flex_sickness_id">
</form>

<script>
//$('#ailmentD').trigger('chosen:updated');
$('#ailment_system_new').trigger('chosen:updated');
$('#ailment_name').trigger('chosen:updated');
$(".select2").select();

jQuery(function($) {
    <?php if ($_SESSION['RoleCode'] == "DOC") {    ?>
    $("#forwardButton").on("click", function() {

        $("#attendedStatus").val($("#forward_status").val());
        validation($("#forward_status").val());

    });
    <?php  } else { ?>
    // validation()
    <?php  } ?>

    if (!ace.vars['old_ie'])
        // $('#sickness_date').datetimepicker({
        //      //use this option to display seconds
        //     format: 'DD/MM/YYYY h:mm:A', //use this option to display seconds

        //     <?php if (isset($row['sickness_date']) && $row['sickness_date'] != '0000-00-00 00:00:00') { ?>
        //         defaultDate: new Date("<?php echo $row['sickness_date'] ?>"),
        //     <?php } else { ?>
        //         defaultDate: new Date(),
        //     <?php } ?>

        //     // maxDate: new Date(),
        //     icons: {
        //         time: 'fa fa-clock-o',
        //         date: 'fa fa-calendar',
        //         up: 'fa fa-chevron-up',
        //         down: 'fa fa-chevron-down',
        //         previous: 'fa fa-chevron-left',
        //         next: 'fa fa-chevron-right',
        //         today: 'fa fa-arrows ',
        //         clear: 'fa fa-trash',
        //         close: 'fa fa-times'
        //     }
        // }).next().on(ace.click_event, function() {
        //     $(this).prev().focus();
        // });
    // $('#from_date').datepicker({
    //     format: 'dd/mm/yyyy', //use this option to display seconds
    //     //'setDate': new Date(),
    //     endDate: "+1d",
    //     //minDate:  new Date()-10,
    //     icons: {
    //         time: 'fa fa-clock-o',
    //         date: 'fa fa-calendar',
    //         up: 'fa fa-chevron-up',
    //         down: 'fa fa-chevron-down',
    //         previous: 'fa fa-chevron-left',
    //         next: 'fa fa-chevron-right',
    //         today: 'fa fa-arrows ',
    //         clear: 'fa fa-trash',
    //         close: 'fa fa-times'
    //     }
    // }).datepicker("setDate", new Date("<?php echo $row['from_date'] ?>"));

    // $('#to_date').datepicker({
    //     format: 'dd/mm/yyyy', //use this option to display seconds
    //     defaultDate: new Date("<?php echo $row['to_date'] ?>"),
    //     endDate: "+1d",
    //     //minDate:  new Date()-10,
    //     icons: {
    //         time: 'fa fa-clock-o',
    //         date: 'fa fa-calendar',
    //         up: 'fa fa-chevron-up',
    //         down: 'fa fa-chevron-down',
    //         previous: 'fa fa-chevron-left',
    //         next: 'fa fa-chevron-right',
    //         today: 'fa fa-arrows ',
    //         clear: 'fa fa-trash',
    //         close: 'fa fa-times'
    //     }
    // }).datepicker("setDate", new Date("<?php echo $row['to_date'] ?>"));

    // $('#date_absent').datepicker({
    //     format: 'dd/mm/yyyy',
    //     endDate: "+1d"

    // }).datepicker("setDate", new Date("<?php echo $row['date_absent'] ?>"));

    // $('#date_absent_to').datepicker({
    //     format: 'dd/mm/yyyy',
    //     endDate: "+1d"

    // }).datepicker("setDate", new Date("<?php echo $row['date_absent_to'] ?>"));

    // $('#date_return').datepicker({
    //     format: 'dd/mm/yyyy', //use this option to display seconds
    //     defaultDate: new Date("<?php echo $row['date_return'] ?>"),
    //     endDate: "+1d",
    //     //minDate:  new Date()-10,
    //     icons: {
    //         time: 'fa fa-clock-o',
    //         date: 'fa fa-calendar',
    //         up: 'fa fa-chevron-up',
    //         down: 'fa fa-chevron-down',
    //         previous: 'fa fa-chevron-left',
    //         next: 'fa fa-chevron-right',
    //         today: 'fa fa-arrows ',
    //         clear: 'fa fa-trash',
    //         close: 'fa fa-times'
    //     }
    // }).datepicker("setDate", new Date("<?php echo $row['date_return'] ?>"));

    $('#justifiable_from').datepicker({
        format: 'dd/mm/yyyy',
        endDate: "+1d"

    }).datepicker("setDate", new Date("<?php echo $row['justifiable_from'] ?>"));

    $('#justifiable_to').datepicker({
        format: 'dd/mm/yyyy', //use this option to display seconds
        defaultDate: new Date("<?php echo $row['justifiable_to'] ?>"),
        endDate: "+1d",
        //minDate:  new Date()-10,
        icons: {
            time: 'fa fa-clock-o',
            date: 'fa fa-calendar',
            up: 'fa fa-chevron-up',
            down: 'fa fa-chevron-down',
            previous: 'fa fa-chevron-left',
            next: 'fa fa-chevron-right',
            today: 'fa fa-arrows ',
            clear: 'fa fa-trash',
            close: 'fa fa-times'
        }
    }).datepicker("setDate", new Date("<?php echo $row['justifiable_to'] ?>"));

    $('#date_not_just').datepicker({
        format: 'dd/mm/yyyy', //use this option to display seconds
        defaultDate: new Date("<?php echo $row['not_justifiable_from'] ?>"),
        endDate: "+1d",
        //minDate:  new Date()-10,
        icons: {
            time: 'fa fa-clock-o',
            date: 'fa fa-calendar',
            up: 'fa fa-chevron-up',
            down: 'fa fa-chevron-down',
            previous: 'fa fa-chevron-left',
            next: 'fa fa-chevron-right',
            today: 'fa fa-arrows ',
            clear: 'fa fa-trash',
            close: 'fa fa-times'
        }

    }).datepicker("setDate", new Date("<?php echo $row['not_justifiable_from'] ?>"));

    $('#date_not_just_to').datepicker({
        format: 'dd/mm/yyyy', //use this option to display seconds
        defaultDate: new Date("<?php echo $row['not_justifiable_to'] ?>"),
        endDate: "+1d",
        //minDate:  new Date()-10,
        icons: {
            time: 'fa fa-clock-o',
            date: 'fa fa-calendar',
            up: 'fa fa-chevron-up',
            down: 'fa fa-chevron-down',
            previous: 'fa fa-chevron-left',
            next: 'fa fa-chevron-right',
            today: 'fa fa-arrows ',
            clear: 'fa fa-trash',
            close: 'fa fa-times'
        }

    }).datepicker("setDate", new Date("<?php echo $row['not_justifiable_to'] ?>"));


    // $('#approval_date').datepicker({
    //     format: 'dd/mm/yyyy', //use this option to display seconds
    //     defaultDate: new Date("<?php echo $row['approval_date'] ?>"),
    //     endDate: "+1d",
    //     //minDate:  new Date()-10,
    //     icons: {
    //         time: 'fa fa-clock-o',
    //         date: 'fa fa-calendar',
    //         up: 'fa fa-chevron-up',
    //         down: 'fa fa-chevron-down',
    //         previous: 'fa fa-chevron-left',
    //         next: 'fa fa-chevron-right',
    //         today: 'fa fa-arrows ',
    //         clear: 'fa fa-trash',
    //         close: 'fa fa-times'
    //     }

    // }).datepicker("setDate", new Date("<?php echo $row['approval_date'] ?>"));

});


$('#ailment_new').trigger('chosen:updated');


if ($('#ailment_new')) {
    var ailments = new Array();
    getAilments();

    function getAilments() {
        $.ajax({
            url: 'select_ailments.php',
            type: "GET",
            success: function(data) {
                ailments = $.parseJSON(data);

            },
            error: function(data) {
                BootstrapDialog.alert('Error pulling Ailments');
                return;
            }
        });
    }
}
$(document).ready(function() {


    if ($('#ailment_new')) {
        setTimeout(function() {
            var tag_input_ailments = $('#ailment_new');
            try {
                tag_input_ailments.tag({
                    placeholder: tag_input_ailments.attr('placeholder'),

                    source: ailments

                })

                //programmatically add/remove a tag
                var $tag_obj = $('#ailment_new').data('tag');
                //$tag_obj.add('Programmatically Added');
                var existingAilments = "<?php echo $existingAilmentList ?>"
                var existingAilments =
                    "<?php echo getCommaSeperatedValuesForInClause('select ailment_name from ailment', 'ailment_id', $existingAilmentList) ?>"
                if (existingAilments != undefined && existingAilments != null && existingAilments !=
                    '') {
                    var existingAilmentsArr = existingAilments.split(",");
                    jQuery.each(existingAilmentsArr, function(i, val) {
                        $tag_obj.add(val.toUpperCase());
                    });
                }
                //var index = $tag_obj.inValues('some tag');
                //	$tag_obj.remove(index);
            } catch (e) {
                //display a textarea for old IE, because it doesn't support this plugin or another one I tried!
                tag_input_ailments.after('<textarea id="' + tag_input_ailments.attr('id') + '" name="' +
                    tag_input_ailments.attr('name') + '" rows="3">' + tag_input_ailments.val() +
                    '</textarea>').remove();
                //autosize($('#form-field-tags'));
            }
            var x = $("#from_date").width();
            $('.tags > input').css('width', (x + 15));
        }, 500);
    } //end Ailments*/

});

function validation() {
    /* var date_absent = $('#approval_date').val();
    if (date_absent == '' || date_absent == null) {
        BootstrapDialog.alert('Please Enter Approval Date .!!!');
        return false;
    }
    var date_return = $('#date_return').val();
    	if(date_return == ''){
    		BootstrapDialog.alert('Please Enter Date Return .!!!');
    		return false;
    	}
        */

    	var name = $('#ailment').val();
    	if(name == ''){
    		BootstrapDialog.alert('Please Enter Ailment Name  .!!!');
    		return false;
    	}

    save();
}
$('#ailmentD').trigger("chosen:updated");

function exporttopdf() {


    document.forms['pdfform'].action = "fitness_certificate.php";
    document.forms['pdfform'].method = "post";
    document.forms['pdfform'].submit();
}
</script>
<?php include('common_ace.php'); ?>
<?php include('support_sickness_document.php') ?>
<?php include('image_popup_sickness.php') ?>