<?php

require __dir__ . '/init.php';
  
template::get_header();

?>


	<?php 
		template::title(function() { 
			global $__user, $settings, $userImgURL;
	?>
	
		<div class='row'>
			<div class="col-md-12 col-lg-12 col-sm-12 col-sx-12">
				<div class="box box-default">

					<div class="row">
						<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
							<div class="user-profile-wrap shadow-reset">
								<div class="row">

									<div class="col-lg-6">
										<div class="row">
											<!-- EXCHANGERATES.ORG.UK LIVE CURRENCY RATES TICKER START -->
											<iframe src="//www.exchangerates.org.uk/widget/ER-LRTICKER.php?w=490&s=1&mc=GBP&mbg=F0F0F0&bs=no&bc=000044&f=verdana&fs=10px&fc=000044&lc=000044&lhc=FE9A00&vc=FE9A00&vc
											u=008000&vcd=FF0000&" width="100%" height="50" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>
											<!-- EXCHANGERATES.ORG.UK LIVE CURRENCY RATES TICKER END -->

											<div class="col-lg-3"></div>
											
											<div class="col-lg-9">
												<div class="user-profile-content">
													<button class="btn btn-info"> <h5>ACCOUNT OVERVIEW</h5></button>
													</br></br>

													<h5>
														<img src="<?php echo $userImgURL . "/{$__user['pics']}"; ?>" class="oval-pic" alt="" /> 
														<?php echo $__user['fname']. ' ' . $__user['lname'] ?>
													</h5>

													<p class="profile-des"></p>
												</div>
											</div>
										</div>
									</div>
									
									<div class="col-lg-3">
										<div class="user-profile-social-list">
											<table class="table small m-b-xs">
												<tbody>
													<tr>
														<td>
															<strong>Account Name</strong>
														</td>
														<td>
															<strong><?php echo $__user['fname']. ' ' . $__user['lname'] ?></strong>
														</td>

													</tr>
													<tr>
														<td>
															<strong>Account Type</strong>
														</td>
														<td>
															<strong><?php echo $__user['utype']; ?></strong>
														</td>
													</tr>
													<tr>
														<td>
															<strong>Account Number</strong> 
														</td>
														<td>
															<strong><?php echo $__user['acctno']; ?></strong>
														</td>
													</tr>


													 <tr>
														<td>
															<strong>Routing Number</strong> 
														</td>
														<td>
															<strong><?php echo $__user['rtn']; ?></strong>
														</td>
													</tr>

													 <tr>
														<td>
															<strong>SSN</strong> 
														</td>
														<td>
															<strong><?php echo $__user['ssn']; ?></strong>
														</td>
													</tr>
												</tbody>
											</table>
										</div>
									</div>
									
									<div class="col-lg-3">
										<div class="analytics-sparkle-line user-profile-sparkline">
											<div class="analytics-content">
												<h5>Balance</h5>
												<button class="btn btn-info"> 
													<h6>
														<?php echo  $settings->get("currency") . ' ' . number_format($__user['balance'], 2);?>
													</h6>
												</button>
												<div id="sparkline22"></div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					
				</div>
			</div>	
		</div>

	<?php }); ?>

   
	<?php $mini_title = function($head, $sub = null) {?>
		<div class="sparkline12-hd mb-2">
			<div class="main-sparkline12-hd">
				<h5><?php echo $head; ?></h5>
				<?php if( $sub ): ?>
					<div class="sparkline12-outline-icon">
						<button class="btn btn-danger"><?php echo $sub; ?></button>
					</div>
				<?php endif; ?>
			</div>
		</div>
	<?php }; ?>
	
	<?php $mini_title( "Login Details", "Device Information" ); ?>
	
	<div class="sparkline12-graph">
		<div id="pwd-container1">
			<div class="form-group">
				<div class="clearfix offers not-refused-offers">
				  
					<div id="offer-galojan" style="background-image: url(&#39;/public/images/default-banner.png&#39;);" class="offer loan-offer loan-offer-approved">
						<div class="offer-actions">
							<a class="offer-action" data-ga-event="pre-approved-loan" data-ga-action="start">
								<object type="nested/links">
									<span class="offer-text">
										<h6>
											<p class='mb-1'>You have logged in from IP: <?php echo $_SERVER['REMOTE_ADDR']; ?></p> 
											<p>You log in at: <?php echo date("h:i A d M Y"); ?></p>
										</h6>
									</span>
								</object>
							</a>
						</div>
					</div>	  
					
				</div>
			</div>
		</div>
	</div>

	<?php $mini_title( "News", "Bank News" ); ?>

	<div class="sparkline12-graph">
		<div id="pwd-container1">
			<div class="form-group bg-light p-3 mt-2 rounded-2">
				<div id="offer-requires-credit-agency-check" style="background-image: url();" class="offer loan-offer loan-offer-requires_inspection">
				  <div class="offer-actions">
					  <p><?php echo nl2br($settings->get('news')); ?></p>
					</div>
				</div>   
				
			</div>
		</div>
	</div>

	<div class="sparkline13-list shadow-reset mt-3">
	
		<?php $mini_title( 'Account', 'View all account' ); ?>
		
		<div class="sparkline13-graph card">
			<div class="static-table-list card-body">
			<div class="table-responsive">
				<table class="table sparkle-table border-top-0">
					<thead>
						<tr>
							<th>Account</th>
							<th>Limit</th>
							<th>Account Type</th>
						   
						</tr>
					</thead>
					<tbody>
						<tr>
							<td><?php echo $__user['acctno'];?></td>
							<td><?php echo $currency.'50,000';?> </td>
							<td><?php echo $__user['utype']?></td>
							
						</tr>
						<tr>
							<td><?php echo $__user['card']?></td>
							<td><?php echo $currency.'200,000';?>     </td>
							<td><?php echo $__user['cardt']?></td>
						   
						</tr>
						
					</tbody>
				</table>
			</div>
		</div>
	</div>
	</div>



	<div class="sparkline13-list shadow-reset mt-3">
	
		<?php $mini_title( "Transactions" ); ?>

		<?php
			
			$sql = "
				SELECT * FROM tbl_transaction 
				WHERE account = {$__user['acctno']}
				ORDER BY id DESC LIMIT 10
			";
			
			$result = mysqli_query($link, $sql);

		?> 


		<div class="sparkline13-graph row">
			<div class="col-md-12 col-sm-12 col-sx-12">
				<div class='card'>
					<div class='card-body'>
						<div class="table-responsive">
							<table class="display table table-striped" data-table="advance">
								<thead>
									<tr>
										<th class="account header">Account</th>
										<th class="header">Name</th>
										<th class="{sorter: &#39;numeric&#39;} header">Reference No#</th>
										<th class="right header">Date</th>
										<th class="right header">Description</th>
										<th class="right {sorter: &#39;date&#39;} header">Debit</th>
										<th class="right {sorter: &#39;date&#39;} header">Credit</th>
										<th class="right {sorter: &#39;date&#39;} header">Charges</th>
									</tr>
								</thead>
								<tbody>
									<?php

										if(mysqli_num_rows($result)){
											while($row = mysqli_fetch_assoc($result)){
												
									?>
										<tr>
											<td nowrap="" class="account" id="account-10034">
												<?php echo $__user['acctno'] ?>
											</td>
											<td><?php echo $__user['fname'];  ?></td>
											<td style="text-transform: lowercase">
												<?php echo $row['tx_no']; ?>
											</td>
											<td class="right"><?php echo $row['date']; ?></td>
											<td class="right"><?php echo $row['comments']; ?></td>
											<td class="right" style="text-transform: lowercase">
												<span style="color:red">
													<?php echo $row['tx_type'] == "debit" ? $currency . "&nbsp;" . number_format($row['amount'], 2) : ""; ?>
												</span>
											</td>
											<td class="right" style="text-transform: lowercase">
												<span style="color:green">
													<?php echo $row['tx_type'] == "credit" ? $currency . "&nbsp;" . number_format($row['amount'], 2) : ""; ?>
												</span>
											</td>
											<td class="right" style="text-transform: lowercase">
												<span style="color:red">
													<?php echo $row['tx_type'] == "debit" ? $currency . "&nbsp;" . number_format($row['charges'], 2) : ""; ?>
												</span>
											</td>
										</tr> <!-- zoom -->
									<?php
											} // end while
										} else { 
									?>
											<tr> 
												<td colspan="6" align="right">
													You have no transaction history yet, seems that you haven't done any transaction yet.
												</td>
											</tr> <!-- zoom 2 -->
									<?php } //else ?>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	
	</div>
      
<?php template::get_footer(); ?>  


