123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- 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 = '<form id="frm_Bizgazetransact_createBatch" default method="post" data-validate="parsley" class="w-f bg-white" data-isdynamic="false"><header class="bg-white modal-header pa-10"><strong class="text-dark titlename" >Create Batch</strong><div class="btn-group ml-auto"><a class="btn btn-sm"><i class="ti-help-alt" title = "help" href = "" target = "_blank"></i></a></div></header>' +
- '<div style="overflow-x:hidden;" class="scrollable"><div id = "bizgaze_BatchErrorMessages" class="clear"></div><div class="card mt-5" ><div class="card-body"> <div class="row" style="overflow-x:hidden;"><div class="col-sm-6"><div class="floating-label-form-group" id = "div_MRP" ><label for= "txt_BatchNo" id = "lbl_BatchNo" >Batch Number<span class= "text-danger" >*</span></label><div class= "input-group" ><input type="text" class="form-control required floating-label-control decimal_numericsvalue" id = "txt_BatchNo" data - isdynamic="false" placeholder = "Batch No. *" style = "width:1200px" data-placeholder="Enter Batch No *" data-label="Batch No *" /><input type="hidden" id = "hf_batch" value = "">' +
- '<label for= "Validation" id = "lblValidation_Batch" ></label><input type = "hidden" id = "hfFormPropertyId" /></div></div></div><div class="col-sm-6"><label for="lbl" id="lbl_MRPid">MRP<span class="text-danger hide " id="spnIsRequired"> *</span></label><div class="input-group"><select type = "text" class="txtAutoComplete_MRP required form-control ui-autocomplete" data-required="true" value = "" id = "txtAutoComplete_MRP" placeholder = "Select MRP" style = "width:100%;"></select>' +
- '<input type = "hidden" id = "hf_MrpId"><label for= "Validation" id = "lblValidation_MRP"></label><input type = "hidden" id = "hfFormPropertyId" /></div>' +
- '</div><div class="col-sm-12"><div class="row"><div class="col-sm-6"><div class="floating-label-form-group floating-label-form-group-with-value" id = "div_PackedDate"><label for= "txt_PackedDate" id = "lbl_PackedDate">Packed Date <span class="text-danger">*</span></label><div class="input-group"><input type="text" id="txt_PackedDate" class="form-control value-control datepicker-input hasDatepicker" placeholder = "dd/mm/yyyy" data - isdynamic="false" data-placeholder="dd/mm/yyyy" data - label="dd/mm/yyyy" >' +
- '<span class="input-group-addon bg-white no-border spndate"><a href="#"><i class="fa fa-calendar"></i></a></span><input type = "hidden" id = "hf_PackedDate" /><label for= "Validation" id = "lblValidation_PackedDate" ></label><input type = "hidden" id = "hfFormPropertyId" /></div></div></div><div class="col-sm-6"><div class="floating-label-form-group floating-label-form-group-with-value" id = "div_ExpiryDate" ><label for= "txt_ExpiryDate" id = "lbl_ExpiryDate">Expiry Date </label><div class="input-group"><input type="text" id = "txt_ExpiryDate" class="form-control value-control datepicker-input hasDatepicker " placeholder = "dd/mm/yyyy" data - isdynamic="false" data - placeholder="dd/mm/yyyy" data - label="dd/mm/yyyy">' +
- '<span class="input-group-addon bg-white no-border spndate"><a href="#" > <i class="fa fa-calendar" ></i></a></span><input type = "hidden" id = "hf_ExpiryDate" /><label for= "Validation" id = "lblValidation_ExpiryDate"></label><input type = "hidden" id = "hfFormPropertyId" /></div></div></div></div></div></div></div></div></div><footer class="bg-white modal-footer">' +
- '<a href="javascript:;" id = "frm_btnBatchCancel" class="btn btn-light btn-sm mr-auto " > Close </a><a href = "javascript:;" id = "frm_btnBatchSave" class="btn btn-primary btn-sm" > Save </a></footer></form>';
- 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 = {}));
|