mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
244 lines
7.4 KiB
PHP
244 lines
7.4 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Models\Clientes\ClienteModel;
|
|
use App\Models\Configuracion\PapelImpresionModel;
|
|
use CodeIgniter\Config\BaseService;
|
|
use App\Models\Configuracion\TipoPapelGenericoModel;
|
|
use App\Models\Configuracion\PapelGenericoModel;
|
|
|
|
class PapelService extends BaseService
|
|
{
|
|
protected TipoPapelGenericoModel $tipoPapelGenericoModel;
|
|
protected PapelGenericoModel $papelGenericoModel;
|
|
protected PapelImpresionModel $papelImpresionModel;
|
|
protected ClienteModel $clienteModel;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->tipoPapelGenericoModel = model(TipoPapelGenericoModel::class);
|
|
$this->papelGenericoModel = model(PapelGenericoModel::class);
|
|
$this->papelImpresionModel = model(PapelImpresionModel::class);
|
|
$this->clienteModel = model(ClienteModel::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;
|
|
|
|
$cliente_id = $data->cliente_id ?? null;
|
|
$forzar_rotativa_POD = false;
|
|
if (isset($cliente_id) && !is_null($cliente_id)) {
|
|
$cliente = $this->clienteModel->find($cliente_id);
|
|
if ($cliente && isset($cliente->forzar_rotativa_pod)) {
|
|
$forzar_rotativa_POD = boolval($cliente->forzar_rotativa_pod);
|
|
}
|
|
}
|
|
|
|
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,
|
|
'forzar_rotativa_POD' => $forzar_rotativa_POD
|
|
];
|
|
|
|
$list = $this->tipoPapelGenericoModel->getTiposPapelCliente($data_output);
|
|
|
|
return $list;
|
|
}
|
|
|
|
/**
|
|
* Obtencion de los tipos de papel genérico dependiendo del uso para un tipo de papel específico
|
|
* @param object $data
|
|
* @return array
|
|
*/
|
|
public function getPapelGenerico($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;
|
|
|
|
$tipo_papel_generico_id = $data->tipo_papel_generico_id ?? null;
|
|
|
|
$anchoLibro = $ancho;
|
|
|
|
if (intval($cubierta) == 1 || intval($sobrecubierta) == 1) {
|
|
$anchoLibro = 2 * $ancho + 2 * $solapas + $lomo;
|
|
}
|
|
|
|
$data_output = (object)
|
|
[
|
|
'tipo' => $tipo,
|
|
'tipo_papel_generico_id' => $tipo_papel_generico_id,
|
|
'cubierta' => $cubierta,
|
|
'tapa_dura' => $tapa_dura,
|
|
'sobrecubierta' => $sobrecubierta,
|
|
'guardas' => $guardas,
|
|
'ancho' => $anchoLibro,
|
|
'alto' => $alto,
|
|
'solapas' => $solapas,
|
|
'lomo' => $lomo,
|
|
'anchoLibro' => $anchoLibro,
|
|
'tirada' => $tirada,
|
|
'POD' => $POD
|
|
];
|
|
|
|
if (isset($data->selected_tipo_id)) {
|
|
$data_output->selected_tipo_id = $data->selected_tipo_id;
|
|
}
|
|
|
|
$list = $this->papelGenericoModel->getPapelGenericoCliente($data_output);
|
|
|
|
return $list;
|
|
}
|
|
|
|
/**
|
|
* Obtencion de los tipos de papel genérico dependiendo del uso para un tipo de papel específico
|
|
* @param object $data
|
|
* @return array
|
|
*/
|
|
public function getGramajes($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;
|
|
|
|
|
|
$forzar_rotativa_POD = $data->forzar_rotativa_POD ?? false;
|
|
|
|
|
|
$papel_id = $data->papel_id ?? null;
|
|
|
|
$anchoLibro = $ancho;
|
|
|
|
if (intval($cubierta) == 1 || intval($sobrecubierta) == 1) {
|
|
$anchoLibro = 2 * $ancho + 2 * $solapas + $lomo;
|
|
}
|
|
|
|
$data_output = (object)
|
|
[
|
|
'tipo' => $tipo,
|
|
'papel_id' => $papel_id,
|
|
'cubierta' => $cubierta,
|
|
'tapa_dura' => $tapa_dura,
|
|
'sobrecubierta' => $sobrecubierta,
|
|
'guardas' => $guardas,
|
|
'ancho' => $anchoLibro,
|
|
'alto' => $alto,
|
|
'solapas' => $solapas,
|
|
'lomo' => $lomo,
|
|
'anchoLibro' => $anchoLibro,
|
|
'tirada' => $tirada,
|
|
'POD' => $POD
|
|
];
|
|
|
|
if (isset($data->selected_tipo_id)) {
|
|
$data_output->selected_tipo_id = $data->selected_tipo_id;
|
|
}
|
|
|
|
$list = $this->papelImpresionModel->getGramajeCliente($data_output);
|
|
|
|
return $list;
|
|
}
|
|
} |