diff --git a/ci4/.env b/ci4/.env index e77bc5bf..347f66d5 100644 --- a/ci4/.env +++ b/ci4/.env @@ -114,9 +114,9 @@ database.default.dump = # SECURITY #-------------------------------------------------------------------- - security.tokenName = 'webguard_token' + security.tokenName = 'safekat_token' security.headerName = 'X-CSRF-TOKEN' - security.cookieName = 'webguard_cookie' + security.cookieName = 'safekat_cookie' security.expires = 7200 security.regenerate = true security.redirect = true diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index e00b2501..015360fc 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -348,8 +348,35 @@ $routes->group('formas-pagos', ['namespace' => 'App\Controllers\Configuracion'], }); $routes->resource('formas-pagos', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Formaspagos', 'except' => 'show,new,create,update']); +$routes->group('tarifasencuadernacion', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { + $routes->get('', 'Tarifasencuadernacion::index', ['as' => 'tarifaEncuadernacionList']); + $routes->get('add', 'Tarifasencuadernacion::add', ['as' => 'newTarifaEncuadernacion']); + $routes->post('add', 'Tarifasencuadernacion::add', ['as' => 'createTarifaEncuadernacion']); + $routes->post('create', 'Tarifasencuadernacion::create', ['as' => 'ajaxCreateTarifaEncuadernacion']); + $routes->put('(:num)/update', 'Tarifasencuadernacion::update/$1', ['as' => 'ajaxUpdateTarifaEncuadernacion']); + $routes->post('edit/(:num)', 'Tarifasencuadernacion::edit/$1', ['as' => 'updateTarifaEncuadernacion']); + $routes->get('delete/(:num)', 'Tarifasencuadernacion::delete/$1', ['as' => 'deleteTarifaEncuadernacion']); + $routes->post('datatable', 'Tarifasencuadernacion::datatable', ['as' => 'dataTableOfTarifasEncuadernacion']); + $routes->post('allmenuitems', 'Tarifasencuadernacion::allItemsSelect', ['as' => 'select2ItemsOfTarifasEncuadernacion']); + $routes->post('menuitems', 'Tarifasencuadernacion::menuItems', ['as' => 'menuItemsOfTarifasEncuadernacion']); +}); +$routes->resource('tarifasencuadernacion', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasencuadernacion', 'except' => 'show,new,create,update']); +$routes->group('tarifaencuadernacionlineas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { + $routes->get('', 'Tarifaencuadernacionlineas::index', ['as' => 'tarifaEncuadernacionLineaList']); + $routes->get('add', 'Tarifaencuadernacionlineas::add', ['as' => 'newTarifaEncuadernacionLinea']); + $routes->post('add', 'Tarifaencuadernacionlineas::add', ['as' => 'createTarifaEncuadernacionLinea']); + $routes->post('create', 'Tarifaencuadernacionlineas::create', ['as' => 'ajaxCreateTarifaEncuadernacionLinea']); + $routes->put('(:num)/update', 'Tarifaencuadernacionlineas::update/$1', ['as' => 'ajaxUpdateTarifaEncuadernacionLinea']); + $routes->post('(:num)/edit', 'Tarifaencuadernacionlineas::edit/$1', ['as' => 'updateTarifaEncuadernacionLinea']); + $routes->post('datatable', 'Tarifaencuadernacionlineas::datatable', ['as' => 'dataTableOfTarifaEncuadernacionLineas']); + $routes->post('datatable_editor', 'Tarifaencuadernacionlineas::datatable_editor', ['as' => 'editorOfTarifaEncuadernacionLineas']); + $routes->post('allmenuitems', 'Tarifaencuadernacionlineas::allItemsSelect', ['as' => 'select2ItemsOfTarifaEncuadernacionLineas']); + $routes->post('menuitems', 'Tarifaencuadernacionlineas::menuItems', ['as' => 'menuItemsOfTarifaEncuadernacionLineas']); +}); +$routes->resource('tarifaencuadernacionlineas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaencuadernacionlineas', 'except' => 'show,new,create,update']); + /* * -------------------------------------------------------------------- * Additional Routing diff --git a/ci4/app/Controllers/Clientes/Cliente.php b/ci4/app/Controllers/Clientes/Cliente.php index cb56cc1c..642ac371 100644 --- a/ci4/app/Controllers/Clientes/Cliente.php +++ b/ci4/app/Controllers/Clientes/Cliente.php @@ -49,7 +49,7 @@ class Cliente extends \App\Controllers\GoBaseResourceController { // Breadcrumbs (IMN) $this->viewData['breadcrumb'] = [ - ['title' => lang("App.menu_clientes"), 'route' => "", 'active' => false], + ['title' => lang("App.menu_clientes"), 'route' => "javascript:void(0);", 'active' => false], ['title' => lang("App.menu_cliente"), 'route' => site_url('clientes/cliente'), 'active' => true] ]; diff --git a/ci4/app/Controllers/Configuracion/Maquinas.php b/ci4/app/Controllers/Configuracion/Maquinas.php index ddbf022c..91e9c361 100644 --- a/ci4/app/Controllers/Configuracion/Maquinas.php +++ b/ci4/app/Controllers/Configuracion/Maquinas.php @@ -40,7 +40,7 @@ class Maquinas extends \App\Controllers\GoBaseResourceController { // Breadcrumbs (IMN) $this->viewData['breadcrumb'] = [ - ['title' => lang("App.menu_configuration"), 'route' => "", 'active' => false], + ['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false], ['title' => lang("App.menu_maquina"), 'route' => site_url('configuracion/maquinas'), 'active' => true] ]; @@ -176,12 +176,26 @@ class Maquinas extends \App\Controllers\GoBaseResourceController { if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : if ($this->canValidate()) : - try { - $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } + //JJO: comprobar alto y ancho impresion < alto y ancho + if($sanitizedData['alto'] < $sanitizedData['alto_impresion']){ + $successfulResult = false; + $this->viewData['errorMessage'] = lang('Maquinas.validation.alto_menor_alto_impresion');; + $this->session->setFlashdata('formErrors', $this->model->errors()); + } + else if ($sanitizedData['ancho'] < $sanitizedData['ancho_impresion']){ + $successfulResult = false; + $this->viewData['errorMessage'] = lang('Maquinas.validation.ancho_menor_ancho_impresion');; + $this->session->setFlashdata('formErrors', $this->model->errors()); + } + else{ + try { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + } + else: $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Maquinas.maquina'))]); $this->session->setFlashdata('formErrors', $this->model->errors()); @@ -190,7 +204,7 @@ class Maquinas extends \App\Controllers\GoBaseResourceController { $maquina->fill($sanitizedData); - $thenRedirect = true; + $thenRedirect = false; endif; if ($noException && $successfulResult) : $id = $maquina->id ?? $id; diff --git a/ci4/app/Controllers/Configuracion/Maquinastarifasimpresion.php b/ci4/app/Controllers/Configuracion/Maquinastarifasimpresion.php index 4dfaeb1c..0b04e2a6 100644 --- a/ci4/app/Controllers/Configuracion/Maquinastarifasimpresion.php +++ b/ci4/app/Controllers/Configuracion/Maquinastarifasimpresion.php @@ -255,20 +255,19 @@ if ($this->request->getPost('predeterminado') == null ) { return lang('MaquinasTarifasImpresions.validation.cubierta_sobrecubierta_color'); } - // No se pueden duplicar valores al crear - if($action === Editor::ACTION_CREATE){ - $builder = $this->model->select('*') - ->where(array( - 'maquina_id'=> $values['maquina_id'], - 'tipo'=> $values['tipo'], - 'uso'=> $values['uso'], - 'is_deleted'=> 0)); + $builder = $this->model->select('*') + ->where(array( + 'maquina_id'=> $values['maquina_id'], + 'tipo'=> $values['tipo'], + 'uso'=> $values['uso'], + 'is_deleted'=> 0)); - if ($builder->countAllResults() >= 1){ - if(($action === Editor::ACTION_EDIT && $builder->get()->getFirstRow()->id != $pkey) - || $action === Editor::ACTION_CREATE) - return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo'); - + // No se pueden duplicar valores al crear o al editar + if ($builder->countAllResults() >= 1){ + if(($action === Editor::ACTION_EDIT && $builder->get()->getFirstRow()->id != $pkey) + || $action === Editor::ACTION_CREATE){ + + return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo'); } } } diff --git a/ci4/app/Controllers/Configuracion/Papelesgenericos.php b/ci4/app/Controllers/Configuracion/Papelesgenericos.php index 8f24642e..407abe29 100644 --- a/ci4/app/Controllers/Configuracion/Papelesgenericos.php +++ b/ci4/app/Controllers/Configuracion/Papelesgenericos.php @@ -42,7 +42,7 @@ class Papelesgenericos extends \App\Controllers\GoBaseResourceController // Breadcrumbs (IMN) $this->viewData['breadcrumb'] = [ - ['title' => lang("App.menu_configuration"), 'route' => "", 'active' => false], + ['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false], ['title' => lang("App.menu_papelgenerico"), 'route' => site_url('configuracion/papelesgenericos'), 'active' => true] ]; diff --git a/ci4/app/Controllers/Configuracion/Papelesimpresion.php b/ci4/app/Controllers/Configuracion/Papelesimpresion.php index 716259cf..05143b21 100644 --- a/ci4/app/Controllers/Configuracion/Papelesimpresion.php +++ b/ci4/app/Controllers/Configuracion/Papelesimpresion.php @@ -65,7 +65,7 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController // Breadcrumbs $this->viewData['breadcrumb'] = [ - ['title' => lang("App.menu_configuration"), 'route' => "", 'active' => false], + ['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false], ['title' => lang("App.menu_papelimpresion"), 'route' => site_url('configuracion/papelesimpresion'), 'active' => true] ]; diff --git a/ci4/app/Controllers/Tarifas/Tarifaacabado.php b/ci4/app/Controllers/Tarifas/Tarifaacabado.php index a1b145eb..87019c48 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaacabado.php +++ b/ci4/app/Controllers/Tarifas/Tarifaacabado.php @@ -41,7 +41,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController // Breadcrumbs $this->viewData['breadcrumb'] = [ - ['title' => lang("App.menu_tarifas"), 'route' => "", 'active' => false], + ['title' => lang("App.menu_tarifas"), 'route' => "javascript:void(0);", 'active' => false], ['title' => lang("App.menu_tarifaacabado"), 'route' => site_url('tarifas/tarifaacabado'), 'active' => true] ]; @@ -114,13 +114,15 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(site_url('tarifas/tarifaacabado/edit/' . $id))->with('sweet-success', $message); + return redirect()->to(site_url('/tarifas/tarifaacabado/edit/' . $id))->with('sweet-success', $message); //return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); endif; else: - $this->session->setFlashData('sweet-success', $message); + //JJO + $this->viewData['successMessage'] = $message; + //$this->session->setFlashData('sweet-success', $message); endif; endif; // $noException && $successfulResult @@ -187,14 +189,14 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController $tarifaacabadoEntity->fill($sanitizedData); - $thenRedirect = true; + $thenRedirect = false; endif; if ($noException && $successfulResult) : $id = $tarifaacabadoEntity->id ?? $id; $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifaacabado.tarifaacabado'))]) . '.'; - $message .= anchor("tarifasacabado/{$id}/edit", lang('Basic.global.continueEditing') . '?'); - $message = ucfirst(str_replace("'", "\'", $message)); + //$message .= anchor("tarifasacabado/{$id}/edit", lang('Basic.global.continueEditing') . '?'); + //$message = ucfirst(str_replace("'", "\'", $message)); if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -203,7 +205,8 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController return $this->redirect2listView('sweet-success', $message); endif; else: - $this->session->setFlashData('sweet-success', $message); + //JJO + $this->viewData['successMessage'] = $message; endif; endif; // $noException && $successfulResult diff --git a/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php b/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php index fcbeb949..9e965574 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php @@ -22,6 +22,8 @@ use DataTables\Editor\Validate, DataTables\Editor\ValidateOptions; +use function PHPUnit\Framework\isEmpty; + class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController { protected $modelName = TarifaAcabadoLineaModel::class; @@ -248,19 +250,19 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController { // Build our Editor instance and process the data coming from _POST $response = Editor::inst( $db, 'tarifa_acabado_lineas' ) ->fields( - Field::inst( 'tirada_min' ) + Field::inst( 'paginas_min' ) ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.tirada_min.decimal') ) + 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal') ) ) ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.tirada_min.required') ) + 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required') ) ), - Field::inst( 'tirada_max' ) + Field::inst( 'paginas_max' ) ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.tirada_max.decimal') ) + 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal') ) ) ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.tirada_max.required') ) + 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required') ) ), Field::inst( 'precio_min' ) ->validator( 'Validate::numeric', array( @@ -276,12 +278,12 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController { ->validator( 'Validate::notEmpty',array( 'message' => lang('TarifaAcabadoLineas.validation.precio_max.required') ) ), - Field::inst( 'precio_unidad' ) + Field::inst( 'margen' ) ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_unidad.decimal') ) + 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal') ) ) ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_unidad.required') ) + 'message' => lang('TarifaAcabadoLineas.validation.margen.required') ) ), Field::inst( 'tarifa_acabado_id' ), Field::inst( 'user_created_id' ), @@ -296,17 +298,14 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController { if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){ foreach ($data['data'] as $pkey => $values ){ // Si no se quiere borrar... - if($data['data'][$pkey]['is_deleted'] != 1) - { - $count = $this->model->select('*') - ->where(array( 'tarifa_acabado_id'=> $values['tarifa_acabado_id'], - 'tirada_min'=> $values['tirada_min'], - 'tirada_max'=> $values['tirada_max'], - 'is_deleted'=> 0 - )) - ->countAllResults(); - if ($count >= 1){ - return lang('TarifaAcabadoLineas.validation.duplicated_tirada'); + if($data['data'][$pkey]['is_deleted'] != 1){ + + $process_data['paginas_min'] = $data['data'][$pkey]['paginas_min']; + $process_data['paginas_max'] = $data['data'][$pkey]['paginas_max']; + $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_acabado_id']); + // No se pueden duplicar valores al crear o al editar + if (!empty($response)){ + return $response; } } } @@ -338,7 +337,7 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController { // if unique key is set in DB /*if(isset($response['error'])){ - if(str_contains($response['error'], "tirada_min_tirada_max") && + if(str_contains($response['error'], "paginas_min_paginas_max") && str_contains($response['error'], "Duplicate entry ")){ $response['error'] = lang('TarifaAcabadoLineas.validation.duplicated_tirada'); } diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php new file mode 100644 index 00000000..178dbf92 --- /dev/null +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php @@ -0,0 +1,389 @@ +viewData['pageTitle'] = lang('TarifaEncuadernacionLineas.moduleTitle'); + $this->viewData['usingSweetAlert'] = true; + parent::initController($request, $response, $logger); + } + + + public function index() { + + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')]), + 'tarifaEncuadernacionLinea' => new TarifaEncuadernacionLinea(), + 'usingServerSideDataTable' => true, + + ]; + + $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class + + return view(static::$viewPath.'viewTarifaEncuadernacionLineaList', $viewData); + } + + + public function add() { + + + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + endif; + + $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission + endif; + if ($noException && $successfulResult) : + + $id = $this->model->db->insertID(); + + $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea'))]).'.'; + $message .= anchor( "tarifaencuadernacionlineas/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + $message = ucfirst(str_replace("'", "\'", $message)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + + endif; // ($requestMethod === 'post') + + $this->viewData['tarifaEncuadernacionLinea'] = isset($sanitizedData) ? new TarifaEncuadernacionLinea($sanitizedData) : new TarifaEncuadernacionLinea(); + + $this->viewData['formAction'] = route_to('createTarifaEncuadernacionLinea'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('TarifaEncuadernacionLineas.moduleTitle').' '.lang('Basic.global.addNewSuffix'); + + + return $this->displayForm(__METHOD__); + } // end function add() + + public function edit($requestedId = null) { + + if ($requestedId == null) : + return $this->redirect2listView(); + endif; + $id = filter_var($requestedId, FILTER_SANITIZE_URL); + $tarifaEncuadernacionLinea = $this->model->find($id); + + if ($tarifaEncuadernacionLinea == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]); + return $this->redirect2listView('sweet-error', $message); + endif; + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $tarifaEncuadernacionLinea->fill($sanitizedData); + + $thenRedirect = true; + endif; + if ($noException && $successfulResult) : + $id = $tarifaEncuadernacionLinea->id ?? $id; + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea'))]).'.'; + $message .= anchor( "tarifaencuadernacionlineas/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + $message = ucfirst(str_replace("'", "\'", $message)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + $this->viewData['tarifaEncuadernacionLinea'] = $tarifaEncuadernacionLinea; + + $this->viewData['formAction'] = route_to('updateTarifaEncuadernacionLinea', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('TarifaEncuadernacionLineas.moduleTitle').' '.lang('Basic.global.edit3'); + + + return $this->displayForm(__METHOD__, $id); + } // end function edit(...) + + + public function datatable_editor() { + if ($this->request->isAJAX()) { + + include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php"); + + // Build our Editor instance and process the data coming from _POST + $response = Editor::inst( $db, 'tarifa_encuadernacion_lineas' ) + ->fields( + Field::inst( 'paginas_min' ) + ->validator( 'Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal') ) + ) + ->validator( 'Validate::notEmpty',array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required') ) + ), + Field::inst( 'paginas_max' ) + ->validator( 'Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal') ) + ) + ->validator( 'Validate::notEmpty',array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required') ) + ), + Field::inst( 'precio_min' ) + ->validator( 'Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal') ) + ) + ->validator( 'Validate::notEmpty',array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required') ) + ), + Field::inst( 'precio_max' ) + ->validator( 'Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal') ) + ) + ->validator( 'Validate::notEmpty',array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_max.required') ) + ), + Field::inst( 'margen' ) + ->validator( 'Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal') ) + ) + ->validator( 'Validate::notEmpty',array( + 'message' => lang('TarifaAcabadoLineas.validation.margen.required') ) + ), + Field::inst( 'tarifa_encuadernacion_id' ), + Field::inst( 'user_created_id' ), + Field::inst( 'created_at' ), + Field::inst( 'user_updated_id' ), + Field::inst( 'updated_at' ), + Field::inst( 'is_deleted' ), + Field::inst( 'deleted_at' ), + + ) + ->validator( function($editor, $action, $data){ + if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){ + foreach ($data['data'] as $pkey => $values ){ + // Si no se quiere borrar... + if($data['data'][$pkey]['is_deleted'] != 1) + { + $process_data['paginas_min'] = $data['data'][$pkey]['paginas_min']; + $process_data['paginas_max'] = $data['data'][$pkey]['paginas_max']; + $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_encuadernacion_id']); + // No se pueden duplicar valores al crear o al editar + if (!empty($response)){ + return $response; + } + } + } + } + }) + ->on( 'preCreate', function ( $editor, &$values ) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field( 'user_created_id' ) + ->setValue( $session->id_user ); + $editor + ->field( 'created_at' ) + ->setValue( $datetime->format('Y-m-d H:i:s') ); + } ) + ->on( 'preEdit', function ( $editor, &$values ) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field( 'user_updated_id' ) + ->setValue( $session->id_user ); + $editor + ->field( 'updated_at' ) + ->setValue( $datetime->format('Y-m-d H:i:s') ); + } ) + ->debug(true) + ->process( $_POST ) + ->data(); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + $response[$csrfTokenName] = $newTokenHash; + + echo json_encode($response); + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function datatable() { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + if (!isset($reqData['draw']) || !isset($reqData['columns']) ) { + $errstr = 'No data available in response to this specific request.'; + $response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr); + return $response; + } + $start = $reqData['start'] ?? 0; + $length = $reqData['length'] ?? 5; + $search = $reqData['search']['value']; + $requestedOrder = $reqData['order']['0']['column'] ?? 0; + $order = TarifaEncuadernacionLineaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + + $id_TM = $reqData['id_tarifaencuadernacion'] ?? -1; + + $resourceData = $this->model->getResource("", $id_TM)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource()->countAllResults(), + $this->model->getResource($search, $id_TM)->countAllResults() + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function allItemsSelect() { + if ($this->request->isAJAX()) { + $onlyActiveOnes = true; + $reqVal = $this->request->getPost('val') ?? 'id'; + $menu = $this->model->getAllForMenu($reqVal.', tarifa_encuadernacion_id', 'tarifa_encuadernacion_id', $onlyActiveOnes, false); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->tarifa_encuadernacion_id = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function menuItems() { + if ($this->request->isAJAX()) { + $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; + $reqId = goSanitize($this->request->getPost('id'))[0]; + $reqText = goSanitize($this->request->getPost('text'))[0]; + $onlyActiveOnes = false; + $columns2select = [$reqId ?? 'id', $reqText ?? 'tarifa_encuadernacion_id']; + $onlyActiveOnes = false; + $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->text = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + +} diff --git a/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php b/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php index 887d16a4..a663c868 100644 --- a/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php +++ b/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php @@ -212,19 +212,19 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController { // Build our Editor instance and process the data coming from _POST $response = Editor::inst( $db, 'tarifa_manipulado_lineas' ) ->fields( - Field::inst( 'tirada_min' ) + Field::inst( 'paginas_min' ) ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.tirada_min.decimal') ) + 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal') ) ) ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.tirada_min.required') ) + 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required') ) ), - Field::inst( 'tirada_max' ) + Field::inst( 'paginas_max' ) ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.tirada_max.decimal') ) + 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal') ) ) ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.tirada_max.required') ) + 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required') ) ), Field::inst( 'precio_min' ) ->validator( 'Validate::numeric', array( @@ -240,12 +240,12 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController { ->validator( 'Validate::notEmpty',array( 'message' => lang('TarifaAcabadoLineas.validation.precio_max.required') ) ), - Field::inst( 'precio_unidad' ) + Field::inst( 'margen' ) ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_unidad.decimal') ) + 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal') ) ) ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_unidad.required') ) + 'message' => lang('TarifaAcabadoLineas.validation.margen.required') ) ), Field::inst( 'tarifa_manipulado_id' ), Field::inst( 'user_created_id' ), @@ -262,16 +262,12 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController { // Si no se quiere borrar... if($data['data'][$pkey]['is_deleted'] != 1) { - - $count = $this->model->select('*') - ->where(array( - 'tarifa_manipulado_id'=> $values['tarifa_manipulado_id'], - 'tirada_min'=> $values['tirada_min'], - 'tirada_max'=> $values['tirada_max'], - 'is_deleted'=> 0)) - ->countAllResults(); - if ($count >= 1){ - return lang('TarifaAcabadoLineas.validation.duplicated_tirada'); + $process_data['paginas_min'] = $data['data'][$pkey]['paginas_min']; + $process_data['paginas_max'] = $data['data'][$pkey]['paginas_max']; + $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_manipulado_id']); + // No se pueden duplicar valores al crear o al editar + if (!empty($response)){ + return $response; } } } @@ -301,14 +297,6 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController { ->process( $_POST ) ->data(); - - /*// if unique key is set in DB - if(isset($response['error'])){ - if(str_contains($response['error'], "tirada_min_tirada_max") && - str_contains($response['error'], "Duplicate entry ")){ - $response['error'] = lang('TarifaAcabadoLineas.validation.duplicated_tirada'); - } - }*/ $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); diff --git a/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php b/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php index 38e4fd0b..6a0f0742 100644 --- a/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php +++ b/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php @@ -29,7 +29,7 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController { // Breadcrumbs $this->viewData['breadcrumb'] = [ - ['title' => lang("App.menu_tarifas"), 'route' => "", 'active' => false], + ['title' => lang("App.menu_tarifas"), 'route' => "javascript:void(0);", 'active' => false], ['title' => lang("App.menu_tarifapreimpresion"), 'route' => site_url('tarifas/tarifapreimpresion'), 'active' => true] ]; @@ -142,9 +142,6 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController { $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - - - if ($this->canValidate()) : try { $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); @@ -160,13 +157,13 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController { $tarifapreimpresionEntity->fill($sanitizedData); - $thenRedirect = true; + $thenRedirect = false; endif; if ($noException && $successfulResult) : $id = $tarifapreimpresionEntity->id ?? $id; $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifapreimpresion.tarifapreimpresion'))]).'.'; - $message .= anchor(route_to('editTarifapreimpresion', $id), lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + //$message .= anchor(route_to('editTarifapreimpresion', $id), lang('Basic.global.continueEditing').'?'); + //$message = ucfirst(str_replace("'", "\'", $message)); if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -175,6 +172,7 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController { return $this->redirect2listView('successMessage', $message); endif; else: + //JJO $this->viewData['successMessage'] = $message; endif; diff --git a/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php b/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php new file mode 100644 index 00000000..b39ad5c3 --- /dev/null +++ b/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php @@ -0,0 +1,296 @@ +viewData['pageTitle'] = lang('Tarifaencuadernacion.moduleTitle'); + $this->viewData['usingSweetAlert'] = true; + + // Se indica que este controlador trabaja con soft_delete + $this->soft_delete = true; + // Se indica el flag para los ficheros borrados + $this->delete_flag = 1; + + $this->viewData = ['usingServerSideDataTable' => true]; // JJO + + // Breadcrumbs + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_tarifas"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("App.menu_tarifaencuadernacion"), 'route' => site_url('tarifas/tarifasencuadernacion'), 'active' => true] + ]; + + parent::initController($request, $response, $logger); + } + + + public function index() { + + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tarifaencuadernacion.tarifaencuadernacion')]), + 'tarifaEncuadernacionEntity' => new TarifaEncuadernacionEntity(), + 'usingServerSideDataTable' => true, + + ]; + + $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class + + return view(static::$viewPath.'viewTarifaEncuadernacionList', $viewData); + } + + + public function add() { + + // JJO + $session = session(); + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + // JJO + if(isset($this->model->user_updated_id)){ + $sanitizedData['user_created_id'] = $session->id_user; + } + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifaencuadernacion.tarifaencuadernacion'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + endif; + + $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission + endif; + if ($noException && $successfulResult) : + + $id = $this->model->db->insertID(); + + $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Tarifaencuadernacion.tarifaencuadernacion'))]).'.'; + //$message .= anchor( "tarifaencuadernacion/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + //$message = ucfirst(str_replace("'", "\'", $message)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(site_url('tarifas/tarifasencuadernacion/edit/'.$id))->with('sweet-success', $message); + //return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + //JJO + $this->viewData['successMessage'] = $message; + //$this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + + endif; // ($requestMethod === 'post') + + $this->viewData['tarifaEncuadernacionEntity'] = isset($sanitizedData) ? new TarifaEncuadernacionEntity($sanitizedData) : new TarifaEncuadernacionEntity(); + + $this->viewData['formAction'] = site_url('tarifas/tarifasencuadernacion/add');//route_to('createTarifaEncuadernacion'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Tarifaencuadernacion.moduleTitle').' '.lang('Basic.global.addNewSuffix'); + + + return $this->displayForm(__METHOD__); + } // end function add() + + public function edit($requestedId = null) { + + // JJO + $session = session(); + + if ($requestedId == null) : + return $this->redirect2listView(); + endif; + $id = filter_var($requestedId, FILTER_SANITIZE_URL); + $tarifaEncuadernacionEntity = $this->model->find($id); + + if ($tarifaEncuadernacionEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tarifaencuadernacion.tarifaencuadernacion')), $id]); + return $this->redirect2listView('sweet-error', $message); + endif; + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + // JJO + if(isset($this->model->user_updated_id)){ + $sanitizedData['user_updated_id'] = $session->id_user; + } + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifaencuadernacion.tarifaencuadernacion'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $tarifaEncuadernacionEntity->fill($sanitizedData); + + $thenRedirect = false; + endif; + if ($noException && $successfulResult) : + $id = $tarifaEncuadernacionEntity->id ?? $id; + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifaencuadernacion.tarifaencuadernacion'))]).'.'; + //$message .= anchor( "tarifa ulado/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + //$message = ucfirst(str_replace("'", "\'", $message)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->viewData['successMessage'] = $message; + endif; + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + $this->viewData['tarifaEncuadernacionEntity'] = $tarifaEncuadernacionEntity; + + $this->viewData['formAction'] = route_to('updateTarifaEncuadernacion', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Tarifaencuadernacion.moduleTitle').' '.lang('Basic.global.edit3'); + + + return $this->displayForm(__METHOD__, $id); + } // end function edit(...) + + + + public function datatable() { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + if (!isset($reqData['draw']) || !isset($reqData['columns']) ) { + $errstr = 'No data available in response to this specific request.'; + $response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr); + return $response; + } + $start = $reqData['start'] ?? 0; + $length = $reqData['length'] ?? 5; + $search = $reqData['search']['value']; + $requestedOrder = $reqData['order']['0']['column'] ?? 1; + $order = TarifaEncuadernacionModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + + $resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource()->countAllResults(), + $this->model->getResource($search)->countAllResults() + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function allItemsSelect() { + if ($this->request->isAJAX()) { + $onlyActiveOnes = true; + $reqVal = $this->request->getPost('val') ?? 'id'; + $menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->nombre = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function menuItems() { + if ($this->request->isAJAX()) { + $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; + $reqId = goSanitize($this->request->getPost('id'))[0]; + $reqText = goSanitize($this->request->getPost('text'))[0]; + $onlyActiveOnes = false; + $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; + $onlyActiveOnes = false; + $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->text = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + +} diff --git a/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php b/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php index 6340b8eb..a5d5b9b2 100644 --- a/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php +++ b/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php @@ -40,8 +40,8 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { // Breadcrumbs $this->viewData['breadcrumb'] = [ - ['title' => lang("App.menu_tarifas"), 'route' => "", 'active' => false], - ['title' => lang("App.menu_tarifamanipulado"), 'route' => site_url('tarifas/tarifamanipulado'), 'active' => true] + ['title' => lang("App.menu_tarifas"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("App.menu_tarifamanipulado"), 'route' => site_url('tarifas/tarifasmanipulado'), 'active' => true] ]; parent::initController($request, $response, $logger); @@ -118,7 +118,9 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { return $this->redirect2listView('sweet-success', $message); endif; else: - $this->session->setFlashData('sweet-success', $message); + //JJO + $this->viewData['successMessage'] = $message; + //$this->session->setFlashData('sweet-success', $message); endif; endif; // $noException && $successfulResult @@ -127,7 +129,7 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { $this->viewData['tarifaManipuladoEntity'] = isset($sanitizedData) ? new TarifaManipuladoEntity($sanitizedData) : new TarifaManipuladoEntity(); - $this->viewData['formAction'] = site_url('configuracion/maquinas/add');//route_to('createTarifaManipulado'); + $this->viewData['formAction'] = site_url('tarifas/tarifasmanipulado/add');//route_to('createTarifaManipulado'); $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Tarifamanipulado.moduleTitle').' '.lang('Basic.global.addNewSuffix'); @@ -183,13 +185,13 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { $tarifaManipuladoEntity->fill($sanitizedData); - $thenRedirect = true; + $thenRedirect = false; endif; if ($noException && $successfulResult) : $id = $tarifaManipuladoEntity->id ?? $id; $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado'))]).'.'; - $message .= anchor( "tarifamanipulado/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + //$message .= anchor( "tarifamanipulado/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + //$message = ucfirst(str_replace("'", "\'", $message)); if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -198,7 +200,7 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { return $this->redirect2listView('sweet-success', $message); endif; else: - $this->session->setFlashData('sweet-success', $message); + $this->viewData['successMessage'] = $message; endif; endif; // $noException && $successfulResult diff --git a/ci4/app/Entities/Tarifas/TarifaAcabadoLinea.php b/ci4/app/Entities/Tarifas/TarifaAcabadoLinea.php index 7a8dbf13..832fa317 100644 --- a/ci4/app/Entities/Tarifas/TarifaAcabadoLinea.php +++ b/ci4/app/Entities/Tarifas/TarifaAcabadoLinea.php @@ -8,11 +8,11 @@ class TarifaAcabadoLinea extends \CodeIgniter\Entity\Entity protected $attributes = [ "id" => null, "tarifa_acabado_id" => 0, - "tirada_min" => 0, - "tirada_max" => 0, + "paginas_min" => 0, + "paginas_max" => 0, "precio_min" => 0, "precio_max" => 0, - "precio_unidad" => 0, + "margen" => 0, "user_created_id" => 0, "user_updated_id" => 0, "is_deleted" => 0, @@ -25,7 +25,7 @@ class TarifaAcabadoLinea extends \CodeIgniter\Entity\Entity "tirada_max" => "int", "precio_min" => "float", "precio_max" => "float", - "precio_unidad" => "float", + "margen" => "float", "user_created_id" => "int", "user_updated_id" => "int", "is_deleted" => "int", diff --git a/ci4/app/Entities/Tarifas/TarifaEncuadernacionEntity.php b/ci4/app/Entities/Tarifas/TarifaEncuadernacionEntity.php new file mode 100644 index 00000000..bdc01d4b --- /dev/null +++ b/ci4/app/Entities/Tarifas/TarifaEncuadernacionEntity.php @@ -0,0 +1,28 @@ + null, + "nombre" => null, + "precio_min" => 0, + "importe_fijo" => 0, + "user_created_id" => 0, + "user_updated_id" => 0, + "is_deleted" => 0, + "deleted_at" => null, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "precio_min" => "float", + "importe_fijo" => "float", + "user_created_id" => "int", + "user_updated_id" => "int", + "is_deleted" => "int", + ]; +} diff --git a/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php b/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php new file mode 100644 index 00000000..58041841 --- /dev/null +++ b/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php @@ -0,0 +1,33 @@ + null, + "tarifa_encuadernacion_id" => 0, + "paginas_min" => 0, + "paginas_max" => 0, + "precio_min" => 0, + "precio_max" => 0, + "margen" => 0, + "user_created_id" => 0, + "user_updated_id" => 0, + "is_deleted" => 0, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "tarifa_encuadernacion_id" => "int", + "paginas_min" => "float", + "paginas_max" => "float", + "precio_min" => "float", + "precio_max" => "float", + "margen" => "float", + "user_created_id" => "int", + "user_updated_id" => "int", + "is_deleted" => "int", + ]; +} diff --git a/ci4/app/Entities/Tarifas/TarifaManipuladoLinea.php b/ci4/app/Entities/Tarifas/TarifaManipuladoLinea.php index eed0f449..63b503c2 100644 --- a/ci4/app/Entities/Tarifas/TarifaManipuladoLinea.php +++ b/ci4/app/Entities/Tarifas/TarifaManipuladoLinea.php @@ -8,11 +8,11 @@ class TarifaManipuladoLinea extends \CodeIgniter\Entity\Entity protected $attributes = [ "id" => null, "tarifa_manipulado_id" => 0, - "tirada_min" => 0, - "tirada_max" => 0, + "paginas_min" => 0, + "paginas_max" => 0, "precio_min" => 0, "precio_max" => 0, - "precio_unidad" => 0, + "margen" => 0, "user_created_id" => 0, "user_updated_id" => 0, "is_deleted" => 0, @@ -21,11 +21,11 @@ class TarifaManipuladoLinea extends \CodeIgniter\Entity\Entity ]; protected $casts = [ "tarifa_manipulado_id" => "int", - "tirada_min" => "float", - "tirada_max" => "float", + "paginas_min" => "float", + "paginas_max" => "float", "precio_min" => "float", "precio_max" => "float", - "precio_unidad" => "float", + "margen" => "float", "user_created_id" => "int", "user_updated_id" => "int", "is_deleted" => "int", diff --git a/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php b/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php index e7199ff0..599bc822 100644 --- a/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php +++ b/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php @@ -8,9 +8,10 @@ class TarifapreimpresionEntity extends \CodeIgniter\Entity\Entity protected $attributes = [ "id" => null, "nombre" => null, - "precio" => null, + "precio_pagina" => null, "precio_min" => 0, "importe_fijo" => 0, + "margen" => 0, "user_created_id" => 1, "user_update_id" => 1, "is_deleted" => 0, @@ -19,9 +20,10 @@ class TarifapreimpresionEntity extends \CodeIgniter\Entity\Entity "updated_at" => null, ]; protected $casts = [ - "precio" => "float", + "precio_pagina" => "float", "precio_min" => "float", "importe_fijo" => "float", + "margen" => "float", "user_created_id" => "int", "user_update_id" => "int", "is_deleted" => "int", diff --git a/ci4/app/Helpers/general_helper.php b/ci4/app/Helpers/general_helper.php index 495703c6..c2d3c27a 100644 --- a/ci4/app/Helpers/general_helper.php +++ b/ci4/app/Helpers/general_helper.php @@ -641,6 +641,15 @@ function templateSelect($templates=[],$name='',$type='') { return null; } +// Devuelve true si los intervalos (a1,a2) (b1,b2) se solapan +// https://stackoverflow.com/questions/3269434/whats-the-most-efficient-way-to-test-if-two-ranges-overlap +function check_overlap($a1, $a2, $b1, $b2){ + + if (max($a2, $b2) - min($a1, $b1) <= ($a2 - $a1) + ($b2 - $b1)) + return true; + return false; +} + function version() { return "1.2.1"; } \ No newline at end of file diff --git a/ci4/app/Language/en/App.php b/ci4/app/Language/en/App.php index d3641a7b..63aa7ec6 100644 --- a/ci4/app/Language/en/App.php +++ b/ci4/app/Language/en/App.php @@ -752,6 +752,7 @@ return [ "menu_tarifas" => "Rates", "menu_tarifapreimpresion" => "Preprinting", "menu_tarifamanipulado" => "Handling", + "menu_tarifaencuadernacion" => "Binding", "menu_tarifapapelcompra" => "Paper", "menu_tarifaacabado" => "Finish", "menu_tarifapapeldefecto" => "Default paper", diff --git a/ci4/app/Language/en/Maquinas.php b/ci4/app/Language/en/Maquinas.php index ca28974c..443c0bdd 100644 --- a/ci4/app/Language/en/Maquinas.php +++ b/ci4/app/Language/en/Maquinas.php @@ -5,10 +5,10 @@ return [ 'acabado' => 'finish', 'alto' => 'Height', - 'altoClick' => 'Height Click', - 'altoImpresion' => 'Height Printing', + 'altoClick' => 'Click Height', + 'altoImpresion' => 'Printing Height', 'ancho' => 'Width', - 'anchoImpresion' => 'Width Printing', + 'anchoImpresion' => 'Printing Width', 'createdAt' => 'Created At', 'deletedAt' => 'Deleted At', 'duracionJornada' => 'Working day duration', @@ -42,14 +42,16 @@ return [ 'velocidad' => 'Speed', 'velocidadCorte' => 'Cut speed', 'validation' => [ + 'alto_menor_alto_impresion' => '\'Printing Height\' field must be lower than \'Height\'', + 'ancho_menor_ancho_impresion' => '\'Printing Width\' field must be lower than \'Width\'', 'alto' => [ 'decimal' => 'The {field} field must contain a decimal number.', - + 'greater_than' => 'The field {field} must be greater than {param}', ], 'ancho' => [ 'decimal' => 'The {field} field must contain a decimal number.', - + 'greater_than' => 'The field {field} must be greater than {param}', ], 'forzar_num_formas_horizontales_portada' => [ @@ -65,19 +67,20 @@ return [ 'alto_click' => [ 'decimal' => 'The {field} field must contain a decimal number.', 'required' => 'The {field} field is required.', + 'greater_than' => 'The field {field} must be greater than {param}', ], 'alto_impresion' => [ 'decimal' => 'The {field} field must contain a decimal number.', 'required' => 'The {field} field is required.', - + 'greater_than' => 'The field {field} must be greater than {param}', ], 'ancho_impresion' => [ 'decimal' => 'The {field} field must contain a decimal number.', 'required' => 'The {field} field is required.', - + 'greater_than' => 'The field {field} must be greater than {param}', ], 'duracion_jornada' => [ diff --git a/ci4/app/Language/en/MaquinasPapelImpresion.php b/ci4/app/Language/en/MaquinasPapelImpresion.php index b16a906e..f1d3829b 100644 --- a/ci4/app/Language/en/MaquinasPapelImpresion.php +++ b/ci4/app/Language/en/MaquinasPapelImpresion.php @@ -3,6 +3,7 @@ return [ + 'papel_impresion_maquinas' => 'Printing papers', 'activo' => 'Active', 'gramaje_duplicado' => 'It can not be selected two pieces of paper with the same grammage', 'sureToChangeRotativaTitle' => 'Are you sure to change this option?', diff --git a/ci4/app/Language/en/TarifaAcabadoLineas.php b/ci4/app/Language/en/TarifaAcabadoLineas.php index 9b120843..db580bec 100644 --- a/ci4/app/Language/en/TarifaAcabadoLineas.php +++ b/ci4/app/Language/en/TarifaAcabadoLineas.php @@ -9,10 +9,12 @@ return [ 'precioMax' => 'Max Price', 'precioMin' => 'Min Price', 'precioUnidad' => 'Price Unit', - 'tiradaMax' => 'Print Max', - 'tiradaMin' => 'Print Min', + 'paginasMax' => 'Max Pages', + 'paginasMin' => 'Min Pages', + 'margen' => 'Margin', 'validation' => [ - 'duplicated_tirada' => "Duplicated line (the couple 'Print Min' and 'Print Max' must be unique)", + 'error_paginas_overlap' => 'The range [Min Pages, Max Pages] is overlapped with another one for the selected type.', + 'error_paginas_range' => 'The field Min Pages must be lower than the field Max Pages', 'precio_max' => [ 'decimal' => 'The field must contain a decimal number.', 'required' => 'The field is required.', @@ -25,24 +27,24 @@ return [ ], - 'precio_unidad' => [ - 'decimal' => 'The field must contain a decimal number.', - 'required' => 'The field is required.', - - ], - - 'tirada_max' => [ + 'paginas_max' => [ 'integer' => 'The field must contain an integer.', 'required' => 'The field is required.', ], - 'tirada_min' => [ + 'paginas_min' => [ 'integer' => 'The field must contain an integer.', 'required' => 'The field is required.', ], + 'margen' => [ + 'integer' => 'The field must contain a decimal number.', + 'required' => 'The field is required.', + + ], + ], diff --git a/ci4/app/Language/en/TarifaEncuadernacionLineas.php b/ci4/app/Language/en/TarifaEncuadernacionLineas.php new file mode 100644 index 00000000..d3528a85 --- /dev/null +++ b/ci4/app/Language/en/TarifaEncuadernacionLineas.php @@ -0,0 +1,50 @@ + 'ID', + 'moduleTitle' => 'Binding rates Lines', + 'deleteLine' => 'the selected register', + 'precioMax' => 'Max Price', + 'precioMin' => 'Min Price', + 'precioUnidad' => 'Price Unit', + 'paginasMax' => 'Max Pages', + 'paginasMin' => 'Min Pages', + 'margen' => 'Margin', + 'validation' => [ + 'error_paginas_overlap' => 'The range [Min Pages, Max Pages] is overlapped with another one for the selected type.', + 'error_paginas_range' => 'The field Min Pages must be lower than the field Max Pages', + 'precio_max' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'precio_min' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'paginas_max' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'paginas_min' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + 'margen' => [ + 'integer' => 'The field must contain a decimal number.', + 'required' => 'The field is required.', + + ], + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/en/TarifaManipuladoLineas.php b/ci4/app/Language/en/TarifaManipuladoLineas.php index 1a214500..5da798c9 100644 --- a/ci4/app/Language/en/TarifaManipuladoLineas.php +++ b/ci4/app/Language/en/TarifaManipuladoLineas.php @@ -9,9 +9,12 @@ return [ 'precioMax' => 'Max Price', 'precioMin' => 'Min Price', 'precioUnidad' => 'Price Unit', - 'tiradaMax' => 'Print Max', - 'tiradaMin' => 'Print Min', + 'paginasMax' => 'Max Pages', + 'paginasMin' => 'Min Pages', + 'margen' => 'Margin', 'validation' => [ + 'error_paginas_overlap' => 'The range [Min Pages, Max Pages] is overlapped with another one for the selected type.', + 'error_paginas_range' => 'The field Min Pages must be lower than the field Max Pages', 'precio_max' => [ 'decimal' => 'The {field} field must contain a decimal number.', 'required' => 'The {field} field is required.', @@ -24,25 +27,23 @@ return [ ], - 'precio_unidad' => [ + 'paginas_max' => [ 'decimal' => 'The {field} field must contain a decimal number.', 'required' => 'The {field} field is required.', ], - 'tirada_max' => [ + 'paginas_min' => [ 'decimal' => 'The {field} field must contain a decimal number.', 'required' => 'The {field} field is required.', ], - - 'tirada_min' => [ - 'decimal' => 'The {field} field must contain a decimal number.', - 'required' => 'The {field} field is required.', + 'margen' => [ + 'integer' => 'The field must contain a decimal number.', + 'required' => 'The field is required.', ], - ], diff --git a/ci4/app/Language/en/Tarifaacabado.php b/ci4/app/Language/en/Tarifaacabado.php index 08940774..64532898 100644 --- a/ci4/app/Language/en/Tarifaacabado.php +++ b/ci4/app/Language/en/Tarifaacabado.php @@ -12,6 +12,9 @@ return [ 'nombre' => 'Name', 'precioMax' => 'Price Max', 'precioMin' => 'Price Min', + 'precioMin' => 'Min Price', + 'importeFijo' => 'Fixed amount', + 'margen' => 'Margin', 'tarifaacabado' => 'Finishing Rates', 'tarifaacabadoList' => 'Finishing Rates List', 'tarifasacabado' => 'Finishing Rates', diff --git a/ci4/app/Language/en/Tarifaencuadernacion.php b/ci4/app/Language/en/Tarifaencuadernacion.php new file mode 100644 index 00000000..99936ab0 --- /dev/null +++ b/ci4/app/Language/en/Tarifaencuadernacion.php @@ -0,0 +1,92 @@ + 'Adjustment', + 'ajusteTotalPedido' => 'Order Total Adjustment', + 'createdAt' => 'Created At', + 'deletedAt' => 'Deleted At', + 'formulaPrice' => 'Formula Price', + 'id' => 'ID', + 'moduleTitle' => 'Binding rates', + 'nombre' => 'Name', + 'precioMax' => 'Price Max', + 'precioMin' => 'Price Min', + 'precioMin' => 'Min Price', + 'importeFijo' => 'Fixed amount', + 'margen' => 'Margin', + 'tarifaencuadernacion' => 'Binding rate', + 'tarifaencuadernacionList' => 'Binding rates List', + 'tarifasencuadernacion' => 'Binding rates', + 'tiradaMax' => 'Print Max', + 'tiradaMin' => 'Print Min', + 'updatedAt' => 'Updated At', + 'userCreatedId' => 'User Created ID', + 'userUpdateId' => 'User Update ID', + 'validation' => [ + 'ajuste' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'ajuste_total_pedido' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'formula_price' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + 'nombre' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + 'precio_max' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'precio_min' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'tirada_max' => [ + 'integer' => 'The {field} field must contain an integer.', + 'required' => 'The {field} field is required.', + + ], + + 'tirada_min' => [ + 'integer' => 'The {field} field must contain an integer.', + 'required' => 'The {field} field is required.', + + ], + + 'user_created_id' => [ + 'integer' => 'The {field} field must contain an integer.', + 'required' => 'The {field} field is required.', + + ], + + 'user_updated_id' => [ + 'integer' => 'The {field} field must contain an integer.', + 'required' => 'The {field} field is required.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/en/Tarifamanipulado.php b/ci4/app/Language/en/Tarifamanipulado.php index 7b260795..a29c2097 100644 --- a/ci4/app/Language/en/Tarifamanipulado.php +++ b/ci4/app/Language/en/Tarifamanipulado.php @@ -13,6 +13,9 @@ return [ 'nombre' => 'Name', 'precioMax' => 'Price Max', 'precioMin' => 'Price Min', + 'precioMin' => 'Min Price', + 'importeFijo' => 'Fixed amount', + 'margen' => 'Margin', 'tarifamanipulado' => 'Handling rate', 'tarifamanipuladoList' => 'Handling rates List', 'tarifasmanipulado' => 'Handling rates', diff --git a/ci4/app/Language/en/Tarifapreimpresion.php b/ci4/app/Language/en/Tarifapreimpresion.php index 3dd6ecb3..a391b388 100644 --- a/ci4/app/Language/en/Tarifapreimpresion.php +++ b/ci4/app/Language/en/Tarifapreimpresion.php @@ -8,7 +8,10 @@ return [ 'id' => 'ID', 'moduleTitle' => 'Preprinting rates', 'nombre' => 'Name', - 'precio' => 'Price', + 'precio' => 'Price per page', + 'precioMin' => 'Min Price', + 'importeFijo' => 'Fixed amount', + 'margen' => 'Margin', 'tarifapreimpresion' => 'Preprinting rate', 'tarifapreimpresionList' => 'Preprinting rates List', 'tarifaspreimpresion' => 'Preprinting rates', diff --git a/ci4/app/Language/es/App.php b/ci4/app/Language/es/App.php index 34dafad2..3a15357b 100644 --- a/ci4/app/Language/es/App.php +++ b/ci4/app/Language/es/App.php @@ -759,11 +759,13 @@ return [ "menu_tarifas" => "Tarifas", "menu_tarifapreimpresion" => "Preimpresión", "menu_tarifamanipulado" => "Manipulado", + "menu_tarifaencuadernacion" => "Encuadernación", "menu_tarifapapelcompra" => "Papel compra", "menu_tarifaacabado" => "Acabado", "menu_tarifapapeldefecto" => "Papel defecto", "menu_tarifaenvio" => "EnvÃo", "menu_tarifaimpresion" => "Impresión", + "menu_encuadernacion" => "Encuadernación", "menu_users" => "Usuarios", "menu_permission_group" => "Roles y permisos", diff --git a/ci4/app/Language/es/Maquinas.php b/ci4/app/Language/es/Maquinas.php index 733d17d3..a58cfc6c 100644 --- a/ci4/app/Language/es/Maquinas.php +++ b/ci4/app/Language/es/Maquinas.php @@ -42,14 +42,16 @@ return [ 'velocidad' => 'Velocidad', 'velocidadCorte' => 'Velocidad Corte', 'validation' => [ + 'alto_menor_alto_impresion' => 'El campo \'Alto impresión\' debe ser menor que \'Alto\'', + 'ancho_menor_ancho_impresion' => '\'Ancho Impresión\' debe ser menor que \'Ancho\'', 'alto' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', - + 'greater_than' => 'El campo {field} debe ser mayor que {param}', ], 'ancho' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', - + 'greater_than' => 'El campo {field} debe ser mayor que {param}', ], 'forzar_num_formas_horizontales_portada' => [ @@ -65,19 +67,19 @@ return [ 'alto_click' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', 'required' => 'El campo {field} es obligatorio.', - + 'greater_than' => 'El campo {field} debe ser mayor que {param}', ], 'alto_impresion' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', 'required' => 'El campo {field} es obligatorio.', - + 'greater_than' => 'El campo {field} debe ser mayor que {param}', ], 'ancho_impresion' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', 'required' => 'El campo {field} es obligatorio.', - + 'greater_than' => 'El campo {field} debe ser mayor que {param}', ], 'duracion_jornada' => [ diff --git a/ci4/app/Language/es/MaquinasPapelImpresion.php b/ci4/app/Language/es/MaquinasPapelImpresion.php index a9bc0ce8..65f6e453 100644 --- a/ci4/app/Language/es/MaquinasPapelImpresion.php +++ b/ci4/app/Language/es/MaquinasPapelImpresion.php @@ -3,6 +3,7 @@ return [ + 'papel_impresion_maquinas' => 'Papeles impresion', 'activo' => 'Activo', 'gramaje_duplicado' => 'No se pueden seleccionar dos papeles con el mismo gramaje', 'sureToChangeRotativaTitle' => 'Está seguro de cambiar esta opción?', diff --git a/ci4/app/Language/es/TarifaAcabadoLineas.php b/ci4/app/Language/es/TarifaAcabadoLineas.php index a4fd7b57..00f4c41a 100644 --- a/ci4/app/Language/es/TarifaAcabadoLineas.php +++ b/ci4/app/Language/es/TarifaAcabadoLineas.php @@ -9,10 +9,12 @@ return [ 'precioMax' => 'Precio Max', 'precioMin' => 'Precio Min', 'precioUnidad' => 'Precio Unidad', - 'tiradaMax' => 'Tirada Max', - 'tiradaMin' => 'Tirada Min', + 'paginasMax' => 'Páginas Max', + 'paginasMin' => 'Páginas Min', + 'margen' => 'Margen', 'validation' => [ - 'duplicated_tirada' => "LÃnea duplicada (la pareja 'Tirada Min' y 'Tirada Max' debe de ser única)", + 'error_paginas_overlap' => 'El rango [Páginas Min, Páginas Max] se solapa con otro existente para el tipo seleccionado.', + 'error_paginas_range' => 'El campo Páginas Min debe ser menor que el campo Páginas Max', 'precio_max' => [ 'decimal' => 'El campo debe contener un número decimal.', 'required' => 'El campo es obligatorio.', @@ -25,24 +27,24 @@ return [ ], - 'precio_unidad' => [ + 'paginas_max' => [ + 'integer' => 'El campo debe contener un número entero.', + 'required' => 'El campo es obligatorio.', + + ], + + 'paginas_min' => [ + 'integer' => 'El campo debe contener un número entero.', + 'required' => 'El campo es obligatorio.', + + ], + + 'margen' => [ 'decimal' => 'El campo debe contener un número decimal.', 'required' => 'El campo es obligatorio.', ], - 'tirada_max' => [ - 'integer' => 'El campo debe contener un número entero.', - 'required' => 'El campo es obligatorio.', - - ], - - 'tirada_min' => [ - 'integer' => 'El campo debe contener un número entero.', - 'required' => 'El campo es obligatorio.', - - ], - ], diff --git a/ci4/app/Language/es/TarifaEncuadernacionLineas.php b/ci4/app/Language/es/TarifaEncuadernacionLineas.php new file mode 100644 index 00000000..eb7f5f84 --- /dev/null +++ b/ci4/app/Language/es/TarifaEncuadernacionLineas.php @@ -0,0 +1,50 @@ + 'ID', + 'moduleTitle' => 'Tarifa Encuadernación Lineas', + 'deleteLine' => 'el registro seleccionado', + 'precioMax' => 'Precio Max', + 'precioMin' => 'Precio Min', + 'precioUnidad' => 'Precio Unidad', + 'paginasMax' => 'Páginas Max', + 'paginasMin' => 'Páginas Min', + 'margen' => 'Margen', + 'validation' => [ + 'error_paginas_overlap' => 'El rango [Páginas Min, Páginas Max] se solapa con otro existente para el tipo seleccionado.', + 'error_paginas_range' => 'El campo Páginas Min debe ser menor que el campo Páginas Max', + 'precio_max' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'The {field} field is required.', + + ], + + 'precio_min' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'The {field} field is required.', + + ], + + 'paginas_max' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'The {field} field is required.', + + ], + + 'paginas_min' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'The {field} field is required.', + + ], + 'margen' => [ + 'decimal' => 'El campo debe contener un número decimal.', + 'required' => 'El campo es obligatorio.', + + ], + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/es/TarifaManipuladoLineas.php b/ci4/app/Language/es/TarifaManipuladoLineas.php index 34996362..4d8ce4c6 100644 --- a/ci4/app/Language/es/TarifaManipuladoLineas.php +++ b/ci4/app/Language/es/TarifaManipuladoLineas.php @@ -9,9 +9,12 @@ return [ 'precioMax' => 'Precio Max', 'precioMin' => 'Precio Min', 'precioUnidad' => 'Precio Unidad', - 'tiradaMax' => 'Tirada Max', - 'tiradaMin' => 'Tirada Min', + 'paginasMax' => 'Páginas Max', + 'paginasMin' => 'Páginas Min', + 'margen' => 'Margen', 'validation' => [ + 'error_paginas_overlap' => 'El rango [Páginas Min, Páginas Max] se solapa con otro existente para el tipo seleccionado.', + 'error_paginas_range' => 'El campo Páginas Min debe ser menor que el campo Páginas Max', 'precio_max' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', 'required' => 'The {field} field is required.', @@ -24,25 +27,23 @@ return [ ], - 'precio_unidad' => [ + 'paginas_max' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', 'required' => 'The {field} field is required.', ], - 'tirada_max' => [ + 'paginas_min' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', 'required' => 'The {field} field is required.', ], - - 'tirada_min' => [ - 'decimal' => 'El campo {field} debe contener un número decimal.', - 'required' => 'The {field} field is required.', + 'margen' => [ + 'decimal' => 'El campo debe contener un número decimal.', + 'required' => 'El campo es obligatorio.', ], - ], diff --git a/ci4/app/Language/es/Tarifaencuadernacion.php b/ci4/app/Language/es/Tarifaencuadernacion.php new file mode 100644 index 00000000..1bf6306d --- /dev/null +++ b/ci4/app/Language/es/Tarifaencuadernacion.php @@ -0,0 +1,89 @@ + 'Ajuste', + 'ajusteTotalPedido' => 'Ajuste Total Pedido', + 'createdAt' => 'Creado en', + 'deletedAt' => 'Borrado en', + 'formulaPrice' => 'Fórmula precio', + 'id' => 'ID', + 'moduleTitle' => 'Tarifas Encuadernación', + 'nombre' => 'Nombre', + 'precioMax' => 'Precio Max', + 'precioMin' => 'Precio Min', + 'importeFijo' => 'Importe Fijo', + 'tarifaencuadernacion' => 'Tarifa Encuadernación', + 'tarifaencuadernacionList' => 'Lista Tarifas Encuadernación', + 'tarifasencuadernacion' => 'Tarifas Encuadernación', + 'tiradaMax' => 'Tirada Max', + 'tiradaMin' => 'Tirada Min', + 'updatedAt' => 'Actualizado en', + 'userCreatedId' => 'ID Usuario \"Creado en\"', + 'userUpdateId' => 'ID Usuario \"Actualizado en\"', + 'validation' => [ + 'ajuste' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'ajuste_total_pedido' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'formula_price' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'nombre' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'precio_max' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'precio_min' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'tirada_max' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'tirada_min' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'user_created_id' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'user_update_id' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/es/Tarifapreimpresion.php b/ci4/app/Language/es/Tarifapreimpresion.php index 999273cf..c579fecd 100644 --- a/ci4/app/Language/es/Tarifapreimpresion.php +++ b/ci4/app/Language/es/Tarifapreimpresion.php @@ -7,9 +7,10 @@ return [ 'id' => 'ID', 'moduleTitle' => 'Tarifas Preimpresión', 'nombre' => 'Nombre', - 'precio' => 'Precio', + 'precio' => 'Precio/página', 'precioMin' => 'Precio MÃnimo', 'importeFijo' => 'Importe Fijo', + 'margen' => 'Margen', 'tarifapreimpresion' => 'Tarifa Preimpresión', 'tarifapreimpresionList' => 'Lista Tarifas Preimpresión', 'tarifaspreimpresion' => 'Tarifas Preimpresión', diff --git a/ci4/app/Models/Configuracion/MaquinaModel.php b/ci4/app/Models/Configuracion/MaquinaModel.php index 35ada300..fb17d42e 100644 --- a/ci4/app/Models/Configuracion/MaquinaModel.php +++ b/ci4/app/Models/Configuracion/MaquinaModel.php @@ -72,23 +72,23 @@ class MaquinaModel extends \App\Models\GoBaseModel protected $validationRules = [ "alto" => [ "label" => "Maquinas.alto", - "rules" => "required|decimal", + "rules" => "required|decimal|greater_than[0]", ], "alto_click" => [ "label" => "Maquinas.altoClick", - "rules" => "required|decimal", + "rules" => "required|decimal|greater_than[0]", ], "alto_impresion" => [ "label" => "Maquinas.altoImpresion", - "rules" => "required|decimal", + "rules" => "required|decimal|greater_than[0]", ], "ancho" => [ "label" => "Maquinas.ancho", - "rules" => "required|decimal", + "rules" => "required|decimal|greater_than[0]", ], "ancho_impresion" => [ "label" => "Maquinas.anchoImpresion", - "rules" => "required|decimal", + "rules" => "required|decimal|greater_than[0]", ], "duracion_jornada" => [ "label" => "Maquinas.duracionJornada", diff --git a/ci4/app/Models/Configuracion/MaquinasDefectoModel.php b/ci4/app/Models/Configuracion/MaquinasDefectoModel.php index f17287dd..bb9ab7b8 100644 --- a/ci4/app/Models/Configuracion/MaquinasDefectoModel.php +++ b/ci4/app/Models/Configuracion/MaquinasDefectoModel.php @@ -183,6 +183,8 @@ class MaquinasDefectoModel extends \App\Models\GoBaseModel public function checkIntervals($data = [], $id = null){ + helper('general'); + if(floatval($data["ancho_min"])>= floatval($data["ancho_max"])){ return lang('MaquinasPorDefecto.validation.error_ancho_range'); } @@ -209,17 +211,17 @@ class MaquinasDefectoModel extends \App\Models\GoBaseModel continue; } } - if($this->check_overlap(floatval($data["ancho_min"]), floatval($data["ancho_max"]), + if(check_overlap(floatval($data["ancho_min"]), floatval($data["ancho_max"]), $row->ancho_min, $row->ancho_max)){ return lang('MaquinasPorDefecto.validation.error_ancho_overlap'); } - if($this->check_overlap(floatval($data["alto_min"]), floatval($data["alto_max"]), + if(check_overlap(floatval($data["alto_min"]), floatval($data["alto_max"]), $row->alto_min, $row->alto_max)){ return lang('MaquinasPorDefecto.validation.error_alto_overlap'); } - if($this->check_overlap(floatval($data["tirada_min"]), floatval($data["tirada_max"]), + if(check_overlap(floatval($data["tirada_min"]), floatval($data["tirada_max"]), $row->tirada_min, $row->tirada_max)){ - return lang('MaquinasPorDefecto.validation.error_ancho_overlap'); + return lang('MaquinasPorDefecto.validation.error_tirada_overlap'); } } @@ -227,15 +229,6 @@ class MaquinasDefectoModel extends \App\Models\GoBaseModel return ""; } - - // Devuelve true si los intervalos (a1,a2) (b1,b2) se solapan - // https://stackoverflow.com/questions/3269434/whats-the-most-efficient-way-to-test-if-two-ranges-overlap - private function check_overlap($a1, $a2, $b1, $b2){ - - if (max($a2, $b2) - min($a1, $b1) < ($a2 - $a1) + ($b2 - $b1)) - return true; - return false; - } } diff --git a/ci4/app/Models/Tarifas/TarifaAcabadoLineaModel.php b/ci4/app/Models/Tarifas/TarifaAcabadoLineaModel.php index 4e1d8ade..48130463 100644 --- a/ci4/app/Models/Tarifas/TarifaAcabadoLineaModel.php +++ b/ci4/app/Models/Tarifas/TarifaAcabadoLineaModel.php @@ -13,19 +13,19 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel protected $useAutoIncrement = true; const SORTABLE = [ - 0 => "t1.tirada_min", - 1 => "t1.tirada_max", + 0 => "t1.paginas_min", + 1 => "t1.paginas_max", 2 => "t1.precio_min", 3 => "t1.precio_max", - 4 => "t1.precio_unidad", + 4 => "t1.margen", ]; protected $allowedFields = [ - "tirada_min", - "tirada_max", + "paginas_min", + "paginas_max", "precio_min", "precio_max", - "precio_unidad", + "margen", "user_created_id", "is_deleted", ]; @@ -53,15 +53,11 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel "label" => "TarifaAcabadoLineas.precioMin", "rules" => "required|decimal", ], - "precio_unidad" => [ - "label" => "TarifaAcabadoLineas.precioUnidad", - "rules" => "required|decimal", - ], - "tirada_max" => [ + "paginas_max" => [ "label" => "TarifaAcabadoLineas.tiradaMax", "rules" => "required|integer", ], - "tirada_min" => [ + "paginas_min" => [ "label" => "TarifaAcabadoLineas.tiradaMin", "rules" => "required|integer", ], @@ -84,17 +80,17 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel "decimal" => "TarifaAcabadoLineas.validation.precio_min.decimal", "required" => "TarifaAcabadoLineas.validation.precio_min.required", ], - "precio_unidad" => [ - "decimal" => "TarifaAcabadoLineas.validation.precio_unidad.decimal", - "required" => "TarifaAcabadoLineas.validation.precio_unidad.required", + "paginas_max" => [ + "integer" => "TarifaAcabadoLineas.validation.paginas_max.integer", + "required" => "TarifaAcabadoLineas.validation.paginas_max.required", ], - "tirada_max" => [ - "integer" => "TarifaAcabadoLineas.validation.tirada_max.integer", - "required" => "TarifaAcabadoLineas.validation.tirada_max.required", + "paginas_min" => [ + "integer" => "TarifaAcabadoLineas.validation.paginas_min.integer", + "required" => "TarifaAcabadoLineas.validation.paginas_min.required", ], - "tirada_min" => [ - "integer" => "TarifaAcabadoLineas.validation.tirada_min.integer", - "required" => "TarifaAcabadoLineas.validation.tirada_min.required", + "margen" => [ + "integer" => "TarifaAcabadoLineas.validation.margen.integer", + "required" => "TarifaAcabadoLineas.validation.margen.required", ], "user_created_id" => [ "integer" => "TarifaAcabadoLineas.validation.user_created_id.integer", @@ -135,7 +131,7 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS id, t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.precio_unidad AS precio_unidad, t1.user_created_id AS user_created_id, t1.user_updated_id AS user_updated_id, t1.is_deleted AS is_deleted, t1.created_at AS created_at, t1.updated_at AS updated_at, t2.id AS tarifa_acabado" + "t1.id AS id, t1.paginas_min AS paginas_min, t1.paginas_max AS paginas_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.margen AS margen, t2.id AS tarifa_acabado" ); //JJO @@ -149,28 +145,14 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel ? $builder : $builder ->groupStart() - ->like("t1.tirada_min", $search) - ->orLike("t1.tirada_max", $search) + ->like("t1.paginas_min", $search) + ->orLike("t1.paginas_max", $search) ->orLike("t1.precio_min", $search) ->orLike("t1.precio_max", $search) - ->orLike("t1.precio_unidad", $search) - ->orLike("t1.user_created_id", $search) - ->orLike("t1.user_updated_id", $search) - ->orLike("t1.is_deleted", $search) - ->orLike("t1.created_at", $search) - ->orLike("t1.updated_at", $search) - ->orLike("t2.id", $search) - ->orLike("t1.tirada_min", $search) - ->orLike("t1.tirada_max", $search) + ->orLike("t1.paginas_min", $search) + ->orLike("t1.paginas_max", $search) ->orLike("t1.precio_min", $search) ->orLike("t1.precio_max", $search) - ->orLike("t1.precio_unidad", $search) - ->orLike("t1.user_created_id", $search) - ->orLike("t1.user_updated_id", $search) - ->orLike("t1.is_deleted", $search) - ->orLike("t1.created_at", $search) - ->orLike("t1.updated_at", $search) - ->orLike("t2.id", $search) ->groupEnd(); } @@ -185,4 +167,35 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel return $builder; } + + public function checkIntervals($data = [], $id_linea = null, $id_tarifa_acabado = null){ + + helper('general'); + + if(floatval($data["paginas_min"])>= floatval($data["paginas_max"])){ + return lang('TarifaAcabadoLineas.validation.error_paginas_range'); + } + + $rows = $this->db + ->table($this->table) + ->select("id, paginas_min, paginas_max") + ->where("is_deleted", 0) + ->where("tarifa_acabado_id", $id_tarifa_acabado) + ->get()->getResultObject(); + + + foreach ($rows as $row) { + if (!is_null($id_linea)){ + if($row->id == $id_linea){ + continue; + } + } + if(check_overlap(floatval($data["paginas_min"]), floatval($data["paginas_max"]), + $row->paginas_min, $row->paginas_max)){ + return lang('TarifaAcabadoLineas.validation.error_paginas_overlap'); + } + } + + return ""; + } } diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php new file mode 100644 index 00000000..aa5b9519 --- /dev/null +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php @@ -0,0 +1,159 @@ + "t1.paginas_min", + 1 => "t1.paginas_max", + 2 => "t1.precio_min", + 3 => "t1.precio_max", + ]; + + protected $allowedFields = [ + "tarifa_encuadernacion_id", + "paginas_min", + "paginas_max", + "precio_min", + "precio_max", + "user_created_id", + "is_deleted", + + ]; + protected $returnType = "App\Entities\Tarifas\TarifaManipuladoLinea"; + + protected $useTimestamps = true; + protected $useSoftDeletes = false; + + protected $createdField = "created_at"; + + protected $updatedField = "updated_at"; + + public static $labelField = "tarifa_encuadernacion_id"; + + protected $validationRules = [ + "precio_max" => [ + "label" => "TarifaManipuladoLineas.precioMax", + "rules" => "required|decimal", + ], + "precio_min" => [ + "label" => "TarifaManipuladoLineas.precioMin", + "rules" => "required|decimal", + ], + "paginas_max" => [ + "label" => "TarifaManipuladoLineas.paginasMax", + "rules" => "required|decimal", + ], + "paginas_min" => [ + "label" => "TarifaManipuladoLineas.paginasMin", + "rules" => "required|decimal", + ], + "margen" => [ + "label" => "TarifaManipuladoLineas.margen", + "rules" => "required|decimal", + ], + ]; + + protected $validationMessages = [ + "precio_max" => [ + "decimal" => "TarifaManipuladoLineas.validation.precio_max.decimal", + "required" => "TarifaManipuladoLineas.validation.precio_max.required", + ], + "precio_min" => [ + "decimal" => "TarifaManipuladoLineas.validation.precio_min.decimal", + "required" => "TarifaManipuladoLineas.validation.precio_min.required", + ], + "paginas_max" => [ + "decimal" => "TarifaManipuladoLineas.validation.paginas_max.decimal", + "required" => "TarifaManipuladoLineas.validation.paginas_max.required", + ], + "paginas_min" => [ + "decimal" => "TarifaManipuladoLineas.validation.paginas_min.decimal", + "required" => "TarifaManipuladoLineas.validation.paginas_min.required", + ], + "margen" => [ + "decimal" => "TarifaManipuladoLineas.validation.margen.decimal", + "required" => "TarifaManipuladoLineas.validation.margen.required", + ], + ]; + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "", $tarifa_encuadernacion_id = -1) + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS id, t1.tarifa_encuadernacion_id AS tarifa_encuadernacion_id, t1.paginas_min AS paginas_min, t1.paginas_max AS paginas_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.margen AS margen, t2.id AS tarifa_encuadernacion" + ); + //JJO + $builder->where('tarifa_encuadernacion_id', $tarifa_encuadernacion_id); + $builder->where("t1.is_deleted", 0); + + $builder->join("tarifa_encuadernacion t2", "t1.tarifa_encuadernacion_id = t2.id", "left"); + + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.tarifa_encuadernacion_id", $search) + ->orLike("t1.paginas_min", $search) + ->orLike("t1.paginas_max", $search) + ->orLike("t1.precio_min", $search) + ->orLike("t1.precio_max", $search) + ->orLike("t1.id", $search) + ->orLike("t1.tarifa_encuadernacion_id", $search) + ->orLike("t1.paginas_min", $search) + ->orLike("t1.paginas_max", $search) + ->orLike("t1.precio_min", $search) + ->orLike("t1.precio_max", $search) + ->groupEnd(); + } + + public function checkIntervals($data = [], $id_linea = null, $id_tarifa_encuadernacion = null){ + + helper('general'); + + if(floatval($data["paginas_min"])>= floatval($data["paginas_max"])){ + return lang('TarifaManipuladoLineas.validation.error_paginas_range'); + } + + $rows = $this->db + ->table($this->table) + ->select("id, paginas_min, paginas_max") + ->where("is_deleted", 0) + ->where("tarifa_encuadernacion_id", $id_tarifa_encuadernacion) + ->get()->getResultObject(); + + + foreach ($rows as $row) { + if (!is_null($id_linea)){ + if($row->id == $id_linea){ + continue; + } + } + if(check_overlap(floatval($data["paginas_min"]), floatval($data["paginas_max"]), + $row->paginas_min, $row->paginas_max)){ + return lang('TarifaManipuladoLineas.validation.error_paginas_overlap'); + } + } + + return ""; + } +} diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php new file mode 100644 index 00000000..69d5a181 --- /dev/null +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php @@ -0,0 +1,91 @@ + "t1.nombre", + ]; + + protected $allowedFields = [ + "nombre", + "precio_min", + "importe_fijo", + "deleted_at", + "is_deleted", + "user_created_id", + "user_updated_id" + ]; + protected $returnType = "App\Entities\Tarifas\TarifaEncuadernacionEntity"; + + protected $useTimestamps = true; + protected $useSoftDeletes = false; + + protected $createdField = "created_at"; + + protected $updatedField = "updated_at"; + + public static $labelField = "nombre"; + + protected $validationRules = [ + "nombre" => [ + "label" => "Tarifaencuadernacion.nombre", + "rules" => "trim|required|max_length[255]", + ], + + "precio_min" => [ + "label" => "Tarifaencuadernacion.precioMin", + "rules" => "required|decimal", + ], + "importe_fijo" => [ + "label" => "Tarifaencuadernacion.importeFijo", + "rules" => "required|decimal", + ], + ]; + + protected $validationMessages = [ + "nombre" => [ + "max_length" => "Tarifaencuadernacion.validation.nombre.max_length", + "required" => "Tarifaencuadernacion.validation.nombre.required", + ], + "precio_min" => [ + "required" => "Tarifaencuadernacion.validation.precio_min.required", + "decimal" => "Tarifaencuadernacion.validation.precio_min.decimal", + ], + "importe_fijo" => [ + "required" => "Tarifaencuadernacion.validation.importe_fijo.required", + "decimal" => "Tarifaencuadernacion.validation.importe_fijo.decimal", + ], + ]; + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "") + { + $builder = $this->db->table($this->table . " t1")->select("t1.id AS id, t1.nombre AS nombre, t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo"); + + //JJO + $builder->where("t1.is_deleted", 0); + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t1.nombre", $search) + ->groupEnd(); + } +} diff --git a/ci4/app/Models/Tarifas/TarifaManipuladoLineaModel.php b/ci4/app/Models/Tarifas/TarifaManipuladoLineaModel.php index 56ae1d14..77fbcc6f 100644 --- a/ci4/app/Models/Tarifas/TarifaManipuladoLineaModel.php +++ b/ci4/app/Models/Tarifas/TarifaManipuladoLineaModel.php @@ -13,20 +13,18 @@ class TarifaManipuladoLineaModel extends \App\Models\GoBaseModel protected $useAutoIncrement = true; const SORTABLE = [ - 0 => "t1.tirada_min", - 1 => "t1.tirada_max", + 0 => "t1.paginas_min", + 1 => "t1.paginas_max", 2 => "t1.precio_min", 3 => "t1.precio_max", - 4 => "t1.precio_unidad", ]; protected $allowedFields = [ "tarifa_manipulado_id", - "tirada_min", - "tirada_max", + "paginas_min", + "paginas_max", "precio_min", "precio_max", - "precio_unidad", "user_created_id", "is_deleted", @@ -51,16 +49,16 @@ class TarifaManipuladoLineaModel extends \App\Models\GoBaseModel "label" => "TarifaManipuladoLineas.precioMin", "rules" => "required|decimal", ], - "precio_unidad" => [ - "label" => "TarifaManipuladoLineas.precioUnidad", + "paginas_max" => [ + "label" => "TarifaManipuladoLineas.paginasMax", "rules" => "required|decimal", ], - "tirada_max" => [ - "label" => "TarifaManipuladoLineas.tiradaMax", + "paginas_min" => [ + "label" => "TarifaManipuladoLineas.paginasMin", "rules" => "required|decimal", ], - "tirada_min" => [ - "label" => "TarifaManipuladoLineas.tiradaMin", + "margen" => [ + "label" => "TarifaManipuladoLineas.margen", "rules" => "required|decimal", ], ]; @@ -74,17 +72,17 @@ class TarifaManipuladoLineaModel extends \App\Models\GoBaseModel "decimal" => "TarifaManipuladoLineas.validation.precio_min.decimal", "required" => "TarifaManipuladoLineas.validation.precio_min.required", ], - "precio_unidad" => [ - "decimal" => "TarifaManipuladoLineas.validation.precio_unidad.decimal", - "required" => "TarifaManipuladoLineas.validation.precio_unidad.required", + "paginas_max" => [ + "decimal" => "TarifaManipuladoLineas.validation.paginas_max.decimal", + "required" => "TarifaManipuladoLineas.validation.paginas_max.required", ], - "tirada_max" => [ - "decimal" => "TarifaManipuladoLineas.validation.tirada_max.decimal", - "required" => "TarifaManipuladoLineas.validation.tirada_max.required", + "paginas_min" => [ + "decimal" => "TarifaManipuladoLineas.validation.paginas_min.decimal", + "required" => "TarifaManipuladoLineas.validation.paginas_min.required", ], - "tirada_min" => [ - "decimal" => "TarifaManipuladoLineas.validation.tirada_min.decimal", - "required" => "TarifaManipuladoLineas.validation.tirada_min.required", + "margen" => [ + "decimal" => "TarifaManipuladoLineas.validation.margen.decimal", + "required" => "TarifaManipuladoLineas.validation.margen.required", ], ]; @@ -100,7 +98,7 @@ class TarifaManipuladoLineaModel extends \App\Models\GoBaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS id, t1.tarifa_manipulado_id AS tarifa_manipulado_id, t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.precio_unidad AS precio_unidad, t2.id AS tarifa_manipulado" + "t1.id AS id, t1.tarifa_manipulado_id AS tarifa_manipulado_id, t1.paginas_min AS paginas_min, t1.paginas_max AS paginas_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.margen AS margen, t2.id AS tarifa_manipulado" ); //JJO $builder->where('tarifa_manipulado_id', $tarifa_manipulado_id); @@ -115,18 +113,47 @@ class TarifaManipuladoLineaModel extends \App\Models\GoBaseModel ->groupStart() ->like("t1.id", $search) ->orLike("t1.tarifa_manipulado_id", $search) - ->orLike("t1.tirada_min", $search) - ->orLike("t1.tirada_max", $search) + ->orLike("t1.paginas_min", $search) + ->orLike("t1.paginas_max", $search) ->orLike("t1.precio_min", $search) ->orLike("t1.precio_max", $search) - ->orLike("t1.precio_unidad", $search) ->orLike("t1.id", $search) ->orLike("t1.tarifa_manipulado_id", $search) - ->orLike("t1.tirada_min", $search) - ->orLike("t1.tirada_max", $search) + ->orLike("t1.paginas_min", $search) + ->orLike("t1.paginas_max", $search) ->orLike("t1.precio_min", $search) ->orLike("t1.precio_max", $search) - ->orLike("t1.precio_unidad", $search) ->groupEnd(); } + + public function checkIntervals($data = [], $id_linea = null, $id_tarifa_manipulado = null){ + + helper('general'); + + if(floatval($data["paginas_min"])>= floatval($data["paginas_max"])){ + return lang('TarifaManipuladoLineas.validation.error_paginas_range'); + } + + $rows = $this->db + ->table($this->table) + ->select("id, paginas_min, paginas_max") + ->where("is_deleted", 0) + ->where("tarifa_manipulado_id", $id_tarifa_manipulado) + ->get()->getResultObject(); + + + foreach ($rows as $row) { + if (!is_null($id_linea)){ + if($row->id == $id_linea){ + continue; + } + } + if(check_overlap(floatval($data["paginas_min"]), floatval($data["paginas_max"]), + $row->paginas_min, $row->paginas_max)){ + return lang('TarifaManipuladoLineas.validation.error_paginas_overlap'); + } + } + + return ""; + } } diff --git a/ci4/app/Models/Tarifas/TarifaManipuladoModel.php b/ci4/app/Models/Tarifas/TarifaManipuladoModel.php index 6b6676df..f7accda2 100644 --- a/ci4/app/Models/Tarifas/TarifaManipuladoModel.php +++ b/ci4/app/Models/Tarifas/TarifaManipuladoModel.php @@ -76,7 +76,7 @@ class TarifaManipuladoModel extends \App\Models\GoBaseModel */ public function getResource(string $search = "") { - $builder = $this->db->table($this->table . " t1")->select("t1.id AS id, t1.nombre AS nombre"); + $builder = $this->db->table($this->table . " t1")->select("t1.id AS id, t1.nombre AS nombre, t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo"); //JJO $builder->where("t1.is_deleted", 0); diff --git a/ci4/app/Models/Tarifas/TarifaacabadoModel.php b/ci4/app/Models/Tarifas/TarifaacabadoModel.php index 245e3e44..958ad690 100644 --- a/ci4/app/Models/Tarifas/TarifaacabadoModel.php +++ b/ci4/app/Models/Tarifas/TarifaacabadoModel.php @@ -14,6 +14,8 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel const SORTABLE = [ 0 => "t1.nombre", + 1 => "precio_min", + 2 => "importe_fijo", ]; protected $allowedFields = [ @@ -77,7 +79,7 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel public function getResource(string $search = "") { $builder = $this->db->table($this->table . " t1")->select( - "t1.id AS id, t1.nombre AS nombre" + "t1.id AS id, t1.nombre AS nombre, t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo" ); //JJO diff --git a/ci4/app/Models/Tarifas/TarifapreimpresionModel.php b/ci4/app/Models/Tarifas/TarifapreimpresionModel.php index cf70b72e..e56da859 100644 --- a/ci4/app/Models/Tarifas/TarifapreimpresionModel.php +++ b/ci4/app/Models/Tarifas/TarifapreimpresionModel.php @@ -14,9 +14,10 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel protected $allowedFields = [ "nombre", - "precio", + "precio_pagina", "precio_min", "importe_fijo", + "margen", "deleted_at", "is_deleted", "user_created_id", @@ -49,6 +50,10 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel "label" => "Tarifapreimpresion.importeFijo", "rules" => "required|decimal", ], + "margen" => [ + "label" => "Tarifapreimpresion.margen", + "rules" => "required|decimal", + ], ]; protected $validationMessages = [ @@ -68,5 +73,9 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel "required" => "Tarifapreimpresion.validation.importe_fijo.required", "decimal" => "Tarifapreimpresion.validation.importe_fijo.decimal", ], + "margen" => [ + "required" => "Tarifapreimpresion.validation.margen.required", + "decimal" => "Tarifapreimpresion.validation.margen.decimal", + ], ]; } diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php index 860a7f2c..9d051314 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php @@ -69,7 +69,7 @@
| = lang('TarifaAcabadoLineas.tiradaMin') ?> | -= lang('TarifaAcabadoLineas.tiradaMax') ?> | -= lang('TarifaAcabadoLineas.precioMin') ?> | += lang('TarifaAcabadoLineas.paginasMin') ?> | = lang('TarifaAcabadoLineas.precioMax') ?> | -= lang('TarifaAcabadoLineas.precioUnidad') ?> | += lang('TarifaAcabadoLineas.paginasMax') ?> | += lang('TarifaAcabadoLineas.precioMin') ?> | += lang('TarifaAcabadoLineas.margen') ?> | |
|---|---|---|---|---|---|---|---|---|---|
| = lang('Tarifaacabado.nombre') ?> | += lang('Tarifaacabado.precioMin') ?> | += lang('Tarifaacabado.importeFijo') ?> | = lang('Basic.global.Action') ?> |
| = lang('TarifaEncuadernacionLineas.paginasMin') ?> | += lang('TarifaEncuadernacionLineas.precioMax') ?> | += lang('TarifaEncuadernacionLineas.paginasMax') ?> | += lang('TarifaEncuadernacionLineas.precioMin') ?> | += lang('TarifaEncuadernacionLineas.margen') ?> | ++ |
|---|
| = lang('Tarifaencuadernacion.nombre') ?> | += lang('Tarifaencuadernacion.precioMin') ?> | += lang('Tarifaencuadernacion.importeFijo') ?> | += lang('Basic.global.Action') ?> | +
|---|
| = lang('TarifaManipuladoLineas.tiradaMin') ?> | -= lang('TarifaManipuladoLineas.tiradaMax') ?> | -= lang('TarifaManipuladoLineas.precioMin') ?> | += lang('TarifaManipuladoLineas.paginasMin') ?> | = lang('TarifaManipuladoLineas.precioMax') ?> | -= lang('TarifaManipuladoLineas.precioUnidad') ?> | += lang('TarifaManipuladoLineas.paginasMax') ?> | += lang('TarifaManipuladoLineas.precioMin') ?> | += lang('TarifaManipuladoLineas.margen') ?> | |
|---|---|---|---|---|---|---|---|---|---|
| = lang('Tarifamanipulado.nombre') ?> | += lang('Tarifamanipulado.precioMin') ?> | += lang('Tarifamanipulado.importeFijo') ?> | = lang('Basic.global.Action') ?> | ||||||
| = lang('Tarifapreimpresion.nombre') ?> | = lang('Tarifapreimpresion.precio') ?> | += lang('Tarifapreimpresion.precioMin') ?> | += lang('Tarifapreimpresion.importeFijo') ?> | += lang('Tarifapreimpresion.margen') ?> | = lang('Basic.global.Action') ?> | ||||
| = empty($item->nombre) || strlen($item->nombre) < 51 ? esc($item->nombre) : character_limiter(esc($item->nombre), 50) ?> | - = esc($item->precio) ?> - | - - = esc($item->user_created_id) ?> + = esc($item->precio_pagina) ?>- = esc($item->user_updated_id) ?> + = esc($item->precio_min) ?> | -- = empty($item->created_at) ? '' : date('d/m/Y H:m:s', strtotime($item->created_at)) ?> + | + = esc($item->importe_fijo) ?> | -- = empty($item->updated_at) ? '' : date('d/m/Y H:m:s', strtotime($item->updated_at)) ?> + | + = esc($item->margen) ?> | - */ ?>
=anchor(route_to('editTarifapreimpresion', $item->id), "", ['class'=>'text-body', 'data-id'=>$item->id,]); ?>
=anchor('#confirm2delete', "", ['class'=>'text-body', 'data-href'=>route_to('deleteTarifapreimpresion', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
diff --git a/ci4/app/Views/themes/backend/vuexy/main/activities_layout.php b/ci4/app/Views/themes/backend/vuexy/main/activities_layout.php
index bd2a4e67..fb37147c 100644
--- a/ci4/app/Views/themes/backend/vuexy/main/activities_layout.php
+++ b/ci4/app/Views/themes/backend/vuexy/main/activities_layout.php
@@ -230,7 +230,7 @@ if (!empty($token) && $tfa == false) {
- = $session->get('first_name') . ' ' . $session->get('first_name') ?>
+ = $session->get('first_name') . ' ' . $session->get('last_name') ?>
Admin
diff --git a/ci4/app/Views/themes/backend/vuexy/main/all.php b/ci4/app/Views/themes/backend/vuexy/main/all.php
index fc100a31..c7127724 100644
--- a/ci4/app/Views/themes/backend/vuexy/main/all.php
+++ b/ci4/app/Views/themes/backend/vuexy/main/all.php
@@ -463,7 +463,7 @@ if (!empty($token) && $tfa == false) {
- = $session->get('first_name') . ' ' . $session->get('first_name') ?>
+ = $session->get('first_name') . ' ' . $session->get('last_name') ?>
Admin
diff --git a/ci4/app/Views/themes/backend/vuexy/main/defaultlayout.php b/ci4/app/Views/themes/backend/vuexy/main/defaultlayout.php
index 991f9015..8f4932fc 100644
--- a/ci4/app/Views/themes/backend/vuexy/main/defaultlayout.php
+++ b/ci4/app/Views/themes/backend/vuexy/main/defaultlayout.php
@@ -233,7 +233,7 @@ if (!empty($token) && $tfa == false) {
- = $session->get('first_name') . ' ' . $session->get('first_name') ?>
+ = $session->get('first_name') . ' ' . $session->get('last_name') ?>
Admin
diff --git a/ci4/app/Views/themes/backend/vuexy/main/demo_view.php b/ci4/app/Views/themes/backend/vuexy/main/demo_view.php
index 496f4006..5c96ceb5 100644
--- a/ci4/app/Views/themes/backend/vuexy/main/demo_view.php
+++ b/ci4/app/Views/themes/backend/vuexy/main/demo_view.php
@@ -178,7 +178,7 @@ if (!empty($token) && $tfa == false) {
- = $session->get('first_name') . ' ' . $session->get('first_name') ?>
+ = $session->get('first_name') . ' ' . $session->get('last_name') ?>
Admin
diff --git a/ci4/app/Views/themes/backend/vuexy/main/general_settings_layout.php b/ci4/app/Views/themes/backend/vuexy/main/general_settings_layout.php
index 1da9e545..67d418c0 100644
--- a/ci4/app/Views/themes/backend/vuexy/main/general_settings_layout.php
+++ b/ci4/app/Views/themes/backend/vuexy/main/general_settings_layout.php
@@ -233,7 +233,7 @@ if (!empty($token) && $tfa == false) {
- = $session->get('first_name') . ' ' . $session->get('first_name') ?>
+ = $session->get('first_name') . ' ' . $session->get('last_name') ?>
Admin
diff --git a/ci4/app/Views/themes/backend/vuexy/main/menu.php b/ci4/app/Views/themes/backend/vuexy/main/menu.php
index f432f2da..5d9bd0d0 100644
--- a/ci4/app/Views/themes/backend/vuexy/main/menu.php
+++ b/ci4/app/Views/themes/backend/vuexy/main/menu.php
@@ -403,7 +403,7 @@
* MENU TARIFAS
*/
if (allowMenuSection($menus,
- ['Tarifaacabado', 'Tarifaenvio', 'Tarifaimpresion', 'Tarifamanipulado',
+ ['Tarifaacabado', 'Tarifaenvio', 'Tarifaimpresion', 'Tarifamanipulado', 'Tarifaencuadernacion',
'Tarifapapelcompra', 'Tarifapapeldefecto', 'Tarifapreimpresion'
], 'index')): ?>
@@ -449,6 +449,15 @@
+ 0): ?>
+ 0): ?>
+ ">= lang("App.menu_tarifaencuadernacion") ?>
+
+ ">= lang("App.menu_encuadernacion") ?>
+
+
- = $session->get('first_name') . ' ' . $session->get('first_name') ?>
+ = $session->get('first_name') . ' ' . $session->get('last_name') ?>
Admin
|