<?php $timezone = $this->db->select('timezone')->from('setting')->get()->row();
date_default_timezone_set($timezone->timezone);

$this->session->set_userdata('attendance_time', date("Y-m-d H:i:s"));


?>

<div class="row">
    <div class="col-sm-12 col-md-12">
        <div class="panel panel-bd">
            <div class="panel-heading panel-aligner">
                <div class="panel-title">
                    <h4><?php echo "Edit Attendance of " .  $record[0]->first_name . ' ' . $record[0]->last_name;  ?></h4>
                </div>

            </div>
            <div class="panel-body">

                <?php if (empty($editdata)) { ?>

                    <div class="row attendance">
                        <ul class="nav nav-tabs">
                            <li class="active"><a data-toggle="tab"
                                                  href="#checkin"><?php echo display('check_in') ?></a></li>
                            <li><a data-toggle="tab" href="#checkout"><?php echo display('check_out') ?></a></li>
                        </ul>
                    </div>

                <?php } else { ?>

                    <div class="row attendance">
                        <ul class="nav nav-tabs">
                            <li class="<?php if ($editdata->status == "in") {
                                echo "active";
                            } ?>"><a><?php echo display('check_in') ?></a></li>
                            <li class="<?php if ($editdata->status == "out") {
                                echo "active";
                            } ?>"><a><?php echo display('check_out') ?></a></li>
                        </ul>
                    </div>


                <?php } ?>

                <div class="tab-content">

                    <div id="checkin" class="tab-pane fade in active">

                        <?php echo form_open('employeeattendance/Attendance/check_in_update') ?>
                        <div class="form-group row">
                            <input type="hidden" name="att_id"
                                   value="<?php echo(!empty($record) ? $record[0]->att_id : '') ?>">
                            <label for="employee_id" class="col-sm-3 col-form-label"><?php echo display('emp_id') ?>
                                *</label>
                            <div class="col-sm-4">
                                <input type="text" name="employee_name" class="form-control"
                                       value="<?php echo $record[0]->first_name . ' ' . $record[0]->last_name; ?>"
                                       readonly>
                                <input type="hidden" name="employee_id" id="employee_id" class="form-control"
                                       value="<?php echo $record[0]->employee_id; ?>">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="check_in_date" class="col-sm-3 col-form-label"><?php echo "Punch Date" ?>
                                *</label>
                            <div class="col-sm-4">
                                <input type="text" name="check_in_date" id=""
                                       placeholder="<?php echo date("Y-m-d") ?>"
                                       class="form-control datepicker"
                                       value="<?php echo(!empty($record) ? $record[0]->check_in_date : '') ?>">

                            </div>

                        </div>

                        <div class="form-group row">
                            <label for="check_in_time" class="col-sm-3 col-form-label"><?php echo "Punch Time" ?>
                                *</label>
                            <div class="col-sm-4">
                                <input type="time" name="check_in_time" id=""
                                       placeholder="<?php echo date("h:ia") ?>"
                                       class="form-control"
                                       value="<?php echo(!empty($record) ? $record[0]->check_in_time : '') ?>">


                            </div>

                        </div>

                        <div class="form-group row">
                            <label for="employee_shift_time" class="col-sm-3 col-form-label"><?php echo "Shift Time" ?>
                                *</label>
                            <div class="col-sm-4">
                                <input type="time" name="employee_shift_time" id=""
                                       placeholder="<?php echo date("h:ia") ?>"
                                       class="form-control"
                                       value="<?php echo(!empty($record) ? $record[0]->employee_shift_time : '') ?>">


                            </div>

                        </div>

                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label"></label>
                            <div class="col-sm-4 text-right">

                                <?php
                                if (!empty($flag) && $flag[0]->flag == '1' && !$this->session->userdata['isAdmin']) { ?>
                                    <button disabled type="submit"
                                            class="btn btn-success w-md m-b-5"><?php echo display('check_in') ?></button>
                                <?php } else { ?>
                                    <button type="submit"
                                            class="btn btn-success w-md m-b-5"><?php echo display('check_in') ?></button>
                                <?php }
                                ?>


                            </div>

                        </div>
                        <?php echo form_close() ?>

                    </div>

                    <div id="checkout" class="tab-pane fade">

                        <?php echo form_open('employeeattendance/Attendance/check_out_update') ?>
                        <div class="form-group row">
                            <input type="hidden" name="att_id"
                                   value="<?php echo(!empty($record) ? $record[0]->att_id : '') ?>">
                            <label for="employee_id" class="col-sm-3 col-form-label"><?php echo display('emp_id') ?>
                                *</label>
                            <div class="col-sm-4">
                                <input type="text" name="employee_name" class="form-control"
                                       value="<?php echo $record[0]->first_name . ' ' . $record[0]->last_name; ?>"
                                       readonly>
                                <input type="hidden" name="employee_id" id="employee_id" class="form-control"
                                       value="<?php echo $record[0]->employee_id; ?>">

                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="check_out_date" class="col-sm-3 col-form-label"><?php echo "Punch Date" ?>
                                *</label>
                            <div class="col-sm-4">

                                <input type="text" name="check_out_date" id=""
                                       placeholder="<?php echo date("Y-m-d") ?>"
                                       class="form-control datepicker"
                                       value="<?php echo(!empty($record) ? $record[0]->check_out_date : '') ?>">

                            </div>

                        </div>

                        <div class="form-group row">
                            <label for="check_out_time" class="col-sm-3 col-form-label"><?php echo "Punch Time" ?>
                                *</label>
                            <div class="col-sm-4">

                                <input type="time" name="check_out_time" id=""
                                       placeholder="<?php echo date("H:i:s") ?>"
                                       class="form-control"
                                       value="<?php echo(!empty($record) ? $record[0]->check_out_time : '') ?>">


                            </div>

                        </div>

                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label"></label>
                            <div class="col-sm-4 text-right">

                                <?php
                                if ((empty($flag) || $flag[0]->flag == '0') && !$this->session->userdata['isAdmin']) { ?>
                                    <button disabled type="submit"
                                            class="btn btn-success w-md m-b-5"><?php echo display('check_out') ?></button>
                                <?php } else { ?>
                                    <button type="submit"
                                            class="btn btn-success w-md m-b-5"><?php echo display('check_out') ?></button>
                                <?php }
                                ?>

                            </div>

                        </div>
                        <?php echo form_close() ?>

                    </div>

                </div>

            </div>

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