añadidos los get para las lineas de presupuesto borrados por error

This commit is contained in:
2025-01-15 09:16:44 +01:00
parent 1722dbecdb
commit 2fc1c637ed

View File

@ -1041,6 +1041,226 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
}
}
public function getPapelGenerico()
{
if ($this->request->isAJAX()) {
$POD_value = $this->getPOD();
$tirada = $this->request->getGet("tirada");
$isPOD = intval($tirada) <= intval($POD_value);
$tipo_impresion_id = $this->request->getGet("tipo_impresion");
$tapa_dura = model('App\Models\Configuracion\TipoPresupuestoModel')->get_isTapaDura(intval($tipo_impresion_id));
$tipo = $this->request->getGet("tipo");
$uso = $this->request->getGet("uso") ?? 'interior';
$cubierta = false;
if ($uso == 'cubierta') {
$cubierta = true;
}
$sobrecubierta = false;
if ($uso == 'sobrecubierta') {
$sobrecubierta = true;
}
$guardas = false;
if ($uso == 'guardas') {
$guardas = true;
}
$rotativa = false;
if ($uso == 'rotativa') {
$rotativa = true;
}
$model = model('App\Models\Configuracion\PapelGenericoModel');
$query = $model->getPapelForComparador($tipo, $cubierta, $sobrecubierta, $rotativa, $guardas, $tapa_dura, $isPOD);
if ($this->request->getGet("q")) {
$query->groupStart()
->orLike("lg_papel_generico.nombre", $this->request->getGet("q"))
->groupEnd();
}
return $this->response->setJSON($query->orderBy("t1.nombre", "asc")->get()->getResultObject());
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function getGramaje()
{
if ($this->request->isAJAX()) {
$papel_generico_id = $this->request->getGet("papel_generico");
$POD_value = $this->getPOD();
$tirada = $this->request->getGet("tirada");
$isPOD = intval($tirada) <= intval($POD_value);
$tipo_impresion_id = $this->request->getGet("tipo_impresion");
$tapa_dura = model('App\Models\Configuracion\TipoPresupuestoModel')->get_isTapaDura(intval($tipo_impresion_id));
$tipo = $this->request->getGet("tipo");
$uso = $this->request->getGet("uso") ?? 'interior';
$cubierta = false;
if ($uso == 'cubierta') {
$cubierta = true;
}
$sobrecubierta = false;
if ($uso == 'sobrecubierta') {
$sobrecubierta = true;
}
$guardas = false;
if ($uso == 'guardas') {
$guardas = true;
}
$rotativa = false;
if ($uso == 'rotativa') {
$rotativa = true;
}
$model = model('App\Models\Configuracion\PapelGenericoModel');
$query = $model->getGramajeForComparador($tipo, $papel_generico_id, $cubierta, $sobrecubierta, $rotativa, $guardas, $tapa_dura, $isPOD);
if ($this->request->getGet("q")) {
$query->groupStart()
->orLike("lg_papel_impresion.gramaje", $this->request->getGet("q"))
->groupEnd();
}
return $this->response->setJSON($query->orderBy("t2.gramaje", "asc")->get()->getResultObject());
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function getPapelImpresion()
{
if ($this->request->isAJAX()) {
$papel_generico_id = $this->request->getGet('papel_generico');
$gramaje = $this->request->getGet('gramaje');
$tipo_impresion_id = $this->request->getGet("tipo_impresion");
$tapa_dura = model('App\Models\Configuracion\TipoPresupuestoModel')->get_isTapaDura(intval($tipo_impresion_id));
$tipo = $this->request->getGet("tipo");
$uso = $this->request->getGet("uso") ?? 'interior';
$model = model('App\Models\Configuracion\PapelImpresionModel');
$query = $model->getPapelesImpresionForMenu(
$papel_generico_id,
$gramaje,
$tipo,
$uso,
$tapa_dura,
false
);
if ($this->request->getGet("q")) {
$query->groupStart()
->orLike("lg_papel_impresion.nombre", $this->request->getGet("q"))
->groupEnd();
}
return $this->response->setJSON($query->orderBy("t1.nombre", "asc")->get()->getResultObject());
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function getMaquinas()
{
if ($this->request->isAJAX()) {
$ancho = $this->request->getGet('ancho');
$alto = $this->request->getGet('alto');
$tirada = $this->request->getGet('tirada');
$merma = $this->request->getGet('merma');
$tipo_impresion_id = $this->request->getGet('tipo_impresion');
$isCosido = (new TipoPresupuestoModel())->get_isCosido($tipo_impresion_id);
$papel_impresion_id = $this->request->getGet('papel_impresion');
$tarifa_tipo = $this->request->getGet("tarifa_tipo"); // negro, color, negrohq, colorhq
$uso_tarifa = $this->request->getGet("uso_tarifa") ?? 'interior'; // interior, cubierta, sobrecubierta
$is_rotativa = $this->request->getGet('is_rotativa') ?? 0;
$lomo_redondo = $this->request->getGet('lomo_redondo');
$lomo = $this->request->getGet('lomo');
$solapas = $this->request->getGet('solapas');
$solapas_ancho = $this->request->getGet('solapas_ancho');
$model = model('App\Models\Configuracion\MaquinaModel');
$query = $model->getMaquinaImpresionForPresupuesto(
$is_rotativa,
$tarifa_tipo,
$uso_tarifa,
intval($tirada) + intval($merma),
$papel_impresion_id
);
if ($this->request->getGet("q")) {
$query->groupStart()
->orLike("lg_maquinas.nombre", $this->request->getGet("q"))
->groupEnd();
}
$data = $query->orderBy("t1.nombre", "asc")->get()->getResultObject();
$query = $model->db->getLastQuery();
$datosPedido = ((object) array(
'ancho' => $ancho,
'alto' => $alto,
'isCosido' => $isCosido,
'lomo' => $lomo,
'solapas' => $solapas,
'solapas_ancho' => $solapas_ancho,
));
for ($i = 0; $i < count($data); $i++) {
if ($is_rotativa) {
$has_error = true;
for ($f = 0; $f < 2; $f++) {
$parametrosRotativa = (object) array(
'a_favor_fibra' => $f,
);
$values = [];
[$values['ancho'], $values['alto']] = PresupuestoService::calculoDimForma($datosPedido, $parametrosRotativa);
$factor_anchura = round($data[$i]->ancho_impresion / $values['ancho'], 2);
if (floor($factor_anchura) != 0) {
$has_error = false;
}
}
if ($has_error) {
unset($data[$i]);
}
} else {
if ($uso_tarifa != 'interior') {
$datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($uso_tarifa, $tipo_impresion_id, $datosPedido, $data[$i]->maquina_id, $lomo_redondo);
$datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($uso_tarifa, $tipo_impresion_id, $datosPedido);
}
$ancho_calculo = ($uso_tarifa == 'cubierta' || $uso_tarifa == 'sobrecubierta') ? $datosPedido->anchoExteriores : $datosPedido->ancho;
$alto_calculo = ($uso_tarifa == 'cubierta' || $uso_tarifa == 'sobrecubierta') ? $datosPedido->altoExteriores : $datosPedido->alto;
$formas = PresupuestoService::getNumFormasPlana($uso_tarifa, $data[$i], $ancho_calculo, $alto_calculo, $datosPedido->isCosido);
if ($formas['num_formas']['posicion_formas'] == 'n/a') {
unset($data[$i]);
}
}
}
return $this->response->setJSON($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
private function getStringsFromTipoImpresion($tipo_impresion_id)
{