<aside class="right-side">
    <section class="content-header">
        <div class="title_bar">
            <h1 class="major_txt_color"><?php echo $title;?></h1>
            <?php if(!IS_KSK_CMS) { ?><div class="breadcrumb_container"><?php echo breadcrumb_links();?></div><?php } ?>
        </div>
    </section>
    <?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">
                        <form name="get_data_search" action="<?php echo $form_action;?>" method="post" class="search_form validate_form">
                        
                            <!-- Filtered Columns to send JS - Start -->
                            <input type="hidden" name="hidden_print" class="hidden_print" value="<?php echo (!empty($search_date)) ? 1 : 0 ;?>" />
                            <?php foreach($filters as $key=>$val) : ?>
                                <input type="hidden" name="hidden_filter_array[]" class="hidden_filter_array" value="<?php echo $val;?>" />
                            <?php endforeach;?>
                            <!-- Filtered Columns to send JS - End -->
                            
                        <?php if(!IS_KSK_CMS) { ?>
                            <input type="hidden" name="hidden_id" class="hidden_id" value="<?php echo (!empty($hidden_id)) ? $hidden_id : '';?>" />
                                <div class="col-xs-12">
                                    <div class="col-md-4">&nbsp;</div>
                                    <div class="col-md-6" style="margin-left: -125px;">
                                        <div class="form-group">
                                            <label style="padding-left: 80px; padding-top: 8px;">Date</label>
                                            <div class="input-group">
                                                <div class="input-group-addon">
                                                    <i class="fa fa-calendar"></i>
                                                </div>
                                                <input type="text" class="search_date date-picker" placeholder="DD-MM-YYYY" style="padding: 6px 12px;margin-right:5%;width:100%;"  id="search_date" name="search_date" value="<?php echo (!empty($search_date)) ? $search_date : date('d-m-Y');?>" autocomplete="off" >
                                                
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-2">&nbsp;</div>
                                </div>
                                <div class="col-xs-12">
                                    <div class="col-md-2">&nbsp;</div>
                                    <div class="col-md-2">
                                        <input type="submit" value="Get Summary Data" name="submit" class="btn btn-danger btn-sm" style="background-color: #e33739;
        border-color: #e33739;" />
                                    </div>
                                    <div class="col-md-2">
                                        <input type="submit" value="Print Summary Data" name="submit" class="btn btn-primary btn-sm" />
                                    </div>
                                    <div class="col-md-2">
                                        <input type="submit" value="Get Details Data" name="submit" class="btn btn-danger btn-sm" style="background-color: #e33739;
        border-color: #e33739;" />
                                    </div>
                                    <div class="col-md-2">
                                        <input type="submit" value="Print Details Data" name="submit" class="btn btn-primary btn-sm" />
                                    </div>
                                    <div class="col-md-2">&nbsp;</div>
                                </div>
                                
                                <!-- Filtered Columns to send JS - Start -->
                                <div class="col-xs-12" style="margin-bottom:4%;">
                                    <div class="col-xs-12 blck" style="margin-bottom: -35px;">
                                        <div class="sub-title" style="color:#0B45B3; background:#f3f3f3 !important;" ><h4><i class="fa fa-fire" style="font-size: 14px;"></i> Filter Columns</h4><i class="ctrl opener opened fa fa-chevron-up" style="float: right; margin-top: -25px;"></i></div>
                                        <div class="blck-content col-xs-12" style="border-bottom: 1px inset rgba(209, 216, 216, 0.6); background: rgba(3, 12, 11, 0.05); margin-top: -15px;">
                                            <div id="grpChkBox" class="grpChkBox">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- Filtered Columns to send JS - End -->
                            
                        <?php } else {?>
                            <div class="col-xs-12">
                                <div class="col-md-4">&nbsp;</div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <span style="padding-left: 116px; font-size: 16px;">Date :&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $search_date;?></span>
                                    </div>
                                </div>
                                <div class="col-md-2">&nbsp;</div>
                            </div>
                        <?php } ?>
                                
                        </form>
                    </div>
                    <div class="box-body table-responsive" style="clear:both;">
                        <div>
                            <h3 style="color: #0B45B3; font-size: 20px;"><?php echo $type;?></h3>
                        </div>
                        <div style="max-height: 410px; overflow-y: auto;">
                            <?php if($type == 'Get Summary Data') { ?>
                                <table class="table table-bordered table-striped filterTable" id="filterTable">
                                    <thead>
                                        <tr>
                                            <th width="5%" class="align-center">S.No</th>
                                            <th width="14%" class="align-center">Receipt No</th>
                                            <th width="22%" class="align-center">Name</th>
                                            <!--<th width="10%" class="align-center">Payment Type</th>-->
                                            <th width="10%" class="align-center">Quantity</th>
                                            <th width="12%" class="align-center">Unit Price</th>
                                            <?php if($general->gst > 0) { ?>
                                                <th width="13%" class="align-center">Before GST</th>
                                                <th width="13%" class="align-center">GST Amount</th>
                                            <?php } ?>
                                            <th width="15%" class="align-center">Total</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php $total_amt = 0; $search_date = (!empty($search_date)) ? $search_date : date('d-m-Y');
                                        if(count($results) > 0) { ?>
                                            <?php $i = 0;
                                            foreach( $results as $key => $row) :
                                                //Refund Amount
                                                $Refund = $this->daily_summary_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$search_date);
                                              
                                                if(!empty($Refund)) {
                                                    $recentAmt = $row['amount'] - $Refund;
                                                }
                                                else {
                                                   $recentAmt = $row['amount'];
                                                }
                                                
                                                $total_amt += $recentAmt;
                                                if(!empty($row['gst'])) {
                                                    $AmtwithGst = $recentAmt * ($row['gst'] / 100);
                                                } else {
                                                    $AmtwithGst = 0;
                                                }
                                                
                                            ?>
                                            <?php 
						/*
						$mem_card_id = (!empty($row['mem_card_id'])) ? $row['mem_card_id'] : '';
                                                $auto_id = (empty($row['mem_card_id'])) ? $row['id'] : '';
                                                $emp_id = ''; // not necessary to send auto id
                                                $paymentType = $this->daily_summary_model->get_payment_details($row['type_id'],$emp_id,$search_date,$mem_card_id);
                                                
                                                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 class="align-center"><?php echo ++$i;?></td>
                                                    <td><?php echo $row['rec_no']; ?></td>
                                                    <td width="25%"><?php echo $row['name']; ?></td>
                                                    <!--<td><?php echo $row['paid_type_name'];?></td>-->
                                                    <td class="align-center"><?php echo $row['qty'];?></td>
                                                    <td class="align-center"><?php echo $row['price'];?></td>
                                                    <?php if($general->gst > 0) { ?>
                                                        <td class="align-right"><?php echo (!empty($recentAmt)) ? number_format($recentAmt - $AmtwithGst,2,'.','') : '0.00';?></td>
                                                        <td class="align-right"><?php echo (!empty($row['gst'])) ? number_format($AmtwithGst,2,'.','') : '0.00';?></td>
                                                    <?php } ?>
                                                    <td class="align-right"><?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($type == 'Get Details Data') {?>
                                <table class="table table-bordered table-striped filterTable" id="filterTable">
                                    <thead>
                                        <tr>
                                            <th width="5%" class="align-center">S.No</th>
                                            <th width="14%" class="align-center">Receipt No</th>
                                            <th width="23%" class="align-center">Category Name</th>
                                            <th width="20%" class="align-center">Sub Category Name</th>
                                            <th width="15%" class="align-center">Payment Type</th>
                                            <th width="14%" class="align-center">Total</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php $total_amt = 0; $search_date = (!empty($search_date)) ? $search_date : date('d-m-Y');
                                        if(count($results) > 0) { ?>
                                            <?php $i = 0;
                                            foreach( $results as $key => $row) :
                                                //Refund Amount
                                                $Refund = $this->daily_summary_model->get_refund_amt_by_ids($row['type_id'],$row['service_id'],$row['id'],$search_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->daily_summary_model->get_payment_details($row['type_id'],$auto_id,$search_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']; }
                                                
                                                $tooltip = ($recentAmt == 0) ? $row['del_reason'] : '';
                                                
                                                ?>
                                                <tr data-toggle="tooltip" data-placement="auto" title="<?php echo $tooltip;?>">
                                                    <td class="align-center"><?php echo ++$i;?></td>
                                                    <td><?php echo $row['rec_no']; ?></td>
                                                    <td width="25%"><?php echo $row['cat_name']; ?></td>
                                                    <td><?php echo $row['name'];?></td>
                                                    <td><?php echo $payType;?></td>
                                                    <td class="align-right"><?php echo number_format($recentAmt,2,'.','');?></td>
                                                </tr>
                                            
                                            <?php endforeach; ?>
                                        <?php } else {?>
                                            <tr>
                                                <td colspan="7" style="color: #0B6CCB;"><center>No Records Found!</center></td>
                                            </tr>
                                        <?php } ?>
                                    </tbody>
                                </table>
                            <?php } ?>
                        </div>
                    </div><!-- /.box-body -->
                    
                    <div class="box-body table-responsive">
                        <div class="row">
                            <div class="right-col action-right-col">
                                <table class="table table-bordered table-striped">
                                <tbody>
                                    <tr>
                                        <td align="left">Total <?php echo ($general->gst > 0) ? '(with GST)' : '';?></td>
                                        <td><?php echo number_format($total_amt,2,'.','');?></td>
                                    </tr>
                                    <!--<tr>
                                        <td align="left">Refund Amount</td>
                                        <?php #$refundAmount = $this->daily_summary_model->get_refund_amount($search_date);?>
                                        <td><?php #echo $refundAmount;?></td>
                                    </tr>-->
                                    <?php foreach($mode as $key=>$value) { ?>
                                        <?php $paidAmount = $this->daily_summary_model->get_total_paid_amt_by_type($value->id,$search_date);?>
                                        <?php if($value->payment_mode == 'cash') { 
                                                $refundAmt = $this->daily_summary_model->get_refund_amount($search_date);
                                            } else { 
                                                $refundAmt = '0.00';
                                            }
                                        ?>
                                        <tr>
                                            <td align="left"><?php echo ucfirst($value->name);?></td>
                                            <td><?php echo (!empty($paidAmount->amount)) ? (($value->payment_mode == 'cash') ? number_format($paidAmount->amount - $refundAmt,2,'.','') :  $paidAmount->amount ) : '0.00';?></td>
                                        </tr>
                                    <?php } ?>
                                </tbody>
                            </table>
                            </div>
                        </div>
                    </div>
                    
                </div><!-- /.box -->
            </div>
        </div>
    </section><!-- /.content -->
</aside><!-- /.right-side -->
<!-- ./wrapper -->