mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into 'dev/criba_tabla_presupuestos'
# Conflicts: # ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php
This commit is contained in:
@ -89,4 +89,28 @@ class PresupuestoDireccionesModel extends \App\Models\GoBaseModel
|
||||
->orLike("t1.telefono", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data for pdf generation.
|
||||
*
|
||||
* @param int $presupuesto_id
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResourceForPdf($presupuesto_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.direccion AS direccion, t2.nombre AS pais,
|
||||
t1.municipio AS municipio, t1.provincia AS provincia, t1.cp AS cp, t1.telefono AS telefono,
|
||||
t1.cantidad AS cantidad"
|
||||
);
|
||||
|
||||
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
||||
$builder->join("lg_paises t2", "t1.pais_id = t2.id", "left");
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Presupuestos;
|
||||
|
||||
class PresupuestoLineaModel extends \App\Models\GoBaseModel
|
||||
@ -307,17 +308,18 @@ class PresupuestoLineaModel extends \App\Models\GoBaseModel
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function createForPresupuesto($presupuesto_id){
|
||||
public function createForPresupuesto($presupuesto_id)
|
||||
{
|
||||
|
||||
$tipos = ['bn','bnhq','color','colorhq','cubierta','sobrecubierta','rot_bn','rot_color'];
|
||||
foreach($tipos as $tipo){
|
||||
$tipos = ['bn', 'bnhq', 'color', 'colorhq', 'cubierta', 'sobrecubierta', 'rot_bn', 'rot_color'];
|
||||
foreach ($tipos as $tipo) {
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1");
|
||||
->table($this->table . " t1");
|
||||
$data = [
|
||||
'presupuesto_id' => $presupuesto_id,
|
||||
'tipo' => $tipo,
|
||||
'presupuesto_id' => $presupuesto_id,
|
||||
'tipo' => $tipo,
|
||||
];
|
||||
|
||||
|
||||
$builder->insert($data);
|
||||
}
|
||||
}
|
||||
@ -330,30 +332,58 @@ class PresupuestoLineaModel extends \App\Models\GoBaseModel
|
||||
"*"
|
||||
)
|
||||
->where("t1.presupuesto_id", $presupuesto_id);
|
||||
|
||||
|
||||
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||
}
|
||||
|
||||
public function deleteLineasPresupuesto($presupuesto_id){
|
||||
public function deleteLineasPresupuesto($presupuesto_id)
|
||||
{
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->where("presupuesto_id", $presupuesto_id)
|
||||
->delete();
|
||||
}
|
||||
|
||||
public function insertLineasPresupuesto($presupuesto_id = -1, $datos=[])
|
||||
public function insertLineasPresupuesto($presupuesto_id = -1, $datos = [])
|
||||
{
|
||||
$this->deleteLineasPresupuesto($presupuesto_id);
|
||||
|
||||
foreach($datos as $linea){
|
||||
|
||||
foreach ($datos as $linea) {
|
||||
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->where("t1.presupuesto_id", $presupuesto_id)
|
||||
->insert($linea);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getResourceByNForPdf($presupuesto_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.paginas AS paginas, t1.papel_impresion AS papel, t1.gramaje AS gramaje"
|
||||
)
|
||||
->where("t1.presupuesto_id", $presupuesto_id)
|
||||
->whereIn('t1.tipo', ['lp_bn', 'lp_bnhq', 'lp_rot_bn']);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getResourceColorForPdf($presupuesto_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.paginas AS paginas, t1.papel_impresion AS papel, t1.gramaje AS gramaje"
|
||||
)
|
||||
->where("t1.presupuesto_id", $presupuesto_id)
|
||||
->whereIn('t1.tipo', ['lp_color', 'lp_colorhq', 'lp_rot_color']);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Presupuestos;
|
||||
|
||||
class PresupuestoModel extends \App\Models\GoBaseModel
|
||||
@ -159,7 +160,7 @@ class PresupuestoModel extends \App\Models\GoBaseModel
|
||||
],
|
||||
"inc_rei" => [
|
||||
"integer" => "Presupuestos.validation.integer",
|
||||
|
||||
|
||||
],
|
||||
"coleccion" => [
|
||||
"max_length" => "Presupuestos.validation.max_length",
|
||||
@ -178,8 +179,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 =
|
||||
@ -235,14 +237,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]);
|
||||
@ -251,6 +253,43 @@ class PresupuestoModel extends \App\Models\GoBaseModel
|
||||
$builder->groupEnd();
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
*
|
||||
* @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.retractilado AS retractilado, t1.guardas AS guardas, t1.marcapaginas AS marcapaginas,
|
||||
t1.comentarios_pdf AS comentarios_pdf,
|
||||
t1.total_presupuesto AS total_presupuesto, t1.total_precio_unidad AS total_precio_unidad,
|
||||
t1.papel_formato_personalizado AS isPersonalizado, t1.envios_recoge_cliente AS recoge_cliente,
|
||||
CONCAT(t1.papel_formato_ancho, 'x', t1.papel_formato_alto) AS formatoPersonalizado,
|
||||
t2.nombre AS cliente,
|
||||
CONCAT(t3.first_name, ' ', t3.last_name) AS comercial, t3.email AS email_comercial,
|
||||
CONCAT(t4.ancho, 'x', t4.alto) AS formato"
|
||||
);
|
||||
$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("lg_papel_formato t4", "t1.papel_formato_id = t4.id", "left");
|
||||
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
$builder->where("t1.id", $presupuesto_id);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user