<?php
@session_start();
if($_SESSION['SECEXP'] !=''){

	}else{
		echo "Go And Fuck Your Self";die;
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=11" >
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="<?php echo SITEURL?>/css/ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="<?php echo SITEURL?>/css/ie7.css">
<![endif]-->
<link rel="stylesheet" type="text/css" href="<?php echo SITEURL?>/css/ie7.css">
</head>

<body>
	<div class="container">
		<div class="menus">
          <ul style="">
              <?php echo innerAdminMenu()?>
          </ul>
        </div>

		<div class="row">
			<div class="a-form" style="width: 250px; padding:10px; float: left; background-color: #6F9;">
            	<form id="frmBarcode" name="frmBarcode" method="GET" action="<?php echo SITEURL?>/barcode">
                	<div class="container">
                    	<table>
                        	<tr>
                            	<td>TRN Number</td>
                                <td><input id="trnno" name="trnno" type="text"></td>
                            </tr>
                            <tr>
                            	<td>Barcode No.</td>
                                <td><input id="barcodeno" name="barcodeno" type="text"></td>
                            </tr>
                            <tr>
                            	<td>User Id</td>
                                <td>
									
									<select id="userid" name="userid" require>
										<option value="">-Select Users-</option>
										<?php
											$sql = 'SELECT id,userCode FROM '.$DB->pre.'users WHERE status="1" AND isActive="1"';
											$D = $DB->dbRows($sql);
											foreach($D as $D){
												?>
												<option value="<?php echo $D['id']?>"><?php echo $D['userCode']?></option>
												<?php

											}
										?>	
								</select>
							</td>
                            </tr>
                            
                            <tr>
                            	<td>Time : </td>
                                <td>
									
									<select id="tme" name="tme" require>
										<option value="">-Select Time-</option>
										<option value="10:00">10:00</option>
										<option value="10:15">10:15</option>
										<option value="10:30">10:30</option>
										<option value="10:45">10:45</option>
										<option value="11:00">11:00</option>
										<option value="11:15">11:15</option>
										<option value="11:30">11:30</option>
										<option value="11:45">11:45</option>
										<option value="12:00">12:00</option>
										<option value="12:15">12:15</option>
										<option value="12:30">12:30</option>
										<option value="12:45">12:45</option>
										<option value="01:00">01:00</option>
										<option value="01:15">01:15</option>
										<option value="01:30">01:30</option>
										<option value="01:45">01:45</option>
										<option value="02:00">02:00</option>
										<option value="02:15">02:15</option>
										<option value="02:30">02:30</option>
										<option value="02:45">02:45</option>
										<option value="03:00">03:00</option>
										<option value="03:15">03:15</option>
										<option value="03:30">03:30</option>
										<option value="03:45">03:45</option>
										<option value="04:00">04:00</option>
										<option value="04:15">04:15</option>
										<option value="04:30">04:30</option>
										<option value="04:45">04:45</option>
										<option value="05:00">05:00</option>
										<option value="05:15">05:15</option>
										<option value="05:30">05:30</option>
										<option value="05:45">05:45</option>
										<option value="06:00">06:00</option>
										<option value="06:15">06:15</option>
										<option value="06:30">06:30</option>
										<option value="06:45">06:45</option>
										<option value="07:00">07:00</option>
										<option value="07:15">07:15</option>
										<option value="07:30">07:30</option>
										<option value="07:45">07:45</option>
										<option value="08:00">08:00</option>
										<option value="08:15">08:15</option>
										<option value="08:30">08:30</option>
										<option value="08:45">08:45</option>
										<option value="09:00">09:00</option>
										<option value="09:15">09:15</option>
										<option value="09:30">09:30</option>
										<option value="09:45">09:45</option>
									</select>
                                <input id="u" name="u" type="hidden" value="<?php echo $_REQUEST['u']?>">
                                <input id="flag" name="flag" type="hidden" value="<?php echo $_REQUEST['flag']?>">
                                <input id="id" name="id" type="hidden" value="<?php echo $_REQUEST['id']?>">
                                
                                </td>
                            </tr>
                            <tr>
                            	<td><button id="search" name="search" type="submit">Search </button></td>
                                <td><button name="reset" type="reset">Reset </button></td>
                            </tr>                            
                        </table>
                    </div>
                </form>
			</div>
            
            <?php
                   
				   
				   if(isset($_REQUEST['search'])){
					global $DB;
					   ?>
                       <div class="a-form" style="width: 1040px; padding:10px; float: right; background-color: #FF6; border:1px solid black;">
            	<table border="1" width="100%" cellspacing="0" cellpadding="0">
                <tr>
                	<th>Type </th>
                    <th>User ID</th>
                    <th>Date </th>
                    <th>Time </th>
                    <th>TRN No </th>
                    <th>Barcode </th>
                    <th>Point </th>
                    <th>Win Amt.</th>
                    </tr>
                       <?php
					   $where = '';
					  // $_REQUEST['frmdate'] = date('Y-m-d');
					if($_REQUEST['trnno']){
						$where .= ' AND tranID="'.$_REQUEST['trno'].'"';
					}
					if($_REQUEST['barcodeno']){
						$where .= ' AND barcode="'.$_REQUEST['barcodeno'].'"';
					}
					if($_REQUEST['userid']){
						
						$where .= ' AND uID="'.$_REQUEST['userid'].'"';

					}
					if($_REQUEST['frmdate']){
							$where .= ' AND lotdate="'.$_REQUEST['frmdate'].'"';
					}
					if($_REQUEST['tme']){
						$where .= ' AND lotTime="'.$_REQUEST['tme'].'"';
					}
					
					$sqlL = 'SELECT * FROM '.$DB->pre.'lottary WHERE status="1" '.$where;
					$L = $DB->dbRows($sqlL);
					if(count($L)>0){
						foreach($L as $L){
							$sqlU = 'SELECT userCode FROM '.$DB->pre.'users WHERE id="'.$L['uID'].'"';
							$U = $DB->dbRow($sqlU);
					
			?>
            
                    
                    <tr>
                    	<td>Ticket</td>
                        <td><?php echo $U['userCode'] ?></td>
                        <td><?php echo $L['lotdate']?></td>
                        <td><?php echo $L['lotTime']?></td>
                        <td><?php echo $L['tranID']?></td>
                        <td><?php echo $L['barcode']?></td>
                        <td><?php echo $L['qtytot']?></td>
                        <td><?php echo getWinAmount($L['barcode'])?></td>
                        
                    </tr>
                    
            </div>
            <?php 
					}
				   }
				   ?>
                   </table>
                   <?php
				   }
				   
				   
				   function getWinAmount($barcode){
					   global $DB;
					   $sql = 'SELECT * FROM '.$DB->pre.'result_win WHERE barcode="'.$L['barcode'].'"';
					   $L = $DB->dbRow($sql);
					   
					   $sqlW = 'SELECT winrate FROM '.$DB->pre.'users WHERE id="'.$L['uID'].'"';
					   $W = $DB->dbRow($sqlW);
					   
					   echo (($L['point']*$W['winrate'])*$L['cv']);
					   
					   
					   
					   
				   }
			?>
				
			
		</div>

	</div>

</body>
</html>
