Add new customer option enabling customer and vehicle fields #319

This commit is contained in:
Kendrick Chan 2020-02-04 18:39:14 +08:00
parent ca8d6fb57d
commit 4ad0db07e8

View file

@ -75,20 +75,27 @@
{% endif %} {% endif %}
<div class="m-form__section{{ mode != 'create' and not obj.getReferenceJO ? ' m-form__section--first' }}"> <div class="m-form__section{{ mode != 'create' and not obj.getReferenceJO ? ' m-form__section--first' }}">
<div class="m-form__heading"> <div class="m-form__heading flex-row">
<h3 class="m-form__heading-title"> <h3 class="m-form__heading-title">
Customer Details Customer Details
</h3> </h3>
<span class="m-switch m-switch--icon block-switch">
<label>
<input type="checkbox" name="new_customer" id="flag-new-customer" value="1"{{ obj.isAdvanceOrder ? ' checked' }}>
<label class="switch-label">New Customer</label>
<span></span>
</label>
</span>
</div> </div>
<div class="form-group m-form__group row"> <div class="form-group m-form__group row">
<div class="col-lg-6"> <div class="col-lg-6">
<label data-field="customer_first_name">First Name</label> <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.getFirstName|default('') }}" data-vehicle-field="1" disabled> <input type="text" name="customer_first_name" id="customer-first-name" class="form-control m-input cust_field" value="{{ obj.getCustomer.getFirstName|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="customer_first_name"></div> <div class="form-control-feedback hide" data-field="customer_first_name"></div>
</div> </div>
<div class="col-lg-6"> <div class="col-lg-6">
<label data-field="customer_last_name">Last Name</label> <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.getLastName|default('') }}" data-vehicle-field="1" disabled> <input type="text" name="customer_last_name" id="customer-last-name" class="form-control m-input cust_field" value="{{ obj.getCustomer.getLastName|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="customer_last_name"></div> <div class="form-control-feedback hide" data-field="customer_last_name"></div>
</div> </div>
</div> </div>
@ -97,7 +104,7 @@
<label data-field="customer_phone_mobile">Mobile Phone</label> <label data-field="customer_phone_mobile">Mobile Phone</label>
<div class="input-group m-input-group"> <div class="input-group m-input-group">
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span> <span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
<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> <input type="text" name="customer_phone_mobile" id="customer-phone-mobile" class="form-control m-input cust_field" value="{{ obj.getCustomer.getPhoneMobile|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="customer_phone_mobile"></div> <div class="form-control-feedback hide" data-field="customer_phone_mobile"></div>
</div> </div>
</div> </div>
@ -105,7 +112,7 @@
<label data-field="customer_phone_landline">Landline</label> <label data-field="customer_phone_landline">Landline</label>
<div class="input-group m-input-group"> <div class="input-group m-input-group">
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span> <span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
<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> <input type="text" name="customer_phone_landline" id="customer-phone-landline" class="form-control m-input cust_field" value="{{ obj.getCustomer.getPhoneLandline|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="customer_phone_landline"></div> <div class="form-control-feedback hide" data-field="customer_phone_landline"></div>
</div> </div>
</div> </div>
@ -115,7 +122,7 @@
<label data-field="customer_phone_office">Office Phone</label> <label data-field="customer_phone_office">Office Phone</label>
<div class="input-group m-input-group"> <div class="input-group m-input-group">
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span> <span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
<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> <input type="text" name="customer_phone_office" id="customer-phone-office" class="form-control m-input cust_field" value="{{ obj.getCustomer.getPhoneOffice|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="customer_phone_office"></div> <div class="form-control-feedback hide" data-field="customer_phone_office"></div>
</div> </div>
</div> </div>
@ -123,7 +130,7 @@
<label data-field="customer_phone_fax">Fax</label> <label data-field="customer_phone_fax">Fax</label>
<div class="input-group m-input-group"> <div class="input-group m-input-group">
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span> <span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
<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> <input type="text" name="customer_phone_fax" id="customer-phone-fax" class="form-control m-input cust_field" value="{{ obj.getCustomer.getPhoneFax|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="customer_phone_fax"></div> <div class="form-control-feedback hide" data-field="customer_phone_fax"></div>
</div> </div>
</div> </div>
@ -131,7 +138,7 @@
<div class="form-group m-form__group row"> <div class="form-group m-form__group row">
<div class="col-lg-6"> <div class="col-lg-6">
<label data-field="customer_customer_notes">Customer Notes</label> <label data-field="customer_customer_notes">Customer Notes</label>
<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 cust_field" 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> </div>
@ -144,33 +151,35 @@
</div> </div>
<div class="form-group m-form__group row"> <div class="form-group m-form__group row">
<div class="col-lg-3"> <div class="col-lg-3">
<label data-field="vmfg">Manufacturer</label> <label data-field="cv_mfg">Manufacturer</label>
<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> <input type="text" name="cv_mfg" id="vmfg" class="form-control m-input cv_field" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getVehicle.getManufacturer.getName }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="vmfg"></div> <div class="form-control-feedback hide" data-field="cv_mfg"></div>
</div> </div>
<div class="col-lg-3"> <div class="col-lg-3">
<label data-field="vehicle_make">Make</label> <label data-field="cv_make">Make</label>
<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> <input type="text" name="cv_make" id="cv-make" class="form-control m-input cv_field" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getVehicle.getMake }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="vehicle_make"></div> <div class="form-control-feedback hide" data-field="cv_make"></div>
</div> </div>
<div class="col-lg-3"> <div class="col-lg-3">
<label data-field="vehicle_year">Model Year</label> <label data-field="cv_year">Model Year</label>
<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> <input type="text" name="cv_year" id="cv-year" class="form-control m-input cv_field" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getModelYear }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="vehicle_year"></div> <div class="form-control-feedback hide" data-field="cv_year"></div>
</div>
<div class="col-lg-3">
<label data-field="cv_plate">Plate #</label>
<input type="text" name="cv_plate" id="cv-plate" class="form-control m-input cv_field" value="{{ obj.getCustomerVehicle.getPlateNumber|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="cv_color"></div>
</div> </div>
</div> </div>
<!--
<div class="form-group m-form__group row"> <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('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="vehicle_color"></div>
</div>
<div class="col-lg-3"> <div class="col-lg-3">
<label data-field="vehicle_color">Color</label> <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 }}" data-vehicle-field="1" disabled> <input type="text" name="vehicle_color" id="vehicle-color" class="form-control m-input cv_field" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getColor }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="vehicle_color"></div> <div class="form-control-feedback hide" data-field="vehicle_color"></div>
</div> </div>
</div> </div>
-->
</div> </div>
<div class="m-form__section"> <div class="m-form__section">
<div class="m-form__heading"> <div class="m-form__heading">
@ -1123,6 +1132,20 @@ $(function() {
} }
}).change(); }).change();
// toggle new customer
$("#flag-new-customer").change(function() {
console.log('HERE');
checked = $(this).prop('checked');
if (checked) {
$('.cust_field').prop('disabled', false);
$('.cv_field').prop('disabled', false);
} else {
$('.cust_field').prop('disabled', true);
$('.cv_field').prop('disabled', true);
}
}).change();
// update battery list when changing manufacturer // update battery list when changing manufacturer
$("#invoice-bmfg").change(function() { $("#invoice-bmfg").change(function() {
{% if ftags.preset_vehicle %} {% if ftags.preset_vehicle %}