/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ function loadGridView() { if ($("#gridview").hasClass("d-flex")) { $.get("action.php", { action: "getgriditems", customer: customerid }, function (data) { $("#gridview").html(""); for (var i = 0; i < data['items'].length; i++) { var itemid = data['items'][i]['id']; var price = data['items'][i]['price']; var name = data['items'][i]['name']; var code = data['items'][i]['code']; var codeicon = ""; if (code != "") { codeicon = ' '; } var html = '
' + '' + name + '' + '' + codeicon + code + "
" + '$' + price + '
' + '
'; $("#gridview").append(html); } }); } } $("#gridview").on("click", ".gridview-itembtn", function () { var name = $(this).data("name"); var code = $(this).data("code"); var price = $(this).data("price"); var itemid = $(this).data("itemid"); addItem(name, code, price, itemid); }); $("#gridviewbtn").click(function () { if ($("#gridview").hasClass("d-flex")) { $("#gridview").addClass("d-none"); $("#gridview").removeClass("d-flex"); } else { $("#gridview").addClass("d-flex"); $("#gridview").removeClass("d-none"); loadGridView(); } }); if (showgridbydefault) { $("#gridview").addClass("d-flex"); $("#gridview").removeClass("d-none"); loadGridView(); }