<script>
    $(document).ready(function (e) {

        $("#challredio").change(function () {
            if ($(this).is(':checked')) {
                // alert(1);
                document.getElementById("Hourlyrate").value = 0;
                //  $(".radioR").prop("checked", true);
            } else {

                // alert(0);
                /*$(".radioR").prop("checked", false);
                 $(".noradioR").prop("checked", true);*/
            }
        });
        $('.calcCost').live('keyup', function () {
            //
            var empSalary = Number($("#empSalary").val());
            var houseAllowance = Number($("#houseAllowance").val());
            var transportationAllowance = Number($("#transportationAllowance").val());
            //
            var noOfWorkDaysPerMonth = Number($("#noOfWorkDaysPerMonth").val());
            var noOfWorkHoursDaysPerDay = Number($("#noOfWorkHoursDaysPerDay").val());
            var noOfDistountDaysWhenAbsences = Number($("#noOfDistountDaysWhenAbsences").val());
            //##
            var Bsat = empSalary + houseAllowance + transportationAllowance;
            var makam1 = noOfWorkDaysPerMonth * noOfWorkHoursDaysPerDay * 60;
            var makam2 = noOfWorkDaysPerMonth * noOfDistountDaysWhenAbsences;

            var miniteLateCost = 0;
            if (makam1 != 0) {
                miniteLateCost = (Bsat / makam1).toFixed(3);
            }
            var dayAbsenseCost = 0;
            if (makam2 != 0) {
                dayAbsenseCost = (Bsat / makam2).toFixed(3);
            }
            $('#miniteLateCost').html(miniteLateCost);
            $('#dayAbsenseCost').html(dayAbsenseCost);
        });
    });


</script>
<script src="{$path}/SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="{$path}/SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />

<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">ادراه الموظفين</a></li>
            <li><a href="#">الموظفين</a></li>
            <li class="active">إضافة موظف</li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title">إضافة موظف</h3>
            </div>
            <div class="panel-body">

                <!-- end box / title -->

                <form method="post" action="?do=add" class="nameToBeChecked form-horizontal"
                      enctype="multipart/form-data">

                    <div class="col-lg-6">
                        <div class="form-group">
                            <label class="col-lg-4 control-label">الاسم</label>
                            <div class="col-lg-8">
                                <span id="sprytextfield1">
                                    <input name="empName" type="text" class="form-control" />
                                    <span class="textfieldRequiredMsg">من فضلك اختر الاسم</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">الكود</label>
                            <div class="col-lg-8">
                                <span id="sprytextfield2">
                                    <input name="empCode" type="text" class="form-control positiveNo" />
                                    <span class="textfieldRequiredMsg">من فضلك ادخل الكود</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">مجموعة الموظفين </label>
                            <div class="col-lg-8">
                                <span id="employeegroupidsp">
                                    <select class="select2" name="employeegroupid" id="employeegroupid">
                                        <option value="-1">اختر مجموعة الموظفين</option>
                                        {foreach $employeeGroup as $data}
                                        <option value="{$data->id}">{$data->name}</option>
                                        {/foreach}
                                    </select>
                                    <span class="selectInvalidMsg">*</span><span
                                        class="selectRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">مجموعة الموظفين الفرعية </label>
                            <div class="col-lg-8">
                                <span id="employeesubgroupidsp">
                                    <input type="text" name="employeesubgroupid" id="employeesubgroupid" value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="usergroupid" class="col-lg-4 control-label">الفرع</label>
                            <div class="col-lg-8">
                                <span id="spryselectBranchId">
                                    <select required class="select2" name="branchid" id="branchid">
                                        <option value="-1">اختر الفرع</option>
                                        {foreach $allbranchdata as $myallbranchdata}
                                        {if $myallbranchdata->branchId neq 0}
                                        <option value="{$myallbranchdata->branchId}">{$myallbranchdata->branchName}
                                        </option>
                                        {/if}
                                        {/foreach}
                                    </select>
                                    <span class="selectInvalidMsg">*</span>
                                    <span class="selectRequiredMsg">*</span>
                                </span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">بصمة الموظف</label>
                            <div class="col-lg-8">
                                <!--<span id="employeesubgroupidsp">-->
                                <input type="text" name="empFingerId" id="empFingerId" class="form-control positiveNo"
                                       value="" />
                                <!--<span class="textfieldRequiredMsg">*</span></span>-->
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">بصمة الموظف 2</label>
                            <div class="col-lg-8">
                                <input type="text" name="empFingerId2" id="empFingerId2" class="form-control positiveNo"
                                       value="" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">بصمة الموظف 3</label>
                            <div class="col-lg-8">
                                <input type="text" name="empFingerId3" id="empFingerId3" class="form-control positiveNo"
                                       value="" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">بصمة الموظف 4</label>
                            <div class="col-lg-8">
                                <input type="text" name="empFingerId4" id="empFingerId4" class="form-control positiveNo"
                                       value="" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">بصمة الموظف 5</label>
                            <div class="col-lg-8">
                                <input type="text" name="empFingerId5" id="empFingerId5" class="form-control positiveNo"
                                       value="" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">كارت RFID الموظف</label>
                            <div class="col-lg-8">
                                <!--<span id="employeesubgroupidsp">-->
                                <input type="text" name="empRFID" id="empRFID" class="form-control positiveNo"
                                       value="" />
                                <!--<span class="textfieldRequiredMsg">*</span></span>-->
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-lg-4 control-label">تاريخ الميلاد </label>
                            <div class="col-lg-8">
                                <input name="empDOF" id="empDOF" class="form-control awdatepicker" autocomplete="off"
                                       data-date-format="yyyy-mm-dd" type="text" />
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-lg-4 control-label"> الجنسية </label>
                            <div class="col-lg-8">
                                <input name="nationality" type="text" class="form-control" />
                            </div>
                        </div>

                        <!--<div class="form-group">-->
                        <!--<label class="col-lg-4 control-label">الجنسية  </label>-->
                        <!--<div class="col-lg-8">-->


                        <!--&lt;!&ndash;<select class="select2" name="nationality">&ndash;&gt;-->
                        <!--&lt;!&ndash;&ndash;&gt;-->
                        <!--&lt;!&ndash;<option value=""></option>&ndash;&gt;-->
                        <!--&lt;!&ndash;{foreach $country as $data}&ndash;&gt;-->
                        <!--&lt;!&ndash;<option value="{$data->id}">{$data->name}</option>&ndash;&gt;-->
                        <!--&lt;!&ndash;{/foreach}&ndash;&gt;-->
                        <!--&lt;!&ndash;</select>&ndash;&gt;-->
                        <!--</div>-->
                        <!--</div>-->


                        <div class="form-group">
                            <label class="col-lg-4 control-label"> الديانة </label>
                            <div class="col-lg-8">
                                <input name="religion" type="text" class="form-control" />
                            </div>
                        </div>


                        <!--<div class="form-group">-->
                        <!--<label class="col-lg-4 control-label">الديانة  </label>-->
                        <!--<div class="col-lg-8">-->
                        <!---->
                        <!--&lt;!&ndash;<select class="select2" name="religion">&ndash;&gt;-->
                        <!--&lt;!&ndash;<option value=""></option>&ndash;&gt;-->
                        <!--&lt;!&ndash;{foreach $religion as $data}&ndash;&gt;-->
                        <!--&lt;!&ndash;<option value="{$data->id}">{$data->name}</option>&ndash;&gt;-->
                        <!--&lt;!&ndash;{/foreach}&ndash;&gt;-->
                        <!--&lt;!&ndash;</select>&ndash;&gt;-->
                        <!--</div>-->
                        <!--</div>-->

                        <div class="form-group">
                            <label class="col-lg-4 control-label"> اسم المستخدم </label>
                            <div class="col-lg-8">
                                <input name="username" type="text" value="{$username}" readonly class="form-control" />
                            </div>
                        </div>


                        <!--<div class="form-group">-->
                        <!--<label class="col-lg-4 control-label">التاريخ  </label>-->
                        <!--<div class="col-lg-8">-->
                        <!--<input type="text" class="form-control awdatepicker" autocomplete="off" value="{$day}"   data-date-format="yyyy-mm-dd" name="from" >                            </div>-->
                        <!--</div>-->

                        <div class="form-group">
                            <label class="col-lg-4 control-label">رقم الجوال </label>
                            <div class="col-lg-8">
                                <input name="empTel" type="text" class="form-control" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label"> العنوان </label>
                            <div class="col-lg-8">
                                <input name="empAddress" type="text" class="form-control" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">صورة التعاقد</label>
                            <div class="col-lg-8">
                                <input type="file" name="contract" id="contract" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">صورة الاقامة</label>
                            <div class="col-lg-8">
                                <input type="file" name="residence" id="residence" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">صورة شخصية</label>
                            <div class="col-lg-8">
                                <input type="file" name="personalPhoto" id="personalPhoto" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">صورة الكارت الصحى</label>
                            <div class="col-lg-8">
                                <input type="file" name="healthCard" id="healthCard" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">صورة التأشيرة</label>
                            <div class="col-lg-8">
                                <input type="file" name="visa" id="visa" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">صورة جواز السفر</label>
                            <div class="col-lg-8">
                                <input type="file" name="passport" id="passport" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">شهادة تخرج</label>
                            <div class="col-lg-8">
                                <input type="file" name="graduate" id="graduate" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">شهادة خبرة 1</label>
                            <div class="col-lg-8">
                                <input type="file" name="expert1" id="expert1" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">شهادة خبرة 2</label>
                            <div class="col-lg-8">
                                <input type="file" name="expert2" id="expert2" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">شهادة خبرة 3</label>
                            <div class="col-lg-8">
                                <input type="file" name="expert3" id="expert3" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">عامل</label>
                            <div class="col-lg-8">
                                <div class="radio-inline">
                                    <label>
                                        <input value="0" name="isworker" type="radio" />

                                        نعم </label>
                                </div>
                                <div class="radio-inline">
                                    <label>
                                        <input value="1" class="noradioR" name="isworker" checked="checked"
                                               id="challredio" type="radio" />
                                        لا </label>
                                </div>

                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">صورة شهادة الميلاد </label>
                            <div class="col-lg-8">
                                <input type="file" name="birthCertificate" id="birthCertificate" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">صورة الجيش </label>
                            <div class="col-lg-8">
                                <input type="file" name="armyPhoto" id="armyPhoto" />
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-lg-4 control-label">صورة البطاقة الشخصية </label>
                            <div class="col-lg-8">
                                <input type="file" name="idCard" id="idCard" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">صورة رخصة القيادة </label>
                            <div class="col-lg-8">
                                <input type="file" name="driverLicense" id="driverLicense" />
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-lg-4 control-label">صورة اقرار السلام العمل</label>
                            <div class="col-lg-8">
                                <input type="file" name="endorsementPeace" id="endorsementPeace" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">صورة اقرار الحفاظ على سريةالعمل </label>
                            <div class="col-lg-8">
                                <input type="file" name="confidentialityDeclaration" id="confidentialityDeclaration" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">صورة القيش الجنائي</label>
                            <div class="col-lg-8">
                                <input type="file" name="criminalCamouflage" id="criminalCamouflage" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label"> يستحق إضافي </label>
                            <div class="col-lg-8">
                                <span id="sprytextfield1">
                                    <input name="worthExtra" type="checkbox" class="form-control" value="1" />
                                    <span class="textfieldRequiredMsg"></span></span>
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-lg-4 control-label"> الإدارة </label>
                            <div class="col-lg-8">
                                <span id="sprytextfield1">
                                    <input name="administration" type="text" class="form-control" />
                                    <span class="textfieldRequiredMsg"></span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">الإدارة الفرعية </label>
                            <div class="col-lg-8">
                                <span id="sprytextfield1">
                                    <input name="subManagement" type="text" class="form-control" />
                                    <span class="textfieldRequiredMsg"></span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label"> اسم المدير المباِشر </label>
                            <div class="col-lg-8">
                                <span id="sprytextfield1">
                                    <input name="directManager" type="text" class="form-control" />
                                    <span class="textfieldRequiredMsg"></span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label"> الوظيفة</label>
                            <div class="col-lg-8">
                                <span id="sprytextfield1">
                                    <input name="occupation" type="text" class="form-control" />
                                    <span class="textfieldRequiredMsg"></span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label"> تاريخ التعين </label>
                            <div class="col-lg-8">
                                <span id="sprytextfield1">
                                    <input name="dateBeing" id="dateBeing" class="form-control awdatepicker"
                                           autocomplete="off" data-date-format="yyyy-mm-dd" type="text" />
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-lg-4 control-label">النوع</label>
                            <div class="col-lg-8">
                                <div class="radio-inline">
                                    <label>
                                        <input value="0" name="gender" type="radio" checked="checked" />

                                        ذكر </label>
                                </div>
                                <div class="radio-inline">
                                    <label>
                                        <input value="1" name="gender" type="radio" />
                                        انثى </label>
                                </div>

                            </div>
                        </div>



                        <div class="form-group">
                            <label class="col-lg-4 control-label"> الحالة الاجتماعية</label>
                            <div class="col-lg-8">
                                <span id="sprytextfield1">
                                    <input name="socialSituation" type="text" class="form-control" />
                                    <span class="textfieldRequiredMsg"></span></span>
                            </div>
                        </div>



                        <div class="form-group">
                            <label class="col-lg-4 control-label">صورة رخصة مزاولة المهنة</label>
                            <div class="col-lg-8">
                                <input type="file" name="practiceProfession" id="practiceProfession" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label"> صورة الحالة الاجتماعية </label>
                            <div class="col-lg-8">
                                <input type="file" name="socialStatus" id="socialStatus" />
                            </div>
                        </div>




                        <div class="form-group">
                            <label class="col-lg-4 control-label"> رقم حساب البنك </label>
                            <div class="col-lg-8">
                                <span id="sprytextfield1">
                                    <input name="bankAccount" type="text" class="form-control" />
                                    <span class="textfieldRequiredMsg"></span></span>
                            </div>
                        </div>



                        <div class="form-group">
                            <label class="col-lg-4 control-label"> منحة دراسية </label>
                            <div class="col-lg-8">
                                <span id="dcholarship1">
                                    <input name="dcholarship" type="checkbox" class="form-control" value="1" />
                                    <span class="textfieldRequiredMsg"></span></span>
                            </div>
                        </div>





                    </div>
                    <div class="col-lg-6">

                        <div class="form-group">
                            <label class="col-lg-4 control-label">سعر الساعه الإضافية </label>
                            <div class="col-lg-8"><span id="">
                                    <input name="Hourlyrate" id="Hourlyrate" type="text" value="0"
                                           class="form-control" />
                                    <!--                                    <span class="textfieldRequiredMsg">***.</span><span class="textfieldInvalidFormatMsg">***.</span></span>-->
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">قيمة اليوم الإضافي </label>
                            <div class="col-lg-8"><span id="">
                                    <input name="extradayval" id="extradayval" type="text" value="0"
                                           class="form-control" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label"> المرتب الاساسى </label>
                            <div class="col-lg-8">
                                <span id="">
                                    <input name="empSalary" id="empSalary" type="text" class="form-control" />
                                    <!--                                    <span class="textfieldRequiredMsg">ادخل رقم صحيح</span><span class="textfieldInvalidFormatMsg calcCost">Invalid format.</span></span>-->
                            </div>
                        </div>



                        <!--div class="form-group">
                            <label class="col-lg-4 control-label"> اضافات المرتب  </label>
                            <div class="col-lg-8">
                                <span id="sprytextfield3">
                                    <input name="empBouns" type="text"   class="form-control"/>
                                    <span class="textfieldRequiredMsg">ادخل رقم صحيح</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
                            </div>
                        </div-->
                        <div class="form-group">
                            <label class="col-lg-4 control-label">بدل سكن </label>
                            <div class="col-lg-8">
                                <input name="houseAllowance" id="houseAllowance" type="text" value=""
                                       class="form-control calcCost" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">بدل مواصلات </label>
                            <div class="col-lg-8">
                                <input name="transportationAllowance" id="transportationAllowance" type="text" value=""
                                       class="form-control calcCost" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">بدلات اخرى</label>
                            <div class="col-lg-8">
                                <input name="otherAllowance" type="text" value="" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">عدد ابام العمل فى الشهر</label>
                            <div class="col-lg-8">
                                <input name="noOfWorkDaysPerMonth" id="noOfWorkDaysPerMonth" type="text" value=""
                                       class="form-control calcCost" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">عدد ساعات العمل فى اليوم</label>
                            <div class="col-lg-8">
                                <input name="noOfWorkHoursDaysPerDay" id="noOfWorkHoursDaysPerDay" type="text" value=""
                                       class="form-control calcCost" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-4 control-label">عدد ابام الخصم عند الغياب</label>
                            <div class="col-lg-8">
                                <input name="noOfDistountDaysWhenAbsences" id="noOfDistountDaysWhenAbsences" type="text"
                                       value="" class="form-control calcCost" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">التامينات الاجتماعيه</label>
                            <div class="col-lg-8">
                                <input name="socialInsurance" id="socialInsurance" type="text" value="" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-4 control-label">ضريبه كسب العمل</label>
                            <div class="col-lg-8">
                                <input name="workTax" id="workTax" type="text" value="" class="form-control"/>
                            </div>
                        </div>

                    </div>

                    <div class="clearfix propbd"></div>
                    <h3><u>نظام الحضور</u></h3>
                    <br />
                    <div class="col-lg-6">

                        <div class="form-group">
                            <label class="col-lg-6 control-label">عدد مرات التاخير المسموح بها </label>
                            <div class="col-lg-6">
                                <span id="numberOfCountsOfDelayAllowedp">
                                    <input type="text" name="numberOfCountsOfDelayAllowed"
                                           id="numberOfCountsOfDelayAllowed" class="form-control positivefloat" value=""
                                           required />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>



                        <div class="form-group">
                            <label class="col-lg-6 control-label">عدد دقائق التاخير المسموح بها </label>
                            <div class="col-lg-6">
                                <span id="numberOfMinutesOfDelayAllowedp">
                                    <input type="text" name="numberOfMinutesOfDelayAllowed"
                                           id="numberOfMinutesOfDelayAllowed" class="form-control positivefloat" value=""
                                           required />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-6 control-label">عدد ايام الاجازات</label>
                            <div class="col-lg-6">
                                <span id="takeVacationDaysp">
                                    <input type="text" name="takeVacationDays" id="takeVacationDays"
                                           class="form-control positivefloat" value="" required />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم الربع ساعة تاخير باذن</label>
                            <div class="col-lg-6">
                                <span id="quarterHourLateWithPermissionDisountS">
                                    <input type="text" name="quarterHourLateWithPermissionDisount"
                                           id="quarterHourLateWithPermissionDisount" class="form-control positivefloat"
                                           value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم النصف ساعة تاخير باذن</label>
                            <div class="col-lg-6">
                                <span id="halfHourLateWithPermissionDisountsp">
                                    <input type="text" name="halfHourLateWithPermissionDisount"
                                           id="halfHourLateWithPermissionDisount" class="form-control positivefloat"
                                           value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم الساعة تاخير باذن</label>
                            <div class="col-lg-6">
                                <span id="hourLateWithPermissionDisountsp">
                                    <input type="text" name="hourLateWithPermissionDisount"
                                           id="hourLateWithPermissionDisount" class="form-control positivefloat"
                                           value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم الساعة ونصف تاخير باذن</label>
                            <div class="col-lg-6">
                                <span id="hourAndHalfLateWithPermissionDisountsp">
                                    <input type="text" name="hourAndHalfLateWithPermissionDisount"
                                           id="hourAndHalfLateWithPermissionDisount" class="form-control positivefloat"
                                           value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم الساعتين تاخير باذن</label>
                            <div class="col-lg-6">
                                <span id="twoHoursLateWithPermissionDisountsp">
                                    <input type="text" name="twoHoursLateWithPermissionDisount"
                                           id="twoHoursLateWithPermissionDisount" class="form-control positivefloat"
                                           value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم اكثر من ساعتين تاخير باذن</label>
                            <div class="col-lg-6">
                                <span id="moreThanTwoHoursLateWithPermissionDisountsp">
                                    <input type="text" name="moreThanTwoHoursLateWithPermissionDisount"
                                           id="moreThanTwoHoursLateWithPermissionDisount"
                                           class="form-control positivefloat" value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <!------------------------------------------------------------------------>
                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم النصف ساعة اذن</label>
                            <div class="col-lg-6">
                                <span id="halfHourPermissionDisountsp">
                                    <input type="text" name="halfHourPermissionDisount" id="halfHourPermissionDisount"
                                           class="form-control positivefloat" value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم الساعة اذن</label>
                            <div class="col-lg-6">
                                <span id="hourPermissionDisountsp">
                                    <input type="text" name="hourPermissionDisount" id="hourPermissionDisount"
                                           class="form-control positivefloat" value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم الساعة ونصف اذن</label>
                            <div class="col-lg-6">
                                <span id="hourAndHalfPermissionDisountsp">
                                    <input type="text" name="hourAndHalfPermissionDisount"
                                           id="hourAndHalfPermissionDisount" class="form-control positivefloat" value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم الساعتين اذن</label>
                            <div class="col-lg-6">
                                <span id="twoHoursPermissionDisountsp">
                                    <input type="text" name="twoHoursPermissionDisount" id="twoHoursPermissionDisount"
                                           class="form-control positivefloat" value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>


                    </div>

                    <div class="col-lg-6">

                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم ربع ساعة تاخير بدون اذن </label>
                            <div class="col-lg-6">
                                <span id="quarterHourLateWithoutPermissionDisountS">
                                    <input type="text" name="quarterHourLateWithoutPermissionDisount"
                                           id="quarterHourLateWithoutPermissionDisount" class="form-control positivefloat"
                                           value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم النصف ساعة تاخير بدون اذن </label>
                            <div class="col-lg-6">
                                <span id="halfHourLateWithoutPermissionDisountsp">
                                    <input type="text" name="halfHourLateWithoutPermissionDisount"
                                           id="halfHourLateWithoutPermissionDisount" class="form-control positivefloat"
                                           value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم الساعة تاخير بدون اذن </label>
                            <div class="col-lg-6">
                                <span id="hourLateWithoutPermissionDisountsp">
                                    <input type="text" name="hourLateWithoutPermissionDisount"
                                           id="hourLateWithoutPermissionDisount" class="form-control positivefloat"
                                           value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم الساعة ونصف تاخير بدون اذن </label>
                            <div class="col-lg-6">
                                <span id="hourAndHalfLateWithoutPermissionDisountsp">
                                    <input type="text" name="hourAndHalfLateWithoutPermissionDisount"
                                           id="hourAndHalfLateWithoutPermissionDisount" class="form-control positivefloat"
                                           value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم الساعتين تاخير بدون اذن </label>
                            <div class="col-lg-6">
                                <span id="twoHoursLateWithoutPermissionDisountsp">
                                    <input type="text" name="twoHoursLateWithoutPermissionDisount"
                                           id="twoHoursLateWithoutPermissionDisount" class="form-control positivefloat"
                                           value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-6 control-label">قيمة خصم اكثر من ساعتين تاخير بدون اذن </label>
                            <div class="col-lg-6">
                                <span id="moreThanTwoHoursLateWithoutPermissionDisountsp">
                                    <input type="text" name="moreThanTwoHoursLateWithoutPermissionDisount"
                                           id="moreThanTwoHoursLateWithoutPermissionDisount"
                                           class="form-control positivefloat" value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <!-- =================================================   -->
                        <div class="form-group">
                            <label class="col-lg-6 control-label">اليوم الغياب باذن</label>
                            <div class="col-lg-6">
                                <span id="dayAbsenceWithPermissionDisountsp">
                                    <input type="text" name="dayAbsenceWithPermissionDisount"
                                           id="dayAbsenceWithPermissionDisount" class="form-control positivefloat"
                                           value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-6 control-label">اليوم الغياب بدون اذن</label>
                            <div class="col-lg-6">
                                <span id="dayAbsenceWithoutPermissionDisountsp">
                                    <input type="text" name="dayAbsenceWithoutPermissionDisount"
                                           id="dayAbsenceWithoutPermissionDisount" class="form-control positivefloat"
                                           value="" />
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <!-- =================================================   -->


                    </div>

                    <div class="col-lg-12">
                        {assign var=itr value=1}
                        {foreach $week as $key => $val}
                        <div class="form-group propbd">
                            <div class="col-lg-1">
                                <input type="checkbox" name="chosseday_{$itr}" id="chosseday_{$itr}"
                                       class="form-control" value="1" checked="" />
                            </div>
                            <div class="col-lg-1">
                                <input type="text" class="form-control" id="shattendancedayar_{$itr}" readonly
                                       value="{$val}" />
                                <input type="hidden" name="employeeattendancesystemweek_id_{$itr}"
                                       id="employeeattendancesystemweek_id_{$itr}" value="{$key}" />
                                <input type="hidden" name="employeeattendancesystem_id_{$itr}"
                                       id="employeeattendancesystem_id_{$itr}" value="{$key}" />
                                <input type="hidden" name="attendancedaynum_{$itr}" id="attendancedaynum_{$itr}"
                                       value="{$key}" />
                                <input type="hidden" name="attendancedayar_{$itr}" id="attendancedayar_{$itr}"
                                       value="{$val}" />
                                <input type="hidden" name="attendancedayen_{$itr}" id="attendancedayen_{$itr}"
                                       value="{$val}" />
                            </div>
                            <label class="col-lg-2 control-label">وقت الحضور</label>
                            <div class="col-lg-3">
                                <input type="time" name="attendancetime_{$itr}" step="2" id="attendancetime_{$itr}"
                                       class="form-control" value="{$timeNow}" />
                            </div>
                            <label class="col-lg-2 control-label">وقت الانصراف</label>
                            <div class="col-lg-3">
                                <input type="time" name="departuretime_{$itr}" step="2" id="departuretime_{$itr}"
                                       class="form-control timePicker" value="{$timeNow}" />
                            </div>

                        </div>
                        {capture assign=itr}{$itr+1}{/capture}
                        {/foreach}
                    </div>

                    <div class="col-lg-offset-8 col-lg-4">
                        <div class="well well-sm">

                            <h4 class="text-center">تكلفة دقيقة التاخير <span id="miniteLateCost">0</span> {$currency}
                            </h4>

                        </div>
                        <div class="well well-sm">

                            <h4 class="text-center">تكلفة يوم الغياب <span id="dayAbsenseCost">0</span> {$currency}</h4>

                        </div>
                    </div>


                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-8">
                            <button type="submit" class="btn btn-primary pull-left">حفظ</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{literal}
<script type="text/javascript">
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "real");
    var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "real");
    var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {isRequired: false, invalidValue: "0"});
    var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "real");
    //    var employeegroupidsp = new Spry.Widget.ValidationSelect("employeegroupidsp", {invalidValue: "-1"});
    //    var employeesubgroupidsp = new Spry.Widget.ValidationTextField("employeesubgroupidsp");

    var halfHourLateWithPermissionDisountsp = new Spry.Widget.ValidationTextField("halfHourLateWithPermissionDisountsp");
    var hourLateWithPermissionDisountsp = new Spry.Widget.ValidationTextField("hourLateWithPermissionDisountsp");
    var hourAndHalfLateWithPermissionDisountsp = new Spry.Widget.ValidationTextField("hourAndHalfLateWithPermissionDisountsp");
    var twoHoursLateWithPermissionDisountsp = new Spry.Widget.ValidationTextField("twoHoursLateWithPermissionDisountsp");
    var moreThanTwoHoursLateWithPermissionDisountsp = new Spry.Widget.ValidationTextField("moreThanTwoHoursLateWithPermissionDisountsp");
    var halfHourLateWithoutPermissionDisountsp = new Spry.Widget.ValidationTextField("halfHourLateWithoutPermissionDisountsp");
    var hourLateWithoutPermissionDisountsp = new Spry.Widget.ValidationTextField("hourLateWithoutPermissionDisountsp");
    var hourAndHalfLateWithoutPermissionDisount = new Spry.Widget.ValidationTextField("hourAndHalfLateWithoutPermissionDisount");
    var twoHoursLateWithoutPermissionDisountsp = new Spry.Widget.ValidationTextField("twoHoursLateWithoutPermissionDisountsp");
    var moreThanTwoHoursLateWithoutPermissionDisountsp = new Spry.Widget.ValidationTextField("moreThanTwoHoursLateWithoutPermissionDisountsp");
    var halfHourPermissionDisountsp = new Spry.Widget.ValidationTextField("halfHourPermissionDisountsp");
    var hourPermissionDisountsp = new Spry.Widget.ValidationTextField("hourPermissionDisountsp");
    var hourAndHalfPermissionDisountsp = new Spry.Widget.ValidationTextField("hourAndHalfPermissionDisountsp");
    var twoHoursPermissionDisountsp = new Spry.Widget.ValidationTextField("twoHoursPermissionDisountsp");
    var dayAbsenceWithPermissionDisountsp = new Spry.Widget.ValidationTextField("dayAbsenceWithPermissionDisountsp");
    var dayAbsenceWithoutPermissionDisountsp = new Spry.Widget.ValidationTextField("dayAbsenceWithoutPermissionDisountsp");
    var spryselectBranchId = new Spry.Widget.ValidationSelect("spryselectBranchId", {isRequired: true, invalidValue: "-1"});

    var formatResult;
    formatResult = function (data) {
        return data.text;
    }
    $(function () {
        $("#employeesubgroupid").select2({
            placeholder: " اختر مجموعة الموظف اولا",
            minimumInputLength: 0,
            multiple: false,
            quietMillis: 100,
            ajax: {
                url: "employeegroups.php?do=getsubgroups",
                dataType: 'json',
                data: function (term, page) {
                    //alert("sellbillAjaxController.php?do=getProducts&term="+term+"&page_limit=10&storeid="+document.getElementById("storeid").value);
                    return {
                        term: term, //search term
                        group: $('#employeegroupid').val(), //search term
                    };
                },
                results: function (data) {
                    //console.log(data);
                    return {results: data};
                }
            },
            formatResult: formatResult,
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = {id: item[0], text: item[1], productquantity: item[2], price: item[3]};
                callback(data);
            }

        });
        $('#employeesubgroupid').live('change', function () {

            var id = Number($(this).val());
            $.post('employeegroups.php?do=getsubgroupAttendanceData', {id: id}, function (data) {
                data = JSON.parse(data);
                $('#numberOfMinutesOfDelayAllowed').val(data[0].numberOfMinutesOfDelayAllowed);
                $('#takeVacationDays').val(data[0].takeVacationDays);
                $('#halfHourLateWithPermissionDisount').val(data[0].halfHourLateWithPermissionDisount);
                $('#hourLateWithPermissionDisount').val(data[0].hourLateWithPermissionDisount);
                $('#hourAndHalfLateWithPermissionDisount').val(data[0].hourAndHalfLateWithPermissionDisount);
                $('#twoHoursLateWithPermissionDisount').val(data[0].twoHoursLateWithPermissionDisount);
                $('#moreThanTwoHoursLateWithPermissionDisount').val(data[0].moreThanTwoHoursLateWithPermissionDisount);
                $('#halfHourLateWithoutPermissionDisount').val(data[0].halfHourLateWithoutPermissionDisount);
                $('#hourLateWithoutPermissionDisount').val(data[0].hourLateWithoutPermissionDisount);
                $('#hourAndHalfLateWithoutPermissionDisount').val(data[0].hourAndHalfLateWithoutPermissionDisount);
                $('#twoHoursLateWithoutPermissionDisount').val(data[0].twoHoursLateWithoutPermissionDisount);
                $('#moreThanTwoHoursLateWithoutPermissionDisount').val(data[0].moreThanTwoHoursLateWithoutPermissionDisount);
                $('#halfHourPermissionDisount').val(data[0].halfHourPermissionDisount);
                $('#hourPermissionDisount').val(data[0].hourPermissionDisount);
                $('#hourAndHalfPermissionDisount').val(data[0].hourAndHalfPermissionDisount);
                $('#twoHoursPermissionDisount').val(data[0].twoHoursPermissionDisount);
                $('#dayAbsenceWithPermissionDisount').val(data[0].dayAbsenceWithPermissionDisount);
                $('#dayAbsenceWithoutPermissionDisount').val(data[0].dayAbsenceWithoutPermissionDisount);
                $('#quarterHourLateWithPermissionDisount').val(data[0].quarterHourLateWithPermissionDisount);
                $('#quarterHourLateWithoutPermissionDisount').val(data[0].quarterHourLateWithoutPermissionDisount);
                $('#numberOfCountsOfDelayAllowed').val(data[0].numberOfCountsOfDelayAllowed);

                var itr = 1;
                var myArray = data[1];
                for (var i in myArray) {
                    if (myArray[i]['chosseday'] == 1) {
                        $('#chosseday_' + itr).prop('checked', true);
                    } else {
                        $('#chosseday_' + itr).prop('checked', false);
                    }
                    $('#employeeattendancesystemweek_id_' + itr).val(myArray[i]['id']);
                    $('#employeeattendancesystem_id_' + itr).val(myArray[i]['employeeattendancesystem_id']);
                    $('#attendancedaynum_' + itr).val(myArray[i]['attendancedaynum']);
                    $('#attendancedayar_' + itr).val(myArray[i]['attendancedayar']);
                    $('#shattendancedayar_' + itr).val(myArray[i]['attendancedayar']);
                    $('#attendancedayen_' + itr).val(myArray[i]['attendancedayen']);
                    $('#attendancetime_' + itr).val(myArray[i]['attendancetime']);
                    $('#departuretime_' + itr).val(myArray[i]['departuretime']);
                    itr++;
                }
                ;
            });
        });


        $('#employeegroupid').live('change', function () {
            $("#employeesubgroupid").val('').change();

            var id = Number($(this).val());
            $.post('employeegroups.php?do=getgroupAttendanceData', {id: id}, function (data) {
                data = JSON.parse(data);
                $('#numberOfMinutesOfDelayAllowed').val(data[0].numberOfMinutesOfDelayAllowed);
                $('#takeVacationDays').val(data[0].takeVacationDays);
                $('#halfHourLateWithPermissionDisount').val(data[0].halfHourLateWithPermissionDisount);
                $('#hourLateWithPermissionDisount').val(data[0].hourLateWithPermissionDisount);
                $('#hourAndHalfLateWithPermissionDisount').val(data[0].hourAndHalfLateWithPermissionDisount);
                $('#twoHoursLateWithPermissionDisount').val(data[0].twoHoursLateWithPermissionDisount);
                $('#moreThanTwoHoursLateWithPermissionDisount').val(data[0].moreThanTwoHoursLateWithPermissionDisount);
                $('#halfHourLateWithoutPermissionDisount').val(data[0].halfHourLateWithoutPermissionDisount);
                $('#hourLateWithoutPermissionDisount').val(data[0].hourLateWithoutPermissionDisount);
                $('#hourAndHalfLateWithoutPermissionDisount').val(data[0].hourAndHalfLateWithoutPermissionDisount);
                $('#twoHoursLateWithoutPermissionDisount').val(data[0].twoHoursLateWithoutPermissionDisount);
                $('#moreThanTwoHoursLateWithoutPermissionDisount').val(data[0].moreThanTwoHoursLateWithoutPermissionDisount);
                $('#halfHourPermissionDisount').val(data[0].halfHourPermissionDisount);
                $('#hourPermissionDisount').val(data[0].hourPermissionDisount);
                $('#hourAndHalfPermissionDisount').val(data[0].hourAndHalfPermissionDisount);
                $('#twoHoursPermissionDisount').val(data[0].twoHoursPermissionDisount);
                $('#dayAbsenceWithPermissionDisount').val(data[0].dayAbsenceWithPermissionDisount);
                $('#dayAbsenceWithoutPermissionDisount').val(data[0].dayAbsenceWithoutPermissionDisount);
                $('#quarterHourLateWithPermissionDisount').val(data[0].quarterHourLateWithPermissionDisount);
                $('#quarterHourLateWithoutPermissionDisount').val(data[0].quarterHourLateWithoutPermissionDisount);
                $('#numberOfCountsOfDelayAllowed').val(data[0].numberOfCountsOfDelayAllowed);

                var itr = 1;
                var myArray = data[1];

                for (var i in myArray) {
                    if (myArray[i]['chosseday'] == 1) {
                        $('#chosseday_' + itr).prop('checked', true);
                    } else {
                        $('#chosseday_' + itr).prop('checked', false);
                    }

                    $('#employeeattendancesystemweek_id_' + itr).val(myArray[i]['id']);
                    $('#employeeattendancesystem_id_' + itr).val(myArray[i]['employeeattendancesystem_id']);
                    $('#attendancedaynum_' + itr).val(myArray[i]['attendancedaynum']);
                    $('#attendancedayar_' + itr).val(myArray[i]['attendancedayar']);
                    $('#shattendancedayar_' + itr).val(myArray[i]['attendancedayar']);
                    $('#attendancedayen_' + itr).val(myArray[i]['attendancedayen']);
                    $('#attendancetime_' + itr).val(myArray[i]['attendancetime']);
                    $('#departuretime_' + itr).val(myArray[i]['departuretime']);
                    itr++;
                }
                ;
            });
        });
    });

</script>
{/literal}

</div>
</div>