modificacion finalizada y testeada

This commit is contained in:
Jaime Jiménez
2023-08-22 09:45:10 +02:00
parent 4b1cb72ec0
commit ed018c3364
4 changed files with 51 additions and 35 deletions

View File

@ -202,6 +202,7 @@ $routes->group('papelimpresiontipologias', ['namespace' => 'App\Controllers\Conf
$routes->group('papelesimpresionmargenes', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
$routes->post('datatable', 'Papelimpresionmargenes::datatable', ['as' => 'dataTableOfPapelImpresionMargen']);
$routes->post('datatable_editor', 'Papelimpresionmargenes::datatable_editor', ['as' => 'editorOfPapelImpresionMargenes']);
$routes->get('delete/(:num)', 'Papelimpresionmargenes::delete/$1', ['as' => 'deletePapelImpresionMargen']);
});
$routes->resource('papelesimpresionmargenes', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelimpresionmargenes', 'except' => 'show,new,create,update']);

View File

@ -157,7 +157,7 @@ class Papelimpresionmargenes extends \App\Controllers\GoBaseResourceController
$order = PapelImpresionMargenModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
$dir = $reqData['order']['0']['dir'] ?? 'asc';
$id_PI = $reqData['papel_impresion_id'] ?? -1;
$id_PI = $reqData['id_PI'] ?? -1;
$resourceData = $this->model->getResource("", $id_PI)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();

View File

@ -148,9 +148,9 @@ class PapelImpresionTipologiaModel extends \App\Models\GoBaseModel
->where("papel_impresion_id", $data["papel_impresion_id"])
->where("tipo", $data["tipo"]);
if ($builder->countAllResults() > 0){
if($builder->get()->getResultObject()[0]->id!=$id){
if ($builder->countAllResults(false) > 0){
$found_id = $builder->get()->getResultObject()[0]->id;
if($found_id != $id){
return lang('ImpresionTipologias.validation.error_tipo_duplicado');
}
}

View File

@ -183,6 +183,35 @@
cache: true
}
});
// Delete row
$(document).on('click', '.btn-delete', function(e) {
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
if($(this).closest('table').attr('id').includes('margenes')){
$(".btn-remove").attr('table', "margenes");
}
else if($(this).closest('table').attr('id').includes('tipologias')){
$(".btn-remove").attr('table', "tipologias");
}
else{
$(".btn-remove").attr('table', );
}
});
$(document).on('click', '.btn-remove', function(e) {
const dataId = $(this).attr('data-id');
const row = $(this).closest('tr');
if ($.isNumeric(dataId)) {
if($(this).attr('table').includes('margenes')){
remove_margenes(dataId, row);
}
else if ($(this).attr('table').includes('tipologias')){
remove_tipologias(dataId, row);
}
}
});
<?= $this->endSection() ?>
@ -302,7 +331,7 @@
// Activate an inline edit on click of a table cell
$(document).on('click', '.btn-edit2', function(e) {
editor.inline(
editor3.inline(
theTable3.cells(this.parentNode.parentNode.parentNode, '*').nodes(),
{
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
@ -341,32 +370,23 @@
});
/*
// Delete row
function remove_margenes(dataId, row){
// Borrar registro
$(document).on('click', '.btn-delete', function(e) {
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
});
$(document).on('click', '.btn-remove', function(e) {
const dataId = $(this).attr('data-id');
const row = $(this).closest('tr');
if ($.isNumeric(dataId)) {
$.ajax({
url: `/configuracion/papelimpresiontipologias/delete/${dataId}`,
$.ajax({
url: `/configuracion/papelimpresionmargenes/delete/${dataId}`,
method: 'GET',
}).done((data, textStatus, jqXHR) => {
$('#confirm2delete').modal('toggle');
theTable.clearPipeline();
theTable.row($(row)).invalidate().draw();
theTable3.clearPipeline();
theTable3.row($(row)).invalidate().draw();
popSuccessAlert(data.msg ?? jqXHR.statusText);
}).fail((jqXHR, textStatus, errorThrown) => {
popErrorAlert(jqXHR.responseJSON.messages.error)
})
}
});
*/
});
}
<?= $this->endSection() ?>
<!------------------------------------------->
@ -507,6 +527,7 @@
// Notificar que no se pueden añadir más tipologías
editor.on( 'initCreate', function () {
if ( $('#tableOfPapelimpresiontipologias').DataTable().data().count() >= 3 ){
editor.close();
popErrorAlert('<?= lang('Basic.global.sweet.maxRowsReached') ?>');
}
});
@ -553,16 +574,10 @@
});
// Borrar registro
$(document).on('click', '.btn-delete', function(e) {
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
});
// Delete row
function remove_tipologias(dataId, row){
$(document).on('click', '.btn-remove', function(e) {
const dataId = $(this).attr('data-id');
const row = $(this).closest('tr');
if ($.isNumeric(dataId)) {
$.ajax({
$.ajax({
url: `/configuracion/papelimpresiontipologias/delete/${dataId}`,
method: 'GET',
}).done((data, textStatus, jqXHR) => {
@ -572,9 +587,9 @@
popSuccessAlert(data.msg ?? jqXHR.statusText);
}).fail((jqXHR, textStatus, errorThrown) => {
popErrorAlert(jqXHR.responseJSON.messages.error)
})
}
});
});
}
<?= $this->endSection() ?>