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

$table_name2 = $_SESSION['db_prefix']."_customer";
$customer_query = "SELECT cust_id, comp_name, bag_box, box_no, postal_place, contact_1, cell_1, email_1, phone, account, status FROM $table_name2 ";
$customer_result = mySQL_query($customer_query);
$customer_num = mysql_num_rows($customer_result);	

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

<!--jscript-->
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 

</head>

<body>
<?php
include ("../navigation/header.php");
$page_name = "Sales-main";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/sales_sidebar.php");
?>
<div class="main_frame">
  <div class="page_head_frame" >
          <table width="590" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="385"><label class="label_page_head">Customers</label></td>
              <td width="253">&nbsp;</td>
              <td width="171" align="right">&nbsp;</td>
            </tr>
          </table>
       </div>
             
        <div class="page_middle_frame" style="height:500px;">
<!--jscript-->
<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": "400px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 0, "asc" ]],
					"aoColumns": [
								{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
                              	{"bSortable": true},
                             	{"bSortable": true}
								]
				} );
			} );
		</script>
          <table width="650px;" id="scroll_table" class="data_display"   >
            <thead>
            <tr>
              <th width="228">Company</th>
              <th width="136">Postal Address</th>
              <th width="46">Phone</th>
              <th width="86">Contact</th>
              <th width="46">Cell</th>
              <th width="80">e-mail</th>
            </tr>
          </thead>
            <?php 
$i=0;
while ($i<$customer_num) {
	$a =  mysql_result($customer_result, $i, "cust_id");
	$a0 = mysql_result($customer_result, $i, "comp_name");
	$a1 = mysql_result($customer_result, $i, "bag_box");
	$a2 = mysql_result($customer_result, $i, "box_no");
	$a3 = mysql_result($customer_result, $i, "postal_place");
	
	$a5 = mysql_result($customer_result, $i, "phone");
	$a6 = mysql_result($customer_result, $i, "account");
	$a7 = mysql_result($customer_result, $i, "status");
	$a8 = mysql_result($customer_result, $i, "contact_1");
	$a9 = mysql_result($customer_result, $i, "cell_1");
	$a10 = mysql_result($customer_result, $i, "email_1");
	
	$customerTT = "<label class=tip_click_label>Click for details</label>";
	?>
            <tr>
              <td align="left" valign="top"><a href="customer_details.php?cust_id=<?php echo $a?>" onMouseover="ddrivetip('<?php echo $customerTT ?>  ', 100)"; onMouseout="hideddrivetip()"><?php echo $a0 ?></a></td>
              <td align="left" valign="top"><?php echo $a1." ".$a2 ?><br />
                <?php echo $a3 ?></td>
              <td align="left" valign="top"><?php echo $a5 ?></td>
              <td align="left" valign="top"><?php echo $a8 ?></td>
              <td align="left" valign="top"><?php echo $a9 ?></td>
              <td align="left" valign="top"><a href="mailto:<?php echo $a10 ?>" onMouseover="ddrivetip('Click to email to:<br> <?php echo $a10 ?>', 200)"; onMouseout="hideddrivetip()"><?php echo substr($a10, 0, 15); if (strlen($a10)>15) { echo '...';}  ?></a></td>
            </tr>
            <?php
  $i++;
}
?>
          </table><br>

          <div align="right">
<a href="customer_email_list.php"><input name="email_list_button" type="button" class="imagebutton" value="Customer e-mail list"></a>  
</div>        
        </div>
  
</div>
<?php include ('../navigation/side_bar.php'); ?>
</body>
<?php } else {
$_SESSION['denied_return'] = $_SESSION['location'];	
include ("../navigation/sales_sidebar.php");?>
<body onload="accessdenied(); return false">
</body>
<?php }
?>
</html>