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

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

$table_name2 = $_SESSION['db_prefix']."_captured_cash_sale";
$quote_query = "SELECT * FROM $table_name2 WHERE job_no ='".$job_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  = '';
$sales_discount  = mysql_result($quote_result, 0, "sales_discount");
$sales_vat  = mysql_result($quote_result, 0, "sales_vat");
$transport  = mysql_result($quote_result, 0, "transport");


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) {
$discount = $_POST['discount_text'];	
$user_name = $_POST['user_select'];	
$password = $_POST['password'];
$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='Discount has been changed';
		$sales_discount=$discount;
		?>
        
        <?php
}
else {
	//$discount_limit = 'yes';
	$auth_message='This user is not allowed to give discount over 5%.'; 
}

}
else {
	//$discount_limit = 'yes'; 
	$auth_message='User name and/or password were not correct, discount was not changed.';
}

}


$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']."_store_items";
$store_item_query = "SELECT store_item_id, item_name, price_2 FROM $table_name WHERE subCategory = 'Timber' AND class = 'S5' 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_2");
		$w++;
	}

$table_name = $_SESSION['db_prefix']."_store_items";
$store_item_query = "SELECT store_item_id, item_name, price_2 FROM $table_name WHERE subCategory = 'Timber' AND class = 'S7' 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_2");
		$w++;
	}
	
$table_name = $_SESSION['db_prefix']."_store_items";
$store_item_query = "SELECT store_item_id, item_name, price_2 FROM $table_name WHERE subCategory = 'Timber' AND class <> 'S5' AND class <> 'S7' AND class <> 'Plate' ORDER BY item_name ASC";

	$store_item_result = execsql($store_item_query);
	$store_item_num = mysql_num_rows($store_item_result);
	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while ($w < $store_item_num) {
		$arrId4[$w] = mysql_result($store_item_result, $w, "store_item_id");
		$arrName4[$w] = mysql_result($store_item_result, $w, "item_name").' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #'.mysql_result($store_item_result, $w, "price_2");
		$w++;
	}		
	

$table_name = $_SESSION['db_prefix']."_store_items";
$store_item_query = "SELECT store_item_id, item_name, price_2 FROM $table_name WHERE subCategory = 'Mitek' ORDER BY item_name ASC";

	$store_item_result = execsql($store_item_query);
	$store_item_num = mysql_num_rows($store_item_result);
	$w = 0;
	$arrId5 = array ();
	$arrName5 = array ();
	while ($w < $store_item_num) {
		$arrId5[$w] = mysql_result($store_item_result, $w, "store_item_id");
		$arrName5[$w] = mysql_result($store_item_result, $w, "item_name").' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #'.mysql_result($store_item_result, $w, "price_2");
		$w++;
	}
	
$table_name = $_SESSION['db_prefix']."_store_items";
$store_item_query = "SELECT store_item_id, item_name, price_2 FROM $table_name WHERE subCategory = 'Sundries' ORDER BY item_name ASC";
	$store_item_result = execsql($store_item_query);
	$store_item_num = mysql_num_rows($store_item_result);
	$w = 0;
	$arrId6 = array ();
	$arrName6 = array ();
	while ($w < $store_item_num) {
		$arrId6[$w] = mysql_result($store_item_result, $w, "store_item_id");
		$arrName6[$w] = mysql_result($store_item_result, $w, "item_name").' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #'.mysql_result($store_item_result, $w, "price_2");
		$w++;
	}

?>
<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 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>

<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 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>



<!--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 ?>", "Timber Class 5", "Timber Class 5", "Timber Class 5");
addList("category<?php echo $k ?>", "Timber Class 7", "Timber Class 7", "Timber Class 7");
addList("category<?php echo $k ?>", "Timber other", "Timber other", "Timber other");
addList("category<?php echo $k ?>", "Mitek", "Mitek", "Mitek");
addList("category<?php echo $k ?>", "Sundries", "Sundries", "Sundries");
<?php
$k++;
}
?>

		addList("Timber Class 5", "", "", "");
		<?php 
    	for ($w = 0; $w < count($arrId2); $w++) { ?>
			addList("Timber Class 5", "<?php echo $arrName2[$w]?> ", "<?php echo $arrId2[$w]?> ", "");
		<?php
	    }
     ?>
		addList("Timber Class 7", "", "", "");
		<?php 
        for ($w = 0; $w < count($arrId3); $w++) { ?>
			addList("Timber Class 7", "<?php echo $arrName3[$w]?> ", "<?php echo $arrId3[$w]?> ", "");
		<?php
	    }
	?>
		addList("Timber other", "", "", "");
		<?php 
        for ($w = 0; $w < count($arrId4); $w++) { ?>
			addList("Timber other", "<?php echo $arrName4[$w]?> ", "<?php echo $arrId4[$w]?> ", "");
		<?php
	    }
	?>
		addList("Mitek", "", "", "");
		<?php 
        for ($w = 0; $w < count($arrId5); $w++) { ?>
			addList("Mitek", "<?php echo $arrName5[$w]?> ", "<?php echo $arrId5[$w]?> ", "");
		<?php
	    }
	?>
		addList("Sundries", "", "", "");
		<?php 
        for ($w = 0; $w < count($arrId6); $w++) { ?>
			addList("Sundries", "<?php echo $arrName6[$w]?> ", "<?php echo $arrId6[$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(); calc_M_tot(); <?php if ($authorise==1) {?> alertMessage(1, '', '<?php echo $auth_message ?> ')<?php } ?>;">
<form name="form1" id="form1" action="cash_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">
              Edit cash sale quotation
              </label>
                 <input type="hidden" name="job_no_text" id="job_no_text" value="<?php echo $job_no ?>"/>
                 
              </td>
              <td width="197"><label style="font-size:24px; color:#FB6808;"><?php echo $job_no ?></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']."_cash_job_lines";
$line_query = "SELECT *  FROM $table_name WHERE  quote_no =  '".$job_no."' AND quantity > 0";
$line_result = mySQL_query($line_query);
$line_num = mysql_num_rows($line_result);
?>
              <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_2</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_2");
					 
					$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_2_text<?php echo $i ?>').value='';
              document.getElementById('quantity_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_2_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_2_text<?php echo $i ?>').value).toFixed(2); calc_M(<?php echo $line_num?>)" onkeypress="return numbersonly(this, event)" onfocus = "this.select();" autocomplete="off"  onchange="document.getElementById('edit_monitor').value='yes'; "/></td>
                  <td align="right" valign="middle"><input type="text" name="price_2_text<?php echo $i ?>" id="price_2_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" align="left" valign="top"><a href="" onmouseover="ddrivetip('Click to add a new line.', 150)"; onmouseout="hideddrivetip()" onclick= " 
                  
	if (document.getElementById('edit_monitor').value=='no') {
		  editwindow=dhtmlmodal.open('editBox', 'iframe', '../edit_windows/cash_quotation_add_line.php?quote_no=<?php echo $job_no ?>', 'Select product', 'width=450px,height=75px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false;
	}
	else {
		alertMessage(1, 'cash_quotation_edit.php', 'Before adding a line, you need to save the changes you made. Click the Save button and try again.'); return false;
	}

                  "><img src="../images//line_edit.png" width="16" height="12" /><font color='#FF6600'> New line</font></a>&nbsp;
                    <?php $discount_amount = $a5_total * ($sales_discount/100) ?>
                  &nbsp;
                  <?php $sub_total2 = $sub_total - $discount_amount ?>
                  &nbsp;
                  <?php $sub_total3 = $sub_total + $transport ?>
                  &nbsp;
                  <?php $vat_amount = $sub_total3 * ($sales_vat/100) ?>
                  &nbsp;
                  <?php $all_total = $sub_total3 + $vat_amount ?>
                  <input type="hidden" name="edit_monitor" id="edit_monitor" value="no" />
                  <div align="right"><font color='#FF6600'>To delete a line, set qty to zero</font></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="3" rowspan="6" align="left" valign="top">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_2.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">Discount: 
                    <input type="text" name="discount" id="discount"  value="<?php echo $sales_discount ?>" width="40" class="text40" onkeyup="if (this.value>5) {alertMessage(1, '', 'Max value for discount to enter here is 5%.<br>Discount is reset to 0.'); document.getElementById('discount').value=0;} this.value = this.value.replace (/(\...).*/, '$1'); calc_M_tot();" onKeyPress="return isNumberKey(event)" />
                  <a href="" onMouseOver="ddrivetip('Click to override discount limit.', 150)"; onMouseOut="hideddrivetip()" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', '../edit_windows/discount_edit_override.php?quote_no=<?php echo $job_no ?>', 'Override discount.', 'width=300px,height=200px,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></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">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 $sales_vat ?>%
                  <input type="hidden" name="vat" id="vat" value="<?php echo $sales_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 />
             
<br />
<br><br>

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