diff --git a/.gitignore b/.gitignore index def2813f7..cf35d4eea 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ tests/codeception/tests/unit.suite.yml bin /application/logs/ /sparks/* +/webdav/google.php diff --git a/CHANGELOG.md b/CHANGELOG.md index dc04db97e..73a56f5dd 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,15 @@ - **[FAS]** Verwaltung von Rechnungsadressen - **[CIS]** Mitarbeiter und Studierende können nach dem Login im CIS zur Passwortänderung umgeleitet werden wenn dieses seit über einem Jahr nicht geändert wurde - **[FAS]** Bei Statuswechsel von Studierenden können Gründe für den Statuswechsel angegeben werden +- **[ADDONS]** Addons können Menüpunkte im Vilesci anpassen +- **[ADDONS]** Addons können Noten für die Gesamtnote vorschlagen ### CHANGED -- **[CORE]** Berechtigungsprüfung wurde angepasst damit deaktiverte Benutzer keine Berechtigungen mehr haben +- **[CORE]** Berechtigungsprüfung wurde angepasst damit deaktivierte Benutzer keine Berechtigungen mehr haben + +### Updateinfo +- **[CORE]** Infoscreen wurde umbenannt (informationsbildschirm.php) +- **[CORE]** Moodle Schnittstelle wurde aus dem Core entfernt und in ein eigenes Addon verschoben. Moodle Versionen < 2.4 werden nicht mehr unterstützt ## [3.2] diff --git a/addons/.gitignore b/addons/.gitignore index 0988e3f76..8674d2623 100644 --- a/addons/.gitignore +++ b/addons/.gitignore @@ -1,6 +1,6 @@ #ignore all addons * #except template addon -!template/* +!template**/** !CodingGuidelines.txt !index.html diff --git a/addons/template/vilesci/menu.inc.php b/addons/template/vilesci/menu.inc.php new file mode 100644 index 000000000..77e9c8ec3 --- /dev/null +++ b/addons/template/vilesci/menu.inc.php @@ -0,0 +1,44 @@ +, + */ +/** + * Hier koennen neue Menuepunkte im Vilesci definiert werden + */ + +// Hauptmenuepunkt hinzufuegen +$menu_addon = array +( + 'Template'=>array + ( + 'name'=>'Template', 'opener'=>'true', 'hide'=>'true', 'permissions'=>array('basis/addon'), 'image'=>'../../skin/images/vilesci_addons.png', + 'link'=>'left.php?categorie=Template', 'target'=>'nav', + 'TemplateEntry1'=>array('name'=>'Template Entry1', 'link'=>'../addons/template/vilesci/index.php', 'target'=>'main'), + 'TemplateEntry2'=>array('name'=>'Template Entry2', 'link'=>'../addons/template/vilesci/index.php', 'target'=>'main') + ) +); +$menu = array_merge($menu,$menu_addon); + +// Submenuepunkt hinzufuegen unter dem Hauptmenue Punkt "Admin" +$menu_addon = array +( + 'TemplateSubmenu'=>array('name'=>'Template', 'link'=>'../addons/template/vilesci/index.php', 'target'=>'main','permissions'=>array('basis/addon')), + +); +$menu['Admin'] = array_merge($menu['Admin'],$menu_addon); +?> diff --git a/application/config/fhcomplete.php b/application/config/fhcomplete.php index f51185a2d..251887d5c 100755 --- a/application/config/fhcomplete.php +++ b/application/config/fhcomplete.php @@ -97,7 +97,6 @@ $config['fhc_acl'] = array 'lehre.tbl_lvangebot' => 'basis/lvangebot', 'lehre.tbl_lvregel' => 'basis/lvregel', 'lehre.tbl_lvregeltyp' => 'basis/lvregeltyp', - 'lehre.tbl_moodle' => 'basis/moodle', 'lehre.tbl_note' => 'basis/note', 'lehre.tbl_notenschluessel' => 'basis/notenschluessel', 'lehre.tbl_notenschluesselaufteilung' => 'basis/notenschluesselaufteilung', @@ -235,12 +234,12 @@ $config['fhc_acl'] = array 'wawi.tbl_rechnungsbetrag' => 'basis/rechnungsbetrag', 'wawi.tbl_rechnungstyp' => 'basis/rechnungstyp', 'wawi.tbl_zahlungstyp' => 'basis/zahlungstyp', - + DMS_PATH => 'fs/dms', - + 'public.tbl_sprache' => 'admin', - + 'PhrasesLib.getPhrase' => 'system/PhrasesLib' ); -$config['addons_aufnahme_url'] = 'http://debian.dev/build/addons/aufnahme/cis/index.php'; \ No newline at end of file +$config['addons_aufnahme_url'] = 'http://debian.dev/build/addons/aufnahme/cis/index.php'; diff --git a/application/controllers/api/v1/crm/Prestudent.php b/application/controllers/api/v1/crm/Prestudent.php index 6ee24463a..5d5ff063b 100644 --- a/application/controllers/api/v1/crm/Prestudent.php +++ b/application/controllers/api/v1/crm/Prestudent.php @@ -34,11 +34,11 @@ class Prestudent extends APIv1_Controller public function getPrestudent() { $prestudentID = $this->get('prestudent_id'); - + if (isset($prestudentID)) { $result = $this->PrestudentModel->load($prestudentID); - + $this->response($result, REST_Controller::HTTP_OK); } else @@ -46,18 +46,18 @@ class Prestudent extends APIv1_Controller $this->response(); } } - + /** * @return void */ public function getPrestudentByPersonID() { $person_id = $this->get('person_id'); - + if (isset($person_id)) { $result = $this->PrestudentModel->load(array('person_id' => $person_id)); - + $this->response($result, REST_Controller::HTTP_OK); } else @@ -65,7 +65,7 @@ class Prestudent extends APIv1_Controller $this->response(); } } - + /** * @return void */ @@ -73,14 +73,14 @@ class Prestudent extends APIv1_Controller { $prestudent_id = $this->get('prestudent_id'); $titel = $this->get('titel'); - + if (isset($prestudent_id) && isset($titel)) { // Loads model Notiz_model $this->load->model('person/Notiz_model', 'NotizModel'); - + $result = $this->NotizModel->getSpecialization($prestudent_id, $titel); - + $this->response($result, REST_Controller::HTTP_OK); } else @@ -88,7 +88,7 @@ class Prestudent extends APIv1_Controller $this->response(); } } - + /** * @return void */ @@ -98,7 +98,7 @@ class Prestudent extends APIv1_Controller $studiensemester_kurzbz = $this->get('studiensemester_kurzbz'); $studiengang_kz = $this->get('studiengang_kz'); $status_kurzbz = $this->get('status_kurzbz'); - + if (isset($person_id)) { $result = $this->PrestudentModel->getLastStatuses( @@ -107,7 +107,7 @@ class Prestudent extends APIv1_Controller $studiengang_kz, $status_kurzbz ); - + $this->response($result, REST_Controller::HTTP_OK); } else @@ -115,21 +115,56 @@ class Prestudent extends APIv1_Controller $this->response(); } } - + + /** + * Get all Persons with a Status in the define Timerange + * Additionally ALL Prestudents of this person are included. + * (Not only the ones with the status) + * + * @return void + */ + public function getPrestudentsPerStatus() + { + $this->load->model('person/person_model', 'PersonModel'); + $status_kurzbz = $this->get('status_kurzbz'); + $von = $this->get('von'); + $bis = $this->get('bis'); + + if (isset($status_kurzbz) && isset($von) && isset($bis)) + { + $result = $this->PersonModel->getPersonFromStatus( + $status_kurzbz, + $von, + $bis + ); + + // Remove person images from result array to reduce useless traffic + foreach($result->retval as $key=>$val) + { + unset($result->retval[$key]->foto); + } + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response(); + } + } + /** * @return void */ public function postRmSpecialization() { $notiz_id = $this->post()['notiz_id']; - + if (isset($notiz_id)) { // Loads model Notiz_model $this->load->model('person/Notiz_model', 'NotizModel'); - + $result = $this->NotizModel->rmSpecialization($notiz_id); - + $this->response($result, REST_Controller::HTTP_OK); } else @@ -137,7 +172,7 @@ class Prestudent extends APIv1_Controller $this->response(); } } - + /** * @return void */ @@ -146,14 +181,14 @@ class Prestudent extends APIv1_Controller $prestudent_id = $this->post()['prestudent_id']; $titel = $this->post()['titel']; $text = $this->post()['text']; - + if (isset($prestudent_id) && isset($titel) && isset($text)) { // Loads model Notiz_model $this->load->model('person/Notiz_model', 'NotizModel'); - + $result = $this->NotizModel->addSpecialization($prestudent_id, $titel, $text); - + $this->response($result, REST_Controller::HTTP_OK); } else @@ -168,7 +203,7 @@ class Prestudent extends APIv1_Controller public function postPrestudent() { $prestudent = $this->post(); - + if ($this->_validate($this->post())) { if (isset($prestudent['prestudent_id'])) @@ -179,7 +214,7 @@ class Prestudent extends APIv1_Controller { $result = $this->PrestudentModel->insert($prestudent); } - + $this->response($result, REST_Controller::HTTP_OK); } else @@ -187,7 +222,7 @@ class Prestudent extends APIv1_Controller $this->response(); } } - + /** * @return void */ @@ -196,7 +231,7 @@ class Prestudent extends APIv1_Controller if ($this->_validate($this->delete())) { $result = $this->PrestudentModel->delete($this->delete()['prestudent_id']); - + $this->response($result, REST_Controller::HTTP_OK); } else @@ -204,28 +239,28 @@ class Prestudent extends APIv1_Controller $this->response(); } } - + /** * @return void */ public function postAddReihungstest() { $ddReihungstest = $this->post(); - + if ($this->_validateReihungstest($ddReihungstest)) { if(isset($ddReihungstest['new']) && $ddReihungstest['new'] == true) { // Remove new parameter to avoid DB insert errors unset($ddReihungstest['new']); - + $result = $this->reihungstestlib->insertPersonReihungstest($ddReihungstest); } else { $result = $this->reihungstestlib->updatePersonReihungstest($ddReihungstest); } - + $this->response($result, REST_Controller::HTTP_OK); } else @@ -233,18 +268,18 @@ class Prestudent extends APIv1_Controller $this->response(); } } - + /** * @return void */ public function postDelReihungstest() { $ddReihungstest = $this->post(); - + if (isset($ddReihungstest['rt_person_id'])) { $result = $this->reihungstestlib->deletePersonReihungstest($ddReihungstest); - + $this->response($result, REST_Controller::HTTP_OK); } else @@ -252,19 +287,19 @@ class Prestudent extends APIv1_Controller $this->response(); } } - + private function _validate($prestudent = NULL) { return true; } - + private function _validateReihungstest($ddReihungstest = NULL) { if (!isset($ddReihungstest['person_id']) || !isset($ddReihungstest['rt_id']) || !isset($ddReihungstest['studienplan_id'])) { return false; } - + return true; } -} \ No newline at end of file +} diff --git a/application/controllers/api/v1/crm/Prestudentstatus.php b/application/controllers/api/v1/crm/Prestudentstatus.php index 93ad9aeb1..814bf0617 100644 --- a/application/controllers/api/v1/crm/Prestudentstatus.php +++ b/application/controllers/api/v1/crm/Prestudentstatus.php @@ -35,11 +35,11 @@ class Prestudentstatus extends APIv1_Controller $studiensemester_kurzbz = $this->get('studiensemester_kurzbz'); $status_kurzbz = $this->get('status_kurzbz'); $prestudent_id = $this->get('prestudent_id'); - + if (isset($ausbildungssemester) && isset($studiensemester_kurzbz) && isset($status_kurzbz) && isset($prestudent_id)) { $result = $this->PrestudentstatusModel->load(array($ausbildungssemester, $studiensemester_kurzbz, $status_kurzbz, $prestudent_id)); - + $this->response($result, REST_Controller::HTTP_OK); } else @@ -47,7 +47,7 @@ class Prestudentstatus extends APIv1_Controller $this->response(); } } - + /** * @return void */ @@ -56,11 +56,11 @@ class Prestudentstatus extends APIv1_Controller $prestudent_id = $this->get("prestudent_id"); $studiensemester_kurzbz = $this->get("studiensemester_kurzbz"); $status_kurzbz = $this->get("status_kurzbz"); - + if (isset($prestudent_id)) { $result = $this->PrestudentstatusModel->getLastStatus($prestudent_id, $studiensemester_kurzbz, $status_kurzbz); - + $this->response($result, REST_Controller::HTTP_OK); } else @@ -75,14 +75,14 @@ class Prestudentstatus extends APIv1_Controller public function postPrestudentstatus() { $prestudentstatus = $this->post(); - + if ($this->_validate($prestudentstatus)) { if(isset($prestudentstatus['new']) && $prestudentstatus['new'] == true) { // Remove new parameter to avoid DB insert errors unset($prestudentstatus['new']); - + $result = $this->PrestudentstatusModel->insert($prestudentstatus); } else @@ -95,7 +95,7 @@ class Prestudentstatus extends APIv1_Controller $result = $this->PrestudentstatusModel->update($pksArray, $prestudentstatus); } - + $this->response($result, REST_Controller::HTTP_OK); } else @@ -103,14 +103,14 @@ class Prestudentstatus extends APIv1_Controller $this->response(); } } - + /** * @return void */ public function deletePrestudentstatus() { $prestudentstatus = $this->delete(); - + if ($this->_validate($prestudentstatus)) { $pksArray = array($prestudentstatus['ausbildungssemester'], @@ -120,7 +120,7 @@ class Prestudentstatus extends APIv1_Controller ); $result = $this->PrestudentstatusModel->delete($pksArray); - + $this->response($result, REST_Controller::HTTP_OK); } else @@ -128,9 +128,34 @@ class Prestudentstatus extends APIv1_Controller $this->response(); } } - + private function _validate($prestudentstatus = null) { return true; } + + /** + * Get list of Status entries of a prestudent according to the filter + * + * @return void + */ + public function getStatusByFilter() + { + $prestudent_id = $this->get("prestudent_id"); + $status_kurzbz = $this->get("status_kurzbz"); + $ausbildungssemester = $this->get("ausbildungssemester"); + $studiensemester_kurzbz = $this->get("studiensemester_kurzbz"); + + if (isset($prestudent_id)) + { + $result = $this->PrestudentstatusModel->getStatusByFilter($prestudent_id, $status_kurzbz, $ausbildungssemester, $studiensemester_kurzbz); + + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response(); + } + } + } diff --git a/application/controllers/api/v1/education/Moodle.php b/application/controllers/api/v1/education/Moodle.php deleted file mode 100644 index c76706534..000000000 --- a/application/controllers/api/v1/education/Moodle.php +++ /dev/null @@ -1,76 +0,0 @@ -load->model('education/Moodle_model', 'MoodleModel'); - } - - /** - * @return void - */ - public function getMoodle() - { - $moodle_id = $this->get('moodle_id'); - - if (isset($moodle_id)) - { - $result = $this->MoodleModel->load($moodle_id); - - $this->response($result, REST_Controller::HTTP_OK); - } - else - { - $this->response(); - } - } - - /** - * @return void - */ - public function postMoodle() - { - if ($this->_validate($this->post())) - { - if (isset($this->post()['moodle_id'])) - { - $result = $this->MoodleModel->update($this->post()['moodle_id'], $this->post()); - } - else - { - $result = $this->MoodleModel->insert($this->post()); - } - - $this->response($result, REST_Controller::HTTP_OK); - } - else - { - $this->response(); - } - } - - private function _validate($moodle = NULL) - { - return true; - } -} \ No newline at end of file diff --git a/application/controllers/organisation/Studienjahr.php b/application/controllers/organisation/Studienjahr.php new file mode 100644 index 000000000..8c98a4c8b --- /dev/null +++ b/application/controllers/organisation/Studienjahr.php @@ -0,0 +1,203 @@ +load->model("organisation/Studienjahr_model", "StudienjahrModel"); + } + + /** + * by default, Studienjahre are listed by calling the listStudienjahr function + */ + /* public function index() + { + $this->listStudienjahr(); + }*/ + + /** + * lists all Studienjahre + */ + public function listStudienjahr() + { + $studienjahr = $this->StudienjahrModel->load(); + if ($studienjahr->error) + { + show_error($studienjahr->retval); + } + + $data = array( + "studienjahr" => $studienjahr->retval + ); + $this->load->view("organisation/studienjahr.php", $data); + } + + /** + * shows view for editing a Studienjahr with a given Kurzbezeichnung + * replaces slash in Kurzbezeichnung with underscore, + * otherwise the Kurzbezeichnung is treated as part of url navigation + * e.g. organisation/studienjahr/editStudienjahr/2017/18 + * @param $studienjahr_kurzbez Studienjahrkurzbezeichnung, e.g. 2017/18 + */ + public function editStudienjahr($studienjahr_kurzbez) + { + $studienjahr_kurzbez = str_replace("_", "/", $studienjahr_kurzbez); + $studienjahr = $this->StudienjahrModel->load($studienjahr_kurzbez); + if ($studienjahr->error) + { + show_error($studienjahr->retval); + } + $data = array( + "studienjahr" => $studienjahr->retval + ); + $this->load->view("organisation/studienjahrEdit.php", $data); + } + + /** + * shows view for adding a Studienjahr + * retrieves all Studienjahre, increases last Studienjahr in database by 1 to get current Studienjahr + * sends current Studienjahrkurzbezeichnung to view + * So view can prefill fields with current Studienjahr + */ + public function newStudienjahr() + { + $this->StudienjahrModel->addOrder('studienjahr_kurzbz', "DESC"); + $allstudienjahrkurzbz = $this->StudienjahrModel->load(); + if ($allstudienjahrkurzbz->error) + { + show_error($allstudienjahrkurzbz->retval); + } + $studienjahrkurzbz = $allstudienjahrkurzbz->retval[0]->studienjahr_kurzbz; + $years = $this->__getYearsFromStudienjahr($studienjahrkurzbz); + $data = array( + "studienjahrkurzbz" => ($years[0] + 1)."/".($years[1] + 1) + ); + $this->load->view("organisation/studienjahrNew.php", $data); + } + + /** + * helper function for extracting the two years from Studienjahrkurzbezeichnung + * @param $studienjahr_kurzbez Studienjahrkurzbezeichnung, e.g. 2017/18 + * @return array contains the two years, e.g. [0] - 2017, [1] - 18 + */ + private function __getYearsFromStudienjahr($studienjahr_kurzbez) + { + $firstyear = intval(substr($studienjahr_kurzbez, 0, 4)); + $secondyear = intval(substr($studienjahr_kurzbez, 5, 2)); + return array($firstyear, $secondyear); + } + + /** + * inserts a Studienjahr + * replaces slash in Kurzbezeichnung with underscore, + * redirects to edit page after inserting. + * saved=true is a GET parameter passed for showing save message + */ + public function insStudienjahr() + { + $data = $this->__retrieveStudienjahrData(); + $studienjahr = $this->StudienjahrModel->insert($data); + + if ($studienjahr->error) + { + show_error($studienjahr->retval); + } + + redirect("/organisation/studienjahr/editStudienjahr/".str_replace("/", "_", $data['studienjahr_kurzbz']."?saved=true")); + } + + /** + * gets Studienjahr data from input fields (POST request) + * escapes html characters for all texts coming from text input fields + * validates the Studienjahr data before returning it or throwing an error + * @return array contains all data for a Studienjahr + */ + private function __retrieveStudienjahrData() + { + $studienjahr_kurzbz = $this->input->post("studienjahrkurzbz"); + $bezeichnung = $this->input->post("studienjahrbz"); + + $data = array( + "studienjahr_kurzbz" => $studienjahr_kurzbz, + "bezeichnung" => html_escape($bezeichnung) + ); + + $validation = $this->_validate($data); + if (isSuccess($validation)) + { + return $data; + } else + { + show_error($validation->retval); + } + } + + /** + * runs checks on Studienjahr data + * checks if Studienjahr Kurzbezeichnung has the correct form e.g. 2017/18 + * checks if second year in Studienjahr is exactly one year after first + * @param $data contains all data for a Studienjahr + * @return array errorarray with error text if a check failed or success-array if all checks succeeded + */ + private function _validate($data) + { + $studienjahr_kurzbz = $data['studienjahr_kurzbz']; + $years = $this->__getYearsFromStudienjahr($studienjahr_kurzbz); + //if wrong form or second year comes not right after the first + $correctyears = $years[0] % 100 == $years[1] - 1; + if (!preg_match("/^\d{4}\/\d{2}$/", $studienjahr_kurzbz) || !$correctyears) + return error("Studienjahrbezeichnung muss folgende Form haben: Jahreszahl/letzeZweiZahlenDesNächstenJahres, z.B. 2017/18"); + return success("Studienjahrdaten sind valide"); + } + + /** + * updates a Studienjahr + * redirects to edit page after inserting + * replaces slash in Kurzbezeichnung with underscore + * saved=true is a GET parameter passed for showing save message + */ + public function saveStudienjahr() + { + $data = $this->__retrieveStudienjahrData(); + $studienjahr = $this->StudienjahrModel->update($data['studienjahr_kurzbz'], $data); + + if ($studienjahr->error) + { + show_error($studienjahr->retval); + } + + redirect("/organisation/studienjahr/editStudienjahr/".str_replace("/", "_", $data['studienjahr_kurzbz']."?saved=true")); + } + + /** + * deletes a Studienjahr + * redirects to list Studienjahr view after deleting + * replaces slash in Kurzbezeichnung with underscore + * @param $studienjahr_kurzbez Studienjahrkurzbezeichnung, e.g. SS2017 + */ + public function deleteStudienjahr($studienjahr_kurzbez) + { + $studienjahr_kurzbez = str_replace("_", "/", $studienjahr_kurzbez); + $studienjahr = $this->StudienjahrModel->delete($studienjahr_kurzbez); + + if ($studienjahr->error) + { + show_error($studienjahr->retval); + } + + redirect("/organisation/studienjahr/listStudienjahr"); + } + + +} \ No newline at end of file diff --git a/application/controllers/organisation/Studiensemester.php b/application/controllers/organisation/Studiensemester.php new file mode 100644 index 000000000..5707bba4a --- /dev/null +++ b/application/controllers/organisation/Studiensemester.php @@ -0,0 +1,208 @@ +load->model("organisation/Studiensemester_model", "StudiensemesterModel"); + $this->load->model("organisation/Studienjahr_model", "StudienjahrModel"); + } + + /** + * by default, Studiensemesters are listed by calling the listStudiensemester function + */ + /* public function index() + { + $this->listStudiensemester(); + }*/ + + /** + * lists all Studiensemesters + */ + public function listStudiensemester() + { + $semester = $this->StudiensemesterModel->load(); + if ($semester->error) + { + show_error($semester->retval); + } + + $data = array( + "semester" => $semester->retval + ); + $this->load->view("organisation/studiensemester.php", $data); + } + + /** + * shows view for editing a Studiensemester with a given Kurzbezeichnung + * retrieves Studienjahre for showing in a dropdown in descending order + * @param $semester_kurzbez Semesterkurzbezeichnung, e.g. SS2017 + */ + public function editStudiensemester($semester_kurzbez) + { + $semester = $this->StudiensemesterModel->load($semester_kurzbez); + if ($semester->error) + { + show_error($semester->retval); + } + $this->StudienjahrModel->addOrder('studienjahr_kurzbz', "DESC"); + $allstudienjahre = $this->StudienjahrModel->load(); + if ($allstudienjahre->error) + { + show_error($allstudienjahre->retval); + } + $data = array( + "semester" => $semester->retval, + "allstudienjahre" => $allstudienjahre->retval + ); + + $this->load->view("organisation/studiensemesterEdit.php", $data); + } + + /** + * shows view for adding a Studiensemester + * retrieves Studienjahre for showing in a dropdown in descending order + */ + public function newStudiensemester() + { + $this->StudienjahrModel->addOrder('studienjahr_kurzbz', "DESC"); + $allstudienjahre = $this->StudienjahrModel->load(); + if ($allstudienjahre->error) + { + show_error($allstudienjahre->retval); + } + + $data = array( + "allstudienjahre" => $allstudienjahre->retval + ); + + $this->load->view("organisation/studiensemesterNew.php", $data); + } + + /** + * inserts a Studiensemester + * redirects to edit page after inserting. + * saved=true is a GET parameter passed for showing save message + */ + public function insStudiensemester() + { + $data = $this->__retrieveStudiensemesterData(); + $semester = $this->StudiensemesterModel->insert($data); + + if ($semester->error) + { + show_error($semester->retval); + } + + redirect("/organisation/studiensemester/editStudiensemester/".$data['studiensemester_kurzbz']."?saved=true"); + } + + + /** + * gets Studiensemester data from input fields (POST request) + * formats Studiensemester begin and end date as required by the database (english format) + * escapes html characters for all texts coming from text input fields + * validates the Studiensemester data before returning it or throwing an error + * @return array contains all data for a Studiensemester + */ + private function __retrieveStudiensemesterData() + { + $studiensemester_kurzbz = $this->input->post("semkurzbz"); + $bezeichnung = $this->input->post("sembz"); + $start = $this->input->post("semstart"); + $ende = $this->input->post("semende"); + $studienjahr_kurzbz = $this->input->post("studienjahrkurzbz"); + $beschreibung = $this->input->post("beschreibung"); + $onlinebewerbung = $this->input->post("onlinebewerbung"); + $onlinebewerbung = isset($onlinebewerbung); + + $data = array( + "studiensemester_kurzbz" => $studiensemester_kurzbz, + "bezeichnung" => html_escape($bezeichnung), + "start" => $start, + "ende" => $ende, + "studienjahr_kurzbz" => $studienjahr_kurzbz, + "beschreibung" => html_escape($beschreibung), + "onlinebewerbung" => $onlinebewerbung + ); + + $validation = $this->_validate($data); + if (isSuccess($validation)) + { + //dateconversion + $data["start"] = date_format(date_create($start), "Y-m-d"); + $data["ende"] = date_format(date_create($ende), "Y-m-d"); + return $data; + } else + { + show_error($validation->retval); + } + } + + /** + * runs checks on Studiensemester data + * checks if Studiensemester Kurzbezeichnung has the correct form e.g. SS2017 + * checks if date was given in the correct format dd.mm.yyyy (german format) + * @param $data contains all data for a Studiensemester + * @return array errorarray with error text if a check failed or success-array if all checks succeeded + */ + private function _validate($data) + { + $datepattern = "/^\d{2}.\d{2}.\d{4}$/"; + + if (!preg_match("/^(WS|SS)\d{4}$/", $data['studiensemester_kurzbz'])) + return error("Semesterkurzbezeichnung muss mit WS oder SS beginnen und mit einer Jahreszahl enden, z.B. SS2017"); + if (!preg_match($datepattern, $data['start'])) + return error("Falsches Startdatumsformat. Richtiges Format: dd.mm.yyyy"); + if (!preg_match($datepattern, $data['ende'])) + return error("Falsches Enddatumsformat. Richtiges Format: dd.mm.yyyy"); + return success("Semesterdaten sind valide"); + } + + /** + * updates a Studiensemester + * redirects to edit page after inserting + * saved=true is a GET parameter passed for showing save message + */ + public function saveStudiensemester() + { + $data = $this->__retrieveStudiensemesterData(); + $semester = $this->StudiensemesterModel->update($data['studiensemester_kurzbz'], $data); + + if ($semester->error) + { + show_error($semester->retval); + } + + redirect("/organisation/studiensemester/editStudiensemester/".$data['studiensemester_kurzbz']."?saved=true"); + } + + /** + * deletes a Studiensemester + * redirects to list Studiensemester view after deleting + * @param $semester_kurzbez Semesterkurzbezeichnung, e.g. SS2017 + */ + public function deleteStudiensemester($semester_kurzbez) + { + $semester = $this->StudiensemesterModel->delete($semester_kurzbez); + + if ($semester->error) + { + show_error($semester->retval); + } + + redirect("/organisation/studiensemester/listStudiensemester"); + } + +} diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index ee21dec11..39ad17da5 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -11,7 +11,7 @@ class Prestudent_model extends DB_Model $this->dbTable = 'public.tbl_prestudent'; $this->pk = 'prestudent_id'; } - + /** * @return void */ @@ -24,7 +24,7 @@ class Prestudent_model extends DB_Model return $isEntitled; if (($isEntitled = $this->isEntitled('public.tbl_status', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true) return $isEntitled; - + $query = 'SELECT * FROM public.tbl_prestudent p JOIN ( @@ -37,33 +37,33 @@ class Prestudent_model extends DB_Model WHERE ps.ausbildungssemester = 1'; $parametersArray = array($person_id); - + if ($studiensemester_kurzbz != '') { array_push($parametersArray, $studiensemester_kurzbz); $query .= ' AND ps.studiensemester_kurzbz = ?'; } - + if (isset($studiengang_kz)) { array_push($parametersArray, $studiengang_kz); $query .= ' AND p.studiengang_kz = ?'; } - + if ($status_kurzbz != '') { array_push($parametersArray, $status_kurzbz); $query .= ' AND ps.status_kurzbz = ?'; } - + return $this->execQuery($query, $parametersArray); } - + /** - * + * */ public function updateAufnahmegruppe($prestudentIdArray, $aufnahmegruppe) - { + { return $this->execQuery( 'UPDATE public.tbl_prestudent SET aufnahmegruppe_kurzbz = ? @@ -74,7 +74,7 @@ class Prestudent_model extends DB_Model ) ); } - + /** * Returns a list of prestudent with additional information: * - person_id @@ -104,7 +104,7 @@ class Prestudent_model extends DB_Model aufnahmegruppe_kurzbz, SUM(rtp.punkte) AS punkte' ); - + $this->addJoin('public.tbl_person p', 'person_id', 'LEFT'); $this->addJoin( '( @@ -123,39 +123,39 @@ class Prestudent_model extends DB_Model $this->addJoin('lehre.tbl_studienordnung so', 'studienordnung_id'); $this->addJoin('public.tbl_studiengang sg', 'sg.studiengang_kz = so.studiengang_kz'); $this->addJoin('public.tbl_studiengangstyp sgt', 'typ'); - + $this->addJoin('public.tbl_rt_person rtp', 'rtp.person_id = p.person_id AND rtp.studienplan_id = s.studienplan_id', 'LEFT'); - + $this->addOrder('p.person_id', 'ASC'); $this->addOrder('prestudent_id', 'ASC'); - + $parametersArray = array('p.aktiv' => true, 'ps.status_kurzbz' => 'Interessent'); - + if ($studiengang != null) { $parametersArray['public.tbl_prestudent.studiengang_kz'] = $studiengang; } - + if ($studiensemester != null) { $parametersArray['ps.studiensemester_kurzbz'] = $studiensemester; } - + if ($gruppe != null) { $parametersArray['aufnahmegruppe_kurzbz'] = $gruppe; } - + if ($reihungstest != null) { $parametersArray['rtp.rt_id'] = $reihungstest; } - + if ($stufe != null) { $parametersArray['ps.rt_stufe'] = $stufe; } - + $this->addGroupBy( array( 'p.person_id', @@ -174,7 +174,7 @@ class Prestudent_model extends DB_Model 'aufnahmegruppe_kurzbz' ) ); - + return $this->loadWhere($parametersArray); } -} \ No newline at end of file +} diff --git a/application/models/crm/Prestudentstatus_model.php b/application/models/crm/Prestudentstatus_model.php index 48619645b..beb5eb845 100644 --- a/application/models/crm/Prestudentstatus_model.php +++ b/application/models/crm/Prestudentstatus_model.php @@ -12,7 +12,7 @@ class Prestudentstatus_model extends DB_Model $this->pk = array('ausbildungssemester', 'studiensemester_kurzbz', 'status_kurzbz', 'prestudent_id'); $this->hasSequence = false; } - + /** * @return void */ @@ -25,7 +25,7 @@ class Prestudentstatus_model extends DB_Model return $isEntitled; if (($isEntitled = $this->isEntitled('public.tbl_status', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true) return $isEntitled; - + $query = 'SELECT tbl_prestudentstatus.*, bezeichnung AS studienplan_bezeichnung, tbl_status.bezeichnung_mehrsprachig @@ -35,7 +35,7 @@ class Prestudentstatus_model extends DB_Model AND prestudent_id = ?'; $parametersArray = array($prestudent_id); - + if ($studiensemester_kurzbz != '') { array_push($parametersArray, $studiensemester_kurzbz); @@ -46,17 +46,17 @@ class Prestudentstatus_model extends DB_Model array_push($parametersArray, $status_kurzbz); $query .= ' AND status_kurzbz = ?'; } - + $query .= ' ORDER BY datum DESC, insertamum DESC, ext_id DESC LIMIT 1'; - + return $this->execQuery($query, $parametersArray); } - + /** - * + * */ public function updateStufe($prestudentIdArray, $stufe) - { + { return $this->execQuery( 'UPDATE public.tbl_prestudentstatus SET rt_stufe = ? @@ -68,4 +68,51 @@ class Prestudentstatus_model extends DB_Model ) ); } -} \ No newline at end of file + + /** + * Get all Prestudent status entries according to the given filter + * + * @param prestudent_id ID of the Prestudent. + * @param $status_kurzbz kurzbz of the status. + * @param $ausbildungssemester ausbildungssemester of the status. + * @param $studiensemester_kurzbz studiensemster of the status. + * + * @return result object with all the status entries + */ + public function getStatusByFilter($prestudent_id, $status_kurzbz = '', $ausbildungssemester = '', $studiensemester_kurzbz = '') + { + // Checks if the operation is permitted by the API caller + if (($isEntitled = $this->isEntitled('public.tbl_prestudentstatus', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true) + return $isEntitled; + + $query = ' + SELECT + tbl_prestudentstatus.* + FROM + public.tbl_prestudentstatus + WHERE + prestudent_id = ?'; + + $parametersArray = array($prestudent_id); + + if ($studiensemester_kurzbz != '') + { + array_push($parametersArray, $studiensemester_kurzbz); + $query .= ' AND studiensemester_kurzbz = ?'; + } + if ($status_kurzbz != '') + { + array_push($parametersArray, $status_kurzbz); + $query .= ' AND status_kurzbz = ?'; + } + if ($ausbildungssemester != '') + { + array_push($parametersArray, $ausbildungssemester); + $query .= ' AND ausbildungssemester = ?'; + } + + $query .= ' ORDER BY datum DESC, insertamum DESC, ext_id DESC'; + + return $this->execQuery($query, $parametersArray); + } +} diff --git a/application/models/education/Moodle_model.php b/application/models/education/Moodle_model.php deleted file mode 100644 index d28026ef9..000000000 --- a/application/models/education/Moodle_model.php +++ /dev/null @@ -1,14 +0,0 @@ -dbTable = 'lehre.tbl_moodle'; - $this->pk = 'moodle_id'; - } -} diff --git a/application/models/organisation/Studienjahr_model.php b/application/models/organisation/Studienjahr_model.php index 902d61ba2..ace9c1525 100644 --- a/application/models/organisation/Studienjahr_model.php +++ b/application/models/organisation/Studienjahr_model.php @@ -10,5 +10,6 @@ class Studienjahr_model extends DB_Model parent::__construct(); $this->dbTable = 'public.tbl_studienjahr'; $this->pk = 'studienjahr_kurzbz'; + $this->hasSequence = false; } } diff --git a/application/models/organisation/Studiensemester_model.php b/application/models/organisation/Studiensemester_model.php index 484956e05..1c5119b2a 100644 --- a/application/models/organisation/Studiensemester_model.php +++ b/application/models/organisation/Studiensemester_model.php @@ -10,6 +10,7 @@ class Studiensemester_model extends DB_Model parent::__construct(); $this->dbTable = 'public.tbl_studiensemester'; $this->pk = 'studiensemester_kurzbz'; + $this->hasSequence = false; } public function getLastOrAktSemester($days = 60) diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index 5192cc316..8298c0d1e 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -3,7 +3,7 @@ class Person_model extends DB_Model { /** - * + * */ public function __construct() { @@ -11,16 +11,16 @@ class Person_model extends DB_Model $this->dbTable = 'public.tbl_person'; $this->pk = 'person_id'; } - + public function getPersonKontaktByZugangscode($zugangscode, $email) { $this->addJoin('public.tbl_kontakt', 'person_id'); - + return $this->loadWhere(array('zugangscode' => $zugangscode, 'kontakt' => $email)); } /** - * + * */ public function checkBewerbung($email, $studiensemester_kurzbz = null) { @@ -34,10 +34,10 @@ class Person_model extends DB_Model return $isEntitled; if (($isEntitled = $this->isEntitled('public.tbl_prestudentstatus', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true) return $isEntitled; - + $checkBewerbungQuery = ''; $parametersArray = array($email, $email, $email); - + if (is_null($studiensemester_kurzbz)) { $checkBewerbungQuery = 'SELECT DISTINCT p.person_id, p.zugangscode, p.insertamum @@ -60,13 +60,13 @@ class Person_model extends DB_Model AND studiensemester_kurzbz = ? ORDER BY p.insertamum DESC LIMIT 1'; - + array_push($parametersArray, $studiensemester_kurzbz); } - + return $this->execQuery($checkBewerbungQuery, $parametersArray); } - + public function updatePerson($person) { if (isset($person['svnr']) && $person['svnr'] != '') @@ -88,7 +88,46 @@ class Person_model extends DB_Model } } } - + return $this->PersonModel->update($person['person_id'], $person); } -} \ No newline at end of file + + /** + * @return void + */ + public function getPersonFromStatus($status_kurzbz, $von, $bis) + { + // Checks if the operation is permitted by the API caller + if (($isEntitled = $this->isEntitled('public.tbl_prestudent', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true) + return $isEntitled; + if (($isEntitled = $this->isEntitled('public.tbl_prestudentstatus', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true) + return $isEntitled; + + $this->addJoin('public.tbl_prestudent', 'person_id'); + + $result = $this->loadTree( + 'public.tbl_person', + array( + 'public.tbl_prestudent' + ), + 'EXISTS ( + SELECT + 1 + FROM + public.tbl_prestudentstatus + JOIN public.tbl_prestudent USING(prestudent_id) + WHERE + person_id=tbl_person.person_id + AND status_kurzbz='.$this->escape($status_kurzbz).' + AND datum >= '.$this->escape($von).' + AND datum <= '.$this->escape($bis).' + )', + array( + 'prestudenten' + ) + ); + + return $result; + } + +} diff --git a/application/views/organisation/studienjahr.php b/application/views/organisation/studienjahr.php new file mode 100644 index 000000000..8cef4634d --- /dev/null +++ b/application/views/organisation/studienjahr.php @@ -0,0 +1,47 @@ +load->view('templates/header', array('title' => 'StudienjahrList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '2:{sorter:false}, 3:{sorter:false}', 'sortList' => '0,1')); +?> +
+| Kurzbez | +Bezeichnung | ++ | + |
|---|---|---|---|
| studienjahr_kurzbz; ?> | +bezeichnung; ?> | ++ + Bearbeiten + + | ++ + Löschen + + | +