<head>
<?php 
$page_name = "Maintenance-quotation";
include ("../navigation/access.php");

if ($permission_num==1) {	
require_once('../include/tc_calendar.php');
$table_name = $_SESSION['db_prefix']."_maintenance_quotations";
$quote_query = "SELECT  cust_id, request_date, project_no, project, project_description, project_place, company_contact, contact_phone, seller  FROM $table_name WHERE  quote_no = '".$_SESSION['quote_no']."' ";
$quote_result = mySQL_query($quote_query);
$a1 = mysql_result($quote_result, 0, "cust_id");
$a2 = mysql_result($quote_result, 0, "request_date");
$a3 = mysql_result($quote_result, 0, "project_no");
$a4 = mysql_result($quote_result, 0, "project_description");
$a5 = mysql_result($quote_result, 0, "company_contact");
$a6 = mysql_result($quote_result, 0, "contact_phone");
$a7 = mysql_result($quote_result, 0, "project_place");
$_SESSION['project'] = mysql_result($quote_result, 0, "project");

$_SESSION['seller'] = mysql_result($quote_result, 0, "seller");
$_SESSION['cust_id'] = $a1;
$cust_id = $a1;
$maintenance_no = $_SESSION['quote_no'];
$job_card_no='';
$quote='yes';
$quote_value='';
?>

<?php
if (($_SESSION['project']=='Maintenance Fence (Residential)') OR ($_SESSION['project']=='Maintenance Fence (Commercial)') OR ($_SESSION['project']=='Maintenance Gate Motor')  OR ($_SESSION['project']=='Maintenance miscellaneous') )  { ?>
<script language="javascript">
function addRow3(dataTable3) {
 
            var table = document.getElementById(dataTable3);
 
            var rowCount = table.rows.length;
            var row = table.insertRow(rowCount);
			var line_no = rowCount-1;
 
            var cell31 = row.insertCell(0);
            var element31 = document.createElement("input");
            element31.type = "checkbox";
            element31.name="line_checkbox3"+line_no;
			element31.id="line_checkbox3"+line_no;
			/*element1.checked="checked";*/
			cell31.style.verticalAlign="top";
            cell31.appendChild(element31);
			 
            var cell32 = row.insertCell(1);
            var element32 = document.createElement("textarea");
            element32.cols=85;
			element32.rows=1;
            element32.name = "item_text3"+line_no;
			element32.id = "item_text3"+line_no;
			element32.className = "text_box";
			element32.value = "";
			element32.onchange = function(){document.getElementById("line_checkbox3"+line_no).checked = "checked";}
			
			cell32.style.verticalAlign="top";
			cell32.appendChild(element32);
						
							
			var cell34 = row.insertCell(2);
			cell34.align="right";
			
			var element36 = document.createElement("input");
            element36.type = "text";
            element36.name = "amount_text3"+line_no;
			element36.id = "amount_text3"+line_no;
			element36.className = "text100";
			element36.onkeypress = function isNumberKey(evt)
       								{
          							var charCode = (evt.which) ? evt.which : event.keyCode
          							if (charCode != 46 && charCode > 31 
            						&& (charCode < 48 || charCode > 57))
             						return false;
 
          							return true;
       								}
									;
			element36.onkeyup = function() {this.value = this.value.replace (/(\...).*/, '$1')};
			element36.onchange = function(){document.getElementById("line_checkbox3"+line_no).checked = "checked";}
			element36.style = "text-align:right";		

            var element34 = document.createElement("input");
            element34.type = "hidden";
            element34.name = "line_num3";
			element34.value = rowCount;
            cell34.style.verticalAlign="top";
			
			cell34.appendChild(element36);
            cell34.appendChild(element34);
			
			var element38 = document.createElement("script");
			element38.setAttribute('type', 'text/javascript');
			element38.innerHTML="var frmvalidator  = new Validator('form1');frmvalidator.EnableMsgsTogether();for (i = 0; i < 10; i++) {frmvalidator.addValidation('item_text3'+i,'req','- price details '+(i+1)+' in option 1 .');frmvalidator.addValidation('amount_text3'+i,'req','- price '+(i+1)+' in option 1');}"; 
			document.getElementsByTagName('head').item(0).appendChild(element38);
		
			element31.onmouseup = function() {
				 if (document.getElementById('line_checkbox3'+line_no).checked) {
                         element32.style.background = '#F0F0F0';
						 element36.style.background = '#F0F0F0';
						 element32.selectedIndex=0;
						 element36.value = '.';
						 element32.disabled = true;
						 element36.disabled = true;
						 
                } else {
                        element32.style.background = '#FFF';
						element36.style.background = '#FFF';
						element32.selected_index=0;
						element36.value = '';
						element32.disabled = false;
						element36.disabled = false;
						 
                }
				};
			
}
</script>

<script language="javascript">
function addRow4(dataTable4) {
 
            var table = document.getElementById(dataTable4);
 
            var rowCount = table.rows.length;
            var row = table.insertRow(rowCount);
			var line_no = rowCount-1;
 
            var cell41 = row.insertCell(0);
            var element41 = document.createElement("input");
            element41.type = "checkbox";
            element41.name="line_checkbox4"+line_no;
			element41.id="line_checkbox4"+line_no;
			/*element1.checked="checked";*/
			cell41.style.verticalAlign="top";
            cell41.appendChild(element41);
			 
            var cell42 = row.insertCell(1);
            var element42 = document.createElement("textarea");
            element42.cols=85;
			element42.rows=1;
            element42.name = "item_text4"+line_no;
			element42.id = "item_text4"+line_no;
			element42.className = "text_box";
			element42.value = "";
			element42.onchange = function(){document.getElementById("line_checkbox4"+line_no).checked = "checked";}
			
			var element44 = document.createElement("input");
            element44.type = "hidden";
            element44.name = "line_num4";
			element44.value = rowCount;
           
					
			cell42.style.verticalAlign="top";
			cell42.appendChild(element42);
			cell42.appendChild(element44);				
	
			var element48 = document.createElement("script");
			element48.setAttribute('type', 'text/javascript');
			element48.innerHTML="var frmvalidator  = new Validator('form1');frmvalidator.EnableMsgsTogether();for (i = 0; i < 10; i++) {frmvalidator.addValidation('item_text4'+i,'req','- item '+(i+i)+' in option 2.');}"; 
			document.getElementsByTagName('head').item(0).appendChild(element48);
		
			element41.onmouseup = function() { 
				 if (document.getElementById('line_checkbox4'+line_no).checked) {
                         element42.style.background = '#F0F0F0';
						 element42.value = '.';
						 element42.disabled = true;				 
                } else {
                        element42.style.background = '#FFF';
						element42.value = '';
						element42.disabled = false;						 
                }
				}
			
}
</script> 
<script language="javascript">
function addRow5(dataTable5) {
 
            var table = document.getElementById(dataTable5);
 
            var rowCount = table.rows.length;
            var row = table.insertRow(rowCount);
			var line_no = rowCount-1;
 
            var cell51 = row.insertCell(0);
            var element51 = document.createElement("input");
            element51.type = "checkbox";
            element51.name="line_checkbox5"+line_no;
			element51.id="line_checkbox5"+line_no;
			/*element1.checked="checked";*/
			cell51.style.verticalAlign="top";
            cell51.appendChild(element51);
			 
            var cell52 = row.insertCell(1);
            var element52 = document.createElement("input");
			element52.type = "text";
            element52.name = "item_text5"+line_no;
			element52.id = "item_text5"+line_no;
			element52.className = "text300";
			element52.value = "";
			element52.onchange = function(){document.getElementById("line_checkbox5"+line_no).checked = "checked";}
			cell52.style.verticalAlign="top";
			cell52.appendChild(element52);
							
			var cell54 = row.insertCell(2);
			cell54.align="right";
			
			var element56 = document.createElement("input");
            element56.type = "text";
            element56.name = "amount_text5"+line_no;
			element56.id = "amount_text5"+line_no;
			element56.className = "text100";
			element56.onkeypress = function isNumberKey(evt)
       								{
          							var charCode = (evt.which) ? evt.which : event.keyCode
          							if (charCode != 46 && charCode > 31 
            						&& (charCode < 48 || charCode > 57))
             						return false;
 
          							return true;
       								}
									;
			element56.onkeyup = function() {this.value = this.value.replace (/(\...).*/, '$1')};
			element56.onchange = function(){document.getElementById("line_checkbox5"+line_no).checked = "checked";}
			element56.style = "text-align:right";		

            var element54 = document.createElement("input");
            element54.type = "hidden";
            element54.name = "line_num5";
			element54.value = rowCount;
            cell54.style.verticalAlign="top";
			
			cell54.appendChild(element56);
            cell54.appendChild(element54);
			
			var element58 = document.createElement("script");
			element58.setAttribute('type', 'text/javascript');
			element58.innerHTML="var frmvalidator  = new Validator('form1');frmvalidator.EnableMsgsTogether();for (i = 0; i < 10; i++) {frmvalidator.addValidation('item_text5'+i,'req','- price details '+(i+1)+' in option 2.');frmvalidator.addValidation('amount_text5'+i,'req','- price '+(i+1)+' in option 2.');}"; 
			document.getElementsByTagName('head').item(0).appendChild(element58);
		
			element51.onmouseup = function() {
				 if (document.getElementById('line_checkbox5'+line_no).checked) {
                         element52.style.background = '#F0F0F0';
						 element56.style.background = '#F0F0F0';
						 element52.selectedIndex=0;
						 element56.value = '.';
						 element52.disabled = true;
						 element56.disabled = true;
						 
                } else {
                        element52.style.background = '#FFF';
						element56.style.background = '#FFF';
						element52.selected_index=0;
						element56.value = '';
						element52.disabled = false;
						element56.disabled = false;
						 
                }
				};
			
}
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
</script>
<?php } ?>

</head>


<?php include('../include/wait.php') ?>
<body onLoad="MM_showHideLayers('wait','','hide';)" onFocus="MM_showHideLayers('wait','','hide');" onBlur="MM_showHideLayers('wait','','hide');">
<div class="wizard_page_middle_frame">
<form id="form1" method="get" action="maintenance_quoteWizbase.php">
      <div class="wizard_frame">
              <?php 
		include ('../include/customer_block.php');
		echo '<br>';
		include ('../include/maintenance_job_block.php')
		?>
    </div>
            <br>

<?php
if (($_SESSION['project']=='Maintenance Fence (Residential)') OR ($_SESSION['project']=='Maintenance Fence (Commercial)') OR ($_SESSION['project']=='Maintenance Gate Motor') OR ($_SESSION['project']=='Maintenance miscellaneous') ) { ?>
<div class="wizard_frame" id="option1_div">

      Re:&nbsp;&nbsp;
      <input name="option1_text" type="text" class="text300" id="option1_text" value="<?php echo $_SESSION['option1_text'] ?>" size="60" maxlength="100" autocomplete="off" autofocus>
      <br>
      <br>
      <br>

    <table id="dataTable3" width="590" border="1" style="border-collapse:collapse;">
      <thead>
        <tr>
          <td colspan="2">&nbsp;</td>
          <td>Price</td>
        </tr>
      </thead>
      <script>
			 function check_it3() {
				 if (document.getElementById('line_checkbox30').checked) {
                         document.getElementById('item_text30').style.background = '#F0F0F0';
						 document.getElementById('amount_text30').style.background = '#F0F0F0';
						 document.getElementById('item_text30').value = '.';
						 document.getElementById('amount_text30').value = '.';
						 document.getElementById('item_text30').disabled = true;
						 document.getElementById('amount_text30').disabled = true;
						 
                } else {
                        document.getElementById('item_text30').style.background = '#FFF';
						 document.getElementById('amount_text30').style.background = '#FFF';
						 document.getElementById('item_text30').value = 'Total Price Supply & Install';
						 document.getElementById('amount_text30').value = '';
						 document.getElementById('item_text30').disabled = false;
						 document.getElementById('amount_text30').disabled = false;
                }
				}
		     </script>
      <tr>
        <td width="20" valign="top"><input type="checkbox" name="line_checkbox30" id="line_checkbox30" onMouseUp="check_it3()" <?php if ($_SESSION['line_checkbox30']==1) { ?> checked="checked" <?php } ?> /></td>
        <td width="408" valign="top"></textarea>
          <textarea name="item_text30" id="item_text30" class="text_box" cols="85" rows="1" onChange="document.getElementById('line_checkbox30').checked='checked';" ><?php echo $_SESSION['item_text30'] ?></textarea></td>
        <td width="140" align="right" valign="top"><input  name="amount_text30" id="amount_text30" type="text" class="text100" value="<?php if ($_SESSION['amount_text30']!='') { echo $_SESSION['amount_text30']; } ?>" onKeyPress="return isNumberKey(event);" onKeyUp="this.value = this.value.replace (/(\...).*/, '$1');" onChange="document.getElementById('line_checkbox30').checked='checked';" style="text-align:right" onfocus = "this.select();" autocomplete="off"/>
          <input type="hidden" name="line_num3" id="line_num3" value="1" ></td>
        
      </tr>
      <?php 
		$i=1;
		while ($i<$_SESSION['line_num3']) { ?>
      <tr>
        <td width="20" valign="top"><input type="checkbox" name="line_checkbox3<?php echo $i ?>" id="line_checkbox3<?php echo $i ?>"  <?php if ($_SESSION['line_checkbox3'.$i]==1) { ?> checked="checked" <?php } ?> onMouseUp="{
				 if (document.getElementById('line_checkbox<?php echo $i ?>').checked) {
                         document.getElementById('item_text<?php echo $i ?>').style.background = '#F0F0F0';
						 document.getElementById('amount_text<?php echo $i ?>').style.background = '#F0F0F0';
						 document.getElementById('item_text<?php echo $i ?>').value = '.';
						 document.getElementById('amount_text<?php echo $i ?>').value = '.';
						 document.getElementById('item_text<?php echo $i ?>').disabled = true;
						 document.getElementById('amount_text<?php echo $i ?>').disabled = true;
						 
                } else {
                        document.getElementById('item_text<?php echo $i ?>').style.background = '#FFF';
						 document.getElementById('amount_text<?php echo $i ?>').style.background = '#FFF';
                         document.getElementById('item_text<?php echo $i ?>').value = '.';
						 document.getElementById('amount_text<?php echo $i ?>').value = '';
						 document.getElementById('item_text<?php echo $i ?>').disabled = false;
						 document.getElementById('amount_text<?php echo $i ?>').disabled = false;
                }
				}
                "/></td>
        <td width="408" valign="top"><textarea name="item_text3<?php echo $i ?>" id="item_text3<?php echo $i ?>" class="text_box" cols="85" rows="1" onChange="document.getElementById('line_checkbox3<?php echo $i ?>').checked='checked';"><?php echo $_SESSION['item_text3'.$i] ?></textarea></td>
        <td width="140" align="right" valign="top"><input  name="amount_text3<?php echo $i ?>" type="text" class="text100" id="amount_text3<?php echo $i ?>" value="<?php if ($_SESSION['amount_text3'.$i]!='') { echo $_SESSION['amount_text3'.$i]; } ?>" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" onChange="document.getElementById('line_checkbox3<?php echo $i ?>').checked='checked';" style="text-align:right" autocomplete="off"/>
          <input type="hidden" name="line_num3" id="line_num3" value="<?php echo $_SESSION['line_num3']?>"></td>
      </tr>
      <?php
		$i++;
		}
?>
</table>
    <input type="button" class="imagebutton" onClick="addRow3('dataTable3')" value="Add line" />
    <div align="right"><label class="label_small">To delete a line: uncheck line box.</label></div>
 </div>
  		
<input type="hidden" name="check2" id="check2" value='2'>
<br>
<?php
}
?>


<?php
if (($_SESSION['project']=='Monthly maintenance') ) { ?>
<div class="wizard_frame" id="option1_div">

      Re:&nbsp;&nbsp;
      <input name="option1_text" type="text" class="text300" id="option1_text" value="<?php echo $_SESSION['option1_text'] ?>" size="60" maxlength="100" autocomplete="off">
      <br>
      <br>
      <br>

    <table id="dataTable3" width="564" border="1" style="border-collapse:collapse;">
      <thead>
        <tr>
          <td width="408">&nbsp;</td>
          <td width="140">Price</td>
        </tr>
      </thead>
      <tr>
        <td valign="top">Year rate (11 months):</td>
        <td align="right" valign="top"><input  name="amount_text31" id="amount_text31" type="text" class="text100" value="<?php if ($_SESSION['amount_text31']!='') { echo $_SESSION['amount_text31']; } ?>" onKeyPress="return isNumberKey(event);" onKeyUp="this.value = this.value.replace (/(\...).*/, '$1');"  style="text-align:right" onfocus = "this.select();" autocomplete="off"/></td>
      </tr>
     
    </table>
    <input type="button" class="imagebutton" onClick="addRow3('dataTable3')" value="Add line" />
    <div align="right"><label class="label_small">To delete a line: uncheck line box.</label></div>
 </div>
  		
<input type="hidden" name="check2" id="check2" value='2'>
<br>
<?php
}
?>
    
 
<div class="wizard_frame">
<table width="675" height="50" align="center" id="table_button_bar">
              <tr>
                  <td width="117">&nbsp;</td>
                  <td width="115">&nbsp;</td>
                  <td width="99"><input name="p" type="hidden" id="p" value="2" />
                    <input name="s" type="hidden" id="s" value="2" />
                  </span></td>
                  <td width="125" align="right"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../maintenance/maintenance_main.php?date=');" value="Cancel" tabindex="9"/></td>
                  <td width="110" align="right"><input type="submit" name="next_button" class="imagebutton" value="Next" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');" tabindex="7"/></td>
        </tr>
    </table>
</div>
</form>
</div>
</div>
<!--form validation-->
  <script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("re_text","req","- subject text");
  
  <?php
  if ( $_SESSION['project']=='Miscelaneous')  { ?>
  frmvalidator.addValidation("option1_text","req","- option 1.");
  frmvalidator.addValidation("item_text20","req","- item 1 in option 1.");
  frmvalidator.addValidation("item_text30","req","- price details 1 in option 1.");
  frmvalidator.addValidation("amount_text30","req","- price 1 in option 1.");
   
  frmvalidator.addValidation("option2_text","req","- option 2.");
  frmvalidator.addValidation("item_text40","req","- item 1 in option 2.");
  frmvalidator.addValidation("item_text50","req","- price details 1 in option 2.");
  frmvalidator.addValidation("amount_text50","req","- price 1 in option 2.");
  <?php } ?>
  
  
  </script>
</body><?php } else { 
    $_SESSION['denied_return'] = "maintenance/maintenance_main.php?date=";	?>
	<body onLoad="needToConfirm = false;accessdenied(); return false">
	</body>
<?php }
?>