<?php

require __dir__ . '/init.php';


if (isset($_POST['apply'])){
	
	unset($_POST['apply']);
	
	$_POST = help::sanitize($_POST);
	
	$_POST['account'] = $__user['acctno'];
	$_POST['email'] = $__user['email'];
	$_POST['loanid'] = substr(md5(help::keygen()), 0, 10);
	
	$SQL = sQuery::insert( 'loan', $_POST );
	
	$status = $link->query( $SQL );
    $msg = $status ? "Your loan application was successfully sent, wait for response!" : "Cannot apply!";
    
}
    

template::get_header();

?>

    <?php template::title( "Loan Application" ); ?>

    <div class="row">
        <div class="col-lg-12">
		
			<div class="sparkline12-list shadow-reset mg-t-30">
				<div class="sparkline12-graph">
					<div class="basic-login-form-ad">
					
						<div class="row">
							<div class="col-lg-12">
								<div class="all-form-element-inner">
										
									<form action="loan.php" method="post">
									
										<?php template::alert( $msg, $status ?? null ); ?>
										
										<div class="form-group">
											<div class="row">
												<div class="col-lg-3">
													<label class="login2 pull-right pull-right-pro">From</label>
												</div>
												<div class="col-lg-6">
													<select type="text" name="" class="form-control" >
														<option value="<?php echo $__user['acctno'] ?>">
															<?php echo $__user['acctno']; ?> 
														</option>
													</select>
												</div>
											</div>
										</div>
										
										<div class="form-group">
											<div class="row">
												<div class="col-lg-3">
													<label class="login2 pull-right pull-right-pro">Date</label>
												</div>
												<div class="col-lg-3">
													<input type="text" name="date" value="<?php echo date("m-d-y");?>" readonly="true" class="form-control" />
												</div>
											</div>
										</div>

										<div class="form-group">
											<div class="row">
												<div class="col-lg-3">
													<label class="login2 pull-right pull-right-pro">Full Name</label>
												</div>
												<div class="col-lg-6">
													<input type="text" class="form-control" name="name"  maxlength="160" value=""  placeholder="Enter full  Name " required />
												</div>
											</div>
										</div>

										<div class="form-group">
											<div class="row">
												<div class="col-lg-3">
													<label class="login2 pull-right pull-right-pro">Amount</label>
												</div>
												<div class="col-lg-6">
													<input type="number" step="0.01" name="amount" class="form-control" required />
												</div>
											</div>
										</div>

										<div class="form-group">
											<div class="row">
												<div class="col-lg-3">
													<label class="login2 pull-right pull-right-pro">Loan Duration</label>
												</div>
												<div class="col-lg-6">
													<select type="text" name="duration"  class="form-control" />
														<option>1 week</option>
														<option>2 weeks</option>
														<option>1 month</option>
														<option>3 months</option>
														<option>1 year</option>
													</select>
												</div>
											</div>
										</div>

										<div class="form-group">
											<div class="row">
												<div class="col-lg-3">
													<label class="login2 pull-right pull-right-pro">Loan Types</label>
												</div>
												<div class="col-lg-6">
													<select type="text" name="lt"  class="form-control" />
														<option>Business loan</option>
														<option>Student Loan</option>
														<option>Individual Loan</option>
													</select>
												</div>
											</div>
										</div>

										<div class="form-group">
											<div class="row">
												<div class="col-lg-3">
													<label class="login2 pull-right pull-right-pro">Reason For Loan</label>
												</div>
												<div class="col-lg-6">
													<textarea name="reason" class="form-control" rows="4"></textarea>
												</div>
											</div>
										</div>

										<div class="form-group">
											<div class="login-btn-inner">
												<div class="row">
													<div class="col-lg-3"></div>
													<div class="col-lg-6">
														<div class="login-horizental cancel-wp pull-left">
															<button class="btn btn-sm btn-primary login-submit-cs" name="apply" type="submit">Apply</button>
														</div>
													</div>
												</div>
											</div>
										</div>
										
									</form>
											
								</div>
							</div>
						</div>
											
					</div>
				</div>
			</div>
				
		</div>
	</div>
             

	
<?php template::get_footer(); ?>  