diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index 68276391..972808b2 100755 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -25,8 +25,8 @@ class Test extends BaseController $data = $model->obtenerLineasPedidoSinFacturar(999); */ - $model = model("\App\Models\Facturas\FacturaModel"); - $data = $model->getCantidadLineaPedidoFacturada(5); + $model = model("\App\Models\Facturas\FacturaLineaModel"); + $data = $model->getResource(9)->get()->getResultObject(); echo('
');
var_dump($data);
diff --git a/ci4/app/Models/Facturas/FacturaLineaModel.php b/ci4/app/Models/Facturas/FacturaLineaModel.php
index 25fd90ec..50e9f8d8 100644
--- a/ci4/app/Models/Facturas/FacturaLineaModel.php
+++ b/ci4/app/Models/Facturas/FacturaLineaModel.php
@@ -39,8 +39,9 @@ class FacturaLineaModel extends \App\Models\BaseModel {
"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.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.deleted_at", null);
diff --git a/ci4/app/Views/themes/vuexy/form/facturas/_addPedidosItems.php b/ci4/app/Views/themes/vuexy/form/facturas/_addPedidosItems.php
index 35e3ae98..cae8922e 100644
--- a/ci4/app/Views/themes/vuexy/form/facturas/_addPedidosItems.php
+++ b/ci4/app/Views/themes/vuexy/form/facturas/_addPedidosItems.php
@@ -116,12 +116,13 @@ $('#addNewPedidoImpresion').on('click', function(){
},
success: function(response) {
yeniden(response.= csrf_token() ?>);
- $('#pedidoImpresion').val(null).trigger('change');
+
// Se actualiza la tabla de lineas de factura
$('#tableOfLineasFactura').DataTable().clearPipeline();
$('#tableOfLineasFactura').DataTable().ajax.reload();
// se ajustan el ancho de las columnas
$('#tableOfLineasFactura').DataTable().columns.adjust().draw();
+ $('#pedidoImpresion').val(null).trigger('change');
}
});
diff --git a/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php b/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php
index 82739ba0..35202562 100644
--- a/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php
+++ b/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php
@@ -16,16 +16,44 @@
+
= lang('Facturas.unidades') ?>
= lang('Facturas.concepto') ?>
= lang('Facturas.precioUnidad') ?>
= lang('Facturas.iva') ?>
= lang('Facturas.subtotal') ?>
+
+
-
+
+
+ Subtotal:
+
+
+
+
+
+ I.V.A.:
+
+
+
+
+
+ Total:
+
+
+
+
+
+ Pendiente de pago:
+
+
+
+
+
estado =='borrador') : ?>
@@ -50,7 +78,21 @@
=$this->section('additionalInlineJs') ?>
const actionBtns = function(data) {
- return `
+
+ // se comprueba si data es null
+ if (data.pedido_id === null) {
+ return `
+
+
+ `;
+ }
+ else{
+ return `
@@ -59,9 +101,10 @@ const actionBtns = function(data) {
-
+
`;
+ }
};
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: '',
+ cancelTrigger: 'span.cancel',
+ submitHtml: '',
+ submitTrigger: 'span.edit',
+ submit: 'allIfChanged'
+ }
+ );
+} );
+
+
var tableLineas = $('#tableOfLineasFactura').DataTable({
processing: true,
serverSide: true,
@@ -133,11 +191,14 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
{data: null, render: actionBtns},
{data: "pedido_linea_impresion_id"},
{data: "pedido_maquetacion_id"},
+ {data: "pedido_id"},
{data: "unidades"},
{data: "concepto"},
{data: "precio_unidad"},
{data: "iva"},
- {data: "subtotal"}
+ {data: "subtotal"},
+ {data: "total_iva"},
+ {data: "total"},
],
order: [[1, "asc"]],
dom: 't',
@@ -158,10 +219,52 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
},
{
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){
})
}
-
-$('.btn-view_pedido').on('click', function(e){
- var pedido_linea_id = $(this).data('id');
- var url = '= route_to('viewPedidoImpresion', ':id') ?>';
- url = url.replace(':id', pedido_linea_id );
+$(document).on('click', '.btn-view_pedido', function(e) {
+ var pedido_id = $(this).data('id');
+ var url = '= route_to('editarPedido', ':id') ?>';
+ url = url.replace(':id', pedido_id );
+
window.open(url, '_blank');
});
diff --git a/ci4/app/Views/themes/vuexy/form/facturas/viewFacturasList.php b/ci4/app/Views/themes/vuexy/form/facturas/viewFacturasList.php
index 9549da86..d92ce5a8 100644
--- a/ci4/app/Views/themes/vuexy/form/facturas/viewFacturasList.php
+++ b/ci4/app/Views/themes/vuexy/form/facturas/viewFacturasList.php
@@ -49,12 +49,22 @@
const lastColNr = $('#tableOfFacturas').find("tr:first th").length - 1;
const actionBtns = function(data) {
- return `
+ if(data.estado == 'borrador'){
+ return `
+
+
+ `;
+ }
+ else{
+ return `
`;
+ }
};
theTable = $('#tableOfFacturas').DataTable({
diff --git a/ci4/app/Views/themes/vuexy/form/pedidos/_lineasItems.php b/ci4/app/Views/themes/vuexy/form/pedidos/_lineasItems.php
index 9665e763..be7f622a 100644
--- a/ci4/app/Views/themes/vuexy/form/pedidos/_lineasItems.php
+++ b/ci4/app/Views/themes/vuexy/form/pedidos/_lineasItems.php
@@ -130,7 +130,6 @@ $(document).on('click', '.btn-view', function(e) {
var url = '= route_to('editarPresupuestoCliente2', ':id') ?>';
url = url.replace(':id', `${$(this).attr('data-id')}` );
- console.log(url);
window.open(
url,
'_blank' // <- This is what makes it open in a new window.