
<?php $__env->startSection('content'); ?>
<?php $__env->startSection('title'); ?>
    <?php echo app('translator')->getFromJson('dashboard.dashboard'); ?>
<?php $__env->stopSection(); ?>
<style>
    .dash_image {

        width: 60px;
    }
</style>

<?php if(count($attendanceData) > 3): ?>
    <style>
        tbody {
            display: block;
            height: 300px;
            overflow: auto;
        }

        thead,
        tbody tr {
            display: table;
            width: 100%;
            table-layout: fixed;
        }

        thead {
            width: calc(100% - 1em)
        }
    </style>
<?php endif; ?>

<?php if(count($leaveApplication) >= 1): ?>
    <style>
        .leaveApplication {
            overflow-x: hidden;
            height: 210px;
        }
    </style>
<?php endif; ?>

<?php if(count($notice) >= 1): ?>
    <style>
        .noticeBord {
            overflow-x: hidden;
            height: 210px;
        }
    </style>
<?php endif; ?>

<div class="container-fluid">
    <div class="row bg-title">
        <div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
            <ol class="breadcrumb">
                <li class="active breadcrumbColor"><a href="#"><i class="fa fa-home"></i> <?php echo app('translator')->getFromJson('dashboard.dashboard'); ?></a></li>
            </ol>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-3 col-sm-6 col-xs-12">
            <div class="white-box analytics-info">
                <h3 class="box-title"> <?php echo app('translator')->getFromJson('dashboard.total_employee'); ?> </h3>
                <ul class="list-inline two-part">
                    <li>
                        <img class="dash_image" src="<?php echo e(asset('admin_assets/img/employee.png')); ?>">
                    </li>
                    <li class="text-right"><i class="ti-arrow-up text-success"></i> <span
                            class="counter text-success"><?php echo e($totalEmployee); ?></span></li>
                </ul>
            </div>
        </div>

        <div class="col-lg-3 col-sm-6 col-xs-12">
            <div class="white-box analytics-info">
                <h3 class="box-title"><?php echo app('translator')->getFromJson('dashboard.total_department'); ?></h3>
                <ul class="list-inline two-part">
                    <li>
                        <img class="dash_image" src="<?php echo e(asset('admin_assets/img/department.png')); ?>">
                    </li>
                    <li class="text-right"><i class="ti-arrow-up text-purple"></i> <span
                            class="counter text-purple"><?php echo e($totalDepartment); ?></span></li>
                </ul>
            </div>
        </div>

        <div class="col-lg-3 col-sm-6 col-xs-12">
            <div class="white-box analytics-info">
                <h3 class="box-title"><?php echo app('translator')->getFromJson('dashboard.total_present'); ?></h3>
                <ul class="list-inline two-part">
                    <li>
                        <img class="dash_image" src="<?php echo e(asset('admin_assets/img/present.png')); ?>">
                    </li>
                    <li class="text-right"><i class="ti-arrow-up text-info"></i> <span
                            class="counter text-info"><?php echo e($totalAttendance); ?></span></li>
                </ul>
            </div>
        </div>

        <div class="col-lg-3 col-sm-6 col-xs-12">
            <div class="white-box analytics-info">
                <h3 class="box-title"><?php echo app('translator')->getFromJson('dashboard.total_absent'); ?></h3>
                <ul class="list-inline two-part">
                    <li>
                        <img class="dash_image" src="<?php echo e(asset('admin_assets/img/absent.png')); ?>">
                    </li>
                    <li class="text-right"><i class="ti-arrow-down text-danger"></i> <span
                            class="counter text-danger"><?php echo e($totalAbsent); ?></span></li>
                </ul>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12 col-lg-12 col-sm-12">
            <div class="panel">
                <div class="panel-heading"> <?php echo app('translator')->getFromJson('dashboard.today_attendance'); ?> </div>
                <div class="table-responsive">
                    <table class="table table-hover manage-u-table">
                        <thead>
                            <tr>
                                <th class="text-center">#</th>
                                <th><?php echo app('translator')->getFromJson('dashboard.photo'); ?></th>
                                <th><?php echo app('translator')->getFromJson('common.name'); ?></th>
                                <th><?php echo app('translator')->getFromJson('dashboard.in_time'); ?></th>
                                <th><?php echo app('translator')->getFromJson('dashboard.out_time'); ?></th>
                                <th><?php echo app('translator')->getFromJson('dashboard.late'); ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if(count($attendanceData) > 0): ?>
                                <?php echo e($dailyAttendanceSl = null); ?>

                                <?php $__currentLoopData = $attendanceData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dailyAttendance): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td class="text-center"><?php echo e(++$dailyAttendanceSl); ?></td>
                                        <td>
                                            <?php if($dailyAttendance->photo != '' && file_exists('uploads/employeePhoto/' . $dailyAttendance->photo)): ?>
                                                <img style=" width: 70px; " src="<?php echo asset('uploads/employeePhoto/' . $dailyAttendance->photo); ?>" alt="user-img"
                                                    class="img-circle">
                                            <?php else: ?>
                                                <img style=" width: 70px; " src="<?php echo asset('admin_assets/img/default.png'); ?>" alt="user-img"
                                                    class="img-circle">
                                            <?php endif; ?>
                                        </td>
                                        <td><?php echo e($dailyAttendance->fullName); ?>

                                            <br /><span
                                                class="text-muted"><?php echo e($dailyAttendance->department_name); ?></span>
                                        </td>
                                        <td><?php echo e($dailyAttendance->in_time); ?> </td>
                                        <td>
                                            <?php
                                            if ($dailyAttendance->out_time != '') {
                                                echo $dailyAttendance->out_time;
                                            } else {
                                                echo '--';
                                            }
                                            ?>
                                        </td>

                                        <td>
                                            <?php
                                            if (date('H:i', strtotime($dailyAttendance->totalLateTime)) != '00:00') {
                                                echo "<b style='color: red;'>" . date('H:i', strtotime($dailyAttendance->totalLateTime)) . '</b>';
                                            } else {
                                                echo "<b style='color: green'><i class='cr-icon glyphicon glyphicon-ok'></i></b>";
                                            }
                                            ?>

                                        </td>

                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php else: ?>
                                <tr>
                                    <td colspan="8"><?php echo app('translator')->getFromJson('common.no_data_available'); ?></td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div class="row">

        <?php if($ip_attendance_status == 1): ?>
            <!-- employe attendance  -->
            <?php 
                $logged_user = employeeInfo();
             ?>
            <div class="col-md-6">
                <div class="white-box">
                    <h3 class="box-title">Hey <?php echo $logged_user[0]->user_name; ?> please Check in/out your attendance</h3>
                    <hr>
                    <div class="noticeBord">
                        <?php if(session()->has('success')): ?>
                            <div class="alert alert-success alert-dismissable">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                <i
                                    class="cr-icon glyphicon glyphicon-ok"></i>&nbsp;<strong><?php echo e(session()->get('success')); ?></strong>
                            </div>
                        <?php endif; ?>
                        <?php if(session()->has('error')): ?>
                            <div class="alert alert-danger alert-dismissable">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                <strong><?php echo e(session()->get('error')); ?></strong>
                            </div>
                        <?php endif; ?>
                        <form action="<?php echo e(route('ip.attendance')); ?>" method="POST">
                            <?php echo e(csrf_field()); ?>

                            <p>Your IP is <?php echo e(\Request::ip()); ?></p>
                            <input type="hidden" name="employee_id" value="<?php echo e($logged_user[0]->user_name); ?>">

                            <input type="hidden" name="ip_check_status" value="<?php echo e($ip_check_status); ?>">
                            <input type="hidden" name="finger_id" value="<?php echo e($logged_user[0]->finger_id); ?>">
                            <?php if($count_user_login_today > 0): ?>
                                <button class="btn btn-danger">
                                    <i class="fa fa-clock-o"> </i>
                                    Check Out
                                </button>
                            <?php else: ?>
                                <button class="btn btn-primary">
                                    <i class="fa fa-clock-o"> </i>
                                    Check In
                                </button>
                            <?php endif; ?>

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

            <!-- end attendance  -->
        <?php endif; ?>



        <?php if(count($notice) > 0): ?>
            <div class="col-md-6">
                <div class="white-box">
                    <h3 class="box-title"><?php echo app('translator')->getFromJson('dashboard.notice_board'); ?></h3>
                    <hr>
                    <div class="noticeBord">
                        <?php $__currentLoopData = $notice; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php 
                                $noticeDate = strtotime($row->publish_date);
                             ?>
                            <div class="comment-center p-t-10">
                                <div class="comment-body">

                                    <div class="user-img"><i style="font-size: 31px"
                                            class="fa fa-flag-checkered text-info"></i></div>



                                    <div class="mail-contnet">
                                        <h5 class="text-danger"><?php echo e(substr($row->title, 0, 70)); ?>..</h5><span
                                            class="time">Published Date: <?php echo e(date(' d M Y ', $noticeDate)); ?></span>
                                        <br /><span class="mail-desc">
                                            <?php echo app('translator')->getFromJson('notice.published_by'); ?>: <?php echo e($row->createdBy->first_name); ?>

                                            <?php echo e($row->createdBy->last_name); ?><br>
                                            <?php echo app('translator')->getFromJson('notice.description'); ?>: <?php echo substr($row->description, 0, 80); ?>..
                                        </span>
                                        <a href="<?php echo e(url('notice/' . $row->notice_id)); ?>"
                                            class="btn m-r-5 btn-rounded btn-outline btn-info"><?php echo app('translator')->getFromJson('common.read_more'); ?></a>
                                    </div>
                                </div>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                </div>
            </div>
        <?php endif; ?>

        <?php if(count($upcoming_birtday) > 0): ?>
            <div class="col-md-6">
                <div class="white-box">
                    <h3 class="box-title"><?php echo app('translator')->getFromJson('dashboard.upcoming_birthday'); ?></h3>
                    <hr>
                    <div class="leaveApplication">
                        <?php $__currentLoopData = $upcoming_birtday; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $employee_birthdate): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="comment-center p-t-10">
                                <div class="comment-body">
                                    <?php if($employee_birthdate->photo != ''): ?>
                                        <div class="user-img"> <img src="<?php echo asset('uploads/employeePhoto/' . $employee_birthdate->photo); ?>" alt="user"
                                                class="img-circle"></div>
                                    <?php else: ?>
                                        <div class="user-img"> <img src="<?php echo asset('admin_assets/img/default.png'); ?>" alt="user"
                                                class="img-circle"></div>
                                    <?php endif; ?>
                                    <div class="mail-contnet">

                                        <?php 
                                            $date_of_birth = $employee_birthdate->date_of_birth;
                                            $separate_date = explode('-', $date_of_birth);
                                            
                                            $date_current_year = date('Y') . '-' . $separate_date[1] . '-' . $separate_date[2];
                                            
                                            $create_date = date_create($date_current_year);
                                         ?>

                                        <h5><?php echo e($employee_birthdate->first_name); ?> <?php echo e($employee_birthdate->last_name); ?>

                                        </h5><span
                                            class="time"><?php echo e(date_format(date_create($employee_birthdate->date_of_birth), 'D dS F Y')); ?></span>
                                        <br />

                                        <span class="mail-desc">
                                            <?php if($date_current_year == date('Y-m-d')): ?>
                                                <b>Today is
                                                    <?php if($employee_birthdate->gender == 'Male'): ?>
                                                        His
                                                    <?php else: ?>
                                                        Her
                                                    <?php endif; ?>
                                                    Birtday Wish
                                                    <?php if($employee_birthdate->gender == 'Male'): ?>
                                                        Him
                                                    <?php else: ?>
                                                        Her
                                                    <?php endif; ?>
                                                </b>
                                            <?php else: ?>
                                                Wish
                                                <?php if($employee_birthdate->gender == 'Male'): ?>
                                                    Him
                                                <?php else: ?>
                                                    Her
                                                <?php endif; ?>
                                                on <?php echo e(date_format($create_date, 'D dS F Y')); ?>

                                            <?php endif; ?>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                </div>
            </div>
        <?php endif; ?>

        <?php if(count($leaveApplication) > 0): ?>
            <div class="col-md-6">
                <div class="white-box">
                    <h3 class="box-title"><?php echo app('translator')->getFromJson('dashboard.recent_leave_application'); ?></h3>
                    <hr>
                    <div class="leaveApplication">
                        <?php $__currentLoopData = $leaveApplication; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $leaveApplication): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="comment-center p-t-10 <?php echo e($leaveApplication->leave_application_id); ?>">
                                <div class="comment-body">
                                    <?php if($leaveApplication->employee->photo != ''): ?>
                                        <div class="user-img"> <img src="<?php echo asset('uploads/employeePhoto/' . $leaveApplication->employee->photo); ?>" alt="user"
                                                class="img-circle"></div>
                                    <?php else: ?>
                                        <div class="user-img"> <img src="<?php echo asset('admin_assets/img/default.png'); ?>" alt="user"
                                                class="img-circle"></div>
                                    <?php endif; ?>
                                    <div class="mail-contnet">
                                        <?php 
                                            $d = strtotime($leaveApplication->created_at);
                                         ?>
                                        <h5><?php echo e($leaveApplication->employee->first_name); ?>

                                            <?php echo e($leaveApplication->employee->last_name); ?></h5><span
                                            class="time"><?php echo e(date(' d M Y h:i: a', $d)); ?></span> <span
                                            class="label label-rouded label-info">PENDING</span>
                                        <br /><span class="mail-desc" style="max-height: none">
                                            <?php echo app('translator')->getFromJson('leave.leave_type'); ?> :
                                            <?php echo e($leaveApplication->leaveType->leave_type_name); ?><br>
                                            <?php echo app('translator')->getFromJson('leave.request_duration'); ?> :
                                            <?php echo e(dateConvertDBtoForm($leaveApplication->application_from_date)); ?> To
                                            <?php echo e(dateConvertDBtoForm($leaveApplication->application_to_date)); ?><br>
                                            <?php echo app('translator')->getFromJson('leave.number_of_day'); ?> : <?php echo e($leaveApplication->number_of_day); ?> <br>
                                            <?php echo app('translator')->getFromJson('leave.purpose'); ?> : <?php echo e($leaveApplication->purpose); ?>

                                        </span>

                                        <a href="javacript:void(0)" data-status="2"
                                            data-leave_application_id="<?php echo e($leaveApplication->leave_application_id); ?>"
                                            class="btn remarksForLeave btn btn-rounded btn-success btn-outline m-r-5"><i
                                                class="ti-check text-success m-r-5"></i><?php echo app('translator')->getFromJson('common.approve'); ?></a>
                                        <a href="javacript:void(0)" data-status="3"
                                            data-leave_application_id="<?php echo e($leaveApplication->leave_application_id); ?>"
                                            class="btn-rounded remarksForLeave btn btn-danger btn-outline"><i
                                                class="ti-close text-danger m-r-5"></i><?php echo app('translator')->getFromJson('common.reject'); ?></a>
                                    </div>
                                </div>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                </div>
            </div>
        <?php endif; ?>
    </div>
</div>

<?php $__env->stopSection(); ?>


<?php $__env->startSection('page_scripts'); ?>
<link href="<?php echo asset('admin_assets/plugins/bower_components/news-Ticker-Plugin/css/site.css'); ?>" rel="stylesheet" type="text/css" />
<script src="<?php echo asset('admin_assets/plugins/bower_components/news-Ticker-Plugin/scripts/jquery.bootstrap.newsbox.min.js'); ?>"></script>

<script type="text/javascript">
    (function() {

        $(".demo1").bootstrapNews({
            newsPerPage: 2,
            autoplay: true,
            pauseOnHover: true,
            direction: 'up',
            newsTickerInterval: 4000,
            onToDo: function() {
                //console.log(this);
            }
        });

    })();

    $(document).on('click', '.remarksForLeave', function() {

        var actionTo = "<?php echo e(URL::to('approveOrRejectLeaveApplication')); ?>";
        var leave_application_id = $(this).attr('data-leave_application_id');
        var status = $(this).attr('data-status');

        if (status == 2) {
            var statusText = "Are you want to approve leave application?";
            var btnColor = "#2cabe3";
        } else {
            var statusText = "Are you want to reject leave application?";
            var btnColor = "red";
        }

        swal({
                title: "",
                text: statusText,
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: btnColor,
                confirmButtonText: "Yes",
                closeOnConfirm: false
            },
            function(isConfirm) {
                var token = '<?php echo e(csrf_token()); ?>';
                if (isConfirm) {
                    $.ajax({
                        type: 'POST',
                        url: actionTo,
                        data: {
                            leave_application_id: leave_application_id,
                            status: status,
                            _token: token
                        },
                        success: function(data) {
                            if (data == 'approve') {
                                swal({
                                        title: "Approved!",
                                        text: "Leave application approved.",
                                        type: "success"
                                    },
                                    function(isConfirm) {
                                        if (isConfirm) {
                                            $('.' + leave_application_id).fadeOut();
                                        }
                                    });

                            } else {
                                swal({
                                        title: "Rejected!",
                                        text: "Leave application rejected.",
                                        type: "success"
                                    },
                                    function(isConfirm) {
                                        if (isConfirm) {
                                            $('.' + leave_application_id).fadeOut();
                                        }
                                    });
                            }
                        }

                    });
                } else {
                    swal("Cancelled", "Your data is safe .", "error");
                }
            });
        return false;

    });
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>