var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let Transact; (function (Transact) { let Controls; (function (Controls) { class Batch extends Unibase.Platform.Core.BaseComponent { constructor() { super(...arguments); this.rowlength = 0; } jsFiles() { return ['apps/transact/controls/pricelist/mrp.js', 'apps/transact/controls/pricelist/managers/pricelistmanager.js']; } cssFiles() { return []; } html(id, containerid) { var html = '
' + '
' + '
' + '
' + '
' + '
' + '
'; return html; } load(id, containerid, callback) { $("#txt_PackedDate").daterangepicker({ locale: { format: 'DD/MM/YYYY', }, singleDatePicker: true, showDropdowns: true, minYear: 1901, maxDate: new Date(2050, 11, 31) }); $("#txt_PackedDate").on('apply.daterangepicker', function (ev, picker) { $("#txt_PackedDate").val(picker.startDate.format('DD/MM/YYYY')); }); $("#txt_ExpiryDate").daterangepicker({ locale: { format: 'DD/MM/YYYY', }, singleDatePicker: true, showDropdowns: true, minYear: 1901, maxDate: new Date(2050, 11, 31) }); $("#txt_ExpiryDate").on('apply.daterangepicker', function (ev, picker) { $("#txt_ExpiryDate").val(picker.startDate.format('DD/MM/YYYY')); }); $("#frm_btnBatchCancel").click(function () { $('#' + containerid).modal('hide'); $('#' + containerid).remove(); if (Batch.instance.rowlength != 0) { $("#select_Batch" + Batch.instance.rowlength).empty(); } }); $("#frm_btnBatchSave").click(function () { Batch.Instance().Save(id, containerid); }); $(".hasDatepicker").keypress(function (e) { $(".hasDatepicker").attr("maxlength", "10"); if (e.which != 8 && e.which != 0 && (e.which < 47 || e.which > 57)) { return false; } else { var value = $(".hasDatepicker").val().toString().replace(/^(\d\d)(\d)$/g, '$1/$2').replace(/^(\d\d\/\d\d)(\d+)$/g, '$1/$2').replace(/[^\d\/]/g, ''); $(".hasDatepicker").val(value); } }); this.loadMrps(id); } loadMrps(ItemId) { var url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/pricelists/mrps_auto/itemid/' + ItemId; var id = 0; AutoCompleteHelper.getHelper().Create("#txtAutoComplete_MRP", "#hf_MrpId", url, function (response) { if (id != response.id) { id = response.id; if ($("#txtAutoComplete_MRP option:selected").text() == 'Create MRP') { let obj = []; obj.push({ ItemId: ItemId, element: null, }); var itemobj = Bizgaze.Apps.Transact.Controls.MRP.Instance(); Unibase.Platform.Helpers.NavigationHelper.Instance().popup(obj, "", itemobj, null, Unibase.Platform.Helpers.Size.DockLeft); } } }); } Save(id, containerid) { if ($("#txt_BatchNo").val() == "" || $("#txt_BatchNo").val() == '') { MessageHelper.Instance().showError("Batch No is Required ", 'bizgaze_BatchErrorMessages'); return false; } if (isNaN(Number($(".txtAutoComplete_MRP option:selected").val()))) { MessageHelper.Instance().showError("Please Select MRP ", 'bizgaze_BatchErrorMessages'); return false; } var PackedDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerDate($("#txt_PackedDate").val()); var P_date = new Date(PackedDate); var ExpiryDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerDate($("#txt_ExpiryDate").val()); var E_date = new Date(ExpiryDate); if (PackedDate > ExpiryDate) { MessageHelper.Instance().showError("Expiry Date cannot be Less than PackedDate ", 'bizgaze_BatchErrorMessages'); return false; } var postData = { ItemId: id, MrpId: Number($(".txtAutoComplete_MRP option:selected").val()), PackedDate: P_date, ExpiryDate: E_date, BatchNo: $("#txt_BatchNo").val(), BatchId: 0 }; Bizgaze.Apps.Transact.Managers.PriceListManager.Instance().saveBatch(postData).then(function (response) { if (response.errors == null) { $('#' + containerid).modal('hide'); $('#' + containerid).remove(); MessageHelper.Instance().showSuccess(response.message, ''); if (Batch.instance.rowlength != 0 && response.result != null) { Bizgaze.Apps.Transact.Controls.SplitItem.Instance().bindDetails(response, Batch.instance.rowlength); } } else { MessageHelper.Instance().showError(response.message, 'bizgaze_BatchErrorMessages'); return false; } }); } static Instance() { if (this.instance === undefined) { this.instance = new Batch(); } return this.instance; } } Controls.Batch = Batch; })(Controls = Transact.Controls || (Transact.Controls = {})); })(Transact = Apps.Transact || (Apps.Transact = {})); })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {})); })(Bizgaze || (Bizgaze = {}));