mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
101 lines
2.8 KiB
PHP
101 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use CodeIgniter\Config\BaseService;
|
|
use App\Models\Configuracion\TipoPapelGenericoModel;
|
|
use App\Models\Configuracion\PapelGenericoModel;
|
|
|
|
class PapelService extends BaseService
|
|
{
|
|
protected TipoPapelGenericoModel $tipoPapelGenericoModel;
|
|
protected PapelGenericoModel $papelGenericoModel;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->tipoPapelGenericoModel = model(TipoPapelGenericoModel::class);
|
|
$this->papelGenericoModel = model(PapelGenericoModel::class);
|
|
}
|
|
|
|
public function getTipoPapelGenerico()
|
|
{
|
|
$values = $this->tipoPapelGenericoModel->findAll();
|
|
$tipoPapelGenericoList = [];
|
|
foreach ($values as $value) {
|
|
$tipoPapelGenericoList[$value->id] = lang('PapelGenerico.' . $value->clave);
|
|
}
|
|
|
|
return $tipoPapelGenericoList;
|
|
}
|
|
|
|
/**
|
|
* Obtencion de los tipos de papel genérico dependiendo del uso
|
|
* @param object $data
|
|
* @return array
|
|
*/
|
|
public function getTiposPalelGenerico($data)
|
|
{
|
|
|
|
if (!isset($data) || empty($data)) {
|
|
return [];
|
|
}
|
|
|
|
$tirada = (int)$data->tirada ?? null;
|
|
$POD = null;
|
|
if ($tirada != null) {
|
|
$POD_value = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
|
if (intval($tirada) <= intval($POD_value)) {
|
|
$POD = true;
|
|
} else {
|
|
$POD = false;
|
|
}
|
|
}
|
|
$tipo = $data->tipo;
|
|
$cubierta = $data->cubierta ?? 0;
|
|
$tapa_dura = $data->tapa_dura ?? null;
|
|
$sobrecubierta = $data->sobrecubierta ?? 0;
|
|
$guardas = $data->guardas ?? 0;
|
|
|
|
$ancho = $data->ancho ?? 0;
|
|
$alto = $data->alto ?? 0;
|
|
$solapas = $data->solapas ?? 0;
|
|
$lomo = $data->lomo ?? 0;
|
|
|
|
$anchoLibro = $ancho;
|
|
|
|
if (intval($cubierta) == 1 || intval($sobrecubierta) == 1) {
|
|
$anchoLibro = 2 * $ancho + 2 * $solapas + $lomo;
|
|
}
|
|
|
|
$data_output = (object)
|
|
[
|
|
'tipo' => $tipo,
|
|
'cubierta' => $cubierta,
|
|
'tapa_dura' => $tapa_dura,
|
|
'sobrecubierta' => $sobrecubierta,
|
|
'guardas' => $guardas,
|
|
'ancho' => $anchoLibro,
|
|
'alto' => $alto,
|
|
'solapas' => $solapas,
|
|
'lomo' => $lomo,
|
|
'anchoLibro' => $anchoLibro,
|
|
'tirada' => $tirada,
|
|
'POD' => $POD
|
|
];
|
|
|
|
$list = $this->tipoPapelGenericoModel->getTiposPapelCliente($data_output);
|
|
|
|
return $list;
|
|
|
|
|
|
/*
|
|
$values = $this->papelGenericoModel->where('uso', $uso)->findAll();
|
|
$tipoPapelGenericoList = [];
|
|
foreach ($values as $value) {
|
|
$tipoPapelGenericoList[$value->id] = lang('PapelGenerico.' . $value->clave);
|
|
}
|
|
|
|
return $tipoPapelGenericoList;
|
|
*/
|
|
}
|
|
} |