<%- include('partials/header') %> 
<%- include('partials/sidemenu') %> 
<style>
	button.btn.dropdown-toggle.btn-light {
    display: none;
}
.dropdown.bootstrap-select.form-control {
    padding: 0;
}
select#loantype {
    width: 100%;
    height: 100%;
}
</style>
        <!--**********************************
            Content body start
        ***********************************-->
        <div class="content-body">
            <div class="container-fluid">
                <div class="page-titles">
					<ol class="breadcrumb">
						<li class="breadcrumb-item"><a href="javascript:void(0)">Edit User</a></li>
						<li class="breadcrumb-item active"><a href="javascript:void(0)">Profile</a></li>
					</ol>
                </div>
                <!-- row -->
                <div class="row">
                    <div class="col-lg-12">
                        <div class="profile card card-body px-3 pt-3 pb-0">
                            <div class="profile-head">
                                <div class="photo-content">
                                    <div class="cover-photo"></div>
                                </div>
                                <div class="profile-info">
									<% if(owner.profileimage.path !== undefined) { %>
										<div class="profile-photo">
											<img src="/<%=owner.profileimage.path%>" class="img-fluid rounded-circle" alt="" style=" width:120px !important; height:120px !important; max-width: unset;">
										</div>
									<%} else{ %>
										<div class="profile-photo" >
											<img src="../images/avatar/profile.png" class="img-fluid rounded-circle" alt="">
										</div>
							     	<%}%>
									
									<div class="profile-details">
										<div class="profile-name px-3 pt-2">
											<h4 class="text-primary mb-0"><%=owner.fullnames.firstname%> <%=owner.fullnames.lastname%></h4>
											<p>Fountain Core User</p>
										</div>
										<div class="profile-email px-2 pt-2">
											<h4 class="text-muted mb-0"><%=owner.username%></h4>
											<p>Email</p>
										</div>
										
									</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                   
                    <div class="col-xl-12">
                        <div class="card">
                            <div class="card-body">
                                <div class="profile-tab">
                                    <div class="custom-tab-1">
                                        <ul class="nav nav-tabs">
                                            <li class="nav-item"><a href="#profilesettings" data-toggle="tab" class="nav-link active show">Profile Settings</a>
                                            </li>
                                            <li class="nav-item"><a href="#accountsettings" data-toggle="tab" class="nav-link">Account Settings</a>
                                            </li>
                                            <li class="nav-item"><a href="#transactions" data-toggle="tab" class="nav-link"> Transactions</a>
											</li>
											<li class="nav-item"><a href="#cardtransactions" data-toggle="tab" class="nav-link">Card Transaction</a>
											</li>
											<li class="nav-item"><a href="#loantransactions" data-toggle="tab" class="nav-link">Loan History</a>
                                            </li>
                                        </ul>
                                        <div class="tab-content">
											<div id="profilesettings" class="tab-pane fade active show">
												<h4>Edit User Profile Details</h4>
                                                <div class="pt-3">
                                                    <div class="settings-form">
                                                        
                                                        <form method="POST" action="/update-user-profile" enctype="multipart/form-data">
                                                            <div class="form-row">
                                                                <div class="form-group col-md-6">
																	<label>First Name</label>
                                                                    <input type="text" value="<%=owner.fullnames.firstname%>" class="form-control" name="firstname">
                                                                </div>
                                                                <div class="form-group col-md-6">
                                                                    <label>Last Name</label>
                                                                    <input type="text" value="<%=owner.fullnames.lastname%>" class="form-control" name="lastname">
                                                                </div>
															</div>
															<div class="form-row">
                                                                <div class="form-group col-md-6">
																	<label>Email</label>
                                                                    <input type="email" value="<%=owner.username%>" class="form-control" name="username" >
																	<input type="text" value="<%=owner.username%>" class="form-control" name="formerusername" hidden>
                                                                </div>
                                                                <div class="form-group col-md-6">
                                                                    <label>Password</label>
																	<input type="text" value="<%=owner.password%>" class="form-control" name="password">
																	<input type="text" value="<%=owner._id%>" class="form-control" name="userid" hidden>
                                                                </div>
															</div>
															<div class="form-row">
                                                                <div class="form-group col-md-6">
																	<label>Phone</label>
                                                                    <input type="text" value="<%=owner.phone%>" class="form-control" name="phone" required>
                                                                </div>
                                                                <div class="form-group col-md-6">
                                                                    <label>Profile Image</label>
                                                                    <input type="file" name="profileimage" class="form-control">
                                                                </div>
                                                            </div>
                                                           
                                                            
                                                            
                                                            <button class="btn btn-primary" type="submit"> Update User                        </button>
                                                        </form>
                                                        <div class="new-account mt-3">
                                                            <% const m=getMessages() %>
                                                            <% if (m.notify) { %>
                                                            <% m.notify.forEach((element) => { %>
                                                           <p style="color: red;"> <%= element %></p>
                                                             <% }) %>
                                                             <% } %>
                                                        </div>
                                                    </div>
                                                </div>
											</div>
											<div id="accountsettings" class="tab-pane fade">
												<h4>Edit Account Details</h4>
                                                <div class="pt-3">
                                                    <div class="settings-form">
                                                        
                                                        <form method="POST" action="/update-user-account">
                                                            <div class="form-row">
                                                                <div class="form-group col-md-6">
                                                                    <label>Account Type</label>
                                                                    <% if (owner.accountype == undefined) {%>
                                                                        <select class="form-control" name="accountype">
                                                                            <option selected>Savings account</option>
                                                                            <option>Checking account</option>
                                                                            <option>Money market account</option>
                                                                            <option>Retirement account</option>
                                                                        </select>
                                                                    <% } else{%>
                                                                        <% var optionsarray = ['Savings account','Checking account','Money market account','Retirement account'] %>
                                                                        <select class="form-control" name="accountype">
                                                                            <option selected><%=owner.accountype%></option>
                                                                            <% optionsarray.forEach(function(option){ %>
                                                                                <% if(option !== owner.accountype) { %>
                                                                                    <option><%=option%></option>
                                                                                <%  }%>
                                                                            <%})%>
                                                                        </select>

                                                                     <%}%>
																
                                                                </div>
                                                                <div class="form-group col-md-6">
                                                                    <label>Account Number</label>
                                                                    <input type="number" value="<%=owner.accountnumber%>" placeholder=" Format 051234567X" class="form-control" name="accountnumber">
                                                                </div>
															</div>
															<div class="form-row">
                                                                <div class="form-group col-md-6">
																	<label>Main Account Balance</label>
                                                                    <input type="number" value="<%=owner.mainbalance%>" class="form-control" name="mainbalance">
                                                                </div>
                                                                <div class="form-group col-md-6">
                                                                    <label>Loan Balance</label>
																	<input type="number" value="<%=owner.loanbalance%>" class="form-control" name="loanbalance" >
																	<input type="text" value="<%=owner._id%>" class="form-control" name="userid" hidden>
                                                                </div>
															</div>
															<div class="form-row">
                                                                <div class="form-group col-md-6">
																	<label>Card Balance</label>
                                                                    <input type="number" value="<%=owner.cardbalance%>" class="form-control" name="cardbalance">
                                                                </div>
                                                                <div class="form-group col-md-6">
                                                                    <label>Certificates of deposit (CDs) Balance</label>
                                                                    <input class="form-control" type="number"  value="<%=owner.termdepositbalance%>"  name="termdepositbalance">
                                                                </div>
                                                            </div>
                                                            <div class="form-row">
                                                                <div class="form-group col-md-6">
                                                                    <label>Account Status</label>
                                                                    <% if (owner.status == undefined) {%>
                                                                        <select class="form-control" name="status">
                                                                            <option selected>Active</option>
                                                                            <option>Dormant</option>
                                                                            <option>Retirement account</option>
                                                                        </select>
                                                                    <% } else{%>
                                                                        <% var optionsarray = ['Active','Dormant', 'Restricted',] %>
                                                                        <select class="form-control" name="status">
                                                                            <option selected><%=owner.status%></option>
                                                                            <% optionsarray.forEach(function(option){ %>
                                                                                <% if(option !== owner.status) { %>
                                                                                    <option><%=option%></option>
                                                                                <%  }%>
                                                                            <%})%>
                                                                        </select>

                                                                     <%}%>
																
                                                                </div>
                                                                <div class="form-group col-md-6">
                                                                    <label>Code Permit</label>
                                                                    <% if (owner.codepermit == undefined) {%>
                                                                        <select class="form-control" name="codepermit">
                                                                            <option selected>Allow Code</option>
                                                                            <option>Don't Allow Code</option>
                                                                        </select>
                                                                    <% } else{%>
                                                                        <% var optionsarray1 = ['Allow Code',"Don't Allow Code"] %>
                                                                        <select class="form-control" name="codepermit">
                                                                            <option selected><%=owner.codepermit%></option>
                                                                            <% optionsarray1.forEach(function(option){ %>
                                                                                <% if(option !== owner.codepermit) { %>
                                                                                    <option><%=option%></option>
                                                                                <%  }%>
                                                                            <%})%>
                                                                        </select>

                                                                     <%}%>
																
                                                                </div>
															</div>
                                                           
                                                            
                                                            
                                                            <button class="btn btn-primary" type="submit"> Update Account                       </button>
                                                        </form>
                                                    </div>
                                                </div>
                                            </div>
                                            <div id="transactions" class="tab-pane fade">
												<h4>Add Transaction To User</h4>
                                                <div class="pt-3">
                                                    <div class="settings-form">
                                                        
                                                        <form method="POST" action="/create-user-transactions">
                                                            <div class="form-row">
                                                                <div class="form-group col-md-6">
                                                                    <label>Transaction Type</label>
                                                                   
                                                                        <select class="form-control" name="transactiontype">
                                                                            <option selected>Credit</option>
                                                                            <option>Debit</option>
                                                                        </select>
                                                                     </div>
                                                                <div class="form-group col-md-6">
                                                                    <label>Beneficiary Name</label>
                                                                    <input type="text" class="form-control" name="beneficiaryname" required>
                                                                </div>
															</div>
															<div class="form-row">
                                                                <div class="form-group col-md-6">
																	<label>Beneficiary Bank</label>
                                                                    <input type="text" class="form-control" name="beneficiarybankname" required>
                                                                </div>
                                                                <div class="form-group col-md-6">
                                                                    <label>Bneficiary Bank BIC</label>
																	<input type="text" name="beneficiarybankbic" class="form-control" required>
																	<input type="text" value="<%=owner._id%>" class="form-control" name="userid" hidden>
                                                                </div>
															</div>
															<div class="form-row">
                                                                <div class="form-group col-md-6">
																	<label>Beneficiary Account Number</label>
                                                                    <input type="number" class="form-control" name="beneficiaryaccountnumber" required>
                                                                </div>
                                                                <div class="form-group col-md-6">
                                                                    <label>Amount</label>
                                                                    <input type="number" class="form-control" name="amount">
                                                                </div>
                                                            </div>
                                                            <div class="form-row">
                                                                <div class="form-group col-md-4">
																	<label>User Balance</label>
                                                                    <input type="number" class="form-control" name="balance" required>
                                                                </div>
                                                                <div class="form-group col-md-4">
                                                                    <label>Date </label>
                                                                    <input type="date" class="form-control" name="date" required>
                                                                </div>
                                                                <div class="form-group col-md-4">
                                                                    <label>Status</label>
                                                                    <select class="form-control" name="status">
                                                                        <option selected>Successful</option>
                                                                        <option>Pending</option>
                                                                        <option>Failed</option>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                             <button class="btn btn-primary" type="submit"> Add Transaction                     </button>
                                                        </form>
                                                    </div>
                                                </div>
                                                <h4 class="transaction-list-title">Transaction List</h4>
                                                <div class="col-xl-12">
                                                    <div class="table-responsive table-hover fs-14">
                                                        <table class="table display mb-4 dataTablesCard  card-table" id="example5">
                                                            <thead>
                                                                <tr>
                                                                    <th>
                                                                        <div class="checkbox mr-0 align-self-center">
                                                                            <div class="custom-control custom-checkbox ">
                                                                                <input type="checkbox" class="custom-control-input" id="checkAll" required="">
                                                                                <label class="custom-control-label" for="checkAll"></label>
                                                                            </div>
                                                                        </div>
                                                                    </th>
                                                                    <th>Reference No</th>
                                                                    <th>Date</th>
                                                                    <th>Description</th>
                                                                    <th>Amount</th>
                                                                    <th>Status</th>
                                                                    <th style="text-align: right;">Manage</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <% owner.transfertransactions.forEach(function(transaction){ %>
                                                                    <tr>
                                                                        <td class="pr-0">
                                                                            <%if (transaction.type == 'Credit'){ %>
                                                                                <span class="bgl-success p-3 d-inline-block">
                                                                                    <svg width="29" height="29" viewBox="0 0 29 29" fill="none" xmlns="http://www.w3.org/2000/svg">
                                                                                        <path d="M23.6186 15.7207L23.6186 15.7207L23.6353 22.6289C23.6354 22.6328 23.6354 22.6363 23.6353 22.6396M23.6186 15.7207L23.1353 22.6341L23.6353 22.635C23.6353 22.6481 23.6347 22.6583 23.6345 22.6627L23.6344 22.6642C23.6346 22.6609 23.6351 22.652 23.6353 22.6407C23.6353 22.6403 23.6353 22.64 23.6353 22.6396M23.6186 15.7207C23.6167 14.9268 22.9717 14.2847 22.1777 14.2866C21.3838 14.2885 20.7417 14.9336 20.7436 15.7275L20.7436 15.7275L20.7519 19.1563M23.6186 15.7207L20.7519 19.1563M23.6353 22.6396C23.6329 23.4282 22.9931 24.0705 22.2017 24.0726C22.2 24.0726 22.1983 24.0727 22.1965 24.0727L22.1944 24.0727L22.1773 24.0726L15.2834 24.056L15.2846 23.556L15.2834 24.056C14.4897 24.054 13.8474 23.4091 13.8494 22.615C13.8513 21.8211 14.4964 21.179 15.2903 21.1809L15.2903 21.1809L18.719 21.1892L5.53639 8.0066C4.975 7.44521 4.975 6.53505 5.53639 5.97367C6.09778 5.41228 7.00793 5.41228 7.56932 5.97367L20.7519 19.1563M23.6353 22.6396C23.6353 22.6376 23.6353 22.6356 23.6353 22.6336L20.7519 19.1563M22.1964 24.0726C22.1957 24.0726 22.1951 24.0726 22.1944 24.0726L22.1964 24.0726Z" fill="#2BC155" stroke="#2BC155"></path>
                                                                                    </svg>
                                                                                </span>
                                                                           <% } else { %>
                                                                            <span class="bgl-danger p-3 d-inline-block">
                                                                                <svg width="29" height="29" viewBox="0 0 29 29" fill="none" xmlns="http://www.w3.org/2000/svg">
                                                                                    <path d="M5.13185 13.9043L5.13185 13.9043L5.11515 6.99607C5.11511 6.99224 5.11513 6.98868 5.11517 6.98542M5.13185 13.9043L5.61517 6.99089L5.11517 6.99005C5.11519 6.97692 5.11575 6.96665 5.116 6.96234L5.11608 6.96082C5.11588 6.96411 5.11535 6.97298 5.11519 6.98431C5.11518 6.98468 5.11517 6.98505 5.11517 6.98542M5.13185 13.9043C5.13378 14.6982 5.77881 15.3403 6.57281 15.3384C7.36672 15.3365 8.00877 14.6914 8.00689 13.8975L8.00689 13.8975L7.99856 10.4687M5.13185 13.9043L7.99856 10.4687M5.11517 6.98542C5.11755 6.19684 5.75739 5.55451 6.54875 5.55238C6.55044 5.55236 6.5522 5.55235 6.554 5.55234L6.55606 5.55234L6.57321 5.55239L13.4671 5.56905L13.4658 6.06905L13.4671 5.56905C14.2608 5.57098 14.903 6.21593 14.9011 7.01004C14.8992 7.80394 14.2541 8.44597 13.4602 8.44409L13.4602 8.4441L10.0315 8.43582L23.2141 21.6184C23.7755 22.1798 23.7755 23.0899 23.2141 23.6513C22.6527 24.2127 21.7426 24.2127 21.1812 23.6513L7.99856 10.4687M5.11517 6.98542C5.11516 6.98743 5.11517 6.98943 5.11517 6.99144L7.99856 10.4687M6.5541 5.55237C6.55474 5.55237 6.5554 5.55237 6.55606 5.55238L6.5541 5.55237Z" fill="#FF2E2E" stroke="#FF2E2E"></path>
                                                                                </svg>
                                                                            </span>
                                                                           <% } %>
                                                                        </td>
                                                                        <td><%= transaction.referencenumber %></td>
                                                                        <%if (transaction.admindate == undefined){ %>
                                                                            <% let date = new Date(transaction.date) %>
                                                                            <% let d = date.toDateString() %>
                                                                            <% let t = date.getTime() %>
                                                                            <% let s = date.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"); %>
                                                                        <td><%= d %></td>   
                                                                        <% } else {%>
                                                                        <td><%= transaction.admindate %></td>
                                                                        <% } %>
                                                                        <td style="text-transform: capitalize;"><%=transaction.action%><br><%=transaction.bdetails.bn %> <br><%=transaction.bdetails.bbn%></td>
                                                                        <% if(transaction.type == 'Credit'){ %>
                                                                            <td>
                                                                                <span class="text-success font-w700">+&#x24;<%=transaction.amount.toLocaleString()%></span>
                                                                            </td> 
                                                                       <%   } else{ %>
                                                                            <td>
                                                                                <span class="text-danger font-w700">-&#x24;<%=transaction.amount.toLocaleString()%></span>
                                                                            </td>
                                                                       <% }%>
                                                                       
                                                                        <% let theClass; %>
                                                                        <% if (transaction.status == 'Successful'){ %>
                                                                            <% theClass = 'success' %>
                                                                        <% } else if(transaction.status == 'Pending'){ %>
                                                                            <% theClass = 'warning' %>
                                                                       <%  } else{ %>
                                                                            <% theClass = 'danger' %>
                                                                       <%  } %>
                                                                        <td>
                                                                            <a href="javascript:void(0);" class="btn-link text-<%=theClass%> float-left"><%=transaction.status%></a>
                                                                        </td>
                                                                        
                                                                        <td>
                                                                            <div class="dropdown" style="text-align: right;">
                                                                                <button type="button" class="btn btn-success light sharp" data-toggle="dropdown">
                                                                                    <svg width="20px" height="20px" viewBox="0 0 24 24" version="1.1"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><rect x="0" y="0" width="24" height="24"/><circle fill="#000000" cx="5" cy="12" r="2"/><circle fill="#000000" cx="12" cy="12" r="2"/><circle fill="#000000" cx="19" cy="12" r="2"/></g></svg>
                                                                                </button>
                                                                                <div class="dropdown-menu" >
                                                                                    <a class="dropdown-item" href="/edit-user-transaction/<%=owner._id%>/<%=transaction._id%>">Edit</a>
                                                                                    <a class="dropdown-item" href="/delete-user-transaction/<%=owner._id%>/<%=transaction._id%>">Delete</a>
                                                                                </div>
                                                                            </div>
                                                                        </td>
                                                                    </tr>
                                                                <%  }) %>
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                </div>
                                            </div>
                                            <div id="cardtransactions" class="tab-pane fade">
												<h4>Add Transaction To Card</h4>
                                                <div class="pt-3">
                                                    <div class="settings-form">
                                                        
                                                        <form method="POST" action="/create-user-cardtransactions">
                                                            <div class="form-row">
                                                                <div class="form-group col-md-6">
                                                                    <label>Transaction Type</label>
                                                                   
                                                                        <select class="form-control" name="transactiontype">
                                                                            <option selected>Credit</option>
                                                                            <option>Debit</option>
                                                                        </select>
                                                                     </div>
                                                                <div class="form-group col-md-6">
                                                                    <label>Date</label>
                                                                    <input type="date" class="form-control" name="date" required>
                                                                    <input type="text" value="<%=owner._id%>" class="form-control" name="userid" hidden>
                                                                </div>
															</div>
															
                                                            <div class="form-row">
                                                                <div class="form-group col-md-6">
																	<label>Amount</label>
                                                                    <input type="number" class="form-control" name="amount" required>
                                                                </div>
                                                                <div class="form-group col-md-6">
                                                                    <label>Status</label>
                                                                    <select class="form-control" name="status">
                                                                        <option selected>Successful</option>
                                                                        <option>Pending</option>
                                                                        <option>Failed</option>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                             <button class="btn btn-primary" type="submit"> Add Transaction                     </button>
                                                        </form>
                                                    </div>
                                                </div>
                                                <h4 class="transaction-list-title"> Card  Transaction List</h4>
                                                <div class="col-xl-12">
                                                    <div class="table-responsive table-hover fs-14">
                                                        <table class="table display mb-4 dataTablesCard  card-table" id="example5">
                                                            <thead>
                                                                <tr>
                                                                    <th>
                                                                        <div class="checkbox mr-0 align-self-center">
                                                                            <div class="custom-control custom-checkbox ">
                                                                                <input type="checkbox" class="custom-control-input" id="checkAll" required="">
                                                                                <label class="custom-control-label" for="checkAll"></label>
                                                                            </div>
                                                                        </div>
                                                                    </th>
                                                                    <th>Reference No</th>
                                                                    <th>Date</th>
                                                                    
                                                                    <th>Amount</th>
                                                                    <th>Status</th>
                                                                    <th style="text-align: right;">Manage</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <% owner.cardtransactions.forEach(function(cardtransaction){ %>
                                                                    <tr>
                                                                        <td class="pr-0">
                                                                            <%if (cardtransaction.type == 'Credit'){ %>
                                                                                <span class="bgl-success p-3 d-inline-block">
                                                                                    <svg width="29" height="29" viewBox="0 0 29 29" fill="none" xmlns="http://www.w3.org/2000/svg">
                                                                                        <path d="M23.6186 15.7207L23.6186 15.7207L23.6353 22.6289C23.6354 22.6328 23.6354 22.6363 23.6353 22.6396M23.6186 15.7207L23.1353 22.6341L23.6353 22.635C23.6353 22.6481 23.6347 22.6583 23.6345 22.6627L23.6344 22.6642C23.6346 22.6609 23.6351 22.652 23.6353 22.6407C23.6353 22.6403 23.6353 22.64 23.6353 22.6396M23.6186 15.7207C23.6167 14.9268 22.9717 14.2847 22.1777 14.2866C21.3838 14.2885 20.7417 14.9336 20.7436 15.7275L20.7436 15.7275L20.7519 19.1563M23.6186 15.7207L20.7519 19.1563M23.6353 22.6396C23.6329 23.4282 22.9931 24.0705 22.2017 24.0726C22.2 24.0726 22.1983 24.0727 22.1965 24.0727L22.1944 24.0727L22.1773 24.0726L15.2834 24.056L15.2846 23.556L15.2834 24.056C14.4897 24.054 13.8474 23.4091 13.8494 22.615C13.8513 21.8211 14.4964 21.179 15.2903 21.1809L15.2903 21.1809L18.719 21.1892L5.53639 8.0066C4.975 7.44521 4.975 6.53505 5.53639 5.97367C6.09778 5.41228 7.00793 5.41228 7.56932 5.97367L20.7519 19.1563M23.6353 22.6396C23.6353 22.6376 23.6353 22.6356 23.6353 22.6336L20.7519 19.1563M22.1964 24.0726C22.1957 24.0726 22.1951 24.0726 22.1944 24.0726L22.1964 24.0726Z" fill="#2BC155" stroke="#2BC155"></path>
                                                                                    </svg>
                                                                                </span>
                                                                           <% } else { %>
                                                                            <span class="bgl-danger p-3 d-inline-block">
                                                                                <svg width="29" height="29" viewBox="0 0 29 29" fill="none" xmlns="http://www.w3.org/2000/svg">
                                                                                    <path d="M5.13185 13.9043L5.13185 13.9043L5.11515 6.99607C5.11511 6.99224 5.11513 6.98868 5.11517 6.98542M5.13185 13.9043L5.61517 6.99089L5.11517 6.99005C5.11519 6.97692 5.11575 6.96665 5.116 6.96234L5.11608 6.96082C5.11588 6.96411 5.11535 6.97298 5.11519 6.98431C5.11518 6.98468 5.11517 6.98505 5.11517 6.98542M5.13185 13.9043C5.13378 14.6982 5.77881 15.3403 6.57281 15.3384C7.36672 15.3365 8.00877 14.6914 8.00689 13.8975L8.00689 13.8975L7.99856 10.4687M5.13185 13.9043L7.99856 10.4687M5.11517 6.98542C5.11755 6.19684 5.75739 5.55451 6.54875 5.55238C6.55044 5.55236 6.5522 5.55235 6.554 5.55234L6.55606 5.55234L6.57321 5.55239L13.4671 5.56905L13.4658 6.06905L13.4671 5.56905C14.2608 5.57098 14.903 6.21593 14.9011 7.01004C14.8992 7.80394 14.2541 8.44597 13.4602 8.44409L13.4602 8.4441L10.0315 8.43582L23.2141 21.6184C23.7755 22.1798 23.7755 23.0899 23.2141 23.6513C22.6527 24.2127 21.7426 24.2127 21.1812 23.6513L7.99856 10.4687M5.11517 6.98542C5.11516 6.98743 5.11517 6.98943 5.11517 6.99144L7.99856 10.4687M6.5541 5.55237C6.55474 5.55237 6.5554 5.55237 6.55606 5.55238L6.5541 5.55237Z" fill="#FF2E2E" stroke="#FF2E2E"></path>
                                                                                </svg>
                                                                            </span>
                                                                           <% } %>
                                                                        </td>
                                                                        <td><%= cardtransaction.referencenumber %></td>
                                                                       
                                                                        <td><%= cardtransaction.admindate %></td>
                                                                       
                                                                        
                                                                        <% if(cardtransaction.type == 'Credit'){ %>
                                                                            <td>
                                                                                <span class="text-success font-w700">+&#x24;<%=cardtransaction.amount.toLocaleString()%></span>
                                                                            </td> 
                                                                       <%   } else{ %>
                                                                            <td>
                                                                                <span class="text-danger font-w700">-&#x24;<%=cardtransaction.amount.toLocaleString()%></span>
                                                                            </td>
                                                                       <% }%>
                                                                       
                                                                        <% let thecardclass; %>
                                                                        <% if (cardtransaction.status == 'Successful'){ %>
                                                                            <% thecardclass = 'success' %>
                                                                        <% } else if(cardtransaction.status == 'Pending'){ %>
                                                                            <% thecardclass = 'warning' %>
                                                                       <%  } else{ %>
                                                                            <% thecardclass = 'danger' %>
                                                                       <%  } %>
                                                                        <td>
                                                                            <a href="javascript:void(0);" class="btn-link text-<%=thecardclass%> float-left"><%=cardtransaction.status%></a>
                                                                        </td>
                                                                        
                                                                        <td>
                                                                            <div class="dropdown" style="text-align: right;">
                                                                                <button type="button" class="btn btn-success light sharp" data-toggle="dropdown">
                                                                                    <svg width="20px" height="20px" viewBox="0 0 24 24" version="1.1"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><rect x="0" y="0" width="24" height="24"/><circle fill="#000000" cx="5" cy="12" r="2"/><circle fill="#000000" cx="12" cy="12" r="2"/><circle fill="#000000" cx="19" cy="12" r="2"/></g></svg>
                                                                                </button>
                                                                                <div class="dropdown-menu" >
                                                                                    <a class="dropdown-item" href="/edit-user-cardtransaction/<%=owner._id%>/<%=cardtransaction._id%>">Edit</a>
                                                                                    <a class="dropdown-item" href="/delete-user-cardtransaction/<%=owner._id%>/<%=cardtransaction._id%>">Delete</a>
                                                                                </div>
                                                                            </div>
                                                                        </td>
                                                                    </tr>
                                                                <%  }) %>
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                </div>
                                            </div>
                                            <div id="loantransactions" class="tab-pane fade">
												<h4>Add Loan History To User</h4>
                                                <div class="pt-3">
                                                    <div class="settings-form">
                                                        
                                                        <form method="POST" action="/create-loans-admin">
                                                            <div class="row form-row">
                                                                <div class="single-field">
                                                                    <select id="loantype" name="loantype">
                                                                        <option selected>Personal Loans</option>
                                                                        <option>Car Loans</option>
                                                                        <option>Business Loans</option>
                                                                        <option>Home Loans</option>
                                                                    </select>
                                                                    
                                                                </div>
                                                                <div class="single-field">
                                                                    <input class="elp" id="loanamount" name="loanamount" type="number" placeholder="Enter Loan Amount" min="0" required>
                                                                </div>
                                                            </div>
                                                            <div class="row form-row">
                                                                <div class="single-field">
                                                                    <input class="elp" type="number" id="duration" name="duration" placeholder="Enter Duration in Months" min="0" required>
                                                                    
                                                                </div>
                                                                <div class="single-field">
                                                                    <input id="amountdue" name="amountdue" type="number" min="0" placeholder="Amount Due" readonly>
                                                                </div>
                                                                <input type="text" value="<%=owner._id%>" class="form-control" name="userid" hidden>
                                                            </div>
                                                            <button class="submit" id="loany">Submit Request</button>
                                                        </form>
                                                    </div>
                                                </div>
                                                <h4 class="transaction-list-title"> Loan  Request List</h4>
                                                <div class="col-xl-12">
                                                    <div class="table-responsive table-hover fs-14">
                                                        
                                                        <table class="table display mb-4 dataTablesCard  card-table" id="example5">
                                                            <thead>
                                                                <tr>
                                                                    
                                                                    <th>Transaction ID</th>
                                                                    <th>Date</th>
                                                                    <th>Amount</th>
                                                                    <th>Amount Due</th>
                                                                    <th>Type</th>
                                                                    
                                                                    <th>Status</th>
                                                                    <th style="text-align: right;">Manage</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                               
                                                                <%owner.loanrequests.forEach(function(loans){ %>
                                                                    <tr>
                                                                    
                                                                        <td><%=loans.referencenumber%></td>
                                                                        <% let date = new Date(loans.date) %>
                                                                        <td class="wspace-no"><%= date.toDateString()%></td>
                                                                        <td>
                                                                            <span class="text-success font-w700">+$ <%=loans.amount%></span>
                                                                        </td>
                                                                        <td>
                                                                            <span class="text-success font-w700">+$ <%=loans.amountdue.toFixed(2)%></span>
                                                                        </td>
                                                                        <td><%=loans.type%></td>
                                                                    
                                                                        <% let theClass; %>
                                                                        <% if (loans.status == 'Successful'){ %>
                                                                            <% theClass = 'success' %>
                                                                        <% } else if(loans.status == 'Pending'){ %>
                                                                            <% theClass = 'warning' %>
                                                                       <%  } else{ %>
                                                                            <% theClass = 'danger' %>
                                                                       <%  } %>
                                                                       
                                                                        
                                                                        
                                                                        <td>
                                                                            <a href="javascript:void(0);" class="btn-link text-<%=theClass%> float-right"><%=loans.status%></a>
                                                                        </td>
                                                                        <td>
                                                                            <div class="dropdown" style="text-align: right;">
                                                                                <button type="button" class="btn btn-success light sharp" data-toggle="dropdown">
                                                                                    <svg width="20px" height="20px" viewBox="0 0 24 24" version="1.1"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><rect x="0" y="0" width="24" height="24"/><circle fill="#000000" cx="5" cy="12" r="2"/><circle fill="#000000" cx="12" cy="12" r="2"/><circle fill="#000000" cx="19" cy="12" r="2"/></g></svg>
                                                                                </button>
                                                                                <div class="dropdown-menu" >
                                                                                    <a class="dropdown-item" href="/edit-user-loans/<%=owner._id%>/<%=loans._id%>">Edit</a>
                                                                                    <a class="dropdown-item" href="/delete-user-loan/<%=owner._id%>/<%=loans._id%>">Delete</a>
                                                                                </div>
                                                                            </div>
                                                                        </td>
                                                                    </tr>
                                                                <%})%>
                                                            
                                                            
                                                                
                                                            
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--**********************************
            Content body end
        ***********************************-->


        <!--**********************************
            Footer start
        ***********************************-->
        <div class="footer">
            <div class="copyright">
                <p>Copyright © 2024 Fountain Core Finance</p>
            </div>
        </div>
        <!--**********************************
            Footer end
        ***********************************-->

        <!--**********************************
           Support ticket button start
        ***********************************-->

        <!--**********************************
           Support ticket button end
        ***********************************-->

        
    </div>
    <!--**********************************
        Main wrapper end
    ***********************************-->
	
	<!--removeIf(production)-->
        
    <!--**********************************
        Scripts
    ***********************************-->
    <!-- Required vendors -->
    <script src="/vendor/global/global.min.js"></script>
	<script src="/vendor/bootstrap-select/dist/js/bootstrap-select.min.js"></script>
    <script src="/js/custom.min.js"></script>
	<script src="/js/deznav-init.js"></script>
	
    
    <script>
		
		let amountdue = document.getElementById('amountdue')
		let loantype = document.querySelector('.filter-option-inner-inner')
		document.querySelectorAll('.elp').forEach(function(elp){
			elp.addEventListener('input', function(){
				let amount = parseInt(document.getElementById('loanamount').value)
				let duration = parseInt(document.getElementById('duration').value)
				amountdue.value = Math.ceil(amount + (amount * 0.01 * (duration/12)))
				
			})
		})
	</script>


	
		
</body>


</html>