{% extends 'base.html.twig' %}
{% block stylesheets %}
{{ parent() }}
<link href="https://fonts.googleapis.com/css2?family=Amaranth:ital,wght@0,400;0,700;1,400;1,700&family=Fjord+One&family=Nova+Flat&family=Oswald:wght@200&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Oswald|Slabo+27px" rel="stylesheet">
<link rel="stylesheet" href="{{ asset('assets/plugins/fontawesome-free-5.3.1-web/css/all.min.css') }}">
<link href="{{ asset('fos/plugins/fonts/Amaranth/amaranth.css') }}" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="{{ asset('assets/plugins/bootstrap-4.1.1/css/bootstrap.min.css') }}">
<style>
.login-page {
width: 50%;
margin: auto;
margin-top: 4%;
}
.form {
z-index: 1;
background: #FFFFFF;
max-width: 700px;
width: 680px;
padding: 45px;
text-align: center;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
height: auto;
margin: auto;
}
.nav p {
font-family: "Amaranth", sans-serif;
text-align: left;
font-size: 12px;
text-transform: uppercase;
line-height: 12px;
color: #6a6a6a;
}
.nav .nav-link.active p b {
font-size: 16px;
color: black;
zoom:1;
}
.nav-tabs {
text-align:center;
}
.nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active {
color: #495057;
background-color: #fff;
border-color: #ffffff #ffffff #ff0000;
}
.nav-tabs .nav-link {
border: 2px solid transparent;
border-top-left-radius: .25rem;
border-top-right-radius: .25rem;
}
.request {
text-align: center;
margin: 15px auto 4px auto;
font-family: "Amaranth", sans-serif;
}
.request button {
margin-top: 20px;
font-family:"Amaranth", sans-serif;
}
.request-other-btn {
text-align: center;
margin: 20px auto 0px -60px;
font-family: "Amaranth", sans-serif;
}
#poweredby{
font-family: Oswald, serif;
font-size: 12px;
padding: 5px;
text-align: center;
}
#poweredby span{
color: red;
}
table td {
/*text-align: left;*/
font-family: "Amaranth", sans-serif;
}
#payments {
margin-top: 20px;
}
.table thead th {
/*text-align: left;*/
font-family: "Nova Flat", Sans-serif, serif;
font-size: 12px;
}
.input-container {
display: -ms-flexbox; /* IE10 */
display: flex;
width: 100%;
}
.icon {
padding: 10px;
background: #b1b1b157;
color: #121212;
min-width: 50px;
text-align: center;
font-size: 28px;
border-bottom-left-radius: 5px;
border-top-left-radius: 5px;
}
.input-field {
width: 100%;
padding: 10px;
outline: none;
border: 1px solid #0000000d;
}
.input-field:focus {
border: 2px solid #b1b1b157;
}
.btn:hover {
opacity: 1;
}
form {
text-align: left;
}
form .help-block {
margin-left: 2px;
color: red;
}
td .btn {
margin-top: 12px;
}
.request_fields {
display: none;
}
.reload, .continue, .back-cash{
border-radius: 30px;
}
.mpesa-detail {
font-family: 'Amaranth', serif;
text-align: left;
text-transform: uppercase;
}
.mpesa-detail span {
font-family: "monospace", sans-serif;
font-size: 14px;
font-weight: normal;
}
.mpesa-detail .fas {
color: orange;
}
.back-cash img {
height: 20px;
}
.parcel b{
font-family: 'Amaranth', serif;
}
.parcel span {
/*font-family: 'Oswald', sans-serif;*/
font-family: monospace;
font-size: 18px;
}
.continue {
font-family: 'Amaranth', sans-serif;
}
.input-field {
}
.input-field input {
margin-right: 5px;
}
.input-field label {
width: 90%;
font-size: 12px;
text-transform: uppercase;
font-family: monospace;
}
</style>
{% endblock %}
{% block head %}
{% endblock %}
{% block main %}
<div class="login-page">
<div class="form">
{% block responseflash %}
{% for flash_message in app.session.flashBag.get('success') %}
<div class="alert alert-success alert-dismissable in pro">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>Success:</strong> {{ flash_message }}
</div>
{% endfor %}
{% for flash_message in app.session.flashBag.get('warning') %}
<div class="alert alert-warning alert-dismissable in pro">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>Warning: </strong> {{ flash_message }}
</div>
{% endfor %}
{% for flash_message in app.session.flashBag.get('error') %}
<div class="alert alert-danger alert-dismissable in pro">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>Error:</strong> {{ flash_message }}
</div>
{% endfor %}
{% endblock %}
<nav>
<div class="nav nav-tabs justify-content-center" id="nav-tab" role="tablist">
<a class="nav-item nav-link active" id="nav-sender-tab" data-toggle="tab" href="#nav-sender" role="tab" aria-controls="nav-sender" aria-selected="true">
<p> SENDER <br>
<b>{{ transaction.wayBill.senderName }}<br>
{{ transaction.wayBill.senderPhoneNumber }}</b>
</p>
</a>
<a class="nav-item nav-link" id="nav-receiver-tab" data-toggle="tab" href="#nav-receiver" role="tab" aria-controls="nav-receiver" aria-selected="false">
<p> RECEIVER <br>
<b>{{ transaction.wayBill.receiverName }}<br>
{{ transaction.wayBill.receiverPhoneNumber }}</b>
</p>
</a>
<a class="nav-item nav-link" id="nav-other-tab" data-toggle="tab" href="#nav-other" role="tab" aria-controls="nav-other" aria-selected="false">
<p>OTHER</p>
</a>
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-sender" role="tabpanel" aria-labelledby="nav-sender-tab">
<div class="row">
<div class="col-lg-12 request">
{{ form_start(senderForm) }}
<div class="request_fields">
{{ form_widget(senderForm.phone,{'attr':{'class':'form-control' , 'value': transaction.wayBill.senderPhoneNumber }} ) }}
{{ form_widget(senderForm.field,{'attr':{'class':'form-control', 'value': 'SENDER'}} ) }}
</div>
<button type="submit" class="btn btn-success" name="action" value="sender_form">
<i><img src="{{ asset('fos/images/m-pesa-icon.svg') }}" alt=""></i>
Request M-PESA
<i class="fas fa-arrow-circle-right"></i>
</button>
{{ form_end(senderForm) }}
</div>
</div>
</div>
<div class="tab-pane fade" id="nav-receiver" role="tabpanel" aria-labelledby="nav-receiver-tab">
<div class="row">
<div class="col-lg-12 request">
{{ form_start(receiverForm) }}
<div class="request_fields" >
{{ form_widget(receiverForm.phone,{'attr':{'class':'form-control' , 'value': transaction.wayBill.receiverPhoneNumber }} ) }}
{{ form_widget(receiverForm.field,{'attr':{'class':'form-control', 'value': 'RECEIVER'}} ) }}
</div>
<button type="submit" class="btn btn-success" name="action" value="receiver_form">
<i><img src="{{ asset('fos/images/m-pesa-icon.svg') }}" alt=""></i>
Request M-PESA
<i class="fas fa-arrow-circle-right"></i>
</button>
{{ form_end(receiverForm) }}
</div>
</div>
</div>
<div class="tab-pane fade" id="nav-other" role="tabpanel" aria-labelledby="nav-other-tab">
{{ form_start(otherForm)}}
<div class="row">
<div class="col-lg-6 request">
<div class="input-container">
<i class="fas fa-mobile icon"></i>
{{ form_widget(otherForm.phone,{'attr':{'id':'phone','class':'input-field other-field' , 'placeholder': '0720 000 000' }} ) }}
<span class="help-block">
{{ form_errors(otherForm.phone) }}
</span>
{{ form_widget(otherForm.field,{'attr':{'class':'form-control other', 'value': 'OTHER', 'style':'display:none'}} ) }}
</div>
</div>
<div class="col-lg-6 request-other-btn">
<button type="submit" class="btn btn-success" name="action" value="other_form">
<i><img src="{{ asset('fos/images/m-pesa-icon.svg') }}" alt=""></i>
Request M-PESA
<i class="fas fa-arrow-circle-right"></i>
</button>
</div>
</div>
{{ form_end(otherForm) }}
</div>
</div>
<div class="row">
<div class="col-lg-12">
<table class="table table-bordered">
<thead class="thead-light">
<tr>
<th>Waybill</th>
<th>Amount</th>
<th>Balance</th>
</tr>
</thead>
<tbody>
<tr>
<td>
{{ transaction.wayBill.id }}
</td>
<td>
{{ transaction.amount }}
</td>
<td>
<span id="balance"></span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-lg-12">
<div class="row" style="margin-top: 20px;">
<div class="col">
<table id="payments"
class="easyui-datagrid"
style="width:100%; font-weight:normal; text-transform: uppercase; margin-top: 20px;"
singleSelect=true
rownumbers=true
pageSize=30
fitColumns=true>
<thead>
<tr>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-4 request">
<br>
<a href="{{ path('one_way_bill', {'id': transaction.wayBill.id }) }}" class="btn btn-success back-cash" >
<i class="fas fa-arrow-circle-left"></i>
Cash
<i><img src="{{ asset('fos/images/money_icon.png') }}" alt=""></i>
</a>
</div>
<div class="col-lg-4 request">
<button type="button" class="btn btn-success reload" onclick="$('#payments').datagrid('reload');" >
<i class="fas fa-redo"></i>
Refresh
</button>
</div>
<div class="col-lg-4 request">
</div>
</div>
<hr>
<div class="row">
{# <div class="col-lg-3">#}
{# <div class="parcel">#}
{# <b>Waybill</b> <br>#}
{# <span>{{ transaction.wayBill.id }}</span><br>#}
{# <b>Amount</b> <br>#}
{# <span>KES{{ transaction.amount }}</span>#}
{# </div>#}
{# <div class="balance">#}
{# balance: <span id="balance"></span>#}
{# </div>#}
{# </div>#}
<div class="col-lg-6">
<div id="mpesa-detail_" style="display: none" class="row">
</div>
</div>
<div class="col-lg-6">
{{ form_start(mpesaSelectionForm, {'attr': { 'style':' display: block'}})}}
{{ form_widget(mpesaSelectionForm.mpesa,{'attr':{'id':'form_id','class':'input-field', 'style':'display: none' }} ) }}
<button type="submit" class="btn btn-warning continue" onclick="" disabled>
Complete
<i class="fas fa-arrow-circle-right"></i>
</button>
{{ form_end(mpesaSelectionForm)}}
{{ form_start(mpesaCashSelectionForm, {'attr': { 'style':' display: block'}})}}
{{ form_widget(mpesaCashSelectionForm.mpesa,{'attr':{'id':'form_id','class':'input-field', 'style':'display: none' }} ) }}
<button type="submit" class="btn btn-warning continue_cash" onclick="" disabled>
Complete with cash
<i class="fas fa-arrow-circle-right"></i>
</button>
{{ form_end(mpesaCashSelectionForm)}}
<span id="balance"></span>
</div>
</div>
</div>
<div id="poweredby">
<hr/>
powered by <span>© Ohau Technologies, ltd</span>
</div>
</div>
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script>
$('.other-field').mask('0000 000 000');
$('#payments').datagrid({
url:'/payment/list',
method: 'post',
pageSize:20,
singleSelect: false,
rownumbers:true,
remoteFilter:true,
pagination:true,
fitColumns:true,
collapsible:true,
onSelect: function(index, row){
selectRow(index,row);
// mpesa_payment_selection_id.value = row.id;
// mpesa_payment_selection_amount.value = row.transaction_amount;
},onLoadSuccess(index, field, value) {
$(".continue").attr("disabled", true);
$("#mpesa-detail_").css('display','none');
$(".continue_cash").attr("disabled", true);
mpesa_cash_payment_selection_mpesa.innerHTML = '';
mpesa_payment_selection_mpesa.innerHTML = '';
for(let i=0; i<document.getElementsByName("mpesa_payment_selection[mpesa][]").length; i++){
let id = document.getElementsByName("mpesa_payment_selection[mpesa][]")[i].id;
document.getElementById(id).checked = false;
}
for(let i=0; i<document.getElementsByName("mpesa_cash_payment_selection[mpesa][]").length; i++){
let id = document.getElementsByName("mpesa_cash_payment_selection[mpesa][]")[i].id;
document.getElementById(id).checked = false;
}
// mpesa_payment_selection_amount.value = '';
// mpesa_payment_selection_id.value = '';
//
// amount.innerHTML = '';
// name_.innerHTML = '';
// phone.innerHTML = '';
// time.innerHTML = '';
// transaction.innerHTML ='';
},onUnselect(index, row){
selectRow(index, row);
},
columns: [[
{field:'ck',title:'NAME',width:20, checkbox: true},
{field:'name',title:'NAME',width:50,formatter:function(value,row,index){
return `${row.first_name} ${row.middle_name} ${row.last_name}`;
}},
{field:'transaction_id',title:'TRANSACTION ID',width:80,formatter:function(value,row,index){
return row.transaction_id;
}},
{field:'phone',title:'PHONE',width:50,formatter:function(value,row,index){
return row.msisdn;
}},
{field:'created_at',title:'TIME',width:80,formatter:function(value,row,index){
return row.created_at;
}},
{field:'transaction_Amount',title:'AMOUNT',width:50,formatter:function(value,row,index){
return row.transaction_amount;
}}
]]
});
function continue_(){
$('#tt').datagrid('getSelected')
let row = $('#tt').datagrid('getSelected');
if (row){
alert('Item ID:'+row.itemid+"\nPrice:"+row.listprice);
}
}
function selectRow(index, row) {
$("#mpesa-detail_").css('display','block');
$(".continue_cash").attr("disabled", true);
console.log(row);
console.log(row.first_name+' selected');
let rows = $('#payments').datagrid('getSelections');
console.log(row.first_name+' selected '+rows.length);
for(let i=0; i<document.getElementsByName("mpesa_payment_selection[mpesa][]").length; i++){
let id = document.getElementsByName("mpesa_payment_selection[mpesa][]")[i].id;
document.getElementById(id).checked = false;
}
for(let i=0; i<document.getElementsByName("mpesa_cash_payment_selection[mpesa][]").length; i++){
let id = document.getElementsByName("mpesa_cash_payment_selection[mpesa][]")[i].id;
document.getElementById(id).checked = false;
}
let html = '';
let selectedTotal = 0;
let checkboxes = '';
let mpesaCheckboxes = '';
for(let i=0; i<rows.length; i++) {
selectedTotal += (rows[i].transaction_amount * 1);
html +=
`<div class="col-lg-12">
<p class="mpesa-detail" id="mpesa_all_details">
<b>MPESA </b><i class="fas fa-arrow-circle-right"></i><span id="name_"> ${rows[i].first_name} ${rows[i].middle_name} ${rows[i].last_name} </span><br>
<b>AMOUNT </b> <i class="fas fa-arrow-circle-right"></i><span id="amount">${rows[i].transaction_amount}</span><br>
<!-- <b>PHONE </b><i class="fas fa-arrow-circle-right"></i> <span id="phone">${rows[i].msisdn}</span><br>-->
<b>TIME </b><i class="fas fa-arrow-circle-right"></i> <span id="time">${rows[i].created_at}</span><br>
<b>TRANSACTION </b><i class="fas fa-arrow-circle-right"></i> <span id="transaction">${rows[i].transaction_id}</span><br>
</p>
</div>`;
checkboxes += `
<input type="checkbox" id="mpesa_cash_payment_selection_mpesa_${rows[i].id}" name="mpesa_cash_payment_selection[mpesa][]" value="${rows[i].id}" checked>
<label for="mpesa_cash_payment_selection_mpesa_${rows[i].id}" >${rows[i].first_name} ${rows[i].middle_name} ${rows[i].last_name}</label>`;
mpesaCheckboxes += `
<input type="checkbox" id="mpesa_payment_selection_mpesa_${rows[i].id}" name="mpesa_payment_selection[mpesa][]" value="${rows[i].id}" checked>
<label for="mpesa_payment_selection_mpesa_${rows[i].id}" >${rows[i].first_name} ${rows[i].middle_name} ${rows[i].last_name}</label>`;
if(document.getElementById("mpesa_payment_selection_mpesa_"+rows[i])) {
document.getElementById("mpesa_payment_selection_mpesa_"+rows[i].id).checked = true;
document.getElementById("mpesa_cash_payment_selection_mpesa_"+rows[i].id).checked = true;
}
}
mpesa_cash_payment_selection_mpesa.innerHTML = checkboxes;
mpesa_payment_selection_mpesa.innerHTML = mpesaCheckboxes;
document.getElementById("mpesa-detail_").innerHTML = html;
let paymentBalance = {{ transaction.amount }} - selectedTotal;
document.getElementById("balance").innerHTML = paymentBalance;
$(".continue_cash").attr("disabled", true);
if(paymentBalance === 0){
$(".continue").attr("disabled", false);
}else{
$(".continue").attr("disabled", true);
if(paymentBalance <= 0){
$(".continue_cash").attr("disabled", true);
console.log('disable continue-cash');
}else{
$(".continue_cash").attr("disabled", false);
console.log('enable continue-cash '+paymentBalance);
}
}
}
</script>
{% endblock %}