<?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>
        
        <link href="fSelect.css" rel="stylesheet">
        	<link rel = "stylesheet" type = "text/css" href = "chosen.css" />
        
                <style>
@font-face {
    font-family: 'DroidSansArabic';
    src: url('../../font/DroidSansArabic.ttf');
}
body * {
    font-family: "DroidSansArabic", sans-serif ;
}
    </style>
    <style>
		.dropdown {
			position: relative;
			display: inline-block;
		}
		
		.dropdown-content {
			display: none;
			position: absolute;
			z-index: 1;
			background-color: #f9f9f9;
			min-width: 160px;
			box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
			padding: 12px 16px;
			border-radius: 5px;
		}
		
		.dropdown:hover .dropdown-content {
			display: block;
		}
		
		.dropdown-checkbox label {
			display: block;
			margin-bottom: 10px;
		}
		
		.dropdown-checkbox input[type="checkbox"] {
			margin-right: 10px;
		}
		
		.selected-items {
			margin-top: 10px;
			font-weight: bold;
		}
	</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");?>
     <?php include("../Function/salf_from_smak.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 -->
			
			<!-- 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'){$level_salf="مستويات السلف";}else{$employy_solf="Advance level";}
                                if($lang=='ar'){$add_level="إضافة مستوى";}else{$add_level="Add Level";}
                                if($lang=='ar'){$add_promolevel="إضافة مستوى الترقية";}else{$add_promolevel="Add Promotion level";}
                                ?>
								<h3 class="page-title"><?php echo $level_salf; ?></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 $level_salf; ?></li>
								</ul>
							</div>
							<div class="col-auto float-end ms-auto">
							
							
                            <?php include("hr_connectEmploySolf_account_modal.php");?>
                            
							 <?php 
							
							 if($urow['user_type']=='Top_Manager' or $urow['user_type']=='System_Manager'){ ?>
								
                                <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'){$prepare="تهيئة السلف";}else{$prepare="prepare levels";}
                            if($lang=='ar'){$acceptrefuselevel="تهيئة مستويات الموافقة والرفض";}else{$acceptrefuselevel="Accept Refuse advance";}
                            if($lang=='ar'){$promo="تهيئة مستويات الترقية";}else{$promo="promotion levels";}
                            if($lang=='ar'){$smak="تهيئة السلف من سماك";}else{$smak="Advance from smak";}
                        ?>
							<ul class="nav nav-tabs nav-tabs-solid nav-justified">
                            <li class="nav-item"><a class="nav-link a " href="hr_prepare_advance.php?<?php echo $link_lang; ?>&company_id=<?php echo $company_id;?>" ><?php echo $prepare;?></a></li>
		                       <li class="nav-item"><a class="nav-link a " href="hr_advance_Level.php?<?php echo $link_lang; ?>&company_id=<?php echo $company_id;?>" ><?php echo $acceptrefuselevel;?></a></li>
                               <li class="nav-item"><a class="nav-link a " href="hr_advance_promo.php?<?php echo $link_lang; ?>&company_id=<?php echo $company_id;?>" ><?php echo $promo;?></a></li>
                               <li class="nav-item"><a class="nav-link a active" href="hr_prepare_smakadvance.php?<?php echo $link_lang; ?>&company_id=<?php echo $company_id;?>" ><?php echo $smak;?></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">
								<!--table class="table table-striped custom-table mb-0 datatable" -->
                                <thead>
										<tr>
                                    <?php 
                                        if($lang=='ar'){$employ="الموظف";}else{$employ="Employ";}
                                        if($lang=='ar'){$level="المستوى";}else{$level="level";}
                                        if($lang=='ar'){$smk="الرصيد من سماك";}else{$smk="The balance of the smak";}
									?>	
                                            <th><?php echo $id; ?></th>
										
											<th><?php echo $the_companyr; ?></th>
                                            <th><?php echo $employ; ?></th>
                                            <th><?php echo $smk; ?></th>
                                           
										</tr>
									</thead>
									<tbody>
                                   
                                    <?php
                    include("dbConfig.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 coonect_employ_with_solfacount_tn where  company_id IN ('$ids') AND company_id!='' AND deleted='0'";
                                }else{
                               $sql_cw="SELECT * FROM coonect_employ_with_solfacount_tn where company_id='$company_id' AND company_id!='' AND deleted='0'";
                                }
                                
                               }else{
                                
                                    $sql_cw="SELECT * FROM coonect_employ_with_solfacount_tn where employ_id='".$urow['user_id']."'AND company_id!='' AND deleted='0'";  
                             
                               }

                        $result_cw = $conn->query($sql_cw);
                        if ($result_cw->num_rows > 0) {
                          while($row_cw = $result_cw->fetch_assoc()) {
                      
                          ?> 
							    
                                        <tr class="D">
											
											<td><?php echo $row_cw["employ_id"];?></td>
						
                                            </td>
											<td>
                                         
                                            <?php 
                                            $sql_company = "SELECT * FROM main_company_tbl where company_id='".$row_cw["company_id"]."'";
                                              $result_company = $conn->query($sql_company);
                                                 if ($result_company->num_rows > 0) {
                                                    while($row_company = $result_company->fetch_assoc()) { 
                                                     if($lang=='ar'){$company_name=$row_company["company_name_ar"];}else{$company_name=$row_company["company_name_en"];}
                                                    echo $company_name;
                                                    }}
                                                    ?>
                                            </td>
                                           
											<td><?php echo employ_name($row_cw["employ_id"],$lang);?></td>
                                            <td><?php
                                               $coonect_employ_with_solfacount_tn = coonect_employ_with_solfacount_tn($row_cw["employ_id"]);
                                               $reaseedSALFsmak = reaseedSALFsmak($coonect_employ_with_solfacount_tn);
                                               ?>
                                                <a href="Employee_Advance_details.php?account_number=<?php echo $row_cw["account_number"];?>&lang=<?php echo $lang;?>&company_id=<?php echo $company_id?>"><?php echo round($reaseedSALFsmak);?></a>
                                                </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>
  $(document).ready(function(e) {
   $(".O_Level").change(function(){
 var lang = '<?php echo $lang;?>';
 if(lang=="ar"){
    var confirmation = confirm('هل انت متاكد انك تريد التبديل');
 }else{
    var confirmation = confirm('Are you sure you want to proceed?');
 }
  
 if (confirmation) {
    var id_first = $(this).attr('data-id');
    var selectedOption = $('#o_level'+id_first).find('option:selected');
    var id_second = selectedOption.val();
    var level_second = selectedOption.data('id');
    var level_first = $("#lev_num"+id_first).val();
    //alert(id_first);
    //alert(level_first);
    //alert(id_second);
    //alert(level_second);
    var company_id = $("#companyy_id"+id_first).val();
   
   $.ajax({
    type: "POST",
    url: "hr_reorder_level.php",
    data: {
        id_first:id_first,id_second:id_second,level_first:level_first,level_second:level_second,company_id:company_id				
    },
    success: function(data) {
     if(data==1){
alert("تمت عملية اعادة الترتيب بنجاح");
location.reload();
     }
    },
    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>




