<?php

  include("dbConfig.php");
header('Content-Type: text/html; charset=utf-8');


//115438  799562

    $employ_id=0;
    $dept_id=0;
    $job_id=0;
   $sql_e="SELECT * FROM hr_employ_tbl where employ_id='496474' ";
   $result_e = $conn->query($sql_e);
   if ($result_e->num_rows > 0) {
   while($row_e = $result_e->fetch_assoc()) {
       
  $employ_id=$row_e['employ_id'];
  $dept_id=$row_e['dept_id'];
  $job_id=$row_e['job_id'];
  
  
      if($lang=='ar'){$employ_name=$row_e['employ_name_ar'];}else{$employ_name=$row_e['employ_name_en'];} 

    $employ_name_ar = $row_e['employ_name_ar']; echo 'employ_name / '.$employ_name_ar.'<br>';
    $employ_name_en = $row_e['employ_name_en'];
    $employ_email = $row_e['employ_email'];
    $mobile_number = $row_e['mobile_number'];
    
    $id_num = $row_e['id_num'];  echo 'id_num / '.$id_num.'<br>';
    

   echo '<hr>';

    $employ_target = $row_e['employ_target']; echo 'employ_target / '.$employ_target;
  echo '<hr>';
    $last_date_commencement = $row_e['last_date_commencement']; echo 'last_date_commencement / '. $last_date_commencement;
  echo '<hr>';

    //-----------------------------------------------------
    $basic_salary = $row_e['basic_salary']; 
    
    echo 'basic_salary / '.$basic_salary.'<br>';
    
    $housing_allowance = $row_e['housing_allowance'];
    $transportation_allowance = $row_e['transportation_allowance'];
    $other_allowances = $row_e['other_allowances'];
    $other_allowances_tow = $row_e['other_allowances_tow'];

    $sum_sal_employ=$basic_salary+$housing_allowance+$transportation_allowance+$other_allowances+$other_allowances_tow;
    
    $allowances=$housing_allowance+$transportation_allowance+$other_allowances+$other_allowances_tow;  
    
    
    echo 'allowances / '. $allowances.'<br>';
    
    echo 'sum_sal_employ / '.$sum_sal_employ.'<br>';
    
    
    
    echo '<hr>';
    
    
    //====================================================================
    echo '<br>';
     //$today_date=date("Y-m-d"); echo $today_date;
     
     $today_date='2024-03-25'; echo $today_date;
     
    echo '<hr>';
    echo '<br>';
     //====================================================================
    
    
    $date_from='2024-03-01';
    $date_to='2024-03-31';
    
    $holiday_dates = array();

	    
     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; 
	
    
    echo 'add_ayammmmmmmmmmmmmm / '.$add_ayam.'<br>';
    
    echo 'safy_ayammmmmmmmmmmm / '.$safy_ayam.'<br>';
    
    
    $target_matloop=$safy_ayam*$employ_target;
    
    
    //====================================================================
    echo '<hr>';
    

    


  //-----------------------------hunger---------------------------------------------------------

include("dbConfig_old.php");

$sql244="SELECT * FROM new_employ_tb where id_num='$id_num'  ";
       $result244 = $conn2->query($sql244);
       if ($result244->num_rows > 0) {
       while($row244 = $result244->fetch_assoc()) { 
        
        $rider_id= $row244['rider_id'];  
           
  }}

}}


    echo '<hr>';


 
   
?>



 <?php 

  $summ_pp=0;
  $sqlhung1="SELECT * FROM driver_hunger_orders_tbl where rider_id ='1628634' AND(report_date between '$date_from' AND '$date_to') AND report_date!='0000-00-00' ORDER BY `driver_hunger_orders_tbl`.`report_date` ASC ";
  $resulthung1 = $conn2->query($sqlhung1);
  if ($resulthung1->num_rows > 0) {
    while($rowhung1 = $resulthung1->fetch_assoc()) {
       echo '<br>';  $number_orders_delivered=$rowhung1['number_orders_delivered'];  echo 'number_orders_delivered / '.$number_orders_delivered;
       
        $report_date=$rowhung1['report_date']; echo '<br>';
    
                                        $num_orders=$rowhung1["number_orders_delivered"];
                                        if($num_orders>1 && $num_orders<150){$p1=12.5; $summ_pp=$num_orders*$p1; echo round($summ_pp,2);
                                       //----------------------------------------------
                                        }elseif($num_orders>150 && $num_orders<300){$p2=13.5;
                                        $num_orders2=$num_orders-150; 
                                        $summ_pp11=(($num_orders-$num_orders2)*12.5);
                                        $summ_pp=($num_orders2*$p2)+$summ_pp11; 
                                        echo round($summ_pp,2);
                                        
                                        //-------------------------------------------
                                        }elseif($num_orders>300 && $num_orders<400){$p3=15.5;
                                        $num_orders3=$num_orders-300; 
                                        $summ_pp12=(($num_orders-$num_orders3)*13.5);
                                        $summ_pp=($num_orders3*$p3)+$summ_pp12; 
                                        echo round($summ_pp,2);
                                        
                                         //-------------------------------------------
                                        }elseif($num_orders>400 && $num_orders<550){$p4=16.5;
                                        $num_orders4=$num_orders-400; 
                                        $summ_pp13=(($num_orders-$num_orders4)*15.5);
                                        $summ_pp=($num_orders4*$p4)+$summ_pp13; 
                                        echo round($summ_pp,2);
                                        
                                           //-------------------------------------------
                                        }elseif($num_orders>550){$p5=18;
                                        $num_orders5=$num_orders-550; 
                                        $summ_pp14=(($num_orders-$num_orders5)*16.5);
                                        $summ_pp=($num_orders5*$p5)+$summ_pp14; 
                                        echo round($summ_pp,2);
                                        
                                        
                                       // }elseif($num_orders>300 && $num_orders<400){$p1=15.5;   
                                       // }elseif($num_orders>400 && $num_orders<550){$p1=16.5;   
                                       // }elseif($num_orders>550){$p1=18;   
                                        }else{ } 
                                        
                                        
                       echo '<br>';    
                       
                       
                       echo 'report_date / '.$report_date;
                          echo '<hr>';               
}}

?>




  

  














