<?php require ("header.php")?>


       <?php
session_start();
if(isset($_SESSION['SESS_ADMINLOGGEDIN']) == FALSE) {
    header("Location: " . $config_basedir."access");
}
require_once("achieved/config.php");
require_once("achieved/db.php");
require_once("achieved/functions.php");
?>
        
                <?php


    $id = pf_validate_number($_GET['id'], "redirect", $config_basedir);
    $funcsql = "UPDATE loan SET verify = 2 WHERE id = " . $_GET['id'];
    mysql_query($funcsql);

 
 
 ?>
 
 
 <?php
 
 if (isset($_POST['pay_remark'])) {
    $pay_remark = mysql_real_escape_string($_POST['pay_remark']);
    $addresssql = mysql_query("UPDATE loan SET pay_remark='$pay_remark' WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>Payment Remark Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}


if (isset($_POST['remarks'])) {
    $remarks = mysql_real_escape_string($_POST['remarks']);
    $addresssql = mysql_query("UPDATE loan SET remarks='$remarks' WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>Remarks Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}


if (isset($_POST['closed_date'])) {
    $closed_date = mysql_real_escape_string($_POST['closed_date']);
    $addresssql = mysql_query("UPDATE loan SET closed_date='$closed_date' WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}




if (isset($_POST['appl_date'])) {
    $appl_date = mysql_real_escape_string($_POST['appl_date']);
    $addresssql = mysql_query("UPDATE loan SET appl_date='$appl_date' WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}




if (isset($_POST['IR'])) {
    $IR = mysql_real_escape_string($_POST['IR']);
    $addresssql = mysql_query("UPDATE loan SET IR='$IR'  WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}



if (isset($_POST['amount'])) {
     $amount = mysql_real_escape_string($_POST['amount']);
    $addresssql = mysql_query("UPDATE loan SET amount='$amount' WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}



if (isset($_POST['pay_amount'])) {
    
    $pay_amount = mysql_real_escape_string($_POST['pay_amount']);
    $addresssql = mysql_query("UPDATE loan SET pay_amount='$pay_amount'  WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}



if (isset($_POST['duration'])) {
      $duration = mysql_real_escape_string($_POST['duration']);
    $addresssql = mysql_query("UPDATE loan SET duration='$duration' WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}




if (isset($_POST['PC'])) {
    
    $PC = mysql_real_escape_string($_POST['PC']);
   
    $addresssql = mysql_query("UPDATE loan SET PC='$PC'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}



if (isset($_POST['SP'])) {
   
    $SP = mysql_real_escape_string($_POST['SP']);
   
      
    $addresssql = mysql_query("UPDATE loan SET SP='$SP'  WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}


if (isset($_POST['PL'])) {
   
    $PL = mysql_real_escape_string($_POST['PL']);
   
      
    $addresssql = mysql_query("UPDATE loan SET PL='$PL'  WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}


if (isset($_POST['nex_pay'])) {
   
    $nex_pay = mysql_real_escape_string($_POST['nex_pay']);
   
      
    $addresssql = mysql_query("UPDATE loan SET nex_pay='$nex_pay'  WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}



if (isset($_POST['nex_date'])) {
   
    $nex_date = mysql_real_escape_string($_POST['nex_date']);
   
      
    $addresssql = mysql_query("UPDATE loan SET nex_date='$nex_date'  WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}


// ($ordrow['amount']+($ordrow['amount']*$ordrow['IR']/100)*($ordrow['PL']/30))

if (isset($_POST['action'])) {
//   $return_pay = mysql_real_escape_string($_POST['return_pay']);
    $loan_bal = mysql_real_escape_string($_POST['loan_bal']);
   $addresssql = mysql_query("UPDATE loan SET loan_bal='$loan_bal'  WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}






if (isset($_POST['new_pay'])) {
   
    $new_pay = mysql_real_escape_string($_POST['new_pay']);
   
      
    $addresssql = mysql_query("UPDATE loan SET new_pay=$new_pay  WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}






if (isset($_POST['action'])) {
   
    $return_pay = mysql_real_escape_string($_POST['return_pay']);
   
      
    $addresssql = mysql_query("UPDATE loan SET return_pay='$return_pay',new_pay='0'  WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}


if (isset($_POST['miss_pay'])) {
   
    $miss_pay = mysql_real_escape_string($_POST['miss_pay']);
   
      
    $addresssql = mysql_query("UPDATE payment SET tmiss_pay=$tmiss_pay, miss_pay=$miss_pay, miss_pay=0  WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}


if (isset($_POST['action'])) {
   
    $total_payment = mysql_real_escape_string($_POST['total_payment']);
   
      
    $addresssql = mysql_query("UPDATE loan SET total_payment='$total_payment'  WHERE id='$id'");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}






if (isset($_POST['status'])) {
   
    $status = mysql_real_escape_string($_POST['status']);
   
//   DATE_ADD(date_col, INTERVAL 5 MINUTE) <= NOW()
//   datefield==CURRENT_DATE - INTERVAL 30 DAY
// WHERE  DATE_ADD(date_col, INTERVAL 5 MINUTE) <= NOW()
      
    $addresssql = mysql_query("UPDATE loan SET status='$status'  WHERE DATE_ADD(appl_date, INTERVAL 5 MINUTE) <= NOW() || id=$id ");
    echo mysql_error();
    $success="<div class='alert alert-success' style='margin-bottom:20px;'>closed_date Set Successfully<meta http-equiv='refresh' content='5; url=' /></div>";
}


// UPDATE table SET status="expired" WHERE datefield<=CURRENT_DATE - INTERVAL 30 DAY

?>
 
 

 
 
 
 
 
 
 <?php 
if(isset($success)){
    echo $success;
}
?>
   
 
  <div class='page-wrapper'>
           
            <div class='page-breadcrumb'>
                <div class='row'>
                    <div class='col-12 d-flex no-block align-items-center'>
                       
                       
                    </div>
                </div>
            </div>
           
            <div class='container-fluid'>
               
                <div class='row'>
                    <div class='col-12'>
                        <div class='card'>
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
 
     <!-- Content Wrapper. Contains page content -->
      <div class='content-wrapper'>
      
        <!-- Main content -->
        <section class='content'>

          <div class='row'>
            <!-- /.col -->
            <div class='col-md-12'>
              <div class='nav-tabs-custom'>
                <ul class='nav nav-tabs'>
                    <li class='active'>
                          <a href='index.php' class='rowtab'><strong>HOME</strong></a>
                          
                          </li>
<a href='list_loan.php'  class='btn btn-primary' value='log in'>List LOAN</a>
                   
                   </li>
                </ul>
                <div class='tab-content'>
                  <div class='active tab-pane' id='activity'>
                    <!-- Post -->
                    <div class='post'>
      
      
          
    <section class='content-header'>
      <h1>
        Borrower's Details
        <small>Customer's panel</small>
      </h1>
      <ol class='breadcrumb'>
        <li><a href='index.php'><i class='fa fa-dashboard'></i> Home</a></li>
        <li class='active'> <a href='list_loan.php'>List LOAN</a></li>
        <li class='active'>Add</li>
      </ol>
    </section>
	
	
    <section class='content'>
	<div class='row'>	
		
	 <section class='content'>
     
	<div class='alert alert-warning fade in' >
			<p><a href = '#' class = 'close' data-dismiss= 'alert'> &times;</a>
  				<strong>Please Note that&nbsp;</strong> &nbsp;&nbsp;You Must Tick All Added Checkbox Before Clicking on update button below</p>
				</div>	
				
				
				
				<div class='box box-success'>
            <div class='box-body'>
              <div class='table-responsive'>
             <div class='box-body'>

			 <!--<div class='col-md-14'>-->
           <div class='container'>
             <ul class='nav nav-tabs'>
              <li class='active'><a href='#tab_1' data-toggle='tab'>CUSTOMER INFORMATION</a></li>
              <li><a href='#tab_2' data-toggle='tab'> GUARANTOR INFORMATION</a></li>
              
             <li><a href='#tab_4' data-toggle='tab'>COLLATERAL</a></li>
              
              <li><a href='#tab_5' data-toggle='tab'>CALCULATOR</a></li>
              
              <li><a href='#tab_3' data-toggle='tab'>PAYMENT</a></li>
              
               
              <li><a href='#tab_6' data-toggle='tab'>MISSED PAYMENT</a></li>
              
              <li>
                  
                   <!--====================================-->
<button onclick='myFunction()' class='btn btn-success btn-flat'>
<i class='fa fa-print'>&nbsp;Print</i></button>

<!--<button onclick='window.print()'><i class='fa fa-print'>&nbsp;Print</i></button>-->


<!--===================================-->
                  
              </li>
              
              
              </ul>
              
              
            
            
            
            
             <div class='tab-content'>
            
            
     




              
              
              
              
              
                        
          
             <?php
 $ordsql = "SELECT * from payment WHERE id = " . $id; 
$ordres = mysql_query($ordsql);
$ordrow = mysql_fetch_assoc($ordres);

echo " <div class='tab-pane fade' id='tab_6'>
              	<form class='form-horizontal' method='post' enctype='multipart/form-data'>
               <hr>	
<div class='alert-danger'>&nbsp;MISSED PAYMENT</div>
<hr>	
					
				
				
                 
                 
                 	<div class='form-group'>
                 <label for='' class='col-sm-2 control-label' style='color:#009900'>Total Missed Payment</label>
                 <div class='col-sm-10'>
                 <div class='input-group date'>
                  <div class='input-group-addon'>
                    NGN </div>
                 <input name='tmiss_pay' type='number' class='form-control' value='".(($ordrow['tmiss_pay'])+$ordrow['miss_pay'])."' readonly>
                 </div>
                 </div></div>
                 
              
                  
                  
                  	   <div class='form-group'>
                <label for='' class='col-sm-2 control-label' style='color:#009900'>Missed Payment Date</label>
			 <div class='col-sm-10'>
              <div class='input-group date'>
                  <div class='input-group-addon'>
                    <i class='fa fa-calendar'></i>
                  </div>
                  <input name='miss_date' type='text' class='form-control pull-right' value='" . $ordrow['miss_date'] . "' readonly>
                </div>
              </div>
			  </div>
                  
                  
                  	<div class='form-group'>
                  <label for='' class='col-sm-2 control-label' style='color:#009900'>Missed Payment</label>
                  <div class='col-sm-10'>
                  <div class='input-group date'>
                  <div class='input-group-addon'>
                    NGN</div>
                  <input name='tmiss_pay' type='number' class='form-control' value='".$ordrow['miss_pay']."'>
                  </div>
                  </div></div>
                  
				  
				 
           			 	
           			 	
           			 <div class='form-group'>
				     
           		<div align='right'>
              <div class='box-footer'>
               <button type='submit' class='btn btn-info btn-flat' name='action'><i class='fa fa-save'>&nbsp;Update Payment</i></button>

              </div>
			  </div>
			  </form>
              </div>";
              ?>
              
              
              
              
              
              
              
			
			
			
			
			
			
			
			
			
			
			
			
				
					
				
				
				</div>
				

              </div>
			 

	
</div>	
</div>
</div></div>	
</div>
</div></div>	
</div>
</div></div>	
</div>
</div></div>	
</div>
</div>	
</div>		</section>
        
        
        
        
        
        
        
        
        
        
                    </div><!-- /.post -->

                
                  </div>
                  <!-- /.tab-pane -->
                  
                  
                  
                  

                  <!-- /.tab-pane -->
                </div><!-- /.tab-content -->
              </div><!-- /.nav-tabs-custom -->
            </div><!-- /.col -->
          </div><!-- /.row -->

        </section><!-- /.content -->
      </div>
                </div>
               
            </div>"
            ;
       
            ?>
           
           <?php require ("footer.php")?>
           
           <script>
function myFunction() {
  window.print(); }
</script>