New file |
| | |
| | | /** |
| | | * quest' oggetto definisce i metodi XML |
| | | * se is_editable è true la stringa XML verrà modificato dall' update massivo |
| | | * @type {{sso_getWebcustomerInformation: {defaultXML: string, is_editable: boolean, actualXML: string}, sso_getSelectedMSISDNDetails: {defaultXML: string, is_editable: boolean, actualXML: string}, sso_getMSISDNDetails: {defaultXML: string, is_editable: boolean, actualXML: string}, picasso_getWebcustomerInformation: {defaultXML: string, is_editable: boolean, actualXML: string}, sso_getMSISDNList: {defaultXML: string, is_editable: boolean, actualXML: string}, sso_getInfoActivationWSC: {defaultXML: string, is_editable: boolean, actualXML: string}}} |
| | | */ |
| | | let xmlMethods = { |
| | | 'sso_getWebcustomerInformation': { |
| | | 'defaultXML': sso_getWebcustomerInformation, |
| | | 'actualXML': sso_getWebcustomerInformation, // dopo le modifiche |
| | | 'is_editable': true // verrà modificato dalle modifiche massive? |
| | | }, |
| | | 'sso_getMSISDNDetails': { |
| | | 'defaultXML': sso_getMSISDNDetails, |
| | | 'actualXML': sso_getMSISDNDetails, |
| | | 'is_editable': true |
| | | }, |
| | | 'sso_getMSISDNList': { |
| | | 'defaultXML': sso_getMSISDNList, |
| | | 'actualXML': sso_getMSISDNList, |
| | | 'is_editable': true |
| | | }, |
| | | 'sso_getSelectedMSISDNDetails': { |
| | | 'defaultXML': sso_getSelectedMSISDNDetails, |
| | | 'actualXML': sso_getSelectedMSISDNDetails, |
| | | 'is_editable': true |
| | | }, |
| | | 'sso_getInfoActivationWSC': { |
| | | 'defaultXML': sso_getInfoActivationWSC, |
| | | 'actualXML': sso_getInfoActivationWSC, |
| | | 'is_editable': true |
| | | }, |
| | | 'picasso_getWebcustomerInformation': { |
| | | 'defaultXML': picasso_getWebcustomerInformation, |
| | | 'actualXML': picasso_getWebcustomerInformation, |
| | | 'is_editable': true |
| | | }, |
| | | } |
| | | |
| | | /** |
| | | * questa è la lista di campi mostrati nella sezione di update massivo |
| | | * per aggiungere un campo è necessario aggiungere un oggetto di questo tipo alla lista |
| | | * @type {({defaultValue: number, inputType: string, requireCheckbox: boolean, inputName: string}|{defaultValue: string, onChangeEditFields: {custcode: {editType: string}}, inputName: string}|{defaultValue: string, inputName: string}|{defaultValue: string, inputName: string}|{defaultValue: string, inputName: string})[]} |
| | | */ |
| | | let editableFields = [ |
| | | { |
| | | 'inputName': 'n_sim', |
| | | 'inputType': 'number', |
| | | "defaultValue": 1, |
| | | 'requireCheckbox': false, |
| | | }, |
| | | { |
| | | 'inputName': 'profile_user_name', |
| | | "defaultValue": "NAME FAKESSO | DUAL TM9 RIC 5.49275", |
| | | 'requireCheckbox': false, |
| | | }, |
| | | { |
| | | 'inputName': 'Custcode', |
| | | 'defaultValue': '5.49275', |
| | | 'onChangeEditFields': { |
| | | 'custcode': { |
| | | 'editType': 'copyMain' |
| | | } |
| | | } |
| | | }, |
| | | { |
| | | 'inputName': 'EmailAddress', |
| | | 'defaultValue': 'pippo@vola.it' |
| | | }, |
| | | { |
| | | 'inputName': 'Name', |
| | | 'defaultValue': 'Paola' |
| | | }, |
| | | { |
| | | 'inputName': 'ProfileIdentifier', |
| | | 'defaultValue': 'BUSINESS_EMPLOYEE' |
| | | }, |
| | | { |
| | | 'inputName': 'Surname', |
| | | 'defaultValue': 'Sandrelli' |
| | | }, |
| | | { |
| | | 'inputName': 'Username', |
| | | 'defaultValue': 'FAKE_SSO_', |
| | | 'onChangeEditFields': { |
| | | 'username': { |
| | | 'editType': 'copyMain' |
| | | }, |
| | | } |
| | | }, |
| | | { |
| | | 'inputName': 'IdPiano', |
| | | 'defaultValue': '2491' |
| | | }, |
| | | { |
| | | 'inputName': 'OMProductId', |
| | | 'defaultValue': '2156' // se uno di quelli dual risulto come dual già attivo |
| | | }, |
| | | { |
| | | 'inputName': 'tmCode', |
| | | 'defaultValue': '2491' |
| | | }, |
| | | { |
| | | 'inputName': 'sim_1', |
| | | 'defaultValue': '3464232371', |
| | | 'onChangeEditFields': { |
| | | 'MSISDN': { |
| | | 'editType': 'copyMain' |
| | | }, |
| | | 'selectedBoID': { |
| | | 'editType': 'copyMain' |
| | | } |
| | | } |
| | | } |
| | | // { |
| | | // 'inputName': 'Type_ID', |
| | | // 'defaultValue':'...', |
| | | // 'labelText': 'Type_ID ex. (2)' |
| | | // }, |
| | | // { |
| | | // 'inputName': 'providerID', |
| | | // 'defaultValue':'...' |
| | | // }, |
| | | // { |
| | | // 'inputName': 'selectedBoId', |
| | | // 'defaultValue':'...' |
| | | // // }, |
| | | // { |
| | | // 'inputName': 'selectedBoType', |
| | | // 'defaultValue':'...' |
| | | // }, |
| | | // { |
| | | // 'inputName': 'username', |
| | | // 'defaultValue':'...' |
| | | // }, |
| | | // { |
| | | // 'inputName': 'productId', |
| | | // 'defaultValue':'...' |
| | | // }, |
| | | // { |
| | | // 'inputName': 'productType', |
| | | // 'defaultValue':'...' |
| | | // }, |
| | | // { |
| | | // 'inputName': 'offerType', |
| | | // 'defaultValue':'...' |
| | | // }, |
| | | // { |
| | | // 'inputName': 'rewardID', |
| | | // 'defaultValue':'...' |
| | | // }, |
| | | // { |
| | | // 'inputName': 'groupTypeID', |
| | | // 'defaultValue':'...' |
| | | // } |
| | | ]; |
| | | |
| | | $(document).ready(function () { |
| | | addEditableFieldsInputs(); |
| | | $.each(xmlMethods, function (method_name) { |
| | | setDefaultXML(method_name); |
| | | if (xmlMethods[method_name]["is_editable"]) { |
| | | $(`input[name="is_editable_${method_name}"]`).prop("checked", true); |
| | | } |
| | | }) |
| | | serializeInputAndEditXML(true, true); |
| | | $('input[name="n_sim"]').on('change', displayNInputsForNSims); |
| | | $('input[name^="shouldReplace_"]').on('change', shouldReplaceOption); |
| | | $(document).on('change', '#edit-all input:not([type="checkbox"])', serializeInputAndEditXML); |
| | | $(document).on('click', '#edit-all button', serializeInputAndEditXML); |
| | | $('input[name^="is_editable_"]').on('change', changeEditOption); |
| | | $(document).on('input', 'textarea', validateTextarea); |
| | | $(document).on('click', 'button[id^="set_default_xml_"]', setDefaultXML); |
| | | $(document).on('click', 'button[name="show_result"]', showResult); |
| | | $(document).on('click', 'button[name="copy-result"]', copyToClipboard); |
| | | }) |
| | | |
| | | /** |
| | | * partendo dalla lista di sim aggiungo tutti i tag sim all' xml del metodo getMSISDNList |
| | | * @param sim_list |
| | | */ |
| | | function editGetMSISDNListXML(sim_list) { |
| | | let jsonMsisdn = $.xml2json(sso_getMSISDNList) |
| | | let MSISDNList = jsonMsisdn["getMDISDNList"]["msisdn_list"] |
| | | |
| | | sim_list.forEach(function (sim_obj) { |
| | | MSISDNList[sim_obj.inputName] = "" |
| | | }); |
| | | |
| | | const newXML = $.json2xml(jsonMsisdn) |
| | | let encodingValue = $.parseXML(sso_getMSISDNList)["xmlEncoding"] ?? null; |
| | | const xmlHead = `<?xml version="1.0" encoding="${encodingValue}"?>`; |
| | | xmlMethods.sso_getMSISDNList.actualXML = xmlHead + newXML |
| | | const formattedXML = vkbeautify.xml(xmlMethods.sso_getMSISDNList.actualXML) |
| | | $(`textarea#sso_getMSISDNList`).val(formattedXML) |
| | | } |
| | | |
| | | /** |
| | | * aggiungo una textarea per ogni sim per il metodo selezionato |
| | | * @param sim_list |
| | | * @param genericMethodName valori tipo -> "sso_getSelectedMSISDNDetails", "sso_getInfoActivationWSC" |
| | | */ |
| | | function add_N_areatext_sections(sim_list, genericMethodName) { |
| | | let additional_methods_wrapper = $('#' + "additional_methods_" + genericMethodName) |
| | | additional_methods_wrapper.empty() |
| | | |
| | | sim_list.forEach(function (sim_obj) { |
| | | let sim_code = sim_obj.inputName |
| | | let uniqueMethodName = sim_code + "_" + genericMethodName |
| | | xmlMethods[uniqueMethodName] = { |
| | | 'defaultXML': xmlMethods.sso_getSelectedMSISDNDetails.defaultXML, |
| | | 'actualXML': xmlMethods.sso_getSelectedMSISDNDetails.defaultXML, |
| | | 'is_editable': true |
| | | } |
| | | let formattedXML = vkbeautify.xml(xmlMethods[uniqueMethodName]["defaultXML"]) |
| | | let additionalMethodArea = ` |
| | | <div class="mb-3"> |
| | | <label for="${uniqueMethodName}" class="form-label text-danger font-weight-bolder">${uniqueMethodName}</label> |
| | | <label> |
| | | Questo metodo deve essere modificato dal replace massivo? |
| | | <input type="checkbox" name="is_editable_${uniqueMethodName}" class="check-control" checked> |
| | | </label> |
| | | <button id="set_default_xml_${uniqueMethodName}" class="btn btn-primary btn-sm m-0 mx-3"> |
| | | DEFAULT XML |
| | | </button> |
| | | <textarea class="form-control" id="${uniqueMethodName}" name="${uniqueMethodName}" rows="10">${formattedXML}</textarea> |
| | | <div id="${uniqueMethodName}_errorBox" class="text-danger font-size-sm"></div> |
| | | </div>`; |
| | | additional_methods_wrapper.append(additionalMethodArea) |
| | | } |
| | | ) |
| | | } |
| | | |
| | | /** |
| | | * questo metodo viene chiamato ogni volta che cambia in numero di sim e: |
| | | * |
| | | * genero gli oggetti input per ogni sim |
| | | * passo la lista di oggetti input a addEditableFieldsInput (aggiunti nella sezione modifica massiva) |
| | | * aggiorno l' xml del metodo getMSISDNList con le nuove sim |
| | | * aggiungo una nuova textarea di editing metodo per ogni sim per i metodi getSelectedMSISDNDetails getInfoActivationWSC |
| | | * @return void |
| | | */ |
| | | function displayNInputsForNSims() { |
| | | $("[id^=sim_][id$=_wrapper]:not(#sim_1_wrapper)").remove();//rimuovo i vecchi input |
| | | editableFields = editableFields.filter(field => !(field.inputName.startsWith('sim_') && (field.inputName !== "sim_1"))); |
| | | let numberOfSim = $(this).val(); |
| | | |
| | | if (!(0 < numberOfSim) || !(numberOfSim <= 6)) { |
| | | $(this).val(1) |
| | | numberOfSim = 1 |
| | | } |
| | | |
| | | const phone_number_sim_1 = $('input[name="sim_1"]').val() |
| | | let sim_list = []; |
| | | for (let sim_n = 2; sim_n <= numberOfSim; sim_n++) { |
| | | let inputObj = { |
| | | "inputName": "sim_" + sim_n, |
| | | "defaultValue": phone_number_sim_1 + sim_n//qui |
| | | }; |
| | | sim_list.push(inputObj) |
| | | editableFields.push(inputObj) |
| | | } |
| | | |
| | | addEditableFieldsInputs(sim_list) |
| | | //cambio actualXML di conseguenza inserendo dove necessario le chiavi aggiuntive di sim_1, sim_2, sim_3... |
| | | // lista di xml che devono essere cambiati: |
| | | // getMSISDNList (deve avere N tag sim_1, sim_2... ) |
| | | editGetMSISDNListXML(sim_list) |
| | | // getSelectedMSISDNDetails deve avere N textarea una per ogni sim |
| | | add_N_areatext_sections(sim_list, "sso_getSelectedMSISDNDetails") |
| | | // getInfoActivationWSC deve avere N textarea una per ogni sim |
| | | add_N_areatext_sections(sim_list, "sso_getInfoActivationWSC") |
| | | } |
| | | |
| | | /** |
| | | * inserisco la lista di input in pagina per l' editing massivo dei campi |
| | | * @param inputList |
| | | */ |
| | | function addEditableFieldsInputs(inputList = editableFields) { |
| | | let inputWrapper = $('#wrapper-input-list') |
| | | |
| | | inputList.forEach(function (inputObj, index) { |
| | | |
| | | let div = $("<div>", {id: inputObj["inputName"] + "_wrapper", class: "col mb-2"}); |
| | | let labelText = inputObj["labelText"] ?? inputObj["inputName"]; |
| | | let label = $("<label>", {for: inputObj["inputName"], class: "form-label"}).text(labelText); |
| | | |
| | | let checkbox = "" |
| | | let input = $("<input>", { |
| | | class: "form-control", |
| | | type: inputObj["inputType"] ?? "text", |
| | | value: inputObj["defaultValue"] ?? "", |
| | | name: inputObj["inputName"], |
| | | placeholder: inputObj["inputName"], |
| | | id: inputObj["inputName"] |
| | | }); |
| | | |
| | | if (inputObj.requireCheckbox !== false) { |
| | | checkbox = $("<input>", { //necessaria per verificare se l' input corrispondente deve essere modificato |
| | | class: "check-control mx-1", |
| | | type: "checkbox", |
| | | name: "shouldReplace_" + inputObj["inputName"] |
| | | }); |
| | | } |
| | | |
| | | |
| | | div.append(label); |
| | | div.append(checkbox); |
| | | div.append(input); |
| | | |
| | | inputWrapper.append(div); |
| | | }) |
| | | |
| | | } |
| | | |
| | | function showError(errorBox = $('#main_errorBox'), msg = "xml non formattato correttamente") { |
| | | errorBox.show() |
| | | const listItem = $('<li>', { |
| | | text: msg |
| | | }) |
| | | errorBox.append(listItem) |
| | | } |
| | | |
| | | /** |
| | | * in questo metodo voglio prendere tutti gli input nella lista editableField (lista degli input edit massivo) parametrizzarli |
| | | * una volta parametrizzati gli input partendo dalla struttura del vecchio xml (oggetto) |
| | | * sostituisco tutte le chiavi che combaciano con i nuovi valori |
| | | * @param alwaysEditable |
| | | * @param updateDefaultXML |
| | | */ |
| | | function serializeInputAndEditXML(alwaysEditable = false, updateDefaultXML = false) { |
| | | let serializedInputs = $('form#edit-all').serializeArray(); |
| | | |
| | | $.each(xmlMethods, function (methodName, methodObj) { |
| | | if ((methodObj.is_editable) || (alwaysEditable === true)) { |
| | | let encodingValue = $.parseXML(methodObj.actualXML)["xmlEncoding"] ?? null; |
| | | |
| | | let oldObj = $.xml2json(methodObj.actualXML) |
| | | let newXML = mergeAndConvertObjInXML(oldObj, serializedInputs) |
| | | |
| | | if (encodingValue !== null) { |
| | | const xmlHead = `<?xml version="1.0" encoding="${encodingValue}"?>`; |
| | | methodObj.actualXML = xmlHead + newXML |
| | | } else { |
| | | methodObj.actualXML = newXML |
| | | } |
| | | |
| | | if (updateDefaultXML === true) { |
| | | methodObj.defaultXML = newXML |
| | | } |
| | | |
| | | let isValid = $.isXmlValid(newXML) |
| | | |
| | | if (isValid) { |
| | | const formattedXML = vkbeautify.xml(newXML) |
| | | $(`textarea#${methodName}`).val(formattedXML.trim()) |
| | | } else { |
| | | $('#main_errorBox').empty() |
| | | showError($('#' + methodName + '_errorBox')) |
| | | } |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | |
| | | /** |
| | | * faccio merge di tutti i valori in newValues in finalObj mantenendo invariata la struttura di finalObj |
| | | * @param finalObj |
| | | * @param newValues |
| | | * @return {object} |
| | | */ |
| | | function mergeObjects(finalObj, newValues) { |
| | | let newProperties = newValues[Object.keys(newValues)[0]] |
| | | |
| | | $.each(newProperties, function (name, value) { |
| | | findAndReplaceKeyInObj(finalObj, name, value) |
| | | }) |
| | | return finalObj |
| | | } |
| | | |
| | | /** |
| | | * prendo l' obj passato e cerco all' interno di esso una chiave key (a qualsiasi livello di indentazione) |
| | | * se esiste la sostituisco con newValue |
| | | * @param obj |
| | | * @param key |
| | | * @param newValue |
| | | * @return {object} |
| | | */ |
| | | function findAndReplaceKeyInObj(obj, key, newValue) { |
| | | if (obj instanceof Object) { |
| | | if (obj.hasOwnProperty(key)) { |
| | | obj[key] = newValue; |
| | | return; |
| | | } |
| | | for (let subKey in obj) { |
| | | if (obj.hasOwnProperty(subKey) && obj[subKey] instanceof Object) { |
| | | findAndReplaceKeyInObj(obj[subKey], key, newValue); |
| | | } |
| | | } |
| | | } |
| | | return obj |
| | | } |
| | | |
| | | |
| | | /** |
| | | * group -> subEditFunction |
| | | * prendo il valore del main e do alla subKey lo stesso valore |
| | | */ |
| | | function copyMain() { |
| | | return (subFields, obj) => { |
| | | const mainName = subFields.inputName |
| | | return obj[mainName] //main value |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * la lista di metodi aggiuntivi che se presenti in subFields.onChangeEditFields invocano delle funzioni secondarie |
| | | * per il campo che è stato modificato |
| | | * |
| | | * ad esempio copyMain prende il valore del campo modificato e lo passa a tutti i subField |
| | | * quindi nel caso di sim_1 quando viene cambiato il valore viene passato anche a MSISDN selectedBoID perché si trovano sotto il campo principale sim_1 con edit_type copyMain |
| | | * @type {{copyMain: (function(*, *): *)}} |
| | | */ |
| | | let subEditFunctions = { |
| | | "copyMain": copyMain() |
| | | } |
| | | |
| | | /** |
| | | * se il campo principale ha delle funzioni onChangeEditFields chiamare le invoca |
| | | * @param subFields |
| | | * @param obj |
| | | * @return {object} |
| | | */ |
| | | function editSubFields(subFields, obj) { |
| | | const subChanges = subFields.onChangeEditFields |
| | | $.each(subChanges, function (subFieldName, subObj) { |
| | | if (subObj.editType in subEditFunctions) { |
| | | obj[subFieldName] = subEditFunctions[subObj.editType](subFields, obj) |
| | | } |
| | | }) |
| | | return obj |
| | | } |
| | | |
| | | /** |
| | | * prendo un oggetto complesso e lo semplifico mettendo tutte le chiavi sullo stesso livello |
| | | * @param objInputList |
| | | * @param mainKey |
| | | * @return {{object}} |
| | | */ |
| | | function simplifyObj(objInputList, mainKey = null) { |
| | | let newObj = {}; |
| | | |
| | | objInputList.forEach(function (objInput) { |
| | | let editableField = editableFields.find(fields => fields.inputName === objInput.name); |
| | | if (editableField) { |
| | | newObj[objInput.name] = objInput.value; |
| | | if (editableField.onChangeEditFields) { |
| | | newObj = editSubFields(editableField, newObj) |
| | | } |
| | | } |
| | | }) |
| | | |
| | | if (typeof mainKey == 'string') { |
| | | return { |
| | | [mainKey]: newObj |
| | | } |
| | | } |
| | | |
| | | return newObj; |
| | | } |
| | | |
| | | /** |
| | | * prendo i valori del vecchio oggetto xml li sostituisco con quelli nuovi e trasformo nuovamente l' obj xml in una stringa XML |
| | | * @param oldObj |
| | | * @param replacingValuesObj |
| | | * @return {string} |
| | | */ |
| | | function mergeAndConvertObjInXML(oldObj, replacingValuesObj) { |
| | | const mainKey = Object.keys(oldObj)[0] |
| | | let newObj = simplifyObj(replacingValuesObj, mainKey) |
| | | |
| | | let mergedObj = mergeObjects(oldObj, newObj) |
| | | return $.json2xml(mergedObj) |
| | | } |
| | | |
| | | /** |
| | | * modifico l' editabiltà massiva di un oggetto in xmlMethods in base al valore della sua checkbox |
| | | * se non è flaggata non modifico il metodo |
| | | */ |
| | | function changeEditOption() { |
| | | let input_name = $(this).attr('name') |
| | | const isEditable = $(this).is(':checked') |
| | | const methodName = input_name.split("is_editable_")[1] ?? "" |
| | | |
| | | if (xmlMethods[methodName]) { |
| | | xmlMethods[methodName]["is_editable"] = isEditable; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * setto i valori di default degli XML e li inserisco nelle rispettive textarea |
| | | * se methodName === null arriva da un input event quindi prendo dinamicamente il nome del metodo a cui settare default XML |
| | | * @param methodName |
| | | */ |
| | | function setDefaultXML(methodName = null) { |
| | | if (typeof methodName !== 'string') { // il caso in cui venga chiamato da un evento |
| | | let btn_id = $(this).attr('id') |
| | | methodName = btn_id.split("set_default_xml_")[1] ?? "" |
| | | } |
| | | |
| | | if (xmlMethods[methodName]) { |
| | | xmlMethods[methodName]["actualXML"] = xmlMethods[methodName]["defaultXML"] |
| | | const formattedXML = vkbeautify.xml(xmlMethods[methodName]["actualXML"]) |
| | | $(`textarea#${methodName}`).val(formattedXML.trim()) |
| | | |
| | | let errorBox = $('#' + methodName + '_errorBox'); |
| | | errorBox.empty() |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * abilita e disabilita il singolo input per la modifica massiva |
| | | * se la checkbox è flaggata il campo non verrà modificato |
| | | */ |
| | | function shouldReplaceOption() { |
| | | let checkbox_name = $(this).attr('name') |
| | | let checkbox_value = $(this).is(':checked') |
| | | const input_name = checkbox_name.split("shouldReplace_")[1] ?? "" |
| | | |
| | | if (checkbox_value) { |
| | | $(`input[name="${input_name}"]`).prop('disabled', true); |
| | | } else { |
| | | $(`input[name="${input_name}"]`).removeAttr('disabled'); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * verifico la validità di un valore XML nella textarea che invoca l' evento |
| | | */ |
| | | function validateTextarea() { |
| | | const xml = $(this).val() |
| | | const methodName = $(this).attr('id') |
| | | let errorBox = $('#' + methodName + '_errorBox'); |
| | | errorBox.empty() |
| | | if ((typeof xml === 'string') && (xml.trim() !== '')) { |
| | | let isValid = $.isXmlValid(xml); |
| | | if (isValid !== true) { |
| | | showError(errorBox, "errore nella validazione dell' xml " + isValid) |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * trasformo un oggetto JS in una stringa con sintassi array PHP |
| | | * @param profileObj |
| | | * @return {string} |
| | | */ |
| | | function buildArrayPHP(profileObj) { |
| | | const newJSON = JSON.stringify(profileObj) |
| | | const prettyJson = vkbeautify.json(newJSON) |
| | | let arrayPHP = prettyJson.replaceAll("{", "[") |
| | | arrayPHP = arrayPHP.replaceAll("}", "]") |
| | | arrayPHP = arrayPHP.replaceAll(":", "=>") |
| | | return '"n" => ' + arrayPHP |
| | | } |
| | | |
| | | /** |
| | | * partendo dall' oggetto profileObj sostituisco i valori dentro parametri[param] inserendo chiavi valore corrette |
| | | * chiave -> (sim_*) | valore -> (sim_*_method_name["actual"]) |
| | | * @param profileObj |
| | | * @param method_name |
| | | * @param param_key |
| | | * @return {*} |
| | | */ |
| | | function set_dynamic_keys_for_profile_method(profileObj, method_name, param_key) { |
| | | |
| | | profileObj["sso"][method_name]["parametri"][param_key] = {} |
| | | |
| | | const sso_method_name = `sso_${method_name}` |
| | | const main_phone_number = $(`input[name="sim_1"]`).val() |
| | | const XML_sim_1 = xmlMethods[sso_method_name]["actualXML"]; |
| | | let encodingValue = $.parseXML(XML_sim_1)["xmlEncoding"] ?? null; |
| | | const xmlHead = `<?xml version="1.0" encoding="${encodingValue}"?>`; |
| | | |
| | | profileObj["sso"][method_name]["parametri"][param_key][main_phone_number] = XML_sim_1 |
| | | |
| | | let sim_length = $('input[name="n_sim"]').val() |
| | | for (let index = 2; index <= sim_length; index++) { |
| | | let sim_code = 'sim_' + index |
| | | let phone_number = $(`input[name="${sim_code}"]`).val() |
| | | |
| | | let new_method_name = sim_code + "_" + sso_method_name |
| | | profileObj["sso"][method_name]["parametri"][param_key][phone_number] = xmlHead + xmlMethods[new_method_name]["actualXML"] |
| | | } |
| | | |
| | | return profileObj |
| | | } |
| | | |
| | | /** |
| | | * costruisco e mostro l' array (formato PHP) in pagina |
| | | */ |
| | | function showResult() { |
| | | let profileObj = { |
| | | "name": $('input[name="profile_user_name"]').val() ?? "inserire un nome utente", |
| | | "sso": { |
| | | "getWebcustomerInformation": |
| | | { |
| | | "parametri": { |
| | | "t": |
| | | { |
| | | "415F2B31F1C15FA45C9A6E1CBEB0ADF3": xmlMethods.sso_getWebcustomerInformation.actualXML |
| | | } |
| | | } |
| | | } |
| | | , |
| | | "getMSISDNDetails": |
| | | { |
| | | "parametri": { |
| | | "t": |
| | | { |
| | | "415F2B31F1C15FA45C9A6E1CBEB0ADF3": xmlMethods.sso_getMSISDNDetails.actualXML |
| | | } |
| | | } |
| | | } |
| | | , |
| | | "getMSISDNList": |
| | | { |
| | | "parametri": { |
| | | "t": |
| | | { |
| | | "415F2B31F1C15FA45C9A6E1CBEB0ADF3": xmlMethods.sso_getMSISDNList.actualXML |
| | | } |
| | | } |
| | | } |
| | | , |
| | | "getSelectedMSISDNDetails": |
| | | { |
| | | "parametri": { |
| | | "t": |
| | | { |
| | | "415F2B31F1C15FA45C9A6E1CBEB0ADF3": '<?xml version="1.0" encoding="iso-8859-1"?><getMDISDNDetails><CardType>Ric</CardType><SimSeniorityDate>15/02/2020</SimSeniorityDate><VodafoneOne>false</VodafoneOne><TopClub>false</TopClub><IdPiano>2491</IdPiano><SeniorityCluster></SeniorityCluster></getMDISDNDetails>' |
| | | }, |
| | | "ms": |
| | | { |
| | | '3464232371': '',//deve essere gestito con un foreach |
| | | '3464232372': ''//deve essere gestito con un foreach |
| | | } |
| | | } |
| | | } |
| | | , |
| | | "getInfoActivationWSC": |
| | | { |
| | | "parametri": { |
| | | "t": |
| | | { |
| | | "415F2B31F1C15FA45C9A6E1CBEB0ADF3": '<?xml version="1.0" encoding="iso-8859-1"?><getInfoActivationWSC><catalog><channel>SSO</channel><providerID></providerID><appidID></appidID><selectedBoId>3464232371</selectedBoId><selectedBoType>SIM_MOBILE</selectedBoType><username>FAKE_SSO_1</username><readOnlyCondition></readOnlyCondition><showcase><showcaseId>27</showcaseId><showcaseDescription>Vetrina Elite</showcaseDescription><tabs><tabPosition>1</tabPosition><tabDescription>new Corporate Infoattivazione Showcase</tabDescription><tabId>17</tabId><sections><collapsed>N</collapsed><sectionPosition>20</sectionPosition><sectionDescription>Tutti gli altri servizi</sectionDescription><sectionId>112</sectionId><products><productId>2583</productId><activationDate><time>1702249200000</time></activationDate><changeStateDate><time>1702249200000</time></changeStateDate><inheritanceRule></inheritanceRule><buyCost>0.0</buyCost><frequency></frequency><infoRecurringFees>N</infoRecurringFees><invertStatus>N</invertStatus><maxNumOfTry>0</maxNumOfTry><monopoliFlag>N</monopoliFlag><longDescription>Abilita la SIM alla distinzione del traffico personale da quello aziendale</longDescription><longName>Autorizzazione Dual</longName><productPosition>1</productPosition><numberOfUsedTry>0</numberOfUsedTry><numberOfTryAvailable>0</numberOfTryAvailable><OMProductId>2156</OMProductId><OMSource>CCBS</OMSource><productType>Service</productType><shortDescription>Abilita la SIM alla distinzione del traffico personale da quello aziendale</shortDescription><shortName>Autorizzazione Dual</shortName><productStateOnSim>ACTIVE</productStateOnSim><spyderId></spyderId><flagCommitment></flagCommitment><mm4MPromoId></mm4MPromoId><idJoin></idJoin><lastPaidFlag></lastPaidFlag><offerType></offerType><lastChargeZeroReason></lastChargeZeroReason></products><products><productId>3823</productId><activationDate><time>1702854000000</time></activationDate><changeStateDate><time>1702854000000</time></changeStateDate><inheritanceRule></inheritanceRule><buyCost>0.0</buyCost><frequency></frequency><infoRecurringFees>N</infoRecurringFees><invertStatus>N</invertStatus><maxNumOfTry>0</maxNumOfTry><monopoliFlag>N</monopoliFlag><longDescription></longDescription><longName>TM9 Smart Passport Extra Europa 1 Rinnovo Ricaricabile</longName><productPosition>1</productPosition><numberOfUsedTry>0</numberOfUsedTry><numberOfTryAvailable>0</numberOfTryAvailable><OMProductId>14644</OMProductId><OMSource>CCBS</OMSource><productType>Service</productType><shortDescription></shortDescription><shortName>TM9 Smart Passport Extra Europa 1 Rinnovo Ricaricabile</shortName><productStateOnSim>ACTIVE</productStateOnSim><spyderId></spyderId><flagCommitment></flagCommitment><mm4MPromoId></mm4MPromoId><idJoin></idJoin><lastPaidFlag></lastPaidFlag><offerType></offerType><lastChargeZeroReason></lastChargeZeroReason></products><____hashCodeCalc>false</____hashCodeCalc></sections><____hashCodeCalc>false</____hashCodeCalc></tabs><____hashCodeCalc>false</____hashCodeCalc></showcase><tmProduct><tmCode>2491</tmCode><description>TM9 Ricaricabile P30</description><activationDate><time>1696244062000</time></activationDate><____hashCodeCalc>false</____hashCodeCalc></tmProduct><convergentOffer><rewardID></rewardID><groupTypeID></groupTypeID><hungReasonID></hungReasonID><cli></cli><status></status></convergentOffer></catalog><operationStatus><status>OK</status><errCode>0</errCode><diagnostic>SUCCESS</diagnostic><____hashCodeCalc>false</____hashCodeCalc></operationStatus></getInfoActivationWSC>' |
| | | }, |
| | | "boID": |
| | | { |
| | | '3464232371': '',//deve essere gestito con un foreach |
| | | '3464232372': ''//deve essere gestito con un foreach |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "picasso": { |
| | | "getWebcustomerInformation": { |
| | | "parametri": { |
| | | "t": { |
| | | "415F2B31F1C15FA45C9A6E1CBEB0ADF3": xmlMethods.picasso_getWebcustomerInformation.actualXML |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | profileObj = set_dynamic_keys_for_profile_method(profileObj, "getSelectedMSISDNDetails", "ms") |
| | | profileObj = set_dynamic_keys_for_profile_method(profileObj, "getInfoActivationWSC", "boID") |
| | | const arrayPHP = buildArrayPHP(profileObj); |
| | | |
| | | $('#final_result pre').text(arrayPHP); |
| | | $("html, body").animate({scrollTop: $(document).height()}, "slow"); |
| | | $('#final_result').show(); |
| | | } |
| | | |
| | | function copyToClipboard() { |
| | | let textToCopy = $("#final_result_text").text(); |
| | | let tempInput = $("<textarea>"); |
| | | $("body").append(tempInput); |
| | | tempInput.val(textToCopy).select(); |
| | | document.execCommand("copy"); |
| | | tempInput.remove(); |
| | | } |