<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
include ("../navigation/header.php");

$page_name = "Sales-main";
include ("../navigation/access.php");

if ($permission_num==1) {

include ("../navigation/sales_sidebar.php");

$quote_no = $_GET['quote_no'];

   
		$table_name = $_SESSION['db_prefix']."_quotations";
		$quote_query = "SELECT *  FROM $table_name WHERE quote_no = '".$quote_no."'";
		
		$quote_result = mySQL_query($quote_query);
		$cust_id=mysql_result($quote_result, 0, "cust_id");
		$seller=mysql_result($quote_result, 0, "seller");
		$branch=mysql_result($quote_result, 0, "branch");
		$seller=mysql_result($quote_result, 0, "seller");
		$pallets=mysql_result($quote_result, 0, "pallets");
		$pallets_price=mysql_result($quote_result, 0, "pallets_price");
		 
		 $company_contact=mysql_result($quote_result, 0, "company_contact");
		 $contact_phone=mysql_result($quote_result, 0, "contact_phone");
	 	 $project_no=mysql_result($quote_result, 0, "project_no");
		 $quote='yes';
		 $b9=$project_no;
		 $b10=mysql_result($quote_result, 0, "project_place");
	 	 //$value=mysql_result($quote_result, 0, "value");
		 $cust_id = $cust_id;
		 $job_no='';
		 		
				
		$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);

	
	$quote_no = $quote_no;

$table_name = $_SESSION['db_prefix']."_tile_orders";
$order_query = "SELECT order_no FROM $table_name WHERE order_no =  '".$quote_no."' ";
$order_result = mySQL_query($order_query);
$order_num = mysql_num_rows($order_result);
if ($order_num > 0) { ?>
<script>
document.getElementById('next_button').hidden=true;
</script>
<?php }
	
?>

<!--jscript-->
<script language="JavaScript" src="../jscript/cancel_confirmation.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/back_button_override.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/upper_case.js"  type="text/javascript"></script>   

</head>

<body onLoad="backButtonOverride()">

<div class="main_frame" >
  <div class="page_head_frame">
        <table width="650" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="483"><label class="label_page_head">Radstone tile order</label></td>
            <td width="167" align="right"><label class="label_page_head_2">Order no <?php echo $quote_no?><br>
<?php echo $branch ?> branch</label></td>
          </tr>
        </table>
  </div><br />
<div class="page_middle_frame">
<form action="tile_order_save.php" method="get" name="form1" id="form1">
      <div class="wizard_frame">
        <label class="label_std">Quoatation no Q<?php echo $quote_no?>&nbsp;was successful.</label>
        <input type="hidden" name="quote_no" id="quote_no" value="<?php echo $quote_no ?>">
        <input type="hidden" name="cust_id" id="cust_id" value="<?php echo $cust_id ?>">
        <input type="hidden" name="branch" id="branch" value="<?php echo $branch ?>">
        <input type="hidden" name="seller" id="seller" value="<?php echo $seller ?>">
        
<br>
        <label class="label_std" style="color:#FF0000;">   Note: if this order is not completed, the quotation will remain with the status of pending.</label>
<br></div>
<br>


      <div class="wizard_frame">
        This order is placed for: 
        <?php 
		include ('../include/customer_block.php');
		?>
         </div><br>
<div class="wizard_frame">
Is this order for direct delivery by Radstone?
&nbsp;&nbsp;

  <label>
    <input type="radio" name="direct_radio_group" value="yes" id="direct_radio_group_0">
    yes</label>
    <label>
    <input type="radio" name="direct_radio_group" value="no" id="direct_radio_group_1">
    no</label>
  <br><br>
  Vertex book order no:&nbsp;&nbsp;
  <input type="text" name="book_order_text" id="book_order_text" class="text100" autocomplete="off" onkeyup="ToUpper(this)">
</div><br>
         
Items to order:<br>
<div class="wizard_frame">
         <table width="650" id="table_display" >
           <tr>
             <td height="26" colspan="2" align="left" valign="top">Item</td>
             <td width="116" align="left" valign="top">Group</td>
             <td width="71" align="left" valign="top">Unit</td>
             <td width="56" align="left" valign="top">quantity</td>
             <td width="85" align="left" valign="top">price</td>
             <td width="73" 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;
					 
				 ?>
           <tr>
             <td colspan="2" valign="top"><?php echo $a1a ?></td>
             <td valign="top"><?php echo $a4a ?></td>
             <td valign="top"><?php echo $a3a ?></td>
             <td valign="top"><?php echo $a2 ?></td>
             <td align="right" valign="top"><?php echo $a3. "  /" .$a3a ?>&nbsp;</td>
             <td align="right" valign="top"><?php echo number_format($a5, 2, '.', ',')?></td>
           </tr>
           <?php 
			   // $a6_total=$a6_total+$a6;
				$i++;
				 }
				 ?>
           <tr>
             <td colspan="2" align="left" valign="top">&nbsp;</td>
             <td align="left" valign="top">&nbsp;</td>
             <td align="left" valign="top">&nbsp;</td>
             <td align="left" valign="top">&nbsp;</td>
             <td align="left" valign="top">Total:</td>
             <td align="right" valign="top"><input name="value_text" type="hidden" value="<?php echo $a5_total ?>"><?php echo number_format($a5_total, 2, '.', ',') ?></td>
           </tr>
         </table>
         </div><br>
         <div>
         <?php echo $pallets ?> pallets to be used for this order. <input name="pallets_text" type="hidden" value="<?php echo $pallets ?>"><input name="pallets_price_text" type="hidden" value="<?php echo $pallets_price ?>">
         </div>
         <br>
<br>


    <table width="642" height="50" align="left" id="table_button_bar">
        <tr>
          <td width="117">&nbsp;</td>
          <td width="115">&nbsp;</td>
          <td width="99">
            </span></td>
          <td width="125" align="right"><input name="cancel_button" type="button" class="imagebutton" id="cancel_button" onClick="needToConfirm = false; cancel_confirmation(6, '../sales/sales_main.php?date=&branch=')" value="Cancel" tabindex="3"/></td>
          <td width="162" align="right"><input type="submit" name="next_button" id="next_button" class="imagebutton" value="Place order" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');" tabindex="1"/></td>
        </tr>
      </table>
</form>
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("direct_radio_group","selone","- direct delivery:   yes / no.");
  frmvalidator.addValidation("book_order_text","req","- Vertex order book number.");
</script>
</div>
</div>    
  
</div>


</body>
<?php } else {  ?>
<script> needToConfirm = false; </script>
<?php
    $_SESSION['denied_return'] = "store/store_main.php";	?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>
<?php include ('../navigation/side_bar.php'); ?>