<?php

require __dir__ . '/init.php';

require _SDIR . '/for-user-details.php';

$user = help::get_user( $email );

template::get_header();

?>

	<?php template::title( "User Detail" ); ?>

	<div class='row'>
		<div class='col-lg-7'>
			<div class="invoice-title">
				<h4>
					<?php echo "Name: <a href='javascript:void(0)'>{$user['fname']} {$user['lname']}</a>"; ?>
				</h4>
				<h4>
					Acct NO: <a href="statement.php?email=<?php echo $email; ?>"> <?php echo $user['acctno'] ;?> </a> 
				</h4>
				<div class="invoice-number mb-4">
					<img src="<?php echo $userImgURL . "/{$user['pics']}"; ?>" width="150px" height="150px"/>
				</div>
				<form action="user-details.php?email=<?php echo $email ;?>" method="POST" onsubmit="return confirm('Sure you want to perform this action?');">
				
					<select name='action' class='form-control mb-2'>
					
						<?php if( empty($user['active']) ): ?>
							<option value='activate'> Activate Transfer </option>
						<?php else: ?>
							<option value='deactivate'> Deactivate Transfer </option>
						<?php endif; ?>
						
						<?php if( empty($user['status']) ): ?>
							<option value='verify'> Verify Account </option>
						<?php else: ?>
							<option value='unverify'> Unverify Account </option>
						<?php endif; ?>
						
						<?php if( empty($user['acone']) ): ?>
							<option value='activate-acone'> Activate Code Transfer </option>
						<?php else: ?>
							<option value='deactivate-acone'> Deactivate Code Transfer </option>
						<?php endif; ?>
						
						<?php if( empty($user['actwo']) ): ?>
							<option value='activate-actwo'> Activate Email OTP Transfer </option>
						<?php else: ?>
							<option value='deactivate-actwo'> Deactivate Email OTP Transfer </option>
						<?php endif; ?>
						
						<option value='delete'> Delete </option>
						
					</select>
					
					<div class='text-right'>
						<button class="btn btn-primary btn-block">
							<i class="fas fa-save mr-1"></i> Make Change
						</button>
					</div>
					
				</form>	
			</div>
		</div>
		<div class='col-lg-5'>
			<div class='border p-3'>
				<h4>KYC DOCUMENT</h4>
				<hr>
				<?php if( empty($user['kyc_image']) ): ?>
					<p>No KYC Document Uploaded</p>
				<?php else: ?>
					<img src='<?php echo help::url( UPLOADS_DIR . '/KYC/' . $user['kyc_image'] ); ?>' class='img-fluid'>
				<?php endif; ?>
			</div>
		</div>
	</div>
	
	<div class="row mt-4">
		<div class="col-md-12">
		
			<?php template::alert( $msg, $status ?? null ); ?>
			
			<hr>
			
			<div class='card'>
				<div class='card-body'>
					
					<div class="table-responsive">
						<table class="table table-striped table-hover table-md" data-table='simple'>
							<thead class='d-none'>
								<tr>
									<th></th>
									<th></th>
								</tr>
							</thead>
							<tbody>
								<?php 
								
									$user = help::get_user( $user['email'] );
									
									$tabledata = array(
									
										"Balance" => $currency . number_format($user['balance'], 2),
										"Email" => $user['email'],
										"Phone" => $user['phone'],
										"Gender" => $user['gender'],
										
										"Account Type" => $user['utype'],
										"Activate Transfer" => help::stdCheck( $user['active'] ),
										"Account Verification" => help::stdCheck( $user['status'], 'Verified', 'Unverified'),
										
										"Transfer With Codes Status" => help::stdCheck( $user['acone'] ),
										"Transfer With Email OTP" => help::stdCheck( $user['actwo'] ),
										"Direct Transfer Status" => help::stdCheck( empty($user['acone']) && empty($user['actwo']) ),
										
										"State" => $user['state'],
										"Address" => $user['address']
										
									);
									
									foreach( $tabledata as $title => $value ):
								?>
									<tr>
										<td><?php echo $title; ?></td>
										<td><?php echo $value; ?></td>
									</tr>
								<?php endforeach; ?>
							</tbody>
						</table>
					</div>
					
				</div>
			</div>
		
		</div>
	</div>

	
	<div class="row">
		<div class="col-12">
			<div class="card">
				<div class="card-header">
					<h4>CREDIT/DEBIT USER ACCOUNT</h4>
				</div>
				<form action="user-details.php?email=<?php echo $email ;?>" method="POST">
					<div class="card-body">
					
						<?php template::alert( $fund_msg ?? null, $fund_status ?? null ); ?>
						
						<div class="form-group row mb-4">
							<label class="col-form-label text-md-right col-12 col-md-3 col-lg-3">Amount</label>
							<div class="col-sm-12 col-md-7">
								<input type="number" step="0.01" name="amount" class="form-control">
							</div>
						</div>
						<div class="form-group row mb-4">
							<label class="col-form-label text-md-right col-12 col-md-3 col-lg-3">Select Transact Type</label>
							<div class="col-sm-12 col-md-7">
								<select class="form-control selectric" name="type">
									<option value="credit">Credit Fund</option>
									<option value="debit">Debit Fund</option>
								</select>
							</div>
						</div>
						<div class="form-group row mb-4">
							<label class="col-form-label text-md-right col-12 col-md-3 col-lg-3">Transfer Description</label>
							<div class="col-sm-12 col-md-7">
								<textarea class="summernote form-control form-control-sm" name="description" rows="4"></textarea>
							</div>
						</div>
						<div class="form-group row mb-4">
							<label class="col-form-label text-md-right col-12 col-md-3 col-lg-3"></label>
							<div class="col-sm-12 col-md-7">
								<button class="btn btn-primary" name="fund">Credit/Debit Account</button>
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>

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