


<div class="row">
    <div class="container">

        <ol class="breadcrumb">
            <li><a href="#">اداره الموظفين</a></li>
            <li><a href="employeeAttendanceSystems.php?do=show">انظمة الحضور</a></li>
            <li class="active">اضافة </li>
        </ol>


        <div class="panel panel-default panel-m">
            <div class="panel-heading">
                <h3 class="panel-title">اضافة </h3>
            </div>
            <div class="panel-body">


                <form class="nameToBeChecked form-horizontal" role="form" action="employeeAttendanceSystems.php?do=add" method="post" id="spform" novalidate>
                    <div class="form-group propbd">
                        <label class="col-lg-3 control-label">اسم النظام</label>
                        <div class="col-lg-4">
                            <span id="namesp">
                                <input required="required" type="text" name="name" id="name" class="form-control" value=""/>
                                <span class="textfieldRequiredMsg">*</span></span>


                            <div id="nameError" class="alert alert-block alert-danger fade in" style="display:none">
                                <button type="button" class="close pull-left" data-dismiss="alert" aria-hidden="true">×</button>
                                <h4>رسالة خطا</h4>
                                <p>هذا الاسم مستخدم من قبل</p>
                                <div class="clearfix"></div>
                            </div>
                        </div>
                    </div>

                    <!-- =================================================   -->
                    {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}"  class="form-control chossedays"   value="1" checked="" />
                        </div>
                        <div class="col-lg-1">
                            <input type="text"   class="form-control"  readonly  value="{$val}"/>
                            <input type="hidden" name="attendancedaynum_{$itr}"  value="{$key}"/>
                            <input type="hidden" name="attendancedayar_{$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="{$timeNowsum8}"/>
                        </div>
                    </div>
                    {capture assign=itr}{$itr+1}{/capture}
                    {/foreach}

                    <!-- =================================================   -->

                    <div class="form-group">
                        <label class="col-lg-3 control-label">عدد مرات التاخير المسموح بها </label>
                        <div class="col-lg-4">
                            <span id="numberOfCountsOfDelayAllowed">
                                <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-3 control-label">عدد دقائق التاخير المسموح بها </label>
                        <div class="col-lg-4">
                            <span id="numberOfMinutesOfDelayAllowed">
                                <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-3 control-label">عدد ايام الاجازات</label>
                        <div class="col-lg-4">
                            <span id="takeVacationDaysp">
                                <input type="text" name="takeVacationDays" id="takeVacationDays" class="form-control positivefloat"  required readonly=""  value="0" />
                                <span class="textfieldRequiredMsg">*</span></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-3 control-label">قيمة خصم الربع ساعة تاخير باذن</label>
                        <div class="col-lg-4">
                            <span id="quarterHourLateWithPermissionDisount">
                                <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-3 control-label">قيمة خصم النصف ساعة تاخير باذن</label>
                        <div class="col-lg-4">
                            <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-3 control-label">قيمة خصم الساعة تاخير باذن</label>
                        <div class="col-lg-4">
                            <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-3 control-label">قيمة خصم الساعة ونصف تاخير باذن</label>
                        <div class="col-lg-4">
                            <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-3 control-label">قيمة خصم الساعتين تاخير باذن</label>
                        <div class="col-lg-4">
                            <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 propbd">
                        <label class="col-lg-3 control-label">قيمة خصم اكثر من  ساعتين تاخير باذن</label>
                        <div class="col-lg-4">
                            <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-3 control-label">قيمة خصم ربع ساعة تاخير بدون اذن </label>
                            <div class="col-lg-4">
                                <span id="quarterHourLateWithoutPermissionDisount">
                                    <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-3 control-label">قيمة خصم النصف ساعة تاخير بدون اذن </label>
                        <div class="col-lg-4">
                            <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-3 control-label">قيمة خصم الساعة تاخير بدون اذن </label>
                        <div class="col-lg-4">
                            <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-3 control-label">قيمة خصم الساعة ونصف تاخير بدون اذن </label>
                        <div class="col-lg-4">
                            <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-3 control-label">قيمة خصم الساعتين تاخير بدون اذن </label>
                        <div class="col-lg-4">
                            <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 propbd">
                        <label class="col-lg-3 control-label">قيمة خصم اكثر من ساعتين تاخير بدون اذن </label>
                        <div class="col-lg-4">
                            <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-3 control-label">قيمة خصم النصف ساعة اذن</label>
                        <div class="col-lg-4">
                            <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-3 control-label">قيمة خصم الساعة اذن</label>
                        <div class="col-lg-4">
                            <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-3 control-label">قيمة خصم الساعة ونصف اذن</label>
                        <div class="col-lg-4">
                            <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 propbd">
                        <label class="col-lg-3 control-label">قيمة خصم الساعتين اذن</label>
                        <div class="col-lg-4">
                            <span id="twoHoursPermissionDisountsp">
                                <input type="text" name="twoHoursPermissionDisount" id="twoHoursPermissionDisount" class="form-control positivefloat" value=""/>
                                <span class="textfieldRequiredMsg">*</span></span>
                        </div>
                    </div>
                    <!-- =================================================   -->
                    <div class="form-group">
                        <label class="col-lg-3 control-label">اليوم الغياب باذن</label>
                        <div class="col-lg-4">
                            <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 propbd">
                        <label class="col-lg-3 control-label">اليوم الغياب بدون اذن</label>
                        <div class="col-lg-4">
                            <span id="dayAbsenceWithoutPermissionDisountsp">
                                <input type="text" name="dayAbsenceWithoutPermissionDisount" id="dayAbsenceWithoutPermissionDisount" class="form-control positivefloat" value=""/>
                                <span class="textfieldRequiredMsg">*</span></span>
                        </div>
                    </div>
                    <!-- =================================================   -->

                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="button"  class="btn btn-primary pull-left"  id="spbutton">حفظ الامر</button>
                        </div>
                    </div>


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




    </div>
</div>

{literal}
<script>
    var namesp = new Spry.Widget.ValidationTextField("namesp");
    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");

    $('#spbutton').live('click', function (e) {
        if ($('#spform').validate().form()) {
            //ckeck name
            var tableName = 'employeeAttendanceSystems';
            var inputName = 'name';
            var name = $("#" + inputName).val();
            $.ajax({
                url: 'checkRedundantNames.php?name=' + name + '&tablename=' + tableName,
                success: function (data) {
                    //alert(data);
                    if (data == '0')
                    {
                        $("#nameError").css("display", "none");
                        //return true;
                        var myForm = document.getElementById("spform");
                        var SS = Spry.Widget.Form.validate(myForm);
                        if (SS == true) {

                            if (!$('#spbutton').hasClass("processing"))
                            {
                                $('#spbutton').addClass("processing");
                                myForm.submit();
                                //$('#spbutton').unbind('click');
                            }
                        }

                    } else if (data == '1')
                    {
                        $("#" + inputName).val("");
                        $("#" + inputName).focus();
                        $("#nameError").css("display", "block");
                        return false;
                    }
                }});

        }
        else
        {
            e.preventDefault();
        }
    });
    $('body').on('change', '#attendancetime_1,#departuretime_1', function () {
        var attendancetime = $.trim($('#attendancetime_1').val());
        var departuretime = $.trim($('#departuretime_1').val());
        for(var i = 2; i < 8; i++)
        {
                $('#attendancetime_'+i).val(attendancetime);
                $('#departuretime_'+i).val(departuretime);
        }           
     });
     $('body').on('click', '.chossedays', function () {
            var checked_boxes = $('input.chossedays:not(":checked")').length // Always 0
            $('#takeVacationDays').val(checked_boxes);
 
     });
</script>
{/literal}

