mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
arraglado bug tarifas cliente
This commit is contained in:
@ -267,26 +267,36 @@ class tarifasClienteView {
|
||||
|
||||
#changePlantilla() {
|
||||
|
||||
self = this;
|
||||
const self = this;
|
||||
const data = $('#plantillas').select2('data');
|
||||
if (data.length > 0) {
|
||||
const id = data[0].id;
|
||||
new Ajax(
|
||||
'/clienteprecios/changeplantilla',
|
||||
{
|
||||
'cliente_id': self.clienteId,
|
||||
'plantilla_id': id,
|
||||
[this.csrf_token]: this.csrf_hash
|
||||
},
|
||||
{},
|
||||
() => {
|
||||
self.tableTarifas.table.clearPipeline();
|
||||
self.tableTarifas.table.draw();
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
}
|
||||
).post();
|
||||
if (data[0].id == 0) {
|
||||
self.#borrarPlantillaTarifa(self.clienteId);
|
||||
self.tableTarifas.table.clearPipeline();
|
||||
self.tableTarifas.table.draw();
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
const id = data[0].id;
|
||||
new Ajax(
|
||||
'/clienteprecios/changeplantilla',
|
||||
{
|
||||
'cliente_id': self.clienteId,
|
||||
'plantilla_id': id,
|
||||
[this.csrf_token]: this.csrf_hash
|
||||
},
|
||||
{},
|
||||
() => {
|
||||
self.tableTarifas.table.clearPipeline();
|
||||
self.tableTarifas.table.draw();
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
}
|
||||
).post();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -15,6 +15,8 @@ class PlantillasTarifasClienteForm {
|
||||
this.csrf_token = getToken();
|
||||
this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
|
||||
|
||||
this.btnApply = $('#btnApply');
|
||||
|
||||
this.tablePlantilla = null;
|
||||
this.deleteModal = null;
|
||||
|
||||
@ -22,6 +24,7 @@ class PlantillasTarifasClienteForm {
|
||||
this.ajaxEditor = null;
|
||||
|
||||
this.changedRows = [];
|
||||
this.deletedRows = [];
|
||||
}
|
||||
|
||||
init() {
|
||||
@ -50,7 +53,8 @@ class PlantillasTarifasClienteForm {
|
||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
|
||||
cancelTrigger: row.find('span.cancel')[0],
|
||||
submitTrigger: row.find('span.edit')[0],
|
||||
submit: 'allIfChanged'
|
||||
submit: 'allIfChanged',
|
||||
drawType: 'none'
|
||||
}
|
||||
);
|
||||
});
|
||||
@ -123,47 +127,14 @@ class PlantillasTarifasClienteForm {
|
||||
|
||||
this.ajaxEditor.init();
|
||||
|
||||
|
||||
this.localEditor.editor.on('postEdit', function (e, json, data) {
|
||||
|
||||
/*console.log(self.tablePlantilla.table.row(0).data());
|
||||
self.tablePlantilla.table.rows().every( function ( rowIdx ) {
|
||||
var rowData = this.data();
|
||||
if(rowData.id == data.id){
|
||||
self.tablePlantilla.table.row(rowIdx).data({
|
||||
id: data.id,
|
||||
tipo: 'interior', // 'interior', 'cubierta', etc.
|
||||
tipo_maquina: 'toner', // 'toner', 'inkjet'
|
||||
tipo_impresion: 'negro', // 'negro', 'color', etc.
|
||||
tiempo_min: 0,
|
||||
tiempo_max: 1,
|
||||
precio_hora: 1,
|
||||
margen: 100,
|
||||
user_updated: 'yo',
|
||||
updated_at: '200000'
|
||||
}).draw(false);
|
||||
}
|
||||
})
|
||||
//self.tablePlantilla.table.row(0).data(data2).draw(false);
|
||||
|
||||
/*self.tablePlantilla.table.row(0).data({
|
||||
id: 1,
|
||||
tipo: 'interior', // 'interior', 'cubierta', etc.
|
||||
tipo_maquina: 'toner', // 'toner', 'inkjet'
|
||||
tipo_impresion: 'negro', // 'negro', 'color', etc.
|
||||
tiempo_min: 0,
|
||||
tiempo_max: 1,
|
||||
precio_hora: 1,
|
||||
margen: 100,
|
||||
user_updated: 'yo',
|
||||
updated_at: '200000'
|
||||
}).draw(false);*/
|
||||
let row = self.tablePlantilla.table.row('#' + data.id);
|
||||
|
||||
if (row.length) {
|
||||
console.log('Data:', data)
|
||||
|
||||
let rowData = row.data();
|
||||
console.log('Datos de la fila:', rowData);
|
||||
|
||||
|
||||
// Actualizar los datos de la fila
|
||||
self.tablePlantilla.table.row('#' + data.id).data({
|
||||
id: data.id,
|
||||
@ -174,41 +145,15 @@ class PlantillasTarifasClienteForm {
|
||||
tiempo_max: data.tiempo_max,
|
||||
precio_hora: data.precio_hora,
|
||||
margen: "150",
|
||||
user_updated_id: data.user_updated_id,
|
||||
user_updated_id: data.user_updated,
|
||||
user_updated: data.user_updated,
|
||||
updated_at: data.updated_at
|
||||
}).draw(true); // Usar invalidate() si es necesario
|
||||
rowData = row.data();
|
||||
console.log('Datos de la fila actualizados:', rowData);
|
||||
} else {
|
||||
console.warn('No se encontró la fila con ID row_' + data.id);
|
||||
}
|
||||
/*
|
||||
if (row.length > 0) {
|
||||
self.tablePlantilla.table.row(row[0]).data({
|
||||
id: data.id,
|
||||
tipo: data.tipo, // 'interior', 'cubierta', etc.
|
||||
tipo_maquina: data.tipo_maquina, // 'toner', 'inkjet'
|
||||
tipo_impresion: data.tipo_impresion, // 'negro', 'color', etc.
|
||||
tiempo_min: data.tiempo_min,
|
||||
tiempo_max: data.tiempo_max,
|
||||
precio_hora: data.precio_hora,
|
||||
margen: data.margen,
|
||||
user_updated: data.user_updated,
|
||||
updated_at: data.updated_at
|
||||
}).invalidate().draw(false);
|
||||
|
||||
console.log('---');
|
||||
console.log(self.tablePlantilla.table.row(row[0]).data())
|
||||
}*/
|
||||
});
|
||||
|
||||
|
||||
|
||||
// check if this id exists
|
||||
// check if this id exists
|
||||
if (!self.changedRows.includes(data.id))
|
||||
self.changedRows.push(data.id);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user