mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
working
This commit is contained in:
@ -25,8 +25,8 @@ class Test extends BaseController
|
|||||||
$data = $model->obtenerLineasPedidoSinFacturar(999);
|
$data = $model->obtenerLineasPedidoSinFacturar(999);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$model = model("\App\Models\Facturas\FacturaModel");
|
$model = model("\App\Models\Facturas\FacturaLineaModel");
|
||||||
$data = $model->getCantidadLineaPedidoFacturada(5);
|
$data = $model->getResource(9)->get()->getResultObject();
|
||||||
|
|
||||||
echo('<pre>');
|
echo('<pre>');
|
||||||
var_dump($data);
|
var_dump($data);
|
||||||
|
|||||||
@ -39,8 +39,9 @@ class FacturaLineaModel extends \App\Models\BaseModel {
|
|||||||
"t1.id AS id, t1.factura_id AS factura_id,
|
"t1.id AS id, t1.factura_id AS factura_id,
|
||||||
t1.pedido_linea_impresion_id AS pedido_linea_impresion_id, t1.pedido_maquetacion_id AS pedido_maquetacion_id,
|
t1.pedido_linea_impresion_id AS pedido_linea_impresion_id, t1.pedido_maquetacion_id AS pedido_maquetacion_id,
|
||||||
t1.descripcion AS concepto, t1.cantidad as unidades, t1.precio_unidad AS precio_unidad, t1.iva AS iva,
|
t1.descripcion AS concepto, t1.cantidad as unidades, t1.precio_unidad AS precio_unidad, t1.iva AS iva,
|
||||||
t1.base AS subtotal, t1.total_iva AS total_iva, t1.total AS total, t1.data AS data,"
|
t1.base AS subtotal, t1.total_iva AS total_iva, t1.total AS total, t1.data AS data, t2.pedido_id AS pedido_id"
|
||||||
)
|
)
|
||||||
|
->join("pedidos_linea t2", "t2.id = t1.pedido_linea_impresion_id", "left")
|
||||||
->where("t1.factura_id", $factura_id)
|
->where("t1.factura_id", $factura_id)
|
||||||
->where("t1.deleted_at", null);
|
->where("t1.deleted_at", null);
|
||||||
|
|
||||||
|
|||||||
@ -116,12 +116,13 @@ $('#addNewPedidoImpresion').on('click', function(){
|
|||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
yeniden(response.<?= csrf_token() ?>);
|
yeniden(response.<?= csrf_token() ?>);
|
||||||
$('#pedidoImpresion').val(null).trigger('change');
|
|
||||||
// Se actualiza la tabla de lineas de factura
|
// Se actualiza la tabla de lineas de factura
|
||||||
$('#tableOfLineasFactura').DataTable().clearPipeline();
|
$('#tableOfLineasFactura').DataTable().clearPipeline();
|
||||||
$('#tableOfLineasFactura').DataTable().ajax.reload();
|
$('#tableOfLineasFactura').DataTable().ajax.reload();
|
||||||
// se ajustan el ancho de las columnas
|
// se ajustan el ancho de las columnas
|
||||||
$('#tableOfLineasFactura').DataTable().columns.adjust().draw();
|
$('#tableOfLineasFactura').DataTable().columns.adjust().draw();
|
||||||
|
$('#pedidoImpresion').val(null).trigger('change');
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -16,16 +16,44 @@
|
|||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
<th></th>
|
||||||
<th><?= lang('Facturas.unidades') ?></th>
|
<th><?= lang('Facturas.unidades') ?></th>
|
||||||
<th><?= lang('Facturas.concepto') ?></th>
|
<th><?= lang('Facturas.concepto') ?></th>
|
||||||
<th><?= lang('Facturas.precioUnidad') ?></th>
|
<th><?= lang('Facturas.precioUnidad') ?></th>
|
||||||
<th><?= lang('Facturas.iva') ?></th>
|
<th><?= lang('Facturas.iva') ?></th>
|
||||||
<th><?= lang('Facturas.subtotal') ?></th>
|
<th><?= lang('Facturas.subtotal') ?></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="8" style="text-align:right">Subtotal:</td>
|
||||||
|
<td id="subtotal-sum"></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="8" style="text-align:right">I.V.A.:</td>
|
||||||
|
<td id="total-iva-sum"></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="8" style="text-align:right">Total:</td>
|
||||||
|
<td id="total-sum"></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="8" style="text-align:right">Pendiente de pago:</td>
|
||||||
|
<td id="pendiente-pago"></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
<?php if($facturaEntity->estado =='borrador') : ?>
|
<?php if($facturaEntity->estado =='borrador') : ?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -50,7 +78,21 @@
|
|||||||
<?=$this->section('additionalInlineJs') ?>
|
<?=$this->section('additionalInlineJs') ?>
|
||||||
|
|
||||||
const actionBtns = function(data) {
|
const actionBtns = function(data) {
|
||||||
return `
|
|
||||||
|
// se comprueba si data es null
|
||||||
|
if (data.pedido_id === null) {
|
||||||
|
return `
|
||||||
|
<td class="text-right py-0 align-middle">
|
||||||
|
<div class="row mb-2">
|
||||||
|
<div class="btn-group btn-group-sm"><span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
|
||||||
|
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}"></i></a>
|
||||||
|
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>`;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return `
|
||||||
<td class="text-right py-0 align-middle">
|
<td class="text-right py-0 align-middle">
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
<div class="btn-group btn-group-sm">
|
<div class="btn-group btn-group-sm">
|
||||||
@ -59,9 +101,10 @@ const actionBtns = function(data) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<button type="button" class="btn btn-sm btn-primary btn-view_pedido" data-id="${data.pedido_linea_impresion_id}">Ver pedido</button>
|
<button type="button" class="btn btn-sm btn-primary btn-view_pedido" data-id="${data.pedido_id}">Ver pedido</button>
|
||||||
</div>
|
</div>
|
||||||
</td>`;
|
</td>`;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var editor = new $.fn.dataTable.Editor( {
|
var editor = new $.fn.dataTable.Editor( {
|
||||||
@ -123,6 +166,21 @@ editor.on( 'submitSuccess', function ( e, json, data, action ) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Activate an inline edit on click of a table cell
|
||||||
|
$('#tableOfLineasFactura').on( 'click', 'tbody span.edit', function (e) {
|
||||||
|
editor.inline(
|
||||||
|
tableLineas.cells(this.parentNode.parentNode, '*').nodes(),
|
||||||
|
{
|
||||||
|
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
|
||||||
|
cancelTrigger: 'span.cancel',
|
||||||
|
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
|
||||||
|
submitTrigger: 'span.edit',
|
||||||
|
submit: 'allIfChanged'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
var tableLineas = $('#tableOfLineasFactura').DataTable({
|
var tableLineas = $('#tableOfLineasFactura').DataTable({
|
||||||
processing: true,
|
processing: true,
|
||||||
serverSide: true,
|
serverSide: true,
|
||||||
@ -133,11 +191,14 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
|
|||||||
{data: null, render: actionBtns},
|
{data: null, render: actionBtns},
|
||||||
{data: "pedido_linea_impresion_id"},
|
{data: "pedido_linea_impresion_id"},
|
||||||
{data: "pedido_maquetacion_id"},
|
{data: "pedido_maquetacion_id"},
|
||||||
|
{data: "pedido_id"},
|
||||||
{data: "unidades"},
|
{data: "unidades"},
|
||||||
{data: "concepto"},
|
{data: "concepto"},
|
||||||
{data: "precio_unidad"},
|
{data: "precio_unidad"},
|
||||||
{data: "iva"},
|
{data: "iva"},
|
||||||
{data: "subtotal"}
|
{data: "subtotal"},
|
||||||
|
{data: "total_iva"},
|
||||||
|
{data: "total"},
|
||||||
],
|
],
|
||||||
order: [[1, "asc"]],
|
order: [[1, "asc"]],
|
||||||
dom: 't',
|
dom: 't',
|
||||||
@ -158,10 +219,52 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
visible: false,
|
visible: false,
|
||||||
targets: [1, 2]
|
targets: [1, 2, 3, 9, 10]
|
||||||
}
|
}
|
||||||
|
|
||||||
],
|
],
|
||||||
|
footerCallback: function (row, data, start, end, display) {
|
||||||
|
var api = this.api();
|
||||||
|
|
||||||
|
// Remove the formatting to get integer data for summation
|
||||||
|
var intVal = function (i) {
|
||||||
|
return typeof i === 'string' ?
|
||||||
|
i.replace(/[\$,]/g, '')*1 :
|
||||||
|
typeof i === 'number' ?
|
||||||
|
i : 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Total over all pages
|
||||||
|
var totalSubtotal = api
|
||||||
|
.column(8)
|
||||||
|
.data()
|
||||||
|
.reduce(function (a, b) {
|
||||||
|
return intVal(a) + intVal(b);
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
var totalIVA = api
|
||||||
|
.column(9)
|
||||||
|
.data()
|
||||||
|
.reduce(function (a, b) {
|
||||||
|
return intVal(a) + intVal(b);
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
var totalTotal = api
|
||||||
|
.column(10)
|
||||||
|
.data()
|
||||||
|
.reduce(function (a, b) {
|
||||||
|
return intVal(a) + intVal(b);
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
// Update footer
|
||||||
|
$('#subtotal-sum').html(totalSubtotal.toFixed(2));
|
||||||
|
$('#total-iva-sum').html(totalIVA.toFixed(2));
|
||||||
|
$('#total-sum').html(totalTotal.toFixed(2));
|
||||||
|
|
||||||
|
// Assuming pendiente de pago is totalTotal - totalIVA for this example
|
||||||
|
var pendientePago = totalTotal ;//- totalIVA;
|
||||||
|
$('#pendiente-pago').html(pendientePago.toFixed(2));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -195,11 +298,11 @@ function deleteConfirmed(params){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(document).on('click', '.btn-view_pedido', function(e) {
|
||||||
$('.btn-view_pedido').on('click', function(e){
|
var pedido_id = $(this).data('id');
|
||||||
var pedido_linea_id = $(this).data('id');
|
var url = '<?= route_to('editarPedido', ':id') ?>';
|
||||||
var url = '<?= route_to('viewPedidoImpresion', ':id') ?>';
|
url = url.replace(':id', pedido_id );
|
||||||
url = url.replace(':id', pedido_linea_id );
|
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -49,12 +49,22 @@
|
|||||||
|
|
||||||
const lastColNr = $('#tableOfFacturas').find("tr:first th").length - 1;
|
const lastColNr = $('#tableOfFacturas').find("tr:first th").length - 1;
|
||||||
const actionBtns = function(data) {
|
const actionBtns = function(data) {
|
||||||
return `
|
if(data.estado == 'borrador'){
|
||||||
|
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>
|
||||||
|
</div>
|
||||||
|
</td>`;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return `
|
||||||
<td class="text-right py-0 align-middle">
|
<td class="text-right py-0 align-middle">
|
||||||
<div class="btn-group btn-group-sm">
|
<div class="btn-group btn-group-sm">
|
||||||
<a href="javascript:void(0);"><i class="ti ti-eye ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
<a href="javascript:void(0);"><i class="ti ti-eye ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</td>`;
|
</td>`;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
theTable = $('#tableOfFacturas').DataTable({
|
theTable = $('#tableOfFacturas').DataTable({
|
||||||
|
|||||||
@ -130,7 +130,6 @@ $(document).on('click', '.btn-view', function(e) {
|
|||||||
var url = '<?= route_to('editarPresupuestoCliente2', ':id') ?>';
|
var url = '<?= route_to('editarPresupuestoCliente2', ':id') ?>';
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
url = url.replace(':id', `${$(this).attr('data-id')}` );
|
url = url.replace(':id', `${$(this).attr('data-id')}` );
|
||||||
console.log(url);
|
|
||||||
window.open(
|
window.open(
|
||||||
url,
|
url,
|
||||||
'_blank' // <- This is what makes it open in a new window.
|
'_blank' // <- This is what makes it open in a new window.
|
||||||
|
|||||||
Reference in New Issue
Block a user