Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/irp/icure/doctor/
Upload File :
Current File : /var/www/html/mmishra/irp/icure/doctor/stock_inout.inc

<h3 align='left'>Stock In-Out</h3>
<center>
<?php

$tbl = 'medicines';
$dated = $_REQUEST["dated"];

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

$dated1 = date('Y-m-d', strtotime($dated .' -1 day'));
$dated2 = date('Y-m-d', strtotime($dated .' +1 day'));

echo "<a href='?pg=$pg&dated=$dated1'>$dated1</a> 
<font size='+1' color='red'>[ $dated ]</font>";

if ($dated != date("Y-m-d")) echo "<a href='?pg=$pg&dated=$dated2'>$dated2</a>";

echo "<table border='1' width='50%'>
<tr><th>Sr</th><th>Medicine Name</th><th>Stock-In</th><th>Stock-Out</th></tr>";
$intotal = 0; $outtotal = 0;

$rs = mysql_query("select med_id,med_name from $tbl order by med_name");
while ($o = mysql_fetch_object($rs)) {
	$i++;
	echo "<tr><td>$i</td>
	<td>$o->med_name</td><td>";
	$sr = mysql_query("select rec_date as dated,sum(qty_receipt) as rq from receipts
	group by med_id,dated having med_id=$o->med_id and dated='$dated'");
	if (mysql_num_rows($sr)) {
		$q = mysql_fetch_object($sr);
		$intotal += $q->rq;
		echo $q->rq;
	} else {
		echo '-';
	}
	echo '</td><td>';
	$sr = mysql_query("select date(dis_datetime) as dated, sum(qty) as iq from medications
        group by med_id,dated having med_id=$o->med_id and dated='$dated'");
	if (mysql_num_rows($sr)) {
		$q = mysql_fetch_object($sr);
		$outtotal += $q->iq;
		echo $q->iq;
	} else {
		echo '-';
	}
	echo "</td></tr>";
}
echo "<tr><th colspan='2'>Total</th><th>$intotal</th><th>$outtotal</th></tr>";
?>
	
</table>
</center>