<?php
include("dbConfig.php");
$id = $_POST["id"];
$employ_id = $_POST["employ_id"];
$hodor_ensraf_date = $_POST["hodor_ensraf_date"];
$mosala_type = $_POST["mosala_type"];
$hodor_time = $_POST["hodor_time"];
$ensraf_time = $_POST["ensraf_time"];

//--------------------------------------------
date_default_timezone_set("Asia/Riyadh");
$createdDate_Time = date("Y-m-d h:i:sa");
$createdDate = date("Y-m-d");
$createdTime = date("h:i:sa"); 
//--------------------------------------------
function GetSeriaother() {	
    $strings = '123456789';	
    $stringLength = strlen($strings);
    $newStrings = '';
    for ($i = 0; $i < 6; $i++) {
        $newStrings .= $strings[rand(0, $stringLength - 1)];
    }
    return $newStrings; 
}
$hodoor_ensraf_id = GetSeriaother();  


for($i=0;$i<count($id);$i++){
 
 if($_POST["mosala_type"][$i]=='hodor'){ 
  //$sql2 = "UPDATE  hr_add_hodor_ensraf_tbl SET hodor_time='".$_POST["hodor_time"][$i]."',id_num='".$_POST["id_num"][$i]."',hodoor_ensraf_date='$att_abs_date',hodoor_ensraf_type='$att_or_abs_or_late',hodoor_time='".$_POST["hodoor_time"][$i]."',ensraf_time='".$_POST["ensraf_time"][$i]."',updatedDate_time='$createdDate_Time',update_user_id='$user_id' where employ_id='".$_POST["id"][$i]."' AND hodoor_ensraf_date='$att_abs_date'  " ;                      
 
  $sql2 = "UPDATE  hr_add_hodor_ensraf_tbl SET hodor_time='".$_POST["hodor_time"][$i]."',hodor_ensraf_stat='1' where hodor_ensraf_id='".$_POST["id"][$i]."'  " ;                      

 }else{
  $sql2 = "UPDATE  hr_add_hodor_ensraf_tbl SET ensraf_time='".$_POST["ensraf_time"][$i]."',hodor_ensraf_stat='1' where hodor_ensraf_id='".$_POST["id"][$i]."'  " ;                      
 }

if ($conn->query($sql2) === TRUE) {
} else {
  echo "Error: " . $sql2 . "<br>" . $conn->error;
}

}
echo "1";
$conn->close();
?>



