<h2 align="center"><strong>ETDS Deduction Details</strong></h2>
<form action="" method="post">
<table width="30%" border="0" cellspacing="2" cellpadding="2" align="center">
  <tr>
    <th>Branch</th>
    <td>
	<select name="site" id="site" style="width:150px">
		<option value="0">Select</option>
		<?php 
		$site_sql=DB_query("Select loccode, prefix, locationname from locations",$db);
		while($site_row=DB_fetch_array($site_sql))
		{?>
		<option value="<?php echo $site_row['loccode'];?>"<?php echo($_REQUEST['site']==$site_row['loccode']?'selected':'')?>><?php echo $site_row['locationname'];?></option>
		<?php 
		}
		?>
	  </select>
	</td>
  </tr>
  <tr>
    <th>Date</th>
    <td><input name="fromDate" type="text" id="fromDate" value="<?php echo $_REQUEST['fromDate'];?>" size="9" class="datepicker">
      <strong> To      </strong>
    <input name="toDate" type="text" id="toDate" value="<?php echo $_REQUEST['toDate'];?>" size="9" class="datepicker">	</td>
  </tr>
  <tr>
    <th>Section</th>
    <td><select name="tds_section" id="tds_section"><option value="0">select</option>
		<option value="193"<?php echo($_REQUEST['tds_section']=='193'?'selected':'')?>>193</option>
		<option value="194"<?php echo($_REQUEST['tds_section']=='194'?'selected':'')?>>194</option>
		<option value="94"<?php echo($_REQUEST['tds_section']=='94'?'selected':'')?>>94</option>
		<option value="94F"<?php echo($_REQUEST['tds_section']=='94F'?'selected':'')?>>94F</option>
		</select></td>
  </tr>
  <tr>
    <th>Party</th>
    <td><select name="vendor" id="vendor" style="width:150px">
		<option value="0">Select</option>
		<?php 
		$vendor_sql=DB_query("Select vendor_code, vendor_name from suppliers",$db);
		while($vendor_row=DB_fetch_array($vendor_sql))
		{?>
		<option value="<?php echo $vendor_row['vendor_code'];?>"<?php echo($_REQUEST['vendor']==$vendor_row['vendor_code']?'selected':'')?>><?php echo $vendor_row['vendor_name'];?></option>
		<?php 
		}
		?>
		</select></td>
  </tr>
</table>
<p align="center"><input type="submit" name="View" value="View"></p>
</form>

<table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <th>Deduction</th>
    <th colspan="4"><div align="center">Supplier</div></th>
    <th>Gross</th>
    <th colspan="2"><div align="center">TDS</div></th>
    <th colspan="2"><div align="center">Surcharge</div></th>
    <th colspan="2"><div align="center">EDU Cess </div></th>
    <th>&nbsp;</th>
    </tr>
  <tr>
    <th>Date</th>
    <th>Deductee</th>
    <th>City</th>
    <th>PAN</th>
    <th>Section</th>
    <th>Amount</th>
    <th>Rate</th>
    <th>Amount</th>
    <th>Rate</th>
    <th>Amount</th>
    <th>Rate</th>
    <th>Amount</th>
    <th>TDS Amount </th>
  </tr>
  <?php 
  if($_REQUEST['View']!='')
  {
		$filter=array();

		$fromDate=$_REQUEST['fromDate'];
		$fromDateBrk=explode("/",$fromDate);
		$fromDate=$fromDateBrk[0];
		$fromMonth=$fromDateBrk[1];
		$fromYear=$fromDateBrk[2];
		$From=$fromYear."-".$fromMonth."-".$fromDate;
		
		$toDate=$_REQUEST['toDate'];
		$toDateBrk=explode("/",$toDate);
		$toDate=$toDateBrk[0];
		$toMonth=$toDateBrk[1];
		$toYear=$toDateBrk[2];
		$To=$toYear."-".$toMonth."-".$toDate;
		
		if($_REQUEST['site']!='0')
		$filter[]="job_billbook.site='".$_REQUEST['site']."'";
		if($_REQUEST['fromDate']!='' && $_REQUEST['toDate']!='')
		$filter[]="job_billbook.billDate between '".$From."' and '".$To."'";
		if($_REQUEST['vendor']!='0')
		$filter[]="job_billbook.vendor='".$_REQUEST['vendor']."'";
		
		if($filter!='')
		{
			$filter=implode(" and ",$filter);
		}
		
		$sql="Select * from job_billbook where $filter";
		
		
		if($_REQUEST['tds_section']!='0' && $filter=='')
		{
			//echo "1";
			$sql="select job_billbook.*, suppliers.tds_selection from job_billbook inner join suppliers 
					on(job_billbook.vendor=suppliers.vendor_code) where suppliers.tds_selection='".$_REQUEST['tds_section']."'";
		}
		else if($_REQUEST['tds_section']!='0' && $filter!='')
		{
			//echo "2";
			$sql="select job_billbook.*, suppliers.tds_selection from job_billbook inner join suppliers 
		on(job_billbook.vendor=suppliers.vendor_code) where $filter and suppliers.tds_selection='".$_REQUEST['tds_section']."' ";
		}
		//echo $sql;
		$result=DB_query($sql,$db); 
		$i=0;
		if(DB_num_rows($result)){
		while($myrow=DB_fetch_array($result)){
  
  ?>
  <tr bgcolor="#FFFFFF">
    <td><?php echo $myrow['billDate'];?></td>
    <td><?php 
	$vendor_sql=DB_query("Select vendor_name,city,pan_no,tds_selection,tds_percentage from suppliers where vendor_code='".$myrow['vendor']."'",$db);
	$vendor_row=DB_fetch_array($vendor_sql);
	echo $vendor_row['vendor_name'];?></td>
    <td><?php 
	$cityName=$s->getField('city_master','id',$vendor_row['city'],'city');
	echo $cityName;?></td>
    <td><?php echo $vendor_row['pan_no'];?></td>
    <td><?php echo $vendor_row['tds_selection'];?></td>
    <td><?php echo $myrow['grandTotal'];?></td>
    <td><?php echo $myrow['TDSPerc'];?> % </td>
    <td><?php echo $myrow['TDSValue'];?></td>
    <td><?php echo $myrow[''];?></td>
    <td><?php echo $myrow[''];?></td>
    <td><?php echo $myrow['SEduPerc'];?> % </td>
    <td><?php echo $myrow['SEduValue'];?></td>
    <td><?php echo $myrow['TDSValue'];?></td>
  </tr><?php $i++;}}
  else
  {?>
<tr><td colspan="13"><div align="center"><strong>No Record Found</strong></div></td></tr>  
<?php   	
  }
  } ?>
</table>

