<?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 style="background-color:#fff;">
	<div class="container">
		<div class="menus">
          <ul style="">
              <?php echo innerAdminMenu()?>
          </ul>
        </div>
		
		<div class="row">
			<div style="margin-top:5px;">
            <form id="frmReplay" name="frmReplay" method="GET" action="<?php echo SITEURL?>/r-play">
            <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']?>">
            	<table border="1px" width="100%" >
                	
                </table>
                
			</div>
            
            			<table border="1" width="80%">
                        	<!--<tr>
                            	<th>Date</th>
                                <td>
                                <select type="text" name="" id="fromdate" />
                                <option value="">-From Date-</option>
                                <?php
                                	$date = '2021-08-05';
									//for($i='2021-08-05';$i<date('Y-m-d');$i++){
										?>
                                        
                                        <option value=""><?php echo date('d-m-Y',strtotime(date('Y-m-d', strtotime($date. ' + 1 days'))));?></option>
                                        <?php
										//$date = date('Y-m-d', strtotime($date. ' + 1 days'));
									//}
								?>
                                
                                </select>
                                </td>
                            </tr>
                            <tr>
                            	<th>To Date</th>
                                <td>
                                <select type="text" name="" id="tdate" />
                                <option value="">-To Date-</option>
                                <?php
                                	$date = '2021-08-05';
									//for($i='2021-08-05';$i<date('Y-m-d');$i++){
										?>
                                        
                                        <option value=""><?php echo date('d-m-Y',strtotime(date('Y-m-d', strtotime($date. ' + 1 days'))));?></option>
                                        <?php
										//$date = date('Y-m-d', strtotime($date. ' + 1 days'));
									//}
								?>
                                
                                </select>
                                </td>
                            </tr>-->
                            <tr>
                            	<th>Time</th>
                                <td>
                                <input id="time" class="cls-time" name="time[]" value="'10:00'" type="checkbox">10:00
                                <input id="time" class="cls-time" name="time[]" value="'10:15'" type="checkbox">10:15
                                <input id="time" class="cls-time" name="time[]" value="'10:30'" type="checkbox">10:30
                                <input id="time" class="cls-time" name="time[]" value="'10:45'" type="checkbox">10:45
                                <input id="time" class="cls-time" name="time[]" value="'11:00'" type="checkbox">11:00
                                <input id="time" class="cls-time" name="time[]" value="'11:15'" type="checkbox">11:15
                                <input id="time" class="cls-time" name="time[]" value="'11:30'" type="checkbox">11:30
                                <input id="time" class="cls-time" name="time[]" value="'11:45'" type="checkbox">11:45
                                <input id="time" class="cls-time" name="time[]" value="'12:00'" type="checkbox">12:00
                                <input id="time" class="cls-time" name="time[]" value="'12:15'" type="checkbox">12:15
                                <input id="time" class="cls-time" name="time[]" value="'12:30'" type="checkbox">12:30
                                <input id="time" class="cls-time" name="time[]" value="'12:45'" type="checkbox">12:45
                                <input id="time" class="cls-time" name="time[]" value="'01:00'" type="checkbox">01:00
                                <input id="time" class="cls-time" name="time[]" value="'01:15'" type="checkbox">01:15
                                <input id="time" class="cls-time" name="time[]" value="'01:30'" type="checkbox">01:30
                                <input id="time" class="cls-time" name="time[]" value="'01:45'" type="checkbox">01:45
                                <input id="time" class="cls-time" name="time[]" value="'02:00'" type="checkbox">02:00
                                <input id="time" class="cls-time" name="time[]" value="'02:15'" type="checkbox">02:15
                                <input id="time" class="cls-time" name="time[]" value="'02:30'" type="checkbox">02:30
                                <input id="time" class="cls-time" name="time[]" value="'02:45'" type="checkbox">02:45
                                <input id="time" class="cls-time" name="time[]" value="'03:00'" type="checkbox">03:00
                                <input id="time" class="cls-time" name="time[]" value="'03:15'" type="checkbox">03:15
                                <input id="time" class="cls-time" name="time[]" value="'03:30'" type="checkbox">03:30
                                <input id="time" class="cls-time" name="time[]" value="'03:45'" type="checkbox">03:45
                                <input id="time" class="cls-time" name="time[]" value="'04:00'" type="checkbox">04:00
                                <input id="time" class="cls-time" name="time[]" value="'04:15'" type="checkbox">04:15
                                <input id="time" class="cls-time" name="time[]" value="'04:30'" type="checkbox">04:30
                                <input id="time" class="cls-time" name="time[]" value="'04:45'" type="checkbox">04:45
                                <input id="time" class="cls-time" name="time[]" value="'05:00'" type="checkbox">05:00
                                <input id="time" class="cls-time" name="time[]" value="'05:15'" type="checkbox">05:15
                                <input id="time" class="cls-time" name="time[]" value="'05:30'" type="checkbox">05:30
                                <input id="time" class="cls-time" name="time[]" value="'05:45'" type="checkbox">05:45
                                <input id="time" class="cls-time" name="time[]" value="'06:00'" type="checkbox">06:00
                                <input id="time" class="cls-time" name="time[]" value="'06:15'" type="checkbox">06:15
                                <input id="time" class="cls-time" name="time[]" value="'06:30'" type="checkbox">06:30
                                <input id="time" class="cls-time" name="time[]" value="'06:45'" type="checkbox">06:45
                                <input id="time" class="cls-time" name="time[]" value="'07:00'" type="checkbox">07:00
                                <input id="time" class="cls-time" name="time[]" value="'07:15'" type="checkbox">07:15
                                <input id="time" class="cls-time" name="time[]" value="'07:30'" type="checkbox">07:30
                                <input id="time" class="cls-time" name="time[]" value="'07:45'" type="checkbox">07:45
                                <input id="time" class="cls-time" name="time[]" value="'08:00'" type="checkbox">08:00
                                <input id="time" class="cls-time" name="time[]" value="'08:15'" type="checkbox">08:15
                                <input id="time" class="cls-time" name="time[]" value="'08:30'" type="checkbox">08:30
                                <input id="time" class="cls-time" name="time[]" value="'08:45'" type="checkbox">08:45
                                <input id="time" class="cls-time" name="time[]" value="'09:00'" type="checkbox">09:00
                                <input id="time" class="cls-time" name="time[]" value="'09:15'" type="checkbox">09:15
                                <input id="time" class="cls-time" name="time[]" value="'09:30'" type="checkbox">09:30
                                <input id="time" class="cls-time" name="time[]" value="'09:45'" type="checkbox">09:45
                                <input id="rodTime" name="chkTime" value="1" type="checkbox" onclick="setTimeID()" >Check All
                                	
                               	</td>     
                            </tr>
                            <tr>
                            	<th>User ID</th>
                                <td>
                                <?php
										 		$sqlU = 'SELECT id,userCode FROM '.$DB->pre.'users WHERE isActive="1" AND status="1" AND userType="3"';
												$U = $DB->dbRows($sqlU);
												foreach($U as $U){
													?>
                                                    <span><?php echo $U['userCode']?><input id="uID" name="uID[]" type="checkbox" value="<?php echo $U['id']?>"></span>
                                                   <?php
												}

										  ?>
                                	
                              	</td>
                            </tr>
                            
                            <tr>
                            	<th colspan="2"><button type="submit" id="btnRSubmit" name="btnRSubmit">Show Reports</button>&nbsp;&nbsp;<button type="submit"  id="" name="" >Remove / cancel</button> </th>

                            </tr>
                        </table>
            
            
            
            			<table border="1" width="100%" cellspacing="0" cellpadding="5">
                        
                        <tr style="background:#AAD5BF">
                            <td>Sr.No.</td>
                            <td>Name</td>
                            <td>Lotter Date Time</td>
                            <td>Print Time</td>
                            <td>Trans. No.</td>
                            <td>Point</td>
                            <td><input id="rodDelete" name="rodDelete" type="checkbox" onclick="setDelID()"> <input id="btnDelete" name="btnDelete" type="submit" value="Delete"></td>
                        </tr>
            
            <?php
				
				
					if(isset($_REQUEST['btnRSubmit'])){

					$where = '';
					if($_REQUEST['frmdate'] !='' && $_REQUEST['todate'] !='' ){
					 $where .= ' (lotdate between "'.date('Y-m-d',strtotime($_REQUEST['frmdate'])).'" AND "'.date('Y-m-d',strtotime($_REQUEST['todate'])).'")';
					}
					
					 $UID = implode($_REQUEST['uID'],',');
					 $time = implode($_REQUEST['time'],',');
					//print_r($_REQUEST['uID']);die;
					 $sql = 'SELECT * FROM '.$DB->pre.'lottary WHERE (lotTime in('.$time.')) AND (uID in('.$UID.')) AND '.$where.' GROUP BY barcode';
					//$sql = 'SELECT * FROM '.$DB->pre.'lottary limit 0,20 ';
					$L = $DB->dbRows($sql);
					foreach($L as $k=>$L){
			?> 

            <tr>
            	<td><?php echo ($k+1)?></td>
                <td><?php 
						$sqlN = 'SELECT userCode FROM '.$DB->pre.'users WHERE id="'.$L['uID'].'"';
						$N = $DB->dbRow($sqlN);
						echo $N['userCode'];
				 ?></td>
                <td><?php echo $L['lotdate'].' '.$L['lotTime']?></td>
                <td><?php echo $L['printTime']?></td>
                <td><?php echo $L['tranID']?></td>
                <td><?php echo $L['qtytot']?></td>
                <td><input id="rdo1" name="rdo1[]" class="cls-delete" type="checkbox" value="<?php echo "'".$L['barcode']."'"?>"></td>
            </tr>
            <?php } 
			
					}
			?>
            </table>	
</form>
		</div>
<?php 
			if(isset($_REQUEST['btnDelete'])){
				//print_r($_REQUEST['rdo1']);die;
				$ID = implode($_REQUEST['rdo1'],',');
				$sqlR = 'DELETE FROM '.$DB->pre.'lottary WHERE barcode in ('.$ID.')';
				if($DB->dbQuery($sqlR)){
					$sqlW = 'DELETE FROM '.$DB->pre.'result_win WHERE barcode in ('.$ID.')';
					$DB->dbQuery($sqlW);
					echo "Record is deleted...";
				
				}
				
			}
		?>
	</div>
    <script type="text/javascript">
	function setDelID(){
		var flag = document.getElementById('rodDelete').checked;
		var chk = document.querySelectorAll("input[class=cls-delete]");
		if(flag){	
			for (i = 0; i <	chk.length; i++) {
				chk[i].checked = true;
			}

		}else{
			for (i = 0; i <	chk.length; i++) {
				chk[i].checked = false;
			}
		}
	}
	function setTimeID(){
		var flag = document.getElementById('rodTime').checked;
		var chk = document.querySelectorAll("input[class=cls-time]");
		if(flag){	
			for (i = 0; i <	chk.length; i++) {
				chk[i].checked = true;
			}

		}else{
			for (i = 0; i <	chk.length; i++) {
				chk[i].checked = false;
			}
		}
	}
    </script>
<!--<script type="text/javascript">
$('document').ready(function(e) {
	var multiID = '';
	$('#rodDelete').click(function(){

 	multiID= '';
 	if($(this).is(':checked')){
 		$('.cls-delete').each(function() {
                var cur = $(this);
                var attr = $(this).attr('disabled');
                if(attr !='disabled'){
                	multiID += cur.val()+',';
                	cur.prop('checked',true);	
                }
        });
 	}else{
		multiID = '';
		$('.cls-delete').each(function() {
			var cur = $(this);
			var attr = $(this).attr('disabled');
			if(attr !='disabled'){
				cur.prop('checked',false);	
			}      
		});
 	}
 }) ;
 
 $('.cls-delete').click(function(){
	 var cur1 = $(this);
	 if($(this).is(':checked')){
		 multiID += cur1.val()+",";
	 }else{
		 var val = cur1.val()
	 	//multiID.replace("/"+val+"/gi",' ');
		
	 }
	 
 });
 var SITEURL = "http://localhost/mr-admin"
 $('#btnDelete').click(function(){
	 
	 var aUrl = SITEURL+"/mod/page/x-page.inc.php?xAction=deleteLot&ID="+multiID;
	 alert(aUrl);
	 $.ajax({
		 type:'GET',
		 url:aUrl,
		 success: function(str){
			 var data = $.parseJSON(str);
			 if(data.str == 'OK'){
			 	location.reload();
			 }
		 }
	 });
	 
 });
    
});
</script>-->
</body>
</html>
