<style type="text/css">
    ::-webkit-scrollbar {
        display: none;
    }
    #dynamic-content-container{background: #fff;}
    .navbar-default.navbar-static-side{display: none !important;}
    #page-wrapper{margin: 0px !important; padding: 0 !important;}
    .row.border-bottom{display: none !important;}
    .footer.fixed{display: none;}
    .ibox-content{padding: 0 !important;}
    #page-wrapper{width: 100%; background: #fff;}
    body {
    -webkit-print-color-adjust:exact;
    background: #fff;
    }
    th{border: 2px solid; border-color: black !important; color: black !important;}
    table{border: 2px solid; border-color: black !important; color: black !important;}
    tr{border: 2px solid; border-color: black !important; color: black !important;}
    td{border: 2px solid; border-color: black !important; color: black !important;}
</style>
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-8">
        <h2><?= print_lang($app_lang,'mod_em_attendence_rep_title'); ?></h2>
        <ol class="breadcrumb">
            <li class="breadcrumb-item">
                <a class="url-elem" href="<?php echo url('/dashboard'); ?>"><?= print_lang($app_lang,'home'); ?></a>
            </li>
            <li class="breadcrumb-item active">
                <strong><?= print_lang($app_lang,'mod_em_attendence_rep_view_breadcrumb_title'); ?></strong>
            </li>
        </ol>
    </div>
    <div class="col-lg-4">
        <div class="title-action">
        </div>
    </div>
</div>


<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">

                    <h2 class="text-center font-bold" style="margin: 10px 0 20px;"><?= print_lang($app_lang,'mod_em_attendence_rep_title'); ?></h2>
                    <hr>

                    <form id="employee-attendence-report-filter-form" action="<?= url('/attendence-report'); ?>">
                        <div class="row">
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label><?= print_lang($app_lang,'mod_em_attendence_rep_filter_employee'); ?> <strong class="text-danger">*</strong></label>
                                    <select class="form-control chosen-select" name="employee">
                                        <option value="">-- <?= print_lang($app_lang,'mod_em_attendence_rep_filter_employee'); ?> --</option>
                                        <?php foreach($employees as $employee){?>
                                            <option <?php if($employee_id == $employee['uid']){echo "selected='selected'";}?> value="<?= $employee['uid']; ?>"><?= $employee['name']; ?></option>
                                        <?php } ?>
                                    </select>
                                </div>
                            </div>

                            <div class="col-md-3">
                                <div class="form-group">
                                    <label><?= print_lang($app_lang,'mod_em_attendence_rep_filter_date'); ?> <strong class="text-danger">*</strong></label>
                                    <input type="date" class="form-control" name="search_date" value="<?= $search_date; ?>">
                                </div>
                            </div>

                            <div class="col-md-2" style="margin-top: 27px;">
                                <button class="btn btn-w-m btn-info" type="submit"><?= print_lang($app_lang,'mod_em_attendence_rep_filter_search'); ?></button>
                            </div>
                        </div>
                    </form>
                    <table style="width: 100%; border: 1px solid black; margin-top: 3px;" cellpadding="3">
                        <tr class="text-center">
                            <td>
                                <span style="font-weight: 900; font-size: 14px; color: black;">(<?= date("Y",strtotime($search_date)); ?>)&nbsp;&nbsp;&nbsp; (<?= date("m",strtotime($search_date)); ?>)</span>
                            </td>
                            
                        </tr>
                    </table>
                    <table style="width: 100%; border: 1px solid black; margin-top: 3px;" cellpadding="3">
                        <thead>
                            <tr class="text-center">
                                <th class="text-center"><?= print_lang($app_lang,'mod_em_attendence_rep_thead_sr_num'); ?></th>
                                <th class="text-center"><?= print_lang($app_lang,'mod_em_attendence_rep_thead_name'); ?></th>
                                <th class="text-center"><?= print_lang($app_lang,'mod_em_attendence_rep_thead_f_name'); ?></th>
                                <?php for($i=1; $i <= $month_days; $i++){?>
                                    <th style="width: 20px; max-width: 20px; min-width: 20px; text-align: center;"><?php echo $i; ?></th>
                                <?php } ?>
                                <th class="text-center" style="width: 70px; max-width: 70px;"><?= print_lang($app_lang,'mod_em_attendence_rep_thead_t_presents'); ?></th>
                                <th class="text-center" style="width: 70px; max-width: 70px;"><?= print_lang($app_lang,'mod_em_attendence_rep_thead_t_absents'); ?></th>
                                <th class="text-center" style="width: 60px; max-width: 60px;"><?= print_lang($app_lang,'mod_em_attendence_rep_thead_t_sick'); ?></th>
                                <th class="text-center" style="width: 60px; max-width: 60px;"><?= print_lang($app_lang,'mod_em_attendence_rep_thead_t_leave'); ?></th>
                                <th class="text-center" style="width: 70px; max-width: 70px;"><?= print_lang($app_lang,'mod_em_attendence_rep_thead_t_holidays'); ?></th>
                                <th class="text-center"><?= print_lang($app_lang,'mod_em_attendence_rep_thead_remarks'); ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                                $sr = 1;
                                foreach($pageData['employees'] as $row){
                            ?>
                            <tr class="text-center">
                                <td><?php echo $sr++; ?></td>
                                <td><?php echo $row['info']['name'];?></td>
                                <td><?php echo $row['info']['father_name'];?></td>
                                <?php foreach($row['month_days'] as $month_data){
                                    if($month_data['status'] == 'present')
                                    {
                                        $td_backgroud = 'green';
                                        $td_value = '<i title="Present" style="color: #fff;" class="fa fa-check"></i>';
                                    }
                                    elseif($month_data['status'] == 'absent')
                                    {
                                        $td_backgroud = 'orange';
                                        $td_value = '<i title="Absent" style="color: #fff;" class="fa fa-times"></i>';
                                    }
                                    elseif($month_data['status'] == 'sick')
                                    {
                                        $td_backgroud = 'blue';
                                        $td_value = '<i title="Sick" style="color: #fff;" class="fa fa-minus"></i>';
                                    }
                                    elseif($month_data['status'] == 'leave')
                                    {
                                        $td_backgroud = 'purple';
                                        $td_value = '<i title="Leave" style="color: #fff;" class="fa fa-minus"></i>';
                                    }
                                    elseif($month_data['status'] == 'holiday')
                                    {
                                        $td_backgroud = 'red';
                                        $td_value = '<span title="Holiday" style="color: #fff; font-weight: 900;">H</span>';
                                    }
                                    else
                                    {
                                        $td_backgroud = '';
                                        $td_value = '';
                                    }
                                ?>
                                    <td style="background: <?= $td_backgroud; ?>">
                                        <?= $td_value; ?>
                                    </td>
                                <?php } ?>
                                <td><?php echo $row['totals']['presents']; ?></td>
                                <td><?php echo $row['totals']['absent']; ?></td>
                                <td><?php echo $row['totals']['sick']; ?></td>
                                <td><?php echo $row['totals']['leave']; ?></td>
                                <td><?php echo $row['totals']['holiday']; ?></td>
                                <td></td>
                            </tr>
                        <?php } ?>
                        </tbody>
                    </table>  

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