<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php 
include ("../navigation/header.php");

$page_name = "Stores-main";
include ("../navigation/access.php");

if ($permission_num==1) {
	
include ("../navigation/store_sidebar.php");


$table_name = $_SESSION['db_prefix']."_pallets_balance";
$pallets_credits_query = "SELECT  *  FROM $table_name WHERE entry_type = 'ret' ORDER BY entry_reference DESC ";
$pallets_credits_result = mySQL_query($pallets_credits_query);
$pallets_credits_num = mysql_num_rows($pallets_credits_result);

?>
<!--style sheets-->
<link href="../css/main.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />
       
</head>

<body>

<div class="main_frame">
<div class="page_head_frame">
    <label class="label_page_head">Returned pallets</label></div>


<div class="page_middle_frame">


<div class="page_inside_frame">

<script type="text/javascript" language="javascript" src="../jscript/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#scroll_table').dataTable( {
					"sScrollY": "500px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 0, "desc" ]],
					"aoColumns": [
								{"bSortable": true},
								{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true}
								 ]
				} );
			} );
		</script>
       
   
          
          <table width="500" id="scroll_table" class="data_display"  >
	<thead>
		<tr>
		  <th>Credit no</th>
          <th>Date</th>
		  <th align="center">Customer</th>
          <th align="center">Qty returned</th>
          </tr>
	</thead>
	<tbody>
  <?php
    $i=0;
	while($i < $pallets_credits_num){
		 $a1 = mysql_result($pallets_credits_result, $i, "entry_reference");
		 $a2 = mysql_result($pallets_credits_result, $i, "cust_id");
		 $a3 = mysql_result($pallets_credits_result, $i, "ret_qty");
		 $a4 = mysql_result($pallets_credits_result, $i, "ret_date"); 	
		 	
			
			$table_name = $_SESSION['db_prefix']."_customer";
			$customer_query = "SELECT status, account_type, comp_name, name_2, title, bag_box, box_no, postal_place, phone, cell_1  FROM $table_name WHERE cust_id = '".$a2."' ";
			$customer_result = mySQL_query($customer_query);
			$customer_num = mysql_num_rows($customer_result);
			if ($customer_num!=0) {
			$type = mysql_result($customer_result, 0, "account_type");
			if ($type=="corporate") { 
				$a2a = mysql_result($customer_result, 0, "comp_name"); 
			} 
			else {
				$a2a = mysql_result($customer_result, 0, "title")." ".mysql_result($customer_result, 0, "name_2")." ".mysql_result($customer_result, 0, "comp_name");
				$a2aa = mysql_result($customer_result, 0, "comp_name");
 			}	
			$a2b = mysql_result($customer_result, 0, "bag_box");
			$a2c = mysql_result($customer_result, 0, "box_no");
			$a2d = mysql_result($customer_result, 0, "postal_place");
			$a2e = mysql_result($customer_result, 0, "phone");
			$a2f = mysql_result($customer_result, 0, "cell_1");
			$a2g = mysql_result($customer_result, 0, "status");
			$a2h="";
			}
			else {
			$a2a='';
			}
		 
		 
	 
		 $customerTT ="<table id=table_tool_tip width=250 ><tr><td  width=75>Company:</td><td width=175>".$a2a."</td></tr><tr><td>Address:</td><td>".$a2b."&nbsp;".$a2c."<br>".$a2d."</td></tr><tr><td>Phone:</td><td>".$a2e."</td></tr><tr><td>Contact:</td><td>".$a2f."</td></tr></table><br><b>Click for details</b>";
		 
		 
		 		
		?>
		<tr >
		  <td ><a href="return_pallets_display.php?entry_reference=<?php echo $a1 ?> " onMouseover="ddrivetip('Click for return note', 150)"; onMouseout="hideddrivetip()"><?php echo $a1 ?></a></td>
          <td ><?php echo date("d-m-Y", strtotime($a4)) ?></td>
			<td align="center"><a href="account_details.php?cust_id=<?php echo $a2 ?>" onMouseOver="ddrivetip('<?php echo $customerTT?>', 250)"; onMouseOut="hideddrivetip()"><?php echo $a2a ?></a></td>
			<td align="center"><?php echo $a3?></td>
		  </tr>
        
		<?php
		$i++;
		  
	}
	
	?>
	</tbody>
</table>
 
 </div>
</div>
</div>



<?php include ('../navigation/side_bar.php'); ?>
</body>
<?php } else { ?>
<script> needToConfirm = false; </script>
<?php
    $_SESSION['denied_return'] = "store/store_main.php?branch=$date=";	?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>

