<!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" />

<script language="javascript" src="../jscript/chainedselects.js"></script>
<script language="javascript" src="../jscript/jquery.1.4.2.js"></script>
<script language="JavaScript" src="../jscript/numbers_only.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/alert_message.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/numbers_only_decimal.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/cancel_confirmation.js"  type="text/javascript"></script> 
<?php
include ("../navigation/header.php");
$page_name = "Sales-edit";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/sales_sidebar.php");

$quote_no = $_GET['quote_no'];
$authorise = $_GET['authorise'];


$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");
$transport  = mysql_result($quote_result, 0, "transport");
$pallets  = mysql_result($quote_result, 0, "pallets");
$pallets_price  = mysql_result($quote_result, 0, "pallets_price");

$pallets_price_total = $pallets * $pallets_price;

if ($authorise==0) {
$table_name = $_SESSION['db_prefix']."_permissions";
$permission_query = "SELECT access_id  FROM  $table_name  WHERE access_id ='". $_SESSION['access_id']."' AND page_name = 'Sales-discount' ";
$permission_result = mySQL_query($permission_query);
$permission_num = mysql_num_rows($permission_result);
if ($permission_num>0) { 
		$discount_limit = 'no'; 
}
else {
	$discount_limit = 'yes'; 
}
}

if ($authorise==1) {
$user_name = $_POST['user_select'];	
$password = $_POST['password'];


$table_name = $_SESSION['db_prefix']."_users";
$verify_query = "SELECT  username, password, access_id FROM $table_name WHERE username = '".$user_name."' AND password = '".$password."' ";
$verify_result = mySQL_query($verify_query);
$verify_num = mysql_num_rows($verify_result);

if ($verify_num!=0) {
$access_id = mysql_result($verify_result, 0, "access_id");
$table_name = $_SESSION['db_prefix']."_permissions";
$permission_query = "SELECT access_id  FROM  $table_name  WHERE access_id ='".$access_id."' AND page_name = 'Sales-discount' ";
$permission_result = mySQL_query($permission_query);
$permission_num = mysql_num_rows($permission_result);
if ($permission_num>0) { 
		$discount_limit = 'no'; 
		$auth_message='The discount limit has been lifted. You can make discounts up to 7.5%';
}
else {
	$discount_limit = 'yes';
	$auth_message='The user entered does not have the permission for higher discount percentages.<br>The discount limit remains on 5%.'; 
}

}
else {
	$discount_limit = 'yes'; 
	$auth_message='The user name and/or password were not correct. The discount limit remains on 5%.';
}

}

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

if ($quote_type=='tiles') {
$table_name = $_SESSION['db_prefix']."_store_items";
$store_item_query = "SELECT store_item_id, item_name, price FROM $table_name WHERE subCategory = 'Tiles' AND branch = '".$_SESSION['userbranch']."' ORDER BY item_name ASC";

	$store_item_result = execsql($store_item_query);
	$store_item_num = mysql_num_rows($store_item_result);
	$w = 0;
	$arrId2 = array ();
	$arrName2 = array ();
	while ($w < $store_item_num) {
		$arrId2[$w] = mysql_result($store_item_result, $w, "store_item_id");
		$arrName2[$w] = mysql_result($store_item_result, $w, "item_name").' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #'.mysql_result($store_item_result, $w, "price");
		$w++;
	}
	
$table_name = $_SESSION['db_prefix']."_store_items";
$store_item_query = "SELECT store_item_id, item_name, price FROM $table_name WHERE subCategory = 'Accessories'  AND branch = '".$_SESSION['userbranch']."' ORDER BY item_name ASC";
	$store_item_result = execsql($store_item_query);
	$store_item_num = mysql_num_rows($store_item_result);
	$w = 0;
	$arrId3 = array ();
	$arrName3 = array ();
	while ($w < $store_item_num) {
		$arrId3[$w] = mysql_result($store_item_result, $w, "store_item_id");
		$arrName3[$w] = mysql_result($store_item_result, $w, "item_name").' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #'.mysql_result($store_item_result, $w, "price");
		$w++;
	}
}

if ($quote_type=='tiles') {
?>

<script>
function calc_M(line_num) {

var sub_total_var = 0;	

for (i = 0; i < line_num; i++) {	
sub_total_var  += Number(document.getElementById('amount_text'+i).value);
}


var discount_var =	sub_total_var * (document.getElementById('discount').value / 100) ;	

var sub_total2_var = sub_total_var - discount_var; 

var pallets_var = document.getElementById('pallets_text').value;

var pallets_total_var = pallets_var * <?php echo $pallets_price ?>;

var transport_var =	parseFloat(document.getElementById('transport').value) ;	

var sub_total3_var = sub_total2_var + pallets_total_var + transport_var;

var vat_var =	sub_total3_var * (document.getElementById('vat').value / 100) ;

var all_total_var = sub_total3_var + vat_var ;


document.getElementById('sub_total_text').value = parseFloat( sub_total_var ).toFixed(2) ;
document.getElementById('discount_text').value = parseFloat(	discount_var ).toFixed(2) ;

document.getElementById('sub_total2_text').value = parseFloat( sub_total2_var ).toFixed(2) ;
document.getElementById('sub_total2').value = sub_total2_var  ;
document.getElementById('pallets_text').value = pallets_var ;
document.getElementById('pallets_total_text').value = parseFloat(pallets_total_var).toFixed(2) ;
document.getElementById('transport_text').value = parseFloat(transport_var).toFixed(2) ;

document.getElementById('sub_total3_text').value = parseFloat(sub_total3_var ).toFixed(2) ;
document.getElementById('sub_total3').value = sub_total3_var  ;

document.getElementById('vat_text').value = parseFloat(vat_var).toFixed(2) ;
document.getElementById('all_total_text').value = parseFloat( all_total_var ).toFixed(2) ;

}
</script>

<script>
function calc_M_tot() {

var sub_total_var = document.getElementById('sub_total').value;	

var discount_var =	sub_total_var * (document.getElementById('discount').value / 100) ;	

var sub_total2_var = sub_total_var - discount_var; 

var pallets_var = document.getElementById('pallets_text').value;

var pallets_total_var = pallets_var * <?php echo $pallets_price ?>;

var transport_var =	parseFloat(document.getElementById('transport').value) ;	

var sub_total3_var = sub_total2_var + pallets_total_var + transport_var;

var vat_var =	sub_total3_var * (document.getElementById('vat').value / 100) ;

var all_total_var = sub_total3_var + vat_var ;


document.getElementById('sub_total_text').value = parseFloat( sub_total_var ).toFixed(2) ;
document.getElementById('discount_text').value = parseFloat(	discount_var ).toFixed(2) ;

document.getElementById('sub_total2_text').value = parseFloat( sub_total2_var ).toFixed(2) ;
document.getElementById('sub_total2').value = sub_total2_var  ;
document.getElementById('pallets_text').value = pallets_var ;
document.getElementById('pallets_total_text').value = parseFloat(pallets_total_var).toFixed(2) ;
document.getElementById('transport_text').value = parseFloat(transport_var).toFixed(2) ;

document.getElementById('sub_total3_text').value = parseFloat(sub_total3_var ).toFixed(2) ;
document.getElementById('sub_total3').value = sub_total3_var  ;

document.getElementById('vat_text').value = parseFloat(vat_var).toFixed(2) ;
document.getElementById('all_total_text').value = parseFloat( all_total_var ).toFixed(2) ;
}
</script>
<?php }
if ($quote_type=='trusses') {

?>

<script>
function calc_I() {
var sub_total_var = 0;

document.getElementById('install_amount1').value = parseFloat(document.getElementById('install_price1').value * document.getElementById('install_quantity1').value).toFixed(2) ;
document.getElementById('install_amount2').value = parseFloat(document.getElementById('install_price2').value * document.getElementById('install_quantity2').value).toFixed(2) ;
document.getElementById('install_amount3').value = parseFloat(document.getElementById('install_price3').value * document.getElementById('install_quantity3').value).toFixed(2) ;
document.getElementById('install_amount4').value = parseFloat(document.getElementById('install_price4').value * document.getElementById('install_quantity4').value).toFixed(2) ;
document.getElementById('install_amount5').value = parseFloat(document.getElementById('install_price5').value * document.getElementById('install_quantity5').value).toFixed(2) ;
document.getElementById('install_amount6').value = parseFloat(document.getElementById('install_price6').value * document.getElementById('install_quantity6').value).toFixed(2) ;
document.getElementById('install_amount7').value = parseFloat(document.getElementById('install_price7').value * document.getElementById('install_quantity7').value).toFixed(2) ;

document.getElementById('install_amount8').value = parseFloat(document.getElementById('install_price8').value * document.getElementById('install_quantity8').value).toFixed(2) ;
document.getElementById('install_amount9').value = parseFloat(document.getElementById('install_price9').value * document.getElementById('install_quantity9').value).toFixed(2) ;




sub_total_var = 
      Number(document.getElementById('install_amount1').value) +
	  Number(document.getElementById('install_amount2').value) +
	  Number(document.getElementById('install_amount3').value) +
	  Number(document.getElementById('install_amount4').value) +
	  Number(document.getElementById('install_amount5').value) +
	  Number(document.getElementById('install_amount6').value) +
	  Number(document.getElementById('install_amount7').value) +
	  Number(document.getElementById('install_amount8').value) +
	  Number(document.getElementById('install_amount9').value) ;


var discount_var =	sub_total_var * (document.getElementById('discount').value / 100) ;	

var sub_total2_var = sub_total_var - discount_var; 

var transport_var =	parseFloat(document.getElementById('transport').value) ;	

var sub_total3_var = sub_total2_var + transport_var;

var vat_var =	sub_total3_var * (document.getElementById('vat').value / 100) ;

var all_total_var = sub_total3_var + vat_var ;


document.getElementById('sub_total_text').value = parseFloat( sub_total_var ).toFixed(2) ;
document.getElementById('discount_text').value = parseFloat(	discount_var ).toFixed(2) ;

document.getElementById('sub_total2_text').value = parseFloat( sub_total2_var ).toFixed(2) ;
document.getElementById('sub_total2').value = sub_total2_var  ;

document.getElementById('transport_text').value = parseFloat(transport_var).toFixed(2) ;

document.getElementById('sub_total3_text').value = parseFloat(sub_total3_var ).toFixed(2) ;
document.getElementById('sub_total3').value = sub_total3_var  ;

document.getElementById('vat_text').value = parseFloat(vat_var).toFixed(2) ;
document.getElementById('all_total_text').value = parseFloat( all_total_var ).toFixed(2) ;
}
</script>
<?php
}
?>



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

<!--jscript-->
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 

<script>
//var disable_empty_list=true; //uncomment this line to disable empty selection lists


<?php 
$k=0;
while ( $k<10 ) {
?>

addListGroup("Direct materials", "category<?php echo $k ?>", "store_item_id_select<?php echo $k ?>", "items");
//addOption("category0", "", "", "", 1); //Empty starter option
addList("category<?php echo $k ?>", "", "", "");
addList("category<?php echo $k ?>", "Tiles", "Tiles", "Tiles");
addList("category<?php echo $k ?>", "Accessories", "Accessories", "Accessories");

<?php
$k++;
}
?>

		addList("Tiles", "", "", "");
		<?php 
    	for ($w = 0; $w < count($arrId2); $w++) { ?>
			addList("Tiles", "<?php echo $arrName2[$w]?> ", "<?php echo $arrId2[$w]?> ", "");
		<?php
	    }
     ?>
		addList("Accessories", "", "", "");
		<?php 
        for ($w = 0; $w < count($arrId3); $w++) { ?>
			addList("Accessories", "<?php echo $arrName3[$w]?> ", "<?php echo $arrId3[$w]?> ", "");
		<?php
	    }
	?>

</script>

<script language="javascript">
function initCS() {
<?php
$t=0;
while ($t<50) {
?>
initListGroup("Direct materials", form1.category<?php echo $t ?>, form1.store_item_id_select<?php echo $t ?>); 

function initLists() {
  form1.category<?php echo $t ?>.onchange();
  category<?php echo $t ?>.fireEvent("onchange");
}

<?php 
$t++;
}
?>
}

</script>

</head>

<body onload="initCS(); <?php if ($quote_type=='trusses') { ?> calc_I(); <?php } ?> <?php if ($quote_type=='trusses') { ?> calc_I(); <?php } ?> <?php if ($authorise==1) {?> alertMessage(1, '', '<?php echo $auth_message ?> ')<?php } ?>;">
<form name="form1" id="form1" action="quotation_edit_save.php" method="get">
<div class="main_frame" style="height:auto; min-height:555px;">
<div class="page_head_frame">
          <table width="690" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="493"><label class="label_page_head">
              <?php if ($quote_type=='tiles') { echo 'Tiles quotation'; } ?>
              <?php if ($quote_type=='trusses') { echo 'Installation quotation'; } ?></label>
              <input type="hidden" name="quote_type_text" id="quote_type_text" value="<?php echo $quote_type ?>"/>
              <input type="hidden" name="quote_no_text" id="quote_no_text" value="<?php echo $quote_no ?>"/>
              </td>
              <td width="197"><label style="font-size:18px; "><?php echo "Q".$quote_no ?></label><br /><label style="font-size:18px; "><?php echo $branch ?> branch</label></td>
            </tr>
          </table>
        </div>
        <br />
        <br />
        <br />
<br />
<br />

      <div class="page_middle_frame">
       <div class="button_inside_frame"> Quotation for:&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;Quoatation date:&nbsp;&nbsp;<?php echo date("d-m-Y", strtotime($quotation_date)) ?>  
              <?php 
		include ('../include/customer_block.php');
		echo' <br>';
		?>
       </div>
      
        <div class="button_inside_frame"> Pricing details<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);

if ($quote_type=='tiles') {
				  ?>
              <table width="650" id="table_display" >
                <tr>
                  <td width="186" height="26" align="left" valign="top">Item</td>
                  <td width="225" align="left" valign="top">Group</td>
                  <td width="25" align="left" valign="top">Unit</td>
                  <td width="50" align="left" valign="top">quantity</td>
                  <td width="60" align="left" valign="top">price</td>
                  <td width="76" align="left" valign="top">total</td>
                </tr>
                <?php
				$i=0;
				$sub_tot=0;
				$a5_total=0;
				 while ($i<$line_num){
					 $a0 = mysql_result($line_result, $i, "quote_line_id");
					 $a1 = mysql_result($line_result, $i, "store_item_id");
					 $table_name = $_SESSION['db_prefix']."_store_items";
						$item_query = "SELECT item_name, unit, subCategory FROM $table_name WHERE store_item_id = '".$a1."' ";
						$item_result = mySQL_query($item_query);
						$a1a = mysql_result($item_result, 0, "item_name");
						$a3a = mysql_result($item_result, 0, "unit");
						$a4a = mysql_result($item_result, 0, "subCategory");
					 $a2 = mysql_result($line_result, $i, "quantity");
					 $a3 = mysql_result($line_result, $i, "price");
					 
					$a5=$a2*$a3;
					$a5_total=$a5_total+$a5;
					$sub_total = $a5_total; 
				 ?>
                <tr>
                  <td colspan="2" valign="middle">
                    <div id="store_item_divA<?php echo $i ?>"><img src="../images/line_edit.png" alt="" width="16" height="12" id="add_icon<?php echo $i ?>" title="Click to edit line" 
              onclick="
              document.getElementById('store_item_divA<?php echo $i ?>').hidden=true; 
              document.getElementById('store_item_divB<?php echo $i ?>').hidden=false; 
              document.getElementById('price_text<?php echo $i ?>').value='';
              document.getElementById('amount_text<?php echo $i ?>').value=''; 
              document.getElementById('store_item_text<?php echo $i ?>').value =''; 
              calc_M(<?php echo $line_num?>)
              " />
                      <input name="store_item_text<?php echo $i ?>" id="store_item_text<?php echo $i ?>" type="text" class="text300" value="<?php echo $a1a ?>" readonly="readonly" style="border:hidden; background-color:inherit" />
                      <input name="store_item_id<?php echo $i ?>" id="store_item_id<?php echo $i ?>" type="hidden" value="<?php echo $a1 ?>" />
                    </div>
                    <div id="store_item_divB<?php echo $i ?>" hidden="hidden">
                      <select name="category<?php echo $i ?>" id="category<?php echo $i ?>" class="select160"  onchange="document.getElementById('store_item_divA<?php echo $i ?>').hidden=true; document.getElementById('store_item_divB<?php echo $i ?>').hidden=false; document.getElementById('store_item_id_select<?php echo $i ?>').selectedIndex=-1; document.getElementById('index<?php echo $i ?>').value = document.getElementById('category<?php echo $i ?>').selectedIndex; ">
                      </select>
                      <input type="hidden" name="index<?php echo $i ?>" id="index<?php echo $i ?>" />
                      <select name="store_item_id_select<?php echo $i ?>" id="store_item_id_select<?php echo $i ?>" class="select230" onchange="
                      document.getElementById('store_item_id<?php echo $i ?>').value = document.getElementById('store_item_id_select<?php echo $i ?>').value;
                      
                     unit = document.getElementById('store_item_id_select<?php echo $i ?>').options[document.getElementById('store_item_id_select<?php echo $i ?>').selectedIndex].text;               		unit2 = unit.split('#'); 
              		unit3 = unit2[1];
                    document.getElementById('price_text<?php echo $i ?>').value = unit3;
                    
                    document.getElementById('amount_text<?php echo $i ?>').value = (document.getElementById('quantity_text<?php echo $i ?>').value * unit3).toFixed(2);
                    calc_M(<?php echo $line_num?>)
                    "
              >
                      </select>
                      <input type="hidden" name="line_num" id="line_num" value="<?php echo $line_num?>" />
                  </div></td>
                  <td valign="middle"><?php echo $a3a ?></td>
                  <td valign="middle"><input name="quantity_text<?php echo $i ?>" id="quantity_text<?php echo $i ?>" type="text" value="<?php echo number_format($a2, 0, '.', '') ?>" class="text50" width="50px" onkeyup="document.getElementById('amount_text<?php echo $i ?>').value = parseFloat(document.getElementById('quantity_text<?php echo $i ?>').value * document.getElementById('price_text<?php echo $i ?>').value).toFixed(2); calc_M(<?php echo $line_num?>)" onkeypress="return numbersonly(this, event)" onfocus = "this.select();" autocomplete="off"/></td>
                  <td align="right" valign="middle"><input type="text" name="price_text<?php echo $i ?>" id="price_text<?php echo $i ?>" value="<?php echo $a3 ?>" class="text50" width="50px;" readonly="readonly" style="border:hidden;" /> </td>
                  <td align="right" valign="middle"><input type="text" name="amount_text<?php echo $i ?>" id="amount_text<?php echo $i ?>" class="text60" width="60px" value="<?php echo number_format($a5, 2, '.', '') ?>" readonly="readonly" style="border:hidden; text-align:right;"  /></td>
                </tr>
                <?php 
			   // $a6_total=$a6_total+$a6;
				$i++;
				 }
				 ?>
                <tr>
                  <td colspan="3" rowspan="8" align="left" valign="top">&nbsp;
                  <?php $discount_amount = $a5_total * ($quote_discount/100) ?>
                  &nbsp;
                  <?php $sub_total2 = $sub_total - $discount_amount ?>
                  &nbsp;
                  <?php $sub_total3 = $sub_total + $transport ?>
                  &nbsp;
                  <?php $vat_amount = $sub_total3 * ($quote_vat/100) ?>
                  &nbsp;
                  <?php $all_total = $sub_total3 + $vat_amount ?>
                  <br />
                  Note on edititng this quotation:<br />
                  <textarea name="note_text" id="note_text" cols="45" rows="5" class="text_box"></textarea>
                  <br /><div align="left">
<img src="../images/info_green.png" width="16" height="16">
<label class="label_info">All changes are recorded with the quotation, only add extra info.</label>          
</div></td>
                  <td colspan="2" align="left" valign="middle">Sub total:
                  <input type="hidden" name="sub_total" id="sub_total" value="<?php echo $sub_total ?>"/></td>
                  <td align="right" valign="middle"><input name="sub_total_text" id="sub_total_text"  type="text" class="text60" width="60px;" value="<?php echo number_format($a5_total, 2, '.', '')?>"  readonly="readonly" style="text-align:right; border:hidden;"/></td>
                </tr>
                <tr>
                  <td colspan="2" align="left" valign="middle">Discount: <select name="discount_select" id="discount_select" onchange="
                    var select = document.getElementById('discount_select');
    				var selectedString = select.options[select.selectedIndex].value;
                    document.getElementById('discount').value = selectedString;
                    calc_M_tot();
                    "
                    >
                    <option value="0">0</option>
                    <option value="0.5">0.5</option>
                    <option value="1.0">1.0</option>
                    <option value="1.5">1.5</option>
                    <option value="2.0">2.0</option>
                    <option value="2.5">2.5</option>
                    <option value="3.0">3.0</option>
                    <option value="3.5">3.5</option>
                    <option value="4.0">4.0</option>
                    <option value="4.5">4.5</option>
                    <option value="5.0">5.0</option>
                    <?php if ($discount_limit=='no') { ?>
                    <option value="5.5">5.5</option>
                    <option value="6.0">6.0</option>
                    <option value="6.5">6.5</option>
                    <option value="7.0">7.0</option>
                    <option value="7.5">7.5</option>
                    <?php } ?>
                    <option value="<?php echo $quote_discount ?>" selected="selected"><?php echo $quote_discount ?></option>
                  </select>%
                  <a href="" onMouseOver="ddrivetip('Click to override discount limit.', 150)"; onMouseOut="hideddrivetip()" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', '../edit_windows/authorisation_edit_override.php?quote_no=<?php echo $quote_no ?>', 'Authorisation.', 'width=350px,height=175px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><img src="../images/lock.png" width="16" height="16" /></a>
                  <input type="hidden" name="discount" id="discount" value="<?php echo $quote_discount ?>" /></td>
                  <td align="right" valign="middle"><input name="discount_text" id="discount_text"  type="text" class="text60" width="60px;" value="<?php echo number_format($discount_amount, 2, '.', '')?>"  readonly="readonly" style="text-align:right; border:hidden;"/></td>
                </tr>
                <tr>
                  <td colspan="2" align="left" valign="middle">Sub total:
                  <input type="hidden" name="sub_total2" id="sub_total2" value="<?php echo $sub_total2 ?>"/></td>
                  <td align="right" valign="middle"><input name="sub_total2_text" id="sub_total2_text"  type="text" class="text60" width="60px;" value="<?php echo number_format($sub_total, 2, '.', '')?>"  readonly="readonly" style="text-align:right; border:hidden;"/></td>
                </tr>
                <tr>
                  <td colspan="2" align="left" valign="middle"><input name="pallets_text" id="pallets_text" type="text" value="<?php echo $pallets ?>" class="text50" width="50px" onkeypress="return numbersonly(this, event)" onfocus = "this.select();" autocomplete="off" onblur="calc_M_tot();"/> 
                                    pallets</td>
                  <td align="right" valign="middle"><input name="pallets_total_text" id="pallets_total_text"  type="text" class="text60" width="60px;" value="<?php echo $pallets_price_total ?>"  readonly="readonly" style="text-align:right; border:hidden;"/></td>
                </tr>
                <tr>
                  <td colspan="2" align="left" valign="middle">Transport:
                  <input type="hidden" name="transport" id="transport"  value="<?php echo $transport ?>"/></td>
                  <td align="right" valign="middle"><input name="transport_text" id="transport_text"  type="text" class="text60" width="60px;" value="<?php echo number_format($transport, 2, '.', '')?>"   style="text-align:right;" onkeypress="return isNumberKey(event)" onkeyup="this.value = this.value.replace (/(\...).*/, '$1'); document.getElementById('transport').value = document.getElementById('transport_text').value;" onblur="calc_M_tot();" onfocus = "this.select();"/></td>
                </tr>
                <tr>
                  <td colspan="2" align="left" valign="middle">Sub total:
                  <input type="hidden" name="sub_total3" id="sub_total3" value="<?php echo $sub_total3 ?>"/></td>
                  <td align="right" valign="middle"><input name="sub_total3_text" id="sub_total3_text"  type="text" class="text60" width="60px;" value="<?php echo number_format($sub_total3, 2, '.', '')?>"  readonly="readonly" style="text-align:right; border:hidden;"/></td>
                </tr>
                <tr>
                  <td colspan="2" align="left" valign="middle">VAT @ <?php echo $quote_vat ?>%
                  <input type="hidden" name="vat" id="vat" value="<?php echo $quote_vat ?>" /></td>
                  <td align="right" valign="middle"><input name="vat_text" id="vat_text"  type="text" class="text60" width="60px;" value="<?php echo number_format($vat_amount, 2, '.', '')?>"  readonly="readonly" style="text-align:right; border:hidden;"/></td>
                </tr>
                <tr>
                  <td colspan="2" align="left" valign="middle">Total:</td>
                  <td align="right" valign="middle"><input name="all_total_text" id="all_total_text"  type="text" class="text60" width="60px;" value="<?php echo number_format($all_total, 2, '.', '')?>"  readonly="readonly" style="text-align:right; border:hidden;"/></td>
                </tr>
              </table><br />
              <?php } ?>
<br />


<?php 
if ($quote_type=='trusses') { 

?>
Installation of Trusses and loose timbers &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CPLX: 
<select name="cplx_select" id="cplx_select" class="select50" onchange="calc_I(); ">
  <option value="0.8">1</option>
  <option value="1" >2</option>
  <option value="1.2">3</option>
  <option value="<?php echo  $cplx ?>" selected="selected"><?php echo  $cplx_display ?></option>
</select>
&nbsp;&nbsp;&nbsp;Double storey:&nbsp;
<select name="double_select" id="double_select" class="select50"  onchange="calc_I(); ">
  <option value="yes">yes</option>
  <option value="no">no</option>
  <option value="<?php echo $storey?>" selected="selected"><?php echo $storey?></option>
</select>
<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 valign="middle">Installation of trusses, inclusive of wall plates, bracing, runners, battens,underlay and valley linings, all as indicated on roof layouts.</td>
    <td valign="middle"><input name="install_quantity1" id="install_quantity1" type="text"  class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" value="<?php if ($quantity!=0) {echo $quantity; } ?>"
    onkeyup="document.getElementById('install_amount1').value = parseFloat(document.getElementById('install_quantity1').value * document.getElementById('install_price1').value).toFixed(2); this.value = this.value.replace (/(\...).*/, '$1');  calc_I();"  onKeyPress="return isNumberKey(event)"  
    /></td>
    <td align="center" valign="middle">M2</td>
    <td align="right" valign="middle"><input name="install_price1" id="install_price1" type="text" value="<?php echo $price ?>" class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" onKeyPress="return isNumberKey(event);"
    onkeyup="this.value = this.value.replace (/(\...).*/, '$1'); document.getElementById('install_amount1').value = parseFloat(document.getElementById('install_quantity1').value * document.getElementById('install_price1').value).toFixed(2);  this.value = this.value.replace (/(\...).*/, '$1');  calc_I();" 
    /></td>
    <td align="right" valign="middle"><input name="install_amount1" id="install_amount1" type="text" class="text60" width="60px;" onfocus = "this.select();" autocomplete="off" style="text-align:right; border:hidden;" value="<?php if ($purchase_price!=0) echo $purchase_price ?>" readonly="readonly"/></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 valign="middle">Install fascia and barge boards.</td>
    <td valign="middle"><input name="install_quantity2" id="install_quantity2" type="text"  class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" value="<?php if ($quantity!=0) {echo $quantity; } ?>"
    onkeyup="document.getElementById('install_amount2').value = parseFloat(document.getElementById('install_quantity2').value * document.getElementById('install_price2').value).toFixed(2); this.value = this.value.replace (/(\...).*/, '$1');  calc_I();" onKeyPress="return isNumberKey(event)"
    /></td>
    <td align="center" valign="middle">M1</td>
    <td align="right" valign="middle"><input name="install_price2" id="install_price2" type="text" value="<?php echo $price ?>" class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" onKeyPress="return isNumberKey(event);"
    onkeyup="this.value = this.value.replace (/(\...).*/, '$1'); document.getElementById('install_amount2').value = parseFloat(document.getElementById('install_quantity2').value * document.getElementById('install_price2').value).toFixed(2); calc_I();"  
    /></td>
    <td align="right" valign="middle"><input name="install_amount2" id="install_amount2" type="text" class="text60" width="60px;" onfocus = "this.select();" autocomplete="off" style="text-align:right; border:hidden;" value="<?php if ($purchase_price!=0) echo $purchase_price ?>" readonly="readonly"/></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 valign="middle">Supply and install truss hangers and rawbolts for trusses fixed to brickwork or concrete.</td>
    <td valign="middle"><input name="install_quantity3" id="install_quantity3" type="text"  class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" value="<?php if ($quantity!=0) {echo $quantity; } ?>"
    onkeyup="document.getElementById('install_amount3').value = parseFloat(document.getElementById('install_quantity3').value * document.getElementById('install_price3').value).toFixed(2); this.value = this.value.replace (/(\...).*/, '$1');  calc_I();" onKeyPress="return isNumberKey(event)"
    /></td>
    <td align="center" valign="middle">NO</td>
    <td align="right" valign="middle"><input name="install_price3" id="install_price3" type="text" value="<?php echo $price ?>" class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" onKeyPress="return isNumberKey(event);"
    onkeyup="this.value = this.value.replace (/(\...).*/, '$1'); document.getElementById('install_amount3').value = parseFloat(document.getElementById('install_quantity3').value * document.getElementById('install_price3').value).toFixed(2); calc_I();" 
    /></td>
    <td align="right" valign="middle"><input name="install_amount3" id="install_amount3" type="text" class="text60" width="60px;" onfocus = "this.select();" autocomplete="off" style="text-align:right; border:hidden;" value="<?php if ($purchase_price!=0) echo $purchase_price ?>" readonly="readonly"/></td>
  </tr>
</table><br>
Installation of concrete roof tiles<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 valign="middle">Installation of concrete roof tiles, incl of cutting for valley- and hip tiles, all as indicated on roof layout</td>
    <td valign="middle"><input name="install_quantity4" id="install_quantity4" type="text"  class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" value="<?php if ($quantity!=0) {echo $quantity; } ?>"
    onkeyup="document.getElementById('install_amount4').value = parseFloat(document.getElementById('install_quantity4').value * document.getElementById('install_price4').value).toFixed(2); this.value = this.value.replace (/(\...).*/, '$1');  calc_I();" onKeyPress="return isNumberKey(event)"
    /></td>
    <td align="center" valign="middle">M2</td>
    <td align="right" valign="middle"><input name="install_price4" id="install_price4" type="text" value="<?php echo $price ?>" class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" onKeyPress="return isNumberKey(event);"
    onkeyup="this.value = this.value.replace (/(\...).*/, '$1'); document.getElementById('install_amount4').value = parseFloat(document.getElementById('install_quantity4').value * document.getElementById('install_price4').value).toFixed(2); calc_I();" 
    /></td>
    <td align="right" valign="middle"><input name="install_amount4" id="install_amount4" type="text" class="text60" width="60px;" onfocus = "this.select();" autocomplete="off" style="text-align:right; border:hidden;" value="<?php if ($purchase_price!=0) echo $purchase_price ?>" readonly="readonly"/></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 valign="middle">Installation of ridge, hip and rake verge tiles (incl. of paint and dpc)</td>
    <td valign="middle"><input name="install_quantity5" id="install_quantity5" type="text"  class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" value="<?php if ($quantity!=0) {echo $quantity; } ?>"
    onkeyup="document.getElementById('install_amount5').value = parseFloat(document.getElementById('install_quantity5').value * document.getElementById('install_price5').value).toFixed(2); this.value = this.value.replace (/(\...).*/, '$1');  calc_I();" onKeyPress="return isNumberKey(event)"
    /></td>
    <td align="center" valign="middle">M1</td>
    <td align="right" valign="middle"><input name="install_price5" id="install_price5" type="text" value="<?php echo $price ?>" class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" onKeyPress="return isNumberKey(event);"
    onkeyup="this.value = this.value.replace (/(\...).*/, '$1'); document.getElementById('install_amount5').value = parseFloat(document.getElementById('install_quantity5').value * document.getElementById('install_price5').value).toFixed(2); calc_I();" /></td>
    <td align="right" valign="middle"><input name="install_amount5" id="install_amount5" type="text" class="text60" width="60px;" onfocus = "this.select();" autocomplete="off" style="text-align:right; border:hidden;" value="<?php if ($purchase_price!=0) echo $purchase_price ?>" readonly="readonly"/></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 valign="middle">Installation of valley gutters</td>
    <td valign="middle"><input name="install_quantity6" id="install_quantity6" type="text"  class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" value="<?php if ($quantity!=0) {echo $quantity; } ?>"
    onkeyup="document.getElementById('install_amount6').value = parseFloat(document.getElementById('install_quantity6').value * document.getElementById('install_price6').value).toFixed(2); this.value = this.value.replace (/(\...).*/, '$1');  calc_I();" onKeyPress="return isNumberKey(event)"
    /></td>
    <td align="center" valign="middle">M1</td>
    <td align="right" valign="middle"><input name="install_price6" id="install_price6" type="text" value="<?php echo $price ?>" class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" onKeyPress="return isNumberKey(event);"
    onkeyup="this.value = this.value.replace (/(\...).*/, '$1'); document.getElementById('install_amount6').value = parseFloat(document.getElementById('install_quantity6').value * document.getElementById('install_price6').value).toFixed(2); calc_I();" 
    /></td>
    <td align="right" valign="middle"><input name="install_amount6" id="install_amount6" type="text" class="text60" width="60px;" onfocus = "this.select();" autocomplete="off" style="text-align:right; border:hidden;" value="<?php if ($purchase_price!=0) echo $purchase_price ?>" readonly="readonly"/></td>
  </tr>
</table><br>

Engineering inspection
<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 valign="middle">Engineering inspection</td>
    <td valign="middle"><input name="install_quantity7" id="install_quantity7" type="text"  class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" value="<?php if ($quantity!=0) {echo $quantity; } ?>"
    onkeyup="document.getElementById('install_amount7').value = parseFloat(document.getElementById('install_quantity7').value * document.getElementById('install_price7').value).toFixed(2); this.value = this.value.replace (/(\...).*/, '$1');  calc_I();" onKeyPress="return isNumberKey(event)"
    /></td>
    <td align="center" valign="middle">NO</td>
    <td align="right" valign="middle"><input name="install_price7" id="install_price7" type="text" value="<?php echo $price ?>" class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" onKeyPress="return isNumberKey(event);"
    onkeyup="this.value = this.value.replace (/(\...).*/, '$1'); document.getElementById('install_amount7').value = parseFloat(document.getElementById('install_quantity7').value * document.getElementById('install_price7').value).toFixed(2); calc_I();" 
    /></td>
    <td align="right" valign="middle"><input name="install_amount7" id="install_amount7" type="text" class="text60" width="60px;" onfocus = "this.select();" autocomplete="off" style="text-align:right; border:hidden;" value="<?php if ($purchase_price!=0) echo $purchase_price ?>" readonly="readonly"/></td>
  </tr>
</table>
<br>
Additional work<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 valign="middle"><input type="text" name="additional8_text" id="additional8_text" class="text300" value="<?php echo $additional_text ?>" autocomplete="off" onfocus = "this.select();"/></td>
    <td valign="middle"><input name="install_quantity8" id="install_quantity8" type="text"  class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" value="<?php if ($quantity!=0) {echo $quantity; } ?>"
    onkeyup="document.getElementById('install_amount8').value = parseFloat(document.getElementById('install_quantity8').value * document.getElementById('install_price8').value).toFixed(2); this.value = this.value.replace (/(\...).*/, '$1');  calc_I();" onKeyPress="return isNumberKey(event)"
    /></td>
    <td align="center" valign="middle">.</td>
    <td align="right" valign="middle"><input name="install_price8" id="install_price8" type="text"  class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" value="<?php if ($price!=0) {echo $price; } ?>" 
    onkeyup="this.value = this.value.replace (/(\...).*/, '$1'); document.getElementById('install_amount8').value = parseFloat(document.getElementById('install_quantity8').value * document.getElementById('install_price8').value).toFixed(2); this.value = this.value.replace (/(\...).*/, '$1');  calc_I();" onKeyPress="return isNumberKey(event);"
    /></td>
    <td align="right" valign="middle"><input name="install_amount8" id="install_amount8" type="text" class="text60" width="60px;" onfocus = "this.select();" autocomplete="off" style="text-align:right; border:hidden;" value="<?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 valign="middle"><input type="text" name="additional9_text" id="additional9_text" class="text300" value="<?php echo $additional_text ?>" autocomplete="off" onfocus = "this.select();"/></td>
    <td valign="middle"><input name="install_quantity9" id="install_quantity9" type="text"  class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" value="<?php if ($quantity!=0) {echo $quantity; } ?>"
    onkeyup="document.getElementById('install_amount9').value = parseFloat(document.getElementById('install_quantity9').value * document.getElementById('install_price9').value).toFixed(2); this.value = this.value.replace (/(\...).*/, '$1');  calc_I();" onKeyPress="return isNumberKey(event)" 
    /></td>
    <td align="center" valign="middle">.</td>
    <td align="right" valign="middle"><input name="install_price9" id="install_price9" type="text"  class="text50" width="50px;" autocomplete="off" onfocus = "this.select();" value="<?php if ($price!=0) {echo $price; } ?>" onKeyPress="return isNumberKey(event);"
    onkeyup="this.value = this.value.replace (/(\...).*/, '$1'); document.getElementById('install_amount9').value = parseFloat(document.getElementById('install_quantity9').value * document.getElementById('install_price9').value).toFixed(2); calc_I();" 
    /></td>
    <td align="right" valign="middle"><input name="install_amount9" id="install_amount9" type="text" class="text60" width="60px;" onfocus = "this.select();" autocomplete="off" style="text-align:right; border:hidden;" value="<?php if ($purchase_price!=0) echo $purchase_price ?>"
     /></td>
  </tr>
</table>
<br />
<table width="650" id="table_details_display">
<td colspan="3" rowspan="7" align="left" valign="top">&nbsp;
                  <?php $discount_amount = $sub_total * ($quote_discount/100) ?>
                  &nbsp;
                  <?php $sub_total2 = $sub_total - $discount_amount ?>
                  &nbsp;
                  <?php $sub_total3 = $sub_total + $transport ?>
                  &nbsp;
                  <?php $vat_amount = $sub_total3 * ($quote_vat/100) ?>
                  &nbsp;
                  <?php $all_total = $sub_total3 + $vat_amount ?>
                  <br />
                  Note on edititng this quotation:<br />
                  <textarea name="note_text" id="note_text" cols="45" rows="5" class="text_box"></textarea>
                  <br /><div align="left">
<img src="../images/info_green.png" width="16" height="16">
<label class="label_info">All changes are recorded with the quotation, only add extra info.</label>          
</div></td>
                  <td colspan="2" align="left" valign="middle">Sub total:
                  <input type="hidden" name="sub_total" id="sub_total" value="<?php echo $sub_total ?>"/></td>
                  <td align="right" valign="middle"><input name="sub_total_text" id="sub_total_text"  type="text" class="text60" width="60px;" value="<?php echo number_format($sub_total, 2, '.', '')?>"  readonly="readonly" style="text-align:right; border:hidden;"/></td>
                </tr>
                <tr>
                  <td colspan="2" align="left" valign="middle">Discount: <select name="install_discount" id="install_discount" onchange="
                    var select = document.getElementById('install_discount');
    				var selectedString = select.options[select.selectedIndex].value;
                    document.getElementById('discount').value = selectedString;
                    calc_I();
                    "
                    >
                    <option value="0">0</option>
                    <option value="0.5">0.5</option>
                    <option value="1.0">1.0</option>
                    <option value="1.5">1.5</option>
                    <option value="2.0">2.0</option>
                    <option value="2.5">2.5</option>
                    <option value="3.0">3.0</option>
                    <option value="3.5">3.5</option>
                    <option value="4.0">4.0</option>
                    <option value="4.5">4.5</option>
                    <?php if ($discount_limit=='no') { ?>
                    <option value="5.0">5.0</option>
                    <option value="5.5">5.5</option>
                    <option value="6.0">6.0</option>
                    <option value="6.5">6.5</option>
                    <option value="7.0">7.0</option>
                    <option value="7.5">7.5</option>
                    <?php } ?>
                    <option value="<?php echo $quote_discount ?>" selected="selected"><?php echo $quote_discount ?></option>
                  </select>%
                  <a href="" onMouseOver="ddrivetip('Click to override discount limit.', 150)"; onMouseOut="hideddrivetip()" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', '../edit_windows/authorisation_edit_override.php?quote_no=<?php echo $quote_no ?>', 'Authorisation.', 'width=350px,height=175px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><img src="../images/lock.png" width="16" height="16" /></a>
                  <input type="hidden" name="discount" id="discount" value="<?php echo $quote_discount ?>" /></td>
                  <td align="right" valign="middle"><input name="discount_text" id="discount_text"  type="text" class="text60" width="60px;" value="<?php echo number_format($discount_amount, 2, '.', '')?>"  readonly="readonly" style="text-align:right; border:hidden;"/></td>
                </tr>
                <tr>
                  <td colspan="2" align="left" valign="middle">Sub total:
                  <input type="hidden" name="sub_total2" id="sub_total2" value="<?php echo $sub_total2 ?>"/></td>
                  <td align="right" valign="middle"><input name="sub_total2_text" id="sub_total2_text"  type="text" class="text60" width="60px;" value="<?php echo number_format($sub_total2, 2, '.', '')?>"  readonly="readonly" style="text-align:right; border:hidden;"/></td>
                </tr>
                <tr>
                  <td colspan="2" align="left" valign="middle">Transport:
                  <input type="hidden" name="transport" id="transport"  value="<?php echo $transport ?>"/><?php echo $transport ?></td>
                  <td align="right" valign="middle"><input name="transport_text" id="transport_text"  type="text" class="text60" width="60px;" value="<?php echo number_format($transport, 2, '.', '')?>"   style="text-align:right;" onkeypress="return isNumberKey(event)" onkeyup="this.value = this.value.replace (/(\...).*/, '$1'); document.getElementById('transport').value = document.getElementById('transport_text').value;" onblur="calc_I();" onfocus = "this.select();"/></td>
                </tr>
                <tr>
                  <td colspan="2" align="left" valign="middle">Sub total:
                  <input type="hidden" name="sub_total3" id="sub_total3" value="<?php echo $sub_total3 ?>"/></td>
                  <td align="right" valign="middle"><input name="sub_total3_text" id="sub_total3_text"  type="text" class="text60" width="60px;" value="<?php echo number_format($sub_total3, 2, '.', '')?>"  readonly="readonly" style="text-align:right; border:hidden;"/></td>
                </tr>
                <tr>
                  <td colspan="2" align="left" valign="middle">VAT @ <?php echo $quote_vat ?>%
                  <input type="hidden" name="vat" id="vat" value="<?php echo $quote_vat ?>" /></td>
                  <td align="right" valign="middle"><input name="vat_text" id="vat_text"  type="text" class="text60" width="60px;" value="<?php echo number_format($vat_amount, 2, '.', '')?>"  readonly="readonly" style="text-align:right; border:hidden;"/></td>
                </tr>
                <tr>
                  <td colspan="2" align="left" valign="middle">Total:</td>
                  <td align="right" valign="middle"><input name="all_total_text" id="all_total_text"  type="text" class="text60" width="60px;" value="<?php echo number_format($all_total, 2, '.', '')?>"  readonly="readonly" style="text-align:right; border:hidden;"/></td>
</table>
  
<br /><?php } ?>            
        </div>
        
        <div class="page_inside_frame">
  <table width="645" border="0">
    <tr>
      <td width="20"></td>
      <td width="615" align="right"><input type="hidden" name="cust_id_text" id="cust_id_text" value="<?php echo $cust_id ?>" />
        <input name="button2" type="button" class="imagebutton" id="button2" onclick="cancel_confirmation(3, '../sales/sales_main.php?date=&branch=');" value="Close"/>
        <input name="save_button"  id="save_button" type="submit" class="imagebutton" value="Save" onclick="needToConfirm = false; confirmRefresh();" />
        <input name="save_close_button"  id="save_close_button" type="submit" class="imagebutton" value="Save &amp; Close" onclick="needToConfirm = false; confirmRefresh();" /></td>
    </tr>
  </table>
</div>
</div>
  </div>
  
  
</div>
</form>
<?php include ('../navigation/side_bar.php'); ?>
</body>
<?php } else { ?>
<script> needToConfirm = false; </script>
<?php
$_SESSION['denied_return'] = "sales/sales_main.php?date=&branch=";	
include ("../navigation/sales_sidebar.php");?>
<body onload="accessdenied(); return false">
</body>
<?php }
?>
</html>