
<?php 
if ($_SESSION['quote_no']=='') {
?>
<script language="javascript" type="text/javascript">
          needToConfirm = false;
          window.location="maintenance_no_return.php";
</script>
<?php
}
else {
	
	?><head>

<link rel="stylesheet" type="text/css" href="../css/wizard.css" />

<?php
    $table_name = $_SESSION['db_prefix']."_maintenance_quotations";
	$quote_query = "SELECT cust_id, seller, company_contact, contact_phone, project_no, project_place, project_description  FROM $table_name WHERE  quote_no = '".$_SESSION['quote_no']."' ";
	$quote_result = mySQL_query($quote_query);
	$a1 = mysql_result($quote_result, 0, "cust_id");
	$a2 = mysql_result($quote_result, 0, "seller");
	$a3 = mysql_result($quote_result, 0, "company_contact");
	$a4 = mysql_result($quote_result, 0, "contact_phone");
	$a5 = mysql_result($quote_result, 0, "project_no");
	$a6 = mysql_result($quote_result, 0, "project_place");
	$a7 = mysql_result($quote_result, 0, "project_description");
	$cust_id = $a1;
	$maintenance_no = $_SESSION['quote_no'];
	$job_card_no='';
	
	$_SESSION['total_amount']=0;

//$quote_value = $_SESSION['quote_amount'] ;
$quote_value = '';
$quote = 'yes';

$table_name = $_SESSION['db_prefix']."_presets";
$vat_query = "SELECT preset_value FROM $table_name WHERE preset_name = 'VAT' ";
$vat_result = mySQL_query($vat_query);
$vat = mysql_result($vat_result, 0, "preset_value");
?>


</head>
<?php include('../include/wait.php') ?>



<link href="../css/wait.css" rel="stylesheet" type="text/css">
<body onLoad="MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');">
<div class="page_middle_frame">

<form id="feedbackform" method="get" action="maintenance_quoteWiz6.php" >
  <table width=595 border="0" align="center" cellpadding="10" cellspacing="0" bordercolor="#0066FF" border-collapse="collapse">
     <tr>
            <td width="525" ><div class="wizard_frame">
              <table width="650" id="table_details_display">
                <tr>
                  <td width="117">Quotation no:</td>
                  <td width="133">Q<?php echo $_SESSION['quote_no'] ?></td>
                  <td width="160">Quotation date:</td>
                  <td width="198"><?php echo date("d-m-Y", strtotime($_SESSION['quotation_date'])) ?></td>
                </tr>
                <tr>
                  <td>Sales rep:</span></td>
                  <td><?php echo  $a2 ?></td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
              </table>
            </div>
              <div class="wizard_frame" >
              <?php 
				include ('../include/customer_block.php');
				echo '<br>';
				include ('../include/maintenance_job_block.php')
			?>
              </div>
              
              <div class="wizard_frame">
              <table width="650" id="table_details_display">
                <tr>
                  <td colspan="4">Project details::</td>
                </tr>
                <tr>
                  <td width="123">Plot no:</td>
                  <td width="205"><?php echo $a5 ?></td>
                  <td width="109">Place:</td>
                  <td width="213"><?php echo $a6 ?></td>
                </tr>
                <tr>
                  <td>Project description:</td>
                  <td colspan="3"><?php echo $a7 ?></td>
                </tr>
              </table>
            </div>
            
<div class="wizard_frame">            
Re: <?php echo $_SESSION['option1_text'] ?>            
</div>            


<?php
if (($_SESSION['project']=='Maintenance Fence (Residential)') OR ($_SESSION['project']=='Maintenance Fence (Commercial)') OR ($_SESSION['project']=='Maintenance Gate Motor')  OR ($_SESSION['project']=='Maintenance miscellaneous')) { ?>
              <div class="wizard_frame">
                
                <table width="650" id="table_details_display">
                  <?php
				  $sub_total=0;
				  $vat_amount=0;
				  $total=0;
				  $i=0;
				  while ($i<$_SESSION['line_num3']) { 
				  ?>
                  <tr>
                    <td width="396"><?php echo $_SESSION['item_text3'.$i] ?></td>
                    <td width="220" ><div align="right">
                      <?php if ($_SESSION['amount_text3'.$i]!="") {echo number_format($_SESSION['amount_text3'.$i], 2, '.', ',');
					  $sub_total = $sub_total + $_SESSION['amount_text3'.$i]; } ?>
                    </div></td>
                  </tr>
                  <?php
				  $i++;
				  }
				  ?>
                  <tr>
                    <td align="right">Sub total</td>
                    <td align="right"><?php echo number_format($sub_total, 2, '.', ',') ?></td>
                  </tr>
                  <tr>
                    <td align="right">VAT <?php echo $vat?>% <?php $vat_amount = $sub_total * ($vat/100) ?> </td>
                    <td align="right"><?php echo number_format($vat_amount, 2, '.', ',') ?></td>
                  </tr>
                  <tr>
                    <td align="right">Total Price Supply & Install <?php $total = $sub_total + $vat_amount ?></td>
                    <td align="right"><?php echo number_format($total, 2, '.', ',') ?><input name="total_amount_text" type="hidden" value="<?php echo $total ?>"></td>
                  </tr>
              </table>
              </div>
              
             
              <?php 
			  }
?>

<?php
if ($_SESSION['project']=='Monthly maintenance') { ?>
              <div class="wizard_frame">
                
                <table width="650" id="table_details_display">
                  <tr>
                    <td width="396" >Year rate (11 months):</td>
                    <td width="220" align="right"><?php if ($_SESSION['amount_text31']!="") {echo number_format($_SESSION['amount_text31'], 2, '.', ',');} ?></td>
                  </tr>
                 
              </table>
              </div>
              
             
              <?php 
			  }
?>

<div class="wizard_frame">
  Terms.<br>
  Price valid for: <?php echo $_SESSION['valid_days']?> days.<br>
  Delivery: <?php echo $_SESSION['delivery_days']?> days.
  

</div>

            <div class="wizard_frame">
              <label class="label_std">If you want to make changes use the 'Prev' button to go back. <br />
              Click 'New' to make a new entry or to finish the wizard click 'Finish'.</label>
           </div>
       </td>
           
    </tr>
          <tr>
            <td>
              <table width="675" height="50" align="center" id="table_button_bar">
                <tr>
                  <td width="141" valign="top"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false;MM_goToURL('parent','maintenance_quoteWizbase.php?s=6&amp;p=3');return document.MM_returnValue; MM_showHideLayers('wait','','show');" /></td>
                  <td width="130" valign="top">
                    <input name="s" type="hidden" id="s" value="5" />
                    <input name="p" type="hidden" id="p" value="5" />
                  </td>
                  <td width="137" valign="top">&nbsp;</td>
                  <td width="131" align="right" valign="top"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../maintenance/maintenance_main.php?date='); " value="Cancel" /></td>
                  <td width="87" align="right" valign="top"><input  name="finish_button" type="submit" class="imagebutton" id="finish_button" value="Finish" onClick="needToConfirm = false;MM_showHideLayers('wait','','show')" /></td>
                </tr>
              </table></td>
          </tr>
  </table>
  
  
</form>
</div>
</body>
<?php
}
?>