<?php
if ($job_no=='') {
	$job_no = $quote_no;
	$quote='yes';
	}

if (($quote!='yes') AND ($job_no!='0')) {

$table_name = $_SESSION['db_prefix']."_captured_jobs";
$job_query = "SELECT * FROM $table_name WHERE job_no = '".$job_no."' ";
$job_result = mySQL_query($job_query);
//$job_no = mysql_result($job_result, 0, "job_no");
$cust_id = mysql_result($job_result, 0, "cust_id");
$designer = mysql_result($job_result, 0, "designer");
$roof_cover = mysql_result($job_result, 0, "roof_cover");
$roof_pitch = mysql_result($job_result, 0, "roof_pitch");
$max_overhang = mysql_result($job_result, 0, "max_overhang");
$roof_area = mysql_result($job_result, 0, "roof_area");
$floor_area = mysql_result($job_result, 0, "floor_area");
$quote_note = mysql_result($job_result, 0, "quote_note");
$value = mysql_result($job_result, 0, "value");
$order_date = mysql_result($job_result, 0, "date");
$del_date = mysql_result($job_result, 0, "del_date");
$note = mysql_result($job_result, 0, "quote_note");
$install = mysql_result($job_result, 0, "install_by");

$b9 = mysql_result($job_result, 0, "project_no");
$b10 = mysql_result($job_result, 0, "project_place");

$b11 = mysql_result($job_result, 0, "project_description");
$b12 = mysql_result($job_result, 0, "designer");
$b13 = mysql_result($job_result, 0, "value");
if ($del_date!='') {$b14 = date("d-m-Y", strtotime($del_date)); } else {$b14='';}
if (basename($_SERVER['PHP_SELF'])=='captureJobWizbase.php') ($del_date = $in_del_date);
}
else
{
$cust_id = '';
$designer = '';
$roof_cover = '';
$roof_pitch = '';
$max_overhang = '';
$roof_area = '';
$floor_area = '';
$quote_note = '';
$value = '';
$order_date = '';
$del_date = '';
$note = '';
$install = '';

$b9 = '';
$b10 = '';

$b11 = '';
$b12 = '';
$b13 = '0.00';
if ($del_date!='') {$b14 = date("d-m-Y", strtotime($del_date)); } else {$b14='';}
}



if (($quote=='yes') AND ($job_no!='0')) {
$table_name = $_SESSION['db_prefix']."_quotations";
$seller_query = "SELECT seller, quote_value, project_no, project_place, quote_type FROM $table_name WHERE quote_no = '".$job_no."' ";
$seller_result = mySQL_query($seller_query);
$quote_value = mysql_result($seller_result, 0, "quote_value");
$quote_type = mysql_result($seller_result, 0, "quote_type");
$seller = mysql_result($seller_result, 0, "seller");
$b9a = mysql_result($seller_result, 0, "project_no");
$b10a = mysql_result($seller_result, 0, "project_place");


$jobTT ="<table id=table_tool_tip width=300 ><tr><td  width=100>Job no:</td><td width=175>".$job_no."</td></tr><tr><td valign=top>Project no /place:</td><td>".$b9."&nbsp;".$b10."</td></tr><tr><td>Project description:</td><td>".$b11."</td></tr><tr><td>Designer:</td><td>".$b12."</td></tr><tr><td>Job value:</td><td>P ".number_format($b13, 2, '.', ',')."</td></tr><tr><td>Delivery date:</td><td>".$b14."</td></tr></table><br><b>Click for job progress.</b>";
}
else {
	$table_name = $_SESSION['db_prefix']."_quotations";
	$seller_query = "SELECT seller, value, project_no, project_place, designer FROM $table_name WHERE quote_no = '".$job_no."' ";
	$seller_result = mySQL_query($seller_query);
	$seller_num = mysql_num_rows($seller_result);
	if ($seller_num!=0) {
	$seller = mysql_result($seller_result, 0, "seller");
	}
	else {
		$seller='';
	}
	$jobTT ="Cash sale";
}


?>
<table width="650" id="table_details_display">
  <tr>
    <td width="116" align="left" valign="top"><?php if($quote=='yes') { echo 'Quote no:';} else {echo 'Job no:'; }?></td>
    <td width="182" align="left" valign="top"><?php if ($job_no!=0) { echo $job_no; } ?>&nbsp;</td>
    <td width="100" align="left" valign="top">Project:</td>
    <td align="left" valign="top"><?php if ($quote=='yes') { echo $b9a.' '.$b10a; } else { echo $b9.' '.$b10 ; } ?></td>
  </tr>
  <tr>
    <td align="left" valign="top"><?php if($quote=='yes') { echo 'Quote type:';} else {echo 'Job type:'; }?></td>
    <td align="left" valign="top"><?php if ($quote_type=='trusses') { echo 'Truss / Tiles installations'; }
	                                    if ($quote_type=='tiles') { echo 'Tiles & Accessories'; }  ?></td>
    <td align="left" valign="top">&nbsp;</td>
    <td align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td align="left" valign="top">Order date:</td>
    <td align="left" valign="top"><?php if ($order_date!='') {echo date("d-m-Y", strtotime($order_date)); } ?></td>
    <td align="left" valign="top">Delivery date:</td>
    <td align="left" valign="top"><?php if ($del_date!='') { echo date("d-m-Y", strtotime($del_date)); } ?></td>
  </tr>
  <tr>
    <td align="left" valign="top"><?php if ($quote=='yes') {echo 'Quote value:';} else { echo 'Job value';} ?></td> 
    <td align="left" valign="top"><?php if ($quote=='yes') {echo number_format($quote_value, 2, '.', ',');} else { if ($job_no!=0) { echo number_format($value, 2, '.', ',');}} ?></td>
    <td align="left" valign="top">Sales rep:</td>
    <td align="left" valign="top"><?php echo $seller?></td>
  </tr>
  <tr>
    <td align="left" valign="top">Additional info:</td>
    <td colspan="3" align="left" valign="top"><?php echo $quote_note ?></td>
  </tr>
</table>
