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; 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() public function __construct()
{ {
$this->numbers = new ArrayCollection(); $this->numbers = new ArrayCollection();
@ -191,6 +206,10 @@ class Customer
$this->priv_promo = 0; $this->priv_promo = 0;
$this->flag_csat = false; $this->flag_csat = false;
$this->flag_promo_email = false;
$this->flag_promo_sms = false;
$this->flag_dpa_consent = false;
} }
public function getID() public function getID()
@ -490,5 +509,36 @@ class Customer
return $this->privpol_promo; 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_landline' => $customer->getPhoneLandline(),
'phone_office' => $customer->getPhoneOffice(), 'phone_office' => $customer->getPhoneOffice(),
'phone_fax' => $customer->getPhoneFax(), 'phone_fax' => $customer->getPhoneFax(),
'email' => $customer->getEmail(),
'flag_dpa_consent' => $customer->isDpaConsent(),
'flag_promo_sms' => $customer->isPromoSms(),
'flag_promo_email' => $customer->isPromoEmail(),
], ],
'vehicle' => [ 'vehicle' => [
'id' => $vehicle->getID(), 'id' => $vehicle->getID(),
@ -566,7 +570,10 @@ class ResqCustomerHandler implements CustomerHandlerInterface
->setCustomerNotes($req->request->get('customer_notes')) ->setCustomerNotes($req->request->get('customer_notes'))
->setEmail($req->request->get('email')) ->setEmail($req->request->get('email'))
->setIsCSAT($req->request->get('flag_csat') ? true : false) ->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 // phone numbers
$obj->setPhoneMobile($req->request->get('phone_mobile')) $obj->setPhoneMobile($req->request->get('phone_mobile'))

View file

@ -24,6 +24,7 @@ use App\Entity\Promo;
use App\Entity\Rider; use App\Entity\Rider;
use App\Entity\JORejection; use App\Entity\JORejection;
use App\Entity\Warranty; use App\Entity\Warranty;
use App\Entity\Customer;
use App\Ramcar\InvoiceCriteria; use App\Ramcar\InvoiceCriteria;
use App\Ramcar\ServiceType; use App\Ramcar\ServiceType;
@ -280,6 +281,22 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$jo = new JobOrder(); $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 // check if lat and lng are provided
if (empty($req->request->get('coord_lng')) || empty($req->request->get('coord_lat'))) { 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.'; $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 // check if errors are found
if (empty($error_array)) 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($jo);
$em->persist($customer);
// the event // the event
$event = new JOEvent(); $event = new JOEvent();

View file

@ -92,7 +92,7 @@
</div> </div>
</div> </div>
<div class="form-group m-form__group row"> <div class="form-group m-form__group row">
<div class="col-lg-12"> <div class="col-lg-4">
<span class="m-switch m-switch--icon block-switch"> <span class="m-switch m-switch--icon block-switch">
<label> <label>
<input type="checkbox" name="flag_csat" id="flag_csat" value="1"{{ obj.isCSAT() ? ' checked' }}> <input type="checkbox" name="flag_csat" id="flag_csat" value="1"{{ obj.isCSAT() ? ' checked' }}>
@ -102,6 +102,30 @@
</span> </span>
<div class="form-control-feedback hide" data-field="flag_active"></div> <div class="form-control-feedback hide" data-field="flag_active"></div>
</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>
<div class="form-group m-form__group row"> <div class="form-group m-form__group row">
<div class="col-lg-12"> <div class="col-lg-12">

View file

@ -46,6 +46,7 @@
</div> </div>
<form id="row-form" class="m-form m-form--fit m-form--label-align-right" method="post" action="{{ submit_url }}"> <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="invoice-change" name="invoice_change" value="0">
<input type="hidden" id="cid" name="cid" value="0">
<div class="m-portlet__body"> <div class="m-portlet__body">
{% if ftags.vehicle_dropdown %} {% 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> <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 class="form-control-feedback hide" data-field="customer_customer_notes"></div>
</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> </div>
<div class="m-form__section"> <div class="m-form__section">
@ -331,6 +337,34 @@
<div class="form-control-feedback hide" data-field="date_transaction"></div> <div class="form-control-feedback hide" data-field="date_transaction"></div>
</div> </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>
<!-- <!--
<div class="form-group m-form__group row"> <div class="form-group m-form__group row">
@ -1032,6 +1066,14 @@ $(function() {
{% endfor %} {% endfor %}
{% endif %} {% 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) { $("#row-form").submit(function(e) {
if (form_in_process) { if (form_in_process) {
alert("Cannot submit form twice. First submission still in progress."); alert("Cannot submit form twice. First submission still in progress.");
@ -1172,12 +1214,27 @@ $(function() {
$("#customer-phone-office").val(vdata.customer.phone_office); $("#customer-phone-office").val(vdata.customer.phone_office);
$("#customer-phone-fax").val(vdata.customer.phone_fax); $("#customer-phone-fax").val(vdata.customer.phone_fax);
$("#customer-customer-notes").val(vdata.customer.customer_notes); $("#customer-customer-notes").val(vdata.customer.customer_notes);
$("#customer-email").val(vdata.customer.email);
$("#vmfg").val(vdata.vehicle.mfg_name); $("#vmfg").val(vdata.vehicle.mfg_name);
$("#vehicle-make").val(vdata.vehicle.make); $("#vehicle-make").val(vdata.vehicle.make);
$("#vehicle-year").val(vdata.vehicle.model_year); $("#vehicle-year").val(vdata.vehicle.model_year);
$("#vehicle-color").val(vdata.vehicle.color); $("#vehicle-color").val(vdata.vehicle.color);
$("#vehicle-plate").val(vdata.vehicle.plate_number); $("#vehicle-plate").val(vdata.vehicle.plate_number);
// 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') { if (typeof vdata.battery !== 'undefined') {
$("#current-battery").val(vdata.battery.mfg_name + " " + vdata.battery.model_name + " " + vdata.battery.size_name + " (" + vdata.battery.prod_code + ")"); $("#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-code").val(vdata.battery.warranty_code);
@ -1213,6 +1270,10 @@ $(function() {
// reset all vehicle info form fields // reset all vehicle info form fields
function resetVehicleFields() { function resetVehicleFields() {
$("[data-vehicle-field='1']").val("").css('color', '').prop('placeholder', 'Select a vehicle first'); $("[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 // datepicker