<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" />
<style type="text/css">
<!--
.style1 {color: #EFB410}
.style2 {color: #004684}
.style3 {	font-size: 10px;
	font-style: italic;
}
-->
</style>
<div align="center">
<? if ($_GET['stat'] == '' ) { ?>
  <table width="80%" border="0">
    <tr>
      <td class="td1"><div align="center">VIP Name</div></td>
      <td width="30%" class="td1"><div align="center">Select Name First</div></td>
    </tr>
    <?	
                        $result = mysql_query('select * from p1_vip'); 
                        while($row = mysql_fetch_array($result)){ 
                ?>
    <tr>
      <td class="td2"><div align="center"><? echo $row['vip_name']?></div></td>
      <td class="td_print1"><div align="center"><a href="index.php?page=20&stat=SaveSession&tid=<? echo $row['tid'] ?>&vip_name=<? echo $row['vip_name'] ?>" class="link">Select</a></div></td>
    </tr>
    <?
          }
    ?>
  </table>
<? } if ($_GET['stat'] == 'show' ) { ?>
<table width="60%" border="0">
    <tr>
      <td class="td1"><div align="center">VIP</div></td>
      <td class="td2"><div align="center"><? echo $_SESSION['20_vip_name'] ?>&nbsp;</div></td>
      <td class="td2"><a href="index.php?page=20&stat=add" class="link">Add New Case</a></td>
    </tr>
  </table>
  <br />
  <table width="95%" border="0">
    <tr>
      <td width="5%" class="td1">#</td>
      <td class="td1">Number of Plate</td>
      <td class="td1">Date</td>
      <td class="td1">Add Plate</td>
      <td class="td1">Print Receipt No.</td>
      <td class="td1">Delivered</td>
    </tr>
    <?	
                        $result = mysql_query('select * from p1_vip_order where status = 0 and tid ='.$_SESSION['20_tid']); 
                        while($row = mysql_fetch_array($result)){ 
                ?>
    <tr>
      <td class="td2"><? echo $row['vid']?></td>
      <td class="td2"><? 
	  						$vid = $row['vid'];
	  						$query = mysql_query("select * from p1_order_info where vid = '$vid'");
							echo mysql_num_rows($query);
	  
	  
	  ?></td>
      <td class="td2"><? echo $row['vip_date']?></td>
      <td class="td2"><a href="index.php?page=20&stat=selectplate&id=<? echo $row['vid']?>" class="link">Add Plate</a></td>
      <td class="td2"><a href="index.php?page=20&stat=print&id=<? echo $row['vid']?>" target="_blank" class="link">Print</a></td>
      <td class="td2"><a href="index.php?page=20&stat=deleverd&vid=<? echo $row['vid']?>" class="link">Delivered</a></td>
    </tr>
    <?
          }
    ?>
  </table>
  <p>
    <? } if ($_GET['stat'] == 'add' ) { ?>
 </p>
  <form action="index.php?page=20&stat=add1" method="post" enctype="multipart/form-data" name="form1" id="form1">
    <input name="Submit" type="submit" class="Submit" id="Submit" value="   Press to add   " />
  </form>
  <p>   
  	<? } if ($_GET['stat'] == 'selectplate' ) { 
	
		$_SESSION['20_vid']  = $_GET['id'];
	
	
	?>
    
    <table width="95%" border="0">
        	
		<?
		
				$row_control = 0;
            $result = mysql_query('SELECT *  FROM p1_plate_type',$db); 
            while($row = mysql_fetch_array($result)){ 
			
				$row_control = $row_control +1;
				$row_id = $row_control %3 ;
				
					if ($row_id  == 1 ) 
						{
							?>
       							  <tr>
                                        <td><div align="center">
                                          <table width="100%" border="0">
                                            <tr>
                                              <td><div align="center"><a href="index.php?page=20&stat=addplate&id=<? echo $row['tyid']; ?>"><img src="images/<? echo $row['tyid']; ?>.jpg" width="200" height="103" border="0" /></a></div></td>
                                            </tr>
                                            <tr>
                                              <td><div align="center"><a href="index.php?page=20&stat=addplate&id=<? echo $row['tyid']; ?>" class="link"><? echo $row['plate_type']; ?></a></div></td>
                                            </tr>
                                          </table>
                                        </div></td>
                                        <td width="30">&nbsp;</td>
                            <?
						}
							
					if ($row_id  == 2 ) 
						{
							?>
                                        <td><div align="center">
                                          <table width="100%" border="0">
                                            <tr>
                                              <td><div align="center"><a href="index.php?page=20&stat=addplate&id=<? echo $row['tyid']; ?>"><img src="images/<? echo $row['tyid']; ?>.jpg" width="200" height="103" border="0" /></a></div></td>
                                            </tr>
                                            <tr>
                                              <td><div align="center"><a href="index.php?page=20&stat=addplate&id=<? echo $row['tyid']; ?>" class="link"><? echo $row['plate_type']; ?></a></div></td>
                                            </tr>
                                          </table>
                                        </div></td>
                                        <td width="30">&nbsp;</td>
                            <?
						}
	   
					if ($row_id  == 0 ) 
						{
							?>

                                        <td><div align="center">
                                          <table width="100%" border="0">
                                            <tr>
                                              <td><div align="center"><a href="index.php?page=20&stat=addplate&id=<? echo $row['tyid']; ?>"><img src="images/<? echo $row['tyid']; ?>.jpg" width="200" height="103" border="0" /></a></div></td>
                                            </tr>
                                            <tr>
                                              <td><div align="center"><a href="index.php?page=20&stat=addplate&id=<? echo $row['tyid']; ?>" class="link"><? echo $row['plate_type']; ?></a></div></td>
                                            </tr>
                                          </table>
                                        </div></td>
                                        <td width="30">&nbsp;</td>
                                   </tr>
                                  <tr>
                                    <td height="5" colspan="5"></td>
                                  </tr>
                            <?
						}
	   
	   
	   
			}
		
		?>
          
          
		</table>
    
    
    
  
	<p>
	  <? } if ($_GET['stat'] == 'addplate' ) { ?>
  <form id="form2" name="form2" method="post" action="index.php?page=20&stat=addvip">
    <p><a href="index.php?page=20&stat=show" class="link">Back</a></p>
    <table width="80%" border="0" align="center">
      <tr>
        <td colspan="4" class="td5">Plate Information</td>
      </tr>
      <tr>
        <td width="20%" class="td1"><div align="center">Plate No.</div></td>
        <td width="30%" class="td2"><span id="sprytextfield1">
        <input name="Plate" type="text" id="Plate" maxlength="6" />
        <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">*</span></span></td>
        <td width="20%" class="td1">Traf .Rcpt No.</td>
        <td class="td2"><span id="sprytextfield2">
          <input type="text" name="traf_recpt" id="traf_recpt" />
        <span class="textfieldRequiredMsg">*</span></span></td>
      </tr>
      <tr>
        <td class="td1"><div align="center">Long</div></td>
        <td class="td2"><span id="spryselect1">
          <select name="Size1" class="select_box" id="Size1">
            <option>Select --&gt;</option>
            <option value="0">0</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
          </select>
        <span class="selectRequiredMsg">*</span></span></td>
        <td class="td1">Short</td>
        <td class="td2"><span id="spryselect2">
          <select name="Size2" class="select_box" id="Size2">
            <option>Select --&gt;</option>
            <option value="0">0</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
          </select>
        <span class="selectRequiredMsg">*</span></span></td>
      </tr>
      <tr>
        <td class="td1">Type</td>
        <td class="td2"><?	
                        $result1 = mysql_query('select * from p1_plate_type where tyid = '.$_GET['id']); 
                        while($row1 = mysql_fetch_array($result1)){ 
                				echo $row1['plate_type'] ;
            
					}
				?></td>
        <td class="td1">&nbsp;</td>
        <td class="td2">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="4" class="td5">Customer Information</td>
      </tr>
      <tr>
        <td class="td1">Month Register</td>
        <td class="td2"><select name="month_register" class="select_box" id="month_register">
            <option value="0">0</option>
            <? for ($i=1;$i<13;$i++) { ?>
            <option value="<? echo $i ?>"><? echo $i ?></option>
            <? } ?>
        </select></td>
        <td class="td1">Car Type</td>
        <td class="td2"><input type="text" name="car_type" id="car_type" /></td>
      </tr>
      <tr>
        <td class="td1">Car Model</td>
        <td class="td2"><input type="text" name="car_model" id="car_model" /></td>
        <td class="td1">+ 1 BD</td>
        <td class="td2"><input name="BD1" type="checkbox" id="BD1" value="1" /></td>
      </tr>
    </table>
    <p>
      <input name="Submit" type="submit" class="Submit" id="Submit" value="    Add    " />
      <input name="vid" type="hidden" id="vid" value="<? echo $_SESSION['20_vid']?>" />
      <input name="tyid" type="hidden" id="tyid" value="<? echo $_GET['id'] ?>" />
    </p>
  </form>
  <p></p>
    <? } if ($_GET['stat'] == 'print' ) { 
		  						$vid = $_GET['id'];
	  					
							

	
	
	
	
	
	
	// Create invoice
						//Invoice No.
				/*			$Inv_year  = $year -2000;
							if ($month < 10 ) {
								$Inv_month = '0'.$month;
							}else{
								$Inv_month = $month;
							}
							if ($serial < 10 ) {
								$Inv_serial = '0000'.$serial;
							}elseif ($serial < 100 ) {
								$Inv_serial = '000'.$serial;
							}elseif ($serial < 1000 ) {
								$Inv_serial = '00'.$serial;
							}elseif ($serial < 10000 ) {
								$Inv_serial = '0'.$serial;
							}elseif ($serial < 100000 ) {
								$Inv_serial = $serial;
							}
							$_SESSION['Inv_no'] = $Inv_year.$Inv_month.'NV'.$Inv_serial;*/
							
					// Date , Time 
						$date_add   = date("Y").'-'.date("m").'-'.date("d");
						$time_add	= date("H").':'.date("i");

							$_SESSION['Inv_Date']   		   = $date_add ;
							$_SESSION['Inv_Time']  			   = $time_add ;
							
	
	
	?>
<p><br />
  <br />
  <br />
  <br />
</p>

    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><div align="center"><strong>RECEIPT</strong></div></td>
      </tr>
      <tr>
        <td><table width="95%" border="0" align="right">
            <tr>
              <td colspan="4"></td>
              <td width="15%" class="td_print3"><div align="left"><strong>&nbsp;Receipt No.</strong></div></td>
              <td class="td_print4"><?
              $query1 = mysql_query("select year(vip_date)-2000 year_add,month(vip_date) month_add from p1_vip_order where vid = '$vid'");
			  
			 $year_add   = mysql_result($query1,0,"year_add");
			 $month_add   = mysql_result($query1,0,"month_add");
			 if ($month_add < 10 ) 
			 {
			 	$month_add = "0".$month_add;
			}
			  
			  ?><img src="image.php?code=code39&o=1&t=30&r=1&text=<? echo $year_add?><? echo $month_add?>VV<? 
						$serial = $vid;
						  if ($serial < 10 ) {
								$Inv_serial = '00000'.$serial;
							}elseif ($serial < 100 ) {
								$Inv_serial = '0000'.$serial;
							}elseif ($serial < 1000 ) {
								$Inv_serial = '000'.$serial;
							}elseif ($serial < 100000 ) {
								$Inv_serial = '00'.$serial;
							}elseif ($serial < 100000 ) {
								$Inv_serial = '0'.$serial;
							}
			  
			  echo $Inv_serial?>&f=3&a1=&a2=" width="169" height="43" /></td>
            </tr>
            
            <tr>
              <td class="td_print3"><div align="center"><strong>Date</strong></div></td>
              <td class="td_print4"><div align="center"><? echo $_SESSION['Inv_Date'] ?></div></td>
              <td class="td_print3"><div align="center"><strong>Time :</strong></div></td>
              <td class="td_print4"><div align="center"><? echo $_SESSION['Inv_Time'] ?></div></td>
              <td class="td_print3"><div align="left"><strong>&nbsp;Cashier</strong></div></td>
              <td class="td_print4">&nbsp;<? echo $_SESSION['P1_Login_name'] ?></td>
            </tr>
            <tr>
              <td class="td_print3"><div align="center"><strong>VIP Name</strong></div></td>
              <td colspan="5" class="td_print4"><div align="center"><? echo $_SESSION['20_vip_name']?>&nbsp;</div>                <div align="left"></div>                
                <div align="center"></div></td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><table width="90%" border="0" align="right" bordercolor="#000000">
            <tr>
              <td class="td_print4">#</td>
              <td class="td_print4"><div align="center"><strong>Plate No.</strong></div></td>
              <td class="td_print4">Type</td>
              <td class="td_print4"><div align="center"><strong>Descripition</strong></div></td>
              <td class="td_print4"><strong>Quantity</strong></td>
              <td class="td_print4"><div align="center"><strong>Unit Price</strong></div></td>
              <td class="td_print4">Sub total</td>
              <td class="td_print4"><div align="center">Fixing new / screws</div></td>
              <td class="td_print4"><div align="right"><strong>Amount</strong></div></td>
            </tr>
            <tr class="td_print4">
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>            <? 
	  						$query = mysql_query("select * from p1_order_info where vid = '$vid'");
							$i=0;
							$sub_total = 0;
							$total = 0;
							$bd1 = 0;
						  while($row = mysql_fetch_array($query)){ 
	  							$i=$i+1;
								
								$tyid = $row['Type1'];
								$query_tyid = mysql_query("select * from p1_plate_type where tyid = $tyid"); 		
								$plate_type  = mysql_result($query_tyid,0,"plate_type");
								$plate_price = mysql_result($query_tyid,0,"plate_price");
								
								
								
	 		 ?>
            <tr>
              <td class="td_print4"><? echo $i ?></td>
              <td class="td_print4"><? echo $row['Plate'];?></td>
              <td class="td_print4"><? echo $plate_type?></td>
              <td class="td_print4">Long(<? echo $row['Size1'];?>) , Short(<? echo $row['Size2'];?>)</td>
              <td class="td_print4"><? echo $row['Size1']+$row['Size2'];?></td>
              <td class="td_print4"><? echo $plate_price ?></td>
              <td class="td_print4"><? echo ($row['Size1']+$row['Size2'])*$plate_price;?>*</td>
              <td class="td_print4"><? echo $row['BD1'];?></td>
              <td class="td_print4"><div align="right"><? echo ($row['Size1']+$row['Size2'])*$plate_price+$row['BD1'];?></div></td>
            </tr>
            <? if ($i % 6 == 0 ) { 
			for ($spa = 1; $spa < 28; $spa++ ){
			?>
            <tr>
              <td class="td_print4">&nbsp;</td>
              <td class="td_print4">&nbsp;</td>
              <td class="td_print4">&nbsp;</td>
              <td class="td_print4">&nbsp;</td>
              <td class="td_print4">&nbsp;</td>
              <td class="td_print4">&nbsp;</td>
              <td class="td_print4">&nbsp;</td>
              <td class="td_print4">&nbsp;</td>
              <td class="td_print2"><div align="right"></div></td>
            </tr>            
            <? } ?>
         <?	}	?>
           <?
		   
		   				$bd1 = $bd1 + $row['BD1'];
		   				$sub_total = $sub_total + ($row['Size1']+$row['Size2'])*$plate_price;
						$total = $total +($row['Size1']+$row['Size2'])*$plate_price+$row['BD1'];
		   
		   				}
						
			?>
            <tr>
              <td class="td_print4"><div align="center"><strong>Total </strong></div></td>
              <td class="td_print4">&nbsp;</td>
              <td class="td_print4">&nbsp;</td>
              <td class="td_print4">&nbsp;</td>
              <td class="td_print4">&nbsp;</td>
              <td class="td_print4">&nbsp;</td>
              <td class="td_print4">&nbsp;<? echo $sub_total ?>*</td>
              <td class="td_print4">&nbsp;<? echo $bd1?></td>
              <td class="td_print4"><div align="right"><strong><? echo $total ?></strong></div></td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td><div align="left"></div></td>
      </tr>
    </table>
  <p>&nbsp;</p>

            <? } ?>
        </p>
</div>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "integer", {useCharacterMasking:true});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1");
var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2");
//-->
</script>
