diff --git a/ci4/.env b/ci4/.env
index a514e191..bf6320e4 100644
--- a/ci4/.env
+++ b/ci4/.env
@@ -41,22 +41,22 @@ app.baseURL = 'https://sk-imn.imnavajas.es'
# DATABASE
#--------------------------------------------------------------------
-# database.default.hostname = localhost
-# database.default.database = sk_jjo
-# database.default.username = sk_jjo
-# database.default.password = 61tv&G1Zf^XY
-# database.default.DBDriver = MySQLi
-# database.default.DBPrefix =
-# database.default.dump =
-
database.default.hostname = localhost
-database.default.database = sk_imn
-database.default.username = sk_imn
-database.default.password = Uyia19_87
+database.default.database = sk_jjo
+database.default.username = sk_jjo
+database.default.password = 61tv&G1Zf^XY
database.default.DBDriver = MySQLi
database.default.DBPrefix =
database.default.dump =
+# database.default.hostname = localhost
+# database.default.database = sk_imn
+# database.default.username = sk_imn
+# database.default.password = Uyia19_87
+# database.default.DBDriver = MySQLi
+# database.default.DBPrefix =
+# database.default.dump =
+
# database.tests.hostname = localhost
# database.tests.database = ci4
# database.tests.username = root
diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php
index 99af8b54..cf5efcbf 100644
--- a/ci4/app/Config/Routes.php
+++ b/ci4/app/Config/Routes.php
@@ -115,18 +115,34 @@ $routes->group('tarifapreimpresion', ['namespace' => 'App\Controllers\Tarifas'],
});
-$routes->group('tarifamanipulado', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
- $routes->get('', 'Tarifamanipulado::index', ['as' => 'tarifamanipuladoList']);
- $routes->get('index', 'Tarifamanipulado::index', ['as' => 'tarifamanipuladoIndex']);
- $routes->get('list', 'Tarifamanipulado::index', ['as' => 'tarifamanipuladoList2']);
- $routes->get('add', 'Tarifamanipulado::add', ['as' => 'newTarifamanipulado']);
- $routes->post('add', 'Tarifamanipulado::add', ['as' => 'createTarifamanipulado']);
- $routes->get('edit/(:num)', 'Tarifamanipulado::edit/$1', ['as' => 'editTarifamanipulado']);
- $routes->post('edit/(:num)', 'Tarifamanipulado::edit/$1', ['as' => 'updateTarifamanipulado']);
- $routes->get('delete/(:num)', 'Tarifamanipulado::delete/$1', ['as' => 'deleteTarifamanipulado']);
- $routes->post('allmenuitems', 'Tarifamanipulado::allItemsSelect', ['as' => 'select2ItemsOfTarifasmanipulado']);
- $routes->post('menuitems', 'Tarifamanipulado::menuItems', ['as' => 'menuItemsOfTarifasmanipulado']);
+$routes->group('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
+ $routes->get('', 'Tarifasmanipulado::index', ['as' => 'tarifaManipuladoList']);
+ $routes->get('add', 'Tarifasmanipulado::add', ['as' => 'newTarifaManipulado']);
+ $routes->post('add', 'Tarifasmanipulado::add', ['as' => 'createTarifaManipulado']);
+ $routes->post('create', 'Tarifasmanipulado::create', ['as' => 'ajaxCreateTarifaManipulado']);
+ $routes->put('(:num)/update', 'Tarifasmanipulado::update/$1', ['as' => 'ajaxUpdateTarifaManipulado']);
+ $routes->post('edit/(:num)', 'Tarifasmanipulado::edit/$1', ['as' => 'updateTarifaManipulado']);
+ $routes->get('delete/(:num)', 'Tarifasmanipulado::delete/$1', ['as' => 'deleteTarifaManipulado']);
+ $routes->post('datatable', 'Tarifasmanipulado::datatable', ['as' => 'dataTableOfTarifasManipulado']);
+ $routes->post('allmenuitems', 'Tarifasmanipulado::allItemsSelect', ['as' => 'select2ItemsOfTarifasManipulado']);
+ $routes->post('menuitems', 'Tarifasmanipulado::menuItems', ['as' => 'menuItemsOfTarifasManipulado']);
});
+$routes->resource('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasmanipulado', 'except' => 'show,new,create,update']);
+
+
+$routes->group('tarifamanipuladolineas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
+ $routes->get('', 'Tarifamanipuladolineas::index', ['as' => 'tarifaManipuladoLineaList']);
+ $routes->get('add', 'Tarifamanipuladolineas::add', ['as' => 'newTarifaManipuladoLinea']);
+ $routes->post('add', 'Tarifamanipuladolineas::add', ['as' => 'createTarifaManipuladoLinea']);
+ $routes->post('create', 'Tarifamanipuladolineas::create', ['as' => 'ajaxCreateTarifaManipuladoLinea']);
+ $routes->put('(:num)/update', 'Tarifamanipuladolineas::update/$1', ['as' => 'ajaxUpdateTarifaManipuladoLinea']);
+ $routes->post('(:num)/edit', 'Tarifamanipuladolineas::edit/$1', ['as' => 'updateTarifaManipuladoLinea']);
+ $routes->post('datatable', 'Tarifamanipuladolineas::datatable', ['as' => 'dataTableOfTarifaManipuladoLineas']);
+ $routes->post('datatable_editor', 'Tarifamanipuladolineas::datatable_editor', ['as' => 'editorOfTarifaManipuladoLineas']);
+ $routes->post('allmenuitems', 'Tarifamanipuladolineas::allItemsSelect', ['as' => 'select2ItemsOfTarifaManipuladoLineas']);
+ $routes->post('menuitems', 'Tarifamanipuladolineas::menuItems', ['as' => 'menuItemsOfTarifaManipuladoLineas']);
+});
+$routes->resource('tarifamanipuladolineas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifamanipuladolineas', 'except' => 'show,new,create,update']);
$routes->group('tipologiaslibros', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
diff --git a/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php b/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php
new file mode 100644
index 00000000..5e59be55
--- /dev/null
+++ b/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php
@@ -0,0 +1,401 @@
+viewData['pageTitle'] = lang('TarifaManipuladoLineas.moduleTitle');
+ $this->viewData['usingSweetAlert'] = true;
+ parent::initController($request, $response, $logger);
+ }
+
+
+ public function index() {
+
+ $viewData = [
+ 'currentModule' => static::$controllerSlug,
+ 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifaManipuladoLineas.tarifamanipuladoLinea')]),
+ 'tarifaManipuladoLinea' => new TarifaManipuladoLinea(),
+ 'usingServerSideDataTable' => true,
+
+ ];
+
+ $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
+
+ return view(static::$viewPath.'viewTarifaManipuladoLineaList', $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('TarifaManipuladoLineas.tarifamanipuladoLinea'))]);
+ $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('TarifaManipuladoLineas.tarifamanipuladoLinea'))]).'.';
+ $message .= anchor( "tarifamanipuladolineas/{$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['tarifaManipuladoLinea'] = isset($sanitizedData) ? new TarifaManipuladoLinea($sanitizedData) : new TarifaManipuladoLinea();
+
+ $this->viewData['formAction'] = route_to('createTarifaManipuladoLinea');
+
+ $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('TarifaManipuladoLineas.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);
+ $tarifaManipuladoLinea = $this->model->find($id);
+
+ if ($tarifaManipuladoLinea == false) :
+ $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaManipuladoLineas.tarifamanipuladoLinea')), $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('TarifaManipuladoLineas.tarifamanipuladoLinea'))]);
+ $this->session->setFlashdata('formErrors', $this->model->errors());
+
+ endif;
+
+ $tarifaManipuladoLinea->fill($sanitizedData);
+
+ $thenRedirect = true;
+ endif;
+ if ($noException && $successfulResult) :
+ $id = $tarifaManipuladoLinea->id ?? $id;
+ $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('TarifaManipuladoLineas.tarifamanipuladoLinea'))]).'.';
+ $message .= anchor( "tarifamanipuladolineas/{$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['tarifaManipuladoLinea'] = $tarifaManipuladoLinea;
+
+ $this->viewData['formAction'] = route_to('updateTarifaManipuladoLinea', $id);
+
+ $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('TarifaManipuladoLineas.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_manipulado_lineas' )
+ ->fields(
+ Field::inst( 'tirada_min' )
+ ->validator( 'Validate::numeric', array(
+ 'message' => lang('TarifaAcabadoLineas.validation.tirada_min.decimal') )
+ )
+ ->validator( 'Validate::notEmpty',array(
+ 'message' => lang('TarifaAcabadoLineas.validation.tirada_min.required') )
+ ),
+ Field::inst( 'tirada_max' )
+ ->validator( 'Validate::numeric', array(
+ 'message' => lang('TarifaAcabadoLineas.validation.tirada_max.decimal') )
+ )
+ ->validator( 'Validate::notEmpty',array(
+ 'message' => lang('TarifaAcabadoLineas.validation.tirada_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( 'precio_unidad' )
+ ->validator( 'Validate::numeric', array(
+ 'message' => lang('TarifaAcabadoLineas.validation.precio_unidad.decimal') )
+ )
+ ->validator( 'Validate::notEmpty',array(
+ 'message' => lang('TarifaAcabadoLineas.validation.precio_unidad.required') )
+ ),
+ Field::inst( 'tarifa_manipulado_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)
+ {
+
+ $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');
+ }
+ }
+ }
+ }
+ })
+ ->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();
+
+
+ /*// 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();
+
+ $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 = TarifaManipuladoLineaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
+ $dir = $reqData['order']['0']['dir'] ?? 'asc';
+
+ $id_TM = $reqData['id_tarifamanipulado'] ?? -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)->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_manipulado_id', 'tarifa_manipulado_id', $onlyActiveOnes, false);
+ $nonItem = new \stdClass;
+ $nonItem->id = '';
+ $nonItem->tarifa_manipulado_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_manipulado_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/Tarifamanipulado.php b/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php
similarity index 56%
rename from ci4/app/Controllers/Tarifas/Tarifamanipulado.php
rename to ci4/app/Controllers/Tarifas/Tarifasmanipulado.php
index 46b01ae9..560173de 100644
--- a/ci4/app/Controllers/Tarifas/Tarifamanipulado.php
+++ b/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php
@@ -1,44 +1,62 @@
viewData['pageTitle'] = lang('Tarifamanipulado.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
parent::initController($request, $response, $logger);
-
}
+
public function index() {
- $this->viewData['usingClientSideDataTable'] = true;
-
- $this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifamanipulado.tarifamanipulado')]);
- parent::index();
+ $viewData = [
+ 'currentModule' => static::$controllerSlug,
+ 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tarifamanipulado.tarifamanipulado')]),
+ 'tarifaManipuladoEntity' => new TarifaManipuladoEntity(),
+ 'usingServerSideDataTable' => true,
+
+ ];
+ $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
+
+ return view(static::$viewPath.'viewTarifaManipuladoList', $viewData);
}
+
public function add() {
// JJO
@@ -51,6 +69,7 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost();
+
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
@@ -60,7 +79,7 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
-
+
if ($this->canValidate()) :
try {
@@ -79,49 +98,50 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
if ($noException && $successfulResult) :
$id = $this->model->db->insertID();
-
+
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado'))]).'.';
- $message .= anchor(route_to('editTarifamanipulado', $id), lang('Basic.global.continueEditing').'?');
+ $message .= anchor( "tarifamanipulado/{$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('successMessage', $message);
+ return redirect()->to(site_url('tarifas/tarifasmanipulado/edit/'.$id))->with('sweet-success', $message);
+ //return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
- return $this->redirect2listView('successMessage', $message);
+ return $this->redirect2listView('sweet-success', $message);
endif;
else:
- $this->viewData['successMessage'] = $message;
+ $this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
- $this->viewData['tarifamanipuladoEntity'] = isset($sanitizedData) ? new TarifamanipuladoEntity($sanitizedData) : new TarifamanipuladoEntity();
+ $this->viewData['tarifaManipuladoEntity'] = isset($sanitizedData) ? new TarifaManipuladoEntity($sanitizedData) : new TarifaManipuladoEntity();
- $this->viewData['formAction'] = route_to('createTarifamanipulado');
+ $this->viewData['formAction'] = route_to('createTarifaManipulado');
- $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Tarifamanipulado.tarifamanipulado').' '.lang('Basic.global.addNewSuffix');
+ $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Tarifamanipulado.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);
- $tarifamanipuladoEntity = $this->model->find($id);
+ $tarifaManipuladoEntity = $this->model->find($id);
- if ($tarifamanipuladoEntity == false) :
+ if ($tarifaManipuladoEntity == false) :
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado')), $id]);
- return $this->redirect2listView('errorMessage', $message);
+ return $this->redirect2listView('sweet-error', $message);
endif;
$requestMethod = $this->request->getMethod();
@@ -131,6 +151,7 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost();
+
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
@@ -140,56 +161,80 @@ class Tarifamanipulado 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);
+ } catch (\Exception $e) {
+ $noException = false;
+ $this->dealWithException($e);
+ }
+ else:
+ $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado'))]);
+ $this->session->setFlashdata('formErrors', $this->model->errors());
+
+ endif;
+
+ $tarifaManipuladoEntity->fill($sanitizedData);
- 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('Tarifamanipulado.tarifamanipulado'))]);
- $this->session->setFlashdata('formErrors', $this->model->errors());
-
- endif;
-
- $tarifamanipuladoEntity->fill($sanitizedData);
-
- $thenRedirect = true;
+ $thenRedirect = true;
endif;
if ($noException && $successfulResult) :
- $id = $tarifamanipuladoEntity->id ?? $id;
+ $id = $tarifaManipuladoEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado'))]).'.';
- $message .= anchor(route_to('editTarifamanipulado', $id), lang('Basic.global.continueEditing').'?');
+ $message .= anchor( "tarifamanipulado/{$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('successMessage', $message);
+ if (!empty($this->indexRoute)) :
+ return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
- return $this->redirect2listView('successMessage', $message);
+ return $this->redirect2listView('sweet-success', $message);
endif;
else:
- $this->viewData['successMessage'] = $message;
+ $this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
- $this->viewData['tarifamanipuladoEntity'] = $tarifamanipuladoEntity;
+ $this->viewData['tarifaManipuladoEntity'] = $tarifaManipuladoEntity;
- $this->viewData['formAction'] = route_to('updateTarifamanipulado', $id);
+ $this->viewData['formAction'] = route_to('updateTarifaManipulado', $id);
- $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Tarifamanipulado.tarifamanipulado').' '.lang('Basic.global.edit3');
+ $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Tarifamanipulado.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 = TarifaManipuladoModel::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()) {
@@ -212,7 +257,7 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
return $this->failUnauthorized('Invalid request', 403);
}
}
-
+
public function menuItems() {
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
@@ -238,5 +283,5 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
return $this->failUnauthorized('Invalid request', 403);
}
}
-
+
}
diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php
index c2186d36..aa44a832 100644
--- a/ci4/app/Controllers/Test.php
+++ b/ci4/app/Controllers/Test.php
@@ -15,14 +15,11 @@ class Test extends BaseController
public function index()
{
- $t_model = new TarifaAcabadoLineaModel();
- $count = $t_model->select('*')
- ->where(array( 'tarifa_acabado_id'=> 13,
- 'tirada_min'=> 1,
- 'tirada_max'=> 1,
- 'is_deleted'=> 0))
- ->countAllResults();
- var_dump($count);
+ /*
+ $papel = new Papelesimpresion();
+ var_dump($papel->datatablePG());*/
+ return redirect()->to(site_url('tarifas/tarifaacabado/edit/'. 30))->with('sweet-success', 'OK');
+ //return redirect()->to('https://sk-jjo.imnavajas.es/tarifas/tarifaacabado/edit/30');
}
}
\ No newline at end of file
diff --git a/ci4/app/Entities/Tarifas/TarifaManipuladoLinea.php b/ci4/app/Entities/Tarifas/TarifaManipuladoLinea.php
new file mode 100644
index 00000000..eed0f449
--- /dev/null
+++ b/ci4/app/Entities/Tarifas/TarifaManipuladoLinea.php
@@ -0,0 +1,33 @@
+ null,
+ "tarifa_manipulado_id" => 0,
+ "tirada_min" => 0,
+ "tirada_max" => 0,
+ "precio_min" => 0,
+ "precio_max" => 0,
+ "precio_unidad" => 0,
+ "user_created_id" => 0,
+ "user_updated_id" => 0,
+ "is_deleted" => 0,
+ "created_at" => null,
+ "updated_at" => null,
+ ];
+ protected $casts = [
+ "tarifa_manipulado_id" => "int",
+ "tirada_min" => "float",
+ "tirada_max" => "float",
+ "precio_min" => "float",
+ "precio_max" => "float",
+ "precio_unidad" => "float",
+ "user_created_id" => "int",
+ "user_updated_id" => "int",
+ "is_deleted" => "int",
+ ];
+}
diff --git a/ci4/app/Entities/Tarifas/TarifamanipuladoEntity.php b/ci4/app/Entities/Tarifas/TarifamanipuladoEntity.php
index 22c1969e..3f2476cd 100644
--- a/ci4/app/Entities/Tarifas/TarifamanipuladoEntity.php
+++ b/ci4/app/Entities/Tarifas/TarifamanipuladoEntity.php
@@ -3,33 +3,20 @@ namespace App\Entities\Tarifas;
use CodeIgniter\Entity;
-class TarifamanipuladoEntity extends \CodeIgniter\Entity\Entity
+class TarifaManipuladoEntity extends \CodeIgniter\Entity\Entity
{
protected $attributes = [
"id" => null,
"nombre" => null,
- "tirada_min" => 0,
- "precio_min" => 0,
- "tirada_max" => 0,
- "precio_max" => null,
- "ajuste" => 0,
- "ajuste_total_pedido" => 0,
- "formula_price" => null,
- "user_created_id" => 1,
- "user_update_id" => 1,
- "deleted_at" => null,
+ "user_created_id" => 0,
+ "user_update_id" => 0,
"is_deleted" => 0,
"created_at" => null,
"updated_at" => null,
];
protected $casts = [
- "tirada_min" => "int",
- "precio_min" => "float",
- "tirada_max" => "int",
- "precio_max" => "float",
- "ajuste" => "float",
- "ajuste_total_pedido" => "float",
"user_created_id" => "int",
"user_update_id" => "int",
+ "is_deleted" => "int",
];
}
diff --git a/ci4/app/Filters/LoginAuthFilter.php b/ci4/app/Filters/LoginAuthFilter.php
index cf42fa71..0a30acdb 100644
--- a/ci4/app/Filters/LoginAuthFilter.php
+++ b/ci4/app/Filters/LoginAuthFilter.php
@@ -182,7 +182,6 @@ class LoginAuthFilter implements FilterInterface
'datatable',
'datatable_editor',
'fetch_single_data',
- 'datatableTintas',
'collect',
'cast',
];
diff --git a/ci4/app/Language/en/TarifaManipuladoLineas.php b/ci4/app/Language/en/TarifaManipuladoLineas.php
new file mode 100644
index 00000000..1a214500
--- /dev/null
+++ b/ci4/app/Language/en/TarifaManipuladoLineas.php
@@ -0,0 +1,49 @@
+ 'ID',
+ 'moduleTitle' => 'Handling rates Lines',
+ 'deleteLine' => 'the selected register',
+ 'precioMax' => 'Max Price',
+ 'precioMin' => 'Min Price',
+ 'precioUnidad' => 'Price Unit',
+ 'tiradaMax' => 'Print Max',
+ 'tiradaMin' => 'Print Min',
+ 'validation' => [
+ '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.',
+
+ ],
+
+ 'precio_unidad' => [
+ 'decimal' => 'The {field} field must contain a decimal number.',
+ 'required' => 'The {field} field is required.',
+
+ ],
+
+ 'tirada_max' => [
+ '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.',
+
+ ],
+
+
+ ],
+
+
+];
\ No newline at end of file
diff --git a/ci4/app/Language/es/TarifaManipuladoLineas.php b/ci4/app/Language/es/TarifaManipuladoLineas.php
new file mode 100644
index 00000000..e6751fc4
--- /dev/null
+++ b/ci4/app/Language/es/TarifaManipuladoLineas.php
@@ -0,0 +1,49 @@
+ 'ID',
+ 'moduleTitle' => 'Tarifa Manipulado Lineas',
+ 'deleteLine' => 'el registro seleccionado',
+ 'precioMax' => 'Precio Max',
+ 'precioMin' => 'Precio Min',
+ 'precioUnidad' => 'Precio Unidad',
+ 'tiradaMax' => 'Tirada Max',
+ 'tiradaMin' => 'Tirada Min',
+ 'validation' => [
+ '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.',
+
+ ],
+
+ 'precio_unidad' => [
+ 'decimal' => 'The {field} field must contain a decimal number.',
+ 'required' => 'The {field} field is required.',
+
+ ],
+
+ 'tirada_max' => [
+ '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.',
+
+ ],
+
+
+ ],
+
+
+];
\ No newline at end of file
diff --git a/ci4/app/Language/es/Tarifamanipulado.php b/ci4/app/Language/es/Tarifamanipulado.php
index 7cf0dd37..9b9bc6ec 100644
--- a/ci4/app/Language/es/Tarifamanipulado.php
+++ b/ci4/app/Language/es/Tarifamanipulado.php
@@ -13,7 +13,7 @@ return [
'nombre' => 'Nombre',
'precioMax' => 'Precio Max',
'precioMin' => 'Precio Min',
- 'tarifamanipulado' => 'Tarifas manipulado',
+ 'tarifamanipulado' => 'Tarifa manipulado',
'tarifamanipuladoList' => 'Lista Tarifas manipulado',
'tarifasmanipulado' => 'Tarifas manipulado',
'tiradaMax' => 'Tirada Max',
diff --git a/ci4/app/Models/Tarifas/TarifaManipuladoLineaModel.php b/ci4/app/Models/Tarifas/TarifaManipuladoLineaModel.php
new file mode 100644
index 00000000..56ae1d14
--- /dev/null
+++ b/ci4/app/Models/Tarifas/TarifaManipuladoLineaModel.php
@@ -0,0 +1,132 @@
+ "t1.tirada_min",
+ 1 => "t1.tirada_max",
+ 2 => "t1.precio_min",
+ 3 => "t1.precio_max",
+ 4 => "t1.precio_unidad",
+ ];
+
+ protected $allowedFields = [
+ "tarifa_manipulado_id",
+ "tirada_min",
+ "tirada_max",
+ "precio_min",
+ "precio_max",
+ "precio_unidad",
+ "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_manipulado_id";
+
+ protected $validationRules = [
+ "precio_max" => [
+ "label" => "TarifaManipuladoLineas.precioMax",
+ "rules" => "required|decimal",
+ ],
+ "precio_min" => [
+ "label" => "TarifaManipuladoLineas.precioMin",
+ "rules" => "required|decimal",
+ ],
+ "precio_unidad" => [
+ "label" => "TarifaManipuladoLineas.precioUnidad",
+ "rules" => "required|decimal",
+ ],
+ "tirada_max" => [
+ "label" => "TarifaManipuladoLineas.tiradaMax",
+ "rules" => "required|decimal",
+ ],
+ "tirada_min" => [
+ "label" => "TarifaManipuladoLineas.tiradaMin",
+ "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",
+ ],
+ "precio_unidad" => [
+ "decimal" => "TarifaManipuladoLineas.validation.precio_unidad.decimal",
+ "required" => "TarifaManipuladoLineas.validation.precio_unidad.required",
+ ],
+ "tirada_max" => [
+ "decimal" => "TarifaManipuladoLineas.validation.tirada_max.decimal",
+ "required" => "TarifaManipuladoLineas.validation.tirada_max.required",
+ ],
+ "tirada_min" => [
+ "decimal" => "TarifaManipuladoLineas.validation.tirada_min.decimal",
+ "required" => "TarifaManipuladoLineas.validation.tirada_min.required",
+ ],
+ ];
+
+ /**
+ * Get resource data.
+ *
+ * @param string $search
+ *
+ * @return \CodeIgniter\Database\BaseBuilder
+ */
+ public function getResource(string $search = "", $tarifa_manipulado_id = -1)
+ {
+ $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"
+ );
+ //JJO
+ $builder->where('tarifa_manipulado_id', $tarifa_manipulado_id);
+ $builder->where("t1.is_deleted", 0);
+
+ $builder->join("lg_tarifa_manipulado t2", "t1.tarifa_manipulado_id = t2.id", "left");
+
+
+ return empty($search)
+ ? $builder
+ : $builder
+ ->groupStart()
+ ->like("t1.id", $search)
+ ->orLike("t1.tarifa_manipulado_id", $search)
+ ->orLike("t1.tirada_min", $search)
+ ->orLike("t1.tirada_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.precio_min", $search)
+ ->orLike("t1.precio_max", $search)
+ ->orLike("t1.precio_unidad", $search)
+ ->groupEnd();
+ }
+}
diff --git a/ci4/app/Models/Tarifas/TarifamanipuladoModel.php b/ci4/app/Models/Tarifas/TarifamanipuladoModel.php
index 640325ec..97e95c09 100644
--- a/ci4/app/Models/Tarifas/TarifamanipuladoModel.php
+++ b/ci4/app/Models/Tarifas/TarifamanipuladoModel.php
@@ -1,7 +1,7 @@
"t1.nombre",
+ ];
+
protected $allowedFields = [
"nombre",
- "tirada_min",
- "precio_min",
- "tirada_max",
- "precio_max",
- "ajuste",
- "ajuste_total_pedido",
- "formula_price",
"deleted_at",
"is_deleted",
"user_created_id",
- "user_update_id",
+ "user_update_id"
];
- protected $returnType = "App\Entities\Tarifas\TarifamanipuladoEntity";
+ protected $returnType = "App\Entities\Tarifas\TarifaManipuladoEntity";
protected $useTimestamps = true;
protected $useSoftDeletes = false;
+
protected $createdField = "created_at";
+
protected $updatedField = "updated_at";
- protected $deletedField = 'deleted_at';
public static $labelField = "nombre";
protected $validationRules = [
- "ajuste" => [
- "label" => "Manipuladoes.ajuste",
- "rules" => "required|decimal",
- ],
- "ajuste_total_pedido" => [
- "label" => "Manipuladoes.ajusteTotalPedido",
- "rules" => "required|decimal",
- ],
- "formula_price" => [
- "label" => "Manipuladoes.formulaPrice",
- "rules" => "trim|required|max_length[1073241]",
- ],
"nombre" => [
- "label" => "Manipuladoes.nombre",
+ "label" => "Tarifamanipulado.nombre",
"rules" => "trim|required|max_length[255]",
],
- "precio_max" => [
- "label" => "Manipuladoes.precioMax",
- "rules" => "required|decimal",
- ],
- "precio_min" => [
- "label" => "Manipuladoes.precioMin",
- "rules" => "required|decimal",
- ],
- "tirada_max" => [
- "label" => "Manipuladoes.tiradaMax",
- "rules" => "required|integer",
- ],
- "tirada_min" => [
- "label" => "Manipuladoes.tiradaMin",
- "rules" => "required|integer",
- ],
];
protected $validationMessages = [
- "ajuste" => [
- "decimal" => "Manipuladoes.validation.ajuste.decimal",
- "required" => "Manipuladoes.validation.ajuste.required",
- ],
- "ajuste_total_pedido" => [
- "decimal" => "Manipuladoes.validation.ajuste_total_pedido.decimal",
- "required" => "Manipuladoes.validation.ajuste_total_pedido.required",
- ],
- "formula_price" => [
- "max_length" => "Manipuladoes.validation.formula_price.max_length",
- "required" => "Manipuladoes.validation.formula_price.required",
- ],
"nombre" => [
- "max_length" => "Manipuladoes.validation.nombre.max_length",
- "required" => "Manipuladoes.validation.nombre.required",
+ "max_length" => "Tarifamanipulado.validation.nombre.max_length",
+ "required" => "Tarifamanipulado.validation.nombre.required",
],
- "precio_max" => [
- "decimal" => "Manipuladoes.validation.precio_max.decimal",
- "required" => "Manipuladoes.validation.precio_max.required",
- ],
- "precio_min" => [
- "decimal" => "Manipuladoes.validation.precio_min.decimal",
- "required" => "Manipuladoes.validation.precio_min.required",
- ],
- "tirada_max" => [
- "integer" => "Manipuladoes.validation.tirada_max.integer",
- "required" => "Manipuladoes.validation.tirada_max.required",
- ],
- "tirada_min" => [
- "integer" => "Manipuladoes.validation.tirada_min.integer",
- "required" => "Manipuladoes.validation.tirada_min.required",
- ]
];
+
+ /**
+ * 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");
+
+ //JJO
+ $builder->where("t1.is_deleted", 0);
+
+ return empty($search)
+ ? $builder
+ : $builder
+ ->groupStart()
+ ->like("t1.nombre", $search)
+ ->orLike("t1.nombre", $search)
+ ->groupEnd();
+ }
}
diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/_tarifamanipuladoFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/_tarifamanipuladoFormItems.php
index 43699a82..94034e98 100644
--- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/_tarifamanipuladoFormItems.php
+++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/_tarifamanipuladoFormItems.php
@@ -1,77 +1,12 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- */ ?>
\ No newline at end of file
diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifamanipuladoForm.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifamanipuladoForm.php
index d3d49d1c..36c6fb57 100644
--- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifamanipuladoForm.php
+++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifamanipuladoForm.php
@@ -1,5 +1,7 @@
+= $this->include("themes/_commonPartialsBs/datatables") ?>
= $this->include("themes/_commonPartialsBs/select2bs5") ?>
-=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
+= $this->include("themes/_commonPartialsBs/sweetalert") ?>
+= $this->extend('themes/backend/vuexy/main/defaultlayout') ?>
= $this->section("content") ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | = lang('TarifaManipuladoLineas.tiradaMin') ?> |
+ = lang('TarifaManipuladoLineas.tiradaMax') ?> |
+ = lang('TarifaManipuladoLineas.precioMin') ?> |
+ = lang('TarifaManipuladoLineas.precioMax') ?> |
+ = lang('TarifaManipuladoLineas.precioUnidad') ?> |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
= $this->endSection() ?>
+
+
+= $this->section("additionalInlineJs") ?>
+
+ const lastColNr = $('#tableOfTarifamanipuladolineas').find("tr:first th").length - 1;
+ const url = window.location.href;
+ const url_parts = url.split('/');
+ if(url_parts[url_parts.length-2] == 'edit'){
+ id = url_parts[url_parts.length-1];
+ }
+ else{
+ id = -1;
+ }
+
+ const actionBtns = function(data) {
+ return `
+
+
+
+ `;
+ };
+
+
+ editor = new $.fn.dataTable.Editor( {
+ ajax: {
+ url: "= route_to('editorOfTarifaManipuladoLineas') ?>",
+ headers: {
+ = csrf_token() ?? "token" ?> : = csrf_token() ?>v,
+ },
+ },
+ table : "#tableOfTarifamanipuladolineas",
+ idSrc: 'id',
+ fields: [ {
+ name: "tirada_min"
+ }, {
+ name: "tirada_max"
+ }, {
+ name: "precio_min"
+ }, {
+ name: "precio_max"
+ }, {
+ name: "precio_unidad"
+ },{
+ "name": "tarifa_manipulado_id",
+ "type": "hidden"
+ },{
+ "name": "deleted_at",
+ "type": "hidden"
+ },{
+ "name": "is_deleted",
+ "type": "hidden"
+ },
+ ]
+ } );
+
+ editor.on( 'preSubmit', function ( e, d, type ) {
+ if ( type === 'create'){
+ d.data[0]['tarifa_manipulado_id'] = id;
+ }
+ else if(type === 'edit' ) {
+ for (v in d.data){
+ d.data[v]['tarifa_manipulado_id'] = id;
+ }
+ }
+ });
+
+
+ editor.on( 'postSubmit', function ( e, json, data, action ) {
+
+ yeniden(json.= csrf_token() ?>);
+ });
+
+ editor.on( 'submitSuccess', function ( e, json, data, action ) {
+
+ theTable.clearPipeline();
+ theTable.draw();
+ });
+
+
+ var theTable = $('#tableOfTarifamanipuladolineas').DataTable( {
+ serverSide: true,
+ processing: true,
+ autoWidth: true,
+ responsive: true,
+ lengthMenu: [ 5, 10, 25],
+ order: [[ 0, "asc" ], [ 1, "asc" ]],
+ pageLength: 10,
+ lengthChange: true,
+ searching: false,
+ paging: true,
+ info: false,
+ dom: "Bltp",
+ ajax : $.fn.dataTable.pipeline( {
+ url: '= route_to('dataTableOfTarifaManipuladoLineas') ?>',
+ data: {
+ id_tarifamanipulado: id,
+ },
+ method: 'POST',
+ headers: {'X-Requested-With': 'XMLHttpRequest'},
+ async: true,
+ }),
+ columns: [
+ { 'data': 'tirada_min' },
+ { 'data': 'tirada_max' },
+ { 'data': 'precio_min' },
+ { 'data': 'precio_max' },
+ { 'data': 'precio_unidad' },
+ {
+ data: actionBtns,
+ className: 'row-edit dt-center'
+ }
+ ],
+ columnDefs: [
+ {
+ orderable: false,
+ searchable: false,
+ targets: [lastColNr]
+ },
+ {"orderData": [ 0, 1 ], "targets": 0 },
+
+ ],
+ language: {
+ url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/= config('Basics')->i18n ?>.json"
+ },
+ buttons: [ {
+ className: 'btn btn-primary float-end me-sm-3 me-1',
+ extend: "createInline",
+ editor: editor,
+ formOptions: {
+ submitTrigger: -1,
+ submitHtml: ''
+ }
+ } ]
+ } );
+
+
+
+ // Activate an inline edit on click of a table cell
+ $('#tableOfTarifamanipuladolineas').on( 'click', 'tbody span.edit', function (e) {
+ editor.inline(
+ theTable.cells(this.parentNode.parentNode, '*').nodes(),
+ {
+ cancelHtml: '',
+ cancelTrigger: 'span.cancel',
+ submitHtml: '',
+ submitTrigger: 'span.edit',
+ submit: 'allIfChanged'
+ }
+ );
+ } );
+
+
+ // Delete row
+ $('#tableOfTarifamanipuladolineas').on( 'click', 'tbody span.remove', function (e) {
+
+ Swal.fire({
+ title: '= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Basic.global.sweet.line'))]) ?>',
+ text: '= lang('Basic.global.sweet.sureToDeleteText') ?>',
+ icon: 'warning',
+ showCancelButton: true,
+ confirmButtonColor: '#3085d6',
+ confirmButtonText: '= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
+ cancelButtonText: '= lang('Basic.global.Cancel') ?>',
+ cancelButtonColor: '#d33'
+ })
+ .then((result) => {
+ const dataId = $(this).data('id');
+ const row = $(this).closest('tr');
+ if (result.value) {
+ editor
+ .create( false )
+ .edit( this.parentNode, false)
+ .set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
+ .set( 'is_deleted', 1 )
+ .submit();
+
+ }
+ });
+ });
+
+
+
+
+
+
+
+= $this->endSection() ?>
+
+=$this->section('css') ?>
+
+
+
+=$this->endSection() ?>
+
+
+= $this->section('additionalExternalJs') ?>
+
+
+
+
+
+
+
+
+
+
+
+
+=$this->endSection() ?>
+
diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifamanipuladoList.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifamanipuladoList.php
index 482c4d6f..15823588 100644
--- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifamanipuladoList.php
+++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifamanipuladoList.php
@@ -1,4 +1,5 @@
=$this->include('themes/_commonPartialsBs/datatables') ?>
+=$this->include('themes/_commonPartialsBs/sweetalert') ?>
=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
=$this->section('content'); ?>
@@ -7,87 +8,20 @@
= view('themes/_commonPartialsBs/_alertBoxes'); ?>
-
+
- = lang('Tarifamanipulado.id') ?>
- */ ?>
| = lang('Tarifamanipulado.nombre') ?> |
- = lang('Tarifamanipulado.tiradaMin') ?> |
- = lang('Tarifamanipulado.tiradaMax') ?> |
- = lang('Tarifamanipulado.precioMin') ?> |
- = lang('Tarifamanipulado.precioMax') ?> |
- = lang('Tarifamanipulado.ajuste') ?> |
- = lang('Tarifamanipulado.ajusteTotalPedido') ?> |
- = lang('Tarifamanipulado.formulaPrice') ?> |
- = lang('Tarifamanipulado.userCreatedId') ?>
- = lang('Tarifamanipulado.userUpdateId') ?> |
- = lang('Tarifamanipulado.createdAt') ?> |
- = lang('Tarifamanipulado.updatedAt') ?> |
- */ ?>
= lang('Basic.global.Action') ?> |
-
-
-
- =$item->id ?>
-
- */ ?>
- |
- = empty($item->nombre) || strlen($item->nombre) < 51 ? esc($item->nombre) : character_limiter(esc($item->nombre), 50) ?>
- |
-
- = esc($item->tirada_min) ?>
- |
-
- = esc($item->tirada_max) ?>
- |
-
- = esc($item->precio_min) ?>
- |
-
- = esc($item->precio_max) ?>
- |
-
- = esc($item->ajuste) ?>
- |
-
- = esc($item->ajuste_total_pedido) ?>
- |
-
- = empty($item->formula_price) || strlen($item->formula_price) < 51 ? esc($item->formula_price) : character_limiter(esc($item->formula_price), 50) ?>
- |
-
- = esc($item->user_created_id) ?>
-
-
- = esc($item->user_update_id) ?>
- |
-
- = empty($item->created_at) ? '' : date('d/m/Y H:m:s', strtotime($item->created_at)) ?>
- |
-
- = empty($item->updated_at) ? '' : date('d/m/Y H:m:s', strtotime($item->updated_at)) ?>
- |
- */ ?>
-
- =anchor(route_to('editTarifamanipulado', $item->id), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id,]); ?>
- =anchor('#confirm2delete', lang('Basic.global.Delete'), ['class'=>'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deleteTarifamanipulado', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
- |
-
-
@@ -98,6 +32,110 @@
+=$this->endSection() ?>
+
+
+=$this->section('additionalInlineJs') ?>
+
+ const lastColNr = $('#tableOfTarifasmanipulado').find("tr:first th").length - 1;
+ const actionBtns = function(data) {
+ return `
+
+
+
+
+ | `;
+ };
+ theTable = $('#tableOfTarifasmanipulado').DataTable({
+ processing: true,
+ serverSide: true,
+ autoWidth: true,
+ responsive: true,
+ scrollX: true,
+ lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
+ pageLength: 10,
+ lengthChange: true,
+ "dom": 'lfBrtip',
+ "buttons": [
+ 'copy', 'csv', 'excel', 'print', {
+ extend: 'pdfHtml5',
+ orientation: 'landscape',
+ pageSize: 'A4'
+ }
+ ],
+ stateSave: true,
+ order: [[0, 'asc']],
+ language: {
+ url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/= config('Basics')->i18n ?>.json"
+ },
+ ajax : $.fn.dataTable.pipeline( {
+ url: '= route_to('dataTableOfTarifasManipulado') ?>',
+ method: 'POST',
+ headers: {'X-Requested-With': 'XMLHttpRequest'},
+ async: true,
+ }),
+ columnDefs: [
+ {
+ orderable: false,
+ searchable: false,
+ targets: [lastColNr]
+ }
+ ],
+ columns : [
+ { 'data': 'nombre' },
+ { 'data': actionBtns }
+ ]
+ });
+
+
+
+
+$(document).on('click', '.btn-edit', function(e) {
+ //window.location.href = `= route_to('tarifaManipuladoList') ?>/${$(this).attr('data-id')}/edit`;
+ window.location.href = `/tarifas/tarifasmanipulado/edit/${$(this).attr('data-id')}`;
+ });
+
+$(document).on('click', '.btn-delete', function(e) {
+ Swal.fire({
+ title: '= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Tarifamanipulado.tarifa manipulado'))]) ?>',
+ text: '= lang('Basic.global.sweet.sureToDeleteText') ?>',
+ icon: 'warning',
+ showCancelButton: true,
+ confirmButtonColor: '#3085d6',
+ confirmButtonText: '= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
+ cancelButtonText: '= lang('Basic.global.Cancel') ?>',
+ cancelButtonColor: '#d33'
+ })
+ .then((result) => {
+ const dataId = $(this).data('id');
+ const row = $(this).closest('tr');
+ if (result.value) {
+ $.ajax({
+ //url: `= route_to('tarifaManipuladoList') ?>/${dataId}`,
+ //method: 'DELETE',
+ url: `/tarifas/tarifasmanipulado/delete/${dataId}`,
+ method: 'GET',
+ }).done((data, textStatus, jqXHR) => {
+ Toast.fire({
+ icon: 'success',
+ title: data.msg ?? jqXHR.statusText,
+ });
+
+ theTable.clearPipeline();
+ theTable.row($(row)).invalidate().draw();
+ }).fail((jqXHR, textStatus, errorThrown) => {
+ Toast.fire({
+ icon: 'error',
+ title: jqXHR.responseJSON.messages.error,
+ });
+ })
+ }
+ });
+ });
+
+
+
+
=$this->endSection() ?>
@@ -116,39 +154,3 @@
=$this->endSection() ?>
-=$this->section('additionalInlineJs') ?>
-
- const lastColNr2 = $(".using-exportable-data-table").find("tr:first th").length - 1;
- theTable = $('.using-exportable-data-table').DataTable({
- "responsive": true,
- "paging": true,
- "lengthMenu": [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
- "pageLength": 10,
- "lengthChange": true,
- "searching": true,
- "ordering": true,
- "info": true,
- "dom": 'lfBrtip', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other
- // "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above
- "buttons": [
- 'copy', 'csv', 'excel', 'print', {
- extend: 'pdfHtml5',
- orientation: 'landscape',
- pageSize: 'A4'
- }
- ],
- "autoWidth": true,
- "scrollX": true,
- "stateSave": true,
- "language": {
- url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/= config('Basics')->i18n ?>.json"
- },
- "columnDefs": [
- {
- orderable: false,
- searchable: false,
- targets: [0,lastColNr2]
- }
- ]
- });
-=$this->endSection() ?>
\ No newline at end of file
diff --git a/ci4/app/Views/themes/backend/vuexy/main/menu_impresion.php b/ci4/app/Views/themes/backend/vuexy/main/menu_impresion.php
index d17014b2..13b52282 100644
--- a/ci4/app/Views/themes/backend/vuexy/main/menu_impresion.php
+++ b/ci4/app/Views/themes/backend/vuexy/main/menu_impresion.php
@@ -361,10 +361,10 @@
- 0): ?>
+ 0): ?>
0): ?>