<?php include('../../connectdb.inc.php'); ?>
<!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" href="<?php echo SITEURL?>/css/net/accountIE7IE8.css">
<![endif]-->

<!--[if IE 8]>
<link rel="stylesheet" href="<?php echo SITEURL?>/css/net/accountIE7IE8.css">
<![endif]-->

<?php
	preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches);
	if(count($matches)<2){
	  preg_match('/Trident\/\d{1,2}.\d{1,2}; rv:([0-9]*)/', $_SERVER['HTTP_USER_AGENT'],$matches);
	}
	if($matches[1] > 8){
	?>
    <link rel="stylesheet" href="<?php echo SITEURL?>/css/net/accountIE10.css">
    <?php
	}
?>



<style>
	


	.userPrint1{width:250px; border: 0px solid black;}
	.userPrint2{font-weight: 600; padding-left: 0px; list-style-type:none;}
	.userPrint3{width:100%;font-weight: lighter; margin-left:0px; border:0px solid red;}
	.userPrint3_0{padding-left: 0.2rem; padding-right:0.2rem;}
	.userPrint4{width:100%;font-weight: lighter; padding-left: 0px; margin-left:0px; border:0px solid red;}
	.userPrint4_0{width:30%; display:inline-block;}
	.accounttbl{width:100%; font-weight:600;}


@media print {
  body {
		height: auto;
		width:100% ;
		font-size:12px;
		letter-spacing:1px;
		line-height:13px;
		margin-top:-8%;
		margin-left:0 !important;
	}
	.container .a-form{
		width:180px !important;
	}
	.bx1_only_print{
		line-height:12px;
		width:40px !important;
	}
	.name{
		margin-bottom:0%;
	}
	.tick01{
		display:inline-flex;
	}
	.tick01 .bx1_only_print{
		width:65px !important;
	}
	.tick01 .bx2_only_print{
		width:30px !important;
	}
	
}
</style>

</head>

<body style="">
	<div class="container">
		<?php
		$DB->data = array();
        	$sqlW = 'SELECT commission,bonus,userCode FROM '.$DB->pre.'users WHERE id="'.$_REQUEST['userID'].'"';
			$W = $DB->dbRow($sqlW);
		?>
        <?php date_default_timezone_set('Asia/Kolkata');?>

		<div class="row">
			<div class="a-form userPrint1">
				<ul class="tick_li userPrint2">
					<li><img src="<?php echo SITEURL?>/images/logo.png"> SHREE ONLINE </li>
					<li>USER REPORTS</li>
					<li>Sales Reports</li>
					<li>User ID : <?php echo $W['userCode']?></li>
					<li>Date From: <?php echo date('d-m-Y',strtotime($_REQUEST['frmdate']))?></li>
					<li>Date To: <?php echo date('d-m-Y',strtotime($_REQUEST['todate']))?></li>
					<li>Dr. <?php echo date('d-m-Y h:i:s')?> </li>
				</ul>
                <hr/>
				<div class="ticket_only_1 userPrint3">
					<table class="accounttbl">
					<tr class="tick_only_print_menu0">
						<th class="userPrint3_0">Date </th>
						<th class="userPrint3_0">Play</th>
						<th class="userPrint3_0">Win </th>                       
					</tr>
				</div>

				<div class="row" style="border: 0px solid black;">
               <?php
               	$where = ' (lotdate between "'.$_REQUEST['frmdate'].'" AND "'.$_REQUEST['todate'].'")';	
               	$DB->data = array();
				$sql = 'SELECT lotdate FROM '.$DB->pre.'lottary WHERE '.$where .' AND uID="'.$_REQUEST['userID'].'" GROUP BY lotdate' ;
						$D = $DB->dbRows($sql);
						
						$tot = 0;
						$cancel = 0;
						$win = 0;
						$comm = 0;
						$tempComm = 0;
						$netPay = 0;
						$bonus = 0;
						$tempBonus = 0;
						$tempNetAmt = 0;
						$tempNetPay = 0;
			   ?>
					<div class="ticket_2 userPrint4">
                    <?php 
						foreach($D as $k=>$D){
							$tot += getSumByDate3($D['lotdate']);
							$cancel += getCancelByDate3($D['lotdate']);
							$win += getWinByDate3($D['lotdate']);
							$comm = (($tot/100)*$W['commission']);
							$tempComm += $comm;
							$netAmtPay = ($tot-($win+$comm));
							$bonus = (($netAmtPay/100)*$W['bonus']);
							
							$tempBonus += $bonus;
							$tempNetAmt += $netAmtPay;
							$tempNetPay += ($netAmtPay-$bonus);
							
							
					?>
                    	<tr>

                            <td class="userPrint3_0"><a href="<?php echo SITEURL?>/lottery/lottery-account-date/?d=<?php echo $D['lotdate'];?>&userID=<?php echo $_REQUEST['userID']?>" style="text-decoration:none;"><?php echo date('d-m-Y',strtotime($D['lotdate']))?></a></td>
                            <td class="userPrint3_0"><?php echo getSumByDate3($D['lotdate']);?></td>
                            <td class="userPrint3_0"><?php echo getWinByDate3($D['lotdate']);?></td>
                           
                        </tr>
                        <?php } ?>
                    </tbody>
                    <tfoot>
                    	<tr style="">
                            <th class="userPrint3_0">Total</th>
                            <td class="userPrint3_0"><?php echo $tot?></td>
                            <td class="userPrint3_0"><?php echo $win?></td>
                            
                        </tr>
                    </tfoot>
                          </table>      
					</div>

					
					
				</div>

 
			</div>
				
			
		</div>

	</div>

</body>
</html>
<?php
function getSumByDate3($lotdate){
	global $DB;
	$DB->data = array();
	$sql = 'SELECT ticketTot as S FROM '.$DB->pre.'lottary WHERE status="1" AND lotdate="'.$lotdate.'" AND uID="'.$_REQUEST['userID'].'" group by tranID';
	$D = $DB->dbRows($sql);
	$tot = 0;
	foreach($D as $D){
		$tot += $D['S'];
	}
	return $tot;
}
function getCancelByDate3($lotdate){
	global $DB;
	$DB->data = array();
	$sql = 'SELECT ticketTot as S FROM '.$DB->pre.'lottary WHERE lotdate="'.$lotdate.'" AND uID="'.$_REQUEST['userID'].'" AND status="0" group by tranID';
	$D = $DB->dbRows($sql);
	$tot = 0;
	foreach($D as $D){
		$tot += $D['S'];
	}
	
	return $tot;
	
}
function getWinByDate3($lotdate){
	global $DB;
	$DB->data = array();
	$sql = 'SELECT claimAmount as S FROM '.$DB->pre.'result_win WHERE date(dateAdded)="'.$lotdate.'" AND uID="'.$_REQUEST['userID'].'"  group by barcode';
	$D = $DB->dbRows($sql);
	$tot = 0;
	foreach($D as $D){
		$tot += $D['S'];
	}
	
	return $tot;
}

?>

