mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminado modulo tarifas acabado
This commit is contained in:
@ -152,7 +152,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController {
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
|
||||
// JJO
|
||||
if(isset($this->model->user_update_id)){
|
||||
$sanitizedData['user_update_id'] = $session->id_user;
|
||||
@ -180,6 +180,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
$thenRedirect = true;
|
||||
endif;
|
||||
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $tarifaacabadoEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifaacabado.tarifaacabado'))]).'.';
|
||||
@ -201,7 +202,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
$this->viewData['tarifaacabadoEntity'] = $tarifaacabadoEntity;
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateTarifaAcabado', $id);
|
||||
$this->viewData['formAction'] = route_to('updateTarifaAcabado', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Tarifaacabado.moduleTitle').' '.lang('Basic.global.edit3');
|
||||
|
||||
|
||||
@ -292,6 +292,18 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
|
||||
Field::inst( 'deleted_at' ),
|
||||
|
||||
)
|
||||
->validator( function($editor, $action, $data){
|
||||
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){
|
||||
foreach ($data['data'] as $pkey => $values ){
|
||||
$count = $this->model->select('*')
|
||||
->where(array('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"));
|
||||
@ -316,6 +328,7 @@ class Tarifaacabadolineas 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 ")){
|
||||
|
||||
Reference in New Issue
Block a user