<head>
<?php 
$page_name = "Quote-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['description'] = "";
	 $_SESSION['seller'] = "";
	 $_SESSION['designer'] = "";
	 $_SESSION['receive_date'] = date('Y-m-d');
	 $_SESSION['require_date'] = date('Y-m-d');
	 

$table_name = $_SESSION['db_prefix']."_customer";
    $position_query = "SELECT cust_id, comp_name 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) {
		$arrId3[$k] = mysql_result($position_result, $k, "cust_id");
		$arrName3[$k] = mysql_result($position_result, $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-->

<!--jscript-->
<script type="text/javascript" src="../jscript/jquery.min.js"></script>
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<script language="JavaScript" src="../jscript/upper_case.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/numbers_only.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/capitalize_textbox.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/lower_case.js"  type="text/javascript"></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="quoteRequestWizbase.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="MM_showHideLayers('client','','hide');MM_showHideLayers('contact','','show'); $('#comp_name_text').attr('value', ''); $('#cell_text').attr('value', '');  $('#sort_group_1').attr('checked', false); $('#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/icon-error.png" width="30" height="30" />&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/icon-error.png" width="30" height="30" />&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;
          <select name="comp_name_select" class="select200"  >
            <option value=" "> </option>
            <option value="Select" selected>Select</option>
            <?php
        	for ($k = 0; $k < count($arrId3); $k++) {
    		echo "<option value=" . "\"" . $arrId3[$k] . "\"" . ">" . $arrName3[$k] . "</option>";
	}
?>
          </select>
          &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" colspan="3"><label class="label_std">
                  <input name="sort_group" type="radio" id="sort_group_0" onClick="MM_showHideLayers('hidden_2','','hide')" value="corporate">
                  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')" value="private" checked>
                  private</label></td>
            </tr>
            <tr>
              <td><label class="label_std">Company or 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">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)"></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><input name="email_text" type="text" class="text150" value="" id="email_text"  onkeyup="ToLower(this)"></td>
              <td>&nbsp;</td>
              <td>&nbsp;</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, '../sales/sales_main.php?date='); " value="Cancel" /></td>
            <td width="110" align="right"><input type="submit" name="next_button" class="imagebutton" value="Next"  disabled="true"  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'] = "sales/sales_main.php";	?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>
