';
include('include/conectdb.php');
include('lightbox.php');
include_once('calender/cal_top_code.php');
include_once('calender/cal_date_convert.php');
;echo '
';
if(isset($_POST['date_submit']))
{
$error = true;
if(!empty($_POST['tes_date']))
{
$tes_date = format_date($_POST['tes_date']);
echo 'Search For Date '.$tes_date;
$q1 = "SELECT gid, date_format(start_time, '%d-%m-%Y
%r') as start_date, gname FROM game_name WHERE date_format(end_time, '%d-%m-%Y') = '00-00-0000' order by gid";
$r1 = mysqli_query($dbc,$q1);
if(mysqli_num_rows($r1) >0)
{
$j_total = array();
while($row = mysqli_fetch_assoc($r1))
{
$q1="SELECT sum(actual_amount) as Jodi_total FROM jodi WHERE gid = '$row[gid]'";
$r2 = mysqli_query($dbc,$q1);
if(mysqli_num_rows($r2) >0)
{
$row2 = mysqli_fetch_assoc($r2);
$j_total[$row['gid']]['Jodi_total'] = $row2['Jodi_total'];
}
else
{
$j_total[$row['gid']]['Jodi_total'] = 0;
}
$j_total[$row['gid']]['Game_id'] = $row['gid'];
$j_total[$row['gid']]['Game_name'] = $row['gname'];
$j_total[$row['gid']]['start_date'] = $row['start_date'];
$q1="SELECT sum(actual_amount) as Single_total FROM single WHERE gid = '$row[gid]'";
$r3 = mysqli_query($dbc,$q1);
if(mysqli_num_rows($r3) >0)
{
$row3 = mysqli_fetch_assoc($r3);
$j_total[$row['gid']]['Single_total'] = $row3['Single_total'];
}
else
$j_total[$row['gid']]['Single_total'] = 0;
$q1="SELECT sum(deduction_amount) as deduction_total FROM deduction WHERE gid = '$row[gid]' AND pid != '0'";
$r4 = mysqli_query($dbc,$q1);
if(mysqli_num_rows($r4) >0)
{
$row4 = mysqli_fetch_assoc($r4);
$j_total[$row['gid']]['players_deduction'] = $row4['deduction_total'];
}
else
$j_total[$row['gid']]['players_deduction'] = 0;
$q1="SELECT deduction_amount FROM deduction WHERE gid = '$row[gid]' AND pid = '0'";
$r5 = mysqli_query($dbc,$q1);
if(mysqli_num_rows($r5) >0)
{
$row5 = mysqli_fetch_assoc($r5);
$j_total[$row['gid']]['game_deduction'] = $row5['deduction_amount'];
}
else
$j_total[$row['gid']]['game_deduction'] = 0;
}
echo'
Current Game Summary |
Game name |
Gid |
Total Amount |
Deductions |
Balance Amount |
Start Date |
Finish Game |
View Details |
';
$gtotal = 0;$gdeduct = 0;
foreach($j_total as $key =>$value)
{
$total = $value['Jodi_total']+$value['Single_total'];
$gtotal += $total;
$deduct = $value['players_deduction']+$value['game_deduction'];
$gdeduct += $deduct;
echo'
'.$value['Game_name'].' |
'.$value['Game_id'].' |
'.$total.' |
'.$deduct.' |
'.($total -$deduct).' |
'.$value['start_date'].' |
Conclude |
View |
';
}
echo'
|
Grand Total |
'.$gtotal.' |
'.$gdeduct.' |
'.($gtotal -$gdeduct).' |
|
';
echo '
';
}
$q1 = "SELECT gid, date_format(end_time, '%d-%m-%Y
%r') as end_date, date_format(start_time, '%d-%m-%Y
%r') as start_date, gname FROM game_name WHERE date_format(end_time, '%d-%m-%Y') = '$tes_date' AND cur_status = '1' order by gid";
$r6 = mysqli_query($dbc,$q1);
if(mysqli_num_rows($r6) >0)
{
$old_game = array();
while($row = mysqli_fetch_assoc($r6))
{
$q1="SELECT remaining_amount FROM deduction WHERE gid = '$row[gid]' AND pid = '0' LIMIT 1";
$r7 = mysqli_query($dbc,$q1);
if(mysqli_num_rows($r7) >0)
{
$row7 = mysqli_fetch_assoc($r7);
$old_game[$row['gid']]['Balance'] = $row7['remaining_amount'];
}
else
{
$old_game[$row['gid']]['Balance'] = 0;
}
$old_game[$row['gid']]['Game_id'] = $row['gid'];
$old_game[$row['gid']]['Game_name'] = $row['gname'];
$old_game[$row['gid']]['end_date'] = $row['end_date'];
$old_game[$row['gid']]['start_date'] = $row['start_date'];
$q1="SELECT sum(actual_amount) as original_amt FROM jodi_old WHERE gid = '$row[gid]' AND type != 'TP'";
$r8 = mysqli_query($dbc,$q1);
if(mysqli_num_rows($r8) >0)
{
$row8 = mysqli_fetch_assoc($r8);
$old_game[$row['gid']]['original_amount'] = $row8['original_amt'];
}
else
{
$old_game[$row['gid']]['original_amount'] = 0;
}
}
echo'
Finished Game Summary |
Game name |
Gid |
Total Amount |
Deductions |
Balance Amount |
Start Date |
Finish Game |
View Details |
';
$gtotal = 0;
$gbal = 0;
foreach($old_game as $key =>$value)
{
$gtotal += $value['original_amount'];
$gbal += $value['Balance'];
echo'
'.$value['Game_name'].' |
'.$value['Game_id'].' |
'.$value['original_amount'].' |
'.($value['original_amount'] -$value['Balance']).' |
'.$value['Balance'].' |
'.$value['start_date'].' |
'.$value['end_date'].' |
View | Won | Partywise |
';
}
echo'
|
Grand Total |
'.$gtotal.' |
'.($gtotal -$gbal).' |
'.$gbal.' |
|
';
echo '
';
echo'
';
echo'
';
}
}
}
;echo '