<?php include("../secure.php"); ?>
<?php //session_start(); ?>
<!DOCTYPE html>
<?php

include('dbConfig.php');

//include('dbConfig.php');

//include('dbconnnn.php');
?>


     <!-- Required meta tags -->
  <meta charset="utf-8">


<html lang="en">
	<head>
	<!--link rel="stylesheet" type="text/css" href="css/fatawa_font.css"/--> 
	<!-- Font CSS -->
        <link rel="stylesheet" type="text/css" href="../../css/fatawa_font.css"/> 
        <!-- Font CSS -->
        
        		<!-- Bootstrap CSS -->
		<!--link rel="stylesheet" href="../../assets/css/bootstrap.rtl.min.css"-->
		

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
		<style>	
		.table {
			width: 100%;
			margin-bottom: 20px;
		}	
		
		.table-striped tbody > tr:nth-child(odd) > td,
		.table-striped tbody > tr:nth-child(odd) > th {
			background-color: #f9f9f9;
		}
		
		@media print{
			#print {
				display:none;
			}
		}
		@media print {
			#PrintButton {
				display: none; 
			}
		}
		
		@page {
			size: auto;   /* auto is the initial value */
			margin: 0;  /* this affects the margin in the printer settings */
		}
	</style>
	
	
  <style>	  
  table {
  border-collapse: collapse;
  width: 100%;
}

th, td {
  text-align: left;
  padding: 8px;
}

tr:nth-child(even) {background-color: #f2f2f2;}
</style>  

   <?php  $lang=$_GET['lang'];  
	
	$link_lang='lang='.$lang;
	
	?>
	

<?php
	if($lang=='ar'){
	?>


         <link rel="stylesheet" href="../../assets/css/bootstrap.rtl.min.css">
   
		<!-- Fontawesome CSS -->
        <link rel="stylesheet" href="../../assets/plugins/fontawesome/css/fontawesome.min.css">
    	<link rel="stylesheet" href="../../assets/plugins/fontawesome/css/all.min.css">

		<!-- Lineawesome CSS -->
        <link rel="stylesheet" href="../../assets/css/line-awesome.min.css">
		<link rel="stylesheet" href="../../assets/css/material.css">
		
		<!-- Fontawesome CSS -->
        <link rel="stylesheet" href="../../assets/css/font-awesome.min.css">
        
        <!-- Select2 CSS -->
		<link rel="stylesheet" href="../../assets/css/select2.min.css">
			<!-- Datetimepicker CSS -->
		<link rel="stylesheet" href="../../assets/css/bootstrap-datetimepicker.min.css">
		
		<!-- Datatable CSS -->
		<link rel="stylesheet" href="../../assets/css/dataTables.bootstrap4.min.css">
		
		<!-- Main CSS -->
        <link rel="stylesheet" href="../../assets/css/style.css">
             
             
             
             
        <?php }else{ ?>
            <link rel="stylesheet" href="../../assets_en/css/bootstrap.min.css">
   
		<!-- Fontawesome CSS -->
        <link rel="stylesheet" href="../../assets_en/plugins/fontawesome/css/fontawesome.min.css">
    	<link rel="stylesheet" href="../../assets_en/plugins/fontawesome/css/all.min.css">

		<!-- Lineawesome CSS -->
        <link rel="stylesheet" href="../../assets_en/css/line-awesome.min.css">
		<link rel="stylesheet" href="../../assets_en/css/material.css">
		
		<!-- Fontawesome CSS -->
        <link rel="stylesheet" href="../../assets_en/css/font-awesome.min.css">
		
		<!-- Datatable CSS -->
		<link rel="stylesheet" href="../../assets_en/css/dataTables.bootstrap4.min.css">
		
		<!-- Main CSS -->
        <link rel="stylesheet" href="../../assets_en/css/style.css">
        

            <?php } ?>
		
		 
     
</head>


	
	   <?php include("../languege_filee_hr.php"); ?> 

    
     
     
<body>
    	<?php 
	$company_id=$_GET['company_id'];
    $step_id=$_GET['step_id'];
    
    $date_from=$_GET['date_from'];
    $date_to=$_GET['date_to']; 

    $check_isset=$_GET['check_isset']; 
     $employ_id = $_GET["employ_id"];
     
      $employ_stat = $_GET["employ_stat"];
    $hr_print_employees = $_GET["hr_print_employees"];
     
     $todaydate = date("Y-m-d");
	?>
	
	
	 <?php include("../hr_permission.php");?>
	
 <?php 
    //================================================== 
     if($lang=='ar'){$main_company_name2='كـــــل الشركات'; 
    }else{ $main_company_name2='All Company';}
     
     if($company_id=='all_company'){
     $main_company_name=$main_company_name2;
         
     }else{
            $sql_m="SELECT * FROM main_company_tbl where company_id='$company_id' ";
          $result_m = $conn->query($sql_m);
           if ($result_m->num_rows > 0) {
          while($row_m = $result_m->fetch_assoc()) {
       if($lang=='ar'){$main_company_name=$row_m['company_name_ar'];}else{$main_company_name=$row_m['company_name_en'];} 
         // $company_name_ar=$row_m['company_name_ar']; 
         // $company_name_en=$row_m['company_name_en']; 
          $company_logo=$row_m['company_logo']; 
            }} 
            
     }
  ?>
  
  
  <?php 

	 
	if(ISSET($_POST['sav_btn'])){
	    
     date_default_timezone_set("Asia/Riyadh");
     $dd1=strtotime($date_from);
     $dd2=strtotime($date_to);
   $datediff = $dd2 - $dd1;
   $add_ayam=round($datediff / (60 * 60 * 24)+1);
   //echo $add_ayam ;
   


$from_date = new DateTime($date_from);
$to_date = new DateTime($date_to);
$i = 0;
for ($date = $from_date; $date <= $to_date; $date->modify('+1 day')) {
    $d = $date->format('l');
  if($d=="Friday"){
      $i++;
  }
}

 
 // صافي عدد الأيام
 
   $safy_ayam=$add_ayam-$i; 
     
	}     
     
	?>	
	
	
	 <?php 
                   
                    function getBetweenDates($startDate, $endDate) {
                        $rangArray = [];
                     
                        $startDate = strtotime($startDate);
                        $endDate = strtotime($endDate);
                     
                        for ($currentDate = $startDate; $currentDate <= $endDate; $currentDate += (86400)) {
                            $date = date('Y-m-d', $currentDate);
                            $rangArray[] = $date;
                        }
                     
                        return $rangArray;
                    }
                    $dates = getBetweenDates($date_from, $date_to);
                   //print_r($dates);
                   $ids_dates = join("','",$dates); 
                    ?>




	<!--h2>Marsa Logistics </h2-->

	
	<b style="color:blue;"></b>
	<?php
 date_default_timezone_set("Asia/Riyadh");
 $date=date('Y-m-d H:i:s');
 //echo $date;
 $main_system_id='2222';
 
  $wind=$_GET['wind']; //echo $wind;
  
  
  $yearr=$_GET['yearr'];
  
  
	?>
	

<!--center>	<b style="color:blue;float:left;" dir="rtl">Date  :
	 <?php  echo $date; ?>
	 <b>
	 </center-->

	
	
	
	 <?php
	$a=array();
    $sql_comv="SELECT * FROM waseet_company_user_tbl where system_id='$main_system_id' AND deleted='0'AND user_id='".$_SESSION['user_id']."' GROUP BY company_id ";
     $result_comv = $conn->query($sql_comv);
     if ($result_comv->num_rows > 0) {
      while($row_comv = $result_comv->fetch_assoc()) {
      $company_id_all=$row_comv['company_id']; //echo $company_id_all.'<br>';
     array_push($a,$company_id_all);
      // echo $_SESSION['user_id'].'<br>';
        }} 
      // print_r($a);
      ?>
	<?php //echo  $company_id.'<br>';
	//echo $main_system_id;
	 //echo $urow['user_type'];
	  $ids = join("','",$a); 
	  
	//  print_r($a);
	 
		?>  
	
	
	   <?php include("../hr_permission.php");?>
	
	

 
 
   	<!-- ========================main=title////======================================================================= -->

   <!--div class="card-header"style="box-shadow:2px 2px 5px lightgray;">
    <br> <br>
   
   <img src="../../assets/img/logo2_marsa.png" width="40" height="40" alt="">
   <h3 class="card-title mb-0"><?php echo $title_settlement_of_dues; ?>
   </h3>
   <br> <br>
   </div-->      
   
   <div class="card-header" style="box-shadow: 2px 2px 5px lightgray; display: flex; justify-content: space-between;height:70px;">
       
   <div style="display: flex; align-items: center;">
        <!--img src="../../assets/img/logo2_marsa.png" width="40" height="40" alt=""-->
        <h3 class="card-title mb-0">//<?php //echo $title_settlement_of_dues; ?>فروقات الحضور والإنصراف</h3>
    </div>
    <div style="display: flex; align-items: center;">
        <h3 class="card-title mb-0"><?php echo $other_title; ?></h3>
        <img src="../../assets/img/logo2_marsa.png" width="40" height="40" alt="">
    </div>
</div>

   
   
   
    <!-- ========================main=/title======================================================================= -->
   <br>
 
 
  	<!-- =========================title////======================================================================= -->

     <div class="card-header">
   <h4 class="card-title mb-0"><?php echo $yearr; ?></h4>
   </div>
   
    <!-- =========================/title======================================================================= -->

 
 
        
          <!-- ==============================/r========================================== -->                        
                    

						<div class="col-md-12">
							<div>
							    <div class="table-responsive">
						
						<div class="row">
						<div class="col-md-12 d-flex">
							<div class="card card-table flex-fill">
								<div class="card-header">
								</div>
								<div class="card-body">
									<div class="table-responsive">
										    <table clas="table table-striped mb-0 dataTable no-footer" class="table table-stripped mb-0 dataTable no-footer">
											<thead>
												<tr class="table-danger" style="font-size:12px; font-weight:bold;"> 
												<th>NO</th>
													<th style="text-align:center;"><?php echo $Employee_data; ?></th>
											    	<th style="text-align:center;"><?php //echo $Total_discount_hours; ?>/7.45</th>
													<th style="text-align:center;"><?php //echo $Total_discount_hours; ?> 7.45 / المبلغ   </th>

										          <th style="text-align:center;"><?php //echo $Total_discount_hours; ?>/8</th>
													<th style="text-align:center;"><?php //echo $Total_discount_hours; ?> 8  / المبلغ   </th>
											
													<th style="text-align:center;"><?php //echo $Total_discount_hours; ?>إجمالي الفارق</th>
										         	
										         	
												</tr>
											</thead>
											<tbody>
				    <?php 
				      $nommm=0;
				    date_default_timezone_set("Asia/Riyadh");
				    $days=+10;
				    $takherr = 0;
				   $inseraf_beforr=0;
                 
                         
                            $sql_c4_hd="SELECT employ_name_ar,employ_name_en,employ_id,dept_id,job_id,employee_number_fingerprint,basic_salary,housing_allowance,transportation_allowance,other_allowances,other_allowances_tow FROM hr_employ_tbl where (employ_stat='active_employ' or employ_stat='employ_action') ";
                            $result_c4_hd = $conn->query($sql_c4_hd);
                           if ($result_c4_hd->num_rows > 0) {
                           while($row_c4_hd = $result_c4_hd->fetch_assoc()) {
                                $takherr = 0;
                                 $inseraf_beforr=0;
                                 $takheer_h=0;
                                 $inseraf_beforr_h=0;
                                 
                            if($lang=='ar'){$employ_name_hd=$row_c4_hd['employ_name_ar'];}else{$employ_name_hd=$row_c4_hd['employ_name_en'];} 	
                            
                            $employ_id_hd=$row_c4_hd['employ_id'];
                            $employee_number_fingerprint=$row_c4_hd['employee_number_fingerprint'];
                            
                            $sum_salary_employ=$row_c4_hd['basic_salary']+$row_c4_hd['housing_allowance']+$row_c4_hd['transportation_allowance']+$row_c4_hd['other_allowances']+$row_c4_hd['other_allowances_tow'];
                           
                           $hours_sal_emp7=($sum_salary_employ/30)/7.45;
                          
                          $hours_sal_emp8=($sum_salary_employ/30)/8; 
                           
                           
                           
                           	   $sql_ws="SELECT * FROM hr_waseet_employ_shift_tbl where employ_id='$employ_id_hd' AND deleted='0' and waseet_stat='0'  ";
                          $result_ws = $conn->query($sql_ws);
                           if ($result_ws->num_rows > 0) {
                            while($row_ws = $result_ws->fetch_assoc()) { 
                             $modal_id=$row_ws['waseet_id'];
                             
                              $sql_sh="SELECT * FROM hr_shift_tbl where shift_id='".$row_ws['shift_id']."' AND hodoor_ghyab='0'  AND stop='0' AND deleted='0'   ";
                                 $result_sh = $conn->query($sql_sh);
                                 if ($result_sh->num_rows > 0) {
                                while($row_sh = $result_sh->fetch_assoc()) {
                               
                          $nommm++;

						   ?>  
						   

						<tr>

						    <td style="text-align:center;"><b><?php echo $nommm; ?></b></td>
						
							<td style="text-align:center;">
							<h2 class="table-avatar">
							
							<a class="avatar" clas="avatar avatar-xs" href="profile.html">
							<?php
							
						
                           
							$attach_link_hd=0;
                          $sql_ico_hd="SELECT * FROM hr_employ_attachments_tbl where employ_id='$employ_id_hd' AND att_name='employ_photo' AND  stop='0' AND deleted='0' ";
                          $result_icohd = $conn->query($sql_ico_hd);
                           if ($result_icohd->num_rows > 0) {
                            while($row_icohd = $result_icohd->fetch_assoc()) {
                              $attach_link_hd=$row_icohd['attach_link'];
                            }}
                            
                          
                             ?>  
                               <?php if($attach_link_hd==''){ ?>  
								<img alt="" src="../../assets/img/profiles/avatar-09.jpg">
								<?php }elseif($attach_link_hd!=''){ ?>
								<img alt="" src="../../../Shipping_Clearance_System/jquery/pages/system_maintenance/user_img/<?php echo $attach_link_hd; ?>">
							<?php }else{ ?>
							<img alt="" src="../../assets/img/profiles/avatar-09.jpg">
							<?php } ?>
								
								</a>
							
						  <?php echo $employ_name_hd; ?>
							  </h2>
							  
							  <br>
							  
							  <?php 
                              if($lang=='ar'){$shift_name=$row_sh['shift_name_ar'];}else{$shift_name=$row_sh['shift_name_en'];}
                              $min_start_time=$row_sh['min_start_time'];
                               $min_end_time=$row_sh['min_end_time'];
                                $end_time=$row_sh['end_time'];
                                  
                                  
                                  $max_start_time1=$row_sh['max_start_time'];
                                 $allowed_minutes=$row_sh['allowed_minutes'];
                                $ddate = strtotime("+$allowed_minutes minutes", strtotime($max_start_time1));
                                  $max_start_time = date('h:i', $ddate);
                                  $number_hours = $row_sh['number_hours_calculated'];
                                 //echo $max_start_time;
                                 //$num_hour_init = ($number_hours * 60);
                                 
                             
							 
							 ?>
							 <small style="font-size:12px;">اقصى وقت للحضور / <?php echo $max_start_time;  ?></small><br>
							 
						 <small style="font-size:12px;"><?php echo $shift_name;  ?></small><br>
						<small style="font-size:12px;"><?php echo $min_start_time; ?>-<?php echo $start_time; ?>-<?php echo $max_start_time; ?></small><br>
						<small style="font-size:12px;"><?php echo $min_end_time; ?>-<?php echo $end_time; ?>-<?php echo $max_end_time; ?></small>
	  
							  
							  
							</td>
							
							
							 <!--td>

							 </td-->  
							 

							<td style="text-align:center;">
							
                              <small> 7.45  /</small>  
							 <small>= <?php echo  round($hours_sal_emp7,2); ?></small>
							    
							<br>  	<br>  
							    
							<h4>      
	                     <?php 
	                      $add_hours_emp_all=0;
                              $sql_kk = "SELECT * FROM hr_takeed_hodor_ensraf_tbl WHERE  employ_id='".$row_c4_hd['employ_id']."'  AND YEAR(date_from)='$yearr'  ";
                              $result_kk = $conn->query($sql_kk);
                              if ($result_kk->num_rows > 0) {
                              while($row_kk = $result_kk->fetch_assoc()) { 

                                $add_hours_emp_all+=$row_kk['khasem_from_salary'];  
                              }}
                              

                             $hours7=$add_hours_emp_all/$hours_sal_emp7;
                              echo  round($hours7,2);    
	                     ?>
	                     
	                      
							</h4> 	
							
							<?php echo $hour; ?>
							
							
						   </td>

							<td style="text-align:center;">
					            <h4> 
					            <?php
					            
					            
					            
					            echo round($add_hours_emp_all,2); ?>   </h4> 
							
								h1
							
								</td>				
								
								
								
								  <td style="text-align:center;">
								      
				      							
                            <small>   8 / </small>  
							 <small>= <?php echo  round($hours_sal_emp8,2); ?></small>
							    
                             <br><br>
								      								      
								  <h4>  
								  <?php 
								  
								     $hours8=$add_hours_emp_all/$hours_sal_emp7;
                                      echo  round($hours8,2);    
								  ?>    
								  </h4>   
								      
						        	<?php echo $hour; ?>

		                           </td>
						   
						   
						  
						            <td style="text-align:center;">
						         <small></small><br>

						                <h4>  
						             <?php 
						             $khasm88=$hours8*$hours_sal_emp8;
						             
						             echo  round($khasm88,2);
						             
						             ?>
						            
						             </h4>    
						             	h2
		                           </td>
					 	   
						    
						   
						    <td style="text-align:center;">
					  <h4>  <?php $fark=$add_hours_emp_all-$khasm88; echo round($fark,2); ?>
		  	            
		  	            
		  	            <?php $all_fark+=$fark; ?><h4>
		  	            
		  	            
						  </td>
						   
						   
												</tr>
												<?php }}  }} }}  ?>
											
											</tbody>
										</table>
									</div>
								</div>
								<div class="card-footer">
									<b style="font-size:18px;"><?php echo $The_total_amount; ?> / <?php echo round($all_fark,2); ?></b>
								</div>
							</div>
						</div>
						</div>
			
				<!-- ==========================================/==ملخص الحضور والإنصراف========================================================== -->


				<!-- ==============================================تفاصيل الطلب  =================================== -->	
			
			
	
 
<br />

    
</div>


<!-- Footer -->
		<?php include("../footer_print.php"); ?>
		<!-- /Footer -->
		
		


	<center><button id="PrintButton" onclick="PrintPage()">Print</button></center>
</body>
<script type="text/javascript">
	function PrintPage() {
		window.print();
	}
	document.loaded = function(){
		
	}
	window.addEventListener('DOMContentLoaded', (event) => {
   		PrintPage()
		setTimeout(function(){ window.close() },750)
	});
</script>




	 <!-- jQuery -->
        <script src="../../assets/js/jquery-3.6.0.min.js"></script>

        <!-- Feather Icon JS -->
        <script src="../../assets/js/feather.min.js"></script>

        <!-- Slimscroll JS -->
        <script src="../../assets/js/jquery.slimscroll.min.js"></script>

        <!-- Datatable JS -->
        <script src="../../assets/js/jquery.dataTables.min.js"></script>
        <script src="../../assets/js/dataTables.bootstrap4.min.js"></script>
        
        <!-- Bootstrap Core JS -->
        <script src="../../assets/js/bootstrap.bundle.min.js"></script>

        <!-- Custom JS -->
        <script src="../../assets/js/script.js"></script>
      

		 <!-- Theme Settings JS -->
		<script src="../../assets/js/layout.js"></script>
		<script src="../../assets/js/theme-settings.js"></script>
		
		<!-- Select2 JS -->
		<script src="../../assets/js/select2.min.js"></script>
		
		<!-- Datetimepicker JS -->
		<script src="../../assets/js/moment.min.js"></script>
		<script src="../../assets/js/bootstrap-datetimepicker.min.js"></script>
		
		
			 <!-- Theme Settings JS -->
	

		<script src="../../assets/js/greedynav.js"></script>
		<!-- Custom JS -->
		<!--script src="../../assets/js/app.js"></script-->

		<!-- Custom JS -->
		<!--script src="../../assets/js/app.js"></script-->
		
		<script src="../script_lang.js"></script> 
		
		  <!-- Alertify JS -->
		<script src="../../assets/plugins/alertify/alertify.min.js"></script>
		<!--script src="../../assets/plugins/alertify/custom-alertify.min.js"></script-->
        <!-- /Alertify JS -->
		
		
		







</html>


