From e990bb3d81524308c3b51d6add1074cc48aee4fe Mon Sep 17 00:00:00 2001 From: ma0048 Date: Wed, 25 Mar 2026 14:41:13 +0100 Subject: [PATCH] tempus pre-alpha version --- .../controllers/api/frontend/v1/Kalender.php | 171 ------ .../controllers/api/frontend/v1/Tempus.php | 94 --- .../api/frontend/v1/tempus/Config.php | 70 +++ .../api/frontend/v1/tempus/Coursepicker.php | 96 +++ .../api/frontend/v1/tempus/Kalender.php | 303 ++++++++++ .../controllers/system/MigrateKalender.php | 190 +++++- application/libraries/KalenderLib.php | 569 ++++++++++++++---- .../models/ressource/Kalenderstatus_model.php | 14 + application/views/Tempus.php | 8 +- public/css/Tempus.css | 150 +++-- public/css/components/calendar/events.css | 37 ++ public/js/api/factory/coursepicker.js | 10 - public/js/api/factory/kalender.js | 60 -- public/js/api/factory/tempus/config.js | 38 ++ public/js/api/factory/tempus/coursepicker.js | 9 + public/js/api/factory/tempus/kalender.js | 53 ++ public/js/apps/Tempus.js | 1 - public/js/components/Calendar/Base.js | 44 +- .../components/Calendar/Base/DragAndDrop.js | 165 ----- public/js/components/Calendar/Base/Grid.js | 198 +++++- .../js/components/Calendar/Base/Grid/Line.js | 1 + .../Calendar/Base/Grid/Line/Event.js | 111 +++- .../Calendar/Base/Grid/Line/EventCard.js | 32 + public/js/components/Calendar/Base/Header.js | 13 +- .../Calendar/Base/Header/Datepicker.js | 5 +- .../js/components/Calendar/Mode/List/View.js | 7 +- .../js/components/Calendar/Mode/Month/View.js | 4 +- public/js/components/Calendar/Mode/Table.js | 109 ++++ .../js/components/Calendar/Mode/Table/View.js | 147 +++++ public/js/components/Calendar/Tempus.js | 146 ++++- .../Cis/Renderer/Lehreinheit/calendarEvent.js | 4 +- .../Stv/Studentenverwaltung/Verband.js | 2 +- public/js/components/Tempus/Coursepicker.js | 141 +++-- .../js/components/Tempus/LectureSelection.js | 44 ++ public/js/components/Tempus/ParkingSlot.js | 78 +++ public/js/composables/EventLoader.js | 17 +- public/js/directives/Calendar/DragAndDrop.js | 100 --- public/js/directives/draggable.js | 3 +- public/js/helpers/DragAndDrop.js | 27 +- public/js/helpers/Tempus/ResizeGhost.js | 102 ++++ public/js/helpers/Tempus/ResizeHandler.js | 217 +++++++ 41 files changed, 2670 insertions(+), 920 deletions(-) delete mode 100644 application/controllers/api/frontend/v1/Kalender.php delete mode 100644 application/controllers/api/frontend/v1/Tempus.php create mode 100644 application/controllers/api/frontend/v1/tempus/Config.php create mode 100644 application/controllers/api/frontend/v1/tempus/Coursepicker.php create mode 100644 application/controllers/api/frontend/v1/tempus/Kalender.php create mode 100644 application/models/ressource/Kalenderstatus_model.php delete mode 100644 public/js/api/factory/coursepicker.js delete mode 100644 public/js/api/factory/kalender.js create mode 100644 public/js/api/factory/tempus/config.js create mode 100644 public/js/api/factory/tempus/coursepicker.js create mode 100644 public/js/api/factory/tempus/kalender.js delete mode 100644 public/js/components/Calendar/Base/DragAndDrop.js create mode 100644 public/js/components/Calendar/Base/Grid/Line/EventCard.js create mode 100644 public/js/components/Calendar/Mode/Table.js create mode 100644 public/js/components/Calendar/Mode/Table/View.js create mode 100644 public/js/components/Tempus/LectureSelection.js create mode 100644 public/js/components/Tempus/ParkingSlot.js delete mode 100644 public/js/directives/Calendar/DragAndDrop.js create mode 100644 public/js/helpers/Tempus/ResizeGhost.js create mode 100644 public/js/helpers/Tempus/ResizeHandler.js diff --git a/application/controllers/api/frontend/v1/Kalender.php b/application/controllers/api/frontend/v1/Kalender.php deleted file mode 100644 index 519853912..000000000 --- a/application/controllers/api/frontend/v1/Kalender.php +++ /dev/null @@ -1,171 +0,0 @@ -. - */ - -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); - } -} diff --git a/application/controllers/api/frontend/v1/Tempus.php b/application/controllers/api/frontend/v1/Tempus.php deleted file mode 100644 index 64824f152..000000000 --- a/application/controllers/api/frontend/v1/Tempus.php +++ /dev/null @@ -1,94 +0,0 @@ -. - */ - -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); - } -} diff --git a/application/controllers/api/frontend/v1/tempus/Config.php b/application/controllers/api/frontend/v1/tempus/Config.php new file mode 100644 index 000000000..0bea310c3 --- /dev/null +++ b/application/controllers/api/frontend/v1/tempus/Config.php @@ -0,0 +1,70 @@ + ['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(); + } + +} diff --git a/application/controllers/api/frontend/v1/tempus/Coursepicker.php b/application/controllers/api/frontend/v1/tempus/Coursepicker.php new file mode 100644 index 000000000..0774fc300 --- /dev/null +++ b/application/controllers/api/frontend/v1/tempus/Coursepicker.php @@ -0,0 +1,96 @@ + 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()); + } +} diff --git a/application/controllers/api/frontend/v1/tempus/Kalender.php b/application/controllers/api/frontend/v1/tempus/Kalender.php new file mode 100644 index 000000000..ca8471a9a --- /dev/null +++ b/application/controllers/api/frontend/v1/tempus/Kalender.php @@ -0,0 +1,303 @@ + 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; + } +} diff --git a/application/controllers/system/MigrateKalender.php b/application/controllers/system/MigrateKalender.php index 610a871db..ea9a7842a 100644 --- a/application/controllers/system/MigrateKalender.php +++ b/application/controllers/system/MigrateKalender.php @@ -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') + ) + ); + } + } } diff --git a/application/libraries/KalenderLib.php b/application/libraries/KalenderLib.php index fcc3f00c9..bd0bd71cf 100644 --- a/application/libraries/KalenderLib.php +++ b/application/libraries/KalenderLib.php @@ -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(); } } diff --git a/application/models/ressource/Kalenderstatus_model.php b/application/models/ressource/Kalenderstatus_model.php new file mode 100644 index 000000000..884a15d07 --- /dev/null +++ b/application/models/ressource/Kalenderstatus_model.php @@ -0,0 +1,14 @@ +dbTable = 'lehre.tbl_kalender_status'; + $this->pk = 'status_kurzbz'; + } +} diff --git a/application/views/Tempus.php b/application/views/Tempus.php index 01ce19075..346ad56ad 100644 --- a/application/views/Tempus.php +++ b/application/views/Tempus.php @@ -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="" tempus-root="" cis-root="" + avatar-url="" + logout-url="" :permissions="" :config="" > diff --git a/public/css/Tempus.css b/public/css/Tempus.css index 26f3679d4..7e88e0a42 100644 --- a/public/css/Tempus.css +++ b/public/css/Tempus.css @@ -77,48 +77,26 @@ body { color: var(--bs-success); } -#parkinglot { + + + +#parkingslot { border: 1px dashed; - width: 300px; - height: 100px; + max-height: 400px; color: #AAAAAA; text-align: center; font-size: large; margin-top: 20px; - + padding-top: 0.5rem; } -#coursechooser { - width: 300px; - min-height: 100px; - font-size: large; - margin-top: 50px; - border: 1px solid #ccc; - background: #eee; - text-align: left; - padding-left: 15px; -} - -#coursechooserheader { - font-weight: bold; - font-size: medium; -} - -#coursechooserfooter { - font-size: small; - color: #AAAAAA; -} - -.eckerl { - width: 200px; - margin: 10px 0; - padding: 2px 4px; - background: #00649c; - color: #fff; - font-size: .85em; - cursor: pointer; - border-radius: 2px; - box-shadow: 3px 3px 3px #bbb; +.parkingevent { + border: 1px dashed !important; + border-color: #AAAAAA; + padding: 0.5rem; + margin-bottom: 0.5rem; + margin-left: 0.5rem; + margin-right: 0.5rem; } :root{ @@ -128,3 +106,105 @@ body { .eckerltest { box-shadow: 3px 3px 3px #ccc; } + + + + + + +.fhc-resizable { + position: relative; +} + +.fhc-resizable .fhc-resize-bar +{ + position:absolute; left:6px; right:6px; height:10px; + opacity:0; pointer-events:none; transition:opacity .12s ease; + cursor: ns-resize; z-index: 20; +} +.fhc-resizable:hover .fhc-resize-bar{ opacity:1; pointer-events:auto; } + +.fhc-resize-bar--top{ top:-4px; } +.fhc-resize-bar--bottom{ bottom:-4px; } + +.fhc-resize-bar::after{ + content:""; display:block; margin:3px auto 0; + width:44px; height:4px; border-radius:999px; + background: rgba(0,0,0,.35); +} + + + + +.verband-selection { + border: 1px dashed #AAAAAA; + margin-bottom: 0.5rem; + max-height: 450px; + overflow-y: auto; + display: flex; + flex-direction: column; +} + +.lecture-selection { + border: 1px dashed #AAAAAA; + margin-bottom: 0.5rem; + max-height: 300px; + overflow-y: auto; + display: flex; + flex-direction: column; +} + +.course-picker { + border: 1px dashed #AAAAAA; + height: 400px; + max-height: 400px; + display: flex; + flex-direction: column; +} +.course-picker-row { + padding: 0.5rem; + margin-bottom: 0.5rem; + border: 1px solid var(--bs-border-color); + background-color: var(--bs-tertiary-bg); +} + +.room-selection { + border: 1px dashed #AAAAAA; + margin-bottom: 0.5rem; + padding: 0.5rem 0.0rem 0.5rem 0.5rem; +} + +.btn-link.text-danger { + text-decoration: none; + font-weight: 600; +} + +.btn-link.text-danger:hover { + color: #dc3545; + transform: scale(1.1); +} + + + +.bg-lecturer-wish { + opacity: .15; +} +.bg-lecturer-block { + background: rgba(255, 0, 0, 0.15); +} + + +.wish-w--2 { + background-color: #FF2200; +} +.wish-w--1 { + background-color: #FF9922; +} +.wish-w-1 { + background-color: #CCFFCC; +} +.wish-w-2 { + background-color: #48FA66; +} + + diff --git a/public/css/components/calendar/events.css b/public/css/components/calendar/events.css index 5bdbb1b46..14bd4fa39 100644 --- a/public/css/components/calendar/events.css +++ b/public/css/components/calendar/events.css @@ -2,6 +2,10 @@ cursor: pointer; font-size: var(--fhc-calendar-fontsize-event, .875rem); } +.event--parked { + opacity: 0.45 !important; +} + .fhc-calendar-mode-day .fhc-calendar-base-grid-line, .fhc-calendar-mode-week .fhc-calendar-base-grid-line { padding: 0 var(--fhc-calendar-gap-events, var(--fhc-calendar-gap, 1px)); @@ -69,3 +73,36 @@ .fhc-calendar-base .event > *:hover { filter: brightness(120%); } + +.fhc-resize-bar { + align-items: center; + justify-content: center; + + height: 15px; + flex: 0 0 12px; + cursor: ns-resize; + position: relative; + + visibility: hidden; + pointer-events: none; +} + +.fhc-resize-bar--top { + margin-bottom: -16px; +} +.fhc-resize-bar--bottom { + margin-top: -16px; +} + +.fhc-calendar-base-grid-line-event:hover > .fhc-resize-bar { + visibility: visible; + pointer-events: auto; +} +.fhc-calendar-base-grid-line-event.event:hover { + z-index: 50; +} +.fhc-resize-bar { + z-index: 2; +} + + diff --git a/public/js/api/factory/coursepicker.js b/public/js/api/factory/coursepicker.js deleted file mode 100644 index aefe15619..000000000 --- a/public/js/api/factory/coursepicker.js +++ /dev/null @@ -1,10 +0,0 @@ - -export default { - getCourses(searchfilter) { - return { - method: 'get', - url: '/api/frontend/v1/tempus/getCourses', - params: { searchfilter } - }; - } -}; diff --git a/public/js/api/factory/kalender.js b/public/js/api/factory/kalender.js deleted file mode 100644 index f0fd32e13..000000000 --- a/public/js/api/factory/kalender.js +++ /dev/null @@ -1,60 +0,0 @@ - -export default { - getRoomplan(ort_kurzbz, start_date, end_date) { - return { - method: 'get', - url: '/api/frontend/v1/Kalender/getRoomplan', - params: { ort_kurzbz, start_date, end_date } - }; - }, - getStundenplan(start_date, end_date) { - return { - method: 'get', - url: '/api/frontend/v1/Kalender/getStundenplan', - params: { start_date, end_date} - }; - }, - getStunden() { - return { - method: 'get', - url: '/api/frontend/v1/Kalender/Stunden', - params: {} - }; - }, - getOrtReservierungen(ort_kurzbz, start_date, end_date) { - return { - method: 'get', - url: `/api/frontend/v1/Kalender/Reservierungen/${ort_kurzbz}`, - params: { start_date, end_date} - }; - }, - getStundenplanReservierungen(start_date, end_date) { - return { - method: 'get', - url: '/api/frontend/v1/Kalender/Reservierungen', - params: { start_date, end_date } - }; - }, - getLehreinheitStudiensemester(lehreinheit_id) { - return { - method: 'get', - url: `/api/frontend/v1/Kalender/getLehreinheitStudiensemester/${lehreinheit_id}`, - params: {} - }; - }, - updateKalenderEvent(kalender_id, ort_kurzbz, start_date, end_date) { - return { - method: 'post', - url: '/api/frontend/v1/Kalender/updateKalenderEvent', - params: { kalender_id, ort_kurzbz, start_date, end_date} - }; - }, - addKalenderEvent(lehreinheit_id, ort_kurzbz, start_date, end_date) { - return { - method: 'post', - url: '/api/frontend/v1/Kalender/addKalenderEvent', - params: { lehreinheit_id, ort_kurzbz, start_date, end_date} - }; - }, - -}; diff --git a/public/js/api/factory/tempus/config.js b/public/js/api/factory/tempus/config.js new file mode 100644 index 000000000..235fddfe6 --- /dev/null +++ b/public/js/api/factory/tempus/config.js @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2025 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 . + */ + +export default { + get() { + return { + method: 'get', + url: 'api/frontend/v1/tempus/config/get' + }; + }, + getHeader() { + return { + method: 'get', + url: 'api/frontend/v1/tempus/config/getHeader' + }; + }, + set(params) { + return { + method: 'post', + url: 'api/frontend/v1/tempus/config/set', + params + }; + } +}; \ No newline at end of file diff --git a/public/js/api/factory/tempus/coursepicker.js b/public/js/api/factory/tempus/coursepicker.js new file mode 100644 index 000000000..637caf732 --- /dev/null +++ b/public/js/api/factory/tempus/coursepicker.js @@ -0,0 +1,9 @@ +export default { + search(query) { + return { + method: 'get', + url: 'api/frontend/v1/tempus/coursepicker/search', + params: { query } + }; + } +}; diff --git a/public/js/api/factory/tempus/kalender.js b/public/js/api/factory/tempus/kalender.js new file mode 100644 index 000000000..61d555db6 --- /dev/null +++ b/public/js/api/factory/tempus/kalender.js @@ -0,0 +1,53 @@ + +export default { + getPlan(filter, start_date, end_date) + { + return { + method: 'get', + url: '/api/frontend/v1/tempus/Kalender/getPlan', + params: { ...filter, start_date, end_date } + }; + }, + getLektorZeitsperren(emp, start_date, end_date) { + return { + method: 'get', + url: '/api/frontend/v1/tempus/Kalender/getZeitsperren', + params: { emp, start_date, end_date } + }; + }, + getLektorZeitwuensche(emp, start_date, end_date) { + return { + method: 'get', + url: '/api/frontend/v1/tempus/Kalender/getZeitwuensche', + params: { emp, start_date, end_date } + }; + }, + getStunden() { + return { + method: 'get', + url: '/api/frontend/v1/tempus/Kalender/getStunden', + }; + }, + updateKalenderEvent(kalender_id, updatedInfos) { + return { + method: 'post', + url: '/api/frontend/v1/tempus/Kalender/updateKalenderEvent', + params: { kalender_id, updatedInfos} + }; + }, + addKalenderEvent(lehreinheit_id, ort_kurzbz, start_date, end_date) { + return { + method: 'post', + url: '/api/frontend/v1/tempus/Kalender/addKalenderEvent', + params: { lehreinheit_id, ort_kurzbz, start_date, end_date} + }; + }, + getRaumvorschlag(start_date, end_date, lehreinheit_id) { + return { + method: 'get', + url: '/api/frontend/v1/tempus/Kalender/getRaumvorschlag', + params: { start_date, end_date, lehreinheit_id} + }; + }, + +}; diff --git a/public/js/apps/Tempus.js b/public/js/apps/Tempus.js index e5596479e..1faf50956 100644 --- a/public/js/apps/Tempus.js +++ b/public/js/apps/Tempus.js @@ -16,7 +16,6 @@ */ import FhcTempus from "../components/Tempus/Tempus.js"; -import fhcapifactory from "./api/fhcapifactory.js"; import Phrasen from "../plugins/Phrasen.js"; diff --git a/public/js/components/Calendar/Base.js b/public/js/components/Calendar/Base.js index 36d9877da..7b770e55c 100644 --- a/public/js/components/Calendar/Base.js +++ b/public/js/components/Calendar/Base.js @@ -1,23 +1,31 @@ -import BaseDraganddrop from './Base/DragAndDrop.js'; import BaseHeader from './Base/Header.js'; import BaseSlider from './Base/Slider.js'; import BsModal from '../Bootstrap/Modal.js'; import CalClick from '../../directives/Calendar/Click.js'; +import DragClick from '../../directives/dragClick.js'; +import Draggable from '../../directives/draggable.js'; +import Drop from '../../directives/drop.js'; export default { name: "CalendarBase", components: { - BaseDraganddrop, BaseHeader, BaseSlider, BsModal }, directives: { - CalClick + CalClick, + DragClick, + Draggable, + Drop }, provide() { return { + events: Vue.computed(() => this.convertedEvents), + backgrounds: Vue.computed(() => this.convertedBackgrounds), + dropAllowed: Vue.computed(() => !!this.onDrop), + onDrop: Vue.computed(() => this.onDrop || null), locale: Vue.computed(() => this.locale), timezone: Vue.computed(() => this.timezone), timeGrid: Vue.computed(() => this.timeGrid), @@ -43,6 +51,17 @@ export default { return () => true; }), + resizableEvents: Vue.computed(() => { + if (!this.resizableEvents) + return () => false; + + if (Array.isArray(this.resizableEvents)) + return event => this.resizableEvents.includes(event.type); + if (this.resizableEvents instanceof Function) + return this.resizableEvents; + + return () => true; + }), hasDragoverFunc: Vue.computed(() => this.onDragover), mode: Vue.computed(() => this.mode) }; @@ -93,9 +112,14 @@ export default { type: Boolean, default: undefined }, + btnTableList: { + type: Boolean, + default: undefined + }, timeGrid: Array, draggableEvents: [Boolean, Array, Function], dropableEvents: [Boolean, Array, Function], + resizableEvents: [Boolean, Array, Function], onDragover: Function, onDrop: Function }, @@ -240,9 +264,7 @@ export default { break; } }, - onDropItem(evt, start, end) { - this.$emit('drop', evt, start, end); - }, + showEventModal(eventObj) { this.modalEvent = eventObj; this.$refs.modal.show(); @@ -263,11 +285,7 @@ export default { }, template: /* html */`
- @@ -282,6 +300,7 @@ export default { :btn-week="!!modes['week'] && (btnWeek || (showBtns && btnWeek !== false))" :btn-month="!!modes['month'] && (btnMonth || (showBtns && btnMonth !== false))" :btn-list="!!modes['list'] && (btnList || (showBtns && btnList !== false))" + :btn-table-list="!!modes['tableList'] && (btnTableList || (showBtns && btnTableList !== false))" :mode-options="modeOptions ? modeOptions[cMode] : undefined" > @@ -293,11 +312,12 @@ export default { @update:range="$emit('update:range', $event)" @request-modal-open="showEventModal" @request-modal-close="hideEventModal" + @drop="$emit('drop', $event)" v-bind="modeOptions ? modeOptions[cMode] : null || {}" > - +