mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
|
||||
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;
|
||||
@ -10,11 +12,15 @@ 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()
|
||||
@ -40,7 +46,7 @@ class PapelService extends BaseService
|
||||
return [];
|
||||
}
|
||||
|
||||
$tirada = (int)$data->tirada ?? null;
|
||||
$tirada = (int) $data->tirada ?? null;
|
||||
$POD = null;
|
||||
if ($tirada != null) {
|
||||
$POD_value = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
@ -63,39 +69,176 @@ class PapelService extends BaseService
|
||||
|
||||
$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
|
||||
];
|
||||
$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)
|
||||
{
|
||||
|
||||
/*
|
||||
$values = $this->papelGenericoModel->where('uso', $uso)->findAll();
|
||||
$tipoPapelGenericoList = [];
|
||||
foreach ($values as $value) {
|
||||
$tipoPapelGenericoList[$value->id] = lang('PapelGenerico.' . $value->clave);
|
||||
if (!isset($data) || empty($data)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $tipoPapelGenericoList;
|
||||
*/
|
||||
$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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user