<aside class="right-side">
    <!-- Main content --> <?php #echo '<pre>';print_r($results);die;?>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                
                <!-- /.box -->
                
                <div class="box box-primary">
                    <!--<a class="print" style="float: right; cursor: pointer;"><img src="<?php echo base_url();?>assets/images/print.jpg" width="70px" height="35px;"/></a>-->
                    <input type="hidden" name="hidden_print" class="hidden_print" value="<?php echo (!empty($start_date)) ? 1 : 0 ;?>" />
                    
                    <div class="box-body table-responsive" style="clear:both;" id="print_data_container" >
                        <div>
                            <?php $general = get_general_setting();
                                if( !IS_KSK ) :
                                $basic = get_basic_setting();
                                $design = get_design_setting();
                            ?>
                            <iframe name="report" id="report" src="#" style="display:none;"></iframe>
                            <table border="0" width="1000" style="border-collapse:collapse;">
                                <tr>
                                    <td width="15%">&nbsp;</td>
                                   
                                    <td width="20%" style="border-right:1px solid #FFF;">
                                        <?php  if ((!empty($design->logo)) && (file_exists(FCPATH . DIR_COMPANY_LOGO . $design->logo))) {
                                            $image_url = base_url() . DIR_COMPANY_LOGO . $design->logo;
                                            $alt = $basic->temple_name;
                                        }
                                        else {
                                            $image_url = base_url() . 'assets/images/logo.png';
                                            $alt = 'Logo not found!';
                                        } ?>
                                        <div style="font-size: 14px;">
                                            <div><span style="float:left;width:155px;height:75px; margin:2px;"><img src="<?php echo $image_url;?>" alt="<?php echo $alt;?>" width="155" height="75" /></span></div>
                                        </div>
                                    </td>
                                    <td width="40%" align="center">
                                        <span style="float:left;font-family:Arial, Helvetica, sans-serif;font-weight:bold; margin-bottom: 20px;"><span style="font-size:24px;" class="lang-tamil"><?php echo $basic->tamil_name;?></span><br/><span style="font-size:16px;"><?php echo $basic->temple_name;?></span><br/><br/><span style="font-size:14px;"><?php echo nl2br($basic->address);?></span><br/><span style="font-size:14px;">Tel: <?php echo $basic->contact_no;?>&nbsp; Fax: <?php echo $basic->fax;?></span> <br/><span style="font-size:14px;">Email: <?php echo $basic->comp_email;?></span><br/><span style="font-size:14px;"><?php echo $basic->website_url;?></span><br/></span>
                                    </td>
                                    <td width="15%">&nbsp;</td>
                                    <td width="10%">&nbsp;</td>
                                </tr>
                                <tr>
                                    <td colspan="5" align="center" style="font-size:16px; font-weight:bold;">Kattalai Archanai Report</td>
                                
                                </tr>
                                <tr>
                                    <td colspan="2" align="center"><strong>Start Date : <?php echo date('d-m-Y',strtotime($start_date));?></strong></td>
                                    <td>&nbsp;</td>
                                    <td colspan="2" align="left"><strong>End Date : <?php echo date('d-m-Y',strtotime($end_date));?></strong></td>
                                </tr>
                                <?php else : ?>
                                    <table border="0" width="1000" style="border-collapse:collapse;">
                                        <tr>
                                            <td align="left"><strong>Start Date : <?php echo date('d-m-Y',strtotime($start_date));?></strong></td>
                                            <td>&nbsp;</td>
                                            <td align="right"><strong>End Date : <?php echo date('d-m-Y',strtotime($end_date));?></strong></td>
                                        </tr>
                                
                                <?php endif; ?>
                            </table>
                            <br/>
                            
                            <!-- Filtered Columns to send JS - Start -->
                            <div class="col-xs-12" style="margin-bottom:4%; display: none;">
                               <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>
                            <?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($submit_type == 'Get Data') { ?>   
                                <table width="1000" border="1" cellpadding="3" cellspacing="0" style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:14px; width: 1000px; border-collapse:collapse;" class="filterTable" id="filterTable">
                                    <thead>
                                        <tr>
                                            <th style="padding:1%; width: 5%;">S.No</th>
                                            <th style="padding:1%; width: 15%;">Receipt No / Type</th>
                                            <th style="padding:1%; width: 15%;">Name(s)</th>
                                            <th style="padding:1%; width: 14%;">Tamil Name(s)</th>
                                            <th style="padding:1%; width: 13%;">Star(s)</th>
                                            <th style="padding:1%; width: 15%;">Deity</th>
                                            <th style="padding:1%; width: 10%;">From Date</th>
                                            <th style="padding:1%; width: 10%;">To Date</th>
                                            <th style="padding:1%; width: 12%;">Booked Date</th>
                                            <th style="padding:1%; width: 10%;">Day Type</th>
                                            <th style="padding:1%; width: 10%;">Day Count</th>
                                            <th style="padding:1%; width: 10%;">Total Days</th>
                                            <th style="padding:1%; width: 12%;">Multiple Dates</th>
                                            <th style="padding:1%; width: 10%;">Desc</th>
                                            <th style="padding:1%; width: 12%;">Amount</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php $i=0; if(count($results) > 0) {  $total_amt = 0;?>
                                            <?php foreach($results as $key=>$value) { ?>
                                                
                                                <?php if($value->bki_day_type == 1) {
                                                       # $count = $value->bki_no_days;
                                                    #$bki_multi_date = $value->bki_dates;
                                                    $multiple_date = explode(',',$value->bki_dates);
                                                    $start = ($start_date != '') ?  $start_date : date('d-m-Y');
                                                    $end = ($end_date != '') ?  $end_date : date('d-m-Y');
                                                    $count = 0;
                                                    $bki_date = '';
                                                    foreach($multiple_date as $k=>$row) {
                                                        $bki_date .= ($start <= trim($row) && $end >= trim($row)) ? '<span style="color:#fff;background-color: #F44336;"><b>'. $row .'</b></span>,' : $row . ',';
                                                        if($start <= trim($row) && $end >= trim($row)) {
                                                            $count += 1;
                                                        }
                                                    }
                                                    $bki_multi_date = ' - ';
                                                } else if ($value->bki_day_type == 2) {
                                                    $multiple_date = explode(',',$value->bki_dates);
                                                    $start = ($start_date != '') ?  $start_date : date('d-m-Y');
                                                    $end = ($end_date != '') ?  $end_date : date('d-m-Y');
                                                    $count = 0;
                                                    $bki_date = '';
                                                    foreach($multiple_date as $k=>$row) {
                                                        $bki_date .= ($start <= trim($row) && $end >= trim($row)) ? '<span style="color:#fff;background-color: #F44336;"><b>'. $row .'</b></span>,' : $row . ',';
                                                        if($start <= trim($row) && $end >= trim($row)) {
                                                            if(date('w', strtotime($row)) == $value->bki_week_day) {
                                                                $count += 1;    
                                                            }
                                                        }
                                                    }
                                                    #$bki_multi_date = rtrim($bki_date,',');
                                                    $bki_multi_date = ' - ';
                                                } elseif($value->bki_day_type == 3) {
                                                    $multiple_date = explode(',',$value->bki_dates);
                                                    $start = ($start_date != '') ?  $start_date : date('d-m-Y');
                                                    $end = ($end_date != '') ?  $end_date : date('d-m-Y');
                                                    $count = 0;
                                                    $bki_date = '';
                                                    foreach($multiple_date as $k=>$row) {
                                                        $bki_date .= ($start <= trim($row) && $end >= trim($row)) ? '<span style="color:#fff;background-color: #F44336;"><b>'. $row .'</b></span>,' : $row . ',';
                                                        if($start <= trim($row) && $end >= trim($row)) {
                                                            $count += 1;
                                                        }
                                                    }
                                                    $bki_multi_date = rtrim($bki_date,',');
                                                } ?>
                                                <?php if($count > 0) {  $total_amt += $value->bki_amount; ?>
                                                    <tr>
                                                        <td align="center" style="padding:1%;"><?php echo ++$i;?></td>
                                                        <td style="padding:1%;"><?php echo ((($general->prefix == 1) ? $value->prefix : '') . $value->bk_rec_no) . ' / ' . text($value->service_name);?></td>
                                                        <td style="padding:1%;"><?php echo text($value->bk_name_1) . ( !empty( $value->bk_name_2 ) ? ' / '.$value->bk_name_2 : '' ); ?></td>
                                                        <td style="padding:1%;" class="lang-tamil"><?php echo text($value->bk_tamil_name_1) . ( !empty( $value->bk_tamil_name_2 ) ? ' / '.$value->bk_tamil_name_2 : '' ); ?></td>
                                                        <td style="padding:1%;"><?php echo text($value->star) . ( !empty( $value->star2 ) ? ' / '.$value->star2 : '' ); ?></td>
                                                        <td style="padding:1%;">
                                                            <?php if($value->bki_god_ids != '') {
                                                                $god_id = explode(',',$value->bki_god_ids);
                                                                $god_name = $this->kattalai_archanai_report_model->get_deity_name($god_id);
                                                                echo $god_name->deity;     
                                                            } ?>
                                                        </td>
                                                        <td style="padding:1%;"><?php echo text(date('d-m-Y',strtotime($value->bki_from_date)));?></td>
                                                        <td style="padding:1%;"><?php echo text(date('d-m-Y',strtotime($value->bki_to_date)));?></td>
                                                        <td style="padding:1%;"><?php echo text(date('d-m-Y',strtotime($value->created_on)));?></td>
                                                        <td style="padding:1%;"><?php echo $value->day_type;?></td>
                                                        <td style="padding:1%;" align="center"><?php echo $count;?></td>
                                                        <td style="padding:1%;" align="center"><?php echo $value->bki_no_days;?></td>
                                                        <td style="padding:1%;"><?php echo $bki_multi_date;?></td>
                                                        <td style="padding:1%;"><?php echo $value->bk_desc;?></td>
                                                        <td style="padding:1%;" align="right"><?php echo $value->bki_amount;?></td>
                                                    </tr>
                                                <?php } ?>
                                            <?php } ?>
                                        <?php } else {?>
                                            <!--<tr>
                                                <td colspan="15" style="color: #0B6CCB;"><center>No Records Found!</center></td>
                                            </tr>-->
                                        <?php } ?>
                                    </tbody>
                                    <tfoot>
                                        <?php if($total_amt > 0) { ?>
                                            <tr>
                                                <td style="padding:1%;" colspan="14" align="right"><b>Total Amount</b></td>
                                                <td style="padding:1%;" align="right"><b><?php echo number_format($total_amt,2,'.','');?></b></td>
                                            </tr>
                                        <?php } else {?>
                                           <tr>
                                                <td colspan="15" style="color: #0B6CCB;"><center>No Records Found!</center></td>
                                           </tr>
                                        <?php }  ?>
                                    </tfoot>
                                </table>
                            <?php } elseif($submit_type == 'Print Details Data') {?>
                                <table width="1000" border="1" cellpadding="3" cellspacing="0" style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:14px; width: 1000px; border-collapse:collapse;" class="filterTable" id="filterTable">
                                    <thead>
                                        <tr>
                                            <th style="padding:1%; width: 5%;">S.No</th>
                                            <th style="padding:1%; width: 10%;">Receipt No</th>
                                            <th style="padding:1%; width: 15%;">God Name</th>
                                            <th style="padding:1%; width: 15%;">Name</th>
                                            <th style="padding:1%; width: 15%;">Tamil Name(s)</th>
                                            <th style="padding:1%; width: 10%;">Booked Date</th>
                                            <th style="padding:1%; width: 10%;">From Date</th>
                                            <th style="padding:1%; width: 10%;">To Date</th>
                                            <th style="padding:1%; width: 10%;">Type</th>
                                            <th style="padding:1%; width: 10%;">Day</th>
                                            <th style="padding:1%; width: 10%;">Total weeks</th>
                                            <th style="padding:1%; width: 10%;">Total Days</th>
                                            <th style="padding:1%; width: 10%;">Amount</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <?php $no_record = 0;
                                        if(count($god_details) > 0) {  $ii = 0;
                                        foreach($god_details as $k => $row) {
                                            $count = 0;
                                           foreach($row as $i => $td) {   
                                                foreach($td as $index=> $val) {  #echo '<pre>';print_r($val);
                                               
                                                    if($val->bki_day_type == 1) {
                                                        #$count = $val->bki_no_days;
                                                        #$bki_multi_date = $value->bki_dates;
                                                        $multiple_date = explode(',',$val->bki_dates);
                                                        $start = ($start_date != '') ?  $start_date : date('d-m-Y');
                                                        $end = ($end_date != '') ?  $end_date : date('d-m-Y');
                                                        #$count = 0;
                                                        $bki_date = '';
                                                        foreach($multiple_date as $ki=>$Row) {
                                                            $bki_date .= ($start <= trim($Row) && $end >= trim($Row)) ? '<span style="color:#fff;background-color: #F44336;"><b>'. $Row .'</b></span>,' : $Row . ',';
                                                            if($start <= trim($Row) && $end >= trim($Row)) {
                                                                $count += 1;
                                                            }
                                                        }
                                                        $bki_multi_date = ' - ';
                                                    } else if ($val->bki_day_type == 2) {
                                                        $multiple_date = explode(',',$val->bki_dates);
                                                        $start = ($start_date != '') ?  $start_date : date('d-m-Y');
                                                        $end = ($end_date != '') ?  $end_date : date('d-m-Y');
                                                        #$count = 0;
                                                        $bki_date = '';
                                                        foreach($multiple_date as $ki=>$Row) {
                                                            $bki_date .= ($start <= trim($Row) && $end >= trim($Row)) ? '<span style="color:#fff;background-color: #F44336;"><b>'. $Row .'</b></span>,' : $Row . ',';
                                                            if($start <= trim($Row) && $end >= trim($Row)) {
                                                                if(date('w', strtotime($Row)) == $val->bki_week_day) {
                                                                    $count += 1;    
                                                                }
                                                            }
                                                        }
                                                        #$bki_multi_date = rtrim($bki_date,',');
                                                        $bki_multi_date = ' - ';
                                                    } elseif($val->bki_day_type == 3) {
                                                        $multiple_date = explode(',',$val->bki_dates);
                                                        $start = ($start_date != '') ?  $start_date : date('d-m-Y');
                                                        $end = ($end_date != '') ?  $end_date : date('d-m-Y');
                                                        #$count = 0;
                                                        $bki_date = '';
                                                        foreach($multiple_date as $ki=>$Row) {
                                                            $bki_date .= ($start <= trim($Row) && $end >= trim($Row)) ? '<span style="color:#fff;background-color: #F44336;"><b>'. $Row .'</b></span>,' : $Row . ',';
                                                            if($start <= trim($Row) && $end >= trim($Row)) {
                                                                $count += 1;
                                                            }
                                                        }
                                                        $bki_multi_date = rtrim($bki_date,',');
                                                    }
                                                }
                                            }
                                        ?> 
                                        <?php if($count > 0) { ?>
                                            <tr>
                                                <td colspan="13" align="center"><b style="font-size: 18px;"><?php echo $row[0];?></b></td>
                                            </tr>
                                        <?php } ?>
                                        
                                        <?php unset($row[0]) ;
                                            
                                            
                                            foreach($row as $i => $td) {   
                                               foreach($td as $index=> $val) {  #echo '<pre>';print_r($val);
                                               
                                                    if($val->bki_day_type == 1) {
                                                        #$count = $val->bki_no_days;
                                                        #$bki_multi_date = $value->bki_dates;
                                                        $multiple_date = explode(',',$val->bki_dates);
                                                        $start = ($start_date != '') ?  $start_date : date('d-m-Y');
                                                        $end = ($end_date != '') ?  $end_date : date('d-m-Y');
                                                        $count = 0;
                                                        $bki_date = '';
                                                        foreach($multiple_date as $ki=>$Row) {
                                                            $bki_date .= ($start <= trim($Row) && $end >= trim($Row)) ? '<span style="color:#fff;background-color: #F44336;"><b>'. $Row .'</b></span>,' : $Row . ',';
                                                            if($start <= trim($Row) && $end >= trim($Row)) {
                                                                $count += 1;
                                                            }
                                                        }
                                                        $bki_multi_date = ' - ';
                                                    } else if ($val->bki_day_type == 2) {
                                                        $multiple_date = explode(',',$val->bki_dates);
                                                        $start = ($start_date != '') ?  $start_date : date('d-m-Y');
                                                        $end = ($end_date != '') ?  $end_date : date('d-m-Y');
                                                        $count = 0;
                                                        $bki_date = '';
                                                        foreach($multiple_date as $ki=>$Row) {
                                                            $bki_date .= ($start <= trim($Row) && $end >= trim($Row)) ? '<span style="color:#fff;background-color: #F44336;"><b>'. $Row .'</b></span>,' : $Row . ',';
                                                            if($start <= trim($Row) && $end >= trim($Row)) {
                                                                if(date('w', strtotime($Row)) == $val->bki_week_day) {
                                                                    $count += 1;    
                                                                }
                                                            }
                                                        }
                                                        #$bki_multi_date = rtrim($bki_date,',');
                                                        $bki_multi_date = ' - ';
                                                    } elseif($val->bki_day_type == 3) {
                                                        $multiple_date = explode(',',$val->bki_dates);
                                                        $start = ($start_date != '') ?  $start_date : date('d-m-Y');
                                                        $end = ($end_date != '') ?  $end_date : date('d-m-Y');
                                                        $count = 0;
                                                        $bki_date = '';
                                                        foreach($multiple_date as $ki=>$Row) {
                                                            $bki_date .= ($start <= trim($Row) && $end >= trim($Row)) ? '<span style="color:#fff;background-color: #F44336;"><b>'. $Row .'</b></span>,' : $Row . ',';
                                                            if($start <= trim($Row) && $end >= trim($Row)) {
                                                                $count += 1;
                                                            }
                                                        }
                                                        $bki_multi_date = rtrim($bki_date,',');
                                                    }
                                                
                                                   $god_names = $this->kattalai_archanai_report_model->getGodName($val->bki_god_ids);
                                            ?>  
                                                    <?php if($count > 0) { 
                                                        $no_record = 1;
                                                    ?>
                                                        <tr>
                                                           <td align="center" style="padding:1%;"><?php echo ++$ii;?></td>
                                                           <td style="padding:1%;"><?php echo (($general->prefix == 1) ? $val->prefix : '') . $val->bk_rec_no;?></td>
                                                           <td style="padding:1%;"><?php echo $god_names->deity;?></td>
                                                           <td style="padding:1%;"><?php echo ($val->bk_name_1  . ' - '. $val->star . ((!empty($val->bk_name_2)) ? '<br/>' .$val->bk_name_2 . ((!empty(bk_star_2)) ? ' - ' . $val->star2 : ''): '') );?></td>
                                                           <td style="padding:1%;" class="lang-tamil"><?php echo text($val->bk_tamil_name_1) . ( !empty( $val->bk_tamil_name_2 ) ? ' / '.$val->bk_tamil_name_2 : '' ); ?></td>
                                                           <td style="padding:1%;"><?php echo date('d-m-Y',strtotime($val->created_on));?></td>
                                                           <td style="padding:1%;"><?php echo date('d-m-Y',strtotime($val->bki_from_date));?></td>
                                                           <td style="padding:1%;"><?php echo date('d-m-Y',strtotime($val->bki_to_date));?></td>
                                                           <td style="padding:1%;"><?php if($val->bki_day_type == 1) { echo 'Daily'; } elseif($val->bki_day_type == 2) { echo 'Weekly'; } elseif( $val->bki_day_type == 3 ) { echo 'Multiple Date(s)'; }?></td>
                                                           <td style="padding:1%;">
                                                           <?php if($val->bki_day_type == 2) {
                                                                if($val->bki_week_day == 0) { echo 'Sunday'; } 
                                                                elseif($val->bki_week_day == 1) { echo 'Monday'; }
                                                                elseif($val->bki_week_day == 2) { echo 'Tuesday'; }
                                                                elseif($val->bki_week_day == 3) { echo 'Wednesday'; }
                                                                elseif($val->bki_week_day == 4) { echo 'Thursday'; }
                                                                elseif($val->bki_week_day == 5) { echo 'Friday'; }
                                                                elseif($val->bki_week_day == 6) { echo 'Saturday'; }
                                                           } else {
                                                               echo '';
                                                           }
                                                           ?>
                                                           </td>
                                                           <td align="center" style="padding:1%;"><?php echo $val->bki_week_day ;?></td>
                                                           <td align="center" style="padding:1%;" ><?php echo $val->bki_no_days ;?></td>
                                                           <td align="right" style="padding:1%;"><?php echo $val->bki_amount ;?></td>
                                                        </tr>
                                                    <?php } ?>
                                               <?php } ?>
                                            <?php } ?>
                                       
                                        <?php } ?>
                                    <?php } else {?>
                                        <tr>
                                            <td colspan="13" style="color: #0B6CCB;"><center>No Records Found!</center></td>
                                        </tr>
                                    <?php } ?>
                                    
				   
                                    <?php if($no_record == 0) {?>
                                        <tr>
                                            <td colspan="13" style="color: #0B6CCB;"><center>No Records Found!</center></td>
                                        </tr>
                                    <?php } ?>
					
                                    </tbody>
                                </table>
                            <?php } ?> 
                        </div>
                    </div>
                
                    
                </div><!-- /.box -->
            </div>
        </div>
    </section><!-- /.content -->
</aside><!-- /.right-side -->
<!-- ./wrapper -->
<?php if( !IS_KSK ) : ?>
<script type="text/javascript">
    window.onload = function() {
        print_layout();
    } 
    
    $(document).ready(function(){
        $('.print').click(function(){
            print_layout();
        });
    });
    
    function print_layout() {
        var body = $('#print_data_container').html();
        var newWin = document.getElementById('report').contentWindow;
        newWin.document.write(body);
        newWin.document.close(); //important!
        newWin.focus(); //IE fix
        newWin.print();
        window.location.href = '<?php echo base_url();?>kattalai_archanai_report';
    }

</script>
<?php endif;