diff --git a/application/config/navigation.php b/application/config/navigation.php index 7f1b29932..d123399b6 100644 --- a/application/config/navigation.php +++ b/application/config/navigation.php @@ -9,20 +9,60 @@ $config['navigation_header'] = array( 'link' => site_url(''), 'icon' => '', 'description' => 'FH-Complete', - 'sort' => 1 + 'sort' => 10 ), - 'vilesci' => array( - 'link' => base_url('vilesci'), - 'icon' => '', - 'description' => 'Vilesci', - 'sort' => 2, - 'requiredPermissions' => 'basis/vilesci:r' + 'Organisation' => array( + 'link' => '#', + 'icon' => 'sitemap', + 'description' => 'Organisation', + 'sort' => 20, + 'children'=> array( + 'vilesci' => array( + 'link' => base_url('vilesci'), + 'icon' => '', + 'description' => 'Vilesci', + 'expand' => true, + 'sort' => 1, + 'requiredPermissions' => 'basis/vilesci:r' + ) + ) ), - 'cis' => array( - 'link' => CIS_ROOT, - 'icon' => '', - 'description' => 'CIS', - 'sort' => 3 + 'Lehre' => array( + 'link' => '#', + 'icon' => 'graduation-cap', + 'description' => 'Lehre', + 'sort' => 30, + 'children'=> array( + 'cis' => array( + 'link' => CIS_ROOT, + 'icon' => '', + 'description' => 'CIS', + 'sort' => 10 + ), + 'infocenter' => array( + 'link' => site_url('system/infocenter/InfoCenter'), + 'icon' => 'info', + 'description' => 'Infocenter', + 'expand' => true, + 'sort' => 20, + 'requiredPermissions' => 'infocenter:r' + ), + ) + ), + 'Personen' => array( + 'link' => '#', + 'icon' => 'user', + 'description' => 'Personen', + 'sort' => 40, + 'children'=> array( + 'bpk' => array( + 'link' => site_url('person/BPKWartung'), + 'icon' => '', + 'description' => 'BPK Wartung', + 'sort' => 10, + 'requiredPermissions' => 'admin:r' + ) + ) ) ) ); diff --git a/application/controllers/person/BPKWartung.php b/application/controllers/person/BPKWartung.php new file mode 100644 index 000000000..a8e9b8829 --- /dev/null +++ b/application/controllers/person/BPKWartung.php @@ -0,0 +1,199 @@ + 'admin:r', + 'showDetails' => 'admin:r', + 'saveBPK' => 'admin:rw', + ) + ); + + // Loads models + $this->load->model('crm/akte_model', 'AkteModel'); + $this->load->model('person/person_model', 'PersonModel'); + $this->load->model('person/adresse_model', 'AdressModel'); + + $this->load->library('WidgetLib'); + $this->loadPhrases( + array( + 'global', + 'person', + 'lehre', + 'ui', + 'infocenter', + 'filter' + ) + ); + + $this->setControllerId(); // sets the controller id + } + + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + + /** + * Main page of the InfoCenter tool + */ + public function index() + { + $this->_setNavigationMenuIndex(); // define the navigation menu for this page + + $this->load->view('person/bpk/bpkwartung.php'); + } + + /** + * Personal details page of the InfoCenter tool + * Initialization function, gets person and prestudent data and loads the view with the data + * @param $person_id + */ + public function showDetails() + { + $this->_setNavigationMenuShowDetails(); + $person_id = $this->input->get('person_id'); + + if (!is_numeric($person_id)) + show_error('person id is not numeric!'); + + $personexists = $this->PersonModel->load($person_id); + + if (isError($personexists)) + show_error($personexists->retval); + + if (!hasData($personexists)) + show_error('Person does not exist!'); + + $persondata = $this->_loadPersonData($person_id); + + + $data[self::FHC_CONTROLLER_ID] = $this->getControllerId(); + + $this->load->view('person/bpk/bpkDetails.php', $persondata); + } + + /** + * Saves a ZGV for a prestudent, includes Ort, Datum, Nation for bachelor and master + * @param $prestudent_id + */ + public function saveBPK() + { + $person_id = $this->input->post('person_id'); + $bpk = $this->input->post('bpk'); + + if (isEmptyString($person_id)) + $result = error('PersonID missing'); + else + { + $result = $this->PersonModel->update( + $person_id, + array( + 'bpk' => $bpk, + 'updateamum' => date('Y-m-d H:i:s') + ) + ); + redirect('person/BPKWartung/index'); + } + } + + // ----------------------------------------------------------------------------------------------------------------- + // Private methods + + /** + * Loads all necessary Person data: Stammdaten (name, svnr, contact, ...), Dokumente, Logs and Notizen + * @param $person_id + * @return array + */ + private function _loadPersonData($person_id) + { + $stammdaten = $this->PersonModel->getPersonStammdaten($person_id, true); + + if (isError($stammdaten)) + { + show_error($stammdaten->retval); + } + + if (!isset($stammdaten->retval)) + return null; + + $adresse = $this->AdressModel->getZustellAdresse($person_id); + + if (isError($adresse)) + { + show_error($adresse->retval); + } + + $data = array( + 'stammdaten' => $stammdaten->retval, + 'adresse' => $adresse->retval[0] + ); + + return $data; + } + + /** + * Define the navigation menu for the showDetails page + */ + private function _setNavigationMenuShowDetails() + { + $this->load->library('NavigationLib', array('navigation_page' => 'person/BPKWartung/showDetails')); + + $link = site_url('person/BPKWartung'); + + $this->navigationlib->setSessionMenu( + array( + 'back' => $this->navigationlib->oneLevel( + 'Zurück', // description + $link, // link + array(), // children + 'angle-left', // icon + true, // expand + null, // subscriptDescription + null, // subscriptLinkClass + null, // subscriptLinkValue + '', // target + 1 // sort + ) + ) + ); + } + + /** + * Define the navigation menu for the showDetails page + */ + private function _setNavigationMenuIndex() + { + $this->load->library('NavigationLib', array('navigation_page' => 'person/BPKWartung/index')); + + $link = site_url(); + + $this->navigationlib->setSessionMenu( + array( + 'back' => $this->navigationlib->oneLevel( + 'Zurück', // description + $link, // link + array(), // children + 'angle-left', // icon + true, // expand + null, // subscriptDescription + null, // subscriptLinkClass + null, // subscriptLinkValue + '', // target + 1 // sort + ) + ) + ); + } +} diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php index 6273cb962..b636c3fe5 100644 --- a/application/core/DB_Model.php +++ b/application/core/DB_Model.php @@ -26,6 +26,8 @@ class DB_Model extends FHC_Model private $executedQueryMetaData; private $executedQueryListFields; + private $debugMode; + /** * Constructor */ @@ -42,6 +44,10 @@ class DB_Model extends FHC_Model // Loads the UDF library $this->load->library('UDFLib'); + // Loads the logs library + $this->load->library('LogLib'); + + $this->debugMode = isset($this->db->db_debug) && $this->db->db_debug === true; } // ------------------------------------------------------------------------------------------ @@ -62,7 +68,11 @@ class DB_Model extends FHC_Model if (isError($validate = $this->_manageUDFs($data, $this->dbTable))) return $validate; // DB-INSERT - if ($this->db->insert($this->dbTable, $data)) + $insert = $this->db->insert($this->dbTable, $data); + + $this->_logLastQuery(); + + if ($insert) { // If the table has a primary key that uses a sequence if ($this->hasSequence === true) @@ -126,7 +136,11 @@ class DB_Model extends FHC_Model $this->db->where($tmpId); // DB-UPDATE - if ($this->db->update($this->dbTable, $data)) + $update = $this->db->update($this->dbTable, $data); + + $this->_logLastQuery(); + + if ($update) { return success($id); } @@ -164,7 +178,11 @@ class DB_Model extends FHC_Model } // DB-DELETE - if ($this->db->delete($this->dbTable, $tmpId)) + $delete = $this->db->delete($this->dbTable, $tmpId); + + $this->_logLastQuery(); + + if ($delete) { return success($id); } @@ -201,15 +219,7 @@ class DB_Model extends FHC_Model $tmpId = array($this->pk => $id); } - // DB-SELECT - if ($result = $this->db->get_where($this->dbTable, $tmpId)) - { - return success($this->_toPhp($result)); - } - else - { - return error($this->db->error(), FHC_DB_ERROR); - } + return $this->loadWhere($tmpId); } /** @@ -223,7 +233,11 @@ class DB_Model extends FHC_Model if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE); // Execute query - if ($result = $this->db->get_where($this->dbTable, $where)) + $result = $this->db->get_where($this->dbTable, $where); + + $this->_logLastQuery(); + + if ($result) { return success($this->_toPhp($result)); } @@ -292,6 +306,9 @@ class DB_Model extends FHC_Model // Execute the query $resultDB = $this->db->get_where($this->dbTable, $where); + + $this->_logLastQuery(); + // If everything went ok... if ($resultDB) { @@ -603,7 +620,6 @@ class DB_Model extends FHC_Model // Workaround to get metadata from this table $result = $this->db->query(sprintf(DB_Model::QUERY_LIST_FIELDS, $this->dbTable)); - if (is_object($result)) { $listFields = $result->list_fields(); @@ -736,6 +752,8 @@ class DB_Model extends FHC_Model $resultDB = $this->db->query($query); } + $this->_logLastQuery(); + // If no errors occurred if ($resultDB) { @@ -940,4 +958,12 @@ class DB_Model extends FHC_Model return $this->execQuery($query, array(strtolower($schema), strtolower($table))); } + + /** + * + */ + private function _logLastQuery() + { + if ($this->debugMode) $this->loglib->logDebug($this->db->last_query()); + } } diff --git a/application/libraries/LogLib.php b/application/libraries/LogLib.php index a42132644..cb0541003 100644 --- a/application/libraries/LogLib.php +++ b/application/libraries/LogLib.php @@ -16,27 +16,48 @@ class LogLib const CLASS_POSTFIX = '->'; const LINE_SEPARATOR = ':'; + // -------------------------------------------------------------------------------------------------------------- + // Public methods + /** - * format + * logDebug */ - private function format($class, $function, $line) + public function logDebug($message) { - $formatted = LogLib::CALLER_PREFIX; - - if (!is_null($class) && $class != '') - { - $formatted .= $class.LogLib::CLASS_POSTFIX; - } - - $formatted .= $function.LogLib::LINE_SEPARATOR.$line.LogLib::CALLER_POSTFIX.' '; - - return $formatted; + $this->_log(LogLib::DEBUG, $message); } /** - * getCaller + * logInfo */ - private function getCaller() + public function logInfo($message) + { + $this->_log(LogLib::INFO, $message); + } + + /** + * logError + */ + public function logError($message) + { + $this->_log(LogLib::ERROR, $message); + } + + // -------------------------------------------------------------------------------------------------------------- + // Private methods + + /** + * log + */ + private function _log($level, $message) + { + log_message($level, $this->_getCaller().$message); + } + + /** + * _getCaller + */ + private function _getCaller() { $classIndex = 3; $functionIndex = 3; @@ -60,38 +81,23 @@ class LogLib $line = $backtrace_arr[$lineIndex]['line']; } - return $this->format($class, $function, $line); + return $this->_format($class, $function, $line); } /** - * log + * format */ - private function log($level, $message) + private function _format($class, $function, $line) { - log_message($level, $this->getCaller().$message); - } + $formatted = LogLib::CALLER_PREFIX; - /** - * logDebug - */ - public function logDebug($message) - { - $this->log(LogLib::DEBUG, $message); - } + if (!is_null($class) && $class != '') + { + $formatted .= $class.LogLib::CLASS_POSTFIX; + } - /** - * logInfo - */ - public function logInfo($message) - { - $this->log(LogLib::INFO, $message); - } + $formatted .= $function.LogLib::LINE_SEPARATOR.$line.LogLib::CALLER_POSTFIX.' '; - /** - * logError - */ - public function logError($message) - { - $this->log(LogLib::ERROR, $message); + return $formatted; } } diff --git a/application/models/person/Adresse_model.php b/application/models/person/Adresse_model.php index 3b17ce956..e049f5ad6 100644 --- a/application/models/person/Adresse_model.php +++ b/application/models/person/Adresse_model.php @@ -11,4 +11,15 @@ class Adresse_model extends DB_Model $this->dbTable = 'public.tbl_adresse'; $this->pk = 'adresse_id'; } + + + /** + * gets person data from uid + * @param $uid + * @return array + */ + public function getZustellAdresse($person_id) + { + return $this->loadWhere(array('person_id' => $person_id, 'zustelladresse'=> true)); + } } diff --git a/application/views/person/bpk/bpkData.php b/application/views/person/bpk/bpkData.php new file mode 100644 index 000000000..f7bf75b50 --- /dev/null +++ b/application/views/person/bpk/bpkData.php @@ -0,0 +1,58 @@ + ' + SELECT + person_id, vorname, nachname, geschlecht, svnr, ersatzkennzeichen, matr_nr, + staatsbuergerschaft, gebdatum + FROM + public.tbl_person + WHERE + matr_nr is not null + AND bpk is null + AND EXISTS(SELECT 1 FROM public.tbl_benutzer JOIN public.tbl_student ON(uid=student_uid) AND + person_id=tbl_person.person_id AND tbl_benutzer.aktiv=true) + ', + 'requiredPermissions' => 'admin', + 'additionalColumns' => array('Details'), + 'columnsAliases' => array( + 'PersonID', + ucfirst($this->p->t('person', 'vorname')) , + ucfirst($this->p->t('person', 'nachname')), + ucfirst($this->p->t('person', 'geschlecht')), + ucfirst($this->p->t('person', 'svnr')), + ucfirst($this->p->t('person', 'ersatzkennzeichen')), + ucfirst($this->p->t('person', 'matrikelnummer')), + ucfirst($this->p->t('person', 'staatsbuergerschaft')), + ucfirst($this->p->t('person', 'geburtsdatum')), + ), + 'formatRow' => function($datasetRaw) { + + /* NOTE: Dont use $this here for PHP Version compatibility */ + $datasetRaw->{'Details'} = sprintf( + 'Details', + site_url('person/BPKWartung/showDetails'), + $datasetRaw->{'person_id'}, + 'index', + (isset($_GET['fhc_controller_id'])?$_GET['fhc_controller_id']:'') + ); + + if ($datasetRaw->{'ersatzkennzeichen'} == null) + { + $datasetRaw->{'ersatzkennzeichen'} = '-'; + } + if ($datasetRaw->{'svnr'} == null) + { + $datasetRaw->{'svnr'} = '-'; + } + + return $datasetRaw; + } + ); + + $filterWidgetArray['app'] = 'core'; + $filterWidgetArray['datasetName'] = 'overview'; + $filterWidgetArray['filterKurzbz'] = 'BPKWartung'; + $filterWidgetArray['filter_id'] = $this->input->get('filter_id'); + + echo $this->widgetlib->widget('FilterWidget', $filterWidgetArray); +?> diff --git a/application/views/person/bpk/bpkDetails.php b/application/views/person/bpk/bpkDetails.php new file mode 100644 index 000000000..e771cb7f5 --- /dev/null +++ b/application/views/person/bpk/bpkDetails.php @@ -0,0 +1,153 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'bPK Details', + 'jquery' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'jqueryui' => true, + 'ajaxlib' => true, + 'tablesorter' => true, + 'tinymce' => true, + 'sbadmintemplate' => true, + 'addons' => true, + 'navigationwidget' => true, + 'customCSSs' => array( + 'public/css/sbadmin2/admintemplate.css', + 'public/css/sbadmin2/tablesort_bootstrap.css', + 'public/css/infocenter/infocenterDetails.css' + ), + 'customJSs' => array( + 'public/js/bootstrapper.js', + 'public/js/tablesort/tablesort.js' + ), + 'phrases' => array( + 'ui' => array( + 'gespeichert', + 'fehlerBeimSpeichern' + ), + 'global' => array( + 'bis', + 'zeilen' + ) + ) + ) + ); +?> +
+| p->t('person','titelpre')) ?> | +titelpre ?> | +
| p->t('person','vorname')) ?> | +vorname ?> | +
| p->t('person','nachname')) ?> | ++ nachname ?> | +
| p->t('person','titelpost')) ?> | +titelpost ?> | +
| p->t('person','geburtsdatum')) ?> | ++ gebdatum), 'd.m.Y') ?> | +
| p->t('person','svnr')) ?> | ++ svnr ?> | +
| p->t('person','ersatzkennzeichen')) ?> | ++ ersatzkennzeichen ?> | +
| p->t('person','staatsbuergerschaft')) ?> | ++ staatsbuergerschaft ?> | +
| p->t('person','geschlecht')) ?> | ++ geschlecht ?> | +
| p->t('person','bpk')) ?> | ++ bpk ?> | +
| p->t('person','postleitzahl')) ?> | ++ plz ?> | +
| p->t('person','strasse')) ?> | ++ strasse ?> | +