<style>
  .pwbtn{
    width:50px;
	cursor:pointer;
  }
  .sortbtn{
    width:90px;
	cursor:pointer;
  }
  .tblfont{
    font-size:25px;
	margin: 0px 5px 0px 5px;
  }
  .infomsg{
    color:#0000FF; 
	font-size:18px;
  }
  .errmsg{
    color:#FF0000; 
	font-size:18px;
  }	
  .tblsort{
    font-size:29px;
	text-align:center;
	width: 80px;
  }
</style>

<script>
  var loadImage = function(event){
	  var myphoto = document.getElementById('myphoto');
	  myphoto.src = URL.createObjectURL(event.target.files[0]);
	  myphoto.onload = function(){
		  URL.revokeObjecjtURL(myphoto.src)
	  }
  };
  
  function saveSubmit(){
    document.getElementById("frmAdd").submit();
  }
</script>

<?php
  $myprod = new PRODUCT();
  $arrProd = $myprod->getProducts(" ORDER BY tb_order ");
?>
<?php
if( !empty($_SESSION["infomsg"])){
  echo "<span class='infomsg'>" . $_SESSION["infomsg"] . "</span>";
  unset($_SESSION["infomsg"]);
}
?>
<?php
if( !empty($_SESSION["errmsg"])){
  echo "<span class='errmsg'>" . $_SESSION["errmsg"] . "</span>";
  unset($_SESSION["errmsg"]);
}
?>
<form action="pg_productsort_up.php" id="myform" method="post">
<table border="1" style="border-collapse:collapse">

  <tr>
    <td colspan="5" align="right" style="font-weight:bold;"></td>
	<td align="center"><img src="img/ico_update.png" class="sortbtn" onclick="sortSubmit()"></td>
  </tr>

  <tr>
    <td style="background-color:#000000" colspan="6"></td>
  </tr>
<?
foreach($arrProd as $tid=>$tprod){
  $txtorder = "txtorder[$tid]";
  ?>
  <tr>
	<td><span class="tblfont"><img style="height:32px;" src="../img/<?= $tprod["photo"] ?>" /></span></td>
    <td><span class="tblfont"><?= $tprod["name"] ?></span></td>
	<td><span class="tblfont"><?= $tprod["ename"] ?></span></td>
	<td><span class="tblfont"><?= $myprod->getRinggit($tprod["price"]) ?></span></td>
	<td align="center"><span class="tblfont"><?= $tprod["stock"] ?></span></td>
	<td width="80px" align="center"><input type="text" name="<?= $txtorder ?>" class="tblsort" value="<?= $tprod["tb_order"] ?>" /></td>
  </tr>
  <?
}
?>
</table>
</form>

<script>
  function sortSubmit(){
  document.getElementById("myform").submit();
  }
</script>