Ferienverwaltung: added new fields Organisationseinheit, Studienplan, added new table and field ferientyp, filtering by date instead of Studiengang

This commit is contained in:
Alexei Karpenko
2026-03-03 23:07:22 +01:00
parent f42ef3d5b6
commit 976ef1f975
7 changed files with 610 additions and 99 deletions
@@ -26,6 +26,8 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
*/
class Ferien extends FHCAPI_Controller
{
const DEFAULT_STUDIENGANG_KZ = 0;
/**
* Calls the parent's constructor and prepares libraries and phrases
*/
@@ -33,6 +35,10 @@ class Ferien extends FHCAPI_Controller
{
parent::__construct([
'getFerien' => 'basis/ferien:r',
'getDefaultVonBis' => 'basis/ferien:r',
'getOe' => 'basis/ferien:r',
'getStudienplaene' => 'basis/ferien:r',
'getFerientypen' => 'basis/ferien:r',
'getStg' => 'basis/ferien:r',
'insert' => 'basis/ferien:w',
'update' => 'basis/ferien:w',
@@ -41,6 +47,7 @@ class Ferien extends FHCAPI_Controller
// Load models
$this->load->model('organisation/Ferien_model', 'FerienModel');
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
// Load language phrases
$this->loadPhrases([
@@ -53,25 +60,31 @@ class Ferien extends FHCAPI_Controller
/**
* Get Ferien
*
* @return void
*/
public function getFerien()
{
$studiengang_kz = $this->input->get('studiengang_kz');
// TODO check input
$this->addMeta('stgkz', $studiengang_kz);
$filterVonDatum = $this->input->get('filterVonDatum');
$filterBisDatum = $this->input->get('filterBisDatum');
if (!isset($studiengang_kz)) $this->terminateWithSuccess([]);
$this->FerienModel->addSelect(
'tbl_ferien.ferien_id, tbl_ferien.bezeichnung, tbl_ferien.vondatum, tbl_ferien.bisdatum,
plan.studienplan_id, stg.studiengang_kz, oe.oe_kurzbz, fetyp.ferientyp_kurzbz,
oe.bezeichnung AS oe_bezeichnung, UPPER(stg.typ::varchar(1) || stg.kurzbz) AS studiengang_kuerzel,
plan.studienplan_id, plan.bezeichnung AS studienplan_bezeichnung, fetyp.mitarbeiter AS mitarbeiterrelevant, fetyp.studierende AS studierendenrelevant,
fetyp.lehre'
);
$this->FerienModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
$this->FerienModel->addJoin('lehre.tbl_studienplan plan', 'studienplan_id', 'LEFT');
$this->FerienModel->addJoin('public.tbl_organisationseinheit oe', 'tbl_ferien.oe_kurzbz = oe.oe_kurzbz', 'LEFT');
$this->FerienModel->addJoin('lehre.tbl_ferientyp fetyp', 'ferientyp_kurzbz', 'LEFT');
//~ if (isset($studiengang_kz) && !is_numeric($studiengang_kz))
//~ $this->terminateWithError($this->p->t('ui', 'errorMissingOrInvalidParameters', ['parameter'=> 'Studiengang']), self::ERROR_TYPE_GENERAL);
if (isset($filterVonDatum))
$this->FerienModel->db->where('tbl_ferien.bisdatum >=', $filterVonDatum);
$this->FerienModel->addSelect('tbl_ferien.*, , UPPER(typ::varchar(1) || kurzbz) AS studiengang_kuerzel');
$this->FerienModel->addJoin('public.tbl_studiengang', 'studiengang_kz');
if (isset($studiengang_kz) && is_numeric($studiengang_kz))
$this->FerienModel->db->where('studiengang_kz', $studiengang_kz);
if (isset($filterBisDatum))
$this->FerienModel->db->where('tbl_ferien.vondatum <=', $filterBisDatum);
$this->FerienModel->addOrder('vondatum', 'DESC');
$result = $this->FerienModel->load();
@@ -82,17 +95,39 @@ class Ferien extends FHCAPI_Controller
}
/**
* Get list of Studiengaenge
*
* @return void
* Gets default dates (from - to) for filtering Ferien.
*/
public function getStg()
public function getDefaultVonBis()
{
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
$defaultVonBis = ['defaultVon' => null, 'defaultBis' => null];
$this->StudiengangModel->addSelect(' tbl_studiengang.*, UPPER(typ::varchar(1) || kurzbz) AS kuerzel');
$this->StudiengangModel->addOrder('typ, kurzbz');
$result = $this->StudiengangModel->load();
// get current Studienjahr
$this->load->model('organisation/Studienjahr_model', 'StudienjahrModel');
$result = $this->StudienjahrModel->getAktOrNextStudienjahr(62);
if (isError($result)) $this->terminateWithError(getError($result));
if (hasData($result))
{
$studienjahr = getData($result)[0];
$defaultVonBis['defaultVon'] = $studienjahr->beginn;
$defaultVonBis['defaultBis'] = $studienjahr->ende;
}
$this->terminateWithSuccess($defaultVonBis);
}
/**
* Get list of Organisationseinheiten
*/
public function getOe()
{
$this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel');
//$this->StudiengangModel->addSelect(' tbl_studiengang.*, UPPER(typ::varchar(1) || kurzbz) AS kuerzel');
$this->OrganisationseinheitModel->addOrder('organisationseinheittyp_kurzbz, oe_kurzbz');
$result = $this->OrganisationseinheitModel->loadWhere(['aktiv' => true]);
$data = $this->getDataOrTerminateWithError($result);
@@ -100,9 +135,108 @@ class Ferien extends FHCAPI_Controller
}
/**
* Save Ferien
*
* @return void
* Get list of Studienplaene.
* Studienplaene are returned by Organisationseinheit, von and bis datum.
*/
public function getStudienplaene()
{
// check input
//~ $this->load->library('form_validation');
//~ $this->form_validation->set_rules('oe_kurzbz', 'Organisationseinheit', 'max_length[32]');
//~ $this->form_validation->set_rules('vondatum', 'Von Datum', 'is_valid_date');
//~ $this->form_validation->set_rules('bisdatum', 'Bis Datum', 'is_valid_date');
//~ if (!$this->form_validation->run())
//~ $this->terminateWithValidationErrors($this->form_validation->error_array());
$oe_kurzbz = $this->input->get('oe_kurzbz');
$vondatum = $this->input->get('vondatum');
$bisdatum = $this->input->get('bisdatum');
// get Studiengang from Oe
$result = $this->StudiengangModel->loadWhere(['oe_kurzbz' => $oe_kurzbz]);
if (isError($result)) $this->terminateWithError(getError($result));
if (!hasData($result)) $this->terminateWithSuccess([]);
$studiengangKzArr = array_column(getData($result), 'studiengang_kz');
// load models
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$this->load->model('organisation/Studienplan_model', 'StudienplanModel');
// get all Studiensemester in requested date range
$result = $this->StudiensemesterModel->getByDateRange($vondatum, $bisdatum);
if (isError($result)) $this->terminateWithError(getError($result));
if (!hasData($result)) $this->terminateWithSuccess([]);
$studiensemesterArr = array_column(getData($result), 'studiensemester_kurzbz');
$studienplaene = [];
foreach ($studiengangKzArr as $studiengang_kz)
{
foreach ($studiensemesterArr as $studiensemester_kurzbz)
{
// get studienplaene for each Studiengang and Studiensemester
$this->StudienplanModel->addDistinct("studienplan_id");
$this->StudienplanModel->addSelect("lehre.tbl_studienplan.*");
$this->StudienplanModel->addJoin("lehre.tbl_studienordnung", "studienordnung_id");
$this->StudienplanModel->addJoin("lehre.tbl_studienplan_semester", "studienplan_id");
$whereArray = array(
"tbl_studienplan.aktiv" => "TRUE",
"tbl_studienordnung.studiengang_kz" => $studiengang_kz,
"tbl_studienplan_semester.studiensemester_kurzbz" => $studiensemester_kurzbz
);
$result = $this->StudienplanModel->loadWhere($whereArray);
//$result = $this->StudienplanModel->getStudienplaeneBySemester($studiengang_kz, $studiensemester_kurzbz);
if (isError($result)) $this->terminateWithError(getError($result));
if (!hasData($result)) continue;
foreach (getData($result) as $studienplan)
{
$studienplaene[$studienplan->studienplan_id] = $studienplan;
}
}
}
$this->terminateWithSuccess($studienplaene);
}
/**
* Get list of Ferientypen
*/
public function getFerientypen()
{
$this->load->model('organisation/Ferientyp_model', 'FerientypModel');
$this->FerientypModel->addOrder('ferientyp_kurzbz');
$result = $this->FerientypModel->load();
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
/**
* Get list of Studiengaenge
*/
public function getStg()
{
$this->StudiengangModel->addSelect(' tbl_studiengang.*, UPPER(typ::varchar(1) || kurzbz) AS kuerzel');
$this->StudiengangModel->addOrder('typ, kurzbz');
$result = $this->StudiengangModel->loadWhere(['aktiv' => true]);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
/**
* Add Ferien
*/
public function insert()
{
@@ -110,11 +244,15 @@ class Ferien extends FHCAPI_Controller
$data = $this->_getData();
// TODO add insertaum and updateamum?
//~ $data = [
//~ 'insertamum' => date('c'),
//~ 'insertvon' => getAuthUID()
//~ ];
// get studiengang_kz from oe, otherwise default kz
$this->StudiengangModel->addSelect('studiengang_kz');
$this->StudiengangModel->addLimit(1);
$result = $this->StudiengangModel->loadWhere(['oe_kurzbz' => $data['oe_kurzbz']]);
$data['studiengang_kz'] = hasData($result) ? getData($result)[0]->studiengang_kz : self::DEFAULT_STUDIENGANG_KZ;
$data = array_merge($data, ['insertamum' => date('c'), 'insertvon' => getAuthUID()]);
$id = $this->getDataOrTerminateWithError($this->FerienModel->insert($data));
$this->terminateWithSuccess(hasData($id) ? getData($id) : null);
@@ -122,8 +260,6 @@ class Ferien extends FHCAPI_Controller
/**
* Update Ferien
*
* @return void
*/
public function update()
{
@@ -137,13 +273,8 @@ class Ferien extends FHCAPI_Controller
$data = $this->_getData();
if (isEmptyArray($data)) $this->terminateWithSuccess(null);
// TODO add insertaum and updateamum?
//~ $data = [
//~ 'updateamum' => date('c'),
//~ 'updatevon' => getAuthUID()
//~ ];
$data['ferien_id'] = $id;
$data = array_merge($data, ['ferien_id' => $id, 'updateamum' => date('c'), 'updatevon' => getAuthUID()]);
$result = $this->FerienModel->update($id, $data);
@@ -154,8 +285,6 @@ class Ferien extends FHCAPI_Controller
/**
* Delete Ferien
*
* @return void
*/
public function delete()
{
@@ -170,7 +299,6 @@ class Ferien extends FHCAPI_Controller
$this->FerienModel->addSelect('ferien_id');
$result = $this->FerienModel->load($ferien_id);
$this->addMeta('res', $result);
if (!hasData($result))
$this->terminateWithError($this->p->t('ferien', 'error_missing', [
@@ -196,8 +324,6 @@ class Ferien extends FHCAPI_Controller
/**
* Validate ferien post input.
* @param
* @return object success or error
*/
private function _validate()
{
@@ -206,7 +332,9 @@ class Ferien extends FHCAPI_Controller
$this->form_validation->set_rules('vondatum', 'Von Datum', 'required|is_valid_date');
$this->form_validation->set_rules('bisdatum', 'Bis Datum', 'required|is_valid_date');
$this->form_validation->set_rules('bezeichnung', 'Bezeichnung', 'required|max_length[128]');
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required|numeric');
$this->form_validation->set_rules('oe_kurzbz', 'Organisationseinheit', 'required|max_length[32]');
$this->form_validation->set_rules('studienplan_id', 'Studienplan', 'numeric');
$this->form_validation->set_rules('ferientyp_kurzbz', 'Ferientyp', 'max_length[64]');
//Events::trigger('konto_insert_validation', $this->form_validation);
@@ -216,7 +344,6 @@ class Ferien extends FHCAPI_Controller
/**
* Gets Ferien data from post input.
* @return array
*/
private function _getData()
{
@@ -226,13 +353,14 @@ class Ferien extends FHCAPI_Controller
'vondatum',
'bisdatum',
'bezeichnung',
'studiengang_kz'
'oe_kurzbz',
'studienplan_id',
'ferientyp_kurzbz'
];
foreach ($allowed as $field)
{
if ($this->input->post($field) !== null) $data[$field] = $this->input->post($field);
$data[$field] = $this->input->post($field);
}
return $data;
@@ -0,0 +1,15 @@
<?php
class Ferientyp_model extends DB_Model
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->dbTable = 'lehre.tbl_ferientyp';
$this->pk = 'ferientyp_kurzbz';
$this->hasSequence = false;
}
}
@@ -53,11 +53,9 @@ class Studienjahr_model extends DB_Model
* @param int $days
* @return array|stdClass|null
*/
public function getLastOrAktStudienjahr($days = 60)
public function getLastOrAktStudienjahr($days = 0)
{
if (!is_numeric($days)) {
$days = 60;
}
$days = is_numeric($days) ? $this->escape($days) : 0;
$query = '
SELECT *
@@ -77,19 +75,25 @@ class Studienjahr_model extends DB_Model
* @param int $days
* @return array|stdClass|null
*/
public function getAktOrNextStudienjahr($days = 62)
public function getAktOrNextStudienjahr($days = 0)
{
if (!is_numeric($days)) {
$days = 62;
}
$days = is_numeric($days) ? $this->escape($days) : 0;
$query = '
SELECT *
FROM public.tbl_studienjahr
JOIN public.tbl_studiensemester using(studienjahr_kurzbz)
WHERE start < NOW() + \'' . $days . ' DAYS\'::INTERVAL
ORDER by start DESC
LIMIT 1
SELECT * FROM (
SELECT
jahr.*, MIN(sem.start) AS beginn, MAX(sem.ende) AS ende
FROM
public.tbl_studienjahr jahr
JOIN public.tbl_studiensemester sem using(studienjahr_kurzbz)
GROUP BY
studienjahr_kurzbz
) jahre
WHERE
ende >= NOW() + \'' . $days . ' DAYS\'::INTERVAL
ORDER BY
ende
LIMIT 1
';
return $this->execQuery($query);
@@ -16,21 +16,51 @@
*/
export default {
getFerien(studiengang_kz) {
getFerien(filterVonDatum, filterBisDatum) {
return {
method: 'get',
url: 'api/frontend/v1/education/ferien/getFerien',
params: {
studiengang_kz
filterVonDatum,
filterBisDatum
}
};
},
getOe() {
return {
method: 'get',
url: 'api/frontend/v1/education/ferien/getOe'
};
},
getStudienplaene(oe_kurzbz, vondatum, bisdatum) {
return {
method: 'get',
url: 'api/frontend/v1/education/ferien/getStudienplaene',
params: {
oe_kurzbz,
vondatum,
bisdatum
}
};
},
getFerientypen() {
return {
method: 'get',
url: 'api/frontend/v1/education/ferien/getFerientypen'
};
},
getStg() {
return {
method: 'get',
url: 'api/frontend/v1/education/ferien/getStg'
};
},
getDefaultVonBis() {
return {
method: 'get',
url: 'api/frontend/v1/education/ferien/getDefaultVonBis'
};
},
insert(params) {
return {
method: 'post',
@@ -20,21 +20,21 @@ export default {
},
data() {
return {
studiengang_kz_list: [],
studiengang_kz: null,
filterVonDatum: null,
filterBisDatum: null,
loading: false,
tabulatorOptions: {
ajaxURL: 'dummy',
ajaxRequestFunc: () => this.$api.call(
ApiFerienverwaltung.getFerien(this.studiengang_kz)
ApiFerienverwaltung.getFerien(this.filterVonDatum, this.filterBisDatum)
),
ajaxResponse: (url, params, response) => response.data,
columns: [
{title:"Ferien Id", field:"ferien_id", visible: false},
{title:"Studiengang", field:"studiengang_kuerzel"},
{title:"Ferien Id", field:"ferien_id", visible: false, headerFilter: true},
{
title:"Datum von",
field:"vondatum",
headerFilter: true,
formatter: function (cell) {
const dateStr = cell.getValue();
if (!dateStr) return "";
@@ -51,6 +51,7 @@ export default {
{
title:"Datum bis",
field:"bisdatum",
headerFilter: true,
formatter: function (cell) {
const dateStr = cell.getValue();
if (!dateStr) return "";
@@ -64,7 +65,56 @@ export default {
});
}
},
{title:"Bezeichnung", field:"bezeichnung"},
{title:"Bezeichnung", field:"bezeichnung", headerFilter: true},
{title:"Organisationseinheit Kurzbezeichnung", field:"oe_kurzbz", visible: false, headerFilter: true},
{title:"Organisationseinheit", field:"oe_bezeichnung", headerFilter: true},
{title:"Studienplan", field:"studienplan_bezeichnung", visible: false, headerFilter: true},
{title:"Ferientyp Kurzbezeichnung", field:"ferientyp_kurzbz", visible: false, headerFilter: true},
{
title:"Mitarbeiterrelevant",
field:"mitarbeiterrelevant",
visible: false,
headerFilter: true,
hozAlign: "center",
formatter:'tickCross', formatterParams: {
tickElement: '<i class="fas fa-check text-success"></i>',
crossElement: '<i class="fas fa-times text-danger"></i>'
},
headerFilter:"tickCross", headerFilterParams: {
"tristate":true, elementAttributes:{"value":"true"}
},
headerFilterEmptyCheck:function(value){return value === null}
},
{
title:"Studierendenrelevant",
field:"studierendenrelevant",
visible: false,
headerFilter: true,
hozAlign: "center",
formatter:'tickCross', formatterParams: {
tickElement: '<i class="fas fa-check text-success"></i>',
crossElement: '<i class="fas fa-times text-danger"></i>'
},
headerFilter:"tickCross", headerFilterParams: {
"tristate":true, elementAttributes:{"value":"true"}
},
headerFilterEmptyCheck:function(value){return value === null}
},
{
title:"Lehre planbar",
field:"lehre",
visible: false,
headerFilter: true,
hozAlign: "center",
formatter:'tickCross', formatterParams: {
tickElement: '<i class="fas fa-check text-success"></i>',
crossElement: '<i class="fas fa-times text-danger"></i>'
},
headerFilter:"tickCross", headerFilterParams: {
"tristate":true, elementAttributes:{"value":"true"}
},
headerFilterEmptyCheck:function(value){return value === null}
},
{title:"Aktionen", field: "actions",
minWidth: 150, // Ensures Action-buttons will be always fully displayed
formatter: (cell, formatterParams, onRendered) => {
@@ -117,9 +167,6 @@ export default {
cm.getColumnByField('ferien_id').component.updateDefinition({
title: this.$p.t('ferien', 'ferien_id'),
});
cm.getColumnByField('studiengang_kuerzel').component.updateDefinition({
title: this.$p.t('ferien', 'studiengang_kuerzel'),
});
cm.getColumnByField('vondatum').component.updateDefinition({
title: this.$p.t('ferien', 'vondatum'),
});
@@ -150,50 +197,74 @@ export default {
//~ },
actionNew() {
this.$refs.modal.open();
},
loadByStg() {
this.reload();
}
},
created() {
this.loading = true;
//this.loading = true;
//~ this.$api
//~ .call(ApiFerienverwaltung.getOe())
//~ .then(result => {
//~ this.oeList = result.data;
//~ }
//~ )
//~ .catch(error => {
//~ if (error)
//~ this.$fhcAlert.handleSystemError(error);
//~ });
this.$api
.call(ApiFerienverwaltung.getStg())
.call(ApiFerienverwaltung.getDefaultVonBis())
.then(result => {
this.studiengang_kz_list = result.data;
this.loading = false;
this.filterVonDatum = result.data.defaultVon;
this.filterBisDatum = result.data.defaultBis;
}
)
.catch(error => {
if (error)
this.$fhcAlert.handleSystemError(error);
this.loading = false;
});
},
template: `
<div class="h-100 d-flex flex-column">
<div class="row justify-content-center">
<div class="col-lg-3">
<div class="input-group w-auto">
<select class="form-select" v-model="studiengang_kz">
<option selected="selected" :value="null">-- {{ $p.t('ferien/keineAuswahl') }} --</option>
<option value="All">-- {{ $p.t('ferien/alleStudiengaenge') }} --</option>
<option v-for="studiengang in studiengang_kz_list" :key="studiengang.studiengang_kz" :value="studiengang.studiengang_kz">
{{ studiengang.kuerzel }}
</option>
</select>
<button
class="btn btn-primary"
@click="loadByStg()"
:disabled="loading"
>
<i v-if="loading" class="fa fa-spinner fa-spin"></i>
{{ $p.t('ui/anzeigen') }}
</button>
</div>
<div class="col-5">
<form-input
type="DatePicker"
v-model="filterVonDatum"
name="filtervondatum"
:label="$p.t('ferien/vondatum')"
:enable-time-picker="false"
text-input
format="dd.MM.yyyy"
auto-apply
>
</form-input>
</div>
<div class="col-5">
<form-input
type="DatePicker"
v-model="filterBisDatum"
name="filterbisdatum"
:label="$p.t('ferien/bisdatum')"
:enable-time-picker="false"
text-input
format="dd.MM.yyyy"
auto-apply
>
</form-input>
</div>
<div class="col-1 align-self-end">
<button
class="btn btn-primary"
@click="reload()"
:disabled="loading"
>
<i v-if="loading" class="fa fa-spinner fa-spin"></i>
{{ $p.t('ui/anzeigen') }}
</button>
</div>
</div>
<div class="row">
<div class="row mt-3">
<div class="col">
<core-filter-cmpt
ref="table"
@@ -208,7 +279,7 @@ export default {
@click:new="actionNew"
>
</core-filter-cmpt>
<ferien-modal ref="modal" :studiengang_kz_list="studiengang_kz_list" @saved="reload"></ferien-modal>
<ferien-modal ref="modal" @saved="reload"></ferien-modal>
</div>
</div>
</div>`
@@ -0,0 +1,202 @@
import BsModal from "../Bootstrap/Modal.js";
import BsConfirm from "../Bootstrap/Confirm.js";
import CoreForm from "../Form/Form.js";
import FormValidation from "../Form/Validation.js";
import FormInput from "../Form/Input.js";
import ApiFerien from '../../api/factory/ferienverwaltung/ferienverwaltung.js';
export default {
components: {
BsModal,
CoreForm,
FormValidation,
FormInput
},
props: {
//~ ferien_id: {
//~ type: Number,
//~ default: null
//~ }
//~ studiengang_kz_list: {
//~ type: Array,
//~ required: true
//~ }
},
data() {
return {
oeList: [],
studienplaeneList: [],
ferientypList: [],
loading: false,
data: {},
};
},
computed: {
},
methods: {
save() {
this.$refs.form.clearValidation();
this.loading = true;
//~ let params = this.data;
let saveFunc = this.data.ferien_id ? ApiFerien.update : ApiFerien.insert;
//~ if (this.data.ferien_id) { // update
//~ params = { ...{ ferien_id: this.ferien_id }, ...this.data };
//~ let saveFunc = ApiFerien.update;
//~ }
this.$refs.form
.call(saveFunc(this.data))
.then(result => {
this.$emit('saved', result.data);
this.loading = false;
this.$refs.modal.hide();
this.$fhcAlert.alertSuccess(this.$p.t('ui/gespeichert'));
})
.catch(error => {
if (error)
this.$fhcAlert.handleSystemError(error);
this.loading = false;
});
},
open(data) {
this.data = data ?? {
oe_kurzbz: null,
bezeichnung: '',
vondatum: null,
bisdatum: null,
studienplan_id: null
};
this.$api
.call(ApiFerien.getOe())
.then(result => {
this.oeList = result.data;
//this.loading = false;
}
)
.catch(error => {
if (error)
this.$fhcAlert.handleSystemError(error);
//this.loading = false;
});
this.getStudienplaene();
this.$api
.call(ApiFerien.getFerientypen())
.then(result => {
this.ferientypList = result.data;
}
)
.catch(error => {
if (error)
this.$fhcAlert.handleSystemError(error);
});
this.$refs.modal.show();
},
getStudienplaene() {
this.$api
.call(ApiFerien.getStudienplaene(this.data.oe_kurzbz, this.data.vondatum, this.data.bisdatum))
.then(result => {
this.studienplaeneList = result.data;
}
)
.catch(error => {
if (error)
this.$fhcAlert.handleSystemError(error);
});
},
preventCloseOnLoading(ev) {
if (this.loading)
ev.returnValue = false;
}
},
template: `
<core-form ref="form" class="stv-details-ferien-edit" @submit.prevent="save">
<bs-modal ref="modal" @hide-bs-modal="preventCloseOnLoading">
<form-validation></form-validation>
<fieldset :disabled="loading">
<form-input
type="DatePicker"
v-model="data.vondatum"
name="vondatum"
:label="$p.t('ferien/vondatum')"
:enable-time-picker="false"
text-input
format="dd.MM.yyyy"
auto-apply
>
</form-input>
<form-input
type="DatePicker"
v-model="data.bisdatum"
name="bisdatum"
:label="$p.t('ferien/bisdatum')"
:enable-time-picker="false"
text-input
format="dd.MM.yyyy"
auto-apply
>
</form-input>
<form-input
v-model="data.bezeichnung"
name="bezeichnung"
:label="$p.t('global/bezeichnung')"
>
</form-input>
<form-input
type="select"
v-model="data.oe_kurzbz"
name="oe_kurzbz"
:label="$p.t('lehre/organisationseinheit')"
@change="getStudienplaene"
>
<option v-for="oe in oeList" :key="oe.oe_kurzbz" :value="oe.oe_kurzbz">
{{ oe.organisationseinheittyp_kurzbz + ' ' + oe.bezeichnung }}
</option>
</form-input>
<form-input
type="select"
v-model="data.studienplan_id"
name="studienplan_id"
:label="$p.t('lehre/studienplan')"
>
<option :value="null">-- {{ $p.t('ui/keineAuswahl') }} --</option>
<option v-for="studienplan in studienplaeneList" :key="studienplan.studienplan_id" :value="studienplan.studienplan_id">
{{ studienplan.bezeichnung }}
</option>
</form-input>
<form-input
type="select"
v-model="data.ferientyp_kurzbz"
name="ferientyp_kurzbz"
:label="$p.t('ferien/ferientypKurzbz')"
>
<option :value="null">-- {{ $p.t('ui/keineAuswahl') }} --</option>
<option v-for="ferientyp in ferientypList" :key="ferientyp.ferientyp_kurzbz" :value="ferientyp.ferientyp_kurzbz">
{{ ferientyp.ferientyp_kurzbz }}
</option>
</form-input>
</fieldset>
<template #footer>
<button type="submit" class="btn btn-primary" :disabled="loading">
<i v-if="loading" class="fa fa-spinner fa-spin"></i>
{{ $p.t('ui/speichern') }}
</button>
</template>
</bs-modal>
</core-form>`
};
@@ -119,3 +119,64 @@ if ($result = @$db->db_query("SELECT conname FROM pg_constraint WHERE conname =
echo '<br>lehre.tbl_ferien: Primary Key tbl_ferien_pk (ferien_id) hinzugefügt';
}
}
if(!$result = @$db->db_query("SELECT oe_kurzbz FROM lehre.tbl_ferien LIMIT 1"))
{
$qry = "ALTER TABLE lehre.tbl_ferien
ADD COLUMN IF NOT EXISTS oe_kurzbz VARCHAR(32),
ADD COLUMN IF NOT EXISTS studienplan_id SMALLINT DEFAULT NULL,
ADD CONSTRAINT tbl_ferien_studienplan_fk
FOREIGN KEY (studienplan_id)
REFERENCES lehre.tbl_studienplan(studienplan_id)
ON UPDATE CASCADE ON DELETE RESTRICT,
ADD CONSTRAINT tbl_ferien_oe_kurzbz_fk
FOREIGN KEY (oe_kurzbz)
REFERENCES public.tbl_organisationseinheit(oe_kurzbz)
ON UPDATE CASCADE ON DELETE RESTRICT,
ADD COLUMN IF NOT EXISTS insertamum timestamp DEFAULT NOW(),
ADD COLUMN IF NOT EXISTS insertvon VARCHAR(32),
ADD COLUMN IF NOT EXISTS updateamum timestamp,
ADD COLUMN IF NOT EXISTS updatevon VARCHAR(32)";
if(!$db->db_query($qry))
echo '<strong>lehre.tbl_ferien: '.$db->db_last_error().'</strong><br>';
else
echo '<br>lehre.tbl_ferien columns oe_kurzbz, studienplan_id, insertamum, insertvon, updateamum, updatevon hinzugefuegt';
}
// Creates table lehre.tbl_ferientyp if it doesn't exist and grants privileges
if (!$result = @$db->db_query('SELECT 0 FROM lehre.tbl_ferientyp WHERE 0 = 1'))
{
$qry = 'CREATE TABLE lehre.tbl_ferientyp (
ferientyp_kurzbz VARCHAR(64),
beschreibung VARCHAR(256) NOT NULL,
mitarbeiter boolean NOT NULL,
studierende boolean NOT NULL,
lehre boolean NOT NULL
);
COMMENT ON TABLE lehre.tbl_ferientyp IS \'Typ-Tabelle zum Speichern von Informationen zu Ferien.\';
COMMENT ON COLUMN lehre.tbl_ferientyp.ferientyp_kurzbz IS \'Typ der Ferien.\';
COMMENT ON COLUMN lehre.tbl_ferientyp.mitarbeiter IS \'Ob die Ferien für MitarbeiterInnen relevant sind.\';
COMMENT ON COLUMN lehre.tbl_ferientyp.studierende IS \'Ob die Ferien für Studierende relevant sind.\';
COMMENT ON COLUMN lehre.tbl_ferientyp.lehre IS \'Ob Lehre in den Ferien verplant werden kann.\';
ALTER TABLE lehre.tbl_ferientyp ADD CONSTRAINT pk_tbl_ferientyp PRIMARY KEY (ferientyp_kurzbz);
ALTER TABLE lehre.tbl_ferien ADD COLUMN IF NOT EXISTS ferientyp_kurzbz VARCHAR(64) DEFAULT NULL;
ALTER TABLE lehre.tbl_ferien ADD CONSTRAINT tbl_lehre_ferien_ferientyp_kurzbz_fk FOREIGN KEY (ferientyp_kurzbz)
REFERENCES lehre.tbl_ferientyp (ferientyp_kurzbz) MATCH FULL
ON DELETE SET NULL ON UPDATE CASCADE;';
if (!$db->db_query($qry))
echo '<strong>lehre.tbl_ferientyp: '.$db->db_last_error().'</strong><br>';
else
echo '<br>lehre.tbl_ferientyp table created';
$qry = 'GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE lehre.tbl_ferientyp TO vilesci;';
if (!$db->db_query($qry))
echo '<strong>lehre.tbl_ferientyp: '.$db->db_last_error().'</strong><br>';
else
echo '<br>Granted privileges to <strong>vilesci</strong> on lehre.tbl_ferientyp';
}