From 4a12fb6eb2762215774b5080d434c2dc4462866c Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 20 Feb 2020 04:12:12 +0000 Subject: [PATCH 1/3] Change edit to edit onestep edit and walkin. #353 --- src/Controller/JobOrderController.php | 6 +- .../JobOrderHandler/CMBJobOrderHandler.php | 16 +- .../job-order/cmb.form.onestep.html.twig | 20 +- .../job-order/cmb.list.fulfillment.html.twig | 183 +++++++++++++++++ templates/job-order/cmb.list.open.html.twig | 190 ++++++++++++++++++ 5 files changed, 391 insertions(+), 24 deletions(-) create mode 100644 templates/job-order/cmb.list.fulfillment.html.twig create mode 100644 templates/job-order/cmb.list.open.html.twig diff --git a/src/Controller/JobOrderController.php b/src/Controller/JobOrderController.php index c06383c7..44265309 100644 --- a/src/Controller/JobOrderController.php +++ b/src/Controller/JobOrderController.php @@ -282,7 +282,7 @@ class JobOrderController extends Controller else { $rows[$key]['meta']['update_url'] = $this->generateUrl($tier_params['edit_route'], ['id' => $jo_id]); - $rows[$key]['meta']['onestep_edit_url'] = $this->generateUrl('jo_onestep_edit_form', ['id' => $jo_id]); + $rows[$key]['meta']['onestep_edit_url'] = $this->generateUrl($tier_params['edit_route'], ['id' => $jo_id]); $rows[$key]['meta']['pdf_url'] = $this->generateUrl('jo_pdf_form', ['id' => $jo_id]); } @@ -430,7 +430,7 @@ class JobOrderController extends Controller * @Menu(selected="jo_fulfill") */ public function fulfillmentForm(JobOrderHandlerInterface $jo_handler, $id, - GISManagerInterface $gis) + GISManagerInterface $gis, EntityManagerInterface $em) { $this->denyAccessUnlessGranted('jo_fulfill.list', null, 'No access.'); @@ -443,6 +443,8 @@ class JobOrderController extends Controller throw $this->createNotFoundException($e->getMessage()); } + $params['vmfgs'] = $em->getRepository(VehicleManufacturer::class)->findAll(); + $params['vmakes'] = $em->getRepository(Vehicle::class)->findAll(); $params['submit_url'] = $this->generateUrl('jo_fulfill_submit', ['id' => $id]); $params['return_url'] = $this->generateUrl('jo_fulfill'); $params['map_js_file'] = $gis->getJSJOFile(); diff --git a/src/Service/JobOrderHandler/CMBJobOrderHandler.php b/src/Service/JobOrderHandler/CMBJobOrderHandler.php index 80e4158e..06f1fb72 100644 --- a/src/Service/JobOrderHandler/CMBJobOrderHandler.php +++ b/src/Service/JobOrderHandler/CMBJobOrderHandler.php @@ -2779,19 +2779,11 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface // $this->template_hash = [ // 'blah' => 'blah', // ]; - $this->template_hash['jo_incoming_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_open_edit_form'] = 'job-order/cmb.form.html.twig'; $this->template_hash['jo_incoming_vehicle_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_processing_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_assigning_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_fulfillment_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_open_hub_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_open_rider_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_all_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_list_processing'] = 'job-order/list.processing.html.twig'; - $this->template_hash['jo_list_assigning'] = 'job-order/list.assigning.html.twig'; - $this->template_hash['jo_list_fulfillment'] = 'job-order/list.fulfillment.html.twig'; - $this->template_hash['jo_list_open'] = 'job-order/list.open.html.twig'; + $this->template_hash['jo_fulfillment_form'] = 'job-order/cmb.form.onestep.html.twig'; + $this->template_hash['jo_all_form'] = 'job-order/cmb.form.onestep.html.twig'; + $this->template_hash['jo_list_fulfillment'] = 'job-order/cmb.list.fulfillment.html.twig'; + $this->template_hash['jo_list_open'] = 'job-order/cmb.list.open.html.twig'; $this->template_hash['jo_list_all'] = 'job-order/list.all.html.twig'; $this->template_hash['jo_onestep_form'] = 'job-order/cmb.form.onestep.html.twig'; $this->template_hash['jo_onestep_edit_form'] = 'job-order/cmb.form.onestep.html.twig'; diff --git a/templates/job-order/cmb.form.onestep.html.twig b/templates/job-order/cmb.form.onestep.html.twig index 0d9bac9f..4c913bca 100644 --- a/templates/job-order/cmb.form.onestep.html.twig +++ b/templates/job-order/cmb.form.onestep.html.twig @@ -389,7 +389,7 @@

- {% if mode == 'view-all' %} + {% if mode in ['view-all', 'update-fulfillment'] %} Assigned Hub {% else %} Nearest Hubs @@ -436,7 +436,7 @@

- {% if mode == 'view-all' %} + {% if mode in ['view-all', 'update-fulfillment'] %} Assigned Rider {% else %} Rider Assignment @@ -464,7 +464,7 @@ - {% if mode in ['onestep-edit', 'view-all'] %} + {% if mode in ['onestep-edit', 'view-all', 'update-fulfillment'] %} {% set avail_riders = obj.getHub.getAvailableRiders|default([]) %} @@ -474,7 +474,7 @@ {% if obj.getHub %} {% for rider in avail_riders %} - {% if mode == 'view-all' %} + {% if mode in ['view-all', 'update-fulfillment'] %} {% else %} @@ -512,9 +512,9 @@
- {% for key, sc in service_charges %} - + {% endfor %}
@@ -653,7 +653,7 @@
{% if mode != 'view-all' %} - + {% if ftags.set_map_coordinate and is_granted('joborder.cancel') and not obj.isCancelled %} Cancel Job Order {% endif %} @@ -801,7 +801,7 @@ $(function() { }); {% endif %} - {% if mode in ['view-all'] %} + {% if mode in ['view-all', 'update-fulfillment'] %} var hub_table = ''; $.getJSON("{{ url('hub_nearest') }}?lat=" + lat + "&long=" + lng, function(data) { var hubs = data['hubs']; @@ -963,7 +963,7 @@ $(function() { {% endif %} }); - {% if mode in ['onestep-edit', 'view-all'] %} + {% if mode in ['onestep-edit', 'view-all', 'update-fulfillment'] %} var lat = {{ obj.getCoordinates.getLatitude }}; var lng = {{ obj.getCoordinates.getLongitude }}; @@ -1357,7 +1357,7 @@ $(function() { var sc_array = []; // populate invoiceItems if editing so that we don't lose the battery - {% if mode in ['view-all', 'open-edit', 'onestep-edit', 'walk-in-edit'] %} + {% if mode in ['view-all', 'open-edit', 'onestep-edit', 'walk-in-edit', 'update-fulfillment'] %} {% if (obj.getInvoice and obj.getInvoice.getItems|length > 0) %} {% for item in obj.getInvoice.getItems %} {% if item.getBattery() %} diff --git a/templates/job-order/cmb.list.fulfillment.html.twig b/templates/job-order/cmb.list.fulfillment.html.twig new file mode 100644 index 00000000..7cd98ad3 --- /dev/null +++ b/templates/job-order/cmb.list.fulfillment.html.twig @@ -0,0 +1,183 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

+ Job Orders (Fulfillment) +

+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + + +
+
+
+
+
+ +
+
+
+
+
+
+ +
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/templates/job-order/cmb.list.open.html.twig b/templates/job-order/cmb.list.open.html.twig new file mode 100644 index 00000000..bffdfd6c --- /dev/null +++ b/templates/job-order/cmb.list.open.html.twig @@ -0,0 +1,190 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

+ Job Orders (Open) +

+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + + +
+
+
+
+
+ +
+
+
+
+
+
+ +
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} From 9125a0d2faf4c8b2cf0978e0fc185c0b6bcc7a5c Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 21 Feb 2020 03:22:17 +0000 Subject: [PATCH 2/3] Moved invoice code out of JO controller. #354 --- src/Controller/JobOrderController.php | 11 ++--------- .../InvoiceGenerator/CMBInvoiceGenerator.php | 19 +++++++++++++++++++ .../InvoiceGenerator/ResqInvoiceGenerator.php | 16 +++++++++++++++- src/Service/InvoiceGeneratorInterface.php | 3 +++ 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/Controller/JobOrderController.php b/src/Controller/JobOrderController.php index 44265309..3c8ad158 100644 --- a/src/Controller/JobOrderController.php +++ b/src/Controller/JobOrderController.php @@ -696,7 +696,7 @@ class JobOrderController extends Controller $items = $req->request->get('items'); $promo_id = $req->request->get('promo'); $cvid = $req->request->get('cvid'); - $service_charges = $req->request->get('service_charges'); + $service_charges = $req->request->get('service_charges', []); $em = $this->getDoctrine()->getManager(); @@ -740,14 +740,7 @@ class JobOrderController extends Controller } */ - // TODO: this snippet should be in the invoice generator - $error = $ic->validateDiscount($criteria, $promo_id); - - // process service charges - $error = $ic->invoiceServiceCharges($criteria, $service_charges); - - if (!$error) - $error = $ic->invoiceBatteries($criteria, $items); + $error = $ic->generateDraftInvoice($criteria, $promo_id, $service_charges, $items); if ($error) { diff --git a/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php b/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php index cc1cb020..534600fb 100644 --- a/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php +++ b/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php @@ -204,6 +204,25 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface } } + // prepare draft for invoice + public function generateDraftInvoice($criteria, $discount, $service_charges, $items) + { + $ierror = $this->validateDiscount($criteria, $discount); + + if (!$ierror) + { + // process service charges + $ierror = $this->invoiceServiceCharges($criteria, $service_charges); + + if (!$ierror) + { + $ierror = $this->invoiceBatteries($criteria, $items); + } + } + + return $ierror; + } + protected function getTaxAmount($price) { $vat_ex_price = $this->getTaxExclusivePrice($price); diff --git a/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php b/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php index f9aad46a..2999d622 100644 --- a/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php +++ b/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php @@ -194,6 +194,20 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface } } + // prepare draft for invoice + public function generateDraftInvoice($criteria, $promo_id, $service_charges, $items) + { + $ierror = $this->invoicePromo($criteria, $promo_id); + + if (!$ierror) + { + $ierror = $this->invoiceBatteries($criteria, $items); + } + + return $ierror; + } + + protected function getTaxAmount($price) { $vat_ex_price = $this->getTaxExclusivePrice($price); @@ -227,7 +241,7 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface return 0; } - public function invoicePromo(InvoiceCriteria $criteria, $promo_id) + protected function invoicePromo(InvoiceCriteria $criteria, $promo_id) { // return error if there's a problem, false otherwise // check service type diff --git a/src/Service/InvoiceGeneratorInterface.php b/src/Service/InvoiceGeneratorInterface.php index 85407c30..3e1c5f88 100644 --- a/src/Service/InvoiceGeneratorInterface.php +++ b/src/Service/InvoiceGeneratorInterface.php @@ -15,4 +15,7 @@ interface InvoiceGeneratorInterface // generate invoice criteria public function generateInvoiceCriteria(JobOrder $jo, int $promo_id, array $invoice_items, array &$error_array); + // prepare draft for invoice + public function generateDraftInvoice(InvoiceCriteria $criteria, int $promo_id, array $service_charges, array $items); + } From e93e0dd9431d83290ee3d815a4f614b291dba132 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 21 Feb 2020 05:10:11 +0000 Subject: [PATCH 3/3] Bug fix for loading JO form for edit. #354 --- templates/job-order/form.html.twig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index a0e5985c..bba70b39 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -47,6 +47,9 @@
+ {% if mode in ['update-assigning', 'update-processing', 'update-reassign-hub', 'update-reassign-rider', 'update-all', 'open_edit'] %} + + {% endif %}
{% if ftags.vehicle_dropdown %}