mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 08:34:29 +00:00
tempus pre-alpha version
This commit is contained in:
@@ -1,171 +0,0 @@
|
||||
<?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');
|
||||
|
||||
class Kalender extends FHCAPI_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Object initialization
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
parent::__construct([
|
||||
'getRoomplan' => self::PERM_LOGGED,
|
||||
'Stunden' => self::PERM_LOGGED,
|
||||
'Reservierungen' => self::PERM_LOGGED,
|
||||
'getStundenplan' => self::PERM_LOGGED,
|
||||
'getLehreinheitStudiensemester' => self::PERM_LOGGED,
|
||||
'updateKalenderEvent' => 'lehre/lvplan:rw',
|
||||
'addKalenderEvent' => 'lehre/lvplan:rw'
|
||||
]);
|
||||
|
||||
$this->load->library('LogLib');
|
||||
$this->loglib->setConfigs(array(
|
||||
'classIndex' => 5,
|
||||
'functionIndex' => 5,
|
||||
'lineIndex' => 4,
|
||||
'dbLogType' => 'API', // required
|
||||
'dbExecuteUser' => 'RESTful API'
|
||||
));
|
||||
|
||||
$this->uid = getAuthUID();
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
//load models
|
||||
//$this->load->model('ressource/Stundenplan_model', 'StundenplanModel');
|
||||
//$this->load->model('ressource/Reservierung_model', 'ReservierungModel');
|
||||
|
||||
$this->load->library('KalenderLib');
|
||||
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* fetches Stunden layout from database
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function Stunden()
|
||||
{
|
||||
$this->load->model('ressource/Stunde_model', 'StundeModel');
|
||||
|
||||
$stunden = $this->StundeModel->load();
|
||||
|
||||
$stunden = $this->getDataOrTerminateWithError($stunden);
|
||||
|
||||
$this->terminateWithSuccess($stunden);
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches stundenplan events from a Room and start/end date
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function getRoomplan()
|
||||
{
|
||||
|
||||
// form validation
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_data($_GET);
|
||||
$this->form_validation->set_rules('start_date',"start_date","required");
|
||||
$this->form_validation->set_rules('end_date',"end_date","required");
|
||||
$this->form_validation->set_rules('ort_kurzbz',"ort_kurzbz","required");
|
||||
if($this->form_validation->run() === FALSE) $this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
// storing the get parameter in local variables
|
||||
$start_date = $this->input->get('start_date', TRUE);
|
||||
$end_date = $this->input->get('end_date', TRUE);
|
||||
$ort_kurzbz = $this->input->get('ort_kurzbz', TRUE);
|
||||
|
||||
$stundenplan_data =$this->kalenderlib->getRoomData($ort_kurzbz, $start_date, $end_date);
|
||||
|
||||
$this->terminateWithSuccess($stundenplan_data);
|
||||
}
|
||||
|
||||
public function updateKalenderEvent()
|
||||
{
|
||||
// form validation
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_data($_POST);
|
||||
$this->form_validation->set_rules('kalender_id',"kalender_id","required");
|
||||
$this->form_validation->set_rules('ort_kurzbz',"ort_kurzbz","required");
|
||||
$this->form_validation->set_rules('start_date',"start_date","required");
|
||||
$this->form_validation->set_rules('end_date',"end_date","optional");
|
||||
|
||||
if($this->form_validation->run() === FALSE) $this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
// storing the get parameter in local variables
|
||||
$kalender_id = $this->input->post('kalender_id', TRUE);
|
||||
$ort_kurzbz = $this->input->post('ort_kurzbz', TRUE);
|
||||
$start_date = $this->input->post('start_date', TRUE);
|
||||
$end_date = $this->input->post('end_date', TRUE);
|
||||
|
||||
|
||||
// Was passiert hier?
|
||||
// Raumänderung, Tagesänderung, Start / Ende Zeit korrektur
|
||||
// Ist das alles ein Endpunkt?
|
||||
$stundenplan_data =$this->kalenderlib->updateKalenderEvent($this->uid,$kalender_id, $ort_kurzbz, $start_date, $end_date);
|
||||
|
||||
$this->terminateWithSuccess($stundenplan_data);
|
||||
}
|
||||
|
||||
public function addKalenderEvent()
|
||||
{
|
||||
// form validation
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_data($_POST);
|
||||
$this->form_validation->set_rules('lehreinheit_id',"kalender_id","required");
|
||||
$this->form_validation->set_rules('ort_kurzbz',"ort_kurzbz","required");
|
||||
$this->form_validation->set_rules('start_date',"start_date","required");
|
||||
$this->form_validation->set_rules('end_date',"end_date","required");
|
||||
|
||||
if($this->form_validation->run() === FALSE) $this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
// storing the get parameter in local variables
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id', TRUE);
|
||||
$ort_kurzbz = $this->input->post('ort_kurzbz', TRUE);
|
||||
$start_date = $this->input->post('start_date', TRUE);
|
||||
$end_date = $this->input->post('end_date', TRUE);
|
||||
|
||||
$this->kalenderlib->addKalenderEvent($this->uid, $ort_kurzbz, $start_date, $end_date, $lehreinheit_id);
|
||||
|
||||
$this->terminateWithSuccess();
|
||||
}
|
||||
|
||||
// gets the reservierungen of a room if the ort_kurzbz parameter is supplied otherwise gets the reservierungen of the stundenplan of a student
|
||||
public function Reservierungen($ort_kurzbz = null)
|
||||
{
|
||||
$this->terminateWithSuccess();
|
||||
}
|
||||
|
||||
public function getLehreinheitStudiensemester($lehreinheit_id)
|
||||
{
|
||||
$this->load->model('education/Lehreinheit_model', 'LehreinheitModel');
|
||||
$this->LehreinheitModel->addSelect(["studiensemester_kurzbz"]);
|
||||
$result = $this->LehreinheitModel->load($lehreinheit_id);
|
||||
$result = current($this->getDataOrTerminateWithError($result))->studiensemester_kurzbz;
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
<?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');
|
||||
|
||||
class Tempus extends FHCAPI_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Object initialization
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
parent::__construct([
|
||||
'getCourses' => self::PERM_LOGGED,
|
||||
]);
|
||||
|
||||
$this->load->library('LogLib');
|
||||
$this->loglib->setConfigs(array(
|
||||
'classIndex' => 5,
|
||||
'functionIndex' => 5,
|
||||
'lineIndex' => 4,
|
||||
'dbLogType' => 'API', // required
|
||||
'dbExecuteUser' => 'RESTful API'
|
||||
));
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
//load models
|
||||
//$this->load->model('ressource/Stundenplan_model', 'StundenplanModel');
|
||||
//$this->load->model('ressource/Reservierung_model', 'ReservierungModel');
|
||||
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
|
||||
/**
|
||||
* fetches courses
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function getCourses()
|
||||
{
|
||||
// form validation
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_data($_GET);
|
||||
$this->form_validation->set_rules('searchfilter',"searchfilter","required");
|
||||
if($this->form_validation->run() === FALSE) $this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
// storing the get parameter in local variables
|
||||
$searchfilter = $this->input->get('searchfiler', TRUE);
|
||||
|
||||
// TODO implement Loading Data
|
||||
$course_data = array(
|
||||
array(
|
||||
'lehreinheit_id'=>'1',
|
||||
'bezeichnung' => 'Englisch 1',
|
||||
'studiengang_kurzbz' => 'BMR',
|
||||
'semester' => '1',
|
||||
'kurzbz' => 'ENG',
|
||||
'lektoren' => array('OesterAn','KindlMa')
|
||||
),
|
||||
array(
|
||||
'lehreinheit_id'=>'2',
|
||||
'bezeichnung' => 'Mahtematik 1',
|
||||
'studiengang_kurzbz' => 'BMR',
|
||||
'semester' => '1',
|
||||
'kurzbz' => 'MAT',
|
||||
'lektoren' => array('BamberHa')
|
||||
)
|
||||
);
|
||||
|
||||
$this->terminateWithSuccess($course_data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH'))
|
||||
exit('No direct script access allowed');
|
||||
|
||||
|
||||
class Config extends FHCAPI_Controller
|
||||
{
|
||||
private $_ci;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'get' => ['admin:r', 'assistenz:r'],
|
||||
'getHeader' => ['admin:r', 'assistenz:r'],
|
||||
'set' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
|
||||
// Load Phrases
|
||||
$this->loadPhrases([
|
||||
'global',
|
||||
]);
|
||||
|
||||
$this->_ci = &get_instance();
|
||||
$this->_ci->load->model('ressource/Kalenderstatus_model', 'KalenderStatusModel');
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
$visible_status = $this->_ci->KalenderStatusModel->load();
|
||||
|
||||
$visible_status = getData($visible_status);
|
||||
|
||||
$config['visible_status'] = [
|
||||
"type" => "select",
|
||||
"label" => $this->p->t('ui', 'status'),
|
||||
"multiple" => true,
|
||||
"value" => 'all'
|
||||
];
|
||||
foreach ($visible_status as $status)
|
||||
{
|
||||
$config['visible_status']['options'][$status->status_kurzbz] = $status->status_kurzbz;
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($config);
|
||||
}
|
||||
public function getHeader()
|
||||
{
|
||||
$visible_status = $this->_ci->KalenderStatusModel->load();
|
||||
|
||||
$visible_status = getData($visible_status);
|
||||
|
||||
|
||||
$config['visible_status']['all'] = 'all';
|
||||
|
||||
foreach ($visible_status as $status)
|
||||
{
|
||||
$config['visible_status'][$status->status_kurzbz] = $status->bezeichnung;
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($config);
|
||||
}
|
||||
|
||||
public function set()
|
||||
{
|
||||
|
||||
$this->terminateWithSuccess();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Coursepicker extends FHCAPI_Controller
|
||||
{
|
||||
private $_ci;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'search' => self::PERM_LOGGED,
|
||||
]);
|
||||
|
||||
$this->_ci = &get_instance();
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->_ci->load->model('education/lehreinheit_model', 'LehreinheitModel');
|
||||
$this->_ci->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel');
|
||||
|
||||
|
||||
$this->loadPhrases([
|
||||
'ui'
|
||||
]);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$query = $this->input->get('query');
|
||||
if (is_null($query))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$query_words = explode(' ', $query);
|
||||
|
||||
//TODO Where weiter anpassen z.B. Fachbereich
|
||||
$this->_ci->LehreinheitModel->addSelect('tbl_lehreinheit.lehreinheit_id,
|
||||
tbl_lehreinheit.unr,
|
||||
tbl_lehreinheit.lvnr,
|
||||
tbl_lehreinheit.lehrfach_id,
|
||||
lehrfach.kurzbz AS lehrfach,
|
||||
lehrfach.bezeichnung AS lehrfach_bez,
|
||||
lehrfach.farbe AS lehrfach_farbe,
|
||||
tbl_lehreinheit.lehrform_kurzbz AS lehrform,
|
||||
lema.mitarbeiter_uid AS lektor_uid,
|
||||
tbl_mitarbeiter.kurzbz AS lektor,
|
||||
tbl_studiengang.studiengang_kz,
|
||||
upper(tbl_studiengang.typ::character varying::text || tbl_studiengang.kurzbz::text) AS studiengang,
|
||||
lvb.semester,
|
||||
lvb.verband,
|
||||
lvb.gruppe,
|
||||
lvb.gruppe_kurzbz,
|
||||
tbl_lehreinheit.raumtyp,
|
||||
tbl_lehreinheit.raumtypalternativ,
|
||||
tbl_lehreinheit.stundenblockung,
|
||||
tbl_lehreinheit.wochenrythmus,
|
||||
lema.semesterstunden,
|
||||
lema.planstunden,
|
||||
tbl_lehreinheit.start_kw,
|
||||
tbl_lehreinheit.anmerkung,
|
||||
tbl_lehreinheit.studiensemester_kurzbz');
|
||||
|
||||
$this->_ci->LehreinheitModel->addJoin('lehre.tbl_lehreinheitmitarbeiter lema', 'tbl_lehreinheit.lehreinheit_id = lema.lehreinheit_id');
|
||||
$this->_ci->LehreinheitModel->addJoin('lehre.tbl_lehreinheitgruppe lvb', 'tbl_lehreinheit.lehreinheit_id = lvb.lehreinheit_id');
|
||||
$this->_ci->LehreinheitModel->addJoin('public.tbl_studiengang', 'lvb.studiengang_kz = tbl_studiengang.studiengang_kz');
|
||||
$this->_ci->LehreinheitModel->addJoin('lehre.tbl_lehrveranstaltung lehrfach', 'tbl_lehreinheit.lehrfach_id = lehrfach.lehrveranstaltung_id');
|
||||
$this->_ci->LehreinheitModel->addJoin('public.tbl_mitarbeiter', 'lema.mitarbeiter_uid = tbl_mitarbeiter.mitarbeiter_uid');
|
||||
$this->_ci->LehreinheitModel->addJoin('lehre.tbl_lehrform', 'tbl_lehrform.lehrform_kurzbz = tbl_lehreinheit.lehrform_kurzbz');
|
||||
|
||||
$this->_ci->MitarbeiterModel->db->group_start();
|
||||
|
||||
foreach ($query_words as $word)
|
||||
{
|
||||
$this->_ci->LehreinheitModel->db->group_start();
|
||||
$this->_ci->LehreinheitModel->db->where('lema.mitarbeiter_uid ILIKE', "%" . $word . "%");
|
||||
$this->_ci->LehreinheitModel->db->or_where('lvb.gruppe_kurzbz ILIKE', "%" . $word . "%");
|
||||
$this->_ci->LehreinheitModel->db->or_where('tbl_studiengang.kurzbzlang ILIKE', "%" . $word . "%");
|
||||
$this->_ci->LehreinheitModel->db->or_where('lvb.verband ILIKE', "%" . $word . "%");
|
||||
$this->_ci->LehreinheitModel->db->or_where('lvb.gruppe ILIKE', "%" . $word . "%");
|
||||
$this->_ci->LehreinheitModel->db->or_where('lehrfach.bezeichnung ILIKE', "%" . $word . "%");
|
||||
|
||||
if (is_numeric($word))
|
||||
{
|
||||
$this->_ci->LehreinheitModel->db->or_where('tbl_studiengang.studiengang_kz', $word);
|
||||
$this->_ci->LehreinheitModel->db->or_where('lvb.semester', $word);
|
||||
}
|
||||
$this->_ci->LehreinheitModel->db->group_end();
|
||||
|
||||
}
|
||||
$this->_ci->LehreinheitModel->db->group_end();
|
||||
$this->_ci->LehreinheitModel->db->where('tbl_lehreinheit.studiensemester_kurzbz = \'SS2025\'');
|
||||
$this->_ci->LehreinheitModel->db->where(array('tbl_lehrform.verplanen' => true));
|
||||
|
||||
$result = $this->_ci->LehreinheitModel->load();
|
||||
|
||||
$this->terminateWithSuccess(hasData($result) ? getData($result) : array());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
<?php
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Kalender extends FHCAPI_Controller
|
||||
{
|
||||
|
||||
private $_ci;
|
||||
const ALLOWED_PLAN_FILTER = ['ort', 'uid', 'stg'];
|
||||
const ALLOWED_ROOM_FILTER = ['lehreinheit_id', 'kalender_id'];
|
||||
|
||||
const ALLOWED_TO_UPDATE = ['start_time', 'end_time', 'ort_kurzbz'];
|
||||
/**
|
||||
* Object initialization
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
parent::__construct([
|
||||
'getStunden' => self::PERM_LOGGED,
|
||||
'getPlan' => self::PERM_LOGGED,
|
||||
'getPlanNew' => self::PERM_LOGGED,
|
||||
'getPlanByOrt' => self::PERM_LOGGED,
|
||||
'getRaumvorschlag' => self::PERM_LOGGED,
|
||||
'getZeitwuensche' => self::PERM_LOGGED,
|
||||
'getZeitsperren' => self::PERM_LOGGED,
|
||||
'updateKalenderEvent' => 'lehre/lvplan:rw',
|
||||
'addKalenderEvent' => 'lehre/lvplan:rw'
|
||||
]);
|
||||
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
$this->_ci->load->library('LogLib');
|
||||
$this->_ci->load->library('form_validation');
|
||||
$this->_ci->load->library('KalenderLib');
|
||||
$this->loadPhrases([
|
||||
'ui'
|
||||
]);
|
||||
|
||||
|
||||
$this->_ci->loglib->setConfigs(array(
|
||||
'classIndex' => 5,
|
||||
'functionIndex' => 5,
|
||||
'lineIndex' => 4,
|
||||
'dbLogType' => 'API', // required
|
||||
'dbExecuteUser' => 'RESTful API'
|
||||
));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
/**
|
||||
* fetches Stunden layout from database
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function getStunden()
|
||||
{
|
||||
$this->load->model('ressource/Stunde_model', 'StundeModel');
|
||||
|
||||
$this->_ci->StundeModel->addOrder('stunde', 'ASC');
|
||||
$stunden = $this->_ci->StundeModel->load();
|
||||
|
||||
$stunden = $this->getDataOrTerminateWithError($stunden);
|
||||
|
||||
$this->terminateWithSuccess($stunden);
|
||||
}
|
||||
public function getPlan()
|
||||
{
|
||||
$this->_ci->form_validation->set_data($_GET);
|
||||
$this->_ci->form_validation->set_rules('start_date',"start_date","required");
|
||||
$this->_ci->form_validation->set_rules('end_date',"end_date","required");
|
||||
|
||||
if($this->_ci->form_validation->run() === FALSE)
|
||||
$this->terminateWithValidationErrors($this->_ci->form_validation->error_array());
|
||||
|
||||
$start_date = $this->_ci->input->get('start_date', TRUE);
|
||||
$end_date = $this->_ci->input->get('end_date', TRUE);
|
||||
|
||||
$filter = $this->_checkFilter(self::ALLOWED_PLAN_FILTER);
|
||||
|
||||
$stundenplan_data = $this->_ci->kalenderlib->getPlan(
|
||||
$start_date,
|
||||
$end_date,
|
||||
isset($filter->ort) ? $filter->ort : null,
|
||||
isset($filter->uid) ? $filter->uid : null,
|
||||
isset($filter->stg) ? $filter->stg : null
|
||||
);
|
||||
|
||||
$this->terminateWithSuccess($stundenplan_data);
|
||||
}
|
||||
|
||||
public function getPlanNew()
|
||||
{
|
||||
$this->_ci->form_validation->set_data($_GET);
|
||||
$this->_ci->form_validation->set_rules('start_date',"start_date","required");
|
||||
$this->_ci->form_validation->set_rules('end_date',"end_date","required");
|
||||
|
||||
if($this->_ci->form_validation->run() === FALSE)
|
||||
$this->terminateWithValidationErrors($this->_ci->form_validation->error_array());
|
||||
|
||||
$start_date = $this->_ci->input->get('start_date', TRUE);
|
||||
$end_date = $this->_ci->input->get('end_date', TRUE);
|
||||
|
||||
$filter = $this->_checkFilter(self::ALLOWED_PLAN_FILTER);
|
||||
|
||||
$stundenplan_data = $this->_ci->kalenderlib->getPlanNew(
|
||||
$start_date,
|
||||
$end_date,
|
||||
isset($filter->ort) ? $filter->ort : null,
|
||||
isset($filter->uid) ? $filter->uid : null,
|
||||
isset($filter->stg) ? $filter->stg : null
|
||||
);
|
||||
|
||||
$this->terminateWithSuccess($stundenplan_data);
|
||||
}
|
||||
|
||||
public function getPlanByOrt($start_date = null, $end_date = null, $ort = null)
|
||||
{
|
||||
if (!isset($start_date) || !isset($end_date) || !isset($ort))
|
||||
{
|
||||
$this->_ci->form_validation->set_data($_GET);
|
||||
$this->_ci->form_validation->set_rules('start_date',"start_date","required");
|
||||
$this->_ci->form_validation->set_rules('end_date',"end_date","required");
|
||||
$this->_ci->form_validation->set_rules('ort',"ort","required");
|
||||
if($this->_ci->form_validation->run() === FALSE)
|
||||
$this->terminateWithValidationErrors($this->_ci->form_validation->error_array());
|
||||
|
||||
$start_date = $this->_ci->input->get('start_date', TRUE);
|
||||
$end_date = $this->_ci->input->get('end_date', TRUE);
|
||||
$ort = $this->_ci->input->get('ort', TRUE);
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($this->_ci->kalenderlib->getPlanByOrt($start_date, $end_date, $ort));
|
||||
}
|
||||
|
||||
public function getZeitsperren()
|
||||
{
|
||||
$this->_ci->form_validation->set_data($_GET);
|
||||
$this->_ci->form_validation->set_rules('start_date',"start_date","required");
|
||||
$this->_ci->form_validation->set_rules('end_date',"end_date","required");
|
||||
$this->_ci->form_validation->set_rules('emp',"emp","required");
|
||||
if($this->_ci->form_validation->run() === FALSE)
|
||||
$this->terminateWithValidationErrors($this->_ci->form_validation->error_array());
|
||||
|
||||
$start_date = $this->_ci->input->get('start_date', TRUE);
|
||||
$end_date = $this->_ci->input->get('end_date', TRUE);
|
||||
$emp = $this->_ci->input->get('emp', TRUE);
|
||||
|
||||
$stundenplan_data = $this->_ci->kalenderlib->getZeitsperren($start_date, $end_date, $emp);
|
||||
|
||||
$this->terminateWithSuccess($stundenplan_data);
|
||||
}
|
||||
|
||||
public function getZeitwuensche()
|
||||
{
|
||||
$this->_ci->form_validation->set_data($_GET);
|
||||
$this->_ci->form_validation->set_rules('start_date',"start_date","required");
|
||||
$this->_ci->form_validation->set_rules('end_date',"end_date","required");
|
||||
$this->_ci->form_validation->set_rules('emp',"emp","required");
|
||||
|
||||
if($this->_ci->form_validation->run() === FALSE)
|
||||
$this->terminateWithValidationErrors($this->_ci->form_validation->error_array());
|
||||
|
||||
$start_date = $this->_ci->input->get('start_date', TRUE);
|
||||
$end_date = $this->_ci->input->get('end_date', TRUE);
|
||||
$emp = $this->_ci->input->get('emp', TRUE);
|
||||
|
||||
$stundenplan_data = $this->_ci->kalenderlib->getZeitwuensche($start_date, $end_date, $emp);
|
||||
|
||||
$this->terminateWithSuccess($stundenplan_data);
|
||||
}
|
||||
|
||||
public function updateKalenderEvent()
|
||||
{
|
||||
$this->_ci->form_validation->set_data($_POST);
|
||||
$this->_ci->form_validation->set_rules('kalender_id',"kalender_id","required");
|
||||
|
||||
if($this->_ci->form_validation->run() === FALSE)
|
||||
$this->terminateWithValidationErrors($this->_ci->form_validation->error_array());
|
||||
|
||||
$updateFields = $this->_checkUpdate($this->_ci->input->post('updatedInfos', TRUE));
|
||||
$kalender_id = $this->_ci->input->post('kalender_id', TRUE);
|
||||
|
||||
if (isset($updateFields->ort_kurzbz) && !isEmptyString($updateFields->ort_kurzbz))
|
||||
{
|
||||
$result = $this->_ci->kalenderlib->updateOrt($kalender_id, $updateFields->ort_kurzbz);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result));
|
||||
}
|
||||
|
||||
if (isset($updateFields->start_time) || isset($updateFields->end_time))
|
||||
{
|
||||
$result = $this->_ci->kalenderlib->updateZeit($kalender_id, $updateFields->start_time, $updateFields->end_time);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result));
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess('Erfolgreich');
|
||||
}
|
||||
|
||||
public function getRaumvorschlag()
|
||||
{
|
||||
$this->_ci->form_validation->set_data($_GET);
|
||||
$this->_ci->form_validation->set_rules('start_date',"start_date","required");
|
||||
$this->_ci->form_validation->set_rules('end_date',"end_date","required");
|
||||
|
||||
if($this->_ci->form_validation->run() === FALSE)
|
||||
$this->terminateWithValidationErrors($this->_ci->form_validation->error_array());
|
||||
|
||||
$start_date = $this->_ci->input->get('start_date', TRUE);
|
||||
$end_date = $this->_ci->input->get('end_date', TRUE);
|
||||
|
||||
$filter = $this->_checkFilter(self::ALLOWED_ROOM_FILTER);
|
||||
|
||||
if (isset($filter->lehreinheit_id))
|
||||
{
|
||||
$result = $this->_ci->kalenderlib->getRaumvorschlagByLehreinheitID(
|
||||
$start_date,
|
||||
$end_date,
|
||||
$filter->lehreinheit_id
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($filter->kalender_id))
|
||||
{
|
||||
$result = $this->_ci->kalenderlib->getRaumvorschlagByKalenderID(
|
||||
$start_date,
|
||||
$end_date,
|
||||
$filter->kalender_id
|
||||
);
|
||||
}
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result));
|
||||
|
||||
$this->terminateWithSuccess(getData($result));
|
||||
}
|
||||
|
||||
public function addKalenderEvent()
|
||||
{
|
||||
$this->_ci->form_validation->set_data($_POST);
|
||||
$this->_ci->form_validation->set_rules('lehreinheit_id',"lehreinheit_id","required");
|
||||
$this->_ci->form_validation->set_rules('start_date',"start_date","required");
|
||||
$this->_ci->form_validation->set_rules('end_date',"end_date","required");
|
||||
|
||||
if($this->_ci->form_validation->run() === FALSE)
|
||||
$this->terminateWithValidationErrors($this->_ci->form_validation->error_array());
|
||||
|
||||
$lehreinheit_id = $this->_ci->input->post('lehreinheit_id', TRUE);
|
||||
$ort_kurzbz = $this->_ci->input->post('ort_kurzbz', TRUE);
|
||||
$start_date = $this->_ci->input->post('start_date', TRUE);
|
||||
$end_date = $this->_ci->input->post('end_date', TRUE);
|
||||
|
||||
|
||||
$result = $this->_ci->kalenderlib->addKalenderEvent($start_date, $end_date, $lehreinheit_id, $ort_kurzbz);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result));
|
||||
|
||||
$this->terminateWithSuccess('Erfolgreich');
|
||||
}
|
||||
|
||||
private function _checkFilter($filters)
|
||||
{
|
||||
$filter_valid = true;
|
||||
$filter_object = new stdClass();
|
||||
foreach ($filters as $filter)
|
||||
{
|
||||
if ($this->_ci->input->get($filter))
|
||||
{
|
||||
$filter_valid = true;
|
||||
$filter_object->$filter = $this->_ci->input->get($filter);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$filter_valid)
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
return $filter_object;
|
||||
}
|
||||
|
||||
private function _checkUpdate($updateInfos)
|
||||
{
|
||||
$update_valid = false;
|
||||
$update_object = new stdClass();
|
||||
foreach (self::ALLOWED_TO_UPDATE as $filter)
|
||||
{
|
||||
if (isset($updateInfos[$filter]))
|
||||
{
|
||||
$update_valid = true;
|
||||
$update_object->$filter = $updateInfos[$filter];
|
||||
}
|
||||
}
|
||||
|
||||
if (!$update_valid)
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
|
||||
return $update_object;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class MigrateKalender extends CLI_Controller
|
||||
class MigrateKalender extends Auth_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -16,7 +16,7 @@ class MigrateKalender extends CLI_Controller
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
parent::__construct(array('index' => ['admin:rw']));
|
||||
|
||||
$this->load->model('ressource/Kalender_model', 'KalenderModel');
|
||||
$this->load->model('ressource/Kalender_Lehreinheit_model', 'KalenderLehreinheitModel');
|
||||
@@ -27,21 +27,65 @@ class MigrateKalender extends CLI_Controller
|
||||
/**
|
||||
* Everything has a beginning
|
||||
*/
|
||||
public function index()
|
||||
public function index($von = null, $bis = null)
|
||||
{
|
||||
$von = date('Y-m-d') // TODO
|
||||
$bis = date('Y-m-d') // TODO
|
||||
|
||||
$db = new DB_Model();
|
||||
$stpldevsql = '
|
||||
SELECT *,
|
||||
(SELECT beginn FROM lehre.tbl_stunde WHERE stunde=tbl_stundenplandev.stunde) as beginn,
|
||||
(SELECT ende FROM lehre.tbl_stunde WHERE stunde=tbl_stundenplandev.stunde) as ende
|
||||
FROM
|
||||
lehre.tbl_stundenplandev WHERE datum>=? and datum<=? ORDER BY datum, stunde, unr';
|
||||
|
||||
$stpldev = $db->execReadOnlyQuery($stpldevsql, array($von, $bis));
|
||||
if (hasData($stpldev))
|
||||
$stpldevsql = '
|
||||
WITH eindeutige_stunden AS (
|
||||
SELECT DISTINCT unr, datum, stunde
|
||||
FROM lehre.tbl_stundenplandev
|
||||
WHERE datum >= ? AND datum <= ?
|
||||
),
|
||||
block_keys AS (
|
||||
SELECT
|
||||
unr,
|
||||
datum,
|
||||
stunde,
|
||||
stunde - ROW_NUMBER() OVER (PARTITION BY unr, datum ORDER BY stunde) AS block_nr
|
||||
FROM eindeutige_stunden
|
||||
),
|
||||
blocks AS (
|
||||
SELECT
|
||||
bk.unr,
|
||||
bk.datum,
|
||||
bk.block_nr,
|
||||
MIN(bk.stunde) AS stunde_von,
|
||||
MAX(bk.stunde) AS stunde_bis,
|
||||
MIN(sp.lehreinheit_id) AS lehreinheit_id,
|
||||
MIN(sp.ort_kurzbz) AS ort_kurzbz,
|
||||
array_agg(sp.stundenplandev_id ORDER BY bk.stunde) AS stundenplandev_ids,
|
||||
MIN(sp.insertamum) AS insertamum,
|
||||
(array_agg(sp.insertvon ORDER BY sp.insertamum ASC))[1] AS insertvon,
|
||||
MAX(sp.updateamum) AS updateamum,
|
||||
(array_agg(sp.updatevon ORDER BY sp.updateamum DESC))[1] AS updatevon
|
||||
FROM block_keys bk JOIN lehre.tbl_stundenplandev sp ON sp.unr = bk.unr AND sp.datum = bk.datum AND sp.stunde = bk.stunde
|
||||
WHERE sp.datum >= ? AND sp.datum <= ?
|
||||
GROUP BY bk.unr, bk.datum, bk.block_nr
|
||||
)
|
||||
SELECT
|
||||
b.stundenplandev_ids,
|
||||
b.unr,
|
||||
b.datum,
|
||||
b.block_nr,
|
||||
b.lehreinheit_id,
|
||||
b.ort_kurzbz,
|
||||
b.datum + stundevon.beginn AS von,
|
||||
b.datum + stundebis.ende AS bis,
|
||||
b.insertamum,
|
||||
b.insertvon,
|
||||
b.updateamum,
|
||||
b.updatevon
|
||||
FROM blocks b
|
||||
JOIN lehre.tbl_stunde stundevon ON stundevon.stunde = b.stunde_von
|
||||
JOIN lehre.tbl_stunde stundebis ON stundebis.stunde = b.stunde_bis
|
||||
ORDER BY b.datum, b.unr, b.block_nr;';
|
||||
|
||||
$stpldev = $db->execReadOnlyQuery($stpldevsql, array($von, $bis, $von, $bis));
|
||||
|
||||
|
||||
if (hasData($stpldev))
|
||||
{
|
||||
// Pruefen ob der Eintrag schon in Sync Tabelle vorhanden ist
|
||||
// Wenn neuere Änderungen vorhanden dann Update
|
||||
@@ -51,12 +95,39 @@ class MigrateKalender extends CLI_Controller
|
||||
// in der neuen Tabelle auch archivieren oder loeschen
|
||||
|
||||
$data = getData($stpldev);
|
||||
foreach($data as $rowstpl)
|
||||
foreach($data as $block)
|
||||
{
|
||||
$SyncResult = $this->SyncModel->loadWhere(
|
||||
array('stundenplandev_id' => $rowstpl->stundenplandev_id)
|
||||
);
|
||||
if(hasData($SyncResult))
|
||||
$this->SyncModel->db->where_in('stundenplandev_id', $block->stundenplandev_ids);
|
||||
$sync_result = $this->SyncModel->load();
|
||||
|
||||
if (!hasData($sync_result))
|
||||
{
|
||||
$kalender_id = $this->_insertKalender($block);
|
||||
if ($kalender_id)
|
||||
{
|
||||
$this->_insertSync($block->stundenplandev_ids, $kalender_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$syncData = getData($sync_result);
|
||||
$kalender_id = $syncData[0]->kalender_id;
|
||||
$last_sync = $syncData[0]->lastupdate;
|
||||
$synced_ids = array_column($syncData, 'stundenplandev_id');
|
||||
|
||||
if ($block->updateamum > $last_sync)
|
||||
{
|
||||
$this->_updateKalender($kalender_id, $block);
|
||||
$this->_updateSync($synced_ids, $kalender_id);
|
||||
}
|
||||
|
||||
$fehlende = array_diff($block->stundenplandev_ids, $synced_ids);
|
||||
if (!empty($fehlende))
|
||||
{
|
||||
$this->_insertSync($fehlende, $kalender_id);
|
||||
}
|
||||
}
|
||||
/*if(hasData($SyncResult))
|
||||
{
|
||||
//bereits vorhanden
|
||||
// TODO Update
|
||||
@@ -115,8 +186,89 @@ class MigrateKalender extends CLI_Controller
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function _insertKalender($block)
|
||||
{
|
||||
$result = $this->KalenderModel->insert(
|
||||
array (
|
||||
'von' => $block->von,
|
||||
'bis' => $block->bis,
|
||||
'typ' => 'lehreinheit',
|
||||
'status_kurzbz'=> 'visible_student',
|
||||
'insertamum' => $block->insertamum,
|
||||
'insertvon' => $block->insertvon,
|
||||
'updateamum' => $block->updateamum,
|
||||
'updatevon' => $block->updatevon
|
||||
)
|
||||
);
|
||||
if(!isSuccess($result))
|
||||
return null;
|
||||
|
||||
$kalender_id = getData($result);
|
||||
|
||||
$this->KalenderLehreinheitModel->insert(
|
||||
array (
|
||||
'kalender_id' => $kalender_id,
|
||||
'lehreinheit_id'=> $block->lehreinheit_id
|
||||
)
|
||||
);
|
||||
$this->KalenderOrtModel->insert(
|
||||
array (
|
||||
'kalender_id' => $kalender_id,
|
||||
'ort_kurzbz' => $block->ort_kurzbz
|
||||
)
|
||||
);
|
||||
|
||||
return $kalender_id;
|
||||
}
|
||||
|
||||
private function _insertSync($ids, $kalender_id)
|
||||
{
|
||||
foreach($ids as $id)
|
||||
{
|
||||
$this->SyncModel->insert(
|
||||
array (
|
||||
'stundenplandev_id' => $id,
|
||||
'kalender_id' => $kalender_id,
|
||||
'lastupdate' => date('Y-m-d H:i:s')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function _updateKalender($kalender_id, $block)
|
||||
{
|
||||
$this->KalenderModel->update(
|
||||
array (
|
||||
'kalender_id' => $kalender_id
|
||||
),
|
||||
array (
|
||||
'von' => $block->von,
|
||||
'bis' => $block->bis,
|
||||
'updateamum'=> $block->updateamum,
|
||||
'updatevon' => $block->updatevon
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function _updateSync($ids, $kalender_id)
|
||||
{
|
||||
foreach($ids as $id)
|
||||
{
|
||||
$this->SyncModel->update(
|
||||
array (
|
||||
'stundenplandev_id' => $id,
|
||||
'kalender_id' => $kalender_id
|
||||
),
|
||||
array (
|
||||
'lastupdate' => date('Y-m-d H:i:s')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,159 +4,480 @@ if (! defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
class KalenderLib
|
||||
{
|
||||
private $_ci;
|
||||
/**
|
||||
* Loads model OrganisationseinheitModel
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->ci =& get_instance();
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
$this->ci->load->model('ressource/Kalender_model', 'KalenderModel');
|
||||
$this->ci->load->model('ressource/Kalender_Lehreinheit_model', 'KalenderLehreinheitModel');
|
||||
$this->ci->load->model('ressource/Kalender_Ort_model', 'KalenderOrtModel');
|
||||
$this->ci->load->model('education/Lehreinheit_model', 'LehreinheitModel');
|
||||
$this->ci->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
$this->ci->load->model('education/LehreinheitMitarbeiter_model', 'LehreinheitMitarbeiterModel');
|
||||
$this->_ci->load->model('ressource/Kalender_model', 'KalenderModel');
|
||||
$this->_ci->load->model('ressource/Kalender_Lehreinheit_model', 'KalenderLehreinheitModel');
|
||||
$this->_ci->load->model('ressource/Kalender_Ort_model', 'KalenderOrtModel');
|
||||
$this->_ci->load->model('education/Lehreinheit_model', 'LehreinheitModel');
|
||||
$this->_ci->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
$this->_ci->load->model('education/LehreinheitMitarbeiter_model', 'LehreinheitMitarbeiterModel');
|
||||
$this->_ci->load->model('ressource/Ort_model', 'OrtModel');
|
||||
|
||||
}
|
||||
|
||||
public function getRoomData($ort_kurzbz, $start_date, $end_date)
|
||||
private function _getBasePlan($start_date, $end_date)
|
||||
{
|
||||
$data = $this->ci->KalenderModel->addJoin('lehre.tbl_kalender_ort', 'kalender_id');
|
||||
$data = $this->ci->KalenderModel->loadWhere(array(
|
||||
'von >=' => $start_date,
|
||||
'bis <= '=>$end_date,
|
||||
'ort_kurzbz'=>$ort_kurzbz
|
||||
));
|
||||
$end_date = date('Y-m-d', strtotime($end_date . ' +1 day'));
|
||||
|
||||
$stundenplan_data = array();
|
||||
if(isSuccess($data) && hasData($data))
|
||||
$this->_ci->KalenderModel->addSelect('tbl_kalender.kalender_id,
|
||||
tbl_kalender.status_kurzbz,
|
||||
tbl_kalender.von,
|
||||
tbl_kalender.bis,
|
||||
tbl_kalender_ort.ort_kurzbz,
|
||||
tbl_lehreinheit.lehreinheit_id,
|
||||
tbl_lehreinheit.lehrveranstaltung_id,
|
||||
tbl_lehreinheit.lehrfach_id,
|
||||
tbl_lehreinheit.lehrform_kurzbz,
|
||||
tbl_lehrveranstaltung.oe_kurzbz,
|
||||
lehrfach.kurzbz AS lehrfach_kurzbz,
|
||||
lehrfach.bezeichnung AS lehrfach_bezeichnung,
|
||||
lehrfach.farbe,
|
||||
tbl_lehreinheitmitarbeiter.mitarbeiter_uid,
|
||||
tbl_person.vorname,
|
||||
tbl_paddKalenderEventerson.nachname,
|
||||
tbl_mitarbeiter.kurzbz AS ma_kurzbz');
|
||||
$this->_ci->KalenderModel->addJoin('lehre.tbl_kalender_lehreinheit', 'tbl_kalender.kalender_id = tbl_kalender_lehreinheit.kalender_id');
|
||||
$this->_ci->KalenderModel->addJoin('lehre.tbl_lehreinheit', 'tbl_kalender_lehreinheit.lehreinheit_id = tbl_lehreinheit.lehreinheit_id');
|
||||
$this->_ci->KalenderModel->addJoin('lehre.tbl_lehrveranstaltung', 'tbl_lehreinheit.lehrveranstaltung_id = tbl_lehrveranstaltung.lehrveranstaltung_id');
|
||||
$this->_ci->KalenderModel->addJoin('lehre.tbl_lehrveranstaltung lehrfach', 'tbl_lehreinheit.lehrfach_id = lehrfach.lehrveranstaltung_id', 'LEFT');
|
||||
$this->_ci->KalenderModel->addJoin('lehre.tbl_kalender_ort', 'tbl_kalender.kalender_id = tbl_kalender_ort.kalender_id', 'LEFT');
|
||||
$this->_ci->KalenderModel->addJoin('lehre.tbl_lehreinheitmitarbeiter', 'tbl_lehreinheit.lehreinheit_id = tbl_lehreinheitmitarbeiter.lehreinheit_id', 'LEFT');
|
||||
$this->_ci->KalenderModel->addJoin('public.tbl_mitarbeiter', 'tbl_mitarbeiter.mitarbeiter_uid = tbl_lehreinheitmitarbeiter.mitarbeiter_uid', 'LEFT');
|
||||
$this->_ci->KalenderModel->addJoin('public.tbl_benutzer', 'tbl_mitarbeiter.mitarbeiter_uid = tbl_benutzer.uid', 'LEFT');
|
||||
$this->_ci->KalenderModel->addJoin('public.tbl_person', 'tbl_person.person_id = tbl_benutzer.person_id', 'LEFT');
|
||||
|
||||
$this->_ci->KalenderModel->db->where('tbl_kalender.von >=', $start_date);
|
||||
$this->_ci->KalenderModel->db->where('tbl_kalender.bis <', $end_date);
|
||||
}
|
||||
|
||||
private function _mapEvents($data)
|
||||
{
|
||||
$stundenplan_data = [];
|
||||
|
||||
if (!isSuccess($data) || !hasData($data))
|
||||
return $stundenplan_data;
|
||||
|
||||
$events = [];
|
||||
|
||||
foreach (getData($data) as $row)
|
||||
{
|
||||
$data = getData($data);
|
||||
foreach($data as $rowstpl)
|
||||
$id = $row->kalender_id;
|
||||
|
||||
if (!isset($events[$id]))
|
||||
{
|
||||
$obj = new stdClass();
|
||||
$obj->type='lehreinheit';
|
||||
$von = new DateTime($row->von);
|
||||
$bis = new DateTime($row->bis);
|
||||
|
||||
$von = new DateTime($rowstpl->von);
|
||||
$bis = new DateTime($rowstpl->bis);
|
||||
$events[$id] = (object) [
|
||||
'type' => 'lehreinheit',
|
||||
'beginn' => $von->format('H:i:s'),
|
||||
'ende' => $bis->format('H:i:s'),
|
||||
'datum' => $von->format('Y-m-d'),
|
||||
'isostart' => $von->format('c'),
|
||||
'isoend' => $bis->format('c'),
|
||||
'tooltip' => 'tip',
|
||||
'status_kurzbz' => $row->status_kurzbz,
|
||||
'ort_kurzbz' => isset($row->ort_kurzbz) ? $row->ort_kurzbz : '',
|
||||
'lehrform' => isset($row->lehrform_kurzbz) ? $row->lehrform_kurzbz : '',
|
||||
'lehrfach' => isset($row->lehrfach_kurzbz) ? $row->lehrfach_kurzbz : '',
|
||||
'lehrfach_bez' => isset($row->lehrfach_bezeichnung) ? $row->lehrfach_bezeichnung : '',
|
||||
'farbe' => isset($row->farbe) ? $row->farbe : '',
|
||||
'lehrveranstaltung_id' => $row->lehrveranstaltung_id,
|
||||
'organisationseinheit' => isset($row->oe_kurzbz) ? $row->oe_kurzbz : '',
|
||||
'kalender_id' => $id,
|
||||
'lehreinheit_id' => [],
|
||||
'lektor' => [],
|
||||
'gruppe' => [],
|
||||
'titel' => '',
|
||||
'topic' => (isset($row->lehrfach_kurzbz) ? $row->lehrfach_kurzbz : '').' '.(isset($row->lehrform_kurzbz) ? $row->lehrform_kurzbz : ''),
|
||||
];
|
||||
}
|
||||
|
||||
$obj->beginn = $von->format('H:i:s');
|
||||
$obj->ende = $bis->format('H:i:s');
|
||||
$obj->datum = $von->format('Y-m-d');
|
||||
$obj->topic = 'undefined';
|
||||
$obj->lektor = array();
|
||||
$obj->gruppe = array();
|
||||
$obj->isostart = $von->format('c');
|
||||
$obj->isoend = $bis->format('c');
|
||||
$obj->tooltip = 'tip';
|
||||
if ($row->lehreinheit_id && !in_array($row->lehreinheit_id, $events[$id]->lehreinheit_id))
|
||||
$events[$id]->lehreinheit_id[] = $row->lehreinheit_id;
|
||||
|
||||
$obj->lehreinheit_id = array();
|
||||
|
||||
$lehreinheiten = $this->ci->KalenderLehreinheitModel->loadWhere(array('kalender_id'=>$rowstpl->kalender_id));
|
||||
if(isSuccess($lehreinheiten) && hasData($lehreinheiten))
|
||||
if ($row->mitarbeiter_uid)
|
||||
{
|
||||
if (!in_array($row->mitarbeiter_uid, array_column($events[$id]->lektor, 'mitarbeiter_uid')))
|
||||
{
|
||||
$lehreinheiten = getData($lehreinheiten);
|
||||
foreach($lehreinheiten as $le)
|
||||
{
|
||||
$obj->lehreinheit_id[] = $le->lehreinheit_id;
|
||||
|
||||
$lehreinheitdata = $this->ci->LehreinheitModel->loadWhere(array('lehreinheit_id'=>$le->lehreinheit_id));
|
||||
|
||||
if(isSuccess($lehreinheitdata) && hasData($lehreinheitdata))
|
||||
{
|
||||
$ledata = getData($lehreinheitdata)[0];
|
||||
|
||||
|
||||
$lvid = $ledata->lehrveranstaltung_id;
|
||||
$lehrfach_id = $ledata->lehrfach_id;
|
||||
$obj->lehrform = $ledata->lehrform_kurzbz;
|
||||
|
||||
$lehreinheitmitarbeiterdata = $this->ci->LehreinheitMitarbeiterModel->loadWhere(array('lehreinheit_id'=>$le->lehreinheit_id));
|
||||
$lemitarbeiterdata = getData($lehreinheitmitarbeiterdata);
|
||||
|
||||
foreach($lemitarbeiterdata as $rowma)
|
||||
{
|
||||
$obj->lektor[] = array(
|
||||
"mitarbeiter_uid"=> $rowma->mitarbeiter_uid,
|
||||
"vorname"=>$rowma->mitarbeiter_uid,
|
||||
"nachname"=>$rowma->mitarbeiter_uid,
|
||||
"kurzbz"=>$rowma->mitarbeiter_uid
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
$events[$id]->lektor[] = [
|
||||
'mitarbeiter_uid' => $row->mitarbeiter_uid,
|
||||
'vorname' => $row->vorname,
|
||||
'nachname' => $row->nachname,
|
||||
'kurzbz' => $row->ma_kurzbz,
|
||||
];
|
||||
}
|
||||
|
||||
$lehrfachdata = $this->ci->LehrveranstaltungModel->loadWhere(array('lehrveranstaltung_id' => $lehrfach_id));
|
||||
$lfdata = getData($lehrfachdata)[0];
|
||||
|
||||
$lehrveranstaltungdata = $this->ci->LehrveranstaltungModel->loadWhere(array('lehrveranstaltung_id' => $lvid));
|
||||
$lvdata = getData($lehrveranstaltungdata)[0];
|
||||
|
||||
$obj->topic = $lfdata->kurzbz.' '.$obj->lehrform;
|
||||
|
||||
$orte = $this->ci->KalenderOrtModel->loadWhere(array('kalender_id'=>$rowstpl->kalender_id));
|
||||
$obj->ort_kurzbz = '';
|
||||
if(isSuccess($orte) && hasData($orte))
|
||||
{
|
||||
$ortedata = getdata($orte);
|
||||
foreach($ortedata as $ort);
|
||||
{
|
||||
$obj->ort_kurzbz .= $ort->ort_kurzbz;
|
||||
}
|
||||
}
|
||||
$obj->titel = '';
|
||||
$obj->lehrfach = $lfdata->kurzbz;
|
||||
$obj->lehrfach_bez = $lfdata->bezeichnung;
|
||||
$obj->organisationseinheit = $lvdata->oe_kurzbz;
|
||||
$obj->farbe = $lfdata->farbe;
|
||||
$obj->lehrveranstaltung_id = $lvid;
|
||||
$obj->kalender_id = $rowstpl->kalender_id;
|
||||
|
||||
$stundenplan_data[] = $obj;
|
||||
}
|
||||
}
|
||||
return $stundenplan_data;
|
||||
|
||||
return array_values($events);
|
||||
}
|
||||
public function getPlanByOrt($start_date, $end_date, $ort)
|
||||
{
|
||||
$this->_getBasePlan($start_date, $end_date);
|
||||
|
||||
$this->_ci->KalenderModel->db->where('tbl_kalender_ort.ort_kurzbz', $ort);
|
||||
$data = $this->_ci->KalenderModel->load();
|
||||
|
||||
return $this->_mapEvents($data);
|
||||
}
|
||||
|
||||
public function addKalenderEvent($user, $ort_kurzbz, $start_date, $end_date, $lehreinheit_id)
|
||||
public function getRaumvorschlagByLehreinheitID($start_date, $end_date, $lehreinheit_id)
|
||||
{
|
||||
$kalenderresult = $this->ci->KalenderModel->insert(array(
|
||||
'von' => $start_date,
|
||||
'bis' => $end_date,
|
||||
'typ' => 'lehreinheit',
|
||||
'status_kurzbz' => 'planning',
|
||||
'insertvon' => $user,
|
||||
'insertamum' => date('Y-m-d H:i:s')
|
||||
));
|
||||
$end_date = date('Y-m-d', strtotime($end_date . ' +1 day'));
|
||||
$lehreinheit = $this->_ci->LehreinheitModel->load(array('lehreinheit_id' => $lehreinheit_id));
|
||||
|
||||
if (isError($lehreinheit))
|
||||
return $lehreinheit;
|
||||
|
||||
if (!hasData($lehreinheit))
|
||||
return error("Not found");
|
||||
|
||||
$lehreinheit = getData($lehreinheit)[0];
|
||||
|
||||
$this->_ci->KalenderModel->addDistinct('ort_kurzbz');
|
||||
$this->_ci->KalenderModel->addSelect('ort_kurzbz');
|
||||
$this->_ci->KalenderModel->addJoin('lehre.tbl_kalender_ort', 'kalender_id');
|
||||
$this->_ci->KalenderModel->db->where('tbl_kalender.von >=', $start_date);
|
||||
$this->_ci->KalenderModel->db->where('tbl_kalender.bis <', $end_date);
|
||||
$belegte_raeume = $this->_ci->KalenderModel->load();
|
||||
|
||||
if (isError($belegte_raeume))
|
||||
return $belegte_raeume;
|
||||
|
||||
$belegte_orte = hasData($belegte_raeume) ? array_column(getData($belegte_raeume), 'ort_kurzbz') : [];
|
||||
|
||||
$vorschlaege = $this->_getFreieRaeume($lehreinheit->raumtyp, $belegte_orte);
|
||||
|
||||
if (isError($vorschlaege))
|
||||
return $vorschlaege;
|
||||
|
||||
$vorschlaege = hasData($vorschlaege) ? getData($vorschlaege) : [];
|
||||
|
||||
if (count($vorschlaege) < 5 && !empty($lehreinheit->raumtypalternativ))
|
||||
{
|
||||
$bereits_gefunden = array_merge($belegte_orte, array_column($vorschlaege, 'ort_kurzbz'));
|
||||
|
||||
$alternativ_raeume = $this->_getFreieRaeume($lehreinheit->raumtypalternativ, $bereits_gefunden);
|
||||
|
||||
if (!isError($alternativ_raeume) && hasData($alternativ_raeume))
|
||||
$vorschlaege = array_merge($vorschlaege, getData($alternativ_raeume));
|
||||
}
|
||||
|
||||
return success($vorschlaege);
|
||||
}
|
||||
|
||||
private function _getFreieRaeume($raumtyp, $belegte_orte)
|
||||
{
|
||||
$this->_ci->OrtModel->addSelect('ort_kurzbz');
|
||||
$this->_ci->OrtModel->addJoin('public.tbl_ortraumtyp', 'ort_kurzbz');
|
||||
$this->_ci->OrtModel->db->where('raumtyp_kurzbz', $raumtyp);
|
||||
$this->_ci->OrtModel->db->where('aktiv', true);
|
||||
$this->_ci->OrtModel->db->where("ort_kurzbz NOT LIKE '\_%'", null, false);
|
||||
|
||||
if (!empty($belegte_orte))
|
||||
$this->_ci->OrtModel->db->where_not_in('ort_kurzbz', $belegte_orte);
|
||||
$this->_ci->OrtModel->addOrder('hierarchie, ort_kurzbz');
|
||||
|
||||
return $this->_ci->OrtModel->load();
|
||||
}
|
||||
|
||||
public function getPlanNew($start_date, $end_date, $ort = null, $uids = null, $stg = null)
|
||||
{
|
||||
$this->_getBasePlan($start_date, $end_date);
|
||||
|
||||
if (!is_null($ort))
|
||||
$this->_ci->KalenderModel->db->where('tbl_kalender_ort.ort_kurzbz', $ort);
|
||||
|
||||
if (!is_null($uids))
|
||||
$this->_ci->KalenderModel->db->where_in('tbl_lehreinheitmitarbeiter.mitarbeiter_uid', $uids);
|
||||
|
||||
if (!is_null($stg))
|
||||
$this->_ci->KalenderModel->db->where('tbl_lehrveranstaltung.studiengang_kz', $stg);
|
||||
|
||||
$data = $this->_ci->KalenderModel->load();
|
||||
|
||||
return $this->_mapEvents($data);
|
||||
}
|
||||
public function getPlan($start_date, $end_date, $ort = null, $uids = null, $stg = null)
|
||||
{
|
||||
$end_date = date('Y-m-d', strtotime($end_date . ' +1 day'));
|
||||
|
||||
$this->_ci->KalenderModel->addSelect('tbl_kalender.kalender_id,
|
||||
tbl_kalender.status_kurzbz,
|
||||
tbl_kalender.von,
|
||||
tbl_kalender.bis,
|
||||
tbl_kalender_ort.ort_kurzbz,
|
||||
tbl_lehreinheit.lehreinheit_id,
|
||||
tbl_lehreinheit.lehrveranstaltung_id,
|
||||
tbl_lehreinheit.lehrfach_id,
|
||||
tbl_lehreinheit.lehrform_kurzbz,
|
||||
tbl_lehrveranstaltung.oe_kurzbz,
|
||||
lehrfach.kurzbz AS lehrfach_kurzbz,
|
||||
lehrfach.bezeichnung AS lehrfach_bezeichnung,
|
||||
lehrfach.farbe,
|
||||
tbl_lehreinheitmitarbeiter.mitarbeiter_uid,
|
||||
tbl_person.vorname,
|
||||
tbl_person.nachname,
|
||||
tbl_mitarbeiter.kurzbz AS ma_kurzbz');
|
||||
$this->_ci->KalenderModel->addJoin('lehre.tbl_kalender_lehreinheit', 'tbl_kalender.kalender_id = tbl_kalender_lehreinheit.kalender_id');
|
||||
$this->_ci->KalenderModel->addJoin('lehre.tbl_lehreinheit', 'tbl_kalender_lehreinheit.lehreinheit_id = tbl_lehreinheit.lehreinheit_id');
|
||||
$this->_ci->KalenderModel->addJoin('lehre.tbl_lehrveranstaltung', 'tbl_lehreinheit.lehrveranstaltung_id = tbl_lehrveranstaltung.lehrveranstaltung_id');
|
||||
$this->_ci->KalenderModel->addJoin('lehre.tbl_lehrveranstaltung lehrfach', 'tbl_lehreinheit.lehrfach_id = lehrfach.lehrveranstaltung_id', 'LEFT');
|
||||
$this->_ci->KalenderModel->addJoin('lehre.tbl_kalender_ort', 'tbl_kalender.kalender_id = tbl_kalender_ort.kalender_id', 'LEFT');
|
||||
$this->_ci->KalenderModel->addJoin('lehre.tbl_lehreinheitmitarbeiter', 'tbl_lehreinheit.lehreinheit_id = tbl_lehreinheitmitarbeiter.lehreinheit_id', 'LEFT');
|
||||
$this->_ci->KalenderModel->addJoin('public.tbl_mitarbeiter', 'tbl_mitarbeiter.mitarbeiter_uid = tbl_lehreinheitmitarbeiter.mitarbeiter_uid', 'LEFT');
|
||||
$this->_ci->KalenderModel->addJoin('public.tbl_benutzer', 'tbl_mitarbeiter.mitarbeiter_uid = tbl_benutzer.uid', 'LEFT');
|
||||
$this->_ci->KalenderModel->addJoin('public.tbl_person', 'tbl_person.person_id = tbl_benutzer.person_id', 'LEFT');
|
||||
|
||||
$this->_ci->KalenderModel->db->where('tbl_kalender.von >=', $start_date);
|
||||
$this->_ci->KalenderModel->db->where('tbl_kalender.bis <', $end_date);
|
||||
|
||||
if (!is_null($ort))
|
||||
$this->_ci->KalenderModel->db->where('tbl_kalender_ort.ort_kurzbz', $ort);
|
||||
|
||||
if (!is_null($uids))
|
||||
$this->_ci->KalenderModel->db->where_in('tbl_lehreinheitmitarbeiter.mitarbeiter_uid', $uids);
|
||||
|
||||
if (!is_null($stg))
|
||||
$this->_ci->KalenderModel->db->where('tbl_lehrveranstaltung.studiengang_kz', $stg);
|
||||
|
||||
$data = $this->_ci->KalenderModel->load();
|
||||
|
||||
$stundenplan_data = [];
|
||||
|
||||
if (!isSuccess($data) || !hasData($data))
|
||||
return $stundenplan_data;
|
||||
|
||||
$events = [];
|
||||
|
||||
foreach (getData($data) as $row)
|
||||
{
|
||||
$id = $row->kalender_id;
|
||||
|
||||
if (!isset($events[$id]))
|
||||
{
|
||||
$von = new DateTime($row->von);
|
||||
$bis = new DateTime($row->bis);
|
||||
|
||||
$events[$id] = (object) [
|
||||
'type' => 'lehreinheit',
|
||||
'beginn' => $von->format('H:i:s'),
|
||||
'ende' => $bis->format('H:i:s'),
|
||||
'datum' => $von->format('Y-m-d'),
|
||||
'isostart' => $von->format('c'),
|
||||
'isoend' => $bis->format('c'),
|
||||
'tooltip' => 'tip',
|
||||
'status_kurzbz' => $row->status_kurzbz,
|
||||
'ort_kurzbz' => isset($row->ort_kurzbz) ? $row->ort_kurzbz : '',
|
||||
'lehrform' => isset($row->lehrform_kurzbz) ? $row->lehrform_kurzbz : '',
|
||||
'lehrfach' => isset($row->lehrfach_kurzbz) ? $row->lehrfach_kurzbz : '',
|
||||
'lehrfach_bez' => isset($row->lehrfach_bezeichnung) ? $row->lehrfach_bezeichnung : '',
|
||||
'farbe' => isset($row->farbe) ? $row->farbe : '',
|
||||
'lehrveranstaltung_id' => $row->lehrveranstaltung_id,
|
||||
'organisationseinheit' => isset($row->oe_kurzbz) ? $row->oe_kurzbz : '',
|
||||
'kalender_id' => $id,
|
||||
'lehreinheit_id' => [],
|
||||
'lektor' => [],
|
||||
'gruppe' => [],
|
||||
'titel' => '',
|
||||
'topic' => (isset($row->lehrfach_kurzbz) ? $row->lehrfach_kurzbz : '') . ' ' . (isset($row->lehrform_kurzbz) ? $row->lehrform_kurzbz : ''),
|
||||
];
|
||||
}
|
||||
|
||||
if ($row->lehreinheit_id && !in_array($row->lehreinheit_id, $events[$id]->lehreinheit_id))
|
||||
$events[$id]->lehreinheit_id[] = $row->lehreinheit_id;
|
||||
|
||||
if ($row->mitarbeiter_uid)
|
||||
{
|
||||
if (!in_array($row->mitarbeiter_uid, array_column($events[$id]->lektor, 'mitarbeiter_uid')))
|
||||
{
|
||||
$events[$id]->lektor[] = [
|
||||
'mitarbeiter_uid' => $row->mitarbeiter_uid,
|
||||
'vorname' => $row->vorname,
|
||||
'nachname' => $row->nachname,
|
||||
'kurzbz' => $row->ma_kurzbz,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($events);
|
||||
}
|
||||
public function getZeitsperren($start_date, $end_date, $emp)
|
||||
{
|
||||
$db = new DB_Model();
|
||||
$qry = "
|
||||
SELECT
|
||||
tbl_zeitsperre.zeitsperre_id,
|
||||
tbl_zeitsperre.vondatum AS start,
|
||||
tbl_zeitsperre.bisdatum AS ende,
|
||||
tbl_vonstunde.beginn AS startstunde,
|
||||
tbl_bisstunde.ende AS bisstunde,
|
||||
tbl_erreichbarkeit.farbe AS erreichbarkeit_farbe,
|
||||
tbl_erreichbarkeit.beschreibung AS erreichbarkeit_beschreibung,
|
||||
tbl_zeitsperretyp.beschreibung as label
|
||||
FROM campus.tbl_zeitsperre
|
||||
JOIN campus.tbl_zeitsperretyp ON tbl_zeitsperre.zeitsperretyp_kurzbz = tbl_zeitsperretyp.zeitsperretyp_kurzbz
|
||||
LEFT JOIN campus.tbl_erreichbarkeit ON tbl_zeitsperre.erreichbarkeit_kurzbz = tbl_erreichbarkeit.erreichbarkeit_kurzbz
|
||||
LEFT JOIN lehre.tbl_stunde tbl_vonstunde ON tbl_zeitsperre.vonstunde = tbl_vonstunde.stunde
|
||||
LEFT JOIN lehre.tbl_stunde tbl_bisstunde ON tbl_zeitsperre.bisstunde = tbl_bisstunde.stunde
|
||||
WHERE tbl_zeitsperre.mitarbeiter_uid = ?
|
||||
AND tbl_zeitsperre.bisdatum >= ?
|
||||
AND tbl_zeitsperre.vondatum <= ?
|
||||
ORDER BY tbl_zeitsperre.vondatum;
|
||||
";
|
||||
|
||||
$result = $db->execReadOnlyQuery($qry, array($emp, $start_date, $end_date));
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
$zeitsperren_array = array();
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
foreach (getData($result) as $zeitsperre)
|
||||
{
|
||||
$obj = new stdClass();
|
||||
$von = new DateTime($zeitsperre->start . ' '. $zeitsperre->startstunde);
|
||||
$bis = new DateTime($zeitsperre->ende . ' '. $zeitsperre->bisstunde);
|
||||
$obj->isostart = $von->format('c');
|
||||
$obj->isoend = $bis->format('c');
|
||||
$obj->label = $zeitsperre->label;
|
||||
$zeitsperren_array[] = $obj;
|
||||
}
|
||||
}
|
||||
return $zeitsperren_array;
|
||||
}
|
||||
public function getZeitwuensche($start_date, $end_date, $emp)
|
||||
{
|
||||
$db = new DB_Model();
|
||||
$qry = "
|
||||
WITH zeitwuensche AS (
|
||||
SELECT
|
||||
tbl_zeitwunsch.*,
|
||||
zw_gueltigkeit.von AS gueltig_von,
|
||||
zw_gueltigkeit.bis AS gueltig_bis
|
||||
FROM campus.tbl_zeitwunsch
|
||||
JOIN campus.tbl_zeitwunsch_gueltigkeit zw_gueltigkeit USING (zeitwunsch_gueltigkeit_id)
|
||||
WHERE tbl_zeitwunsch.mitarbeiter_uid = ?
|
||||
),
|
||||
tage AS (
|
||||
SELECT
|
||||
tage::date AS tag,
|
||||
EXTRACT(DOW FROM tage)::int AS wochentag
|
||||
FROM generate_series(?::date, ?::date, interval '1 day') AS tage
|
||||
)
|
||||
SELECT
|
||||
tage.tag,
|
||||
zeitwuensche.gewicht,
|
||||
tage.tag + s.beginn as start,
|
||||
tage.tag + s.ende as ende,
|
||||
mitarbeiter_uid as label
|
||||
FROM tage
|
||||
JOIN zeitwuensche ON tage.wochentag = zeitwuensche.tag
|
||||
AND tage.tag >= zeitwuensche.gueltig_von
|
||||
AND (zeitwuensche.gueltig_bis IS NULL OR tage.tag <= zeitwuensche.gueltig_bis)
|
||||
JOIN lehre.tbl_stunde s ON s.stunde = zeitwuensche.stunde
|
||||
ORDER BY tage.tag, start;";
|
||||
|
||||
$result = $db->execReadOnlyQuery($qry, array($emp, $start_date, $end_date));
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
$zeitwuensche_array = array();
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
foreach (getData($result) as $zeitwuensch)
|
||||
{
|
||||
$obj = new stdClass();
|
||||
|
||||
$von = new DateTime($zeitwuensch->start);
|
||||
$bis = new DateTime($zeitwuensch->ende);
|
||||
|
||||
$obj->isostart = $von->format('c');
|
||||
$obj->isoend = $bis->format('c');
|
||||
$obj->gewicht = $zeitwuensch->gewicht;
|
||||
$obj->label = $zeitwuensch->label;
|
||||
$zeitwuensche_array[] = $obj;
|
||||
}
|
||||
}
|
||||
|
||||
return $zeitwuensche_array;
|
||||
|
||||
}
|
||||
public function addKalenderEvent($start_date, $end_date, $lehreinheit_id, $ort_kurzbz)
|
||||
{
|
||||
$kalenderresult = $this->_ci->KalenderModel->insert(
|
||||
array (
|
||||
'von' => $start_date,
|
||||
'bis' => $end_date,
|
||||
'typ' => 'lehreinheit',
|
||||
'status_kurzbz' => 'planning',
|
||||
'insertvon' => getAuthUID(),
|
||||
'insertamum' => date('Y-m-d H:i:s')
|
||||
)
|
||||
);
|
||||
|
||||
if(isSuccess($kalenderresult) && hasData($kalenderresult))
|
||||
{
|
||||
$kalender_id = getData($kalenderresult);
|
||||
|
||||
$kalenderlehreinheitresult = $this->_ci->KalenderLehreinheitModel->insert(
|
||||
array (
|
||||
'kalender_id' => $kalender_id,
|
||||
'lehreinheit_id' => $lehreinheit_id
|
||||
)
|
||||
);
|
||||
|
||||
$kalenderlehreinheitresult = $this->ci->KalenderLehreinheitModel->insert(array(
|
||||
'kalender_id' => $kalender_id,
|
||||
'lehreinheit_id' => $lehreinheit_id
|
||||
));
|
||||
|
||||
if(isSuccess($kalenderlehreinheitresult))
|
||||
if(isSuccess($kalenderlehreinheitresult) && !is_null($ort_kurzbz))
|
||||
{
|
||||
$kalenderOrtresult = $this->ci->KalenderOrtModel->insert(array(
|
||||
'kalender_id'=>$kalender_id,
|
||||
'ort_kurzbz'=>$ort_kurzbz
|
||||
));
|
||||
return $this->_addKalenderOrt($kalender_id, $ort_kurzbz);
|
||||
}
|
||||
|
||||
return $kalenderlehreinheitresult;
|
||||
}
|
||||
}
|
||||
|
||||
public function updateKalenderEvent($user, $kalender_id, $ort_kurzbz, $start_date, $end_date)
|
||||
private function _addKalenderOrt($kalender_id, $ort_kurzbz)
|
||||
{
|
||||
return $this->_ci->KalenderOrtModel->insert(
|
||||
array (
|
||||
'kalender_id'=>$kalender_id,
|
||||
'ort_kurzbz'=>$ort_kurzbz
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function updateOrt($kalender_id, $ort_kurzbz)
|
||||
{
|
||||
$exist = $this->_ci->KalenderOrtModel->load(array('kalender_id' => $kalender_id));
|
||||
|
||||
if (hasData($exist))
|
||||
{
|
||||
return $this->_ci->KalenderOrtModel->update(array('kalender_id' => $kalender_id),
|
||||
array (
|
||||
'ort_kurzbz' => $ort_kurzbz
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->_addKalenderOrt($kalender_id, $ort_kurzbz);
|
||||
}
|
||||
|
||||
}
|
||||
public function updateZeit($kalender_id, $start_date, $end_date)
|
||||
{
|
||||
/*TODO Checks:
|
||||
Von-Tag muss gleich dem Bis-Tag sein
|
||||
@@ -165,13 +486,15 @@ class KalenderLib
|
||||
History erstellen
|
||||
Sync Status setzen
|
||||
*/
|
||||
$this->ci->KalenderModel->update($kalender_id,
|
||||
array(
|
||||
'von'=>$start_date,
|
||||
'updateamum'=>date('Y-m-d H:i:s'),
|
||||
'updatevon' => $user
|
||||
$this->_ci->KalenderModel->update($kalender_id,
|
||||
array (
|
||||
'von' => $start_date,
|
||||
'bis' => $end_date,
|
||||
'updateamum'=> date('Y-m-d H:i:s'),
|
||||
'updatevon' => getAuthUID()
|
||||
)
|
||||
);
|
||||
|
||||
return success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Kalenderstatus_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'lehre.tbl_kalender_status';
|
||||
$this->pk = 'status_kurzbz';
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@
|
||||
'bootstrap5' => true,
|
||||
'fontawesome6' => true,
|
||||
'vue3' => true,
|
||||
'vuedatepicker11' => true,
|
||||
'primevue3' => true,
|
||||
'tabulator5' => true,
|
||||
'vuedatepicker11' => true,
|
||||
'phrases' => array(
|
||||
'global',
|
||||
'ui',
|
||||
@@ -17,7 +17,9 @@
|
||||
'public/css/components/vue-datepicker.css',
|
||||
'public/css/components/primevue.css',
|
||||
'public/css/components/calendar.css',
|
||||
'public/css/Tempus.css'
|
||||
'public/css/Tempus.css',
|
||||
'public/css/Studentenverwaltung.css',
|
||||
'public/css/components/function.css'
|
||||
],
|
||||
'customJSs' => [
|
||||
#'vendor/npm-asset/primevue/tree/tree.min.js',
|
||||
@@ -37,6 +39,8 @@
|
||||
active-addons="<?= defined('ACTIVE_ADDONS') ? ACTIVE_ADDONS : ''; ?>"
|
||||
tempus-root="<?= site_url('Tempus'); ?>"
|
||||
cis-root="<?= CIS_ROOT; ?>"
|
||||
avatar-url="<?= site_url('Cis/Pub/bild/person/' . getAuthPersonId()); ?>"
|
||||
logout-url="<?= site_url('Cis/Auth/logout'); ?>"
|
||||
:permissions="<?= htmlspecialchars(json_encode($permissions)); ?>"
|
||||
:config="<?= htmlspecialchars(json_encode($variables)); ?>"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user