<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

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

<link href="../css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
</script>
</head>
<?php
if ($permission_num==1) {
	include ("../navigation/sales_sidebar.php");
	
$table_name = $_SESSION['db_prefix']."_customer";
$table_name2 = $_SESSION['db_prefix']."_customer";
$customer_query = "SELECT account_type, cust_id, comp_name, title, name_2 FROM $table_name2 ORDER BY comp_name ";
$customer_result = mySQL_query($customer_query);
$customer_num = mysql_num_rows($customer_result);
$cust_id = mysql_result($customer_result, 0, "cust_id"); 	

	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while ($w < $customer_num) {
		$a1 = mysql_result($customer_result, $w, "account_type");
		if ($a1=="corporate") { 
				$arrName4[$w] = mysql_result($customer_result, $w, "comp_name"); 
		} 
		else {
				$arrName4[$w] = mysql_result($customer_result, $w, "comp_name").', '.mysql_result($customer_result, $w, 'name_2')." (".mysql_result($customer_result, $w, "title").')';
 		}
		$arrId4[$w] = mysql_result($customer_result, $w, 'cust_id');
		
		$w++;
	}
	
$table_name = $_SESSION['db_prefix']."_list_sellers";
$sellers_query = "SELECT item_name, user_name FROM $table_name  ORDER BY item_name ASC";
	$sellers_result = execsql($sellers_query);
	$sellers_num = mysql_num_rows($sellers_result);
	$w = 0;
	$arrId2 = array ();
	$arrName2 = array ();
	while ($w < $sellers_num) {
		$arrId2[$w] = mysql_result($sellers_result, $w, "user_name");
		$arrName2[$w] = mysql_result($sellers_result, $w, "item_name");
		$w++;
	}	
?>
<body>

<div class="main_frame">
<table width="630" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="52" colspan="4" align="left" valign="top"><div class="page_head_frame">
        <table width="630" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="385"><label class="label_page_head">Select sales reports</label></td>
            <td align="right">&nbsp;</td>
          </tr>
        </table>
      </div>
       <br />
<br /><br />
<br />
<br />
<br />

<div class="page_middle_frame">
<form action="" method="get" ><br />
  <div class="page_inside_frame">
    <input name="tiles_button2" type="button" class="imagebutton" id="tiles_button2" onclick="MM_goToURL('parent','sales_products.php?date=&cust_id=0&branch=<?php echo $_SESSION['userbranch']?>');return document.MM_returnValue" value="Product sales" />
  &nbsp;&nbsp;&nbsp;&nbsp;
  <input name="acc_button2" type="button" class="imagebutton"  id="acc_button2" value="Customer sales" onclick="MM_goToURL('parent','store_items_list.php?subCatSelect=Accessories&branch=<?php echo $_SESSION['userbranch']?>');return document.MM_returnValue"/>
  </div>
  <br />
<div class="page_inside_frame">
      <p><br>
        
        
        <input name="tiles_button" type="button" class="imagebutton" id="tiles_button" onClick="MM_goToURL('parent','tile_sales_list.php?subCatSelect=Tiles&branch=<?php echo $_SESSION['userbranch']?>&date=');return document.MM_returnValue" value="Tiles" />
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input name="acc_button" type="button" class="imagebutton"  id="acc_button" value="Accessories" onClick="MM_goToURL('parent','tile_sales_list.php?subCatSelect=Accessories&branch=<?php echo $_SESSION['userbranch']?>&date=');return document.MM_returnValue"/>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input name="tile_acc_button" type="button" class="imagebutton"  id="tile_acc_button" value="Tiles & Accessories" onClick="MM_goToURL('parent','tile_sales_list.php?subCatSelect=both&branch=<?php echo $_SESSION['userbranch']?>&date=');return document.MM_returnValue"/>
        <br>
        <br>
        
        
        <label class="label_std">Customer:</label>
        &nbsp;&nbsp;
        <select name="job_no_select"  class="selectbox300" id="job_no_select" onChange="window.location.href= this.form.job_no_select.options[this.form.job_no_select.selectedIndex].value">
          <option value=" " selected="selected" >&nbsp;</option>
          <?php
    	for ($j = 0; $j < count($arrId4); $j++) {
			echo "<option value=customer_ordered_list.php?cust_id=".$arrId4[$j]."&date=>".$arrName4[$j]."</option>";	
		}
     ?>
        </select>
      </p>
      <p>&nbsp;</p>
      <p>Sales rep: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <select name="seller_select" id="seller_select" class="select160" onChange="window.location.href= this.form.seller_select.options[this.form.seller_select.selectedIndex].value">
          <option value="  " selected="selected"> </option>
<?php 
    	for ($w = 0; $w < count($arrId2); $w++) {
		echo "<option value=sales_rep_sales_list.php?sales_rep=".$arrId2[$w] ."&date=>". $arrName2[$w]."</option>";	
	    }
     ?>
        </select>
      </p>
        
    </div>
  
  <br />
<br>
<br>

<br />
<br /><br />
<br />
<br />
</form>
</div>

    </td>
    </tr>
    </table>
</div>

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

<?php } else { ?>
<script> needToConfirm = false; </script>
<?php
    $_SESSION['denied_return'] = "sales/sales_main.php?date=&branch=";	
    include ("../navigation/sales_sidebar.php");?>
    <?php include ('../navigation/sales_bar.php'); ?>
	<body onLoad="accessdenied(); return false">	
	</body>
<?php }
?>
</html>
