trabajando

This commit is contained in:
2025-07-21 11:52:20 +02:00
parent 7bb6329783
commit 40b53dc1e3
3 changed files with 99 additions and 43 deletions

View File

@ -308,38 +308,7 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
$data_input = $this->request->getGet();
$result = $this->papelService->getTiposPalelGenerico((object)$data_input);
/*
$tirada = goSanitize($this->request->getGet('tirada'))[0] ?? 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 = goSanitize($this->request->getGet('tipo'))[0];
$selected_papel = goSanitize($this->request->getGet('papel'))[0] ?? null;
$cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
$tapa_dura = goSanitize($this->request->getGet('tapa_dura'))[0] ?? null;
$sobrecubierta = goSanitize($this->request->getGet('sobrecubierta'))[0] ?? 0;
$guardas = goSanitize($this->request->getGet('guardas'))[0] ?? 0;
$ancho = floatval($this->request->getGet('ancho') ?? 0);
$alto = floatval($this->request->getGet('alto') ?? 0);
$solapas = floatval($this->request->getGet('solapas') ?? 0);
$lomo = floatval($this->request->getGet('lomo') ?? 0);
$anchoLibro = $ancho;
if(intval($cubierta) == 1 || intval($sobrecubierta) == 1){
$anchoLibro = 2 * $ancho + 2 * $solapas + $lomo;
}
$menu = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, $guardas, $selected_papel, $tapa_dura, false, $POD, $anchoLibro, $alto, $tirada);
*/
return $this->respond($result);
} else {

View File

@ -18,8 +18,11 @@ class TipoPapelGenericoModel extends \App\Models\BaseModel
];
protected $returnType = "App\Entities\Configuracion\TipoPapelGenerico";
public function getTiposPapel($data)
public function getTiposPapelCliente($data)
{
if (!isset($data) || empty($data)) {
return [];
}
$builder = $this->db
->table($this->table . " t1")
->select(
@ -39,11 +42,11 @@ class TipoPapelGenericoModel extends \App\Models\BaseModel
->where("t3.use_in_client", 1)
->where("t4.active", 1)
->where("t5.is_deleted", 0)
->where("t5.min <= ", $data['tirada'] ?? 0)
->where("t5.max >= ", $data['tirada'] ?? 0)
->where("t5.min <= ", $data->tirada ?? 0)
->where("t5.max >= ", $data->tirada ?? 0)
->where("t5.tipo", "impresion")
->where("t6.is_deleted", 0)
->where("t6.tipo", $data['tipo'] ?? null)
->where("t6.tipo", $data->tipo ?? null)
->distinct('t1.id');
// Validación adicional para asegurar que t1.id esté presente en las combinaciones con t3.active = 1
@ -57,18 +60,54 @@ class TipoPapelGenericoModel extends \App\Models\BaseModel
$builder->groupStart()
->groupStart()
->where("t5.ancho_impresion >", $data['ancho'] ?? 0)
->where("t5.alto_impresion >", $data['alto'] ?? 0)
->where("t5.ancho_impresion >", $data->ancho ?? 0)
->where("t5.alto_impresion >", $data->alto ?? 0)
->groupEnd()
->orGroupStart()
->where("t5.ancho_impresion >", $data['alto'] ?? 0)
->where("t5.alto_impresion >", $data['ancho'] ?? 0)
->where("t5.ancho_impresion >", $data->alto ?? 0)
->where("t5.alto_impresion >", $data->ancho ?? 0)
->groupEnd()
->orGroupStart()
->where("t5.ancho_impresion >", $data['alto'] ?? 0)
->where("t5.ancho_impresion >", $data->alto ?? 0)
->where("t5.is_rotativa", 1)
->groupEnd()
->groupEnd();
if ($data->cubierta == true) {
$builder->where("t3.cubierta", 1);
$builder->where("t6.uso", 'cubierta');
if ($data->tapa_dura == true) {
$builder->where("t3.use_for_tapa_dura", 1);
}
} else if ($data->sobrecubierta == true) {
$builder->where("t3.sobrecubierta", 1);
$builder->where("t6.uso", 'sobrecubierta');
} else if ($data->guardas == true) {
$builder->where("t3.guardas", 1);
$builder->where("t6.uso", 'interior');
} else {
$builder->where("t3.interior", 1);
$builder->where("t6.uso", 'interior');
if ($data->tipo == 'negro' || $data->tipo == 'negrohq')
$builder->where("t3.bn", 1);
else if ($data->tipo == 'color' || $data->tipo == 'colorhq')
$builder->where("t3.color", 1);
}
if ($data->tipo == 'colorhq' || $data->tipo == 'negrohq') {
$builder->where("t3.rotativa", 0);
} else {
if ($data->POD == false) {
$builder->where("t3.rotativa", 1);
} else if ($data->POD == true) {
$builder->where("t3.rotativa", 0);
}
}
$return_data = $builder->orderBy("t1.clave", "asc")->get()->getResultObject();
//$query = $this->db->getLastQuery();
return $return_data;
}
}

View File

@ -33,13 +33,61 @@ class PapelService extends BaseService
* @param object $data
* @return array
*/
public function getTiposPalelGenerico($data){
public function getTiposPalelGenerico($data)
{
if(!isset($data) || empty($data)){
if (!isset($data) || empty($data)) {
return [];
}
return $this->papelGenericoModel->where('tipo_papel_generico_id !=', null)->findAll();
$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 = [];