1/*! 2* Farmatradenet reference condition setting component 3* version: 1.0.0 4* author: Bitdrome <[email protected]> <[email protected]> 5* website: https://www.bitdrome.com 6*/ 7(function (global, factory){ 8 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 9 typeof define === 'function' && define.amd ? define(factory) : 10 (global.FTNReferenceConditionsSetting = factory()); 11}(this, ( function (){ 12 'use strict'; 13 14 function _classCallCheck(instance, Constructor) { 15 if (!(instance instanceof Constructor)) { 16 throw new TypeError("Cannot call a class as a function"); 17 } 18 } 19 20 function _defineProperties(target, props) { 21 for (let i = 0; i < props.length; i++) { 22 let descriptor = props[i]; 23 descriptor.enumerable = descriptor.enumerable || false; 24 descriptor.configurable = true; 25 if ("value" in descriptor) descriptor.writable = true; 26 Object.defineProperty(target, descriptor.key, descriptor); 27 } 28 } 29 30 function _createClass(Constructor, protoProps, staticProps) { 31 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 32 if (staticProps) _defineProperties(Constructor, staticProps); 33 return Constructor; 34 } 35 36 const MULTIPLIER = 500; 37 38 let Util = function (){ 39 function Util(){ 40 _classCallCheck(this, Util); 41 } 42 43 _createClass(Util, null, [ 44 { 45 key: "getUid", 46 /** 47 * Get Uid 48 * 49 * @returns {string} 50 */ 51 value: function getUid(){ 52 const dateString = Date.now().toString(36); 53 const randomness = Math.random().toString(36).substr(2); 54 return `_${dateString}${randomness}`; 55 } 56 }, 57 { 58 key: "getOptionsSelect", 59 /** 60 * get Options Select 61 * 62 * @returns {string} 63 */ 64 value: function getOptionsSelect(type, umi, base = null, valueSelected = null){ 65 let optionsSelect = ``; 66 if(type === 'baseSelectOptionsConditionFormTo'){ 67 optionsSelect = ` 68 <option value="null" disabled selected>-</option> 69 <option value="-1">Illimitato</option> 70 `; 71 72 let starter = (type === 'base') ? 2 : 1; 73 for(let multipleUmi = starter; multipleUmi <= MULTIPLIER; multipleUmi++){ 74 optionsSelect = `${optionsSelect}<option value="${(parseFloat(umi)*multipleUmi)}">${(parseFloat(umi)*multipleUmi)}</option>` 75 } 76 } 77 else if(type === 'baseSelectOptionsConditionForm'){ 78 optionsSelect = ` 79 <option value="${umi}"selected>${umi}</option> 80 `; 81 for(let multipleUmi = 2; multipleUmi < MULTIPLIER; multipleUmi++){ 82 optionsSelect = `${optionsSelect}<option value="${(parseFloat(umi)*multipleUmi)}">${(parseFloat(umi)*multipleUmi)}</option>` 83 } 84 } 85 else if(type === 'baseSelectOptionsConditionFormPrefilled' || type === 'baseSelectOptionsConditionFormToPrefilled' || type === 'deepSelectOptionsConditionFormPrefilled' || type === 'deepSelectOptionsConditionFormToPrefilled'){ 86 let selectedFirst = (valueSelected === (base)) ? 'selected' : ''; 87 let selectedUnlimited = (valueSelected === -1) ? 'selected' : ''; 88 89 optionsSelect = `${optionsSelect}<option value="${base}" ${selectedFirst}>${base}</option>` 90 91 for(let multipleUmi = 1; multipleUmi < MULTIPLIER; multipleUmi++){ 92 let selectedAttr = (valueSelected === (base + (umi*multipleUmi))) ? 'selected' : ''; 93 optionsSelect = `${optionsSelect}<option value="${base + (umi*multipleUmi)}" ${selectedAttr}>${base + (umi*multipleUmi)}</option>` 94 } 95 96 if(['baseSelectOptionsConditionFormToPrefilled', 'deepSelectOptionsConditionFormToPrefilled'].includes(type)){ 97 optionsSelect = ` 98 <option value="-1" ${selectedUnlimited}>Illimitato</option> 99 ${optionsSelect} 100 `; 101 } 102 } 103 else if(type === 'deepSelectOptionsConditionForm' || type === 'deepSelectOptionsConditionFormTo'){ 104 if(type === 'deepSelectOptionsConditionFormTo'){ 105 optionsSelect = ` 106 <option value="null" disabled selected>-</option> 107 `; 108 } 109 optionsSelect = `${optionsSelect}<option value="${base}">${base}</option>` 110 111 for(let multipleUmi = 1; multipleUmi < MULTIPLIER; multipleUmi++){ 112 optionsSelect = `${optionsSelect}<option value="${base + (umi*multipleUmi)}">${base + (umi*multipleUmi)}</option>` 113 } 114 if(type === 'deepSelectOptionsConditionFormTo'){ 115 optionsSelect = ` 116 <option value="-1">Illimitato</option> 117 ${optionsSelect} 118 `; 119 } 120 } 121 else if('template'){ 122 optionsSelect = ` 123 <option value="null" disabled selected>-</option> 124 <option value="-1">Illimitato</option> 125 `; 126 for(let multipleUmi = 2; multipleUmi < MULTIPLIER; multipleUmi++){ 127 optionsSelect = `${optionsSelect}<option value="${(parseFloat(umi)*multipleUmi)}">${(parseFloat(umi)*multipleUmi)}</option>` 128 } 129 } 130 131 return optionsSelect; 132 } 133 }, 134 ]) 135 return Util; 136 }(); 137 138 139 let FTNReferenceConditionsSetting = function (){ 140 /** 141 * @constructor 142 * @param {object} reference 143 * @param {boolean} isForCentral 144 * @param {string} containerId 145 * @param {integer} conditionType 146 * @param {boolean} isForWinWin 147 * @param {function} callbackSubmit 148 */ 149 function FTNReferenceConditionsSetting(reference, isForCentral = false, containerId = '', conditionType = 0, isForWinWin= false, callbackSubmit = () => {}, isBundle = false){ 150 let _self = this; 151 _self.conditions = {} 152 _self.callbackSubmit = callbackSubmit; 153 _self.container = (containerId.length !== 0) ? $(`#${containerId}`) : null; 154 _self.isPromotional = (parseInt(conditionType) === 3); 155 _self.isOngoing = (parseInt(conditionType) === 1); 156 _self.isFirstArrangement = (parseInt(conditionType) === 8); 157 _self.isBundle = isBundle; 158 if(isBundle) { 159 _self.bundleReferenceCode = reference._id; 160 _self.bundleTotalCount = Number(reference.referencesCodes.length); 161 }; 162 _self.hasBundle = 'hasBundle' in reference ? reference.hasBundle : false;
163 164 //NOTE: We had to remove the restocking price, 165 // which was dedicated only to centrals and was the only difference between retailers and central chains. 166 // To do this we set isForCentral to false, 167 // if we were to reactivate it we would handle the flow normally by uncommenting it. 168 // _self.isForCentral = isForCentral; 169 _self.isForCentral = false; 170 _self.templatePreview = null; 171 _self.restockingDiscount = null; 172 _self.shippingObject = null; 173 _self.extras = null; 174 _self.tippyInfos = []; 175 _self.tippyValuesId = []; 176 _self.isForWinWin = isForWinWin; 177 178 _self.conditionsType = 'conditions'; 179 if(_self.isForWinWin && parseInt(conditionType) === 1){ 180 _self.conditionsType = 'proposedSellPriceSettings'; 181 } 182 183 if(_self.isForWinWin && parseInt(conditionType) === 2){ 184 _self.conditionsType = 'proposedPreseasonSellPriceSettings'; 185 } 186 187 if("restockingDiscount" in reference && reference.restockingDiscount !== null){ 188 _self.restockingDiscount = parseFloat(reference.restockingDiscount) 189 } 190 191 if("shippingObject" in reference && reference.shippingObject !== null){ 192 _self.shippingObject = reference.shippingObject; 193 } 194 195 if("extras" in reference && reference.extras !== null){ 196 _self.extras = reference.extras; 197 } 198 199 _classCallCheck(_self, FTNReferenceConditionsSetting); 200 _self.init(reference); 201 } 202 203 _createClass(FTNReferenceConditionsSetting,[ 204 { 205 key: "init", 206 /** 207 * Init 208 * @param {object} reference 209 * @return {boolean} 210 */ 211 value: function init(reference){ 212 let _self = this; 213 let umi = 1; 214 if("umi" in reference){ 215 umi = reference.umi 216 } 217 218 _self.conditions = { 219 id: Util.getUid(), 220 bundleId: _self.isBundle ? _self.bundleReferenceCode : null, 221 minimumDistinctReferences: _self.isBundle ? reference.minimumDistinctReferences : null, 222 referenceCode: reference.code, 223 price: reference.catalogPrice || reference.sellPrice, 224 priceToShow: (parseFloat(reference.catalogPrice || reference.sellPrice)).toFixed(2), 225 umi: umi, 226 lowerRangeLimit: umi, 227 upperRangeLimit: null, 228 restockingDiscount: _self.restockingDiscount, 229 name: reference.name, 230 isMandatory: reference.isMandatory, 231 settings: [] 232 }; 233 234 _self.financialConditions = reference.financialConditions; 235 _self.minimumOrderAmount = reference.minimumOrderAmount; 236 _self.minimumOrderQuantity = reference.minimumOrderQuantity; 237 238 if(_self.isBundle && _self.container !== null) { 239 if("settings" in reference) { 240 _self.conditions.settings = reference.settings.map(setting => { 241 return { 242 discount: setting.discount, 243 umiLowerLimit: setting.lowerLimit, 244 umiUpperLimit: setting.upperLimit, 245 id: Util.getUid() 246 } 247 }); 248 _self.getFirstRowWithPrefill(); 249 } else { 250 _self.getFirstRowObject(); 251 } 252 } else if(_self.hasBundle) { 253 _self.conditions.settings = reference.bundles.map(bundle => { 254 const bundleSettings = { 255 name: bundle.name, 256 bundleId: bundle._id, 257 minimumDistinctReferences: bundle.minimumDistinctReferences, 258 settings: bundle.settings.map( setting => { 259 return { 260 discount: setting.discount, 261 id: Util.getUid(), 262 umiLowerLimit: parseFloat(setting.lowerLimit), 263 umiUpperLimit: parseFloat(setting.upperLimit) 264 } 265 }) 266 }; 267 return bundleSettings; 268 }); 269 _self.getFirstRowWithPrefillPreview(); 270 } else { 271 if(`${_self.conditionsType}` in reference && reference[`${_self.conditionsType}`]){ 272 if(reference[`${_self.conditionsType}`].length === 0){ 273 if(_self.container !== null){ 274 _self.getFirstRowObject() 275 }else{ 276 _self.getFirstRowObjectPreview() 277 } 278 }else{ 279 $.each(reference[`${_self.conditionsType}`], (iCondition, condition) => { 280 let umiUpperLimit = (condition.umiUpperLimit === null) ? -1 : condition.umiUpperLimit; 281 let internalObjectReference = { 282 id: Util.getUid(), 283 discount: parseFloat(condition.discount), 284 umiLowerLimit: parseFloat(condition.umiLowerLimit), 285 umiUpperLimit: parseFloat(umiUpperLimit), 286 } 287 _self.conditions.settings.push(internalObjectReference) 288 }) 289 if(_self.container !== null){ 290 _self.getFirstRowWithPrefill(); 291 }else { 292 _self.getFirstRowWithPrefillPreview(); 293 } 294 } 295 }else{ 296 if(_self.container !== null){ 297 _self.getFirstRowObject() 298 }else{ 299 _self.getFirstRowObjectPreview() 300 } 301 } 302 } 303 } 304 }, 305 { 306 key: "getFirstRowObject", 307 /** 308 * get First Row Object 309 * @return {boolean} 310 */ 311 value: function getFirstRowObject(){ 312 let _self = this; 313 let idSetting = Util.getUid(); 314 const isBundle = _self.isBundle; 315 const bundleSelect = isBundle ? _self.buildBundleSelectOptions(_self.bundleTotalCount) : ''; 316 _self.bundleSelectId = `ftnMinimumDistinctReferences${idSetting}`; 317 318 let partialTemplate = `` 319 let selectOptionsFrom = Util.getOptionsSelect('baseSelectOptionsConditionForm', _self.conditions.umi); 320 let selectOptionsTo = Util.getOptionsSelect('baseSelectOptionsConditionFormTo', _self.conditions.umi); 321 partialTemplate = ` 322 <div class="col-${isBundle? '4' : '3'} no-padding"> 323 <p class="ftn-plc-setting-item-box-label">Range quantità </p> 324 <div class="ftn-plc-setting-item-box-information-promotional-range range">
325 <span>da</span> 326 <div class="input-filed rcs"> 327 <select id="ftnPriceListConditionStartLimitRange${idSetting}" class="ftn-signup-side-select ftn-plc-input" numericSearchable="Cerca"> 328 ${selectOptionsFrom} 329 </select> 330 </div> 331 <span style="white-space: nowrap">Fino a n.</span> 332 </div> 333 </div> 334 <div class="col-${isBundle? '4' : '3'} no-padding ftn-plc-item-box-container-select"> 335 <div class="input-filed rcs"> 336 <span class="plc-input-label" style="color: transparent">Select</span> 337 <select id="ftnPriceListConditionLimitRange${idSetting}" class="ftn-signup-side-select ftn-plc-input" numericSearchable="Cerca"> 338 ${selectOptionsTo} 339 </select> 340 </div> 341 </div> 342 ` 343 344 _self.conditions.settings.push({ 345 id: idSetting, 346 discount: null, 347 umiLowerLimit: _self.conditions.umi, 348 umiUpperLimit: null 349 }) 350 351 let partialTemplateForCentralConditionOngoing = `` 352 if(_self.isOngoing && _self.isForCentral){ 353 partialTemplateForCentralConditionOngoing = ` 354 <div class="row"> 355 <div class="col-md-4 no-padding"></div> 356 <div class="col-md-8 no-padding"> 357 <div class="container-fluid"> 358 <div class="row"> 359 <div class="col-6 no-padding"> 360 <p class="ftn-plc-setting-item-box-label" style="color: transparent">Prezzo riassortimento</p> 361 <div class="ftn-plc-setting-item-box-information price"> 362 <span>Prezzo riassortimento</span> 363 </div> 364 </div> 365 <div class="col-2 no-padding"> 366 <span class="plc-input-label">Sconto (%)</span> 367 <input id="ftnPriceListConditionSoldRestocking${idSetting}" class="ftn-plc-input" type="text" placeholder="0.00" step="0.01" min="0.00" max="100.00" autocomplete="nohint"> 368 <span id="ftnPriceListConditionSoldRestocking${idSetting}HelperText" class="helper-text" style="font-size: 11px; position: absolute; top: 48px"></span> 369 </div> 370 <div class="col-3 no-padding"> 371 <p class="ftn-plc-setting-item-box-label">Prezzo di cessione</p> 372 <div id="ftnPriceListConditionFinalPriceRestocking${idSetting}" class="ftn-plc-setting-item-box-information price ftn-plc-input"><span>⬠${_self.conditions.priceToShow}</span></div> 373 </div> 374 </div> 375 </div> 376 </div> 377 </div> 378 ` 379 } 380 381 let template = ` 382 <div class="ftn-plc-setting-item-box" id="ftnPlcSettingItemBox${_self.conditions.id}"> 383 <section class="section-materialize ftn-dashboard"> 384 <div class="container-fluid"> 385 <div class="row"> 386 <div class="col-md-12" style="display: flex; align-items: center; justify-content: ${_self.isFirstArrangement ? "space-between" : "flex-end"}"> 387 ${_self.isFirstArrangement ? ` 388 <div class="switch" style="display: flex; justify-content: center;"> 389 <label style="margin: 0 !important; font-family: Metropolis-SemiBold; font-size: 12px; color: var(--ftnBlueFonts);"> 390 Obbligatoria 391 <input type="checkbox" id="ref_setting_isMandatory_${_self.conditions.referenceCode}" ${_self.conditions.isMandatory ? "checked" : ""} data-code="${_self.conditions.referenceCode}">
392 <span class="lever"></span> 393 </label> 394 </div>` : `` 395 } 396 <button id="ftnReferenceConditionsComponentSubmit${_self.conditions.id}" class="waves-effect waves-light btn ftn-button ftn-blue disabled" disabled>SALVA</button> 397 </div> 398 </div> 399 <div class="row" style="height: 30px"> 400 </div> 401 <div class="row"> 402 <div class="col-md-${isBundle ? '5' : '4'} no-padding"> 403 <div id="ftnPlcContainerListPrice" class="container-fluid"> 404 <div class="row"> 405 <div class="col-md-6 no-padding"> 406 <p class="ftn-plc-setting-item-box-label">${isBundle ? 'Nome Bundle' : 'Nome Referenza'}</p> 407 <div class="ftn-plc-setting-item-box-information name">${_self.conditions.name}</div> 408 </div> 409 ${isBundle ? ` 410 <div class="col-md-6 no-padding ftn-plc-item-box-container-select"> 411 <div id="bundleSelectWrapper" class="input-filed rcs"> 412 <p class="ftn-plc-setting-item-box-label">Minimo referenze</p> 413 <select id="${_self.bundleSelectId}" class="ftn-signup-side-select ftn-plc-input" numericSearchable="Cerca"> 414 ${bundleSelect} 415 </select> 416 <span id="${_self.bundleSelectId}HelperText" class="helper-text" style="font-size: 11px; position: absolute; top: 48px; visibility: hidden; color: red;" data-error="">Campo obbligatorio</span> 417 </div> 418 </div> 419 ` 420 : ` 421 <div class="col-md-6 no-padding"> 422 <p class="ftn-plc-setting-item-box-label">Prezzo Listino</p> 423 <div class="ftn-plc-setting-item-box-information price"><span>⬠${_self.conditions.priceToShow}</span></div> 424 </div> 425 `} 426 </div> 427 </div> 428 </div> 429 <div class="col-md-${isBundle ? '7' : '8'} no-padding"> 430 <div class="container-fluid" id="ftnPlcContainerPrice${_self.conditions.id}"> 431 <div class="row" id="ftnPlcRowPrice${idSetting}"> 432 ${partialTemplate} 433 <div class="${isBundle? 'col-3' : 'col-2'} no-padding"> 434 <span class="plc-input-label">Sconto (%)</span> 435 <input id="ftnPriceListConditionSold${idSetting}" class="ftn-plc-input disabled" type="text" placeholder="0.00" step="0.01" min="0.00" max="100.00" autocomplete="nohint" disabled>
436 <span id="ftnPriceListConditionSold${idSetting}HelperText" class="helper-text" style="font-size: 11px; position: absolute; top: 48px"></span> 437 </div> 438 ${!isBundle ? ` 439 <div class="col-3 no-padding"> 440 <p class="ftn-plc-setting-item-box-label">Prezzo di cessione</p> 441 <div id="ftnPriceListConditionFinalPrice${idSetting}" class="ftn-plc-setting-item-box-information price ftn-plc-input"><span>⬠${_self.conditions.priceToShow}</span></div> 442 </div> 443 ` 444 : ``} 445 <div class="col-1 no-padding"> 446 <button id="ftnPriceListConditionItemBoxAddRow${idSetting}" class="waves-effect waves-light btn ftn-button icon-button green disabled reference-condition-setting-button first-row" disabled><i class="material-icons">add</i></button> 447 <button id="ftnPriceListConditionItemBoxRemoveRow${idSetting}" class="waves-effect waves-light btn ftn-button icon-button red disabled reference-condition-setting-button first-row" data-remove-all="1" disabled style="display: none"><i class="material-icons">remove</i></button> 448 </div> 449 </div> 450 </div> 451 </div> 452 </div> 453 ${partialTemplateForCentralConditionOngoing} 454 </div> 455 </section> 456 </div> 457 <div id="ftnReferenceConditionsModalHandlingUpdate${_self.conditions.id}" class="reference-condition-setting-modal"> 458 <div class="reference-condition-setting-modal-content"> 459 <div class="reference-condition-setting-modal-header" style="border-bottom: 0!important; height: 0; padding: 0"> 460 </div> 461 <div class="reference-condition-setting-modal-body"> 462 <div class="container-fluid"> 463 <div class="row" style="height: 10px"> 464 465 </div> 466 <div class="row"> 467 <div class="col-md-12"> 468 <p id="ftnReferenceConditionsHandlingDescription${_self.conditions.id}" class="ftn-modal-handling-conditions-text"></p> 469 </div> 470 </div> 471 <div class="row" style="height: 10px"> 472 473 </div> 474 <div class="row"> 475 <section class="section-materialize ftn-dashboard"> 476 <div class="col-md-12" style="margin-left: auto; margin-right: auto; display: flex; align-items: center; justify-content: center">
477 <a id="ftnReferenceConditionsHandlingUpdateDenies${_self.conditions.id}" class="waves-effect waves-light btn ftn-button ftn-red" style="display: block; margin-bottom: 34px; margin-left: 0; margin-right: 7.5px">TORNA INDIETRO</a> 478 <a id="ftnReferenceConditionsHandlingUpdateConfirm${_self.conditions.id}" class="waves-effect waves-light btn ftn-button ftn-green" style="display: block; margin-bottom: 34px; margin-left: 7.5px; margin-right: 0">CONFERMA</a> 479 </div> 480 </section> 481 </div> 482 </div> 483 </div> 484 </div> 485 </div> 486 </div> 487 ` 488 489 _self.container.html(template); 490 $(`#${_self.bundleSelectId}`).formSelect(); 491 492 if (_self.isFirstArrangement) { 493 const isMandatoryRefSwitch = $(`#ref_setting_isMandatory_${_self.conditions.referenceCode}`); 494 isMandatoryRefSwitch.off("change").on("change", (e) => { 495 const checked = $(e.target).prop("checked"); 496 _self.conditions.isMandatory = checked; 497 }); 498 } 499 500 _self.handlingInputsEvent(idSetting); 501 } 502 }, 503 { 504 key: "getFirstRowObjectPreview", 505 /** 506 * get First Row Object Preview 507 * @return {string} 508 */ 509 value: function getFirstRowObjectPreview(){ 510 return `<div>Non esiste nessuna configurazione per la seguente referenze</div>` 511 } 512 }, 513 { 514 key: "getFirstRowWithPrefill", 515 /** 516 * get First Row Object 517 * @return {boolean} 518 */ 519 value: function getFirstRowWithPrefill(){ 520 let _self = this; 521 const isBundle = _self.isBundle; 522 let objectConfiguration = _self.conditions.settings[0]; 523 let idSetting = objectConfiguration.id; 524 let umi = _self.conditions.umi; 525 let umiLowerLimit = objectConfiguration.umiLowerLimit; 526 let selectedValue = objectConfiguration.umiUpperLimit; 527 let restockingDiscount = _self.conditions.restockingDiscount; 528 const bundleSelect = isBundle ? _self.buildBundleSelectOptions(_self.bundleTotalCount, _self.conditions.minimumDistinctReferences) : ''; 529 _self.bundleSelectId = `ftnMinimumDistinctReferences${idSetting}`; 530 531 let partialTemplate = ``; 532 let optionsFrom = Util.getOptionsSelect('baseSelectOptionsConditionFormPrefilled', umi, umi, umiLowerLimit); 533 let optionsTo = Util.getOptionsSelect('baseSelectOptionsConditionFormToPrefilled', umi, umiLowerLimit, selectedValue); 534 535 partialTemplate = ` 536 <div class="col-${isBundle? '4' : '3'} no-padding"> 537 <p class="ftn-plc-setting-item-box-label">Range quantità </p> 538 <div class="ftn-plc-setting-item-box-information-promotional-range range"> 539 <span>da</span> 540 <select id="ftnPriceListConditionStartLimitRange${idSetting}" class="ftn-signup-side-select ftn-plc-input" data-first-row="true" numericSearchable="Cerca"> 541 ${optionsFrom} 542 </select> 543 <span style="white-space: nowrap">Fino a n.</span> 544 </div> 545 </div> 546 <div class="col-${isBundle? '4' : '3'} no-padding ftn-plc-item-box-container-select"> 547 <div class="input-filed rcs">
548 <span class="plc-input-label" style="color: transparent">Select</span> 549 <select id="ftnPriceListConditionLimitRange${idSetting}" class="ftn-signup-side-select ftn-plc-input" numericSearchable="Cerca"> 550 ${optionsTo} 551 </select> 552 </div> 553 </div> 554 `; 555 556 let priceRecommended = parseFloat(_self.conditions.price); 557 let saving = (priceRecommended/100)*parseFloat(objectConfiguration.discount); 558 let finalPriceNotAround = parseFloat(priceRecommended) - parseFloat(saving); 559 let finalePriceAround = Math.round(finalPriceNotAround * 100) / 100; 560 let finalPriceAroundToShow = parseFloat(finalePriceAround).toFixed(2); 561 562 let partialTemplateForCentralConditionOngoing = `` 563 if(_self.isOngoing && _self.isForCentral){ 564 let discountRestockingValue = ``; 565 let finalePriceAroundRestocking = Math.round(priceRecommended * 100) / 100; 566 if(restockingDiscount !== null){ 567 discountRestockingValue = restockingDiscount; 568 let savingRestocking = (priceRecommended/100)*parseFloat(restockingDiscount); 569 let finalPriceNotAroundRestocking = parseFloat(priceRecommended) - parseFloat(savingRestocking); 570 finalePriceAroundRestocking = Math.round(finalPriceNotAroundRestocking * 100) / 100; 571 } 572 573 partialTemplateForCentralConditionOngoing = ` 574 <div class="row"> 575 <div class="col-md-4 no-padding"></div> 576 <div class="col-md-8 no-padding"> 577 <div class="container-fluid"> 578 <div class="row"> 579 <div class="col-6 no-padding"> 580 <p class="ftn-plc-setting-item-box-label" style="color: transparent">Prezzo riassortimento</p> 581 <div class="ftn-plc-setting-item-box-information price"> 582 <span>Prezzo riassortimento</span> 583 </div> 584 </div> 585 <div class="col-2 no-padding"> 586 <span class="plc-input-label">Sconto (%)</span> 587 <input id="ftnPriceListConditionSoldRestocking${idSetting}" class="ftn-plc-input" type="text" placeholder="0.00" step="0.01" min="0.00" max="100.00" autocomplete="nohint" value="${discountRestockingValue}"> 588 <span id="ftnPriceListConditionSoldRestocking${idSetting}HelperText" class="helper-text" style="font-size: 11px; position: absolute; top: 48px"></span> 589 </div> 590 <div class="col-3 no-padding"> 591 <p class="ftn-plc-setting-item-box-label">Prezzo di cessione</p> 592 <div id="ftnPriceListConditionFinalPriceRestocking${idSetting}" class="ftn-plc-setting-item-box-information price ftn-plc-input"><span>⬠${finalePriceAroundRestocking}</span></div> 593 </div> 594 </div> 595 </div> 596 </div> 597 </div> 598 ` 599 } 600 601 let template = ` 602 <div class="ftn-plc-setting-item-box" id="ftnPlcSettingItemBox${_self.conditions.id}"> 603 <section class="section-materialize ftn-dashboard"> 604 <div class="container-fluid"> 605 <div class="row"> 606 <div class="col-md-12" style="display: flex; align-items: center; justify-content: ${_self.isFirstArrangement ? "space-between" : "flex-end"}"> 607 ${_self.isFirstArrangement ? ` 608 <div class="switch" style="display: flex; justify-content: center;"> 609 <label style="margin: 0 !important; font-family: Metropolis-SemiBold; font-size: 12px; color: var(--ftnBlueFonts);"> 610 Obbligatoria 611 <input type="checkbox" id="ref_setting_isMandatory_${_self.conditions.referenceCode}" ${_self.conditions.isMandatory ? "checked" : ""} data-code="${_self.conditions.referenceCode}">
612 <span class="lever"></span> 613 </label> 614 </div>` : `` 615 } 616 <button id="ftnReferenceConditionsComponentSubmit${_self.conditions.id}" class="waves-effect waves-light btn ftn-button ftn-blue">SALVA</button> 617 </div> 618 </div> 619 <div class="row" style="height: 30px"> 620 </div> 621 <div class="row"> 622 <div class="col-md-${isBundle ? '5' : '4'} no-padding"> 623 <div class="container-fluid"> 624 <div class="row"> 625 <div class="col-md-6 no-padding"> 626 <p class="ftn-plc-setting-item-box-label">${isBundle ? 'Nome Bundle' : 'Nome Referenza'}</p> 627 <div class="ftn-plc-setting-item-box-information name">${_self.conditions.name}</div> 628 </div> 629 ${isBundle ? ` 630 <div class="col-md-6 no-padding ftn-plc-item-box-container-select"> 631 <div id="bundleSelectWrapper" class="input-filed rcs"> 632 <p class="ftn-plc-setting-item-box-label">Minimo referenze</p> 633 <select id="${_self.bundleSelectId}" class="ftn-signup-side-select ftn-plc-input" numericSearchable="Cerca"> 634 ${bundleSelect} 635 </select> 636 <span id="${_self.bundleSelectId}HelperText" class="helper-text" style="font-size: 11px; position: absolute; top: 48px; visibility: hidden; color: red;" data-error="">Campo obbligatorio</span> 637 </div> 638 </div> 639 ` 640 : ` 641 <div class="col-md-6 no-padding"> 642 <p class="ftn-plc-setting-item-box-label">Prezzo Listino</p> 643 <div class="ftn-plc-setting-item-box-information price"><span>⬠${_self.conditions.priceToShow}</span></div> 644 </div> 645 `} 646 </div> 647 </div> 648 </div> 649 <div class="col-md-${isBundle ? '7' : '8'} no-padding"> 650 <div class="container-fluid" id="ftnPlcContainerPrice${_self.conditions.id}"> 651 <div class="row" id="ftnPlcRowPrice${idSetting}"> 652 ${partialTemplate} 653 <div class="${isBundle? 'col-3' : 'col-2'} no-padding"> 654 <span class="plc-input-label">Sconto (%)</span> 655 <input id="ftnPriceListConditionSold${idSetting}" class="ftn-plc-input" type="text" placeholder="0.00" step="0.01" min="0.00" max="100.00" autocomplete="nohint" value="${objectConfiguration.discount}">
656 <span id="ftnPriceListConditionSold${idSetting}HelperText" class="helper-text" style="font-size: 11px; position: absolute; top: 48px"></span> 657 </div> 658 ${!isBundle ? ` 659 <div class="col-3 no-padding"> 660 <p class="ftn-plc-setting-item-box-label">Prezzo di cessione</p> 661 <div id="ftnPriceListConditionFinalPrice${idSetting}" class="ftn-plc-setting-item-box-information price ftn-plc-input"><span>⬠${finalPriceAroundToShow}</span></div> 662 </div> 663 ` 664 : ``} 665 <div class="col-1 no-padding"> 666 <button id="ftnPriceListConditionItemBoxAddRow${idSetting}" class="waves-effect waves-light btn ftn-button icon-button green disabled reference-condition-setting-button first-row"><i class="material-icons">add</i></button> 667 <button id="ftnPriceListConditionItemBoxRemoveRow${idSetting}" class="waves-effect waves-light btn ftn-button icon-button red disabled reference-condition-setting-button first-row" data-remove-all="1"><i class="material-icons">remove</i></button> 668 </div> 669 </div> 670 </div> 671 </div> 672 </div> 673 ${partialTemplateForCentralConditionOngoing} 674 </div> 675 </section> 676 </div> 677 <div id="ftnReferenceConditionsModalHandlingUpdate${_self.conditions.id}" class="reference-condition-setting-modal"> 678 <div class="reference-condition-setting-modal-content"> 679 <div class="reference-condition-setting-modal-header" style="border-bottom: 0!important; height: 0; padding: 0"> 680 </div> 681 <div class="reference-condition-setting-modal-body"> 682 <div class="container-fluid"> 683 <div class="row" style="height: 10px"> 684 685 </div> 686 <div class="row"> 687 <div class="col-md-12"> 688 <p id="ftnReferenceConditionsHandlingDescription${_self.conditions.id}" class="ftn-modal-handling-conditions-text"></p> 689 </div> 690 </div> 691 <div class="row" style="height: 10px"> 692 693 </div> 694 <div class="row"> 695 <section class="section-materialize ftn-dashboard"> 696 <div class="col-md-12" style="margin-left: auto; margin-right: auto; display: flex; align-items: center; justify-content: center">
697 <a id="ftnReferenceConditionsHandlingUpdateDenies${_self.conditions.id}" class="waves-effect waves-light btn ftn-button ftn-red" style="display: block; margin-bottom: 34px; margin-left: 0; margin-right: 7.5px">TORNA INDIETRO</a> 698 <a id="ftnReferenceConditionsHandlingUpdateConfirm${_self.conditions.id}" class="waves-effect waves-light btn ftn-button ftn-green" style="display: block; margin-bottom: 34px; margin-left: 7.5px; margin-right: 0">CONFERMA</a> 699 </div> 700 </section> 701 </div> 702 </div> 703 </div> 704 </div> 705 </div> 706 </div> 707 ` 708 709 _self.container.html(template); 710 $(`#${_self.bundleSelectId}`).formSelect(); 711 712 if (_self.isFirstArrangement) { 713 const isMandatoryRefSwitch = $(`#ref_setting_isMandatory_${_self.conditions.referenceCode}`); 714 isMandatoryRefSwitch.off("change").on("change", (e) => { 715 const checked = $(e.target).prop("checked"); 716 _self.conditions.isMandatory = checked; 717 }); 718 } 719 720 let buttonAdd = $(`#ftnPriceListConditionItemBoxAddRow${idSetting}`); 721 let buttonRemove = $(`#ftnPriceListConditionItemBoxRemoveRow${idSetting}`); 722 723 if(_self.conditions.settings.length === 1){ 724 buttonRemove.attr('disabled'); 725 buttonRemove.addClass('disabled'); 726 buttonRemove.hide(); 727 728 buttonAdd.show(); 729 if(selectedValue !== -1){ 730 buttonAdd.removeAttr('disabled'); 731 buttonAdd.removeClass('disabled'); 732 } 733 }else{ 734 buttonAdd.attr('disabled'); 735 buttonAdd.addClass('disabled'); 736 buttonAdd.hide(); 737 buttonRemove.removeAttr('disabled'); 738 buttonRemove.removeClass('disabled'); 739 buttonRemove.show(); 740 _self.getRowsWithPrefill(`ftnPlcContainerPrice${_self.conditions.id}`); 741 } 742 743 _self.handlingInputsEvent(idSetting); 744 } 745 }, 746 { 747 key: "getFirstRowWithPrefillPreview", 748 /** 749 * get First Row With Prefill Preview 750 * @return {boolean} 751 */ 752 value: function getFirstRowWithPrefillPreview(){ 753 let _self = this; 754 let template = ``; 755 let templateInternal = ``; 756 let indexReferenceProcessed = 0; 757 let objectConfiguration = _self.conditions.settings[0]; 758 let idSetting = objectConfiguration.id; 759 let umi = _self.conditions.umi; 760 let umiLowerLimit = objectConfiguration.umiLowerLimit; 761 let selectedValue = objectConfiguration.umiUpperLimit; 762 763 if(selectedValue === -1){ 764 selectedValue = 'Illimitato' 765 } 766 767 if(umiLowerLimit === undefined || umiLowerLimit === null){ 768 umiLowerLimit = umi; 769 } 770 771 let priceRecommended = parseFloat(_self.conditions.price); 772 let saving = (priceRecommended/100)*parseFloat(objectConfiguration.discount); 773 let finalPriceNotAround = parseFloat(priceRecommended) - parseFloat(saving); 774 let finalePriceAround = Math.round(finalPriceNotAround * 100) / 100; 775 let finalPriceAroundToShow = parseFloat(finalePriceAround).toFixed(2); 776 777 if(_self.hasBundle) { 778 template = _self.getBundleRowsWithPrefillPreview(); 779 } else { 780 $.each(_self.conditions.settings, (iSetting, setting) => { 781 if(iSetting !== 0){ 782 indexReferenceProcessed = iSetting; 783 let idSettingInternal = setting.id; 784 let umiInternal = _self.conditions.umi; 785 let umiLowerLimitInternal = setting.umiLowerLimit; 786 let selectedValueInternal = setting.umiUpperLimit; 787 if(selectedValueInternal === -1){ 788 selectedValueInternal = 'Illimitato' 789 } 790 791 let priceRecommendedInternal = parseFloat(_self.conditions.price); 792 let savingInternal = (priceRecommendedInternal/100)*parseFloat(setting.discount); 793 let finalPriceNotAroundInternal = parseFloat(priceRecommendedInternal) - parseFloat(savingInternal); 794 let finalePriceAroundInternal = Math.round(finalPriceNotAroundInternal * 100) / 100; 795 let finalePriceAroundInternalToSHow = parseFloat(finalePriceAroundInternal).toFixed(2); 796 templateInternal = `${templateInternal} 797 <div class="row" id="ftnPlcRowPrice${idSettingInternal}"> 798 <div class="col-3 no-padding"> 799 <div class="ftn-plc-setting-item-box-information range"><span>da <span class="quantity">${umiLowerLimitInternal}</span></span> <span>Fino a n.</span></div> 800 </div> 801 <div class="col-3 no-padding ftn-plc-item-box-container-select"> 802 <div class="ftn-plc-setting-item-box-information range"><span class="quantity">${selectedValueInternal}</span></div> 803 </div> 804 <div class="col-2 no-padding"> 805 <div class="ftn-plc-setting-item-box-information price"><span>${setting.discount} %</span></div> 806 </div> 807 <div class="col-4 no-padding"> 808 <div id="ftnPriceListConditionFinalPrice${idSettingInternal}" class="ftn-plc-setting-item-box-information price ftn-plc-input"><span>⬠${finalePriceAroundInternalToSHow}</span></div> 809 </div> 810 </div> 811 ` 812 } 813 }) 814 815 template = ` 816 <div class="ftn-plc-setting-item-box" id="ftnPlcSettingItemBox${_self.conditions.id}" style="padding: 15px 0px;"> 817 <section class="section-materialize ftn-dashboard"> 818 <div class="container-fluid"> 819 <div class="row"> 820 <div class="col-12 no-padding"> 821 <p style="font-family: Metropolis-Bold; font-size: 16px; color: #16366B">Condizioni Commerciali</p> 822 </div> 823 </div> 824 <div class="row"> 825 <div class="col-md-2 no-padding"> 826 <div class="container-fluid"> 827 <div class="row"> 828 <div class="col-md-12 no-padding"> 829 <p class="ftn-plc-setting-item-box-label">Prezzo Listino</p> 830 <div class="ftn-plc-setting-item-box-information price"><span>⬠${_self.conditions.priceToShow}</span></div> 831 </div> 832 </div> 833 </div> 834 </div> 835 <div class="col-md-10 no-padding"> 836 <div class="container-fluid" id="ftnPlcContainerPrice${_self.conditions.id}"> 837 <div class="row" id="ftnPlcRowPrice${idSetting}"> 838 <div class="col-3 no-padding"> 839 <p class="ftn-plc-setting-item-box-label">Range quantità </p> 840 <div class="ftn-plc-setting-item-box-information range"><span>da <span class="quantity">${umiLowerLimit}</span></span> <span>Fino a n.</span></div> 841 </div> 842 <div class="col-3 no-padding ftn-plc-item-box-container-select"> 843 <p class="ftn-plc-setting-item-box-label" style="color: transparent">Range quantità </p> 844 <div class="ftn-plc-setting-item-box-information range"><span class="quantity">${selectedValue}</span></div> 845 </div> 846 <div class="col-2 no-padding"> 847 <p class="ftn-plc-setting-item-box-label">Sconto %</p> 848 <div class="ftn-plc-setting-item-box-information price"><span>${objectConfiguration.discount} %</span></div> 849 </div> 850 <div class="col-4 no-padding"> 851 <p class="ftn-plc-setting-item-box-label">Prezzo di cessione</p> 852 <div id="ftnPriceListConditionFinalPrice${idSetting}" class="ftn-plc-setting-item-box-information price ftn-plc-input"><span>⬠${finalPriceAroundToShow}</span></div> 853 </div> 854 </div> 855 ${templateInternal} 856 </div> 857 </div> 858 </div> 859 </div> 860 </section> 861 </div> 862 </div> 863 ` 864 } 865 866 // Append General info section title 867 template = `${template} 868 <p style="font-family: Metropolis-Bold; font-size: 16px; color: #16366B; width: 50%">Informazioni generali</p> 869 `; 870 871 if(_self.shippingObject !== null){ 872 let shippingStartAndEndText = ``; 873 if('start' in _self.shippingObject && 'end' in _self.shippingObject){ 874 let startShipping = moment(_self.shippingObject.start).format('DD-MM-YYYY'); 875 let endShipping = moment(_self.shippingObject.end).format('DD-MM-YYYY'); 876 shippingStartAndEndText = `. Le consegne sono previste dal <span style="font-family: Metropolis-Bold">${startShipping}</span> al <span style="font-family: Metropolis-Bold">${endShipping}</span>` 877 } 878 879 let orderShippingDaysText= `
880 Giorni per la prima consegna <span style="font-family: Metropolis-Bold">${parseInt(_self.shippingObject.daysFirstOrder)}</span>, 881 giorni per la consegna ordini successivi <span style="font-family: Metropolis-Bold">${parseInt(_self.shippingObject.daysStandardOrder)}</span> 882 ` 883 884 if(!_self.shippingObject.daysFirstOrder){ 885 orderShippingDaysText = ` 886 Giorni per la consegna <span style="font-family: Metropolis-Bold">${parseInt(_self.shippingObject.daysStandardOrder)}</span>, 887 ` 888 } 889 890 template = `${template} 891 <div class="container-fluid"> 892 <div class="row" style="height: 15px"></div> 893 <div class="row"> 894 <div class="col-md-12" style="display: flex; align-items: flex-end; justify-content: flex-start"> 895 <div class="ftn-order-confirm-container-shipment-information"> 896 <div style="min-width: 50px"> 897 <img src="/assets/media/images/orders/shipping.svg" class="shipping" alt="shipping"/> 898 </div> 899 <span id="ftnOrderContainerInformationShippingFreeText" class="text"> 900 Spedizione gratuita a partire da <span style="font-family: Metropolis-Bold"> 901 ${parseFloat(_self.shippingObject.upperFreeLimit).toFixed(2)} â¬</span>. 902 Costo della spedizione <span style="font-family: Metropolis-Bold">${parseFloat(_self.shippingObject.cost).toFixed(2)} â¬</span>; 903 ${orderShippingDaysText} 904 ${shippingStartAndEndText} 905 </span> 906 <img src="/assets/media/images/orders/check.svg" class="check" alt="check"/> 907 </div> 908 </div> 909 </div> 910 </div> 911 ` 912 }; 913 914 const minimumOrderAmount = _self.minimumOrderAmount || "0"; 915 const minimumOrderQuantity = _self.minimumOrderQuantity || "0"; 916 const minimumOrderValueToShow = _self.minimumOrderAmount 917 ? minimumOrderAmount 918 : _self.minimumOrderQuantity 919 ? minimumOrderQuantity 920 : "0"; 921 const minimumOrderIconToShow = _self.minimumOrderAmount ? "â¬" : "pezzi"; 922 923 let financialConditionsTemplate = ``; 924 if(Array.isArray(_self.financialConditions) && _self.financialConditions.length > 0){ 925 financialConditionsTemplate = ` 926 <div class="container-fluid"> 927 <div class="row" style="height: 15px"></div> 928 <div class="row"> 929 <div class="col-md-12" style="display: flex; align-items: flex-end; justify-content: flex-start"> 930 <div class="col-12 no-padding"> 931 <div style="width: 100%; display: flex; border-bottom: 1px solid lightgrey; margin-bottom: 5px"> 932 <p style="font-family: Metropolis-Medium; font-size: 13px; color: var(--ftnBrightBlueFonts); width: 50%">Metodo di pagamento</p> 933 <p style="font-family: Metropolis-Medium; font-size: 13px; color: var(--ftnBrightBlueFonts); width: 50%">Ordini netti pari o superiori a:</p> 934 </div> 935 ${_self.financialConditions.map(financial => { 936 return ` 937 <div style="display: flex; gap: 10px;"> 938 <p style="font-family: Metropolis-Medium; font-size: 12px; color: #16366B; width: 50%">${financial.typeText}</p> 939 <p style="font-family: Metropolis-Medium; font-size: 12px; color: #16366B; width: 50%">${financial.limit}
939 â¬</p> 940 </div> 941 `; 942 }).join("")} 943 </div> 944 </div> 945 </div> 946 </div> 947 `; 948 } 949 950 template = `${template} 951 <div class="container-fluid"> 952 <div class="row" style="height: 15px"></div> 953 <div class="row"> 954 <div class="col-md-12" style="display: flex; align-items: flex-end; justify-content: flex-start"> 955 <div class="ftn-order-confirm-container-shipment-information" style="padding: 0 20px;"> 956 <div style="min-width: 40px"> 957 <img src="/assets/media/images/orders/orderGreen.svg" class="shipping" alt="shipping"/> 958 </div> 959 <div style="display: flex; gap: 10px;"> 960 <p style="font-family: Metropolis-Medium; font-size: 12px; color: #16366B">Ordine minimo:</p> 961 <p style="font-family: Metropolis-Medium; font-size: 12px; color: #16366B">${minimumOrderValueToShow} ${minimumOrderIconToShow}</p> 962 </div> 963 </div> 964 </div> 965 </div> 966 </div> 967 ${financialConditionsTemplate} 968 <div class="row" style="height: 15px"></div> 969 `; 970 971 if(_self.extras !== null){ 972 let templateExtras = ``; 973 _self.tippyInfos = []; 974 _self.tippyValuesId = []; 975 $.each(_self.extras, (iExtra, extra) => { 976 let keyOfExtraConditions = Object.keys(extra)[0]; 977 if(!keyOfExtraConditions) return true;// skip to next iteration 978 let titleExtra = ''; 979 let isSingleOrderValueFees = false; 980 981 switch (keyOfExtraConditions){ 982 case 'singleOrderValue': 983 titleExtra = 'Valore Ordine Singolo'; 984 break; 985 case 'singleOrderValueFees': 986 isSingleOrderValueFees = true; 987 titleExtra ='Pagamento commissioni su singolo ordine'; 988 break; 989 case 'numberOfReferencesByBrand': 990 titleExtra = 'Numero Minimo Referenze Trattate'; 991 break; 992 case 'numberOfBrandsHandled': 993 titleExtra = 'Numero Brands Trattati'; 994 break; 995 case 'termsOfPayment': 996 titleExtra = 'Modalità di pagamento'; 997 break; 998 case 'singleWarehouseShipment': 999 titleExtra = 'Spedizione ad unico magazzino'; 1000 break; 1001 case 'referenceBundle': 1002 titleExtra = 'Assortimento'; 1003 break; 1004 } 1005 1006 let notes = extra[keyOfExtraConditions].notes ? extra[keyOfExtraConditions].notes : ''; 1007 let boxesOfExtras = ``; 1008 let tippyContent = ``; 1009 $.each(extra[keyOfExtraConditions].settings, (iSetting, setting) => { 1010 const tippyUuid = FTNutility.getUid(); 1011 const tippyValuid = FTNutility.getUid(); 1012 const tippyIcon = `<img src="/assets/media/images/orders/technical-info-active.svg" id="${tippyUuid}" style="cursor: pointer" class="referencesDetailIcon" alt="technical-info" />` 1013 _self.tippyInfos.push({ 1014 uuid: tippyUuid, 1015 exKey: keyOfExtraConditions, 1016 notes: notes, 1017 setting 1018 }); 1019 _self.tippyValuesId.push(tippyValuid); 1020 let textExtra = ``; 1021 switch (keyOfExtraConditions){ 1022 case 'singleOrderValue': 1023 textExtra = `Per ordini superiori a ${setting.upperLimit} â¬`; 1024 break; 1025 case 'singleOrderValueFees': 1026 textExtra = `Per ordini superiori a ${setting.upperLimit} â¬`; 1027 break; 1028 case 'numberOfReferencesByBrand': 1029 textExtra = `Per numero di referenze uguali o superiori a ${setting.upperLimit}`; 1030 break; 1031 case 'numberOfBrandsHandled': 1032 if('brands' in setting && setting.brands && setting.brands.length > 0){ 1033 1034 const brandNames = setting.brands.map(function(brandObject) { 1035 return brandObject.name; 1036 }); 1037 1038 if(brandNames.length === 1){ 1039 textExtra = `Se nell'ordine è compreso: `; 1040 }else{ 1041 textExtra = `Se nell'ordine sono compresi: `; 1042 } 1043 textExtra = `${textExtra}${brandNames.join(', ')}` 1044 } else textExtra = ''; 1045 break; 1046 case 'termsOfPayment': 1047 textExtra = `Modalità di pagamento: ${setting.typeText}`; 1048 break; 1049 case 'singleWarehouseShipment': 1050 textExtra = 'Per spedizioni al magazzino della centrale'; 1051 break; 1052 case 'referenceBundle': 1053 textExtra = 'Assortimento'; 1054 break; 1055 } 1056 1057 const bundleBrand = keyOfExtraConditions === "referenceBundle"
1058 ? (setting.mandatoryReferences[0]?.brand.value || "Non disponibile") 1059 : ""; 1060 const conditionLabel = keyOfExtraConditions === "referenceBundle" 1061 ? `<span style="font-family: Metropolis-SemiBold; color: var(--ftnBlueFonts)">${bundleBrand}</span>${textExtra ? ` · ${textExtra}` : ""}` 1062 : textExtra; 1063 const discountLabel = !isSingleOrderValueFees ? `${setting.discount}%` : "No Fee"; 1064 1065 boxesOfExtras = `${boxesOfExtras} 1066 <div style="display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--ftnGreyShadow)"> 1067 <span style="flex: 1; font-family: Metropolis-Medium; font-size: 12px; color: var(--ftnBlueFonts); line-height: 1.3"> 1068 ${conditionLabel || "—"} 1069 </span> 1070 <span style="flex-shrink: 0; min-width: 64px; text-align: right; font-family: Metropolis-Bold; font-size: 13px; color: var(--ftnDarkGreen)"> 1071 ${discountLabel} 1072 </span> 1073 <span style="flex-shrink: 0; width: 20px; display: flex; align-items: center; justify-content: center"> 1074 ${tippyIcon} 1075 </span> 1076 </div> 1077 `; 1078 }) 1079 1080 if(boxesOfExtras !== ``){ 1081 templateExtras = `${templateExtras} 1082 <div class="container-fluid" style="margin-bottom: 12px; padding: 0"> 1083 <div style="display: flex; align-items: baseline; justify-content: space-between; padding-bottom: 4px; border-bottom: 2px solid var(--ftnBlueFonts)"> 1084 <p style="margin: 0; font-family: Metropolis-SemiBold; font-size: 13px; color: var(--ftnBlueFonts)">${titleExtra}</p> 1085 <span style="font-family: Metropolis-Medium; font-size: 11px; color: var(--ftnGreyFonts)">Extrasconto</span> 1086 </div> 1087 ${boxesOfExtras} 1088 </div> 1089 ` 1090 } 1091 }) 1092 1093 if(templateExtras !== ``){ 1094 template = `${template} 1095 <div class="container-fluid"> 1096 <div class="row" style="height: 24px"></div> 1097 <div class="row"> 1098 <div class="col-md-12"> 1099 <div class="col-12 no-padding"> 1100 <div style="margin-bottom: 14px"> 1101 <p style="margin: 0 0 2px 0; font-family: Metropolis-Bold; font-size: 16px; color: var(--ftnBlueFonts)">Extra Sconti sull'intero listino</p> 1102 <p style="margin: 0; font-family: Metropolis-Medium; font-size: 12px; color: var(--ftnGreyFonts)">Gli sconti non sono applicabili per ordini composti interamente da etico</p> 1103 </div> 1104 ${templateExtras} 1105 </div> 1106 </div> 1107 </div> 1108 </div> 1109 ` 1110 } 1111 1112 } 1113 1114 _self.templatePreview = template 1115 return true; 1116 } 1117 }, 1118 { key: "getBundleRowsWithPrefillPreview", 1119 /** 1120 * get Row Object 1121 * @return {object} 1122 */ 1123 value: function getBundleRowsWithPrefillPreview() { 1124 const _self = this; 1125 1126 const bundleSettingsTemplate = ` 1127 <div class="col-12 no-padding"> 1128 <p style="font-family: Metropolis-Bold; font-size: 0.8rem; color: #16366B;">Lista Bundle</p> 1129 <p style="font-family: Metropolis-Medium; font-size: 0.6rem; color: #7a7e87;">La referenza selezionata appartiene ${_self.conditions.settings.length > 1 ? `a più Bundle` : `ad un Bundle`}, vedi a seguito le condizioni finanziarie specifiche.</p> 1130 </div> 1131 <section id="ftnBundleConditionsAccordion" class="" style="max-height: 550px; overflow: auto;"> 1132 <ul class="collapsible"> 1133 ${_self.conditions.settings.map((bundle, iBundle) => { 1134 1135 return ` 1136 <li class="${iBundle === 0 ? 'active' : ''}" tabIndex=${iBundle}> 1137 <div class="collapsible-header" style="font-family: Metropolis-Bold; font-size: 18px; color: #016ed0; padding: 0.5rem 1rem">${bundle.name}</div> 1138 <div class="collapsible-body"> 1139 <div class="row" style="margin: 0 0 0.5rem 0;"> 1140 <div class="col-8 no-padding"> 1141 <p style="font-family: Metropolis-Bold; font-size: 12px; color: #233b63; margin-bottom: 3px;">Referenza</p> 1142 <p style="font-family: Metropolis-Bold; font-size: 0.8rem; color: #0ba488; line-height: 1;">${_self.conditions.name}</p> 1143 </div> 1144 <div class="col-4 no-padding" style="text-align: right;"> 1145 <p style="font-family: Metropolis-Bold; font-size: 12px; color: #233b63; margin-bottom: 3px;">Prezzo di Listino</p> 1146 <p style="font-family: Metropolis-Bold; font-size: 1.1rem; color: #0ba488; line-height: 1;">${_self.conditions.priceToShow}</p> 1147 </div> 1148 </div> 1149 <div class="col-12 no-padding"> 1150 <p style="font-family: Metropolis-Bold; font-size: 12px; color: #16366B">Condizioni Commerciali</p> 1151 </div> 1152 1153 <div class="row" style="margin: 0 0;"> 1154 <div class="col-3 no-padding"> 1155 <p class="ftn-plc-setting-item-box-label">Range Quantità </p> 1156 </div> 1157 <div class="col-3 no-padding ftn-plc-item-box-container-select"> 1158 <p class="ftn-plc-setting-item-box-label"></p> 1159 </div> 1160 <div class="col-3 no-padding"> 1161 <p class="ftn-plc-setting-item-box-label">Sconto %</p> 1162 </div> 1163 <div class="col-3 no-padding"> 1164 <p class="ftn-plc-setting-item-box-label">Prezzo di Cessione</p> 1165 </div> 1166 </div> 1167 ${bundle.settings.map((setting, iSett
1167ing) => { 1168 const umiUpperLimit = setting.umiUpperLimit === -1 ? 'Illimitato' : setting.umiUpperLimit; 1169 1170 const priceRecommended = parseFloat(_self.conditions.price); 1171 const saving = (priceRecommended/100)*parseFloat(setting.discount); 1172 const finalPriceNotAround = parseFloat(priceRecommended) - parseFloat(saving); 1173 const finalePriceAround = Math.round(finalPriceNotAround * 100) / 100; 1174 const finalPriceAroundToShow = parseFloat(finalePriceAround).toFixed(2); 1175 1176 const spacingRow = iSetting === (bundle.settings.length - 1) ? `<div style="height: 8px;"></div>` : ''; 1177 1178 return ` 1179 <div class="row" id="ftnPlcRowPrice${setting.id}" style="margin: 0 0;"> 1180 <div class="col-3 no-padding"> 1181 <div class="ftn-plc-setting-item-box-information range"><span>da <span class="quantity">${setting.umiLowerLimit}</span></span> <span>Fino a n.</span></div> 1182 </div> 1183 <div class="col-3 no-padding ftn-plc-item-box-container-select"> 1184 <div class="ftn-plc-setting-item-box-information range"><span class="quantity">${umiUpperLimit}</span></div> 1185 </div> 1186 <div class="col-3 no-padding"> 1187 <div class="ftn-plc-setting-item-box-information price"><span>${setting.discount} %</span></div> 1188 </div> 1189 <div class="col-3 no-padding"> 1190 <div class="ftn-plc-setting-item-box-information price"><span>${finalPriceAroundToShow}</span></div> 1191 </div> 1192 </div> 1193 ${spacingRow} 1194 `; 1195 }).join('')} 1196 </div> 1197 </li> 1198 `; 1199 }).join('') 1200 } 1201 </ul> 1202 </section> 1203 `; 1204 1205 return bundleSettingsTemplate; 1206 } 1207 }, 1208 { 1209 key: "getRowObject", 1210 /** 1211 * get Row Object 1212 * @return {object} 1213 */ 1214 value: function getRowObject(umiLowerLimit, umiUpperLimit, isFirst = false, distinctReferencesPrevLimit = 2){ 1215 let _self = this; 1216 let idSetting = Util.getUid(); 1217 1218 let partialTemplate = ``; 1219 1220 const optionSelectFrom = `<option value="${umiLowerLimit}" selected>${umiLowerLimit}</option>`; 1221 const optionsSelectTo = Util.getOptionsSelect('deepSelectOptionsConditionFormTo', _self.conditions.umi, umiLowerLimit); 1222 partialTemplate = ` 1223 <div class="col-${_self.isBundle? '4' : '3'} no-padding"> 1224 <div class="ftn-plc-setting-item-box-information-promotional-range static"> 1225 <span>da</span> 1226 <select id="ftnPriceListConditionStartLimitRange${idSetting}" class="ftn-signup-side-select ftn-plc-input" numericSearchable="Cerca"> 1227 ${optionSelectFrom} 1228 </select>
1229 <span style="white-space: nowrap">Fino a n.</span> 1230 </div> 1231 </div> 1232 <div class="col-${_self.isBundle? '4' : '3'} no-padding ftn-plc-item-box-container-select"> 1233 <div class="input-filed rcs"> 1234 <select id="ftnPriceListConditionLimitRange${idSetting}" class="ftn-signup-side-select ftn-plc-input" numericSearchable="Cerca"> 1235 ${optionsSelectTo} 1236 </select> 1237 </div> 1238 </div> 1239 ` 1240 1241 let template = ``; 1242 if(!isFirst){ 1243 template = ` 1244 <div class="row" id="ftnPlcRowPrice${idSetting}"> 1245 ${partialTemplate} 1246 <div class="col-${_self.isBundle ? '3' : '2'} no-padding"> 1247 <input id="ftnPriceListConditionSold${idSetting}" class="ftn-plc-input disabled" type="text" placeholder="0.00" step="0.01" min="0.00" max="100.00" autocomplete="nohint" disabled> 1248 <span id="ftnPriceListConditionSold${idSetting}HelperText" class="helper-text" style="font-size: 11px; position: absolute; top: 30px"></span> 1249 </div> 1250 ${_self.isBundle ? '' : ` 1251 <div class="col-3 no-padding"> 1252 <div id="ftnPriceListConditionFinalPrice${idSetting}" class="ftn-plc-setting-item-box-information price ftn-plc-input"><span>⬠${_self.conditions.priceToShow}</span></div> 1253 </div> 1254 `} 1255 <div class="col-1 no-padding"> 1256 <button id="ftnPriceListConditionItemBoxAddRow${idSetting}" class="waves-effect waves-light btn ftn-button icon-button green disabled reference-condition-setting-button" disabled><i class="material-icons">add</i></button> 1257 <button id="ftnPriceListConditionItemBoxRemoveRow${idSetting}" class="waves-effect waves-light btn ftn-button icon-button red disabled reference-condition-setting-button" data-remove-all="0" disabled style="display: none"><i class="material-icons">remove</i></button> 1258 </div> 1259 </div> 1260 ` 1261 }else{ 1262 let optionsFrom = Util.getOptionsSelect('template', umiLowerLimit); 1263 template = ` 1264 <div class="row" id="ftnPlcRowPrice${idSetting}"> 1265 <div class="col-3 no-padding"> 1266 <p class="ftn-plc-setting-item-box-label">Range quantità </p> 1267 <div class="ftn-plc-setting-item-box-information range"><span>da <span class="quantity">${umiLowerLimit}</span></span> <span>Fino a n.</span></div> 1268 </div> 1269 <div class="col-3 no-padding ftn-plc-item-box-container-select"> 1270 <div class="input-filed rcs"> 1271 <span class="plc-input-label" style="color: transparent">Select</span> 1272 <select id="ftnPriceListConditionLimitRange${idSetting}" class="ftn-signup-side-select ftn-plc-input" numericSearchable="Cerca"> 1273 ${optionsFrom} 1274 </select> 1275 </div> 1276 </div> 1277 <div class="col-2 no-padding"> 1278 <span class="plc-input-label">Sconto (%)</span> 1279 <input id="ftnPriceListConditionSold${idSetting}" class="ftn-plc-input disabled" type="text" placeholder="0.00" step="0.01" min="0.00" max="100.00" autocomplete="nohint" value="
12790" disabled> 1280 </div> 1281 <div class="col-3 no-padding"> 1282 <p class="ftn-plc-setting-item-box-label">Prezzo di cessione</p> 1283 <div id="ftnPriceListConditionFinalPrice${idSetting}" class="ftn-plc-setting-item-box-information price ftn-plc-input"><span>⬠${_self.conditions.priceToShow}</span></div> 1284 </div> 1285 <div class="col-1 no-padding"> 1286 <button id="ftnPriceListConditionItemBoxAddRow${idSetting}" class="waves-effect waves-light btn ftn-button icon-button green disabled reference-condition-setting-button first-row" disabled><i class="material-icons">add</i></button> 1287 <button id="ftnPriceListConditionItemBoxRemoveRow${idSetting}" class="waves-effect waves-light btn ftn-button icon-button red disabled reference-condition-setting-button first-row" data-remove-all="1" disabled style="display: none"><i class="material-icons">remove</i></button> 1288 </div> 1289 </div> 1290 ` 1291 } 1292 1293 _self.conditions.settings.push({ 1294 id: idSetting, 1295 discount: 0, 1296 umiLowerLimit: parseFloat(umiLowerLimit), 1297 umiUpperLimit: null 1298 }) 1299 1300 return { 1301 template: template, 1302 id: _self.conditions.id, 1303 settingId: idSetting 1304 }; 1305 } 1306 }, 1307 { 1308 key: "getRowsWithPrefill", 1309 /** 1310 * get Row Object 1311 * @param {string} containerId 1312 * @return {boolean} 1313 */ 1314 value: function getRowsWithPrefill(containerId){ 1315 let containerRow = $(`#${containerId}`); 1316 let _self = this; 1317 const isBundle = _self.isBundle; 1318 let indexReferenceProcessed = null; 1319 $.each(_self.conditions.settings, (iSetting, setting) => { 1320 if(iSetting !== 0){ 1321 indexReferenceProcessed = iSetting; 1322 let idSetting = setting.id; 1323 let umi = _self.conditions.umi; 1324 let umiLowerLimit = setting.umiLowerLimit; 1325 let selectedValue = setting.umiUpperLimit; 1326 1327 let partialTemplate = ``; 1328 1329 const optionsSelectFrom = `<option value="${umiLowerLimit}" selected>${umiLowerLimit}</option>`; 1330 const optionsSelectTo = Util.getOptionsSelect('deepSelectOptionsConditionFormToPrefilled', umi, umiLowerLimit, selectedValue); 1331 1332 partialTemplate = ` 1333 <div class="col-${isBundle? '4' : '3'} no-padding"> 1334 <div class="ftn-plc-setting-item-box-information-promotional-range static"> 1335 <span>da</span> 1336 <select id="ftnPriceListConditionStartLimitRange${idSetting}" class="ftn-signup-side-select ftn-plc-input" numericSearchable="Cerca"> 1337 ${optionsSelectFrom} 1338 </select> 1339 <span style="white-space: nowrap">Fino a n.</span> 1340 </div> 1341 </div> 1342 <div class="col-${isBundle? '4' : '3'} no-padding ftn-plc-item-box-container-select"> 1343 <div class="input-filed rcs"> 1344 <select id="ftnPriceListConditionLimitRange${idSetting}" class="ftn-signup-side-select ftn-plc-input" numericSearchable="Cerca"> 1345 ${optionsSelectTo} 1346 </select> 1347 </div> 1348 </div> 1349 ` 1350 1351 1352 1353 let priceRecommended = parseFloat(_self.conditions.price); 1354 let saving = (priceRecommended/100)*parseFloat(setting.discount); 1355 let finalPriceNotAround = parseFloat(priceRecommended) - parseFloat(saving); 1356 let finalePriceAround = Math.round(finalPriceNotAround * 100) / 100; 1357 let template = ` 1358 <div class="row" id="ftnPlcRowPrice${idSetting}"> 1359 ${partialTemplate} 1360 <div class="${isBundle ? 'col-3' : 'col-2'} no-padding"> 1361 <input id="ftnPriceListConditionSold${idSetting}" class="ftn-plc-input" type="text" placeholder="0.00" step="0.01" min="0.00" max="100.00" autocomplete="nohint" value="${setting.discount}">
1362 <span id="ftnPriceListConditionSold${idSetting}HelperText" class="helper-text" style="font-size: 11px; position: absolute; top: 30px"></span> 1363 </div> 1364 ${!isBundle ? ` 1365 <div class="col-3 no-padding"> 1366 <div id="ftnPriceListConditionFinalPrice${idSetting}" class="ftn-plc-setting-item-box-information price ftn-plc-input"><span>⬠${finalePriceAround}</span></div> 1367 </div>` 1368 : ''} 1369 <div class="col-1 no-padding"> 1370 <button id="ftnPriceListConditionItemBoxAddRow${idSetting}" class="waves-effect waves-light btn ftn-button icon-button green disabled reference-condition-setting-button" disabled><i class="material-icons">add</i></button> 1371 <button id="ftnPriceListConditionItemBoxRemoveRow${idSetting}" class="waves-effect waves-light btn ftn-button icon-button red disabled reference-condition-setting-button" data-remove-all="0"><i class="material-icons">remove</i></button> 1372 </div> 1373 </div> 1374 ` 1375 containerRow.append(template); 1376 let buttonAddRow = $(`#ftnPriceListConditionItemBoxAddRow${idSetting}`); 1377 let buttonRemoveRow = $(`#ftnPriceListConditionItemBoxRemoveRow${idSetting}`); 1378 1379 if((indexReferenceProcessed + 1) === _self.conditions.settings.length){ 1380 buttonAddRow.removeAttr('disabled'); 1381 buttonAddRow.removeClass('disabled'); 1382 buttonAddRow.show(); 1383 buttonRemoveRow.attr('disabled'); 1384 buttonRemoveRow.addClass('disabled'); 1385 buttonRemoveRow.hide(); 1386 }else{ 1387 buttonRemoveRow.removeAttr('disabled'); 1388 buttonRemoveRow.removeClass('disabled'); 1389 buttonRemoveRow.show(); 1390 buttonAddRow.attr('disabled'); 1391 buttonAddRow.addClass('disabled'); 1392 buttonAddRow.hide(); 1393 } 1394 1395 1396 if(selectedValue === -1){ 1397 buttonRemoveRow.removeAttr('disabled'); 1398 buttonRemoveRow.removeClass('disabled'); 1399 buttonRemoveRow.show(); 1400 buttonAddRow.attr('disabled'); 1401 buttonAddRow.addClass('disabled'); 1402 buttonAddRow.hide(); 1403 } 1404 1405 _self.handlingInputsEvent(idSetting) 1406 } 1407 }) 1408 } 1409 }, 1410 { 1411 key: "handlingInputsEvent", 1412 /** 1413 * handling Inputs Event 1414 * @param {string} settingId 1415 * @return {boolean} 1416 */ 1417 value: function handlingInputsEvent(settingId){ 1418 let _self = this; 1419 let indexSettingSelected = null; 1420 1421 let buttonSubmit = $(`#ftnReferenceConditionsComponentSubmit${_self.conditions.id}`); 1422 1423 $.each(_self.conditions.settings, (iSetting, setting) => { 1424 if(setting.id === settingId){ 1425 indexSettingSelected = iSetting; 1426 } 1427 }) 1428 1429 let modalAlert = document.getElementById(`ftnReferenceConditionsModalHandlingUpdate${_self.conditions.id}`); 1430 let buttonModalConfirmUpdate = $(`#ftnReferenceConditionsHandlingUpdateConfirm${_self.conditions.id}`); 1431 let buttonModalDeniesUpdate = $(`#ftnReferenceConditionsHandlingUpdateDenies${_self.conditions.id}`); 1432 buttonModalConfirmUpdate.off('click');
1433 let modalDescription = $(`#ftnReferenceConditionsHandlingDescription${_self.conditions.id}`); 1434 1435 1436 let buttonAddNewRow = $(`#ftnPriceListConditionItemBoxAddRow${settingId}`); 1437 let buttonRemoveRow = $(`#ftnPriceListConditionItemBoxRemoveRow${settingId}`); 1438 1439 let discountInput = $(`#ftnPriceListConditionSold${settingId}`); 1440 discountInput.off('keyup'); 1441 discountInput.on('keyup', () => { 1442 let discountPercentage = discountInput.val(); 1443 if(isNaN(discountPercentage)){ 1444 discountInput.addClass('invalid'); 1445 discountInput.removeClass('valid'); 1446 discountInput.attr('data-error', 'stringa non ammessa'); 1447 }else{ 1448 discountInput.removeClass('invalid'); 1449 discountInput.addClass('valid'); 1450 discountInput.attr('data-error', ''); 1451 if(discountPercentage.length === 0){ 1452 discountPercentage = 0.00 1453 } 1454 if(parseFloat(discountPercentage) >= 100.00){ 1455 discountInput.val(100.00) 1456 discountPercentage = 100.00 1457 } 1458 let priceRecommended = parseFloat(_self.conditions.price); 1459 let saving = (priceRecommended/100)*parseFloat(discountPercentage); 1460 let finalPriceNotAround = parseFloat(priceRecommended) - parseFloat(saving); 1461 let finalePriceAround = Math.round(finalPriceNotAround * 100) / 100; 1462 $(`#ftnPriceListConditionFinalPrice${settingId}`).html(`<span>⬠${finalePriceAround.toFixed(2)}</span>`); 1463 _self.conditions.settings[indexSettingSelected].discount = parseFloat(discountPercentage); 1464 } 1465 }); 1466 1467 // BUNDLE min quantity handler 1468 if(_self.isBundle) { 1469 const bundleSelect = $(`#${_self.bundleSelectId}`); 1470 let bundleSelectedQuantity = bundleSelect.val(); 1471 console.log(bundleSelectedQuantity); 1472 _self.conditions.minimumDistinctReferences = parseInt(bundleSelectedQuantity); 1473 1474 bundleSelect.off('change'); 1475 bundleSelect.on('change', () => { 1476 const bundleErrorMessage = $(`#${_self.bundleSelectId}HelperText`); 1477 bundleErrorMessage.animate({ opacity: 0 }, 400, function() { 1478 $(this).css("visibility", "hidden"); 1479 }); 1480 1481 const bundleSelectContainer = $(`#bundleSelectWrapper input.select-dropdown.dropdown-trigger`); 1482 bundleSelectContainer.attr("style", ""); 1483 1484 let bundleSelectedQuantity = bundleSelect.val(); 1485 _self.conditions.minimumDistinctReferences = parseInt(bundleSelectedQuantity); 1486 }); 1487 } 1488 1489 if(_self.isOngoing && _self.isForCentral){ 1490 let discountInputRestocking = $(`#ftnPriceListConditionSoldRestocking${settingId}`); 1491 discountInputRestocking.off('keyup'); 1492 discountInputRestocking.on('keyup', () => { 1493 discountInputRestocking.removeClass('invalid'); 1494 discountInputRestocking.addClass('valid'); 1495 discountInputRestocking.attr('data-error', ''); 1496 1497 let discountPercentageRestocking = discountInputRestocking.val(); 1498 if(discountPercentageRestocking.length === 0){ 1499 discountPercentageRestocking = 0.00 1500 } 1501 if(parseFloat(discountPercentageRestocking) >= 100.00){ 1502 discountInputRestocking.val(100.00) 1503 discountPercentageRestocking = 100.00 1504 } 1505 let priceRecommendedRestocking = parseFloat(_self.conditions.price); 1506 let savingRestocking = (priceRecommendedRestocking/100)*parseFloat(discountPercentageRestocking); 1507 let finalPriceNotAroundRestocking = parseFloat(priceRecommendedRestocking) - parseFloat(savingRestocking); 1508 let finalePriceAroundRestocking = Math.round(finalPriceNotAroundRestocking * 100) / 100; 1509 $(`#ftnPriceListConditionFinalPriceRestocking${settingId}`).html(`<span>⬠${finalePriceAroundRestocking.toFixed(2)}</span>`); 1510 _self.conditions.restockingDiscount = parseFloat(discountPercentageRestocking); 1511 }); 1512 } 1513 1514 // Select change handlers 1515 let selectInput = $(`#ftnPriceListConditionLimitRange${settingId}`); 1516 let oldSelectVal = selectInput.val(); 1517 selectInput.off('change'); 1518 selectInput.on('change', () => { 1519 buttonSubmit.removeClass('disabled'); 1520 buttonSubmit.removeAttr('disabled'); 1521 let isLastItem = false;
1522 if ((parseInt(indexSettingSelected) + 1) === _self.conditions.settings.length) { 1523 isLastItem = true; 1524 } 1525 1526 let selectedValue = selectInput.val(); 1527 if (isLastItem) { 1528 _self.handlingSelectChange(settingId, indexSettingSelected, selectedValue); 1529 oldSelectVal = selectInput.val(); 1530 return; 1531 } else { 1532 modalDescription.html('Sei assolutamente sicuro di voler effettuare la modifica su questa riga? Perderai tutte le informazioni successive a questa.') 1533 buttonModalConfirmUpdate.html('MODIFICA'); 1534 modalAlert.style.display = "block"; 1535 1536 buttonModalDeniesUpdate.off('click'); 1537 buttonModalDeniesUpdate.on('click', () => { 1538 selectInput.val(oldSelectVal); 1539 selectInput.formSelect(); 1540 modalAlert.style.display = "none"; 1541 }); 1542 1543 buttonModalConfirmUpdate.off('click'); 1544 buttonModalConfirmUpdate.on('click', () => { 1545 _self.handlingSelectChange(settingId, indexSettingSelected, selectedValue, _self.removeRow(settingId, false)); 1546 oldSelectVal = selectedValue; 1547 selectInput.val(selectedValue); 1548 selectInput.formSelect(); 1549 modalAlert.style.display = "none"; 1550 }); 1551 return; 1552 } 1553 }); 1554 selectInput.formSelect(); 1555 1556 let selectInitialUmi = $(`#ftnPriceListConditionStartLimitRange${settingId}`) 1557 selectInitialUmi.off('change'); 1558 selectInitialUmi.on('change', (e) => { 1559 let initialUmiValue = parseInt(selectInitialUmi.val()); 1560 1561 let isLastItem = false; 1562 if ((parseInt(indexSettingSelected) + 1) === _self.conditions.settings.length) { 1563 isLastItem = true; 1564 } 1565 1566 const isFirstRow = selectInitialUmi.data('first-row'); 1567 let selectedValue = selectInput.val() >= initialUmiValue ? selectInput.val() : null; 1568 1569 if(isLastItem) { 1570 _self.conditions.settings[indexSettingSelected].umiLowerLimit = initialUmiValue; 1571 1572 if(parseInt(initialUmiValue) > parseInt(selectedValue)) { 1573 _self.handlingSelectChange(settingId, indexSettingSelected, 'null'); 1574 selectedValue = 0; 1575 }; 1576 selectInput.html(``); 1577 1578 let options = `<option value="null" disabled ${!selectedValue || selectedValue < initialUmiValue ? 'selected' : ''}>-</option><option value="-1">Illimitato</option>`; 1579 for(let i = 0; i < (MULTIPLIER -1); i++){ 1580 const currentValue = initialUmiValue + parseInt(_self.conditions.umi)*i; 1581 options = `${options}<option value="${currentValue}" ${parseInt(selectedValue) === currentValue ? 'selected' : ''}>${currentValue}</option>` 1582 } 1583 1584 selectInput.append(` 1585 ${options} 1586 `); 1587 selectInput.formSelect(); 1588 1589 return; 1590 } else { 1591 if(initialUmiValue <= selectedValue) { 1592 _self.conditions.settings[indexSettingSelected].umiLowerLimit = initialUmiValue; 1593 selectInput.html(``); 1594 1595 let options = `${!selectedValue || parseInt(selectedValue) < parseInt(initialUmiValue) ? '<option value="null" disabled selected>-</option>' : ''}<option value="-1">Illimitato</option>`; 1596 for(let i = 0; i < (MULTIPLIER); i++){ 1597 const currentVal = (parseInt(initialUmiValue) + (parseInt(_self.conditions.umi)*i)); 1598 options = `${options}<option value="${currentVal}" ${currentVal === parseInt(selectedValue) ? 'selected' : ''}>${currentVal}</option>` 1599 } 1600 selectInput.html(` 1601 ${options} 1602 `); 1603 selectInput.formSelect(); 1604 oldSelectVal = selectedValue; 1605 1606 return; 1607 }; 1608
1609 modalDescription.html('Sei assolutamente sicuro di voler effettuare la modifica su questa riga? Perderai tutte le informazioni successive a questa.') 1610 buttonModalConfirmUpdate.html('MODIFICA'); 1611 modalAlert.style.display = "block"; 1612 1613 buttonModalDeniesUpdate.off('click'); 1614 buttonModalDeniesUpdate.on('click', () => { 1615 selectInitialUmi.val(_self.conditions.settings[indexSettingSelected].umiLowerLimit); 1616 selectInitialUmi.formSelect(); 1617 selectInput.val(oldSelectVal); 1618 selectInput.formSelect(); 1619 modalAlert.style.display = "none"; 1620 }); 1621 1622 buttonModalConfirmUpdate.off('click'); 1623 buttonModalConfirmUpdate.on('click', () => { 1624 _self.handlingSelectChange(settingId, indexSettingSelected, (isFirstRow && selectedValue ? selectedValue : 'null'), _self.removeRow(settingId, false)); 1625 _self.conditions.settings[indexSettingSelected].umiLowerLimit = initialUmiValue; 1626 selectInput.html(``); 1627 1628 let options = `${!selectedValue || parseInt(selectedValue) < parseInt(initialUmiValue) ? '<option value="null" disabled selected>-</option>' : ''}<option value="-1">Illimitato</option>`; 1629 1630 for(let i = 0; i < (MULTIPLIER); i++){ 1631 const currentVal = (parseInt(initialUmiValue) + (parseInt(_self.conditions.umi)*i)); 1632 options = `${options}<option value="${currentVal}" ${currentVal === parseInt(selectedValue) ? 'selected' : ''}>${currentVal}</option>` 1633 } 1634 selectInput.html(` 1635 ${options} 1636 `); 1637 1638 selectInput.formSelect(); 1639 oldSelectVal = selectedValue; 1640 modalAlert.style.display = "none"; 1641 1642 return; 1643 }); 1644 } 1645 }) 1646 selectInitialUmi.formSelect(); 1647 1648 1649 buttonAddNewRow.off('click'); 1650 buttonAddNewRow.on('click', () => { 1651 buttonAddNewRow.addClass('disabled'); 1652 buttonAddNewRow.attr('disabled'); 1653 let discountManagement = CustomMaterializeValidate.validateInputAndGetValue(`ftnPriceListConditionSold${settingId}`, { 1654 isRequired : { 1655 value: true, 1656 errorMessage: 'Campo obbligatorio' 1657 }, 1658 }); 1659 1660 if(!discountManagement.isValid){ 1661 buttonAddNewRow.removeClass('disabled'); 1662 buttonAddNewRow.removeAttr('disabled'); 1663 return false; 1664 } 1665 1666 let objectNewRow = _self.getRowObject((parseFloat(_self.conditions.settings[indexSettingSelected].umiUpperLimit) + parseFloat(_self.conditions.umi)), (parseFloat(_self.conditions.settings[indexSettingSelected].umiUpperLimit) + parseFloat(_self.conditions.umi)*2), false); 1667 let container = $(`#ftnPlcContainerPrice${_self.conditions.id}`); 1668 container.append(objectNewRow.template); 1669 _self.handlingInputsEvent(objectNewRow.settingId); 1670 buttonAddNewRow.hide(); 1671 buttonRemoveRow.show(); 1672 FTNutility.enabledButtonOrLinkMaterialize(buttonRemoveRow) 1673 }); 1674 1675 let removeAll = buttonRemoveRow.data('remove-all'); 1676 buttonRemoveRow.off('click'); 1677 buttonRemoveRow.on('click', () => {
1678 modalDescription.html('Sei assolutamente sicuro di voler cancellare questa riga? Perderai tutte le informazioni successive a questa.') 1679 buttonModalConfirmUpdate.html('Cancella'); 1680 modalAlert.style.display = "block"; 1681 1682 buttonModalDeniesUpdate.off('click'); 1683 buttonModalDeniesUpdate.on('click', () => { 1684 modalAlert.style.display = "none"; 1685 }); 1686 1687 buttonModalConfirmUpdate.off('click'); 1688 buttonModalConfirmUpdate.on('click', (event) => { 1689 event.preventDefault(); 1690 if(parseInt(removeAll) === 0){ 1691 _self.removeRow(settingId); 1692 modalAlert.style.display = "none"; 1693 }else{ 1694 buttonSubmit.addClass('disabled'); 1695 buttonSubmit.attr('disabled'); 1696 _self.removeAllRow(); 1697 modalAlert.style.display = "none"; 1698 // _self.callbackSubmit(_self.conditions); 1699 } 1700 }); 1701 }) 1702 1703 buttonSubmit.off('click'); 1704 buttonSubmit.on('click', () => { 1705 let isAllValidDiscount = true; 1706 if(_self.isBundle) { 1707 if(isNaN(_self.conditions.minimumDistinctReferences) || _self.conditions.minimumDistinctReferences === 0) { 1708 isAllValidDiscount = false; 1709 const bundleSelectContainer = $(`#bundleSelectWrapper input.select-dropdown.dropdown-trigger`); 1710 bundleSelectContainer.attr("style", "border: 1px solid red !important;"); 1711 1712 const bundleErrorMessageElements = $(`#${_self.bundleSelectId}HelperText`); 1713 bundleErrorMessageElements.css({"visibility": "visible"}); 1714 }; 1715 }; 1716 $.each(_self.conditions.settings, (iSetting, setting) => { 1717 let discountManagement = CustomMaterializeValidate.validateInputAndGetValue(`ftnPriceListConditionSold${setting.id}`, { 1718 isRequired : { 1719 value: true, 1720 errorMessage: 'Campo obbligatorio', 1721 }, 1722 regex: { 1723 value: CustomMaterializeValidate.regexRules.float, 1724 errorMessage: '' 1725 }, 1726 }); 1727 if(!discountManagement.isValid){ 1728 isAllValidDiscount = false; 1729 } 1730 }); 1731 1732 if(isAllValidDiscount){ 1733 _self.callbackSubmit(_self.conditions) 1734 }else{ 1735 return false; 1736 } 1737 }) 1738 1739 } 1740 }, 1741 { 1742 key: "removeRow", 1743 /** 1744 * handling remove Row 1745 * @param {string} settingId 1746 * @param {boolean} removeCurrentRow 1747 * @return {boolean} 1748 */ 1749 value: function removeRow(settingId, removeCurrentRow = true) { 1750 let _self = this; 1751 let indexSettingSelected = null; 1752 $.each(_self.conditions.settings, (iSetting, setting) => { 1753 if(setting.id === settingId){ 1754 indexSettingSelected = iSetting; 1755 } 1756 }) 1757 let buttonAddNewRow = ''; 1758 let buttonRemoveRow = ''; 1759 if(removeCurrentRow){ 1760 $.each(_self.conditions.settings, (iSetting, setting) => { 1761 if(iSetting >= indexSettingSelected){ 1762 $(`#ftnPlcRowPrice${setting.id}`).remove(); 1763 } 1764 }) 1765 _self.conditions.settings.length = indexSettingSelected 1766 const lastItem = _self.conditions.settings[indexSettingSelected - 1] 1767 buttonAddNewRow = $(`#ftnPriceListConditionItemBoxAddRow${lastItem.id}`); 1768 buttonRemoveRow = $(`#ftnPriceListConditionItemBoxRemoveRow${lastItem.id}`); 1769 }else{ 1770 $.each(_self.conditions.settings, (iSetting, setting) => { 1771 if(iSetting > indexSettingSelected){ 1772 $(`#ftnPlcRowPrice${setting.id}`).remove(); 1773 } 1774 }) 1775 1776 _self.conditions.settings.length = indexSettingSelected + 1; 1777 const lastItem = _self.conditions.settings[indexSettingSelected] 1778 buttonAddNewRow = $(`#ftnPriceListConditionItemBoxAddRow${lastItem.id}`); 1779 buttonRemoveRow = $(`#ftnPriceListConditionItemBoxRemoveRow${lastItem.id}`); 1780 1781 } 1782 buttonRemoveRow.hide(); 1783 buttonAddNewRow.show(); 1784 buttonAddNewRow.removeClass('disabled'); 1785 buttonAddNewRow.removeAttr('disabled'); 1786 } 1787 }, 1788 { 1789 key: "removeAllRow", 1790 /** 1791 * handling remove All Row 1792 * @return {boolean} 1793 */ 1794 value: function removeAllRow() { 1795 let _self = this; 1796 let umi = _self.conditions.umi; 1797 _self.conditions.settings = []; 1798 _self.getFirstRowObject(); 1799 // let objectNewRow = _self.getRowObject(umi, null, true); 1800 // let container = $(`#ftnPlcContainerPrice${_self.conditions.id}`); 1801 // container.html(objectNewRow.template); 1802 // _self.handlingInputsEvent(objectNewRow.settingId); 1803 return true; 1804 } 1805 }, 1806 { 1807 key: "handlingSelectChange", 1808 /** 1809 * handling select change 1810 * @param {string} settingId 1811 * @param {integer} indexSettingSelected 1812 * @param {string} selectedValue 1813 * @return {boolean} 1814 */
1815 value: function handlingSelectChange(settingId, indexSettingSelected, selectedValue, callback = () => {}) { 1816 let _self = this; 1817 let buttonAddNewRow = $(`#ftnPriceListConditionItemBoxAddRow${settingId}`); 1818 let buttonRemoveRow = $(`#ftnPriceListConditionItemBoxRemoveRow${settingId}`); 1819 let discountInput = $(`#ftnPriceListConditionSold${settingId}`); 1820 1821 if(selectedValue === 'null'){ 1822 buttonAddNewRow.addClass('disabled'); 1823 buttonAddNewRow.attr('disabled'); 1824 1825 discountInput.addClass('disabled'); 1826 discountInput.attr('disabled', 'disabled'); 1827 discountInput.val(""); 1828 $(`#ftnPriceListConditionFinalPrice${settingId}`).html(`<span>⬠${_self.conditions.priceToShow}</span>`); 1829 _self.conditions.settings[indexSettingSelected].discount = 0; 1830 _self.conditions.settings[indexSettingSelected].umiUpperLimit = null; 1831 }else if(parseInt(selectedValue) === -1){ 1832 buttonAddNewRow.addClass('disabled'); 1833 buttonAddNewRow.attr('disabled'); 1834 discountInput.removeClass('disabled'); 1835 discountInput.removeAttr('disabled'); 1836 _self.conditions.settings[indexSettingSelected].umiUpperLimit = parseFloat(selectedValue); 1837 }else{ 1838 buttonAddNewRow.removeClass('disabled'); 1839 buttonAddNewRow.removeAttr('disabled'); 1840 discountInput.removeClass('disabled'); 1841 discountInput.removeAttr('disabled'); 1842 _self.conditions.settings[indexSettingSelected].umiUpperLimit = parseFloat(selectedValue); 1843 } 1844 callback(); 1845 } 1846 }, 1847 { key: "buildBundleSelectOptions", 1848 1849 value: function buildBundleSelectOptions(n, prefillSelectValue) { 1850 let options = '<option value="" disabled selected> - </option>'; 1851 1852 for (let i = 1; i <= n; i++) { 1853 if(Number(prefillSelectValue) === i) { 1854 options += `<option value="${i}" selected>${i}</option>`; 1855 } else { 1856 options += `<option value="${i}">${i}</option>`; 1857 } 1858 } 1859 1860 return options; 1861 } 1862 }, 1863 ]) 1864 1865 return FTNReferenceConditionsSetting; 1866 }(); 1867 1868 return FTNReferenceConditionsSetting; 1869})))
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.