<!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=utf-8" />

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

$quote_no = $_GET['quote_no'];
	
$table_name2 = $_SESSION['db_prefix']."_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");
$quote_type  = mysql_result($quote_result, 0, "quote_type");
$cplx  = mysql_result($quote_result, 0, "cplx");
		if ($cplx=='0.8') {$cplx_display='1';}
		if ($cplx=='1') {$cplx_display='2';}
		if ($cplx=='1.2') {$cplx_display='3';}
$storey  = mysql_result($quote_result, 0, "storey");
$quote_discount  = mysql_result($quote_result, 0, "quote_discount");
$quote_vat  = mysql_result($quote_result, 0, "quote_vat");
$branch  = mysql_result($quote_result, 0, "branch");
$project_no = mysql_result($quote_result, 0, "project_no");
$project_place = mysql_result($quote_result, 0, "project_place");
$notes = mysql_result($quote_result, 0, "notes");
$sales_rep = mysql_result($quote_result, 0, "seller");
$transport = mysql_result($quote_result, 0, "transport");


$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");

$customerTT = "<label class=tip_text_label>".$c1."<br>".$c2." ".$c3."<br>".$c4."<br>".$c5."<br>".$c6."<br><label class=tip_click_label>Click for details</label>";

$table_name = $_SESSION['db_prefix']."_quotation_notes";	
$notes_query = "SELECT  *   FROM $table_name WHERE quote_number = '".$quote_no."' ";
$notes_result = mySQL_query($notes_query);
$notes_num = mysql_num_rows($notes_result);

$table_name = $_SESSION['db_prefix']."_quotation_accept";
$accept_query = "SELECT accept_value, receipt_no, order_no FROM $table_name WHERE quote_no = '".$quote_no."' ORDER BY accept_id DESC LIMIT 1 ";
$accept_result = mySQL_query($accept_query);
$accept_num = mysql_num_rows($accept_result);
if ($accept_num!=0) {
		$value = mysql_result($accept_result, 0, "accept_value");
		$receipt_no = mysql_result($accept_result, 0, "receipt_no");
		$order_no = mysql_result($accept_result, 0, "order_no");
		
}
else {
	$value = '';
}
$report_name = 'Quotation';
$report_no = $quote_no;
?>

<!--style sheets-->
<link href="../css/print.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" type="image/x-icon" href="../images/favicon.ico">
<title>Install quotation <?php echo $quote_no ?></title>
</head>

<body>

<script>
window.onload = function () {
  window.print();
  setTimeout(function(){window.close();}, 100);
}
</script>


<div class="print_standard_frame">
<?php include('../include/print_header.php'); ?>
<div class="print_main_frame" style="height:auto; margin-left:50px;">
<br>
<br>

<div class="print_standard_frame"> 
<label class="print_header_label_std">Quotation for:</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<label class="print_header_label_std">Quoatation date:&nbsp;&nbsp;
<?php echo date("d-m-Y", strtotime($quotation_date)) ?></label><br /><br />

              <?php 
		include ('../include/customer_block.php');
		echo' <br>';
		?>
       </div>
<div class="print_standard_frame">
<label class="print_header_label_std">Delivery address:</label>
<br />
<br>
<table width="650" id="table_display" >
  <tr>
    <td width="112">Plot no:</td>
    <td width="132"><?php echo $project_no ?></td>
    <td width="146">Place:;</td>
    <td width="240"><?php echo $project_place ?></td>
  </tr>
  <tr>
    <td>Quotation made by:</td>
    <td><?php echo $branch ?> branch</td>
    <td>Sales representative:</td>
    <td><?php echo $sales_rep ?></td>
    </tr>
</table>
</div>           
    <div class="print_standard_frame"> <label class="print_header_label_std">Pricing details
      &nbsp;&nbsp;<font size="+1">INSTALLATION ONLY</font></label><br />

<?php

$table_name = $_SESSION['db_prefix']."_quotation_lines";
$line_query = "SELECT *  FROM $table_name WHERE  quote_no =  '".$quote_no."'";
$line_result = mySQL_query($line_query);
$line_num = mysql_num_rows($line_result);
?>

<br />


<label class="print_header_label_std">Installation of Trusses and loose timbers &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CPLX: <?php echo  $cplx_display ?>&nbsp;&nbsp;&nbsp;Double storey:&nbsp;<?php echo $storey?></label>
<table width="650" id="table_details_display">
  <tr>
    <td width="426">Description</td>
    <td width="56">Quantity</td>
    <td width="46">Unit</td>
    <td width="60">Price/Unit</td>
    <td width="58">Total</td>
  </tr>
  <tr>
  <?php
  	$sub_total = 0;
  	$table_name = $_SESSION['db_prefix']."_quotation_lines";
	$data_query = "SELECT quantity, price, purchase_price FROM $table_name WHERE truss_item = 'truss_M2' and quote_no = '".$quote_no."'" ;
	$data_result = mySQL_query($data_query);
	$quantity = mysql_result($data_result, 0, "quantity");
	$price = mysql_result($data_result, 0, "price");
	$purchase_price = mysql_result($data_result, 0, "purchase_price");
	$sub_total = $sub_total + $purchase_price;
	?>
    <td>Installation of trusses, inclusive of wall plates, bracing, runners, battens,underlay and valley linings, all as indicated on roof layouts.</td>
    <td><?php if ($quantity!=0) {echo number_format($quantity, 2, '.', ','); } ?></td>
    <td align="center">M2</td>
    <td align="right"><?php echo number_format($price, 2, '.', ',') ?></td>
    <td align="right"><?php if ($purchase_price!=0) echo $purchase_price ?></td>
  </tr>
  <tr>
  <?php
  	$table_name = $_SESSION['db_prefix']."_quotation_lines";
	$data_query = "SELECT quantity, price, purchase_price FROM $table_name WHERE truss_item = 'truss_M1' and quote_no = '".$quote_no."'" ;
	$data_result = mySQL_query($data_query);
	$quantity = mysql_result($data_result, 0, "quantity");
	$price = mysql_result($data_result, 0, "price");
	$purchase_price = mysql_result($data_result, 0, "purchase_price");
	$sub_total = $sub_total + $purchase_price;
	?>
    <td>Install fascia and barge boards.</td>
    <td><?php if ($quantity!=0) {echo number_format($quantity, 2, '.', ','); } ?></td>
    <td align="center">M1</td>
    <td align="right"><?php echo number_format($price, 2, '.', ',') ?></td>
    <td align="right"><?php if ($purchase_price!=0) echo $purchase_price ?></td>
  </tr>
  <tr>
  <?php
  	$table_name = $_SESSION['db_prefix']."_quotation_lines";
	$data_query = "SELECT quantity, price, purchase_price FROM $table_name WHERE truss_item = 'truss_No' and quote_no = '".$quote_no."'" ;
	$data_result = mySQL_query($data_query);
	$quantity = mysql_result($data_result, 0, "quantity");
	$price = mysql_result($data_result, 0, "price");
	$purchase_price = mysql_result($data_result, 0, "purchase_price");
	$sub_total = $sub_total + $purchase_price;
	?>
    <td>Supply and install rawbolts for trusses fixed to brickwork or concrete.</td>
    <td><?php if ($quantity!=0) {echo number_format($quantity, 2, '.', ','); } ?></td>
    <td align="center">NO</td>
    <td align="right"><?php echo number_format($price, 2, '.', ',') ?></td>
    <td align="right"><?php if ($purchase_price!=0) echo $purchase_price ?></td>
  </tr>
</table><br>
<label class="print_header_label_std">Installation of concrete roof tiles</label><br>
<table width="650" id="table_details_display">
  <tr>
    <td width="426">Description</td>
    <td width="56">Quantity</td>
    <td width="46">Unit</td>
    <td width="60">Price/Unit</td>
    <td width="58">Total</td>
  </tr>
  <tr>
  <?php
  	$table_name = $_SESSION['db_prefix']."_quotation_lines";
	$data_query = "SELECT quantity, price, purchase_price FROM $table_name WHERE truss_item = 'tiles_M2' and quote_no = '".$quote_no."'" ;
	$data_result = mySQL_query($data_query);
	$quantity = mysql_result($data_result, 0, "quantity");
	$price = mysql_result($data_result, 0, "price");
	$purchase_price = mysql_result($data_result, 0, "purchase_price");
	$sub_total = $sub_total + $purchase_price;
	?>
    <td>Installation of concrete roof tiles, incl of cutting for valley- and hip tiles, all as indicated on roof layout</td>
    <td><?php if ($quantity!=0) {echo number_format($quantity, 2, '.', ','); } ?></td>
    <td align="center">M2</td>
    <td align="right"><?php echo number_format($price, 2, '.', ',') ?></td>
    <td align="right"><?php if ($purchase_price!=0) echo $purchase_price ?></td>
  </tr>
  <tr>
  <?php
  	$table_name = $_SESSION['db_prefix']."_quotation_lines";
	$data_query = "SELECT quantity, price, purchase_price FROM $table_name WHERE truss_item = 'tiles_M1' and quote_no = '".$quote_no."'" ;
	$data_result = mySQL_query($data_query);
	$quantity = mysql_result($data_result, 0, "quantity");
	$price = mysql_result($data_result, 0, "price");
	$purchase_price = mysql_result($data_result, 0, "purchase_price");
	$sub_total = $sub_total + $purchase_price;
	?>
    <td>Installation of ridge, hip and rake verge tiles (incl. of paint and dpc)</td>
    <td><?php if ($quantity!=0) {echo number_format($quantity, 2, '.', ','); } ?></td>
    <td align="center">M1</td>
    <td align="right"><?php echo number_format($price, 2, '.', ',') ?></td>
    <td align="right"><?php if ($purchase_price!=0) echo $purchase_price ?></td>
  </tr>
  <tr>
  <?php
  	$table_name = $_SESSION['db_prefix']."_quotation_lines";
	$data_query = "SELECT quantity, price, purchase_price FROM $table_name WHERE truss_item = 'tiles_M3' and quote_no = '".$quote_no."'" ;
	$data_result = mySQL_query($data_query);
	$quantity = mysql_result($data_result, 0, "quantity");
	$price = mysql_result($data_result, 0, "price");
	$purchase_price = mysql_result($data_result, 0, "purchase_price");
	$sub_total = $sub_total + $purchase_price;
	?>
    <td>Installation of valley gutters</td>
    <td><?php if ($quantity!=0) {echo number_format($quantity, 2, '.', ','); } ?></td>
    <td align="center">M1</td>
    <td align="right"><?php echo number_format($price, 2, '.', ',') ?></td>
    <td align="right"><?php if ($purchase_price!=0) echo $purchase_price ?></td>
  </tr>
</table><br>

<label class="print_header_label_std">Engineering inspection</label>
<table width="650" id="table_details_display">
  <tr>
    <td width="426">Description</td>
    <td width="56">Quantity</td>
    <td width="46">Unit</td>
    <td width="60">Price/Unit</td>
    <td width="58">Total</td>
  </tr>
  <tr>
  <?php
  	$table_name = $_SESSION['db_prefix']."_quotation_lines";
	$data_query = "SELECT quantity, price, purchase_price FROM $table_name WHERE truss_item = 'inspection' and quote_no = '".$quote_no."'" ;
	$data_result = mySQL_query($data_query);
	$quantity = mysql_result($data_result, 0, "quantity");
	$price = mysql_result($data_result, 0, "price");
	$purchase_price = mysql_result($data_result, 0, "purchase_price");
	$sub_total = $sub_total + $purchase_price;
	?>
    <td>Engineering inspection</td>
    <td><?php if ($quantity!=0) {echo number_format($quantity, 2, '.', ','); } ?></td>
    <td align="center">NO</td>
    <td align="right"><?php echo number_format($price, 2, '.', ',') ?></td>
    <td align="right"><?php if ($purchase_price!=0) echo $purchase_price ?></td>
  </tr>
</table>
<br>
<label class="print_header_label_std">Additional work</label><br>
<table width="650" id="table_details_display">
  <tr>
    <td width="426">Description</td>
    <td width="56">Quantity</td>
    <td width="46">Unit</td>
    <td width="60">Price/Unit</td>
    <td width="58">Total</td>
  </tr>
  <tr>
  <?php
  	$table_name = $_SESSION['db_prefix']."_quotation_lines";
	$data_query = "SELECT additional_text, quantity, price, purchase_price FROM $table_name WHERE truss_item = 'add_1' and quote_no = '".$quote_no."'" ;
	$data_result = mySQL_query($data_query);
	$additional_text = mysql_result($data_result, 0, "additional_text");
	$quantity = mysql_result($data_result, 0, "quantity");
	$price = mysql_result($data_result, 0, "price");
	$purchase_price = mysql_result($data_result, 0, "purchase_price");
	$sub_total = $sub_total + $purchase_price;
	?>
    <td><?php echo $additional_text ?></td>
    <td><?php if ($quantity!=0) {echo number_format($quantity, 2, '.', ','); } ?></td>
    <td align="center">.</td>
    <td align="right"><?php if ($price!=0) {echo $price; } ?></td>
    <td align="right"><?php if ($purchase_price!=0) echo $purchase_price ?></td>
  </tr>
  <tr>
  <?php
  	$table_name = $_SESSION['db_prefix']."_quotation_lines";
	$data_query = "SELECT additional_text, quantity, price, purchase_price FROM $table_name WHERE truss_item = 'add_2' and quote_no = '".$quote_no."'" ;
	$data_result = mySQL_query($data_query);
	$additional_text = mysql_result($data_result, 0, "additional_text");
	$quantity = mysql_result($data_result, 0, "quantity");
	$price = mysql_result($data_result, 0, "price");
	$purchase_price = mysql_result($data_result, 0, "purchase_price");
	$sub_total = $sub_total + $purchase_price;
	?>
    <td><?php echo $additional_text ?></td>
    <td><?php if ($quantity!=0) {echo number_format($quantity, 2, '.', ','); } ?></td>
    <td align="center">.</td>
    <td align="right"><?php if ($price!=0) {echo $price; } ?></td>
    <td align="right"><?php if ($purchase_price!=0) echo $purchase_price ?></td>
  </tr>
</table>
<br />
<table width="650" id="table_details_display">
  <tr>
    <td width="398" rowspan="7" valign="top"><font size="-2">NOTE:
      <?php $discount_amount = $sub_total * ($quote_discount/100) ?>
&nbsp;      <?php $sub_total2 = $sub_total - $discount_amount ?>
<?php $sub_total3 = $sub_total2 + $transport ?>
&nbsp;
<?php $vat_amount = $sub_total3 * ($quote_vat/100) ?>
&nbsp;
<?php $all_total = $sub_total3 + $vat_amount ?>
<br />
ACCESS SCAFFOLDING TO BE SUPPLIED BY CLIENT<br />
CEMENT, RIVER SAND FOR RIDGE AND HIP TILES TO BE SUPPLIED BY THE CLIENT<br />
AREAS ARE MEASURED IN ROOF AREA AND NOT FLOOR AREA<br />
ALL WATERPROOFING AND FLASHING INCL. PARAPET WALLS &amp; CHIMNEYS TO BE CARRIED OUT BY CLIENT<br />
STANDARD ONE TILE GABLE OVERHANG INCLUDED UNLESS OTHERWISE INDICATED<br />
THE USE OF UNDERLAY IS MANDATORY AND SHOULD BE INSTALLED ACCORDING TO MANUFACTURURER'S INSTRUCTION<br />
FULL PAYMENT REQUIRED BEFORE COMMENCEMENT</font></td>
    <td width="116">Sub total:</td>
    <td width="120" align="right"><?php echo number_format($sub_total, 2, '.', ',') ?>&nbsp;</td>
  </tr>
  <tr>
    <td>Discount: <?php echo $quote_discount ?>%</td>
    <td align="right"><?php echo number_format($discount_amount, 2, '.', ',') ?></td>
  </tr>
  <tr>
    <td>Sub total:</td>
    <td align="right"><?php echo number_format($sub_total2, 2, '.', ',') ?></td>
  </tr>
  <tr>
    <td>Transport:</td>
    <td align="right"><?php if ($transport!='') { echo number_format($transport, 2, '.', ','); } else { echo '0.00'; } ?></td>
    </tr>
  <tr>
    <td>Sub total:</td>
    <td align="right" valign="top"><?php echo number_format($sub_total3, 2, '.', ',') ?></td>
    </tr>
  <tr>
    <td>VAT @ <?php echo $quote_vat ?>%</td>
    <td align="right"><?php echo number_format($vat_amount, 2, '.', ',') ?></td>
  </tr>
  <tr>
    <td>Total:</td>
    <td align="right"><?php echo number_format($all_total, 2, '.', ',') ?></td>
  </tr>
</table>
<br />
<table width="650" id="table_details_display">
  <tr>
    <td width="218">For Vertex:<br />
      <br />
Signed: ____________________<br />
<br />
<br />
Date:  &nbsp;&nbsp;&nbsp;&nbsp;____________________<br />
<br /></td>
    <td width="420">For acceptance signed by client:  &nbsp;&nbsp;_____________________________<br />
<br /><br />
Date:&nbsp; _____________________&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Plot no.:&nbsp;&nbsp;___________________</td>
  </tr>
  <tr>
    <td colspan="2">Our general sales conditions are applicable&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;errors &amp; omissions excluded&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prices quoted are valid for 30 days</td>
    </tr>
</table>
  

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

</body>
</html>