<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="JavaScript" src="../jscript/upper_case.js"  type="text/javascript"></script>  
<?php

include ("../navigation/header.php");
$page_name = "AD-pre defined";
include ("../navigation/access.php");
$page_display='';

//$size=$_GET['sizes'];

   $list_item = "";
   $page = $_GET['page_select'];
   
   $set = $_GET['set'];
   $input_type="char"; 
   if ($page=="packaging design") { $table_name = $_SESSION['db_prefix']."_list_packaging_design";}
   if ($page=="stores-location") { $table_name = $_SESSION['db_prefix']."_list_stores_location";}
   if ($page=="recycle") { $table_name = $_SESSION['db_prefix']."_list_recycle";}
   if ($page=="places") { $table_name = $_SESSION['db_prefix']."_list_places";}
   if ($page=="country") { $table_name = $_SESSION['db_prefix']."_list_country";}
   if ($page=="nationality") { $table_name = $_SESSION['db_prefix']."_list_nationality";}
   if ($page=="department") { $table_name = $_SESSION['db_prefix']."_list_department";}
   if ($page=="position") { $table_name = $_SESSION['db_prefix']."_list_positions";}
   if ($page=="salary_scale") { $table_name = $_SESSION['db_prefix']."_list_salary_scale";}
   if ($page=="branch") { $table_name = $_SESSION['db_prefix']."_list_branch";}
   if ($page=="banks") { $table_name = $_SESSION['db_prefix']."_list_banks";}
   if ($page=="late") { $table_name = $_SESSION['db_prefix']."_list_late";}
   if ($page=="early") { $table_name = $_SESSION['db_prefix']."_list_early";}
   if ($page=="absent") { $table_name = $_SESSION['db_prefix']."_list_absent";}
   if ($page=="warnings") { $table_name = $_SESSION['db_prefix']."_list_warnings";}
   if ($page=="overtime") { $table_name = $_SESSION['db_prefix']."_list_overtime";}
   if ($page=="company") { $table_name = $_SESSION['db_prefix']."_list_company";}
   if ($page=="names") { $table_name = $_SESSION['db_prefix']."_list_names";}
   
   if ($page=="store-names") { $table_name = $_SESSION['db_prefix']."_list_names_store";}
   if ($page=="approve-names") { $table_name = $_SESSION['db_prefix']."_list_approve_names";}
   if ($page=="discipline-names") { $table_name = $_SESSION['db_prefix']."_list_names_discipline";}
   if ($page=="admin-names") { $table_name = $_SESSION['db_prefix']."_list_admin";}
   if ($page=="stores-location") { $table_name = $_SESSION['db_prefix']."_list_stores_location";}
   if ($page=="recycle") { $table_name = $_SESSION['db_prefix']."_list_recycle";}
   
  
	   
   $set = $_GET['set'];
   
 
if ($set==0) {
	
	if ($table_name==$_SESSION['db_prefix']."_list_stores_location") { $page_display='Different stores locations';}
	if ($table_name==$_SESSION['db_prefix']."_list_recycle") { $page_display='Recycle';}
	if ($table_name==$_SESSION['db_prefix']."_list_places") { $page_display='Places';}
	if ($table_name==$_SESSION['db_prefix']."_list_country") { $page_display='Countries';}
	if ($table_name==$_SESSION['db_prefix'].'_list_nationality') { $page_display='Nationality';}
	if ($table_name==$_SESSION['db_prefix']."_list_department") { $page_display='Company departments';}
	if ($table_name==$_SESSION['db_prefix'].'_list_salary_scale') { $page_display='Salary scale';}
	if ($table_name==$_SESSION['db_prefix']."_list_company") { $page_display='Sister companies';}
	if ($table_name==$_SESSION['db_prefix']."_list_admin") { $page_display='Admistrative employees';}
	if ($table_name==$_SESSION['db_prefix']."_list_names_discipline") { $page_display='Discipline personnel';}
		
	if ($table_name==$_SESSION['db_prefix']."_list_names_store") { $page_display='Stores personnel';}
	if ($table_name==$_SESSION['db_prefix']."_list_quality_names") { $page_display='Quality Control';}
	if ($table_name==$_SESSION['db_prefix']."_list_approve_names") { $page_display='Authorisation';}
	if ($table_name==$_SESSION['db_prefix'].'_list_branch') { $page_display='Bank branches';}
	if ($table_name==$_SESSION['db_prefix'].'_list_banks') { $page_display='Banks';}
	if ($table_name==$_SESSION['db_prefix'].'_list_late') { $page_display='Late';}
	if ($table_name==$_SESSION['db_prefix'].'_list_early') { $page_display='Early leave';}
	if ($table_name==$_SESSION['db_prefix'].'_list_absent') { $page_display='Absent';}
	if ($table_name==$_SESSION['db_prefix'].'_list_warnings') { $page_display='Warnings';}
	if ($table_name==$_SESSION['db_prefix'].'_list_overtime') { $page_display='Overtime';}
	if ($table_name==$_SESSION['db_prefix'].'_list_positions') { $page_display='Employee positions';}
	
		
    $page_query = "SELECT item_name FROM $table_name  ORDER BY item_name ASC";
	
	$arrId2 = array ();
	$arrName2 = array ();
	$page_result = $con->query($page_query);
	if ($page_result!="") {
	$page_num = mysqli_num_rows($page_result);
	$b = 0;
	while ($b < $page_num) {
		$row = mysqli_fetch_assoc($page_result);
		$arrId2[$b] = $row['item_name'];
		$arrName2[$b] = $row['item_name'];
		$b++;
	}
	}
	
}

if ($set==1) {
		
	$item = $_GET['item_text'];
	$item = trim($item," ");
	$item_query  = "INSERT INTO $table_name (item_name) VALUES ('".$item."')";
		$item_result = $con->query($item_query);
	
	
   if ($table_name==$_SESSION['db_prefix']."_list_stores_location") { $page_display='Different stores locations';}
   if ($table_name==$_SESSION['db_prefix']."_list_places") { $page_display='Places';}
	if ($table_name==$_SESSION['db_prefix']."_list_country") { $page_display='Countries';}
	if ($table_name==$_SESSION['db_prefix'].'_list_nationality') { $page_display='Nationality';}
	if ($table_name==$_SESSION['db_prefix']."_list_department") { $page_display='Company departments';}
	if ($table_name==$_SESSION['db_prefix'].'_list_salary_scale') { $page_display='Salary scale';}
	if ($table_name==$_SESSION['db_prefix']."_list_admin") { $page_display='Admistrative employees';}
	if ($table_name==$_SESSION['db_prefix']."_list_names_discipline") { $page_display='Discipline personnel';}
	
	if ($table_name==$_SESSION['db_prefix']."_list_names_store") { $page_display='Stores personnel';}
	if ($table_name==$_SESSION['db_prefix']."_list_approve_names") { $page_display='Authorisation';}
	if ($table_name==$_SESSION['db_prefix'].'_list_branch') { $page_display='Bank branches';}
	if ($table_name==$_SESSION['db_prefix'].'_list_banks') { $page_display='Banks';}
	if ($table_name==$_SESSION['db_prefix'].'_list_late') { $page_display='Late';}
	if ($table_name==$_SESSION['db_prefix'].'_list_early') { $page_display='Early leave';}
	if ($table_name==$_SESSION['db_prefix'].'_list_absent') { $page_display='Absent';}
	if ($table_name==$_SESSION['db_prefix'].'_list_warnings') { $page_display='Warnings';}
	if ($table_name==$_SESSION['db_prefix'].'_list_overtime') { $page_display='Overtime';}
	if ($table_name==$_SESSION['db_prefix'].'_list_positions') { $page_display='Employee positions';}
	
    $page_query = "SELECT item_name FROM $table_name  ORDER BY item_name ASC";
	$arrId2 = array ();
	$arrName2 = array ();
	$page_result = $con->query($page_query);
	if ($page_result!="") {
	$page_num = mysqli_num_rows($page_result);
	$b = 0;
	while ($b < $page_num) {
		$row = mysqli_fetch_assoc($page_result);
		$arrId2[$b] = $row['item_name'];
		$arrName2[$b] = $row['item_name'];
		$b++;
	}
	}
	
}	
	

if ($set==2) {
	
	$list_item = $_GET['list_select'];
	
	$del_query = "DELETE FROM $table_name WHERE  item_name ='".$list_item."'";
	$del_result = $con->query($del_query);
    $message= "<font color=red><b>Permission was removed.</b></font>";
	
	
	if ($table_name==$_SESSION['db_prefix']."_list_stores_location") { $page_display='Different stores locations';}
	if ($table_name==$_SESSION['db_prefix']."_list_places") { $page_display='Places';}
	if ($table_name==$_SESSION['db_prefix']."_list_country") { $page_display='Countries';}
	if ($table_name==$_SESSION['db_prefix'].'_list_nationality') { $page_display='Nationality';}
	if ($table_name==$_SESSION['db_prefix']."_list_department") { $page_display='Company departments';}
	if ($table_name==$_SESSION['db_prefix'].'_list_salary_scale') { $page_display='Salary scale';}
	if ($table_name==$_SESSION['db_prefix']."_list_company") { $page_display='Sister companies';}
	if ($table_name==$_SESSION['db_prefix']."_list_admin") { $page_display='Admistrative employees';}
	if ($table_name==$_SESSION['db_prefix']."_list_names_discipline") { $page_display='Discipline personnel';}
	if ($table_name==$_SESSION['db_prefix']."_list_store_names") { $page_display='Stores personnel';}
	if ($table_name==$_SESSION['db_prefix']."_list_approve_names") { $page_display='Authorisation';}
	if ($table_name==$_SESSION['db_prefix'].'_list_branch') { $page_display='Bank branches';}
	if ($table_name==$_SESSION['db_prefix'].'_list_banks') { $page_display='Banks';}
	if ($table_name==$_SESSION['db_prefix'].'_list_late') { $page_display='Late';}
	if ($table_name==$_SESSION['db_prefix'].'_list_early') { $page_display='Early leave';}
	if ($table_name==$_SESSION['db_prefix'].'_list_absent') { $page_display='Absent';}
	if ($table_name==$_SESSION['db_prefix'].'_list_warnings') { $page_display='Warnings';}
	if ($table_name==$_SESSION['db_prefix'].'_list_overtime') { $page_display='Overtime';}
	if ($table_name==$_SESSION['db_prefix'].'_list_positions') { $page_display='Employee positions';}
	
	
	
	
    $page_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId2 = array ();
	$arrName2 = array ();
	$page_result = $con->query($page_query);
	if ($page_result!="") {
	$page_num = mysqli_num_rows($page_result);
	$b = 0;
	while ($b < $page_num) {
		$row = mysqli_fetch_assoc($page_result);
		$arrId2[$b] = $row['item_name'];
		$arrName2[$b] = $row['item_name'];
		$b++;
	}
	}
	
	
}
	
if ($set==5) {
$user_id = $_SESSION['username'];
date_default_timezone_set('Africa/Khartoum');
$entry_date = date("Y-m-d H:i:s",time()-3600);

$page_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId2 = array ();
	$arrName2 = array ();
	$page_result = $con->query($page_query);
	if ($page_result!="") {
	$page_num = mysqli_num_rows($page_result);
	$b = 0;
	while ($b < $page_num) {
		$row = mysqli_fetch_assoc($_result);
		$arrId2[$b] = $row['item_name'];
		$arrName2[$b] = $row['item_name'];
		$b++;
	}
	}
	
	

$table_name = $_SESSION['db_prefix']."_tracking_admin";
$action_query = "INSERT INTO $table_name (entry_date, user, action, details) VALUES ('".$entry_date."' ,'".$user_id."','pre-defined page' ,'predefined page' )";
$action_result = $con->query($action_query);


}
	
?>

<!--jscript-->
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/capitalize_textbox.js"  type="text/javascript"></script>  
</head>

<?php if ($permission_num==1) {
	include ("../navigation/admin_sidebar.php");
?>
<body  onload="<?php if ($set==5) { ?>document.getElementById('section_table').style.display = 'none';<?php } else { ?>document.getElementById('section_table').style.display = 'block';<?php } ?>" >


<div class="main_frame">
<div class="page_head_frame">
        <table width="809" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="385"><label class="label_page_head">Pre-defined lists</label></td>
            <td align="right">&nbsp;</td>
          </tr>
        </table>
      </div>
<div class="page_middle_frame">        
<div class="page_inside_frame"><form name="form1" id="form1" action="list_definitions.php" method="get"> <label class="label_std">Select a pre-defined list to manage: &nbsp;&nbsp;</label>
    <select name="page_select" class="selectbox300" id="page_select" onchange="window.location.href= this.form.page_select.options[this.form.page_select.selectedIndex].value">
    <option selected="selected" disabled="disabled"></option>

      <option disabled="disabled" style="font-weight:700; color:#0047D4">General</option>
      <option value="list_definitions.php?page_select=places&set=0;">Places</option>
      <option value="list_definitions.php?page_select=country&set=0">Country</option>
      
      <option disabled="disabled" style="font-weight:700; color:#0047D4">Production</option>
      
            
      <option disabled="list_definitions.php?page_select=disabled" style="font-weight:700; color:#0047D4">Admin</option>
      <option value="list_definitions.php?page_select=department&set=0">Company departments</option>
            <option value="list_definitions.php?page_select=admin-names&set=0">Admin personnel</option>
      <option value="list_definitions.php?page_select=discipline-names&set=0">Discipline personnel</option>
      <option value="list_definitions.php?page_select=approve-names&set=0">Authorisation personnel</option>
      <option value="list_definitions.php?page_select=store-names&set=0">Stores personnel</option>
      
      <option disabled="disabled" style="font-weight:700; color:#0047D4">HR</option>
      <option value="list_definitions.php?page_select=salary_scale&set=0">Salary scale</option>
      <option value="list_definitions.php?page_select=banks&set=0">Banks</option>
      <option value="list_definitions.php?page_select=branch&set=0">Branches</option>
      <option value="list_definitions.php?page_select=late&set=0">Late</option>
      <option value="list_definitions.php?page_select=early&set=0">Early leave</option>
      <option value="list_definitions.php?page_select=absent&set=0">Absent</option>
      <option value="list_definitions.php?page_select=position&set=0">Position</option>
      <option value="list_definitions.php?page_select=warnings&set=0">Warnings</option>
      <option value="list_definitions.php?page_select=overtime&set=0">Overtime</option>
      <option value="list_definitions.php?page_select=nationality&set=0">Nationality</option>         
      <option disabled="disabled" style="font-weight:700; color:#0047D4">Stores</option>
      <option value="list_definitions.php?page_select=stores-location&set=0">Stores location</option>
      <option value="list_definitions.php?page_select=recycle&set=0">Recycle</option>
      
      
      
    </select>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input name="set" type="hidden" id="set" value="0" />
           <?php
$infoTT = "";

?>
           <a href="" onMouseover="ddrivetip('<?php echo $infoTT ?>  ',300)" onMouseout="hideddrivetip();"></a>
</form>
</div>
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("page_select","req","Please select a page.");
</script>
<br />
<br />
<br />
<div class="hidden_frame" id="hidden_frame">
<div class="page_inside_frame">
<table width="650" border="0" cellspacing="0" cellpadding="0" id="section_table">
  <tr>
    <td height="83" colspan="3"><div class="caption_frame" style="width:600px;">
      <label class="label_std" style="font-size:16px;">Pre-defined list for:&nbsp;&nbsp;&nbsp;<font size="3"><font size="3"><?php echo $page_display ?></font></font></label></div></td>
    </tr>
  <tr>
    <td>
    <div class="standard_frame">
          <form action="list_definitions.php" name="remove_form" method="get">
            <select name="list_select" size="15" class="selectbox300"  >
              <?php
        	for ($j = 0; $j < count($arrId2); $j++) {
    		echo "<option value=" . "\"" . $arrId2[$j] . "\"" . ">" . $arrName2[$j] . "</option>";
	}
?>
              </select>
            <br />
            
            
            
            <label class="label_std">To remove an item, select the item<br />
              in the above list and click 'Remove'.</label><br />
              <br />
              <input name="button3" type="submit" class="imagebutton" id="button3" value="Remove" />
              <input name="page_select" type="hidden" id="page_select" value="<?php echo $page ?>" />
              <input name="set" type="hidden" id="set" value="2" />
              <br />
              </form>
          <script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("remove_form");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("list_select","req","Please select item to remove.");
</script>
          
          </div>
          </td>
    <td>&nbsp;</td>
    <td valign="top">
    <div class="standard_frame"><label class="label_std">Type the name of the item and<br />
      click &quot;add&quot; to add it to the list.</label><br />
            <br />
            
            <form action="list_definitions.php" name="set_form" method="get">
              &nbsp;&nbsp;
              <input name="item_text" type="text" class="text300" id="item_text"  onBlur="capitalize(this)"  <?php if($input_type=="number") {?> onkeypress="return numbersonly(this, event)" <?php } ?>  autofocus autocomplete="off"  />
              
              &nbsp;&nbsp;&nbsp;&nbsp;<br />
              <br />
             
              &nbsp;
              <input name="button2" type="submit" class="imagebutton" id="button2" value="Add" />
              <input name="page_select" type="hidden" id="page_select" value="<?php echo $page ?>" />
              <input name="set" type="hidden" id="set" value="1" />
              </form>
            <script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("set_form");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("item_text","req","Please enter item to add to list.");
  
</script></div></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</div>

</div>
</div>
</div>




<?php include ('../navigation/side_bar.php'); ?>
</body>

<?php } else { 
$_SESSION['denied_return'] = "admin_module/user_list.php";	
include ("../navigation/admin_sidebar.php");
include ('../navigation/side_bar.php');
?>
	<body onload="needToConfirm = false; accessdenied(); return false">
	</body>
<?php }
?>

</html>