@extends('training.inc.master')

@section('title','Dashboard')

@section('content')

<main class="content">
				<div class="container-fluid p-0">

				<h1 class="h3 mb-3"><strong>Update Payment Account Details</strong></h1>
				@include('training.alerts.alert')


					<div class="row">
						<div class="col-4">
							<div class="card">
								<div class="card-header">
									<h5 class="card-title mb-0">Update payment Details</h5>
								</div>
								<div class="card-body">
									<form action="{{ route('post.payment.update') }}" method="post">
										@csrf
										<input type="hidden" name="userid" value="{{ Auth::user()->id }}">
										<div class="mb-3">
											<label for="transactionid" class="form-label">Mpesa Transaction ID</label>
											<input type="text" class="form-control" id="transactionid" name="transactionid" placeholder="Enter Mpesa Transaction ID" required>
										</div>
									
										<div class="mb-3">
											<label for="accountnumber" class="form-label">Account Number</label>
											<input type="text" class="form-control" id="accountnumber" name="accountnumber" placeholder="Enter The Account Number" required>
										</div>

										<div class="mb-3">
											<label for="username" class="form-label">Update by </label>
											<input type="text" class="form-control" id="username" name="username" value="{{ Auth::user()->name }}" readonly>
										</div>
									
										
									
										<button type="submit" class="btn btn-primary">Update Payment Records</button>
									</form>
									
								</div>
							</div>
						</div>
					
						<div class="col-8">
						<div class="card">
								<div class="card-header">
									<h5 class="card-title">Registered Updates</h5>
									
								</div>
								<div class="card-body">
									<table id="datatables-reponsive" class="table table-striped" style="width:100%">
										<thead>
											<tr>
												<th>#</th>
												<th>User</th>
												<th>Transation ID</th>
												<th>Account</th>
												<th>Transaction Date</th>
											</tr>
										</thead>
										<tbody>
											@forelse($transactions as $index => $tx)
												<tr>
													<td>{{ $index + 1 }}</td>
													<td>{{ $tx->user_name }}</td>
													<td>{{ $tx->transaction_id }}</td>
													<td>{{ $tx->account_no }}</td>
													<td>{{ $tx->transaction_date }}</td>													
												</tr>
											@empty
												<tr>
													<td colspan="6" class="text-center">No transactions found.</td>
												</tr>
											@endforelse
										</tbody>
									</table>
								</div>
							</div>

				</div>
				
			</main>
@endsection