diff --git a/config/routes/customer.yaml b/config/routes/customer.yaml index 89d361f5..7cc30fe8 100644 --- a/config/routes/customer.yaml +++ b/config/routes/customer.yaml @@ -27,6 +27,9 @@ customer_create_submit: controller: App\Controller\CustomerController::addSubmit methods: [POST] +customer_update_blank: + path: /customers + customer_update: path: /customers/{id} controller: App\Controller\CustomerController::updateForm diff --git a/config/routes/job_order.yaml b/config/routes/job_order.yaml index 5d22a4bd..65a808c3 100644 --- a/config/routes/job_order.yaml +++ b/config/routes/job_order.yaml @@ -3,6 +3,14 @@ jo_in: controller: App\Controller\JobOrderController::incomingForm methods: [GET] +jo_in_vehicle: + path: /job-order/incoming/cvehicle/{cvid} + controller: App\Controller\JobOrderController::incomingVehicleForm + methods: [GET] + +jo_in_vehicle_blank: + path: /job-order/incoming/cvehicle + jo_in_submit: path: /job-order/incoming controller: App\Controller\JobOrderController::incomingSubmit diff --git a/src/Controller/CustomerController.php b/src/Controller/CustomerController.php index 0d7eb16c..ccf79fbc 100644 --- a/src/Controller/CustomerController.php +++ b/src/Controller/CustomerController.php @@ -294,7 +294,8 @@ class CustomerController extends BaseController // return successful response return $this->json([ - 'success' => 'Changes have been saved!' + 'success' => 'Changes have been saved!', + 'id' => $row->getID() ]); } } @@ -457,7 +458,8 @@ class CustomerController extends BaseController // return successful response return $this->json([ - 'success' => 'Changes have been saved!' + 'success' => 'Changes have been saved!', + 'id' => $cust->getID() ]); } } diff --git a/src/Controller/JobOrderController.php b/src/Controller/JobOrderController.php index 3c74931b..d812df67 100644 --- a/src/Controller/JobOrderController.php +++ b/src/Controller/JobOrderController.php @@ -158,6 +158,38 @@ class JobOrderController extends BaseController return $this->render('job-order/form.html.twig', $params); } + public function incomingVehicleForm($cvid) + { + $this->denyAccessUnlessGranted('jo_in.list', null, 'No access.'); + + $params = $this->initParameters('jo_in'); + $params['mode'] = 'create_vehicle'; + $params['submit_url'] = $this->generateUrl('jo_in_submit'); + $params['return_url'] = $this->generateUrl('jo_in'); + + $em = $this->getDoctrine()->getManager(); + + // get customer vehicle + $cv = $em->getRepository(CustomerVehicle::class)->find($cvid); + + // make sure this customer vehicle exists + if (empty($cv)) + { + $em->getConnection()->rollback(); + throw $this->createNotFoundException('The job order does not exist'); + } + + $jo = new JobOrder(); + $jo->setCustomerVehicle($cv) + ->setCustomer($cv->getCustomer()); + + $params['obj'] = $jo; + $this->fillDropdownParameters($params); + + // response + return $this->render('job-order/form.html.twig', $params); + } + public function incomingSubmit(Request $req, ValidatorInterface $validator, InvoiceCreator $ic) { $this->denyAccessUnlessGranted('jo_in.list', null, 'No access.'); diff --git a/templates/customer/form.html.twig b/templates/customer/form.html.twig index c6518a83..5278a332 100644 --- a/templates/customer/form.html.twig +++ b/templates/customer/form.html.twig @@ -434,7 +434,7 @@ {% if app.request.query.get('ref') == 'jo' %} window.location.href = "{{ url('jo_in') }}"; {% else %} - window.location.href = "{{ url('customer_list') }}"; + window.location.href = "{{ url('customer_update_blank') }}/" + response.id; {% endif %} } }); @@ -666,6 +666,27 @@ return false; } + // forward to job edit form + $(document).on("click", ".btn-jo-vehicle", function() { + var form = $("#vehicle-form"); + var tr = $(this).closest('tr'); + var index = parseInt(tr.find("[name='index']").val()); + var rowData = findVehicleRow(index); + + if (!rowData) { + return; + } + + row = rowData.row; + + // check if we can forward to job order + if (row.id == '') { + alert('Customer has to be saved first.'); + } else { + window.location.href = "{{ url("jo_in_vehicle_blank") }}/" + row.id; + } + }); + // display edit vehicle form $(document).on("click", ".btn-edit-vehicle", function() { var form = $("#vehicle-form"); @@ -1010,15 +1031,16 @@ }, { field: 'Actions', - width: 70, + width: 100, title: 'Actions', sortable: false, overflow: 'visible', template: function (row, index, datatable) { html = ''; - html += '' + - ''; + html += ''; + html += ''; + html += ''; return html; }, diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index 9d11ffa9..238f887a 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -72,9 +72,7 @@ - {% endif %} - - {% if mode != 'create' and obj.getReferenceJO %} + {% elseif obj.getReferenceJO %}
@@ -95,12 +93,12 @@
- +
- +
@@ -109,7 +107,7 @@
+63 - +
@@ -117,7 +115,7 @@
+63 - +
@@ -127,7 +125,7 @@
+63 - +
@@ -135,7 +133,7 @@
+63 - +
@@ -143,7 +141,7 @@
- +
@@ -157,29 +155,29 @@
- +
- +
- +
- +
- +
@@ -193,17 +191,17 @@
- +
- +
- +
@@ -774,7 +772,7 @@ {% if mode != 'update-all' %} {% endif %} - {% if mode != 'create' and is_granted('joborder.cancel') and obj.getStatus != status_cancelled %} + {% if mode != 'create' and mode != 'create_vehicle' and is_granted('joborder.cancel') and obj.getStatus != 'status_cancelled' %} Cancel Job Order {% endif %} {% if mode != 'create' %} @@ -853,7 +851,7 @@ $(function() { } }); - {% if mode != 'create' %} + {% if mode != 'create' and mode != 'create_vehicle'%} // check if we need to set map var latlng = new google.maps.LatLng({{ obj.getCoordinates.getLatitude }}, {{ obj.getCoordinates.getLongitude }}); selectPoint(map, latlng);