<!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" />
<link href="../css/main.css" rel="stylesheet" type="text/css" />
<?php
include('../include/session.php');

$quote_no = $_GET['quote_no'];
$job_card_no = $_GET['job_card_no'];
$table_name = $_SESSION['db_prefix']."_compiled_jobs";
$job_query = "SELECT * FROM $table_name WHERE job_card_no = '".$job_card_no."' ";
$job_result = mySQL_query($job_query);
$cust_id = mysql_result($job_result, 0, "cust_id");	
$job_card_no = mysql_result($job_result, 0, "job_card_no");
//$job_no = $job_card_no;	
?>
<link href="../css/wizard.css" rel="stylesheet" type="text/css" />
</head>
<?php



	
$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);
$d3 = mysql_result($quote_result, 0, "value");
$quote='';



$table_name = $_SESSION['db_prefix']."_compiled_jobs";
$note_query = "SELECT quote_note, date, value FROM $table_name WHERE job_no ='".$quote_no."'    ";
$note_result = mySQL_query($note_query);
$a12 = mysql_result($note_result, 0, "quote_note");
$a13 = mysql_result($note_result, 0, "date");
$a14 = mysql_result($note_result, 0, "value");
 


$table_name = $_SESSION['db_prefix']."_quotation_lines";
$line_query = "SELECT quote_item_text, quote_item_price  FROM $table_name WHERE quote_number = '".$quote_no."' ";
$line_result = mySQL_query($line_query);
$line_num = mysql_num_rows($line_result);

$table_name4 = $_SESSION['db_prefix']."_quotation_accept";
$accept_query = "SELECT account, receipt_no, order_no, invoice_no, acceptor, accept_value FROM $table_name4 WHERE quote_no = '".$quote_no."' ";
$accept_result = mySQL_query($accept_query);
$e1 = mysql_result($accept_result, 0, "account");


$e2 = mysql_result($accept_result, 0, "receipt_no");
$e3 = mysql_result($accept_result, 0, "acceptor");
$e4 = mysql_result($accept_result, 0, "order_no");
$e5 = mysql_result($accept_result, 0, "invoice_no");
$e6 = mysql_result($accept_result, 0, "accept_value");



$table_name = $_SESSION['db_prefix']."_quotation_notes";	
$notes_query = "SELECT  *   FROM $table_name WHERE quote_number = '".$quote_no."' ";
$notes_result = mySQL_query($notes_query);
$notes_num = mysql_num_rows($notes_result);
?>
<script type="text/javascript" src="../jscript/tablesort.js"></script>
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<body>
<?php include ('../include/tooltip.php'); 
include ("../navigation/header.php");
$page_name = "Sales-main";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/sales_sidebar.php");
	?>
<div class="main_frame" style="height:auto">
  <div class="page_head_frame">
          <table width="690" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="535"><label class="label_page_head">Job created </label></td>
              <td width="155"><label class="label_quote_no">job card <?php echo $job_card_no ?></label></td>
            </tr>
          </table>
        </div>
        <br />
        <br />       
        <br />
        <br />
        <div class="page_middle_frame">
        <div class="button_inside_frame"> 
         <?php 
			include ('../include/customer_block.php');
			echo '<br>';
			include ('../include/job_block.php')
		?>
          </div>
        
        <div class="button_inside_frame" > Pricing details<br />
          <table width="666" id="table_details_display">
            <?php 
	  $i=0;
	 
	  while ($i<$line_num) {
		  $d1 = mysql_result($line_result, $i, "quote_item_text");
		  $d2 = mysql_result($line_result, $i, "quote_item_price");
		  
		  ?>
            <tr>
              <td width="175"><?php echo $d1 ?></td>
              <td width="112"><div align="right"><?php echo number_format($d2, 2, '.', ',') ?></div></td>
              <td width="25">&nbsp;</td>
              <td width="103">&nbsp;</td>
              <td width="227">&nbsp;</td>
            </tr>
            <?php
	  $i++;
	  }
	  ?>
            <tr>
              <td align="right">&nbsp;</td>
              <td align="right">&nbsp;</td>
              <td align="right">&nbsp;</td>
              <td align="right">&nbsp;</td>
              <td align="right">&nbsp;</td>
            </tr>
            <tr>
              <td align="right"><b>Quote value:</b></td>
              <td align="right"><b>
                <div align="right"><?php echo number_format($d3, 2, '.', ',') ?></div>
                </b></td>
              <td align="right">&nbsp;</td>
              <td align="right">&nbsp;</td>
              <td align="right">&nbsp;</td>
            </tr>
            <tr>
              <td align="right"><b>Accepted on (Job value):</b></td>
              <td align="right"><b>
                <div align="right"><?php echo number_format($e6, 2, '.', ',') ?></div>
              </b></td>
              <td align="right">&nbsp;</td>
              <td align="right">Accepted by:</td>
              <td align="left"><?php echo $e3 ?></td>
            </tr>
            <?php if ($e1=="account") { ?>
            <tr>
              <td align="right">&nbsp;</td>
              <td align="right">&nbsp;</td>
              <td align="right">&nbsp;</td>
              <td align="right">Order no:</td>
              <td align="left"><?php echo $e4 ?>
              </td>
            </tr>
            <tr>
              <td colspan="3" align="right">&nbsp;</td>
              <td align="right">Invoice no:</td>
              <td align="left"><?php echo $e5 ?></td>
            </tr>
            <?php } ?>
            <?php if ($e1=="cash") { ?>
            <tr>
              <td colspan="3" align="right">&nbsp;</td>
              <td align="right">Receipt no:</td>
              <td align="left"><?php echo $e2 ?></td>
            </tr>
            
            <?php } ?>
          </table>
        </div>
        <div class="button_inside_frame" >Job card:
          <table width="671" id="table_details_display">
       
            <tr>
              <td>
                <label class="label_std">A job card with number <?php echo $job_card_no ?> has been created.</label>
              </td>
            </tr>
           
          </table>
          
        </div><br />
  
  
</div>
</div>
<?php include ('../navigation/side_bar.php'); ?>
</body>
<?php } else {
$_SESSION['denied_return'] = "sales/sales_main.php";	
include ("../navigation/sales_sidebar.php");?>
<body onload="accessdenied(); return false">
</body>
<?php }
?>
</html>