123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498 |
- var Bizgaze;
- (function (Bizgaze) {
- let Apps;
- (function (Apps) {
- let Transact;
- (function (Transact) {
- let Controls;
- (function (Controls) {
- class CustomizedProducts extends Unibase.Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.g_LoadedCPItems = [];
- this.g_SelectedItems = [];
- this.g_ParentItemId = 0;
- }
- init(formpropertyid, prop, callback) {
- }
- loadControl(containerid, prop) { }
- loadControlSettings(controlsettingjson, formpropertyid) { }
- loadPropertySettings(propertysettings, formpropertyid) { }
- bindEditFormDetails(formpropertyid, propval, DocPropertyName) { }
- loadCPModal(response) {
- let instance = this;
- let jsFiles = ["bundle/index.order.component.js"];
- instance.fileCacheHelper.loadJsFiles(jsFiles, function () {
- instance.fileCacheHelper.addCacheFiles(["apps/transact/infos/orders/orderitem.js", "apps/transact/controls/orders/order.component.js", "apps/transact/controls/orders/orderitems.component.js"]);
- instance._order = Bizgaze.Apps.Transact.Controls.Order.Instance();
- instance._orderItems = Bizgaze.Apps.Transact.Controls.OrderItems.Instance();
- instance._cartDetails = Bizgaze.Apps.Transact.Controls.CartDetails.Instance();
- });
- instance.resetAllVariables();
- let ModalHtml = `<div class="modal fade" id="CustomizedProductModal" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-hidden="true">
- <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
- <div class="modal-content rounded-10 text-center bg-white">
- <div class="modal-header" style="border-style: dashed;">
- <h5 class="modal-title ml-auto"> Customized Products </h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true" class="badge badge-soft-danger font-20 rounded-circle pb-2 px-2">×</span>
- </button>
- </div>
- <div class="modal-body product_body customized_product_body text-center pb-30 biz-custom-scrollbar h-500p"> </div>
- <div class="modal-footer custmized_product_footer">
- <button class="btn btn-success confirm_btn" onclick="Bizgaze.Apps.Transact.Controls.CustomizedProducts.Instance().confirmCP()">Confirm </button>
- </div>
- </div>
- </div>
- </div>
- </div>`;
- $("#_bizgaze_modal").html(ModalHtml);
- $('#CustomizedProductModal').modal();
- let data = response.result;
- instance.g_LoadedCPItems = data;
- instance.g_LoadedCPItems.forEach(x => {
- let LoadedItem_Index = instance._orderItems.g_LoadedItems.findIndex(z => z.ItemId == x.ChildItemId);
- if (LoadedItem_Index == -1) {
- instance._orderItems.g_LoadedItems.push(x);
- }
- });
- if (response.result.length != 0) {
- for (let i = 0; i < data.length; i++) {
- let products = data[i];
- let RowId = products.ChildItemId;
- let MinLimit = products.Minlimit;
- let MaxLimit = products.Maxlimit;
- let DefName = products.DefinitionName;
- let DefId = products.DefinitionId;
- let IsRequired = products.IsRequired ? 1 : 0;
- let ItemName = products.ItemName;
- let SKU = products.SKU;
- let ItemId = products.ChildItemId;
- let ParentItemId = products.ItemId;
- let Qty = products.Qty;
- let UnitPrice = products.UnitPrice;
- let valNew = Qty.split(',');
- instance.g_ParentItemId = ParentItemId;
- if ($("#CustomizedProductModal").find('.div_definition_' + DefId).length == 0) {
- let sno = 1;
- $('.card-count').each(function () {
- sno++;
- });
- let diverror = `<div class="def_errormsg" id="def_errormsg"></div>`;
- $(".product_body").append(diverror);
- let structure = `<div class="div_definition div_definition_` + DefId + ` bg-charcoal-light-5 rounded-0 card card-count">
- <input type="hidden" id="hf_minlimit" value=` + MinLimit + `>
- <input type="hidden" id="hf_maxlimit" value=` + MaxLimit + `>
- <input type="hidden" id="hf_defid" value=` + DefId + `>
- <input type="hidden" id="hf_typeid" value=` + products.Type + `>
- <input type="hidden" id="hf_isrequired" value=` + IsRequired + `>
- <input type="hidden" id="hf_defname" value=` + DefName + `>
- <input type="hidden" id="hf_iserror" class="hf_iserror" value="0">
- <input type="hidden" id="hf_errormsg" class="hf_errormsg" value="">
-
- <div class="card-header text-left d-flex pr-0">
- <div class="row col-sm-12 pr-0">
- <div class="col-sm-10 mt-10">
- <div class="row">
- <h4 class="list-item-main-title border-right card-header-s-no px-2">` + sno + `</h4>
- <h4 class="list-item-main-title px-2 cp_categoryName_` + DefId + `">` + DefName + `</h4>
- <span class="d-none text-danger Cmp__isrequired">*</span>
- </div>
- </div>
- <div class="col-sm-2 pull-right pr-0">
- <small class="text-danger Cmp__minlimit text-dark"> Min Limit - ` + MinLimit + `</small> <br>
- <small class="text-danger Cmp__maxlimit text-dark"> Max Limit - ` + MaxLimit + `</small> <br>
- </div>
- </div>
- </div>
- <div class="card-body card_body pt-0 pb-2 bg-white card_body_` + DefId + `">
- <ul class="Cmp__Desc"></ul> <ul class="Cmp__item"></ul>
- </div>
- </div>`;
- $(".product_body").append(structure);
- }
- if (products.IsRequired == true) {
- $('.Cmp__isrequired').removeClass('d-none');
- }
- if (products.Type == 1) {
- let CmpDesc = $(`.card_body_` + DefId + ``).find('.Cmp__description');
- let radio = `<div class="form-check">
- <input class="form-check-input Cmp__radio Cmp__radio_` + DefId + `_` + RowId + `" type="radio" name="Cmp__radio" id="Cmp__radio_` + RowId + `" value="option_` + RowId + `" style="transform: scale(1.3);" >
- <label class="form-check-label" for="Cmp__radio_` + RowId + `"></label>
- </div>`;
- let structurebody = `<li class="d-flex align-items-center justify-content-between mt-2 px-2 def_body_` + DefId + `" id="def_body_` + DefId + `_` + RowId + `">
- <input type="hidden" id="hf_itemid" value=` + ItemId + `>
- <input type="hidden" id="hf_parentitemid" value=` + ParentItemId + `>
- <input type="hidden" id="hf_rowid" value=` + RowId + `>
-
- <div class="col-6 p-0 text-left">
- <p>` + ItemName + ` (` + SKU + `) </p>
- </div>
- <div class="col-2 p-0 text-right">
- <p> ₹` + UnitPrice + `</p>
- </div>
- <div class="col-2 p-0 text-right">` + radio + `</div>
- </li>`;
- $(`.card_body_` + DefId + ``).find(".Cmp__item").append(structurebody);
- if (CmpDesc.length == 0) {
- $(`.card_body_` + DefId + ``).find(".Cmp__Desc").append(`<div class="Cmp__description px-2 mt-2 text-left"> Description </div>`);
- }
- }
- else if (products.Type == 2) {
- let CmpDesc = $(`.card_body_` + DefId + ``).find('.Cmp__description');
- let structurebody = `<li class="d-flex align-items-center justify-content-between mt-2 px-2 def_body_` + DefId + `" id="def_body_` + DefId + `_` + RowId + `">
- <input type="hidden" id="hf_itemid" value=` + ItemId + `>
- <input type="hidden" id="hf_parentitemid" value=` + ParentItemId + `>
- <input type="hidden" id="hf_rowid" value=` + RowId + `>
-
- <div class="col-6 p-0 text-left">
- <p>` + ItemName + ` (` + SKU + `) </p>
- </div>
- <div class="col-2 p-0 text-right">
- <p> ₹` + UnitPrice + `</p>
- </div>
- <div class="col-2 p-0 text-right">
- <select class="Cmp__select rounded p-1 w-65p Cmp__select_` + DefId + `_` + RowId + `" id="` + RowId + `"
- </select>
- </div>
- </li> `;
- $(`.card_body_` + DefId + ``).find(".Cmp__item").append(structurebody);
- let count = 0;
- $('<option>').val(count).text(0).appendTo(`.Cmp__select_` + DefId + `_` + RowId + ``);
- for (let q = 0; q < valNew.length; q++) {
- let qData = valNew[q].replace(/ /g, '');
- $('<option>').val(qData).text(qData).appendTo(`.Cmp__select_` + DefId + `_` + RowId + ``);
- count++;
- }
- if (CmpDesc.length == 0) {
- $(`.card_body_` + DefId + ``).find(".Cmp__Desc").append(`<div class="Cmp__description px-2 mt-2 text-left">Description</div>`);
- }
- }
- instance.bindAllItemEvents(DefId, RowId);
- }
- let CartItems = instance._orderItems.g_CartItems_New.filter(x => x.ParentItemId == instance.g_ParentItemId);
- if (CartItems.length > 0) {
- instance.bindCPDetails();
- }
- }
- }
- resetAllVariables() {
- let instance = this;
- instance.g_SelectedItems = [];
- instance.g_LoadedCPItems = [];
- instance.g_ParentItemId = 0;
- instance._cartDetails.g_Categories = [];
- }
- bindAllItemEvents(DefinitionId, RowId) {
- let instance = this;
- let elem = $(".div_definition_" + DefinitionId);
- let MinLimit = Number($(elem).find("#hf_minlimit").val());
- let MaxLimit = Number($(elem).find("#hf_maxlimit").val());
- let DefName = $(elem).find("#hf_defname").val();
- $(".Cmp__select_" + DefinitionId + "_" + RowId).change(function () {
- let select_elem = $("#def_body_" + DefinitionId + "_" + RowId);
- let ItemId = Number($(select_elem).find("#hf_itemid").val());
- let Qty = Number($(this).val());
- instance.modifyItem(DefinitionId, ItemId, Qty);
- });
- $(".Cmp__radio_" + DefinitionId + "_" + RowId).click(function () {
- let select_elem = $("#def_body_" + DefinitionId + "_" + RowId);
- let ItemId = Number($(select_elem).find("#hf_itemid").val());
- let Qty = 1;
- instance.modifyItem(DefinitionId, ItemId, Qty);
- });
- instance.checkValidations(0);
- }
- modifyItem(DefId, ItemId, Qty) {
- let instance = this;
- let ItemIndex = instance.g_LoadedCPItems.findIndex(x => x.ChildItemId == ItemId);
- if (ItemIndex == -1) {
- return false;
- }
- let Item = instance.g_LoadedCPItems[ItemIndex];
- let ParentItemId = Item.ItemId;
- let Quantity = Qty;
- let onlyPacks = parseInt((Number(Quantity) / Number(Item.PackCount * Item.PackSize)).toString());
- let remainingQty = Quantity - (onlyPacks * Item.PackCount * Item.PackSize);
- let onlyPieces = remainingQty / Item.PackSize;
- let Packs = Number(onlyPacks);
- let Pieces = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(onlyPieces, 2));
- let CategoryName = $(".cp_categoryName_" + DefId).text();
- let TypeId = Number($(".div_definition_" + DefId).find("#hf_typeid").val());
- let RowId = Number($(".div_definition_" + DefId).find("#hf_rowid").val());
- let ItemData = {
- OrderItemId: 0,
- ItemIndex: 0,
- TypeId: TypeId,
- DefId: DefId,
- RowId: RowId,
- ItemId: ItemId,
- ParentItemId: ParentItemId,
- HSNId: Item.HSNId,
- ItemName: Item.ItemName,
- Packs: Packs,
- Pieces: Pieces,
- PriceListId: Item.PriceListId,
- PriceListName: Item.PriceListName,
- UnitPrice: Item.UnitPrice,
- UnitPriceWithOutTax: 0,
- ExpectedPrice: Item.UnitPrice,
- ActualPrice: Item.UnitPrice,
- PackCount: Item.PackCount,
- PackSize: Item.PackSize,
- UnitName: Item.UnitName,
- Quantity: Quantity,
- SKU: Item.SKU,
- PartNo: Item.PartNo,
- Amount: Quantity * Item.UnitPrice,
- AmountWithDiscount: Quantity * Item.UnitPrice,
- DiscountPercent: 0,
- DiscountValue: 0,
- DiscountType: 0,
- DiscountAmount: 0,
- ItemValueAfterDiscount: 0,
- StrTaxPercents: null,
- AvailableQuantity: Item.AvailableQuantity,
- AvailablePacks: Item.AvailablePacks,
- AvailablePieces: Item.AvailablePieces,
- TotalAvailablePieces: 0,
- ExchangeDC: false,
- IsAfterTax: false,
- BaseQty: Quantity,
- IsFocItem: false,
- optoutAmount: 0,
- TaxGroupId: Item.TaxGroupId,
- TaxGroupName: Item.TaxGroupName,
- TaxAmount: 0,
- TaxRateAmount: 0,
- TaxRate: 0,
- TaxPercentage: 0,
- IsOfferAvailable: false,
- Description: "",
- Discountable: false,
- PiecePrice: 0,
- CompositePrice: 0,
- CompositePiecePrice: 0,
- IsCheckPendingItems: false,
- IsError: false,
- ErrorMsg: "",
- ErrorClass: "text-danger",
- IsTaxError: false,
- IsLeverageError: false,
- IsFocAdded: false,
- RefOrderItemId: 0,
- RefItemIds: "",
- RefItemSKUs: "",
- FocItemIds: "",
- DiscountGroupId: 0,
- IsOfferDiscountApplied: false,
- AppliedOfferVolume: 0,
- AppliedPlanVolumeId: 0,
- AppliedOfferId: 0,
- optoutOfferGroupId: 0,
- SuggestedPacks: 0,
- MinPacks: 0,
- AvgPacks: 0,
- InwardOrderPacks: 0,
- OutwardOrderPacks: 0,
- IsManualUOM: false,
- UOMs: [],
- IsMultipleUOMs: false,
- UOMSchemaId: 0,
- MultipleUOMs: [],
- SelectedUnitId: 0,
- SelectedUnitName: "",
- DefaultSize: 0,
- IsBoMAvailable: false,
- IsSpecialPrice: false,
- ConversionQuantity: 0,
- RowTotal: Item.UnitPrice * Qty,
- RowDiscount: 0,
- TaxTotal: 0,
- IsPacksFocus: false,
- IsPiecesFocus: false,
- CategoryName: CategoryName
- };
- let SelectedItemIndex = instance.g_SelectedItems.findIndex(x => x.ItemId == ItemId && x.DefId == DefId);
- if (TypeId == 1) {
- SelectedItemIndex = instance.g_SelectedItems.findIndex(x => x.DefId == DefId);
- }
- if (SelectedItemIndex != -1) {
- if (Qty == 0) {
- instance.g_SelectedItems.splice(SelectedItemIndex, 1);
- }
- else {
- instance.g_SelectedItems[SelectedItemIndex] = ItemData;
- }
- }
- else {
- instance.g_SelectedItems.push(ItemData);
- }
- instance.checkValidations(DefId);
- }
- bindCPDetails() {
- let instance = this;
- let ParentItemId = instance.g_ParentItemId;
- let CartItems = instance._orderItems.g_CartItems_New;
- let PresentCartCPItems = CartItems.filter(x => x.ParentItemId == ParentItemId);
- for (let i = 0; i < PresentCartCPItems.length; i++) {
- let CartItem = PresentCartCPItems[i];
- let ItemId = CartItem.ItemId;
- let TypeId = CartItem.TypeId;
- let RowId = CartItem.ItemId;
- let DefId = CartItem.DefId;
- let Qty = CartItem.Quantity;
- if (TypeId == 1) {
- $(".Cmp__radio_" + DefId + "_" + RowId).prop("checked", "true");
- }
- else if (TypeId == 2) {
- $(".Cmp__select_" + DefId + "_" + RowId).val(Qty);
- }
- instance.modifyItem(DefId, ItemId, Qty);
- }
- instance.checkValidations(0);
- }
- confirmCP() {
- let instance = this;
- instance._orderItems.g_IsCategory = true;
- let ParentItemId = instance.g_ParentItemId;
- let CartItems = instance._orderItems.g_CartItems_New;
- let PresentCartCPItems = CartItems.filter(x => x.ParentItemId == ParentItemId);
- PresentCartCPItems.forEach(x => {
- let CartItems = instance._orderItems.g_CartItems_New;
- let SelectedItmIndex = instance.g_SelectedItems.findIndex(y => y.ItemId == x.ItemId && y.ParentItemId == ParentItemId);
- if (SelectedItmIndex == -1) {
- let CartIndex = CartItems.findIndex(z => z.ItemId == x.ItemId && z.ParentItemId == ParentItemId);
- instance._orderItems.g_CartItems_New.splice(CartIndex, 1);
- instance._orderItems.deleteCartItems(x.ItemId);
- }
- });
- for (let i = 0; i < instance.g_SelectedItems.length; i++) {
- let SelectedItem = instance.g_SelectedItems[i];
- let ItemId = SelectedItem.ItemId;
- let DefId = SelectedItem.DefId;
- let TypeId = SelectedItem.TypeId;
- let CartItemIndex = CartItems.findIndex(x => x.ItemId == ItemId && x.DefId == DefId);
- if (TypeId == 1) {
- CartItemIndex = CartItems.findIndex(x => x.DefId == DefId);
- }
- if (CartItemIndex != -1) {
- instance._orderItems.g_CartItems_New[CartItemIndex] = SelectedItem;
- let elem = $(".cartitem-" + ItemId);
- instance._orderItems.updateItemsDesign(elem, "CP", true, false);
- }
- else {
- instance._orderItems.g_CartItems_New.push(SelectedItem);
- instance._orderItems.addCartItem(ItemId, false);
- }
- }
- $("#CustomizedProductModal").modal("hide");
- }
- getNewRowId() {
- let text = "";
- let possible = "0123456789";
- for (let i = 0; i < 5; i++)
- text += possible.charAt(Math.floor(Math.random() * possible.length));
- return Number(text);
- }
- getDefinitionTotal(DefinitionId) {
- let Total = 0;
- $(".def_body_" + DefinitionId).each(function () {
- let TypeId = Number($(".div_definition_" + DefinitionId).find("#hf_typeid").val());
- if (TypeId == 1) {
- let isChecked = $(".def_body_" + DefinitionId + " [name='Cmp__radio']").is(':checked');
- if (isChecked) {
- let MinLimit = Number($(".div_definition_" + DefinitionId).find("#hf_minlimit").val());
- Total = Total + MinLimit;
- }
- }
- else if (TypeId == 2) {
- Total = Total + Number($(this).find(".Cmp__select option:selected").val());
- }
- });
- return Total;
- }
- checkValidations(DefinitionId) {
- let instance = this;
- if (DefinitionId == 0) {
- $(".div_definition").each(function () {
- let elem = $(this);
- let DefId = Number($(elem).find("#hf_defid").val());
- instance.checkDefinitionValidation(DefId);
- });
- }
- else {
- instance.checkDefinitionValidation(DefinitionId);
- }
- let ErrorCartItems = $(".hf_iserror[value='1']");
- if (ErrorCartItems.length == 0) {
- instance.enableConfirm();
- for (let i = 0; i < ErrorCartItems.length; i++) {
- let DefinitionId = ErrorCartItems[i].DefId;
- $(".div_definition_" + DefinitionId).find(".card-header").removeAttr("style");
- $(".def_body_" + DefinitionId).find(".Cmp__select").removeAttr("disabled");
- }
- }
- else {
- instance.disableConfirm();
- }
- }
- checkDefinitionValidation(DefId) {
- let instance = this;
- let elem = $(".div_definition_" + DefId);
- let MinLimit = Number($(elem).find("#hf_minlimit").val());
- let MaxLimit = Number($(elem).find("#hf_maxlimit").val());
- let DefName = $(elem).find("#hf_defname").val();
- let TypeId = Number($(elem).find("#hf_typeid").val());
- let IsRequired = Boolean(Number($(elem).find("#hf_isrequired").val()));
- let IsError = $(elem).find("#hf_iserror").val();
- let ErrorMsg = $(elem).find("#hf_errormsg").val();
- let DefTotal = instance.getDefinitionTotal(DefId);
- $(elem).find("#hf_iserror").val(0);
- $(elem).find("#hf_errormsg").val("");
- $(elem).find(".card-header").find(".Cmp__maxlimit, .Cmp__minlimit").removeClass("text-danger").addClass("text-dark");
- if (DefTotal < MinLimit && IsRequired) {
- $(".div_definition_" + DefId).find(".card-header").find(".Cmp__minlimit").removeClass("text-dark").addClass("text-danger");
- $(elem).find("#hf_iserror").val(1);
- $(elem).find("#hf_errormsg").val(" '" + DefName + "' - Min Limit " + MinLimit + " ");
- instance.disableConfirm();
- }
- if (DefTotal > MaxLimit && TypeId == 2) {
- MessageHelper.Instance().showError(" '" + DefName + "' - Max Limit " + MaxLimit + " Exceeded", "def_errormsg");
- $(".div_definition_" + DefId).find(".card-header").find(".Cmp__maxlimit").removeClass("text-dark").addClass("text-danger");
- $(elem).find("#hf_iserror").val(1);
- $(elem).find("#hf_errormsg").val(" '" + DefName + "' - Max Limit " + MaxLimit + " Exceeded");
- instance.disableConfirm();
- }
- else {
- if (DefTotal == MaxLimit) {
- $(".def_body_" + DefId).find(".Cmp__select").each(function () {
- let Selectedval = $(this).val();
- if (Selectedval == 0) {
- $(this).attr("disabled", "disabled");
- }
- });
- }
- else {
- $(".def_body_" + DefId).find(".Cmp__select").removeAttr("disabled");
- }
- }
- }
- disableConfirm() {
- $(".confirm_btn").attr("disabled", "disabled");
- }
- enableConfirm() {
- $(".confirm_btn").removeAttr("disabled");
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new CustomizedProducts();
- }
- return this.instance;
- }
- }
- Controls.CustomizedProducts = CustomizedProducts;
- })(Controls = Transact.Controls || (Transact.Controls = {}));
- })(Transact = Apps.Transact || (Apps.Transact = {}));
- })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
- })(Bizgaze || (Bizgaze = {}));
|