		<!-- Add Shift Modal -->
        <div id="add_shift" class="modal custom-modal fade" role="dialog">
				<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
					<div class="modal-content">
						<div class="modal-header">
							<h5 class="modal-title"><?php echo $Add_Shifts; ?></h5>
							<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
								<span aria-hidden="true">&times;</span>
							</button>
						</div>
						<div class="modal-body">
							 <form clas="cmxform" id="signupForm" method="post" action="add_shift_modal_code.php" enctype="multipart/form-data" > 
								<div class="row">
								    
		<div class="form-group">
			<input type="hidden" name="add_user_id" id="add_user_id" readonly value="<?php echo $urow['user_id']; ?>">
           	<input type="hidden" name="user_id_top_manager" id="user_id_top_manager" readonly value="<?php echo $user_id_top_manager; ?>">
           	 <input type="hidden" name="company_id" id="company_id" readonly value="<?php echo $company_id; ?>">
           	  <input type="hidden" name="system_id" id="system_id" readonly value="<?php echo $main_system_id; ?>"> 

           <input type="hidden" name="link_lang" id="link_lang" readonly value="<?php echo $link_lang; ?>">  
        <input type="hidden" name="lang" id="lang" readonly value="<?php echo $lang; ?>"> 
		   	<input type="hidden" name="messag_add" id="messag_add" readonly value="<?php echo $messag_add; ?>"> 
		   	 </div>
								    
				
			<div class="col-sm-12">			    
				<div class="form-group">
				<lable><?php echo $the_companyr; ?></lable>
				<select clas="select" name="company_id_sel" id="company_id_sel" class="form-select"required="">
                 <!--option value=""><?php echo $select.$space.$the_companyr; ?> </option-->
               <option value="all_company"><?php echo $company_title; ?> </option>
                    <?php
                         if($urow['user_type']=="System_Manager"){
                       $sql_com="SELECT * FROM waseet_company_user_tbl GROUP BY company_id ";
                         }else{
                     if($company_id=='all_company'){   
                        $sql_com="SELECT * FROM waseet_company_user_tbl where deleted='0'AND company_id IN ('$ids')GROUP BY company_id ";
                     }else{
                      $sql_com="SELECT * FROM waseet_company_user_tbl where deleted='0'AND company_id='$company_id' GROUP BY company_id ";
                     } 
                         }
                        $result_com = $conn->query($sql_com);
                        if ($result_com->num_rows > 0) {
                        while($row_com = $result_com->fetch_assoc()) {
                            
                        $sql_com1="SELECT * FROM main_company_tbl where deleted='0'AND  company_id='".$row_com['company_id']."' ";
                        $result_com1 = $conn->query($sql_com1);
                        if ($result_com1->num_rows > 0) {
                        while($row_com1 = $result_com1->fetch_assoc()) {
                          //  echo $row_com1['company_name_ar'];
                            if($lang=='ar'){$name_ar2=$row_com1['company_name_ar'];}else{$name_ar2=$row_com1['company_name_en'];}        
                            //  echo $name_ar2;
                          ?>
                   <option value="<?php echo $row_com1['company_id']; ?>"><?php echo $name_ar2; ?> </option>
					<?php  }} }}  ?>	
					</select>
					</div>  
					</div>   
					
					

										<div class="col-sm-12">
										<div class="form-group">
											<label class="col-form-label"><?php echo $The_name_of_the_shift_Arabic; ?> <span class="text-danger">*</span></label>
											<div class="input-group time">
												<input class="form-control" name="shift_name_ar" id="shift_name_ar" required=""><span class="input-group-text"><i class="fa fa-clock-o"></i></span>
											</div>
										</div>
									</div>
									
									
										<div class="col-sm-12">
										<div class="form-group">
											<label class="col-form-label"><?php echo $The_name_of_the_shift_english; ?> <span class="text-danger">*</span></label>
											<div class="input-group time">
												<input class="form-control" name="shift_name_en" id="shift_name_en" required=""><span class="input-group-text"><i class="fa fa-clock-o"></i></span>
											</div>
										</div>
									</div>

                                     	<div class="col-sm-12" >
                                     	    	<div class="form-group">
										<div class="custom-control form-check"style="background-color:rgba(255, 0, 0, 0.2);">
											<input style="width:20px;height:20px;"  type="checkbox" class="form-check-input" name="billed_for_absence" id="billed_for_absence">
											<label class="form-check-label" for="billed_for_absence"><?php echo $The_employee_is_billed_for_absence; ?></label>
										</div>
									</div>
									</div>
									
									
									  	<div class="col-sm-12">
                                     	    	<div class="form-group">
										<div class="custom-control form-check">
											<input style="width:20px;height:20px;"  type="checkbox" class="form-check-input" name="only_presence_and_absence" id="only_presence_and_absence">
											<label class="form-check-label" for="Only_presence_and_absence"><?php echo $Only_presence_and_absence; ?></label>
										</div>
									</div>
									</div>
									
									
									<div class="col-sm-12">
										<div class="custom-control form-check">
											<input style="width:20px;height:20px;"  type="checkbox" class="form-check-input" id="flexible_working" name="flexible_working">
											<label class="form-check-label" for="customCheck1"><?php echo $Flexible_Working; ?></label>
										</div>
									</div>
									<div class="col-md-4">
										<div class="form-group min_start_time" >
											<label><?php echo $Min_Start_Time; ?> <span class="text-danger">*</span></label>
											<div class="input-group time">
												<input type="time" name="min_start_time" id="min_start_time"  class="form-control tim" required=""><span class="input-group-text"><i class="fa fa-clock-o"></i></span>
											</div>
										</div>
									</div>
									<div class="col-md-4">
										<div class="form-group start_time">
											<label><?php echo $Start_Time; ?> <span class="text-danger">*</span></label>
											<div class="input-group time">
												<input type="time" name="start_time" id="start_time" class="form-control tim" required=""><span class="input-group-text"><i class="fa fa-clock-o"></i></span>
											</div>									
										</div>
									</div>
									<div class="col-md-4">
										<div class="form-group max_start_time">
											<label><?php echo $Max_Start_Time; ?> <span class="text-danger">*</span></label>
											<div class="input-group time">
												<input type="time" name="max_start_time" id="max_start_time" class="form-control tim" required=""><span class="input-group-text"><i class="fa fa-clock-o"></i></span>
											</div>											
										</div>
									</div>		
									<div class="col-md-4">
										<div class="form-group min_end_time">
											<label><?php echo $MinEndTime; ?> <span class="text-danger">*</span></label>
											<div class="input-group time">
												<input type="time" name="min_end_time" id="min_end_time" class="form-control tim" required=""><span class="input-group-text"><i class="fa fa-clock-o"></i></span>
											</div>
										</div>
									</div>
									<div class="col-md-4">
										<div class="form-group end_time">
											<label><?php echo $End_Time; ?> <span class="text-danger">*</span></label>
											<div class="input-group time">
												<input type="time" name="end_time" id="end_time" class="form-control tim" required=""><span class="input-group-text"><i class="fa fa-clock-o"></i></span>
											</div>									
										</div>
									</div>
									<div class="col-md-4">
										<div class="form-group max_end_time">
											<label><?php echo $Max_End_Time; ?> <span class="text-danger">*</span></label>
											<div class="input-group time">
												<input type="time" name="max_end_time" id="max_end_time" class="form-control tim" required=""><span class="input-group-text"><i class="fa fa-clock-o"></i></span>
											</div>											
										</div>
									</div>	
									
									<div class="col-md-4">
										<div class="form-group">
											<label class="col-form-label"><?php echo $working_hours; ?> <span class="text-danger">*</span></label>
											<div class="input-group time">
												<input class="form-control" name="number_hours" id="number_hours" required="" readonly><span class="input-group-text"><i class="fa fa-clock-o"></i></span>
											</div>
										</div>
									</div>
									
										<div class="col-md-4">
										<div class="form-group">
											<label class="col-form-label"><?php echo $allowed_minutes; ?> <span class="text-danger">*</span></label>
											<div class="input-group time">
												<input class="form-control" name="allowed_minutes" id="allowed_minutes" required=""><span class="input-group-text"><i class="fa fa-clock-o"></i></span>
											</div>
										</div>
									</div>
									
										<div class="col-md-4">
										<div class="form-group">
											<label class="col-form-label"><?php echo $The_number_of_hours_calculated; ?> <span class="text-danger">*</span></label>
											<div class="input-group time">
												<input class="form-control" name="number_hours_calculated" id="number_hours_calculated" required="" readonly><span class="input-group-text"><i class="fa fa-clock-o"></i></span>
											</div>
										</div>
									</div> 
									
									
									
									<div class="col-md-4">
										<div class="form-group">
											<label><?php echo $Break_Time; ?></label>
											<input type="text" value="0" name="break_time" id="break_time" class="form-control">											
										</div>
									</div>
									
									
										<div class="col-sm-12">
										<div class="form-group wday-box">
										    <label class="col-form-label"><?php echo $Working_days; ?> <span class="text-danger">*</span></label>
											<label class="checkbox-inline"><input name="sat" id="sat" style="width:20px;height:20px;" type="checkbox" value="1" class="days recurring" checked=""><span class="checkmark"><?php echo $sat; ?></span></label>
		
											<label class="checkbox-inline"><input name="sun" id="sun" style="width:20px;height:20px;" type="checkbox" value="1" class="days recurring" checked=""><span class="checkmark"><?php echo $sun; ?></span></label>
										
											<label class="checkbox-inline"><input name="mon" id="mon" style="width:20px;height:20px;" type="checkbox" value="1" class="days recurring" checked=""><span class="checkmark"><?php echo $mon; ?></span></label>
										
											<label class="checkbox-inline"><input name="tue" id="tue" style="width:20px;height:20px;" type="checkbox" value="1" class="days recurring" checked=""><span class="checkmark"><?php echo $tue; ?></span></label>
										
											<label class="checkbox-inline"><input name="we" id="we" style="width:20px;height:20px;" type="checkbox" value="1" class="days recurring" checked=""><span class="checkmark"><?php echo $we; ?></span></label>
										
											<label class="checkbox-inline"><input name="thu" id="thu" style="width:20px;height:20px;" type="checkbox" value="1" class="days recurring"checked=""><span class="checkmark"><?php echo $thu; ?></span></label>
										
											<label class="checkbox-inline"><input name="fr" id="fr" style="width:20px;height:20px;" type="checkbox" value="0" class="days recurring"><span class="checkmark"><?php echo $fr; ?></span></label>
										</div>
									</div>
									
									<!--div class="col-sm-12">
										<div class="form-group">
											<label class="col-form-label">Repeat Every</label>
											<select class="select">
												<option value="">1 </option>
												<option value="1">2</option>
												<option value="2">3</option>
												<option value="3">4</option>
												<option  selected value="4">5</option>
												<option value="3">6</option>
											</select>
											<label class="col-form-label">Week(s)</label>
										</div>
									</div-->
									
								
									
									
									<!--div class="col-sm-12">
										<div class="form-group">
											<label class="col-form-label">End On <span class="text-danger">*</span></label>
											<div class="cal-icon"><input class="form-control datetimepicker" type="text"></div>
										</div>
									</div-->
									
									
									<!--div class="col-sm-12">
										<div class="custom-control form-check">
											<input type="checkbox" class="form-check-input" id="customCheck2">
											<label class="form-check-label" for="customCheck2">Indefinite</label>
										</div>
									</div-->								
							
									<!--div class="col-md-12">
										<div class="form-group">
											<label>Add Tag </label>
											<input type="text" class="form-control">											
										</div>
									</div-->
									
									<div class="col-md-12">
										<div class="form-group">
											<label><?php echo $Notes; ?></label>
											<textarea name="notes" id="notes" class="form-control"></textarea>											
										</div>
									</div>
								</div>
								<div class="submit-section">
									<!--button class="btn btn-primary submit-btn">Submit</button-->
									 <input type="submit" name="sav_btn" id="sav_btn" style="display:non;" class="btn btn-primary submit-btn" value="<?php echo $save; ?>">
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
			<!-- /Add Shift Modal -->
			 <script src="../../assets/js/jquery-3.6.0.min.js"></script>
			 <script>
				$("#billed_for_absence").click(function(){
					if($('#billed_for_absence:checked').length){
            $('.tim').attr('readonly',true); //If checked - Read only
			$('#flexible_working').prop('checked', false);
			$('#flexible_working').attr("disabled", true);
			$('#only_presence_and_absence').attr("disabled", true);

			$("#billed_for_absence").val(1);
			$("#only_presence_and_absence").val(1);
			$('#only_presence_and_absence').prop('checked', true);
			
			$('#flexible_working').val(0);
        }else{
            $('.tim').attr('readonly',false);//Not Checked - Normal
			$('#flexible_working').attr("disabled", false);
			$('#only_presence_and_absence').attr("disabled", false);
			
			$("#only_presence_and_absence").val(0);
			$('#only_presence_and_absence').prop('checked', false);
			
			$("#billed_for_absence").val(0);
			$('#flexible_working').val(0);
        }
				});
			 </script>
			 
			 
			 	 <script>
				$("#only_presence_and_absence").click(function(){
					if($('#only_presence_and_absence:checked').length){
            $('.tim').attr('readonly',true); //If checked - Read only
			$('#flexible_working').prop('checked', false);
			$('#flexible_working').attr("disabled", true);
			$('#billed_for_absence').attr("disabled", true);

			$("#only_presence_and_absence").val(1);
			$('#flexible_working').val(0);
        }else{
            $('.tim').attr('readonly',false);//Not Checked - Normal
			$('#flexible_working').attr("disabled", false);
			$('#billed_for_absence').attr("disabled", false);
			$("#only_presence_and_absence").val(0);
			$('#flexible_working').val(0);
			
        }
				});
			 </script>
			 
			 <script>
				$("#flexible_working").click(function(){
				if($('#flexible_working:checked').length){
            $('.tim').attr('readonly',true); //If checked - Read only
			$('#only_presence_and_absence').prop('checked', false);
			$('#only_presence_and_absence').attr("disabled", true);
				$('#billed_for_absence').attr("disabled", true);
			$('#number_hours').attr("readonly", false);

			$("#only_presence_and_absence").val(0);
			$('#flexible_working').val(1);
        }else{
            $('.tim').attr('readonly',false);//Not Checked - Normal
			$('#only_presence_and_absence').attr("disabled", false);
				$('#billed_for_absence').attr("disabled", false);
			$('#number_hours').attr("readonly", true);

			$("#only_presence_and_absence").val(0);
			$('#flexible_working').val(0);
        }
				});
			 </script>
			 
			 
			 
			 
			 <Script>
				const convertTime12to24 = time12h => {
  const [time, modifier] = time12h.split(" ");
 
  let [hours, minutes] = time.split(":");
 
  if (hours === "12") {
    hours = "00";
  }
 
  if (modifier === "PM") {
    hours = parseInt(hours, 10) + 12;
  }
 
  return `${hours}:${minutes}`;
};
 
			 </script>
		   <script>
$('#sat').click(function(event) { 

            if(this.checked) { 
                var sat = $("#sat").val(1);  
              
            }else{
                 var sat = $("#sat").val(0); 
                 
            }
        });
        </script>
        <script>
        function timeToSeconds(time) {
    time = time.split(/:/);
    return time[0] * 3600 + time[1] * 60 + time[2];
}

            $(".time").focusout(function(){
				 var min_start_time = convertTime12to24($("#min_start_time").val());
                var start_time = convertTime12to24($("#start_time").val());
                var max_start_time = convertTime12to24($("#max_start_time").val());

                var min_end_time = convertTime12to24($("#min_end_time").val());
                var end_time = convertTime12to24($("#end_time").val());
				
                var max_end_time = convertTime12to24($("#max_end_time").val());
				var diff1 = ( new Date("1970-1-1 " + end_time) - new Date("1970-1-1 " + start_time) ) / 1000 / 60 / 60;
                var diff = Math.round(diff1);
				//alert(diff);
				if(isNaN(diff)) {
					
				}else{
					$("#number_hours").val(diff);
					//$("#number_hours_calculated").val(diff);
				}
				
                $("#new_pass2-error2").remove();
                if(start_time < min_start_time){
                   var message = "لا يمكن ان يكون وقت الحضور اصغر من اقل وقت للحضور";
                    //alert(message);
				
                  $("#start_time").val(""); 
                  $(".start_time").after("<span id='new_pass2-error2' style='color:red;font-size:12px;'>"+message+"</span>");
                }else if(max_start_time < start_time){
					var message ="لا يمكن ان يكون اقصى وقت للحضور اصغر من وقت الحضور";
                    //alert(message);
                    $("#max_start_time").val("");
					$(".max_start_time").after("<span id='new_pass2-error2' style='color:red;font-size:12px;'>"+message+"</span>");
                }else if(end_time < min_end_time){
					var message = "لا يمكن ان يكون وقت الانصراف اصغر من اقل وقت للانصراف"
					//alert(message);
                   $("#end_time").val("");
				   $(".end_time").after("<span id='new_pass2-error2' style='color:red;font-size:12px;'>"+message+"</span>");
                }else if(max_end_time < end_time){
					var message = "لا يمكن ان يكون اقصى وقت للانصراف اصغر من وقت الانصراف";
                    //alert(message);
                     $("#max_end_time").val("");
					 $(".max_end_time").after("<span id='new_pass2-error2' style='color:red;font-size:12px;'>"+message+"</span>");
                }else if(min_end_time <= max_start_time){
					var message = "لا يمكن ان يكون اقل وقت للانصراف اصغر او يساوي من اقصى وقت للحضور ";
					//alert(message);
                    $("#min_end_time").val("");
					$(".min_end_time").after("<span id='new_pass2-error2' style='color:red;font-size:12px;'>"+message+"</span>");
                }else{
                    //alert("f");
                }
            });
        </script>
        <script>
            $("#allowed_minutes").keyup(function(){
                var number_hours1 = parseFloat($("#number_hours").val());
                var number_hours = number_hours1 * 60;
                var allowed_minutes = parseFloat($("#allowed_minutes").val());
                var number_hours_calculated1 = number_hours - allowed_minutes;
                var number_hours_calculated = Math.floor(number_hours_calculated1 / 60) + '.' + number_hours_calculated1 % 60;
                $("#number_hours_calculated").val(number_hours_calculated);
            });
        </script>
        
			
			
			
			