<form name="formXXX" method="post" action="">
<table width="100%" border="0" align="center">
  <tr>
     <td colspan="2" align="center" bgcolor="#EACA00">菜名</td>
   <td width="70" align="center" bgcolor="#EACA00">单价</td>
    </tr>
  
<?php
	  
	$TotalRealTime=0;
	$sql = "SELECT ID,OrderID,ProductID ,UserCode ,ProductName ,UnitPrice,Quantity ,Discount,Tax  FROM [Order Details]";
	if (!empty($_POST['OrderID'])) {  $sql .= " where OrderID=".$_POST['OrderID'];  }  
	elseif (!empty($OrderID)) {  $sql .= " where OrderID=".$OrderID;  }  
$values = $orders->query($sql);
if (is_iterable($values)){
  foreach ($values   as $p){ 
			$p['UserCode']=loadFromMssql($p['UserCode']);
			$p['ProductName']=loadFromMssql($p['ProductName']);

			$Line1++; 
			$TotalRealTime= $TotalRealTime +  number_format($p['5'],2) * number_format($p['6'],0) *(100 - number_format($p['7'],0)) /100  ;
			?>
		           
           <tr>
             <td colspan="3" align="left" bgcolor="#D5E300"><?php echo $p['4']; if ($p['7']<>0) echo " -".$p['7']."%"; ?>
             <input name="OD_ID<?php  echo $Line1; ?>" type="hidden"  value="" size="2"/></td>
           </tr>
           <tr>
           
           <td colspan="2" align="left" bgcolor="#FAFFB5">
           		<?php if ($Line1>20) { echo "请在POS机上编辑数量"; } ?>
<!--           		<input name="Count_<?php  echo $Line1; ?>" type="text" style= "width:35px;" value="<?php echo number_format($p['6'],0); ?>" size="5" 
              onChange="document.formXXX.OD_ID<?php  echo $Line1; ?>.value=<?php echo $p['0']; ?>;document.formXXX.checkbox_<?php  echo $Line1; ?>.checked='checked';">
 -->              
              
              
           		<select name="Count_<?php  echo $Line1; ?>"  onChange="document.formXXX.OD_ID<?php  echo $Line1; ?>.value=<?php echo $p['0']; ?>;document.formXXX.checkbox_<?php  echo $Line1; ?>.checked='checked';"  style="width:50px;">

           		  <?php   for ($i=0; $i<=100; $i++) 
			   	{
				   if (number_format($p['6'],0)==$i) echo ('<option  selected="selected" value="'.$i.'">'.$i.'</option>');
				   else echo ('<option value="'.$i.'">'.$i.'</option>');
				   } ?>
       		  </select>
              
              
           		<input type="button" name="Submit2" value="+" 
                onClick="
                		document.formXXX.Count_<?php  echo $Line1; ?>.value++;
                        document.formXXX.OD_ID<?php  echo $Line1; ?>.value=<?php echo $p['0']; ?>;
                        document.formXXX.checkbox_<?php  echo $Line1; ?>.checked='checked';"
                         style= "width:25px;">
                
                
                
           		<input type="button" name="Submit3" value="-" onClick="document.formXXX.Count_<?php  echo $Line1; ?>.value--;document.formXXX.OD_ID<?php  echo $Line1; ?>.value=<?php echo $p['0']; ?>;document.formXXX.checkbox_<?php  echo $Line1; ?>.checked='checked';" style= "width:25px;">
                
                
                
       		 <input type="submit" name="Submit" value="删"  onClick="document.formXXX.Count_<?php  echo $Line1; ?>.value=0;document.formXXX.OD_ID<?php  echo $Line1; ?>.value=<?php echo $p['0']; ?>;javascript:formXXX.submist();" style= "width:35px;" />
             <input type="submit" name="Submit" value="OK"  style= "width:35px;" /> <label for="select"></label></td>              
           <td align="center" bgcolor="#FAFFB5">
		  		 <?php echo number_format($p['5'],2); ?>
           </td>
    </tr>
	
	 <?php }}
	 
	$sql_TotalRealTime="UPDATE Orders SET SubTotal = ".$TotalRealTime." WHERE OrderID=".$OrderID;
$orders->query($sql_TotalRealTime);
?>
  <tr>
    <td colspan="3" align="center" bgcolor="#65CC00"> <h3><a href="javascript:formAddMenu.submit();">[ 　　加 　　菜 　]</a>　
      　</h3></td>
    </tr>
   <tr>
    <td width="409" align="center" bgcolor="#00BC46">TOTAL:</td>
    <td colspan="2" align="left" bgcolor="#00BC46">　　<?php echo number_format($TotalRealTime,2);?></td>
    </tr>
   <tr>
    <td colspan="3" align="center" bgcolor="#0079BC"><?php 	if (!empty($OrderID))	echo '  <input type="hidden" name="OrderID" id="OrderID" value="'.$OrderID.'"/>';?>
      <input name="input" type="submit" value="更改" style= "width:270px;height:40px;" id="input" /></td>
    </tr>

</table>
 </form> 