Multistatus Adaptions Design

This commit is contained in:
ma0068
2024-04-29 10:51:02 +02:00
22 changed files with 1480 additions and 1405 deletions
@@ -0,0 +1,90 @@
<?php
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* This controller operates between (interface) the JS (GUI) and the back-end
* Provides data to the ajax get calls about the Studiengang filter
* Listens to ajax post calls to change the Studiengang filter data
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
*/
class Filter extends FHCAPI_Controller
{
/**
* Calls the parent's constructor and prepares libraries and phrases
*/
public function __construct()
{
// TODO(chris): permissions
parent::__construct([
'getStg' => 'student/stammdaten:r',#self::PERM_LOGGED,
'setStg' => 'student/stammdaten:r'#self::PERM_LOGGED
]);
// Load models
$this->load->model('system/Variable_model', 'VariableModel');
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Get current setting
*
* @return void
*/
public function getStg()
{
$result = $this->VariableModel->getVariables(getAuthUID(), ['kontofilterstg']);
#$data = $this->getDataOrTerminateWithError($result);
if (isError($result))
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
$data = $result->retval;
$this->terminateWithSuccess($data['kontofilterstg'] == 'true');
}
/**
* Set current setting
*
* @return void
*/
public function setStg()
{
$this->load->library('form_validation');
$studiengang_kz = $this->input->post('studiengang_kz');
if ($studiengang_kz === null) {
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required');
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$result = $this->VariableModel->setVariable(getAuthUID(), 'kontofilterstg', $studiengang_kz ? 'true' : 'false');
#$this->getDataOrTerminateWithError($result);
if (isError($result))
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
$this->terminateWithSuccess(true);
}
}
@@ -49,7 +49,7 @@ class Konto extends FHCAPI_Controller
// Load language phrases
$this->loadPhrases([
'ui'
'konto'
]);
}
@@ -175,22 +175,21 @@ class Konto extends FHCAPI_Controller
return $row->nachname . ' ' . $row->vorname;
}, $result);
// TODO(chris): Phrases
$result = $this->p->t('konto', 'buchung_vorhanden') . "\n";
$result = $this->p->t('konto', 'confirm_overwrite') . "\n";
if (count($persons) > 10) {
$result .= "-" . implode("\n-", array_slice($persons, 0, 10)) . "\n";
if (count($persons) == 11) {
$result .= "\n" . $this->p->t('konto', 'and_1_additional_person');
$result .= "\n" . $this->p->t('konto', 'confirm_overwrite_1_add_pers');
} else {
$result .= "\n" . $this->p->t('konto', 'and_x_additional_person', [
$result .= "\n" . $this->p->t('konto', 'confirm_overwrite_x_add_pers', [
'x' => count($persons) - 10
]);
}
} else {
$result .= "-" . implode("\n-", $persons) . "\n";
}
$result .= $this->p->t('konto', 'proceed');
$result .= $this->p->t('konto', 'confirm_overwrite_proceed');
$this->addError($result, 'confirm');
@@ -327,8 +326,8 @@ class Konto extends FHCAPI_Controller
'label' => 'Buchung # ' . $buchungsnr,
'rules' => 'regex_match[/^$/]',
'errors' => [
'regex_match' => 'Gegenbuchungen koennen nur auf die obersten Buchungen getaetigt werden'
] // TODO(chris): phrase
'regex_match' => $this->p->t('konto', 'error_counter_level')
]
];
}
}
@@ -355,9 +354,9 @@ class Konto extends FHCAPI_Controller
if ($betrag === null) {
$this->addError($this->p->t(
'konto',
'Buchung #{buchungsnr} does not exist',
'error_missing',
$buchung
), self::ERROR_TYPE_GENERAL); // TODO(chris): phrase
), self::ERROR_TYPE_GENERAL);
continue;
}
@@ -482,7 +481,9 @@ class Konto extends FHCAPI_Controller
$result = $result->retval;
if (!$result)
$this->terminateWithError('buchung not found', self::ERROR_TYPE_GENERAL); // TODO(chris): phrase
$this->terminateWithError($this->p->t('konto', 'error_missing', [
'buchungsnr' => $buchungsnr
]), self::ERROR_TYPE_GENERAL);
$_POST['studiengang_kz'] = current($result)->studiengang_kz;
@@ -500,7 +501,7 @@ class Konto extends FHCAPI_Controller
if (isError($result)) {
if (getCode($result) != 42)
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); // TODO(chris): phrase
$this->terminateWithError($this->p->t('konto', 'error_delete_level'), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess();