<?php
include("../include/session.php");

	
	$d = date("d");
	$m = date("m");
	$y = date("Y");
	
	$user_id = $_SESSION['username'];
	date_default_timezone_set('Africa/Khartoum');
    $entry_time = date("Y-m-d H:i:s",time()-3600); 
	
	 
	$table_name = $_SESSION['db_prefix']."_employee_issue";
	$return_query = "UPDATE $table_name SET return_date = '". $_SESSION['return_date'] ."' WHERE store_item_id = '".$_SESSION['store_item_id']."' AND emp_id = '". $_SESSION['emp_id']."' " ;
	execsql($return_query);
	
	$table_name5 = $_SESSION['db_prefix']."_store_items";
	$store_query = "UPDATE $table_name5 SET `quantity`=`quantity`+1 WHERE `store_item_id` = '".$_SESSION['store_item_id']."'";
	               
    execsql($store_query);
			
	$table_name = $_SESSION['db_prefix']."_tracking_hr";
   $trackingQuery = "INSERT INTO $table_name (entry_date, user, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_time."' ,'".$_SESSION['username']."', '24', '". $_SESSION['emp_id']."' ,'".$_SESSION['store_item_id']."','','' )";
   $trackingResult = mySQL_query($trackingQuery);
	
	if (isset($_GET['new_button']) )
	   {
		 $action='returnFromWiz0.php';
	   }
		 
	if (isset($_GET['finish_button']) )
	  {
		$action='hr_main.php?date=?date=0';
	  }
	
	 
 	 $_SESSION['emp_id']="";
	 $_SESSION['store_item_id']="";
     $_SESSION['item_name'] = "";
	 $_SESSION['return_date'] = date('Y-m-d');
     $_SESSION['employee_name'] = "";
	 $_SESSION['return'] = "";

	 
?>

<script language="javascript" type="text/javascript">
        <!--
		  window.location="<?php echo $action ?> ";
        -->
       </script>



