<?php

/* 
 * Author       : Kowsalya K
 * Purpose      : The view page for Donation Billing
 * Created On   : 2016-08-11
 */
?>
<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">
                <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) ? $donation->prefix : '') . $donation->receipt_no;?><div id="curve"></div><div id="padder"></div></div>
                            <?php if($donation->amount_type != 2) { ?><div class="col-md-4" data-target="#tab-2"><i class="fa fa-paper-plane-o"></i> Payments</div> <?php } ?>
                        </div>  
                        
                        <div class="col-xs-12 tab view-form">
                            <div class="col-md-6" style="margin-top: 15px;">        
                                <!--<div class="form-group">
                                    <label>Receipt No</label>
                                    <div class="lbl-value"><?php echo text($donation->receipt_no);?></div>
                                </div>-->
                                
                                <div class="form-group">
                                    <label>Type</label>
                                    <div class="lbl-value"><?php echo text($donation->service);?></div>
                                </div>
                            </div>
                            
                            <div class="col-xs-12 blck">
                                <div class="sub-title" ><h4><i class="fa fa-fire" style="font-size: 14px;"></i> Contact 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>Name</label>
                                            <div class="lbl-value"><?php echo text($donation->name);?></div>
                                        </div>

                                        <div class="form-group">
                                            <label>Contact No</label>
                                            <div class="lbl-value"><?php echo text($donation->contact_no);?></div>
                                        </div>
                                       
                                        <div class="form-group float-clear">
                                            <label>Email Id</label>
                                            <div class="lbl-value"><?php echo text($donation->email);?></div>
                                        </div>
                                    </div>
                                    
                                    <div class="col-md-6">        
                                        <div class="form-group">
                                            <label>Tamil Name</label>
                                            <div class="lbl-value">
                                                <?php echo (!empty($donation->tamil_name)) ? '<span class="lang-tamil">' . $donation->tamil_name . '</span>' : 'N/A';?>
                                            </div>
                                        </div>
                                        
                                        <div class="form-group float-clear">
                                            <label>Address</label>
                                            <div class="lbl-value"><?php echo text(nl2br($donation->address));?></div>
                                        </div>
                                    </div>
                                </div> <!-- blck-content -->    
                            </div> <!-- blck -->

                            <div class="col-xs-12 blck">
                                <div class="sub-title" ><h4><i class="fa fa-fire" style="font-size: 14px;"></i> Cost Details</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">
                                    <?php if($donation->amount_type != 3) { ?>
                                        <div class="col-md-6">     
                                            <div class="form-group float-clear">
                                                <label>Pledge Amount/Item</label>
                                                <div class="lbl-value"><?php echo ($donation->pledge_type == 1) ? 'Yes' : 'No';?></div>
                                            </div>

                                            <div class="form-group m-h30">
                                                <label class="leftcol">Pledge Type</label>
                                                <div class="lbl-value"><?php echo text($donation->amount_str);?></div>
                                            </div>
                                            
                                            <?php if($donation->amount_type == 1) { ?>
                                                <div class="form-group m-h30">
                                                    <label class="leftcol">Pledge Amount</label>
                                                    <div class="lbl-value"><?php echo text($donation->pledge_amount);?></div>
                                                </div>
                                            <?php } elseif($donation->amount_type == 2) { ?>
                                                <div class="form-group m-h30">
                                                    <label class="leftcol">Pledge Item</label>
                                                    <div class="lbl-value"><?php echo text($donation->pledge_amount . '&nbsp;&nbsp;&nbsp;&nbsp;<b>grams</b>');?></div>
                                                </div>
                                            <?php }  ?>

                                        </div>
                                        
                                        <div class="col-md-6">
                                            <div class="form-group m-h30">
                                                <label class="leftcol">Balance<?php echo ($donation->amount_type == 1) ? ' Amount' : ' Item (grams)';?></label>
                                                <div class="lbl-value">
                                                    <?php echo number_format(($transaction->pledge_amount - $balance->balance_amount),2,'.','');?>
                                                </div>
                                            </div>
                                            
                                            <div class="form-group m-h30">
                                                <label class="leftcol"><?php echo ($donation->amount_type == 1) ? ' Amount' : ' Item (grams)';?></label>
                                                <div class="lbl-value"><?php echo text($donation->d_amount);?></div>
                                            </div>
                                            
                                            <div class="form-group float-clear">
                                                <label>Description</label>
                                                <div class="lbl-value"><?php echo text(nl2br($donation->desc));?></div>
                                            </div>
                                        </div>
                                        
                                        <?php if(count($transaction_data) > 1 && $donation->pledge_type == 1) { ?>
                                            <div class="col-xs-12 transaction_history_container" style="margin-top: 30px;">
                                            <h4 class="heading_lbl">Transaction History</h4>
                                            <div id="retrieve-details" class="resp-table" style="display: block; margin:0px !important;">
                                                <?php foreach($transaction_data as $key=>$value) { ?>
                                                    <?php if($value->id != $transaction->id) { ?>
                                                        <div class="col-xs-12">
                                                            <div class="col-md-2" style="padding: 0px 2px;">
                                                                <div class="form-group">
                                                                    <div class="lbl"><i class="fa fa-fire"></i>S.No</div><div class="lbl-value" style="text-align: center;"><?php echo ++$key;?></div>
                                                                </div>
                                                            </div>
                                                            
                                                            <div class="col-md-2" style="padding: 0px 2px;">
                                                                <div class="form-group">
                                                                    <div class="lbl"><i class="fa fa-fire"></i>Date</div><div class="lbl-value" style="text-align: center;"><?php echo date('d M Y',strtotime($value->pledge_date));?></div>
                                                                </div>
                                                            </div>
                                                                
                                                            <div class="col-md-2" style="padding: 0px 2px;">
                                                                <div class="form-group">
                                                                    <div class="lbl"><i class="fa fa-fire"></i>Ref No</div><div class="lbl-value" style="text-align: center;"><?php echo $value->receipt_no;?></div>
                                                                </div>
                                                            </div>

                                                            <div class="col-md-3" style="padding: 0px 2px;">
                                                                <div class="form-group">
                                                                    <div class="lbl"><i class="fa fa-fire"></i>Amount<?php echo ($value->amount_type == 2) ? ' (grams)' : '';?></div><div class="lbl-value" style="text-align: right;"><?php echo $value->amount;?></div>
                                                                </div>
                                                            </div>
                                                            
                                                            <div class="col-md-1" style="padding: 0px 2px;">
                                                                <div class="form-group">&nbsp;</div>
                                                            </div>
                                                            
                                                            <div class="col-md-1" style="padding: 0px 2px;">
                                                                <div class="form-group">&nbsp;</div>
                                                            </div>
                                                        
                                                        </div>
                                                    <?php } ?>
                                                <?php } ?>
                                            </div>
                                        
                                        </div>
                                    <?php } ?>
                                    
                                    <?php } else {?>
                                        <div class="col-md-6">
                                            <div class="form-group m-h30">
                                                <label class="leftcol">Amount</label>
                                                <div class="lbl-value"><?php echo text($donation->d_amount);?></div>
                                            </div>
                                            
                                            <!--<div class="form-group float-clear">
                                                <label>Status</label>
                                                <div class="lbl-value"><?php echo text($donation->status_str);?></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($donation->desc));?></div>
                                            </div>
                                        </div>
                                    <?php } ?>
                                    
                                </div> <!-- blck-content -->    
                            </div> <!-- blck -->

                        </div> <!-- Tab 1 -->
                        <?php if($donation->amount_type != 2) { ?>
                            <!-- 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; $style = 'padding: 0px 2px;';
                                                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>
                                    
                                    <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>
                                    <!--<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->login_details_model->get_refund_details_by_ids($donation->type_id,$donation->service_id,$donation->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 2 Payment types -->
                        <?php } ?>
                        
                    </div> <!-- /.box body -->
                </div><!-- /.box -->
                
            </div><!-- /.col-xs-12 -->
        </div><!-- /.row -->
    </section><!-- /.content -->
</aside>

