<?php
include("../include/session.php");
if(!$session->isAdmin()){
	header("Location: ../Store/denied2.php");
}else{
	include("../storeHeader.php");
	
	$repId = mysql_real_escape_string($_GET['repId']);
	$edit = $_GET['edit'];
	
	if ($edit=="1") {
		$field = $_GET['field'];
		$editText = $_GET['editText'];
		
		$editQuery = "UPDATE rad_representatives SET $field = '".  $editText ."' WHERE repId = '$repId' ";
        $editResult = mySQL_query($editQuery);
	}
   
	
		
	$repQuery = "SELECT * FROM rad_representatives WHERE repId ='". $repId. "' ";
	$repResult = execsql($repQuery);
	$a1 = mysql_result($repResult, 0, "account");
	$a2 = mysql_result($repResult, 0, "last_name");
	$a3 = mysql_result($repResult, 0, "first_name");
	$a4 = mysql_result($repResult, 0, "designation");
	$a5 = mysql_result($repResult, 0, "cell");
	$a6 = mysql_result($repResult, 0, "id_number");
	$a7 = mysql_result($repResult, 0, "notes");
	
	$w=1;
	while ($w < 8) {
	$a = 'a';	
	   if (${$a.$w} == '') { ${$a.$w}="?"; }
	   $w++;
	}
	
	?>
<script type="text/javascript">
function checkifempty(){
if (document.form2.account_no_text.value==''){
document.getElementById("add_button").disabled=true
}
else {
document.getElementById("add_button").disabled=false	
}
}
if (document.all || document.getElementById)
setInterval("checkifempty()",100)
</script>
<script type="text/javascript" src="../css/tablesort.js"></script>

<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"> Tocotex Representative</div>
      <p class="edit">
    <label class="std"><font size="3"><b><?php echo $a3 ." ".$a2 ?></b></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Click on the line you want to edit.</label></p></td>
    <!--center of tableMain-->
  </tr>
  <tr>
    <td><!--center of tableMain-->
      <table width="600" id="tablePlain">
        <tr>
          <td width="113">rep no:</td>
          <td width="159"><b>
		  <?php echo $repId ?></b></td>
          <td colspan="2"></b></td>
        </tr>
        <tr>
          <td>last name:</td>
          <td><b>
		  <a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editRepLine.php?repId=<?php echo $repId?>&field=<?php echo 'last_name' ?>&Type=T ', 'Edit Representative', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a2 ?></a></b></td>
          <td>first name</td>
          <td>
		  <a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editRepLine.php?repId=<?php echo $repId?>&field=<?php echo 'first_name' ?>&Type=T ', 'Edit Representative', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a3 ?></a></td>
        </tr>
        <tr>
          <td>company:</td>
          <td><a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editRepLine.php?repId=<?php echo $repId?>&field=<?php echo 'account' ?>&Type=D ', 'Edit Representative', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a1 ?></a></td>
          <td width="129">&nbsp;</td>
          <td width="179">&nbsp;</td>
        </tr>
        <tr>
          <td>designation</td>
          <td><b>
		  <a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editRepLine.php?repId=<?php echo $repId?>&field=<?php echo 'designation' ?>&Type=T ', 'Edit Representative', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a4 ?></a></b></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>cell</td>
          <td><b>
		  <a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editRepLine.php?repId=<?php echo $repId?>&field=<?php echo 'cell' ?>&Type=N ', 'Edit Representative', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a5 ?></a></b></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>id number</td>
          <td colspan="3"><b>
		  <a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editRepLine.php?repId=<?php echo $repId?>&field=<?php echo 'id_number' ?>&Type=T ', 'Edit Representative', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a6 ?></a></b></td>
        </tr>
        <tr>
          <td>notes:</td>
          <td colspan="3"><b>
		  <a href="" onClick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editRepLine.php?repId=<?php echo $repId?>&field=<?php echo 'notes' ?>&Type=T ', 'Edit Representative', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a7 ?></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-->
<?php

	include("../footer.php");
}
?>
