<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<?php
include('../include/session.php');

$quote_no = $_GET['quote_no'];



$table_name2 = $_SESSION['db_prefix']."_maintenance_quotations";
$quote_query = "SELECT * FROM $table_name2 WHERE quote_no ='".$quote_no."' ";
$quote_result = mySQL_query($quote_query);
$quote_num = mysql_num_rows($quote_result);
$cust_id  = mysql_result($quote_result, 0, "cust_id");
$quotation_date  = mysql_result($quote_result, 0, "quotation_date");
$project  = mysql_result($quote_result, 0, "project");
//$job_card_no  = mysql_result($quote_result, 0, "job_card_no");
$valid_days   = mysql_result($quote_result, 0, "valid_days");
$delivery_days   = mysql_result($quote_result, 0, "delivery_days");
$terms   = mysql_result($quote_result, 0, "terms");
$vat   = mysql_result($quote_result, 0, "vat_text");
$re_title   = mysql_result($quote_result, 0, "re_title");
$sales_rep =  mysql_result($quote_result, 0, "seller");


$table_name = $_SESSION['db_prefix']."_maintenance_quotation_lines";
$line2_query = "SELECT quote_option_text, quote_item_text, quote_item_price  FROM $table_name WHERE quote_number = '".$quote_no."' ";
$line2_result = mySQL_query($line2_query);
$line2_num = mysql_num_rows($line2_result);
$re_text = mysql_result($line2_result, 0, "quote_option_text");

$table_name3 = $_SESSION['db_prefix']."_customer";
$customer_query = "SELECT account_type, comp_name, name_2, title, bag_box, box_no, postal_place, phone, contact_1, email_1, cell_1, status FROM $table_name3 WHERE cust_id = '".$cust_id."' ";
$customer_result = mySQL_query($customer_query);
$c0 = mysql_result($customer_result, 0, "account_type");
if ($c0=="corporate") { $c1 = mysql_result($customer_result, 0, "comp_name"); } else { $c1 = mysql_result($customer_result, 0, "title")." ".mysql_result($customer_result, 0, "name_2")." ".mysql_result($customer_result, 0, "comp_name"); }

$c2 = mysql_result($customer_result, 0, "bag_box");
$c3 = mysql_result($customer_result, 0, "box_no");
$c4 = mysql_result($customer_result, 0, "postal_place");
$c5 = mysql_result($customer_result, 0, "phone");
$c6 = mysql_result($customer_result, 0, "contact_1");
$c7 = mysql_result($customer_result, 0, "email_1");
$c8 = mysql_result($customer_result, 0, "status");
$c9 = mysql_result($customer_result, 0, "cell_1");

?>

<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/print.css" />

<title>Quotation <?php echo $quote_no ?> for <?php echo $c1 ?></title>
<style>
body {
  font-family:Arial, Helvetica, sans-serif;
  font-size:12px;
}
</style>
</head>
<body  onload="window.print(); window.close();" >
<div style="width:800px;">
<?php include('../include/print_header.php'); ?>


<div style="width:650px; margin-left:50px; font-family:'Arial, Helvetica, sans-serif; font-size:14px;"><br>
<br>
<?php 
echo $c1.'<br>';
echo $c2.' '.$c3.'<br>';
echo $c4;
?>
<br>
<br>
<br>

Date: <?php echo date("d-m-Y", strtotime($quotation_date)); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ref: <?php echo 'M'.$quote_no?>
<br>
<br>
<br>
<b><u>Re: <?php echo $re_text; ?></u></b>
<br>
<br>
<br>
Dear Sir/Madam,
<br>
<br>

Thank you for your enquiry. Herewith our quotation for the above requirements. <br>
<br>


<table width="542" border="0" style="border-collapse:collapse;">
<?php
$sub_total_amount = 0; 
$total_amount = 0;
$i=0;
while ($i<$line2_num) {
  $quote_item_text = mysql_result($line2_result, $i, "quote_item_text");
  $quote_price = mysql_result($line2_result, $i, "quote_item_price");
  $sub_total_amount = $sub_total_amount + $quote_price;
  
?>
  <tr>
    <td width="439">&nbsp;&nbsp;&nbsp;<?php echo $quote_item_text?>&nbsp;</td>
    <td width="26" align="center">P</td>
    <td width="63" align="right">&nbsp;&nbsp;&nbsp;<?php echo number_format($quote_price, 2, '.', ',')?>&nbsp;</td>
    </tr>
  <?php
  $i++;
}
?>
<tr>
    <td align="right">Sub total&nbsp;&nbsp;</td>
    <td align="center">P</td>
    <td align="right"><?php echo number_format($sub_total_amount, 2, '.', ',') ?></td>
    </tr>
<tr>
  <td align="right">&nbsp;Add <?php echo $vat ?>% VAT
    <?php $VAT_amount = $sub_total_amount * ($vat/100) ?></td>
  <td align="center">P</td>
  <td align="right"><?php echo number_format($VAT_amount, 2, '.', ',')?></td>
</tr>
<tr style="border-bottom:thick; border-bottom:solid;">
  <td height="41" align="<?php $total_amount = $sub_total_amount + $VAT_amount ?>" valign="bottom"><b>Total Price Supply &amp; Install</b></td>
  <td align="center" valign="bottom"><b>P</b></td>
  <td align="right" valign="bottom"><b><?php echo number_format($total_amount, 2, '.', ',') ?></b></td>
</tr>
</table>

<br>
<br>
<b><u>Confirmation / Acceptance of Quotation</u></b><br>

I/we accept the quoatation & terms set out<br><br>

Signed:  ..............................  Date:  ..... - ..... - .........
<br>
<br>
<br>
<br>

      
      
<br>
<br>

<u>Terms of Sale </u> <br>
Delivery: <?php echo $delivery_days ?> days.<br>
Price valid for: <?php echo $valid_days ?> days.<br>
<b>Prices include 14% VAT</b><br>
<b>If acceptable , please sign and return to us so that we may proceed with the maintenance.</b><br>
<b><u>Bank details</u></b><br>
<table width="632" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="123">Account Name:</td>
    <td width="205">Manase Construction</td>
    <td width="120">Account Name:</td>
    <td width="184">Manase Construction</td>
  </tr>
  <tr>
    <td>Bank:</td>
    <td>First National Bank</td>
    <td>Bank:</td>
    <td>Barclays Bank of Botswana</td>
  </tr>
  <tr>
    <td>Branch</td>
    <td>Main</td>
    <td>Branch</td>
    <td>Barclays Corporate Branch</td>
  </tr>
  <tr>
    <td>Branch Code</td>
    <td>281467</td>
    <td>Branch Code</td>
    <td>290267</td>
  </tr>
  <tr>
    <td>Account Number:</td>
    <td>621 314 65 123</td>
    <td>Account Number:</td>
    <td>1021202</td>
  </tr>
</table>

<br>
<br>
<br>
<br>
<?php echo $sales_rep ?>
</div>
</div>

</body>
</html>