<?php 
session_start();
ob_start(); 
include "header.php";
//$objIms->Semifinisheditem_alter();
?>



<?php

if(isset($_GET["uid"]))
{
$uid=$_GET["uid"];
$rs=$objIms->getRows("view_purchase_supplier","md5(id)='$uid'");
$pur_id=$rs["id"];
$order_no=$rs["order_no"];
$purchase_date=$objIms->IntToDate($rs["purchase_date"]);
$supplier_name=$rs["supplier_name"];

}


	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

		
	
		 <style>
			select.error { background-color:#ffa8a8; border: 1px dotted red;  }
			input.error{ background-color:#ffa8a8;   }
			textarea.error{ background-color:#ffa8a8; border: 1px dotted red;  }
         </style>
		 
        


<style type="text/css">
<!--
.table_bg{ border:#CCCCCC solid 1px; border-radius:5px; height:auto; width:auto; padding:20px; margin-bottom:10px;}


-->
</style>
</head>
<script type="text/javascript">
 
function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}

</script>
<script type="text/javascript">
$(function(){
    $('button').click(function(){
        var url='data:application/vnd.ms-excel,' + encodeURIComponent($('#tableWrap').html()) 
        location.href=url
        return false
    })
})
</script>
<body>

<div class="span11" style=" width:83%;">



<div class="12" style=" margin-left:0px; ">



<br />
<br />
<br />

<div class="12" style=" margin-left:0px;">

<div class="panel" style="border:<?php echo THEMECOLOR?> solid 1px; border-radius:0px;">
<div class="entry-head" >
<h4>View Transaction Report</h4>
</div>
<p>&nbsp;</p>
<form name="form1" id="form1" method="post">
  <table width="100%" border="0" align="center">
    <tr>
      <td width="10%" height="49" nowrap="nowrap"><strong>From Date </strong></td>
      <td width="1%"><strong>:</strong></td>
      <td width="25%"><input name="s_date" type="text" class="tcal" id="s_date" readonly=""  value="<?=date('d-m-Y')?>"/></td>
      <td width="13%"><strong>To Date </strong></td>
      <td width="3%"><strong>:</strong></td>
      <td width="21%"><input name="end_date" type="text" class="tcal" id="end_date" readonly=""  value="<?=date('d-m-Y')?>" /></td>
      <td width="3%">&nbsp;</td>
      <td width="24%"><input type="submit" name="Search" value="Search" class="btn btn-info" /></td>
      </tr>
  </table>
</form>
<br />
<div id="tableWrap">
<div id="printableArea">
<?php 
if(isset($_POST["Search"]))
{
$s_date=$objIms->DateToInt($_POST["s_date"]);
$end_date=$objIms->DateToInt($_POST["end_date"]);
?>
     
            
		
            <?php 
			$totCr=0;
			$totDr=0;
			$totalbal=0;
			
				  $sql_viewtmp="select * from tbl_account where cancel_status=0 and trans_date>='$s_date' and trans_date<='$end_date'";
				$res_viewtmp=mysql_query($sql_viewtmp);
				if(mysql_num_rows($res_viewtmp)>0)
				{ 
					$i=1;
					$sums=0;
					?>
					<div class="panel">
					<div class="panel-heading">Transaction From <?php echo $_POST["s_date"];?> To <?php echo $_POST["end_date"];?></div>
					<p>&nbsp;</p>
                     <table width="100%" class="table table-bordered">
                     <tr height="32" align="left">
            <th nowrap="nowrap" width="6%">SL No</th>
            <th nowrap="nowrap" width="24%">Transaction Date </th>
            <th nowrap="nowrap" width="35%">Head</th>
            <th nowrap="nowrap" width="35%">Against</th>
           
            <th nowrap="nowrap" width="17%">Credit</th>
            <th nowrap="nowrap" width="18%">Debit</th>
            </tr>
            <?php
				while($rows=mysql_fetch_assoc($res_viewtmp))
					{
					$againstno='';
					if($rows["sales_type"]=='Purchase')	
					{
					$rs=$objIms->getRows("tbl_purchase_master","id=".$rows["mas_id"]);
					$againstno=$rs["receiving_no"];
					}
					elseif($rows["sales_type"]=='Purchase Return')	
					{
					$rs=$objIms->getRows("tbl_purchase_return_mstr","id=".$rows["mas_id"]);
					$againstno=$rs["return_no"];
					}
					elseif($rows["sales_type"]=='Sales')	
					{
					$rs=$objIms->getRows("tbl_sales","id=".$rows["mas_id"]);
					$againstno=$rs["sale_no"];
					}
					elseif($rows["sales_type"]=='Sales Return')	
					{
					$rs=$objIms->getRows("tbl_sales_return_mstr","id=".$rows["mas_id"]);
					$againstno=$rs["salereturn_no"];
					}	
						
						
					$totCr+=$rows["actual_amt"];		
					$totDr+=$rows["Dr_Amt"];		
			?>
           
            <tr height="32">
            <td nowrap="nowrap" width="6%"><?php echo $i++;?></td>
           
		    <td nowrap="nowrap" width="24%"><?php echo $objIms->IntToDate($rows["trans_date"]);?></td>
		    <td nowrap="nowrap" width="35%"><?php echo $rows["sales_type"];?></td>
		    <td nowrap="nowrap" width="35%"><?php echo $againstno;?></td>
            
            <td nowrap="nowrap" width="17%"><?php echo $rows["actual_amt"];?></td>
            <td nowrap="nowrap" width="18%"><?php echo $rows["Dr_Amt"];?></td>
            </tr>
             
            <?php }?>
			 <tr height="32">
              <td colspan="4" nowrap="nowrap"><div align="right"><strong>Total</strong></div></td>
              <td nowrap="nowrap"><?php echo number_format($totCr,2);?></td>
              <td nowrap="nowrap"><?php echo number_format($totDr,2);?></td>
            </tr>
			 <tr height="32">
			   <td colspan="4" nowrap="nowrap"><div align="right"><strong>Balance</strong></div></td>
			   <td colspan="2" nowrap="nowrap"><?php $totalbal=$totDr-$totCr; echo number_format($totalbal,2)?></td>
			   </tr> 
           </table>
		   </div>
    <?php }
	else
	{
	echo '<span style="color:#FF0000">No Data Found</span>';
	}
	}?>
	
		

   
<p></p>
		<br />
        

</div>
</div>
<br />

<div align="center"><span class="btn btn-info" onClick="printDiv('printableArea')">Print</span> &nbsp;&nbsp;<button class="btn btn-success">Export to Excel</button></div></div></div></div></div>
</body>
</html>
