Inciado link presupuesto PDF con backend

This commit is contained in:
imnavajas
2024-01-15 22:09:18 +01:00
parent 74e25dfa84
commit b62a5d1b9a
3 changed files with 67 additions and 26 deletions

View File

@ -1,4 +1,5 @@
<?php
namespace App\Models\Presupuestos;
class PresupuestoModel extends \App\Models\GoBaseModel
@ -258,7 +259,7 @@ class PresupuestoModel extends \App\Models\GoBaseModel
],
"inc_rei" => [
"integer" => "Presupuestos.validation.integer",
],
"coleccion" => [
"max_length" => "Presupuestos.validation.max_length",
@ -277,8 +278,9 @@ class PresupuestoModel extends \App\Models\GoBaseModel
],
"referencia_cliente" => [
"max_length" => "Presupuestos.validation.max_length",
],
],
];
public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0)
{
$sql =
@ -324,14 +326,14 @@ class PresupuestoModel extends \App\Models\GoBaseModel
$builder->where("t1.is_deleted", 0);
if(empty($search))
if (empty($search))
return $builder;
else{
else {
$builder->groupStart();
foreach($search as $col_search){
if($col_search[0] != 1)
foreach ($search as $col_search) {
if ($col_search[0] != 1)
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
else{
else {
$dates = explode(" ", $col_search[2]);
$builder->where(self::SORTABLE[$col_search[0]] . ">=", $dates[0]);
$builder->where(self::SORTABLE[$col_search[0]] . "<=", $dates[1]);
@ -340,6 +342,41 @@ class PresupuestoModel extends \App\Models\GoBaseModel
$builder->groupEnd();
return $builder;
}
}
/**
* Get resource data.
*
* @param string $search
*
* @return \CodeIgniter\Database\BaseBuilder
*/
public function getResourceForPdf($presupuesto_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.created_at AS fecha, t1.titulo AS titulo, t1.autor AS autor, t1.ferro AS ferro,
t1.ferro_digital AS ferro_digital, t1.prototipo AS prototipo, t1.solapas AS solapas,
t1.solapas_ancho AS solapas_ancho, t1.paginas AS paginas, t1.tirada AS tirada, t1.coleccion AS coleccion,
t1.total_presupuesto AS total_presupuesto, t1.total_precio_unidad AS total_precio_unidad,
t2.nombre AS cliente,
CONCAT(t3.first_name, ' ', t3.last_name) AS comercial, t3.email AS email_comercial,
t1.inc_rei AS inc_rei,
t6.estado AS estado"
);
$builder->join("clientes t2", "t1.cliente_id = t2.id", "left");
$builder->join("auth_user t3", "t1.user_update_id = t3.id_user", "left");
$builder->join("presupuesto_estados t6", "t1.estado_id = t6.id", "left");
$builder->where("t1.is_deleted", 0);
$builder->where("t1.id", $presupuesto_id);
return $builder;
}
}