<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />        	
<?php
include('../include/session.php');
include ("../navigation/header.php");
include ("../navigation/sales_sidebar.php");

	$d="";
	$s = $_GET['s'];
	$p = $_GET['p'];
	$_SESSION['p']=$p;
	$_SESSION['s']=$s;
	
	
	if (isset($_GET['prev_button']) )
	   {
		 $_SESSION['p']= $_SESSION['p']-1;
	   }
		 
	if (isset($_GET['next_button']) )
	  {
		$_SESSION['p']=$_SESSION['p']+1;
	  }
	
		
	
	if ($s==1) {
	  $_SESSION['quote_no']	 = $_GET['quote_no'];
	  $_SESSION['cust_id']	 = $_GET['cust_id'];
		
	  	$table_name2 = $_SESSION['db_prefix']."_customer";
		$customer_query = "SELECT * FROM $table_name2 WHERE cust_id ='".$_SESSION['cust_id']."' ";
		$customer_result = mySQL_query($customer_query);
		$customer_num = mysql_num_rows($customer_result);
		if ($customer_num!=0) {	
		$a1 = mysql_result($customer_result, 0, "account_type");
			if ($a1=="corporate") { 
				$_SESSION['name'] = mysql_result($customer_result, 0, "comp_name"); 
			} 
			else {
				$_SESSION['name'] = mysql_result($customer_result, 0, "title")." ".mysql_result($customer_result, 0, "name_2")." ".mysql_result($customer_result, 0, "comp_name");
 			}
		}
		else {
			$_SESSION['name'] = 'Bill of quantity';
		}
		
	}
		
	
	if($s==2) {
	  	
	  $_SESSION['status'] = $_GET['status_group'];
	  if ($_SESSION['status']=="successful" ) {
	
	  if ($_SESSION['name']!='Bill of quantity') {	  
		  	
	    	$_SESSION['entry_date'] = $_GET['entry_date'];
	  		$_SESSION['seller'] = $_GET['seller_select'];
	  		$_SESSION['notes'] = $_GET['notes_text'];
					
			
			$table_name = $_SESSION['db_prefix']."_quotation_notes";
    		$notes_query = "INSERT INTO $table_name (quote_number, note_date, progress_status, note_text, seller ) VALUES ( '".trim($_SESSION['quote_no'])."', '".trim($_SESSION['entry_date'])."', '".trim($_SESSION['status'])."', '".trim($_SESSION['notes'])."', '".trim($_SESSION['seller'])."' ) ";
    		execsql($notes_query);
			
				$table_name = $_SESSION['db_prefix']."_quotations";
				$status_query = "UPDATE $table_name SET status = 'quoted' WHERE quote_no = '".$_SESSION['quote_no']."' ";
				execsql($status_query);
			
		?>
            <script language="javascript" type="text/javascript">
        		window.location="acceptanceWiz0.php?quote_no=<?php echo $_SESSION['quote_no'] ?> ";
        	</script>
            <?php	
	  }
	   else {
		    $_SESSION['priority'] = $_GET['priority_group'];
		    $_SESSION['entry_date'] = $_GET['entry_date'];
	  		$_SESSION['seller'] = $_GET['seller_select'];
	  		$_SESSION['notes'] = $_GET['notes_text'];
			
			   
		       	$table_name = $_SESSION['db_prefix']."_quotation_notes";
				$notes_query = "INSERT INTO $table_name (quote_number, note_date, progress_status, note_text, seller ) VALUES ( '".trim($_SESSION['quote_no'])."', '".trim($_SESSION['entry_date'])."', '".trim($_SESSION['status'])."', 'This bill of quantity was successful', '".trim($_SESSION['seller'])."' ) ";
    			execsql($notes_query);
    			$notes_query = "INSERT INTO $table_name (quote_number, note_date, progress_status, note_text, seller ) VALUES ( '".trim($_SESSION['quote_no'])."', '".trim($_SESSION['entry_date'])."', '".trim($_SESSION['status'])."', '".trim($_SESSION['notes'])."', '".trim($_SESSION['seller'])."' ) ";
    			execsql($notes_query);
		   
				$table_name = $_SESSION['db_prefix']."_quotations";
				$status_query = "UPDATE $table_name SET status = 'accepted' WHERE quote_no = '".$_SESSION['quote_no']."' ";
				execsql($status_query);
			}	
			
			?>
        	<script language="javascript" type="text/javascript">
        		window.location="qbill.php?quote_no=<?php echo $_SESSION['quote_no'] ?> ";
        	</script>
        	<?php
			}
	 
	  else {
		    $_SESSION['priority'] = $_GET['priority_group'];
		    $_SESSION['entry_date'] = $_GET['entry_date'];
	  		$_SESSION['seller'] = $_GET['seller_select'];
			
			
			if ($_SESSION['saved_priority']!=$_SESSION['priority']) {
				   
				   $_SESSION['notes'] = 'Priority changed from '.$_SESSION['saved_priority'].' to '.$_SESSION['priority'].'<br>'.$_GET['notes_text'];
			}
			else {
				$_SESSION['notes'] = $_GET['notes_text'];
			}
	  		
	  }
			
			
	 
	};
	
	
	
	
	
	?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/wizard.css" />
<link href="../css/wait.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="../window/dhtmlwindow.css" type="text/css" />
<link rel="stylesheet" href="../window/modal.css" type="text/css" />


<!--jscript-->
<script language="JavaScript" src="../jscript/cancel_confirmation.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/confirm_exit.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></script>
<script type="text/javascript" src="../window/dhtmlwindow.js"></script>
<script type="text/javascript" src="../window/modal.js"></script>
            
        	
<div class="main_frame">
<div class="page_head_frame">
<label class="label_page_head">Status <?php if ($_SESSION['name']=='Bill of quantity'){ echo 'Bill of quantity';} else { echo 'Quote';} ?></label>
              &nbsp;&nbsp;
  <label class="label_page_head_2"><?php if ($_SESSION['name']!='Bill of quantity'){ echo $_SESSION['name'];}?></label>
  &nbsp;
  <label class="label_quote_no">
&nbsp;
<?php if ($_SESSION['quote_no']!='') { echo $_SESSION['quote_no']; } ?>           
</div><br>
<br>
<br>
<br>

      <table >
      <tr>
      <td > 
      <div class="wizard_paging_frame">
      <table align="left">
      <tr>
      <td>
	  <?php if ($_SESSION['p']==1) { ?>
      <div class="active_step_frame">
      <div class="active_step_head_label">&nbsp;1</div></div>
      <div class="active_step_label">
      Select quote</div>
      <?php } else { ?>
      <div class="de_active_step_frame">
      <div class="de_active_step_head_label">&nbsp;1</div></div>
      <div class="de_active_step_label">
      Select quote</div>
      <?php } ?>
      </td>
      <td>
	  <?php if ($_SESSION['p']==2) { ?>
      <div class="active_step_frame">
      <div class="active_step_head_label">&nbsp;2</div></div>
      <div class="active_step_label">
      Enter notes</div>
      
      <?php } else { ?>
      <div class="de_active_step_frame">
      <div class="de_active_step_head_label">&nbsp;2</div></div>
      <div class="de_active_step_label">
      Enter notes</div>
      
      <?php } ?>
      </td>
      </tr>
      </table>
      </div> 
       </td>
       </tr>
       <tr>
              <td>
	   <?php 
	if ($_SESSION['p']==1) { include("quote_updateWiz1.php"); }
	if ($_SESSION['p']==2) { include("quote_updateWiz2.php"); }
		
    ?></td>
    </tr>
    </table>
                    </div>
                      

                  
        	<?php include ('../navigation/side_bar.php'); ?>
