<?php include("../secure.php"); ?>
<!DOCTYPE html>
<html lang="en" data-layout="vertical" data-topbar="light" data-sidebar="dark" data-sidebar-size="lg" data-sidebar-image="none">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
        <meta name="description" content="Smarthr - Bootstrap Admin Template">
		<meta name="keywords" content="admin, estimates, bootstrap, business, corporate, creative, management, minimal, modern, accounts, invoice, html5, responsive, CRM, Projects">
        <meta name="author" content="Dreamguys - Bootstrap Admin Template">
        <meta name="robots" content="noindex, nofollow">
        <title>Dept - HR Marsa System </title>
                <style>
@font-face {
    font-family: 'DroidSansArabic';
    src: url('../../font/DroidSansArabic.ttf');
}
body * {
    font-family: "DroidSansArabic", sans-serif ;
}
    </style>
		<?php 
	$lang=$_GET['lang'];  
    $link_lang='lang='.$lang;
    $company_id=$_GET['company_id']; 
    $main_system_id='2222';
    
	?> 
	
	 <?php include("../languege_filee_hr.php");?>
	 
	 <?php include("../hr_permission.php");?>
     <?php include("../Function/level_salf.php");?>
		<!-- Favicon -->
        <link rel="shortcut icon" type="image/x-icon" href="../../assets/img/favicon.png">
        
        <link rel="stylesheet" href="../../assets/plugins/alertify/alertify.min.css">
        
		<?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">
		
		<!-- 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>
    <body>
		<!-- Main Wrapper -->
        <div class="main-wrapper">
		
			<!-- Toper -->
            <?php include("../toper.php"); ?>
			<!-- /Toper -->
			
			<!-- header -->
            <?php include("../header.php");?>
			
			<!-- /header -->
			
			
				<!-- permission View -->
	<?php //if(($urow['user_type']=='Top_Manager' or $urow['user_type']=='System_Manager')or($hr_add_dept==1)){ ?>			
					<!-- /permission View -->
		
		
			
			<!-- Page Wrapper -->
            <div class="page-wrapper">
			
				<!-- Page Content -->
                <div class="content container-fluid">
				
					<!-- Page Header -->
					<div class="page-header">
						<div class="row align-items-center">
							<div class="col">
                                <?php 
                                if($lang=='ar'){$employy_solf="سلف الموظفين";}else{$employy_solf="Employee Advance";}
                                if($lang=='ar'){$employy_connectsolf="ربط الموظفين بحسابات السلف";}else{$employy_connectsolf="Connect Employy with Advance Account";}
                                if($lang=='ar'){$salf_request="طلب سلفه";}else{$salf_request="Advance Request";}
                                ?>
								<h3 class="page-title"><?php echo $employy_solf; ?></h3>
								<ul class="breadcrumb">
									<li class="breadcrumb-item"><a href="../main/index.php?<?php echo $link_lang; ?>&company_id=<?php echo $company_id; ?>"><?php echo $Dashboard; ?></a></li>
									<li class="breadcrumb-item active"><?php echo $employy_solf; ?></li>
								</ul>
							</div>
							<div class="col-auto float-end ms-auto">
							 <?php include("hr_connectEmploySolf_account_modal.php");?>
							 <?php include("Salf_Request_modal.php");?>
                             <a href="#" class="btn add-btn" data-bs-toggle="modal" data-bs-target="#add_salf_request"><i class="fa fa-plus"></i><?php  echo $salf_request; ?></a>
							 <?php 
							
							 if(($urow['user_type']=='Top_Manager' or $urow['user_type']=='System_Manager')or $connect_employ_solf=='1'){ ?>
								<a href="#" class="btn add-btn" data-bs-toggle="modal" data-bs-target="#add_department"><i class="fa fa-plus"></i><?php  echo $employy_connectsolf; ?></a>
							<?php }else{ ?>
							
							<?php }  ?>
                           
							</div>
						</div>
					</div>
					<!-- /Page Header -->
					<div class="card">
						<div class="card-body">
							<?php 
                            if($lang=='ar'){$salf_request="طلبات السلف";}else{$salf_request="Employee Advance Request";}
                            if($lang=='ar'){$Confirmed_advances=" السلف المؤكده";}else{$Confirmed_advances="Confirmed advances";}
                            if($lang=='ar'){$Rejected_advances="السلف المرفوضة";}else{$Rejected_advances="Employee Advance Request";}
                            ?>
							<ul class="nav nav-tabs nav-tabs-solid nav-justified">
		                       <li class="nav-item"><a class="nav-link a active" id="salf_request" href="#" ><?php echo $salf_request;?></a></li>
                               <li class="nav-item"><a class="nav-link a "  id="Confirmed_advances" href="#" ><?php echo $Confirmed_advances;?></a></li>
                               <li class="nav-item"><a class="nav-link a " id="Rejected_advances" href="#" ><?php echo $Rejected_advances;?></a></li>
                            </ul>
						</div>
					</div>
					<div class="row">
					    
		<div class="alert1" id="messages" style="font-family:'Tajawal',sans-serif;">
		    
         	   <?php if(isset($_SESSION['message'])): ?>
            <div class="alert3 alert3-success">
            <?php echo $_SESSION['message']; ?>
            <script>
    setTimeout(function() {
        let alert = document.querySelector(".alert3");
            alert.remove();
    }, 3000);
    </script>
           </div>
            <?php endif; ?>
           <?php unset($_SESSION['message']); ?></div>
			
			
			<?php
			   $modal_table_name='holidays_waseet_tbl';
              
                $id_name='holidays_waseet';
                  $proccess_details_delete='حذف العطله رقم '.$modal_id;
                   $proccess_details_en_delete='Delete Holiday Number'.$modal_id;
                  $proccess_details_delete_enable='تنشيط العطله رقم '.$modal_id;
                   $proccess_details_en_delete_enable='Enable Holiday Number'.$modal_id;
                  $proccess_details_delete_disable='الغاء تنشيط العطله رقم '.$modal_id;
                $proccess_details_en_delete_disable='Disable Holiday Number'.$modal_id;
               
                $proccess_details_enable=' تنشيط القسم رقم '.$modal_id;
                 $proccess_details_en_enable='Enable Holiday Number'.$modal_id;        
			
			?>		    
			<input type="hidden" name="modal_table_name" id="modal_table_name" readonly value="<?php echo $modal_table_name; ?>"> 
            <input type="hidden" name="id_name" id="id_name" readonly value="<?php echo $id_name; ?>"> 
           <input type="hidden" name="proccess_details_delete" id="proccess_details_delete" readonly value="<?php echo $proccess_details_delete; ?>"> 
           <input type="hidden" name="proccess_details_en_delete" id="proccess_details_en_delete" readonly value="<?php echo $proccess_details_en_delete; ?>">
           
           
              <input type="hidden" name="$proccess_details_delete_disable" id="proccess_details_delete_disable" readonly value="<?php echo $proccess_details_delete_disable; ?>"> 
           <input type="hidden" name="proccess_details_en_delete_disable" id="proccess_details_en_delete_disable" readonly value="<?php echo $proccess_details_en_delete_disable; ?>">
           
           
           <input type="hidden" name="proccess_details_enable" id="proccess_details_enable" readonly value="<?php echo $proccess_details_enable; ?>"> 
           <input type="hidden" name="proccess_details_en_enable" id="proccess_details_en_enable" readonly value="<?php echo $proccess_details_en_enable; ?>">
           
					    
						<div class="col-md-12">
							<div>
							    <div class="table-responsive">
							    <table class="table  datanew table-striped mb-0">
								<!--table class="table table-striped custom-table mb-0 datatable" -->
                                <thead>
										<tr>
                                    <?php 
                                        if($lang=='ar'){$employ_name="اسم الموظف";}else{$employ_name="employ_name";}
                                        if($lang=='ar'){$solaf_frmsmak_name="السلف من سماك";}else{$solaf_frmsmak_name="Advance from smak";}
                                        if($lang=='ar'){$solaf_name="السلفه";}else{$solaf_name="Advance";}
                                        if($lang=='ar'){$details="التفاصيل";}else{$details="details";}
                                        if($lang=='ar'){$solf_stat="الحاله";}else{$solf_stat="stat";}
									?>	
                                        <th><?php echo $id; ?></th>
											<th><?php echo $employ_name; ?></th>
                                            <th><?php echo $solaf_name; ?></th>
                                            <th><?php echo $details; ?></th>
                                            <th><?php echo $solf_stat; ?></th>
                                            <th>...</th>
										</tr>
									</thead>
									<tbody class="advance_body" id="salf_request" >
                                        <?php 

if(($urow['user_type']=='Top_Manager' or $urow['user_type']=='System_Manager')or($view_solaf_ul==1)){
    if($company_id=='all_company'){
        
           $sql_cw="SELECT * FROM hr_salf_tbl where  company_id IN ('$ids') AND company_id!='' AND deleted='0' and type='salf'";
            }else{
           $sql_cw="SELECT * FROM hr_salf_tbl where system_id='2222' and company_id='$company_id'AND company_id!='' AND deleted='0' and type='salf'";
            }
            
           }else{
            
                $sql_cw="SELECT * FROM hr_salf_tbl where company_id!='' AND deleted='0' and type='salf'";  
         
           }
              
                  
                        $result_cw = $conn->query($sql_cw);
                        if ($result_cw->num_rows > 0) {
                          while($row_cw = $result_cw->fetch_assoc()) { ?>
                           <input type="text" name="companyid" id="companyid<?php echo $row_cw["id"]; ?>" value="<?php echo $row_cw["company_id"]; ?>">   
                       <?php 
                    $sql_emp="SELECT * FROM hr_employ_tbl where employ_id='".$row_cw['employ_id']."' and employ_stat='active_employ' and stop='0' and deleted='0'";
                     $result_emp = $conn->query($sql_emp);
                      if ($result_emp->num_rows > 0) {
                       while($row_emp = $result_emp->fetch_assoc()) {
                        if($lang=='ar'){$employ_name=$row_emp['employ_name_ar'];}else{$employ_name=$row_emp['employ_name_en'];}
                         $employ_id = $row_emp["employ_id"];
                       }}
                       /*$salf_stat_count = countsalfStat($row_cw["id"]);
                       echo $salf_stat_count."</br>";
                       */
                       $salf_level = salf_level($row_cw['id']);
                       echo $salf_level."</br>";
                       $refuselevel = refuselevel($salf_level,$row_cw["company_id"]);
                       echo $refuselevel."</br>";
                       $employy_approval = getemployacceptid($salf_level,$row_cw["company_id"]);
                       $employy_refuse = getemployacceptid($refuselevel,$row_cw["company_id"]);
                       $em_dept = employ_dept($row_cw['employ_id']);
                       echo $em_dept."</br>";
                       $dept_manager = dept_manager($em_dept);
                       $checkifleveldeptmanager = checkifleveldeptmanager($salf_level,$row_cw["company_id"]);
                       echo $row_cw["company_id"]."</br>";
                       echo $dept_manager; 
                       $promotionEmploy = promotionEmploy($row_cw["company_id"]);
                       ?>
                      <?php if ((in_array($urow['user_id'],$employy_approval) or ($row_cw["employ_id"]==$urow['user_id']) ) && $row_cw["stat"]==2) { ?>
                        <tr class="D<?php echo $row_cw["id"]; ?>">
                        <td>
							<?php echo $row_cw["id"]; ?><br><b style="color:red;"></b>
								
							</td>
											
											<td>
                                           
											<?php  
											echo $employ_name; ?>
											</td>
                                            <?php
                                                /*$daenn = 0;
                                                $madenn = 0;
                                                $rasedd = 0;
                                                $sql_daily_restt="SELECT * FROM daily_restriction_tbl where account_number='".$row_cw["account_number"]."'";
                                                $result_daily_ress = $conn->query($sql_daily_restt);
                                                if ($result_daily_ress->num_rows > 0) {
                                                while($row_daily_restt = $result_daily_ress->fetch_assoc()) {
                                                    $daenn = $daenn + $row_daily_restt["daen"];
                                                    $madenn = $madenn + $row_daily_restt["maden"];
                                                    $rasedd = $daenn - $madenn;
                                                }}
                                                if($rasedd>=0){?>
                                                <a href="Employee_Advance_details.php?account_number=<?php echo $accont_number;?>"><?php echo round($rasedd);?></a>
                                                    
                                               <?php }else{ ?>
                                                <a href="Employee_Advance_details.php?account_number=<?php echo $accont_number;?>"><?php echo round($rasedd) * -1;?></a>
                                                   
                                               <?php  } */?>
                                           
											<td>
                                               <?php echo $row_cw["maden"];?>
                                               <input type="hidden" name="amount" id="amount<?php echo $row_cw["id"];?>" value="<?php echo $row_cw["maden"]; ?>">
                                            </td>
											<td><?php echo $row_cw["details"];?></td>
                                            <td><?php 
                                             if($lang=='ar'){$stat_detail=$row_cw['detailsar'];}else{$stat_detail=$row_cw['detailsen'];}
                                             if($lang=='ar'){$accept="موافقه";}else{$accept="accept";}
                                             if($lang=='ar'){$refuse="رفض";}else{$refuse="refuse";}
                                            
                                            echo $stat_detail;?>
                                             <input type="hidden" name="employy_id" id="employy_id<?php echo $row_cw["id"];?>" value="<?php echo $row_cw["employ_id"]; ?>">
                                               
                                        </td>
                                        <td>
                                        <?php if(in_array($urow['user_id'],$employy_approval)){?>
                                            <button class="btn_approve" id="<?php echo $row_cw['id']?>"><?php echo $accept."".$row_cw["level"];?></button>
                                       
                                        <button class="btn_refuse" id="<?php echo $row_cw['id']?>"><?php echo $refuse."".$row_cw["level"];?></button>
                                        <?php } ?>
                                        </td>
                                        <?php  }elseif(($row_cw["employ_id"]==$urow['user_id']) && $row_cw["stat"]=="3"){ ?>
                                            <td>
							<?php echo $row_cw["id"]; ?><br><b style="color:red;"></b>
								
							</td>
											
											<td>
                                               
											<?php  
											echo $employ_name; ?>
											</td>
                                            <?php
                                                /*$daenn = 0;
                                                $madenn = 0;
                                                $rasedd = 0;
                                                $sql_daily_restt="SELECT * FROM daily_restriction_tbl where account_number='".$row_cw["account_number"]."'";
                                                $result_daily_ress = $conn->query($sql_daily_restt);
                                                if ($result_daily_ress->num_rows > 0) {
                                                while($row_daily_restt = $result_daily_ress->fetch_assoc()) {
                                                    $daenn = $daenn + $row_daily_restt["daen"];
                                                    $madenn = $madenn + $row_daily_restt["maden"];
                                                    $rasedd = $daenn - $madenn;
                                                }}
                                                if($rasedd>=0){?>
                                                <a href="Employee_Advance_details.php?account_number=<?php echo $accont_number;?>"><?php echo round($rasedd);?></a>
                                                    
                                               <?php }else{ ?>
                                                <a href="Employee_Advance_details.php?account_number=<?php echo $accont_number;?>"><?php echo round($rasedd) * -1;?></a>
                                                   
                                               <?php  } */?>
                                           
											<td>
                                               <?php echo $row_cw["maden"];?>
                                               <input type="hidden" name="amount" id="amount<?php echo $row_cw["id"];?>" value="<?php echo $row_cw["maden"]; ?>">
                                            </td>
											<td><?php echo $row_cw["details"];?></td>
                                            <td><?php 
                                             if($lang=='ar'){$stat_detail=$row_cw['detailsar'];}else{$stat_detail=$row_cw['detailsen'];}
                                             if($lang=='ar'){$accept="موافقه";}else{$accept="accept";}
                                             if($lang=='ar'){$refuse="رفض";}else{$refuse="refuse";}
                                             if($lang=='ar'){$promotion="ترقية للمدير العام";}else{$promotion="promotion_to_general manager";}
                                            echo $stat_detail;?>
                                             <input type="hidden" name="employy_id" id="employy_id<?php echo $row_cw["id"];?>" value="<?php echo $row_cw["employ_id"]; ?>">
                                               
                                        </td>
                                        <td>
                                        <?php 
                                        if(($row_cw["employ_id"]==$urow['user_id']) && $row_cw["stat"]=="3"){ ?>
                                       <button class="btn_promotion_to_general_manager" id="<?php echo $row_cw['id']?>"><?php echo $promotion."".$row_cw["level"];?></button>
                                       <?php  }else{ ?>
                                            
                                       <?php } ?>
                                        
                                       
                                        </td>
                        <?php }elseif((in_array($urow['user_id'],$promotionEmploy ) or ($row_cw["employ_id"]==$urow['user_id']) ) && $row_cw["stat"]=="4") { ?>
                            <td>
							<?php echo $row_cw["id"]; ?><br><b style="color:red;"></b>
								
							</td>
											
											<td>
                                               
											<?php  
											echo $employ_name; ?>
											</td>
                                            <?php
                                                /*$daenn = 0;
                                                $madenn = 0;
                                                $rasedd = 0;
                                                $sql_daily_restt="SELECT * FROM daily_restriction_tbl where account_number='".$row_cw["account_number"]."'";
                                                $result_daily_ress = $conn->query($sql_daily_restt);
                                                if ($result_daily_ress->num_rows > 0) {
                                                while($row_daily_restt = $result_daily_ress->fetch_assoc()) {
                                                    $daenn = $daenn + $row_daily_restt["daen"];
                                                    $madenn = $madenn + $row_daily_restt["maden"];
                                                    $rasedd = $daenn - $madenn;
                                                }}
                                                if($rasedd>=0){?>
                                                <a href="Employee_Advance_details.php?account_number=<?php echo $accont_number;?>"><?php echo round($rasedd);?></a>
                                                    
                                               <?php }else{ ?>
                                                <a href="Employee_Advance_details.php?account_number=<?php echo $accont_number;?>"><?php echo round($rasedd) * -1;?></a>
                                                   
                                               <?php  } */?>
                                           
											<td>
                                               <?php echo $row_cw["maden"];?>
                                               <input type="hidden" name="amount" id="amount<?php echo $row_cw["id"];?>" value="<?php echo $row_cw["maden"]; ?>">
                                            </td>
											<td><?php echo $row_cw["details"];?></td>
                                            <td><?php 
                                             if($lang=='ar'){$stat_detail=$row_cw['detailsar'];}else{$stat_detail=$row_cw['detailsen'];}
                                             if($lang=='ar'){$accept="موافقه";}else{$accept="accept";}
                                             if($lang=='ar'){$refuse="رفض";}else{$refuse="refuse";}
                                             if($lang=='ar'){$promotion="ترقية للمدير العام";}else{$promotion="promotion_to_general manager";}
                                            echo $stat_detail;?>
                                             <input type="hidden" name="employy_id" id="employy_id<?php echo $row_cw["id"];?>" value="<?php echo $row_cw["employ_id"]; ?>">
                                               
                                        </td>
                                        <td>
                                        <?php 
                                        if(in_array($urow['user_id'],$promotionEmploy )){ ?>
                                        <button class="btn_approve_fromManager" id="<?php echo $row_cw['id']?>"><?php echo $accept;?></button>
                                        
                                        <button class="btn_refuse_fromManager" id="<?php echo $row_cw['id']?>"><?php echo $refuse;?></button>
                                       <?php  }else{ ?>
                                            
                                       <?php } ?>
                                        
                                       
                                        </td>
                     <?php }elseif(($checkifleveldeptmanager=="dept_manager")&& (($dept_manager==$urow['user_id'])or($row_cw["employ_id"]==$urow['user_id'])) && $row_cw["stat"]==0){ ?>
                      
											
											<td>
											  <?php echo $row_cw["id"]; ?><br><b style="color:red;"></b>
								
											</td>
											
											<td>
                                               
											<?php  
											echo $employ_name; ?>
											</td>
                                            <?php
                                                /*$daenn = 0;
                                                $madenn = 0;
                                                $rasedd = 0;
                                                $sql_daily_restt="SELECT * FROM daily_restriction_tbl where account_number='".$row_cw["account_number"]."'";
                                                $result_daily_ress = $conn->query($sql_daily_restt);
                                                if ($result_daily_ress->num_rows > 0) {
                                                while($row_daily_restt = $result_daily_ress->fetch_assoc()) {
                                                    $daenn = $daenn + $row_daily_restt["daen"];
                                                    $madenn = $madenn + $row_daily_restt["maden"];
                                                    $rasedd = $daenn - $madenn;
                                                }}
                                                if($rasedd>=0){?>
                                                <a href="Employee_Advance_details.php?account_number=<?php echo $accont_number;?>"><?php echo round($rasedd);?></a>
                                                    
                                               <?php }else{ ?>
                                                <a href="Employee_Advance_details.php?account_number=<?php echo $accont_number;?>"><?php echo round($rasedd) * -1;?></a>
                                                   
                                               <?php  } */?>
                                           
											<td>
                                               <?php echo $row_cw["maden"];?>
                                               <input type="hidden" name="amount" id="amount<?php echo $row_cw["id"];?>" value="<?php echo $row_cw["maden"]; ?>">
                                            </td>
											<td><?php echo $row_cw["details"];?></td>
                                            <td><?php 
                                             if($lang=='ar'){$stat_detail=$row_cw['detailsar'];}else{$stat_detail=$row_cw['detailsen'];}
                                             if($lang=='ar'){$accept="موافقه";}else{$accept="accept";}
                                             if($lang=='ar'){$refuse="رفض";}else{$refuse="refuse";}
                                            echo $stat_detail;?>
                                             <input type="hidden" name="employy_id" id="employy_id<?php echo $row_cw["id"];?>" value="<?php echo $row_cw["employ_id"]; ?>">
                                               
                                        </td>
                                        <td>
                                        <?php if($dept_manager==$urow['user_id']){?>
                                        <button class="btn_approve" id="<?php echo $row_cw['id']?>"><?php echo $accept."".$row_cw["level"];?></button>
                                        </br>
                                        <button class="btn_refuse" id="<?php echo $row_cw['id']?>"><?php echo $refuse."".$row_cw["level"];?></button>
                                        <?php } ?> 
                                        </td>
										
                                              
                      <?php  }else{ ?>

                     
                     <?php 
                        if ((in_array($urow['user_id'],$employy_approval ) or ($row_cw["employ_id"]==$urow['user_id']) ) && $row_cw["stat"]==0) {
                         
                      
                          ?> 
							    
                                        <tr class="D<?php echo $row_cw["id"]; ?>">
											
											<td>
											  <?php echo $row_cw["id"]; ?><br><b style="color:red;"></b>
								
											</td>
											
											<td>
                                               
											<?php  
											echo $employ_name; ?>
											</td>
                                            <?php
                                                /*$daenn = 0;
                                                $madenn = 0;
                                                $rasedd = 0;
                                                $sql_daily_restt="SELECT * FROM daily_restriction_tbl where account_number='".$row_cw["account_number"]."'";
                                                $result_daily_ress = $conn->query($sql_daily_restt);
                                                if ($result_daily_ress->num_rows > 0) {
                                                while($row_daily_restt = $result_daily_ress->fetch_assoc()) {
                                                    $daenn = $daenn + $row_daily_restt["daen"];
                                                    $madenn = $madenn + $row_daily_restt["maden"];
                                                    $rasedd = $daenn - $madenn;
                                                }}
                                                if($rasedd>=0){?>
                                                <a href="Employee_Advance_details.php?account_number=<?php echo $accont_number;?>"><?php echo round($rasedd);?></a>
                                                    
                                               <?php }else{ ?>
                                                <a href="Employee_Advance_details.php?account_number=<?php echo $accont_number;?>"><?php echo round($rasedd) * -1;?></a>
                                                   
                                               <?php  } */?>
                                           
											<td>
                                               <?php echo $row_cw["maden"];?>
                                               <input type="hidden" name="amount" id="amount<?php echo $row_cw["id"];?>" value="<?php echo $row_cw["maden"]; ?>">
                                            </td>
											<td><?php echo $row_cw["details"];?></td>
                                            <td><?php 
                                             if($lang=='ar'){$stat_detail=$row_cw['detailsar'];}else{$stat_detail=$row_cw['detailsen'];}
                                             if($lang=='ar'){$accept="موافقه";}else{$accept="accept";}
                                             if($lang=='ar'){$refuse="رفض";}else{$refuse="refuse";}
                                            echo $stat_detail;?>
                                             <input type="hidden" name="employy_id" id="employy_id<?php echo $row_cw["id"];?>" value="<?php echo $row_cw["employ_id"]; ?>">
                                               
                                        </td>
										<td>
                                        <?php if(in_array($urow['user_id'],$employy_approval )){?>
                                        <button class="btn_approve" id="<?php echo $row_cw['id']?>"><?php echo $accept."".$row_cw["level"];?></button>
                                       
                                        <button class="btn_refuse" id="<?php echo $row_cw['id']?>"><?php echo $refuse."".$row_cw["level"];?></button>
                                        <?php } ?>
                                        </td>
                                              
                                              <?php } ?>
                                              <?php   } ?>
											<?php }}else{ ?>
                                             
                                                <td></td>
                                                <td></td>
                                                <td><?php echo $notfound;?></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                            
                                           <?php } ?>
                                            </tr>
                                        
									</tbody>
								</table>
							</div>
						</div>
					</div>
                </div>
                	</div>
				<!-- /Page Content -->
				
			
				
				
				
				
				<!-- Edit Department Modal -->
				<div id="edit_department" class="modal custom-modal fade" role="dialog">
					<div class="modal-dialog modal-dialog-centered" role="document">
						<div class="modal-content">
							<div class="modal-header">
								<h5 class="modal-title">Edit Department</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>
									<div class="form-group">
										<label>Department Name <span class="text-danger">*</span></label>
										<input class="form-control" value="IT Management" type="text">
									</div>
									<div class="submit-section">
										<button class="btn btn-primary submit-btn">Save</button>
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
				
				
            </div>
			<!-- /Page Wrapper -->

        </div>
		<!-- /Main Wrapper -->
		
	 
		<!-- sitting -->
		<?php include("../setting.php"); ?>
	    <!-- /sitting -->

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

	 <!-- 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>

		<!-- 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 -->
		
		<script>
		var company_id = '<?php echo $company_id;?>';
		var lang = '<?php echo $_GET['lang'];?>';
		var user_id = '<?php echo $urow["user_id"];?>';
		$('.a').click(function() {
		    $("#loaderr").remove();
            $('.nav-link').removeClass('active');
            $(this).addClass('active');
			var id = $(this).attr('id');
          
			$('#advance_body').html('');
			$(this).append('<span class="spinner-border spinner-border-sm me-2" role="status" id="loaderr"></span>');
			
			$.ajax({
		url: "Show_Employee_Advanceonclick.php",
		type: "POST",
		data: {
			id: id,
			company_id:company_id,
			lang:lang,
            user_id:user_id
		},
		cache: false,
		success: function(dataResult){
		    $("#loaderr").fadeOut();
			$('#advance_body').attr('id',id);
			$('.advance_body').html(dataResult);	
		}
	});
			

        });
</script>
        <script>
  $(document).ready(function(e) {
   $(".btn_approve").click(function(){
    var id = $(this).attr('id');
    var lang = $("#lang").val();
    var employy_id = $("#add_user_id").val();
    var amount = $("#amount"+id).val();
    var add_user_id = $("#add_user_id").val();
    var company_id = $("#companyid"+id).val();
    //alert(amount);
    $.ajax({
    type: "POST",
    url: "hr_advance_accept_approvel.php",
    data: {
      id:id,lang:lang,employy_id:employy_id,amount:amount,add_user_id:add_user_id,company_id:company_id				
    },
    success: function(data) {
if(data == 1){
    alert("تمت عملية الموافقه بنجاح");
     window.location.reload();
}else{
    alert(data);
    alert("هناك خطاء الرجاء المحاوله مره اخرى");
}
     
    },
    error:function(data){
        
       alert(data); //===Show Error Message====
    }
    });

      });
      });
       </script>
         <script>
 
   $(".btn_refuse").click(function(){
    var id = $(this).attr('id');
    var lang = $("#lang").val();
    var employy_id = $("#add_user_id").val();
    var amount = $("#amount"+id).val();
    var add_user_id = $("#add_user_id").val();
    var company_id = $("#companyid"+id).val();
 alert(id);
 alert(company_id);
    $.ajax({
    type: "POST",
    url: "hr_advance_refuse.php",
    data: {
      id:id,lang:lang,employy_id:employy_id,amount:amount,add_user_id:add_user_id,company_id:company_id				
    },
    success: function(data) {
        alert(data);
if(data == 1){
    alert("تمت عملية الرفض بنجاح");
     window.location.reload();
}else{
    alert(data);
    alert("هناك خطاء الرجاء المحاوله مره اخرى");
}
     
    },
    error:function(data){
        
       alert(data); //===Show Error Message====
    }
    });

      });
      
       </script>
       <script>
 
 $(".btn_promotion_to_general_manager").click(function(){
  var id = $(this).attr('id');
  var lang = $("#lang").val();
  var employy_id = $("#add_user_id").val();
  var amount = $("#amount"+id).val();
  var add_user_id = $("#add_user_id").val();
  var company_id = $("#companyid"+id).val();
 alert(id);
 alert(company_id);
  $.ajax({
  type: "POST",
  url: "hr_promotion_to_general_manager.php",
  data: {
    id:id,lang:lang,employy_id:employy_id,amount:amount,add_user_id:add_user_id,company_id:company_id				
  },
  success: function(data) {
      alert(data);
if(data == 1){
  alert("تمت عملبة الترقيه بنجاح");
   window.location.reload();
}else{
  alert(data);
  alert("هناك خطاء الرجاء المحاوله مره اخرى");
}
   
  },
  error:function(data){
      
     alert(data); //===Show Error Message====
  }
  });

    });
    
     </script>
      <script>
  $(document).ready(function(e) {
   $(".btn_approve_fromManager").click(function(){
    var id = $(this).attr('id');
    var lang = $("#lang").val();
    var employy_id = $("#add_user_id").val();
    var amount = $("#amount"+id).val();
    var add_user_id = $("#add_user_id").val();
    var company_id = $("#companyid").val();
    //alert(amount);
    $.ajax({
    type: "POST",
    url: "hr_advance_approve_fromManager.php",
    data: {
      id:id,lang:lang,employy_id:employy_id,amount:amount,add_user_id:add_user_id,company_id:company_id				
    },
    success: function(data) {
if(data == 1){
    alert("تمت عملية الموافقه بنجاح");
     window.location.reload();
}else{
    alert(data);
    alert("هناك خطاء الرجاء المحاوله مره اخرى");
}
     
    },
    error:function(data){
        
       alert(data); //===Show Error Message====
    }
    });

      });
      });
       </script>
        <script>
  $(document).ready(function(e) {
   $(".btn_refuse_fromManager").click(function(){
    var id = $(this).attr('id');
    var lang = $("#lang").val();
    var employy_id = $("#add_user_id").val();
    var amount = $("#amount"+id).val();
    var add_user_id = $("#add_user_id").val();
    var company_id = $("#companyid").val();
    //alert(amount);
    $.ajax({
    type: "POST",
    url: "hr_advance_refuse_fromManager.php",
    data: {
      id:id,lang:lang,employy_id:employy_id,amount:amount,add_user_id:add_user_id,company_id:company_id				
    },
    success: function(data) {
if(data == 1){
    alert("تمت عملية الموافقه بنجاح");
     window.location.reload();
}else{
    alert(data);
    alert("هناك خطاء الرجاء المحاوله مره اخرى");
}
     
    },
    error:function(data){
        
       alert(data); //===Show Error Message====
    }
    });

      });
      });
       </script>
       	<script>
       	 var modal_table_name=$('#modal_table_name').val();
       	 var id_name=$('#id_name').val();
       	 var proccess_details_delete_disable=$('#proccess_details_delete_disable').val();
       	 var proccess_details_en_delete_disable=$('#proccess_details_en_delete_disable').val();
       	 
       	 var proccess_details_enable=$('#proccess_details_enable').val();
       	 var proccess_details_en_enable=$('#proccess_details_en_enable').val();
       	  
    $(".checktoggle").click(function(e){
        var id = $(this).attr('data-id');
        //alert(id);
        
           var id_check=$('#id_check').val(); 
        if(id_check==''){
      alertify.error(message_per);
        }else{
        
        if($('#user'+id).is(':checked') ){
      if(confirm(message_disabled)){
         //alert("Checkbox Is checked");
    $('#user'+id).prop('checked', true);
    
   //======================
      var add_user_id=$('#add_user_id').val();
      var company_id=$('#company_id').val();
      var g = $(this).attr('data-id');
      var date_did = $("#date_did"+g).val();
   //alert(g);
          $.post('../modals/hr_disabeld_code.php', {'g':g,'add_user_id':add_user_id,'company_id':company_id,'modal_table_name':modal_table_name,'id_name':id_name,'proccess_details_delete_disable':proccess_details_delete_disable,'proccess_details_en_delete_disable':proccess_details_en_delete_disable}, function(r) {
              //alert(r);
        if (r == 1) {
     //  alert("تمت العمليه بنجاح");
      alertify.error(message_success);
         // window.location.reload();
         $(".D"+i).css("background-color", "#ccc");
         $(".D"+i).fadeOut("slow");
       

               }
             });
             
      }else{
        return false;
      }
   
   //======================
}
else{
   // alert("Checkbox Is not checked");
    $('#user'+id).prop('checked', false);
     if(confirm(message_enabled)){
    
      //======================
      var add_user_id=$('#add_user_id').val();  
      var company_id=$('#company_id').val();
      var g = $(this).attr('data-id');
      var date_did = $("#date_did"+g).val();
  // alert(g);
          $.post('../modals/hr_enable_code.php', {'g':g,'add_user_id':add_user_id,'company_id':company_id,'modal_table_name':modal_table_name,'id_name':id_name,'proccess_details_enable':proccess_details_enable,'proccess_details_en_enable':proccess_details_en_enable}, function(r) {
             // alert(r);
        if (r == 1) {
     //  alert("تمت العمليه بنجاح");
   alertify.success(message_success);
         $(".D"+i).css("background-color", "#ccc");
         $(".D"+i).fadeOut("slow");
          window.location.reload();

               }
             });
             
      }else{
        return false;
      }
   
 }  //====================== 
    
}
    });
</script>
       
       
		
		
   <style>
.alert {
  text-align: center;
  padding: 10px;
  background: rgb(168, 240, 177);
  color: green;
  margin-bottom: 10px;
  display: none;
}
.alert3 {
  text-align: center;
  padding: 10px;
  background: rgb(168, 240, 177);
  color: green;
  margin-bottom: 10px;
  
}
.alert4 {
  text-align: center;
  padding: 10px;
  margin-bottom: 10px;
  border-color: #ebad30;
  font-size:18px;
}

</style>	
		
    </body>
</html>




