 <table style="width:100%" cellpadding='' height='' cellspacing='0' border='0' align='center' valign= 'top' >
	   
	   
	  
	   
	   
	   <?php 
											
											$sl=0;
                                $sqlSelectedLG = "select * from (SELECT * FROM `months`) as g1 left join (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.*,IFNULL(w2.a_ev_value,0) 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 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) = '$yr' 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) = '$yr' 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)-IFNULL(sum(t2.discount),0) as in_total from (SELECT invoice_id, IFNULL(sum(total),0) 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) = '$yr' 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) = '$yr' 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) = '$yr' 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) = '$yr' group by MONTHNAME(approved_at) order by DATE_FORMAT('approved_at', '%m')) as w6 on w1.month=w6.month) as y order by y.m) as g2 on g1.name=g2.month";

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


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

                                 if($type=="booking_value"){
									  $value=round(($row1->total_booking_value),0);	
								 }
                                 	
                                 if($type=="event_value"){
									  $value=round(($row1->event_value),0);	
								 }

                                 if($type=="booking_no"){
									  $value=round(($row1->total_no_bk),0);	
								 }								 
					
				                $balancen=IND_money_format($value);
								
									
									?>
									
									 <tr align="left" >
	    <td style="border-bottom: 1px solid black;border-right: 1px solid black;" > &nbsp;&nbsp; <b><?php echo $value; ?></b>
	   </td>
	   </tr>
	   
							<?php   } ?>
									
									
	   </table>