mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-18 15:32:17 +00:00
Added GUI for adding Bismeldestichtag
This commit is contained in:
@@ -14,19 +14,23 @@ class Bismeldestichtag extends Auth_Controller
|
||||
{
|
||||
parent::__construct(
|
||||
array(
|
||||
'index' => 'admin:r'
|
||||
'index' => 'admin:r',
|
||||
'addBismeldestichtag' => 'admin:rw',
|
||||
'getStudiensemester' => 'admin:r'
|
||||
)
|
||||
);
|
||||
|
||||
// Loads WidgetLib
|
||||
$this->load->library('WidgetLib');
|
||||
|
||||
// Load models
|
||||
$this->load->model('codex/Bismeldestichtag_model', 'BismeldestichtagModel');
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
// Loads phrases system
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'global',
|
||||
'ui',
|
||||
'filter'
|
||||
'bismeldestichtag'
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -41,4 +45,64 @@ class Bismeldestichtag extends Auth_Controller
|
||||
{
|
||||
$this->load->view('codex/bismeldestichtag.php');
|
||||
}
|
||||
|
||||
public function getStudiensemester()
|
||||
{
|
||||
// load semester list
|
||||
$semList = array();
|
||||
$this->StudiensemesterModel->addSelect('studiensemester_kurzbz');
|
||||
$this->StudiensemesterModel->addOrder('start', 'DESC');
|
||||
$semRes = $this->StudiensemesterModel->load();
|
||||
|
||||
if (hasData($semRes))
|
||||
{
|
||||
$semList = getData($semRes);
|
||||
}
|
||||
|
||||
// load current semester
|
||||
$currSem = null;
|
||||
$semRes = $this->StudiensemesterModel->getAkt();
|
||||
|
||||
if (hasData($semRes))
|
||||
{
|
||||
$currSem = getData($semRes)[0]->studiensemester_kurzbz;
|
||||
}
|
||||
|
||||
// output data
|
||||
$this->outputJsonSuccess(
|
||||
array('semList' => $semList, 'currSem' => $currSem)
|
||||
);
|
||||
}
|
||||
|
||||
public function addBismeldestichtag()
|
||||
{
|
||||
// get request data
|
||||
$request = $this->getPostJSON();
|
||||
|
||||
// check request data
|
||||
if (!property_exists($request, 'meldestichtag') || isEmptyString($request->meldestichtag))
|
||||
$this->terminateWithJsonError('Error occured: Meldestichtag missing');
|
||||
if (!property_exists($request, 'studiensemester_kurzbz') || isEmptyString($request->studiensemester_kurzbz))
|
||||
$this->terminateWithJsonError('Error occured: Studiensemester missing');
|
||||
|
||||
$meldestichtag = $request->meldestichtag;
|
||||
$studiensemester_kurzbz = $request->studiensemester_kurzbz;
|
||||
|
||||
// check if Bismeldestichtag already exists
|
||||
$this->BismeldestichtagModel->addSelect('1');
|
||||
$bismeldestichtagRes = $this->BismeldestichtagModel->loadWhere(
|
||||
array('meldestichtag' => $meldestichtag, 'studiensemester_kurzbz' => $studiensemester_kurzbz)
|
||||
);
|
||||
|
||||
// return success if already exists
|
||||
if (hasData($bismeldestichtagRes))
|
||||
$this->outputJsonSuccess('Bismeldestichtag already exists');
|
||||
else
|
||||
{
|
||||
// insert new if Stichtag does not exist
|
||||
$this->outputJson($this->BismeldestichtagModel->insert(
|
||||
array('meldestichtag' => $request->meldestichtag, 'studiensemester_kurzbz' => $request->studiensemester_kurzbz)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Bismeldestichtag_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'bis.tbl_bismeldestichtag';
|
||||
$this->pk = 'meldestichtag_id';
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
$includesArray = array(
|
||||
'title' => 'Logs Viewer',
|
||||
'title' => 'Bismeldestichtage',
|
||||
'axios027' => true,
|
||||
'bootstrap5' => true,
|
||||
'fontawesome6' => true,
|
||||
@@ -8,34 +8,60 @@
|
||||
'filtercomponent' => true,
|
||||
'navigationcomponent' => true,
|
||||
'tabulator5' => true,
|
||||
'phrases' => array(
|
||||
'global' => array('mailAnXversandt'),
|
||||
'ui' => array('bitteEintragWaehlen')
|
||||
'customCSSs' => array(
|
||||
'public/css/components/verticalsplit.css'
|
||||
),
|
||||
'customJSModules' => array('public/js/apps/Bismeldestichtag/Bismeldestichtag.js')
|
||||
);
|
||||
|
||||
$this->load->view('templates/FHC-Header', $includesArray);
|
||||
?>
|
||||
|
||||
<!-- Load Studiensemester -->
|
||||
<div id="main">
|
||||
|
||||
<!-- Navigation component -->
|
||||
<core-navigation-cmpt v-bind:add-side-menu-entries="appSideMenuEntries"></core-navigation-cmpt>
|
||||
|
||||
<!-- fetch component -->
|
||||
<core-fetch-cmpt
|
||||
v-bind:api-function="fetchCmptApiFunction"
|
||||
v-bind:api-function-parameters="fetchCmptApiFunctionParams"
|
||||
v-bind:refresh="fetchCmptRefresh"
|
||||
@data-fetched="fetchCmptDataFetched">
|
||||
</core-fetch-cmpt>
|
||||
|
||||
<div id="content">
|
||||
<div>
|
||||
<!-- Filter component -->
|
||||
<core-filter-cmpt
|
||||
title="Bismeldestichtage verwalten"
|
||||
filter-type="Bismeldestichtag"
|
||||
:tabulator-options="bismeldestichtagTabulatorOptions"
|
||||
:tabulator-events="bismeldestichtagTabulatorEventHandlers"
|
||||
@nw-new-entry="newSideMenuEntryHandler">
|
||||
</core-filter-cmpt>
|
||||
<verticalsplit>
|
||||
<template #top>
|
||||
<!-- input fields -->
|
||||
<div class="input-group">
|
||||
<input type="date" class="form-control" name="meldestichtag" v-model="meldestichtag">
|
||||
<select class="form-control" name="studiensemester_kurzbz" v-model="currSem">
|
||||
<option v-for="sem in semList" :value="sem.studiensemester_kurzbz">
|
||||
{{ sem.studiensemester_kurzbz }}
|
||||
</option>
|
||||
</select>
|
||||
<div class="input-group-btn">
|
||||
<button type="button" class="btn btn-secondary" @click="handlerAddBismeldestichtag">
|
||||
<?php echo $this->p->t('bismeldestichtag', 'stichtagHinzufuegen') ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #bottom>
|
||||
<!-- Filter component -->
|
||||
<core-filter-cmpt
|
||||
title="<?php echo $this->p->t('bismeldestichtag', 'stichtageVerwalten') ?>"
|
||||
filter-type="Bismeldestichtag"
|
||||
:tabulator-options="bismeldestichtagTabulatorOptions"
|
||||
:tabulator-events="bismeldestichtagTabulatorEventHandlers"
|
||||
@nw-new-entry="newSideMenuEntryHandler">
|
||||
</core-filter-cmpt>
|
||||
</template>
|
||||
</verticalsplit>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $this->load->view('templates/FHC-Footer', $includesArray); ?>
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright (C) 2022 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/>.
|
||||
*/
|
||||
|
||||
import {CoreRESTClient} from '../../RESTClient.js';
|
||||
|
||||
//
|
||||
const CORE_BISMELDESTICHTAG_CMPT_TIMEOUT = 2000;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export const BismeldestichtagAPIs = {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
getStudiensemester: function() {
|
||||
return CoreRESTClient.get(
|
||||
'codex/Bismeldestichtag/getStudiensemester',
|
||||
null,
|
||||
{
|
||||
timeout: CORE_BISMELDESTICHTAG_CMPT_TIMEOUT
|
||||
}
|
||||
);
|
||||
},
|
||||
addBismeldestichtag: function(wsParams) {
|
||||
return CoreRESTClient.post(
|
||||
'codex/Bismeldestichtag/addBismeldestichtag',
|
||||
{
|
||||
meldestichtag: wsParams.meldestichtag,
|
||||
studiensemester_kurzbz: wsParams.studiensemester_kurzbz
|
||||
},
|
||||
{
|
||||
timeout: CORE_BISMELDESTICHTAG_CMPT_TIMEOUT
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -20,22 +20,108 @@ import {BismeldestichtagTabulatorEventHandlers} from './TabulatorSetup.js';
|
||||
|
||||
import {CoreFilterCmpt} from '../../components/filter/Filter.js';
|
||||
import {CoreNavigationCmpt} from '../../components/navigation/Navigation.js';
|
||||
import {CoreRESTClient} from '../../RESTClient.js';
|
||||
import {CoreFetchCmpt} from '../../components/Fetch.js';
|
||||
import {BismeldestichtagAPIs} from './API.js';
|
||||
import verticalsplit from '../../components/verticalsplit/verticalsplit.js';
|
||||
|
||||
const bismeldestichtagApp = Vue.createApp({
|
||||
data: function() {
|
||||
return {
|
||||
appSideMenuEntries: {},
|
||||
bismeldestichtagTabulatorOptions: BismeldestichtagTabulatorOptions,
|
||||
bismeldestichtagTabulatorEventHandlers: BismeldestichtagTabulatorEventHandlers
|
||||
bismeldestichtagTabulatorEventHandlers: BismeldestichtagTabulatorEventHandlers,
|
||||
meldestichtag: null, // date of Meldestichtag
|
||||
semList: null, // all Studiensemester for dropdown
|
||||
currSem: null, // selected Studiensemester
|
||||
fetchCmptApiFunction: {}, // api function call
|
||||
fetchCmptApiFunctionParams: null, // parameters for api function call
|
||||
fetchCmptDataFetched: null, // function to execute after call
|
||||
fetchCmptRefresh: true // for refreshing
|
||||
};
|
||||
},
|
||||
components: {
|
||||
CoreNavigationCmpt,
|
||||
CoreFilterCmpt
|
||||
CoreFilterCmpt,
|
||||
BismeldestichtagAPIs,
|
||||
CoreFetchCmpt,
|
||||
verticalsplit
|
||||
},
|
||||
created() {
|
||||
this.handlerStudiensemester();
|
||||
},
|
||||
methods: {
|
||||
newSideMenuEntryHandler: function(payload) {
|
||||
this.appSideMenuEntries = payload;
|
||||
},
|
||||
/**
|
||||
* Define Studiensemester call and method to be executed after the call
|
||||
*/
|
||||
handlerStudiensemester: function() {
|
||||
this.startFetchCmpt(
|
||||
BismeldestichtagAPIs.getStudiensemester,
|
||||
null,
|
||||
this.fetchCmptDataFetchedStudiensemester
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Define Bismeldestichtag call and method to be executed after the call
|
||||
*/
|
||||
handlerAddBismeldestichtag: function(event) {
|
||||
this.startFetchCmpt(
|
||||
BismeldestichtagAPIs.addBismeldestichtag,
|
||||
{
|
||||
meldestichtag: this.meldestichtag,
|
||||
studiensemester_kurzbz: this.currSem
|
||||
},
|
||||
this.fetchCmptDataFetchedAddBismeldestichtag
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Called after Studiensemester response is received
|
||||
*/
|
||||
fetchCmptDataFetchedStudiensemester: function(data) {
|
||||
if (CoreRESTClient.isError(data)) alert(CoreRESTClient.getError(data));
|
||||
if (CoreRESTClient.hasData(data))
|
||||
{
|
||||
let semRes = CoreRESTClient.getData(data);
|
||||
this.semList = semRes.semList;
|
||||
this.currSem = semRes.currSem;
|
||||
}
|
||||
else
|
||||
alert("No response data");
|
||||
},
|
||||
/**
|
||||
* Called after Bismeldestichtag response is received
|
||||
*/
|
||||
fetchCmptDataFetchedAddBismeldestichtag: function(data) {
|
||||
if (CoreRESTClient.isError(data))
|
||||
alert(CoreRESTClient.getError(data));
|
||||
else if (CoreRESTClient.hasData(data))
|
||||
{
|
||||
window.location.reload();
|
||||
alert("Successfully added Bismeldestichtag");
|
||||
}
|
||||
else
|
||||
alert("No response data");
|
||||
},
|
||||
/**
|
||||
* Used to start/refresh the FetchCmpt
|
||||
*/
|
||||
startFetchCmpt: function(apiFunction, apiFunctionParameters, dataFetchedCallback) {
|
||||
// Assign the function api of the FetchCmpt binded property
|
||||
this.fetchCmptApiFunction = apiFunction;
|
||||
|
||||
// In case a null value is provided set the parameters as an empty object
|
||||
if (apiFunctionParameters == null) apiFunctionParameters = {};
|
||||
|
||||
// Assign parameters to the FetchCmpt binded properties
|
||||
this.fetchCmptApiFunctionParams = apiFunctionParameters;
|
||||
// Assign data fetch callback to the FetchCmpt binded properties
|
||||
this.fetchCmptDataFetched = dataFetchedCallback;
|
||||
// Set the FetchCmpt binded property refresh to have the component to refresh
|
||||
// NOTE: this should be the last one to be called because it triggers the FetchCmpt to start to refresh
|
||||
this.fetchCmptRefresh === true ? this.fetchCmptRefresh = false : this.fetchCmptRefresh = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -23,13 +23,12 @@ export const BismeldestichtagTabulatorOptions = {
|
||||
layout: 'fitColumns',
|
||||
columns: [
|
||||
{title: 'ID', field: 'Id', headerFilter: true},
|
||||
{title: 'Meldestichtag', field: 'Meldestichtag', headerFilter: true},
|
||||
{title: 'Meldestichtag',field: 'Meldestichtag', headerFilter: true, formatter: function(cell){
|
||||
return cell.getValue().replace(/(.*)-(.*)-(.*)/, '$3.$2.$1');
|
||||
}
|
||||
},
|
||||
{title: 'Studiensemester', field: 'Studiensemester', headerFilter: true}
|
||||
],
|
||||
rowFormatter: function(row) {
|
||||
|
||||
let data = row.getData(); // get data for this row
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -39,7 +38,8 @@ export const BismeldestichtagTabulatorEventHandlers = [
|
||||
{
|
||||
event: "rowClick",
|
||||
handler: function(e, row) {
|
||||
alert(row.getData().Data);
|
||||
let data = row.getData();
|
||||
alert(data.Studiensemester + ': ' + data.Meldestichtag);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -18123,6 +18123,46 @@ array(
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'bismeldestichtag',
|
||||
'phrase' => 'stichtagHinzufuegen',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Meldestichtag hinzufügen',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'Add report target date',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'bismeldestichtag',
|
||||
'phrase' => 'stichtageVerwalten',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Bismeldestichtage verwalten',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'Manage report target dates',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user