From 643f84684a133ef26d6d1e1d524dafa81ab07bfc Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Tue, 17 Dec 2024 14:38:02 +0100 Subject: [PATCH] trabajando en comparador --- ci4/app/Config/Routes.php | 3 + ci4/app/Controllers/Configuracion/Users.php | 6 +- .../Presupuestos/Presupuestoadmin.php | 198 ++++++++-------- ci4/app/Entities/Usuarios/UserEntity.php | 1 + .../Configuracion/PapelGenericoModel.php | 218 +++++++++++------- ci4/app/Models/Usuarios/UserModel.php | 123 +--------- .../admin/_datosPresupuestoClienteItems.php | 165 +------------ .../admin/_lineasPresupuestoItems.php | 21 +- .../admin/viewPresupuestoadminForm.php | 2 +- .../presupuestoAdmin/presupuestoAdminEdit.js | 1 + .../presupuestoAdmin/sections/comparador.js | 21 +- 11 files changed, 267 insertions(+), 492 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 0974fafd..94d0516a 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -579,6 +579,9 @@ $routes->group('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos $routes->post('datatable_2', 'Presupuestoadmin::datatable_2', ['as' => 'updateDataOfPresupuestoAdmin']); $routes->post('allmenuitems', 'Presupuestoadmin::allItemsSelect', ['as' => 'select2ItemsOfPresupuestoAdmin']); $routes->post('menuitems', 'Presupuestoadmin::menuItems', ['as' => 'menuItemsOfPresupuestoAdmin']); + + $routes->get('papelgenerico', 'Presupuestoadmin::getPapelGenerico'); + $routes->get('papelgramaje', 'Presupuestoadmin::getGramaje'); }); $routes->resource('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestoadmin', 'except' => 'show,new,create,update']); diff --git a/ci4/app/Controllers/Configuracion/Users.php b/ci4/app/Controllers/Configuracion/Users.php index 8fcc153e..c537dd57 100755 --- a/ci4/app/Controllers/Configuracion/Users.php +++ b/ci4/app/Controllers/Configuracion/Users.php @@ -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, ]); diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index 4a8a9832..d7240367 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -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() { diff --git a/ci4/app/Entities/Usuarios/UserEntity.php b/ci4/app/Entities/Usuarios/UserEntity.php index 61f750ce..34206cad 100755 --- a/ci4/app/Entities/Usuarios/UserEntity.php +++ b/ci4/app/Entities/Usuarios/UserEntity.php @@ -13,6 +13,7 @@ class UserEntity extends \CodeIgniter\Entity\Entity "status" => null, "status_message" => null, 'active' => null, + "comments" => null, "last_active" => null, "created_at" => null, "updated_at" => null, diff --git a/ci4/app/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php index 4f2d8cf9..739ccf6d 100755 --- a/ci4/app/Models/Configuracion/PapelGenericoModel.php +++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php @@ -129,141 +129,185 @@ class PapelGenericoModel extends \App\Models\BaseModel return empty($search) ? $builder : $builder - ->groupStart() - ->like("t1.id", $search) - ->orLike("t1.nombre", $search) - ->orLike("t1.code", $search) - ->orLike("t1.code_ot", $search) - ->orLike("t1.id", $search) - ->orLike("t1.nombre", $search) - ->orLike("t1.code", $search) - ->orLike("t1.code_ot", $search) - ->groupEnd(); + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->orLike("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->groupEnd(); } - public function getPapelForComparador($tipo, $is_cubierta = false, $is_sobrecubierta = false, $rotativa = false, $is_guardas = false, $mostrar_cliente = null) - { + public function getPapelForComparador( + $tipo, + $is_cubierta = false, + $is_sobrecubierta = false, + $rotativa = false, + $is_guardas = false, + $tapa_dura = false, + $POD = false + ) { /* 1.-> Tipo impresion 2.-> Maquina 3.-> Papeles impresion asociados a esa maquina 4.-> papeles genericos que aparecen en esos papeles impresion */ + + if ($POD == true && ($tipo == 'color' || $tipo == 'negro')) { + if ($tipo == 'color') + $tipo = 'colorhq'; + else if ($tipo == 'negro') + $tipo = 'negrohq'; + } + $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id as id, t1.nombre AS nombre" + "t1.id as id, t1.nombre AS nombre", // for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo" ) - ->distinct('t1.id') - ->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "left") - ->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "left") - ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left") - ->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "left") + ->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner") + ->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner") + ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner") + ->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner") ->where("t1.is_deleted", 0) + ->where("t1.show_in_client", 1) ->where("t2.is_deleted", 0) ->where("t2.isActivo", 1) ->where("t3.active", 1) ->where("t4.is_deleted", 0) ->where("t4.tipo", "impresion") ->where("t5.is_deleted", 0) - ->where("t5.tipo", $tipo); + ->where("t5.tipo", $tipo) + ->distinct('t1.id'); + + // Validación adicional para asegurar que t1.id esté presente en las combinaciones con t3.active = 1 + $builder->whereIn("t1.id", function ($subQuery) { + $subQuery->select("t1_inner.id") + ->from("lg_papel_generico t1_inner") + ->join("lg_papel_impresion t2_inner", "t2_inner.papel_generico_id = t1_inner.id", "inner") + ->join("lg_maquina_papel_impresion t3_inner", "t3_inner.papel_impresion_id = t2_inner.id", "inner") + ->where("t3_inner.active", 1); + }); if ($is_cubierta == true) { - $builder->where("t2.cubierta", 1); $builder->where("t5.uso", 'cubierta'); - } - - if ($is_sobrecubierta == true) { + if ($tapa_dura == true) { + $builder->where("t2.use_for_tapa_dura", 1); + } + } else if ($is_sobrecubierta == true) { $builder->where("t2.sobrecubierta", 1); $builder->where("t5.uso", 'sobrecubierta'); - } - - if ($is_cubierta == false && $is_sobrecubierta == false) { - $builder->where("t5.uso", 'interior'); - } - - if ($is_guardas == true) { + } else if ($is_guardas == true) { $builder->where("t2.guardas", 1); + } else { + $builder->where("t2.interior", 1); + $builder->where("t5.uso", 'interior'); + if ($tipo == 'negro' || $tipo == 'negrohq') + $builder->where("t2.bn", 1); + else if ($tipo == 'color' || $tipo == 'colorhq') + $builder->where("t2.color", 1); } - if ($rotativa == true) { + if ($tipo == 'colorhq' || $tipo == 'negrohq') { + $builder->where("t2.rotativa", 0); + } else if ($rotativa && $POD == false) { $builder->where("t2.rotativa", 1); + } else if ($POD) { + $builder->where("t2.rotativa", 0); } - if ($mostrar_cliente != null) { - $builder->where("t1.show_in_client", $mostrar_cliente); - } - - $data = $builder->orderBy("t1.nombre", "asc")->get()->getResultObject(); - //var_dump($this->db->getLastQuery()); - return $data; + //$query = $this->db->getLastQuery(); + return $builder; } - public function getGramajeComparador(string $papel_generico_nombre = "", $uso = "", $ejemplares = 0) - { - if ($uso == 'cubierta' || $uso == 'sobrecubierta') - $tipo = 'colorhq'; - else - $tipo = $uso; // color y colorhq valen para los dos - if ($uso == 'bn') - $tipo = "negro"; - if ($uso == 'bnhq') - $tipo = "negrohq"; + public function getGramajeForComparador( + $tipo, + $selected_papel_id, + $is_cubierta = false, + $is_sobrecubierta = false, + $rotativa = false, + $is_guardas = false, + $tapa_dura = false, + $POD = false + ) { + if ($POD == true && ($tipo == 'color' || $tipo == 'negro')) { + if ($tipo == 'color') + $tipo = 'colorhq'; + else if ($tipo == 'negro') + $tipo = 'negrohq'; + } + $builder = $this->db ->table($this->table . " t1") ->select( - "t2.gramaje AS text" + "t2.gramaje as id, t2.gramaje as nombre", + // for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo" ) - ->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "left") - ->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "left") - ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left") - ->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "left") + ->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner") + ->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner") + ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner") + ->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner") + ->where("t1.id", $selected_papel_id) ->where("t1.is_deleted", 0) + ->where("t1.show_in_client", 1) ->where("t2.is_deleted", 0) ->where("t2.isActivo", 1) ->where("t3.active", 1) ->where("t4.is_deleted", 0) ->where("t4.tipo", "impresion") + ->where("t5.is_deleted", 0) ->where("t5.tipo", $tipo) - ->where("t1.nombre", $papel_generico_nombre); + ->distinct('t2.gramaje'); - $uso_tarifa = 'interior'; + // Validación adicional para asegurar que t1.id esté presente en las combinaciones con t3.active = 1 + $builder->whereIn("t1.id", function ($subQuery) { + $subQuery->select("t1_inner.id") + ->from("lg_papel_generico t1_inner") + ->join("lg_papel_impresion t2_inner", "t2_inner.papel_generico_id = t1_inner.id", "inner") + ->join("lg_maquina_papel_impresion t3_inner", "t3_inner.papel_impresion_id = t2_inner.id", "inner") + ->where("t3_inner.active", 1); + }); - if ($uso == 'bn' || $uso == 'bnhq') - $builder->where("t2.bn", 1); - else if ($uso == 'color' || $uso == 'colorhq') - $builder->where("t2.color", 1); - else if ($uso == 'cubierta') { - $uso_tarifa = 'cubierta'; + if ($is_cubierta == true) { $builder->where("t2.cubierta", 1); - } else if ($uso == 'sobrecubierta') { - $uso_tarifa = 'sobrecubierta'; + $builder->where("t5.uso", 'cubierta'); + if ($tapa_dura == true) { + $builder->where("t2.use_for_tapa_dura", 1); + } + } else if ($is_sobrecubierta == true) { $builder->where("t2.sobrecubierta", 1); + $builder->where("t5.uso", 'sobrecubierta'); + } else if ($is_guardas == true) { + $builder->where("t2.guardas", 1); + } else { + $builder->where("t2.interior", 1); + $builder->where("t5.uso", 'interior'); + if ($tipo == 'negro' || $tipo == 'negrohq') + $builder->where("t2.bn", 1); + else if ($tipo == 'color' || $tipo == 'colorhq') + $builder->where("t2.color", 1); } - $builder->where("t5.uso", $uso_tarifa); - - $builder->where("t4.min <=", $ejemplares); - $builder->where("t4.max >=", $ejemplares); - - $values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject(); - $id = 1; - foreach ($values as $value) { - $value->id = $id; - $id++; + if ($tipo == 'colorhq' || $tipo == 'negrohq') { + $builder->where("t2.rotativa", 0); + } else if ($rotativa && $POD == false) { + $builder->where("t2.rotativa", 1); + } else if ($POD) { + $builder->where("t2.rotativa", 0); } - $values_array = array_map(function ($value) { - return $value->text; - }, $values); - $unique_values = array_unique($values_array); - return array_values(array_intersect_key($values, $unique_values)); + //$query = $this->db->getLastQuery(); + return $builder; } //tipo: negro, negrohq, color, colorhq @@ -323,7 +367,6 @@ class PapelGenericoModel extends \App\Models\BaseModel }, $values); $unique_values = array_unique($values_array); return array_values(array_intersect_key($values, $unique_values)); - } @@ -337,9 +380,9 @@ class PapelGenericoModel extends \App\Models\BaseModel */ if ($POD == true && ($tipo == 'color' || $tipo == 'negro')) { - if($tipo == 'color') + if ($tipo == 'color') $tipo = 'colorhq'; - else if($tipo == 'negro') + else if ($tipo == 'negro') $tipo = 'negrohq'; } @@ -403,7 +446,7 @@ class PapelGenericoModel extends \App\Models\BaseModel if ($is_cubierta == true) { $builder->where("t2.cubierta", 1); $builder->where("t5.uso", 'cubierta'); - if($tapa_dura == true){ + if ($tapa_dura == true) { $builder->where("t2.use_for_tapa_dura", 1); } } else { @@ -417,19 +460,16 @@ class PapelGenericoModel extends \App\Models\BaseModel if ($papel_especial == true) { $builder->where("t1.show_in_client_special", 1); - } - else{ + } else { $builder->where("t1.show_in_client_special", 0); } if ($tipo == 'colorhq' || $tipo == 'negrohq') { $builder->where("t2.rotativa", 0); - } - else{ - if($POD == false){ + } else { + if ($POD == false) { $builder->where("t2.rotativa", 1); - } - else if ($POD == true){ + } else if ($POD == true) { $builder->where("t2.rotativa", 0); } } diff --git a/ci4/app/Models/Usuarios/UserModel.php b/ci4/app/Models/Usuarios/UserModel.php index a4748d14..d4e2d993 100755 --- a/ci4/app/Models/Usuarios/UserModel.php +++ b/ci4/app/Models/Usuarios/UserModel.php @@ -20,14 +20,13 @@ class UserModel extends \App\Models\BaseModel protected $allowedFields = [ "username", - "email", "first_name", "last_name", "client_id", "status", "status_message", "active", - "country", + "comments", "last_active", "created_at", "updated_at", @@ -39,143 +38,25 @@ class UserModel extends \App\Models\BaseModel protected $validationRules = [ - "address" => [ - "label" => "Users.address", - "rules" => "trim|max_length[255]", - ], - "blocked" => [ - "label" => "Users.blocked", - "rules" => "required|permit_empty", - ], - "city" => [ - "label" => "Users.city", - "rules" => "trim|max_length[255]", - ], - "country" => [ - "label" => "Users.country", - "rules" => "trim|max_length[2]", - ], - "date_birth" => [ - "label" => "Users.dateBirth", - "rules" => "valid_date|permit_empty", - ], - "email" => [ - "label" => "Users.email", - "rules" => "trim|required|max_length[150]|valid_email", - ], - "email_confirmed" => [ - "label" => "Users.emailConfirmed", - "rules" => "required|integer", - ], "first_name" => [ "label" => "Users.firstName", "rules" => "trim|max_length[150]", ], - "language" => [ - "label" => "Users.language", - "rules" => "trim|max_length[10]", - ],/* - "last_access" => [ - "label" => "Users.lastAccess", - "rules" => "valid_date", - ],*/ - "last_ip" => [ - "label" => "Users.lastIp", - "rules" => "max_length[50]", - ], "last_name" => [ "label" => "Users.lastName", "rules" => "trim|max_length[150]", ], - "mobile" => [ - "label" => "Users.mobile", - "rules" => "trim|max_length[50]", - ], - "password" => [ - "label" => "Users.password", - "rules" => "required|max_length[35]", - ], - "picture" => [ - "label" => "Users.picture", - "rules" => "trim|max_length[150]", - ], - "state" => [ - "label" => "Users.state", - "rules" => "trim|max_length[255]", - ], - "zip_code" => [ - "label" => "Users.zipCode", - "rules" => "trim|max_length[50]", - ], ]; protected $validationMessages = [ - "address" => [ - "max_length" => "Users.validation.address.max_length", - ], - - "blocked" => [ - "required" => "Users.validation.email_confirmed.required", - ], - "city" => [ - "max_length" => "Users.validation.city.max_length", - ], - "country" => [ - "max_length" => "Users.validation.country.max_length", - "required" => "Users.validation.country.required", - ], - "date_birth" => [ - "valid_date" => "Users.validation.date_birth.valid_date", - ], - "email" => [ - "max_length" => "Users.validation.email.max_length", - "required" => "Users.validation.email.required", - "valid_email" => "Users.validation.email.valid_email", - ], - "email_confirmed" => [ - "integer" => "Users.validation.email_confirmed.integer", - "required" => "Users.validation.email_confirmed.required", - ], "first_name" => [ "max_length" => "Users.validation.first_name.max_length", "required" => "Users.validation.first_name.required", ], - - "language" => [ - "max_length" => "Users.validation.language.max_length", - "required" => "Users.validation.language.required", - ], - "last_access" => [ - "required" => "Users.validation.last_access.required", - "valid_date" => "Users.validation.last_access.valid_date", - ], - "last_ip" => [ - "max_length" => "Users.validation.last_ip.max_length", - "required" => "Users.validation.last_ip.required", - ], "last_name" => [ "max_length" => "Users.validation.last_name.max_length", "required" => "Users.validation.last_name.required", - ], - "mobile" => [ - "max_length" => "Users.validation.mobile.max_length", - "required" => "Users.validation.mobile.required", - ], - "password" => [ - "max_length" => "Users.validation.password.max_length", - "required" => "Users.validation.password.required", - ], - "picture" => [ - "max_length" => "Users.validation.picture.max_length", - "required" => "Users.validation.picture.required", - ], - "state" => [ - "max_length" => "Users.validation.state.max_length", - "required" => "Users.validation.state.required", - ], - "zip_code" => [ - "max_length" => "Users.validation.zip_code.max_length", - ], + ], ]; public function getGroupsTitles($user_token){ diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php index 0022fc3a..b9c143f3 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php @@ -74,17 +74,10 @@

- +
@@ -578,161 +571,7 @@ allowClear: false, }); - $('#compPapelNegro').select2({ - allowClear: false, - }); - - $('#compGramajeNegro').select2({ - - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'bn', - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - datos: $('#compPapelNegro').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - - $('#compPapelNegrohq').select2({ - allowClear: false, - }); - - $('#compGramajeNegrohq').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'bnhq', - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - datos: $('#compPapelNegrohq').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - - }); - - $('#compPapelColor').select2({ - allowClear: false, - }); - - $('#compPapelColorhq').select2({ - allowClear: false, - }); - - $('#compGramajeColor').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'color', - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - datos: $('#compPapelColor').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - - $('#compGramajeColorhq').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'colorhq', - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - datos: $('#compPapelColorhq').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - - $('#compPapelCubierta').select2({ - allowClear: false, - }); - - $('#compGramajeCubierta').select2({ - allowClear: false, - }); - - $('#compPapelSobrecubierta').select2({ - allowClear: false, - }); - - $('#compGramajeSobrecubierta').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - }); - - $('#encuadernacion').select2({ - allowClear: false, - }); - $('#compCarasCubierta').select2({ allowClear: false, @@ -1543,6 +1382,7 @@ function checkComparadorInt(is_color, is_hq, actualizarLineaPlana=false, actualizarLineaRot=false) { + /* TO-DO with select2 component try{ clearIntLineas(is_color); @@ -1587,6 +1427,7 @@ }catch(e){ console.log(e) } + */ } diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php index 330ec907..d6bb3738 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php @@ -74,17 +74,17 @@ section("additionalInlineJs") ?> -window.papelGenericoNegroList = ; -window.papelGenericoNegroHQList = ; -window.papelGenericoColorList = ; -window.papelGenericoColorHQList = ; -window.papelGenericoCubiertaList = ; -window.papelGenericoSobrecubiertaList = ; -window.papelGenericoRotativaNegroList = ; -window.papelGenericoRotativaColorList = ; +window.papelGenericoNegroList = []; +window.papelGenericoNegroHQList = []; +window.papelGenericoColorList = []; +window.papelGenericoColorHQList = []; +window.papelGenericoCubiertaList = []; +window.papelGenericoSobrecubiertaList = []; +window.papelGenericoRotativaNegroList = []; +window.papelGenericoRotativaColorList = []; - window.papelGenericoGuardasList = ; + window.papelGenericoGuardasList = []; window.lineasPresupuestoList = ; @@ -95,8 +95,11 @@ window.routes_lp = { } + +/* fill_lp_from_bbdd() checkPaginasPresupuesto() +*/ endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php index afd59484..9e5a7e7a 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php @@ -309,7 +309,7 @@ - + diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js index e7f6ad1b..7dfaf2eb 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js @@ -79,6 +79,7 @@ class PresupuestoAdminEdit { self.datosGenerales.cargarDatos(response.data.datosGenerales); self.datosLibro.cargarDatos(response.data.datosLibro); + self.comparador.cargarDatos(response.data.comparador); /*self.direcciones.handleChangeCliente(); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index f198aa96..c86df266 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -15,20 +15,29 @@ class Comparador { this.paginasNegro = $('#compPaginasNegro'); this.papelNegro = new ClassSelect($('#compPapelNegro'), - '/papelesgenericos/getpapelcliente', 'Seleccione papel', false, + '/presupuestoadmin/papelgenerico', 'Seleccione papel', false, { [this.csrf_token]: this.csrf_hash, + tipo_impresion: this.tipo_impresion.val(), tirada: $('#tirada').val(), tipo: 'negro', - cubierta: 0, }); - this.gramajeNegro = $('#compGramajeNegro'); + this.gramajeNegro = new ClassSelect($('#compGramajeNegro'), + '/presupuestoadmin/papelgramaje', 'Seleccione gramaje', false, + { + [this.csrf_token]: this.csrf_hash, + papel_generico: this.papelNegro.getVal(), + tipo_impresion: this.tipo_impresion.val(), + tirada: $('#tirada').val(), + tipo: 'negro', + }); } init() { this.papelNegro.init(); + this.gramajeNegro.init(); } cargarDatos(datos) { @@ -36,7 +45,11 @@ class Comparador { this.tipo_impresion.val(datos.tipo_impresion); this.comparador_json.val(JSON.stringify(datos.json_data)); - //if (datos.json_data.bn) + if (datos.json_data.bn){ + this.paginasNegro.val(datos.json_data.bn.paginas); + this.papelNegro.setOption(datos.json_data.bn.papel_id, datos.json_data.bn.papel_nombre); + this.gramajeNegro.setOption(datos.json_data.bn.gramaje, datos.json_data.bn.gramaje); + } } }