mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into 'dev/delete-ui'
# Conflicts: # ci4/app/Controllers/Tarifas/Tarifaacabado.php # ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaList.php # ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php # ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionList.php
This commit is contained in:
@ -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]
|
||||
];
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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]
|
||||
];
|
||||
|
||||
|
||||
@ -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]
|
||||
];
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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');
|
||||
}
|
||||
|
||||
389
ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php
Normal file
389
ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php
Normal file
@ -0,0 +1,389 @@
|
||||
<?php namespace App\Controllers\Tarifas;
|
||||
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Entities\Tarifas\TarifaEncuadernacionLinea;
|
||||
|
||||
use App\Models\Tarifas\TarifaEncuadernacionLineaModel;
|
||||
|
||||
use
|
||||
DataTables\Editor,
|
||||
DataTables\Database,
|
||||
DataTables\Editor\Field,
|
||||
DataTables\Editor\Format,
|
||||
DataTables\Editor\Mjoin,
|
||||
DataTables\Editor\Options,
|
||||
DataTables\Editor\Upload,
|
||||
DataTables\Editor\Validate,
|
||||
DataTables\Editor\ValidateOptions;
|
||||
|
||||
|
||||
class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
protected $modelName = TarifaEncuadernacionLineaModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Tarifa Encuadernacion Linea';
|
||||
protected static $singularObjectNameCc = 'tarifaEncuadernacionLinea';
|
||||
protected static $pluralObjectName = 'Tarifa Encuadernacion Lineas';
|
||||
protected static $pluralObjectNameCc = 'tarifaEncuadernacionLineas';
|
||||
|
||||
protected static $controllerSlug = 'tarifaencuadernacionlineas';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/tarifas/encuadernacion/';
|
||||
|
||||
protected $indexRoute = 'tarifaEncuadernacionLineaList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
296
ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php
Normal file
296
ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php
Normal file
@ -0,0 +1,296 @@
|
||||
<?php namespace App\Controllers\Tarifas;
|
||||
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Entities\Tarifas\TarifaEncuadernacionEntity;
|
||||
|
||||
use App\Models\Tarifas\TarifaEncuadernacionModel;
|
||||
|
||||
class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
protected $modelName = TarifaEncuadernacionModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Tarifa Encuadernacion';
|
||||
protected static $singularObjectNameCc = 'tarifaEncuadernacion';
|
||||
protected static $pluralObjectName = 'Tarifas Encuadernacion';
|
||||
protected static $pluralObjectNameCc = 'tarifasEncuadernacion';
|
||||
|
||||
protected static $controllerSlug = 'tarifaencuadernacion';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/tarifas/encuadernacion/';
|
||||
|
||||
protected $indexRoute = 'tarifaEncuadernacionList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user