<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--reference to main.css removed-->
<?php
include('../include/session.php');

?>

<?php
$contract_card_no=$_GET['contract_card_no'];
require_once ('../include/tc_calendar.php');


$table_name = $_SESSION['db_prefix']."_maintenance_contracts";
$job_query = "SELECT * FROM $table_name WHERE contract_card_no = '".$contract_card_no."' ";
$job_result = mySQL_query($job_query);
//$maintenance_card_no = mysql_result($job_result, 0, "maintenance_card_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");
$start_date = mysql_result($job_result, 0, "start_date");
$end_date = mysql_result($job_result, 0, "end_date");
$project_description = mysql_result($job_result, 0, "project_description");
$project = mysql_result($job_result, 0, "project");

$project_no = mysql_result($job_result, 0, "project_no");
$project_place = mysql_result($job_result, 0, "project_place");
$project_area = mysql_result($job_result, 0, "project_area");
$deliver_date = mysql_result($job_result, 0, "start_date");
$cluster = mysql_result($job_result, 0, "cluster");


//$captured = mysql_result($job_result, 0, "captured");
$compiled = mysql_result($job_result, 0, "compiled");
$invoiced = mysql_result($job_result, 0, "invoiced");
$completed = mysql_result($job_result, 0, "completed");

$table_name = $_SESSION['db_prefix']."_list_clusters";
$position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
$arrId1 = array ();
$arrName1 = array ();
$position_result = execsql($position_query);
if ($position_result!="") {
$position_num = mysql_num_rows($position_result);
$b = 0;
while ($b < $position_num) {
		$arrId1[$b] = mysql_result($position_result, $b, "item_name");
		$arrName1[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
}
}	


	$start = strtotime($start_date);
	$d = date("d", $start );
	$m = date("m", $start );
	$y = date("Y", $start );?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />

<!--jscript-->
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script>
<script language="javascript" src="../jscript/calendar.js"></script>
<script language="JavaScript" src="../jscript/cancel_confirmation.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></script>    

</head>

<body>
<?php
include ("../navigation/header.php");
$page_name = "Maintenance-contract";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/maintenance_sidebar.php");
?>
<div class="main_frame">
<form action="maintenance_contract_edit_save.php" method="get">
  <div class="page_head_frame">
          <table width="650" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="553"><label class="label_page_head">Edit maintenance contract</label></td>
              <td width="97"><label class="label_quote_no"><?php echo $contract_card_no;  ?></label>
              </td>
            </tr>
          </table>
          </div>
          <div class="page_middle_frame">
<div class="page_inside_frame">
<?php 
include('../include/customer_block.php');
?>
</div>    
<div class="page_inside_frame">
<table width="642" id="table_details_display">
    <tr>
      <td align="left" valign="top">Project:</td>
      <td align="left" valign="top"><?php  echo $project;  ?></td>
      <td align="left" valign="top"><?php echo 'Contract card no:'; ?></td>
      <td align="left" valign="top"><?php echo $contract_card_no;  ?></td>
    </tr>
    <tr>
      <td align="left" valign="top"><?php  echo 'Order date:';?></td>
      <td width="206" align="left" valign="top"><?php  echo date("d-m-Y", strtotime($order_date));  ?></td>
      <td width="158" align="left" valign="top"><?php  echo 'Job value'; ?></td>
      <td width="156" align="left" valign="top"><?php   echo number_format($value, 2, '.', ','); ?></td>
    </tr>
    <tr>
      <td width="122" align="left" valign="top">Project place:</td>
      <td colspan="3" align="left" valign="top"><?php echo $project_no?>&nbsp;&nbsp;<?php echo $project_area?>&nbsp;&nbsp;<?php echo $project_place?></td>
    </tr>
    <tr>
      <td align="left" valign="top">Notes:</td>
      <td colspan="3" align="left" valign="top"><?php echo $quote_note ?></td>
    </tr>
  </table>
<br>
<table width="642" id="table_details_display">
  <tr>
    <td width="118">Cluster:</td>
    <td>
      <select name="cluster_select" class="select120"  >
        <option value="<?php echo $cluster ?>" selected="selected"><?php echo $cluster ?></option>
        <?php
        	for ($j = 0; $j < count($arrId1); $j++) {
    		echo "<option value=" . "\"" . $arrId1[$j] . "\"" . ">" . $arrName1[$j] . "</option>";
	}
?>
      </select></td>
    </tr>
  <tr>
    <td valign="top">Contract  period start date:</td>
    <td><?php

		$myCalendar = new tc_calendar("start_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d, $m, $y);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2010, 2030);
		$myCalendar->writeScript();
?>
      <br>
<br>
<div align="left"> <img src="../images/info_green.png" width="16" height="16">
      <label class="label_info">Selected month will be no 1 in the cycle of 12.<br>
Changing the start date will change the end date accordingly.</label>
    </div></td>
    </tr>
</table>

</div>  

<div class="page_inside_frame">
  <table width="645" border="0">
    <tr>
      <td width="20"></td>
      <td width="615" align="right"><input type="hidden" name="contract_card_no" id="contract_card_no" value="<?php echo $contract_card_no ?>" />
        <input name="button2" type="button" class="imagebutton" id="button2" onClick="cancel_confirmation(3, '../maintenance/maintenance_main.php');" value="Close"/>
        <input name="save_button"  id="save_button" type="submit" class="imagebutton" value="Save" onClick="needToConfirm = false; confirmRefresh();" />
        <input name="save_close_button"  id="save_close_button" type="submit" class="imagebutton" value="Save &amp; Close" onClick="needToConfirm = false; confirmRefresh();" /></td>
    </tr>
  </table>
</div>
</div>
</form>
</div>
<?php include ('../navigation/side_bar.php'); ?>


<?php } else {
$_SESSION['denied_return'] = "maintenance/maintenance_main.php";	
include ("../navigation/maintenance_sidebar.php");?>
<body onLoad="accessdenied(); return false">
<?php include ('../navigation/side_bar.php'); ?>
</body>
<?php }
?>
</body>
</html>