mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Preparada factura en PDF
This commit is contained in:
@ -102,6 +102,40 @@ class FacturaModel extends \App\Models\BaseModel {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResourceForPdf($factura_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.numero AS numero, DATE_FORMAT(t1.fecha_factura_at, '%d/%m/%Y') AS fecha_factura_at,
|
||||
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(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.nombre AS cliente, t2.direccion AS cliente_direccion, t2.ciudad AS cliente_ciudad,
|
||||
t2.cp AS cliente_cp, t2.cif AS cliente_cif, t2.vencimiento AS dias_vencimiento, t2.ccc AS cliente_ccc,
|
||||
t5.nombre AS cliente_pais"
|
||||
);
|
||||
|
||||
$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");
|
||||
$builder->join("lg_paises t5", "t2.pais_id = t5.id", "left");
|
||||
|
||||
$builder->where("t1.deleted_at IS NULL");
|
||||
$builder->groupBy("t1.id"); // Agrupa por id de la factura
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
public function getResourcePedidos($pedido_id)
|
||||
{
|
||||
$builder = $this->db
|
||||
|
||||
Reference in New Issue
Block a user