<?php session_start(); ob_start(); ?>

<?php  include 'header.php'; ?>

<?php
	ini_set('display_errors', 0);
if(empty($_SESSION['LOGINID']) && empty($_SESSION['LOGINNM']) ){

	header("Location:index.php");
}


include("user.php");
	$year = $_GET["year"];
	
	
?>


						  
	<?php
												  

$settingsSQL = mysqli_query($connection, "SELECT * FROM `settings` where name='address' ");
$settingsSQL = mysqli_fetch_object($settingsSQL);
									
$address = $settingsSQL->value;

$settingsSQL = mysqli_query($connection, "SELECT * FROM `settings` where name='mobile' ");
$settingsSQL = mysqli_fetch_object($settingsSQL);
									
$our_mobile = $settingsSQL->value;

$settingsSQL = mysqli_query($connection, "SELECT * FROM `settings` where name='email' ");
$settingsSQL = mysqli_fetch_object($settingsSQL);
									
$our_email = $settingsSQL->value;
								   
?>	

<html>

<style>
body {
  background: rgb(204,204,204); 
}
page {
  background: white;
  display: block;
  padding-top: 2cm;
  padding-left: 2cm;
  padding-right: 2cm;
  margin: auto;
  margin-bottom: 2.0cm;
}
page[size="A4"] {  
  width: 21cm;
  height: 29.7cm; 
}
page[size="A4"][layout="landscape"] {
  width: 29.7cm;
  height: 21cm;  
}

@media print {
  body, page {
    margin: 0;
    box-shadow: 0;
  }
}



</style>

  <head>
    <title>Booking Print</title>
	<meta http-equiv='content-type' content='text/html;charset=utf-8' />
  </head>
  
  <page size="A4">
  
  <body>
<center>
<table style="width:100%;border: 0px solid black;" cellpadding='0' height='' cellspacing='0'  >
 
  <tr align="center" >
    <td  style="width:100%; "  > <img src="assets/images/logo_wd.png" width="150" /> </br>
<?php echo "$address"; ?> </br>
<?php echo "$our_email"; ?> </br>
<?php echo "$our_mobile"; ?>  </br>
For The Year : <?php echo "$year"; ?> 

	</td>
  
  </tr>
</table>

</br></br>

<table style="width:100%" cellpadding='' height='' cellspacing='0' border='0' align='center' valign= 'top' >
	<tr align="left" >
	  <td style="width:10%;border-bottom: 1px solid black;" > 
	   &nbsp;&nbsp; <b>Month </b>
      </td> 
	  <td style="width:25%;border-bottom: 1px solid black;" > 
	   <b>Booking Value (events)</b>
      </td> 
	  <td style="width:15%;border-bottom: 1px solid black;" > 
	   <b>POS Value</b>
      </td> 
	    <td style="width:15%;border-bottom: 1px solid black;" > 
	   <b>Total Booking Value</b>
      </td> 
	    <td style="width:20%;border-bottom: 1px solid black;" > 
	  <b> No.of Ev</b>
      </td> 
	  <td style="width:20%;border-bottom: 1px solid black;" > 
	  <b> No.of Booking</b>
      </td> 
	   <td style="width:15%;border-bottom: 1px solid black;" > 
	  &nbsp;&nbsp; <b> E.Value</b>
      </td>
	</tr> 
	
	
	
	 <?php 
											
											$sl=0;
                                $sqlSelectedLG = " select * from (select ( CASE w1.month  WHEN 'January' THEN 1
            WHEN 'February' THEN 2
            WHEN 'March' THEN 3
            WHEN 'April' THEN 4
            WHEN 'May' THEN 5
            WHEN 'June' THEN 6
            WHEN 'July' THEN 7
            WHEN 'August' THEN 8
            WHEN 'September' THEN 9
            WHEN 'October' THEN 10
            WHEN 'November' THEN 11
            WHEN 'December' THEN 12
          END ) as m , w1.*,w2.a_ev_value,IFNULL(w3.in_total,0) in_total,IFNULL(w1.ev_value,0)+IFNULL(w2.a_ev_value,0)+IFNULL(w3.in_total,0) as total_booking_value,w4.event_value,w5.total_received,w6.total_no_bk,w7.total_evnt from (SELECT MONTHNAME(approved_at) month, sum(t1.ev_value-((t1.ev_value*t2.discount)/100)) ev_value FROM `events`  as t1 left join bookings as t2 on t1.temp_id=t2.id where (t2.status=1 AND t1.added_later='no') AND YEAR(approved_at) = '$year' group by MONTHNAME(approved_at) order by DATE_FORMAT('approved_at', '%m')) as w1 left join (SELECT MONTHNAME(approved_at) month, sum(t1.ev_value-((t1.ev_value*t2.discount)/100)) a_ev_value FROM `events` as t1 left join bookings as t2 on t1.temp_id=t2.id where (t2.status=1 AND t1.added_later='yes') AND YEAR(approved_at) = '$year' group by MONTHNAME(approved_at) order by DATE_FORMAT('approved_at', '%m')) as w2 on w1.month=w2.month left join (SELECT MONTHNAME(date) month,sum(t1.inv_amount)-sum(t2.discount) as in_total from (SELECT invoice_id, sum(total) inv_amount FROM `invoice_items` group by invoice_id order by invoice_id desc) as t1 left join invoices as t2 on t1.invoice_id=t2.inv_id left join bookings as t3 on t2.customer_id=t3.id where YEAR(date) = '$year' group by MONTHNAME(date) order by DATE_FORMAT('date', '%m')) as w3 on w1.month=w3.month left join (SELECT MONTHNAME(t1.date) month,sum(t1.ev_value-((t1.ev_value*t2.discount)/100)) event_value FROM `events`  as t1 left join bookings as t2 on t1.temp_id=t2.id where t2.status=1 AND YEAR(t1.date) = '$year' group by MONTHNAME(t1.date) order by DATE_FORMAT('t1.date', '%m') ) as w4 on w1.month=w4.month left join (SELECT MONTHNAME(date) month, sum(amount) total_received FROM `transactions` where YEAR(date) = '$year' group by MONTHNAME(date) order by DATE_FORMAT('date', '%m') ) as w5 on w1.month=w5.month left join (SELECT MONTHNAME(approved_at) month, count(id) total_no_bk FROM `bookings` where (booking_id!=0 AND status!=2) AND YEAR(approved_at) = '$year' group by MONTHNAME(approved_at) order by DATE_FORMAT('approved_at', '%m')) as w6 on w1.month=w6.month left join (SELECT MONTHNAME(l1.date) month, count(l1.id) total_evnt FROM (SELECT t1.* FROM `events` as t1 left join bookings as t2 on t1.temp_id=t2.id where t2.booking_id!=0) as l1 where YEAR(l1.date) = '$year' group by MONTHNAME(l1.date) order by DATE_FORMAT('l1.date', '%m')) as w7 on w1.month=w7.month) as y order by y.m";

                               $sqlSelectedLG = mysqli_query($connection, $sqlSelectedLG);


                               while ($row1 = mysqli_fetch_object($sqlSelectedLG)) {

                                 
                                  $month=$row1->month;
	                             $ev_value=$row1->ev_value;
	                              $a_ev_value=$row1->a_ev_value;
								   $in_total=$row1->in_total;
								    $total_booking_value=$row1->total_booking_value;
									 $event_value=$row1->event_value;
									 $total_evnt=$row1->total_evnt;
									  $total_received=$row1->total_received;
									  
									  $total_no_bk=$row1->total_no_bk;
									  
			                     $total=$total_asset+$balance;						
					
				                $balancen=IND_money_format($balance);
								
									
									?>
	
	
	
	
	
	
	
	<tr align="left" >
	  <td style="width:10%;border-bottom: 1px solid black;" > 
	   &nbsp;&nbsp; <?php echo $month; ?>
      </td> 
	  <td style="width:25%;border-bottom: 1px solid black;" > 
	  <?php echo $ev_value+$a_ev_value; ?>
      </td> 
	  <td style="width:15%;border-bottom: 1px solid black;" > 
	<?php echo round($in_total,0); ?>
      </td> 
	    <td style="width:15%;border-bottom: 1px solid black;" > 
	<?php echo round($total_booking_value,0); ?>
      </td> 
	  <td style="width:20%;border-bottom: 1px solid black;" > 
	  <?php echo $total_evnt; ?> 
      </td>
	    <td style="width:20%;border-bottom: 1px solid black;" > 
	  <?php echo $total_no_bk; ?> 
      </td> 
	   <td style="width:15%;border-bottom: 1px solid black;" > 
	  &nbsp;&nbsp;  <?php echo round($event_value,0); ?>
      </td>
	</tr> 
	
	
							   <?php } ?>
</table>
</br></br>




 
 
 
 
 
 
 
 
 </center> 
 
 
  </body>
  
  </page>
  
</html>