<?php

/* 
 * Author       : Jai K
 * Purpose      : The View page for Billing - Wedding Hall Booking
 * Created On   : 2016-08-12 11:13    
 */
$bwh = $results[0];
?>
<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();    
        $part_pay_rec_no = $this->wedding_booking_model->get_part_pay_rec_no($bwh['id']);
        $rec_no = explode(',',$part_pay_rec_no->receipt_no);  $Receipt = '';
        foreach($rec_no as $no) {
            if(!empty($no)) {
                $Receipt .= ((($general->prefix == 1) ? $service['prefix'] : '') . trim($no));
                $Receipt .= ',';
            }
        }
        $Rec = rtrim($Receipt,',');
    ?>
    
    <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) ? $service['prefix'] : '') . $bwh['bwh_rec_no'].'&nbsp;' . '<span style="color: #999; font-size: 11px;" data-toggle="tooltip" title="Rec.No for Part Paid">' . ((!empty($Rec)) ? ' (' . $Rec . ')' : '') . '</span>'; ?><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">
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label>Type</label><div class="lbl-value"><?php echo $bwh['service_name'];?></div>
                                        </div>
                                    </div>

                                </div>    

                                <div class="col-xs-12 blck">
                                    <div class="sub-title" id="per-details-btn" ><h4><i class="fa fa-fire" style="font-size: 14px;"></i> Wedding 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 float-clear">
                                                <label>Groom Name</label><div class="lbl-value"><?php echo text($bwh['bwh_groom_name']);?></div>
                                            </div>

                                            <div class="form-group float-clear">
                                                <label>Wedding Date</label><div class="lbl-value"><?php echo date( "d M Y", strtotime( $bwh['bwh_from_date'] ) );?></div>
                                            </div>

                                            <div class="form-group float-clear">
                                                <label>Email ID</label><div class="lbl-value"><?php echo text($bwh['bwh_email']);?></div>
                                            </div>

                                        </div>

                                        <div class="col-md-6">                                    
                                            <div class="form-group float-clear">
                                                <label>Bride Name</label><div class="lbl-value"><?php echo text($bwh['bwh_bride_name']);?></div>
                                            </div>

                                            <?php
                                                $e1 = explode( " ", $bwh['bwh_from_date'] );
                                                $e2 = explode( " ", $bwh['bwh_to_date'] );
                                            ?>
                                            <div class="form-group float-clear" style="padding: 3px 0px 33px 0px;">
                                                <label class="leftcol">Time</label><div class="lbl-value"><?php echo ( $e1[1] != '00:00:00' ? date( "h:i A", strtotime( $bwh['bwh_from_date'] ) ) : 'Unknown' ) . ' &nbsp; &nbsp; &nbsp; <b>To</b> &nbsp; &nbsp; &nbsp; ' . ( $e2[1] != '00:00:00' ? date( "h:i A", strtotime( $bwh['bwh_to_date'] ) ) : 'Unknown' );?></div>
                                            </div>

                                            <div class="form-group">
                                                <label>Period</label><div class="lbl-value"><?php echo $bwh['bwh_period'] == "1" ? 'Morning' : 'Evening'; ?></div>
                                            </div>

                                            <div class="form-group float-clear">
                                                <label>Address</label><div class="lbl-value"><?php echo text(nl2br($bwh['bwh_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> Document 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( $bwh['bwh_groom_proof'] == "1" ) :
                                        ?>
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label for="proof_1"><input type="checkbox" checked disabled /> &nbsp;&nbsp;Groom ID Proof</label> 
                                            </div>
                                        </div>
                                        <?php endif; if( $bwh['bwh_bride_proof'] == "1" ) : ?>
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label for="proof_2"><input type="checkbox" checked disabled /> &nbsp;&nbsp;Bride ID Proof</label> 
                                            </div>
                                        </div>
                                        <?php endif; if( $bwh['bwh_invitation_proof'] == "1" ) : ?>
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label for="proof_3"><input type="checkbox" checked disabled /> &nbsp;&nbsp;Wedding Invitation</label> 
                                            </div>
                                        </div>
                                        <?php endif; ?>
                                    </div>
                                </div> <!-- Doc. details -->    


                                <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 fa fa-chevron-up opened" style="float: right; margin-top: -25px;"></i></div>
                                    <div class="blck-content col-xs-12">
                                        <div class="col-md-6">     
                                            <div class="form-group float-clear">
                                                <label>Contact Name</label><div class="lbl-value"><?php echo text($bwh['bwh_contact_name']); ?></div>
                                            </div>
                                        </div>

                                        <div class="col-md-6">     
                                            <div class="form-group float-clear">
                                                <label>Contact No</label><div class="lbl-value"><?php echo text($bwh['bwh_contact_no']); ?></div>
                                            </div>
                                        </div>
                                    </div>
                                </div> <!-- Contact details --> 
                                
                                
                                <div class="col-xs-12 blck innr-table">
                                <div class="sub-title" ><h4><i class="fa fa-fire" style="font-size: 14px;"></i> Additionl Payment 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                                    
									$items = !empty($additional_payments) ? $additional_payments : '';
									$items_cnt = is_array($items) ? count($items) : 0;
									if(!empty($items)){
									foreach( $items as $ik => $item ) :
								?>                                
                                   <div class="col-md-6"> 
                                        <div class="form-group float-clear">
                                            <label>Description</label>
                                            <div class="lbl-value"><?php echo ($item['bwh_remarks'])? $item['bwh_remarks'] : ''; ?></div>
                                        </div>
                                    </div>
                                    
                                    <div class="col-md-6">     
                                        <div class="form-group float-clear">
                                            <label>Amount</label>
                                            <div class="lbl-value"><?php echo ($item['bwh_additional_amount'])? $item['bwh_additional_amount'] : "0.00"; ?></div>
                                        </div>
                                    </div>
                                 	<!--<div class="col-md-1">
                                    	<a href="<?php echo base_url().'billing_wedding_booking/print_additionalamount/'.$item['id']?>"><button class="btn btn-primary">Print</button></a>
                                    </div>-->
                                <?php endforeach; ?>                                
                                <?php } ?> 
                                </div> <!-- blck-content -->                                                           
                            	</div>  


                                <div class="col-xs-12 blck">
                                    <div class="sub-title" ><h4><i class="fa fa-fire" style="font-size: 14px;"></i> Payment 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" style="min-height: 200px;">
                                        <div class="col-md-6">     
                                            <div class="form-group float-clear">
                                                <label>Total Amount</label><div class="lbl-value"><?php echo $bwh['bwh_amount']; ?></div>
                                            </div>

                                            <div class="form-group float-clear">
                                                <label>Deposit Amount</label><div class="lbl-value"><?php echo $bwh['bwh_paid_amount']; ?></div>
                                            </div>
                                            
                                            <!--<div class="form-group float-clear">
                                                <label>Total Additional Amount</label>
                                                <div class="lbl-value"><?php echo $bwh['bwh_additional_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($bwh['bwh_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;">
                                        <?php
                                            $step = 4;
                                            $pymnts = array();
                                            foreach( $payments as $k => $pay ) :
                                                $pymnts[date("Y-m-d", strtotime($pay['created_on']))][] = $pay;
                                            endforeach;
                                            
                                            foreach( $pymnts as $x => $pays ) :
                                                ?>
                                                    <div class="row" style="padding: 20px;">
                                                        <h4 style="color: #999; font-size: 12px; text-align: right; padding: 10px 20px; width: 120px; float: right;"><?php echo date("d M, Y", strtotime( $x )); ?></h4>
                                                        <div style="float: left; width: 100%; padding: 20px; border: 1px inset #f3f4f5; background: #fafdfd;">
                                                            <div class="row" >
                                                            <?php
                                                                foreach( $pays 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>
                                                <?php
                                            endforeach;
                                        ?>

                                        </div>
                                    </div>

                                    <div class="col-xs-12">
                                        <div class="col-md-2" style="<?php echo $style; ?>">                                    
                                            <div class="form-group">
                                                <div style="color: #999;"><i class="fa fa-rubee"></i>Balance 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: #f33; text-align: right;"><?php echo inr_format( $bwh['bwh_amount'] - $bwh['bwh_paid_amount'] ); ?></div>
                                            </div>
                                        </div>

                                        <div class="col-md-4" style="<?php echo $style; ?>">                                    
                                            <div class="form-group">
                                                <div style="color: #999; text-align: right;"><i class="fa fa-rubee"></i>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: 75%; color: #1ba; text-align: right;"><?php echo inr_format( $bwh['bwh_paid_amount'] ); ?></div>
                                            </div>
                                        </div>    
                                    </div>

                                </div> <!-- Tab - wrapper -->
                            </div> <!-- Tab 2 Payment types -->    
                            
                        </div> <!-- Box body -->
                        
                        
                        
                    </div><!-- /.box -->
                    
                    
                    
                    
                    
                
            </div><!-- /.col-xs-12 -->
        </div><!-- /.row -->
        
    </section><!-- /.content -->
</aside>


