<link href="wstyle.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
<link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
<div align="center">
<p>
  <? if ($_GET['stat'] == '' ) { ?>
</p>
<form id="form1" name="form1" method="post" action="index.php?page=59&stat=moreinfo">
  <p class="link">Cash by Agent</p>
  <table width="50%" border="0">
    <tr>
      <td class="td1">From</td>
      <td class="td2"><span id="sprytextfield3">
      <input type="text" name="From" id="From" />
      <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span><span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></td>
    </tr>
    <tr>
      <td class="td1">TO</td>
      <td class="td2"><span id="sprytextfield4">
      <input type="text" name="To" id="To" />
      <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span><span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></td>
    </tr>
    <tr>
      <td class="td1">User</td>
      <td class="td2"><select name="tid" id="tid"><?
                        $result = mysql_query("SELECT * from p1_agent"); 
                        while($row = mysql_fetch_array($result)){ 
      				?>
      		<option value="<? echo $row['tid'];?>"><? echo $row['agent_name'];?></option>
                    <? } ?>
      </select>      </td>
    </tr>
  </table>
  <p>
    <input name="Submit" type="submit" class="Submit" id="Submit" value="    Create    " />
  </p>
</form>
 
<? } if ($_GET['stat'] == 'moreinfo' ) {
			$date_From=$_POST['From'];
			$date_To=$_POST['To'];
			$tid = $_POST['tid'];
			$query = mysql_query("select * from p1_agent where tid = $tid "); 		
			
 ?>
    <span class="link"><? echo mysql_result($query,0,"agent_name");?></span><br />
    <span class="link"><? echo "{ ".$date_From." } - { ".$date_To." }";?></span><br />
    <table width="100%" border="0">
      <tr>
        <td class="td1">ID</td>
        <td class="td1">Date</td>
       
        <td class="td1">Plate No.</td>
        <td class="td1">Type</td>
        <td colspan="2" class="td1">Size</td>
        <td class="td1">urgency</td>
        <td class="td1">price</td>
        <td class="td1">Fixing new / screws</td>
      </tr>
      <?
			
			$result = mysql_query("SELECT p1_order_info.*, p1_agent_order.tid taid  FROM p1_order_info INNER JOIN p1_agent_order ON p1_order_info.aid = p1_agent_order.aid WHERE  p1_order_info.Date_a between '".$date_From."' and '".$date_To."' and p1_order_info.stop1 =0 and p1_agent_order.tid = ".$tid." order by Date_a");

		  $i = 0;
            while($row = mysql_fetch_array($result)){ 
		  $i = $i+1;
        ?>
      <tr <? if( $row['Type2'] == '1') { ?>class="td4" <? }else{ ?> class="td2" <? } ?>>
        <td><? echo $i; ?></td>
        <td><? echo $row['Date_a']; ?></td>
        <td><div align="center"><? echo $row['Plate']; ?></div></td>
        <td><div align="center">
          <div align="center" class="p_c<? echo $row['Type1']?>">
              <?	
                        $result1 = mysql_query('select * from p1_plate_type where tyid = '.$row['Type1']); 
                        while($row1 = mysql_fetch_array($result1)){ 
                				echo $row1['plate_type'] ;
								$plate_price = $row1['plate_price'];
            
					}
				?>
            </div>
        </div></td>
        <td><div align="center"><? echo $row['Size1']; ?></div></td>
        <td><div align="center"><? echo $row['Size2']; ?></div></td>
        <td><? if( $row['Type2'] == '1') { ?>
          Yes
            <? }else{ ?>
          No
          <? } ?></td>
        <td><? echo $plate_price * $row['number_of_plate']?></td>
        <td><? echo $row['BD1']?></td>
      </tr>
      <?
	  
	  $total_price = $total_price +$plate_price* $row['number_of_plate'];
	  $BD1 = $BD1 + $row['BD1'];
			}
		
		?>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td class="td_print1">Total</td>
        <td class="td_print1">&nbsp;<? echo $total_price ?></td>
        <td class="td_print1">&nbsp;<? echo  $BD1 ?></td>
      </tr>
    </table>
      <? } ?>
    
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</div>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "date", {format:"yyyy-mm-dd", useCharacterMasking:true});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "date", {format:"yyyy-mm-dd", useCharacterMasking:true});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "date", {useCharacterMasking:true, format:"yyyy-mm-dd"});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "date", {useCharacterMasking:true, format:"yyyy-mm-dd"});
//-->
</script>
