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:
@ -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