Commit e5bc68be by Tu Nombre

Guardado de snaper

1 parent 4e1e29ea
function CargarLista() {
//API KET
const requestData = {
"token": "sdñÑREgerqw3$E#]ÑgdfbversdfFfew435",
"url": "https://hgt.hgt.com.ar/api_rto/diaria",
......
......@@ -5,20 +5,23 @@ window.allFieldsToJson = function allFieldsToJson() {
fields.forEach(field => {
const key = field.name;// || field.id; // Usa el nombre del campo, o su ID si no tiene nombre
const value = field.value;
const ignorar = ["?","","---",false,"-",]
if (!ignorar.includes(value)){
// Si la clave ya existe (por ejemplo, en caso de checkboxes o radios con el mismo nombre)
if (data.hasOwnProperty(key)) {
if (Array.isArray(data[key])) {
data[key].push(value);
} else {
data[key] = [data[key], value];
}
//if (Array.isArray(data[key])) {
// data[key].push(value);
//} else {
// data[key] = [data[key], value];
//}
} else {
data[key] = value;
}
}
});
return JSON.stringify(data);
//return JSON.stringify(data);
return data;
}
window.populateFieldsFromJson = function populateFieldsFromJson(data) {
......@@ -65,3 +68,44 @@ window.watchForChanges = function watchForChanges() {
});
}
window.Snapeador = function Sanapeador(){
const valor = document.getElementById('snapear').value;
if (valor === "0"){
return;
}
const data = allFieldsToJson()
this.SubirSnap(data)
document.getElementById('snapear').value = 0
}
function SubirSnap(data) {
//API KET
const requestData = {
"token": "sdñÑREgerqw3$E#]ÑgdfbversdfFfew435",
//"url": "https://hgt.hgt.com.ar/api_rto/snaper",
"url": "https://validacion.hgtsa.com.ar/api_rto/snaper",
"clear": true,
"params": {
"ApiKey": "sdñÑREgerqw3$E#]ÑgdfbversdfFfew435",
"id_cent": "61",
"data_snap": data
}
};
fetch('https://api.hgt.com.ar/redirect', {
method: 'POST',
headers: {
'Accept': 'application/json',
"Content-Type": "application/json"
},
body: JSON.stringify(requestData)
})
.then(response => response.json())
.then(data => {
//createHistoricoList(data);
})
.catch(error => {
console.error('Error:', error);
});
};
......@@ -21,7 +21,9 @@ function agregarCampoAObjetoID(nombreCampo,reportCampo, objeto) {
function Reportar (){
///ACA hay que determinar el template
const template = document.getElementById('ReporteInspeccion');
window.Snapeador();
generarReporteTemplate(template.value)
}
function generarReporteTemplate (template) {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!