templates/payment/payment.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block stylesheets %}
  3.     {{ parent() }}
  4.     <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">
  5.     <link href="https://fonts.googleapis.com/css?family=Oswald|Slabo+27px" rel="stylesheet">
  6.     <link rel="stylesheet" href="{{ asset('assets/plugins/fontawesome-free-5.3.1-web/css/all.min.css') }}">
  7.     <link href="{{ asset('fos/plugins/fonts/Amaranth/amaranth.css') }}" rel="stylesheet" type="text/css">
  8.     <link rel="stylesheet" href="{{ asset('assets/plugins/bootstrap-4.1.1/css/bootstrap.min.css') }}">
  9.     <style>
  10.         .login-page {
  11.             width: 50%;
  12.             margin: auto;
  13.             margin-top: 4%;
  14.         }
  15.         .form {
  16.             z-index: 1;
  17.             background: #FFFFFF;
  18.             max-width: 700px;
  19.             width: 680px;
  20.             padding: 45px;
  21.             text-align: center;
  22.             box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
  23.             height: auto;
  24.             margin: auto;
  25.         }
  26.         .nav p {
  27.             font-family: "Amaranth", sans-serif;
  28.             text-align: left;
  29.             font-size: 12px;
  30.             text-transform: uppercase;
  31.             line-height: 12px;
  32.             color: #6a6a6a;
  33.         }
  34.         .nav .nav-link.active p b {
  35.             font-size: 16px;
  36.             color: black;
  37.             zoom:1;
  38.         }
  39.         .nav-tabs {
  40.             text-align:center;
  41.         }
  42.         .nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active {
  43.             color: #495057;
  44.             background-color: #fff;
  45.             border-color: #ffffff #ffffff #ff0000;
  46.         }
  47.         .nav-tabs .nav-link {
  48.             border: 2px solid transparent;
  49.             border-top-left-radius: .25rem;
  50.             border-top-right-radius: .25rem;
  51.         }
  52.         .request {
  53.             text-align: center;
  54.             margin: 15px auto 4px auto;
  55.             font-family: "Amaranth", sans-serif;
  56.         }
  57.         .request button {
  58.             margin-top: 20px;
  59.             font-family:"Amaranth", sans-serif;
  60.         }
  61.         .request-other-btn {
  62.             text-align: center;
  63.             margin: 20px auto 0px -60px;
  64.             font-family: "Amaranth", sans-serif;
  65.         }
  66.         #poweredby{
  67.             font-family: Oswald, serif;
  68.             font-size: 12px;
  69.             padding: 5px;
  70.             text-align: center;
  71.         }
  72.         #poweredby span{
  73.             color: red;
  74.         }
  75.         table td {
  76.             /*text-align: left;*/
  77.             font-family:  "Amaranth", sans-serif;
  78.         }
  79.         #payments {
  80.             margin-top: 20px;
  81.         }
  82.         .table thead th {
  83.             /*text-align: left;*/
  84.             font-family: "Nova Flat", Sans-serif, serif;
  85.             font-size: 12px;
  86.         }
  87.         .input-container {
  88.             display: -ms-flexbox; /* IE10 */
  89.             display: flex;
  90.             width: 100%;
  91.         }
  92.         .icon {
  93.             padding: 10px;
  94.             background: #b1b1b157;
  95.             color: #121212;
  96.             min-width: 50px;
  97.             text-align: center;
  98.             font-size: 28px;
  99.             border-bottom-left-radius: 5px;
  100.             border-top-left-radius: 5px;
  101.         }
  102.         .input-field {
  103.             width: 100%;
  104.             padding: 10px;
  105.             outline: none;
  106.             border: 1px solid #0000000d;
  107.         }
  108.         .input-field:focus {
  109.             border: 2px solid #b1b1b157;
  110.         }
  111.         .btn:hover {
  112.             opacity: 1;
  113.         }
  114.         form {
  115.             text-align: left;
  116.         }
  117.         form .help-block {
  118.             margin-left: 2px;
  119.             color: red;
  120.         }
  121.         td .btn {
  122.             margin-top: 12px;
  123.         }
  124.         .request_fields {
  125.             display: none;
  126.         }
  127.         .reload, .continue, .back-cash{
  128.             border-radius: 30px;
  129.         }
  130.         .mpesa-detail {
  131.             font-family: 'Amaranth', serif;
  132.             text-align: left;
  133.             text-transform: uppercase;
  134.         }
  135.         .mpesa-detail span {
  136.             font-family: "monospace", sans-serif;
  137.             font-size: 14px;
  138.             font-weight: normal;
  139.         }
  140.         .mpesa-detail .fas {
  141.             color: orange;
  142.         }
  143.         .back-cash img {
  144.             height: 20px;
  145.         }
  146.         .parcel b{
  147.             font-family: 'Amaranth', serif;
  148.         }
  149.         .parcel span {
  150.             /*font-family: 'Oswald', sans-serif;*/
  151.             font-family: monospace;
  152.             font-size: 18px;
  153.         }
  154.         .continue {
  155.             font-family: 'Amaranth', sans-serif;
  156.         }
  157.         .input-field {
  158.         }
  159.         .input-field input {
  160.             margin-right: 5px;
  161.         }
  162.         .input-field label {
  163.             width: 90%;
  164.             font-size: 12px;
  165.             text-transform: uppercase;
  166.             font-family: monospace;
  167.         }
  168.     </style>
  169. {% endblock %}
  170. {% block head %}
  171. {% endblock %}
  172. {% block main %}
  173.     <div class="login-page">
  174.         <div class="form">
  175.             {% block responseflash %}
  176.                 {% for flash_message in app.session.flashBag.get('success') %}
  177.                     <div class="alert alert-success alert-dismissable in pro">
  178.                         <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
  179.                         <strong>Success:</strong> {{ flash_message }}
  180.                     </div>
  181.                 {% endfor %}
  182.                 {% for flash_message in app.session.flashBag.get('warning') %}
  183.                     <div class="alert alert-warning alert-dismissable in pro">
  184.                         <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
  185.                         <strong>Warning: </strong> {{ flash_message }}
  186.                     </div>
  187.                 {% endfor %}
  188.                 {% for flash_message in app.session.flashBag.get('error') %}
  189.                     <div class="alert alert-danger alert-dismissable  in pro">
  190.                         <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
  191.                         <strong>Error:</strong> {{ flash_message }}
  192.                     </div>
  193.                 {% endfor %}
  194.             {% endblock %}
  195.             <nav>
  196.                 <div class="nav nav-tabs justify-content-center" id="nav-tab" role="tablist">
  197.                     <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">
  198.                         <p> SENDER <br>
  199.                             <b>{{ transaction.wayBill.senderName }}<br>
  200.                                 {{ transaction.wayBill.senderPhoneNumber }}</b>
  201.                         </p>
  202.                     </a>
  203.                     <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">
  204.                         <p> RECEIVER <br>
  205.                             <b>{{ transaction.wayBill.receiverName }}<br>
  206.                                 {{ transaction.wayBill.receiverPhoneNumber }}</b>
  207.                         </p>
  208.                     </a>
  209.                     <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">
  210.                         <p>OTHER</p>
  211.                     </a>
  212.                 </div>
  213.             </nav>
  214.             <div class="tab-content" id="nav-tabContent">
  215.                 <div class="tab-pane fade show active" id="nav-sender" role="tabpanel" aria-labelledby="nav-sender-tab">
  216.                     <div class="row">
  217.                         <div class="col-lg-12 request">
  218.                             {{ form_start(senderForm) }}
  219.                             <div class="request_fields">
  220.                                 {{ form_widget(senderForm.phone,{'attr':{'class':'form-control' , 'value': transaction.wayBill.senderPhoneNumber }} ) }}
  221.                                 {{ form_widget(senderForm.field,{'attr':{'class':'form-control', 'value': 'SENDER'}} ) }}
  222.                             </div>
  223.                             <button type="submit" class="btn btn-success" name="action" value="sender_form">
  224.                                 <i><img src="{{ asset('fos/images/m-pesa-icon.svg') }}" alt=""></i>
  225.                                 Request M-PESA
  226.                                 <i class="fas fa-arrow-circle-right"></i>
  227.                             </button>
  228.                             {{ form_end(senderForm) }}
  229.                         </div>
  230.                     </div>
  231.                 </div>
  232.                 <div class="tab-pane fade" id="nav-receiver" role="tabpanel" aria-labelledby="nav-receiver-tab">
  233.                     <div class="row">
  234.                         <div class="col-lg-12 request">
  235.                             {{ form_start(receiverForm) }}
  236.                             <div class="request_fields" >
  237.                                 {{ form_widget(receiverForm.phone,{'attr':{'class':'form-control' , 'value': transaction.wayBill.receiverPhoneNumber }} ) }}
  238.                                 {{ form_widget(receiverForm.field,{'attr':{'class':'form-control', 'value': 'RECEIVER'}} ) }}
  239.                             </div>
  240.                             <button type="submit" class="btn btn-success" name="action" value="receiver_form">
  241.                                 <i><img src="{{ asset('fos/images/m-pesa-icon.svg') }}" alt=""></i>
  242.                                 Request M-PESA
  243.                                 <i class="fas fa-arrow-circle-right"></i>
  244.                             </button>
  245.                             {{ form_end(receiverForm) }}
  246.                         </div>
  247.                     </div>
  248.                 </div>
  249.                 <div class="tab-pane fade" id="nav-other" role="tabpanel" aria-labelledby="nav-other-tab">
  250.                     {{ form_start(otherForm)}}
  251.                     <div class="row">
  252.                             <div class="col-lg-6 request">
  253.                                 <div class="input-container">
  254.                                     <i class="fas fa-mobile icon"></i>
  255.                                     {{ form_widget(otherForm.phone,{'attr':{'id':'phone','class':'input-field other-field' , 'placeholder': '0720 000 000' }} ) }}
  256.                                     <span class="help-block">
  257.                                              {{ form_errors(otherForm.phone) }}
  258.                                           </span>
  259.                                     {{ form_widget(otherForm.field,{'attr':{'class':'form-control other', 'value': 'OTHER', 'style':'display:none'}} ) }}
  260.                                 </div>
  261.                             </div>
  262.                             <div class="col-lg-6 request-other-btn">
  263.                                 <button type="submit" class="btn btn-success" name="action" value="other_form">
  264.                                     <i><img src="{{ asset('fos/images/m-pesa-icon.svg') }}" alt=""></i>
  265.                                     Request M-PESA
  266.                                     <i class="fas fa-arrow-circle-right"></i>
  267.                                 </button>
  268.                             </div>
  269.                     </div>
  270.                     {{ form_end(otherForm) }}
  271.                 </div>
  272.             </div>
  273.             <div class="row">
  274.                 <div class="col-lg-12">
  275.                     <table class="table table-bordered">
  276.                         <thead class="thead-light">
  277.                         <tr>
  278.                             <th>Waybill</th>
  279.                             <th>Amount</th>
  280.                             <th>Balance</th>
  281.                         </tr>
  282.                         </thead>
  283.                         <tbody>
  284.                         <tr>
  285.                             <td>
  286.                                 {{ transaction.wayBill.id }}
  287.                             </td>
  288.                             <td>
  289.                                 {{ transaction.amount }}
  290.                             </td>
  291.                             <td>
  292.                                 <span id="balance"></span>
  293.                             </td>
  294.                          </tr>
  295.                         </tbody>
  296.                     </table>
  297.                 </div>
  298.                 <div class="col-lg-12">
  299.                     <div class="row" style="margin-top: 20px;">
  300.                         <div class="col">
  301.                             <table id="payments"
  302.                                    class="easyui-datagrid"
  303.                                    style="width:100%; font-weight:normal; text-transform: uppercase; margin-top: 20px;"
  304.                                    singleSelect=true
  305.                                    rownumbers=true
  306.                                    pageSize=30
  307.                                    fitColumns=true>
  308.                                 <thead>
  309.                                 <tr>
  310.                                 </tr>
  311.                                 </thead>
  312.                             </table>
  313.                         </div>
  314.                     </div>
  315.                 </div>
  316.             </div>
  317.             <div class="row">
  318.                 <div class="col-lg-4 request">
  319.                     <br>
  320.                     <a href="{{ path('one_way_bill', {'id': transaction.wayBill.id }) }}" class="btn btn-success back-cash" >
  321.                         <i class="fas fa-arrow-circle-left"></i>
  322.                         Cash
  323.                         <i><img src="{{ asset('fos/images/money_icon.png') }}" alt=""></i>
  324.                     </a>
  325.                 </div>
  326.                 <div class="col-lg-4 request">
  327.                     <button type="button" class="btn btn-success reload"  onclick="$('#payments').datagrid('reload');" >
  328.                         <i class="fas fa-redo"></i>
  329.                         Refresh
  330.                     </button>
  331.                 </div>
  332.                 <div class="col-lg-4 request">
  333.                 </div>
  334.             </div>
  335.             <hr>
  336.             <div class="row">
  337. {#                <div class="col-lg-3">#}
  338. {#                    <div class="parcel">#}
  339. {#                        <b>Waybill</b> <br>#}
  340. {#                        <span>{{ transaction.wayBill.id }}</span><br>#}
  341. {#                        <b>Amount</b> <br>#}
  342. {#                        <span>KES{{ transaction.amount }}</span>#}
  343. {#                    </div>#}
  344. {#                    <div class="balance">#}
  345. {#                        balance: <span id="balance"></span>#}
  346. {#                    </div>#}
  347. {#                </div>#}
  348.                 <div class="col-lg-6">
  349.                     <div id="mpesa-detail_" style="display: none" class="row">
  350.                     </div>
  351.                 </div>
  352.                 <div class="col-lg-6">
  353.                      {{ form_start(mpesaSelectionForm, {'attr': { 'style':' display: block'}})}}
  354.                              {{ form_widget(mpesaSelectionForm.mpesa,{'attr':{'id':'form_id','class':'input-field', 'style':'display: none' }} ) }}
  355.                             <button type="submit" class="btn btn-warning continue" onclick=""  disabled>
  356.                                 Complete
  357.                                 <i class="fas fa-arrow-circle-right"></i>
  358.                             </button>
  359.                     {{ form_end(mpesaSelectionForm)}}
  360.                     {{ form_start(mpesaCashSelectionForm, {'attr': { 'style':' display: block'}})}}
  361.                     {{ form_widget(mpesaCashSelectionForm.mpesa,{'attr':{'id':'form_id','class':'input-field', 'style':'display: none' }} ) }}
  362.                     <button type="submit" class="btn btn-warning continue_cash" onclick=""  disabled>
  363.                         Complete with cash
  364.                         <i class="fas fa-arrow-circle-right"></i>
  365.                     </button>
  366.                     {{ form_end(mpesaCashSelectionForm)}}
  367.                     <span id="balance"></span>
  368.                 </div>
  369.             </div>
  370.         </div>
  371.         <div id="poweredby">
  372.                 <hr/>
  373.                  powered by <span>&copy Ohau Technologies, ltd</span>
  374.         </div>
  375.     </div>
  376. {% endblock %}
  377.  {% block javascripts %}
  378.     {{ parent() }}
  379.     <script>
  380.         $('.other-field').mask('0000 000 000');
  381.         $('#payments').datagrid({
  382.             url:'/payment/list',
  383.             method: 'post',
  384.             pageSize:20,
  385.             singleSelect: false,
  386.             rownumbers:true,
  387.             remoteFilter:true,
  388.             pagination:true,
  389.             fitColumns:true,
  390.             collapsible:true,
  391.             onSelect: function(index, row){
  392.                 selectRow(index,row);
  393.                 // mpesa_payment_selection_id.value = row.id;
  394.                 // mpesa_payment_selection_amount.value = row.transaction_amount;
  395.             },onLoadSuccess(index, field, value) {
  396.                 $(".continue").attr("disabled", true);
  397.                 $("#mpesa-detail_").css('display','none');
  398.                 $(".continue_cash").attr("disabled", true);
  399.                 mpesa_cash_payment_selection_mpesa.innerHTML = '';
  400.                 mpesa_payment_selection_mpesa.innerHTML = '';
  401.                 for(let i=0; i<document.getElementsByName("mpesa_payment_selection[mpesa][]").length; i++){
  402.                     let id = document.getElementsByName("mpesa_payment_selection[mpesa][]")[i].id;
  403.                      document.getElementById(id).checked = false;
  404.                 }
  405.                 for(let i=0; i<document.getElementsByName("mpesa_cash_payment_selection[mpesa][]").length; i++){
  406.                     let id = document.getElementsByName("mpesa_cash_payment_selection[mpesa][]")[i].id;
  407.                     document.getElementById(id).checked = false;
  408.                 }
  409.                 // mpesa_payment_selection_amount.value = '';
  410.                 // mpesa_payment_selection_id.value = '';
  411.                 //
  412.                 // amount.innerHTML = '';
  413.                 // name_.innerHTML = '';
  414.                 // phone.innerHTML = '';
  415.                 // time.innerHTML = '';
  416.                 // transaction.innerHTML ='';
  417.             },onUnselect(index, row){
  418.                 selectRow(index, row);
  419.             },
  420.             columns: [[
  421.                 {field:'ck',title:'NAME',width:20, checkbox: true},
  422.                 {field:'name',title:'NAME',width:50,formatter:function(value,row,index){
  423.                         return `${row.first_name} ${row.middle_name} ${row.last_name}`;
  424.                     }},
  425.                 {field:'transaction_id',title:'TRANSACTION ID',width:80,formatter:function(value,row,index){
  426.                         return row.transaction_id;
  427.                     }},
  428.                 {field:'phone',title:'PHONE',width:50,formatter:function(value,row,index){
  429.                         return row.msisdn;
  430.                     }},
  431.                 {field:'created_at',title:'TIME',width:80,formatter:function(value,row,index){
  432.                         return row.created_at;
  433.                     }},
  434.                 {field:'transaction_Amount',title:'AMOUNT',width:50,formatter:function(value,row,index){
  435.                         return row.transaction_amount;
  436.                     }}
  437.             ]]
  438.         });
  439.         function continue_(){
  440.             $('#tt').datagrid('getSelected')
  441.             let row = $('#tt').datagrid('getSelected');
  442.             if (row){
  443.                 alert('Item ID:'+row.itemid+"\nPrice:"+row.listprice);
  444.             }
  445.         }
  446.         function selectRow(index, row) {
  447.             $("#mpesa-detail_").css('display','block');
  448.             $(".continue_cash").attr("disabled", true);
  449.             console.log(row);
  450.             console.log(row.first_name+' selected');
  451.             let rows = $('#payments').datagrid('getSelections');
  452.             console.log(row.first_name+' selected '+rows.length);
  453.             for(let i=0; i<document.getElementsByName("mpesa_payment_selection[mpesa][]").length; i++){
  454.                 let id = document.getElementsByName("mpesa_payment_selection[mpesa][]")[i].id;
  455.                  document.getElementById(id).checked = false;
  456.             }
  457.             for(let i=0; i<document.getElementsByName("mpesa_cash_payment_selection[mpesa][]").length; i++){
  458.                 let id = document.getElementsByName("mpesa_cash_payment_selection[mpesa][]")[i].id;
  459.                 document.getElementById(id).checked = false;
  460.             }
  461.             let html = '';
  462.             let selectedTotal = 0;
  463.             let checkboxes = '';
  464.             let mpesaCheckboxes = '';
  465.             for(let i=0; i<rows.length; i++) {
  466.                 selectedTotal += (rows[i].transaction_amount * 1);
  467.                 html +=
  468.                     `<div class="col-lg-12">
  469.                         <p class="mpesa-detail" id="mpesa_all_details">
  470.                             <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>
  471.                             <b>AMOUNT      </b> <i class="fas fa-arrow-circle-right"></i><span id="amount">${rows[i].transaction_amount}</span><br>
  472. <!--                            <b>PHONE       </b><i class="fas fa-arrow-circle-right"></i> <span id="phone">${rows[i].msisdn}</span><br>-->
  473.                             <b>TIME        </b><i class="fas fa-arrow-circle-right"></i> <span id="time">${rows[i].created_at}</span><br>
  474.                             <b>TRANSACTION </b><i class="fas fa-arrow-circle-right"></i> <span id="transaction">${rows[i].transaction_id}</span><br>
  475.                         </p>
  476.                     </div>`;
  477.                 checkboxes += `
  478.                     <input type="checkbox" id="mpesa_cash_payment_selection_mpesa_${rows[i].id}" name="mpesa_cash_payment_selection[mpesa][]" value="${rows[i].id}" checked>
  479.                     <label for="mpesa_cash_payment_selection_mpesa_${rows[i].id}" >${rows[i].first_name} ${rows[i].middle_name} ${rows[i].last_name}</label>`;
  480.                 mpesaCheckboxes += `
  481.                     <input type="checkbox" id="mpesa_payment_selection_mpesa_${rows[i].id}" name="mpesa_payment_selection[mpesa][]" value="${rows[i].id}" checked>
  482.                     <label for="mpesa_payment_selection_mpesa_${rows[i].id}" >${rows[i].first_name} ${rows[i].middle_name} ${rows[i].last_name}</label>`;
  483.                 if(document.getElementById("mpesa_payment_selection_mpesa_"+rows[i])) {
  484.                     document.getElementById("mpesa_payment_selection_mpesa_"+rows[i].id).checked = true;
  485.                     document.getElementById("mpesa_cash_payment_selection_mpesa_"+rows[i].id).checked = true;
  486.                 }
  487.             }
  488.             mpesa_cash_payment_selection_mpesa.innerHTML = checkboxes;
  489.             mpesa_payment_selection_mpesa.innerHTML = mpesaCheckboxes;
  490.             document.getElementById("mpesa-detail_").innerHTML = html;
  491.             let paymentBalance = {{ transaction.amount }} - selectedTotal;
  492.             document.getElementById("balance").innerHTML = paymentBalance;
  493.             $(".continue_cash").attr("disabled", true);
  494.             if(paymentBalance === 0){
  495.                 $(".continue").attr("disabled", false);
  496.             }else{
  497.                 $(".continue").attr("disabled", true);
  498.                 if(paymentBalance <= 0){
  499.                     $(".continue_cash").attr("disabled", true);
  500.                     console.log('disable continue-cash');
  501.                 }else{
  502.                     $(".continue_cash").attr("disabled", false);
  503.                     console.log('enable continue-cash '+paymentBalance);
  504.                 }
  505.             }
  506.         }
  507.     </script>
  508. {% endblock %}