<?php
	require_once 'inc/conx.php';
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Print Invoice</title>
<script type="text/javascript">
	function PrintContent()
	{
		var DocumentContainer = document.getElementById('printtdis');
 		var WindowObject = window.open('', "PrintWindow", "widtd=595,height=650,top=10,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes");
		WindowObject.document.writeln(DocumentContainer.innerHTML);
		WindowObject.document.close();
		WindowObject.focus();
		WindowObject.print();
		WindowObject.close();
		window.close();
 	}
</script>
<style>
	body
	{
		widtd:300px;
		margin:0px auto;
		margin:5px;
		font-family:"Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
		font-size:12px;
	}
</style>
</head>
<body  onLoad="PrintContent()">
	<div id="printtdis">
    <?php
		 $sql  = "SELECT * FROM  customer_setup";
		 //$sql .= " ";
		 $run = $db->query($sql);
	
		 $row = $run->fetchArray();
	?>
    <div align="center">
    	<span style="text-transform:uppercase; font-weight:bold; font-size:18px; text-decoration:underline; border-bottom:1px solid #000; text-align:center; color: #4CAF50;
    text-shadow: 1px 1px 2px #000;">
			<?php echo $row['company_name']; ?>
        </span>
   </div>
        
        <div style="clear:both;">&nbsp;</div>
        <div style="float:left; margin-right:100px;">
        	<span><strong>Voucher No # : </strong> <?php echo $_GET['invoice']; ?></span>
        </div>
        <div style="float:left; margin-right:100px;">
        	<span><strong>Date : </strong> <?php echo date("d/m/Y"); ?></span>
        </div>
        
        <div style="float:left;">
        	<span><strong>Time : </strong> <?php echo date("h:i:s A"); ?></span>
        </div>
        <div style="clear:both;">&nbsp;</div>
        
		<h3 align="center"><ins>Cash Book Voucher</ins></h3>

        <style>
        	#itemsNames thead th {
				border:1px solid #000;
				border-bottom:3px solid #000;
			}
			#itemsNames tbody td {
				border:1px solid #000;
			}

        </style>
        <br>
        <table width="100%" id="itemsNames" cellpadding="0" cellspacing="0">
        <thead>
        	<th align="left">Name</th>
            <th align="left">Description</th>
            <th align="left">Amount</th>
        </thead>
        <tbody>
    <?php
		if(isset($_GET['invoice'])){
			//echo $row['trucknum'] . " " . $row['truckdate'];
			// Here we are seeing tdat, how many buyers buy item from particular truck ?
/* 			$sql2  = "SELECT CTIN.name, CTIN.user_name, CTIR.receive FROM customerinvoice2 AS CTIN ";
			$sql2 .= "INNER JOIN customerinvoicereceipt AS CTIR ";
			$sql2 .= "ON CTIN.invoiceNo = CTIR.invoiceNo ";
			$sql2 .= "WHERE CTIN.invoiceNo = '".$_GET['invoice']."'";
 */	
			$sql2 = "SELECT * FROM payments ";
 			$sql2 .= "WHERE id = '".$_GET['invoice']."'";
			$run2 = $db->query($sql2);
			if(!$run2){
				echo mysqli_error($db);
			}
          
	   
		$row2 = $run2->fetchArray();
        $data=str_replace("c", " ", $row2['cs_id']);
        $querys1=$db->query("select * from customer_setup where id='".$data."'");
        $fetch_name=$querys1->fetchArray();
		   // echo $buyer['buyerFullName'];
	?>
    	<tr>
            <td align="left"><strong><?php echo $fetch_name['customer_name']; ?></strong></td>
            <td align="left"><?php echo $row2['description']; ?></td>
            <td align="left"><?php echo $row2['amount']; ?></td>
        </tr>
   <?php
		}
	?>
      </tbody>
</table>
     	
        <br><br>
        <div style="float:left; margin-right:100px; margin-left:50px; text-align:center;">
        	<span>____________</span><br>
			Receiver Signature
        </div>
        <div style="float:left; margin-right:100px; text-align:center;">
        	<span>____________</span><br>
			Accountant
        </div>
        <div style="float:left;text-align:center;">
        	<span>____________</span><br>
			Authorised Signature
        </div>
        <div style="clear:both;">&nbsp;</div>

        
        <table width="100%" align="center">
        	<tr>
            	<th><?php echo $row['address'] . ", " . $row['city'] . " PH: " .$row['phone']; ?></th>
            </tr>
        	<tr>
            	<th><strong>Software Developed by: WESKIA</strong></th>
            </tr>
			<tr>
            	<th><strong>Contact No: 0315-3152923</strong></th>
            </tr>
        </table>
    </div>
</body>
</html>