Autopopulate the OR Name field with the customer name. #434

This commit is contained in:
Korina Cordero 2020-07-03 07:29:47 +00:00
parent 6e07e24e93
commit c3487358f1
3 changed files with 29 additions and 15 deletions

View file

@ -350,7 +350,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
->setTier2Notes($req->request->get('tier2_notes')) ->setTier2Notes($req->request->get('tier2_notes'))
->setDeliveryAddress($req->request->get('delivery_address')) ->setDeliveryAddress($req->request->get('delivery_address'))
->setORName($req->request->get('or_name')) ->setORName($req->request->get('or_name'))
//->setPromoDetail($req->request->get('promo_detail')) ->setPromoDetail($req->request->get('promo_detail', ''))
->setModeOfPayment($req->request->get('mode_of_payment')) ->setModeOfPayment($req->request->get('mode_of_payment'))
->setLandmark($req->request->get('landmark')); ->setLandmark($req->request->get('landmark'));
@ -554,11 +554,12 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
} }
// get discount and set to meta // get discount and set to meta
$discount = $req->request->get('invoice_discount', []); $discount = $req->request->get('invoice_discount');
// check if discount is greater than 50 or negative number if (($discount > 60) || ($discount < 0))
if (($discount > 50) || ($discount < 0)) {
$error_array['invoice_discount'] = 'Invalid discount specified'; $error_array['invoice_discount'] = 'Invalid discount specified';
}
// get list of service charges // get list of service charges
$service_charges = $req->request->get('service_charges', []); $service_charges = $req->request->get('service_charges', []);
@ -599,7 +600,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
->setTier2Notes($req->request->get('tier2_notes')) ->setTier2Notes($req->request->get('tier2_notes'))
->setDeliveryAddress($req->request->get('delivery_address')) ->setDeliveryAddress($req->request->get('delivery_address'))
->setORName($req->request->get('or_name')) ->setORName($req->request->get('or_name'))
//->setPromoDetail($req->request->get('promo_detail')) ->setPromoDetail($req->request->get('promo_detail', ''))
->setModeOfPayment($req->request->get('mode_of_payment')) ->setModeOfPayment($req->request->get('mode_of_payment'))
->setLandmark($req->request->get('landmark')) ->setLandmark($req->request->get('landmark'))
->setHub($hub) ->setHub($hub)
@ -2673,7 +2674,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
->setTier1Notes($req->request->get('tier1_notes')) ->setTier1Notes($req->request->get('tier1_notes'))
->setTier2Notes($req->request->get('tier2_notes')) ->setTier2Notes($req->request->get('tier2_notes'))
->setORName($req->request->get('or_name')) ->setORName($req->request->get('or_name'))
//->setPromoDetail($req->request->get('promo_detail')) ->setPromoDetail($req->request->get('promo_detail', ''))
->setModeOfPayment($req->request->get('mode_of_payment')) ->setModeOfPayment($req->request->get('mode_of_payment'))
->setLandmark($req->request->get('landmark')) ->setLandmark($req->request->get('landmark'))
->setDeliveryAddress('Walk-in') ->setDeliveryAddress('Walk-in')

View file

@ -644,13 +644,11 @@
<input type="text" name="or_name" id="or_name" class="form-control m-input" value="{{ obj.getORName|default('') }}"> <input type="text" name="or_name" id="or_name" class="form-control m-input" value="{{ obj.getORName|default('') }}">
<div class="form-control-feedback hide" data-field="or_name"></div> <div class="form-control-feedback hide" data-field="or_name"></div>
</div> </div>
<!-- <div style="display:none" class="col-lg-6">
<div class="col-lg-6">
<label data-field="promo_detail">Employee ID / Card Number / Referred By</label> <label data-field="promo_detail">Employee ID / Card Number / Referred By</label>
<input type="text" name="promo_detail" id="promo_detail" class="form-control m-input" value="{{ obj.getPromoDetail|default('') }}"> <input type="text" name="promo_detail" id="promo_detail" class="form-control m-input" value="{{ obj.getPromoDetail|default('') }}">
<div class="form-control-feedback hide" data-field="promo_detail"></div> <div class="form-control-feedback hide" data-field="promo_detail"></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-6"> <div class="col-lg-6">
@ -660,7 +658,7 @@
<option value=""></option> <option value=""></option>
{% for discount in discounts %} {% for discount in discounts %}
{% if obj.getInvoice %} {% if obj.getInvoice %}
<option value="{{ discount }}"{{ obj.getInvoice.getDiscount|number_format(0) == discount ? ' selected' }}>{{ discount }}</option> <option value="{{ discount }}"{{ obj.getInvoice.getDiscount|number_format(2) == discount ? ' selected' }}>{{ discount }}</option>
{% else %} {% else %}
<option value="{{ discount }}">{{ discount }}</option> <option value="{{ discount }}">{{ discount }}</option>
{% endif %} {% endif %}
@ -672,12 +670,13 @@
<option value=""></option> <option value=""></option>
{% for discount in discounts %} {% for discount in discounts %}
{% if obj.getInvoice %} {% if obj.getInvoice %}
<option value="{{ discount }}"{{ obj.getInvoice.getDiscount == discount ? ' selected' }} disabled>{{ discount }}</option> <option value="{{ discount }}"{{ obj.getInvoice.getDiscount|number_format(2) == discount ? ' selected' }} disabled>{{ discount }}</option>
{% else %} {% else %}
<option value="{{ discount }}" disabled>{{ discount }}</option> <option value="{{ discount }}" disabled>{{ discount }}</option>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</select> </select>
<div class="form-control-feedback hide" data-field="invoice_discount"></div>
{% endif %} {% endif %}
</div> </div>
<div class="col-lg-6"> <div class="col-lg-6">
@ -1359,6 +1358,7 @@ $(function() {
} else { } else {
$("#current-battery, #warranty-expiration").val("No current battery").css('color', '#f4516c'); $("#current-battery, #warranty-expiration").val("No current battery").css('color', '#f4516c');
} }
$("#or_name").val(vdata.customer.first_name + ' ' + vdata.customer.last_name);
}) })
}).focus(); }).focus();
{% endif %} {% endif %}
@ -1582,6 +1582,7 @@ $(function() {
// update invoice when promo is changed // update invoice when promo is changed
$("#invoice-discount").change(function() { $("#invoice-discount").change(function() {
console.log('discount ' + $("#invoice-discount").val());
generateInvoice(); generateInvoice();
}); });
@ -1926,6 +1927,12 @@ $(function() {
generateInvoice(); generateInvoice();
}); });
$("#customer-first-name, #customer-last-name").change(function() {
// autopopulate OR name with customer name
var cust_name = $("#customer-first-name").val() + ' ' + $("#customer-last-name").val();
$("#or_name").val(cust_name);
});
}); });
</script> </script>
{% endblock %} {% endblock %}

View file

@ -392,13 +392,11 @@
<input type="text" name="or_name" id="or_name" class="form-control m-input" value="{{ obj.getORName|default('') }}"> <input type="text" name="or_name" id="or_name" class="form-control m-input" value="{{ obj.getORName|default('') }}">
<div class="form-control-feedback hide" data-field="or_name"></div> <div class="form-control-feedback hide" data-field="or_name"></div>
</div> </div>
<!-- <div style="display:none" class="col-lg-6">
<div class="col-lg-6">
<label data-field="promo_detail">Employee ID / Card Number / Referred By</label> <label data-field="promo_detail">Employee ID / Card Number / Referred By</label>
<input type="text" name="promo_detail" id="promo_detail" class="form-control m-input" value="{{ obj.getPromoDetail|default('') }}"> <input type="text" name="promo_detail" id="promo_detail" class="form-control m-input" value="{{ obj.getPromoDetail|default('') }}">
<div class="form-control-feedback hide" data-field="promo_detail"></div> <div class="form-control-feedback hide" data-field="promo_detail"></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-6"> <div class="col-lg-6">
@ -741,6 +739,8 @@ var vdata = false;
} else { } else {
$("#current-battery, #warranty-expiration").val("No current battery").css('color', '#f4516c'); $("#current-battery, #warranty-expiration").val("No current battery").css('color', '#f4516c');
} }
$("#or_name").val(vdata.customer.first_name + ' ' + vdata.customer.last_name);
}) })
}).focus(); }).focus();
{% endif %} {% endif %}
@ -1107,6 +1107,12 @@ var vdata = false;
}); });
}); });
}); });
$("#customer-first-name, #customer-last-name").change(function() {
// autopopulate OR name with customer name
var cust_name = $("#customer-first-name").val() + ' ' + $("#customer-last-name").val();
$("#or_name").val(cust_name);
});
}); });
</script> </script>
{% endblock %} {% endblock %}