Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/istore/
Upload File :
Current File : /var/www/html/mmishra/istore/stdistribution.inc

<h3>Query Distribution</h3>
<center>

<?php
$tbl = "st_stockout";

$id = $_REQUEST["id"];
$category = $_REQUEST["category"];
$subcategory = $_REQUEST["subcategory"];

$item = $_POST["item"];
$date1 = $_REQUEST["date1"];
$date2 = $_REQUEST["date2"];

if (!$date1) $date1 = date("Y-m-d");
if (!$date2) $date2 = date("Y-m-d");

echo "Period ";

$myCalendar = new tc_calendar("date1", true, false);
$myCalendar->setIcon("images/iconCalendar.gif");
$myCalendar->setDate(date('d', strtotime($date1)), date('m', strtotime($date1)), date('Y', strtotime($date1)));
$myCalendar->setPath("calendar/");
$myCalendar->setYearInterval(2015, date("Y"));
$myCalendar->setAlignment('left', 'bottom');
$myCalendar->writeScript();	  

echo " To ";

$myCalendar = new tc_calendar("date2", true, false);
$myCalendar->setIcon("images/iconCalendar.gif");
$myCalendar->setDate(date('d', strtotime($date2)), date('m', strtotime($date2)), date('Y', strtotime($date2)));
$myCalendar->setPath("calendar/");
$myCalendar->setYearInterval(2015, date("Y"));
$myCalendar->setAlignment('left', 'bottom');
$myCalendar->writeScript();	  

echo " (<i>For all records leave default date values unchanged</i>)<br>
Select category	<select name='category' onchange=\"javascript: document.location.href='?pg=$pg&date1=$date1&date2=$date2&item=$item&category='+this.value\">
<option value=''>Category</option>";

$rs = mysql_query("select * from st_category order by code");
while ($o = mysql_fetch_object($rs)) {
	echo "<option value='$o->id'";
	if ($o->id == $category) echo " selected";
	echo ">$o->code ($o->qty_in/$o->qty_out)</option>";
}
echo "</select> 
	
Subcategory <select name='subcategory' onchange=\"javascript: document.location.href='?pg=$pg&date1=$date1&date2=$date2&item=$item&category=$category&subcategory='+this.value\">
<option value=''>Subcategory</option>";

$rs = mysql_query("select * from st_subcategory where category=$category order by code");
while ($o = mysql_fetch_object($rs)) {
       	echo "<option value='$o->id'";
       	if ($o->id == $subcategory) echo " selected";
       	echo ">$o->code ($o->qty_in/$o->qty_out)</option>";
}
echo "</select> 
			
<!--select name='item' onchange=\"javascript: document.location.href='?pg=$pg&date1=$date1&date2=$date2&category=$category&subcategory=$subcategory&item='+this.value\"-->
item <select name='item'>
<option value=''>Item</option>";

$rs = mysql_query("select * from st_items where category=$category and subcategory=$subcategory order by code");
while ($o = mysql_fetch_object($rs)) {
       	echo "<option value='$o->id'";
       	if ($o->id == $item) echo " selected";
       	echo ">$o->code ($o->qty_in/$o->qty_out)</option>";
}
echo "</select>
<input type='submit' name='submit' value='SUBMIT'> 
</div>";


if ($_POST['submit'] == 'SUBMIT') {
	echo "<table width='80%' border='1' style='border-collapse: collapse'>
	<tr><th>No.</th><th>Indent</th><th>Indentor</th><th>Purpose</th><th>Location</th><th>Account</th><th>Qty</th><th nowrap>Dated</th></tr>";
	
	if ($item) {
		$rs = mysql_query("select * from $tbl where item=$item".($date1 == $date2 ? '' : " and dateCreation between '$date1' and '$date2'"). " order by id");
	} else {
		$rs = mysql_query("select distinct * from $tbl where item in (select id from st_items where subcategory=$subcategory)  ".($date1 == $date2 ? '' : " and dateCreation between '$date1' and '$date2'"). " order by id");
	}
	while ($o = mysql_fetch_object($rs)) {
		$i++;       
		$qty = $o->qty_out;
		$unit = $o->unit; 
		echo "<tr><td>$i</td><th><a href='?pg=inindents&indent_no=$o->indent_no'>$o->indent_no</a></th>";

		$sr = mysql_query("select * from indents where indent_no=$o->indent_no");
		if (mysql_num_rows($sr)) {
			$q = mysql_fetch_object($sr);
			echo "<td>$q->emp_no ".employee_detail($q->emp_no)."</td><td>$q->purpose</td><td>$q->location</td><td>$q->account</td>";
		}
		echo "<td>$qty $unit</td><td nowrap>$o->dateCreation</td></tr>";
		$tqty += $qty;
	}
	echo "<tr><th colspan='6'>Total</th><th nowrap>".number_format($tqty, 2)." $unit</th><th></th></tr>
	<table>";

}
?>
</center>