mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Trabajando
This commit is contained in:
@ -24,9 +24,7 @@ if (session()->has('error')) {
|
||||
|
||||
<?= $this->section('additionalInlineJs') ?>
|
||||
|
||||
function popAlert(message, alertType){
|
||||
var alertClass = "alert-" + alertType;
|
||||
var alertIcon = alertType == "success" ? "ti-check" : "ti-" + alertType;
|
||||
function popAlert(message, alertClass, alertIcon){
|
||||
var htmlString = `
|
||||
<div class="alert ${alertClass} d-flex align-items-baseline" role="alert">
|
||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||
@ -45,15 +43,15 @@ function popAlert(message, alertType){
|
||||
}
|
||||
|
||||
function popSuccessAlert(successMsg){
|
||||
popAlert(successMsg, "success");
|
||||
popAlert(successMsg, "alert-success", "ti-check");
|
||||
}
|
||||
|
||||
function popWarningAlert(warningMsg){
|
||||
popAlert(warningMsg, "warning");
|
||||
popAlert(warningMsg, "alert-warning", "ti-bell");
|
||||
}
|
||||
|
||||
function popErrorAlert(errorMsg){
|
||||
popAlert(errorMsg, "error");
|
||||
popAlert(errorMsg, "alert-danger", "ti-ban");
|
||||
}
|
||||
|
||||
<?php if (isset($successMessage) && $successMessage){ ?>
|
||||
|
||||
@ -78,7 +78,7 @@
|
||||
<th><?= lang('TarifaEncuadernacionLineas.paginasMax') ?></th>
|
||||
<th><?= lang('TarifaEncuadernacionLineas.precioMin') ?></th>
|
||||
<th><?= lang('TarifaEncuadernacionLineas.margen') ?></th>
|
||||
<th></th>
|
||||
<th style="min-width:100px"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -117,6 +117,10 @@
|
||||
`;
|
||||
};
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
||||
});
|
||||
|
||||
var selected_tirada_id = -1;
|
||||
<?php endif; ?>
|
||||
<?= $this->endSection() ?>
|
||||
@ -166,11 +170,11 @@
|
||||
|
||||
editor.on( 'preSubmit', function ( e, d, type ) {
|
||||
if ( type === 'create'){
|
||||
d.data[0]['tirada_encuadernacion_id'] = id;
|
||||
d.data[0]['tirada_encuadernacion_id'] = selected_tirada_id;
|
||||
}
|
||||
else if(type === 'edit' ) {
|
||||
for (v in d.data){
|
||||
d.data[v]['tirada_encuadernacion_id'] = id;
|
||||
d.data[v]['tirada_encuadernacion_id'] = selected_tirada_id;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -188,6 +192,7 @@
|
||||
theTable.draw();
|
||||
});
|
||||
|
||||
|
||||
var theTable = $('#tableOfTarifaencuadernacionlineas').DataTable( {
|
||||
serverSide: true,
|
||||
processing: true,
|
||||
@ -203,8 +208,8 @@
|
||||
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
|
||||
ajax : $.fn.dataTable.pipeline( {
|
||||
url: '<?= route_to('dataTableOfTarifaEncuadernacionLineas') ?>',
|
||||
data: {
|
||||
tirada_id: selected_tirada_id,
|
||||
data: function ( d ) {
|
||||
d.tirada_id = selected_tirada_id;
|
||||
},
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
@ -240,7 +245,21 @@
|
||||
formOptions: {
|
||||
submitTrigger: -1,
|
||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
|
||||
}
|
||||
|
||||
},
|
||||
action: function ( e, dt, node, config ) {
|
||||
if(selected_tirada_id == -1){
|
||||
popErrorAlert("<?= lang('TarifaEncuadernacionLineas.validation.error_seleccion_tiradas') ?>");
|
||||
}
|
||||
else{
|
||||
formOptions= {
|
||||
submitTrigger: -1,
|
||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
|
||||
|
||||
};
|
||||
editor.inlineCreate(config.position, formOptions);
|
||||
}
|
||||
},
|
||||
} ]
|
||||
} );
|
||||
|
||||
@ -261,34 +280,29 @@
|
||||
|
||||
|
||||
// Delete row
|
||||
$(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}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
$('#confirm2delete').modal('toggle');
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||
})*/
|
||||
console.log(this.parentNode);
|
||||
/*editor
|
||||
.create( false )
|
||||
.edit( this.parentNode, false)
|
||||
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
|
||||
.set( 'is_deleted', 1 )
|
||||
.submit();*/
|
||||
}
|
||||
});
|
||||
$(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}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
$('#confirm2delete').modal('toggle');
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||
})*/
|
||||
/*editor
|
||||
.create( false )
|
||||
.edit( this.parentNode, false)
|
||||
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
|
||||
.set( 'is_deleted', 1 )
|
||||
.submit();*/
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
$('#tableOfTarifaencuadernacionlineas').on( 'click', 'tbody span.remove', function (e) {
|
||||
@ -326,8 +340,11 @@
|
||||
<!------------------------------------------->
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
// Definicion de la ultima columna de la tabla
|
||||
const lastColNr2 = $('#tableOfTarifaencuadernaciontiradas').find("tr:first th").length - 1;
|
||||
|
||||
|
||||
// Datatables Editor
|
||||
var editor2 = new $.fn.dataTable.Editor( {
|
||||
ajax: {
|
||||
url: "<?= route_to('editorOfTarifaEncuadernacionTiradas') ?>",
|
||||
@ -338,7 +355,7 @@
|
||||
table : "#tableOfTarifaencuadernaciontiradas",
|
||||
idSrc: 'id',
|
||||
fields: [ {
|
||||
name: "proveedor",
|
||||
name: "proveedor_id",
|
||||
"type": "select"
|
||||
}, {
|
||||
name: "tirada_min"
|
||||
@ -348,7 +365,7 @@
|
||||
"name": "tarifa_encuadernacion_id",
|
||||
"type": "hidden"
|
||||
},{
|
||||
name: "proveedor_id",
|
||||
name: "proveedor",
|
||||
"type": "hidden"
|
||||
}, {
|
||||
"name": "deleted_at",
|
||||
@ -361,6 +378,11 @@
|
||||
} );
|
||||
|
||||
|
||||
// Generación de la lista de proveedores (id, nombre) para encuadernación
|
||||
const suppliersList = <?php echo json_encode($proveedores); ?>;
|
||||
editor2.field( 'proveedor_id' ).update( suppliersList );
|
||||
|
||||
|
||||
editor2.on( 'preSubmit', function ( e, d, type ) {
|
||||
if ( type === 'create'){
|
||||
d.data[0]['tarifa_encuadernacion_id'] = id;
|
||||
@ -381,11 +403,12 @@
|
||||
|
||||
editor2.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||
|
||||
theTable.clearPipeline();
|
||||
theTable.draw();
|
||||
theTable2.clearPipeline();
|
||||
theTable2.draw();
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Tabla de tiradas
|
||||
var theTable2 = $('#tableOfTarifaencuadernaciontiradas').DataTable( {
|
||||
serverSide: true,
|
||||
processing: true,
|
||||
@ -410,7 +433,12 @@
|
||||
async: true,
|
||||
}),
|
||||
columns: [
|
||||
{ 'data': 'proveedor' },
|
||||
{ 'data': 'proveedor_id',
|
||||
render: function(data, type, row, meta) {
|
||||
var value = suppliersList.find(element => element.value === data);
|
||||
return value['label'];
|
||||
},
|
||||
},
|
||||
{ 'data': 'tirada_min' },
|
||||
{ 'data': 'tirada_max' },
|
||||
{
|
||||
@ -441,6 +469,25 @@
|
||||
} ]
|
||||
} );
|
||||
|
||||
|
||||
// Obtener la id de la fila seleccionada o ponerla a -1 cuando no haya ninguna seleccionada
|
||||
var selected_tirada_id = -1;
|
||||
theTable2.on( 'select', function ( e, dt, type, indexes ) {
|
||||
if ( type === 'row' ) {
|
||||
selected_tirada_id = parseInt(theTable2.rows( indexes ).data().pluck( 'id' )[0]);
|
||||
theTable.clearPipeline();
|
||||
theTable.draw();
|
||||
}
|
||||
} );
|
||||
|
||||
theTable2.on( 'deselect', function ( e, dt, type, indexes ) {
|
||||
if ( theTable2.rows( '.selected' ).count() == 0 ) {
|
||||
selected_tirada_id = -1;
|
||||
theTable.clearPipeline();
|
||||
theTable.draw();
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
// Activate an inline edit on click of a table cell
|
||||
$('#tableOfTarifaencuadernaciontiradas').on( 'click', 'tbody span.edit', function (e) {
|
||||
@ -458,36 +505,24 @@
|
||||
|
||||
|
||||
// Delete row
|
||||
$(document).on('click', '.btn-remove', function(e) {
|
||||
const dataId = $(this).attr('data-id');
|
||||
const row = $(this).closest('tr');
|
||||
if ($.isNumeric(dataId)) {
|
||||
$.ajax({
|
||||
url: `/tarifas/tarifaencuadernaciontiradas/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
$('#confirm2delete').modal('toggle');
|
||||
theTable2.clearPipeline();
|
||||
theTable2.row($(row)).invalidate().draw();
|
||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
$('#tableOfTarifaencuadernacionlineas').on( 'click', 'tbody span.remove', function (e) {
|
||||
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Basic.global.sweet.line'))]) ?>',
|
||||
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
|
||||
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
|
||||
cancelButtonColor: '#d33'
|
||||
})
|
||||
.then((result) => {
|
||||
const dataId = $(this).data('id');
|
||||
const row = $(this).closest('tr');
|
||||
if (result.value) {
|
||||
editor
|
||||
.create( false )
|
||||
.edit( this.parentNode, false)
|
||||
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
|
||||
.set( 'is_deleted', 1 )
|
||||
.submit();
|
||||
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
Reference in New Issue
Block a user