<!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']."_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");
$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']."_quotation_lines";
$line_query = "SELECT quote_item_text  FROM $table_name WHERE quote_number = '".$quote_no."' AND quote_option = '20' ";
$line_result = mySQL_query($line_query);
$line_num = mysql_num_rows($line_result);

$table_name = $_SESSION['db_prefix']."_quotation_lines";
$line2_query = "SELECT quote_item_text, quote_item_price  FROM $table_name WHERE quote_number = '".$quote_no."' AND quote_option = '21' ";
$line2_result = mySQL_query($line2_query);
$line2_num = mysql_num_rows($line2_result);


$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>';
if ($c3!='') { echo $c2.' '.$c3.'<br>'; }
if ($c4!='') { echo $c4; }
if ($c7!='') { echo '<br>email: '.$c7; }
?>
<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 'Q'.$quote_no?>
<br>
<br>
<br>
<b>Re: <?php echo $re_title ?></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 
$total_amount = 0;
$i=0;
while ($i<$line_num) {
  $quote_item_text = mysql_result($line_result, $i, "quote_item_text");
?>
  <tr>
    <td>&nbsp;&nbsp;&nbsp;<?php echo $quote_item_text?>&nbsp;</td>
    </tr>
  <?php
  $i++;
}
?>
</table>

<br>
<?php
    $table_name = $_SESSION['db_prefix']."_quotation_lines";
    $line_query = "SELECT quote_item_text  FROM $table_name WHERE quote_number = '".$quote_no."' AND quote_option = '1' AND quote_item_price = 0 ";
    $line_result = mySQL_query($line_query);
    $line_num = mysql_num_rows($line_result);
    
    $table_name = $_SESSION['db_prefix']."_quotation_lines";
    $line2_query = "SELECT quote_item_text, quote_item_price  FROM $table_name WHERE quote_number = '".$quote_no."' AND quote_option = '11' AND quote_item_price > 0 ";
    $line2_result = mySQL_query($line2_query);
    $line2_num = mysql_num_rows($line2_result);
    ?>  
       <table width="572" border=0 style="border-collapse:collapse;">
       <tr>
          <td colspan="3"><b>Option 1:</b></td>
         </tr>
      <?php
    $i=0;  
    while ($i<$line_num) {
      $d1 = mysql_result($line_result, $i, "quote_item_text");
       ?>
            <tr>
              <td width="59" align="right">&#8226;</td>
              <td width="296"><?php echo $d1 ?></td>
              <td>&nbsp;</td>
            </tr>
            <?php
    $i++;
    }
    ?>
      <?php
    $i=0;  
    while ($i<$line2_num) {
      $d1 = mysql_result($line2_result, $i, "quote_item_text");
      $d2 = mysql_result($line2_result, $i, "quote_item_price");
       ?>
            <tr>
              <td height="33" colspan="2" valign="bottom" style="border-bottom:solid; border-bottom-width:2px;"><b><?php echo $d1 ?></b></td>
              <td width="203" valign="bottom" style="border-bottom:solid; border-bottom-width:2px;"><div align="right"><b>P <?php if($d2!=0) { echo number_format($d2, 2, '.', ',');} else { echo '----'; } ?></b></div></td>
         </tr>
            <?php
    $i++;
    }
    ?>
      </table>
      <?php 
      $table_name = $_SESSION['db_prefix']."_quotation_lines";
    $line_query = "SELECT quote_item_text  FROM $table_name WHERE quote_number = '".$quote_no."' AND quote_option = '2' AND quote_item_price = 0 ";
    $line_result = mySQL_query($line_query);
    $line_num = mysql_num_rows($line_result);
    
    $table_name = $_SESSION['db_prefix']."_quotation_lines";
    $line2_query = "SELECT quote_item_text, quote_item_price  FROM $table_name WHERE quote_number = '".$quote_no."' AND quote_option = '22' AND quote_item_price > 0 ";
    $line2_result = mySQL_query($line2_query);
    $line2_num = mysql_num_rows($line2_result);
    ?> <br />
<br />
    <?php if ($line_num>0) { ?>
    <table width="572" border=0 style="border-collapse:collapse;">
       <tr>
          <td colspan="3"><b>Option 2:</b></td>
         </tr>
      <?php
    $i=0;  
    while ($i<$line_num) {
      $d1 = mysql_result($line_result, $i, "quote_item_text");
       ?>
            <tr>
              <td width="59" align="right">&#8226;</td>
              <td width="296"><?php echo $d1 ?></td>
              <td>&nbsp;</td>
            </tr>
            <?php
    $i++;
    }
    ?>
      <?php
    $i=0;  
    while ($i<$line2_num) {
      $d1 = mysql_result($line2_result, $i, "quote_item_text");
      $d2 = mysql_result($line2_result, $i, "quote_item_price");
       ?>
            <tr>
              <td height="39" colspan="2" valign="bottom" style="border-bottom:solid; border-bottom-width:2px;"><b><?php echo $d1 ?></b></td>
              <td width="203" valign="bottom" style="border-bottom:solid; border-bottom-width:2px;"><div align="right"><b>P <?php if($d2!=0) { echo number_format($d2, 2, '.', ',');} else { echo '----'; } ?></b></div></td>
            </tr>
            <?php
    $i++;
    }
    ?>
      </table>
      
      
      
      <?php 
      $table_name = $_SESSION['db_prefix']."_quotation_lines";
    $line_query = "SELECT quote_item_text  FROM $table_name WHERE quote_number = '".$quote_no."' AND quote_option = '3' AND quote_item_price = 0 ";
    $line_result = mySQL_query($line_query);
    $line_num = mysql_num_rows($line_result);
    
    $table_name = $_SESSION['db_prefix']."_quotation_lines";
    $line2_query = "SELECT quote_item_text, quote_item_price  FROM $table_name WHERE quote_number = '".$quote_no."' AND quote_option = '33' AND quote_item_price > 0 ";
    $line2_result = mySQL_query($line2_query);
    $line2_num = mysql_num_rows($line2_result);
    ?> <br />
<br />
    <?php if ($line_num>0) { ?>
    <table width="572" border=0 style="border-collapse:collapse;">
       <tr>
          <td colspan="3"><b>Option 3:</b></td>
         </tr>
      <?php
    $i=0;  
    while ($i<$line_num) {
      $d1 = mysql_result($line_result, $i, "quote_item_text");
       ?>
            <tr>
              <td width="59" align="right">&#8226;</td>
              <td width="296"><?php echo $d1 ?></td>
              <td>&nbsp;</td>
            </tr>
            <?php
    $i++;
    }
    ?>
      <?php
    $i=0;  
    while ($i<$line2_num) {
      $d1 = mysql_result($line2_result, $i, "quote_item_text");
      $d2 = mysql_result($line2_result, $i, "quote_item_price");
       ?>
            <tr>
              <td height="39" colspan="2" valign="bottom" style="border-bottom:solid; border-bottom-width:2px;"><b><?php echo $d1 ?></b></td>
              <td width="203" valign="bottom" style="border-bottom:solid; border-bottom-width:2px;"><div align="right"><b>P <?php if($d2!=0) { echo number_format($d2, 2, '.', ',');} else { echo '----'; } ?></b></div></td>
            </tr>
            <?php
    $i++;
    }
  }
    ?>
      </table>
      
      <?php 
      $table_name = $_SESSION['db_prefix']."_quotation_lines";
    $line_query = "SELECT quote_item_text  FROM $table_name WHERE quote_number = '".$quote_no."' AND quote_option = '4' AND quote_item_price = 0 ";
    $line_result = mySQL_query($line_query);
    $line_num = mysql_num_rows($line_result);
    
    $table_name = $_SESSION['db_prefix']."_quotation_lines";
    $line2_query = "SELECT quote_item_text, quote_item_price  FROM $table_name WHERE quote_number = '".$quote_no."' AND quote_option = '44' AND quote_item_price > 0 ";
    $line2_result = mySQL_query($line2_query);
    $line2_num = mysql_num_rows($line2_result);
    ?> <br />
<br />
    <?php if ($line_num>0) { ?>
    <table width="572" border=0 style="border-collapse:collapse;">
       <tr>
          <td colspan="3"><b>Option 4:</b></td>
         </tr>
      <?php
    $i=0;  
    while ($i<$line_num) {
      $d1 = mysql_result($line_result, $i, "quote_item_text");
       ?>
            <tr>
              <td width="59" align="right">&#8226;</td>
              <td width="296"><?php echo $d1 ?></td>
              <td>&nbsp;</td>
            </tr>
            <?php
    $i++;
    }
    ?>
      <?php
    $i=0;  
    while ($i<$line2_num) {
      $d1 = mysql_result($line2_result, $i, "quote_item_text");
      $d2 = mysql_result($line2_result, $i, "quote_item_price");
       ?>
            <tr>
              <td height="39" colspan="2" valign="bottom" style="border-bottom:solid; border-bottom-width:2px;"><b><?php echo $d1 ?></b></td>
              <td width="203" valign="bottom" style="border-bottom:solid; border-bottom-width:2px;"><div align="right"><b>P <?php if($d2!=0) { echo number_format($d2, 2, '.', ',');} else { echo '----'; } ?></b></div></td>
            </tr>
            <?php
    $i++;
    }
  }
    ?>
      </table>
      
      <?php 
      $table_name = $_SESSION['db_prefix']."_quotation_lines";
    $line_query = "SELECT quote_item_text  FROM $table_name WHERE quote_number = '".$quote_no."' AND quote_option = '5' AND quote_item_price = 0 ";
    $line_result = mySQL_query($line_query);
    $line_num = mysql_num_rows($line_result);
    
    $table_name = $_SESSION['db_prefix']."_quotation_lines";
    $line2_query = "SELECT quote_item_text, quote_item_price  FROM $table_name WHERE quote_number = '".$quote_no."' AND quote_option = '55' AND quote_item_price > 0 ";
    $line2_result = mySQL_query($line2_query);
    $line2_num = mysql_num_rows($line2_result);
    ?> <br />
<br />
    <?php if ($line_num>0) { ?>
    <table width="572" border=0 style="border-collapse:collapse;">
       <tr>
          <td colspan="3"><b>Option 5:</b></td>
         </tr>
      <?php
    $i=0;  
    while ($i<$line_num) {
      $d1 = mysql_result($line_result, $i, "quote_item_text");
       ?>
            <tr>
              <td width="59" align="right">&#8226;</td>
              <td width="296"><?php echo $d1 ?></td>
              <td>&nbsp;</td>
            </tr>
            <?php
    $i++;
    }
    ?>
      <?php
    $i=0;  
    while ($i<$line2_num) {
      $d1 = mysql_result($line2_result, $i, "quote_item_text");
      $d2 = mysql_result($line2_result, $i, "quote_item_price");
       ?>
            <tr>
              <td height="39" colspan="2" valign="bottom" style="border-bottom:solid; border-bottom-width:2px;"><b><?php echo $d1 ?></b></td>
              <td width="203" valign="bottom" style="border-bottom:solid; border-bottom-width:2px;"><div align="right"><b>P <?php if($d2!=0) { echo number_format($d2, 2, '.', ',');} else { echo '----'; } ?></b></div></td>
            </tr>
            <?php
    $i++;
    }
  }
    ?>
      </table>
      
      
    <?php } ?>  
<br>
<br>

<u>Terms</u><br>
Payment: <?php echo $terms ?>.<br>
Delivery: <?php echo $delivery_days ?> days.<br>
Price valid for: <?php echo $valid_days ?> days.<br>
Prices <?php echo $vat ?> 14% VAT<br><br>
<br>
<br>
Yours faithfully
<br>
<br>
<br>
<?php echo $sales_rep ?>
</div>
</div>

</body>
</html>