Merge branch 'main' into 'dev/chat'

Main

See merge request jjimenez/safekat!305
This commit is contained in:
Ignacio Martinez Navajas
2024-08-16 08:51:39 +00:00
30 changed files with 770 additions and 367 deletions

View File

@ -21,7 +21,7 @@
<th><?= lang('Clientes.cif') ?></th>
<th><?= lang('Clientes.email') ?></th>
<th><?= lang('Users.comercial') ?></th>
<th><?= lang('FormasPagoes.formaDePago') ?></th>
<th><?= lang('FormasPago.formaDePago') ?></th>
<th><?= lang('Clientes.vencimiento') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>

View File

@ -1,12 +1,11 @@
<div class="row">
<div class="col-md-12 col-lg-12 px-4">
<div class="mb-3">
<label for="nombre" class="form-label">
<?=lang('FormasPagoes.nombre') ?>*
</label>
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $formaPagoEntity->nombre) ?>">
</div><!--//.mb-3 -->
</div><!--//.col -->
</div><!-- //.row -->
<div class="row">
<div class="col-md-12 col-lg-12 px-4">
<div class="mb-3">
<label for="nombre" class="form-label">
<?= lang('FormasPago.nombre') ?>*
</label>
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control"
value="<?= old('nombre', $formaPagoEntity->nombre) ?>">
</div><!--//.mb-3 -->
</div><!--//.col -->
</div><!-- //.row -->

View File

@ -1,26 +1,45 @@
<?= $this->include("themes_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes_commonPartialsBs/sweetalert") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?>
<div class="row">
<div class="col-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="formaDePagoForm" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?>
<div class="card-body">
<?= view("themes_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/vuexy/form/configuracion/formasPagoViews/_formaDePagoFormItems") ?>
</div><!-- /.card-body -->
<div class="card-footer">
<?= anchor(route_to("formaDePagoList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
<input type="submit" class="btn btn-primary float-end" name="save" value="<?= lang("Basic.global.Save") ?>">
</div><!-- /.card-footer -->
</form>
</div><!-- //.card -->
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="formaDePagoForm" class="card-body" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?>
<div class="card-body">
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/vuexy/form/configuracion/formas-pago/_formaDePagoFormItems") ?>
</div><!-- /.card-body -->
<div class="pt-4">
<input type="submit"
class="btn btn-primary float-start me-sm-3 me-1"
name="save"
value="<?= lang("Basic.global.Save") ?>"
/>
<?= anchor(
route_to("formasPagoList"),
lang("Basic.global.Cancel"),
["class" => "btn btn-secondary float-start",]
) ?>
</div>
</form>
</div><!-- //.card -->
</div><!--//.col -->
</div><!--//.row -->
<?= $this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>"
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
<?= $this->endSection() ?>

View File

@ -1,25 +1,23 @@
<?=$this->include('themes_commonPartialsBs/datatables') ?>
<?=$this->include('themes_commonPartialsBs/sweetalert') ?>
<?=$this->extend('themes'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?>
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
<?=$this->include('themes/_commonPartialsBs/sweetalert') ?>
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
<?=$this->section('content'); ?>
<div class="row">
<div class="col-md-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?=lang('FormasPagoes.formaDePagoList') ?></h3>
<h3 class="card-title"><?=lang('FormasPago.formaPagoList') ?></h3>
<?=anchor(route_to('formasPagoAdd'), lang('Basic.global.addNew').' '.lang('FormasPago.formaPago'), ['class'=>'btn btn-primary float-end']); ?>
</div><!--//.card-header -->
<div class="card-body">
<?= view('themes_commonPartialsBs/_alertBoxes'); ?>
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<table id="tableOfFormasdepagos" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
<th><?=lang('FormasPagoes.id')?></th>
<th><?= lang('FormasPagoes.nombre') ?></th>
<th><?= lang('FormasPagoes.createdAt') ?></th>
<th><?= lang('FormasPagoes.updatedAt') ?></th>
<th><?= lang('FormasPago.nombre') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
@ -29,7 +27,7 @@
</table>
</div><!--//.card-body -->
<div class="card-footer">
<?=anchor(route_to('newFormaDePago'), lang('Basic.global.addNew').' '.lang('FormasPagoes.formaDePago'), ['class'=>'btn btn-primary float-end']); ?>
</div><!--//.card-footer -->
</div><!--//.card -->
</div><!--//.col -->
@ -40,125 +38,83 @@
<?=$this->section('additionalInlineJs') ?>
const lastColNr = $('#tableOfFormasdepagos').find("tr:first th").length - 1;
const actionBtns = function(data) {
return `<td class="text-right py-0 align-middle">
<div class="btn-group btn-group-sm">
<button class="btn btn-sm btn-warning btn-edit me-1" data-id="${data.id}"><?= lang('Basic.global.edit') ?></button>
<button class="btn btn-sm btn-danger btn-delete ms-1" data-id="${data.id}"><?= lang('Basic.global.Delete') ?></button>
</div>
</td>`;
};
theTable = $('#tableOfFormasdepagos').DataTable({
processing: true,
serverSide: true,
autoWidth: true,
responsive: true,
scrollX: true,
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
pageLength: 10,
lengthChange: true,
"dom": 'lfrtipB', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other
// "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above
"buttons": [
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
],
stateSave: true,
order: [[1, 'asc']],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfFormasDePagos') ?>',
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columnDefs: [
{
orderable: false,
searchable: false,
targets: [0,lastColNr]
}
],
columns : [
{ 'data': actionBtns },
{ 'data': 'id' },
{ 'data': 'nombre' },
{ 'data': 'created_at' },
{ 'data': 'updated_at' },
{ 'data': actionBtns }
]
});
const lastColNr = $('#tableOfFormasdepagos').find("tr:first th").length - 1;
const actionBtns = function(data) {
return `<td class="text-right py-0 align-middle">
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
</div>
</td>`;
};
theTable.on( 'draw.dt', function () {
const dateCols = [3, 4];
const shortDateFormat = '<?= convertPhpDateToMomentFormat('mm/dd/YYYY')?>';
const dateTimeFormat = '<?= convertPhpDateToMomentFormat('mm/dd/YYYY h:i a')?>';
for (let coln of dateCols) {
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
const datestr = cell.innerHTML;
const dateStrLen = datestr.toString().trim().length;
if (dateStrLen > 0) {
let dateTimeParts= datestr.split(/[- :]/); // regular expression split that creates array with: year, month, day, hour, minutes, seconds values
dateTimeParts[1]--; // monthIndex begins with 0 for January and ends with 11 for December so we need to decrement by one
const d = new Date(...dateTimeParts); // new Date(datestr);
const md = moment(d);
const usingThisFormat = dateStrLen > 11 ? dateTimeFormat : shortDateFormat;
const formattedDateStr = md.format(usingThisFormat);
cell.innerHTML = formattedDateStr;
}
});
theTable = $('#tableOfFormasdepagos').DataTable({
processing: true,
serverSide: true,
autoWidth: true,
responsive: true,
scrollX: true,
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
pageLength: 10,
lengthChange: true,
"dom": 'lfBrtip',
"buttons": [
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
],
stateSave: true,
order: [[1, 'asc']],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('formasPagoDT') ?>',
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columnDefs: [
{
orderable: false,
searchable: false,
targets: [0,lastColNr]
}
],
columns : [
{ 'data': 'nombre' },
{ 'data': actionBtns }
]
});
$(document).on('click', '.btn-edit', function(e) {
window.location.href = `<?= route_to('formaDePagoList') ?>/${$(this).attr('data-id')}/edit`;
$(document).on('click', '.btn-edit', function(e) {
window.location.href = `/configuracion/formas-pago/edit/${$(this).attr('data-id')}`;
});
$(document).on('click', '.btn-delete', function(e) {
Swal.fire({
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('FormasPagoes.forma de pago'))]) ?>',
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) {
$.ajax({
url: `<?= route_to('formaDePagoList') ?>/${dataId}`,
method: 'DELETE',
}).done((data, textStatus, jqXHR) => {
Toast.fire({
icon: 'success',
title: data.msg ?? jqXHR.statusText,
});
theTable.clearPipeline();
theTable.row($(row)).invalidate().draw();
}).fail((jqXHR, textStatus, errorThrown) => {
Toast.fire({
icon: 'error',
title: jqXHR.responseJSON.messages.error,
});
})
}
});
$(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/formas-pago/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)
})
}
});

View File

@ -6,26 +6,29 @@
<?= $this->section("content") ?>
<div class="row">
<div class="col-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="seriesFacturasForm" class="card-body" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?>
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/vuexy/form/configuracion/series-facturas/_seriesFacturasFormItems") ?>
<div class="pt-4">
<input type="submit"
class="btn btn-primary float-start me-sm-3 me-1"
name="save"
value="<?= lang("Basic.global.Save") ?>"
/>
<?= anchor(route_to("seriesFacturasList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start",]) ?>
</div><!-- /.card-footer -->
</form>
</div><!-- //.card -->
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="seriesFacturasForm" class="card-body" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?>
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/vuexy/form/configuracion/series-facturas/_seriesFacturasFormItems") ?>
<div class="pt-4">
<input type="submit"
class="btn btn-primary float-start me-sm-3 me-1"
name="save"
value="<?= lang("Basic.global.Save") ?>"
/>
<?= anchor(
route_to("seriesFacturasList"),
lang("Basic.global.Cancel"),
["class" => "btn btn-secondary float-start",]
) ?>
</div>
</form>
</div><!-- //.card -->
</div><!--//.col -->
</div><!--//.row -->
@ -33,20 +36,22 @@
<?=$this->section('css') ?>
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
<?=$this->endSection() ?>
<?= $this->section('css') ?>
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
<link rel="stylesheet"
href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
<?= $this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
<?=$this->endSection() ?>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>"
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
<?= $this->endSection() ?>

View File

@ -112,7 +112,7 @@
const row = $(this).closest('tr');
if ($.isNumeric(dataId)) {
$.ajax({
url: `/configuracion/series-facturas//delete/${dataId}`,
url: `/configuracion/series-facturas/delete/${dataId}`,
method: 'GET',
}).done((data, textStatus, jqXHR) => {
$('#confirm2delete').modal('toggle');

View File

@ -118,11 +118,10 @@ $('#addNewPedidoImpresion').on('click', function(){
yeniden(response.<?= csrf_token() ?>);
// se ajustan el ancho de las columnas
$('#tableOfLineasFactura').DataTable().columns.adjust().draw();
$('#pedidoImpresion').val(null).trigger('change');
// Se actualiza la tabla de lineas de factura
tableLineas.clearPipeline();
tableLineas.draw();
$('#tableOfLineasFactura').DataTable().columns.adjust().draw();
}
});
});

View File

@ -255,7 +255,7 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
error_text = 'El total del pedido ('+ total_aceptado + '€) no coincide con la línea ('+ subtotal + '€)';
}
return `
var returned_data = `
<div>
${data}
</div>
@ -265,11 +265,55 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
<span style="color: red;" id="error-${meta.row}">${error_text}</span>
</div>
<div class="mt-2">
<label for="input-${meta.row}">Total aceptado</label>
<input readonly type="text" id="input-${meta.row}" value="${row.total_aceptado}">
</div>
<div class="row mt-2">
<div style="margin-top: auto;" class="col-md-12 col-lg-2 px-4">
<label for="total-aceptado_-${meta.row}">Total aceptado</label>
<input readonly style="max-width: 110px;" type="text" id="total-aceptado_${meta.row}" value="${row.total_aceptado}">
</div>
`;
if (row.tirada_flexible === "1"){
returned_data += `
<div style="margin-top: auto;" class="col-md-12 col-lg-2 px-4">
<label for="descuento-tf_${meta.row}">Descuento tirada flexible</label>
<input readonly style="max-width: 110px;" type="text" id="descuento-tf_${meta.row}" value="${row.descuento_tirada_flexible}">
</div>
<div style="margin-top: auto;" class="col-md-12 col-lg-2 px-4">
<label for="tirada-albaran_${meta.row}">Tirada albarán</label>
<input readonly style="max-width: 110px;" type="text" id="tirada-albaran_${meta.row}" value="${row.cantidad_albaran}">
</div>
`;
if(row.cantidad<row.cantidad_albaran){
returned_data += `
<div style="margin-top: auto;" class="col-md-12 col-lg-2 px-4">
<button
type="button"
class="btn btn-label-primary float-start me-sm-3 me-1 btn-excedentes"
name="btn-excedentes_${meta.row}"
id="btn-excedentes_${meta.row}"
data-row="${meta.row}"
>
<span class="ti-xs ti ti-circle-plus me-1"></span>
Excedentes
</button>
</div>
</div>
`;
}
else{
returned_data += `
</div>
`;
}
}
else{
returned_data += `
</div>
`;
}
return returned_data;
}
else{
return `
@ -372,7 +416,8 @@ function updateFooterLineas(table){
base: totalSubtotal,
total: totalTotal,
total_pagos: total_pagos,
pendiente: pendientePago
pendiente: pendientePago,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
}
}).done((data, textStatus, jqXHR) => {
if(data.estado_pago == 'pagada'){
@ -397,12 +442,12 @@ $(document).on('click', '.btn-delete', function(e) {
asyncConfirmDialogWithParams(
"Borrar Linea de Factura",
"¿Está seguro de borrar la línea? Esta acción no se puede deshacer.",
deleteConfirmed, function(){}, [dataId, row])
deleteConfirmedLinea, function(){}, [dataId, row])
}
});
function deleteConfirmed(params){
function deleteConfirmedLinea(params){
var factura_linea_id = params[0];
var row = params[1];
const row_data = tableLineas.row($(row)).data();
@ -415,7 +460,8 @@ function deleteConfirmed(params){
data: {
factura_id: <?= $facturaEntity->id ?>,
pedido_linea_impresion_id: row_data.pedido_linea_impresion_id,
cantidad: row_data.cantidad
cantidad: row_data.cantidad,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
}
}).done((data, textStatus, jqXHR) => {
@ -457,4 +503,47 @@ $('#addLineaFactura').on('click', function() {
});
$(document).on('click', '.btn-excedentes', function(e) {
const row = $(this).data('row');
const row_data = tableLineas.row(row).data();
const pedido_id = row_data.pedido_id;
var pedido_linea_impresion_id = null;
var pedido_linea_maquetacion_id = null;
if(row_data.pedido_linea_impresion_id != null){
pedido_linea_impresion_id = row_data.pedido_linea_impresion_id
}
else{
pedido_linea_maquetacion_id = row_data.pedido_maquetacion_id
}
var factura_id = <?= $facturaEntity->id ?>;
var url = '<?= route_to('addLineaExcedentes', ':factura_id') ?>';
url = url.replace(':factura_id', factura_id );
$.ajax({
url: url,
method: 'POST',
data: {
pedido_id: pedido_id,
pedido_linea_impresion_id: pedido_linea_impresion_id,
pedido_linea_maquetacion_id: pedido_linea_maquetacion_id,
precio_unidad: row_data.precio_unidad,
descripcion: row_data.descripcion,
iva: row_data.iva,
descuento: row_data.descuento_tirada_flexible,
cantidad: parseInt(row_data.cantidad_albaran)-parseInt(row_data.cantidad),
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
}
}).done((data, textStatus, jqXHR) => {
$('#tableOfLineasFactura').DataTable().clearPipeline();
$('#tableOfLineasFactura').DataTable().draw();
}).fail((jqXHR, textStatus, errorThrown) => {
popErrorAlert(jqXHR.responseJSON.messages.error)
})
});
<?=$this->endSection() ?>

View File

@ -11,6 +11,14 @@
</div><!--//.card-header -->
<div class="card-body">
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<div class="row">
<div class="form-check form-check-inline">
<input type="checkbox" class="form-check-input" id="showTotal" name="showTotal">
<label for="showTotal" class="form-check-label">
<?= lang('Pedidos.showTotal') ?>
</label>
</div>
</div>
<table id="tableOfPedidos" class="table table-striped table-hover" style="width: 100%;">
<thead>
@ -23,11 +31,11 @@
<th><?= lang('Pedidos.titulo') ?></th>
<th><?= lang('Pedidos.ubicacion') ?></th>
<th><?= lang('Pedidos.inc_rei') ?></th>
<th><?= lang('Pedidos.num_paginas') ?></th>
<th><?= lang('Pedidos.tiradas') ?></th>
<th><?= lang('Pedidos.total_presupuesto') ?></th>
<th class='noFilter'><?= lang('Pedidos.num_paginas') ?></th>
<th class='totalizador'><?= lang('Pedidos.tiradas') ?></th>
<th class='totalizador'><?= lang('Pedidos.total_presupuesto') ?></th>
<th><?= lang('Pedidos.estado') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
<th class="noFilter text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
@ -57,24 +65,130 @@
</td>`;
};
theTable = $('#tableOfPedidos').DataTable({
// Setup - add a text input to each footer cell
$('#tableOfPedidos thead tr').clone(true).appendTo('#tableOfPedidos thead');
$('#tableOfPedidos thead tr:eq(1) th').each(function (i) {
if (!$(this).hasClass("noFilter")) {
var title = $(this).text();
if($(this).hasClass("totalizador")){
if(i==9){
$(this).html('<label id="total_tirada" />');
}
else if(i==10){
$(this).html('<label id="total_aceptado" />');
}
}
else{
if(i==1 || i==2){
name = 'bs-rangepicker-range_' + i;
$(this).html('<input id="'+name+'" type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
var bsRangePickerRange = $('#' + name);
bsRangePickerRange.daterangepicker({
ranges: {
'<?= lang('datePicker.hoy') ?>': [moment(), moment()],
'<?= lang('datePicker.ayer') ?>': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'<?= lang('datePicker.ultimos7') ?>': [moment().subtract(6, 'days'), moment()],
'<?= lang('datePicker.ultimos30') ?>': [moment().subtract(29, 'days'), moment()],
'<?= lang('datePicker.esteMes') ?>': [moment().startOf('month'), moment().endOf('month')],
'<?= lang('datePicker.ultimoMes') ?>': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
opens: 'right',
language: '<?= config('Basics')->i18n ?>',
"locale": {
"customRangeLabel": "<?= lang('datePicker.personalizar') ?>",
"format": "YYYY-MM-DD",
"separator": " ",
"applyLabel": "<?= lang('datePicker.aplicar') ?>",
"cancelLabel": "<?= lang('datePicker.limpiar') ?>",
},
"alwaysShowCalendars": true,
autoUpdateInput: false,
});
bsRangePickerRange.on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('YYYY-MM-DD') + ' ' + picker.endDate.format('YYYY-MM-DD'));
theTable
.column(i)
.search(this.value)
.draw();
});
bsRangePickerRange.on('cancel.daterangepicker', function(ev, picker) {
$(this).val('');
theTable
.column(i)
.search(this.value)
.draw();
});
}
else if (i == 11) {
// Agregar un selector en la tercera columna
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
// Agregar opciones al selector
var selector = $('select', this);
selector.append('<option value="">Todos</option>'); // Opción vacía
selector.append('<option value="validacion"><?= lang('Pedidos.validacion') ?></option>');
selector.append('<option value="produccion"><?= lang('Pedidos.produccion') ?></option>');
selector.append('<option value="finalizado"><?= lang('Pedidos.finalizado') ?></option>');
selector.append('<option value="enviado"><?= lang('Pedidos.enviado') ?></option>');
selector.append('<option value="cancelado"><?= lang('Pedidos.cancelado') ?></option>');
selector.on('change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
theTable.column(i).search(val).draw();
});
}
else{
$(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 () {
if (theTable.column(i).search() !== this.value) {
theTable
.column(i)
.search(this.value)
.draw();
}
});
}
}
}
else {
$(this).html('<span></span>');
}
});
var theTable = $('#tableOfPedidos').DataTable({
select: {
style: 'multi',
info: false
},
orderCellsTop: true,
fixedHeader: true,
processing: true,
serverSide: true,
autoWidth: true,
responsive: true,
searching: true,
scrollX: true,
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
pageLength: 50,
pageLength: 100,
lengthChange: true,
"dom": 'lfBrtip',
"dom": '<"mb-3"l>Brtip',
"buttons": [
'copy', 'csv', 'excel', 'print', {
'colvis', 'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
],
stateSave: true,
stateSave: false,
order: [[0, 'asc']],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
@ -82,8 +196,9 @@
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfPedidos') ?>',
method: 'POST',
data: {
estado: "<?= $estadoPedidos ?>",
data: function(d, settings){
d.estado= "<?= $estadoPedidos ?>";
d.showTotal= $('#showTotal').is(':checked')? "1":"0";
},
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
@ -91,7 +206,7 @@
columnDefs: [
{
orderable: false,
searchable: false,
searchable: true,
targets: [lastColNr]
}
],
@ -138,39 +253,76 @@
}
},
{ 'data': actionBtns }
]
],
drawCallback: function (settings) {
$('#total_tirada').text(settings.json.extra.total_tirada);
$('#total_aceptado').text(settings.json.extra.total);
}
});
theTable.on( 'draw.dt', function () {
const boolCols = [];
for (let coln of boolCols) {
const dateCols = [1,2];
const priceCols = [10];
for (let coln of dateCols) {
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
const datestr = cell.innerHTML;
const dateStrLen = datestr.toString().trim().length;
if (dateStrLen > 0) {
let dateTimeParts= datestr.split(/[- :]/); // regular expression split that creates array with: year, month, day, hour, minutes, seconds values
dateTimeParts[1]--; // monthIndex begins with 0 for January and ends with 11 for December so we need to decrement by one
const d = new Date(...dateTimeParts); // new Date(datestr);
cell.innerHTML = d.toLocaleDateString();
}
});
}
for (let coln of priceCols) {
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
cell.innerHTML = parseFloat(cell.innerHTML).toFixed(2);
});
}
});
$(document).on('click', '.btn-edit', function(e) {
var url = '<?= route_to('editarPedido', ':id') ?>';
url = url.replace(':id', `${$(this).attr('data-id')}` );
window.location.href = url;
});
theTable.on('click', 'tbody tr', function (e) {
e.currentTarget.classList.toggle('selected');
});
$('#showTotal').on('change', function() {
theTable.clearPipeline();
theTable.ajax.reload(null, false);
//theTable.draw();
});
<?=$this->endSection() ?>
<?=$this->section('css') ?>
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/fixedheader/fixedHeader.dataTables.min.css") ?>">
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/bootstrap-daterangepicker/bootstrap-daterangepicker.css') ?>" />
<?=$this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/select/dataTables.select.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.colVis.min.js") ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/moment/moment.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/bootstrap-daterangepicker/bootstrap-daterangepicker.js') ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>

View File

@ -4,6 +4,7 @@
*/
if (
auth()->user()->can('paises.menu') ||
auth()->user()->can('formas-pago.menu') ||
auth()->user()->can('papel-genericosk .menu') ||
auth()->user()->can('papel-impresion.menu') ||
auth()->user()->can('maquinas.menu') ||
@ -11,7 +12,7 @@ if (
auth()->user()->can('usuarios.menu') ||
auth()->user()->can('roles-permisos.menu')
) {
?>
?>
<li class="menu-item">
<a href="javascript:void(0);" class="menu-link menu-toggle">
<i class="menu-icon tf-icons ti ti-adjustments-horizontal"></i>
@ -25,6 +26,13 @@ if (
</a>
</li>
<?php } ?>
<?php if (auth()->user()->can('formas-pago.menu')) { ?>
<li class="menu-item">
<a href="<?= route_to('formasPagoList') ?>" class="menu-link">
<?= lang("App.menu_formas_pago") ?>
</a>
</li>
<?php } ?>
<?php if (auth()->user()->can('papel-generico.menu')) { ?>
<li class="menu-item">
<a href="<?= site_url("configuracion/papelesgenericos") ?>" class="menu-link">
@ -40,32 +48,32 @@ if (
</li>
<?php } ?>
<?php if (auth()->user()->can('maquinas.menu')) { ?>
<li class="menu-item">
<a href="<?= site_url("configuracion/maquinas") ?>" class="menu-link">
<?= lang("App.menu_maquina") ?>
</a>
</li>
<li class="menu-item">
<a href="<?= site_url("configuracion/maquinas") ?>" class="menu-link">
<?= lang("App.menu_maquina") ?>
</a>
</li>
<?php } ?>
<?php if (auth()->user()->can('maquinas-defecto.menu')) { ?>
<li class="menu-item">
<a href="<?= site_url("configuracion/maquinasdefecto") ?>" class="menu-link">
<?= lang("App.menu_maquina_defecto") ?>
</a>
</li>
<li class="menu-item">
<a href="<?= site_url("configuracion/maquinasdefecto") ?>" class="menu-link">
<?= lang("App.menu_maquina_defecto") ?>
</a>
</li>
<?php } ?>
<?php if (auth()->user()->can('usuarios.menu')) { ?>
<li class="menu-item">
<a href="<?= site_url("configuracion/users") ?>" class="menu-link">
<?= lang("App.menu_users") ?>
</a>
</li>
<li class="menu-item">
<a href="<?= site_url("configuracion/users") ?>" class="menu-link">
<?= lang("App.menu_users") ?>
</a>
</li>
<?php } ?>
<?php if (auth()->user()->can('roles-permisos.menu')) { ?>
<li class="menu-item">
<a href="<?= site_url("configuracion/group") ?>" class="menu-link">
<?= lang("App.menu_permission_group") ?>
</a>
</li>
<li class="menu-item">
<a href="<?= site_url("configuracion/group") ?>" class="menu-link">
<?= lang("App.menu_permission_group") ?>
</a>
</li>
<?php } ?>
<?php if (auth()->user()->can('ubicaciones.menu')) { ?>
<li class="menu-item">