

<div class="panel panel-default panel-m">
    <div class="panel-heading">
        <h3 class="panel-title">تقفيل يوم{$day} </h3>
    </div>
    <div class="panel-body">

        {if count($employeeArr) > 0}
        <form class="form-horizontal" method="post" id="employeeEndDayform">
            <table class="table">
                <thead>
                    <tr>
                        <td>#</td>
                        <td>الموظف</td>
                        <td>الحضور</td>
                        <td>الانصراف</td>
                        <td>التاخير بالدقائق</td>
                        <td>قيمة التاخير</td>
                        <td>غياب</td>
                        <td>قيمة الغياب</td>
                    </tr>
                </thead>
                <tbody>
                    {assign var=i value=1}
                    {foreach $employeeArr as $data}
                    {assign var=attendanceTimeExploded value=explode(":", $data->attendanceTime)}
                    {assign var=departureTimeExploded value=explode(":", $data->departureTime)}
                    <tr>
                        <td>{$i}</td>
                        <td>
                            {$data->employeeName}
                            <input type="hidden" name="empid{$i}" id="empid{$i}" value="{$data->employeeId}"/>
                            <input type='hidden' id='system{$data->employeeId}' value='{$data->attendanceSys}'/>
                            <input type="hidden" name="status{$data->employeeId}" id="status{$data->employeeId}" value="{$data->status}"/><!--employeeclosedayhistoryid-->
                            <input type="hidden" name="id{$data->employeeId}" id="id{$data->employeeId}" value="{$data->id}"/><!--employeeclosedayhistoryid-->
                        </td>
                        <td><input type="time" name="attendanceTime{$data->employeeId}" id="attendanceTime{$data->employeeId}" class="form-control attendanceTime lateSet" value="{if $data->attendanceTime != '00:00:00'}{$attendanceTimeExploded[0]}:{$attendanceTimeExploded[1]}{/if}" data-id="{$data->employeeId}"/></td>
                        <td><input type="time" name="departureTime{$data->employeeId}" id="departureTime{$data->employeeId}" class="form-control departureTime lateSet" value="{if $data->departureTime != '00:00:00'}{$departureTimeExploded[0]}:{$departureTimeExploded[1]}{/if}" data-id="{$data->employeeId}"/></td>
                        <td>
                            <input type="text" name="latePeriod{$data->employeeId}" id="latePeriod{$data->employeeId}" data-id="{$data->employeeId}" class="form-control positivefloat lateSet classLate" value="{$data->latePeriod}" style="display: inline;width: 60%"/>
                            <label id="lateHasPermissionLabel{$data->employeeId}" style=" {if $data->latePeriod==0} display: none; {/if}">
                                <input type="checkbox" name="lateHasPermission{$data->employeeId}" id="lateHasPermission{$data->employeeId}" class="lateSet lateHasPermission" value="1" data-id="{$data->employeeId}" style="margin: 0px 2px;" {if $data->lateHasPermission == 1}checked{/if}/>تاخير باذن</label>
                        </td>
                        <td><input type="text" name="lateDiscount{$data->employeeId}" id="lateDiscount{$data->employeeId}" class="form-control positivefloat lateDiscount lateSet" value="{$data->lateDiscount}" data-id="{$data->employeeId}"/></td>
                        <td>
                            <label>
                                <input type="checkbox" name="isAbsent{$data->employeeId}" id="isAbsent{$data->employeeId}" class="absenceSet calcAbset classIsAbsent" value="1" data-id="{$data->employeeId}" style="margin: 0px 2px;" {if $data->isAbsent == 1}checked{/if}/>غائب</label>
                            <label id="absentHasPermissionLabel{$data->employeeId}" style="{if $data->isAbsent==0} display: none; {/if}">
                                <input type="checkbox" name="absentHasPermission{$data->employeeId}" id="absentHasPermission{$data->employeeId}" class="absenceSet calcAbset" value="1" data-id="{$data->employeeId}" style="margin: 0px 2px;" {if $data->absentHasPermission == 1}checked{/if}/>غياب باذن</label>
                        </td>
                        <td><input type="text" name="absentDiscount{$data->employeeId}" id="absentDiscount{$data->employeeId}" class="form-control positivefloat absenceSet" value="{$data->absentDiscount}" data-id="{$data->employeeId}"/></td>
                    </tr>
                    {assign var=i value=$i+1}
                    {/foreach}
                </tbody>
            </table>

            <input type="hidden" name="empitr" id="empitr" value="{$i}"/>
            <!-- =================================================   -->
            <input type="hidden" name="day" id="day" value="{$day}"/>
            <input type="hidden" name="employeegroupid_day" id="employeegroupid_day" value="{$employeegroupid}"/>
            <input type="hidden" name="employeesubgroupid_day" id="employeesubgroupid_day" value="{$employeesubgroupid}"/>
            <div class="form-group">
                <div class="col-lg-offset-2 col-lg-4">
                    <button type="button"  class="btn btn-primary pull-left"  id="employeeEndDayNow">اقفل اليوم</button>
                </div>
            </div>


        </form>
        {else}
        <p>
        <ul style="font-size: 14px;">
            <li>لا يوجد بيانات للحضور فى هذا اليوم</li>
        </ul>
        </p>
        {/if}
    </div>
</div>

{literal}
<script>
    $('.positivefloat').forcepositivefloat();
    $(document).ready(function () {
        var empitr = $('#empitr').val();
        for (var i = 1; i < empitr; i++) {
            var empid = $('#empid' + i).val();
            var status = $('#status' + empid).val();
            var attendanceTime = $('#attendanceTime' + empid).val();
            if (status == -1 && attendanceTime != "") {// && attendanceTime != "00:00"
                $('#attendanceTime' + empid).change();
            }
        }
    });
</script>
{/literal}