Merge branch '324-add-new-fields-for-jo-form' into '329-transition-branch-for-cmb-and-resq-merging'

Resolve "Add new fields for JO form"

See merge request jankstudio/resq!375
This commit is contained in:
Kendrick Chan 2020-02-11 02:05:56 +00:00
commit cf7e026948
5 changed files with 216 additions and 56 deletions

View file

@ -165,6 +165,21 @@ class Customer
*/
protected $privpol_promo;
/**
* @ORM\Column(type="boolean", options={"default":false})
*/
protected $flag_promo_email;
/**
* @ORM\Column(type="boolean", options={"default":false})
*/
protected $flag_promo_sms;
/**
* @ORM\Column(type="boolean", options={"default":false})
*/
protected $flag_dpa_consent;
public function __construct()
{
$this->numbers = new ArrayCollection();
@ -191,6 +206,10 @@ class Customer
$this->priv_promo = 0;
$this->flag_csat = false;
$this->flag_promo_email = false;
$this->flag_promo_sms = false;
$this->flag_dpa_consent = false;
}
public function getID()
@ -490,5 +509,36 @@ class Customer
return $this->privpol_promo;
}
public function setPromoEmail($flag_promo_email = true)
{
$this->flag_promo_email = $flag_promo_email;
return $this;
}
public function isPromoEmail()
{
return $this->flag_promo_email;
}
public function setPromoSms($flag_promo_sms = true)
{
$this->flag_promo_sms = $flag_promo_sms;
return $this;
}
public function isPromoSms()
{
return $this->flag_promo_sms;
}
public function setDpaConsent($flag_dpa_consent = true)
{
$this->flag_dpa_consent = $flag_dpa_consent;
return $this;
}
public function isDpaConsent()
{
return $this->flag_dpa_consent;
}
}

View file

@ -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(),
@ -566,7 +570,10 @@ class ResqCustomerHandler implements CustomerHandlerInterface
->setCustomerNotes($req->request->get('customer_notes'))
->setEmail($req->request->get('email'))
->setIsCSAT($req->request->get('flag_csat') ? true : false)
->setActive($req->request->get('flag_active') ? true : false);
->setActive($req->request->get('flag_active') ? true : false)
->setPromoSms($req->request->get('flag_promo_sms', false))
->setPromoEmail($req->request->get('flag_promo_email', false))
->setDpaConsent($req->request->get('flag_dpa_consent', false));
// phone numbers
$obj->setPhoneMobile($req->request->get('phone_mobile'))

View file

@ -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', false))
->setPromoEmail($req->request->get('flag_promo_email', false))
->setDpaConsent($req->request->get('flag_dpa_consent', 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();

View file

@ -92,30 +92,54 @@
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-12">
<span class="m-switch m-switch--icon block-switch">
<label>
<input type="checkbox" name="flag_csat" id="flag_csat" value="1"{{ obj.isCSAT() ? ' checked' }}>
<label class="switch-label">CSAT</label>
<span></span>
</label>
</span>
<div class="form-control-feedback hide" data-field="flag_active"></div>
</div>
</div>
<div class="col-lg-4">
<span class="m-switch m-switch--icon block-switch">
<label>
<input type="checkbox" name="flag_csat" id="flag_csat" value="1"{{ obj.isCSAT() ? ' checked' }}>
<label class="switch-label">CSAT</label>
<span></span>
</label>
</span>
<div class="form-control-feedback hide" data-field="flag_active"></div>
</div>
<div class="col-lg-4">
<div class="col-lg-12 form-group-inner">
<label data-field="source">Marketing Promo</label>
<div class="m-checkbox-list">
<label class="m-checkbox">
<input type="checkbox" name="flag_promo_sms" value="1"{{ obj.isPromoSms ? ' checked' }} >
SMS
<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="1"{{ obj.isPromoEmail ? ' checked' }} >
Email
<span></span>
<div class="form-control-feedback hide" data-field="flag_promo_email"></div>
</label>
</div>
</div>
</div>
<div class="col-lg-4">
<input type="checkbox" name="flag_dpa_consent" id="flag-dpa_consent" value="1"{{ obj.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 class="form-group m-form__group row">
<div class="col-lg-12">
<span class="m-switch m-switch--icon block-switch">
<label>
<input type="checkbox" name="flag_active" id="flag_active" value="1"{{ obj.isActive() ? ' checked' }}>
<label class="switch-label">Active</label>
<span></span>
</label>
</span>
<div class="form-control-feedback hide" data-field="flag_active"></div>
</div>
</div>
</div>
<div class="col-lg-12">
<span class="m-switch m-switch--icon block-switch">
<label>
<input type="checkbox" name="flag_active" id="flag_active" value="1"{{ obj.isActive() ? ' checked' }}>
<label class="switch-label">Active</label>
<span></span>
</label>
</span>
<div class="form-control-feedback hide" data-field="flag_active"></div>
</div>
</div>
</div>
<div class="m-form__seperator m-form__seperator--dashed"></div>

View file

@ -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 %}
@ -148,6 +149,11 @@
<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 class="col-lg-6">
<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>
<div class="m-form__section">
@ -295,8 +301,8 @@
<div class="form-control-feedback hide" data-field="tier2_notes"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-6">
<div class="form-group m-form__group row">
<div class="col-lg-6">
<div class="col-lg-12 form-group-inner">
<label data-field="source">Transaction Origin</label>
<select class="form-control m-input" id="source" name="source">
@ -311,7 +317,7 @@
<label data-field="delivery_instructions">Delivery Instructions</label>
<textarea name="delivery_instructions" class="form-control m-input" rows="4">{{ obj.getDeliveryInstructions }}</textarea>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="col-lg-12 form-group-inner">
<label>Prepared By</label>
@ -331,6 +337,34 @@
<div class="form-control-feedback hide" data-field="date_transaction"></div>
</div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-6">
<div class="col-lg-12 form-group-inner">
<label data-field="source">Marketing Promo</label>
<div class="m-checkbox-list">
<label class="m-checkbox">
<input type="checkbox" name="flag_promo_sms" id="flag-promo-sms" value="1"{{ obj.getCustomer ? obj.getCustomer.isPromoSms ? ' checked' }} >
SMS
<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" 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>
</div>
<div class="col-lg-6">
<div class="col-lg-12 form-group-inner">
<label>Email Address</label>
<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>
<!--
<div class="form-group m-form__group row">
@ -1032,6 +1066,14 @@ $(function() {
{% endfor %}
{% endif %}
// disable the enabled customer fields
{% if mode != 'create' %}
$("#customer-email").prop("disabled", true);
$("#flag-dpa-consent").prop("disabled", true);
$("#flag-promo-sms").prop("disabled", true);
$("#flag-promo-email").prop("disabled", true);
{% endif %}
$("#row-form").submit(function(e) {
if (form_in_process) {
alert("Cannot submit form twice. First submission still in progress.");
@ -1148,44 +1190,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 %}
@ -1213,6 +1270,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