ok
Direktori : /home2/selectio/www/mm-tailor-billing/themes/default/assets/dist/js/ |
Current File : /home2/selectio/www/mm-tailor-billing/themes/default/assets/dist/js/purchases.min.js |
function loadItems() { get("spoitems") && (total = 0, $("#poTable tbody").empty(), spoitems = JSON.parse(get("spoitems")), $.each(spoitems, function() { var t = this, e = 1 == Settings.item_addition ? t.item_id : t.id, o = (spoitems[e] = t).row.id, s = t.row.cost, i = t.row.qty, a = t.row.code, n = t.row.name.replace(/"/g, """).replace(/'/g, "'"), d = (new Date).getTime(), m = $('<tr id="' + d + '" class="' + e + '" data-item-id="' + e + '"></tr>'); tr_html = '<td style="min-width:100px;"><input name="product_id[]" type="hidden" class="rid" value="' + o + '"><span class="sname" id="name_' + d + '">' + n + " (" + a + ")</span></td>", tr_html += '<td style="padding:2px;"><input class="form-control input-sm kb-pad text-center rquantity" name="quantity[]" type="text" value="' + i + '" data-id="' + d + '" data-item="' + e + '" id="quantity_' + d + '" onClick="this.select();"></td>', tr_html += '<td style="padding:2px; text-align:center;"><span>'+t.row.unit_name+'</span></td>', tr_html += '<td style="padding:2px; min-width:80px;"><input class="form-control input-sm kb-pad text-center rcost" name="cost[]" type="text" value="' + s + '" data-id="' + d + '" data-item="' + e + '" id="cost_' + d + '" onClick="this.select();"></td>', tr_html += '<td class="text-right"><span class="text-right ssubtotal" id="subtotal_' + d + '">' + formatMoney(parseFloat(s) * parseFloat(i)) + "</span></td>", tr_html += '<td class="text-center"><i class="fa fa-trash-o tip pointer spodel" id="' + d + '" title="Remove"></i></td>', m.html(tr_html), m.prependTo("#poTable"), total += parseFloat(s) * parseFloat(i) }), grand_total = formatMoney(total), $("#gtotal").text(grand_total), $("#add_item").focus()) } function add_order_item(t) { var e = 1 == Settings.item_addition ? t.item_id : t.id; return spoitems[e] ? spoitems[e].row.qty = parseFloat(spoitems[e].row.qty) + 1 : spoitems[e] = t, store("spoitems", JSON.stringify(spoitems)), loadItems(), !0 } $(document).ready(function() { loadItems(), $("#date").inputmask("yyyy-mm-dd hh:mm", { placeholder: "yyyy-mm-dd hh:mm" }), $(document).on("click", ".spodel", function() { var t = $(this).closest("tr"), e = t.attr("data-item-id"); if (delete spoitems[e], t.remove(), !spoitems.hasOwnProperty(e)) return localStorage.setItem("spoitems", JSON.stringify(spoitems)), void loadItems() }), $("#add_item").autocomplete({ source: base_url + "purchases/suggestions", minLength: 1, autoFocus: !1, delay: 200, response: function(t, e) { 16 <= $(this).val().length && 0 == e.content[0].id ? (bootbox.alert(lang.no_match_found, function() { $("#add_item").focus() }), $(this).val("")) : 1 == e.content.length && 0 != e.content[0].id ? (e.item = e.content[0], $(this).data("ui-autocomplete")._trigger("select", "autocompleteselect", e), $(this).autocomplete("close")) : 1 == e.content.length && 0 == e.content[0].id && (bootbox.alert(lang.no_match_found, function() { $("#add_item").focus() }), $(this).val("")) }, select: function(t, e) { (t.preventDefault(), 0 !== e.item.id) ? add_order_item(e.item) && $(this).val(""): bootbox.alert(lang.no_match_found) } }), $("#add_item").bind("keypress", function(t) { 13 == t.keyCode && (t.preventDefault(), $(this).autocomplete("search")) }), $("#add_item").focus(), $("#reset").click(function(t) { bootbox.confirm(lang.r_u_sure, function(t) { t && (get("spoitems") && remove("spoitems"), window.location.reload()) }) }), $(document).on("change", ".rquantity", function() { var t = $(this).closest("tr"), e = parseFloat($(this).val()), o = t.attr("data-item-id"); spoitems[o].row.qty = e, store("spoitems", JSON.stringify(spoitems)), loadItems() }), $(document).on("change", ".rcost", function() { var t = $(this).closest("tr"), e = parseFloat($(this).val()), o = t.attr("data-item-id"); spoitems[o].row.cost = e, store("spoitems", JSON.stringify(spoitems)), loadItems() }) }); //# sourceMappingURL=maps/purchases.min.js.map