mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
casi terminado
This commit is contained in:
@ -7,6 +7,7 @@ use App\Models\Collection;
|
||||
use DataTables\Editor;
|
||||
use DataTables\Editor\Field;
|
||||
use DataTables\Editor\Validate;
|
||||
use DataTables\Editor\Format;
|
||||
|
||||
class FacturasPagos extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
@ -61,16 +62,13 @@ class FacturasPagos extends \App\Controllers\BaseResourceController
|
||||
'message' => lang('Facturas.validation.requerido'))
|
||||
),
|
||||
Field::inst( 'fecha_pago_at' )
|
||||
->set( function ($val, $data, $field) {
|
||||
// Convierte la fecha de formato DD/MM/YYYY a YYYY-MM-DD
|
||||
$date = DateTime::createFromFormat('d/m/Y', $val)->format('Y-m-d');
|
||||
return DateTime::createFromFormat('d/m/Y', $val)->format('Y-m-d');
|
||||
}),
|
||||
->validator( Validate::dateFormat( 'Y-m-d H:i:s' ) )
|
||||
->getFormatter( Format::dateSqlToFormat( 'Y-m-d H:i:s' ) )
|
||||
->setFormatter( Format::dateFormatToSql( 'Y-m-d H:i:s' ) ),
|
||||
Field::inst( 'fecha_vencimiento_at' )
|
||||
->set( function ($val, $data, $field) {
|
||||
// Convierte la fecha de formato DD/MM/YYYY a YYYY-MM-DD
|
||||
return DateTime::createFromFormat('d/m/Y', $val)->format('Y-m-d');
|
||||
}),
|
||||
->validator( Validate::dateFormat( 'Y-m-d H:i:s' ) )
|
||||
->getFormatter( Format::dateSqlToFormat( 'Y-m-d H:i:s' ) )
|
||||
->setFormatter( Format::dateFormatToSql( 'Y-m-d H:i:s' ) ),
|
||||
Field::inst( 'total' )
|
||||
->validator('Validate::numeric', array(
|
||||
'message' => lang('Facturas.validation.numerico'))
|
||||
|
||||
@ -3,7 +3,7 @@ namespace App\Models\Configuracion;
|
||||
|
||||
class FormaPagoModel extends \App\Models\BaseModel
|
||||
{
|
||||
protected $table = "lg_formas_pago";
|
||||
protected $table = "formas_pago";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
|
||||
@ -72,7 +72,9 @@ class FacturaModel extends \App\Models\BaseModel {
|
||||
"t1.id AS id, t1.numero AS numero, DATE_FORMAT(t1.fecha_factura_at, '%d/%m/%Y') AS fecha_factura_at,
|
||||
t2.nombre AS cliente, t1.base AS base, t1.total AS total, t1.pendiente AS pendiente,
|
||||
t1.creditoAsegurado AS creditoAsegurado, t1.estado AS estado, t1.estado_pago AS estado_pago,
|
||||
t4.nombre AS forma_pago, DATE_FORMAT(t3.fecha_vencimiento_at, '%d/%m/%Y') AS vencimiento"
|
||||
GROUP_CONCAT(DISTINCT t4.nombre ORDER BY t4.nombre ASC SEPARATOR ', ') AS forma_pago,
|
||||
DATE_FORMAT(MIN(CASE WHEN t3.fecha_vencimiento_at != '0000-00-00 00:00:00' THEN t3.fecha_vencimiento_at ELSE NULL END), '%d/%m/%Y') AS vencimiento,
|
||||
t2.vencimiento AS dias_vencimiento"
|
||||
);
|
||||
|
||||
$builder->join("clientes t2", "t2.id = t1.cliente_id", "left");
|
||||
@ -80,6 +82,7 @@ class FacturaModel extends \App\Models\BaseModel {
|
||||
$builder->join("formas_pago t4", "t3.forma_pago_id = t4.id", "left");
|
||||
|
||||
$builder->where("t1.deleted_at IS NULL");
|
||||
$builder->groupBy("t1.id"); // Agrupa por id de la factura
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<div class="row">
|
||||
<div id="addPagoRow" class="row">
|
||||
<div class="col-md-12 col-lg-2">
|
||||
<button
|
||||
type="button"
|
||||
@ -50,6 +50,10 @@
|
||||
<?=$this->section('additionalInlineJs') ?>
|
||||
|
||||
const formas_pago = <?= json_encode($facturaEntity->formas_pago) ?>;
|
||||
var formaPagoLookup = {};
|
||||
formas_pago.forEach(function(pago) {
|
||||
formaPagoLookup[pago.value] = pago.label;
|
||||
});
|
||||
|
||||
const actionBtns_pagos = function(data) {
|
||||
return `
|
||||
@ -92,12 +96,21 @@ var editor_pagos = new $.fn.dataTable.Editor( {
|
||||
{
|
||||
name: "fecha_pago_at",
|
||||
type: "datetime",
|
||||
format: "DD/MM/YYYY"
|
||||
def: function () {
|
||||
return new Date().toISOString().split('T')[0]; // YYYY-MM-DD
|
||||
},
|
||||
wireFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
displayFormat: 'DD/MM/YYYY',
|
||||
},
|
||||
{
|
||||
name: "fecha_vencimiento_at",
|
||||
type: "datetime",
|
||||
format: "DD/MM/YYYY"
|
||||
def: () => new Date(),
|
||||
def: function () {
|
||||
return new Date().toISOString().split('T')[0]; // YYYY-MM-DD
|
||||
},
|
||||
wireFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
displayFormat: 'DD/MM/YYYY',
|
||||
},
|
||||
{
|
||||
name: "id",
|
||||
@ -146,7 +159,12 @@ var tablePagos = $('#tableOfLineasPagos').DataTable({
|
||||
className: 'row-edit dt-center'
|
||||
},
|
||||
{data: "id"},
|
||||
{data: "forma_pago_id"},
|
||||
{
|
||||
data: "forma_pago_id",
|
||||
render: function(data, type, row) {
|
||||
return formaPagoLookup[data] || data;
|
||||
}
|
||||
},
|
||||
{data: "notes"},
|
||||
{
|
||||
data: "fecha_vencimiento_at",
|
||||
@ -183,7 +201,16 @@ var tablePagos = $('#tableOfLineasPagos').DataTable({
|
||||
{
|
||||
visible: false,
|
||||
targets: [1]
|
||||
}
|
||||
},
|
||||
{
|
||||
width: '40%', // Ajusta el ancho para la columna de notas
|
||||
targets: 3
|
||||
},
|
||||
{
|
||||
width: '10%', // Ajusta el ancho para la columna de notas
|
||||
targets: [4, 5, 6]
|
||||
},
|
||||
|
||||
],
|
||||
footerCallback: function (row, data, start, end, display) {
|
||||
var api = this.api();
|
||||
@ -268,7 +295,11 @@ function updateFooterLineas(table){
|
||||
pendiente: pendientePago
|
||||
}
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
//console.log(data);
|
||||
if($('#pendiente-pago').html() == '0.00'){
|
||||
$('#addPagoRow').hide();
|
||||
} else {
|
||||
$('#validarFactura').show();
|
||||
}
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||
})
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
<th><?= lang('Facturas.estadoPago') ?></th>
|
||||
<th><?= lang('Facturas.formaPago') ?></th>
|
||||
<th><?= lang('Facturas.vencimiento') ?></th>
|
||||
<th><?= lang('Facturas.dias') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -196,13 +197,14 @@
|
||||
break;
|
||||
|
||||
default:
|
||||
return '--'; // Debug
|
||||
return data; // Debug
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
{ 'data': 'vencimiento' },
|
||||
{ 'data': 'dias_vencimiento' },
|
||||
{ 'data': actionBtns }
|
||||
]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user