<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<?php
include('../include/session.php');

$maintenance_card_no = $_GET['maintenance_card_no'];
$quote='no';
$table_name = $_SESSION['db_prefix']."_maintenance_jobs";
$maintenance_query = "SELECT * FROM $table_name WHERE maintenance_card_no = '".$maintenance_card_no."' ";
$maintenance_result = mySQL_query($maintenance_query);
$cust_id = mysql_result($maintenance_result, 0, "cust_id");	


$table_name2 = $_SESSION['db_prefix']."_customer";
		$customer_query = "SELECT * FROM $table_name2 WHERE cust_id ='".$cust_id."' ";
		$customer_result = mySQL_query($customer_query);
		$customer_num = mysql_num_rows($customer_result);	
		$a1 = mysql_result($customer_result, 0, "account_type");
			if ($a1=="corporate") { 
				$name = mysql_result($customer_result, 0, "comp_name"); 
			} 
			else {
				$name = mysql_result($customer_result, 0, "title")." ".mysql_result($customer_result, 0, "name_2")." ".mysql_result($customer_result, 0, "comp_name");
 			}

$table_name = $_SESSION['db_prefix']."_maintenance_jobs";
$job_query = "SELECT * FROM $table_name WHERE maintenance_card_no = '".$maintenance_card_no."' ";
$job_result = mySQL_query($job_query);
$maintenance_no = mysql_result($job_result, 0, "maintenance_no");
$cycle_no = mysql_result($job_result, 0, "cycle_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");
$team = mysql_result($job_result, 0, "team");

$table_name = $_SESSION['db_prefix']."_survey_maintenance";
$survey_query = "SELECT * FROM $table_name WHERE  maintenance_card_no = '".$maintenance_card_no."' ";
$survey_result = mySQL_query($survey_query);
$survey_num = mysql_num_rows($survey_result);

if ($survey_num==1) {
$result_1 = mysql_result($survey_result, 0, "result_1");
$result_2 = mysql_result($survey_result, 0, "result_2");
$result_3 = mysql_result($survey_result, 0, "result_3");
$result_4 = mysql_result($survey_result, 0, "result_4");
$cust_notes = mysql_result($survey_result, 0, "cust_notes");
}
else {
$result_1 = '100';
$result_2 = '100';
$result_3 = '100';
$result_4 = '100';
$cust_notes = '';
}
?>


<!--style sheets-->
<link href="../css/main.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<link rel="stylesheet" href="../window/dhtmlwindow.css" type="text/css" />
<link rel="stylesheet" href="../window/modal.css" type="text/css" />

<!--jscript-->
<script type="text/javascript" src="../jscript/tablesort.js"></script>
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>

<script type="text/javascript" src="../window/dhtmlwindow.js"></script>
<script type="text/javascript" src="../window/modal.js"></script>
<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/confirm_exit.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/cancel_confirmation.js"  type="text/javascript"></script> 
  
</head>
<body>
<?php
include ("../navigation/header.php");
$page_name = "Maintenance-survey";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/maintenance_sidebar.php");
?>
<div class="main_frame" style="height:auto;">
  <div class="page_head_frame">
      <table width="809" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="472"><label class="label_page_head">Survey maintenance job:</label>
              &nbsp;&nbsp;&nbsp;<label class="label_page_head_2">&nbsp;&nbsp;&nbsp; <?php echo $name ?></label></td>
            <td width="208"><label style="font-size:24px; color:#209949;"><?php echo $maintenance_card_no ?></label></td>
            </tr>
        </table>
      </div>
<div class="page_middle_frame">
<div class="page_inside_frame">
<?php 
		include ('../include/customer_block.php');
		echo '<br>';
		?>
</div>

<div class="page_inside_frame">
<table width="650" 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 'Maintenance card no:'; ?></td>
      <td align="left" valign="top"><?php echo $maintenance_card_no;  ?></td>
    </tr>
    <?php if ($project=='Monthly maintenance') { ?>
    <tr>
      <td align="left" valign="top">Cycle number:</td>
      <td align="left" valign="top"><?php echo $cycle_no ?></td>
      <td align="left" valign="top">Maintenance contract no:</td>
      <td align="left" valign="top"><?php echo $maintenance_no ?></td>
    </tr>
    <?php } ?>
    <tr>
      <td align="left" valign="top">Maintenance team:</td>
      <td align="left" valign="top"><?php echo $team ?></td>
      <td align="left" valign="top">&nbsp;</td>
      <td align="left" valign="top">&nbsp;</td>
    </tr>
    <tr>
      <td align="left" valign="top"><?php  echo 'Order date:';?></td>
      <td width="193" align="left" valign="top"><?php  echo date("d-m-Y", strtotime($order_date));  ?></td>
      <td width="156" align="left" valign="top"><?php  echo 'Job value'; ?></td>
      <td width="160" align="left" valign="top"><?php   echo number_format($value, 2, '.', ','); ?></td>
    </tr>
    <tr>
      <td align="left" valign="top">Project period:</td>
      <td colspan="3" align="left" valign="top"><?php if ($deliver_date!='') {?>from: <?php echo date("d-m-Y", strtotime($deliver_date));  ?> to: <?php echo date("d-m-Y", strtotime($end_date));  ?><?php } ?> </td>
      </tr>
    <tr>
      <td width="121" 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>
</div>



        
<div class="page_inside_frame"></div>
<form action="../maintenance/survey_maintenance_save.php" method="get" name="form1">
<div class="page_inside_frame">
    <table width="600" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="330" height="31">Office team and sales team knowledge &amp; assstance.</td>
      <td width="270"><label>
        <input type="radio" name="survey_result_1" value="0" id="survey_result_1_0"  <?php if ($result_1==0) {?> checked=checked <?php } ?> >
        poor </label>
        <label>
          <input type="radio" name="survey_result_1" value="1" id="survey_result_1_1" <?php if ($result_1==1) {?> checked=checked <?php } ?> >
          average</label>
        <label>
          <input type="radio" name="survey_result_1" value="2" id="survey_result_1_2" <?php if ($result_1==2) {?> checked=checked <?php } ?> >
          good</label></td>
    </tr>
    <tr>
      <td height="30">Quality of product &amp; workmanship.</td>
      <td><label>
        <input type="radio" name="survey_result_2" value="0" id="survey_result_2_0"  <?php if ($result_2==0) {?> checked=checked <?php } ?> >
        poor </label>
        <label>
          <input type="radio" name="survey_result_2" value="1" id="survey_result_2_1" <?php if ($result_2==1) {?> checked=checked <?php } ?> >
          average</label>
        <label>
          <input type="radio" name="survey_result_2" value="2" id="survey_result_2_2" <?php if ($result_2==2) {?> checked=checked <?php } ?> >
good</label></td>
    </tr>
    <tr>
      <td height="30">Overall customer service.</td>
      <td><label>
        <input type="radio" name="survey_result_3" value="0" id="survey_result_3_0"  <?php if ($result_3==0) {?> checked=checked <?php } ?> >
        poor </label>
        <label>
          <input type="radio" name="survey_result_3" value="1" id="survey_result_3_1" <?php if ($result_3==1) {?> checked=checked <?php } ?> >
          average</label>
        <label>
          <input type="radio" name="survey_result_3" value="2" id="survey_result_3_2" <?php if ($result_3==2) {?> checked=checked <?php } ?> >
          good</label></td>
    </tr>
    <tr>
      <td height="30">Would you recommend or use service again?</td>
      <td><label>
        <input type="radio" name="survey_result_4" value="0" id="survey_result_4_0"  <?php if ($result_4==0) {?> checked=checked <?php } ?> >
        no&nbsp;&nbsp;&nbsp;&nbsp; </label>
        <label>
          <input type="radio" name="survey_result_4" value="1" id="survey_result_4_1" <?php if ($result_4==1) {?> checked=checked <?php } ?> >
          maybe&nbsp;</label>
        <label>
          &nbsp;
          <input type="radio" name="survey_result_4" value="2" id="survey_result_4_2" <?php if ($result_4==2) {?> checked=checked <?php } ?> >
          yes</label></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
  <p>Customer comments:</p>
  <p>
    <textarea name="cust_notes_text" cols="75" rows="8" id="cust_notes_text" maxlength="250" class="text_box"><?php echo $cust_notes ?></textarea>
  </p>
</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="maintenance_card_no_text" id="maintenance_card_no_text" value="<?php echo $maintenance_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>
</form>
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("survey_result_1","selone","- rate office/sales team.");
  frmvalidator.addValidation("survey_result_2","selone","- rate product and workmanship.");
  frmvalidator.addValidation("survey_result_3","selone","- rate customer service.");
  frmvalidator.addValidation("survey_result_4","selone","- rate recommendation.");
  
  
</script>
</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>