<?php

/* 
 * Author       : Jai K
 * Purpose      : The View page for Kattalai Archanai
 * Created On   : 2016-09-08 19:03
 */
$bk = $results[0];
?>
<?php header('Content-Type: text/html; charset=utf-8'); ?>
<aside class="right-side" id="kattalai">
    <section class="content-header">
        <div class="title_bar">
            <h1 class="major_txt_color"><a href="<?php echo get_bill_list_url(); ?>" class="list-btn"><i class="fa fa-list" title="Go to Listing"></i></a><?php echo $title; ?> - View</h1>
            <div class="breadcrumb_container"><?php echo breadcrumb_links();?></div>
        </div>
    </section>
    <?php $general = get_general_setting();?>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                
                <div class="box-body row" style="padding: 10px 15px 0px 15px;">
                        <div class="col-xs-12 tabs">
                            <div class="col-md-3 active autoload"><i class="fa fa-paper-plane-o"></i> <?php echo (($general->prefix == 1) ? $service['prefix'] : '') . $bk['bk_rec_no'].'&nbsp;'; ?><div id="curve"></div><div id="padder"></div></div>
                            <div class="col-md-3" data-target="#tab-2"><i class="fa fa-paper-plane-o"></i> Archanai's</div>
                            <div class="col-md-3" data-target="#tab-3"><i class="fa fa-paper-plane-o"></i> Naivedyam</div>
                            <div class="col-md-3" data-target="#tab-4"><i class="fa fa-paper-plane-o"></i> Payments</div>
                        </div>     
                        
                        
                        <div class="col-xs-12 tab view-form">
                            
                            <div class="col-xs-12 blck">
                                <div class="sub-title" ><h4><i class="fa fa-fire" style="font-size: 14px;"></i> Details</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">
                                    <div class="col-md-6">        
                                        <div class="form-group">
                                            <label>Archanai Type</label><div class="lbl-value"><?php echo $bk['service_name'];?></div>
                                        </div>
                                        
                                        <div class="form-group">
                                            <label>Name 1</label><div class="lbl-value"><?php echo text($bk['bk_name_1']);?></div>
                                        </div>
                                        
                                        <div class="form-group">
                                            <label>Name 2</label><div class="lbl-value"><?php echo text($bk['bk_name_2']);?></div>
                                        </div>

                                        <div class="form-group">
                                            <label>Name 3</label><div class="lbl-value"><?php echo text($bk['bk_name_3']);?></div>
                                        </div>

                                        <div class="form-group">
                                            <label>Contact No</label><div class="lbl-value"><?php echo text($bk['contact_no']);?></div>
                                        </div>
                                        
                                        <div class="form-group">
                                            <label>Star 1</label><div class="lbl-value"><?php echo (!empty($bk['star_name_1'])) ? $bk['star_name_1'] . ' / '. $bk['star_tamil_name1'] : 'N/A';?></div>
                                        </div>

                                        <div class="form-group">
                                            <label>Star 3</label><div class="lbl-value"><?php echo (!empty($bk['star_name_3'])) ? $bk['star_name_3'] . ' / '. $bk['star_tamil_name3'] : 'N/A';?></div>
                                        </div>
                                        
                                        <div class="form-group">
                                            <label>Begin Date (least)</label><div class="lbl-value" <?php echo strtotime( $bk['bk_begin_date'] ) < time() ? 'style="color: #f33;"' : ''; ?>><?php echo date("d M Y", strtotime( $bk['bk_begin_date'] ) );?></div>
                                        </div>
                                        
                                        <div class="form-group float-clear">
                                            <label>Description</label><div class="lbl-value"><?php echo !empty( $bk['bk_desc'] ) ? $bk['bk_desc'] : 'N/A';?></div>
                                        </div>
                                        
                                    </div>

                                    <div class="col-md-6">                                    
                                        <div class="form-group">
                                        <!-- Currently Disabled 
                                            <label>Booking Status</label><div class="lbl-value"><?php //echo $bk['bk_book_status'] == 2 ? '<b style="color: #f33;">Yes</b>' : 'No';?></div>
                                        -->
                                        </div>
                                        
                                        <div class="form-group">
                                            <label>Name 1 (T)</label><div class="lbl-value">
                                                <?php echo (!empty($bk['bk_tamil_name_1'])) ? '<span class="lang-tamil">' . $bk['bk_tamil_name_1'] . '</span>' : 'N/A';?>
                                            </div>
                                        </div>
                                        
                                        <div class="form-group">
                                            <label>Name 2 (T)</label><div class="lbl-value">
                                                <?php echo (!empty($bk['bk_tamil_name_2'])) ? '<span class="lang-tamil">' . $bk['bk_tamil_name_2'] . '</span>' : 'N/A';?>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label>Name 3 (T)</label><div class="lbl-value">
                                                <?php echo (!empty($bk['bk_tamil_name_3'])) ? '<span class="lang-tamil">' . $bk['bk_tamil_name_3'] . '</span>' : 'N/A';?>
                                            </div>
                                        </div>
                                        
                                        <div class="form-group">
                                            <label>Star 2</label><div class="lbl-value"><?php echo (!empty($bk['star_name_2'])) ? $bk['star_name_2'] . ' / '. $bk['star_tamil_name2'] : 'N/A';?></div>
                                        </div>
                                        
                                        <div class="form-group">
                                            <label>End Date (topmost)</label><div class="lbl-value"  <?php echo strtotime( $bk['bk_end_date'] ) < time() ? 'style="color: #f33;"' : ''; ?>><?php echo date("d M Y", strtotime( $bk['bk_end_date'] ) );?></div>
                                        </div>
                                        
                                        <div class="form-group">
                                            <label>Total Amount</label><div class="lbl-value"><?php echo number_format( $bk['bk_amount'], 2, '.', '');?></div>
                                        </div>
                                        
                                    </div>
                                    
                                </div> <!-- blck-content -->    
                            </div> <!-- blck -->
                            
                        </div> <!-- Tab 1 -->
                            
                            
                            
                        <!-- Tab 2 -->
                        <div class="col-xs-12 tab" id="tab-2">
                            <div class="resp-table tab-wrapper">
                               
                                <?php
                                    /*
                                     * Items
                                     */
                                    $total_no_days = $total_amt = 0;
                                    $style = 'padding: 0px 2px;';
                                    foreach( $items as $k => $item ) :
                                        $day_type = $item['bki_day_type'];
                                        $start_date = date("d-m-Y", strtotime( $item['bki_from_date'] ));
                                        $to_date = date("d-m-Y", strtotime( $item['bki_to_date'] ));

                                        $total_no_days  += $item['bki_no_days'];
                                        $total_amt      += $item['bki_amount']; 
                                
                                        $_stle = $k % 2 != 0 ? 'background: rgba(17, 187, 170, 0.06);' : '';
                                        $_stle .= 'height: 60px; overflow: overlay;';
                                
                                ?>
                                                            
                                        <div class="col-xs-12">
                                            <div class="col-md-2" style="<?php echo $style; ?>">                                    
                                                <div class="form-group">
                                                    <div class="lbl"><i class="fa fa-fire"></i>Type</div><div class="lbl-value" style="<?php echo $_stle; ?>">
                                                        <?php echo $day_type == '1' ? 'Daily' : ($day_type == '2' ? 'Weekly - <b style="font-size: 12px; color: #1ba;">'. $week[$item['bki_week_day']] .'</b>' : 'Multiple Date(s)'); ?>
                                                    </div>
                                                </div>
                                            </div>    
                                            <div class="col-md-3" style="<?php echo $style; ?>">                                    
                                                <div class="form-group">
                                                    <div class="lbl"><i class="fa fa-fire"></i>Deity(s)</div><div class="lbl-value"  style="<?php echo $_stle; ?>">
                                                        <?php echo $item['god_names']; ?>
                                                    </div>
                                                </div>
                                            </div>    
                                            <div class="col-md-3" style="<?php echo $style; ?>">                                    
                                                <div class="form-group">
                                                    <div class="lbl"><i class="fa fa-fire"></i>Date(s)</div><div class="lbl-value" style="<?php echo $_stle; ?>">
                                                        <?php echo $day_type == '3' ? $item['bki_dates'] : $start_date .'<b style="color: #999;"> to </b>'. $to_date; ?>
                                                    </div>
                                                </div>
                                            </div>    

                                            <div class="col-md-2" style="<?php echo $style; ?>">                                    
                                                <div class="form-group">
                                                    <div class="lbl"><i class="fa fa-fire"></i>No. of Days</div><div class="lbl-value" style="text-align: center; <?php echo $_stle; ?>">
                                                        <?php echo $item['bki_no_days']; ?>
                                                    </div>
                                                </div>
                                            </div>
                                            
                                            <div class="col-md-2" style="<?php echo $style; ?>">                                    
                                                <div class="form-group">
                                                    <div class="lbl"><i class="fa fa-fire"></i>Amount</div><div class="lbl-value" style="text-align: right; <?php echo $_stle; ?>">
                                                        <?php echo $item['bki_amount']; ?>
                                                    </div>
                                                </div>
                                            </div>    

                                        </div>    
                                        <?php
                                    endforeach;
                            ?>
                                
                                <div class="col-xs-12">
                                    <div class="col-md-8" style="<?php echo $style; ?>">                                    
                                        <div class="form-group">
                                            <div style="color: #999; text-align: right;"><i class="fa fa-rubee"></i>Total :</div>
                                        </div>
                                    </div>    
                                
                                    <div class="col-md-2" style="<?php echo $style; ?>">                                    
                                        <div class="form-group">
                                            <div class="lbl-value"  style="color: #1ba; text-align: center;"><?php echo $total_no_days; ?></div>
                                        </div>
                                    </div>    
                                
                                    <div class="col-md-2" style="<?php echo $style; ?>">                                    
                                        <div class="form-group">
                                            <div class="lbl-value"  style="color: #1ba; text-align: right;"><?php echo number_format( $total_amt, 2 , '.', ''); ?></div>
                                        </div>
                                    </div>    
                                </div>    
                            
                            </div> <!-- resp-table -->    
                        </div> <!-- tab 2 -->
                            
 						 <!-- Tab 3 -->
                        <div class="col-xs-12 tab" id="tab-3">
                        	<?php if(count($p_items) > 0) { ?>
                            <div class="col-xs-12">
                                <div class="col-md-3">                                    
                                    <div class="form-group">
                                        <div style="color: #000;">Period: <strong><?php echo ($p_items[0]->period == 1) ? "Morning" : "Evening"; ?></strong></div>
                                    </div> 
                                </div>   
                            </div>
                            <div class="resp-table tab-wrapper">                                
								<?php $total = 0; $style = 'padding: 0px 2px;';?>
                                <?php foreach($p_items as $key=> $prasadam) {
                                $_stle = $key % 2 != 0 ? 'background: rgba(17, 187, 170, 0.06);' : '';
                                $total += $prasadam->sub_total;
                                ?>
                                    <div class="col-xs-12">
                                        <div class="col-md-3" style="<?php echo $style; ?>">                                    
                                            <div class="form-group">
                                                <div class="lbl"><i class="fa fa-fire"></i>Deity</div><div class="lbl-value" style="<?php echo $_stle; ?>"><?php echo text($prasadam->god_name);?></div>
                                            </div>
                                        </div>    
                                        <div class="col-md-3" style="<?php echo $style; ?>">                                    
                                            <div class="form-group">
                                                <div class="lbl"><i class="fa fa-fire"></i>Naivedyam</div><div class="lbl-value"  style="<?php echo $_stle; ?>"><?php echo $prasadam->prasadam_name;?></div>
                                            </div>
                                        </div> 
                                        <div class="col-md-2" style="<?php echo $style; ?>">                                    
                                            <div class="form-group">
                                                <div class="lbl"><i class="fa fa-fire"></i>No. of Days</div><div class="lbl-value" style="text-align: center; <?php echo $_stle; ?>"><?php echo $prasadam->bkp_no_days;?></div>
                                            </div>
                                        </div>   
                                        <div class="col-md-1" style="<?php echo $style; ?>">                                    
                                            <div class="form-group">
                                                <div class="lbl"><i class="fa fa-fire"></i>Quantity</div><div class="lbl-value" style="text-align: right; <?php echo $_stle; ?>"><?php echo $prasadam->quantity;?></div>
                                            </div>
                                        </div>    
                                
                                        <div class="col-md-1" style="<?php echo $style; ?>">                                    
                                            <div class="form-group">
                                                <div class="lbl"><i class="fa fa-fire"></i>Price</div><div class="lbl-value" style="text-align: right; <?php echo $_stle; ?>"><?php echo $prasadam->price;?></div>
                                            </div>
                                        </div>    
                                
                                        <div class="col-md-2" style="<?php echo $style; ?>">                                    
                                            <div class="form-group">
                                                <div class="lbl"><i class="fa fa-fire"></i>Sub Total</div><div class="lbl-value" style="text-align: right; <?php echo $_stle; ?>"><?php echo $prasadam->sub_total;?></div>
                                            </div>
                                        </div>    
                                    </div>
                                <?php } ?>  
                                <div class="col-xs-12">
                                    <div class="col-md-10" style="<?php echo $style; ?>">                                    
                                        <div class="form-group">
                                            <div style="color: #999; text-align: right;"><i class="fa fa-rubee"></i>Total Amount :</div>
                                        </div>
                                    </div>    
                                    <div class="col-md-2" style="<?php echo $style; ?>">                                    
                                        <div class="form-group">
                                            <div class="lbl-value"  style="color: #1ba; text-align: right;"><?php echo inr_format( $total ); ?></div>
                                        </div>
                                    </div>    
                                </div> 
                            </div>
                            <?php }  ?>
                        </div> <!-- Prasadam Dialog -->
                            
                        <!-- Tab 4 -->
                        <div class="col-xs-12 tab" id="tab-4">
                            <div class="resp-table tab-wrapper">

                                <div style="margin-top: 10px; border-top: 1px dotted #1ba; padding: 20px 0px;">
                                    <div class="row">
                                        <?php
                                            $step = 4;
                                            foreach( $payments as $k => $pay ) :

                                                echo '<div class="col-md-'. floor( 12 / $step ) .'">';
                                                ?>
                                                    <div class="form-group float-clear blck-content ptype-box">
                                                        <label style="width: 100%; padding: 5px; margin-bottom: 30px; border-bottom: 1px dotted #1ba;"><?php echo $pay['name']; ?></label>
                                                        <div style="width: 60px; height: 60px; margin-top: 45px; position: absolute; left: 20px;"><img src="<?php echo base_url() . DIR_PAY_TYPE . $pay['img_url']; ?>"></div>
                                                        <div class="lbl-value" style="border-bottom: none; text-align: right;"><?php echo $pay['pay_amount']; ?></div>
                                                    </div>
                                                <?php
                                                echo '</div>';

                                                if( ($k+1) % $step == 0 ) :
                                                    echo '</div><div class="row">';
                                                endif;

                                            endforeach;
                                        ?>
                                    </div>
                                </div>
                                <?php $paid_amount = $this->kattalai_archanai_model->total_paid_amount($bk['type_id'],$bk['id']); ?>
                                <div class="col-xs-12">
                                    <div class="col-md-9" style="<?php echo $style; ?>">                                    
                                        <div class="form-group">
                                            <div style="color: #999; text-align: right;">Total Paid Amount :</div>
                                        </div>
                                    </div>    
                                    <div class="col-md-3" style="<?php echo $style; ?>">                                    
                                        <div class="form-group" style="padding-left: 15%;">
                                            <div class="lbl-value"  style="width: 100%; color: #1ba; text-align: right;"><?php echo $paid_amount->paidAmount; ?></div>
                                        </div>
                                    </div>    
                                </div>
                                
                                
                                <!--<div class="col-xs-12">
                                    <div class="col-md-6" style="<?php echo $style; ?>">                                    
                                        <div class="form-group">
                                            <div style="color: #999; text-align: right;">&nbsp;</div>
                                        </div>
                                    </div>
                                    <div class="col-md-3" style="<?php echo $style; ?>">                                    
                                        <div class="form-group">
                                            <div style="color: #999; text-align: right;">Refund Amount (From Cash) :</div>
                                        </div>
                                    </div>
                                    <?php $refund_detail = $this->kattalai_archanai_model->get_refund_details_by_ids($bk['type_id'],$bk['service_id'],$bk['id']);?>
                                    <div class="col-md-3" style="<?php echo $style; ?>">                                
                                        <div class="form-group" style="padding-left: 15%;">
                                            <div class="lbl-value"  style="width: 100%; color: #1ba; text-align: right;"><?php echo ($refund_detail->refund_amount != '') ? $refund_detail->refund_amount : '0.00'; ?></div>
                                        </div>
                                    </div>
                                </div>
                                
                                <div class="col-xs-12">
                                    <div class="col-md-6" style="<?php echo $style; ?>">                                    
                                        <div class="form-group">
                                            <div style="color: #999; text-align: right;">&nbsp;</div>
                                        </div>
                                    </div>
                                    <div class="col-md-3" style="<?php echo $style; ?>">                                    
                                        <div class="form-group">
                                            <div style="color: #999; text-align: right;">Final Amount :</div>
                                        </div>
                                    </div>    
                                    <div class="col-md-3" style="<?php echo $style; ?>">                                    
                                        <div class="form-group" style="padding-left: 15%;">
                                            <div class="lbl-value"  style="width: 100%; color: #1ba; text-align: right;"><?php echo (!empty($refund_detail->refund_amount)) ? number_format(($paid_amount->paidAmount - $refund_detail->refund_amount),2,'.','') : $paid_amount->paidAmount; ?></div>
                                        </div>
                                    </div>    
                                </div>-->
                                
                            </div> <!-- Tab - wrapper -->
                        </div> <!-- Tab 3 Payment types -->    

                </div><!-- /.box -->
                    
              
            </div><!-- /.col-xs-12 -->
        </div><!-- /.row -->
        
    </section><!-- /.content -->
</aside>