cambiado POD para cogerlo de la nueva tabla de variables

This commit is contained in:
2024-12-26 16:28:26 +01:00
parent afb7ca0812
commit 93d3793ef9
6 changed files with 17 additions and 63 deletions

View File

@ -301,7 +301,7 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
$tirada = goSanitize($this->request->getGet('tirada'))[0] ?? null;
$POD = null;
if($tirada != null){
$POD_value = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
$POD_value = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
if(intval($tirada) <= intval($POD_value)){
$POD = true;
}
@ -339,7 +339,7 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
$tirada = goSanitize($this->request->getGet('tirada'))[0] ?? null;
$POD = null;
if($tirada != null){
$POD_value = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
$POD_value = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
if(intval($tirada) <= intval($POD_value)){
$POD = true;
}

View File

@ -1246,8 +1246,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
protected function getPOD()
{
$model = model('App\Models\Configuracion\ConfiguracionSistemaModel');
return $model->getPOD();
return model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
}
protected function getLineasPresupuesto($presupuestoEntity){

View File

@ -110,7 +110,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
}
}
$POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_presupuestos"), 'route' => site_url('presupuestocliente/list'), 'active' => false],
@ -161,7 +161,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$this->viewData['paisList'] = $this->getPaisListItems();
$this->viewData['clienteId'] = $clienteId;
$this->viewData['POD'] = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
$this->viewData['POD'] = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
// Si se ha llamado a esta funcion porque se ha duplicado el presupuesto
// se actualiza la bbdd para que sólo ejecute algunas funciones una vez
if ($presupuestoEntity->is_duplicado) {
@ -480,7 +480,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$reqData = $this->request->getPost();
$modelPapelGenerico = new PapelGenericoModel();
$POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
$cliente_id = $reqData['clienteId'] ?? -1;
@ -719,7 +719,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$reqData = $this->request->getPost();
$POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
$id = $reqData['id'] ?? 0;
$id = intval($id);
@ -1486,7 +1486,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$coste_servicios = 0.0;
$POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
$precio_u = [];
$peso = [];

View File

@ -1,17 +0,0 @@
<?php
namespace App\Entities\Configuracion;
use CodeIgniter\Entity;
class ConfiguracionSistemaEntity extends \CodeIgniter\Entity\Entity
{
protected $attributes = [
"id" => null,
"var_name" => null,
"value" => null,
"datatype" => null,
];
protected $casts = [
];
}

View File

@ -47,4 +47,13 @@ class ConfigVariableModel extends Model
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
public function getVariable($name)
{
$builder = $this->db
->table($this->table . " t1")
->where('name', $name);
return $builder->get()->getFirstRow();
}
}

View File

@ -1,37 +0,0 @@
<?php
namespace App\Models\Configuracion;
class ConfiguracionSistemaModel extends \App\Models\BaseModel
{
protected $table = "configuracion_sistema";
/**
* Whether primary key uses auto increment.
*
* @var bool
*/
protected $useAutoIncrement = true;
protected $allowedFields = ["var_name", "value", "datatype"];
protected $returnType = "App\Entities\Configuracion\ConfiguracionSistemaEntity";
public static $labelField = "var_name";
protected $validationRules = [
];
protected $validationMessages = [
];
public function getPOD()
{
$builder = $this->db
->table($this->table . " t1")
->select(
'(SELECT CAST(t1.value AS INT)) AS POD', false)
->where('t1.var_name', 'POD');
$POD = intval($builder->get()->getFirstRow()->POD);
return $POD;
}
}