This commit is contained in:
cgfhtw
2024-04-12 10:38:06 +02:00
parent 8705341563
commit efebaeeb27
8 changed files with 572 additions and 110 deletions
@@ -16,7 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
if (!defined('BASEPATH')) exit('No direct script access allowed');
use CI3_Events as Events;
/**
* This controller operates between (interface) the JS (GUI) and the back-end
@@ -33,7 +35,9 @@ class Konto extends FHCAPI_Controller
{
// TODO(chris): permissions
parent::__construct([
'get' => 'student/stammdaten:r'
'get' => 'student/stammdaten:r',
'getBuchungstypen' => 'student/stammdaten:r', // alle?
'update' => ['admin:w', 'assistenz:w']
]);
// Load models
@@ -51,15 +55,20 @@ class Konto extends FHCAPI_Controller
/**
* Get details for a prestudent
*
* @param string $type
* @param string (optional) $studiengang_kz
* @return void
*/
public function get($type, $studiengang_kz = '')
public function get()
{
// TODO(chris): validation
$this->load->library('form_validation');
$this->form_validation->set_rules('person_id', 'Person ID', 'required');
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$person_id = $this->input->post('person_id');
$studiengang_kz = $this->input->post('studiengang_kz');
if ($this->input->post('only_open')) {
$result = $this->KontoModel->getOffeneBuchungen($person_id, $studiengang_kz);
@@ -95,4 +104,77 @@ class Konto extends FHCAPI_Controller
$this->terminateWithSuccess(array_values($data));
}
/**
* Get list of Buchungstypen
*
* @return void
*/
public function getBuchungstypen()
{
$this->load->model('crm/Buchungstyp_model', 'BuchungstypModel');
$result = $this->BuchungstypModel->load();
#$data = $this->getDataOrTerminateWithError($result);
if (isError($result))
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
$data = $result->retval;
$this->terminateWithSuccess($data);
}
/**
* Save Buchung
*
* @return void
*/
public function update()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('buchungsnr', 'Buchungsnr', 'required');
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required|has_permissions_for_stg[admin:rw,assistenz:rw]');
$this->form_validation->set_rules('buchungsdatum', 'Buchungsdatum', 'is_valid_date');
Events::trigger('konto_update_validation', $this->form_validation);
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$id = $this->input->post('buchungsnr');
$allowed = [
'betrag',
'buchungsdatum',
'buchungstext',
'mahnspanne',
'buchungstyp_kurzbz',
'studiensemester_kurzbz',
'studiengang_kz',
'credit_points',
'anmerkung'
];
$data = [
'updateamum' => date('c'),
'updatevon' => getAuthUID()
];
foreach ($allowed as $field)
if ($this->input->post($field) !== null)
$data[$field] = $this->input->post($field);
$result = $this->KontoModel->update($id, $data);
#$this->getDataOrTerminateWithError($result);
if (isError($result))
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
$result = $this->KontoModel->withAdditionalInfo()->load($id);
#$result = $this->getDataOrTerminateWithError($result);
if (isError($result))
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
$result = $result->retval;
$this->terminateWithSuccess($result);
}
}
@@ -0,0 +1,72 @@
<?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 generally used lists
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
*/
class Lists extends FHCAPI_Controller
{
public function __construct()
{
// TODO(chris): permissions
parent::__construct([
'getStudiensemester' => ['admin:r', 'assistenz:r', 'student/stammdaten:r'], // alle?
'getStgs' => ['admin:r', 'assistenz:r', 'student/stammdaten:r'] // alle?
]);
}
public function getStudiensemester()
{
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$this->StudiensemesterModel->addOrder('ende');
$result = $this->StudiensemesterModel->load();
#$data = $this->getDataOrTerminateWithError($result);
if (isError($result))
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
$data = $result->retval;
$this->terminateWithSuccess($data);
}
public function getStgs()
{
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
$this->StudiengangModel->addSelect('*');
$this->StudiengangModel->addSelect('UPPER(typ || kurzbz) AS kuerzel');
$this->StudiengangModel->addOrder('typ');
$this->StudiengangModel->addOrder('kurzbz');
$result = $this->StudiengangModel->load();
#$data = $this->getDataOrTerminateWithError($result);
if (isError($result))
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
$data = $result->retval;
$this->terminateWithSuccess($data);
}
}
@@ -6,10 +6,15 @@ use CI3_Events as Events;
class Config extends FHC_Controller
{
public function __construct()
{
// TODO(chris): access!
parent::__construct();
$this->load->library('AuthLib');
$this->load->library('PermissionLib');
}
public function student()
@@ -39,7 +44,13 @@ class Config extends FHC_Controller
$result['konto'] = [
'title' => 'Konto',
'component' => './Stv/Studentenverwaltung/Details/Konto.js',
'config' => ['ZAHLUNGSBESTAETIGUNG_ANZEIGEN' => (defined('ZAHLUNGSBESTAETIGUNG_ANZEIGEN') && ZAHLUNGSBESTAETIGUNG_ANZEIGEN)]
'config' => [
'showZahlungsbestaetigung' => (defined('ZAHLUNGSBESTAETIGUNG_ANZEIGEN') && ZAHLUNGSBESTAETIGUNG_ANZEIGEN),
'showBuchungsnr' => $this->permissionlib->isBerechtigt('admin'),
'showMahnspanne' => (!defined('FAS_KONTO_SHOW_MAHNSPANNE') || FAS_KONTO_SHOW_MAHNSPANNE===true),
'showCreditpoints' => (defined('FAS_KONTO_SHOW_CREDIT_POINTS') && FAS_KONTO_SHOW_CREDIT_POINTS == 'true'),
'additionalCols' => []
]
];
$result['betriebsmittel'] = [
'title' => 'Betriebsmittel',
@@ -64,7 +75,13 @@ class Config extends FHC_Controller
$result['konto'] = [
'title' => 'Konto',
'component' => './Stv/Studentenverwaltung/Details/Konto.js',
'config' => ['ZAHLUNGSBESTAETIGUNG_ANZEIGEN' => (defined('ZAHLUNGSBESTAETIGUNG_ANZEIGEN') && ZAHLUNGSBESTAETIGUNG_ANZEIGEN)]
'config' => [
'showZahlungsbestaetigung' => (defined('ZAHLUNGSBESTAETIGUNG_ANZEIGEN') && ZAHLUNGSBESTAETIGUNG_ANZEIGEN),
'showBuchungsnr' => $this->permissionlib->isBerechtigt('admin'),
'showMahnspanne' => (!defined('FAS_KONTO_SHOW_MAHNSPANNE') || FAS_KONTO_SHOW_MAHNSPANNE===true),
'showCreditpoints' => (defined('FAS_KONTO_SHOW_CREDIT_POINTS') && FAS_KONTO_SHOW_CREDIT_POINTS == 'true'),
'additionalCols' => []
]
];
Events::trigger('stv_conf_students', function & () use (&$result) {
+23 -6
View File
@@ -1,4 +1,7 @@
<?php
use CI3_Events as Events;
class Konto_model extends DB_Model
{
@@ -14,14 +17,11 @@ class Konto_model extends DB_Model
/**
* Get all accounting entries for a person optionally filtered by Studiengang
* Adds additional fields to the Query
*
* @param integer|array $person_id
* @param string (optional) $studiengang_kz
*
* @return stdClass
* @return Konto_model
*/
public function getAlleBuchungen($person_id, $studiengang_kz = '')
public function withAdditionalInfo()
{
$this->addSelect($this->dbTable . '.*');
$this->addSelect('UPPER(typ::varchar(1) || kurzbz) AS kuerzel');
@@ -35,6 +35,23 @@ class Konto_model extends DB_Model
$this->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
$this->addJoin('public.tbl_person person', 'person_id', 'LEFT');
Events::trigger('konto_query');
return $this;
}
/**
* Get all accounting entries for a person optionally filtered by Studiengang
*
* @param integer|array $person_id
* @param string (optional) $studiengang_kz
*
* @return stdClass
*/
public function getAlleBuchungen($person_id, $studiengang_kz = '')
{
$this->withAdditionalInfo();
$this->addOrder('buchungsdatum');
if (is_array($person_id))