<?php //header('Content-Type: text/html; charset=utf-8'); ?>
<style>
.submit_excel {
    background-image: url(./assets/images/file-icons/xlsx.png);
    border: 0px;
    background-color: #FFFFFF;
    color: transparent;
    /*float: left;*/
    margin: 5px 0 10px 20px;
    height: 25px;
    width: 25px;
}
.submit_pdf {
    background-image: url(./assets/images/file-icons/pdf.png);
    border: 0px;
    background-color: #FFFFFF;
    color: transparent;
    float: initial;
    margin: 5px 0 10px 0;
    height: 25px;
    width: 25px;
}
.print_chart {
    background-image: url(./assets/images/file-icons/chart.png);
    border: 0px;
    background-color: #FFFFFF;
    color: transparent;
    /*float: left;
    margin: 5px 0 10px 20px;*/
    height: 24px;
    width: 24px;
}
.cht-pie{
    width: 75%;
    margin: 0 auto;
    margin-top: 20px;
    margin-bottom: 60px;
    background: #f3f3f3;
    padding: 30px 30px;
    box-shadow: -1px 20px 7px -18px #717171;
}
</style>
<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">
                        <div class="cht-pie">
                            <canvas id="chart-area"></canvas>
                        </div>
                        <!-- Filtered Columns to send JS - Start -->
                        <input type="hidden" name="hidden_print" class="hidden_print" value="<?php echo (!empty($start_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) { ?>
                            <form name="get_data_search" action="<?php echo $form_action;?>" method="post" class="search_form validate_form">
                            <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-3">
                                        <div class="form-group">
                                            <label >Date Type</label>
                                            <div class="input-group">
                                                <div class="input-group-addon">
                                                    <i class="fa fa-soccer-ball-o"></i>
                                                </div>
                                                <select name="date_type" class="form-control select2 date_type">
                                                    <option value="1" <?php echo ($date_type == 1) ? 'selected' : '';?>>Function Date</option>
                                                    <option value="2" <?php echo ($date_type == 2) ? 'selected' : '';?>>Booked Date</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label >Start Date</label>
                                            <div class="input-group">
                                                
                                                <div class="input-group-addon">
                                                    <i class="fa fa-calendar"></i>
                                                </div>
                                                <input type="text" class="start_date" placeholder="DD-MM-YYYY" style="padding: 6px 12px;margin-right:5%;width:100%;" id="start_date" name="start_date" value="<?php echo (!empty($start_date)) ? $start_date : date('d-m-Y');?>" autocomplete="off" >
                                                
                                            </div>
                                        </div>
                                        
                                    </div>
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label >End Date</label>
                                            <div class="input-group">
                                                
                                                <div class="input-group-addon">
                                                    <i class="fa fa-calendar"></i>
                                                </div>
                                                <input type="text" class="end_date" placeholder="DD-MM-YYYY" style="padding: 6px 12px;margin-right:5%;width:100%;"  id="end_date" name="end_date" value="<?php echo (!empty($end_date)) ? $end_date : date('d-m-Y');?>" autocomplete="off" >
                                            </div>
                                        </div>
                                    </div>
                                    
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label >Type</label>
                                            <div class="input-group">
                                                <div class="input-group-addon">
                                                    <i class="fa fa-soccer-ball-o"></i>
                                                </div>
                                                <select name="type_id" class="form-control select2">
                                                    <option value="">Select Type</option>
                                                    <?php foreach($types as $key=>$row) {?>
                                                        <option value="<?php echo $row->id;?>" <?php echo ($row->id == $type_id) ? 'selected' : '';?>><?php echo $row->service_name;?></option>
                                                    <?php } ?>
                                                </select>
                                            </div>    
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-12">
                                    <div class="col-md-2">&nbsp;</div>
                                    <div class="col-md-8">
                                        <input type="submit" value="Get Data" name="submit" class="btn btn-danger btn-sm" style="background-color: #e33739; border-color: #e33739;" />
                                    &nbsp;&nbsp;
                                        <input type="submit" value="Print Data" name="submit" class="btn btn-primary btn-sm" />
                                    &nbsp;&nbsp;
                                        <input type="submit" value="Get Details Data" name="submit" class="btn btn-danger btn-sm" style="background-color: #e33739; border-color: #e33739;" />
                                   &nbsp;&nbsp;
                                        <input type="submit" value="Print Details Data" name="submit" class="btn btn-primary btn-sm" />&nbsp;&nbsp;
                                    
                                    	<input type="submit" name="submit" value="<?php echo $exceltype; ?>" class="submit_excel" title="Export Excel" />&nbsp;&nbsp;
                                    
                                    	<input type="submit" name="submit" value="<?php echo $pdftype; ?>" class="submit_pdf" title="Export PDF" />&nbsp;&nbsp;
                                    
                                    	<input type="submit" name="submit" value="Chart Data" class="print_chart" title="PDF Chart" />
                                    </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 -->
                                
                            </form>
                        <?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 $start_date;?></span>
                                    </div>
                                </div>
                                <div class="col-md-2">&nbsp;</div>
                            </div>
                        <?php } ?>
                    </div>
                    <div class="box-body table-responsive">
                        <?php if($submit_type == 'Get Data') { ?>
                            <table class="table table-bordered table-striped data_table filterTable" id="filterTable">
                                <thead>
                                    <tr>
                                        <th width="5%" class="align-center">S.No</th>
                                        <th class="align-center">Receipt No / Type</th>
                                        <th class="align-center">Name(s)</th>
                                        <th class="align-center">Tamil Name(s)</th>
                                        <th class="align-center">Star(s)</th>
                                        <th class="align-center">Deity</th>
                                        <th class="align-center">From Date</th>
                                        <th class="align-center">To Date</th>
                                        <th class="align-center">Booked Date</th>
                                        <th class="align-center">Day Type</th>
                                        <th class="align-center">Day Count</th>
                                        <th class="align-center">Total Days</th>
                                        <th width="10%" class="align-center">Multiple Dates</th>
                                        <th width="10%" class="align-center">Desc</th>
                                        <th class="align-center">Amount</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php 
										$i=0; 
										foreach($results as $key=>$value) { 
											$chartData[$value->service_name] += $value->bki_amount;
									?>
                                        <?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,',');
                                        } //echo "<pre>Data: "; print_r( $value ); die;
                                        ?>
                                        <?php if($count > 0) { ?>
                                            <tr>
                                                <td><?php echo ++$i;?></td>
                                                <td><?php echo ((($general->prefix == 1) ? $value->prefix : '') . $value->bk_rec_no) . ' / ' . text($value->service_name);?></td>
                                                
                                                <td><?php echo text($value->bk_name_1) . ( !empty( $value->bk_name_2 ) ? ' / '.$value->bk_name_2 : '' ) . ( !empty( $value->bk_name_3 ) ? ' / '.$value->bk_name_3 : '' ); ?></td>
                                                <td><?php echo ((!empty($value->bk_tamil_name_1)) ? '<span class="lang-tamil">'.$value->bk_tamil_name_1 .'</span>' : 'N/A'). ( !empty( $value->bk_tamil_name_2 ) ? ' / <span class="lang-tamil">'.$value->bk_tamil_name_2.'</span>' : '' ); ?></td>
                                                <td><?php echo text($value->star) . ( !empty( $value->star2 ) ? ' / '.$value->star2 : '' ) . ( !empty( $value->star3 ) ? ' / '.$value->star3 : '' ); ?></td>
                                                <td>
                                                    <?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><?php echo text(date('d-m-Y',strtotime($value->bki_from_date)));?></td>
                                                <td><?php echo text(date('d-m-Y',strtotime($value->bki_to_date)));?></td>
                                                <td><?php echo text(date('d-m-Y',strtotime($value->created_on)));?></td>
                                                <td><?php echo $value->day_type;?></td>
                                                <td align="center"><?php echo $count;?></td>
                                                <td align="center"><?php echo $value->bki_no_days;?></td>
                                                <td><?php echo $bki_multi_date;?></td>
                                                <td><?php echo $value->bk_desc;?></td>
                                                <td align="right"><?php echo $value->bki_amount;?></td>
                                            </tr>
                                        <?php } ?>
                                    <?php } ?>
                                </tbody>
                            </table>
                        <?php } elseif($submit_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 class="align-center">Receipt No</th>
                                        <th class="align-center">God Name</th>
                                        <th class="align-center">Name</th>
                                        <th class="align-center">Tamil Name(s)</th>
                                        <th class="align-center">Booked Date</th>
                                        <th class="align-center">From Date</th>
                                        <th class="align-center">To Date</th>
                                        <th class="align-center">Type</th>
                                        <th class="align-center">Day</th>
                                        <th class="align-center">Total weeks</th>
                                        <th width="10%" class="align-center">Total Days</th>
                                        <th class="align-center">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><?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><?php echo ++$ii;?></td>
                                                           <td><?php echo (($general->prefix == 1) ? $val->prefix : '' ) . $val->bk_rec_no;?></td>
                                                           <td><?php echo $god_names->deity;?></td>
                                                           <td><?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><?php echo (!empty($val->bk_tamil_name_1) ? '<span class="lang-tamil">' . ($val->bk_tamil_name_1) . '</span>' : 'N/A') . ( !empty( $val->bk_tamil_name_2 ) ? ' / <span class="lang-tamil">'.$val->bk_tamil_name_2 .'</span>' : '' ); ?></td>
                                                           <td><?php echo date('d-m-Y',strtotime($val->created_on));?></td>
                                                           <td><?php echo date('d-m-Y',strtotime($val->bki_from_date));?></td>
                                                           <td><?php echo date('d-m-Y',strtotime($val->bki_to_date));?></td>
                                                           <td><?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>
                                                           <?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"><?php echo $val->bki_week_day ;?></td>
                                                           <td align="center"><?php echo $val->bki_no_days ;?></td>
                                                           <td align="right"><?php echo $val->bki_amount ;?></td>
                                                        </tr>
                                                    <?php } ?>
                                               <?php } ?>
                                            <?php } ?>
                                       
                                        <?php } ?>
                                    <?php } else {?>
                                        <tr>
                                            <td colspan="13"><center>No Records Found!</center></td>
                                        </tr>
                                    <?php } ?>
                                    
                                    <?php if($no_record == 0) {?>
                                        <tr>
                                            <td colspan="13"><center>No Records Found!</center></td>
                                        </tr>
                                    <?php } ?>
                                </tbody>
                            </table>
                        <?php } ?>
                    </div><!-- /.box-body -->
                </div><!-- /.box -->
            </div>
        </div>
    </section><!-- /.content -->
</aside><!-- /.right-side -->
<!-- ./wrapper -->
<div class="modal fade" id="pdfModal" role="dialog">
    <div class="modal-dialog modal-lg">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Kattalai Archanai Report PDF</h4>
        </div>
        <div class="modal-body">
         <iframe src="" class="pdf_iframe" width="850" height="600"></iframe>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
      
    </div>
</div>

<div class="modal fade" id="pdfchartModal" role="dialog">
    <div class="modal-dialog modal-lg">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Kattalai Archanai Chart Report PDF</h4>
        </div>
        <div class="modal-body">
         <iframe src="" class="pdf_iframe" width="850" height="600"></iframe>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
      
    </div>
</div>
<?php 
//echo "<pre>"; print_r($chartData); echo "</pre>"; exit;  
$label 		= '';
$dataval 	= '';

if($chartData){
	foreach($chartData as $key => $amount){
		if(empty($label)){
			$label = "'".$key."'";
		}else{
			$label .= ",'".$key."'";
		}
		
		if(empty($dataval)){
			$dataval = "'".number_format($amount,2,".","")."'";
		}else{
			$dataval .= ",'".number_format($amount,2,".","")."'";
		}
	}		
}
?>
<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');
var myChart = new Chart(ctx, {
  type: 'bar',
  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; ?>]
     
    }]
    
  },
  options: {
	  		tooltips: {
			  callbacks: {
					label: function(tooltipItem, data) {
						var value = data.datasets[0].data[tooltipItem.index];
						if(parseInt(value) >= 1000){
						   return 'S$' + value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
						} else {
						   return 'S$' + value;
						}
					}
			  } // end callbacks:
			}, //end tooltips
          responsive: true,
          legend: false,
		  scales: {
				yAxes: [{
					ticks: {
						beginAtZero: true
					}
				}]
			}
        }
});
};    

$(document).ready(function () {
     <?php if(isset($_SESSION['pdf_kattalai_archanai'])): ?>
        var srcval='<?php echo base_url().'uploads/kattalai_archanai_pdf/'.$_SESSION['pdf_kattalai_archanai_file']; ?>';
        $('.pdf_iframe').attr("src",srcval);
        $('#pdfModal').modal({"show":true}); 
      <?php 
	  $_SESSION['pdf_kattalai_archanai'] = '';
      unset($_SESSION['pdf_kattalai_archanai']);
      endif; ?> 
	  
	  <?php if(isset($_SESSION['pdf_chart'])): ?>
		var srcval='<?php echo base_url().'uploads/kattalai_archanai_pdf/'.$_SESSION['pdf_chart_file']; ?>';
		$('.pdf_iframe').attr("src",srcval);
		$('#pdfchartModal').modal({"show":true}); 
		<?php 
		$_SESSION['pdf_chart'] = '';
		unset($_SESSION['pdf_chart']);
		endif; 
		?>
	  
        $('.start_date').bootstrapMaterialDatePicker({ 
            time: false, 
            format: 'DD-MM-YYYY'
        }). on('change', function(e, date) {
            if($('.end_date').val() != '') {
                $('.end_date').val('');
                var cur_date = new Date(date);
                $('.end_date').val(getTwoDigits(cur_date.getDate()) + '-'+ getTwoDigits((cur_date.getMonth() + 1)) + '-'+ cur_date.getFullYear());
                change_todate(getTwoDigits(cur_date.getDate()) + '-'+ getTwoDigits((cur_date.getMonth() + 1)) + '-'+ cur_date.getFullYear());
            }
        });
        
        $('.end_date').bootstrapMaterialDatePicker({ 
            time: false, 
            format: 'DD-MM-YYYY'
        });
        
        var date = $('.start_date').val();
        change_todate(date);
    });
   
    function change_todate(date) {
       $('.end_date').bootstrapMaterialDatePicker('setMinDate', date);
    }
</script>