(()=>{function t(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,n){if(!t)return;if("string"==typeof t)return e(t,n);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return e(t,n)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=new Array(e);n.01?(r.addClass("is-invalid"),r.attr("required",!0),r.attr("placeholder","Catatan wajib diisi karena ada perbedaan stock"),e.addClass("table-warning")):(r.removeClass("is-invalid"),r.removeAttr("required"),r.attr("placeholder","Catatan item"),e.removeClass("table-warning"))}$(".select2").select2({placeholder:"Pilih...",allowClear:!0}),$("#dealer").change((function(){e()})),$(document).on("change",".product-select",(function(){var t=$(this).closest("tr"),n=$(this).val(),r=t.find(".system-quantity"),i=t.find('input[name^="physical_quantity"]'),o=i.val();n?e():(r.val("0"),o&&i.val(o),a(r[0]))})),$("#btn-add-row").click((function(){var t=document.getElementById("product-row-template"),e=$("#product-table tbody"),a=t.content.cloneNode(!0),r=$(".product-row").length;$(a).find('select[name="product[]"]').attr("name","product[".concat(r,"]")),$(a).find('input[name="system_quantity[]"]').attr("name","system_quantity[".concat(r,"]")),$(a).find('input[name="physical_quantity[]"]').attr("name","physical_quantity[".concat(r,"]")),$(a).find('input[name="item_notes[]"]').attr("name","item_notes[".concat(r,"]")),$(a).find('input[name="system_quantity[]"]').addClass("system-quantity").attr("readonly",!0).val("0"),$(a).find("select").val(""),$(a).find("input:not(.system-quantity)").val(""),e.append(a),n()})),$(document).on("click",".btn-remove-row",(function(){$(this).closest("tr").remove(),n(),$(".product-row").each((function(t){$(this).find('select[name^="product"]').attr("name","product[".concat(t,"]")),$(this).find('input[name^="system_quantity"]').attr("name","system_quantity[".concat(t,"]")),$(this).find('input[name^="physical_quantity"]').attr("name","physical_quantity[".concat(t,"]")),$(this).find('input[name^="item_notes"]').attr("name","item_notes[".concat(t,"]"))}))})),$(document).on("keydown",".system-quantity",(function(t){return t.preventDefault(),!1})),$(document).on("paste",".system-quantity",(function(t){return t.preventDefault(),!1})),$("#opname-form").submit((function(e){if(!$("#dealer").val())return e.preventDefault(),alert("Silakan pilih dealer terlebih dahulu!"),!1;var n=$('select[name^="product"]').map((function(){return $(this).val()})).get(),a=t(new Set(n));if(n.length!==a.length)return e.preventDefault(),alert("Produk tidak boleh duplikat!"),!1;if(n.includes(""))return e.preventDefault(),alert("Semua produk harus dipilih!"),!1;var r=!1;return $(".product-row").each((function(){var t=parseFloat($(this).find('input[name^="system_quantity"]').val())||0,e=parseFloat($(this).find('input[name^="physical_quantity"]').val())||0,n=$(this).find('input[name^="item_notes"]').val();Math.abs(t-e)>.01&&!n&&(r=!0,$(this).addClass("table-danger"))})),r?(e.preventDefault(),alert("Catatan wajib diisi untuk produk yang memiliki perbedaan stock!"),!1):void 0})),$("#dealer").val()&&e()}))})(); //# sourceMappingURL=create.js.map