
PK 
<?php
session_start();
require_once 'common/common.php';
require_once 'common/secure.php';
include "head.php";
include("connexion.php");
//include "head.php";
include("connexion.php");
$dataquery="SELECT sum(grandtotal) FROM invoices WHERE invstatus='pending' and branch='$_SESSION[city]'";
$result=mysql_query($dataquery);
$rowdata=mysql_fetch_row($result);
$datatotal=$rowdata[0];
$data="SELECT sum(pamount) FROM payments where branch='$_SESSION[city]' ";
$resu=mysql_query($data);
$rowdata=mysql_fetch_row($resu);
$datato=$rowdata[0];
$data1="SELECT sum(tds) FROM payments where branch='$_SESSION[city]'";
$resu1=mysql_query($data1);
$rowdata1=mysql_fetch_row($resu1);
$datato1=$rowdata1[0];
include("connexion.php");
$sql="SELECT count(*) FROM invoices WHERE invstatus='paid' and branch='$_SESSION[city]'";
$result=mysql_fetch_array(mysql_query($sql));
$count=$result[0];
echo"<table width=100%><tr><td>Total no of paid Entry <b>($count)</b></td>
<td>
Total Amount Recieved <strong>($datato)</strong> / TDS <strong>($datato1)</strong>
</td>
</tr>";
include("connexion.php");
$sqlo="SELECT count(*) FROM invoices WHERE invstatus='pending' and branch='$_SESSION[city]'";
$resulto=mysql_fetch_array(mysql_query($sqlo));
$counto=$resulto[0];
echo"<tr><td>Total no of pending Entry <b>($counto)</b></td>
<td>Total Amount Pending <strong>($datatotal)</strong><td>
</tr>";
include("connexion.php");
$dataquery5="SELECT sum(grandtotal) FROM invoices";
$result5=mysql_query($dataquery5);
$rowdata5=mysql_fetch_row($result5);
$datatotal5=$rowdata5[0];
$dataquery6="SELECT sum(amount) FROM invoices";
$result6=mysql_query($dataquery6);
$rowdata6=mysql_fetch_row($result6);
$datatotal6=$rowdata6[0];
$dataquery7="SELECT sum(discount) FROM invoices";
$result7=mysql_query($dataquery7);
$rowdata7=mysql_fetch_row($result7);
$datatotal7=$rowdata7[0];
$tax=$datatotal5-($datatotal6-$datatotal7);
//print_r($_POST);
echo"<tr><td>Total Amount Of Tax: <b>($tax)</b></td>
<td><td>
</tr>";
$c_month=date("m");
$c_day=date("d");
$c_year=date("Y");
if($_POST['month']=="all")
{
$tot_mon_coll=mysql_query("Select * from invoices where year(dtd)='$c_year'") or die("Cannot fetch records because ".mysql_error());
}
else
{
$tot_mon_coll=mysql_query("Select * from invoices where year(dtd)='$c_year' and month(dtd)='".$_POST['month']."'") or die("Cannot fetch records because ".mysql_error());
}
$i=0;
while($row_mon_coll=mysql_fetch_array($tot_mon_coll))
{
$i=$i+($row_mon_coll[grandtotal]-($row_mon_coll[amount]-$row_mon_coll[discount]));
}
//echo $i;
echo"<form name='form1' method='post' action=''><tr><td>Monthly Tax:</b> ";
?>
<select name="month" id="month" style="width:140px;">
<option value="all" >Yearly</option>
<option value="01">Jan</option>
<option value="02">Feb</option>
<option value="03">Mar</option>
<option value="04">Apr</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">Aug</option>
<option value="09">Sep</option>
<option value="10">Oct</option>
<option value="11">Nov</option>
<option value="12">Dec</option>
</select>
<input type="submit" name="submit" value="Get" >
<?
if($_POST['month']!="all")
{
$showdate=date("F", mktime(0, 0, 0, $_POST['month'], $c_day, $c_year));
}
else
{
$showdate="Yearly";
}
if(isset($_POST['month']))
{
echo "</td>
<td>
Tax Of $showdate is <b>( $i )</b>
<td>
</tr>";
}
echo "<tr><td colspan=2><center><a href=billing.php>Search Again</a></center></td></tr>
</table>";
include "foot.php";
?>


PK 99