<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->weekly_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;

$abishegam_amt 			= 0;
$archanai_amt 			= 0;
$building_fund_amt 		= 0;
$donation_amt 			= 0;
$festival_amt 			= 0;
$gold_silver_amt 		= 0;
$hall_booking_amt 		= 0;
$homam_amt 				= 0;
$kattalai_amt 			= 0;
$madappalli_amt 		= 0;
$mega_amt 				= 0;
$member_subscripe_amt 	= 0;
$membership_amt 		= 0;
$card_topup_amt 		= 0;
$outdoor_amt 			= 0;
$other_amt 				= 0;
$prasadam_amt 			= 0;
$temple_amt 			= 0;
$temple_shop_amt 		= 0;
$ubayam_amt 			= 0;
$wedding_hall_amt 		= 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;">
            Weekly 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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}						
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}						
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}						
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}						
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									} 							
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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->weekly_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);
						} else {
							$AmtwithGst = 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="center" style="padding:0.6%;">'.$row['price'].'</td>';
									if($general->gst > 0) {
									$html .= '<td align="right" style="padding:0.6%;">'.((!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : "0.00").'</td>
												<td align="right" style="padding:0.6%;">'.((!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : "0.00").'</td>';
									}						
					   $html .= '<td align="right" style="padding:0.6%;">'.number_format($recentAmt,2,'.','').'</td>
								</tr>';
					
					endforeach;
					$html .= '<tr>
								<td colspan="'.(($general->gst > 0) ? 7 : 5).'" align="right">Total S$</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/>';
	}
	
	$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 width="100%" style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:14px; width: 100%; border-collapse:collapse;" border="0" cellpadding="5" cellspacing="0">
		<tbody>
			<tr>
				<td width="40%">&nbsp;</td>
			
				<td valign="top" width="60%" align="right">
					<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 align="left" style="padding:0.6%;border:1px solid #000; width: 190px;">Total S$</td>
							<td style="padding:0.6%;border:1px solid #000; width: 160px;" align="right">'.number_format($total_amt,2,'.','').'</td>
						</tr>';
					   	foreach($data['mode'] as $key=>$value) { 
							$paidAmount = $this->weekly_model->get_total_paid_amt_by_type($value->id,$start_date,$end_date);
							if($value->payment_mode == 'cash') { 
								$refundAmt = $this->weekly_model->get_refund_amount($start_date,$end_date);
							} else { 
								$refundAmt = '0.00';
							}
							$html .= '<tr>                                                        
										<td align="left" style="padding:0.6%;border:1px solid #000; width: 190px;">'.ucfirst($value->name).' S$</td>
										<td align="right" style="padding:0.6%;border:1px solid #000; width: 160px;">'.((!empty($paidAmount->amount)) ? (($value->payment_mode == 'cash') ? number_format($paidAmount->amount - $refundAmt,2,'.','') :  $paidAmount->amount ) : '0.00').'</td>
									</tr>';
						 }
					$html .= '</table>
				 </td>
			</tr>
		</tbody>
	</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(); ?>weekly_report/generate_section_report';
					   $.post( url, { variable: value}, function( resdata ){
						  //main_image.attr('src', data);  
						  window.location.href = '<?php echo base_url().'weekly_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>