Allow user to create JO from customer vehicle #62
This commit is contained in:
parent
22dc854481
commit
e371d9900d
4 changed files with 83 additions and 23 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.');
|
||||
|
|
|
|||
|
|
@ -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 = '<input type="hidden" name="index" value="' + row.index + '">';
|
||||
|
||||
html += '<button type="button" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit-vehicle" title="Edit"><i class="la la-edit"></i></button>' +
|
||||
'<button data-index="' + row.index + '" type="button" class="m-portlet__nav-link btn m-btn m-btn--hover-danger m-btn--icon m-btn--icon-only m-btn--pill btn-delete-vehicle" title="Delete"><i class="la la-trash"></i></button>';
|
||||
html += '<button type="button" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-jo-vehicle" title="Job Order"><i class="flaticon-calendar-3"></i></button>';
|
||||
html += '<button type="button" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit-vehicle" title="Edit"><i class="la la-edit"></i></button>';
|
||||
html += '<button data-index="' + row.index + '" type="button" class="m-portlet__nav-link btn m-btn m-btn--hover-danger m-btn--icon m-btn--icon-only m-btn--pill btn-delete-vehicle" title="Delete"><i class="la la-trash"></i></button>';
|
||||
|
||||
return html;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -72,9 +72,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if mode != 'create' and obj.getReferenceJO %}
|
||||
{% elseif obj.getReferenceJO %}
|
||||
<div class="m-form__section m-form__section--first">
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-6">
|
||||
|
|
@ -95,12 +93,12 @@
|
|||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-6">
|
||||
<label data-field="customer_first_name">First Name</label>
|
||||
<input type="text" name="customer_first_name" id="customer-first-name" class="form-control m-input" value="{{ obj.getCustomer ? obj.getCustomer.getFirstName }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="customer_first_name" id="customer-first-name" class="form-control m-input" value="{{ obj.getCustomer.getFirstName|default('') }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="customer_first_name"></div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<label data-field="customer_last_name">Last Name</label>
|
||||
<input type="text" name="customer_last_name" id="customer-last-name" class="form-control m-input" value="{{ obj.getCustomer ? obj.getCustomer.getLastName }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="customer_last_name" id="customer-last-name" class="form-control m-input" value="{{ obj.getCustomer.getLastName|default('') }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="customer_last_name"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -109,7 +107,7 @@
|
|||
<label data-field="customer_phone_mobile">Mobile Phone</label>
|
||||
<div class="input-group m-input-group">
|
||||
<span class="input-group-addon">+63</span>
|
||||
<input type="text" name="customer_phone_mobile" id="customer-phone-mobile" class="form-control m-input" value="{{ obj.getCustomer.getPhoneMobile|default('') }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="customer_phone_mobile" id="customer-phone-mobile" class="form-control m-input" value="{{ obj.getCustomer.getPhoneMobile|default('') }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="customer_phone_mobile"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -117,7 +115,7 @@
|
|||
<label data-field="customer_phone_landline">Landline</label>
|
||||
<div class="input-group m-input-group">
|
||||
<span class="input-group-addon">+63</span>
|
||||
<input type="text" name="customer_phone_landline" id="customer-phone-landline" class="form-control m-input" value="{{ obj.getCustomer.getPhoneLandline|default('') }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="customer_phone_landline" id="customer-phone-landline" class="form-control m-input" value="{{ obj.getCustomer.getPhoneLandline|default('') }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="customer_phone_landline"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -127,7 +125,7 @@
|
|||
<label data-field="customer_phone_office">Office Phone</label>
|
||||
<div class="input-group m-input-group">
|
||||
<span class="input-group-addon">+63</span>
|
||||
<input type="text" name="customer_phone_office" id="customer-phone-office" class="form-control m-input" value="{{ obj.getCustomer.getPhoneOffice|default('') }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="customer_phone_office" id="customer-phone-office" class="form-control m-input" value="{{ obj.getCustomer.getPhoneOffice|default('') }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="customer_phone_office"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -135,7 +133,7 @@
|
|||
<label data-field="customer_phone_fax">Fax</label>
|
||||
<div class="input-group m-input-group">
|
||||
<span class="input-group-addon">+63</span>
|
||||
<input type="text" name="customer_phone_fax" id="customer-phone-fax" class="form-control m-input" value="{{ obj.getCustomer.getPhoneFax|default('') }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="customer_phone_fax" id="customer-phone-fax" class="form-control m-input" value="{{ obj.getCustomer.getPhoneFax|default('') }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="customer_phone_fax"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -143,7 +141,7 @@
|
|||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-6">
|
||||
<label data-field="customer_customer_notes">Customer Notes</label>
|
||||
<textarea name="customer_customer_notes" id="customer-customer-notes" class="form-control m-input" placeholder="Select a vehicle first" data-vehicle-field="1" rows="4" disabled>{{ obj.getCustomer ? obj.getCustomer.getCustomerNotes }}</textarea>
|
||||
<textarea name="customer_customer_notes" id="customer-customer-notes" class="form-control m-input" data-vehicle-field="1" rows="4" disabled>{{ obj.getCustomer ? obj.getCustomer.getCustomerNotes }}</textarea>
|
||||
<div class="form-control-feedback hide" data-field="customer_customer_notes"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -157,29 +155,29 @@
|
|||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-3">
|
||||
<label data-field="vmfg">Manufacturer</label>
|
||||
<input type="text" name="vmfg" id="vmfg" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getVehicle.getManufacturer.getName }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="vmfg" id="vmfg" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getVehicle.getManufacturer.getName }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="vmfg"></div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<label data-field="vehicle_make">Make</label>
|
||||
<input type="text" name="vehicle_make" id="vehicle-make" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getVehicle.getMake }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="vehicle_make" id="vehicle-make" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getVehicle.getMake }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="vehicle_make"></div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<label data-field="vehicle_year">Model Year</label>
|
||||
<input type="text" name="vehicle_year" id="vehicle-year" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getModelYear }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="vehicle_year" id="vehicle-year" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getModelYear }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="vehicle_year"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-3">
|
||||
<label data-field="vehicle_plate">Plate #</label>
|
||||
<input type="text" name="vehicle_plate" id="vehicle-plate" class="form-control m-input" value="{{ obj.getCustomerVehicle.getPlateNumber|default('') }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="vehicle_plate" id="vehicle-plate" class="form-control m-input" value="{{ obj.getCustomerVehicle.getPlateNumber|default('') }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="vehicle_color"></div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<label data-field="vehicle_color">Color</label>
|
||||
<input type="text" name="vehicle_color" id="vehicle-color" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getColor }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="vehicle_color" id="vehicle-color" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getColor }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="vehicle_color"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -193,17 +191,17 @@
|
|||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-3">
|
||||
<label data-field="current_battery">Current Battery</label>
|
||||
<input type="text" name="current_battery" id="current-battery" class="form-control m-input" value="{{ obj.getCustomerVehicle and obj.getCustomerVehicle.getCurrentBattery ? obj.getCustomerVehicle.getCurrentBattery.getManufacturer.getName ~ ' ' ~ obj.getCustomerVehicle.getCurrentBattery.getModel.getName ~ ' ' ~ obj.getCustomerVehicle.getCurrentBattery.getSize.getName ~ ' (' ~ obj.getCustomerVehicle.getCurrentBattery.getProductCode ~ ')' }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="current_battery" id="current-battery" class="form-control m-input" value="{{ obj.getCustomerVehicle and obj.getCustomerVehicle.getCurrentBattery ? obj.getCustomerVehicle.getCurrentBattery.getManufacturer.getName ~ ' ' ~ obj.getCustomerVehicle.getCurrentBattery.getModel.getName ~ ' ' ~ obj.getCustomerVehicle.getCurrentBattery.getSize.getName ~ ' (' ~ obj.getCustomerVehicle.getCurrentBattery.getProductCode ~ ')' }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="current_battery"></div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<label data-field="warranty_code">Warranty Code</label>
|
||||
<input type="text" name="warranty_code" id="warranty-code" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getWarrantyCode }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="warranty_code" id="warranty-code" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getWarrantyCode }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="warranty_code"></div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<label data-field="warranty_expiration">Warranty Expiration Date</label>
|
||||
<input type="text" name="warranty_expiration" id="warranty-expiration" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getWarrantyExpiration|date("d M Y") }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="warranty_expiration" id="warranty-expiration" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getWarrantyExpiration|date("d M Y") }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="warranty_expiration"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -774,7 +772,7 @@
|
|||
{% if mode != 'update-all' %}
|
||||
<button type="submit" class="btn btn-success">{{ mode == 'update-fulfillment' ? 'Fulfill' : 'Submit' }}</button>
|
||||
{% 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' %}
|
||||
<a href="{{ url('jo_cancel', {'id': obj.getID}) }}" class="btn btn-danger btn-cancel-job-order">Cancel Job Order</button>
|
||||
{% 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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue