<link href="wstyle.css" rel="stylesheet" type="text/css" />

<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<div align="center">
<? if ($_GET['stat'] == '' ) { ?>
  <p><a href="index.php?page=11&stat=adduser" class="link">Add New User</a></p>
  <table width="80%" border="0">
    <tr>
      <td class="td1"><div align="center">Full Name</div></td>
      <td class="td1"><div align="center">User Name</div></td>
      <td class="td1"><div align="center">Stop User</div></td>
      <td class="td1"><div align="center">Edit</div></td>
    </tr>
    <?	
                        $result = mysql_query('select * from p1_powers where stop_user = 0'); 
                        while($row = mysql_fetch_array($result)){ 
                ?>
    <tr>
      <td class="td2"><? echo $row['fullname']?></td>
      <td class="td2"><? echo $row['username']?></td>
      <td class="td3"><div align="center"><a href="index.php?page=11&stat=stop&uid=<? echo $row['uid'] ?>" class="td3">Stop</a></div></td>
      <td class="td3"><div align="center"><a href="index.php?page=11&stat=edit&uid=<? echo $row['uid'] ?>" class="td3">Edit</a></div></td>
    </tr>
    <?
          }
    ?>
  </table>
<? } if ($_GET['stat'] == 'adduser' ) { ?>
<form id="form1" name="form1" method="post" action="index.php?page=11&stat=add">
  <table width="100%" border="0">
    <tr>
      <td width="20%" class="td1"><div align="center">Full Name</div></td>
      <td width="30%" class="td2"><div align="center"><span id="sprytextfield1">
        <label>
        <input type="text" name="fullname" id="fullname" />
        </label>
        <span class="textfieldRequiredMsg">*</span></span></div></td>
      <td width="20%" class="td1"><div align="center">User Name</div></td>
      <td class="td2"><div align="center"><span id="sprytextfield2">
        <label>
        <input type="text" name="username" id="username" />
        </label>
        <span class="textfieldRequiredMsg">*</span></span></div></td>
    </tr>
    <tr>
      <td class="td1"><div align="center">Password</div></td>
      <td class="td2"><div align="center"><span id="sprytextfield3">
        <label>
        <input type="password" name="password" id="password" />
        </label>
        <span class="textfieldRequiredMsg">*</span></span></div></td>
      <td class="td1"><div align="center">Appointments</div></td>
      <td class="td2"><div align="center">
        <input name="appointments" type="checkbox" id="appointments" value="1" />
      </div></td>
    </tr>
    <tr>
      <td class="td1"><div align="center">Factory</div></td>
      <td class="td2"><div align="center">
        <label>
        <input name="factory" type="checkbox" id="factory" value="1" />
        </label>
      </div></td>
      <td class="td1"><div align="center">Printed</div></td>
      <td class="td2"><div align="center">
        <label>
        <input name="delivery" type="checkbox" id="delivery" value="1" />
        </label>
      </div></td>
    </tr>
    <tr>
      <td class="td1"><div align="center">Delivery</div></td>
      <td class="td2"><div align="center">
        <label>
        <input name="fixing" type="checkbox" id="fixing" value="1" />
        </label>
      </div></td>
      <td class="td1"><div align="center">Search</div></td>
      <td class="td2"><div align="center">
        <label>
        <input name="search" type="checkbox" id="search" value="1" />
        </label>
      </div></td>
    </tr>
    <tr>
      <td class="td1"><div align="center">Add New Date</div></td>
      <td class="td2"><div align="center">
        <label>
        <input name="add_new_date" type="checkbox" id="add_new_date" value="1" />
        </label>
      </div></td>
      <td class="td1"><div align="center">Control User</div></td>
      <td class="td2"><div align="center">
        <label>
        <input name="control_user" type="checkbox" id="control_user" value="1" />
        </label>
      </div></td>
    </tr>
    <tr>
      <td class="td1">Account &amp; POS Report</td>
      <td class="td2"><div align="center">
        <label>
        <input name="report_os" type="checkbox" id="report_os" value="1" />
        </label>
      </div></td>
      <td class="td1">Manage Sales</td>
      <td class="td2"><input name="manage_sales" type="checkbox" id="manage_sales" value="1" /></td>
    </tr>
  </table>
    <p>
      <input name="Submit" type="submit" class="Submit" id="Submit" value="   Save   " />
    </p>
</form>

<? } if ($_GET['stat'] == 'reenter' ) { ?>

  	<p class="td2">You have anther user have same name</p>
<? } if ($_GET['stat'] == 'edit' ) { 
		$uid = $_GET['uid'];
		$query = mysql_query("SELECT * FROM p1_powers where uid = $uid"); 		

?>

<form id="form1" name="form1" method="post" action="index.php?page=11&stat=update&uid=<? echo $uid;?>">
  <table width="100%" border="0">
    <tr>
      <td width="20%" class="td1"><div align="center">Full Name</div></td>
      <td width="30%" class="td2"><div align="center"><span id="sprytextfield1">
        <label>
        <input type="text" name="fullname" id="fullname" value="<? echo mysql_result($query,0,"fullname"); ?>" />
        </label>
        <span class="textfieldRequiredMsg">*</span></span></div></td>
      <td width="20%" class="td1"><div align="center">User Name</div></td>
      <td class="td2"><div align="center"><span id="sprytextfield2">
        <label>
        <input type="text" name="username" id="username" value="<? echo mysql_result($query,0,"username"); ?>" />
        </label>
        <span class="textfieldRequiredMsg">*</span></span></div></td>
    </tr>
    <tr>
      <td class="td1"><div align="center">Password</div></td>
      <td class="td2"><div align="center"> <input type="password" name="password" id="password" />
        <input name="newpass" type="checkbox" id="newpass" value="1" /><span id="sprytextfield3">
        <label>        </label>
        <span class="textfieldRequiredMsg">*</span></span></div></td>
      <td class="td1"><div align="center">Appointments</div></td>
      <td class="td2"><div align="center">
        <input name="appointments" type="checkbox" id="appointments" value="1" <? if (mysql_result($query,0,"appointments") == 1){ ?>	checked="checked" <? } ?> />
      </div></td>
    </tr>
    <tr>
      <td class="td1"><div align="center">Factory</div></td>
      <td class="td2"><div align="center">
        <label>
        <input name="factory" type="checkbox" id="factory" value="1" <? if (mysql_result($query,0,"factory") == 1){ ?>	checked="checked" <? } ?>  />
        </label>
      </div></td>
      <td class="td1"><div align="center">Delivery</div></td>
      <td class="td2"><div align="center">
        <label>
        <input name="delivery" type="checkbox" id="delivery" value="1" <? if (mysql_result($query,0,"delivery") == 1){ ?>	checked="checked" <? } ?>  />
        </label>
      </div></td>
    </tr>
    <tr>
      <td class="td1"><div align="center">Fixing</div></td>
      <td class="td2"><div align="center">
        <label>
        <input name="fixing" type="checkbox" id="fixing" value="1" <? if (mysql_result($query,0,"fixing") == 1){ ?>	checked="checked" <? } ?>  />
        </label>
      </div></td>
      <td class="td1"><div align="center">Search</div></td>
      <td class="td2"><div align="center">
        <label>
        <input name="search" type="checkbox" id="search" value="1" <? if (mysql_result($query,0,"search") == 1){ ?>	checked="checked" <? } ?>  />
        </label>
      </div></td>
    </tr>
    <tr>
      <td class="td1"><div align="center">Add New Date</div></td>
      <td class="td2"><div align="center">
        <label>
        <input name="add_new_date" type="checkbox" id="add_new_date" value="1" <? if (mysql_result($query,0,"add_new_date") == 1){ ?>	checked="checked" <? } ?>  />
        </label>
      </div></td>
      <td class="td1"><div align="center">Control User</div></td>
      <td class="td2"><div align="center">
        <label>
        <input name="control_user" type="checkbox" id="control_user" value="1"	<? if (mysql_result($query,0,"control_user") == 1){ ?> checked="checked" <? } ?>  />
        </label>
      </div></td>
    </tr>
    <tr>
      <td class="td1">Account &amp; POS Report</td>
      <td class="td2"><div align="center">
        <label>
        <input name="report_os" type="checkbox" id="report_os" value="1" <? if (mysql_result($query,0,"report_os") == 1){ ?>	checked="checked" <? } ?>  />
        </label>
      </div></td>
      <td class="td1">Manage Sales</td>
      <td class="td2"><input name="manage_sales" type="checkbox" id="manage_sales" value="1"	<? if (mysql_result($query,0,"manage_sales") == 1){ ?> checked="checked" <? } ?>  /></td>
    </tr>
  </table>
    <p>
      <input name="Submit" type="submit" class="Submit" id="Submit" value="   update   " />
    </p>
</form>
  	<p>&nbsp;</p>
  <? } ?>  
</div>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
//-->
</script>
