<?php include 'inc/conx.php';
setlocale(LC_MONETARY, 'en_US');
?>
<?php include 'numbertoword.php'; ?>

<!DOCTYPE html>
	<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>
		</title>
	<style>
		.text-center{
			text-align:center;
		}
		.text-left{
			text-align:left;
		}
		.text-right{
			text-align:right;
		}
		*{
			margin:0px !important;
		}
		.col-md-3{
				width:25%;
				float: left;
		}
		.invoice_desc{
			margin-top:20px !important;
			text-align:center;
			overflow: hidden;
		}
		/*table{
			width: 95%;
			margin-right:auto !important;
			margin-left:auto !important;
			margin-top: 30px !important; 
			
		}
		table th, td{
			text-align:left;
		}
		thead th{
			border:1.5px solid;
			padding: 0px !important;
		}
		.item_table table thead td{
			text-align:left;
			border-bottom: 2px solid;	
			border-right:2px solid;
			padding: 0px;
		}
		tbody th, td{
			text-align:left;
			border-bottom : 1px dotted;
		}*/
		#itemsNames thead th {
				border:1px solid #000;
				border-bottom:3px solid #000;
				font-size:12px;
				/*font-size:11px;*/
		}
		#itemsNames tbody td {
				border:1px dotted #000;
				font-size:12px;
		}
		#itemsNames{
			margin-left:auto !important;
			margin-right:auto !important;
			position: relative;

		}

		#simple_table 
		{
			position: relative;
			margin-left:auto !important;
			margin-right:auto !important;
			margin-top: 20px;
		}

	</style>
	</head>
	<body>
	 <?php
			    	$store = $db->query("SELECT * FROM store");
			    	$fdata = $store->fetchArray();
	?>
	<?php 
			$allData = $db->query("SELECT * FROM quotations WHERE invoiceNo = '".$_GET['saleid']."'");
			$fDatarow = $allData->fetchArray();
	?>

		<div class="wrapper">
	<h3 class="text-center"><?php echo $fdata['name']; ?></h3>
	<p class="text-center"> <?php echo $fdata['address']; ?> <br><?php echo $fdata['city']; ?> - <?php echo $fdata['phone']; ?></p>
	<!-- <p class="text-center"> & </p>
	<p class="text-center"> Book Bank</p> -->
		</div>

		<table width="95%" id="simple_table" cellpadding="0" cellspacing="0">
			<tr>
				<td colspan="2">
				<div class="wrapper" style="position: relative; border: 2px solid #eee;">
					<div style="
    position: absolute;
    border: 2px solid #000;
    top: -20px;
    padding: 10px;
    font-weight: bold;
    box-shadow: 3px 3px;
	background-color: #fff;
	left: -3px;
">
						Quotation
					</div>
				</div>
				</td>
			</tr>
		</table>
		<table width="95%" id="simple_table" style="top: 30px;" cellpadding="0" cellspacing="0">
			
			<tr>
				<td><strong>Quotation#</strong> <?php echo $_GET['saleid'];?></td>
				<td><strong>DATE:</strong> <?php echo $fDatarow['show_date']; ?></td>
			</tr>
			<tr>
				<td><strong>To,</strong> <ins><?php echo $fDatarow['name_word']; ?></ins></td>
				<td><strong>User:</strong> <?php echo $fDatarow['user_name']; ?></td>
			</tr>
		</table>
		<!-- <div class="item_table">
			<table>
				<thead>
					<tr>
						<th>Item Name</th>
						<th>Qty</th>
						<th>Rate</th>
						<th>Dis</th>
						<th>Amount</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td>Ppc</td>
						<td>5</td>
						<td>290</td>
						<td>0</td>
						<td>1450</td>
					</tr>
					<tr>
						<td>Ppc</td>
						<td>5</td>
						<td>290</td>
						<td>0</td>
						<td>1450</td>
					</tr>
				</tbody>
			</table>
		</div> -->
		
		<table width="95%" id="itemsNames" style="top: 50px;" cellpadding="0" cellspacing="0">
        <thead>
        	<th align="left">Item Name</th>
           	<th align="left">Qty.</th>
            <th align="left">Rate</th>
            <th align="left">Amount</th>
        </thead>
        <tbody>
     <?php 
			    	$select = $db->query("SELECT * FROM quotations WHERE invoiceNo = '".$_GET['saleid']."'");
			    	$qty = 0 ;
			    	$total = 0;
			    	$tdis = 0;
			    	$tdisp =0;
			    	$rt = 0;
			    	while($row = $select->fetchArray()){
			    		$qty += $row['qty'];
			    		$total += $row['total'];
			    		$rt += $row['sell'] * $row['qty'];
			    		$tdis += ($row['discount_rs']) ? $row['discount_rs'] : 0;
			    		$tdisp += ($row['discount_pr']) ? $row['discount_pr'] : 0; 
	?>
	
    	<tr>
			
            <td align="center"><?php echo $row['item_name']; ?></td>
           <td align="center" style="border-left: none;"><?php echo $row['qty']; ?></td>
            <td align="center" style="border-left: none;"><?php echo $row['sell']; ?></td>
            <td align="center" style="border-left: none;"><?php echo $row['total']; ?></td>
        </tr>
 <?php } ?>
      </tbody>
</table>

<style>
	.totalCal {
			table-layout: fixed;
			font-size: 11px;
			margin-right:31px !important;
		}
	.totalCal td{
		text-align: right;
		border-bottom:1px solid;

	}
</style>
<?php 
	$select = $db->query("SELECT * FROM quotations WHERE invoiceNo = '".$_GET['saleid']."'");
	$runtotal = $select->fetchArray();
?>
<table align="left" width="95%" style="position: relative; top: 50px; left: 30px;">
<tr>
	<td>
		<ins><strong><?php echo ucwords(number_to_words(ceil(@$runtotal['grand_total']))); ?> Only</strong></ins>
	</td>
</tr>
</table>

<table align="right" class="totalCal" style="position: relative; top: 50px;">
	<tr>
		<th>Total Qty</th>
		<td><?php echo $qty; ?></td>
	</tr>
	<tr style="font-size:11px">	
		<th>Total Amount</th>
		<td><?php echo $runtotal['grand_total']; ?></td>
	</tr>
	</table>

<div class="policy" style="position: relative; top: 50px; left: 30px; overflow:hidden; width:100%;">
	<strong><ins><?php echo $runtotal['description']; ?></ins></strong>
</div>
<div class="shopdesc" style="width:100%; position: relative; top: 50px; text-align:center ; font-size: 11px;">
	<p>Software Developed By WESKIA - 03153152923</p>
</div>


	</body>
	</html>	
<script>
    window.print();
</script>