<style type="text/css">
.fa-3x {
	font-size: 2em !important;
}
.report_view_th {
	background-color: #428bca;
	color: #fff !important;
	font-size: 14px;
}
.table-responsive td {
	font-size: 14px;
}
h4 {
	font-size: 13px;
}
</style>
<?php $this->load->view("common/header"); ?>
<!-- end: HEAD -->
<!-- end: CSS REQUIRED FOR THIS PAGE ONLY -->
<!-- end: HEAD -->
<!-- start: BODY -->
<body>
<!-- start: HEADER -->
<div class="navbar navbar-inverse navbar-fixed-top"> 
  <!-- start: TOP NAVIGATION CONTAINER -->
  <div class="container">
    <div class="navbar-header"> 
      <!-- start: RESPONSIVE MENU TOGGLER -->
      <button data-target=".navbar-collapse" data-toggle="collapse" class="navbar-toggle" type="button"> <span class="clip-list-2"></span> </button>
      <!-- end: RESPONSIVE MENU TOGGLER --> 
      <!-- start: LOGO -->
      <?php $this->load->view("common/logo"); ?>
      <!-- end: LOGO --> 
    </div>
    <div class="navbar-tools"> 
      <!-- start: TOP NAVIGATION MENU -->
      <?php $this->load->view("common/notifications.php"); ?>
      <!-- end: TOP NAVIGATION MENU --> 
    </div>
  </div>
  <!-- end: TOP NAVIGATION CONTAINER --> 
</div>
<!-- end: HEADER --> 
<!-- start: MAIN CONTAINER -->
<div class="main-container">
  <div class="navbar-content"> 
    <!-- start: SIDEBAR -->
    <?php $this->load->view("common/navigation"); ?>
    <!-- end: SIDEBAR --> 
  </div>
  <!-- start: PAGE -->
  <div class="main-content"> 
    <!-- end: SPANEL CONFIGURATION MODAL FORM -->
    <div class="container"> 
      <!-- start: PAGE HEADER -->
      <div class="row">
        <div class="col-sm-12"> 
          <!-- start: PAGE TITLE & BREADCRUMB -->
          <ol class="breadcrumb">
            <li> <a href="<?php echo base_url('dashboard'); ?>"> Dashboard </a> </li>
            <li> <a href="<?php echo base_url('loan'); ?>"> List Loan </a> </li>
            <li class="active"> View </li>
            <li class="search-box">
              <form class="sidebar-search">
                <div class="form-group">
                  <input type="text" placeholder="Start Searching...">
                  <button class="submit"> <i class="clip-search-3"></i> </button>
                </div>
              </form>
            </li>
          </ol>
          <div class="page-header">
            <?php  
							   $message = $this->session->flashdata('message');
							   if($message){ ?>
            <div class="alert alert-success">
              <button type="button" class="close" data-dismiss="alert">×</button>
              <?php echo $message ?> </div>
            <?php
                               }
							    ?>
          </div>
        </div>
      </div>
      <!-- end: PAGE HEADER --> 
      <!-- start: PAGE CONTENT 
                               <!-- start grid -->
      <div class="row">
        <div class="col-md-12"> 
          <!-- start: DYNAMIC TABLE PANEL -->
          <div class="panel panel-default">
            <div class="panel-heading"> <i class="fa fa-external-link-square"></i> Reference ID <?php echo $loan_id ?>
              <div class="panel-tools" style="top:2px;">
              <?php if($this->session->userdata('ss_group_id')==1&&$loan_details->is_closed==0){ ?>
                <button class="btn btn-blue dropdown-toggle" data-toggle="dropdown"> <i class="clip-list-5"></i> Modify  Loan </button>
                
                <?php }?>
                <ul class="dropdown-menu dropdown-light pull-right">
                  <li> <a id="" data-toggle="modal" href="<?php echo base_url("loan/loan_modify/$loan_id"); ?>"> <i class="fa fa-plus"></i> Modify this Loan Details </a> </li>
                </ul>
              </div>
              <!--panel-tools--> 
            </div>
            <!--panel-heading-->
            <div class="panel-body">
              <div class="well well-sm">
                <div class="col-xs-4 border-right">
                  <div class="col-xs-1"><i class="fa fa-2x fa-file-text-o  text-muted"></i></div>
                  <div class="col-xs-10">
                    <h4 class="">Reference ID : <?php echo $loan_details->loan_ref;?></h4>
                    <p>Created Date: <?php echo $loan_details->loan_creted_date;?></p>
                    <p>Loan Opening  : <?php echo $loan_details->loan_date;?></p>
                    <p>Loan Closing  : <?php echo $loan_details->loan_close_date;?></p>
                   <p>Total Holidays  : <?php echo $holiday_count;?> ( Include : <?php echo $include_holi_date;?>  Extend : <?php echo $addition_holi_date;?> )</p>                    
                   <p>Extended Closing  : <?php echo $extented_closing_date;?></p>
                     
                     
                  </div>
                  <div class="clearfix"></div>
                </div>
                <div class="col-xs-4 border-right">
                  <div class="col-xs-1"><i class="fa fa-2x fa-file-text-o padding010 text-muted"></i></div>
                  <div class="col-xs-10">
                    <h4 >Loan Capital  : Rs. <?php echo number_format($loan_details->loan_tot_amount, 2, '.', ',');?></h4>
                    <p>Payment Term  : <?php echo $loan_details->payment_term_name;?> </p>
                    <p>Interest : <?php echo $loan_details->loan_interest;?> %</p>
                    <p>Total Interest : Rs. <?php echo $loan_details->total_interest;?> </p>
                    <p>Total Loan Amount : Rs. <?php echo number_format($loan_details->loan_payable_total_amount, 2, '.', ',') ?></p>
                    <p>No. of Terms : <?php echo $loan_details->loan_no_of_terms;?></p>
                    <p ><strong>Term Amount : Rs. <?php echo number_format($loan_details->loan_term_amount, 2, '.', ',') ; ?></strong></p>
                  </div>
                  <div class="clearfix"></div>
                </div>
                <div class="col-xs-4 border-right">
                  <div class="col-xs-1"><i class="fa fa-2x fa-user padding010 text-muted"></i></div>
                  <div class="col-xs-10">
                    <h4 class=""><?php echo $customer_details['cus_name']; ?></h4>
                    <p><?php echo $customer_details['cus_address']; ?></p>
                    <p>Tel: <?php echo $customer_details['cus_mobile']; ?> &nbsp; <?php echo $customer_details['cus_mobile_2']; ?> <?php echo $customer_details['cus_home_phone']; ?> </p>
                    <p>Garanter: <?php echo $loan_details->garanter_name; ?></p>
                  </div>
                  <div class="clearfix"></div>
                </div>
                <div class="clearfix"></div>
              </div>
              
              <!--col-xs-4-->
              
              <div class="col-xs-5">
                <input name="loan_id" type="hidden" id="loan_id" value="<?php echo $loan_id ?>">
                <input type="hidden" id="sale_type" name="sale_type" value="sale">
                <div class="clearfix"></div>
              </div>
              <!--col-xs-4"-->
              <div class="clearfix"></div>
              <div class="clearfix"></div>
              
              <!--  start -->
              
              <div class="well well-sm">
                <div class="col-xs-4 border-right">
                  <div class="col-xs-1"><i class="fa fa-2x fa-money text-muted"></i></div>
                  <div class="col-xs-10">
                    <h4 class=""> Collected Loan </h4>
                    <?php					
					$presentage=($paid_summary['loan_received']/$loan_details->loan_payable_total_amount)*100;					
					?>
                    <!-- Cal paid %  start --> 
                    <!-- Cal paid % End -->
                    <p>Collected Capital: Rs. <?php echo number_format($paid_summary['capital_received'], 2, '.', ',');?></p>
                    <p>Collected Interest : Rs. <?php echo number_format($paid_summary['loan_interest_recived'], 2, '.', ',');?></p>
                    <p><strong>Loan Collected : Rs. <?php echo number_format($paid_summary['loan_received'], 2, '.', ','); ?> (<?php echo round($presentage,2);?> %)</strong></p>
                  </div>
                  <div class="clearfix"></div>
                </div>
                <div class="col-xs-4 border-right">
                  <div class="col-xs-1"><i class="fa fa-2x fa-money  text-muted"></i></div>
                  <div class="col-xs-10">
                    <h4 class=""> Collectable Loan</h4>
                    <p>Collectable Capital: Rs. <?php echo number_format($loan_details->loan_tot_amount-$paid_summary['capital_received'], 2, '.', ',');?></p>
                    <p>Collectable Interest : Rs. <?php echo number_format($loan_details->total_interest-$paid_summary['loan_interest_recived'], 2, '.', ',');?></p>
                    <p><strong>Loan Collectable  : Rs. <?php echo number_format($loan_details->loan_payable_total_amount-$paid_summary['loan_received'], 2, '.', ','); ?> (<?php echo round(100-$presentage,2);?> %)</strong> </p>
                  </div>
                  <div class="clearfix"></div>
                </div>
                <div class="col-xs-4 border-right">
                  <div class="col-xs-1"><i class="fa fa-2x fa-money  text-muted"></i></div>
                  <div class="col-xs-10">
                    <h4 class=""> Collectable Panalty / Due </h4>
                    <?php 
					 $paid_panalty=0; 
					 if($paid_summary['panalty_received']>0){$paid_panalty=$paid_summary['panalty_received'];} 
					  $paid_due=0; 
					 if($paid_summary['due_received']>0){$paid_due=$paid_summary['due_received'];} 
					?>
                    <p>Panalty Balance : Rs. <?php echo number_format($total_panalty-$paid_panalty, 2, '.', ',') ?> </p>
                    <p>Due Balance : Rs. <?php echo number_format($total_due-$paid_due, 2, '.', ',') ?> </p>
                  </div>
                  <div class="clearfix"></div>
                </div>
                <div class="clearfix"></div>
              </div>
              
              
              <!------------------------------------------------------------------------------------------->
               <div class="well well-sm">
                <div class="col-xs-4 border-right">
                  <div class="col-xs-1"><i class="fa fa-2x fa-money  text-muted"></i></div>
                  <div class="col-xs-10">
                    <h4 class=""> Arrears</h4>
                    <?php
											
					?>
                    <!-- Cal paid %  start --> 
                    <!-- Cal paid % End -->
                    <p <?php if($arreas_amount>0){?>style="color:#D00"<?php }else{?> style="color:#0A0" <?php }?>><strong>Arrears value : Rs. <?php echo number_format($arreas_amount, 2, '.', ',');?></strong></p>
                    <p >Arrears instalments : <?php echo number_format($arreas_amount/$loan_details->loan_term_amount, 0, '.', ',');?></p>
                    
                  
                  </div>
                  <div class="clearfix"></div>
                </div>
                <div class="col-xs-4 border-right">
                  <div class="col-xs-1"><i class="fa fa-2x fa-money padding010 text-muted"></i></div>
                  <div class="col-xs-10">
                    <h4 class=""> Total Paid</h4>
                    <p><strong>Total Paid: Rs. <?php echo number_format($paid_summary['pymnt_amount'], 2, '.', ',') ?></strong></p>
                    <p><strong> Total Paid Charges : Rs. <?php echo number_format($paid_summary['panalty_received']+$paid_summary['due_received'], 2, '.', ',') ?></strong></p>
                    <p>Total Paid Panalty : Rs. <?php echo number_format($paid_summary['panalty_received'], 2, '.', ',') ?></p>
                    <p>Total Paid Due  : Rs. <?php echo number_format($paid_summary['due_received'], 2, '.', ',') ?></p>
                  </div>
                  <div class="clearfix"></div>
                </div>
                <div class="col-xs-4 border-right">
                  <div class="col-xs-1"><i class="fa fa-2x fa-file-text-o text-muted"></i></div>
                  <div class="col-xs-10">
                   <h4 class=""> Info</h4>
                 	 <p>Reduce from cheque  : <?php  if($loan_details->reduce_fron_ceque==1){echo "Yes";}else{echo "No";}?></p>
                    <p>Panalty  : <?php  if($loan_details->panalty_enable==1){?> <a class="btn btn-xs btn-green tooltips" data-placement="top" data-original-title="Disable panalty" onClick="disable_panalty(<?php echo $loan_id ?>)"><i class="glyphicon fa fa-check"></i> ON</a><?php }else{?>  <a class="btn btn-xs btn-warning tooltips" data-placement="top" data-original-title="Disable customer" onClick="enable_panalty(<?php echo $loan_id ?>)"><i class="glyphicon fa fa-minus-circle"></i> OFF</a><?php }?>  <?php echo $loan_details->panalty_presentage;?> % </p>
                  
                  
                    <p>Due  : <?php  if($loan_details->enable_due==1){?> <a class="btn btn-xs btn-green tooltips" data-placement="top" data-original-title="Disable due" onClick="disable_due(<?php echo $loan_id ?>)"><i class="glyphicon fa fa-check"></i> ON</a><?php }else{?>  <a class="btn btn-xs btn-warning tooltips" data-placement="top" data-original-title="enable due" onClick="enable_due(<?php echo $loan_id ?>)"><i class="glyphicon fa fa-minus-circle"></i> OFF</a><?php }?>  <?php echo $loan_details->due_presentage;?> % </p>
                    
                    
                    
                  </div>
                  </div>         
                  <div class="clearfix"></div>
                </div>
                
                
                <!--  start -->
              
              <div class="well well-sm">
                <div class="col-xs-12 border-right">
                 <!-- <div class="col-xs-1"><i class="fa fa-2x fa-text-o text-muted"></i></div>-->
                  <div class="col-xs-10">
                    <h4 class=""> Note </h4>
                  <p> <?php echo $loan_details->note;?> </p>
                  </div>
                  <div class="clearfix"></div>
                </div>
             
           
                  <div class="clearfix"></div>
                </div>
                <div class="clearfix"></div>
                
                
                
                    <div class="well well-sm">
                <div class="col-xs-12 border-right">
                  <!--<div class="col-xs-1"><i class="fa fa-2x fa-text-o text-muted"></i></div>-->
                  <div class="col-xs-12">
                    <h4> Configuration </h4>
                    <div class="well" style="background-color:#FFF" >
                      <h4 class=""> Penalty Charges</h4>
                    <div class="col-md-12">   
                   <div class="col-md-2">Status  : <?php  if($loan_details->panalty_enable==1){?> <a class="btn btn-xs btn-green tooltips" data-placement="top" data-original-title="Disable panalty" onClick="disable_panalty(<?php echo $loan_id ?>)"><i class="glyphicon fa fa-check"></i> ON</a><?php }else{?>  <a class="btn btn-xs btn-warning tooltips" data-placement="top" data-original-title="Disable customer" onClick="enable_panalty(<?php echo $loan_id ?>)"><i class="glyphicon fa fa-minus-circle"></i> OFF</a><?php }?> </div>
                   
                     <div class="col-md-3" style="color:#D00">Reduce Paid  : <input id="red_p_panalty" name="red_p_panalty" type="number"> <button id="panalty_p_adj"  onClick="panalty_p_adj()" class="btn btn-sm btn-warning"><i class="clip-remove"></i></button></div>
                      
                     
                      <div class="col-md-3">Reduce Unpaid  : <input id="red_un_panalty" name="red_un_panalty" type="number"> <button id="panalty_up_adj"  onClick="panalty_up_adj()" class="btn btn-sm btn-warning"><i class="clip-remove"></i></button></div> 
                      
                      <div class="col-md-3 form-group"> Percentage <input  id="penalty_presentage" name="penalty_presentage" type="number" value="<?php echo$loan_details->panalty_presentage; ?>"> <button id="panalty_presentage_adj"  onClick="panalty_presentage_adj()" class="btn btn-sm btn-warning"><i class="fa fa-edit"></i></button></div> 
                      
                      </div>
                 
                 
                 <hr>
                    </div>
                    
                    
                    <!-- ------------------------------------------------------------------------------------------------ -->
                    
                    
                      <div class="well" style="background-color:#FFF" >
                      <h4 class=""> Due Charges </h4>
                      <div class="col-xs-12">   
                     <div class="col-md-2">Status  :  <?php  if($loan_details->enable_due==1){?> <a class="btn btn-xs btn-green tooltips" data-placement="top" data-original-title="Disable due" onClick="disable_due(<?php echo $loan_id ?>)"><i class="glyphicon fa fa-check"></i> ON</a><?php }else{?>  <a class="btn btn-xs btn-warning tooltips" data-placement="top" data-original-title="enable due" onClick="enable_due(<?php echo $loan_id ?>)"><i class="glyphicon fa fa-minus-circle"></i> OFF</a><?php }?>  </div>
                     
                     
                     <div class="col-md-3"  style="color:#D00">Reduce Paid : <input id="red_p_due" name="red_p_due" type="number"> <button id="due_p_adj"  onClick="due_p_adj()" class="btn btn-sm btn-warning"><i class="clip-remove"></i></button></div>
                      
                     
                      <div class="col-md-3">Reduce Unpaid : <input id="red_un_due" name="red_un_due" type="number" > <button id="due_up_adj"  onClick="due_up_adj()" class="btn btn-sm btn-warning"><i class="clip-remove"></i></button></div> 
                      
                       <div class="col-md-3 form-group"> Percentage <input  id="due_presentage" name="due_presentage" type="number" value="<?php echo $loan_details->due_presentage;?>"> <button id="due_presentage_adj"  onClick="due_presentage_adj()" class="btn btn-sm btn-warning"><i class="fa fa-edit"></i></button></div> 
                      
                      </div>
                 
                 
                 <hr>
                 
                    </div>
                    
                    
                 
                  </div>
                  <div class="clearfix"></div>
                </div>
             
           
                  <div class="clearfix"></div>
                </div>
                <div class="clearfix"></div>
                
                
                
                
                
                
                
              </div>
              
              
              <!------------------------------------------------------------------------------------------->
               
              </div>
              
              
              
              <!-- end--> 
              <!-- payment list -->
              <div class="col-xs-12 border-right">
                <h4>Payment History</h4>
              </div>
              <div class="row">
                <div class="col-xs-12">
                  <div class="table-responsive">
                    <table class="table items table-striped table-bordered table-condensed table-hover">
                      <thead>
                        <tr class="report_view_th">
                          <th width="100 px;">Date Added</th>
                          <th width="100 px;">Payment <br>Date</th>
                          <th>Reference</th>
                          <th>Tracking<br>Number</th>
                          <th>Paid by</th>
                          <th>Status</th>
                          <th>Received<br>Panalty Rs.</th>
                          <th>Received<br>Due Rs.</th>
                          <th>Received<br>interest Rs.</th>
                          <th>Received<br>Capital Rs.</th>
                          <th>Received<br>Loan Rs.</th>
                      	  <th>Received<br>Money Rs.</th>
                           <th>Action</th>
                        </tr>
                      </thead>
                      <tbody>
                        <?php   foreach ($loan_payment_list as $row){?>
                        <tr>
                          <td><?php echo  date('Y-m-d', strtotime($row->pymnt_added_date_time)); ?></td>
                          <td><?php echo  date('Y-m-d', strtotime($row->pymnt_date_time)); ?></td>                          
                          <td><?php echo $row->pymnt_ref_no ?></td>
                          <td><?php echo $row->tracking_number ?></td>
                          <td><?php echo $row->pymnt_paying_by ?></td>
                         <?php
						 $status="check this recode";
						 if($row->pymnt_collected==1)
						 {							 
							$status="Collected" ;
						 }
						 if($row->pymnt_deposited==1)
						 {							 
							$status="Deposited" ;
						 }
						 if($row->pymnt_realize==1)
						 {							 
							$status="Realize" ;
						 }
						 if($row->pymnt_returned==1)
						 {							 
							$status="Return" ;
						 }
						 
						 
						 
						 
						 ?>                         
                         <?php /*?> <td><?php echo $status ?></td><?php */?> 
                         <td><?php echo $row->user_first_name ?></td>
                         
                          <td style="text-align:end"><?php echo $row->panalty_received ?></td>
                          <td style="text-align:end"><?php echo number_format($row->due_received, 2, '.', ',') ?></td>                         
                          <td style="text-align:end"><?php echo number_format($row->loan_interest_recived, 2, '.', ',') ?></td>
                          <td style="text-align:end"><?php echo number_format($row->capital_received, 2, '.', ',') ?></td>
                          <td style="text-align:end"><?php echo number_format($row->loan_received, 2, '.', ',') ?></td>
                          <td style="text-align:end"><?php echo number_format($row->pymnt_amount, 2, '.', ',') ?></td>
                          <td style="text-align:center"><button id="delete_pay" onClick="delete_payment(<?php echo $row->paymnt_id;?>)" ><i class="fa fa-trash-o"></i></button></td>
                        </tr>
                        <?php }?>
                      
                      </tbody>
                    </table>
                    
                    
                    
                   <?php /*?>  <table class="table items table-striped table-bordered table-condensed table-hover">
                      <thead>
                        <tr class="report_view_th">
                          <th width="100px;">Date Added</th>
                          <th>Reference</th>
                          <th>Paid by</th>
                          <th>Bank</th>
                          <th>Branch</th>
                          <th>Cheque No</th>
                          <th>Cheque/Cash Date<br/>
                            (dd-mm-yyyy)</th>
                          <th width="100px;">Cheque Deposited Status</th>
                          <th width="100px;">Check Returned Status</th>
                          <th width="100px;">Cash Collectd Status</th>
                          <th>Amount</th>
                        </tr>
                      </thead>
                      <tbody>
                        <?php   foreach ($loan_payment_list as $row){?>
                        <tr>
                          <td><?php echo  date('Y-m-d', strtotime($row->pymnt_added_date_time)); ?></td>
                          <td><?php echo $row->pymnt_ref_no ?></td>
                          <td><?php echo $row->pymnt_paying_by ?></td>
                          <td><?php echo $row->bank_code ?>
                            <?php if($row->bank_code) echo '/<br/>';?>
                            <?php echo $row->bank_name ?></td>
                          <td><?php echo $row->pymnt_branch ?></td>
                          <td><?php echo $row->pymnt_cheque_no ?></td>
                          <td><?php  if($row->pymnt_cheque_date!="0000-00-00"){echo $row->pymnt_cheque_date; } ?></td>
                          <td><?php if($row->pymnt_paying_by=='Cheque'){?>
                            <label class="checkbox-inline">
                              <input type="checkbox" onChange="changeColectedStatus(<?php echo $row->paymnt_id;?>,this.checked,'deposited')" value="4" class="collected_checkbox" id="collected_<?php echo $row->paymnt_id;?>" <?php if($row->pymnt_deposited==1) echo 'checked';?>>
                              Deposited </label>
                            <?php } ?></td>
                          <td><?php if($row->pymnt_paying_by=='Cheque'){?>
                            <label class="checkbox-inline">
                              <input type="checkbox" onChange="changeColectedStatus(<?php echo $row->paymnt_id;?>,this.checked,'returned')" value="4" class="collected_checkbox" id="collected_<?php echo $row->paymnt_id;?>" <?php if($row->pymnt_returned==1) echo 'checked';?>>
                              Returned </label>
                            <?php } ?></td>
                          <td><?php if($row->pymnt_paying_by=='Cash'){?>
                            <label class="checkbox-inline">
                              <input type="checkbox" onChange="changeColectedStatus(<?php echo $row->paymnt_id;?>,this.checked,'collected')" value="4" class="collected_checkbox" id="collected_<?php echo $row->paymnt_id;?>" <?php if($row->pymnt_collected==1) echo 'checked';?>>
                              Collectd </label>
                            <?php } ?></td>
                          <td><?php echo number_format($row->pymnt_amount, 2, '.', ',') ?></td>
                        </tr>
                        <?php }?>
                        <tr >
                      
                      </tbody>
                    </table><?php */?>
                    
                    
                  </div>
                </div>
              </div>
              <div class="col-xs-12 border-right">
                <h4>Due History </h4>
              </div>
              <div class="row">
                <div class="col-xs-12">
                  <div class="table-responsive">
                    <table class="table items table-striped table-bordered table-condensed table-hover">
                      <thead>
                        <tr class="report_view_th">
                          <th width="100px;">Date</th>
                          <th>Amount</th>
                          <th>Remark</th>
                          <th>Action</th>
                        </tr>
                      </thead>
                      <tbody>
                        <?php $tot=0;   foreach ($loan_due as $row){?>
                        <tr>
                          <td><?php echo date('Y-m-d', strtotime($row->system_date_time))  ?></td>
                          <td style="text-align:end"><?php echo number_format($row->due_amount, 2, '.', ',') ?></td>
                          <td><?php echo $row->remarks ?></td>
                           <td style="text-align:center"><button id="delete_due" onClick="delete_due(<?php echo $row->id;?>)" ><i class="fa fa-trash-o"></i></button></td>
                        </tr>
                        <?php $tot+=$row->due_amount; }?>
                        <tr>
                          <td> Total </td>
                          <td style="text-align:right;"><?php echo $tot; ?></td>
                          <td></td>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
              <div class="clearfix"></div>
             
              <!-- panalty list -->
              <div class="col-xs-12 border-right">
                <h4>Panalty History </h4>
              </div>
              <div class="row">
                <div class="col-xs-12">
                  <div class="table-responsive">
                    <table class="table items table-striped table-bordered table-condensed table-hover">
                      <thead>
                        <tr class="report_view_th">
                          <th width="100px;">Date</th>
                          <th>Amount</th>
                          <th>Remark</th>
                           <th>Action</th>
                        </tr>
                      </thead>
                      <tbody>
                        <?php $tot=0;
						foreach ($loan_panalty as $row){?>
                        <tr>
                          <td><?php echo $row->payment_date ?></td>
                          <td style="text-align:end"><?php echo number_format($row->panalty_amount, 2, '.', ',') ?></td>
                          <td><?php echo $row->remark ?></td>
                          <td style="text-align:center"><button id="delete_panalty" onClick="delete_panalty(<?php echo $row->id;?>)" ><i class="fa fa-trash-o"></i></button></td>
                        </tr>
                        <?php $tot+=$row->panalty_amount; }?>
                        <tr>
                          <td> Total </td>
                          <td style="text-align:right;"><?php echo $tot; ?></td>
                          <td></td>
                          
                        </tr>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
              <!-- panalty list -->
              
              <!-- end payment list-->
              
              <div class="buttons">
                <div class="btn-group btn-group-justified">
                  <div class="btn-group" onClick="fbs_click(<?php echo $loan_id; ?>)"><a title="" class="tip btn btn-primary" data-original-title="Print"><i class="fa fa-print"></i> <span class="hidden-sm hidden-xs">Print</span></a> </div>
                </div>
              </div>
              <!--buttons--> 
              
            </div>
            <!--panel-body--> 
          </div>
          <!--panel--> 
          
        </div>
        <!--col-md-12--> 
      </div>
      <!--row--> 
      
      <!-- end grid --> 
      
    </div>
    <!-- end: PAGE --> 
  </div>
  <!-- end: MAIN CONTAINER --> 
  <!-- start: FOOTER -->
  <div class="footer clearfix">
    <div class="footer-inner"> <?php echo date("Y");?> &copy; Vehical Maintacne Management System by sallelanka solutions. </div>
    <div class="footer-items"> <span class="go-top"><i class="clip-chevron-up"></i></span> </div>
  </div>
  <!-- end: FOOTER --> 
  <!-- start: RIGHT SIDEBAR --> 
  <!-- end: RIGHT SIDEBAR -->
  <div id="event-management" class="modal fade" tabindex="-1" data-width="760" style="display: none;">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times; </button>
          <h4 class="modal-title">Event Management</h4>
        </div>
        <div class="modal-body"></div>
        <div class="modal-footer">
          <button type="button" data-dismiss="modal" class="btn btn-light-grey"> Close </button>
          <button type="button" class="btn btn-danger remove-event no-display"> <i class='fa fa-trash-o'></i> Delete Event </button>
          <button type='submit' class='btn btn-success save-event'> <i class='fa fa-check'></i> Save </button>
        </div>
      </div>
    </div>
  </div>
</div>

<!-- start ajax model -->
<div id="ajax-modal" class="modal fade" data-backdrop="static" data-keyboard="false" tabindex="-1" style="display: none;"></div>
<!-- end ajax model --> 

<!-- start: MAIN JAVASCRIPTS -->
<?php $this->load->view("common/footer"); ?>
<!-- end: MAIN JAVASCRIPTS --> 

<!-- start: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->

<?php /*?>	<script type="text/javascript" src="<?php echo asset_url(); ?>plugins/bootbox/bootbox.min.js"></script>
		<script src="<?php echo asset_url(); ?>plugins/bootstrap-modal/js/bootstrap-modal.js"></script>
		<script src="<?php echo asset_url(); ?>plugins/bootstrap-modal/js/bootstrap-modalmanager.js"></script>
		<script src="<?php echo asset_url(); ?>js/ui-modals.js"></script>       
        <script src="<?php echo asset_url(); ?>plugins/jQuery-lib/2.0.3/jquery.min.js"></script><?php */?>
<!-- end: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY --> 
<script>
			jQuery(document).ready(function() {
				//TableData.init();
				//Main.init();
				//TableData.init();
				//UIModals.init();
			});
				</script> 
<script type="text/javascript" language="javascript" >
function fbs_click(id,d) {
	u=location.href;
	t=document.title;
	window.open('<?php echo base_url() ?>loan/print_loan_invoice/'+id,'sharer','toolbar=0,status=0,width=700,height=700, left=10, top=10,scrollbars=yes');return false;
}

 function delete_payment(id){
			$.post( "<?php echo base_url();?>management/delete_payment", {id:id})
	  .done(function( data ) {		
	  	var obj = jQuery.parseJSON(data);
		 if (obj.status==0) 
		{
		alert('Error!');
		}		  
	   if (obj.status==1) 
		{
			//displayNotice('Payment','Deleted Payment Succesfully ');
			alert('Deleted Payment Succesfully ');
			location.reload();
		}		
		});
	   return false;	   
   }
   
   function delete_panalty(id){
			$.post( "<?php echo base_url();?>management/delete_panalty", {id:id})
	  .done(function( data ) {		
	  	var obj = jQuery.parseJSON(data);
		 if (obj.status==0) 
		{
		alert('Error!');
		}		  
	   if (obj.status==1) 
		{
			//displayNotice('Payment','Deleted Payment Succesfully ');
			alert('Deleted Payment Succesfully ');
			location.reload();
		}		
		});
	   return false;	   
   }
   function delete_due(id){
			$.post( "<?php echo base_url();?>management/delete_due", {id:id})
	  .done(function( data ) {		
	  	var obj = jQuery.parseJSON(data);
		 if (obj.status==0) 
		{
		alert('Error!');
		}		  
	   if (obj.status==1) 
		{
			//displayNotice('Payment','Deleted Payment Succesfully ');
			alert('Deleted Payment Succesfully ');
			location.reload();
		}		
		});
	   return false;	   
   }
   
   function disable_panalty(id){
			$.post( "<?php echo base_url();?>management/disable_panalty", {id:id})
	  .done(function( data ) {		
	  	var obj = jQuery.parseJSON(data);
		 if (obj.status==0) 
		{
		alert('Error!');
		}		  
	   if (obj.status==1) 
		{
			//displayNotice('Payment','Deleted Payment Succesfully ');
			alert(obj.validation);
			location.reload();
		}		
		});
	   return false;	   
   }
   
   function enable_panalty(id){
			$.post( "<?php echo base_url();?>management/enable_panalty", {id:id})
	  .done(function( data ) {		
	  	var obj = jQuery.parseJSON(data);
		 if (obj.status==0) 
		{
		alert('Error!');
		}		  
	   if (obj.status==1) 
		{
			//displayNotice('Payment','Deleted Payment Succesfully ');
			alert(obj.validation);
			location.reload();
		}		
		});
	   return false;	   
   }
   
    function disable_due(id){
			$.post( "<?php echo base_url();?>management/disable_due", {id:id})
	  .done(function( data ) {		
	  	var obj = jQuery.parseJSON(data);
		 if (obj.status==0) 
		{
		alert('Error!');
		}		  
	   if (obj.status==1) 
		{
			//displayNotice('Payment','Deleted Payment Succesfully ');
			alert(obj.validation);
			location.reload();
		}		
		});
	   return false;	   
   }
   
   function enable_due(id){
			$.post( "<?php echo base_url();?>management/enable_due", {id:id})
	  .done(function( data ) {		
	  	var obj = jQuery.parseJSON(data);
		 if (obj.status==0) 
		{
		alert('Error!');
		}		  
	   if (obj.status==1) 
		{
			//displayNotice('Payment','Deleted Payment Succesfully ');
			alert(obj.validation);
			location.reload();
		}		
		});
	   return false;	   
   }
   
   
   function panalty_p_adj()
   {
	bootbox.confirm({
    title: "Adjest Paid Penalty?",
    message: "Do you want to adjest the paid penalty now? This cannot be undone.",
    buttons: {
        cancel: {
            label: '<i class="fa fa-times"></i> Cancel'
        },
        confirm: {
            label: '<i class="fa fa-check"></i> Confirm'
        }
    },
    callback: function (result) {
        if(result==true)
		{
		//-------------------------------------------------------if confirm start
		var red_p_panalty=$('#red_p_panalty').val();
		var loan_id=$('#loan_id').val();
				
		if(red_p_panalty>0&&loan_id>0){
		
		$.post( "<?php echo base_url();?>management/reduce_p_penalty", {loan_id:loan_id,red_p_panalty:red_p_panalty})
	  .done(function( data ) {		
	  	var obj = jQuery.parseJSON(data);
		 	  
	   if (obj.status==1) 
		{
			//displayNotice('Payment','Deleted Payment Succesfully ');
			alert(obj.validation);
			location.reload(true);
		}
		else{
			
		alert(obj.validation);	
		}
		});	
			
			
		}else
		{
		alert("Amount Not valid! Please check again");	
		}
		
		
		
		//-------------------------------------------------------if confirm end
		}else
		{
		//alert("cancel")
		}
    }
});
	   
   }
   
   
   
   
   
   
   
   
   
function panalty_up_adj()
   {
	bootbox.confirm({
    title: "Adjest Unpaid Penalty?",
    message: "Do you want to adjest the unpaid penalty now? This cannot be undone.",
    buttons: {
        cancel: {
            label: '<i class="fa fa-times"></i> Cancel'
        },
        confirm: {
            label: '<i class="fa fa-check"></i> Confirm'
        }
    },
    callback: function (result) {
        if(result==true)
		{
		//-------------------------------------------------------if confirm start
		var red_up_panalty=$('#red_un_panalty').val();
		var loan_id=$('#loan_id').val();
				
		if(red_up_panalty>0&&loan_id>0){
		
		$.post( "<?php echo base_url();?>management/reduce_up_penalty", {loan_id:loan_id,red_up_panalty:red_up_panalty})
	  .done(function( data ) {		
	  	var obj = jQuery.parseJSON(data);
		 	  
	   if (obj.status==1) 
		{
			//displayNotice('Payment','Deleted Payment Succesfully ');
			alert(obj.validation);
			location.reload(true);
		}
		else{
			
		alert(obj.validation);	
		}
		});	
			
			
		}else
		{
		alert("Amount Not valid! Please check again");	
		}
		
		
		
		//-------------------------------------------------------if confirm end
		}else
		{
		//alert("cancel")
		}
    }
});
	   
   }
   
   
   
   
   
   
    function due_p_adj()
   {
	bootbox.confirm({
    title: "Adjest Paid Due?",
    message: "Do you want to adjest the paid due now? This cannot be undone.",
    buttons: {
        cancel: {
            label: '<i class="fa fa-times"></i> Cancel'
        },
        confirm: {
            label: '<i class="fa fa-check"></i> Confirm'
        }
    },
    callback: function (result) {
        if(result==true)
		{
		//-------------------------------------------------------if confirm start
		var red_p_due=$('#red_p_due').val();
		var loan_id=$('#loan_id').val();
				
		if(red_p_due>0&&loan_id>0){
		
		$.post( "<?php echo base_url();?>management/reduce_p_due", {loan_id:loan_id,red_p_due:red_p_due})
	  .done(function( data ) {		
	  	var obj = jQuery.parseJSON(data);
		 	  
	   if (obj.status==1) 
		{
			//displayNotice('Payment','Deleted Payment Succesfully ');
			alert(obj.validation);
			location.reload(true);
		}
		else{
			
		alert(obj.validation);	
		}
		});	
			
			
		}else
		{
		alert("Amount Not valid! Please check again");	
		}
		
		
		
		//-------------------------------------------------------if confirm end
		}else
		{
		//alert("cancel")
		}
    }
});
	   
   }
   
   
   
   
   
   
   
   
   
function due_up_adj()
   {
	bootbox.confirm({
    title: "Adjest Unpaid Penalty?",
    message: "Do you want to adjest the unpaid due now? This cannot be undone.",
    buttons: {
        cancel: {
            label: '<i class="fa fa-times"></i> Cancel'
        },
        confirm: {
            label: '<i class="fa fa-check"></i> Confirm'
        }
    },
    callback: function (result) {
        if(result==true)
		{
		//-------------------------------------------------------if confirm start
		var red_un_due=$('#red_un_due').val();
		var loan_id=$('#loan_id').val();
				
		if(red_un_due>0&&loan_id>0){
		
		$.post( "<?php echo base_url();?>management/reduce_up_due", {loan_id:loan_id,red_un_due:red_un_due})
	  .done(function( data ) {		
	  	var obj = jQuery.parseJSON(data);
		 	  
	   if (obj.status==1) 
		{
			//displayNotice('Payment','Deleted Payment Succesfully ');
			alert(obj.validation);
			location.reload(true);
		}
		else{
			
		alert(obj.validation);	
		}
		});	
			
			
		}else
		{
		alert("Amount Not valid! Please check again");	
		}
		
		
		
		//-------------------------------------------------------if confirm end
		}else
		{
		//alert("cancel")
		}
    }
});
	   
   }
   
   
      
function panalty_presentage_adj()
   {
	bootbox.confirm({
    title: "Adjest penalty percentage?",
    message: "Do you want to adjest the penalty percentage now?.",
    buttons: {
        cancel: {
            label: '<i class="fa fa-times"></i> Cancel'
        },
        confirm: {
            label: '<i class="fa fa-check"></i> Confirm'
        }
    },
    callback: function (result) {
        if(result==true)
		{
		//-------------------------------------------------------if confirm start
		var penalty_precentage=$('#penalty_presentage').val();
		var loan_id=$('#loan_id').val();
				
		if(penalty_precentage>0 && penalty_precentage<=100 &&loan_id>0){
		
		$.post( "<?php echo base_url();?>management/adj_penalty_precentage", {loan_id:loan_id,penalty_precentage:penalty_precentage})
	  .done(function( data ) {		
	  	var obj = jQuery.parseJSON(data);
		 	  
	   if (obj.status==1) 
		{
			//displayNotice('Payment','Deleted Payment Succesfully ');
			alert(obj.validation);
			location.reload(true);
		}
		else{
			
		alert(obj.validation);	
		}
		});	
			
			
		}else
		{
		alert("Amount Not valid! Please check again");	
		}
		
		
		
		//-------------------------------------------------------if confirm end
		}else
		{
		//alert("cancel")
		}
    }
});
	   
   }
   
   
   function due_presentage_adj()
   {
	bootbox.confirm({
    title: "Adjest penalty percentage?",
    message: "Do you want to adjest the penalty percentage now?.",
    buttons: {
        cancel: {
            label: '<i class="fa fa-times"></i> Cancel'
        },
        confirm: {
            label: '<i class="fa fa-check"></i> Confirm'
        }
    },
    callback: function (result) {
        if(result==true)
		{
		//-------------------------------------------------------if confirm start
		var due_precentage=$('#due_presentage').val();
		var loan_id=$('#loan_id').val();
				
		if(due_precentage>0 && due_precentage<=100 &&loan_id>0){
		
		$.post( "<?php echo base_url();?>management/adj_due_precentage", {loan_id:loan_id,due_precentage:due_precentage})
	  .done(function( data ) {		
	  	var obj = jQuery.parseJSON(data);
		 	  
	   if (obj.status==1) 
		{
			//displayNotice('Payment','Deleted Payment Succesfully ');
			alert(obj.validation);
			location.reload(true);
		}
		else{
			
		alert(obj.validation);	
		}
		});	
			
			
		}else
		{
		alert("Amount Not valid! Please check again");	
		}
		
		
		
		//-------------------------------------------------------if confirm end
		}else
		{
		//alert("cancel")
		}
    }
});
	   
   }
   
   function delete_panalty_disable()
   {
	alert("delete function disable for safty reason by admin. please contact system administrator to enable it");   
	   
   }
   
    function delete_due_disable()
   {
	   
	 alert("delete function disable for safty reason by admin. please contact system administrator to enable it");   
   }
   
   
</script>
</body>
<!-- end: BODY -->
</html>