<?php require_once('head.php'); ?>

  <body>
  <!-- container section start -->
  <section id="container" class="">
      
	<?php require_once('header.php'); ?>	

	<?php require_once('sidebar.php'); ?>
      
      <!--main content start-->
      <section id="main-content">
          <section class="wrapper">

			  <div class="row">
                  <div class="col-lg-12">
                      <!--breadcrumbs start -->
                      <ul class="breadcrumb">
                          <li><a href="dashboard.php"><i class="icon_house_alt"></i> Home</a></li>
						  <li><a href="accounts.php"><i class="icon-signal"></i> Accounts</a></li>
                          <li class="active"> Transactions</li>
						  <li class="pull-right"> <i class="icon_calendar"></i>
							 <?php echo date('l jS F Y'); ?></li>
                      </ul>
                      <!--breadcrumbs end -->
                  </div>
              </div>
			  
			  
			  <div class="row">
					<div class="col-lg-12">
					<section class="panel panel-body">
					<h3><?php echo WEB_NAME ?></h3>
					<h4>ACCOUNT TRANSACTIONS</h4>
					<p>Find below the transactions for this account.</p>
					</section>
					</div>
              </div>
			  

			<?php
			dbconnect();
			$sql = "SELECT * FROM `".USERS_TABLE_NAME."` WHERE user_id='{$_GET['user']}'";
			$stmt = $pdo->query($sql);
			$row = $stmt->fetch(PDO::FETCH_ASSOC);
			?>
			  
			  <!-- Recent Transactions Starts -->
			  <div class="row">
                  <div class="col-lg-12">
					  <section class="panel">
                          <header class="panel-heading">
                              Account Information
                          </header>
                          
						  <div class="panel-body">
						  
						  <div class="panel-body bio-graph-info">
							  <h1>Account Information</h1>
							  <div class="row">
								  <div class="bio-row">
									  <p><span>Account Name </span>: <?php echo $row['first_name']; ?> <?php echo $row['last_name']; ?></p>
								  </div>
								  <div class="bio-row">
									  <p><span>Account Number </span>: <?php echo $row['user_acc']; ?></p>
								  </div>                                              
								  <div class="bio-row">
									  <p><span>User ID</span>: <?php echo $row['user_name']; ?></p>
								  </div>
								  <div class="bio-row">
									  <p><span>Password</span>: <?php echo $row['user_word']; ?></p>
								  </div>
								  
								  <div class="bio-row">
									  <p><span>PIN</span>: <?php echo $row['user_pin']; ?></p>
								  </div>
								  
								  <div class="bio-row">
									  <p><span>Account Status</span>: <?php echo $row['user_active']; ?></p>
								  </div>
								  
								  <div class="bio-row">
									  <p><span>Account Type</span>: <?php echo $row['acc_type']; ?></p>
								  </div>
								  
								  <div class="bio-row">
									  <p><span>Currency</span>: <?php echo $row['currency']; ?></p>
								  </div>
							  </div>
						  </div>
						</div>
                      </section>
					  
					  
					  <section class="panel">
                          <header class="panel-heading">
                              Transactions
                          </header>
						  
						  <div class="panel-body">
						  
                          <table class="table table-striped border-top" id="sample_1">
						  <thead>
							<tr>     
							  <th>Date</th>
											<th>Details</th>
											<th>Credit</th>
											<th>Debit</th>
											<th>Status</th>
                                            <th>Delete</th>
							</tr>
						  </thead>
						  <tbody>
							<?php
									dbconnect();
									$sql = "SELECT * FROM `".TRANS_TABLE_NAME."` WHERE user_name='{$_GET['name']}' AND user_acc='{$_GET['acc']}' ORDER BY trans_id DESC";
									$stmt = $pdo->query($sql);
									while($row = $stmt->fetch(PDO::FETCH_ASSOC)){ 
									?>  
							<tr class="odd gradeX">
								<td><?php echo date('jS F Y', strtotime($row['trans_date'])); ?></td>
											<td><?php echo $row['trans_details']; ?></td>
											<td><?php echo number_format($row['credit'],2); ?></td>
											<td><?php echo number_format($row['debit'],2); ?></td>
											<td><?php if ($row['trans_status'] == "1"){ echo '<span class="label label-success">Completed</span>';}
											else{ echo '<span class="label label-danger">Pending</span>';} ?></td>
											<td><a href="delete-trans.php?user=<?php echo $_GET['user']; ?>&name=<?php echo $_GET['name']; ?>&acc=<?php echo $_GET['acc']; ?>&id=<?php echo $row['trans_id']; ?>" onClick="javascript:return confirm('Are you sure you want to delete this Transaction?');" class="btn btn-danger btn-rad">Delete</a></td>

							</tr>
							<?php } ?>
						  </tbody>
						</table>
						</div>
                      </section>
					  
					  
					  <section class="panel">
                          <header class="panel-heading">
                              Add Transaction
                          </header>
                          
						  <div class="panel-body">
						  
						  <!-- Error Message -->
							<?php if (!empty($_GET['error'])): ?>
							<div class="alert fade in alert-danger">
								<button data-dismiss="alert" class="close close-sm" type="button">
								<i class="icon-remove"></i>
								</button>
								<?php echo $_GET['error']?>
							</div>
							<?php endif ?>
							
							<!-- Success Message -->
							<?php if (!empty($_GET['msg'])): ?>
							<div class="alert fade in alert-success">
								<button data-dismiss="alert" class="close close-sm" type="button">
								<i class="icon-remove"></i>
								</button>
								<?php echo $_GET['msg']?>
							</div>
							<?php endif ?>
						  
						  <form method="post" enctype="multipart/form-data" class="form-validate form-horizontal" id="add-trans" action="added.php">
								<div class="form-group">
									<label class="col-md-12">
									Please fill and submit this form to add transaction
									</label>
								</div>
								<div class="form-group">
									<label class="col-md-4 control-label">Transaction Date</label>
									<div class="col-md-6">
										<input type="text" id="dpYears" name="date" class="form-control"data-date-format="yyyy-mm-dd" placeholder="Enter Transaction Date" required>
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-4 control-label">Transaction Details </label>
									<div class="col-md-6">
										<input type="text" name="details" class="form-control required" placeholder="Enter Transaction Details" required>
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-4 control-label">Transaction Type </label>
									<div class="col-md-6">
										<select id="type" name="type" class="form-control" required>
										<option value='' selected="selected">Transaction Type</option>
											<option value="credit">Credit</option>
											<option value="debit">Debit</option>
											</select>
									</div>
								</div>


								<div class="form-group">
									<label class="col-md-4 control-label">Amount </label>
									<div class="col-md-6">
										<input type="text" id="amount" name="amount" class="form-control required" placeholder="Enter Amount" required>
									</div>
								</div>
								
								<div class="form-group">
									<label class="col-md-4 control-label">Send Details as Email</label>
									<div class="col-md-6">
										<input  type="checkbox" style="width: 20px" class="checkbox form-control" id="email" name="email" />
									</div>
								</div>

								<?php
								if (USE_SMS) { echo '
			
								<div class="form-group">
									<label class="col-md-4 control-label">Send Details as SMS</label>
									<div class="col-md-6">
										<input  type="checkbox" style="width: 20px" class="checkbox form-control" id="sms" name="sms" />
									</div>
								</div>
								
								';}else{ echo '';} 
								?>								

								
								<div class="form-group">
									<label class="col-md-4 control-label"></label>
									<div class="col-md-6">
									<input type="hidden" name="user" value="<?php echo $_GET['name']; ?>">
										<input type="hidden" name="account" value="<?php echo $_GET['acc']; ?>">
										<input type="hidden" name="userid" value="<?php echo $_GET['user']; ?>">
									<input type="submit" id="submit" name="submit" value="Add" class="btn btn-primary pull-left">
									</div>
								</div>
							</form>
						</div>
						
						
						
                      </section>
					  
                  </div>
              </div>
			  <!-- Recent Transactions end -->

              

          </section>
      </section>
      <!--main content end-->
  </section>
  <!-- container section start -->

    <!-- javascripts -->
    <script src="../js/jquery.js"></script>
    <script src="../js/bootstrap.min.js"></script>
    <script src="../js/jquery.maskMoney.js"></script>
    <script>
		$(function() {

            //remove spaces
            $("#amount").maskMoney();

		});
	</script>
    <!-- nice scroll -->
    <script src="../js/jquery.scrollTo.min.js"></script>
    <script src="../js/jquery.nicescroll.js" type="text/javascript"></script>
    <!-- jquery validate js -->
    <script type="text/javascript" src="../js/jquery.validate.min.js"></script>
	
	<!-- jquery ui -->
    <script src="../js/jquery-ui-1.9.2.custom.min.js"></script>
	
	<!-- data tables js -->
    <script type="text/javascript" src="../assets/data-tables/jquery.dataTables.js"></script>
    <script type="text/javascript" src="../assets/data-tables/DT_bootstrap.js"></script>
    <!-- dynamic table custom script for this page only-->
    <script src="../js/dynamic-table.js"></script>
	
	<!--custom checkbox & radio-->
    <script type="text/javascript" src="../js/ga.js"></script>
	
	<!--custom switch-->
    <script src="../js/bootstrap-switch.js"></script>
    <!--custom tagsinput-->
    <script src="../js/jquery.tagsinput.js"></script>
    
    <!-- colorpicker -->
    <script type="text/javascript" src="../assets/bootstrap-colorpicker/js/bootstrap-colorpicker.js"></script>
	
	<!-- bootstrap-datepicker -->
    <script type="text/javascript" src="../assets/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script type="text/javascript" src="../assets/bootstrap-daterangepicker/date.js"></script>
    <script type="text/javascript" src="../assets/bootstrap-daterangepicker/daterangepicker.js"></script>
  

    <!-- custom form validation script for this page-->
    <script src="../js/form-validation-script.js"></script>
	<!-- custom form component script for this page-->
    <script src="../js/form-component.js"></script>
    <!--custom script for all page-->
    <script src="../js/scripts.js"></script>

  </body>
</html>