<style>
::-webkit-scrollbar {display:none;}
.page_loader {
     position: fixed;
     left: 0px;
     top: 0px;
     width: 100%;
     height: 100%;
     z-index: 9999;
     background: url('<?php echo base_url(); ?>assets/images/loader.gif') 50% 50% no-repeat rgb(249, 249, 249);
 }

</style>
<div class="page_loader"></div>
<canvas id="chart-area" width="210" height="70"></canvas>
<?php $general = get_general_setting();?>
<?php 
$logo_url 	= !empty($data['settings']['logo']) && file_exists(DIR_COMPANY_LOGO. $data['settings']['logo']) ? DIR_COMPANY_LOGO . $data['settings']['logo'] : 'assets/images/logo.png';
$total_amt 	= 0;
$start_date = (!empty($data['start_date'])) ? $data['start_date'] : date('d-m-Y');
$add_days 	= 27;
$d 			= date('d-m-Y',strtotime($start_date) + (24*3600*$add_days));
$end_date 	= (!empty($data['end_date'])) ? $data['end_date'] : date('d-m-Y');
//echo "<pre>"; print_r($data['results']); print_r($data['abishegam']); exit;
if(count($data['results']) > 0) { 
	foreach( $data['results'] as $key => $row) :
		//Refund Amount
		$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
	  
		if(!empty($Refund)) {
			$recentAmt = $row['amount'] - $Refund;
		}
		else {
		   $recentAmt = $row['amount'];
		}
		$chartamout[$row['type_id']] += $recentAmt;                                            
	endforeach; 
} 
$calArray	= $chartamout;
arsort($calArray);
if($calArray){
	$i = 0;
	foreach($calArray as $greater){
	  if($i == 1)
	  	continue;
		
	  if($i == 0){
		  $num 		= (int)((int)$greater/6);
		  $round 	= (strlen($num)-1)*-1;
		  $stepSize =  round($num,$round); // prints 200
	  }
	  $i++;
	}
}else{
	$num 		= 20;
	$round 		= (strlen($num)-1)*-1;
	$stepSize 	=  round($num,$round);
}

$total_amt 				= 0;
$before_gst_total 		= 0;
$gst_total 				= 0;

$abishegam_amt 			= 0;
$abishegam_bgst_total 	= 0;
$abishegam_gst_total	= 0;

$archanai_amt 			= 0;
$archanai_bgst_total 	= 0;
$archanai_gst_total		= 0;

$building_fund_amt 		= 0;
$building_bgst_total 	= 0;
$building_gst_total		= 0;

$donation_amt 			= 0;
$donation_bgst_total 	= 0;
$donation_gst_total		= 0;

$festival_amt 			= 0;
$festival_bgst_total 	= 0;
$festival_gst_total		= 0;

$gold_silver_amt 		= 0;
$gold_silver_bgst_total = 0;
$gold_silver_gst_total	= 0;

$hall_booking_amt 		= 0;
$hall_booking_bgst_total= 0;
$hall_booking_gst_total	= 0;

$homam_amt 				= 0;
$homam_bgst_total		= 0;
$homam_gst_total		= 0;

$kattalai_amt 			= 0;
$kattalai_bgst_total	= 0;
$kattalai_gst_total		= 0;

$madappalli_amt 		= 0;
$madappalli_bgst_total	= 0;
$madappalli_gst_total	= 0;

$mega_amt 				= 0;
$mega_bgst_total		= 0;
$mega_gst_total			= 0;

$member_subscripe_amt 			= 0;
$member_subscripe_bgst_total	= 0;
$member_subscripe_gst_total		= 0;

$membership_amt 		= 0;
$membership_bgst_total	= 0;
$membership_gst_total	= 0;

$card_topup_amt 		= 0;
$card_bgst_total		= 0;
$card_gst_total			= 0;

$outdoor_amt 			= 0;
$outdoor_bgst_total		= 0;
$outdoor_gst_total		= 0;

$other_amt 				= 0;
$other_bgst_total		= 0;
$other_gst_total		= 0;

$prasadam_amt 			= 0;
$prasadam_bgst_total	= 0;
$prasadam_gst_total		= 0;

$temple_amt 			= 0;
$temple_bgst_total		= 0;
$temple_gst_total		= 0;

$temple_shop_amt 		= 0;
$temple_shop_bgst_total	= 0;
$temple_shop_gst_total	= 0;

$ubayam_amt 			= 0;
$ubayam_bgst_total		= 0;
$ubayam_gst_total		= 0;

$wedding_hall_amt 		= 0;
$wedding_hall_bgst_total= 0;
$wedding_hall_gst_total	= 0;

$html = '<div id="print_content">
    <table width="100%" style="font-family:Verdana, Geneva, sans-serif">
        <tr>
            <td width="25%">
                    <img src="'.$logo_url.'"/>
            </td>
            <td width="50%" align="center">
                <table border="0" width="100%">
                    <tr>
                        <td align="center" style="font-size:18px;">
                            <strong>'.$data['settings']['temple_name'].'</strong>
                        </td>
                    </tr>
                </table>
            </td>
            <td width="25%">&nbsp;</td>
        </tr>
        <tr><td colspan="3"><hr></td></tr>    
        <tr>
            <td width="25%">&nbsp;</td>
            <td align="center" width="50%" style="font-weight:bold; font-size:18px;">
            Monthly Section Wise Report
            </td>
            <td width="25%" style="font-size:14px;">
            &nbsp;
            </td>
        </tr>
        <tr>
            <td align="left" style="font-size:14px;"><strong>Start Date : '.date('d-m-Y',strtotime($start_date)).'</strong></td>
            <td>&nbsp;</td>
            <td align="right" style="font-size:14px;"><strong>End Date : '.date('d-m-Y',strtotime($end_date)).'</strong></td>
        </tr>
		<tr><td colspan="3">&nbsp;</td></tr>
		<tr><td colspan="3"><img id="myImage" /></td></tr>
    </table>  ';
    
	if($data['abishegam']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Abishegam</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) { 
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['abishegam']) > 0) { 
					 $i = 0;
					foreach( $data['abishegam'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$abishegam_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) { 
										$html .= '<td class="align-right" align="right">';										
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$abishegam_bgst_total 	= $abishegam_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}											
										$html .= '</td>
												  <td class="align-right" align="right">';										
											if(!empty($row['gst'])) {									
												$abishegam_gst_total 	= $abishegam_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{															
												$html 					.= '0.00';
											}											
										$html .= '</td>';
									} 							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($abishegam_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($abishegam_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($abishegam_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['archanai']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Archanai</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) { 
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['archanai']) > 0) { 
					 $i = 0;
					foreach( $data['archanai'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$archanai_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) { 
										$html .= '<td class="align-right" align="right">';	 
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$archanai_bgst_total 	= $archanai_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}							
										$html .= '</td>
												  <td class="align-right" align="right">';						 
											if(!empty($row['gst'])) {									
												$archanai_gst_total 	= $archanai_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{															
												$html 					.= '0.00';
											}							
										$html .= '</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($archanai_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($archanai_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($archanai_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['building_fund']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Kumbabishegam</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['building_fund']) > 0) { 
					 $i = 0;
					foreach( $data['building_fund'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$building_fund_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$building_bgst_total 	= $building_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$building_gst_total 	= $building_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{															
												$html 					.= '0.00';
											}
										$html .= '</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($building_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($building_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($building_fund_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['donation']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Donation</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['donation']) > 0) { 
					 $i = 0;
					foreach( $data['donation'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$donation_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">'; 
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$donation_bgst_total 	= $donation_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$donation_gst_total 	= $donation_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{															
												$html 					.= '0.00';
											}
										$html .= '</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($donation_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($donation_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($donation_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['festival']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Festival Function</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['festival']) > 0) { 
					 $i = 0;
					foreach( $data['festival'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$festival_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$festival_bgst_total 	= $festival_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$festival_gst_total 	= $festival_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{															
												$html 					.= '0.00';
											}
										$html .= '</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($festival_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($festival_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($festival_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['gold_silver']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Gold Silver</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['gold_silver']) > 0) { 
					 $i = 0;
					foreach( $data['gold_silver'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$gold_silver_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$gold_silver_bgst_total	= $gold_silver_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$gold_silver_gst_total 	= $gold_silver_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{															
												$html 					.= '0.00';
											}
										$html .= '</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($gold_silver_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($gold_silver_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($gold_silver_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['hall_booking']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Hall Booking</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['hall_booking']) > 0) { 
					 $i = 0;
					foreach( $data['hall_booking'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$hall_booking_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 				= number_format($recentAmt - $gst_amt,2,'.','');
												$hall_booking_bgst_total	= $hall_booking_bgst_total + $before_gst;
												$html 						.= $before_gst;
											}else{
												$html 						.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">'; 
											if(!empty($row['gst'])) {									
												$hall_booking_gst_total 	= $hall_booking_gst_total + $gst_amt;
												$html 						.= $gst_amt;
											}else{															
												$html 						.= '0.00';
											}
										$html .= '</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($hall_booking_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($hall_booking_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($hall_booking_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['homam']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Homam</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['homam']) > 0) { 
					 $i = 0;
					foreach( $data['homam'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$homam_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$homam_bgst_total		= $homam_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$homam_gst_total 		= $homam_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{														
												$html 					.= '0.00';
											}
										$html .= '</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($homam_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($homam_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($homam_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['kattalai']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Kattalai Archanai</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['kattalai']) > 0) { 
					 $i = 0;
					foreach( $data['kattalai'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$kattalai_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$kattalai_bgst_total	= $kattalai_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$kattalai_gst_total 	= $kattalai_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{														
												$html 					.= '0.00';
											}
										$html .= '</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($kattalai_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($kattalai_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($kattalai_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['madappalli']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Madappalli</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['madappalli']) > 0) { 
					 $i = 0;
					foreach( $data['madappalli'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$madappalli_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$madappalli_bgst_total	= $madappalli_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$madappalli_gst_total 	= $madappalli_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{														
												$html 					.= '0.00';
											}
										$html .= '</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($madappalli_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($madappalli_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($madappalli_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['mega']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Mega Function</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['mega']) > 0) { 
					 $i = 0;
					foreach( $data['mega'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$mega_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$mega_bgst_total		= $mega_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$mega_gst_total 		= $mega_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{														
												$html 					.= '0.00';
											}
										$html .= '</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($mega_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($mega_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($mega_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['member_subscripe']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Member Subscription</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['member_subscripe']) > 0) { 
					 $i = 0;
					foreach( $data['member_subscripe'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$member_subscripe_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 					= number_format($recentAmt - $gst_amt,2,'.','');
												$member_subscripe_bgst_total	= $member_subscripe_bgst_total + $before_gst;
												$html 							.= $before_gst;
											}else{
												$html 							.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$member_subscripe_gst_total		= $member_subscripe_gst_total + $gst_amt;
												$html 							.= $gst_amt;
											}else{														
												$html 							.= '0.00';
											}
										$html .= '</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($member_subscripe_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($member_subscripe_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($member_subscripe_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['membership']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Membership</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['membership']) > 0) { 
					 $i = 0;
					foreach( $data['membership'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$membership_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$membership_bgst_total	= $membership_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$membership_gst_total		= $membership_gst_total + $gst_amt;
												$html 						.= $gst_amt;
											}else{														
												$html 						.= '0.00';
											}
										$html .= '</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($membership_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($membership_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($membership_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['card_topup']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Card Topup</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['card_topup']) > 0) { 
					 $i = 0;
					foreach( $data['card_topup'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$card_topup_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$card_bgst_total		= $card_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$card_gst_total			= $card_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{														
												$html 					.= '0.00';
											}
										$html .= '</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($card_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($card_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($card_topup_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['outdoor']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Outdoor Services</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['outdoor']) > 0) { 
					 $i = 0;
					foreach( $data['outdoor'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$outdoor_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$outdoor_bgst_total		= $outdoor_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$outdoor_gst_total		= $outdoor_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{														
												$html 					.= '0.00';
											}
										$html .= '</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($outdoor_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($outdoor_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($outdoor_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['other']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Other Services</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['other']) > 0) { 
					 $i = 0;
					foreach( $data['other'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$other_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$other_bgst_total		= $other_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$other_gst_total		= $other_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{														
												$html 					.= '0.00';
											}
										$html .= '</td>';
									}						
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($other_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($other_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($other_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['prasadam']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Prasadam</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['prasadam']) > 0) { 
					 $i = 0;
					foreach( $data['prasadam'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$prasadam_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$prasadam_bgst_total	= $prasadam_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$prasadam_gst_total		= $prasadam_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{														
												$html 					.= '0.00';
											}
										$html .= '</td>';
									}						
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($prasadam_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($prasadam_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($prasadam_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['temple']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Temple</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['temple']) > 0) { 
					 $i = 0;
					foreach( $data['temple'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$temple_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$temple_bgst_total		= $temple_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$temple_gst_total		= $temple_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{														
												$html 					.= '0.00';
											}
										$html .= '</td>';
									}						
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($temple_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($temple_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($temple_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['temple_shop']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Temple Shop</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['temple_shop']) > 0) { 
					 $i = 0;
					foreach( $data['temple_shop'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$temple_shop_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$temple_shop_bgst_total	= $temple_shop_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$temple_shop_gst_total	= $temple_shop_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{														
												$html 					.= '0.00';
											}
										$html .= '</td>';
									}						
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($ubayam_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($temple_shop_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($temple_shop_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['ubayam']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Ubayam</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['ubayam']) > 0) { 
					 $i = 0;
					foreach( $data['ubayam'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$ubayam_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 			= number_format($recentAmt - $gst_amt,2,'.','');
												$ubayam_bgst_total		= $ubayam_bgst_total + $before_gst;
												$html 					.= $before_gst;
											}else{
												$html 					.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$ubayam_gst_total		= $ubayam_gst_total + $gst_amt;
												$html 					.= $gst_amt;
											}else{														
												$html 					.= '0.00';
											}
										$html .= '</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($ubayam_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($ubayam_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($ubayam_amt,2,'.','').'</td>
							</tr>';
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}
	
	if($data['wedding_hall']){		
		$html .= '<table width="100%" style="font-family:Verdana, Geneva, sans-serif"><tr><td align="center"><b><ul>Wedding Hall Booking</ul></b></td></tr></table>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" class="filterTable" id="filterTable">
			<thead>
				<tr>
					<th style="padding:0.6%; width:7%;">S.No</th>
					<th style="padding:0.6%; width:16%;">Receipt No</th>
					<th style="padding:0.6%; width:30%">Name</th>
					<th style="padding:0.6%; width:10%">Qty</th>
					<th style="padding:0.6%; width:9%">U.Price</th>';
					if($general->gst > 0) {
						$html .= '<th style="padding:0.6%; width:13%">Before GST</th>
						<th style="padding:0.6%; width:9%">GST</th>';
					}
		 $html .= '<th style="padding:0.6%; width:13%">Total '.(($general->gst > 0) ? '(Incl. of GST)' : '').'</th>
				</tr>
			</thead>
			<tbody>';
				
				if(count($data['wedding_hall']) > 0) { 
					 $i = 0;
					foreach( $data['wedding_hall'] as $key => $row) :
						//Refund Amount
						$Refund = $this->monthly_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$start_date,$end_date);
						if(!empty($Refund)) {
							$recentAmt = $row['amount'] - $Refund;
						}else {
						   $recentAmt = $row['amount'];
						}						
						$wedding_hall_amt += $recentAmt;
						if(!empty($row['gst'])) {
							$AmtwithGst = $recentAmt * ($row['gst'] / 100);
							$gst_amt 	= number_format($AmtwithGst,2,'.','');
						} else {
							$AmtwithGst = 0;
							$gst_amt 	= 0;
						} // not necessary to send auto id
						
						$mem_card_id 	= (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
						$auto_id 		= (empty($row['mem_card_id'])) ? $row['id'] : '';
						$emp_id 		= '';
					
						
						$html .= '<tr>
									<td align="center" style="padding:0.6%;">'.++$i.'</td>
									<td style="padding:0.6%;">'.$row['rec_no'].'</td>
									<td width="20%" style="padding:0.6%;">'.$row['name'].'</td>
									<td align="center" style="padding:0.6%;">'.$row['qty'].'</td>
									<td align="right" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
										$html .= '<td class="align-right" align="right">';
											if(!empty($recentAmt)) {										
												$before_gst 				= number_format($recentAmt - $gst_amt,2,'.','');
												$wedding_hall_bgst_total	= $wedding_hall_bgst_total + $before_gst;
												$html 						.= $before_gst;
											}else{
												$html 						.= '0.00';
											}
										$html .= '</td>
												  <td class="align-right" align="right">';
											if(!empty($row['gst'])) {									
												$wedding_hall_gst_total		= $wedding_hall_gst_total + $gst_amt;
												$html 						.= $gst_amt;
											}else{														
												$html 						.= '0.00';
											}
										$html .= '</td>';
									}						
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 5 : 3).'" align="right">Total S$</td>
								<td align="right" style="padding:0.6%;">'.number_format($wedding_hall_bgst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($wedding_hall_gst_total,2,'.','').'</td>
								<td align="right" style="padding:0.6%;">'.number_format($wedding_hall_amt,2,'.','').'</td>
							</tr>';
					
				} else {
					$html .= '<tr>
						<td colspan="'.(($general->gst > 0) ? 8 : 6).'" style="color: #0B6CCB;"><center>No Records Found!</center></td>
					</tr>';
				}
			$html .= '</tbody>
		</table>';
		
		$html .= '<br/>';
	}

	
	$before_gst_total 	= $abishegam_bgst_total + $archanai_bgst_total + $building_bgst_total + $donation_bgst_total + $festival_bgst_total + $gold_silver_bgst_total + $hall_booking_bgst_total + $homam_bgst_total + $kattalai_bgst_total + $madappalli_bgst_total + $mega_bgst_total + $member_subscripe_bgst_total +$membership_bgst_total + $card_bgst_total + $outdoor_bgst_total + $other_bgst_total + $prasadam_bgst_total + $temple_bgst_total + $temple_shop_bgst_total + $ubayam_bgst_total + $wedding_hall_bgst_total;
	
	$gst_total 	= $abishegam_gst_total + $archanai_gst_total + $building_gst_total + $donation_gst_total + $festival_gst_total + $gold_silver_gst_total + $hall_booking_gst_total + $homam_gst_total + $kattalai_gst_total + $madappalli_gst_total + $mega_gst_total + $member_subscripe_gst_total + $membership_gst_total + $card_gst_total + $outdoor_gst_total + $other_gst_total + $prasadam_gst_total + $temple_gst_total + $temple_shop_gst_total + $ubayam_gst_total + $wedding_hall_gst_total;
	
	$total_amt 	= $abishegam_amt + $archanai_amt + $building_fund_amt + $donation_amt + $festival_amt + $gold_silver_amt + $hall_booking_amt + $homam_amt + $kattalai_amt + $madappalli_amt + $mega_amt + $member_subscripe_amt + $membership_amt + $card_topup_amt + $outdoor_amt + $other_amt + $prasadam_amt + $temple_amt + $temple_shop_amt + $ubayam_amt + $wedding_hall_amt;
	
	$html .= '
	<table style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" border="1" cellpadding="5" cellspacing="0">
		<tr>
			<td width="7%" align="center" style="padding:1%;">&nbsp;</td>
			<td width="16.5%" style="padding:1%;">&nbsp;</td>
			<td width="20%" style="padding:1%;">&nbsp;</td>
			<td width="22.1%" colspan="2" align="right" style="padding:1%;">&nbsp;</td>';
			if($before_gst_total > 0){
			$html .= '<th width="14.1%" style="padding:1%;" align="center">Before GST</th>
					<th width="6.8%" style="padding:1%;"align="center">GST</th>';
			}
			$html .= '<th width="13.5%" style="padding:1%;" align="right">Amount</th>
		</tr>
		<tr>
			<td width="7%" align="center" style="padding:1%;">&nbsp;</td>
			<td width="16.5%" style="padding:1%;">&nbsp;</td>
			<td width="20%" style="padding:1%;">&nbsp;</td>
			<td width="22.1%" colspan="2" style="padding:1%;" align="right">Total</td>';
			if($before_gst_total > 0){
				$html .= '<td width="14.1%" align="right" style="padding:1%;">'.number_format($before_gst_total,2,'.','').'</td><td width="6.8%" align="right" style="padding:1%;">'.number_format($gst_total,2,'.','').'</td>';
			}
	$html .= '<td width="13.5%" style="padding:0.6%;border:1px solid #000;" align="right">'.number_format($total_amt,2,'.','').'</td>
		</tr>';
		foreach($data['mode'] as $key=>$value) { 
			$paidAmount = $this->monthly_model->get_total_paid_amt_by_type($value->id,$start_date,$end_date);
			if($value->payment_mode == 'cash') { 
				$refundAmt = $this->monthly_model->get_refund_amount($start_date,$end_date);
			} else { 
				$refundAmt = '0.00';
			}
			$html .= '<tr> 
						<td width="7%" align="center" style="padding:1%;">&nbsp;</td>
						<td width="16%" style="padding:1%;">&nbsp;</td>
						<td width="20%" style="padding:1%;">&nbsp;</td>
						<td width="20%"  colspan="2" align="right" style="padding:0.6%;border:1px solid #000;">'.ucfirst($value->name).' S$</td>';
						if($before_gst_total > 0){
						 $html .= '<td align="right" colspan="2" style="padding:1%;border-left:0px;">&nbsp;</td>';
						}
			$html .= '<td align="right" style="padding:0.6%;border:1px solid #000;">'.((!empty($paidAmount->amount)) ? (($value->payment_mode == 'cash') ? number_format($paidAmount->amount - $refundAmt,2,'.','') :  $paidAmount->amount ) : '0.00').'</td>
					</tr>';
		 }
	$html .= '</table>
</div>';
//echo "<pre>"; print_r($chartamout); echo "</pre>";  
$servicess 	= service_type_name(); 
$label 		= '';
$dataval 	= '';

if($chartamout){
	$barchart_label	= array();
	$barchart_data	= array();
	foreach($chartamout as $key => $amount){
		if(empty($label)){
			$label = "'".$servicess[$key]."'";
		}else{
			$label .= ",'".$servicess[$key]."'";
		}
		
		if(empty($dataval)){
			$dataval = "'".number_format($amount,2,".","")."'";
		}else{
			$dataval .= ",'".number_format($amount,2,".","")."'";
		}
	}		
}
?>
<div id="htmldata"><?php echo $html; ?></div>
<script type="text/javascript" src="<?php echo base_url().'assets/js/'; ?>library/jquery-1.11.1.min.js"></script>
<script src="<?php echo base_url().'assets/js/Chart.min.js'?>"></script>
<script type="text/javascript">
window.onload = function() {
var ctx = document.getElementById("chart-area").getContext('2d');
     Chart.defaults.global.defaultFontColor = "#ff0000";
     Chart.defaults.global.defaultFontSize = "14";
     Chart.defaults.global.defaultFontStyle = "bolder";
debugger;

var data= {
    labels: [<?php echo $label; ?>],
    datasets: [{
      backgroundColor: [
        "#ff4700",
        "#FFA07A",
        "#bc00bf",
        "#FA8072",
        "#E9967A",
        "#E74C3C",
        "#34495E",
        "#bf8400",
        "#148F77",
        "#dd0000",
        "#0093f4",
		"#B22222",
		'#FFD700',
		'#FFEFD5',
		'#FFE4B5',
		'#7CFC00',
		'#00FF7F',
		'#98FB98',
		'#808000',
		'#00FFFF',
		'#008B8B'       
      ],
      //label: '',
      data: [<?php echo $dataval; ?>]
     
    }]
    
  }
var myChart = new Chart(ctx, {
  type: 'bar',
  data: data,
  options: {
      "hover": {
                    "animationDuration": 0
                },
                "animation": {
                  "duration": 1,
                    
                  "onComplete": function() {
                      
                    var chartInstance = this.chart,
                      ctx = chartInstance.ctx;
                    ctx.font = Chart.helpers.fontString(Chart.defaults.global.defaultFontSize, Chart.defaults.global.defaultFontColor, Chart.defaults.global.defaultFontStyle, Chart.defaults.global.defaultFontFamily, Chart.defaults.global.defaultFontWeight);
                    ctx.textAlign = 'center';
                    ctx.textBaseline = 'bottom';

                    this.data.datasets.forEach(function(dataset, i) {
                      var meta = chartInstance.controller.getDatasetMeta(i);
                      meta.data.forEach(function(bar, index) {
                        var data = "S$"+dataset.data[index];
//                          this.style.("font-weight","bolder");
                        ctx.fillText(data, bar._model.x, bar._model.y - 3);
                      });
					  
					  document.querySelector('#myImage').setAttribute('src', myChart.toBase64Image());
					   var value = $('#htmldata').html(); 				    
					   var url = '<?php echo base_url(); ?>monthly_report/generate_section_report';
					   $.post( url, { variable: value}, function( resdata ){
						  //main_image.attr('src', data);  
						  window.location.href = '<?php echo base_url().'monthly_report'; ?>';
					   });
                    });
                  }
                },
        tooltips: {
              "enabled": false
            },
          responsive: true,
         
          legend: false,
       fontColor: 'black',
         
		   scales: {
                  yAxes: [{
                    display: true,
                    gridLines: {
                      display: false
                    },
                    ticks: {
                      //max: Math.max(...data.datasets[0].data) + 50,
					  stepSize: <?php echo $stepSize; ?>,
                      display: true,
                      beginAtZero: true
                    }
                  }],
                  xAxes: [{
                    gridLines: {
                      display: true
                    },
                    ticks: {
                      beginAtZero: true
                    }
                  }]
               
                }
        }
});
};
</script>