mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
tarifas manipulado actualizado
This commit is contained in:
@ -259,11 +259,20 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
|
||||
->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('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');
|
||||
// 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');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -293,13 +302,13 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
|
||||
->data();
|
||||
|
||||
|
||||
// if unique key is set in DB
|
||||
/*// 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();
|
||||
|
||||
|
||||
@ -98,14 +98,15 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado'))]).'.';
|
||||
$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('sweet-success', $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('sweet-success', $message);
|
||||
endif;
|
||||
@ -160,25 +161,22 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
$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;
|
||||
@ -187,7 +185,7 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
@ -223,7 +221,7 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
||||
$order = TarifaManipuladoModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 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();
|
||||
|
||||
@ -15,8 +15,11 @@ class Test extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
/*
|
||||
$papel = new Papelesimpresion();
|
||||
var_dump($papel->datatablePG());
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user