Make editable the new fields in JO form. #324
This commit is contained in:
parent
5dc57dc073
commit
716f263e6b
3 changed files with 80 additions and 35 deletions
|
|
@ -514,6 +514,10 @@ class ResqCustomerHandler implements CustomerHandlerInterface
|
|||
'phone_landline' => $customer->getPhoneLandline(),
|
||||
'phone_office' => $customer->getPhoneOffice(),
|
||||
'phone_fax' => $customer->getPhoneFax(),
|
||||
'email' => $customer->getEmail(),
|
||||
'flag_dpa_consent' => $customer->isDpaConsent(),
|
||||
'flag_promo_sms' => $customer->isPromoSms(),
|
||||
'flag_promo_email' => $customer->isPromoEmail(),
|
||||
],
|
||||
'vehicle' => [
|
||||
'id' => $vehicle->getID(),
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ use App\Entity\Promo;
|
|||
use App\Entity\Rider;
|
||||
use App\Entity\JORejection;
|
||||
use App\Entity\Warranty;
|
||||
use App\Entity\Customer;
|
||||
|
||||
use App\Ramcar\InvoiceCriteria;
|
||||
use App\Ramcar\ServiceType;
|
||||
|
|
@ -280,6 +281,22 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$jo = new JobOrder();
|
||||
}
|
||||
|
||||
// find customer
|
||||
$cust_id = $req->request->get('cid');
|
||||
$customer = $em->getRepository(Customer::class)->find($cust_id);
|
||||
if (empty($customer))
|
||||
{
|
||||
$error_array['customer_vehicle'] = 'Invalid customer specified.';
|
||||
}
|
||||
else
|
||||
{
|
||||
// get email, dpa_consent, promo_sms, and promo_email, if set
|
||||
$customer->setEmail($req->request->get('customer_email'))
|
||||
->setPromoSms($req->request->get('flag_promo_sms') ? true : false)
|
||||
->setPromoEmail($req->request->get('flag_promo_email') ? true : false)
|
||||
->setDpaConsent($req->request->get('flag_dpa_consent') ? true : false);
|
||||
}
|
||||
|
||||
// check if lat and lng are provided
|
||||
if (empty($req->request->get('coord_lng')) || empty($req->request->get('coord_lat'))) {
|
||||
$error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.';
|
||||
|
|
@ -365,8 +382,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
// check if errors are found
|
||||
if (empty($error_array))
|
||||
{
|
||||
// validated, no error. save the job order
|
||||
// validated, no error. save the job order and customer
|
||||
$em->persist($jo);
|
||||
$em->persist($customer);
|
||||
|
||||
// the event
|
||||
$event = new JOEvent();
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
</div>
|
||||
<form id="row-form" class="m-form m-form--fit m-form--label-align-right" method="post" action="{{ submit_url }}">
|
||||
<input type="hidden" id="invoice-change" name="invoice_change" value="0">
|
||||
<input type="hidden" id="cid" name="cid" value="0">
|
||||
<div class="m-portlet__body">
|
||||
|
||||
{% if ftags.vehicle_dropdown %}
|
||||
|
|
@ -149,8 +150,9 @@
|
|||
<div class="form-control-feedback hide" data-field="customer_customer_notes"></div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<input type="checkbox" name="flag_dpa_consent" id="flag-dpa_consent" value="1"{{ obj.getCustomer ? obj.getCustomer.isDpaConsent ? ' checked' }} disabled>
|
||||
<input type="checkbox" name="flag_dpa_consent" id="flag-dpa-consent" value="1"{{ obj.getCustomer ? obj.getCustomer.isDpaConsent ? ' checked' }} >
|
||||
<label class="switch-label">With DPA Consent</label>
|
||||
<div class="form-control-feedback hide" data-field="flag_dpa_consent"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -342,14 +344,16 @@
|
|||
<label data-field="source">Marketing Promo</label>
|
||||
<div class="m-checkbox-list">
|
||||
<label class="m-checkbox">
|
||||
<input type="checkbox" name="flag_promo_sms" value="{{ obj.getCustomer ? obj.getCustomer.isPromoSms ? ' checked': '' }}" disabled>
|
||||
<input type="checkbox" name="flag_promo_sms" id="flag-promo-sms" value="1"{{ obj.getCustomer ? obj.getCustomer.isPromoSms ? ' checked' }} >
|
||||
SMS
|
||||
<span></span>
|
||||
<span></span>
|
||||
<div class="form-control-feedback hide" data-field="flag_promo_sms"></div>
|
||||
</label>
|
||||
<label class="m-checkbox">
|
||||
<input type="checkbox" name="flag_promo_email" value="{{ obj.getCustomer ? obj.getCustomer.isPromoEmail ? ' checked': '' }}" disabled>
|
||||
<input type="checkbox" name="flag_promo_email" id="flag-promo-email" value="1"{{ obj.getCustomer ? obj.getCustomer.isPromoEmail ? ' checked' }} >
|
||||
Email
|
||||
<span></span>
|
||||
<div class="form-control-feedback hide" data-field="flag_promo_email"></div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -357,8 +361,8 @@
|
|||
<div class="col-lg-6">
|
||||
<div class="col-lg-12 form-group-inner">
|
||||
<label>Email Address</label>
|
||||
<input type="text" name="email_address" class="form-control m-input" value="{{ obj.getCustomer ? obj.getCustomer.getEmail|default('') }}" disabled>
|
||||
<div class="form-control-feedback hide" data-field="email_address"></div>
|
||||
<input type="text" name="customer_email" id="customer-email" class="form-control m-input" value="{{ obj.getCustomer ? obj.getCustomer.getEmail|default('') }}" data-vehicle-field="1" >
|
||||
<div class="form-control-feedback hide" data-field="customer_email"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1178,44 +1182,59 @@ $(function() {
|
|||
|
||||
// get info for this customer vehicle
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "{{ url('customer_vehicle_info') }}",
|
||||
data: { id: data.id }
|
||||
}).done(function(response) {
|
||||
vdata = response.data;
|
||||
method: "GET",
|
||||
url: "{{ url('customer_vehicle_info') }}",
|
||||
data: { id: data.id }
|
||||
}).done(function(response) {
|
||||
vdata = response.data;
|
||||
|
||||
// reset vehicle fields
|
||||
resetVehicleFields();
|
||||
// reset vehicle fields
|
||||
resetVehicleFields();
|
||||
|
||||
// reset invoice fields
|
||||
$("#btn-reset-invoice").click();
|
||||
// reset invoice fields
|
||||
$("#btn-reset-invoice").click();
|
||||
|
||||
// get compatible batteries
|
||||
$("#invoice-bmfg").change();
|
||||
// get compatible batteries
|
||||
$("#invoice-bmfg").change();
|
||||
|
||||
// set form fields
|
||||
$("[data-vehicle-field='1']").prop('placeholder', '');
|
||||
$("#customer-first-name").val(vdata.customer.first_name);
|
||||
$("#customer-last-name").val(vdata.customer.last_name);
|
||||
// set form fields
|
||||
$("[data-vehicle-field='1']").prop('placeholder', '');
|
||||
$("#customer-first-name").val(vdata.customer.first_name);
|
||||
$("#customer-last-name").val(vdata.customer.last_name);
|
||||
$("#customer-phone-mobile").val(vdata.customer.phone_mobile);
|
||||
$("#customer-phone-landline").val(vdata.customer.phone_landline);
|
||||
$("#customer-phone-office").val(vdata.customer.phone_office);
|
||||
$("#customer-phone-fax").val(vdata.customer.phone_fax);
|
||||
$("#customer-customer-notes").val(vdata.customer.customer_notes);
|
||||
$("#vmfg").val(vdata.vehicle.mfg_name);
|
||||
$("#vehicle-make").val(vdata.vehicle.make);
|
||||
$("#vehicle-year").val(vdata.vehicle.model_year);
|
||||
$("#vehicle-color").val(vdata.vehicle.color);
|
||||
$("#customer-customer-notes").val(vdata.customer.customer_notes);
|
||||
$("#customer-email").val(vdata.customer.email);
|
||||
$("#vmfg").val(vdata.vehicle.mfg_name);
|
||||
$("#vehicle-make").val(vdata.vehicle.make);
|
||||
$("#vehicle-year").val(vdata.vehicle.model_year);
|
||||
$("#vehicle-color").val(vdata.vehicle.color);
|
||||
$("#vehicle-plate").val(vdata.vehicle.plate_number);
|
||||
|
||||
if (typeof vdata.battery !== 'undefined') {
|
||||
$("#current-battery").val(vdata.battery.mfg_name + " " + vdata.battery.model_name + " " + vdata.battery.size_name + " (" + vdata.battery.prod_code + ")");
|
||||
$("#warranty-code").val(vdata.battery.warranty_code);
|
||||
$("#warranty-expiration").val(vdata.battery.warranty_expiration);
|
||||
} else {
|
||||
$("#current-battery, #warranty-code, #warranty-expiration").val("No current battery").css('color', '#f4516c');
|
||||
}
|
||||
})
|
||||
// checkboxes
|
||||
if (vdata.customer.flag_dpa_consent === true) {
|
||||
$("#flag-dpa-consent").prop("checked", true);
|
||||
}
|
||||
if (vdata.customer.flag_promo_sms === true) {
|
||||
$("#flag-promo-sms").prop("checked", true);
|
||||
}
|
||||
if (vdata.customer.flag_promo_email === true) {
|
||||
$("#flag-promo-email").prop("checked", true);
|
||||
}
|
||||
|
||||
// set hidden customer id
|
||||
$("#cid").val(vdata.customer.id);
|
||||
|
||||
if (typeof vdata.battery !== 'undefined') {
|
||||
$("#current-battery").val(vdata.battery.mfg_name + " " + vdata.battery.model_name + " " + vdata.battery.size_name + " (" + vdata.battery.prod_code + ")");
|
||||
$("#warranty-code").val(vdata.battery.warranty_code);
|
||||
$("#warranty-expiration").val(vdata.battery.warranty_expiration);
|
||||
} else {
|
||||
$("#current-battery, #warranty-code, #warranty-expiration").val("No current battery").css('color', '#f4516c');
|
||||
}
|
||||
})
|
||||
}).focus();
|
||||
{% endif %}
|
||||
|
||||
|
|
@ -1243,6 +1262,10 @@ $(function() {
|
|||
// reset all vehicle info form fields
|
||||
function resetVehicleFields() {
|
||||
$("[data-vehicle-field='1']").val("").css('color', '').prop('placeholder', 'Select a vehicle first');
|
||||
|
||||
$("#flag-dpa-consent").prop("checked", false);
|
||||
$("#flag-promo-sms").prop("checked", false);
|
||||
$("#flag-promo-email").prop("checked", false);
|
||||
}
|
||||
|
||||
// datepicker
|
||||
|
|
|
|||
Loading…
Reference in a new issue