mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
listado de facturas terminado. trabajando en añadir
This commit is contained in:
@ -6,6 +6,23 @@ class FacturaModel extends \App\Models\BaseModel {
|
||||
|
||||
protected $table = 'facturas';
|
||||
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.id",
|
||||
1 => "t1.numero",
|
||||
2 => "t1.fecha_factura_at",
|
||||
3 => "t2.nombre",
|
||||
4 => "t1.base",
|
||||
5 => "t1.total",
|
||||
6 => "t1.pendiente",
|
||||
7 => "t1.creditoAsegurado",
|
||||
8 => "t1.estado",
|
||||
9 => "t1.estado_pago",
|
||||
10 => "t4.nombre",
|
||||
11 => "DAFEDIFF(days, NOW(), t3.fecha_vencimiento_at)",
|
||||
];
|
||||
|
||||
// Lista de columnas basada en los campos de la tabla, para asignación masiva
|
||||
protected $allowedFields = [
|
||||
'pedido_id',
|
||||
@ -47,4 +64,30 @@ class FacturaModel extends \App\Models\BaseModel {
|
||||
|
||||
public static $labelField = "id";
|
||||
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.numero AS numero, t1.fecha_factura_at 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, t3.fecha_vencimiento_at AS venciemento,
|
||||
DAFEDIFF(days, NOW(), t3.fecha_vencimiento_at) AS dias"
|
||||
//'DATEDIFF((SELECT MIN(facturas_pagos.fecha_vencimiento_at) FROM facturas_pagos WHERE facturas_pagos.deleted_at is null and factura_id = facturas.id), facturas.fecha_factura_at)
|
||||
);
|
||||
|
||||
$builder->join("clientes t2", "t2.id = t1.cliente_id", "left");
|
||||
$builder->join("facturas_pagos t3", "t3.factura_id = t1.id", "left");
|
||||
$builder->join("formas_pago t4", "t3.forma_pago_id = t4.id", "left");
|
||||
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user