<?php

/* 
 * Author       : Jai K
 * Purpose      : The view page for Prasadam Billing
 * Created On   : 2016-08-13 13:19    
 */

$bp = $results[0];
?>
<?php header('Content-Type: text/html; charset=utf-8'); ?>
<aside class="right-side">
    <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">
                <?php #echo '<pre>'; print_r($bp);?>
                <div class="box box-danger">
                    <div class="box-body row" style="padding: 10px 15px 0px 15px;">
                        <div class="col-xs-12 tabs">
                            <div class="col-md-4 active autoload"><i class="fa fa-paper-plane-o"></i> <?php echo (($general->prefix == 1) ? $service['prefix'] : '') . $bp['bp_rec_no'].'&nbsp;'; ?><div id="curve"></div><div id="padder"></div></div>
                            <div class="col-md-4" data-target="#tab-2"><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 err-target"><h4><i class="fa fa-fire" style="font-size: 14px;"></i> Prasadam 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>Type</label><div class="lbl-value"><?php echo $bp['service_name']; ?></div>
                                        </div>
                                        
                                        <div class="form-group float-clear">
                                            <label>Date</label><div class="lbl-value"><?php echo date("d-m-Y", strtotime( $bp['bp_fn_date'] )); ?></div>
                                        </div>

                                        <div class="form-group float-clear">
                                            <label>Name 1</label><div class="lbl-value"><?php echo text($bp['bp_dev_name_1']); ?></div>
                                        </div>

                                        <div class="form-group float-clear">
                                            <label>Name 2</label><div class="lbl-value"><?php echo text($bp['bp_dev_name_2']); ?></div>
                                        </div>

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

                                        <div class="form-group float-clear">
                                            <label>Contact No</label><div class="lbl-value"><?php echo text($bp['bp_contact_no']); ?></div>
                                        </div>

                                        <!--<div class="form-group float-clear">
                                            <label>Address 1</label><div class="lbl-value"><?php echo text($bp['bp_address_1']); ?></div>
                                        </div>-->

                                    </div>

                                    <div class="col-md-6">                                    
                                        <div class="form-group">
                                            <label>Period</label><div class="lbl-value"><?php echo $bp['bp_period'] == "1" ? 'Morning' : 'Evening'; ?></div>
                                        </div>

                                        <div class="form-group float-clear">
                                            <label>Name 1 (T)</label><div class="lbl-value">
                                                <?php echo (!empty($bp['bp_tamil_name_1'])) ? '<span class="lang-tamil">' . $bp['bp_tamil_name_1'] . '</span>' : 'N/A';?>
                                            </div>
                                        </div>

                                        <div class="form-group float-clear">
                                            <label>Name 2 (T)</label><div class="lbl-value">
                                                <?php echo (!empty($bp['bp_tamil_name_2'])) ? '<span class="lang-tamil">' . $bp['bp_tamil_name_2'] . '</span>' : 'N/A';?>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label>Star 2</label><div class="lbl-value"><?php echo (!empty($bp['star_name_2'])) ? $bp['star_name_2'] . ' / ' . $bp['star_tamil_name2'] : 'N/A' ; ?></div>
                                        </div>

                                        <div class="form-group float-clear">
                                            <label>Email ID</label><div class="lbl-value"><?php echo text($bp['bp_email']); ?></div>
                                        </div>
                                        <!--<div class="form-group float-clear">
                                            <label>Address 2</label><div class="lbl-value"><?php echo text($bp['bp_address_2']); ?></div>
                                        </div>-->

                                    </div>

                                </div> <!-- blck-content -->    
                            </div> <!-- blck -->

                            <div class="col-xs-12 blck innr-table">
                                <div class="sub-title err-target" ><h4><i class="fa fa-fire" style="font-size: 14px;"></i> Items</h4><i class="ctrl opener fa fa-chevron-up opened" style="float: right; margin-top: -25px;"></i></div>
                                <div class="blck-content col-xs-12">
                                    <div class="col-xs-12">                                    
                                        <div class="col-md-3"> 
                                            <label>Deity</label>
                                        </div>

                                        <div class="col-md-3"> 
                                            <label>Prasadam</label>
                                        </div>

                                        <div class="col-md-1"> 
                                            <label>Quantity</label>
                                        </div>

                                        <div class="col-md-2"> 
                                            <label>Price</label>
                                        </div>
                                        <div class="col-md-2"> 
                                            <label>Sub Total</label>
                                        </div>
                                        
                                    </div>    

                                    <?php

                                        $items = !empty($items) ? $items : array('');
                                        foreach( $items as $ik => $item ) :
                                    ?>
                                            <div class="col-xs-12 row-details">    
                                                <div class="col-md-3">
                                                    <input type="text" class="form-control" value="<?php echo text($item['god_name']); ?>" disabled />
                                                </div>

                                                <div class="col-md-3">
                                                    <input type="text" class="form-control readonly" value="<?php echo $item['prasadam_name']; ?>"disabled />
                                                </div>

                                                <div class="col-md-1">                                    
                                                    <input type="text" class="form-control low-width readonly" placeholder="0"  style="min-width: 60px;" value="<?php echo $item['bpi_qty']; ?>" disabled />
                                                </div>

                                                <div class="col-md-2">                                    
                                                    <input type="text" class="form-control readonly" value="<?php echo $item['bpi_price']; ?>" disabled />
                                                </div>

                                                <div class="col-md-2">                                    
                                                    <input type="text" class="form-control readonly" value="<?php echo $item['bpi_sub_total']; ?>" disabled />
                                                </div>

                                                
                                            </div> <!-- col-xs-12 -->
                                    <?php endforeach; ?>

                                </div> <!-- blck-content -->


                            </div> <!-- blck -->

                            <div class="col-xs-12 blck">
                                <div class="sub-title err-target" ><h4><i class="fa fa-fire" style="font-size: 14px;"></i> Amount</h4><i class="ctrl opener fa fa-chevron-up opened" style="float: right; margin-top: -25px;"></i></div>
                                <div class="blck-content col-xs-12" style="min-height: 200px;">
                                    <div class="col-md-6">     
                                        <div class="form-group float-clear">
                                            <label>Amount</label><div class="lbl-value"><?php echo $bp['bp_amount']; ?></div>
                                        </div>

                                    </div>

                                    <div class="col-md-6">                                    
                                        <div class="form-group float-clear">
                                            <label>Description</label><div class="lbl-value"><?php echo text(nl2br($bp['bp_desc'])); ?></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">

                                <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->prasadam_model->total_paid_amount(15,$bp['id']); ?>
                                <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;">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>
                               <?php $refund_detail = $this->prasadam_model->get_refund_details_by_ids(15,$bp['service_id'],$bp['id']);?>
                                <!--<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>    
                                    <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 2 Payment types -->    

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


