mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'fix/plantillas_clientes' into 'main'
arreglados bugs en plantillas cliente See merge request jjimenez/safekat!427
This commit is contained in:
@ -418,6 +418,7 @@ $routes->resource('clienteplantillaprecios', ['namespace' => 'App\Controllers\Cl
|
|||||||
$routes->group('clienteplantillaprecioslineas', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
|
$routes->group('clienteplantillaprecioslineas', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
|
||||||
$routes->post('datatable', 'Clienteplantillaprecioslineas::datatable', ['as' => 'dataTableOfClientesplantillaprecioslineas']);
|
$routes->post('datatable', 'Clienteplantillaprecioslineas::datatable', ['as' => 'dataTableOfClientesplantillaprecioslineas']);
|
||||||
$routes->post('datatable_editor', 'Clienteplantillaprecioslineas::datatable_editor', ['as' => 'editorOfClienteplantillaprecioslineas']);
|
$routes->post('datatable_editor', 'Clienteplantillaprecioslineas::datatable_editor', ['as' => 'editorOfClienteplantillaprecioslineas']);
|
||||||
|
$routes->post('getrows', 'Clienteplantillaprecioslineas::getStoredRows', ['as' => 'getStoredRowsOfClienteplantillaprecioslineas']);
|
||||||
});
|
});
|
||||||
$routes->resource('clienteplantillaprecioslineas', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'clienteplantillaprecioslineas', 'except' => 'show,new,create,update']);
|
$routes->resource('clienteplantillaprecioslineas', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'clienteplantillaprecioslineas', 'except' => 'show,new,create,update']);
|
||||||
|
|
||||||
|
|||||||
@ -120,6 +120,26 @@ class Clienteplantillaprecioslineas extends \App\Controllers\BaseResourceControl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getStoredRows()
|
||||||
|
{
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
$reqData = $this->request->getPost();
|
||||||
|
$plantilla_id = $reqData['plantilla_id'] ?? 0;
|
||||||
|
|
||||||
|
$resourceData = $this->model->getResource([], $plantilla_id);
|
||||||
|
$resourceData = $resourceData->get()->getResultObject();
|
||||||
|
|
||||||
|
return $this->respond(Collection::datatable(
|
||||||
|
$resourceData,
|
||||||
|
$this->model->getResource([], $plantilla_id)->countAllResults(),
|
||||||
|
$this->model->getResource([], $plantilla_id)->countAllResults()
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function datatable_editor() {
|
public function datatable_editor() {
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
@ -178,26 +198,6 @@ class Clienteplantillaprecioslineas extends \App\Controllers\BaseResourceControl
|
|||||||
),
|
),
|
||||||
|
|
||||||
)
|
)
|
||||||
->validator(function ($editor, $action, $data) {
|
|
||||||
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT) {
|
|
||||||
foreach ($data['data'] as $pkey => $values) {
|
|
||||||
// Si no se quiere borrar...
|
|
||||||
if ($data['data'][$pkey]['is_deleted'] != 1) {
|
|
||||||
$process_data['tiempo_min'] = $data['data'][$pkey]['tiempo_min'];
|
|
||||||
$process_data['tiempo_max'] = $data['data'][$pkey]['tiempo_max'];
|
|
||||||
$process_data['tipo'] = $data['data'][$pkey]['tipo'];
|
|
||||||
$process_data['tipo_maquina'] = $data['data'][$pkey]['tipo_maquina'];
|
|
||||||
$process_data['tipo_impresion'] = $data['data'][$pkey]['tipo_impresion'];
|
|
||||||
|
|
||||||
$response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['plantilla_id']);
|
|
||||||
// No se pueden duplicar valores al crear o al editar
|
|
||||||
if (!empty($response)) {
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->on('preCreate', function ($editor, &$values) {
|
->on('preCreate', function ($editor, &$values) {
|
||||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||||
$editor
|
$editor
|
||||||
|
|||||||
@ -160,7 +160,7 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
|
|||||||
else {
|
else {
|
||||||
$builder->groupStart();
|
$builder->groupStart();
|
||||||
foreach ($search as $col_search) {
|
foreach ($search as $col_search) {
|
||||||
if ($col_search[1] > 0 && $col_search[0] < 4)
|
if ($col_search[0] > 0 && $col_search[0] < 4)
|
||||||
$builder->where(self::SORTABLE[$col_search[0]], $col_search[2]);
|
$builder->where(self::SORTABLE[$col_search[0]], $col_search[2]);
|
||||||
else
|
else
|
||||||
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
|
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
|
||||||
|
|||||||
@ -7,8 +7,10 @@ class ModalYesNo {
|
|||||||
this.btnCancelId = alias !== "" ? `btnCancelModal-${alias}` : 'btnCancelModal';
|
this.btnCancelId = alias !== "" ? `btnCancelModal-${alias}` : 'btnCancelModal';
|
||||||
this.btnConfirmId = alias !== "" ? `btnYesModal-${alias}` : 'btnYesModal';
|
this.btnConfirmId = alias !== "" ? `btnYesModal-${alias}` : 'btnYesModal';
|
||||||
|
|
||||||
|
this.callback = () => {};
|
||||||
|
|
||||||
this.modalHtml = `
|
this.modalHtml = `
|
||||||
<div class="modal fade" id="${this.modalId}" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="${this.modalId}Label" aria-hidden="true">
|
<div class="modal modalYesNo fade" id="${this.modalId}" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="${this.modalId}Label" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-dialog-centered">
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
@ -30,13 +32,22 @@ class ModalYesNo {
|
|||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
// Insertar el modal en el body del documento si no existe
|
// Insertar el modal en el body del documento si no existe
|
||||||
if (!document.getElementById(this.modalId)) {
|
if (!document.getElementById(this.modalId)) {
|
||||||
document.body.insertAdjacentHTML('beforeend', this.modalHtml);
|
document.body.insertAdjacentHTML('beforeend', this.modalHtml);
|
||||||
}
|
}
|
||||||
document.getElementById(this.btnCancelId).addEventListener('click', () => {
|
$('#' + this.btnCancelId).on('click', () => {
|
||||||
const modal = new bootstrap.Modal(document.getElementById(this.modalId));
|
|
||||||
modal.hide();
|
$('#' + self.modalId).modal('hide');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#' + this.btnConfirmId).on('click', () => {
|
||||||
|
|
||||||
|
self.callback(); // Llamar al callback que el usuario haya proporcionado
|
||||||
|
$('#' + self.modalId).modal('hide');
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,21 +58,15 @@ class ModalYesNo {
|
|||||||
// Método para mostrar el modal
|
// Método para mostrar el modal
|
||||||
show(callback) {
|
show(callback) {
|
||||||
|
|
||||||
// Mostrar el modal usando Bootstrap
|
this.callback = callback;
|
||||||
const modal = new bootstrap.Modal(document.getElementById(this.modalId));
|
|
||||||
modal.show();
|
|
||||||
|
|
||||||
// Configurar el evento de confirmación de eliminación
|
// Mostrar el modal usando Bootstrap
|
||||||
document.getElementById(this.btnConfirmId).addEventListener('click', () => {
|
$('#' + this.modalId).modal('show');
|
||||||
callback(); // Llamar al callback que el usuario haya proporcionado
|
|
||||||
modal.hide(); // Cerrar el modal
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Método para ocultar el modal si es necesario
|
// Método para ocultar el modal si es necesario
|
||||||
hide() {
|
hide() {
|
||||||
const modal = new bootstrap.Modal(document.getElementById(this.modalId));
|
$('#' + this.modalId).modal('hide');
|
||||||
modal.hide();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -93,7 +93,7 @@ let Table = function (
|
|||||||
autoWidth: true,
|
autoWidth: true,
|
||||||
responsive: true,
|
responsive: true,
|
||||||
scrollX: true,
|
scrollX: true,
|
||||||
stateSave: true,
|
stateSave: false,
|
||||||
lengthMenu: [5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500],
|
lengthMenu: [5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500],
|
||||||
order: order,
|
order: order,
|
||||||
orderCellsTop: true,
|
orderCellsTop: true,
|
||||||
|
|||||||
@ -23,6 +23,11 @@ class PlantillasTarifasClienteForm {
|
|||||||
|
|
||||||
this.localEditor = null;
|
this.localEditor = null;
|
||||||
this.ajaxEditor = null;
|
this.ajaxEditor = null;
|
||||||
|
|
||||||
|
this.rows = [];
|
||||||
|
this.rowsDeleted = [];
|
||||||
|
this.rowsEdited = [];
|
||||||
|
this.rowsCreated = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@ -42,6 +47,20 @@ class PlantillasTarifasClienteForm {
|
|||||||
|
|
||||||
this.#initTable();
|
this.#initTable();
|
||||||
|
|
||||||
|
new Ajax(
|
||||||
|
'/clienteplantillaprecioslineas/getrows',
|
||||||
|
{
|
||||||
|
[this.csrf_token]: this.csrf_hash,
|
||||||
|
plantilla_id: this.plantillaId
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
(response) => {
|
||||||
|
self.rows = response.data;
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
).post();
|
||||||
|
|
||||||
// Editar en linea la fila
|
// Editar en linea la fila
|
||||||
this.tablePlantilla.table.on('click', 'tbody span.edit', function (e) {
|
this.tablePlantilla.table.on('click', 'tbody span.edit', function (e) {
|
||||||
@ -62,10 +81,38 @@ class PlantillasTarifasClienteForm {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
this.tablePlantilla.table.on('draw.dt', function (e) {
|
||||||
|
self.tablePlantilla.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var row = this.data();
|
||||||
|
if (self.rowsDeleted.includes(row.id)) {
|
||||||
|
$('#' + row.id).css('background-color', '#ffcccc');
|
||||||
|
$('#' + row.id).addClass('row-deleted');
|
||||||
|
$('#' + row.id).find('span.edit').addClass('d-none');
|
||||||
|
$('#' + row.id).find('.btn-delete-' + self.tablePlantilla.getAlias()).addClass('d-none');
|
||||||
|
}
|
||||||
|
else if (self.rowsEdited.includes(row.id)) {
|
||||||
|
$('#' + row.id).css('background-color', '#E9DEAC');
|
||||||
|
$('#' + row.id).addClass('row-edited');
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (row.id === '') {
|
||||||
|
self.tablePlantilla.table.row(rowIdx).nodes().to$().addClass('row-created');
|
||||||
|
self.tablePlantilla.table.row(rowIdx).nodes().to$().css('background-color', '#C9E2C7');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
this.tablePlantilla.table.on('click', '.btn-delete-' + this.tablePlantilla.getAlias(), function (e) {
|
this.tablePlantilla.table.on('click', '.btn-delete-' + this.tablePlantilla.getAlias(), function (e) {
|
||||||
|
|
||||||
self.tablePlantilla.table.settings()[0].oFeatures.bServerSide = false;
|
self.tablePlantilla.table.settings()[0].oFeatures.bServerSide = false;
|
||||||
|
|
||||||
|
|
||||||
|
if ($(this).closest('tr').hasClass('row-created')) {
|
||||||
|
$(this).closest('tr').remove();
|
||||||
|
}
|
||||||
|
|
||||||
const row = $(this).attr('data-id');
|
const row = $(this).attr('data-id');
|
||||||
self.btnApply.removeClass('d-none');
|
self.btnApply.removeClass('d-none');
|
||||||
self.btnUndo.removeClass('d-none');
|
self.btnUndo.removeClass('d-none');
|
||||||
@ -76,6 +123,9 @@ class PlantillasTarifasClienteForm {
|
|||||||
// find closest span.edit
|
// find closest span.edit
|
||||||
$('#' + row).find('span.edit').addClass('d-none');
|
$('#' + row).find('span.edit').addClass('d-none');
|
||||||
$('#' + row).find('.btn-delete-' + self.tablePlantilla.getAlias()).addClass('d-none');
|
$('#' + row).find('.btn-delete-' + self.tablePlantilla.getAlias()).addClass('d-none');
|
||||||
|
|
||||||
|
if (self.rowsDeleted.indexOf(row) == -1)
|
||||||
|
self.rowsDeleted.push(row);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.btnApply.on('click', function (e) {
|
this.btnApply.on('click', function (e) {
|
||||||
@ -121,7 +171,7 @@ class PlantillasTarifasClienteForm {
|
|||||||
{
|
{
|
||||||
name: "id",
|
name: "id",
|
||||||
type: "readonly",
|
type: "readonly",
|
||||||
def: new Date().toISOString().slice(0, 19).replace('T', ' ')
|
def: ''
|
||||||
}, {
|
}, {
|
||||||
name: "tipo",
|
name: "tipo",
|
||||||
type: "select",
|
type: "select",
|
||||||
@ -192,6 +242,10 @@ class PlantillasTarifasClienteForm {
|
|||||||
|
|
||||||
const row = self.tablePlantilla.table.row('#' + json.data[0].id);
|
const row = self.tablePlantilla.table.row('#' + json.data[0].id);
|
||||||
|
|
||||||
|
if (row.length) {
|
||||||
|
self.rowsCreated.push(row);
|
||||||
|
}
|
||||||
|
|
||||||
let rowNode = row.node();
|
let rowNode = row.node();
|
||||||
|
|
||||||
$(rowNode).addClass('row-created');
|
$(rowNode).addClass('row-created');
|
||||||
@ -209,6 +263,9 @@ class PlantillasTarifasClienteForm {
|
|||||||
|
|
||||||
let rowNode = row.node();
|
let rowNode = row.node();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Añadir una clase usando jQuery
|
// Añadir una clase usando jQuery
|
||||||
if (!$(rowNode).hasClass('row-created')) {
|
if (!$(rowNode).hasClass('row-created')) {
|
||||||
$(rowNode).addClass('row-edited');
|
$(rowNode).addClass('row-edited');
|
||||||
@ -234,6 +291,15 @@ class PlantillasTarifasClienteForm {
|
|||||||
|
|
||||||
self.btnApply.removeClass('d-none');
|
self.btnApply.removeClass('d-none');
|
||||||
self.btnUndo.removeClass('d-none');
|
self.btnUndo.removeClass('d-none');
|
||||||
|
|
||||||
|
|
||||||
|
// modificar la fila en rows que tenga el mismo id
|
||||||
|
let index = self.rows.findIndex(r => r.id == data.id);
|
||||||
|
if (index != -1) {
|
||||||
|
self.rows[index] = data;
|
||||||
|
}
|
||||||
|
if (self.rowsEdited.indexOf(row.id) == -1)
|
||||||
|
self.rowsEdited.push(row.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -251,12 +317,8 @@ class PlantillasTarifasClienteForm {
|
|||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
const deletedRows = self.tablePlantilla.table.rows('.row-deleted').data().toArray();
|
if (this.rowsEdited.length != 0) {
|
||||||
const editedRows = self.tablePlantilla.table.rows('.row-edited').data().toArray();
|
let error = self.#checkInterval(self.rowsEdited);
|
||||||
const createdRows = self.tablePlantilla.table.rows('.row-created').data().toArray();
|
|
||||||
|
|
||||||
if (editedRows.length != 0) {
|
|
||||||
let error = self.#checkInterval(editedRows);
|
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error == 1) {
|
if (error == 1) {
|
||||||
popErrorAlert('Hay filas EDITADAS con el tiempo mínimo mayor que el tiempo máximo');
|
popErrorAlert('Hay filas EDITADAS con el tiempo mínimo mayor que el tiempo máximo');
|
||||||
@ -268,8 +330,8 @@ class PlantillasTarifasClienteForm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createdRows.length != 0) {
|
if (this.rowsCreated.length != 0) {
|
||||||
let error = self.#checkInterval(editedRows);
|
let error = self.#checkInterval(self.rowsCreated.map(row => row.data()));
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error == 1) {
|
if (error == 1) {
|
||||||
popErrorAlert('Hay filas CREADAS con el tiempo mínimo mayor que el tiempo máximo');
|
popErrorAlert('Hay filas CREADAS con el tiempo mínimo mayor que el tiempo máximo');
|
||||||
@ -281,9 +343,9 @@ class PlantillasTarifasClienteForm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deletedRows.length != 0) {
|
if (this.rowsDeleted.length != 0) {
|
||||||
|
|
||||||
let rowIds = deletedRows.map(row => '#' + row.id);
|
let rowIds = self.rowsDeleted.map(row => '#' + row);
|
||||||
|
|
||||||
// Iterar sobre cada fila y actualizar los campos necesarios
|
// Iterar sobre cada fila y actualizar los campos necesarios
|
||||||
self.ajaxEditor.editor
|
self.ajaxEditor.editor
|
||||||
@ -297,13 +359,15 @@ class PlantillasTarifasClienteForm {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (editedRows.length != 0) {
|
if (this.rowsEdited.length != 0) {
|
||||||
|
|
||||||
let rowIds = editedRows.map(row => '#' + row.id);
|
let rowIds = this.rowsEdited.map(row => '#' + this.tablePlantilla.table.row(row).data().id);
|
||||||
let updatedFields = {};
|
let updatedFields = {};
|
||||||
|
|
||||||
// Iterar sobre las filas editadas y construir el objeto actualizado
|
// Iterar sobre las filas editadas y construir el objeto actualizado
|
||||||
editedRows.forEach(row => {
|
this.rowsEdited.forEach(row2Edit => {
|
||||||
|
|
||||||
|
const row = this.tablePlantilla.table.row(row2Edit).data();
|
||||||
|
|
||||||
updatedFields['tipo'] = updatedFields['tipo'] || {};
|
updatedFields['tipo'] = updatedFields['tipo'] || {};
|
||||||
updatedFields['tipo'][row.id] = row.tipo;
|
updatedFields['tipo'][row.id] = row.tipo;
|
||||||
@ -332,13 +396,13 @@ class PlantillasTarifasClienteForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (createdRows.length != 0) {
|
if (this.rowsCreated.length != 0) {
|
||||||
|
|
||||||
let updatedFields = {};
|
let updatedFields = {};
|
||||||
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
// Iterar sobre las filas editadas y construir el objeto actualizado
|
// Iterar sobre las filas editadas y construir el objeto actualizado
|
||||||
createdRows.forEach(row => {
|
this.rowsCreated.forEach(row => {
|
||||||
|
|
||||||
updatedFields['id'] = updatedFields['id'] || {};
|
updatedFields['id'] = updatedFields['id'] || {};
|
||||||
updatedFields['id'][row.id] = count;
|
updatedFields['id'][row.id] = count;
|
||||||
@ -370,48 +434,68 @@ class PlantillasTarifasClienteForm {
|
|||||||
count++;
|
count++;
|
||||||
});
|
});
|
||||||
|
|
||||||
self.ajaxEditor.editor.create(createdRows.length, false).multiSet(updatedFields)
|
self.ajaxEditor.editor.create(self.rowsCreated.length, false).multiSet(updatedFields)
|
||||||
.submit()
|
.submit()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deletedRows.length != 0 || editedRows.length != 0 || createdRows.length != 0) {
|
|
||||||
|
|
||||||
new Ajax(
|
new Ajax(
|
||||||
'/clienteprecios/update',
|
'/clienteprecios/update',
|
||||||
{
|
{
|
||||||
[self.csrf_token]: self.csrf_hash,
|
[self.csrf_token]: self.csrf_hash,
|
||||||
plantilla_id: self.plantillaId
|
plantilla_id: self.plantillaId
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
() => {
|
() => {
|
||||||
window.location.reload();
|
self.tablePlantilla.table.settings()[0].oFeatures.bServerSide = true;
|
||||||
},
|
|
||||||
(error) => {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
).post();
|
|
||||||
|
|
||||||
}
|
new Ajax(
|
||||||
|
'/clienteplantillaprecioslineas/getrows',
|
||||||
|
{
|
||||||
|
[self.csrf_token]: self.csrf_hash,
|
||||||
|
plantilla_id: self.plantillaId
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
(response) => {
|
||||||
|
self.rows = response.data;
|
||||||
|
self.rowsDeleted = [];
|
||||||
|
self.rowsEdited = [];
|
||||||
|
self.rowsCreated = [];
|
||||||
|
|
||||||
|
self.tablePlantilla.table.clearPipeline();
|
||||||
|
self.tablePlantilla.table.draw(true);
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.log(error);
|
||||||
|
}).post();
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
).post();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#checkInterval(rows) {
|
#checkInterval(rows) {
|
||||||
|
|
||||||
// obtener todas las filas de la tabla que no tengan la clase row-deleted
|
for (let row of this.rows) {
|
||||||
let rowsNotDeletedDT = this.tablePlantilla.table.rows(':not(.row-deleted)').nodes().toArray();
|
let rowData = this.tablePlantilla.table.row(row).data();
|
||||||
for (let row of rowsNotDeletedDT) {
|
for (let row2Check of rows) {
|
||||||
let rowData = this.tablePlantilla.table.row(row).data();
|
let checkRow = this.tablePlantilla.table.row(row2Check).data();
|
||||||
for (let rowEdited of rows) {
|
if (checkRow.tiempo_min > checkRow.tiempo_max) {
|
||||||
if (rowEdited.tiempo_min > rowEdited.tiempo_max) {
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (rowData.tipo == rowEdited.tipo && rowData.tipo_maquina == rowEdited.tipo_maquina && rowData.tipo_impresion == rowEdited.tipo_impresion) {
|
if (checkRow.id == rowData.id) continue;
|
||||||
|
if (rowData.tipo == checkRow.tipo && rowData.tipo_maquina == checkRow.tipo_maquina && rowData.tipo_impresion == checkRow.tipo_impresion) {
|
||||||
// check overlapping intervals
|
// check overlapping intervals
|
||||||
if (rowEdited.tiempo_min >= rowData.tiempo_min || rowEdited.tiempo_min <= rowData.tiempo_max) {
|
if (Math.max(checkRow.tiempo_max, rowData.tiempo_max) - Math.min(checkRow.tiempo_min, rowData.tiempo_min)
|
||||||
|
<= Math.min(checkRow.tiempo_max - checkRow.tiempo_min) + Math.min(rowData.tiempo_max - rowData.tiempo_min))
|
||||||
return 2;
|
return 2;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -518,12 +602,38 @@ class PlantillasTarifasClienteForm {
|
|||||||
selector.append('<option value="sobrecubierta">Sobrecubierta</option>');
|
selector.append('<option value="sobrecubierta">Sobrecubierta</option>');
|
||||||
|
|
||||||
selector.on('change', function () {
|
selector.on('change', function () {
|
||||||
var val = $.fn.dataTable.util.escapeRegex(
|
|
||||||
$(this).val()
|
if (!self.tablePlantilla.table.settings()[0].oFeatures.bServerSide) {
|
||||||
);
|
|
||||||
self.tablePlantilla.table.column(i).search(val).draw();
|
var val = $(this).val(); // El valor seleccionado
|
||||||
|
var searchVal = "";
|
||||||
|
|
||||||
|
// Determinar el texto renderizado que debe buscarse
|
||||||
|
if (val === "interior") {
|
||||||
|
searchVal = window.language.ClientePrecios.interior;
|
||||||
|
} else if (val === "cubierta") {
|
||||||
|
searchVal = window.language.ClientePrecios.cubierta;
|
||||||
|
} else if (val === "sobrecubierta") {
|
||||||
|
searchVal = window.language.ClientePrecios.sobrecubierta;
|
||||||
|
}
|
||||||
|
|
||||||
|
const allRows = [...self.rows, ...self.rowsCreated.map(row => row.data())];
|
||||||
|
|
||||||
|
// Actualizar los datos de la tabla
|
||||||
|
self.tablePlantilla.table.clear().rows.add(allRows).draw();
|
||||||
|
// Aplicar el filtro sobre los valores renderizados
|
||||||
|
self.tablePlantilla.table.column(i).search(searchVal ? '^' + searchVal + '$' : '', true, false).draw();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Aplicar el filtro sobre los valores renderizados
|
||||||
|
var val = $.fn.dataTable.util.escapeRegex(
|
||||||
|
$(this).val()
|
||||||
|
);
|
||||||
|
self.tablePlantilla.table.column(i).search(val).draw();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (i == 2) {
|
else if (i == 2) {
|
||||||
@ -537,10 +647,35 @@ class PlantillasTarifasClienteForm {
|
|||||||
selector.append('<option value="inkjet">Inkjet</option>');
|
selector.append('<option value="inkjet">Inkjet</option>');
|
||||||
|
|
||||||
selector.on('change', function () {
|
selector.on('change', function () {
|
||||||
var val = $.fn.dataTable.util.escapeRegex(
|
if (!self.tablePlantilla.table.settings()[0].oFeatures.bServerSide) {
|
||||||
$(this).val()
|
|
||||||
);
|
var val = $(this).val(); // El valor seleccionado
|
||||||
self.tablePlantilla.table.column(i).search(val).draw();
|
var searchVal = "";
|
||||||
|
|
||||||
|
// Determinar el texto renderizado que debe buscarse
|
||||||
|
if (val === "toner") {
|
||||||
|
searchVal = window.language.ClientePrecios.toner;
|
||||||
|
} else if (val === "inkjet") {
|
||||||
|
searchVal = window.language.ClientePrecios.inkjet;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const allRows = [...self.rows, ...self.rowsCreated.map(row => row.data())];
|
||||||
|
|
||||||
|
// Actualizar los datos de la tabla
|
||||||
|
self.tablePlantilla.table.clear().rows.add(allRows).draw();
|
||||||
|
// Aplicar el filtro sobre los valores renderizados
|
||||||
|
self.tablePlantilla.table.column(i).search(val).draw();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Aplicar el filtro sobre los valores renderizados
|
||||||
|
var val = $.fn.dataTable.util.escapeRegex(
|
||||||
|
$(this).val()
|
||||||
|
);
|
||||||
|
self.tablePlantilla.table.column(i).search(val).draw();
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,17 +692,52 @@ class PlantillasTarifasClienteForm {
|
|||||||
selector.append('<option value="colorhq">' + window.language.ClientePrecios.colorhq + '</option>');
|
selector.append('<option value="colorhq">' + window.language.ClientePrecios.colorhq + '</option>');
|
||||||
|
|
||||||
selector.on('change', function () {
|
selector.on('change', function () {
|
||||||
var val = $.fn.dataTable.util.escapeRegex(
|
|
||||||
$(this).val()
|
if (!self.tablePlantilla.table.settings()[0].oFeatures.bServerSide) {
|
||||||
);
|
|
||||||
self.tablePlantilla.table.column(i).search(val).draw();
|
var val = $(this).val(); // El valor seleccionado
|
||||||
|
var searchVal = "";
|
||||||
|
|
||||||
|
// Determinar el texto renderizado que debe buscarse
|
||||||
|
if (val === "negro") {
|
||||||
|
searchVal = window.language.ClientePrecios.negro;
|
||||||
|
} else if (val === "negrohq") {
|
||||||
|
searchVal = window.language.ClientePrecios.negrohq;
|
||||||
|
} else if (val === "color") {
|
||||||
|
searchVal = window.language.ClientePrecios.color;
|
||||||
|
} else if (val === "colorhq") {
|
||||||
|
searchVal = window.language.ClientePrecios.colorhq;
|
||||||
|
}
|
||||||
|
|
||||||
|
const allRows = [...self.rows, ...self.rowsCreated.map(row => row.data())];
|
||||||
|
|
||||||
|
// Actualizar los datos de la tabla
|
||||||
|
self.tablePlantilla.table.clear().rows.add(allRows).draw();
|
||||||
|
self.tablePlantilla.table.column(i).search(searchVal ? '^' + searchVal + '$' : '', true, false).draw();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Aplicar el filtro sobre los valores renderizados
|
||||||
|
var val = $.fn.dataTable.util.escapeRegex(
|
||||||
|
$(this).val()
|
||||||
|
);
|
||||||
|
self.tablePlantilla.table.column(i).search(val).draw();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
$(this).html('<input type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
|
$(this).html('<input type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
|
||||||
|
|
||||||
$('input', this).on('change clear', function () {
|
$('input', this).on('change clear', function () {
|
||||||
|
|
||||||
if (self.tablePlantilla.table.column(i).search() !== this.value) {
|
if (self.tablePlantilla.table.column(i).search() !== this.value) {
|
||||||
|
if (!self.tablePlantilla.table.settings()[0].oFeatures.bServerSide) {
|
||||||
|
const allRows = [...self.rows, ...self.rowsCreated.map(row => row.data())];
|
||||||
|
|
||||||
|
// Actualizar los datos de la tabla
|
||||||
|
self.tablePlantilla.table.clear().rows.add(allRows).draw();
|
||||||
|
}
|
||||||
|
|
||||||
self.tablePlantilla.table
|
self.tablePlantilla.table
|
||||||
.column(i)
|
.column(i)
|
||||||
.search(this.value)
|
.search(this.value)
|
||||||
|
|||||||
Reference in New Issue
Block a user