<aside class="right-side">
<?php $general = get_general_setting(); ?>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <!-- /.box -->                
                <div class="box box-primary">
                    <div class="box-body table-responsive" style="clear:both;" id="print_data_container">
                            <table border="0" width="100%" style="border-collapse:collapse;">                          
                                <tr>
                                    <td align="left" width="49%"><strong>Start Date : <?php echo date('d-m-Y',strtotime($start_date));?></strong></td>
                                    <td width="2%"></td>
                                    <td align="right" width="49%"><strong>End Date : <?php echo date('d-m-Y',strtotime($end_date));?></strong></td>
                                </tr>
                            </table>
                            <br/>
                            <?php if($dataType == 'Print Summary Data' || $dataType == 'Pdf Summary Data') { ?>
                                <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:1%;">S.No</th>
                                            <th style="padding:1%;">Receipt No</th>
                                            <th style="padding:1%;">Name</th>
                                            <th style="padding:1%;">Quantity</th>
                                            <th style="padding:1%;">Unit Price</th>
											<?php if($general->gst > 0) { ?>
												<th  style="padding:1%;">Before GST</th>
												<th  style="padding:1%;">GST</th>
											<?php } ?>
                                            <th style="padding:1%;">Total <?php echo ($general->gst > 0) ? '(Incl. of GST)' : '';?></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php $total_amt = 0;
                                        $start_date = (!empty($start_date)) ? $start_date : date('d-m-Y');
                                        $add_days = 6;
                                        $d = date('d-m-Y',strtotime($start_date) + (24*3600*$add_days));
                                        $end_date = (!empty($end_date)) ? $end_date : $d;
                                        if(count($results) > 0) { ?>
                                            <?php $i = 0;
                                            foreach( $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'];
                                                }
                                                
                                                $total_amt += $recentAmt;
                                                
                                                if(!empty($row['gst'])) {
                                                    $AmtwithGst = (($recentAmt /107) * 100); //$recentAmt * ($row['gst'] / 100);
                                                } else {
                                                    $AmtwithGst = 0;
                                                }
                                            ?> 
                                                <tr>
                                                    <td align="center" style="padding:1%;"><?php echo ++$i;?></td>
                                                    <td style="padding:1%;"><?php echo $row['rec_no']; ?></td>
                                                    <td width="20%" style="padding:1%;"><?php echo $row['name']; ?></td>
                                                    <td align="center" style="padding:1%;"><?php echo $row['qty'];?></td>
                                                    <td align="center" style="padding:1%;"><?php echo $row['price'];?></td>  
													<?php if($general->gst > 0) { ?>
															<td align="right"><?php echo (!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : '0.00';?></td>
															<td align="right"><?php echo (!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : '0.00';?></td>
													<?php } ?>														
                                                    <td width="10%" align="right" style="padding:0.6%;"><?php echo number_format($recentAmt,2,'.','');?></td>
                                                </tr>
                                            
                                            <?php endforeach; ?>
                                        <?php } else {?>
                                            <tr>
                                                <td colspan="<?php echo ($general->gst > 0) ? 8 : 6;?>" style="color: #0B6CCB;"><center>No Records Found!</center></td>
                                            </tr>
                                        <?php } ?>
                                    </tbody>
                                </table>
                            <?php } else if($dataType == 'Print Details Data' || $dataType == 'Pdf Details Data') {?>
                                <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 width="5%" align="center" style="padding:1%;">S.No</th>
                                            <th width="14%" align="center" style="padding:1%;">Receipt No</th>
                                            <th width="23%" align="center" style="padding:1%;">Category Name</th>
                                            <th width="20%" align="center" style="padding:1%;">Sub Category Name</th>
                                            <th width="15%" align="center" style="padding:1%;">Payment Type</th>
                                            <th width="14%" align="center" style="padding:1%;">Total</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php $total_amt = 0;
                                        $start_date = (!empty($start_date)) ? $start_date : date('d-m-Y');
                                        $add_days = 6;
                                        $d = date('d-m-Y',strtotime($start_date) + (24*3600*$add_days));
                                        $end_date = (!empty($end_date)) ? $end_date : $d;
                                        if(count($results) > 0) { ?>
                                            <?php $i = 0; 
                                            foreach( $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'];
                                                }
                                                
                                                $total_amt += $recentAmt;
                                            ?>  
											<?php 
												$mem_card_id = (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
												$auto_id = (empty($row['mem_card_id'])) ? $row['id'] : '';
												$paymentType = $this->weekly_model->get_payment_details($row['type_id'],$auto_id,$start_date,$end_date,$mem_card_id);
											?>
                                                
											<?php 
                                                if((!empty($row['amount_type'])) && $row['amount_type'] == 2) {
                                                    $payType = '-';
                                                } elseif((!empty($row['amount_type'])) && $row['amount_type'] != 2){
                                                    $payType = $paymentType[0]['payment'];
                                                } else { 
                                                    $payType = $paymentType[0]['payment']; 
                                                }
                                            ?>
                                                
                                                <tr>
                                                    <td align="center" style="padding:1%;"><?php echo ++$i;?></td>
                                                    <td style="padding:1%;"><?php echo $row['rec_no']; ?></td>
                                                    <td width="25%" style="padding:1%;"><?php echo $row['cat_name']; ?></td>
                                                    <td style="padding:1%;"><?php echo $row['name'];?></td>
                                                    <td style="padding:1%;"><?php echo $payType;?></td>
                                                    <td align="right" style="padding:1%;"><?php echo number_format($recentAmt,2,'.','');?></td>
                                                </tr>
                                            
                                            <?php endforeach; ?>
                                        <?php } else {?>
                                            <tr>
                                                <td colspan="6" style="color: #0B6CCB;"><center>No Records Found!</center></td>
                                            </tr>
                                        <?php } ?>
                                    </tbody>
                                </table>
                            <?php } ?>
                            <br/>                            
                            <table width="100%" style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:18px; float: right; border-collapse:collapse;" border="0" cellpadding="5" cellspacing="0">
                                <tbody>
                                	<tr>
                                    	<td width="50%">&nbsp;</td>
                                    
                                    	<td valign="top" width="50%" align="right">
                                        	<table style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:17px; width: 100%; border-collapse:collapse;" border="1" cellpadding="5" cellspacing="0">
                                                <tr>
                                                    <td colspan="2" align="left" style="padding:1%;border:1px solid #000; width: 70%;">Total S$</td>
                                                    <td style="padding:1%;border:1px solid #000; width: 30%;" align="right"><?php echo number_format($total_amt,2,'.','');?></td>
                                                </tr>
                                                <?php foreach($mode as $key=>$value) { ?>
                                                    <?php $paidAmount = $this->weekly_model->get_total_paid_amt_by_type($value->id,$start_date,$end_date);?>
                                                    <?php if($value->payment_mode == 'cash') { 
                                                            $refundAmt = $this->weekly_model->get_refund_amount($start_date,$end_date);
                                                        } else { 
                                                            $refundAmt = '0.00';
                                                        }
                                                    ?>
                                                    <tr>                                                        
                                                        <td colspan="2" align="left" style="padding:1%;border:1px solid #000; width: 70%;"><?php echo ucfirst($value->name);?> S$</td>
                                                        <td align="right" style="padding:1%;border:1px solid #000; width: 30%;"><?php echo (!empty($paidAmount->amount)) ? (($value->payment_mode == 'cash') ? number_format($paidAmount->amount - $refundAmt,2,'.','') :  $paidAmount->amount ) : '0.00';?></td>
                                                    </tr>
                                                <?php } ?>
                                             </table>
                                         </td>
                                    </tr>
                                </tbody>
                            </table>
                            <div style="width: 100%; float: right;">
                                <div style="float: left; clear: both; width:33.3%;">
                                    <div>&nbsp;</div>
                                    <div>&nbsp;</div>
                                    <div>&nbsp;</div>
                                    <div><b style="font-size: 15px;">Verified By</b></div>
                                    <div>&nbsp;</div>
                                    <div>&nbsp;</div>
                                    <div>&nbsp;</div>
                                    <div>-----------------------------------------</div>
                               </div>
                               <div style="float: left; width:33.3%;">
                                    <div>&nbsp;</div>
                                    <div>&nbsp;</div>
                                    <div>&nbsp;</div>
                                    <div><b style="font-size: 15px;">Approved By</b></div>
                                    <div>&nbsp;</div>
                                    <div>&nbsp;</div>
                                    <div>&nbsp;</div>
                                    <div>-----------------------------------------</div>
                               </div>
                               <div style="float: left; width:33.3%;">
                                    <div>&nbsp;</div>
                                    <div>&nbsp;</div>
                                    <div>&nbsp;</div>
                                    <div><b style="font-size: 15px;">Confirmed By</b></div>
                                    <div>&nbsp;</div>
                                    <div>&nbsp;</div>
                                    <div>&nbsp;</div>
                                    <div>-----------------------------------------</div>
                               </div>
                           </div>
                            
                           <div style="clear:both;"></div>
                        </div>
                    </div>
                    
                </div><!-- /.box -->
            </div>
        </div>
    </section><!-- /.content -->
</aside><!-- /.right-side -->
<!-- ./wrapper -->