<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
include ("../navigation/header.php");
$page_name = "Sales-main";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/store_sidebar.php");

$supplier_id = $_GET['supplier_id'];

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

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


	
$table_name2 = $_SESSION['db_prefix']."_suppliers";
$customer_query = "SELECT * FROM $table_name2 WHERE supplier_id ='".$supplier_id."' ";
$customer_result = mySQL_query($customer_query);
$customer_num = mysql_num_rows($customer_result);	

$a0 = mysql_result($customer_result, 0, "account_name");
$a1 = mysql_result($customer_result, 0, "contact1");
$a2 = mysql_result($customer_result, 0, "credit_cash");
$a3 = mysql_result($customer_result, 0, "post_address");
$a4 = mysql_result($customer_result, 0, "post_place");
$a5 = mysql_result($customer_result, 0, "phys_address");
$a6 = mysql_result($customer_result, 0, "phys_place");
$a7 = mysql_result($customer_result, 0, "web_site");
$a8 = mysql_result($customer_result, 0, "VAT_no");
$a9 = mysql_result($customer_result, 0, "email2");
$a10 = mysql_result($customer_result, 0, "fax");
$a11 = mysql_result($customer_result, 0, "phone");
$a12 = mysql_result($customer_result, 0, "country");
$a13 = mysql_result($customer_result, 0, "email1");
$a14 = mysql_result($customer_result, 0, "cell1");
$a15 = mysql_result($customer_result, 0, "cell2");
$a16 = mysql_result($customer_result, 0, "contact2");
$a17 = mysql_result($customer_result, 0, "notes");
	

?>
<!--jscript-->
<script language="JavaScript" src="../jscript/capitalize_textbox.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/lower_case.js"  type="text/javascript"></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/alert_message.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/cancel_confirmation.js"  type="text/javascript"></script> 


</head>

<body>

<div class="main_frame" style="auto;">
<div class="page_head_frame">
<form action="supplier_details_edit_save.php" method="post">
          <table width="809" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><label class="label_page_head">Edit Supplier</label>
                &nbsp;&nbsp;&nbsp;
                <label class="label_page_head_2"> <?php echo $a0 ?></label></td>
            </tr>
          </table>
        </div>
        
        <div class="page_middle_frame">
          <div align="left">Company details</div>
          <table width="680" id="table_details_display">
            <tr>
              <td width="101" height="25">Supplier name:</td>
              <td width="311"><input name="account_name_text" type="text" class="text300" value="<?php echo $a0?>" onBlur="capitalize(this)">&nbsp;</td>
              <td width="141">Account status:</td>
              <td width="103"><select name="credit_cash_select" class="select120" id="credit_cash_select">
                <option value="cash">cash</option>
                <option value="credit">credit</option>
                <option value="<?php echo $a2?>" selected="selected"><?php echo $a2?></option>
              </select></td>
            </tr>
          </table>
        </div>
        <div class="page_middle_frame">
          <div align="left">Contact details</div>
          <table width="673" id="table_details_display">
            <tr>
              <td width="94" height="25">Postal address:</td>
              <td width="226"><input name="post_address_text" type="text" class="text150" id="post_address_text" value="<?php echo $a3?>" onBlur="capitalize(this)"></td>
              <td width="101">Postal place:</td>
              <td width="232"><select name="post_place_select" class="select160" id="post_place_select">
                <option value="<?php echo $a4?>" selected="selected"><?php echo $a4?></option>
                <?php
        	for ($j = 0; $j < count($arrId3); $j++) {
    		echo "<option value=" . "\"" . $arrId3[$j] . "\"" . ">" . $arrName3[$j] . "</option>";
	}
?>
              </select></td>
            </tr>
            <tr>
              <td height="25">Physical address:</td>
              <td><input name="phys_address_text" type="text" class="text150" id="phys_address_text" value="<?php echo $a5?>"onBlur="capitalize(this)"></td>
              <td>Place:</td>
              <td><select name="phys_place_select" class="select160" id="phys_place_select">
                <option value="<?php echo $a6?>" selected="selected"><?php echo $a6?></option>
                <?php
        	for ($j = 0; $j < count($arrId3); $j++) {
    		echo "<option value=" . "\"" . $arrId3[$j] . "\"" . ">" . $arrName3[$j] . "</option>";
	}
?>
              </select></td>
            </tr>
            <tr>
              <td height="25">Country:</td>
              <td><select name="country_select" class="select160" id="country_select">
                <option value="<?php echo $a12?>" selected="selected"><?php echo $a12?></option>
                <?php
        	for ($j = 0; $j < count($arrId4); $j++) {
    		echo "<option value=" . "\"" . $arrId4[$j] . "\"" . ">" . $arrName4[$j] . "</option>";
	}
?>
              </select></td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="25">Phone:</td>
              <td><input name="phone_text" type="text" class="text150" id="phone_text" value="<?php echo $a11?>" onKeyPress="return numbersonly(this, event)"></td>
              <td>Fax:</td>
              <td><input name="fax_text" type="text" class="text150" id="fax_text" value="<?php echo $a10?>" onKeyPress="return numbersonly(this, event)"></td>
            </tr>
            <tr>
              <td height="25">VAT registration no:</td>
              <td colspan="3"><input name="vat_text" type="text" class="text300" id="vat_text"  value="<?php echo $a8?>" onKeyUp="ToUpper(this)"><b><a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', '../edit_windows/supplier_edit_line.php?supplier_id=<?php echo $supplier_id?>&field=<?php echo 'web_site' ?>&amp;type=S', 'Edit web site', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"></a></b></td>
            </tr>
          </table>
        </div>
        
        <div class="page_middle_frame">
          <div align="left">Company contacts</div>
          <table width="673" id="table_details_display">
            <tr>
              <td width="94" height="25">Contact 1:</td>
              <td width="226"><input name="contact1_text" type="text" class="text150" id="contact1_text"  value="<?php echo $a1?>" onBlur="capitalize(this)"></td>
              <td width="101">Cell:</td>
              <td width="232"><input name="cell1_text" type="text" class="text150" id="cell1_text" value="<?php echo $a14?>" onKeyPress="return numbersonly(this, event)"></td>
            </tr>
            <tr>
              <td height="25">e-mail:</td>
              <td colspan="2"><input name="email1_text" type="text" class="text300" id="email1_text"  value="<?php echo $a13?>" onKeyUp="ToLower(this)"></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="25">Contact 2:</td>
              <td><input name="contact2_text" type="text" class="text150" id="contact2_text" value="<?php echo $a16?>" onBlur="capitalize(this)"></td>
              <td>Cell:</td>
              <td><input name="cell2_text" type="text" class="text150" id="cell2_text" value="<?php echo $a15?>"  onkeypress="return numbersonly(this, event)"></td>
            </tr>
            <tr>
              <td height="25">e-mail:</td>
              <td colspan="2"><input name="email2_text" type="text" class="text300" id="email2_text" value="<?php echo $a9?>" onKeyUp="ToLower(this)"></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="25">web site:</td>
              <td colspan="3"><input name="web_site_text" type="text" class="text300" id="web_site_text"  value="<?php echo $a7?>" onKeyUp="ToLower(this)"></td>
            </tr>
          </table>
        </div>
        <div class="page_middle_frame">
          <div align="left">Miscelaneous</div>
          <table width="678" id="table_details_display">
            <tr>
              <td width="131" height="25" valign="top">Notes</td>
              <td width="535"><textarea name="notes_text" cols="65" rows="3" class="text_box"><?php echo $a17?></textarea></td>
            </tr>
          </table>
        </div>
        
 <div class="page_middle_frame">
  <table width="645" border="0">
    <tr>
      <td width="20"></td>
      <td width="615" align="right"><input type="hidden" name="supplier_id_text" id="supplier_id_text" value="<?php echo $supplier_id?>" />
        <input name="button2" type="button" class="imagebutton" id="button2" onClick="cancel_confirmation(3, '../store/store_main.php?date=&branch=&subCatSelect=Tiles');" 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>
</div>
<?php include ('../navigation/side_bar.php'); ?>

</body>
<?php } else { ?>
<script> needToConfirm = false; </script>
<?php
$_SESSION['denied_return'] = "sales/sales_main.php";
include ("../navigation/sales_sidebar.php");?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>
</html>