{% extends 'fos/base.html.twig' %}
{% block firstnav %}
{{ render(controller('App\\Parcels\\DefaultController::nav')) }}
{% endblock %}
{% block secondnav %}
<script src="https://printjs-4de6.kxcdn.com/print.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://printjs-4de6.kxcdn.com/print.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"
integrity="sha512-BNaRQnYJYiPSqHHDb58B0yaPfCu+Wgds8Gp/gU33kqBtgNS4tSPHuGibyoeqMV/TJlSKda6FXzoEyYGjTe+vXA=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/2.4.0/purify.min.js" integrity="sha512-/hVAZO5POxCKdZMSLefw30xEVwjm94PAV9ynjskGbIpBvHO9EBplEcdUlBdCKutpZsF+La8Ag4gNrG0gAOn3Ig==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
{# <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script>#}
<!-- Second Nav -->
<nav class="navbar-second navbar navbar-default navbar-static-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- Brand -->
{% block current %}
<span class="navbar-brand" href="#"><i class="fa fa-gears"></i> PARCEL TO {{ transaction.wayBill.toStation }}</span>
{% endblock %}
</div>
<div class="collapse navbar-collapse animated fadeIn" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav animated fadeIn">
{% block secondarylinkblock %}
{#<li><a href="{{ path('new-parcel') }}"><i class="fa fa-plus-circle"></i> Register Parcel</a></li>#}
{#<li class=""><a href="#"><i class="fa fa-th-list"></i> Parcels</a></li>#}
<li class=""><a href="{{ app.request.headers.get('referer') }}"><i class="fa fa-arrow-circle-left"></i> Back</a></li>
{#<li class="active"><a href=""><i class="fa fa-plus-circle"></i> View Parcel #{{ transaction.waybill.parcel.id }}</a></li>#}
{% endblock %}
</ul>
<ul class="nav navbar-nav navbar-right">
<li class=""><a></a></li>
{#<li><p class="navbar-text"></p></li>#}
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
{% endblock %}
{% block stylesheets %}
<style>
/*@import "../../../../../web/assets/css/print.css";*/
h6{
font-weight: bold;
}
h3 {
/*font-size: 20px;*/
}
h5,h3,h4,p {
padding: 0px;
font-family: "Amaranth", sans-serif;
background: #ffffff;
}
legend {
border: none;
padding: 5px;
}
.print-area h5, .print-area h3, .print-area h4 {
padding: 0px;
font-family: "Nova Flat", sans-serif;
background: #ffffff;
border: none;
margin: 0;
}
.print-area p {
font-size: 12px;
padding: 4px;
margin: 0px;
line-height: 10px;
border: none;
}
hr {
margin-top: 1px;
margin-bottom: 1px;
border-top: 2px dashed rgba(0, 0, 0, 0.99);
}
.print-area hr {
border-top: 1px dashed rgba(0, 0, 0, 0.99);
}
.print-area {
width: 28%;
background: white;
/*border: 1px dotted;*/
padding: 2%;
display: none;
/*background-color: firebrick;*/
}
.print-area table {
font-family: 'Fjord One', serif;
}
element.style {
}
fieldset {
display: block;
margin-left: 0px;
margin-right: 2px;
border-top: 1px dotted black;
}
.kkk fieldset{
float: right;
width: 40%;
}
.detail{
padding: 0px;
font-size: 11px;
border: none;
}
@media print {
.sf-toolbar, .sf-display-none, .sf-minitoolbar {
display: none;
}
.print-area {
display: block;
}
@page {
margin: 0 !important;
}
html {
margin: 0 !important;
}
body {margin:0 !important;}
.print-area {
width: 100%;
}
.pro {
display: none;
}
.sf-toolbar, .sf-toolbarreset, .sf-minitoolbar {
display: none;
}
/*.page-break {display: block; page-break-before: always }*/
.page-break {
page-break-before: avoid;
}
.page-break {
page-break-after: always;
}
pre, blockquote {
page-break-inside: avoid;
}
}
.parcel {
font-family: 'Big Shoulders Text', cursive;
margin-bottom: 10px;
margin-left: 10px;
}
.parcel h3, .parcel span{
font-family: 'Merriweather', serif;
margin-top: 15px;
}
.sender_receiver .col-lg-6 + fieldset {
box-shadow: 5px 3px 20px #888888;
}
.sender_receiver fieldset{
background-color: beige;
border-top: 1px solid #d3cece;
}
.sender_receiver fieldset legend{
background-color: beige;
border: 1px solid #d3cece;
}
.sender_receiver fieldset h5{
background: none;
}
.destinations {
float: left;
width: 50%;
padding: 10px;
font-family: 'Open Sans', sans-serif;
margin-bottom: 15px;
}
.destinations h4, .destinations b {
font-family: 'Merriweather', serif;
}
.destinations h3 {
margin-bottom: 10px;
}
.description {
font-size: 37px;
margin-left: 10px;
}
.all_parcels{
text-transform: uppercase;
-ms-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
-o-transform: rotate(90deg);
margin-top: 115px;
width: 430px;
margin-left: -60px;
}
.payment button, .print, .payment a {
width: 150px;
border-radius: 30px;
}
.payment .cash {
float: right;
}
.payment .cash img {
height: 20px;
}
</style>
{% endblock %}
{% block main %}
<div class="row pro" style="padding: 10px 0px 20px 20px; /*border-right: 1px solid #888888;*/ background: #FFFFFF; /*box-shadow: 5px 3px 20px #888888;*/">
<h3 style="font-family:Serif;margin-top: 30px;">WayBill: {{ transaction.wayBill.id }} - {{ transaction.cuInvoiceNumber }}</h3>
<div class="col-lg-6 pro">
<div class="row sender_receiver">
<div class="col-lg-6">
<fieldset style="box-shadow: 5px 5px 0px #888888;">
<legend class="top-legend">SENDER</legend>
<div class="row">
<div class="col-lg-12">
<fieldset>
<legend>Name</legend>
<h5>{{ transaction.waybill.senderName | upper }}</h5>
</fieldset>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<fieldset>
<legend>Phone</legend>
<h5>{{ transaction.waybill.senderPhoneNumber }}</h5>
</fieldset>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<fieldset>
<legend>From</legend>
<h5>{{ transaction.waybill.fromStation }}</h5>
</fieldset>
</div>
</div>
</fieldset>
</div>
<div class="col-lg-6">
<fieldset style="box-shadow:5px 5px 0px #888888">
<legend class="top-legend">RECEIVER</legend>
<div class="row">
<div class="col-lg-12">
<fieldset>
<legend>Name</legend>
<h5>{{ transaction.wayBill.receiverName | upper }}</h5>
</fieldset>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<fieldset>
<legend>Phone</legend>
<h5>{{ transaction.waybill.receiverPhoneNumber }}</h5>
</fieldset>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<fieldset>
<legend>To</legend>
<h5>{{ transaction.waybill.toStation }}</h5>
</fieldset>
</div>
</div>
</fieldset>
</div>
</div>
</div>
<div class="receipt" >
<div class="row pro">
<div class="col-lg-4 col-md-6">
<fieldset align="center" style="border: 1px dotted black; padding-bottom: 10px;">
<legend>Cost</legend>
<table width="90%" style="text-align: center; align-content: center;">
<tr>
<td align="left"><h5 align="left" style="border: none;">{{ transaction.taxPercentage }}% V.A.T</h5></td>
<td align="right" style="font-family: 'Fjord One', Serif; font-weight: bolder;">{{ (transaction.taxAmount) | number_format(2, '.', ',') }}</td>
</tr>
<tr style="">
<td align="left"><h5 align="left" style="border: none;">COST</h5></td>
<td align="right" style="font-family: 'Fjord One', Serif;font-weight: bolder;">{{ (transaction.grossAmount - transaction.taxAmount) | number_format(2, '.', ',') }}</td>
</tr>
{% for expense in transaction.wayBillExpenses %}
{% if expense.expenseType.isAutomatic == false %}
<tr style="border-bottom: 1px solid black;">
<td align="left"><h5 align="left" style="border: none;">{{ expense.expenseType.expenseName | upper }}</h5></td>
<td align="right" style="font-family: 'Fjord One', Serif; font-weight: bolder;border-right: none;">-{{ expense.amount }}</td>
</tr>
{#{% set expenseAmount = (expenseAmount + expense.amount) %}#}
{% endif %}
{% endfor %}
<tr style="border-bottom: 2px double black;border-top: 2px double black;">
<td align="right"><h4 align="left" style="border: none;">TOTAL</h4></td>
<td align="right" style="font-family: 'Fjord One', Serif; font-weight: bolder;">KSH {{ (transaction.stationBalance ) | number_format }}</td>
</tr>
</table>
</fieldset>
<p style="border:none;">Transaction by: {{ transaction.waybill.createdBy.person.secondName }} {{ transaction.waybill.createdBy.person.sirName }}</p>
{% if transaction.isCancelled == false %}
{% if transaction.isComplete == false or is_granted('ROLE_BOS_USER') or is_granted('ROLE_STATION_ADMIN') %}
{{ form_start(cancelForm) }}
<button type="submit" class="btn btn-sm btn-warning ">cancel transaction</button>
{{ form_end(cancelForm) }}
{% endif %}
{% endif %}
</div>
</div>
</div>
</div>
<div class="row">
<div class="row">
{% if transaction.isPaid %}
{% if transaction.isCancelled != true %}
<div class="col-lg">
{#{% if transaction.isCancelled == false and isCancellable == true %}#}
<div class="row pro kkk" style="padding: 10px 0px 20px 20px; background: #FFFFFF; margin-left: auto">
<div class="col-lg-12">
<fieldset>
<legend>Print</legend>
{% if isCashCanChangeMpesa %}
<a href="{{ path('payment_request_view', {'waybill': transaction.wayBill.id}) }}" class="btn btn-success" style="float: left;">
<i><img src="{{ asset('fos/images/m-pesa-icon.svg') }}" alt=""></i>
change payment to M-PESA
</a>
{%endif%}
<div align="right">
{#<a href="{{ path('pdf_report', {'id': transaction.waybill.id }) }}" class="btn btn-success" target="_blank"><i class="fa fa-print"></i> Print</a>#}
{#<a href="javascript:window.print()" class="btn btn-success" target="_blank"><i class="fa fa-print"></i> Print</a>#}
{% if tims is not null %}
{% if tims.type == 'TYPEC' and tims.supplierCode == 'PARGAMON' %}
{# {% if tims.type == 'TYPEC' and tims.supplierCode == 'PARGAMON' and is_granted('ROLE_BOS_USER')%}#}
<a href="{{ path('receipt_action', {'waybill_': transaction.wayBill.id }) }}" download="application/pdf">
<button type="button" class="btn btn-success print">
<i class="fa fa-print"></i>
Print PDF
</button>
</a>
{% elseif tims.type == 'TYPEC' and tims.supplierCode == 'TREMOL' %}
<button type="button" class="btn btn-success print" onclick="print('/fos/receipt/g03/{{ transaction.wayBill.id }}')">
<i class="fa fa-print"></i>
Print Receipt
</button>
{% else %}
<button type="button" class="btn btn-success print" onclick="print('/fos/receipt/{{ transaction.wayBill.id }}')">
<i class="fa fa-print"></i>
Print Receipt
</button>
{% endif %}
{% else %}
----
<button type="button" class="btn btn-success print" onclick="print('/fos/receipt/{{ transaction.wayBill.id }}')">
<i class="fa fa-print"></i>
Print Receipt
</button>
{% endif %}
{# <button type="button" class="btn btn-success print" onclick="printReceipt()">#}
{# <i class="fa fa-print"></i>#}
{# Print#}
{# </button>#}
{# <button type="button" class="btn btn-success print" onclick="save()">#}
{# <i class="fa fa-print"></i>#}
{# Print#}
{# </button>#}
</div>
</fieldset>
</div>
</div>
{#{% endif %}#}
</div>
{% else %}
<div class="col-lg">
<fieldset>
<legend>Print</legend>
<div align="right">
<button type="button" class="btn btn-danger print" style="width: auto" disabled>
<i class="fa fa-print"></i>
this transaction is cancelled
</button>
</div>
</fieldset>
<b></b>
</div>
{% endif %}
{% else %}
{% if transaction.isCancelled != true %}
<div class="col-lg"s>
<div class="row pro kkk" style="padding: 10px 0px 20px 20px; background: #FFFFFF; margin-left: auto">
<div class="col-lg-12">
<fieldset class="payment">
<legend>Select Payment option</legend>
{% if isMpesaAvailable %}
<a href="{{ path('payment_request_view', {'waybill': transaction.wayBill.id}) }}" class="btn btn-success" style="float: left;">
<i><img src="{{ asset('fos/images/m-pesa-icon.svg') }}" alt=""></i>
M-PESA
</a>
{%else%}
<button {#href="{{ path('payment_request_view', {'waybill': transaction.wayBill.id}) }}"#} class="btn btn-success" style="float: left;" disabled>
<i><img src="{{ asset('fos/images/m-pesa-icon.svg') }}" alt=""></i>
M-PESA
</button>
{%endif%}
{{ form_start(cashPaymentOptionForm) }}
<button type="submit" class="btn btn-warning cash">
<i><img src="{{ asset('fos/images/money_icon.png') }}" alt=""></i>
Cash
</button>
{{ form_end(cashPaymentOptionForm) }}
</fieldset>
</div>
</div>
</div>
{% endif %}
{% endif %}
</div>
</div>
{# <div class="row" style="padding: 10px 0px 20px 20px; border-right: 1px solid #888888; background: #FFFFFF; box-shadow: 5px 3px 20px #888888;">
{{ form_start(form) }}
<fieldset>
<legend>WayBill Expense</legend>
<div class="row">
<div class="col-lg-3 col-md-3">
<label for="sender_name">Expense Type</label>
{{ form_widget(form.expenseType,{'attr':{'class':'form-control' }} ) }}
<div class="invalid-feedback">
{{ form_errors(form.expenseType) }}
</div>
</div>
<div class="col-lg-2 col-md-4">
<label for="sender_name">Amount</label>
{{ form_widget(form.amount,{'attr':{'class':'form-control' }} ) }}
<div class="invalid-feedback">
{{ form_errors(form.amount) }}
</div>
</div>
</div>
<div class="row" style="margin-top: 10px;">
<div class="col-lg-1 col-md-1">
<button type="submit" class="btn btn-success right-align">Save</button>
</div>
</div>
</fieldset>
{{ form_end(form) }}
</div>#}
<div class=" row pro">
{% for parcel in parcels %}
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12" style="background: #FFFFFF; /*box-shadow: 5px 3px 20px #888888;*/ margin-top: 10px; padding-top: 10px; margin-right: 20px;">
<div class="col-lg-12">
<fieldset>
<legend>Parcel #{{ parcel.number }}</legend>
<h5>{{ parcel.description }}</h5>
</fieldset>
<fieldset>
<legend><i class="fa fa-arrow-circle-down"></i></legend>
<fieldset>
<legend>Location</legend>
<h5>IN OFFICE :{{ transaction.wayBill.fromStation }}
<p class="detail">From: <i class="fas fa-hand-point-right"></i>{{ transaction.wayBill.createdAt | date("F jS, Y \\a\\t g:ia") }}</p>
{# {% if parcel.isEnRoute %}
<p class="detail">To: <i class="fas fa-hand-point-right"></i>{{ parcel.enRouteFrom | date("F jS, Y \\a\\t g:ia") }}</p>
{% endif %}#}
</h5>
</fieldset>
{#{{ render(controller('App\\Parcels\\DefaultController::nav')) }}#}
{{ render(controller('App\\Parcels\\ParcelController::getParcelDeliveryData',{'parcel_id':parcel.id})) }}
{#{% if parcel.isEnRoute %}
<fieldset>
<legend>En route</legend>
<h5>REG: {{ parcel.vehicle.regNumber }}
<p class="detail">Loaded By: {{ transaction.waybill.createdBy.person.secondName }} {{ transaction.waybill.createdBy.person.sirName }}</p>
{% if parcel.isEnRoute %}
<p class="detail">From: <i class="fas fa-hand-point-right"></i>{{ parcel.enRouteFrom | date("F jS, Y \\a\\t g:ia") }}</p>
{% endif %}
{% if parcel.isReceived %}
<p class="detail">To: <i class="fas fa-hand-point-right"></i>{{ parcel.receivedAt | date("F jS, Y \\a\\t g:ia") }}</p>
{% endif %}
</h5>
</fieldset>
{% endif %}#}
{#{% if parcel.isReceived %}
<fieldset>
<legend>Received By</legend>
<h5>USER: {{ parcel.receivedBy.person.firstName | upper }} {{ parcel.receivedBy.person.secondName | upper }} {{parcel.receivedBy.person.sirName | upper }}
{% if parcel.isReceived %}
<p class="detail">From: <i class="fas fa-hand-point-right"></i>{{ parcel.receivedAt | date("F jS, Y \\a\\t g:ia") }}</p>
{% endif %}
{% if transaction.wayBill.isCollected %}
<p class="detail">to: <i class="fas fa-hand-point-right"></i>{{ parcel.collectedAt | date("F jS, Y \\a\\t g:ia") }}</p>
{% endif %}
</h5>
</fieldset>
{% endif %}#}
{#{% if parcel.isCollected %}
<fieldset>
<legend>Collected By</legend>
<h5>National ID: {{ parcel.collectorNationalId }}</h5>
<h5>USER: {{ parcel.collectedOfficerBy.person.firstName | upper }} {{ parcel.collectedOfficerBy.person.secondName | upper }} {{parcel.collectedOfficerBy.person.sirName | upper }}</h5>
<p class="detail">At: <i class="fas fa-hand-point-right"></i>{{ parcel.collectedAt | date("F jS, Y \\a\\t g:ia") }}</p>
</fieldset>
{% endif %}#}
</fieldset>
<div style="align-content: center; text-align: center;">
<img alt="Coding Sips" src="/barcode?text={{ transaction.wayBill.id }}/{{ parcel.number }}&Codetype=Code128&size=60&print=true" />
</div>
</div>
</div>
{% endfor %}
</div>
{% if sms is defined and sms %}
<hr>
<div class="row">
<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>RECEIVER</th>
<th>STATUS</th>
<th>Sent Via Phone</th>
<th>MESSAGE</th>
</tr>
</thead>
<tbody>
{% for message in sms %}
<tr>
<td>{{ loop.index }} </td>
<td>{{ message.recepient }}</td>
<td>
{% if message.status %}
{% if message.status == 'Success' or message.status == 'Sent' %}
<span class="alert-success">{{ message.status }}</span>
{% else %}
<span class="alert-danger">
{{ message.status }}{#[{{ message.statusCode }}]#} <br>
{% if message.statusCode < 1000 %}
{{ statusChart[message.statusCode] }} [{{ message.statusCode }}]
{% endif %}
</span>
{% endif %}
{% else %}
<span>N/A</span>
{% endif %}
</td>
<td>
{% if message.status != 'Success' or message.status != 'Sent' %}
{% if message.manuallySent %}
<i class="fas fa-check-circle" style="color: green;"></i>
{% endif %}
{% endif %}
</td>
<td>{{ message.sms }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
<div class="print-area" id="print-area">
</div>
<script>
let printReceipt = async () => {
$(".se-pre-con").fadeIn("slow");
let completeTransaction = await fetch("{{ path('register_transaction_as_complete', {'id': transaction.wayBill.id }) }}", {
method: 'POST'
}).then(response => {
response.json().then(json => {
if(response.status === 200){
printJS({
printable:'print-area',
type: 'html',
css:'../../../../../assets/css/print.css'});
}else{
console.log('error occurred');
}
})
}).finally(() => {
$(".se-pre-con").fadeOut("slow");
});
};
jQuery(document).bind("keyup keydown", function(e){
if(e.ctrlKey && e.keyCode === 80){
console.log("printing ...");
printReceipt();
}
});
window.jsPDF = window.jspdf.jsPDF;
function download() {
let renderHtml = $('#print-area').html();
let pdf = new jsPDF('p','mm', [254, 80]);
pdf.html(renderHtml, {
callback: function (pdf) {
window.open(pdf.output('bloburl'));
}
});
}
// download();
// $( document ).ready(function() {
// window.jsPDF = window.jspdf.jsPDF;
//
// // Default export is a4 paper, portrait, using millimeters for units
// var doc = window.jsPDF;
// var specialElementHandlers = {
// '#editor': function (element, renderer) {
// return true;
// }
// };
//
// doc.html($('.receipt-print').html(), 15, 15, {
// 'width': 170,
// 'elementHandlers': specialElementHandlers
// });
// doc.save('sample-file.pdf');
// });
function save() {
var content = ["your-content-here"];
var bl = new Blob(content, {type: "application/pdf"});
var a = document.createElement("a");
a.href = URL.createObjectURL("http://localhost:8000/fos/receipt/{{ transaction.wayBill.id }}");
a.download = "{{ transaction.wayBill.id }}.pdf";
a.hidden = true;
document.body.appendChild(a);
a.click();
}
function print(url){
// $(".se-pre-con").fadeIn("slow");
// printJS(url);
printJS({
printable: url,
type:'pdf',
showModal:true,
modalMessage: 'Downloading receipt please wait!',
onError: function (error) {
console.log(error);
alert('Could not generate receipt please try again ')
}
});
}
</script>
{% endblock %}