diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index 9d3987ec..952d8050 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -350,6 +350,10 @@
+
+
+ +
@@ -926,6 +930,13 @@ $(function() { generateInvoice(); }); + // reset the invoice table + $("#btn-reset-invoice").click(function() { + $("#invoice-promo").prop('selectedIndex', 0); + invoiceItems = []; + generateInvoice(); + }); + function generateInvoice() { var promo = $("#invoice-promo").val(); var table = $("#invoice-table tbody"); @@ -951,20 +962,26 @@ $(function() { // populate rows var html = ''; - $.each(invoice.items, function(key, item) { - html += '' + - '' + item.title + '' + - '' + item.quantity + '' + - '' + item.unit_price + '' + - '' + item.amount + '' + - /* - '' + - */ + if (invoice.items.length > 0) { + $.each(invoice.items, function(key, item) { + html += '' + + '' + item.title + '' + + '' + item.quantity + '' + + '' + item.unit_price + '' + + '' + item.amount + '' + + /* + '' + + */ + ''; + }); + } else { + html = '' + + '' + + 'No items to display.' + + '' + ''; - }); - - // save to invoice table - table.find('.placeholder-row').addClass('hide'); + } + table.html(html); }); }