<?php

//$maintenance_no = $_SESSION['maintenance_no'];

if (($quote!='yes') AND ($maintenance_no!='')) {

if ($maintenance_card_no!='') {
$table_name = $_SESSION['db_prefix']."_maintenance_jobs";
$job_query = "SELECT * FROM $table_name WHERE maintenance_no = '".$maintenance_no."' ";
$job_result = mySQL_query($job_query);
$job_card_no = mysql_result($job_result, 0, "maintenance_card_no");
$type = 'Maintenance card no:';
}
else {
$table_name = $_SESSION['db_prefix']."_maintenance_contracts";
$job_query = "SELECT * FROM $table_name WHERE contract_no = '".$maintenance_no."' ";
$job_result = mySQL_query($job_query);
$job_card_no = mysql_result($job_result, 0, "contract_card_no");
$type = 'Maintenance contract no:';
}

$cust_id = mysql_result($job_result, 0, "cust_id");
$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, "start_date");
$end_date = mysql_result($job_result, 0, "end_date");
$note = mysql_result($job_result, 0, "quote_note");

$b8 = mysql_result($job_result, 0, "project_description");
$b9 = mysql_result($job_result, 0, "project_no");
$b10 = mysql_result($job_result, 0, "project_place");
$b12 = mysql_result($job_result, 0, "project_area");

$b11 = mysql_result($job_result, 0, "project_description");

$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'])=='compileJobWizbase.php') ($del_date = $in_del_date);
}
else
{
$cust_id = '';
$quote_note = '';
$value = '';
$order_date = '';
$del_date = '';
$note = '';
$install = '';
$b8 = '';
$b9 = '';
$b10 = '';

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


if (($quote=='yes') AND ($maintenance_no!='0')) {
$table_name = $_SESSION['db_prefix']."_maintenance_quotations";
$seller_query = "SELECT seller, value, project, project_no,  project_area,  project_place, request_date FROM $table_name WHERE quote_no = '".$maintenance_no."' ";
$seller_result = mySQL_query($seller_query);

$seller = mysql_result($seller_result, 0, "seller");
$b8a = mysql_result($seller_result, 0, "project");
$b9a = mysql_result($seller_result, 0, "project_no");
$b10a = mysql_result($seller_result, 0, "project_place");
$b12a = mysql_result($seller_result, 0, "project_area");
$order_date = mysql_result($seller_result, 0, "request_date");

$jobTT ="<table id=table_tool_tip width=300 ><tr><td  width=100>Job no:</td><td width=175>".$job_card_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>---:</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 FROM $table_name WHERE quote_no = '".$job_card_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 align="left" valign="top">Project:</td>
    <td colspan="3" align="left" valign="top"><?php if ($quote=='yes') { echo $b8a; } else { echo $b8; } ?></td>
  </tr>
  <tr>
    <td width="121" align="left" valign="top"><?php if($quote=='yes') { echo 'Quote no:';} else {echo $type; }?></td>
    <td width="131" align="left" valign="top"><?php if ($job_card_no!=0) { echo $job_card_no; } ?>&nbsp;</td>
    <td width="101" align="left" valign="top">Project place:</td>
    <td width="277" align="left" valign="top"><?php if ($quote=='yes') { echo $b9a.', '.$b12a.', '.$b10a; } else { echo $b9.', '.$b12.', '.$b10 ; } ?></td>
  </tr>
  <tr>
    <td align="left" valign="top"><?php if ($quote=='yes') { echo 'Quote date:';} else { echo 'Order date:';}?></td>
    <td align="left" valign="top"><?php if ($order_date!='0000-00-00') { echo date("d-m-Y", strtotime($order_date)); } ?></td>
    <td align="left" valign="top">&nbsp;</td>
    <td align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td align="left" valign="top">Project period:</td>
    <td colspan="3" align="left" valign="top"><?php if ($del_date!='') { echo 'from: '.date("d-m-Y", strtotime($del_date)).' to : '.date("d-m-Y", strtotime($end_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') { if ($quote_value!='') { echo number_format($quote_value, 2, '.', ',');} } else { if ($job_card_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">Notes:</td>
    <td colspan="3" align="left" valign="top"><?php echo $quote_note ?></td>
  </tr>
</table>
