<?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>Countries - 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");?>
	
		<!-- 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">
           <!-- Datetimepicker CSS -->
		<link rel="stylesheet" href="../../assets/css/bootstrap-datetimepicker.min.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">
           <!-- Datetimepicker CSS -->
		<link rel="stylesheet" href="../../assets/css/bootstrap-datetimepicker.min.css">
        
        
           <!-- Datetimepicker JS -->
		<script src="../../assets/js/moment.min.js"></script>
		<script src="../../assets/js/bootstrap-datetimepicker.min.js"></script>

            <?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">
								<h3 class="page-title"> <?php echo "التعريفات" ; ?></h3>
								<ul class="breadcrumb">
									<li class="breadcrumb-item"></li>
									<li class="breadcrumb-item active"> <?php echo "التعريفات" ; ?></li>
								</ul>
							</div>
                            <div class="col-auto float-end ms-auto">
                            <a href="hr_Add_Difinition_Report.php?lang=<?php echo $lang;?>&company_id=<?php echo $company_id;?>" class="btn add-btn"><i class="fa fa-plus"></i><?php  echo "إضافة تعريف"; ?></a>
                            </div>							
						</div>
					</div>
					<!-- /Page Header -->					
					<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']; ?>
           </div>
            <?php endif; ?>
           <?php unset($_SESSION['message']); ?></div>
						<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>
                                        <th>اسم التعريف</th>
											<th>العمليات</th>
                                            <th>حذف</th>
										</tr>
									</thead>
                                    <tbody>
							<?php 
                         // التعريفات الرئيسيه
                         if($company_id=='all_company'){
                         $sql_def="SELECT * FROM def_tb where type='hr' and company_id IN ('$ids') order by createdDate,creatime";
                        }else{ 
                        $sql_def="SELECT * FROM def_tb where type='hr' and company_id='$company_id' order by createdDate,creatime"; 
                        }   
                         $result_def = $conn->query($sql_def);
                              if ($result_def->num_rows > 0) {
                                while($row_def = $result_def->fetch_assoc()) {
                        ?>
										<tr class="D">
											<td><?php echo $row_def["def_name"];?></td>
											<td>
                                                <?php 
                                            $sql_sub_def="SELECT * FROM sub_def_tb where def_id='".$row_def["id"]."'";
                              $result_sub_def = $conn->query($sql_sub_def);
                              if ($result_sub_def->num_rows > 0) {
                                while($row_sub_def = $result_sub_def->fetch_assoc()) {

                                    $sql_account="SELECT * FROM accounts_tbl where account_number='".$row_sub_def["account_number"]."' and company_id='".$row_com["company_id"]."'";
                              $result_account = $conn->query($sql_account);
                              if ($result_account->num_rows > 0) {
                                while($row_account = $result_account->fetch_assoc()) {
                                    $account_name = $row_account["account_name"];
                                }}
                                    ?>
                                    <?php if($row_sub_def["request"]=="sum_maden"){
                                        $request = "مدين";
                                    }elseif($row_sub_def["request"]=="sum_daen"){
                                        $request = "دائن";
                                    }elseif($row_sub_def["request"]=="raseed"){
                                        $request = "رصيد";
                                    }else{

                                    }?>
                                    <?php if($row_sub_def["operator"]=="sum"){
                                        $operate = "+";
                                    }elseif($row_sub_def["operator"]=="sub"){
                                        $operate = "-";
                                    }elseif($row_sub_def["operator"]=="multi"){
                                        $operate = "*";
                                    }elseif($row_sub_def["operator"]=="divid"){
                                        $operate = "/";
                                    }else{
                                        $operate = "";
                                    }?>
                                    <?php echo $account_name."  "."(".$request.")"."  ".$operate;?>
                                    <?php }} ?>
                                            </td>
                                            <td><button class="delete_def" id="<?php echo $row_def["id"]?>">حذف</button></td>
										</tr>
                                        <?php }} ?>
                                       
									</tbody>
								</table>
							</div>
						</div>
					</div>
                </div>
                	</div>
				<!-- /Page Content -->
				</form>
			
				
				
				
				
				<!-- 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>
				<!-- /Edit Department Modal -->

				<!-- Delete Department Modal -->
				<div class="modal custom-modal fade" id="delete_department" role="dialog">
					<div class="modal-dialog modal-dialog-centered">
						<div class="modal-content">
							<div class="modal-body">
								<div class="form-header">
									<h3>Delete Department</h3>
									<p>Are you sure want to delete?</p>
								</div>
								<div class="modal-btn delete-action">
									<div class="row">
										<div class="col-6">
											<a href="javascript:void(0);" class="btn btn-primary continue-btn">Delete</a>
										</div>
										<div class="col-6">
											<a href="javascript:void(0);" data-bs-dismiss="modal" class="btn btn-primary cancel-btn">Cancel</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!-- /Delete Department Modal -->
				
				
				
				
            </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>
		
		  <!-- Datetimepicker JS -->
		<script src="../../assets/js/moment.min.js"></script>
		<script src="../../assets/js/bootstrap-datetimepicker.min.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>
$('.delete_def').click(function(event) { 

   var id = $(this).attr('id');
   $.post('delete_def.php', {'id':id}, function(r) {
                if(r=='1'){
                    alert("تمت عملية الحذف بنجاح");
               location.reload();
                }
              });
        });
  </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>




