<?php 

@session_start();


	if($_REQUEST['id'] !=''){

	}else{
		die;
	}
?>

<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" style="background:#fff;">
	<div class="menus">
          <ul style="">
              <?php echo innerAdminMenu()?>
          </ul>
        </div>	
		<?php
        	$sqlN = 'SELECT userCode FROM '.$DB->pre.'users WHERE id="'.$_REQUEST['retailerID'].'"';
			$N = $DB->dbRow($sqlN);
		?>

		<p><?php echo $_REQUEST['frmdate']?> To <?php echo $_REQUEST['todate']?> &nbsp;&nbsp;<span><b style="color: #F03">Usercode :- <?php echo $N['userCode']?></b></span></p>	
        
        <table border="1px" cellpadding="1px" cellspacing="1" width="98%" style="font-size:20px; background-color:#fff;" id="tblData">
        <tr>

            <td>Lottery Date Time</td>
            <td>Print Time</td>
            <td>Claim Time</td>
            <td>Cancel</td>
            <td>Pending Claim</td>
            <td>Tran. No.</td>
            <td>Point</td>
            <td>Win</td>
            
        </tr>
        <?php
			
			$dateClause = '(lotdate between "'.$_REQUEST['frmdate'].'" AND "'.$_REQUEST['todate'].'")';
        
			$sql = 'SELECT * FROM '.$DB->pre.'lottary WHERE uID="'.$_REQUEST['retailerID'].'" AND '.$dateClause.' group by tranID ORDER BY lotID DESC';
			$D = $DB->dbRows($sql);
			
			foreach($D as $k=>$D){
				$css = '';
				$flag = '';
				$claim = '';
				if($D['status'] == 0){
					$css = 'style="background-color:red"';	
					$flag = 'Cancel';
				}
				?>
                <tr <?php echo $css;?>>

            <td><?php echo date('d-m-Y',strtotime($D['lotdate'])).' '.$D['lotTime'];?></td>
            <td><?php echo $D['printTime'] ?></td>
            <td>
            	<?php
                	$sqlCT = 'SELECT dateAdded,claimAmount FROM '.$DB->pre.'result_win WHERE barcode="'.$D['barcode'].'"';
					$CT = $DB->dbRow($sqlCT);
					if($CT['dateAdded'] !=''){
						echo date('d-m-Y h:i:s',strtotime($CT['dateAdded']));
					}
				?>
            </td>
            <td><?php echo $flag;?></td>
            <td>
            	<?php
                	$sqlW = 'SELECT R.lotID FROM '.$DB->pre.'result_tran as R
					LEFT JOIN '.$DB->pre.'lottary as L on R.cellID=L.cellID AND R.sernum=L.sernum AND R.lotnum=L.lotnum AND R.lotdate=L.lotdate
					WHERE R.lotdate="'.date('Y-m-d').'" AND R.uID="'.$_REQUEST['id'].'" AND L.uID="'.$_REQUEST['retailerID'].' AND L.barcode="'.$D['barcode'].'"';
					$L = $DB->dbRow($sqW);
					if($L['lotID'] !=''){
						$sqlR = 'SELECT barcode FROM '.$DB->pre.'result_win WHERE barcode="'.$D['barcode'].'"';
						$R = $DB->dbRow($sqlR);
						if($R['barcode'] == '' ){
							$claim = 'Pending';
						}
					}
					echo $claim;

				?>
            </td>
            <td><a href="<?php echo SITEURL?>/user-sell-ticket/?tranID=<?php echo $D['tranID']?>&u=<?php echo $_REQUEST['u']?>&id=<?php echo $_REQUEST['id']?>"><?php echo $D['tranID']?></td>
            <td><?php echo $D['ticketTot']?></td>
            <td><?php echo $CT['claimAmount']?></td>

            
        </tr>
                <?php
			}
			
		
		?>
        </table>
			

	</div>

</body>
</html>
<script>
  document.getElementById('tblData').focus();
document.onkeydown = getBackBtn;
function getBackBtn(){

	var key = event.which || event.keyCode || event.charCode; 
	//alert(key+"-----"+'<?php echo SITEURL?>/live-betting/?u=<?php echo $_REQUEST['u']?>&flag=1&id=<?php echo $_REQUEST['id']?>');
	
	if(key == 8){
		//location.href = '<?php echo SITEURL?>/live-betting/?u=<?php echo $_REQUEST['u']?>&flag=1&id=<?php echo $_REQUEST['id']?>'
      window.history.go(-1);
	}
}
</script>
