<?php
include("../include/session.php");
if( !$session->isAdmin() && !$session->isRadstoneReceptionUser() ){
	//header("Location: ../Store/storeMenu.php");?>
<script language="javascript" type="text/javascript">
        <!--
		  window.location="denied.php";
        -->
       </script>
<?php 
}else{
	include("../storeHeader.php");
	

    $CustNo = mysql_real_escape_string($_GET['CustNo']);
	$edit = $_GET['edit'];
	
	if ($edit=="1") {
		$field = $_GET['field'];
		$editText = $_GET['editText'];
		
		$editQuery = "UPDATE customer SET $field = '".  $editText ."' WHERE CustNo = '$CustNo' ";
        $editResult = mySQL_query($editQuery);
	}
	
    	
	if ($CustNo!='0') {
	$selectQuery = "SELECT * FROM customer  WHERE CustNo =".$CustNo;
	$selectResult = execsql($selectQuery);
	
	$b0 = mysql_result($selectResult, 0, "CustNo");
	$b1 = mysql_result($selectResult, 0, "CompanyName");
	$b2 = mysql_result($selectResult, 0, "ContactName");
	$b3 = mysql_result($selectResult, 0, "Phone");
	$b7 = mysql_result($selectResult, 0, "Fax");
	$b4 = mysql_result($selectResult, 0, "Cell");
    $b8 = mysql_result($selectResult, 0, "email");
	$b5 = mysql_result($selectResult, 0, "PostalAddress");
	$b6 = mysql_result($selectResult, 0, "PostalPlace");
	$b9 = mysql_result($selectResult, 0, "VATNo");
	$b10 = mysql_result($selectResult, 0, "Remarks");
	}
	
	$w=1;
	while ($w < 11) {
	$b = 'b';	
	   if (${$b.$w} == '') { ${$b.$w}="?"; }
	   $w++;
	}
   
	?>

<link rel="stylesheet" href="../css/dhtmlwindow.css" type="text/css" />
<script type="text/javascript" src="../css/dhtmlwindow.js"></script>
<link rel="stylesheet" href="../css/modal.css" type="text/css" />
<script type="text/javascript" src="../css/modal.js"></script>
<script type="text/javascript">
<!--
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
<table id="tableMain" width="595">
  <!--begin of tableMain-->
  <tr>
    <td ><div class="headerbox2"> Edit Customer Details </div>
      <br />
      <p class="edit"><font size="3"><b><?php echo $b1 ?></b></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Click on the line you want to edit.</p></td>
    <!--center of tableMain-->
  </tr>
  <tr>
    <td><!--center of tableMain-->
      <table width="599" id="tablePlain">
        <tr>
          <td width="103">Cust. No:</td>
          <td width="186"><b>
            <?php echo $b0?>
          </b></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>Company Name:</td>
          <td><b>
            <a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editCustomerLine.php?cust_no=<?php echo $b0?>&field=<?php echo 'CompanyName' ?>&Type=T ', 'Edit Customer account', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $b1?></a>
            </b></td>
          <td width="109">Contact Name: </td>
          <td width="165"><b>
            <a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editCustomerLine.php?cust_no=<?php echo $b0?>&field=<?php echo 'ContactName' ?>&Type=T ', 'Edit Customer account', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $b2?></a>
            </b></td>
        </tr>
        <tr>
          <td>Postal Address: </td>
          <td colspan="3"><b>
           <a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editCustomerLine.php?cust_no=<?php echo $b0?>&field=<?php echo 'postalAddress' ?>&Type=T ', 'Edit Customer account', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"> <?php echo $b5."  ".$b6?></a>
            </b> </span></td>
        </tr>
        <tr>
          <td>Phone:</td>
          <td><b>
            <a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editCustomerLine.php?cust_no=<?php echo $b0?>&field=<?php echo 'Phone' ?>&Type=N ', 'Edit Customer account', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $b3?></a>
            </b></td>
          <td>Fax:</td>
          <td><b>
            <a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editCustomerLine.php?cust_no=<?php echo $b0?>&field=<?php echo 'Fax' ?>&Type=N ', 'Edit Customer account', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $b7?></a>
            </b></td>
        </tr>
        <tr>
          <td>Cell:</td>
          <td><b>
            <a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editCustomerLine.php?cust_no=<?php echo $b0?>&field=<?php echo 'Cell' ?>&Type=N ', 'Edit Customer account', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $b4?></a>
            </b></td>
          <td>e-mail:</td>
          <td><b>
           <a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editCustomerLine.php?cust_no=<?php echo $b0?>&field=<?php echo 'email' ?>&Type=T ', 'Edit Customer account', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"> <?php echo $b8?></a>
            </b></td>
        </tr>
        <tr>
          <td>VAT No.: </td>
          <td><b>
           <a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editCustomerLine.php?cust_no=<?php echo $b0?>&field=<?php echo 'VatNo' ?>&Type=T ', 'Edit Customer account', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"> <?php echo $b9?></a>
            </b></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>Remarks:</td>
          <td colspan="3"><b>
            <a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editCustomerLine.php?cust_no=<?php echo $b0?>&field=<?php echo 'Remarks' ?>&Type=T ', 'Edit Customer account', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $b10?></a>
            </b></td>
        </tr>
      </table></td>
  </tr>
   <tr>
  <td><p class="main">
    <label class="std">&nbsp;&nbsp;&nbsp;&nbsp;</label>
    <input name="button" type="button" class="imagebutton" id="button" onclick="MM_goToURL('parent','showAllProducts.php?cat=Tiles and Accessories&amp;productSelect=All&amp;colorSelect=All');return document.MM_returnValue" value="Done" />
  </p>
  </p></td>
  </tr>
</table>
<!--end of tableMain-->
<p>
  <?php
	}
	include("../footer.php");

?>
</p>
</p>
