<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-8">
        <h2><?= print_lang($app_lang,'attendence_title'); ?></h2>
        <ol class="breadcrumb">
            <li>
                <a class="url-elem" href="<?php echo url('/dashboard'); ?>"><?= print_lang($app_lang,'home'); ?></a>
            </li>
            <li class="active">
                <strong><?= print_lang($app_lang,'attendence_breadcrumb_title'); ?></strong>
            </li>
        </ol>
    </div>
    <div class="col-lg-4">
        <div class="title-action">

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


<input type="hidden" name="mod_em_daily_attendence_confirm_btn_text" value="<?= print_lang($app_lang,'mod_em_daily_attendence_confirm_btn_text'); ?>">
<input type="hidden" name="mod_em_daily_attendence_cancel_btn_text" value="<?= print_lang($app_lang,'mod_em_daily_attendence_cancel_btn_text'); ?>">
<input type="hidden" name="mod_em_daily_attendence_confirm_heading" value="<?= print_lang($app_lang,'mod_em_daily_attendence_confirm_heading'); ?>">
<input type="hidden" name="mod_em_daily_attendence_confirm_message" value="<?= print_lang($app_lang,'mod_em_daily_attendence_confirm_message'); ?>">
<input type="hidden" name="mod_em_daily_attendence_confirm_del_btn" value="<?= print_lang($app_lang,'mod_em_daily_attendence_confirm_del_btn'); ?>">
<input type="hidden" name="mod_em_daily_attendence_confirm_del_cancel" value="<?= print_lang($app_lang,'mod_em_daily_attendence_confirm_del_cancel'); ?>">
<input type="hidden" name="mod_em_daily_attendence_del_confirm_heading" value="<?= print_lang($app_lang,'mod_em_daily_attendence_del_confirm_heading'); ?>">
<input type="hidden" name="mod_em_daily_attendence_del_confirm_message" value="<?= print_lang($app_lang,'mod_em_daily_attendence_del_confirm_message'); ?>">


<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-sm-12 b-r">
                            <form role="form" id="attendence-search-form" action="<?= url('/attendence'); ?>">

                                <div class="row extra-mar-botm">
                                    <div class="col-md-3 custom-col">
                                        <div class="form-group">
                                            <label><?= print_lang($app_lang,'mod_em_daily_attendence_filter_date'); ?> <strong class="text-danger">*</strong></label>
                                            <input type="date" required="required" class="form-control" name="search_date" value="<?= $search_date; ?>">
                                        </div>
                                    </div>
                                    <div class="col-md-2 custom-col" style="margin-top: 28px;">
                                        <button class="btn btn-w-m btn-primary" type="submit"><?= print_lang($app_lang,'mod_em_daily_attendence_filter_search'); ?></button>
                                    </div>

                                    <div class="col-md-7 text-right custom-col" style="margin-top: 28px;">
                                        <button class="btn btn-w-m btn-info employees-all-attandence-btn-trigger" data-status="present" style="font-size: 12px !important;" type="button"><?= print_lang($app_lang,'mod_em_daily_attendence_btn_mark_present'); ?></button>
                                        <button class="btn btn-w-m btn-danger employees-all-attandence-btn-trigger" data-status="holiday" style="font-size: 12px !important;" type="button"><?= print_lang($app_lang,'mod_em_daily_attendence_btn_mark_holiday'); ?></button>
                                    </div>
                                    
                                </div>
                            </form>
                        </div>
                    </div>


                    <?php if($is_filter == 'yes'){?>
                        <table class="table-bordered" style="width: 70%; margin: 0 auto;">
                            <tr class="text-center">
                                <td style="width: 25%; background: #051F3E; border: 1px solid #051F3E; color: #fff;">Date</td>
                                <td style="width: 25%; background: #051F3E; border: 1px solid #051F3E; color: #fff;">Year</td>
                                <td style="width: 25%; background: #051F3E; border: 1px solid #051F3E; color: #fff;">Month</td>
                                <td style="width: 25%; background: #051F3E; border: 1px solid #051F3E; color: #fff;">Day</td>
                            </tr>
                            <tr class="text-center">
                                <td style="width: 25%;">
                                    <?= date("Y-m-d",strtotime($search_date));?>
                                </td>
                                <td style="width: 25%;">
                                    <?= date("Y",strtotime($search_date));?>
                                </td>
                                <td style="width: 25%;">
                                    <?= date("m",strtotime($search_date));?>
                                </td>
                                <td style="width: 25%;">
                                    <?= date("d",strtotime($search_date));?>
                                </td>
                            </tr>
                        </table>
                        <input type="hidden" name="selected_year" value="<?= $year; ?>">
                        <input type="hidden" name="selected_month" value="<?= $month; ?>">
                        <input type="hidden" name="selected_day" value="<?= $day; ?>">
                        <div class="row extra-mar-botm">
                            <div class="col-md-12 custom-col">
                                <table class="table table-bordered">
                                    <thead>
                                        <tr class="text-center">
                                            <th style="background: #051F3E; border: 1px solid #051F3E; color: #fff; text-align: center;"><?= print_lang($app_lang,'mod_em_daily_attendence_thead_sr_num'); ?></th>
                                            <th style="background: #051F3E; border: 1px solid #051F3E; color: #fff; text-align: center;"><?= print_lang($app_lang,'mod_em_daily_attendence_thead_name'); ?></th>
                                            <th style="background: #051F3E; border: 1px solid #051F3E; color: #fff; text-align: center;"><?= print_lang($app_lang,'mod_em_daily_attendence_thead_f_name'); ?></th>
                                            <th style="background: #051F3E; border: 1px solid #051F3E; color: #fff; text-align: center;"><?= print_lang($app_lang,'mod_em_daily_attendence_thead_present'); ?></th>
                                            <th style="background: #051F3E; border: 1px solid #051F3E; color: #fff; text-align: center;"><?= print_lang($app_lang,'mod_em_daily_attendence_thead_absent'); ?></th>
                                            <th style="background: #051F3E; border: 1px solid #051F3E; color: #fff; text-align: center;"><?= print_lang($app_lang,'mod_em_daily_attendence_thead_sick'); ?></th>
                                            <th style="background: #051F3E; border: 1px solid #051F3E; color: #fff; text-align: center;"><?= print_lang($app_lang,'mod_em_daily_attendence_thead_leave'); ?></th>
                                            <th style="background: #051F3E; border: 1px solid #051F3E; color: #fff; text-align: center;"><?= print_lang($app_lang,'mod_em_daily_attendence_thead_holiday'); ?></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php 
                                            $sr = 1;
                                            foreach($employees as $employee){
                                                $attendenc_status = '';
                                                if(array_key_exists($employee['uid'], $old_attendence))
                                                {
                                                    $attendenc_status = $old_attendence[$employee['uid']]['status'];
                                                }
                                            ?>

                                                <tr class="text-center employee-attendence-tr-row">
                                                    <td><?= $sr++; ?></td>
                                                    <td><?= $employee['name']; ?></td>
                                                    <td><?= $employee['father_name']; ?></td>
                                                    <td style="padding: 2px;">
                                                        <?php if($attendenc_status == 'present'){?>
                                                            <button style="width: 16px; height: 16px; margin-top: 8px;" class="btn btn-primary btn-circle btn-outline employee-attendence-trigger-btn active" data-employee="<?= $employee['uid']; ?>" data-value="present" type="button"><i style="position: relative; bottom: 9px; font-size: 9px;" class="fa fa-check"></i></button>
                                                        <?php }else{?>
                                                            <button style="width: 16px; height: 16px; margin-top: 8px;" class="btn btn-danger btn-circle btn-outline employee-attendence-trigger-btn" data-employee="<?= $employee['uid']; ?>" data-value="present" type="button"><i style="position: relative; bottom: 9px; font-size: 9px;" class="fa fa-times"></i></button>
                                                        <?php } ?>
                                                    </td>
                                                    <td style="padding: 2px;">
                                                        <?php if($attendenc_status == 'absent'){?>
                                                            <button style="width: 16px; height: 16px; margin-top: 8px;" class="btn btn-primary btn-circle btn-outline employee-attendence-trigger-btn active" data-employee="<?= $employee['uid']; ?>" data-value="absent" type="button"><i style="position: relative; bottom: 9px; font-size: 9px;" class="fa fa-check"></i></button>
                                                        <?php }else{?>
                                                            <button style="width: 16px; height: 16px; margin-top: 8px;" class="btn btn-danger btn-circle btn-outline employee-attendence-trigger-btn" data-employee="<?= $employee['uid']; ?>" data-value="absent" type="button"><i style="position: relative; bottom: 9px; font-size: 9px;" class="fa fa-times"></i></button>
                                                        <?php } ?>
                                                    </td>
                                                    <td style="padding: 2px;">
                                                        <?php if($attendenc_status == 'sick'){?>
                                                            <button style="width: 16px; height: 16px; margin-top: 8px;" class="btn btn-primary btn-circle btn-outline employee-attendence-trigger-btn active" data-employee="<?= $employee['uid']; ?>" data-value="sick" type="button"><i style="position: relative; bottom: 9px; font-size: 9px;" class="fa fa-check"></i></button>
                                                        <?php }else{?>
                                                            <button style="width: 16px; height: 16px; margin-top: 8px;" class="btn btn-danger btn-circle btn-outline employee-attendence-trigger-btn" data-employee="<?= $employee['uid']; ?>" data-value="sick" type="button"><i style="position: relative; bottom: 9px; font-size: 9px;" class="fa fa-times"></i></button>
                                                        <?php } ?>
                                                    </td>
                                                    <td style="padding: 2px;">
                                                        <?php if($attendenc_status == 'leave'){?>
                                                            <button style="width: 16px; height: 16px; margin-top: 8px;" class="btn btn-primary btn-circle btn-outline employee-attendence-trigger-btn active" data-employee="<?= $employee['uid']; ?>" data-value="leave" type="button"><i style="position: relative; bottom: 9px; font-size: 9px;" class="fa fa-check"></i></button>
                                                        <?php }else{?>
                                                            <button style="width: 16px; height: 16px; margin-top: 8px;" class="btn btn-danger btn-circle btn-outline employee-attendence-trigger-btn" data-employee="<?= $employee['uid']; ?>" data-value="leave" type="button"><i style="position: relative; bottom: 9px; font-size: 9px;" class="fa fa-times"></i></button>
                                                        <?php } ?>
                                                    </td>
                                                    <td style="padding: 2px;">
                                                        <?php if($attendenc_status == 'holiday'){?>
                                                            <button style="width: 16px; height: 16px; margin-top: 8px;" class="btn btn-primary btn-circle btn-outline employee-attendence-trigger-btn active" data-employee="<?= $employee['uid']; ?>" data-value="holiday" type="button"><i style="position: relative; bottom: 9px; font-size: 9px;" class="fa fa-check"></i></button>
                                                        <?php }else{?>
                                                            <button style="width: 16px; height: 16px; margin-top: 8px;" class="btn btn-danger btn-circle btn-outline employee-attendence-trigger-btn" data-employee="<?= $employee['uid']; ?>" data-value="holiday" type="button"><i style="position: relative; bottom: 9px; font-size: 9px;" class="fa fa-times"></i></button>
                                                        <?php } ?>
                                                    </td>
                                                </tr>

                                            <?php } ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    <?php } ?>


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


    
</div>