trabajando en comparador

This commit is contained in:
2024-12-17 14:38:02 +01:00
parent 4e7f53ba6c
commit 643f84684a
11 changed files with 267 additions and 492 deletions

View File

@ -89,6 +89,8 @@ class Users extends \App\Controllers\GoBaseController
// Marcar el username como NULL
$sanitizedData = $this->sanitized($postData, true);
$email = $sanitizedData['email'];
unset($sanitizedData['email']);
$noException = true;
@ -100,7 +102,7 @@ class Users extends \App\Controllers\GoBaseController
try {
// The Email is unique
if ($this->user_model->isEmailUnique($sanitizedData['email'])) {
if ($this->user_model->isEmailUnique($email)) {
// Crear el usuario si pasa la validación
$user = new \CodeIgniter\Shield\Entities\User([
@ -109,8 +111,6 @@ class Users extends \App\Controllers\GoBaseController
'last_name' => $sanitizedData['last_name'],
'cliente_id' => $sanitizedData['cliente_id'],
'comments' => $sanitizedData['comments'],
'email' => $sanitizedData['email'],
'password' => $sanitizedData['password'],
'status' => $sanitizedData['status'] ?? 0,
'active' => $sanitizedData['active'] ?? 0,
]);

View File

@ -336,15 +336,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
$this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
$this->viewData['incReiList'] = array('incidencia' => lang('Presupuestos.incidencia'), 'reimpresion' => lang('Presupuestos.reimpresion'), 'sin_cargo' => lang('Presupuestos.sinCargo'));
$this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null);
$this->viewData['papelGenericoNegroList'] = $this->getPapelGenericoNegro();
$this->viewData['papelGenericoNegroHQList'] = $this->getPapelGenericoNegroHQ();
$this->viewData['papelGenericoColorList'] = $this->getPapelGenericoColor();
$this->viewData['papelGenericoColorHQList'] = $this->getPapelGenericoColorHQ();
$this->viewData['papelGenericoCubiertaList'] = $this->getPapelGenericoCubierta();
$this->viewData['papelGenericoGuardasList'] = $this->getPapelGenericoGuardas();
$this->viewData['papelGenericoSobrecubiertaList'] = $this->getPapelGenericoSobreCubierta();
$this->viewData['papelGenericoRotativaNegroList'] = $this->getPapelGenericoRotativaNegro();
$this->viewData['papelGenericoRotativaColorList'] = $this->getPapelGenericoRotativaColor();
// Acabados exteriores
$this->viewData['acabadosCubierta'] = $this->getAcabadosCubierta();
@ -475,6 +467,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
$modelPapelFormato = new PapelFormatoModel();
$modelCliente = new ClienteModel();
$modelPapelGenerico = new PapelGenericoModel();
$presupuesto = $this->model->find($id);
@ -537,7 +530,12 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
$data['datosLibro']['fajaColor'] = $presupuesto->faja_color;
$data['comparador']['tipo_impresion'] = $presupuesto->comp_tipo_impresion;
$data['comparador']['json_data'] = $presupuesto->comparador_json_data;
$data['comparador']['json_data'] = json_decode($presupuesto->comparador_json_data, true);
foreach ($data['comparador']['json_data'] as &$item) {
$item['papel_nombre'] = $modelPapelGenerico->getNombre($item['papel_id'])['nombre'];
}
/*
$data['datosGenerales']['posPaginasColor'] = $presupuesto->comp_pos_paginas_color;
@ -1231,105 +1229,99 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
return $data;
}
public function getPapelGenerico(){
protected function getPapelGenericoRotativaNegro()
{
$model = model('App\Models\Configuracion\PapelGenericoModel');
$data = $model->getPapelForComparador('negro', false, false, true);
array_unshift($data, (object)array(
"id" => 0,
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))])
));
return $data;
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);
}
}
protected function getPapelGenericoRotativaColor()
{
$model = model('App\Models\Configuracion\PapelGenericoModel');
$data = $model->getPapelForComparador('color', false, false, true);
array_unshift($data, (object)array(
"id" => 0,
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))])
));
return $data;
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_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);
}
}
protected function getPapelGenericoNegro()
{
$model = model('App\Models\Configuracion\PapelGenericoModel');
$data = $model->getPapelForComparador('negro', false, false);
array_unshift($data, (object)array(
"id" => 0,
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))])
));
return $data;
}
protected function getPapelGenericoNegroHQ()
{
$model = model('App\Models\Configuracion\PapelGenericoModel');
$data = $model->getPapelForComparador('negrohq', false, false);
array_unshift($data, (object)array(
"id" => 0,
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))])
));
return $data;
}
protected function getPapelGenericoColor()
{
$model = model('App\Models\Configuracion\PapelGenericoModel');
$data = $model->getPapelForComparador('color', false, false);
array_unshift($data, (object)array(
"id" => 0,
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))])
));
return $data;
}
protected function getPapelGenericoColorHQ()
{
$model = model('App\Models\Configuracion\PapelGenericoModel');
$data = $model->getPapelForComparador('colorhq', false, false);
array_unshift($data, (object)array(
"id" => 0,
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))])
));
return $data;
}
protected function getPapelGenericoCubierta()
{
$model = model('App\Models\Configuracion\PapelGenericoModel');
$data = $model->getPapelForComparador('colorhq', true, false);
array_unshift($data, (object)array(
"id" => 0,
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))])
));
return $data;
}
protected function getPapelGenericoGuardas()
{
$model = model('App\Models\Configuracion\PapelGenericoModel');
$data = $model->getPapelForComparador('colorhq', false, false, false, true);
array_unshift($data, (object)array(
"id" => 0,
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))])
));
return $data;
}
protected function getPapelGenericoSobreCubierta()
{
$model = model('App\Models\Configuracion\PapelGenericoModel');
$data = $model->getPapelForComparador('colorhq', false, true);
array_unshift($data, (object)array(
"id" => 0,
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))])
));
return $data;
}
protected function getServiciosPreimpresion()
{