Populate invoice items array upon loading of form. #803
This commit is contained in:
parent
90628f0b54
commit
acee5f8f55
1 changed files with 17 additions and 11 deletions
|
|
@ -1237,17 +1237,29 @@ $(function() {
|
|||
|
||||
function populateInvoiceItems()
|
||||
{
|
||||
console.log('populateInvoiceItems start');
|
||||
{% if invoice_items is defined %}
|
||||
{% for item in invoice_items %}
|
||||
var qty = {{ item.getQuantity }};
|
||||
{% if item.getBattery is not null %}
|
||||
var battery_id = {{ item.getBattery.getID }};
|
||||
var trade_in = '';
|
||||
|
||||
console.log(battery_id);
|
||||
invoiceItems.push({
|
||||
battery: battery_id,
|
||||
quantity: qty,
|
||||
trade_in: '',
|
||||
});
|
||||
{% else %}
|
||||
var battery_size = {{ item.getBatterySize.GetID }};
|
||||
{% if item.getBatterySize is not null %}
|
||||
var battery_size = {{ item.getBatterySize.GetID }};
|
||||
var trade_in_type = '{{ item.getTradeInType }}';
|
||||
|
||||
// add to invoice array
|
||||
invoiceItems.push({
|
||||
battery_size: battery_size,
|
||||
quantity: qty,
|
||||
trade_in: trade_in_type,
|
||||
});
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
|
@ -1255,7 +1267,6 @@ $(function() {
|
|||
|
||||
function selectPoint(lat, lng)
|
||||
{
|
||||
console.log('selectPoint start');
|
||||
// check if point is in coverage area
|
||||
// commenting out the geofence call for CRM
|
||||
/*
|
||||
|
|
@ -1293,12 +1304,11 @@ $(function() {
|
|||
$('#map_lng').val(lng);
|
||||
|
||||
// regenerate invoice
|
||||
// generateInvoice();
|
||||
generateInvoice();
|
||||
|
||||
}
|
||||
|
||||
osm_map.on('click', function(e) {
|
||||
console.log('point clicked');
|
||||
selectPoint(e.latlng.lat, e.latlng.lng);
|
||||
});
|
||||
|
||||
|
|
@ -1312,7 +1322,6 @@ $(function() {
|
|||
console.log(results);
|
||||
var lat = results[0].geometry.location.lat();
|
||||
var lng = results[0].geometry.location.lng();
|
||||
console.log('geocode point clicked');
|
||||
selectPoint(lat, lng);
|
||||
}
|
||||
},
|
||||
|
|
@ -1341,10 +1350,7 @@ $(function() {
|
|||
var lat = {{ obj.getCoordinates.getLatitude }};
|
||||
var lng = {{ obj.getCoordinates.getLongitude }};
|
||||
|
||||
console.log('set coordinate point clicked');
|
||||
|
||||
var promo = $("#invoice-promo").val();
|
||||
console.log(promo);
|
||||
|
||||
populateInvoiceItems();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue