arraglando la tabla tarifas con la forma nueva

This commit is contained in:
Jaime Jimenez
2023-05-11 07:33:06 +02:00
parent ff9bf6a000
commit 3cbf5cf8a8
15 changed files with 819 additions and 177 deletions

View File

@ -39,37 +39,65 @@ class Group extends \App\Controllers\GoBaseController
public function add()
{
helper('form');
$requestMethod = $this->request->getMethod();
$data['title'] = [
'module' => lang("App.group_add_title"),
'page' => lang("App.group_add_subtitle"),
'icon' => 'far fa-plus-square'
];
if ($requestMethod === 'post') :
$data['breadcrumb'] = [
['title' => lang("App.menu_dashboard"), 'route' => "/home", 'active' => false],
['title' => lang("App.group_title"), 'route' => "/usuarios/group", 'active' => false],
['title' => lang("App.group_add_title"), 'route' => "", 'active' => true]
];
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$data['btn_return'] = [
'title' => lang("App.global_come_back"),
'route' => 'usuarios/group',
'class' => 'btn btn-dark mr-1',
'icon' => 'fas fa-angle-left'
];
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
$data['btn_submit'] = [
'title' => lang("App.global_save"),
'route' => '',
'class' => 'btn btn-primary mr-1',
'icon' => 'fas fa-save'
];
echo view(getenv('theme.path').'main/header');
echo view(getenv('theme.path').'form/group/form',$data);
echo view(getenv('theme.path').'main/footer');
$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('Group.userGroup'))]);
$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('Group.userGroup'))]).'.';
$message .= anchor( "admin/user-groups/{$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['group'] = isset($sanitizedData) ? new UserGroupModel($sanitizedData) : new UserGroupModel();
$this->viewData['formAction'] = route_to('createUserGroup');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Group.moduleTitle').' '.lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
}
//public function edit($id)