<head>
<?php 
$page_name = "Maintenance-enquiry";
include ("../navigation/access.php");
if ($permission_num==1) {
   $_SESSION['name'] ="";
   $_SESSION['type'] ="";
   $_SESSION['sort'] ="";
     $_SESSION['contact'] = "";
   $_SESSION['cell'] = "";
   $_SESSION['bag_box'] = "";
   $_SESSION['box_number'] = "";
   $_SESSION['post_place'] = "";
   $_SESSION['phone'] = "";
   $_SESSION['fax'] = "";
   $_SESSION['email'] = "";
   $_SESSION['reference'] = "";
   $_SESSION['comp_contact'] = "";
   $_SESSION['contact_phone'] = "";
   $_SESSION['project_no'] = "";
   $_SESSION['project_area'] = "";
   $_SESSION['project_place'] = "";
   $_SESSION['description'] = "";
   $_SESSION['seller'] = "";
   
   $_SESSION['receive_date'] = date('Y-m-d');
   
   

$table_name = $_SESSION['db_prefix']."_customer";
    $position_query = "SELECT cust_id, account_type, comp_name, title, name_2 FROM $table_name ORDER BY comp_name ASC";
  $arrId3 = array ();
  $arrName3 = array ();
  $position_result = execsql($position_query);
  if ($position_result!="") {
  $position_num = mysql_num_rows($position_result);
  $k = 0;
  while ($k < $position_num) {
      $a1 = mysql_result($position_result, $k, "account_type");
      if ($a1=="corporate") { 
        $comp_name = mysql_result($position_result, $k, "comp_name"); 
      } 
      else {
        $comp_name = mysql_result($position_result, $k, "title")." ".mysql_result($position_result, $k, "name_2")." ".mysql_result($position_result, $k, "comp_name");
       }
    
    $arrId3[$k] = mysql_result($position_result, $k, "cust_id");
    $arrName3[$k] = $comp_name;
    $k++;
  }
  }


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

?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/jquery.autocomplete.css" />

<!--jscript-->
<script type="text/javascript" src="../jscript/jquery.autocomplete.js"></script>
<script type="text/javascript">
 $(document).ready(function(){
  $("#comp_name_text2").autocomplete("customer_autocomplete.php", {
        selectFirst: true
  });
 });
</script>

<link href="../css/main.css" rel="stylesheet" type="text/css">
</head>
<?php include('../include/wait.php') ?>

<body onLoad="MM_showHideLayers('client','','hide', 'wait','','hide');MM_showHideLayers('contact','','hide'); <?php if ($_SESSION['type'] == "contact") { ?> MM_showHideLayers('contact','','show'); <?php } ?><?php if ($_SESSION['type'] == "client") { ?>  MM_showHideLayers('client','','show'); <?php } ?> <?php if ($_SESSION['type'] == "") { ?>  <?php } ?> " onFocus="MM_showHideLayers('wait','','hide');"  onBlur="MM_showHideLayers('wait','','hide');">
<form id="form1" name="form1" method="get" action="maintenanceRequestWizbase.php">
  <div class="page_middle_frame">
  <br>
        <div class="wizard_frame">
          
            Select for who the quotation is:
          &nbsp;&nbsp;
          
            <input type="button" name="existing_cust_button" id="existing_cust_button" value="Existing customer" class="imagebutton" onClick="MM_showHideLayers('client','','show');MM_showHideLayers('contact','','hide'); $('#comp_name_text').attr('value', '---'); $('#cell_text').attr('value', '0'); $('#sub_cat_group_1').attr('checked', true); $('#type_text').attr('value', 'client'); MM_callJS('form1.comp_name_select.selectedIndex = 0;'); next_button.disabled = false;">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="new_cust_button" type="button" class="imagebutton" id="new_cust_button" value="New customer" onClick="document.getElementById('name_2_text').hidden = true; document.getElementById('title_select').hidden = true; document.getElementById('first_name_label').hidden = true; document.getElementById('last_name_label').hidden = true; document.getElementById('company_name_label').hidden = false; MM_showHideLayers('client','','hide');MM_showHideLayers('contact','','show'); $('#comp_name_text').attr('value', ''); $('#cell_text').attr('value', '');  $('#sort_group_0').attr('checked', true); $('#type_text').attr('value', 'contact'); MM_callJS('form1.comp_name_select.selectedIndex = 1;'); next_button.disabled = false; ">

          
        </div>
        <br>
        <br>
        <br>
        <?php if ($_SESSION['error']==1) { ?>
        <div class="wizard_frame">&nbsp;<img src="../images/exclamation_mark_green_small.png" width="20" height="32" />&nbsp;&nbsp;&nbsp;
          <label class="label_std">A client with the name "<?php echo $_SESSION['company_name'];?>" does not exist exists, use a different name or select New contact.</label>
        </div>
        <?php 
  // $_SESSION['comp_name'] = "";
     } ?>
        <?php if ($_SESSION['error']==2) { ?>
        <div class="wizard_frame">&nbsp;<img src="../images/exclamation_mark_green_small.png" width="20" height="32" />&nbsp;&nbsp;&nbsp;
          <label class="label_std">A client with the name "<?php echo $_SESSION['company_name'];?>" allready exists, use a different name or select Existing customer.</label>
        </div>
        <?php 
  // $_SESSION['comp_name'] = "";
     } ?>
        <div class="wizard_frame" id="client"  >&nbsp;&nbsp;
          <label class="label_std">Select customer:&nbsp;&nbsp;</label>
          <label class="star">*</label>
          &nbsp;&nbsp;&nbsp;
          <input name="comp_name_text2" type="text" id="comp_name_text2" class="text300" value=""  "this.value='';" onBlur="capitalize(this)"/>
          &nbsp;&nbsp;&nbsp; </div>
        <div class="wizard_frame" id="contact"  >
          <table width="674" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="169" height="37"><label class="label_std">Type of customer:</label></td>
              <td height="37"><label class="label_std">
                  <input name="sort_group" type="radio" id="sort_group_0" onClick="MM_showHideLayers('hidden_2','','hide'); document.getElementById('name_2_text').hidden=true; document.getElementById('title_select').hidden=true; document.getElementById('first_name_label').hidden=true; document.getElementById('last_name_label').hidden=true; document.getElementById('company_name_label').hidden=false;" value="corporate" checked >



                  company</label>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <label class="label_std">
                  <input name="sort_group" type="radio" id="sort_group_1" onClick="MM_showHideLayers('hidden_2','','show'); document.getElementById('name_2_text').hidden=false; document.getElementById('title_select').hidden=false; document.getElementById('first_name_label').hidden=false; document.getElementById('last_name_label').hidden=false; document.getElementById('company_name_label').hidden=true;" value="private" >

                  private</label></td>
 <td height="37">&nbsp;</td>
              <td height="37"><select name="title_select" id="title_select" class="select50" hidden="hidden">
                <option value="Mr">Mr</option>
                <option value="Mrs">Mrs</option>
                <option value="Ms">Ms</option>
                <option value="Miss">Miss</option>
                <option value="Dr">Dr</option>
                <option value=" " selected="selected"> </option>
              </select></td>
            </tr>
            <tr>
                            <td><label class="label_std" id="company_name_label">Company name:</label><label class="label_std" id="last_name_label" hidden="hidden">Last name:</label>
                <label class="star"> *</label></td>
              <td width="225"><span class="wizard">
                <input name="comp_name_text" type="text" id="comp_name_text" class="text200" value="---"  onBlur="capitalize(this)" onKeyUp="ToLower(this)"/>
                </span></td>
                           <td width="96"><label class="label_std" id="first_name_label" hidden="hidden" >First name:</label></td>
              <td width="184"><label for="textfield"></label>
                             <input type="text" name="name_2_text" id="name_2_text" onBlur="capitalize(this)" onKeyUp="ToLower(this)" hidden="hidden"></td>
            </tr>
            <tr>
              <td><label class="label_std">Postal Address:</label></td>
              <td><select name="bag_box_select" class="select80" id="bag_box_select">
                  <option value="PO Box">PO Box</option>
                  <option value="P Bag">P Bag</option>
                  <option value="" selected="selected"></option>
                </select>
                <input name="box_number_text" type="text" class="text100" id="box_number_text"  value="" onKeyUp="ToUpper(this)" ></td>
              <td><label class="label_std">Postal place:</label></td>
              <td><select name="post_place_select" class="select120"  >
                  <option value="" selected="selected"></option>
                  <?php
          for ($j = 0; $j < count($arrId2); $j++) {
        echo "<option value=" . "\"" . $arrId2[$j] . "\"" . ">" . $arrName2[$j] . "</option>";
  }
?>
                </select></td>
            </tr>
            <tr>
              <td><label class="label_std">Phone:</label></td>
              <td><input name="phone_text" type="text" class="text150" id="phone_text" value="" onKeyPress="return numbersonly(this, event)"></td>
              <td><label class="label_std">Fax:</label></td>
              <td><input name="fax_text" type="text" class="text150" id="fax_text" value="" onKeyPress="return numbersonly(this, event)"></td>
            </tr>
            <tr>
              <td><label class="label_std">e-mail:</label></td>
              <td colspan="3"><input name="email_text" type="text" class="text400" value="" id="email_text"  onkeyup="ToLower(this)"></td>
            </tr>
          </table>
          &nbsp;&nbsp;
          <label class="label_red_bold">Note: when clicking next, the contact details will be saved.</label>
          </div>
        
  <table width="675" height="50" align="center" id="table_button_bar">
          <tr>
            <td width="117"><input type="hidden" name="type_text" id="type_text"></td>
            <td width="115"><input name="p" type="hidden" id="p" value="1" />
              <input name="error" type="hidden" id="error" value="0" />
              <input name="s" type="hidden" id="s" value="1" /></td>
            <td width="99">&nbsp;</td>
            <td width="125"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../maintenance/maintenance_main.php?date='); " value="Cancel" /></td>
            <td width="110" align="right"><input type="submit" name="next_button" class="imagebutton" value="Next"  onClick="needToConfirm = false; MM_showHideLayers('wait','','show');" /></td>
          </tr>
        </table>
        
</div>       
</form>

<!--form validation--> 

<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
frmvalidator.addValidation("type_group","selone","Please select existing or new customer.");
  frmvalidator.addValidation("sort_group","selone","Please select company or private.");
  frmvalidator.addValidation("comp_name_select","req","Please select customer name.");
  frmvalidator.addValidation("comp_name_text","req","Please enter customer name.");
  frmvalidator.addValidation("cell_text","req","Please enter a cell number.");
  
</script>
</body>
<?php } else { 
    $_SESSION['denied_return'] = "maintenance/maintenance_main.php?date=";  ?>
<body onLoad="needToConfirm = false; accessdenied(); return false">
</body>
<?php }
?>
