<?
session_start();
include("../opendb.php");
include("../test.php");
?>
<link rel="stylesheet" href="../style.css" type="text/css" />

<style>
	//tr1{background-color:white}
	th{background-color:steelblue;color:white}
</style>
<?
if($show)
{
$dt=$y.'-'.$m.'-'.$d;
print "<center><h2>TELCON DAILY REPORT FOR THE DAY ".datetohtml($dt)."</h2>";
$re1=mysqli_query($db,"select distinct brcode from branch order by brcode");
/*$s="create table repobr (brcode varchar(25),partcode varchar(100),partname varchar(200),qty double(14,2),customer varchar(200),";
*/

while($row1=mysqli_fetch_array($re1))
{
  $brre=mysqli_query($db,"select brname,brcode from branch where brcode='$row1[0]'");
  $brrow=mysqli_fetch_array($brre);
 print "<fieldset><legend>Branch: $brrow[0]</legend>";
 $re2=mysqli_query($db,"select * from spareinvoice where brcode='$row1[0]' and entrydate='$dt' order by partcode");
 print "<table border=1 width=100%>";
 print "<th>No <th width=170>Part Code <th width=450>Part Name <th width=50>Qty <th>Customer ";
 $i=1;
 while($row=mysqli_fetch_array($re2))
 {
  print "<tr><td>".$i++."</td><td>$row[partcode]</td><td>$row[partname]</td>";
  print "<td align=right>$row[qty]</td><td>$row[customer]</td></tr>";
 }

$re31=mysqli_query($db,"select * from jobcard where brcode='$row1[brcode]' and date='$dt'")or die(mysqli_error($db));

 while($jrow=mysqli_fetch_array($re31))
 {
   $sql="select partcode,partname,qty from jcardparts where jcno='$jrow[jcno]' and brcode='$jrow[brcode]'";
   $jres2=mysqli_query($db,$sql)or die('err'.mysqli_error($db));
    while($jrow1=mysqli_fetch_array($jres2))
    {
      print "<tr><td>".$i++."(jc)</td><td>$jrow1[partcode]</td><td>$jrow1[partname]</td>";
      print "<td align=right>$jrow1[qty]</td><td>$jrow[cname]</td></tr>";
    }
 }
 print "</table></fieldset>";
}
return;
}// end if
?>


<center>
<form action='<?print $PHP_SELF?>'>
<table border=1>
<th colspan=2><h3>DAILY SALES REPORT - BRANCH WISE</H3></TH>
<tr><td>Date </td><td>dd <input type=text name='d' value='<?print date('d')?>' size=2>
	mm <input type=text name='m' value='<?print date('m')?>' size=2>
	yy <input type=text name='y' value='<?print date('Y')?>' size=4>
</td></tr>
<tr><td colspan=2 align=center><input type=submit value='Show' name='show'></td></tr>
</table>
</form>

<?
print "calc...........<br>";



?>
