<?php

/* 
 * Author       : Kowsalya K
 * Purpose      : The edit page for Membership Card Registration
 * Created On   : 2016-08-02   
 */
?>
<script type="text/javascript" src="<?php echo base_url();?>assets/js/billing/billing_membership_card.js"></script>
<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; ?> - Edit</h1>
            <div class="breadcrumb_container"><?php echo breadcrumb_links();?></div>
        </div>
    </section>
    <section class="content">
        <div class="row" id="main-content">
            <div class="col-xs-12">
                <form action="<?php echo $form_action;?>" method="post"  enctype="multipart/form-data" method="post" >
                    <input type="hidden" name="hidden_id" value="<?php echo $member->id;?>" />
                    <input type="hidden" name="service_type_id" value="<?php echo $member->type_id;?>" />  
                    <div class="box box-danger">
                        <div class="box-body">
                            <ul class="error_container"></ul>
                            <div class="col-xs-12">
                                <div class="col-md-6">&nbsp;</div>
                                
                                <div class="col-md-6">
                                    <div class="form-group float-clear" style="text-align: right;">
                                        <button class="btn btn-success"><a href="<?php echo base_url();?>billing_membership_card/add/12" style="color: #fff;"><i class="fa fa-arrow-circle-up" title="Go to Topup" style="color: #fff;"></i> Topup</a></button>
                                    </div>
                                </div>
                            </div>    
                                    
                            <div class="col-xs-12 blck err-target-wrapper">
                                <div class="sub-title err-target"><h4><i class="fa fa-fire" style="font-size: 14px;"></i> User Creation</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>Card No<span class="required">*</span></label>
                                            <input type="text" class="form-control req" name="card_no" placeholder="Card No" value="<?php echo $member->card_no;?>" />
                                        </div>

                                        <div class="form-group float-clear">
                                            <label>Name<span class="required">*</span></label>
                                            <input type="text" class="form-control req name" name="name" placeholder="Name" value="<?php echo $member->name;?>" />
                                        </div>
                                        
                                        <div class="form-group star_div">
                                            <label>Star</label>
                                            <div class="input-group">
                                                <select name="star" class="form-control select2 star">
                                                    <option value="">-- Select Star --</option>
                                                    <?php foreach($stars as $key=>$star) {?>
                                                        <option value="<?php echo $star->id;?>" <?php echo ($star->id == $member->star ) ? 'selected' : '';?>><?php echo $star->name . ' / ' . $star->tamil_name ;?></option>
                                                    <?php } ?>
                                                </select>
                                            </div>
                                        </div>

                                        <div class="form-group star_div_txt">
                                        </div>
                                        
                                        <div class="form-group float-clear">
                                            <label>Email Id</label>
                                            <div class="input-group">
                                                <input type="text" class="form-control email" name="email" value="<?php echo $member->email;?>" />
                                                <div class="input-group-addon"><i class="fa fa-envelope"></i></div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="col-md-6">
                                        <!--<div class="form-group float-clear">
                                            <label>Amount</label>
                                            <div class="input-group">
                                                <div class="input-group-addon">$</div>
                                                <input type="text" class="form-control float_value" name="amount" value="10.00" readonly value="<?php echo $member->amount;?>" />
                                            </div>
                                        </div>-->
                                        
                                        <div class="form-group float-clear">
                                            <label>Balance Amount</label>
                                            <div class="input-group">
                                                <div class="input-group-addon">$</div>
                                                <input type="text" class="form-control float_value" name="bal_amount" value="<?php echo $member->amount;?>" readonly />
                                            </div>
                                        </div>
                                        
                                        <div class="form-group float-clear">
                                            <label>Name (T)</label>
                                            <div class="input-group">
                                                <input type="text" class="form-control multi tamil-name input-tamil" name="tamil_name" placeholder="jkpH;bgah;" onclick="set_tamil_keypad(this);" value="<?php echo $member->tamil_name;?>" />
                                                <div class="input-group-addon"><i class="fa fa-keyboard-o"></i></div>
                                            </div>
                                        </div>
                                        
                                        <div class="form-group float-clear">
                                            <label>Contact No<span class="required">*</span></label>
                                            <div class="input-group">
                                                <input type="text" class="form-control req contact-no num-pad" name="contact_no" placeholder="Contact No" value="<?php echo $member->contact_no;?>" />
                                                <div class="input-group-addon"><i class="fa fa-phone"></i></div>
                                            </div>
                                        </div>
                                        
                                        <div class="form-group float-clear">
                                            <label>Address</label>
                                            <textarea class="form-control address" name="address"><?php echo $member->address;?></textarea>
                                        </div>
                                        
                                    </div>
                                    
                                </div> <!-- blck-content -->    
                            </div> <!-- blck -->
                            
                            <div class="col-xs-12 blck err-target-wrapper innr-table">
                                <div class="sub-title err-target" ><h4><i class="fa fa-fire" style="font-size: 14px;"></i> Add Members</h4><i class="ctrl opener fa fa-chevron-down" style="float: right; margin-top: -25px;"></i></div>
                                <div class="blck-content col-xs-12 blck2" style="display: none;">
                                    <div class="col-xs-12">                                    
                                        <div class="col-md-4"> 
                                            <label>Name<span class="required">*</span></label>
                                        </div>
                                        
                                        <div class="col-md-4"> 
                                            <label>Star<span class="required">*</span></label>
                                        </div>
                                        
                                        <div class="col-md-3"> 
                                            <label>Name (T)</label>
                                        </div>
                                        <div class="col-md-1"> 
                                            <label>&nbsp;</label>
                                        </div>
                                    </div>    
                                    
                                    <?php $length = count($member_list); ?>
                                    <?php foreach($member_list as $k=> $items){?>
                                       
                                        <div class="col-xs-12 row-details">
                                      <input type="hidden" name="mem_id[]" class="db-id" value="<?php echo $items->id; ?>" />
                                            <div class="col-md-4">
                                <input type="text" class="form-control low-width req" name="mem_name[]" style="min-width: 60px;" value="<?php echo $items->name;?>" />
                                            </div>

                                            <div class="col-md-4">
                                                <select name="mem_star[]" class="form-control select2 req star">
                                                    <option value="">-- Select Star --</option>
                                                    <?php foreach($stars as $key=>$star) {?>
                                                        <option value="<?php echo $star->id;?>" <?php echo ($star->id == $items->star) ? 'selected' : '';?>><?php echo $star->name . ' / ' . $star->tamil_name;?></option>
                                                    <?php } ?>
                                                </select>
                                            </div>
                                            
                                            <div class="col-md-3"> 
                            <input type="text" class="form-control low-width multi tamil-name input-tamil" name="mem_name_tamil[]" value="<?php echo $items->tamil_name;?>"  onclick="set_tamil_keypad(this);" />
                                            </div>
                                            
                                            <div class="col-md-1 ctrls">
                                                <?php  if( $k+1 == $length ) : ?>
                                                    <i class="fa fa-plus-circle add-btn"></i> 
                                                    <i class="fa fa-power-off rm-btn" style="color: #f00;"></i> 
                                                <?php else : ?>
                                                    <i class="fa fa-power-off rm-btn" style="color: #f00;"></i>
                                                <?php  endif; ?>
                                            </div>   
                                        </div> <!-- col-xs-12 -->
                                    <?php } ?>
									
									
									
									<?php if($length==0){ ?>
									
									
									<div class="col-xs-12 row-details">    
                                        <div class="col-md-4">
                                            <input type="text" class="form-control low-width req" name="mem_name[]" style="min-width: 60px;"/>
                                        </div>

                                        <div class="col-md-4">
                                            <select name="mem_star[]" class="form-control select2">
                                                <option value="">-- Select Star --</option>
                                                <?php foreach($stars as $key=>$star) {?>
                                                    <option value="<?php echo $star->id;?>"><?php echo $star->name . ' / ' . $star->tamil_name;?></option>
                                                <?php } ?>
                                            </select>
                                        </div>
                                        
                                        <div class="col-md-3"> 
                                            <input type="text" class="form-control low-width multi tamil-name input-tamil" name="mem_name_tamil[]" onclick="set_tamil_keypad(this);" />
                                        </div>
                                        
                                        <div class="col-md-1 ctrls">                                    
                                            <i class="fa fa-plus-circle add-btn"></i> 
                                            <i class="fa fa-power-off rm-btn" style="color: #f00;"></i>
                                        </div>    
                                    </div> 
									
									<?php } ?>
									
									
									
									
									
									
									
									
									
									
									
                                    
                                </div> <!-- blck-content -->
                            </div> <!-- blck -->
                        </div>
                        
                        <div class="box-footer form-actions float-clear member_edit" style="text-align: right; padding-right: 30px;">
                            <button class="btn btn-primary" type="reset"><i class="fa fa-trash"></i> Clear</button>
                            <button class="btn btn-danger" id="payment-btn"><i class="fa fa-undo"></i> Update</button>
                        </div>
                    </div><!-- /.box -->
                    
                    <!-- Payment types Modal -->
                    <div class="modal fade" id="ptypes-dialog" role="dialog">
                        <div class="modal-dialog">
                            <!-- Modal content-->
                            <div class="modal-content">
                                <div class="modal-header" style="background-color: #337AB7;">
                                    <h4 class="modal-title" style="color: #FFF;">Payment Details</h4>
                                </div>
                                <div class="modal-body col-xs-12">
                                    <div class="err-blck" style="margin-top: -20px;"></div>
                                    <div class="row" id="pay-amounts-box">

                                        <div class="col-md-6">                                    
                                            <div class="form-group float-clear">
                                                <label>Amount To Pay</label>
                                                <input type="text" class="form-control readonly" name="pay_amount" placeholder="0.00" readonly value="<?php echo $member->amount;?>" />
                                            </div>
                                        </div>

                                        <div class="col-md-6">                                    
                                            <div class="form-group float-clear">
                                                <label>Now Paying</label>
                                                <input type="text" class="form-control readonly" name="paid_amount" placeholder="0.00" value="<?php echo $member->amount;?>" readonly />
                                            </div>
                                        </div>

                                    </div>

                                    <div class="row" id="cheque-box" style="display: none;">
                                        <div class="col-xs-4">                                    
                                            <div class="form-group float-clear">
                                                <label>Bank Name</label>
                                                <input type="text" class="form-control input"  name="chq_bnk_name" placeholder="Bank Name" value=""/>
                                            </div>
                                        </div>
                
                                        <div class="col-xs-4">                                    
                                            <div class="form-group float-clear">
                                                <label>Acc No</label>
                                                <input type="text" class="form-control input"  name="chq_acc_no" placeholder="Acc No" value=""/>
                                            </div>
                                        </div>
                                        
                                        <div class="col-xs-4">                                    
                                            <div class="form-group float-clear">
                                                <label>Date</label>
                                                <input type="text" class="form-control input date-picker"  name="chq_date" placeholder="dd/mm/YYYY" value="<?php echo date('d-m-Y');?>"/>
                                            </div>
                                        </div>
                
                                    </div>                                    
                                    
                                    <div style="margin-top: 10px; border-top: 1px dotted #1ba; padding: 20px 0px;">
                                        <div class="row">
                                            <?php
                                                $step = 4;
                                                foreach( $payments as $k => $ptype ) :
                                                    $paidtype = $this->membership_card_model->get_paid_type($member->type_id,$member->id,$ptype->id);
                                                    echo '<div class="col-md-'. floor( 12 / $step ) .'">';
                                                    ?>
                                                        <div class="form-group float-clear blck-content ptype-box" id="ptype-box-<?php echo $ptype->slug; ?>" style="margin: 10px 10px;">
                                                            <div class="pay-box">
                                                                <?php if( !empty( $ptype->img_url ) && file_exists( DIR_PAY_TYPE . $ptype->img_url ) ) : ?><div id="pay-preview"><img src="<?php echo BASE_URL . DIR_PAY_TYPE . $ptype->img_url; ?>" /></div><?php endif; ?>
                                                                <label><?php echo $ptype->name; ?></label>
                                                            </div>
                                                            <input type="text" class="input pay-type amount num-pad" data-id="<?php echo $ptype->id; ?>" name="pay_type[<?php echo $ptype->id; ?>]" value="<?php echo ((!empty($paidtype)) && ($ptype->id == $paidtype->pay_type_id)) ?  $paidtype->pay_amount : '';?>" />
                                                        </div>
                                                    <?php
                                                    echo '</div>';

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

                                                endforeach;
                                            ?>
                                        </div>
                                    </div>
                                </div>

                                <div class="modal-footer" style="padding-right: 30px;">
                                    <button type="button" class="btn btn-primary cancel_popup" id="sbmt-cancel-btn" data-dismiss="modal"><i class="fa fa-chevron-left"></i> Go Back</button>
                                    <button type="submit" id="sbmt-btn" class="btn btn-danger" name="submit" value="Submit" ><i class="fa fa-floppy-o"></i> Submit</button>
                                </div>
                            </div>   <!-- Modal Content -->     
                        </div> 
                    </div> <!-- Payment Types Dialog -->
                    
                </form>
            </div><!-- /.col-xs-12 -->
        </div><!-- /.row -->
    <!-- End Modal -->
    </section><!-- /.content -->
</aside>