<?php require "_header.php";   
include "Numbers/Words.php"; ?>
<script language="javascript" type="text/javascript">
//document.getElementById("main-content").style.display = 'none';
</script>

<div id="main-report" align="center">

<?php 
$height=200;
$nw = new Numbers_Words();
if($_SESSION["cCompany_id"]!="" && isset($_SESSION["cCompany_id"]))
{ 

		$cond = "";
		$agencyid = $_SESSION["cCompany_id"];
		
		$headerflag=$_REQUEST['headerflag'];
		$startdate = Escape($_REQUEST["startdate"]);
		$enddate= Escape($_REQUEST["enddate"]);
		if($startdate !="From" && $enddate !="To")
		{	
		
		 $startdate = DateConversion($startdate,"Y-m-d","d/m/Y");
		 $enddate = DateConversion($enddate,"Y-m-d","d/m/Y");
		  $cond.= " AND invoice_date >= '$startdate' ";  
		  $cond.= " AND invoice_date <=  '$enddate' ";  
		}
		
		
		$qry = " SELECT * FROM invoice_data where 1=1 ";
		$qry .= $cond;
		//$ObjagencymasterMgmt = new agencymasterMgmt(); ".$_REQUEST['nro_no']. "
		 
	 	$rs = dbQuery($qry);
		$rs1=dbQuery($qry);
		$count=dbRows($rs);
		$j=0;
		$custome_height = 240;
		///extract($row);
		ob_start();
		
		$i=0;
		$sno=1;
		$net_amount = 0;
		$page_break=1;
		if($count> 0)
		{
		
	   ?>
<style>	   
		 .container table {
  border-spacing: 0;
  border-top: solid 1px #000;
  border-left: solid 1px #000;
}
.container table td {
  border: solid 1px #000;
 
}
.container .no-border-right {
  border-right: none;
  color: black;
   
}
.container .no-border-right1 {
  border-bottom: none;
  color: black;
   
}

.container .no-border-right + td {
  border-left: none;
}
</style>

    <?php while($row = dbArray($rs))
	{
	$net_amount = 0;
	?>
	
		<div class="container">
		<table  width="100%" >
     	
		<tr>
		<td width="50%" height="20px;" ><b>Name : </b></td>			
		<td width="50%" height="20px;" ><b>Address :<b></td>	
		</tr>
		
		<tr>
		<td width="50%" height="20px;"><?php print $row['name'];?></td>	
		<td width="50%" height="20px;"><?php print $row['address'];?></td>	
		</tr>
		
		<tr>
		<td colspan="2"><center><b><font size="5">Invoice</font><b></center><br/></td>
		</tr>
			
		<tr>
		<td  width="50%" align="left"><b><font size="2">Bill To,<font></b></td>
		<td  width="50%" align="left"><b><font size="2">Invoice No : <?php print $row['invoice_no'];?><font></b></td>
		</tr>
		
		<tr>
		<td  width="50%" align="left" >Aum Imagineering Pvt Ltd</td>
		<td width="50%" align="left" >Date : <?php  print date("d/m/Y",strtotime($row['invoice_date']));?></td>
		</tr>
		
		<tr>
		<td  width="50%" align="left" >602-603/A, Shapath-1</td>
		<td width="50%" align="left" >PAN No : <?php print $row['pan_no'];?></td>
		</tr>
		
		<tr>
		<td  width="50%" align="left" >S.G.Highway,</td>
		<td width="50%" align="left" >&nbsp;</td>
		</tr>
		
		<tr>
		<td width="50%"  align="left" >Opposite Rajpath Club, Satellite,</td>
		<td width="50%" align="left" >&nbsp;</td>
		
		</tr>
		<tr>
		<td  width="50%" align="left" >Ahmedabad, Gujarat - 380015</td>
		<td width="50%" align="left">&nbsp;</td>
		
		</tr>
		<tr>
		<td  width="50%" align="left" >PAN No : AAJCA3252C</td>
		<td width="50%" align="left" >&nbsp;</td>
		
		</tr>

                 <tr><td align="center" colspan="2">
			<table width="100%" cellpadding="0" cellspacing="0" class="report" frame="box" border="0" cellpadding="0" cellspacing="0"  >
			<tr style="font-weight:bold">
			<td align="center" width="2%" >SR.</td>
			<td align="center" width="12%" >PARTICULARS</td>
			<td align="center" width="5%" >QTY</td>
			<td align="center" width="5%" >UNIT PRICE</td>
			<td align="center" width="6%">Total</td>
			
			</tr>
                

                  <tr>
                    <td  style="text-align:left;" width="5%">
                    <center> 1 </center>
                     </td>
                     <td  style="text-align:left;" width="25%">
                      <?php echo $row['particular']; ?>
                     </td>
                      <td  style="text-align:center;" width="10%">
                      <?php echo $row['qty']; ?>
                     </td>
                    <td  style="text-align:center;" width="10%">
                      <?php echo $row['unit_price']; ?>
                     </td>
                    
                    
                      <td  style="text-align:center;" width="10%">
                      <?php 
					  echo $row['total'] ?>
                     </td>
                     
                     
                 </tr>
               <?php
			   		$height=$height-25;
					 $sno++;
					 $net_amount=$net_amount+$row['total'];
					 
			 
			    ?>  
                <tr style="height:30px">
               <td></td>
			    <td colspan="4"></td>
                </tr>
				<tr>
                   <td  style="text-align:center;" colspan="4">
                      GRAND TOTAL
                     </td>
               
				<td align="center" >
                  	
                   <?php echo ' Rs. '.number_format(round($net_amount),2); ?>
                  </td>
                </td>
				</tr>
			  <tr>
				<td colspan="5" height="20px;"></td>
			  </tr>
               <tr style="height:35px;vertical-align:middle">
                
                   <td align="left" width="71%" colspan="5"> 
                   Amount in Words : 
                  <?php  echo strtoupper($nw->toWords($net_amount)." Rupees Only");?>
                  </td>
                </tr>
				
			 <tr style="height:70px;vertical-align:middle">
                
                   <td  width="71%" colspan="5" style="padding-top:50px;padding-left:500px;"> 
                   Authorized Signatory
                  
                  </td>
                </tr>	
				
				
				
       	</table>
		</td>
		</tr>
               
        </table>
</div>
		</br>		
		</br>
		<?php 
		if($page_break%2!=0){
		?>
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
		</br> </br></br>
		<?php
		}
		?>
<?php	
		if($page_break%2==0){	
		?>
		<div style="page-break-before:always;">&nbsp;</div>		
		<?php
		}
		?>
			<?php $page_break ++;
	}
	}
		
	
	   
		
			 ?>		
       
          
          		
	   <?php  
	   $HtmlCode= ob_get_contents();
			ob_end_flush();
			$HtmlUrl 	=	"customerbill-report-". $_SESSION["eAgencyId"].".html";
			$HtmlPath 	=	"report/".$HtmlUrl;		
			createHTMLReportPage($header_row_string,$HtmlUrl,$HtmlPath,$HtmlCode,true); 		
		?>		
		<br />
<br /><br />
		<form name="frm" id="frm" action="" method="post">		
<input type="hidden" name="txtFile" id="txtFile" value="<?php echo $HtmlUrl ;?>" />
<input type="button" name="btnPdf" id="btnPdf" value="Print" onClick="SetPageAction('PRINT');"/>
<input type="button" name="btnPdf" id="btnPdf" value="Create PDF" onClick="SetPageAction('PDF');"/>
<input type="button" name="btnHtml" id="btnHtml" value="Create HTML" onClick="SetPageAction('HTML');"/>
<input type="button" name="btnWord" id="btnWord" value="Create WORD" onClick="SetPageAction('WORD');"/>
<input type="button" name="btnExcel" id="btnExcel" value="Create EXCEL" onClick="SetPageAction('Excel');"/>
		</form>
		<script language="javascript" type="text/javascript">
			function SetPageAction(varAction) {
				
				if(varAction=="PRINT"){			
                        document.frm.action="print/create-print.php";
                        document.frm.submit();
                    }
			   else if(varAction=="PDF"){			
					document.frm.action="convertpdf/create-pdf.php";
					document.frm.target = "_blank";
					document.frm.submit();
				}
				else if(varAction=="HTML"){
					document.frm.action="<?php echo $HtmlPath ;?>";
					document.frm.target = "_blank";
					document.frm.submit();
				}
				else if(varAction=="WORD"){
					document.frm.action="convertword/create-word.php";
					document.frm.target="_blank";
					document.frm.submit();
				}
				else if(varAction=="Excel"){
					document.frm.action="convertword/create-excel.php";
					document.frm.target="_blank";
					document.frm.submit();
				}
			}
		</script> 
<?php } ?> 
</div>
<?php require "_footer.php";?>