diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d712a143..fe2a855d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -119,7 +119,7 @@ - **[DEPRECATED]** Spalte ort_kurzbz in tbl_reihungstest wird nicht mehr verwendet und in zukünftigen Versionen entfernt Zum Update auf diese Version folgen Sie den Anweisungen auf folgender Seite: -http://fhcomplete.technikum-wien.at/dokuwiki/doku.php?id=fh-complete:codeigniter +https://wiki.fhcomplete.org/doku.php?id=fh-complete:codeigniter ## [3.1.0] - 2015-11-12 ### Added diff --git a/README.md b/README.md index c4b24c64d..d5620010a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # FH-Complete -* [FH-Complete Homepage](http://www.fhcomplete.org) -* [Wiki](http://fhcomplete.technikum-wien.at/dokuwiki/) +* [FH-Complete Homepage](https://www.fhcomplete.org) +* [Wiki](https://wiki.fhcomplete.org/) * [Changelog](CHANGELOG.md) diff --git a/application/config/config.php b/application/config/config.php index 1c0993c92..591b84f2c 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -503,3 +503,15 @@ $config['rewrite_short_tags'] = FALSE; | Array: array('10.0.1.200', '192.168.5.0/24') */ $config['proxy_ips'] = ''; + +/* +|-------------------------------------------------------------------------- +| FHComplete Build Version +|-------------------------------------------------------------------------- +| +| Version Number of the Current Build +| This is used to invalidate Cache for JS and CSS Files +| +| Example: 2019102901 +*/ +$config['fhcomplete_build_version'] = '2019102903'; diff --git a/application/config/navigation.php b/application/config/navigation.php index d6f4b8452..9253c87a1 100644 --- a/application/config/navigation.php +++ b/application/config/navigation.php @@ -14,6 +14,7 @@ $config['navigation_header'] = array( 'icon' => 'sitemap', 'description' => 'Organisation', 'sort' => 20, + 'requiredPermissions' => 'basis/vilesci:r', 'children'=> array( 'vilesci' => array( 'link' => base_url('vilesci'), @@ -30,6 +31,7 @@ $config['navigation_header'] = array( 'icon' => 'graduation-cap', 'description' => 'Lehre', 'sort' => 30, + 'requiredPermissions' => 'basis/vilesci:r', 'children'=> array( 'cis' => array( 'link' => CIS_ROOT, @@ -51,6 +53,16 @@ $config['navigation_header'] = array( 'sort' => 30, 'requiredPermissions' => 'infocenter:r' ), + 'lehrauftrag' => array( + 'link' => site_url('lehre/lehrauftrag/Lehrauftrag/Dashboard'), + 'description' => 'Lehrauftrag', + 'expand' => true, + 'sort' => 40, + 'requiredPermissions' => array( + 'lehre/lehrauftrag_bestellen:r', + 'lehre/lehrauftrag_erteilen:r' + ) + ) ) ), 'Personen' => array( @@ -58,6 +70,7 @@ $config['navigation_header'] = array( 'icon' => 'user', 'description' => 'Personen', 'sort' => 40, + 'requiredPermissions' => 'basis/vilesci:r', 'children'=> array( 'bpk' => array( 'link' => site_url('person/BPKWartung'), @@ -82,6 +95,13 @@ $config['navigation_header'] = array( 'expand' => true, 'sort' => 10, 'requiredPermissions' => 'admin:r' + ), + 'logsviewer' => array( + 'link' => site_url('system/LogsViewer'), + 'description' => 'Logs', + 'expand' => true, + 'sort' => 20, + 'requiredPermissions' => 'system/developer:r' ) ) ) @@ -118,3 +138,62 @@ $config['navigation_menu']['organisation/Reihungstest/index'] = array( 'target' => '_blank' ) ); + +$config['navigation_menu']['lehre/lehrauftrag/Lehrauftrag/*'] = array( + 'lehrauftragDashboard' => array( + 'link' => site_url('lehre/lehrauftrag/Lehrauftrag/Dashboard'), + 'description' => 'Dashboard', + 'icon' => 'dashboard', + 'sort' => 1, + 'requiredPermissions' => array('lehre/lehrauftrag_bestellen:r','lehre/lehrauftrag_erteilen:r') + ),'lehrauftragBestellen' => array( + 'link' => site_url('lehre/lehrauftrag/Lehrauftrag'), + 'description' => 'Lehrauftrag bestellen', + 'icon' => '', + 'sort' => 1, + 'requiredPermissions' => 'lehre/lehrauftrag_bestellen:r' + ), + 'lehrauftragErteilen' => array( + 'link' => site_url('lehre/lehrauftrag/LehrauftragErteilen'), + 'description' => 'Lehrauftrag erteilen', + 'icon' => '', + 'sort' => 1, + 'requiredPermissions' => 'lehre/lehrauftrag_erteilen:r' + ), + 'lehrauftragLehrendeÜbersicht' => array( + 'link' => site_url('lehre/lehrauftrag/Lehrauftrag/LehrendeUebersicht'), + 'description' => 'Lehrendenübersicht', + 'icon' => '', + 'sort' => 1, + 'requiredPermissions' => array('lehre/lehrauftrag_erteilen:r') + ) +); +$config['navigation_menu']['lehre/lehrauftrag/LehrauftragErteilen/*'] = array( + 'lehrauftragDashboard' => array( + 'link' => site_url('lehre/lehrauftrag/Lehrauftrag/Dashboard'), + 'description' => 'Dashboard', + 'icon' => 'dashboard', + 'sort' => 1, + 'requiredPermissions' => array('lehre/lehrauftrag_bestellen:r','lehre/lehrauftrag_erteilen:r') + ),'lehrauftragBestellen' => array( + 'link' => site_url('lehre/lehrauftrag/Lehrauftrag'), + 'description' => 'Lehrauftrag bestellen', + 'icon' => '', + 'sort' => 1, + 'requiredPermissions' => 'lehre/lehrauftrag_bestellen:r' + ), + 'lehrauftragErteilen' => array( + 'link' => site_url('lehre/lehrauftrag/LehrauftragErteilen'), + 'description' => 'Lehrauftrag erteilen', + 'icon' => '', + 'sort' => 1, + 'requiredPermissions' => 'lehre/lehrauftrag_erteilen:r' + ), + 'lehrauftragLehrendeÜbersicht' => array( + 'link' => site_url('lehre/lehrauftrag/Lehrauftrag/LehrendeUebersicht'), + 'description' => 'Lehrendenübersicht', + 'icon' => '', + 'sort' => 1, + 'requiredPermissions' => array('lehre/lehrauftrag_erteilen:r') + ) +); diff --git a/application/config/rest.php b/application/config/rest.php index 9bbbf40ef..833a99881 100644 --- a/application/config/rest.php +++ b/application/config/rest.php @@ -1,6 +1,6 @@ '1234', 'test' => 'test']; - -/* -|-------------------------------------------------------------------------- -| Global IP Whitelisting -|-------------------------------------------------------------------------- -| -| Limit connections to your REST server to whitelisted IP addresses +| Limit connections to your REST server to White-listed IP addresses | | Usage: | 1. Set to TRUE and select an auth option for extreme security (client's IP -| address must be in whitelist and they must also log in) -| 2. Set to TRUE with auth set to FALSE to allow whitelisted IPs access with no login -| 3. Set to FALSE but set 'auth_override_class_method' to 'whitelist' to -| restrict certain methods to IPs in your whitelist +| address must be in white-list and they must also log in) +| 2. Set to TRUE with auth set to FALSE to allow White-listed IPs access with no login +| 3. Set to FALSE but set 'auth_override_class_method' to 'white-list' to +| restrict certain methods to IPs in your white-list | */ $config['rest_ip_whitelist_enabled'] = TRUE; /* |-------------------------------------------------------------------------- -| REST IP Whitelist +| REST IP White-list |-------------------------------------------------------------------------- | | Limit connections to your REST server with a comma separated @@ -240,42 +107,6 @@ $config['rest_ip_whitelist_enabled'] = TRUE; */ $config['rest_ip_whitelist'] = '127.0.0.1'; -/* -|-------------------------------------------------------------------------- -| Global IP Blacklisting -|-------------------------------------------------------------------------- -| -| Prevent connections to the REST server from blacklisted IP addresses -| -| Usage: -| 1. Set to TRUE and add any IP address to 'rest_ip_blacklist' -| -*/ -$config['rest_ip_blacklist_enabled'] = FALSE; - -/* -|-------------------------------------------------------------------------- -| REST IP Blacklist -|-------------------------------------------------------------------------- -| -| Prevent connections from the following IP addresses -| -| e.g: '123.456.789.0, 987.654.32.1' -| -*/ -$config['rest_ip_blacklist'] = ''; - -/* -|-------------------------------------------------------------------------- -| REST Database Group -|-------------------------------------------------------------------------- -| -| Connect to a database group for keys, logging, etc. It will only connect -| if you have any of these features enabled -| -*/ -$config['rest_database_group'] = 'default'; - /* |-------------------------------------------------------------------------- | REST API Keys Table Name @@ -298,6 +129,7 @@ $config['rest_keys_table'] = 'ci_apikey'; | Default table schema: | CREATE TABLE `keys` ( | `id` INT(11) NOT NULL AUTO_INCREMENT, +| `user_id` INT(11) NOT NULL, | `key` VARCHAR(40) NOT NULL, | `level` INT(2) NOT NULL, | `ignore_limits` TINYINT(1) NOT NULL DEFAULT '0', @@ -310,45 +142,6 @@ $config['rest_keys_table'] = 'ci_apikey'; */ $config['rest_enable_keys'] = TRUE; -/* -|-------------------------------------------------------------------------- -| REST Table Key Column Name -|-------------------------------------------------------------------------- -| -| If not using the default table schema in 'rest_enable_keys', specify the -| column name to match e.g. my_key -| -*/ -$config['rest_key_column'] = 'key'; - -/* -|-------------------------------------------------------------------------- -| REST API Limits method -|-------------------------------------------------------------------------- -| -| Specify the method used to limit the API calls -| -| Available methods are : -| $config['rest_limits_method'] = 'API_KEY'; // Put a limit per api key -| $config['rest_limits_method'] = 'METHOD_NAME'; // Put a limit on method calls -| $config['rest_limits_method'] = 'ROUTED_URL'; // Put a limit on the routed URL -| -*/ -$config['rest_limits_method'] = 'ROUTED_URL'; - -/* -|-------------------------------------------------------------------------- -| REST Key Length -|-------------------------------------------------------------------------- -| -| Length of the created keys. Check your default database schema on the -| maximum length allowed -| -| Note: The maximum length is 40 -| -*/ -$config['rest_key_length'] = 40; - /* |-------------------------------------------------------------------------- | REST API Key Variable @@ -364,156 +157,10 @@ $config['rest_key_name'] = 'FHC-API-KEY'; /* |-------------------------------------------------------------------------- -| REST Enable Logging +| REST Methods name format |-------------------------------------------------------------------------- | -| When set to TRUE, the REST API will log actions based on the column names 'key', 'date', -| 'time' and 'ip_address'. This is a general rule that can be overridden in the -| $this->method array for each controller -| -| Default table schema: -| CREATE TABLE `logs` ( -| `id` INT(11) NOT NULL AUTO_INCREMENT, -| `uri` VARCHAR(255) NOT NULL, -| `method` VARCHAR(6) NOT NULL, -| `params` TEXT DEFAULT NULL, -| `api_key` VARCHAR(40) NOT NULL, -| `ip_address` VARCHAR(45) NOT NULL, -| `time` INT(11) NOT NULL, -| `rtime` FLOAT DEFAULT NULL, -| `authorized` VARCHAR(1) NOT NULL, -| `response_code` smallint(3) DEFAULT '0', -| PRIMARY KEY (`id`) -| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +| REST Controllers methods name format | */ -$config['rest_enable_logging'] = FALSE; - -/* -|-------------------------------------------------------------------------- -| REST API Logs Table Name -|-------------------------------------------------------------------------- -| -| If not using the default table schema in 'rest_enable_logging', specify the -| table name to match e.g. my_logs -| -*/ -$config['rest_logs_table'] = 'logs'; - -/* -|-------------------------------------------------------------------------- -| REST Method Access Control -|-------------------------------------------------------------------------- -| When set to TRUE, the REST API will check the access table to see if -| the API key can access that controller. 'rest_enable_keys' must be enabled -| to use this -| -| Default table schema: -| CREATE TABLE `access` ( -| `id` INT(11) unsigned NOT NULL AUTO_INCREMENT, -| `key` VARCHAR(40) NOT NULL DEFAULT '', -| `controller` VARCHAR(50) NOT NULL DEFAULT '', -| `date_created` DATETIME DEFAULT NULL, -| `date_modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -| PRIMARY KEY (`id`) -| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -| -*/ -$config['rest_enable_access'] = FALSE; - -/* -|-------------------------------------------------------------------------- -| REST API Access Table Name -|-------------------------------------------------------------------------- -| -| If not using the default table schema in 'rest_enable_access', specify the -| table name to match e.g. my_access -| -*/ -$config['rest_access_table'] = 'access'; - -/* -|-------------------------------------------------------------------------- -| REST API Param Log Format -|-------------------------------------------------------------------------- -| -| When set to TRUE, the REST API log parameters will be stored in the database as JSON -| Set to FALSE to log as serialized PHP -| -*/ -$config['rest_logs_json_params'] = FALSE; - -/* -|-------------------------------------------------------------------------- -| REST Enable Limits -|-------------------------------------------------------------------------- -| -| When set to TRUE, the REST API will count the number of uses of each method -| by an API key each hour. This is a general rule that can be overridden in the -| $this->method array in each controller -| -| Default table schema: -| CREATE TABLE `limits` ( -| `id` INT(11) NOT NULL AUTO_INCREMENT, -| `uri` VARCHAR(255) NOT NULL, -| `count` INT(10) NOT NULL, -| `hour_started` INT(11) NOT NULL, -| `api_key` VARCHAR(40) NOT NULL, -| PRIMARY KEY (`id`) -| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -| -| To specify the limits within the controller's __construct() method, add per-method -| limits with: -| -| $this->method['METHOD_NAME']['limit'] = [NUM_REQUESTS_PER_HOUR]; -| -| See application/controllers/api/example.php for examples -*/ -$config['rest_enable_limits'] = FALSE; - -/* -|-------------------------------------------------------------------------- -| REST API Limits Table Name -|-------------------------------------------------------------------------- -| -| If not using the default table schema in 'rest_enable_limits', specify the -| table name to match e.g. my_limits -| -*/ -$config['rest_limits_table'] = 'limits'; - -/* -|-------------------------------------------------------------------------- -| REST Ignore HTTP Accept -|-------------------------------------------------------------------------- -| -| Set to TRUE to ignore the HTTP Accept and speed up each request a little. -| Only do this if you are using the $this->rest_format or /format/xml in URLs -| -*/ -$config['rest_ignore_http_accept'] = FALSE; - -/* -|-------------------------------------------------------------------------- -| REST AJAX Only -|-------------------------------------------------------------------------- -| -| Set to TRUE to allow AJAX requests only. Set to FALSE to accept HTTP requests -| -| Note: If set to TRUE and the request is not AJAX, a 505 response with the -| error message 'Only AJAX requests are accepted.' will be returned. -| -| Hint: This is good for production environments -| -*/ -$config['rest_ajax_only'] = FALSE; - -/* -|-------------------------------------------------------------------------- -| REST Language File -|-------------------------------------------------------------------------- -| -| Language file to load from the language directory -| -*/ -$config['rest_language'] = 'english'; +$config['rest_methods_name_format'] = '%2$s%1$s'; diff --git a/application/config/routes.php b/application/config/routes.php index 791b6d03c..36bfdcb1e 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -1,5 +1,6 @@ my_controller/index -| my-controller/my-method -> my_controller/my_method +| Examples: my-controller/index -> my_controller/index +| my-controller/my-method -> my_controller/my_method */ $route['default_controller'] = 'Vilesci'; -$route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; // Class name conflicts @@ -59,4 +59,4 @@ $route['api/v1/organisation/[F|f]achbereich/(:any)'] = 'api/v1/organisation/fach $route['api/v1/organisation/[G|g]eschaeftsjahr/(:any)'] = 'api/v1/organisation/geschaeftsjahr2/$1'; $route['api/v1/organisation/[O|o]rganisationseinheit/(:any)'] = 'api/v1/organisation/organisationseinheit2/$1'; $route['api/v1/ressource/[B|b]etriebsmittelperson/(:any)'] = 'api/v1/ressource/betriebsmittelperson2/$1'; -$route['api/v1/system/[S|s]prache/(:any)'] = 'api/v1/system/sprache2/$1'; \ No newline at end of file +$route['api/v1/system/[S|s]prache/(:any)'] = 'api/v1/system/sprache2/$1'; diff --git a/application/controllers/Redirect.php b/application/controllers/Redirect.php index 8a24c590d..8a107b4b3 100644 --- a/application/controllers/Redirect.php +++ b/application/controllers/Redirect.php @@ -37,12 +37,13 @@ class Redirect extends FHC_Controller public function redirectByToken($token) { $msg = $this->MessageTokenModel->getMessageByToken($token); - if ($msg->error) + if (isError($msg)) { - show_error($msg->retval); + show_error(getError($msg)); } - $oe_kurzbz = $msg->retval[0]->oe_kurzbz; + $oe_kurzbz = null; + if (hasData($msg)) $oe_kurzbz = getData($msg)[0]->oe_kurzbz; if ($oe_kurzbz != null && $oe_kurzbz != '') { @@ -51,7 +52,7 @@ class Redirect extends FHC_Controller $getOERoot = $this->MessageTokenModel->getOERoot($oe_kurzbz); if (isSuccess($getOERoot)) // If no errors occurred { - $organisationRoot = $getOERoot->retval; + $organisationRoot = getData($getOERoot); } else { diff --git a/application/controllers/api/v1/CheckUserAuth.php b/application/controllers/api/v1/CheckUserAuth.php index 4d6522fe2..ee751e886 100644 --- a/application/controllers/api/v1/CheckUserAuth.php +++ b/application/controllers/api/v1/CheckUserAuth.php @@ -2,7 +2,7 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); -class CheckUserAuth extends REST_Controller +class CheckUserAuth extends RESTFul_Controller { /** * Course API constructor. diff --git a/application/controllers/api/v1/Test.php b/application/controllers/api/v1/Test.php index 41feb1a16..c9918f52b 100644 --- a/application/controllers/api/v1/Test.php +++ b/application/controllers/api/v1/Test.php @@ -5,7 +5,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); /** * Testing class for REST calls and authentication */ -class Test extends REST_Controller +class Test extends RESTFul_Controller { public function __construct() { diff --git a/application/controllers/api/v1/person/Benutzer.php b/application/controllers/api/v1/person/Benutzer.php index 23fcdadac..f1ea4f149 100644 --- a/application/controllers/api/v1/person/Benutzer.php +++ b/application/controllers/api/v1/person/Benutzer.php @@ -37,7 +37,7 @@ class Benutzer extends APIv1_Controller if (isset($uid)) { - $result = $this->BenutzerModel->load($uid); + $result = $this->BenutzerModel->load(array('uid' => $uid)); $this->response($result, REST_Controller::HTTP_OK); } diff --git a/application/controllers/api/v1/system/CallerLibrary.php b/application/controllers/api/v1/system/CallerLibrary.php deleted file mode 100644 index 594786384..000000000 --- a/application/controllers/api/v1/system/CallerLibrary.php +++ /dev/null @@ -1,77 +0,0 @@ - 'admin:rw')); - - // Loads the CallerLib - $this->load->library('CallerLib'); - } - - /** - * Manages a HTTP get call - */ - public function getCall() - { - // Start me up! - $result = $this->callerlib->callLibrary($this->get()); - - // Print the result - $this->response($result, REST_Controller::HTTP_OK); - } - - /** - * @return void - */ - public function postCall() - { - // Start me up! - $result = $this->callerlib->callLibrary($this->post()); - - // Print the result - $this->response($result, REST_Controller::HTTP_OK); - } - - /** - * @return void - */ - public function putCall() - { - // Start me up! - $result = $this->callerlib->callLibrary($this->put()); - - // Print the result - $this->response($result, REST_Controller::HTTP_OK); - } - - /** - * @return void - */ - public function deleteCall() - { - // Start me up! - $result = $this->callerlib->callLibrary($this->delete()); - - // Print the result - $this->response($result, REST_Controller::HTTP_OK); - } -} diff --git a/application/controllers/api/v1/system/CallerModel.php b/application/controllers/api/v1/system/CallerModel.php deleted file mode 100644 index 68296aff8..000000000 --- a/application/controllers/api/v1/system/CallerModel.php +++ /dev/null @@ -1,77 +0,0 @@ - 'admin:rw')); - - // Loads the CallerLib - $this->load->library('CallerLib'); - } - - /** - * Manages a HTTP get call - */ - public function getCall() - { - // Start me up! - $result = $this->callerlib->callModel($this->get()); - - // Print the result - $this->response($result, REST_Controller::HTTP_OK); - } - - /** - * @return void - */ - public function postCall() - { - // Start me up! - $result = $this->callerlib->callModel($this->post()); - - // Print the result - $this->response($result, REST_Controller::HTTP_OK); - } - - /** - * @return void - */ - public function putCall() - { - // Start me up! - $result = $this->callerlib->callModel($this->put()); - - // Print the result - $this->response($result, REST_Controller::HTTP_OK); - } - - /** - * @return void - */ - public function deleteCall() - { - // Start me up! - $result = $this->callerlib->callModel($this->delete()); - - // Print the result - $this->response($result, REST_Controller::HTTP_OK); - } -} diff --git a/application/controllers/crm/Statusgrund.php b/application/controllers/crm/Statusgrund.php index 472270ef3..344ac06dc 100644 --- a/application/controllers/crm/Statusgrund.php +++ b/application/controllers/crm/Statusgrund.php @@ -35,7 +35,7 @@ class Statusgrund extends Auth_Controller $status = $this->StatusModel->load(); if ($status->error) { - show_error($status->retval); + show_error(getError($status)); } $data = array ( @@ -50,7 +50,7 @@ class Statusgrund extends Auth_Controller $statusGrund = $this->StatusgrundModel->loadWhere(array("status_kurzbz" => $status_kurzbz)); if ($statusGrund->error) { - show_error($statusGrund->retval); + show_error(getError($statusGrund)); } $data = array ( @@ -66,13 +66,13 @@ class Statusgrund extends Auth_Controller $statusGrund = $this->StatusgrundModel->load($statusgrund_id); if ($statusGrund->error) { - show_error($statusGrund->retval); + show_error(getError($statusGrund)); } $sprache = $this->SpracheModel->loadWhere(array('content' => true)); if ($sprache->error) { - show_error($sprache->retval); + show_error(getError($sprache)); } $data = array ( @@ -89,13 +89,13 @@ class Statusgrund extends Auth_Controller $status = $this->StatusModel->load($status_id); if ($status->error) { - show_error($status->retval); + show_error(getError($status)); } $sprache = $this->SpracheModel->loadWhere(array('content' => true)); if ($sprache->error) { - show_error($sprache->retval); + show_error(getError($sprache)); } $data = array ( @@ -112,7 +112,7 @@ class Statusgrund extends Auth_Controller $sprache = $this->SpracheModel->loadWhere(array('content' => true)); if ($sprache->error) { - show_error($sprache->retval); + show_error(getError($sprache)); } $data = array ( @@ -184,7 +184,7 @@ class Statusgrund extends Auth_Controller if ($statusgrund->error) { - show_error($statusgrund->retval); + show_error(getError($statusgrund)); } redirect("/crm/Statusgrund/editGrund/" . $statusgrund_id . "/" . true); @@ -252,7 +252,7 @@ class Statusgrund extends Auth_Controller if ($statusgrund->error) { - show_error($statusgrund->retval); + show_error(getError($statusgrund)); } redirect("/crm/Statusgrund/editGrund/" . $statusgrund->retval . "/" . true); @@ -297,7 +297,7 @@ class Statusgrund extends Auth_Controller if ($status->error) { - show_error($status->retval); + show_error(getError($status)); } redirect("/crm/Statusgrund/editStatus/" . $status_kurzbz . "/" . true); diff --git a/application/controllers/jobs/AmpelMail.php b/application/controllers/jobs/AmpelMail.php index e29cac8fd..67acd76d0 100644 --- a/application/controllers/jobs/AmpelMail.php +++ b/application/controllers/jobs/AmpelMail.php @@ -121,13 +121,13 @@ class AmpelMail extends CLI_Controller } elseif (isError($result_ampel_user)) { - show_error($result_ampel_user->error); + show_error(getError($result_ampel_user)); } } } elseif (isError($result_active_ampeln)) { - show_error($result_active_ampeln->error); + show_error(getError($result_active_ampeln)); } // Send mails for new ampeln merged by user diff --git a/application/controllers/jobs/LehrauftragJob.php b/application/controllers/jobs/LehrauftragJob.php new file mode 100644 index 000000000..2f6b928c7 --- /dev/null +++ b/application/controllers/jobs/LehrauftragJob.php @@ -0,0 +1,536 @@ +load->model('accounting/Vertrag_model', 'VertragModel'); + $this->load->model('accounting/Vertragvertragsstatus_model', 'VertragvertragsstatusModel'); + $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); + $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); + $this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); + + // Load libraries + $this->load->library('PermissionLib'); + + // Load helpers + $this->load->helper('hlp_sancho_helper'); + } + + /** + * This daily job sends information about all lehr-/projektauftraege ordered (and not approved) the day bofore. + * Receivers: Department-/Kompetenzfeldleiter + **/ + public function mailLehrauftraegeToApprove() + { + // Get vertrag_ids of lehrauftraege that had been ordered and had NOT been approved or cancelled YESTERDAY + $this->VertragvertragsstatusModel->addSelect('vertrag_id'); + $result = $this->VertragvertragsstatusModel->getOrdered_fromDate('YESTERDAY'); + + // Get lehrveranstaltung_ids and studiensemester of the lehr-/or projektauftrag contracts + $lehreinheit_data_arr = array(); + if ($vertrag_arr = getData($result)) + { + foreach ($vertrag_arr as $vertrag) + { + $result = $this->VertragModel->getLehreinheitData($vertrag->vertrag_id, 'lehrveranstaltung_id, studiensemester_kurzbz'); + + if (hasData($result)) + { + $obj = new StdClass(); + $obj->lehrveranstaltung_id = $result->retval[0]->lehrveranstaltung_id; + $obj->studiensemester_kurzbz = $result->retval[0]->studiensemester_kurzbz; + $lehreinheit_data_arr []= $obj; + } + } + } + + /** + * Build the data array to be used in the email. Data array is clustered as follows: + * Array + * [studiensemester_kurzbz] // studiensemester of lehreinheit + * Array + * [oe_kurzbz] // oe of lehreinheits lehrveranstaltung + * [oe_bezeichnung] + * Array + * [stg_kz] // stg of lehreinheits lehrveranstaltung + * [stg_kurzbz] + * [stg_bezeichnung] + * [amount] // amount of new ordered lehrauftraege of that stg + */ + $data_arr = array(); + foreach ($lehreinheit_data_arr as $lehreinheit_data) + { + $result = $this->_getLVData($lehreinheit_data->lehrveranstaltung_id); + + if (hasData($result)) + { + // Search if studiensemester exists in data_arr + $ss_index = array_search($lehreinheit_data->studiensemester_kurzbz, array_column($data_arr, 'studiensemester_kurzbz')); + + // If studiensemester is new, add studienesemester, oe and stg + if ($ss_index === false) + { + $data = array( + 'studiensemester_kurzbz' => $lehreinheit_data->studiensemester_kurzbz + ); + + $data []= array( + 'oe_kurzbz' => $result->retval[0]->oe_kurzbz, + 'oe_bezeichnung' => $result->retval[0]->lv_oe_bezeichnung + ); + + // Add stg data to oe, start amount with 1 + $data[0][] = array( + 'stg_kz' => $result->retval[0]->studiengang_kz, + 'stg_kurzbz' => strtoupper($result->retval[0]->stg_typ. $result->retval[0]->stg_kurzbz), + 'stg_bezeichnung' => $result->retval[0]->lv_stg_bezeichnung, + 'amount' => 1 + ); + + // Push to final data_arr + $data_arr []= $data; + } + // Else if studiensemester exists + else + { + // Search if oe exists inside existing studiensemester of data_arr + $oe_index = array_search($result->retval[0]->oe_kurzbz, array_column($data_arr[$ss_index], 'oe_kurzbz')); + + // If oe is new, add oe and stg to studiensemester + if ($oe_index === false) + { + // Add oe data + $data_arr[$ss_index][] = array( + 'oe_kurzbz' => $result->retval[0]->oe_kurzbz, + 'oe_bezeichnung' => $result->retval[0]->lv_oe_bezeichnung, + + // Add stg data to oe, start amount with 1 + array( + 'stg_kz' => $result->retval[0]->studiengang_kz, + 'stg_kurzbz' => strtoupper($result->retval[0]->stg_typ. $result->retval[0]->stg_kurzbz), + 'stg_bezeichnung' => $result->retval[0]->lv_stg_bezeichnung, + 'amount' => 1 + ) + ); + } + // Else if oe exists + else + { + // Search if stg exists inside existing oe of data_arr + $stg_index = array_search($result->retval[0]->studiengang_kz, array_column($data_arr[$ss_index][$oe_index], 'stg_kz')); + + // If stg is new, add stg to oe, start amount with 1 + if ($stg_index === false) + { + $data_arr[$ss_index][$oe_index][] = array( + 'stg_kz' => $result->retval[0]->studiengang_kz, + 'stg_kurzbz' => strtoupper($result->retval[0]->stg_typ. $result->retval[0]->stg_kurzbz), + 'stg_bezeichnung' => $result->retval[0]->lv_stg_bezeichnung, + 'amount' => 1 + ); + } + // Else if stg exists + else + { + // Increase amount +1 + $data_arr[$ss_index][$oe_index][$stg_index]['amount']++; + } + } + } + } + } + + /** + * Cluster data by uid of entitled mail receivers. + * Returning array is clustered as follows: + * Array + * [uid] + * Array + * [studiensemester_kurzbz] // studiensemester of lehreinheit + * Array + * [oe_kurzbz] // oe of lehreinheits lehrveranstaltung + * [oe_bezeichnung] + * Array + * [stg_kz] // stg of lehreinheits lehrveranstaltung + * [stg_kurzbz] + * [stg_bezeichnung] + * [amount] // amount of new ordered lehrauftraege of that stg + */ + $data_arr = $this->_clusterData_byReceiver($data_arr); + + // Send email + if(!$this->_sendMail_toApprove($data_arr)) + { + $this->logInfo('SUCCEDED: Sending emails about yesterdays ordered lehrauftraege succeded.'); + } + else + { + $this->logError('Error when sending emails in job MailLehrauftragToApprove'); + } + } + + /** + * This daily job sends information about all lehr-/projektauftraege approved the day bofore. + * Receivers: lectors + **/ + public function mailLehrauftraegeToAccept() + { + // Get vertrag_id and uid of lehrauftraege that had been approved and had NOT been accepted or cancelled YESTERDAY + $this->VertragvertragsstatusModel->addSelect('vertrag_id, uid'); + $this->VertragvertragsstatusModel->addOrder('uid'); + $result = $this->VertragvertragsstatusModel->getApproved_fromDate('YESTERDAY'); + + /** + * Build the data array to be used in the email. Data array is clustered as follows: + * Array + * [uid] // lectors uid (mail receiver) + * [studiensemester] // studiensemester of the lehrauftraege (can be more, e.g. 'WS2019 and SS2020') + * [amount] // amount of new approved lehrauftraege + **/ + $data_arr = array(); + if ($vertrag_arr = getData($result)) + { + foreach ($vertrag_arr as $vertrag) + { + // Get studiensemester of the lehrauftrag + $this->VertragModel->addSelect('vertragsstunden_studiensemester_kurzbz'); + $result = $this->VertragModel->load($vertrag->vertrag_id); + if ($studiensemester = getData($result)) + { + $studiensemester = $studiensemester[0]->vertragsstunden_studiensemester_kurzbz; + } + + // Search if uid exists in data_arr + $uid_index = array_search($vertrag->uid, array_column($data_arr, 'uid')); + + // If uid is new, add uid, studiensemester and start amount with 1 + if ($uid_index === false) + { + $data = array(); + $data['uid'] = $vertrag->uid; + $data['studiensemester'] = $studiensemester; + $data['amount']= 1; + $data_arr []= $data; + } + // Else if uid exists + else + { + // If studiensemester is new, add to studiensemester-string + if (strpos($data_arr[$uid_index]['studiensemester'], $studiensemester) === false) + { + $data_arr[$uid_index]['studiensemester'] .= ' und '. $studiensemester; + } + + // Increase amount +1 + $data_arr[$uid_index]['amount']++; + } + } + } + + // Send email + if ($this->_sendMail_toAccept($data_arr)) + { + $this->logInfo('SUCCEDED: Sending emails about yesterdays approved lehrauftraege succeded.'); + } + else + { + $this->logError('Error when sending emails in job MailLehrauftragToAccept'); + } + } + + //****************************************************************************************************************** + // PRIVATE FUNCTIONS + //****************************************************************************************************************** + + /** + * Get data of given lehrveranstaltung. + * @param $lehrveranstaltung_id + * @return mixed + */ + private function _getLVData($lehrveranstaltung_id) + { + $this->LehrveranstaltungModel->addSelect(' + tbl_lehrveranstaltung.oe_kurzbz, + oe.bezeichnung AS "lv_oe_bezeichnung", + tbl_lehrveranstaltung.studiengang_kz, + stg.bezeichnung AS "lv_stg_bezeichnung", + stg.typ AS "stg_typ", + stg.kurzbz AS "stg_kurzbz" + '); + + $this->LehrveranstaltungModel->addJoin('lehre.tbl_studienplan_lehrveranstaltung stpllv', 'lehrveranstaltung_id'); + $this->LehrveranstaltungModel->addJoin('lehre.tbl_studienplan stpl', 'studienplan_id'); + $this->LehrveranstaltungModel->addJoin('lehre.tbl_studienordnung sto', 'studienordnung_id'); + $this->LehrveranstaltungModel->addJoin('public.tbl_studiengang stg', 'ON stg.studiengang_kz = tbl_lehrveranstaltung.studiengang_kz'); + $this->LehrveranstaltungModel->addJoin('public.tbl_organisationseinheit oe', 'ON oe.oe_kurzbz = tbl_lehrveranstaltung.oe_kurzbz'); + $this->LehrveranstaltungModel->addOrder('stpllv.insertamum', 'DESC'); + $this->LehrveranstaltungModel->addLimit(1); + + return $this->LehrveranstaltungModel->load($lehrveranstaltung_id); + } + + /** + * Send Sancho eMail about ordered Lehrauftraege. + * @param $data_arr + */ + private function _sendMail_toApprove($data_arr) + { + // Loop through 'container' of mail recipients + foreach($data_arr as $data) + { + // Set mail recipients (department assistance/leader) + $to = $data['uid']. '@'. DOMAIN; + $html_table = $this->_renderData_LehrauftraegeToApprove($data); + + // Prepare mail content + $content_data_arr = array( + 'table' => $html_table + ); + + sendSanchoMail( + 'LehrauftragNeueBestellungen', + $content_data_arr, + $to, + 'Bestellung neuer Lehraufträge', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg' + ); + } + } + + /** + * Cluster the data array by entitled mail receiver. + * Returning array is clustered as follows: + * Array + * [uid] + * Array + * [studiensemester_kurzbz] // studiensemester of lehreinheit + * Array + * [oe_kurzbz] // oe of lehreinheits lehrveranstaltung + * [oe_bezeichnung] + * Array + * [stg_kz] // stg of lehreinheits lehrveranstaltung + * [stg_kurzbz] + * [stg_bezeichnung] + * [amount] // amount of new ordered lehrauftraege of that stg + * @param $data_arr + * @return array + * + */ + private function _clusterData_byReceiver($data_arr) + { + $mail_data_arr = array(); // final array with all data clustered by mail receiver + + // Loop through 'container' of studiensemester + foreach ($data_arr as $data) + { + $data_len = count($data) - 1; + + // Loop through 'container' of organisational units + for ($i = 0; $i < $data_len; $i++) + { + // Get all users entitled by organisational unit + $result = $this->BenutzerrolleModel->getBenutzerByBerechtigung(self::BERECHTIGUNG_LEHRAUFTRAG_ERTEILEN, $data[$i]['oe_kurzbz']); + + if ($berechtigung_arr = getData($result)) + { + // Loop through entitled users + foreach ($berechtigung_arr as $berechtigung) + { + // Search if UID exists inside mail_data_arr + $uid_index = array_search($berechtigung->uid, array_column($mail_data_arr, 'uid')); + + // If UID is new, add UID to final array + if ($uid_index === false) + { + // add UID with corresponding data + $mail_data_arr [] = array( + 'uid' => $berechtigung->uid, + array( + 'studiensemester_kurzbz' => $data['studiensemester_kurzbz'], + $data[$i] + ) + ); + } // Else if UID exists + else + { + // Search if studiensemester exists + $ss_index = array_search($data['studiensemester_kurzbz'], array_column($mail_data_arr, 'studiensemester_kurzbz')); + + // If studiensemester is new, add studiensemester to existing UID + if ($ss_index === false) + { + $mail_data_arr[$uid_index] []= array( + 'studiensemester_kurzbz' => $data['studiensemester_kurzbz'], + $data[$i] + ); + } + // Else if studiensemester exists + else + { + // Add corresponding data to existing studiensemester of UID + $mail_data_arr[$uid_index]['studiensemester_kurbz'][] = $data[$i]; + } + + } + } + } + } + } + + return $mail_data_arr; + } + + /** + * Render the data array for the mail template returing a HTML table. + * @param $data_arr Data to be used in HTML table + * @return string HTML table to be embedded in eMail + */ + private function _renderData_LehrauftraegeToApprove($data_arr) + { + $html = ''; + foreach ($data_arr as $studiensemester_container) + { + if (is_array($studiensemester_container)) // is_array 'trims' the outer associative key [uid] + { + if (isset($studiensemester_container['studiensemester_kurzbz'])) + { + $studiensemester = $studiensemester_container['studiensemester_kurzbz']; + + // Link to LehrauftragErteilen + $url = site_url(self::LEHRAUFTRAG_ERTEILEN_URI).'?studiensemester='. $studiensemester; + } + + // HTML table header + $html .= ' +
+ Studiensemester: '. $studiensemester. ' +

+ + + + + + + + + + ' + ; + + // HTML table body + foreach ($studiensemester_container as $oe_container) + { + if (is_array($oe_container)) // is_array 'trims' the outer associative key [studiensemester_kurzbz] + { + if (isset($oe_container['oe_bezeichnung'])) + { + $oe_bezeichnung = $oe_container['oe_bezeichnung']; + } + + foreach ($oe_container as $stg_data) + { + if (is_array($stg_data)) // is_array 'trims' the outer associative keys [oe_kurzbz] and [oe_bezeichnung] + { + $html .= ' + + + + + + + '; + } + } + } + } + + // HTML table body end and link + $html .= ' + +
LV-OrganisationseinheitStudiengangSTG-KurzbezeichnungAnzahl neu bestellter Lehraufträge
'. $oe_bezeichnung. ''. $stg_data['stg_bezeichnung']. ''. $stg_data['stg_kurzbz']. ''. $stg_data['amount']. '
+
+ '. anchor($url, 'Lehraufträge Übersicht '. $studiensemester). ' +

+ '; + } + } + + return $html; + } + + /** + * Send Sancho eMail about ordered Lehrauftraege. + * @param $data_arr + */ + private function _sendMail_toAccept($data_arr) + { + // Loop through 'container' of mail recipients + foreach($data_arr as $data) + { + // Set mail recipient (lector) + $to = $data['uid']. '@'. DOMAIN; + + // Link to LehrauftragAkzeptieren + $url = CIS_ROOT. 'cis/index.php?menu='. + CIS_ROOT. 'cis/menu.php?content_id=&content='. + CIS_ROOT. index_page(). self::LEHRAUFTRAG_AKZEPTIEREN_URI; + + // Get first name + $first_name = ''; + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + $this->BenutzerModel->addSelect('vorname'); + $this->BenutzerModel->addJoin('public.tbl_person', 'person_id'); + $result = $this->BenutzerModel->loadWhere(array('uid' => $data['uid'])); + + if (hasData($result)) + { + $first_name = $result->retval[0]->vorname; + } + + // Prepare mail content + $content_data_arr = array( + 'vorname' => $first_name, + 'studiensemester' => $data['studiensemester'], + 'anzahl' => $data['amount'], + 'link' => anchor($url, 'Lehraufträge Übersicht') + ); + + sendSanchoMail( + 'LehrauftragNeueErteilte', + $content_data_arr, + $to, + 'Neu erteilte Lehraufträge zum Annehmen bereit' + ); + } + } +} diff --git a/application/controllers/jobs/Prestudentstatus.php b/application/controllers/jobs/Prestudentstatus.php index 27cafeb0e..a3b765f07 100644 --- a/application/controllers/jobs/Prestudentstatus.php +++ b/application/controllers/jobs/Prestudentstatus.php @@ -37,7 +37,8 @@ class Prestudentstatus extends CLI_Controller tbl_prestudent.studiengang_kz, tbl_prestudentstatus.studienplan_id, tbl_studienplan.orgform_kurzbz, - tbl_prestudent.person_id'); + tbl_prestudent.person_id, + tbl_studienplan.sprache'); $this->PrestudentstatusModel->addJoin('public.tbl_prestudent', 'prestudent_id'); $this->PrestudentstatusModel->addJoin('lehre.tbl_studienplan', 'studienplan_id','LEFT'); $this->PrestudentstatusModel->addJoin('lehre.tbl_studienordnung', 'studienordnung_id','LEFT'); @@ -64,7 +65,8 @@ class Prestudentstatus extends CLI_Controller $row_status->studiengang_kz, $row_status->studiensemester_kurzbz, $row_status->ausbildungssemester, - $row_status->orgform_kurzbz); + $row_status->orgform_kurzbz, + $row_status->sprache); if(isSuccess($studienplan) && count($studienplan->retval) == 1) { @@ -107,7 +109,7 @@ class Prestudentstatus extends CLI_Controller } else { - show_error($status->retval); + show_error(getError($status)); } echo "Corrected:".$sum_corrected."\n"; echo "Not Corrected:".$sum_notcorrected."\n"; diff --git a/application/controllers/jobs/ReihungstestJob.php b/application/controllers/jobs/ReihungstestJob.php index 5aa355b5f..84a5fe614 100644 --- a/application/controllers/jobs/ReihungstestJob.php +++ b/application/controllers/jobs/ReihungstestJob.php @@ -35,7 +35,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($result)) { - show_error($result->error); + show_error(getError($result)); } // Get free places @@ -48,7 +48,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($result)) { - show_error($result->error); + show_error(getError($result)); } // Prepare data for mail template 'ReihungstestJob' @@ -103,7 +103,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($result)) { - show_error($result->error); + show_error(getError($result)); } $applicants_arr = array(); @@ -118,7 +118,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($applicants)) { - show_error($applicants->error); + show_error(getError($applicants)); } // Get all Bachelor-Degree-Programs with Mailadress @@ -131,7 +131,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($bachelorStudiengeange)) { - show_error($bachelorStudiengeange->error); + show_error(getError($bachelorStudiengeange)); } // If a person ist an applicant of this degree-program send mail with application data @@ -222,7 +222,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($result)) { - show_error($result->error); + show_error(getError($result)); } $studiengang = ''; @@ -382,7 +382,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($resultTestsOnDate)) { - show_error($resultTestsOnDate->error); + show_error(getError($resultTestsOnDate)); } } @@ -399,7 +399,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($applicants)) { - show_error($applicants->error); + show_error(getError($applicants)); } foreach ($applicants_arr as $applicant) @@ -479,7 +479,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($yesterdays_applicants_arr)) { - show_error($yesterdays_applicants_arr->error); + show_error(getError($yesterdays_applicants_arr)); } // Get all other prestudenten of the given persons. @@ -503,7 +503,7 @@ class ReihungstestJob extends CLI_Controller // Store them, if they have already absolved a placement test in the same study term they have applied for. $placement_absolvents_arr = $this->PrestudentModel->loadWhere(' person_id IN (' . implode(', ', $person_id_arr) . ') AND - typ = \'b\' AND + typ = \'b\' AND teilgenommen = \'t\' AND tbl_reihungstest.studiensemester_kurzbz IN ( SELECT @@ -548,7 +548,7 @@ class ReihungstestJob extends CLI_Controller $to = ''; // mail recipient (stg assistance) $content_arr = array(); // url paths to the new applicants $base_link = base_url('vilesci/stammdaten/auswertung_fhtw.php'); - + $i = 0; // loop counter $len = count($result_arr); @@ -569,7 +569,7 @@ class ReihungstestJob extends CLI_Controller { // Prepare content for mail template $content_data_arr = $this->_getContentDataNewApplicant($content_arr); - + // Send mail sendSanchoMail( 'BewerberNachReihungstest', @@ -786,4 +786,3 @@ class ReihungstestJob extends CLI_Controller } } } - diff --git a/application/controllers/lehre/lehrauftrag/Lehrauftrag.php b/application/controllers/lehre/lehrauftrag/Lehrauftrag.php new file mode 100644 index 000000000..3c0808d42 --- /dev/null +++ b/application/controllers/lehre/lehrauftrag/Lehrauftrag.php @@ -0,0 +1,347 @@ + 'lehre/lehrauftrag_bestellen:r', + 'orderLehrauftrag' => 'lehre/lehrauftrag_bestellen:rw', + 'Dashboard' => array('lehre/lehrauftrag_bestellen:r', 'lehre/lehrauftrag_erteilen:rw'), + 'LehrendeUebersicht' => array('lehre/lehrauftrag_erteilen:r') + ) + ); + + // Load models + $this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); + $this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + $this->load->model('accounting/Vertrag_model', 'VertragModel'); + + // Load libraries + $this->load->library('WidgetLib'); + $this->load->library('PermissionLib'); + + // Load helpers + $this->load->helper('array'); + $this->load->helper('url'); + $this->load->helper('hlp_sancho_helper'); + + // Load language phrases + $this->loadPhrases( + array( + 'global', + 'ui', + 'lehre' + ) + ); + + $this->_setAuthUID(); // sets property uid + + $this->setControllerId(); // sets the controller id + } + + /** + * Display of Custom Dashboard for Lehraufträge App + * Charts are hooked from Reporting Addon + */ + public function Dashboard() + { + $this->load->view('lehre/lehrauftrag/Dashboard.php'); + } + + /** + * Display of Lehrauftragsübersicht report + */ + public function LehrendeUebersicht() + { + $this->load->view('lehre/lehrauftrag/LehrendeUebersicht.php'); + } + + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + /** + * Main page of Lehrauftrag + */ + public function index() + { + // Set studiengang selected for studiengang dropdown + $studiengang_kz = $this->input->get('studiengang'); // if provided by selected studiengang + $studiengang_kz = ($studiengang_kz == 'null' ? null : $studiengang_kz); + + // Retrieve studiengaenge the user is entitled for to populate studiengang dropdown + if (!$studiengang_kz_arr = $this->permissionlib->getSTG_isEntitledFor(self::BERECHTIGUNG_LEHRAUFTRAG_BESTELLEN)) { + show_error('Fehler bei Berechtigungsprüfung'); + } + + // If studiengang_kz get param was set, check against entitled stg + if (!is_null($studiengang_kz)) + { + if (!in_array($studiengang_kz, $studiengang_kz_arr)) + { + show_error('Keine Berechtigung für diesen Studiengang'); + } + } + + // Set studiensemester selected for studiengang dropdown + $studiensemester_kurzbz = $this->input->get('studiensemester'); // if provided by selected studiensemester + if (is_null($studiensemester_kurzbz)) // else set next studiensemester as default value + { + $studiensemester = $this->StudiensemesterModel->getNext(); + if (hasData($studiensemester)) + { + $studiensemester_kurzbz = $studiensemester->retval[0]->studiensemester_kurzbz; + } + elseif (isError($studiensemester)) + { + show_error(getError($studiensemester)); + } + } + + // Set ausbildungssemester selected for ausbildungssemester dropdown + $ausbildungssemester = $this->input->get('ausbildungssemester'); // if provided by selected ausbildungssemester + $ausbildungssemester = ($ausbildungssemester == 'null' ? null : $ausbildungssemester); + + $view_data = array( + 'studiengang_selected' => $studiengang_kz, + 'studiengang' => $studiengang_kz_arr, + 'studiensemester_selected' => $studiensemester_kurzbz, + 'ausbildungssemester_selected' => $ausbildungssemester, + ); + + $this->load->view('lehre/lehrauftrag/orderLehrauftrag.php', $view_data); + } + + public function orderLehrauftrag() + { + $new_lehrvertrag_data_arr = array(); // information of new lehrvertraege to be used in mail + $lehrauftrag_arr = json_decode($this->input->post('selected_data')); + + // Loop through lehraufträge + if(is_array($lehrauftrag_arr)) + { + foreach($lehrauftrag_arr as $lehrauftrag) + { + $lehreinheit_id = (isset($lehrauftrag->lehreinheit_id)) ? $lehrauftrag->lehreinheit_id : null; + $lehrveranstaltung_id = (isset($lehrauftrag->lehrveranstaltung_id)) ? $lehrauftrag->lehrveranstaltung_id : null; + $person_id = (isset($lehrauftrag->person_id)) ? $lehrauftrag->person_id : null; + $mitarbeiter_uid = (isset($lehrauftrag->mitarbeiter_uid)) ? $lehrauftrag->mitarbeiter_uid : null; + $vertrag_id = (isset($lehrauftrag->vertrag_id)) ? $lehrauftrag->vertrag_id : null; + $projektarbeit_id = (isset($lehrauftrag->projektarbeit_id)) ? $lehrauftrag->projektarbeit_id : null; + $stunden = (isset($lehrauftrag->stunden)) ? $lehrauftrag->stunden : 0; + $betrag = (isset($lehrauftrag->betrag)) ? $lehrauftrag->betrag : 0; + $studiensemester_kurzbz = (isset($lehrauftrag->studiensemester_kurzbz)) ? $lehrauftrag->studiensemester_kurzbz : null; + $studiengang_kz = (isset($lehrauftrag->studiengang_kz)) ? $lehrauftrag->studiengang_kz : null; + + // Check if user is entitled to order this Lehrauftrag + if (!$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_LEHRAUFTRAG_BESTELLEN, 'suid', $studiengang_kz)) + { + return $this->outputJsonError('Sie haben keine Bestellberechtigung für diesen Studiengang: '. $studiengang_kz); + } + + // update contract if contract exists and the betrag was changed + if (!is_null($vertrag_id)) + { + $this->VertragModel->addSelect('vertragsstunden, betrag'); + + if($result = getData($this->VertragModel->load($vertrag_id))) + { + $vertrag_betrag = $result[0]->betrag; + $vertrag_stunden = $result[0]->vertragsstunden; + } + elseif (isError($result)) + { + return $this->outputJsonError('Fehler beim Laden des Vertrags'); + } + + $hasChanged = ($betrag != floatval($vertrag_betrag) || $stunden != $vertrag_stunden) ? true : false; + + if ($hasChanged) + { + $result = $this->VertragModel->updateVertrag( + $vertrag_id, + $stunden, + $betrag, + $mitarbeiter_uid + ); + + if (isSuccess($result)) + { + $json []= array( + 'row_index' => $lehrauftrag->row_index, + 'bestellt' => date('Y-m-d'), + 'vertrag_betrag' => $betrag, + 'vertrag_stunden' => $stunden, + 'erteilt' => null + ); + } + else + { + return $this->outputJsonError('Fehler beim Vertragsupdate'); + } + } + } + // else save new contract + else + { + $result = $this->VertragModel->save( + $person_id, + $mitarbeiter_uid, + $lehrveranstaltung_id, + $lehreinheit_id, + $projektarbeit_id, + $stunden, + $betrag, + $studiensemester_kurzbz + ); + + if (isSuccess($result)) + { + $json []= array( + 'row_index' => $lehrauftrag->row_index, + 'bestellt' => date('Y-m-d'), + 'vertrag_betrag' => $betrag, + 'vertrag_stunden' => $stunden + ); + } + elseif (isError($result) && $result->retval) + { + return $this->outputJsonError($result->retval); + } + else + { + return $this->outputJsonError('Fehler beim Speichern des Vertrags'); + } + + $new_lehrvertrag_data_arr[] = array( + 'studiensemester_kurzbz' => $lehrauftrag->studiensemester_kurzbz, + 'studiengang_kz' => $lehrauftrag->studiengang_kz, + 'lv_oe_kurzbz' => $lehrauftrag->lv_oe_kurzbz + ); + } + } + } + else + { + return $this->outputJsonError('Fehler beim Übertragen der Daten.'); + } + + if (isset($json) && !isEmptyArray($json)) + { + $this->outputJsonSuccess($json); + } + } + + // ----------------------------------------------------------------------------------------------------------------- + // Private methods + + /** + * Retrieve the UID of the logged user and checks if it is valid + */ + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) show_error('User authentification failed'); + } + + private function _sendMail($lehrvertrag_data_arr) + { + // Cluster data of new lehrvertraege as needed to send mail + $lehrvertrag_data_arr = $this->_cluster_newVertragData($lehrvertrag_data_arr); + + foreach ($lehrvertrag_data_arr as $lehrvertrag_data) + { + // Get mail recipients + $result = $this->BenutzerrolleModel->getBenutzerByBerechtigung('lehre/lehrauftrag_erteilen', $lehrvertrag_data['lv_oe_kurzbz']); + + // If given lv organisational unit has no authorized user, check if is a Kompetenzfeld. + // If so, look up for authorized user on Department level. + if (!hasData($result)) { + $result = $this->OrganisationseinheitModel->getParent($lehrvertrag_data['lv_oe_kurzbz']); + + if (hasData($result)) { + if ($result->retval[0]->organisationseinheittyp_kurzbz === 'Department') { + $result = $this->BenutzerrolleModel->getBenutzerByBerechtigung('lehre/lehrauftrag_erteilen', $result->retval[0]->oe_kurzbz); + } + } + } + + // Set mail recipients (department assistance/leader) + $to = ''; + $to_arr = array(); + foreach ($result->retval as $berechtigung) { + $to_arr []= $berechtigung->uid . '@' . DOMAIN; // TODO: als array, dann splitten mit ;? oder als array lassen? + } + $to = implode(', ', $to_arr); + + // Set link to lehrauftrag-site with preselected studiengang and studiensemester of new lehrauftraege + $url = site_url(self::LEHRAUFTRAG_URI).'?studiensemester='. $lehrvertrag_data['studiensemester_kurzbz']. '&studiengang='. $lehrvertrag_data['studiengang_kz']; + + // Prepare mail content + $content_data_arr = array( + 'anzahl' => $lehrvertrag_data['amount_new_lehrvertraege'], + 'studiengang' => $lehrvertrag_data['studiengang_kz'], + 'studiensemester' => $lehrvertrag_data['studiensemester_kurzbz'], + 'link' => anchor($url, 'Lehrverträge Übersicht') + ); + + // Send mail + sendSanchoMail( + 'LehrauftragBestellMail', + $content_data_arr, + $to, + 'Bestellung neuer Lehraufträge', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg' + ); + } + } + + /** + * Clusters data as needed for _sendMail. + * Makes array of new lehrvertraege unique (by studiensemester, studiengang and lv_oe_kurzbz) + * Adds the amount of lehrvertraege of each unique array element. + * @param $new_lehrvertrag_data_arr + * @return array + */ + private function _cluster_newVertragData($new_lehrvertrag_data_arr) + { + $unique_new_lehrvertrag_data_arr = array_unique($new_lehrvertrag_data_arr, SORT_REGULAR); + foreach ($unique_new_lehrvertrag_data_arr as &$new_lehrvertrag) + { + $cnt = 1; + foreach ($new_lehrvertrag_data_arr as $item) + { + if ($new_lehrvertrag['studiensemester_kurzbz'] === $item['studiensemester_kurzbz'] && + $new_lehrvertrag['studiengang_kz'] === $item['studiengang_kz'] && + $new_lehrvertrag['lv_oe_kurzbz'] === $item['lv_oe_kurzbz']) + { + $new_lehrvertrag['amount_new_lehrvertraege'] = $cnt++; + } + } + } + + return $unique_new_lehrvertrag_data_arr; + } +} diff --git a/application/controllers/lehre/lehrauftrag/LehrauftragAkzeptieren.php b/application/controllers/lehre/lehrauftrag/LehrauftragAkzeptieren.php new file mode 100644 index 000000000..dfb1390d3 --- /dev/null +++ b/application/controllers/lehre/lehrauftrag/LehrauftragAkzeptieren.php @@ -0,0 +1,219 @@ + 'lehre/lehrauftrag_akzeptieren:r', + 'acceptLehrauftrag' => 'lehre/lehrauftrag_akzeptieren:rw', + 'checkInkludierteLehre' => 'lehre/lehrauftrag_akzeptieren:rw' + ) + ); + + // Load models + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + $this->load->model('accounting/Vertrag_model', 'VertragModel'); + $this->load->model('accounting/Vertragvertragsstatus_model', 'VertragvertragsstatusModel'); + $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); + $this->load->model('codex/Bisverwendung_model', 'BisverwendungModel'); + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + + // Load libraries + $this->load->library('WidgetLib'); + $this->load->library('PermissionLib'); + $this->load->library('AuthLib'); + + // Load helpers + $this->load->helper('array'); + $this->load->helper('url'); + + // Load language phrases + $this->loadPhrases( + array( + 'global', + 'ui', + 'lehre' + ) + ); + + $this->_setAuthUID(); // sets property uid + + $this->setControllerId(); // sets the controller id + } + + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + + /** + * Main page of Lehrauftrag + */ + public function index() + { + // Set studiensemester selected for studiengang dropdown + $studiensemester_kurzbz = $this->input->get('studiensemester'); // if provided by selected studiensemester + if (is_null($studiensemester_kurzbz)) // else set next studiensemester as default value + { + $studiensemester = $this->StudiensemesterModel->getNext(); + if (hasData($studiensemester)) + { + $studiensemester_kurzbz = $studiensemester->retval[0]->studiensemester_kurzbz; + } + elseif (isError($studiensemester)) + { + show_error(getError($studiensemester)); + } + } + + $view_data = array( + 'studiensemester_selected' => $studiensemester_kurzbz + ); + + $this->load->view('lehre/lehrauftrag/acceptLehrauftrag.php', $view_data); + } + + /** + * Set the contract status of Lehrauftrag to 'akzeptiert'. + * Performed on ajax call. + */ + public function acceptLehrauftrag() + { + // Verify password + $password = $this->input->post('password'); + if (!isEmptyString($password)) + { + $result = $this->authlib->checkUserAuthByUsernamePassword($this->_uid, $password); + if (isError($result)) + { + return $this->outputJsonError('Passwort ist inkorrekt'); // exit if password is incorrect + } + } + else + { + return $this->outputJsonError('Passwort fehlt'); + } + + // Loop through lehraufträge + $lehrauftrag_arr = $this->input->post('selected_data'); + + if(is_array($lehrauftrag_arr)) + { + foreach($lehrauftrag_arr as $lehrauftrag) + { + $vertrag_id = (!is_null($lehrauftrag['vertrag_id'])) ? $lehrauftrag['vertrag_id'] : null; + + // Check if user is entitled to accept this Lehrauftrag + // * first retrieve person_id of the contract + $this->VertragModel->addSelect('person_id'); + + if ($result = getData($this->VertragModel->load($vertrag_id))) + { + // * then find the uid of that contracts person_id + $this->BenutzerModel->addSelect('uid'); + + if ($result = getData($this->BenutzerModel->getFromPersonId($result[0]->person_id))) + { + // * finally check uid of contract against the logged in user + $account_found = false; + foreach($result as $row_accounts) + { + if($row_accounts->uid == $this->_uid) + { + $account_found = true; + } + } + + if (!$account_found) + { + return $this->outputJsonError('Sie haben keine Berechtigung für einen Vertrag'); + } + } + else + { + return $this->outputJsonError('Fehler beim Laden der Benutzerdaten'); + } + } + else + { + return $this->outputJsonError('Fehler beim Laden des Vertrags'); + } + + // Set status to accepted + $result = $this->VertragvertragsstatusModel->setStatus($vertrag_id, $this->_uid, 'akzeptiert'); + + if ($result->retval) + { + $json []= array( + 'row_index' => $lehrauftrag['row_index'], + 'akzeptiert' => date('Y-m-d') + ); + } + else + { + return $this->outputJsonError($result->retval); + } + } + + // Output json to ajax + if (isset($json) && !isEmptyArray($json)) + { + $this->outputJsonSuccess($json); + } + } + else + { + return $this->outputJsonError('Fehler beim Übertragen der Daten.'); + } + } + + /** + * Check if lectors latest active Verwendung has inkludierte Lehre + * - inkludierte_lehre is null OR 0: freelancer lector -> has NO inkludierte Lehre + * - inkludierte_lehre -1: fix employed lector -> has inkludierte Lehre (all inclusive) + * - inkludierte_lehre > 0: fix employed lector -> has inkludierte Lehre (value is amount of hours included) + */ + public function checkInkludierteLehre() + { + $result = $this->BisverwendungModel->getLast($this->_uid); + + if (hasData($result)) + { + $this->outputJsonSuccess(!is_null($result->retval[0]->inkludierte_lehre) && $result->retval[0]->inkludierte_lehre != 0); + } + else + { + $this->outputJsonError(getError($result)); + } + } + + // ----------------------------------------------------------------------------------------------------------------- + // Private methods + + /** + * Retrieve the UID of the logged user and checks if it is valid + */ + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) show_error('User authentification failed'); + } + +} diff --git a/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php b/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php new file mode 100644 index 000000000..b70b6e2f9 --- /dev/null +++ b/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php @@ -0,0 +1,204 @@ + 'lehre/lehrauftrag_erteilen:r', + 'approveLehrauftrag' => 'lehre/lehrauftrag_erteilen:rw' + ) + ); + + // Load models + $this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); + $this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + $this->load->model('accounting/Vertrag_model', 'VertragModel'); + $this->load->model('accounting/Vertragvertragsstatus_model', 'VertragvertragsstatusModel'); + + // Load libraries + $this->load->library('WidgetLib'); + $this->load->library('PermissionLib'); + + // Load helpers + $this->load->helper('array'); + $this->load->helper('url'); + + // Load language phrases + $this->loadPhrases( + array( + 'global', + 'ui', + 'lehre' + ) + ); + + $this->_setAuthUID(); // sets property uid + + $this->setControllerId(); // sets the controller id + } + + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + + /** + * Main page of Lehrauftrag + */ + public function index() + { + // Set studiengang to be selected in studiengang dropdown + $oe_kurzbz = $this->input->get('organisationseinheit'); // if provided by selected studiengang + $oe_kurzbz = ($oe_kurzbz == 'null' ? null : $oe_kurzbz); + + // Retrieve studiengaenge the user is entitled for to populate studiengang dropdown + if (!$oe_kurzbz_arr = $this->permissionlib->getOE_isEntitledFor(self::BERECHTIGUNG_LEHRAUFTRAG_ERTEILEN)) + { + show_error('Fehler bei Berechtigungsprüfung'); + } + + // If oe_kurzbz get param was set, check against entitled stg + if (!is_null($oe_kurzbz)) + { + if (!in_array($oe_kurzbz, $oe_kurzbz_arr)) + { + show_error('Keine Berechtigung für diese Organisationseinheit'); + } + } + + // Set studiensemester selected for studiengang dropdown + $studiensemester_kurzbz = $this->input->get('studiensemester'); // if provided by selected studiensemester + if (is_null($studiensemester_kurzbz)) // else set next studiensemester as default value + { + $studiensemester = $this->StudiensemesterModel->getNext(); + if (hasData($studiensemester)) + { + $studiensemester_kurzbz = $studiensemester->retval[0]->studiensemester_kurzbz; + } + elseif (isError($studiensemester)) + { + show_error(getError($studiensemester)); + } + } + + // Set ausbildungssemester selected for ausbildungssemester dropdown + $ausbildungssemester = $this->input->get('ausbildungssemester'); // if provided by selected ausbildungssemester + $ausbildungssemester = ($ausbildungssemester == 'null' ? null : $ausbildungssemester); + + $view_data = array( + 'organisationseinheit_selected' => $oe_kurzbz, + 'organisationseinheit' => $oe_kurzbz_arr, + 'studiensemester_selected' => $studiensemester_kurzbz, + 'ausbildungssemester_selected' => $ausbildungssemester, + ); + + $this->load->view('lehre/lehrauftrag/approveLehrauftrag.php', $view_data); + } + + /** + * Set the contract status of Lehrauftrag to 'erteilt'. + * Performed on ajax call. + */ + public function approveLehrauftrag() + { + $lehrauftrag_arr = json_decode($this->input->post('selected_data')); + + if (is_array($lehrauftrag_arr)) + { + foreach ($lehrauftrag_arr as $lehrauftrag) + { + $mitarbeiter_uid = (isset($lehrauftrag->mitarbeiter_uid)) ? $lehrauftrag->mitarbeiter_uid : null; + $vertrag_id = (isset($lehrauftrag->vertrag_id)) ? $lehrauftrag->vertrag_id : null; + + $lv_oe_kurzbz = null; + + // Retrieve organisational unit to which the lehrveranstaltung of the contract belongs to + // * first get lehrveranstaltung + $result = $this->VertragModel->getLehreinheitData($vertrag_id, 'lehrveranstaltung_id'); + if (hasData($result)) + { + // * then get corresponding organisational unit + $this->load->model('education/Lehrveranstaltung_model', 'Lehrveranstaltung_model'); + $result = $this->LehrveranstaltungModel->load($result->retval[0]->lehrveranstaltung_id); + if (hasData($result)) + { + $lv_oe_kurzbz = $result->retval[0]->oe_kurzbz; + } + elseif (isError(($result))) + { + return $this->outputJsonError('Fehler beim Laden einer Lehrveranstaltung.'); + } + } + elseif (isError($result)) + { + return $this->outputJsonError('Fehler beim Laden von Lehreinheitdaten.'); + } + + // Check if user is entitled to approve this lehrauftrag (by permission and organisational unit) + if (!$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_LEHRAUFTRAG_ERTEILEN, 'suid', $lv_oe_kurzbz)) + { + return $this->outputJsonError('Sie haben keine Erteilberechtigung für diese Organisationseinheit: '. $lv_oe_kurzbz); + } + + // Approve lehrauftrag by setting vertragsstatus to 'erteilt' + $result = $this->VertragvertragsstatusModel->setStatus($vertrag_id, $mitarbeiter_uid, 'erteilt'); + + if (!isError($result)) + { + $json [] = array( + 'row_index' => $lehrauftrag->row_index, + 'erteilt' => date('Y-m-d') + ); + } + else + { + return $this->outputJsonError($result->retval); + } + } + } + else + { + return $this->outputJsonError('Fehler beim Übertragen der Daten.'); + } + + // output success json to ajax + if (isset($json) && !isEmptyArray($json)) + { + $this->outputJsonSuccess($json); + } + } + + // ----------------------------------------------------------------------------------------------------------------- + // Private methods + + /** + * Retrieve the UID of the logged user and checks if it is valid + */ + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) show_error('User authentification failed'); + } + +} diff --git a/application/controllers/organisation/Studienjahr.php b/application/controllers/organisation/Studienjahr.php index c3c841df9..ed8c0b6a1 100644 --- a/application/controllers/organisation/Studienjahr.php +++ b/application/controllers/organisation/Studienjahr.php @@ -20,7 +20,7 @@ class Studienjahr extends Auth_Controller 'editStudienjahr' => 'basis/studiensemester:rw', 'newStudienjahr' => 'basis/studiensemester:rw', 'insStudienjahr' => 'basis/studiensemester:rw', - 'saveStudienjahr' => 'basis/studiensemester:rw', + 'updateStudienjahr' => 'basis/studiensemester:rw', 'deleteStudienjahr' => 'basis/studiensemester:rw' ) ); @@ -44,7 +44,7 @@ class Studienjahr extends Auth_Controller $studienjahr = $this->StudienjahrModel->load(); if ($studienjahr->error) { - show_error($studienjahr->retval); + show_error(getError($studienjahr)); } $data = array( @@ -66,7 +66,7 @@ class Studienjahr extends Auth_Controller $studienjahr = $this->StudienjahrModel->load($studienjahr_kurzbez); if ($studienjahr->error) { - show_error($studienjahr->retval); + show_error(getError($studienjahr)); } $data = array( "studienjahr" => $studienjahr->retval @@ -86,7 +86,7 @@ class Studienjahr extends Auth_Controller $allstudienjahrkurzbz = $this->StudienjahrModel->load(); if ($allstudienjahrkurzbz->error) { - show_error($allstudienjahrkurzbz->retval); + show_error(getError($allstudienjahrkurzbz)); } $studienjahrkurzbz = $allstudienjahrkurzbz->retval[0]->studienjahr_kurzbz; $years = $this->__getYearsFromStudienjahr($studienjahrkurzbz); @@ -117,11 +117,15 @@ class Studienjahr extends Auth_Controller public function insStudienjahr() { $data = $this->__retrieveStudienjahrData(); + $studienjahr_exists = $this->StudienjahrModel->load($data['studienjahr_kurzbz']); + if (hasData($studienjahr_exists)) + show_error("Studienjahr existiert bereits"); + $studienjahr = $this->StudienjahrModel->insert($data); if ($studienjahr->error) { - show_error($studienjahr->retval); + show_error(getError($studienjahr)); } redirect("/organisation/studienjahr/editStudienjahr/".str_replace("/", "_", $data['studienjahr_kurzbz']."?saved=true")); @@ -149,7 +153,7 @@ class Studienjahr extends Auth_Controller return $data; } else { - show_error($validation->retval); + show_error(getError($validation)); } } @@ -177,14 +181,14 @@ class Studienjahr extends Auth_Controller * replaces slash in Kurzbezeichnung with underscore * saved=true is a GET parameter passed for showing save message */ - public function saveStudienjahr() + public function updateStudienjahr() { $data = $this->__retrieveStudienjahrData(); $studienjahr = $this->StudienjahrModel->update($data['studienjahr_kurzbz'], $data); if ($studienjahr->error) { - show_error($studienjahr->retval); + show_error(getError($studienjahr)); } redirect("/organisation/studienjahr/editStudienjahr/".str_replace("/", "_", $data['studienjahr_kurzbz']."?saved=true")); @@ -203,7 +207,7 @@ class Studienjahr extends Auth_Controller if ($studienjahr->error) { - show_error($studienjahr->retval); + show_error(getError($studienjahr)); } redirect("/organisation/studienjahr/listStudienjahr"); diff --git a/application/controllers/organisation/Studiensemester.php b/application/controllers/organisation/Studiensemester.php index cdca4997d..10fa5b3ad 100644 --- a/application/controllers/organisation/Studiensemester.php +++ b/application/controllers/organisation/Studiensemester.php @@ -20,7 +20,7 @@ class Studiensemester extends Auth_Controller 'editStudiensemester' => 'basis/studiensemester:rw', 'newStudiensemester' => 'basis/studiensemester:rw', 'insStudiensemester' => 'basis/studiensemester:rw', - 'saveStudiensemester' => 'basis/studiensemester:rw', + 'updateStudiensemester' => 'basis/studiensemester:rw', 'deleteStudiensemester' => 'basis/studiensemester:rw' ) ); @@ -45,7 +45,7 @@ class Studiensemester extends Auth_Controller $semester = $this->StudiensemesterModel->load(); if ($semester->error) { - show_error($semester->retval); + show_error(getError($semester)); } $data = array( @@ -64,13 +64,13 @@ class Studiensemester extends Auth_Controller $semester = $this->StudiensemesterModel->load($semester_kurzbez); if ($semester->error) { - show_error($semester->retval); + show_error(getError($semester)); } $this->StudienjahrModel->addOrder('studienjahr_kurzbz', "DESC"); $allstudienjahre = $this->StudienjahrModel->load(); if ($allstudienjahre->error) { - show_error($allstudienjahre->retval); + show_error(getError($allstudienjahre)); } $data = array( "semester" => $semester->retval, @@ -90,7 +90,7 @@ class Studiensemester extends Auth_Controller $allstudienjahre = $this->StudienjahrModel->load(); if ($allstudienjahre->error) { - show_error($allstudienjahre->retval); + show_error(getError($allstudienjahre)); } $data = array( @@ -108,11 +108,16 @@ class Studiensemester extends Auth_Controller public function insStudiensemester() { $data = $this->__retrieveStudiensemesterData(); + + $studiensemester_exists = $this->StudiensemesterModel->load($data['studiensemester_kurzbz']); + if (hasData($studiensemester_exists)) + show_error("Studiensemester existiert bereits"); + $semester = $this->StudiensemesterModel->insert($data); if ($semester->error) { - show_error($semester->retval); + show_error(getError($semester)); } redirect("/organisation/studiensemester/editStudiensemester/".$data['studiensemester_kurzbz']."?saved=true"); @@ -156,7 +161,7 @@ class Studiensemester extends Auth_Controller return $data; } else { - show_error($validation->retval); + show_error(getError($validation)); } } @@ -185,14 +190,14 @@ class Studiensemester extends Auth_Controller * redirects to edit page after inserting * saved=true is a GET parameter passed for showing save message */ - public function saveStudiensemester() + public function updateStudiensemester() { $data = $this->__retrieveStudiensemesterData(); $semester = $this->StudiensemesterModel->update($data['studiensemester_kurzbz'], $data); if ($semester->error) { - show_error($semester->retval); + show_error(getError($semester)); } redirect("/organisation/studiensemester/editStudiensemester/".$data['studiensemester_kurzbz']."?saved=true"); @@ -209,10 +214,9 @@ class Studiensemester extends Auth_Controller if ($semester->error) { - show_error($semester->retval); + show_error(getError($semester)); } redirect("/organisation/studiensemester/listStudiensemester"); } - } diff --git a/application/controllers/person/BPKWartung.php b/application/controllers/person/BPKWartung.php index a8e9b8829..52cb09c5c 100644 --- a/application/controllers/person/BPKWartung.php +++ b/application/controllers/person/BPKWartung.php @@ -71,7 +71,7 @@ class BPKWartung extends Auth_Controller $personexists = $this->PersonModel->load($person_id); if (isError($personexists)) - show_error($personexists->retval); + show_error(getError($personexists)); if (!hasData($personexists)) show_error('Person does not exist!'); @@ -122,7 +122,7 @@ class BPKWartung extends Auth_Controller if (isError($stammdaten)) { - show_error($stammdaten->retval); + show_error(getError($stammdaten)); } if (!isset($stammdaten->retval)) @@ -132,7 +132,7 @@ class BPKWartung extends Auth_Controller if (isError($adresse)) { - show_error($adresse->retval); + show_error(getError($adresse)); } $data = array( diff --git a/application/controllers/person/Gradelist.php b/application/controllers/person/Gradelist.php index e1ef14792..230c7f67f 100644 --- a/application/controllers/person/Gradelist.php +++ b/application/controllers/person/Gradelist.php @@ -46,6 +46,9 @@ class Gradelist extends Auth_Controller $this->_grades[$row->note]['anmerkung'] = $row->anmerkung; $this->_grades[$row->note]['notenwert'] = $row->notenwert; } + $this->_grades['']['positiv'] = false; + $this->_grades['']['anmerkung'] = ''; + $this->_grades['']['notenwert'] = 0; } /** @@ -386,6 +389,15 @@ class Gradelist extends Auth_Controller 'sws' => $row['sws'] ); } + elseif (isset($row['zugeordnet']) && $row['zugeordnet'] == true && $row['lehrtyp_kurzbz']=='lv') + { + // ECTS und SWS mitzaehlen wenn die Person zugeordnet ist auch wenn noch keine Noten vorhanden ist. + $grades[] = array( + 'note' => '', + 'ects' => $row['ects'], + 'sws' => $row['sws'] + ); + } if (isset($row['childs'])) { diff --git a/application/controllers/system/UDF.php b/application/controllers/system/FAS_UDF.php similarity index 66% rename from application/controllers/system/UDF.php rename to application/controllers/system/FAS_UDF.php index dafa3f8f7..cd78d64d2 100644 --- a/application/controllers/system/UDF.php +++ b/application/controllers/system/FAS_UDF.php @@ -2,8 +2,10 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); -class UDF extends Auth_Controller +class FAS_UDF extends Auth_Controller { + const FAS_UDF_SESSION_NAME = 'fasUdfSessionName'; + public function __construct() { parent::__construct( @@ -22,31 +24,33 @@ class UDF extends Auth_Controller */ public function index() { + $fasUdfSession = getSession(self::FAS_UDF_SESSION_NAME); + $person_id = $this->input->get('person_id'); - if (isset($this->session->person_id)) + if (isset($fasUdfSession['person_id'])) { if (!isset($person_id)) { - $person_id = $this->session->person_id; + $person_id = $fasUdfSession['person_id']; } - unset($this->session->person_id); + unset($fasUdfSession['person_id']); } $prestudent_id = $this->input->get('prestudent_id'); - if (isset($this->session->prestudent_id)) + if (isset($fasUdfSession['prestudent_id'])) { if (!isset($prestudent_id)) { - $prestudent_id = $this->session->prestudent_id; + $prestudent_id = $fasUdfSession['prestudent_id']; } - unset($this->session->prestudent_id); + unset($fasUdfSession['prestudent_id']); } $result = null; - if (isset($this->session->result)) + if (isset($fasUdfSession['result'])) { - $result = clone $this->session->result; - $this->session->set_userdata('result', null); + $result = clone $fasUdfSession['result']; + setSessionElement(self::FAS_UDF_SESSION_NAME, 'result', null); } $data = array('result' => $result); @@ -71,7 +75,7 @@ class UDF extends Auth_Controller } } - $this->load->view('system/udf', $data); + $this->load->view('system/fas_udf', $data); } /** @@ -90,9 +94,9 @@ class UDF extends Auth_Controller if (isSuccess($validation)) { // Load model UDF_model - $this->load->model('system/UDF_model', 'UDFModel'); + $this->load->model('system/FAS_UDF_model', 'FASUDFModel'); - $result = $this->UDFModel->saveUDFs($udfs); + $result = $this->FASUDFModel->saveUDFs($udfs); $userdata['result'] = $result; } @@ -101,8 +105,11 @@ class UDF extends Auth_Controller $userdata['result'] = $validation; } - $this->session->set_userdata($userdata); - redirect('system/UDF'); + setSessionElement(self::FAS_UDF_SESSION_NAME, 'person_id', $userdata['person_id']); + setSessionElement(self::FAS_UDF_SESSION_NAME, 'prestudent_id', $userdata['prestudent_id']); + setSessionElement(self::FAS_UDF_SESSION_NAME, 'result', $userdata['result']); + + redirect('system/FAS_UDF'); } /** diff --git a/application/controllers/system/LogsViewer.php b/application/controllers/system/LogsViewer.php new file mode 100644 index 000000000..8caf9f3a7 --- /dev/null +++ b/application/controllers/system/LogsViewer.php @@ -0,0 +1,44 @@ + 'system/developer:r' + ) + ); + + // Loads WidgetLib + $this->load->library('WidgetLib'); + + // Loads phrases system + $this->loadPhrases( + array( + 'global', + 'ui', + 'filter' + ) + ); + } + + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + + /** + * Main page of the InfoCenter tool + */ + public function index() + { + $this->load->view('system/logs/logsViewer.php'); + } +} diff --git a/application/controllers/system/Navigation.php b/application/controllers/system/Navigation.php index 1abf7d9a8..190f84acd 100644 --- a/application/controllers/system/Navigation.php +++ b/application/controllers/system/Navigation.php @@ -7,7 +7,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); * Provides data to the ajax get calls about the filter * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON */ -class Navigation extends Auth_Controller +class Navigation extends FHC_Controller { const NAVIGATION_PAGE_PARAM = 'navigation_page'; // Navigation page parameter name @@ -16,12 +16,9 @@ class Navigation extends Auth_Controller */ public function __construct() { - parent::__construct( - array( - 'menu' => 'basis/vilesci:r', - 'header' => 'basis/vilesci:r' - ) - ); + parent::__construct(); + + $this->load->library('AuthLib'); $this->_loadNavigationLib(); // Loads the NavigationLib with parameters } diff --git a/application/controllers/system/Phrases.php b/application/controllers/system/Phrases.php index 070750b7c..f589eaeb2 100644 --- a/application/controllers/system/Phrases.php +++ b/application/controllers/system/Phrases.php @@ -45,7 +45,7 @@ class Phrases extends Auth_Controller { $phrases = $this->phraseslib->getPhraseByApp('aufnahme'); if ($phrases->error) - show_error($phrases->retval); + show_error(getError($phrases)); $data = array( 'app' => 'aufnahme', @@ -67,7 +67,7 @@ class Phrases extends Auth_Controller $phrase_inhalt = $this->phraseslib->getPhraseInhalt($phrase_id); if ($phrase_inhalt->error) - show_error($phrase_inhalt->retval); + show_error(getError($phrase_inhalt)); $data = array( 'phrase_id' => $phrase_id, @@ -88,7 +88,7 @@ class Phrases extends Auth_Controller $phrase_inhalt = $this->phraseslib->delPhrasentext($phrasentext_id); if ($phrase_inhalt->error) - show_error($phrase_inhalt->retval); + show_error(getError($phrase_inhalt)); redirect('/system/Phrases/view/'.$phrase_id); } @@ -102,7 +102,7 @@ class Phrases extends Auth_Controller $phrase = $this->phraseslib->getPhrase($phrase_id); if ($phrase->error) - show_error($phrase->retval); + show_error(getError($phrase)); if (count($phrase->retval) != 1) show_error('Phrase nicht vorhanden! ID: '.$phrase_id); @@ -124,7 +124,7 @@ class Phrases extends Auth_Controller $phrase = $this->phraseslib->savePhrase($phrase_id, $data); if ($phrase->error) - show_error($phrase->retval); + show_error(getError($phrase)); $phrase_id = $phrase->retval; @@ -145,7 +145,7 @@ class Phrases extends Auth_Controller $resultOE = $this->OrganisationseinheitModel->loadWhere(array('aktiv' => true, 'oe_parent_kurzbz' => null)); if ($resultOE->error) - show_error($resultOE->retval); + show_error(getError($resultOE)); if (hasData($resultOE)) { @@ -161,7 +161,7 @@ class Phrases extends Auth_Controller $phrase_inhalt = $this->phraseslib->insertPhraseinhalt($data); if ($phrase_inhalt->error) - show_error($phrase_inhalt->retval); + show_error(getError($phrase_inhalt); $phrase_inhalt_id = $phrase_inhalt->retval; @@ -180,7 +180,7 @@ class Phrases extends Auth_Controller { $phrase_inhalt = $this->phraseslib->getPhrasentextById($phrasentext_id); if ($phrase_inhalt->error) - show_error($phrase_inhalt->retval); + show_error(getError($phrase_inhalt)); $data = $phrase_inhalt->retval[0]; @@ -204,7 +204,7 @@ class Phrases extends Auth_Controller $phrase_inhalt = $this->phraseslib->updatePhraseInhalt($phrase_inhalt_id, $data); if ($phrase_inhalt->error) - show_error($phrase_inhalt->retval); + show_error(getError($phrase_inhalt)); redirect('/system/Phrases/editText/'.$phrase_inhalt_id); diff --git a/application/controllers/system/Variables.php b/application/controllers/system/Variables.php new file mode 100644 index 000000000..20303118b --- /dev/null +++ b/application/controllers/system/Variables.php @@ -0,0 +1,78 @@ + 'basis/variable:rw', + 'getVar' => 'basis/variable:rw', + 'changeStudiensemesterVar' => 'basis/variable:rw' + ) + ); + + $this->load->model('system/variable_model', 'VariableModel'); + + $this->_setAuthUID(); + + $this->load->library('VariableLib', array('uid' => $this->_uid)); + } + + /** + * Sets a user variable based on received post parameters, outputs JSON response. + */ + public function setVar() + { + $name = $this->input->post('name'); + $wert = $this->input->post('wert'); + + $result = $this->VariableModel->setVariable($this->_uid, $name, $wert); + + $this->outputJson($result); + } + + /** + * gets a user variable based on received post parameter, outputs JSON response. + */ + public function getVar() + { + $name = $this->input->get('name'); + $this->outputJson($this->VariableModel->getVariables($this->_uid, array($name))); + } + + /** + * Changes a user variable containing a Studiensemester based on received post parameters, outputs JSON response. + */ + public function changeStudiensemesterVar() + { + $name = $this->input->post('name'); + $change = $this->input->post('change'); + + $result = $this->variablelib->changeStudiensemesterVar($this->_uid, $name, $change); + + $this->outputJson($result); + } + + /** + * Retrieve the UID of the logged user and checks if it is valid + */ + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) show_error('User authentification failed'); + } +} diff --git a/application/controllers/system/Vorlage.php b/application/controllers/system/Vorlage.php index 22513970e..7ae79c77f 100644 --- a/application/controllers/system/Vorlage.php +++ b/application/controllers/system/Vorlage.php @@ -49,7 +49,7 @@ class Vorlage extends Auth_Controller $vorlage = $this->vorlagelib->getVorlageByMimetype($mimetype); if ($vorlage->error) - show_error($vorlage->retval); + show_error(getError($vorlage)); $data = array ( 'mimetype' => $mimetype, @@ -66,7 +66,7 @@ class Vorlage extends Auth_Controller $vorlagentext = $this->vorlagelib->getVorlagetextByVorlage($vorlage_kurzbz); if ($vorlagentext->error) - show_error($vorlagentext->retval); + show_error(getError($vorlagentext)); $data = array ( 'vorlage_kurzbz' => $vorlage_kurzbz, @@ -83,7 +83,7 @@ class Vorlage extends Auth_Controller $vorlage = $this->vorlagelib->getVorlage($vorlage_kurzbz); if ($vorlage->error) - show_error($vorlage->retval); + show_error(getError($vorlage)); if (count($vorlage->retval) != 1) show_error('Nachricht nicht vorhanden! ID: '.$vorlage_kurzbz); @@ -119,7 +119,7 @@ class Vorlage extends Auth_Controller $vorlage = $this->vorlagelib->saveVorlage($vorlage_kurzbz, $data); if ($vorlage->error) - show_error($vorlage->retval); + show_error(getError($vorlage)); $vorlage_kurzbz = $vorlage->retval; @@ -137,7 +137,7 @@ class Vorlage extends Auth_Controller $resultOE = $this->OrganisationseinheitModel->loadWhere(array('aktiv' => true, 'oe_parent_kurzbz' => null)); if ($resultOE->error) - show_error($resultOE->retval); + show_error(getError($resultOE)); if (hasData($resultOE)) { @@ -153,7 +153,7 @@ class Vorlage extends Auth_Controller $vorlagetext = $this->vorlagelib->insertVorlagetext($data); if ($vorlagetext->error) - show_error($vorlagetext->retval); + show_error(getError($vorlagetext)); $vorlagestudiengang_id = $vorlagetext->retval; @@ -170,7 +170,7 @@ class Vorlage extends Auth_Controller $vorlagetext = $this->vorlagelib->getVorlagetextById($vorlagestudiengang_id); if ($vorlagetext->error) - show_error($vorlagetext->retval); + show_error(getError($vorlagetext)); $data = $vorlagetext->retval[0]; @@ -254,7 +254,7 @@ class Vorlage extends Auth_Controller $vorlagetext = $this->vorlagelib->updateVorlagetext($data['vorlagestudiengang_id'], $data); if ($vorlagetext->error) - show_error($vorlagetext->retval); + show_error(getError($vorlagetext)); redirect('/system/vorlage/editText/'.$data['vorlagestudiengang_id']); } @@ -266,7 +266,7 @@ class Vorlage extends Auth_Controller $vorlagetext = $this->vorlagelib->getVorlagetextById($vorlagestudiengang_id); if ($vorlagetext->error) - show_error($vorlagetext->retval); + show_error(getError($vorlagetext)); $data = array( 'text' => parseText($vorlagetext->retval[0]->text, $jsonDecodedForm) diff --git a/application/controllers/system/aufnahme/PrestudentMultiAssign.php b/application/controllers/system/aufnahme/PrestudentMultiAssign.php index 30df81281..9906e83cb 100644 --- a/application/controllers/system/aufnahme/PrestudentMultiAssign.php +++ b/application/controllers/system/aufnahme/PrestudentMultiAssign.php @@ -61,7 +61,7 @@ class PrestudentMultiAssign extends Auth_Controller } else if (isError($returnUsers)) { - show_error($returnUsers->retval); + show_error(getError($returnUsers)); } } diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index b83d6e48b..d0dfc2f04 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -24,6 +24,7 @@ class InfoCenter extends Auth_Controller const FILTER_ID = 'filter_id'; const PREV_FILTER_ID = 'prev_filter_id'; + const KEEP_TABLESORTER_FILTER = 'keepTsFilter'; private $_uid; // contains the UID of the logged user @@ -100,9 +101,11 @@ class InfoCenter extends Auth_Controller 'reloadNotizen' => 'infocenter:r', 'reloadLogs' => 'infocenter:r', 'outputAkteContent' => 'infocenter:r', - 'getParkedDate' => 'infocenter:r', + 'getPostponeDate' => 'infocenter:r', 'park' => 'infocenter:rw', 'unpark' => 'infocenter:rw', + 'setOnHold' => 'infocenter:rw', + 'removeOnHold' => 'infocenter:rw', 'getStudienjahrEnd' => 'infocenter:r', 'setNavigationMenuArrayJson' => 'infocenter:r' ) @@ -136,6 +139,8 @@ class InfoCenter extends Auth_Controller $this->_setAuthUID(); // sets property uid + $this->load->library('VariableLib', array('uid' => $this->_uid)); + $this->setControllerId(); // sets the controller id } @@ -188,7 +193,7 @@ class InfoCenter extends Auth_Controller $personexists = $this->PersonModel->load($person_id); if (isError($personexists)) - show_error($personexists->retval); + show_error(getError($personexists)); if (!hasData($personexists)) show_error('Person does not exist!'); @@ -199,8 +204,7 @@ class InfoCenter extends Auth_Controller // mark person as locked for editing $result = $this->PersonLockModel->lockPerson($person_id, $this->_uid, self::APP); - if (isError($result)) - show_error($result->retval); + if (isError($result)) show_error(getError($result)); } $persondata = $this->_loadPersonData($person_id); @@ -226,13 +230,12 @@ class InfoCenter extends Auth_Controller { $result = $this->PersonLockModel->unlockPerson($person_id, self::APP); - if (isError($result)) - show_error($result->retval); + if (isError($result)) show_error(getError($result)); $redirectLink = '/'.self::INFOCENTER_URI.'?'.self::FHC_CONTROLLER_ID.'='.$this->getControllerId(); // Force reload of Dataset after Unlock - $redirectLink .= '&reloadDataset=true'; + $redirectLink .= '&'.self::KEEP_TABLESORTER_FILTER.'=true'; $currentFilterId = $this->input->get(self::FILTER_ID); if (isset($currentFilterId)) @@ -659,7 +662,7 @@ class InfoCenter extends Auth_Controller if (isError($notizen)) { - show_error($notizen->retval); + show_error(getError($notizen)); } $this->load->view('system/infocenter/notizen.php', array('notizen' => $notizen->retval)); @@ -687,14 +690,14 @@ class InfoCenter extends Auth_Controller if (isError($akte)) { - show_error($akte->retval); + show_error(getError($akte)); } $aktecontent = $this->dmslib->getAkteContent($akte_id); if (isError($aktecontent)) { - show_error($aktecontent->retval); + show_error(getError($aktecontent)); } $this->output @@ -709,11 +712,32 @@ class InfoCenter extends Auth_Controller * Gets the date until which a person is parked * @param $person_id */ - public function getParkedDate($person_id) + public function getPostponeDate($person_id) { + $result = array( + 'type' => null, + 'date' => null + ); + $parkedDate = $this->personloglib->getParkedDate($person_id); - $this->outputJsonSuccess(array($parkedDate)); + if (isset($parkedDate)) + { + $result['type'] = 'parked'; + $result['date'] = $parkedDate; + } + else + { + $onholdDate = $this->personloglib->getOnHoldDate($person_id); + + if (isset($onholdDate)) + { + $result['type'] = 'onhold'; + $result['date'] = $onholdDate; + } + } + + $this->outputJsonSuccess($result); } /** @@ -741,6 +765,31 @@ class InfoCenter extends Auth_Controller $this->outputJson($result); } + /** + * Sets a person on hold ("zurückstellen") + */ + public function setOnHold() + { + $person_id = $this->input->post('person_id'); + $date = $this->input->post('onholddate'); + + $result = $this->personloglib->setOnHold($person_id, date_format(date_create($date), 'Y-m-d'), self::TAETIGKEIT, self::APP, null, $this->_uid); + + $this->outputJson($result); + } + + /** + * Removed on hold status of a person + */ + public function removeOnHold() + { + $person_id = $this->input->post('person_id'); + + $result = $this->personloglib->removeOnHold($person_id); + + $this->outputJson($result); + } + /** * Gets the End date of the current Studienjahr */ @@ -891,6 +940,7 @@ class InfoCenter extends Auth_Controller $freigegebenLink = site_url(self::INFOCENTER_URI.'/'.self::FREIGEGEBEN_PAGE); $reihungstestAbsolviertLink = site_url(self::INFOCENTER_URI.'/'.self::REIHUNGSTESTABSOLVIERT_PAGE); + $currentFilterId = $this->input->get(self::FILTER_ID); if (isset($currentFilterId)) { @@ -948,7 +998,7 @@ class InfoCenter extends Auth_Controller $origin_page = $this->input->get(self::ORIGIN_PAGE); - $link = site_url(self::INFOCENTER_URI.'/'.self::INDEX_PAGE); + $link = site_url(self::INFOCENTER_URI); if ($origin_page == self::FREIGEGEBEN_PAGE) { $link = site_url(self::INFOCENTER_URI.'/'.self::FREIGEGEBEN_PAGE); @@ -961,7 +1011,7 @@ class InfoCenter extends Auth_Controller $prevFilterId = $this->input->get(self::PREV_FILTER_ID); if (isset($prevFilterId)) { - $link .= '?'.self::FILTER_ID.'='.$prevFilterId; + $link .= '?'.self::FILTER_ID.'='.$prevFilterId.'&'.self::KEEP_TABLESORTER_FILTER.'=true'; } $this->navigationlib->setSessionMenu( @@ -997,7 +1047,7 @@ class InfoCenter extends Auth_Controller $prevFilterId = $this->input->get(self::PREV_FILTER_ID); if (isset($prevFilterId)) { - $homeLink .= '?'.self::FILTER_ID.'='.$prevFilterId; + $homeLink .= '&'.self::FILTER_ID.'='.$prevFilterId; } $this->navigationlib->setSessionElementMenu( @@ -1112,7 +1162,7 @@ class InfoCenter extends Auth_Controller if (isError($locked)) { - show_error($locked->retval); + show_error(getError($locked)); } $lockedby = null; @@ -1131,7 +1181,7 @@ class InfoCenter extends Auth_Controller if (isError($stammdaten)) { - show_error($stammdaten->retval); + show_error(getError($stammdaten)); } if (!isset($stammdaten->retval)) @@ -1141,21 +1191,21 @@ class InfoCenter extends Auth_Controller if (isError($dokumente)) { - show_error($dokumente->retval); + show_error(getError($dokumente)); } $dokumente_nachgereicht = $this->AkteModel->getAktenWithDokInfo($person_id, null, true); if (isError($dokumente_nachgereicht)) { - show_error($dokumente_nachgereicht->retval); + show_error(getError($dokumente_nachgereicht)); } $messages = $this->MessageModel->getMessagesOfPerson($person_id, 1); if (isError($messages)) { - show_error($messages->retval); + show_error(getError($messages)); } $logs = $this->personloglib->getLogs($person_id); @@ -1164,21 +1214,21 @@ class InfoCenter extends Auth_Controller if (isError($notizen)) { - show_error($notizen->retval); + show_error(getError($notizen)); } $notizen_bewerbung = $this->NotizModel->getNotizByTitel($person_id, 'Anmerkung zur Bewerbung%'); if (isError($notizen_bewerbung)) { - show_error($notizen_bewerbung->retval); + show_error(getError($notizen_bewerbung)); } $user_person = $this->PersonModel->getByUid($this->_uid); if (isError($user_person)) { - show_error($user_person->retval); + show_error(getError($user_person)); } $data = array ( @@ -1209,7 +1259,7 @@ class InfoCenter extends Auth_Controller if (isError($prestudenten)) { - show_error($prestudenten->retval); + show_error(getError($prestudenten)); } foreach ($prestudenten->retval as $prestudent) @@ -1218,7 +1268,7 @@ class InfoCenter extends Auth_Controller if (isError($prestudentWithZgv)) { - show_error($prestudentWithZgv->retval); + show_error(getError($prestudentWithZgv)); } $zgvpruefung = $prestudentWithZgv->retval[0]; @@ -1326,13 +1376,13 @@ class InfoCenter extends Auth_Controller $starta = $this->StudiensemesterModel->load($a->prestudentstatus->studiensemester_kurzbz); if (!hasData($starta)) { - show_error($starta->retval); + show_error(getError($starta)); } $startb = $this->StudiensemesterModel->load($b->prestudentstatus->studiensemester_kurzbz); if (!hasData($startb)) { - show_error($startb->retval); + show_error(getError($startb)); } $starta = date_format(date_create($starta->retval[0]->start), 'Y-m-d'); @@ -1404,7 +1454,7 @@ class InfoCenter extends Auth_Controller if (isError($prestudent)) { - show_error($prestudent->retval); + show_error(getError($prestudent)); } $person_id = $prestudent->retval[0]->person_id; diff --git a/application/controllers/system/Filters.php b/application/controllers/widgets/Filters.php similarity index 68% rename from application/controllers/system/Filters.php rename to application/controllers/widgets/Filters.php index 3bdb6dde2..b5cbc07ea 100644 --- a/application/controllers/system/Filters.php +++ b/application/controllers/widgets/Filters.php @@ -3,7 +3,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); /** - * This controller operates between (interface) the JS (GUI) and the FiltersLib (back-end) + * This controller operates between (interface) the JS (GUI) and the FilterWidgetLib (back-end) * Provides data to the ajax get calls about the filter * Accepts ajax post calls to change the filter data * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON @@ -12,10 +12,10 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); */ class Filters extends FHC_Controller { - const FILTER_PAGE_PARAM = 'filter_page'; + const FILTER_UNIQUE_ID = 'filterUniqueId'; /** - * Calls the parent's constructor and loads the FiltersLib + * Calls the parent's constructor and loads the FilterWidgetLib */ public function __construct() { @@ -24,8 +24,8 @@ class Filters extends FHC_Controller // Loads authentication library and starts authentication $this->load->library('AuthLib'); - // Loads the FiltersLib with HTTP GET/POST parameters - $this->_loadFiltersLib(); + // Loads the FilterWidgetLib with HTTP GET/POST parameters + $this->_loadFilterWidgetLib(); // Checks if the caller is allow to read this data $this->_isAllowed(); @@ -39,7 +39,7 @@ class Filters extends FHC_Controller */ public function getFilter() { - $this->outputJsonSuccess($this->filterslib->getSession()); + $this->outputJsonSuccess($this->filterwidgetlib->getSession()); } /** @@ -48,7 +48,7 @@ class Filters extends FHC_Controller public function rowNumber() { $rowNumber = 0; - $dataset = $this->filterslib->getSessionElement(FiltersLib::SESSION_DATASET); + $dataset = $this->filterwidgetlib->getSessionElement(FilterWidgetLib::SESSION_DATASET); if (isset($dataset) && is_array($dataset)) { @@ -66,7 +66,7 @@ class Filters extends FHC_Controller { $selectedFields = $this->input->post('selectedFields'); - if ($this->filterslib->sortSelectedFields($selectedFields) == true) + if ($this->filterwidgetlib->sortSelectedFields($selectedFields) == true) { $this->getFilter(); } @@ -84,7 +84,7 @@ class Filters extends FHC_Controller { $selectedField = $this->input->post('selectedField'); - if ($this->filterslib->removeSelectedField($selectedField) == true) + if ($this->filterwidgetlib->removeSelectedField($selectedField) == true) { $this->getFilter(); } @@ -101,7 +101,7 @@ class Filters extends FHC_Controller { $selectedField = $this->input->post('selectedField'); - if ($this->filterslib->addSelectedField($selectedField) == true) + if ($this->filterwidgetlib->addSelectedField($selectedField) == true) { $this->getFilter(); } @@ -118,7 +118,7 @@ class Filters extends FHC_Controller { $appliedFilter = $this->input->post('appliedFilter'); - if ($this->filterslib->removeAppliedFilter($appliedFilter) == true) + if ($this->filterwidgetlib->removeAppliedFilter($appliedFilter) == true) { $this->outputJsonSuccess('Removed'); } @@ -138,7 +138,7 @@ class Filters extends FHC_Controller $appliedFiltersConditions = $this->input->post('appliedFiltersConditions'); $appliedFiltersOptions = $this->input->post('appliedFiltersOptions'); - if ($this->filterslib->applyFilters( + if ($this->filterwidgetlib->applyFilters( $appliedFilters, $appliedFiltersOperations, $appliedFiltersConditions, @@ -160,7 +160,7 @@ class Filters extends FHC_Controller { $filter = $this->input->post('filter'); - if ($this->filterslib->addFilter($filter) == true) + if ($this->filterwidgetlib->addFilter($filter) == true) { $this->getFilter(); } @@ -177,7 +177,7 @@ class Filters extends FHC_Controller { $customFilterDescription = $this->input->post('customFilterDescription'); - if ($this->filterslib->saveCustomFilter($customFilterDescription) == true) + if ($this->filterwidgetlib->saveCustomFilter($customFilterDescription) == true) { $this->outputJsonSuccess('Saved'); } @@ -194,7 +194,7 @@ class Filters extends FHC_Controller { $filter_id = $this->input->post('filter_id'); - if ($this->filterslib->removeCustomFilter($filter_id) == true) + if ($this->filterwidgetlib->removeCustomFilter($filter_id) == true) { $this->outputJsonSuccess('Removed'); } @@ -211,7 +211,17 @@ class Filters extends FHC_Controller public function setNavigationMenu() { // Generates the filters structure array - $filterMenu = $this->filterslib->generateFilterMenu($this->input->get(FiltersLib::NAVIGATION_PAGE)); + $filterMenu = $this->filterwidgetlib->generateFilterMenu($this->input->get(FilterWidgetLib::NAVIGATION_PAGE)); + + $this->outputJsonSuccess('Success'); + } + + /** + * Reloads the dataset + */ + public function reloadDataset() + { + $this->filterwidgetlib->reloadDataset(); $this->outputJsonSuccess('Success'); } @@ -224,38 +234,40 @@ class Filters extends FHC_Controller */ private function _isAllowed() { - if (!$this->filterslib->isAllowed()) + if (!$this->filterwidgetlib->isAllowed()) { $this->terminateWithJsonError('You are not allowed to access to this content'); } } /** - * Loads the FiltersLib with the FILTER_PAGE_PARAM parameter - * If the parameter FILTER_PAGE_PARAM is not given then the execution of the controller is terminated and + * Loads the FilterWidgetLib with the FILTER_UNIQUE_ID parameter + * If the parameter FILTER_UNIQUE_ID is not given then the execution of the controller is terminated and * an error message is printed */ - private function _loadFiltersLib() + private function _loadFilterWidgetLib() { - // If the parameter FILTER_PAGE_PARAM is present in the HTTP GET or POST - if (isset($_GET[self::FILTER_PAGE_PARAM]) || isset($_POST[self::FILTER_PAGE_PARAM])) + // If the parameter FILTER_UNIQUE_ID is present in the HTTP GET or POST + if (isset($_GET[self::FILTER_UNIQUE_ID]) || isset($_POST[self::FILTER_UNIQUE_ID])) { // If it is present in the HTTP GET - if (isset($_GET[self::FILTER_PAGE_PARAM])) + if (isset($_GET[self::FILTER_UNIQUE_ID])) { - $filterPage = $this->input->get(self::FILTER_PAGE_PARAM); // is retrieved from the HTTP GET + $filterUniqueId = $this->input->get(self::FILTER_UNIQUE_ID); // is retrieved from the HTTP GET } - elseif (isset($_POST[self::FILTER_PAGE_PARAM])) // Else if it is present in the HTTP POST + elseif (isset($_POST[self::FILTER_UNIQUE_ID])) // Else if it is present in the HTTP POST { - $filterPage = $this->input->post(self::FILTER_PAGE_PARAM); // is retrieved from the HTTP POST + $filterUniqueId = $this->input->post(self::FILTER_UNIQUE_ID); // is retrieved from the HTTP POST } - // Loads the FiltersLib that contains all the used logic - $this->load->library('FiltersLib', array(self::FILTER_PAGE_PARAM => $filterPage)); + // Loads the FilterWidgetLib that contains all the used logic + $this->load->library('FilterWidgetLib'); + + $this->filterwidgetlib->setFilterUniqueId($filterUniqueId); } else // Otherwise an error will be written in the output { - $this->terminateWithJsonError('Parameter "'.self::FILTER_PAGE_PARAM.'" not provided!'); + $this->terminateWithJsonError('Parameter "'.self::FILTER_UNIQUE_ID.'" not provided!'); } } } diff --git a/application/controllers/widgets/Tables.php b/application/controllers/widgets/Tables.php new file mode 100644 index 000000000..21161ff9f --- /dev/null +++ b/application/controllers/widgets/Tables.php @@ -0,0 +1,105 @@ +load->library('AuthLib'); + + // Loads the tablewidgetlib with HTTP GET/POST parameters + $this->_loadTableWidgetLib(); + + // Checks if the caller is allow to read this data + $this->_isAllowed(); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Retrieves data about the current filter from the session and will be written on the output in JSON format + */ + public function getTable() + { + $this->outputJsonSuccess($this->tablewidgetlib->getSession()); + } + + /** + * Retrieves the number of records present in the current dataset and will be written on the output in JSON format + */ + public function rowNumber() + { + $rowNumber = 0; + $dataset = $this->tablewidgetlib->getSessionElement(TableWidgetLib::SESSION_DATASET); + + if (isset($dataset) && is_array($dataset)) + { + $rowNumber = count($dataset); + } + + $this->outputJsonSuccess($rowNumber); + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Checks if the user is allowed to use this filter + */ + private function _isAllowed() + { + if (!$this->tablewidgetlib->isAllowed()) + { + $this->terminateWithJsonError('You are not allowed to access to this content'); + } + } + + /** + * Loads the tablewidgetlib with the TABLE_UNIQUE_ID parameter + * If the parameter TABLE_UNIQUE_ID is not given then the execution of the controller is terminated and + * an error message is printed + */ + private function _loadTableWidgetLib() + { + // If the parameter TABLE_UNIQUE_ID is present in the HTTP GET or POST + if (isset($_GET[self::TABLE_UNIQUE_ID]) || isset($_POST[self::TABLE_UNIQUE_ID])) + { + // If it is present in the HTTP GET + if (isset($_GET[self::TABLE_UNIQUE_ID])) + { + $tableUniqueId = $this->input->get(self::TABLE_UNIQUE_ID); // is retrieved from the HTTP GET + } + elseif (isset($_POST[self::TABLE_UNIQUE_ID])) // Else if it is present in the HTTP POST + { + $tableUniqueId = $this->input->post(self::TABLE_UNIQUE_ID); // is retrieved from the HTTP POST + } + + // Loads the tablewidgetlib that contains all the used logic + $this->load->library('TableWidgetLib'); + + $this->tablewidgetlib->setTableUniqueId($tableUniqueId); + } + else // Otherwise an error will be written in the output + { + $this->terminateWithJsonError('Parameter "'.self::TABLE_UNIQUE_ID.'" not provided!'); + } + } +} diff --git a/application/core/APIv1_Controller.php b/application/core/APIv1_Controller.php index 6432c87db..14b4b626d 100644 --- a/application/core/APIv1_Controller.php +++ b/application/core/APIv1_Controller.php @@ -1,9 +1,11 @@ isEntitled * - Checks if the caller is allowed to access to this content with the given permissions * if it is not allowed will set the HTTP header with code 401 * - Calls the parent (REST_Controller) _remap method to performs other checks + * NOTE: this methods override the parent method!!! */ - public function _remap($object_called, $arguments) + public function _remap($object_called, $arguments = []) { if (isset($this->authlib)) // if set then the authentication is ok { diff --git a/application/core/Auth_Controller.php b/application/core/Auth_Controller.php index 5d03091f0..c407a106f 100644 --- a/application/core/Auth_Controller.php +++ b/application/core/Auth_Controller.php @@ -1,8 +1,11 @@ load->library('LogLib', array( + 'classIndex' => 5, + 'functionIndex' => 5, + 'lineIndex' => 4, + 'dbLogType' => 'job', // required + 'dbExecuteUser' => 'Cronjob system' + )); + } + + //------------------------------------------------------------------------------------------------------------------ + // Protected methods + + /** + * Writes a cronjob info log + */ + protected function logInfo($response, $parameters = null) + { + $this->_log(LogLib::INFO, 'Cronjob info', $response, $parameters); + } + + /** + * Writes a cronjob debug log + */ + protected function logDebug($response, $parameters = null) + { + $this->_log(LogLib::DEBUG, 'Cronjob debug', $response, $parameters); + } + + /** + * Writes a cronjob warning log + */ + protected function logWarning($response, $parameters = null) + { + $this->_log(LogLib::WARNING, 'Cronjob warning', $response, $parameters); + } + + /** + * Writes a cronjob error log + */ + protected function logError($response, $parameters = null) + { + $this->_log(LogLib::ERROR, 'Cronjob error', $response, $parameters); + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Writes a log to database + */ + private function _log($level, $requestId, $response, $parameters) + { + $data = new stdClass(); + + $data->response = $response; + if ($parameters != null) $data->parameters = $parameters; + + switch($level) + { + case LogLib::INFO: + $this->loglib->logInfoDB($requestId, json_encode(success($data, LogLib::INFO))); + break; + case LogLib::DEBUG: + $this->loglib->logDebugDB($requestId, json_encode(success($data, LogLib::DEBUG))); + break; + case LogLib::WARNING: + $this->loglib->logWarningDB($requestId, json_encode(error($data, LogLib::WARNING))); + break; + case LogLib::ERROR: + $this->loglib->logErrorDB($requestId, json_encode(error($data, LogLib::ERROR))); + break; + } + } +} diff --git a/application/core/RESTFul_Controller.php b/application/core/RESTFul_Controller.php new file mode 100644 index 000000000..984f193de --- /dev/null +++ b/application/core/RESTFul_Controller.php @@ -0,0 +1,215 @@ +load->helper('hlp_return_object'); + + // Loads helper session to manage the php session + $this->load->helper('hlp_session'); + + // Loads helper with generic utility function + $this->load->helper('hlp_common'); + } + + /** + * Totally overrode parent's _perform_library_auth method to keep file and class name + * for AuthLib and to call AuthLib with the extra parameter + */ + protected function _perform_library_auth($username = '', $password = NULL) + { + if (empty($username)) + { + log_message('error', 'Library Auth: Failure, empty username'); + return FALSE; + } + + $auth_library_class = $this->config->item('auth_library_class'); + $auth_library_function = $this->config->item('auth_library_function'); + + if (empty($auth_library_class)) + { + log_message('debug', 'Library Auth: Failure, empty auth_library_class'); + return FALSE; + } + + if (empty($auth_library_function)) + { + log_message('debug', 'Library Auth: Failure, empty auth_library_function'); + return FALSE; + } + + if (is_callable([$auth_library_class, $auth_library_function]) === FALSE) + { + $this->load->library($auth_library_class, array(false)); + } + + return $this->{strtolower($auth_library_class)}->$auth_library_function($username, $password); + } + + /** + * Totally overrode parent's _remap method to change the naming convention of controllers methods + */ + public function _remap($object_called, $arguments = []) + { + // Should we answer if not over SSL? + if ($this->config->item('force_https') && $this->request->ssl === FALSE) + { + $this->response([ + $this->config->item('rest_status_field_name') => FALSE, + $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_unsupported') + ], self::HTTP_FORBIDDEN); + + $this->is_valid_request = false; + } + + // Remove the supported format from the function name e.g. index.json => index + $object_called = preg_replace('/^(.*)\.(?:'.implode('|', array_keys($this->_supported_formats)).')$/', '$1', $object_called); + + // NOTE: START changes + $controller_method = $object_called.'_'.$this->request->method; // Method name fallback + // If the config entry rest_methods_name_format is provided and is not empty then use it to produce the method name + if (!empty($this->config->item('rest_methods_name_format'))) + { + $controller_method = sprintf($this->config->item('rest_methods_name_format'), $object_called, $this->request->method); + } + // END changes + + // Does this method exist? If not, try executing an index method + if (!method_exists($this, $controller_method)) { + $controller_method = "index_" . $this->request->method; + array_unshift($arguments, $object_called); + } + + // Do we want to log this method (if allowed by config)? + $log_method = ! (isset($this->methods[$controller_method]['log']) && $this->methods[$controller_method]['log'] === FALSE); + + // Use keys for this method? + $use_key = ! (isset($this->methods[$controller_method]['key']) && $this->methods[$controller_method]['key'] === FALSE); + + // They provided a key, but it wasn't valid, so get them out of here + if ($this->config->item('rest_enable_keys') && $use_key && $this->_allow === FALSE) + { + if ($this->config->item('rest_enable_logging') && $log_method) + { + $this->_log_request(); + } + + // fix cross site to option request error + if($this->request->method == 'options') { + exit; + } + + $this->response([ + $this->config->item('rest_status_field_name') => FALSE, + $this->config->item('rest_message_field_name') => sprintf($this->lang->line('text_rest_invalid_api_key'), $this->rest->key) + ], self::HTTP_FORBIDDEN); + + $this->is_valid_request = false; + } + + // Check to see if this key has access to the requested controller + if ($this->config->item('rest_enable_keys') && $use_key && empty($this->rest->key) === FALSE && $this->_check_access() === FALSE) + { + if ($this->config->item('rest_enable_logging') && $log_method) + { + $this->_log_request(); + } + + $this->response([ + $this->config->item('rest_status_field_name') => FALSE, + $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_api_key_unauthorized') + ], self::HTTP_UNAUTHORIZED); + + $this->is_valid_request = false; + } + + // Sure it exists, but can they do anything with it? + if (! method_exists($this, $controller_method)) + { + $this->response([ + $this->config->item('rest_status_field_name') => FALSE, + $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_unknown_method') + ], self::HTTP_METHOD_NOT_ALLOWED); + + $this->is_valid_request = false; + } + + // Doing key related stuff? Can only do it if they have a key right? + if ($this->config->item('rest_enable_keys') && empty($this->rest->key) === FALSE) + { + // Check the limit + if ($this->config->item('rest_enable_limits') && $this->_check_limit($controller_method) === FALSE) + { + $response = [$this->config->item('rest_status_field_name') => FALSE, $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_api_key_time_limit')]; + $this->response($response, self::HTTP_UNAUTHORIZED); + + $this->is_valid_request = false; + } + + // If no level is set use 0, they probably aren't using permissions + $level = isset($this->methods[$controller_method]['level']) ? $this->methods[$controller_method]['level'] : 0; + + // If no level is set, or it is lower than/equal to the key's level + $authorized = $level <= $this->rest->level; + // IM TELLIN! + if ($this->config->item('rest_enable_logging') && $log_method) + { + $this->_log_request($authorized); + } + if($authorized === FALSE) + { + // They don't have good enough perms + $response = [$this->config->item('rest_status_field_name') => FALSE, $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_api_key_permissions')]; + $this->response($response, self::HTTP_UNAUTHORIZED); + + $this->is_valid_request = false; + } + } + + //check request limit by ip without login + elseif ($this->config->item('rest_limits_method') == "IP_ADDRESS" && $this->config->item('rest_enable_limits') && $this->_check_limit($controller_method) === FALSE) + { + $response = [$this->config->item('rest_status_field_name') => FALSE, $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_ip_address_time_limit')]; + $this->response($response, self::HTTP_UNAUTHORIZED); + + $this->is_valid_request = false; + } + + // No key stuff, but record that stuff is happening + elseif ($this->config->item('rest_enable_logging') && $log_method) + { + $this->_log_request($authorized = TRUE); + } + + // Call the controller method and passed arguments + try + { + if ($this->is_valid_request) { + call_user_func_array([$this, $controller_method], $arguments); + } + } + catch (Exception $ex) + { + if ($this->config->item('rest_handle_exceptions') === FALSE) { + throw $ex; + } + + // If the method doesn't exist, then the error will be caught and an error response shown + $_error = &load_class('Exceptions', 'core'); + $_error->show_exception($ex); + } + } +} diff --git a/application/core/REST_Controller.php b/application/core/REST_Controller.php deleted file mode 100644 index 9cd276556..000000000 --- a/application/core/REST_Controller.php +++ /dev/null @@ -1,2166 +0,0 @@ - 'application/json', - 'array' => 'application/json', - 'csv' => 'application/csv', - 'html' => 'text/html', - 'jsonp' => 'application/javascript', - 'php' => 'text/plain', - 'serialized' => 'application/vnd.php.serialized', - 'xml' => 'application/xml' - ]; - - /** - * Information about the current API user - * - * @var object - */ - protected $_apiuser; - - /** - * Enable XSS flag - * Determines whether the XSS filter is always active when - * GET, OPTIONS, HEAD, POST, PUT, DELETE and PATCH data is encountered. - * Set automatically based on config setting - * - * @var bool - */ - protected $_enable_xss = FALSE; - - /** - * HTTP status codes and their respective description - * Note: Only the widely used HTTP status codes are used - * - * @var array - * @link http://www.restapitutorial.com/httpstatuscodes.html - */ - protected $http_status_codes = [ - self::HTTP_OK => 'OK', - self::HTTP_CREATED => 'CREATED', - self::HTTP_NO_CONTENT => 'NO CONTENT', - self::HTTP_NOT_MODIFIED => 'NOT MODIFIED', - self::HTTP_BAD_REQUEST => 'BAD REQUEST', - self::HTTP_UNAUTHORIZED => 'UNAUTHORIZED', - self::HTTP_FORBIDDEN => 'FORBIDDEN', - self::HTTP_NOT_FOUND => 'NOT FOUND', - self::HTTP_METHOD_NOT_ALLOWED => 'METHOD NOT ALLOWED', - self::HTTP_NOT_ACCEPTABLE => 'NOT ACCEPTABLE', - self::HTTP_CONFLICT => 'CONFLICT', - self::HTTP_INTERNAL_SERVER_ERROR => 'INTERNAL SERVER ERROR', - self::HTTP_NOT_IMPLEMENTED => 'NOT IMPLEMENTED' - ]; - - /** - * Extend this function to apply additional checking early on in the process - * - * @access protected - * @return void - */ - protected function early_checks() - { - // Loads helper message to manage returning messages - $this->load->helper('hlp_return_object'); - - // Loads helper session to manage the php session - $this->load->helper('hlp_session'); - - // Loads helper with generic utility function - $this->load->helper('hlp_common'); - } - - /** - * Constructor for the REST API - * - * @access public - * @param string $config Configuration filename minus the file extension - * e.g: my_rest.php is passed as 'my_rest' - * @return void - */ - public function __construct($config = 'rest') - { - parent::__construct(); - - // Disable XML Entity (security vulnerability) - libxml_disable_entity_loader(TRUE); - - // Check to see if PHP is equal to or greater than 5.4.x - if (is_php('5.4') === FALSE) - { - // CodeIgniter 3 is recommended for v5.4 or above - throw new Exception('Using PHP v' . PHP_VERSION . ', though PHP v5.4 or greater is required'); - } - - // Check to see if this is CI 3.x - $ci_version_number = explode('.', CI_VERSION, 2); - if ($ci_version_number[0] < 3) - { - throw new Exception('REST Server requires CodeIgniter 3.x'); - } - - // Set the default value of global xss filtering. Same approach as CodeIgniter 3 - $this->_enable_xss = ($this->config->item('global_xss_filtering') === TRUE); - - // Don't try to parse template variables like {elapsed_time} and {memory_usage} - // when output is displayed for not damaging data accidentally - $this->output->parse_exec_vars = FALSE; - - // Start the timer for how long the request takes - $this->_start_rtime = microtime(TRUE); - - // Load the rest.php configuration file - $this->load->config($config); - - // At present the library is bundled with REST_Controller 2.5+, but will eventually be part of CodeIgniter (no citation) - $this->load->library('format'); - - // Determine supported output formats from configiguration. - $supported_formats = $this->config->item('rest_supported_formats'); - - // Validate the configuration setting output formats - if (empty($supported_formats)) - { - $supported_formats = []; - } - - if (!is_array($supported_formats)) - { - $supported_formats = [$supported_formats]; - } - - // Add silently the default output format if it is missing. - $default_format = $this->_get_default_output_format(); - if (!in_array($default_format, $supported_formats)) - { - $supported_formats[] = $default_format; - } - - // Now update $this->_supported_formats - $this->_supported_formats = array_intersect_key($this->_supported_formats, array_flip($supported_formats)); - - // Get the language - $language = $this->config->item('rest_language'); - if ($language === NULL) - { - $language = 'en-US'; - } - - // Load the language file - $this->lang->load('rest_controller', $language); - - // Initialise the response, request and rest objects - $this->request = new stdClass(); - $this->response = new stdClass(); - $this->rest = new stdClass(); - - // Check to see if the current IP address is blacklisted - if ($this->config->item('rest_ip_blacklist_enabled') === TRUE) - { - $this->_check_blacklist_auth(); - } - - // Determine whether the connection is HTTPS - $this->request->ssl = is_https(); - - // How is this request being made? GET, POST, PATCH, DELETE, INSERT, PUT, HEAD or OPTIONS - $this->request->method = $this->_detect_method(); - - // Create an argument container if it doesn't exist e.g. _get_args - if (isset($this->{'_' . $this->request->method . '_args'}) === FALSE) - { - $this->{'_' . $this->request->method . '_args'} = []; - } - - // Set up the query parameters - $this->_parse_query(); - - // Set up the GET variables - $this->_get_args = array_merge($this->_get_args, $this->uri->ruri_to_assoc()); - - // Try to find a format for the request (means we have a request body) - $this->request->format = $this->_detect_input_format(); - - // Not all methods have a body attached with them - $this->request->body = NULL; - - $this->{'_parse_' . $this->request->method}(); - - // Now we know all about our request, let's try and parse the body if it exists - if ($this->request->format && $this->request->body) - { - $this->request->body = $this->format->factory($this->request->body, $this->request->format)->to_array(); - // Assign payload arguments to proper method container - $this->{'_' . $this->request->method . '_args'} = $this->request->body; - } - - // Merge both for one mega-args variable - $this->_args = array_merge( - $this->_get_args, - $this->_options_args, - $this->_patch_args, - $this->_head_args, - $this->_put_args, - $this->_post_args, - $this->_delete_args, - $this->{'_' . $this->request->method . '_args'} - ); - - // Which format should the data be returned in? - $this->response->format = $this->_detect_output_format(); - - // Which language should the data be returned in? - $this->response->lang = $this->_detect_lang(); - - // Extend this function to apply additional checking early on in the process - $this->early_checks(); - - // Load DB if its enabled - if ($this->config->item('rest_database_group') && ($this->config->item('rest_enable_keys') || $this->config->item('rest_enable_logging'))) - { - $this->rest->db = $this->load->database($this->config->item('rest_database_group'), TRUE); - } - - // Use whatever database is in use (isset returns FALSE) - elseif (property_exists($this, 'db')) - { - $this->rest->db = $this->db; - } - - // Check if there is a specific auth type for the current class/method - // _auth_override_check could exit so we need $this->rest->db initialized before - $this->auth_override = $this->_auth_override_check(); - - // Checking for keys? GET TO WorK! - // Skip keys test for $config['auth_override_class_method']['class'['method'] = 'none' - if ($this->config->item('rest_enable_keys') && $this->auth_override !== TRUE) - { - $this->_allow = $this->_detect_api_key(); - } - - // Only allow ajax requests - if ($this->input->is_ajax_request() === FALSE && $this->config->item('rest_ajax_only')) - { - // Display an error response - $this->response([ - $this->config->item('rest_status_field_name') => FALSE, - $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_ajax_only') - ], self::HTTP_NOT_ACCEPTABLE); - } - - // When there is no specific override for the current class/method, use the default auth value set in the config - if ($this->auth_override === FALSE && ($this->config->item('rest_enable_keys') && $this->_allow === TRUE)) - { - $rest_auth = strtolower($this->config->item('rest_auth')); - switch ($rest_auth) - { - case 'basic': - $this->_prepare_basic_auth(); - break; - case 'digest': - $this->_prepare_digest_auth(); - break; - case 'session': - $this->_check_php_session(); - break; - } - if ($this->config->item('rest_ip_whitelist_enabled') === TRUE) - { - $this->_check_whitelist_auth(); - } - } - } - - /** - * Deconstructor - * - * @author Chris Kacerguis - * @access public - * @return void - */ - public function __destruct() - { - // Get the current timestamp - $this->_end_rtime = microtime(TRUE); - - // Log the loading time to the log table - if ($this->config->item('rest_enable_logging') === TRUE) - { - $this->_log_access_time(); - } - } - - /** - * Requests are not made to methods directly, the request will be for - * an "object". This simply maps the object and method to the correct - * Controller method - * - * @access public - * @param string $object_called - * @param array $arguments The arguments passed to the controller method - */ - public function _remap($object_called, $arguments) - { - // Should we answer if not over SSL? - if ($this->config->item('force_https') && $this->request->ssl === FALSE) - { - $this->response([ - $this->config->item('rest_status_field_name') => FALSE, - $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_unsupported') - ], self::HTTP_FORBIDDEN); - } - - // Remove the supported format from the function name e.g. index.json => index - $object_called = preg_replace('/^(.*)\.(?:' . implode('|', array_keys($this->_supported_formats)) . ')$/', '$1', $object_called); - - //$controller_method = $object_called . '_' . $this->request->method; - // CamelCase compliant - $controller_method = $this->request->method.ucfirst($object_called); - - // Do we want to log this method (if allowed by config)? - $log_method = !(isset($this->methods[$controller_method]['log']) && $this->methods[$controller_method]['log'] === FALSE); - - // Use keys for this method? - $use_key = !(isset($this->methods[$controller_method]['key']) && $this->methods[$controller_method]['key'] === FALSE); - - // They provided a key, but it wasn't valid, so get them out of here - if ($this->config->item('rest_enable_keys') && $use_key && $this->_allow === FALSE) - { - if ($this->config->item('rest_enable_logging') && $log_method) - { - $this->_log_request(); - } - - $this->response([ - $this->config->item('rest_status_field_name') => FALSE, - $this->config->item('rest_message_field_name') => sprintf($this->lang->line('text_rest_invalid_api_key'), $this->rest->key) - ], self::HTTP_FORBIDDEN); - } - - // Check to see if this key has access to the requested controller - if ($this->config->item('rest_enable_keys') && $use_key && empty($this->rest->key) === FALSE && $this->_check_access() === FALSE) - { - if ($this->config->item('rest_enable_logging') && $log_method) - { - $this->_log_request(); - } - - $this->response([ - $this->config->item('rest_status_field_name') => FALSE, - $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_api_key_unauthorized') - ], self::HTTP_UNAUTHORIZED); - } - - // Sure it exists, but can they do anything with it? - if (method_exists($this, $controller_method) === FALSE) - { - $this->response([ - $this->config->item('rest_status_field_name') => FALSE, - $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_unknown_method') - ], self::HTTP_NOT_FOUND); - } - - // Doing key related stuff? Can only do it if they have a key right? - if ($this->config->item('rest_enable_keys') && empty($this->rest->key) === FALSE) - { - // Check the limit - if ($this->config->item('rest_enable_limits') && $this->_check_limit($controller_method) === FALSE) - { - $response = [$this->config->item('rest_status_field_name') => FALSE, $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_api_key_time_limit')]; - $this->response($response, self::HTTP_UNAUTHORIZED); - } - - // If no level is set use 0, they probably aren't using permissions - $level = isset($this->methods[$controller_method]['level']) ? $this->methods[$controller_method]['level'] : 0; - - // If no level is set, or it is lower than/equal to the key's level - $authorized = $level <= $this->rest->level; - - // IM TELLIN! - if ($this->config->item('rest_enable_logging') && $log_method) - { - $this->_log_request($authorized); - } - - // They don't have good enough perms - $response = [$this->config->item('rest_status_field_name') => FALSE, $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_api_key_permissions')]; - $authorized || $this->response($response, self::HTTP_UNAUTHORIZED); - } - - // No key stuff, but record that stuff is happening - elseif ($this->config->item('rest_enable_logging') && $log_method) - { - $this->_log_request($authorized = TRUE); - } - - // Call the controller method and passed arguments - try - { - call_user_func_array([$this, $controller_method], $arguments); - } - catch (Exception $ex) - { - // If the method doesn't exist, then the error will be caught and an error response shown - $this->response([ - $this->config->item('rest_status_field_name') => FALSE, - $this->config->item('rest_message_field_name') => [ - 'classname' => get_class($ex), - 'message' => $ex->getMessage() - ] - ], self::HTTP_INTERNAL_SERVER_ERROR); - } - } - - /** - * Takes mixed data and optionally a status code, then creates the response - * - * @access public - * @param array|NULL $data Data to output to the user - * @param int|NULL $http_code HTTP status code - * @param bool $continue TRUE to flush the response to the client and continue - * running the script; otherwise, exit - */ - public function response($data = NULL, $http_code = NULL, $continue = FALSE) - { - // If the HTTP status is not NULL, then cast as an integer - if ($http_code !== NULL) - { - // So as to be safe later on in the process - $http_code = (int) $http_code; - } - - // Set the output as NULL by default - $output = NULL; - // If data is NULL and no HTTP status code provided, then display, error and exit - if ($data === NULL && $http_code === NULL) - { - $http_code = self::HTTP_NOT_FOUND; - } - - // If data is not NULL and a HTTP status code provided, then continue - elseif ($data !== NULL) - { - // If the format method exists, call and return the output in that format - if (method_exists($this->format, 'to_' . $this->response->format)) - { - // Set the format header - $this->output->set_content_type($this->_supported_formats[$this->response->format], strtolower($this->config->item('charset'))); - $output = $this->format->factory($data)->{'to_' . $this->response->format}(); - - // An array must be parsed as a string, so as not to cause an array to string error - // Json is the most appropriate form for such a datatype - if ($this->response->format === 'array') - { - $output = $this->format->factory($output)->{'to_json'}(); - } - } - else - { - // If an array or object, then parse as a json, so as to be a 'string' - if (is_array($data) || is_object($data)) - { - $data = $this->format->factory($data)->{'to_json'}(); - } - // Format is not supported, so output the raw data as a string - $output = $data; - } - } - - // If not greater than zero, then set the HTTP status code as 200 by default - // Though perhaps 500 should be set instead, for the developer not passing a - // correct HTTP status code - $http_code > 0 || $http_code = self::HTTP_OK; - - $this->output->set_status_header($http_code); - - // JC: Log response code only if rest logging enabled - if ($this->config->item('rest_enable_logging') === TRUE) - { - $this->_log_response_code($http_code); - } - - // Output the data - $this->output->set_output($output); - - if ($continue === FALSE) - { - // Display the data and exit execution - $this->output->_display(); - exit; - } - - // Otherwise dump the output automatically - } - - /** - * Takes mixed data and optionally a status code, then creates the response - * within the buffers of the Output class. The response is sent to the client - * lately by the framework, after the current controller's method termination. - * All the hooks after the controller's method termination are executable - * - * @access public - * @param array|NULL $data Data to output to the user - * @param int|NULL $http_code HTTP status code - */ - public function set_response($data = NULL, $http_code = NULL) - { - $this->response($data, $http_code, TRUE); - } - - /** - * Get the input format e.g. json or xml - * - * @access protected - * @return string|NULL Supported input format; otherwise, NULL - */ - protected function _detect_input_format() - { - // Get the CONTENT-TYPE value from the SERVER variable - $content_type = $this->input->server('CONTENT_TYPE'); - - if (empty($content_type) === FALSE) - { - // Check all formats against the HTTP_ACCEPT header - foreach ($this->_supported_formats as $key => $value) - { - // $key = format e.g. csv - // $value = mime type e.g. application/csv - - // If a semi-colon exists in the string, then explode by ; and get the value of where - // the current array pointer resides. This will generally be the first element of the array - $content_type = (strpos($content_type, ';') !== FALSE ? current(explode(';', $content_type)) : $content_type); - - // If both the mime types match, then return the format - if ($content_type === $value) - { - return $key; - } - } - } - - return NULL; - } - - /** - * Gets the default format from the configuration. Fallbacks to 'json'. - * if the corresponding configuration option $config['rest_default_format'] - * is missing or is empty. - * - * @access protected - * @return string The default supported input format - */ - protected function _get_default_output_format() - { - $default_format = (string) $this->config->item('rest_default_format'); - return $default_format === '' ? 'json' : $default_format; - } - - /** - * Detect which format should be used to output the data - * - * @access protected - * @return mixed|NULL|string Output format - */ - protected function _detect_output_format() - { - // Concatenate formats to a regex pattern e.g. \.(csv|json|xml) - $pattern = '/\.(' . implode('|', array_keys($this->_supported_formats)) . ')($|\/)/'; - $matches = []; - - // Check if a file extension is used e.g. http://example.com/api/index.json?param1=param2 - if (preg_match($pattern, $this->uri->uri_string(), $matches)) - { - return $matches[1]; - } - - // Get the format parameter named as 'format' - if (isset($this->_get_args['format'])) - { - $format = strtolower($this->_get_args['format']); - - if (isset($this->_supported_formats[$format]) === TRUE) - { - return $format; - } - } - - // Get the HTTP_ACCEPT server variable - $http_accept = $this->input->server('HTTP_ACCEPT'); - - // Otherwise, check the HTTP_ACCEPT server variable - if ($this->config->item('rest_ignore_http_accept') === FALSE && $http_accept !== NULL) - { - // Check all formats against the HTTP_ACCEPT header - foreach (array_keys($this->_supported_formats) as $format) - { - // Has this format been requested? - if (strpos($http_accept, $format) !== FALSE) - { - if ($format !== 'html' && $format !== 'xml') - { - // If not HTML or XML assume it's correct - return $format; - } - elseif ($format === 'html' && strpos($http_accept, 'xml') === FALSE) - { - // HTML or XML have shown up as a match - // If it is truly HTML, it wont want any XML - return $format; - } - else if ($format === 'xml' && strpos($http_accept, 'html') === FALSE) - { - // If it is truly XML, it wont want any HTML - return $format; - } - } - } - } - - // Check if the controller has a default format - if (empty($this->rest_format) === FALSE) - { - return $this->rest_format; - } - - // Obtain the default format from the configuration - return $this->_get_default_output_format(); - } - - /** - * Get the HTTP request string e.g. get or post - * - * @access protected - * @return string|NULL Supported request method as a lowercase string; otherwise, NULL if not supported - */ - protected function _detect_method() - { - // Declare a variable to store the method - $method = NULL; - - // Determine whether the 'enable_emulate_request' setting is enabled - if ($this->config->item('enable_emulate_request') === TRUE) - { - $method = $this->input->post('_method'); - if ($method === NULL) - { - $method = $this->input->server('HTTP_X_HTTP_METHOD_OVERRIDE'); - } - - $method = strtolower($method); - } - - if (empty($method)) - { - // Get the request method as a lowercase string - $method = $this->input->method(); - } - - return in_array($method, $this->allowed_http_methods) && method_exists($this, '_parse_' . $method) ? $method : 'get'; - } - - /** - * See if the user has provided an API key - * - * @access protected - * @return bool - */ - protected function _detect_api_key() - { - // Get the api key name variable set in the rest config file - $api_key_variable = $this->config->item('rest_key_name'); - - // Work out the name of the SERVER entry based on config - $key_name = 'HTTP_' . strtoupper(str_replace('-', '_', $api_key_variable)); - - $this->rest->key = NULL; - $this->rest->level = NULL; - $this->rest->user_id = NULL; - $this->rest->ignore_limits = FALSE; - - // Find the key from server or arguments - if (($key = isset($this->_args[$api_key_variable]) ? $this->_args[$api_key_variable] : $this->input->server($key_name))) - { - if (!($row = $this->rest->db->where($this->config->item('rest_key_column'), $key)->get($this->config->item('rest_keys_table'))->row())) - { - return FALSE; - } - - $this->rest->key = $row->{$this->config->item('rest_key_column')}; - - isset($row->user_id) && $this->rest->user_id = $row->user_id; - isset($row->level) && $this->rest->level = $row->level; - isset($row->ignore_limits) && $this->rest->ignore_limits = $row->ignore_limits; - - $this->_apiuser = $row; - - /* - * If "is private key" is enabled, compare the ip address with the list - * of valid ip addresses stored in the database - */ - if (empty($row->is_private_key) === FALSE) - { - // Check for a list of valid ip addresses - if (isset($row->ip_addresses)) - { - // multiple ip addresses must be separated using a comma, explode and loop - $list_ip_addresses = explode(',', $row->ip_addresses); - $found_address = FALSE; - - foreach ($list_ip_addresses as $ip_address) - { - if ($this->input->ip_address() === trim($ip_address)) - { - // there is a match, set the the value to TRUE and break out of the loop - $found_address = TRUE; - break; - } - } - - return $found_address; - } - else - { - // There should be at least one IP address for this private key - return FALSE; - } - } - - return TRUE; - } - - // No key has been sent - return FALSE; - } - - /** - * Preferred return language - * - * @access protected - * @return string|NULL The language code - */ - protected function _detect_lang() - { - $lang = $this->input->server('HTTP_ACCEPT_LANGUAGE'); - if ($lang === NULL) - { - return NULL; - } - - // It appears more than one language has been sent using a comma delimiter - if (strpos($lang, ',') !== FALSE) - { - $langs = explode(',', $lang); - - $return_langs = []; - foreach ($langs as $lang) - { - // Remove weight and trim leading and trailing whitespace - list($lang) = explode(';', $lang); - $return_langs[] = trim($lang); - } - - return $return_langs; - } - - // Otherwise simply return as a string - return $lang; - } - - /** - * Add the request to the log table - * - * @access protected - * @param bool $authorized TRUE the user is authorized; otherwise, FALSE - * @return bool TRUE the data was inserted; otherwise, FALSE - */ - protected function _log_request($authorized = FALSE) - { - // Insert the request into the log table - $is_inserted = $this->rest->db - ->insert( - $this->config->item('rest_logs_table'), [ - 'uri' => $this->uri->uri_string(), - 'method' => $this->request->method, - 'params' => $this->_args ? ($this->config->item('rest_logs_json_params') === TRUE ? json_encode($this->_args) : serialize($this->_args)) : NULL, - 'api_key' => isset($this->rest->key) ? $this->rest->key : '', - 'ip_address' => $this->input->ip_address(), - 'time' => time(), - 'authorized' => $authorized - ]); - - // Get the last insert id to update at a later stage of the request - $this->_insert_id = $this->rest->db->insert_id(); - - return $is_inserted; - } - - /** - * Check if the requests to a controller method exceed a limit - * - * @access protected - * @param string $controller_method The method being called - * @return bool TRUE the call limit is below the threshold; otherwise, FALSE - */ - protected function _check_limit($controller_method) - { - // They are special, or it might not even have a limit - if (empty($this->rest->ignore_limits) === FALSE) - { - // Everything is fine - return TRUE; - } - - switch ($this->config->item('rest_limits_method')) - { - case 'API_KEY': - $limited_uri = 'api-key:' . (isset($this->rest->key) ? $this->rest->key : ''); - $limited_method_name = isset($this->rest->key) ? $this->rest->key : ''; - break; - - case 'METHOD_NAME': - $limited_uri = 'method-name:' . $controller_method; - $limited_method_name = $controller_method; - break; - - case 'ROUTED_URL': - default: - $limited_uri = $this->uri->ruri_string(); - if (strpos(strrev($limited_uri), strrev($this->response->format)) === 0) - { - $limited_uri = substr($limited_uri,0, -strlen($this->response->format) - 1); - } - $limited_uri = 'uri:' . $limited_uri . ':' . $this->request->method; // It's good to differentiate GET from PUT - $limited_method_name = $controller_method; - break; - } - - if (isset($this->methods[$limited_method_name]['limit']) === FALSE ) - { - // Everything is fine - return TRUE; - } - - // How many times can you get to this method in a defined time_limit (default: 1 hour)? - $limit = $this->methods[$limited_method_name]['limit']; - - $time_limit = (isset($this->methods[$limited_method_name]['time']) ? $this->methods[$limited_method_name]['time'] : 3600); // 3600 = 60 * 60 - - // Get data about a keys' usage and limit to one row - $result = $this->rest->db - ->where('uri', $limited_uri) - ->where('api_key', $this->rest->key) - ->get($this->config->item('rest_limits_table')) - ->row(); - - // No calls have been made for this key - if ($result === NULL) - { - // Create a new row for the following key - $this->rest->db->insert($this->config->item('rest_limits_table'), [ - 'uri' => $limited_uri, - 'api_key' => isset($this->rest->key) ? $this->rest->key : '', - 'count' => 1, - 'hour_started' => time() - ]); - } - - // Been a time limit (or by default an hour) since they called - elseif ($result->hour_started < (time() - $time_limit)) - { - // Reset the started period and count - $this->rest->db - ->where('uri', $limited_uri) - ->where('api_key', isset($this->rest->key) ? $this->rest->key : '') - ->set('hour_started', time()) - ->set('count', 1) - ->update($this->config->item('rest_limits_table')); - } - - // They have called within the hour, so lets update - else - { - // The limit has been exceeded - if ($result->count >= $limit) - { - return FALSE; - } - - // Increase the count by one - $this->rest->db - ->where('uri', $limited_uri) - ->where('api_key', $this->rest->key) - ->set('count', 'count + 1', FALSE) - ->update($this->config->item('rest_limits_table')); - } - - return TRUE; - } - - /** - * Check if there is a specific auth type set for the current class/method/HTTP-method being called - * - * @access protected - * @return bool - */ - protected function _auth_override_check() - { - // Assign the class/method auth type override array from the config - $auth_override_class_method = $this->config->item('auth_override_class_method'); - - // Check to see if the override array is even populated - if (!empty($auth_override_class_method)) - { - // check for wildcard flag for rules for classes - if (!empty($auth_override_class_method[$this->router->class]['*'])) // Check for class overrides - { - // None auth override found, prepare nothing but send back a TRUE override flag - if ($auth_override_class_method[$this->router->class]['*'] === 'none') - { - return TRUE; - } - - // Basic auth override found, prepare basic - if ($auth_override_class_method[$this->router->class]['*'] === 'basic') - { - $this->_prepare_basic_auth(); - - return TRUE; - } - - // Digest auth override found, prepare digest - if ($auth_override_class_method[$this->router->class]['*'] === 'digest') - { - $this->_prepare_digest_auth(); - - return TRUE; - } - - // Session auth override found, check session - if ($auth_override_class_method[$this->router->class]['*'] === 'session') - { - $this->_check_php_session(); - - return TRUE; - } - - // Whitelist auth override found, check client's ip against config whitelist - if ($auth_override_class_method[$this->router->class]['*'] === 'whitelist') - { - $this->_check_whitelist_auth(); - - return TRUE; - } - } - - // Check to see if there's an override value set for the current class/method being called - if (!empty($auth_override_class_method[$this->router->class][$this->router->method])) - { - // None auth override found, prepare nothing but send back a TRUE override flag - if ($auth_override_class_method[$this->router->class][$this->router->method] === 'none') - { - return TRUE; - } - - // Basic auth override found, prepare basic - if ($auth_override_class_method[$this->router->class][$this->router->method] === 'basic') - { - $this->_prepare_basic_auth(); - - return TRUE; - } - - // Digest auth override found, prepare digest - if ($auth_override_class_method[$this->router->class][$this->router->method] === 'digest') - { - $this->_prepare_digest_auth(); - - return TRUE; - } - - // Session auth override found, check session - if ($auth_override_class_method[$this->router->class][$this->router->method] === 'session') - { - $this->_check_php_session(); - - return TRUE; - } - - // Whitelist auth override found, check client's ip against config whitelist - if ($auth_override_class_method[$this->router->class][$this->router->method] === 'whitelist') - { - $this->_check_whitelist_auth(); - - return TRUE; - } - } - } - - // Assign the class/method/HTTP-method auth type override array from the config - $auth_override_class_method_http = $this->config->item('auth_override_class_method_http'); - - // Check to see if the override array is even populated - if (!empty($auth_override_class_method_http)) - { - // check for wildcard flag for rules for classes - if (!empty($auth_override_class_method_http[$this->router->class]['*'][$this->request->method])) - { - // None auth override found, prepare nothing but send back a TRUE override flag - if ($auth_override_class_method_http[$this->router->class]['*'][$this->request->method] === 'none') - { - return TRUE; - } - - // Basic auth override found, prepare basic - if ($auth_override_class_method_http[$this->router->class]['*'][$this->request->method] === 'basic') - { - $this->_prepare_basic_auth(); - - return TRUE; - } - - // Digest auth override found, prepare digest - if ($auth_override_class_method_http[$this->router->class]['*'][$this->request->method] === 'digest') - { - $this->_prepare_digest_auth(); - - return TRUE; - } - - // Session auth override found, check session - if ($auth_override_class_method_http[$this->router->class]['*'][$this->request->method] === 'session') - { - $this->_check_php_session(); - - return TRUE; - } - - // Whitelist auth override found, check client's ip against config whitelist - if ($auth_override_class_method_http[$this->router->class]['*'][$this->request->method] === 'whitelist') - { - $this->_check_whitelist_auth(); - - return TRUE; - } - } - - // Check to see if there's an override value set for the current class/method/HTTP-method being called - if (!empty($auth_override_class_method_http[$this->router->class][$this->router->method][$this->request->method])) - { - // None auth override found, prepare nothing but send back a TRUE override flag - if ($auth_override_class_method_http[$this->router->class][$this->router->method][$this->request->method] === 'none') - { - return TRUE; - } - - // Basic auth override found, prepare basic - if ($auth_override_class_method_http[$this->router->class][$this->router->method][$this->request->method] === 'basic') - { - $this->_prepare_basic_auth(); - - return TRUE; - } - - // Digest auth override found, prepare digest - if ($auth_override_class_method_http[$this->router->class][$this->router->method][$this->request->method] === 'digest') - { - $this->_prepare_digest_auth(); - - return TRUE; - } - - // Session auth override found, check session - if ($auth_override_class_method_http[$this->router->class][$this->router->method][$this->request->method] === 'session') - { - $this->_check_php_session(); - - return TRUE; - } - - // Whitelist auth override found, check client's ip against config whitelist - if ($auth_override_class_method_http[$this->router->class][$this->router->method][$this->request->method] === 'whitelist') - { - $this->_check_whitelist_auth(); - - return TRUE; - } - } - } - return FALSE; - } - - /** - * Parse the GET request arguments - * - * @access protected - * @return void - */ - protected function _parse_get() - { - // Merge both the URI segments and query parameters - $this->_get_args = array_merge($this->_get_args, $this->_query_args); - } - - /** - * Parse the POST request arguments - * - * @access protected - * @return void - */ - protected function _parse_post() - { - $this->_post_args = $_POST; - - if ($this->request->format) - { - $this->request->body = $this->input->raw_input_stream; - } - } - - /** - * Parse the PUT request arguments - * - * @access protected - * @return void - */ - protected function _parse_put() - { - if ($this->request->format) - { - $this->request->body = $this->input->raw_input_stream; - } - else if ($this->input->method() === 'put') - { - // If no filetype is provided, then there are probably just arguments - $this->_put_args = $this->input->input_stream(); - } - } - - /** - * Parse the HEAD request arguments - * - * @access protected - * @return void - */ - protected function _parse_head() - { - // Parse the HEAD variables - parse_str(parse_url($this->input->server('REQUEST_URI'), PHP_URL_QUERY), $head); - - // Merge both the URI segments and HEAD params - $this->_head_args = array_merge($this->_head_args, $head); - } - - /** - * Parse the OPTIONS request arguments - * - * @access protected - * @return void - */ - protected function _parse_options() - { - // Parse the OPTIONS variables - parse_str(parse_url($this->input->server('REQUEST_URI'), PHP_URL_QUERY), $options); - - // Merge both the URI segments and OPTIONS params - $this->_options_args = array_merge($this->_options_args, $options); - } - - /** - * Parse the PATCH request arguments - * - * @access protected - * @return void - */ - protected function _parse_patch() - { - // It might be a HTTP body - if ($this->request->format) - { - $this->request->body = $this->input->raw_input_stream; - } - else if ($this->input->method() === 'patch') - { - // If no filetype is provided, then there are probably just arguments - $this->_patch_args = $this->input->input_stream(); - } - } - - /** - * Parse the DELETE request arguments - * - * @access protected - * @return void - */ - protected function _parse_delete() - { - // These should exist if a DELETE request - if ($this->input->method() === 'delete') - { - $this->_delete_args = $this->input->input_stream(); - } - } - - /** - * Parse the query parameters - * - * @access protected - * @return void - */ - protected function _parse_query() - { - $this->_query_args = $this->input->get(); - } - - // INPUT FUNCTION -------------------------------------------------------------- - - /** - * Retrieve a value from a GET request - * - * @access public - * @param NULL $key Key to retrieve from the GET request - * If NULL an array of arguments is returned - * @param NULL $xss_clean Whether to apply XSS filtering - * @return array|string|NULL Value from the GET request; otherwise, NULL - */ - public function get($key = NULL, $xss_clean = NULL) - { - if ($key === NULL) - { - return $this->_get_args; - } - - return isset($this->_get_args[$key]) ? $this->_xss_clean($this->_get_args[$key], $xss_clean) : NULL; - } - - /** - * Retrieve a value from a OPTIONS request - * - * @access public - * @param NULL $key Key to retrieve from the OPTIONS request. - * If NULL an array of arguments is returned - * @param NULL $xss_clean Whether to apply XSS filtering - * @return array|string|NULL Value from the OPTIONS request; otherwise, NULL - */ - public function options($key = NULL, $xss_clean = NULL) - { - if ($key === NULL) - { - return $this->_options_args; - } - - return isset($this->_options_args[$key]) ? $this->_xss_clean($this->_options_args[$key], $xss_clean) : NULL; - } - - /** - * Retrieve a value from a HEAD request - * - * @access public - * @param NULL $key Key to retrieve from the HEAD request - * If NULL an array of arguments is returned - * @param NULL $xss_clean Whether to apply XSS filtering - * @return array|string|NULL Value from the HEAD request; otherwise, NULL - */ - public function head($key = NULL, $xss_clean = NULL) - { - if ($key === NULL) - { - return $this->_head_args; - } - - return isset($this->_head_args[$key]) ? $this->_xss_clean($this->_head_args[$key], $xss_clean) : NULL; - } - - /** - * Retrieve a value from a POST request - * - * @access public - * @param NULL $key Key to retrieve from the POST request - * If NULL an array of arguments is returned - * @param NULL $xss_clean Whether to apply XSS filtering - * @return array|string|NULL Value from the POST request; otherwise, NULL - */ - public function post($key = NULL, $xss_clean = NULL) - { - if ($key === NULL) - { - return $this->_post_args; - } - - return isset($this->_post_args[$key]) ? $this->_xss_clean($this->_post_args[$key], $xss_clean) : NULL; - } - - /** - * Retrieve a value from a PUT request - * - * @access public - * @param NULL $key Key to retrieve from the PUT request - * If NULL an array of arguments is returned - * @param NULL $xss_clean Whether to apply XSS filtering - * @return array|string|NULL Value from the PUT request; otherwise, NULL - */ - public function put($key = NULL, $xss_clean = NULL) - { - if ($key === NULL) - { - return $this->_put_args; - } - - return isset($this->_put_args[$key]) ? $this->_xss_clean($this->_put_args[$key], $xss_clean) : NULL; - } - - /** - * Retrieve a value from a DELETE request - * - * @access public - * @param NULL $key Key to retrieve from the DELETE request - * If NULL an array of arguments is returned - * @param NULL $xss_clean Whether to apply XSS filtering - * @return array|string|NULL Value from the DELETE request; otherwise, NULL - */ - public function delete($key = NULL, $xss_clean = NULL) - { - if ($key === NULL) - { - return $this->_delete_args; - } - - return isset($this->_delete_args[$key]) ? $this->_xss_clean($this->_delete_args[$key], $xss_clean) : NULL; - } - - /** - * Retrieve a value from a PATCH request - * - * @access public - * @param NULL $key Key to retrieve from the PATCH request - * If NULL an array of arguments is returned - * @param NULL $xss_clean Whether to apply XSS filtering - * @return array|string|NULL Value from the PATCH request; otherwise, NULL - */ - public function patch($key = NULL, $xss_clean = NULL) - { - if ($key === NULL) - { - return $this->_patch_args; - } - - return isset($this->_patch_args[$key]) ? $this->_xss_clean($this->_patch_args[$key], $xss_clean) : NULL; - } - - /** - * Retrieve a value from the query parameters - * - * @access public - * @param NULL $key Key to retrieve from the query parameters - * If NULL an array of arguments is returned - * @param NULL $xss_clean Whether to apply XSS filtering - * @return array|string|NULL Value from the query parameters; otherwise, NULL - */ - public function query($key = NULL, $xss_clean = NULL) - { - if ($key === NULL) - { - return $this->_query_args; - } - - return isset($this->_query_args[$key]) ? $this->_xss_clean($this->_query_args[$key], $xss_clean) : NULL; - } - - /** - * Sanitizes data so that Cross Site Scripting Hacks can be - * prevented - * - * @access protected - * @param string $value Input data - * @param bool $xss_clean Whether to apply XSS filtering - * @return string - */ - protected function _xss_clean($value, $xss_clean) - { - is_bool($xss_clean) || $xss_clean = $this->_enable_xss; - - return $xss_clean === TRUE ? $this->security->xss_clean($value) : $value; - } - - /** - * Retrieve the validation errors - * - * @access public - * @return array - */ - public function validation_errors() - { - $string = strip_tags($this->form_validation->error_string()); - - return explode(PHP_EOL, trim($string, PHP_EOL)); - } - - // SECURITY FUNCTIONS --------------------------------------------------------- - - /** - * Perform LDAP Authentication - * - * @access protected - * @param string $username The username to validate - * @param string $password The password to validate - * @return bool - */ - protected function _perform_ldap_auth($username = '', $password = NULL) - { - if (empty($username)) - { - log_message('debug', 'LDAP Auth: failure, empty username'); - return FALSE; - } - - log_message('debug', 'LDAP Auth: Loading configuration'); - - $this->config->load('ldap.php', TRUE); - - $ldap = [ - 'timeout' => $this->config->item('timeout', 'ldap'), - 'host' => $this->config->item('server', 'ldap'), - 'port' => $this->config->item('port', 'ldap'), - 'rdn' => $this->config->item('binduser', 'ldap'), - 'pass' => $this->config->item('bindpw', 'ldap'), - 'basedn' => $this->config->item('basedn', 'ldap'), - ]; - - log_message('debug', 'LDAP Auth: Connect to ' . (isset($ldaphost) ? $ldaphost : '[ldap not configured]')); - - // Connect to the ldap server - $ldapconn = ldap_connect($ldap['host'], $ldap['port']); - if ($ldapconn) - { - log_message('debug', 'Setting timeout to ' . $ldap['timeout'] . ' seconds'); - - ldap_set_option($ldapconn, LDAP_OPT_NETWORK_TIMEOUT, $ldap['timeout']); - - log_message('debug', 'LDAP Auth: Binding to ' . $ldap['host'] . ' with dn ' . $ldap['rdn']); - - // Binding to the ldap server - $ldapbind = ldap_bind($ldapconn, $ldap['rdn'], $ldap['pass']); - - // Verify the binding - if ($ldapbind === FALSE) - { - log_message('error', 'LDAP Auth: bind was unsuccessful'); - return FALSE; - } - - log_message('debug', 'LDAP Auth: bind successful'); - } - - // Search for user - if (($res_id = ldap_search($ldapconn, $ldap['basedn'], "uid=$username")) === FALSE) - { - log_message('error', 'LDAP Auth: User ' . $username . ' not found in search'); - return FALSE; - } - - if (ldap_count_entries($ldapconn, $res_id) !== 1) - { - log_message('error', 'LDAP Auth: Failure, username ' . $username . 'found more than once'); - return FALSE; - } - - if (($entry_id = ldap_first_entry($ldapconn, $res_id)) === FALSE) - { - log_message('error', 'LDAP Auth: Failure, entry of search result could not be fetched'); - return FALSE; - } - - if (($user_dn = ldap_get_dn($ldapconn, $entry_id)) === FALSE) - { - log_message('error', 'LDAP Auth: Failure, user-dn could not be fetched'); - return FALSE; - } - - // User found, could not authenticate as user - if (($link_id = ldap_bind($ldapconn, $user_dn, $password)) === FALSE) - { - log_message('error', 'LDAP Auth: Failure, username/password did not match: ' . $user_dn); - return FALSE; - } - - log_message('debug', 'LDAP Auth: Success ' . $user_dn . ' authenticated successfully'); - - $this->_user_ldap_dn = $user_dn; - - ldap_close($ldapconn); - - return TRUE; - } - - /** - * Perform Library Authentication - Override this function to change the way the library is called - * - * @access protected - * @param string $username The username to validate - * @param string $password The password to validate - * @return bool - */ - protected function _perform_library_auth($username = '', $password = NULL) - { - if (empty($username)) - { - log_message('error', 'Library Auth: Failure, empty username'); - return FALSE; - } - - $auth_library_class = $this->config->item('auth_library_class'); - $auth_library_function = $this->config->item('auth_library_function'); - - if (empty($auth_library_class)) - { - log_message('debug', 'Library Auth: Failure, empty auth_library_class'); - return FALSE; - } - - if (empty($auth_library_function)) - { - log_message('debug', 'Library Auth: Failure, empty auth_library_function'); - return FALSE; - } - - if (is_callable([$auth_library_class, $auth_library_function]) === FALSE) - { - $this->load->library($auth_library_class, array(false)); - } - - return $this->{strtolower($auth_library_class)}->$auth_library_function($username, $password); - } - - /** - * Check if the user is logged in - * - * @access protected - * @param string $username The user's name - * @param bool|string $password The user's password - * @return bool - */ - protected function _check_login($username = NULL, $password = FALSE) - { - if (empty($username)) - { - return FALSE; - } - - $auth_source = strtolower($this->config->item('auth_source')); - $rest_auth = strtolower($this->config->item('rest_auth')); - $valid_logins = $this->config->item('rest_valid_logins'); - - if (!$this->config->item('auth_source') && $rest_auth === 'digest') - { - // For digest we do not have a password passed as argument - return md5($username . ':' . $this->config->item('rest_realm') . ':' . (isset($valid_logins[$username]) ? $valid_logins[$username] : '')); - } - - if ($password === FALSE) - { - return FALSE; - } - - if ($auth_source === 'ldap') - { - log_message('debug', "Performing LDAP authentication for $username"); - - return $this->_perform_ldap_auth($username, $password); - } - - if ($auth_source === 'library') - { - log_message('debug', "Performing Library authentication for $username"); - - return $this->_perform_library_auth($username, $password); - } - - if (array_key_exists($username, $valid_logins) === FALSE) - { - return FALSE; - } - - if ($valid_logins[$username] !== $password) - { - return FALSE; - } - - return TRUE; - } - - /** - * Check to see if the user is logged in with a PHP session key - * - * @access protected - * @return void - */ - protected function _check_php_session() - { - // Get the auth_source config item - $key = $this->config->item('auth_source'); - - // If falsy, then the user isn't logged in - if (!$this->session->userdata($key)) - { - // Display an error response - $this->response([ - $this->config->item('rest_status_field_name') => FALSE, - $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_unauthorized') - ], self::HTTP_UNAUTHORIZED); - } - } - - /** - * Prepares for basic authentication - * - * @access protected - * @return void - */ - protected function _prepare_basic_auth() - { - // If whitelist is enabled it has the first chance to kick them out - if ($this->config->item('rest_ip_whitelist_enabled')) - { - $this->_check_whitelist_auth(); - } - - // Returns NULL if the SERVER variables PHP_AUTH_USER and HTTP_AUTHENTICATION don't exist - $username = $this->input->server('PHP_AUTH_USER'); - $http_auth = $this->input->server('HTTP_AUTHENTICATION'); - - $password = NULL; - if ($username !== NULL) - { - $password = $this->input->server('PHP_AUTH_PW'); - } - elseif ($http_auth !== NULL) - { - // If the authentication header is set as basic, then extract the username and password from - // HTTP_AUTHORIZATION e.g. my_username:my_password. This is passed in the .htaccess file - if (strpos(strtolower($http_auth), 'basic') === 0) - { - // Search online for HTTP_AUTHORIZATION workaround to explain what this is doing - list($username, $password) = explode(':', base64_decode(substr($this->input->server('HTTP_AUTHORIZATION'), 6))); - } - } - - // Check if the user is logged into the system - if ($this->_check_login($username, $password) === FALSE) - { - $this->_force_login(); - } - } - - /** - * Prepares for digest authentication - * - * @access protected - * @return void - */ - protected function _prepare_digest_auth() - { - // If whitelist is enabled it has the first chance to kick them out - if ($this->config->item('rest_ip_whitelist_enabled')) - { - $this->_check_whitelist_auth(); - } - - // We need to test which server authentication variable to use, - // because the PHP ISAPI module in IIS acts different from CGI - $digest_string = $this->input->server('PHP_AUTH_DIGEST'); - if ($digest_string === NULL) - { - $digest_string = $this->input->server('HTTP_AUTHORIZATION'); - } - - $unique_id = uniqid(); - - // The $_SESSION['error_prompted'] variable is used to ask the password - // again if none given or if the user enters wrong auth information - if (empty($digest_string)) - { - $this->_force_login($unique_id); - } - - // We need to retrieve authentication data from the $digest_string variable - $matches = []; - preg_match_all('@(username|nonce|uri|nc|cnonce|qop|response)=[\'"]?([^\'",]+)@', $digest_string, $matches); - $digest = (empty($matches[1]) || empty($matches[2])) ? [] : array_combine($matches[1], $matches[2]); - - // For digest authentication the library function should return - // already stored password for that username, even if it is hashed - $username = $this->_check_login($digest['username'], TRUE); - // If there no password - if (array_key_exists('username', $digest) === FALSE || $username === FALSE || $username === NULL) - { - $this->_force_login($unique_id); - } - // If the password was found for this username, generete the string md5('USERNAME:REALM:PASSWORD') - else - { - $username = md5($digest['username'].":".$this->config->item('rest_realm').":".$username); - } - - $md5 = md5(strtoupper($this->request->method) . ':' . $digest['uri']); - $valid_response = md5($username . ':' . $digest['nonce'] . ':' . $digest['nc'] . ':' . $digest['cnonce'] . ':' . $digest['qop'] . ':' . $md5); - - // Check if the string don't compare (case-insensitive) - if (strcasecmp($digest['response'], $valid_response) !== 0) - { - // Display an error response - $this->response([ - $this->config->item('rest_status_field_name') => FALSE, - $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_invalid_credentials') - ], self::HTTP_UNAUTHORIZED); - } - } - - /** - * Checks if the client's ip is in the 'rest_ip_blacklist' config and generates a 401 response - * - * @access protected - * @return void - */ - protected function _check_blacklist_auth() - { - // Match an ip address in a blacklist e.g. 127.0.0.0, 0.0.0.0 - $pattern = sprintf('/(?:,\s*|^)\Q%s\E(?=,\s*|$)/m', $this->input->ip_address()); - - // Returns 1, 0 or FALSE (on error only). Therefore implicitly convert 1 to TRUE - if (preg_match($pattern, $this->config->item('rest_ip_blacklist'))) - { - // Display an error response - $this->response([ - $this->config->item('rest_status_field_name') => FALSE, - $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_ip_denied') - ], self::HTTP_UNAUTHORIZED); - } - } - - /** - * Check if the client's ip is in the 'rest_ip_whitelist' config and generates a 401 response - * - * @access protected - * @return void - */ - protected function _check_whitelist_auth() - { - $whitelist = explode(',', $this->config->item('rest_ip_whitelist')); - - array_push($whitelist, '127.0.0.1', '0.0.0.0'); - - foreach ($whitelist as &$ip) - { - // As $ip is a reference, trim leading and trailing whitespace, then store the new value - // using the reference - $ip = trim($ip); - } - - if (in_array($this->input->ip_address(), $whitelist) === FALSE) - { - $this->response([ - $this->config->item('rest_status_field_name') => FALSE, - $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_ip_unauthorized') - ], self::HTTP_UNAUTHORIZED); - } - } - - /** - * Force logging in by setting the WWW-Authenticate header - * - * @access protected - * @param string $nonce A server-specified data string which should be uniquely generated - * each time - * @return void - */ - protected function _force_login($nonce = '') - { - $rest_auth = $this->config->item('rest_auth'); - $rest_realm = $this->config->item('rest_realm'); - if (strtolower($rest_auth) === 'basic') - { - // See http://tools.ietf.org/html/rfc2617#page-5 - header('WWW-Authenticate: Basic realm="' . $rest_realm . '"'); - } - elseif (strtolower($rest_auth) === 'digest') - { - // See http://tools.ietf.org/html/rfc2617#page-18 - header( - 'WWW-Authenticate: Digest realm="' . $rest_realm - . '", qop="auth", nonce="' . $nonce - . '", opaque="' . md5($rest_realm) . '"'); - } - - // Display an error response - $this->response([ - $this->config->item('rest_status_field_name') => FALSE, - $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_unauthorized') - ], self::HTTP_UNAUTHORIZED); - } - - /** - * Updates the log table with the total access time - * - * @access protected - * @author Chris Kacerguis - * @return bool TRUE log table updated; otherwise, FALSE - */ - protected function _log_access_time() - { - $payload['rtime'] = $this->_end_rtime - $this->_start_rtime; - - return $this->rest->db->update( - $this->config->item('rest_logs_table'), $payload, [ - 'id' => $this->_insert_id - ]); - } - - /** - * Updates the log table with HTTP response code - * - * @access protected - * @author Justin Chen - * @param $http_code int HTTP status code - * @return bool TRUE log table updated; otherwise, FALSE - */ - protected function _log_response_code($http_code) - { - $payload['response_code'] = $http_code; - - return $this->rest->db->update( - $this->config->item('rest_logs_table'), $payload, [ - 'id' => $this->_insert_id - ]); - } - - /** - * Check to see if the API key has access to the controller and methods - * - * @access protected - * @return bool TRUE the API key has access; otherwise, FALSE - */ - protected function _check_access() - { - // If we don't want to check access, just return TRUE - if ($this->config->item('rest_enable_access') === FALSE) - { - return TRUE; - } - - // Fetch controller based on path and controller name - $controller = implode( - '/', [ - $this->router->directory, - $this->router->class - ]); - - // Remove any double slashes for safety - $controller = str_replace('//', '/', $controller); - - // Query the access table and get the number of results - return $this->rest->db - ->where('key', $this->rest->key) - ->where('controller', $controller) - ->get($this->config->item('rest_access_table')) - ->num_rows() > 0; - } -} diff --git a/application/helpers/hlp_header_helper.php b/application/helpers/hlp_header_helper.php index 611325722..1a0d9dc49 100644 --- a/application/helpers/hlp_header_helper.php +++ b/application/helpers/hlp_header_helper.php @@ -46,13 +46,16 @@ function generateCSSsInclude($CSSs) { $cssLink = ''; + $ci =& get_instance(); + $cachetoken = '?'.$ci->config->item('fhcomplete_build_version'); + if (isset($CSSs)) { $tmpCSSs = is_array($CSSs) ? $CSSs : array($CSSs); for ($tmpCSSsCounter = 0; $tmpCSSsCounter < count($tmpCSSs); $tmpCSSsCounter++) { - $toPrint = sprintf($cssLink, base_url($tmpCSSs[$tmpCSSsCounter])).PHP_EOL; + $toPrint = sprintf($cssLink, base_url($tmpCSSs[$tmpCSSsCounter]).$cachetoken).PHP_EOL; if ($tmpCSSsCounter > 0) $toPrint = "\t\t".$toPrint; @@ -108,13 +111,16 @@ function generateJSsInclude($JSs) { $jsInclude = ''; + $ci =& get_instance(); + $cachetoken = '?'.$ci->config->item('fhcomplete_build_version'); + if (isset($JSs)) { $tmpJSs = is_array($JSs) ? $JSs : array($JSs); for ($tmpJSsCounter = 0; $tmpJSsCounter < count($tmpJSs); $tmpJSsCounter++) { - $toPrint = sprintf($jsInclude, base_url($tmpJSs[$tmpJSsCounter])).PHP_EOL; + $toPrint = sprintf($jsInclude, base_url($tmpJSs[$tmpJSsCounter].$cachetoken)).PHP_EOL; if ($tmpJSsCounter > 0) $toPrint = "\t\t".$toPrint; diff --git a/application/helpers/hlp_return_object_helper.php b/application/helpers/hlp_return_object_helper.php index 03b56bbbc..cc896856d 100644 --- a/application/helpers/hlp_return_object_helper.php +++ b/application/helpers/hlp_return_object_helper.php @@ -125,3 +125,18 @@ function getCode($result) return $code; } + +/** + * Returns the property retval if present, otherwise null + */ +function getError($result) +{ + $error = null; + + if (isset($result->retval)) + { + $error = $result->retval; + } + + return $error; +} diff --git a/application/language/english/rest_controller_lang.php b/application/language/english/rest_controller_lang.php deleted file mode 100644 index 1c665bdc5..000000000 --- a/application/language/english/rest_controller_lang.php +++ /dev/null @@ -1,17 +0,0 @@ -_createAuthObjByPerson(array('uid' => $_SERVER['PHP_AUTH_USER'])); + // NOTE: Username needs to be trimmed and lowered because htaccess is allowing login + $hta = $this->_createAuthObjByPerson(array('uid' => mb_strtolower(trim($_SERVER['PHP_AUTH_USER'])))); } // Invalid credentials @@ -390,7 +391,7 @@ class AuthLib } elseif (isError($hta)) // display error and stop execution { - $this->_showError(getData($hta)); + $this->_showError(getError($hta)); } return $hta; // if success then is returned! @@ -550,7 +551,7 @@ class AuthLib } elseif (isError($auth)) // blocking error { - $this->_showError(getData($auth)); // display a generic error message and logs the occurred error + $this->_showError(getError($auth)); // display a generic error message and logs the occurred error } } // else the user is already logged, then loads authentication helper and continue with the execution @@ -574,10 +575,11 @@ class AuthLib // Needed information $this->_ci->PersonModel->addSelect('person_id, vorname, nachname, uid'); - // Retrieves the uid if it is possible - $this->_ci->PersonModel->addJoin('public.tbl_benutzer', 'person_id', 'LEFT'); - - $queryParamsArray['tbl_person.aktiv'] = true; // only active users! + // Retrieves the uid if it is possible for active users + $this->_ci->PersonModel->addJoin( + '(SELECT uid, person_id FROM public.tbl_benutzer WHERE aktiv = TRUE) tb', 'person_id', + 'LEFT' + ); // Execute query with where clause $personResult = $this->_ci->PersonModel->loadWhere($queryParamsArray); diff --git a/application/libraries/CallerLib.php b/application/libraries/CallerLib.php deleted file mode 100644 index 0b46cf0c6..000000000 --- a/application/libraries/CallerLib.php +++ /dev/null @@ -1,361 +0,0 @@ -_ci =& get_instance(); // Gets CI instance - } - - /** - * Wrapper method for _call - */ - public function callLibrary($callParameters) - { - return $this->_call($callParameters); - } - - /** - * Wrapper method for _call - */ - public function callModel($callParameters) - { - return $this->_call($callParameters); - } - - /** - * Everything starts here... - */ - private function _call($callParameters) - { - $result = null; - $parameters = $this->_getParameters($callParameters); - $validation = $this->_validateCall($parameters); - - // If the validation was passed - if (isSuccess($validation)) - { - $loaded = null; - // If the given resource is a model - if (strpos($parameters->resourceName, CallerLib::MODEL_PREFIX) !== false) - { - // Try to load the model - $result = $this->_loadModel($parameters->resourcePath, $parameters->resourceName); - if (isSuccess($result)) - { - $loaded = $result->retval; - } - } - // If the given resource is a library - elseif (strpos($parameters->resourceName, CallerLib::LIB_PREFIX) !== false) - { - // Check if the resource is already loaded, it works only with libraries and drivers - $isLoaded = $this->_ci->load->is_loaded($parameters->resourceName); - // If not loaded then load it - if ($isLoaded === false) - { - // Try to load the library - $result = $this->_loadLibrary($parameters->resourcePath, $parameters->resourceName); - if (isSuccess($result)) - { - $loaded = $result->retval; - } - } - // If it is already loaded $isLoaded contains the instance of the library - else - { - $loaded = $isLoaded; - } - } - // Wrong selection! - else - { - $result = error('Neither a lib nor model: '.$parameters->resourcePath.$parameters->resourceName); - } - - // If the resource was found and loaded - if (!is_null($loaded)) - { - $result = $this->_callThis($parameters->resourceName, $parameters->function, $parameters->parameters); - } - else - { - // Resource not loaded - } - } - else - { - $result = $validation; - } - - return $result; - } - - /** - * Gets the parameters from the http call - * Search for parameters and - * is the name of the model or of the library - * is the name of the method present in the model/library - * All the others parameters will be given to the method in the same order that - * they are present in the HTTP call - * EX: - * URL: ../system/CallerLibrary/Call?resource=&function=&=&=&= - * will call .(par1, par2, par3) - */ - private function _getParameters($parametersArray) - { - $parameters = new stdClass(); - $parameters->parameters = array(); - $count = 0; - - foreach ($parametersArray as $parameterName => $parameterValue) - { - // The name of the resource, path included - if ($parameterName == CallerLib::RESOURCE_PARAMETER) - { - // Separates the resource path from the resource name - $splittedResource = preg_split(CallerLib::REG_SPLIT_EXPR, $parameterValue); - $parameters->resourceName = $splittedResource[count($splittedResource) - 1]; - $parameters->resourcePath = str_replace($parameters->resourceName, '', $parameterValue); - } - // The name of the function - elseif ($parameterName == CallerLib::FUNCTION_PARAMETER) - { - $parameters->function = $parameterValue; - } - // It is assumed that all other parameters are the parameters to be passed to the function - // They will be passed to the function in the same order in which they are passed to - // this controller - else - { - $parameters->parameters[$count++] = $parameterValue; - } - } - - return $parameters; - } - - /** - * Validate the given parameters - */ - private function _validateCall($parameters) - { - if (!is_object($parameters)) - { - return error('Parameter is not an object'); - } - if (!isset($parameters->resourcePath)) - { - return error('Resource path is not specified'); - } - if (!isset($parameters->resourceName)) - { - return error('Resource name is not specified'); - } - if (!isset($parameters->function)) - { - return error('Function is not specified'); - } - if (!is_array($parameters->parameters)) - { - return error('Parameters are not specified'); - } - if (in_array($parameters->resourceName, CallerLib::$RESOURCES_BLACK_LIST)) - { - return error('You are trying to access to unauthorized resources'); - } - - return success('Input data are valid'); - } - - /** - * Loads a model using the given path and name - * - * NOTE: the models automatically handle the permissions - */ - private function _loadModel($resourcePath, $resourceName) - { - $loaded = null; - $result = null; - - try - { - $loaded = $this->_ci->load->model($resourcePath.$resourceName); - } - catch (Exception $e) - { - // Errors while loading the model - $result = error('Errors while loading the model: '.$e->getMessage()); - } - - if (!is_null($loaded)) - { - $result = success($loaded); - } - - return $result; - } - - /** - * Loads a library using the given path and name - * - * The method 'library' of the class CI_Loader provided by CI has some limitations, - * so to be able to check errors was used a workaround. - * It consists in: - * - Checking if the file (identified by parameters $resourcePath and $resourceName) exists - * - If exists it will be loaded using the method 'file' from CI_Loader - * - Checks if the loaded file contains a class identified by parameter $resourceName - * - * If one of the previous tests fails, it will be returned a null value - */ - private function _loadLibrary($resourcePath, $resourceName) - { - $loaded = null; - - try - { - // Gets all the configured resources paths - $packagePaths = $this->_ci->load->get_package_paths(); - // Looking for a file in every paths with the same name of the resource - $found = null; - for ($i = 0; $i < count($packagePaths) && is_null($found); $i++) - { - $file = $packagePaths[$i].CallerLib::LIBS_PATH.DIRECTORY_SEPARATOR. - $resourcePath.$resourceName.CallerLib::LIB_FILE_EXTENSION; - if (file_exists($file)) - { - $found = $file; - } - } - - // If the file was found - if (!is_null($found)) - { - // Load the file - $loaded = $this->_ci->load->file($found); - // If the resource is not present inside the file - if (!class_exists($resourceName)) - { - $loaded = null; - // Same phrase error as load->model() provided by CI - $result = error($found.' exists, but doesn\'t declare class '.$resourceName); - } - } - else - { - $loaded = null; - // Same phrase error as load->model() provided by CI - $result = error('Unable to load the requested class: '.$resourceName); - } - } - catch (Exception $e) - { - // Errors while loading the library - $result = error('Errors while loading the library: '.$e->getMessage()); - } - - if (!is_null($loaded)) - { - $result = success($loaded); - } - - return $result; - } - - /** - * Calls a method of a class with the given parameters and returns its result - * - * @param string $resourceName identifies the class name - * @param string $function identifies the method name - * @param array $parameters contains the parameters to be passed to the method - */ - private function _callThis($resourceName, $function, $parameters) - { - $result = null; - - try - { - // Get informations about the function - $reflectionMethod = new ReflectionMethod($resourceName, $function); - // If the number of given parameters is greater or equal to the number of - // parameters required by the function - if (count($parameters) >= $reflectionMethod->getNumberOfRequiredParameters()) - { - // If the function is static - if ($reflectionMethod->isStatic() === true) - { - $classMethod = $resourceName.'::'.$function; - } - // If the function is not static - else - { - $classMethod = array(new $resourceName(), $function); - } - - // If the resource's function is callable - if (is_callable($classMethod)) - { - // Call resource->function() - // @ was applied to prevent really ugly and unmanageable errors - $resultCall = @call_user_func_array($classMethod, $parameters); - // If errors occurred while running it - // NOTE: if the called function via call_user_func_array returns a boolean set as false, - // it will be recognized like a running error. A little bit tricky ;) - if ($resultCall === false) - { - $result = error('Error running '.$resourceName.'->'.$function.'()'); - } - // Returns the result of resource->function() - else - { - $result = success($resultCall); - } - } - else - { - $result = error($resourceName.'->'.$function.'() is not callable!'); - } - } - else - { - $result = error( - 'Number of required parameters: '.$reflectionMethod->getNumberOfRequiredParameters().'. Given: '.count($parameters) - ); - } - } - catch (Exception $e) - { - $result = error($e->getMessage()); - } - - return $result; - } -} diff --git a/application/libraries/DmsLib.php b/application/libraries/DmsLib.php index 6b86ce7f8..f32df5fd1 100644 --- a/application/libraries/DmsLib.php +++ b/application/libraries/DmsLib.php @@ -249,7 +249,7 @@ class DmsLib } else { - return error($dmscontent->retval); + return error(getError($dmscontent)); } } else @@ -259,7 +259,7 @@ class DmsLib } else { - return error($akte->retval); + return error(getError($akte)); } } diff --git a/application/libraries/DocumentLib.php b/application/libraries/DocumentLib.php index ed87a9f38..98e546b4e 100644 --- a/application/libraries/DocumentLib.php +++ b/application/libraries/DocumentLib.php @@ -68,7 +68,7 @@ class DocumentLib } else { - return error($ret->retval); + return error(getError($ret)); } case 'application/pdf': return success($filename); diff --git a/application/libraries/FiltersLib.php b/application/libraries/FilterWidgetLib.php similarity index 91% rename from application/libraries/FiltersLib.php rename to application/libraries/FilterWidgetLib.php index 6346150d8..c2e57eed2 100644 --- a/application/libraries/FiltersLib.php +++ b/application/libraries/FilterWidgetLib.php @@ -5,10 +5,12 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); /** * FilterWidget logic */ -class FiltersLib +class FilterWidgetLib { - // Session parameters names - const SESSION_NAME = 'FHC_FILTER_WIDGET'; // Filter session name + // FilterWidget session name + const SESSION_NAME = 'FHC_FILTER_WIDGET'; + + // Session elements const SESSION_FILTER_NAME = 'filterName'; const SESSION_FIELDS = 'fields'; const SESSION_SELECTED_FIELDS = 'selectedFields'; @@ -17,11 +19,18 @@ class FiltersLib const SESSION_CHECKBOXES = 'checkboxes'; const SESSION_FILTERS = 'filters'; const SESSION_METADATA = 'datasetMetadata'; - const SESSION_DATASET = 'dataset'; const SESSION_ROW_NUMBER = 'rowNumber'; - const SESSION_RELOAD_DATASET = 'reloadDataset'; + const SESSION_TIMEOUT = 'sessionTimeout'; + + // Session dataset elements + const SESSION_DATASET = 'dataset'; + const SESSION_DATASET_RELOAD = 'reloadDataset'; const SESSION_DATASET_REPRESENTATION = 'datasetRepresentation'; const SESSION_DATASET_REP_OPTIONS = 'datasetRepresentationOptions'; + const SESSION_DATASET_REP_FIELDS_DEFS = 'datasetRepresentationFieldsDefinitions'; + + // Default session timeout + const SESSION_DEFAULT_TIMEOUT = 30; // Alias for the dynamic table used to retrieve the dataset const DATASET_TABLE_ALIAS = 'datasetFilterTable'; @@ -32,16 +41,16 @@ class FiltersLib // ...to identify a single filter widget in the DB const FILTER_ID = 'filter_id'; - const APP_PARAMETER = 'app'; - const DATASET_NAME_PARAMETER = 'datasetName'; - const FILTER_KURZBZ_PARAMETER = 'filterKurzbz'; - const DATASET_RELOAD_PARAMETER = 'reloadDataset'; + const APP = 'app'; + const DATASET_NAME = 'datasetName'; + const FILTER_KURZBZ = 'filterKurzbz'; + const DATASET_RELOAD = 'reloadDataset'; // ...to specify permissions that are needed to use this FilterWidget - const REQUIRED_PERMISSIONS_PARAMETER = 'requiredPermissions'; + const REQUIRED_PERMISSIONS = 'requiredPermissions'; // ...stament to retrieve the dataset - const QUERY_PARAMETER = 'query'; + const QUERY = 'query'; // ...to specify more columns or aliases for them const ADDITIONAL_COLUMNS = 'additionalColumns'; @@ -53,18 +62,23 @@ class FiltersLib const MARK_ROW = 'markRow'; // ...to hide the options for a filter - const HIDE_HEADER = 'hideHeader'; + const HIDE_OPTIONS = 'hideOptions'; + const HIDE_SELECT_FIELDS = 'hideSelectFields'; + const HIDE_SELECT_FILTERS = 'hideSelectFilters'; const HIDE_SAVE = 'hideSave'; const CUSTOM_MENU = 'customMenu'; // ...to specify if the menu for this filter is custom (true) or not (false) + const HIDE_MENU = 'hideMenu'; // ...to specify if the menu should be shown or not // ...to specify how to represent the dataset (ex: tablesorter, pivotUI, ...) const DATASET_REPRESENTATION = 'datasetRepresentation'; const DATASET_REP_OPTIONS = 'datasetRepOptions'; + const DATASET_REP_FIELDS_DEFS = 'datasetRepFieldsDefs'; // Different dataset representations const DATASET_REP_TABLESORTER = 'tablesorter'; const DATASET_REP_PIVOTUI = 'pivotUI'; + const DATASET_REP_TABULATOR = 'tabulator'; // Filter operations values const OP_EQUAL = 'equal'; @@ -84,7 +98,7 @@ class FiltersLib const FILTER_PHRASES_CATEGORY = 'FilterWidget'; // The category used to store phrases for the FilterWidget - const FILTER_PAGE_PARAM = 'filter_page'; // Filter page parameter name + const FILTER_UNIQUE_ID = 'filterUniqueId'; // Filter page parameter name const PERMISSION_FILTER_METHOD = 'FilterWidget'; // Name for fake method to be checked by the PermissionLib const PERMISSION_TYPE = 'rw'; @@ -107,8 +121,6 @@ class FiltersLib public function __construct($params = null) { $this->_ci =& get_instance(); // get code igniter instance - - $this->_filterUniqueId = $this->_getFilterUniqueId($params); // sets the id for the related filter widget } //------------------------------------------------------------------------------------------------------------------ @@ -127,7 +139,7 @@ class FiltersLib // Gets the required permissions from the session if they are not provided as parameter $rq = $requiredPermissions; - if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS_PARAMETER); + if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS); return $this->_ci->permissionlib->hasAtLeastOne($rq, self::PERMISSION_FILTER_METHOD, self::PERMISSION_TYPE); } @@ -175,6 +187,29 @@ class FiltersLib setSessionElement(self::SESSION_NAME, $this->_filterUniqueId, $session); // stores the single value } + /** + * + */ + public function dropExpiredFilterWidgets() + { + // Loads the session for all the filter widgets + $filterWidgetsSession = getSession(self::SESSION_NAME); + + // If something is present in session + if ($filterWidgetsSession != null) + { + // Loops in the session for all the filter widgets + foreach ($filterWidgetsSession as $filterWidget => $filterWidgetData) + { + // If this filter widget is not the currrent used filter widget and the it is expired... + if ($this->_filterUniqueId != $filterWidget && $filterWidgetData[self::SESSION_TIMEOUT] <= time()) + { + cleanSessionElement(self::SESSION_NAME, $filterWidget); // ...remove it + } + } + } + } + /** * Loads the definition data from DB for a filter widget */ @@ -467,7 +502,7 @@ class FiltersLib // Write changes into the session $this->setSessionElement(self::SESSION_FILTERS, $filters); - $this->setSessionElement(self::SESSION_RELOAD_DATASET, true); // the dataset must be reloaded + $this->setSessionElement(self::SESSION_DATASET_RELOAD, true); // the dataset must be reloaded $removeAppliedFilter = true; } @@ -519,7 +554,7 @@ class FiltersLib // Write changes into the session $this->setSessionElement(self::SESSION_FILTERS, $filters); - $this->setSessionElement(self::SESSION_RELOAD_DATASET, true); // the dataset must be reloaded + $this->setSessionElement(self::SESSION_DATASET_RELOAD, true); // the dataset must be reloaded $applyFilters = true; } @@ -528,6 +563,14 @@ class FiltersLib return $applyFilters; } + /** + * Reloads dataset by setting session variable to true + */ + public function reloadDataset() + { + $this->setSessionElement(self::SESSION_DATASET_RELOAD, true); + } + /** * Add a filter (SQL where clause) to be applied to the current filter */ @@ -591,8 +634,8 @@ class FiltersLib // Loads the definition to check if is already present in the DB $definition = $this->_ci->FiltersModel->loadWhere(array( - 'app' => $this->getSessionElement(self::APP_PARAMETER), - 'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER), + 'app' => $this->getSessionElement(self::APP), + 'dataset_name' => $this->getSessionElement(self::DATASET_NAME), 'description' => $descPGArray, 'person_id' => $authPersonId )); @@ -620,8 +663,8 @@ class FiltersLib // update it $this->_ci->FiltersModel->update( array( - 'app' => $this->getSessionElement(self::APP_PARAMETER), - 'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER), + 'app' => $this->getSessionElement(self::APP), + 'dataset_name' => $this->getSessionElement(self::DATASET_NAME), 'description' => $descPGArray, 'person_id' => $authPersonId ), @@ -636,8 +679,8 @@ class FiltersLib { $this->_ci->FiltersModel->insert( array( - 'app' => $this->getSessionElement(self::APP_PARAMETER), - 'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER), + 'app' => $this->getSessionElement(self::APP), + 'dataset_name' => $this->getSessionElement(self::DATASET_NAME), 'filter_kurzbz' => uniqid($authPersonId, true), 'description' => $descPGArray, 'person_id' => $authPersonId, @@ -681,7 +724,7 @@ class FiltersLib public function generateFilterMenu($navigationPage) { // Loads the NavigationLib for the current page (given as parameter) - $this->_ci->load->library('NavigationLib', array(FiltersLib::NAVIGATION_PAGE => $navigationPage)); + $this->_ci->load->library('NavigationLib', array(self::NAVIGATION_PAGE => $navigationPage)); $filterMenu = null; $currentMenu = $this->_ci->navigationlib->getSessionMenu(); // The navigation menu currently stored in session @@ -694,7 +737,7 @@ class FiltersLib // Loads all the filters related to this page (same dataset_name and same app name) $filters = $this->_ci->FiltersModel->getFiltersByAppDatasetName( - $session[self::APP_PARAMETER], $session[self::DATASET_NAME_PARAMETER] + $session[self::APP], $session[self::DATASET_NAME] ); // If filters were loaded @@ -763,7 +806,7 @@ class FiltersLib ); // Sets in the session only the element related to the filters menu - $this->_ci->navigationlib->setSessionElementMenu(FiltersLib::NAV_MENU_FILTER_KEY, $filterMenu); + $this->_ci->navigationlib->setSessionElementMenu(self::NAV_MENU_FILTER_KEY, $filterMenu); } } } @@ -776,14 +819,14 @@ class FiltersLib * NOTE: The default value is the URI where the FilterWidget is called * If the fhc_controller_id is present then is also used */ - private function _getFilterUniqueId($params) + public function setFilterUniqueIdByParams($params) { if ($params != null && is_array($params) - && isset($params[self::FILTER_PAGE_PARAM]) - && !isEmptyString($params[self::FILTER_PAGE_PARAM])) + && isset($params[self::FILTER_UNIQUE_ID]) + && !isEmptyString($params[self::FILTER_UNIQUE_ID])) { - $filterUniqueId = $params[self::FILTER_PAGE_PARAM]; + $filterUniqueId = $params[self::FILTER_UNIQUE_ID]; } else { @@ -791,6 +834,14 @@ class FiltersLib $filterUniqueId = $this->_ci->router->directory.$this->_ci->router->class.'/'.$this->_ci->router->method; } + $this->setFilterUniqueId($filterUniqueId); + } + + /** + * + */ + public function setFilterUniqueId($filterUniqueId) + { // If the FHC_CONTROLLER_ID parameter is present in the HTTP GET if (isset($_GET[self::FHC_CONTROLLER_ID])) { @@ -801,7 +852,7 @@ class FiltersLib $filterUniqueId .= '/'.$this->_ci->input->post(self::FHC_CONTROLLER_ID); // then use it } - return $filterUniqueId; + $this->_filterUniqueId = $filterUniqueId; } /** diff --git a/application/libraries/Format.php b/application/libraries/Format.php deleted file mode 100644 index 0f7ea4a87..000000000 --- a/application/libraries/Format.php +++ /dev/null @@ -1,531 +0,0 @@ -_CI = &get_instance(); - - // Load the inflector helper - $this->_CI->load->helper('inflector'); - - // If the provided data is already formatted we should probably convert it to an array - if ($from_type !== NULL) - { - if (method_exists($this, '_from_' . $from_type)) - { - $data = call_user_func([$this, '_from_' . $from_type], $data); - } - else - { - throw new Exception('Format class does not support conversion from "' . $from_type . '".'); - } - } - - // Set the member variable to the data passed - $this->_data = $data; - } - - /** - * Create an instance of the format class - * e.g: echo $this->format->factory(['foo' => 'bar'])->to_csv(); - * - * @param mixed $data Data to convert/parse - * @param string $from_type Type to convert from e.g. json, csv, html - * - * @return object Instance of the format class - */ - public function factory($data, $from_type = NULL) - { - // $class = __CLASS__; - // return new $class(); - - return new static($data, $from_type); - } - - // FORMATTING OUTPUT --------------------------------------------------------- - - /** - * Format data as an array - * - * @param mixed|NULL $data Optional data to pass, so as to override the data passed - * to the constructor - * @return array Data parsed as an array; otherwise, an empty array - */ - public function to_array($data = NULL) - { - // If no data is passed as a parameter, then use the data passed - // via the constructor - if ($data === NULL && func_num_args() === 0) - { - $data = $this->_data; - } - - // Cast as an array if not already - if (is_array($data) === FALSE) - { - $data = (array) $data; - } - - $array = []; - foreach ((array) $data as $key => $value) - { - if (is_object($value) === TRUE || is_array($value) === TRUE) - { - $array[$key] = $this->to_array($value); - } - else - { - $array[$key] = $value; - } - } - - return $array; - } - - /** - * Format data as XML - * - * @param mixed|NULL $data Optional data to pass, so as to override the data passed - * to the constructor - * @param NULL $structure - * @param string $basenode - * @return mixed - */ - public function to_xml($data = NULL, $structure = NULL, $basenode = 'xml') - { - if ($data === NULL && func_num_args() === 0) - { - $data = $this->_data; - } - - // turn off compatibility mode as simple xml throws a wobbly if you don't. - if (ini_get('zend.ze1_compatibility_mode') == 1) - { - ini_set('zend.ze1_compatibility_mode', 0); - } - - if ($structure === NULL) - { - $structure = simplexml_load_string("<$basenode />"); - } - - // Force it to be something useful - if (is_array($data) === FALSE && is_object($data) === FALSE) - { - $data = (array) $data; - } - - foreach ($data as $key => $value) - { - - //change false/true to 0/1 - if (is_bool($value)) - { - $value = (int) $value; - } - - // no numeric keys in our xml please! - if (is_numeric($key)) - { - // make string key... - $key = (singular($basenode) != $basenode) ? singular($basenode) : 'item'; - } - - // replace anything not alpha numeric - $key = preg_replace('/[^a-z_\-0-9]/i', '', $key); - - if ($key === '_attributes' && (is_array($value) || is_object($value))) - { - $attributes = $value; - if (is_object($attributes)) - { - $attributes = get_object_vars($attributes); - } - - foreach ($attributes as $attribute_name => $attribute_value) - { - $structure->addAttribute($attribute_name, $attribute_value); - } - } - // if there is another array found recursively call this function - elseif (is_array($value) || is_object($value)) - { - $node = $structure->addChild($key); - - // recursive call. - $this->to_xml($value, $node, $key); - } - else - { - // add single node. - $value = htmlspecialchars(html_entity_decode($value, ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8'); - - $structure->addChild($key, $value); - } - } - - return $structure->asXML(); - } - - /** - * Format data as HTML - * - * @param mixed|NULL $data Optional data to pass, so as to override the data passed - * to the constructor - * @return mixed - */ - public function to_html($data = NULL) - { - // If no data is passed as a parameter, then use the data passed - // via the constructor - if ($data === NULL && func_num_args() === 0) - { - $data = $this->_data; - } - - // Cast as an array if not already - if (is_array($data) === FALSE) - { - $data = (array) $data; - } - - // Check if it's a multi-dimensional array - if (isset($data[0]) && count($data) !== count($data, COUNT_RECURSIVE)) - { - // Multi-dimensional array - $headings = array_keys($data[0]); - } - else - { - // Single array - $headings = array_keys($data); - $data = [$data]; - } - - // Load the table library - $this->_CI->load->library('table'); - - $this->_CI->table->set_heading($headings); - - foreach ($data as $row) - { - // Suppressing the "array to string conversion" notice - // Keep the "evil" @ here - $row = @array_map('strval', $row); - - $this->_CI->table->add_row($row); - } - - return $this->_CI->table->generate(); - } - - /** - * @link http://www.metashock.de/2014/02/create-csv-file-in-memory-php/ - * @param mixed|NULL $data Optional data to pass, so as to override the data passed - * to the constructor - * @param string $delimiter The optional delimiter parameter sets the field - * delimiter (one character only). NULL will use the default value (,) - * @param string $enclosure The optional enclosure parameter sets the field - * enclosure (one character only). NULL will use the default value (") - * @return string A csv string - */ - public function to_csv($data = NULL, $delimiter = ',', $enclosure = '"') - { - // Use a threshold of 1 MB (1024 * 1024) - $handle = fopen('php://temp/maxmemory:1048576', 'w'); - if ($handle === FALSE) - { - return NULL; - } - - // If no data is passed as a parameter, then use the data passed - // via the constructor - if ($data === NULL && func_num_args() === 0) - { - $data = $this->_data; - } - - // If NULL, then set as the default delimiter - if ($delimiter === NULL) - { - $delimiter = ','; - } - - // If NULL, then set as the default enclosure - if ($enclosure === NULL) - { - $enclosure = '"'; - } - - // Cast as an array if not already - if (is_array($data) === FALSE) - { - $data = (array) $data; - } - - // Check if it's a multi-dimensional array - if (isset($data[0]) && count($data) !== count($data, COUNT_RECURSIVE)) - { - // Multi-dimensional array - $headings = array_keys($data[0]); - } - else - { - // Single array - $headings = array_keys($data); - $data = [$data]; - } - - // Apply the headings - fputcsv($handle, $headings, $delimiter, $enclosure); - - foreach ($data as $record) - { - // If the record is not an array, then break. This is because the 2nd param of - // fputcsv() should be an array - if (is_array($record) === FALSE) - { - break; - } - - // Suppressing the "array to string conversion" notice. - // Keep the "evil" @ here. - $record = @ array_map('strval', $record); - - // Returns the length of the string written or FALSE - fputcsv($handle, $record, $delimiter, $enclosure); - } - - // Reset the file pointer - rewind($handle); - - // Retrieve the csv contents - $csv = stream_get_contents($handle); - - // Close the handle - fclose($handle); - - return $csv; - } - - /** - * Encode data as json - * - * @param mixed|NULL $data Optional data to pass, so as to override the data passed - * to the constructor - * @return string Json representation of a value - */ - public function to_json($data = NULL) - { - // If no data is passed as a parameter, then use the data passed - // via the constructor - if ($data === NULL && func_num_args() === 0) - { - $data = $this->_data; - } - - // Get the callback parameter (if set) - $callback = $this->_CI->input->get('callback'); - - if (empty($callback) === TRUE) - { - return json_encode($data); - } - - // We only honour a jsonp callback which are valid javascript identifiers - elseif (preg_match('/^[a-z_\$][a-z0-9\$_]*(\.[a-z_\$][a-z0-9\$_]*)*$/i', $callback)) - { - // Return the data as encoded json with a callback - return $callback . '(' . json_encode($data) . ');'; - } - - // An invalid jsonp callback function provided. - // Though I don't believe this should be hardcoded here - $data['warning'] = 'INVALID JSONP CALLBACK: ' . $callback; - - return json_encode($data); - } - - /** - * Encode data as a serialized array - * - * @param mixed|NULL $data Optional data to pass, so as to override the data passed - * to the constructor - * @return string Serialized data - */ - public function to_serialized($data = NULL) - { - // If no data is passed as a parameter, then use the data passed - // via the constructor - if ($data === NULL && func_num_args() === 0) - { - $data = $this->_data; - } - - return serialize($data); - } - - /** - * Format data using a PHP structure - * - * @param mixed|NULL $data Optional data to pass, so as to override the data passed - * to the constructor - * @return mixed String representation of a variable - */ - public function to_php($data = NULL) - { - // If no data is passed as a parameter, then use the data passed - // via the constructor - if ($data === NULL && func_num_args() === 0) - { - $data = $this->_data; - } - - return var_export($data, TRUE); - } - - // INTERNAL FUNCTIONS - - /** - * @param $data XML string - * @return SimpleXMLElement XML element object; otherwise, empty array - */ - protected function _from_xml($data) - { - return $data ? (array) simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA) : []; - } - - /** - * @param string $data CSV string - * @param string $delimiter The optional delimiter parameter sets the field - * delimiter (one character only). NULL will use the default value (,) - * @param string $enclosure The optional enclosure parameter sets the field - * enclosure (one character only). NULL will use the default value (") - * @return array A multi-dimensional array with the outer array being the number of rows - * and the inner arrays the individual fields - */ - protected function _from_csv($data, $delimiter = ',', $enclosure = '"') - { - // If NULL, then set as the default delimiter - if ($delimiter === NULL) - { - $delimiter = ','; - } - - // If NULL, then set as the default enclosure - if ($enclosure === NULL) - { - $enclosure = '"'; - } - - return str_getcsv($data, $delimiter, $enclosure); - } - - /** - * @param $data Encoded json string - * @return mixed Decoded json string with leading and trailing whitespace removed - */ - protected function _from_json($data) - { - return json_decode(trim($data)); - } - - /** - * @param string Data to unserialized - * @return mixed Unserialized data - */ - protected function _from_serialize($data) - { - return unserialize(trim($data)); - } - - /** - * @param $data Data to trim leading and trailing whitespace - * @return string Data with leading and trailing whitespace removed - */ - protected function _from_php($data) - { - return trim($data); - } - -} diff --git a/application/libraries/LogLib.php b/application/libraries/LogLib.php index cb0541003..b98575150 100644 --- a/application/libraries/LogLib.php +++ b/application/libraries/LogLib.php @@ -1,102 +1,252 @@ '; const LINE_SEPARATOR = ':'; - // -------------------------------------------------------------------------------------------------------------- - // Public methods + // CodeIgniter configuration log entry name and log debug value + const CI_LOG_THRESHOLD_NAME = 'log_threshold'; + const CI_LOG_THRESHOLD_DEBUG = 2; + + // LogLib parameters names + const P_NAME_CLASS_INDEX = 'classIndex'; + const P_NAME_FUNCTION_INDEX = 'functionIndex'; + const P_NAME_LINE_INDEX = 'lineIndex'; + const P_NAME_DB_LOG_TYPE = 'dbLogType'; + const P_NAME_DB_EXECUTE_USER = 'dbExecuteUser'; + + // Properties used to retrieve caller data + private $_classIndex; + private $_functionIndex; + private $_lineIndex; + + // Properties used when logging to database + private $_dbLogType; + private $_dbExecuteUser; /** - * logDebug + * Set properties to a default value or overwrites them with the given parameters + */ + public function __construct($params = null) + { + // Properties default values + $this->_classIndex = self::CLASS_INDEX; + $this->_functionIndex = self::FUNCTION_INDEX; + $this->_lineIndex = self::LINE_INDEX; + $this->_dbLogType = null; + $this->_dbExecuteUser = self::DB_EXECUTE_USER; + + // If parameters are given then overwrite the default values + if (!isEmptyArray($params)) + { + if (isset($params[self::P_NAME_CLASS_INDEX])) $this->_classIndex = $params[self::P_NAME_CLASS_INDEX]; + if (isset($params[self::P_NAME_FUNCTION_INDEX])) $this->_functionIndex = $params[self::P_NAME_FUNCTION_INDEX]; + if (isset($params[self::P_NAME_LINE_INDEX])) $this->_lineIndex = $params[self::P_NAME_LINE_INDEX]; + if (isset($params[self::P_NAME_DB_LOG_TYPE])) $this->_dbLogType = $params[self::P_NAME_DB_LOG_TYPE]; + if (isset($params[self::P_NAME_DB_EXECUTE_USER])) $this->_dbExecuteUser = $params[self::P_NAME_DB_EXECUTE_USER]; + } + } + + // -------------------------------------------------------------------------------------------------------------- + // Public methods based on CodeIgniter log system + + /** + * Writes a debug log to CodeIgniter log */ public function logDebug($message) { - $this->_log(LogLib::DEBUG, $message); + $this->_log(self::DEBUG, $message); } /** - * logInfo + * Writes an info log to CodeIgniter log */ public function logInfo($message) { - $this->_log(LogLib::INFO, $message); + $this->_log(self::INFO, $message); } /** - * logError + * Writes an error log to CodeIgniter log */ public function logError($message) { - $this->_log(LogLib::ERROR, $message); + $this->_log(self::ERROR, $message); + } + + // -------------------------------------------------------------------------------------------------------------- + // Public methods based on database + + /** + * Writes an info log to database + */ + public function logInfoDB($requestId, $data) + { + $this->_logDB(self::INFO, $requestId, $data); + } + + /** + * Writes a debug log to database + */ + public function logDebugDB($requestId, $data) + { + $this->_logDB(self::DEBUG, $requestId, $data); + } + + /** + * Writes an warning log to database + */ + public function logWarningDB($requestId, $data) + { + $this->_logDB(self::WARNING, $requestId, $data); + } + + /** + * Writes an error log to database + */ + public function logErrorDB($requestId, $data) + { + $this->_logDB(self::ERROR, $requestId, $data); } // -------------------------------------------------------------------------------------------------------------- // Private methods /** - * log + * Writes using CodeIgniter log system (file system) */ private function _log($level, $message) { - log_message($level, $this->_getCaller().$message); + log_message($level, $this->_getPrefix($this->_getCaller()).$message); } /** - * _getCaller + * Writes logs to database + */ + private function _logDB($level, $requestId, $data) + { + // If the _dbLogType parameter was not given when this library was loaded + // NOTE: this message will be displayed only to the developer AND stops the execution + if ($this->_dbLogType == null) + { + show_error('To log to database you need to specify the "'.self::P_NAME_DB_LOG_TYPE.'" parameter when the LogLib is loaded'); + } + + $ci =& get_instance(); // get code igniter instance + + // If only debug log is enabed then is possible to write a debug log, otherwise... + if ($level == self::DEBUG && $ci->config->item(self::CI_LOG_THRESHOLD_NAME) != self::CI_LOG_THRESHOLD_DEBUG) + { + // ...do nothing + } + else + { + // Loads WebservicelogModel + $ci->load->model('system/Webservicelog_model', 'WebservicelogModel'); + + // Get caller data + $callerData = $this->_getCaller(); + + // Writes a log to database + $ci->WebservicelogModel->insert(array( + 'webservicetyp_kurzbz' => $this->_dbLogType, + 'request_id' => $requestId, + 'beschreibung' => $this->_getDatabaseDescription($callerData), + 'request_data' => $data, + 'execute_user' => $this->_dbExecuteUser, + 'execute_time' => 'NOW()' // current time + )); + } + } + + /** + * Retrieves caller's data */ private function _getCaller() { - $classIndex = 3; - $functionIndex = 3; - $lineIndex = 2; $class = ''; $function = ''; $line = ''; $backtrace_arr = debug_backtrace(); - if (isset($backtrace_arr[$classIndex]['class']) && $backtrace_arr[$classIndex]['class'] != '') + + if (isset($backtrace_arr[$this->_classIndex]['class']) && $backtrace_arr[$this->_classIndex]['class'] != '') { - $class = $backtrace_arr[$classIndex]['class']; + $class = $backtrace_arr[$this->_classIndex]['class']; } - if (isset($backtrace_arr[$functionIndex]['function']) && $backtrace_arr[$functionIndex]['function'] != '') + if (isset($backtrace_arr[$this->_functionIndex]['function']) && $backtrace_arr[$this->_functionIndex]['function'] != '') { - $function = $backtrace_arr[$functionIndex]['function']; + $function = $backtrace_arr[$this->_functionIndex]['function']; } - if (isset($backtrace_arr[$lineIndex]['line']) && $backtrace_arr[$lineIndex]['line'] != '') + if (isset($backtrace_arr[$this->_lineIndex]['line']) && $backtrace_arr[$this->_lineIndex]['line'] != '') { - $line = $backtrace_arr[$lineIndex]['line']; + $line = $backtrace_arr[$this->_lineIndex]['line']; } - return $this->_format($class, $function, $line); + return array( + self::CLASS_NAME => $class, + self::FUNCTION_NAME => $function, + self::CODE_LINE => $line + ); } /** - * format + * Formats the log message prefix (file system based) */ - private function _format($class, $function, $line) + private function _getPrefix($callerData) { - $formatted = LogLib::CALLER_PREFIX; + $formatted = self::CALLER_PREFIX; - if (!is_null($class) && $class != '') + if (!isEmptyString($callerData[self::CLASS_NAME])) { - $formatted .= $class.LogLib::CLASS_POSTFIX; + $formatted .= $callerData[self::CLASS_NAME].self::CLASS_POSTFIX; } - $formatted .= $function.LogLib::LINE_SEPARATOR.$line.LogLib::CALLER_POSTFIX.' '; + $formatted .= $callerData[self::FUNCTION_NAME].self::LINE_SEPARATOR.$callerData[self::CODE_LINE].self::CALLER_POSTFIX.' '; + + return $formatted; + } + + /** + * Formats the database description for a log + */ + private function _getDatabaseDescription($callerData) + { + $formatted = $callerData[self::FUNCTION_NAME].self::LINE_SEPARATOR.$callerData[self::CODE_LINE]; + + if (!isEmptyString($callerData[self::CLASS_NAME])) + { + $formatted = $callerData[self::CLASS_NAME].self::CLASS_POSTFIX.$formatted; + } return $formatted; } diff --git a/application/libraries/MigrationLib.php b/application/libraries/MigrationLib.php deleted file mode 100644 index a461d7a82..000000000 --- a/application/libraries/MigrationLib.php +++ /dev/null @@ -1,466 +0,0 @@ -load->library('EPrintfLib'); - } - - /** - * Check if a column exists in a table and schema - */ - private function columnExists($name, $schema, $table) - { - $query = sprintf("SELECT %s FROM %s.%s LIMIT 1", $name, $schema, $table); - - if (@$this->db->simple_query($query)) - { - return true; - } - - return false; - } - - /** - * Print an info about the starting of method up - */ - protected function startUP() - { - $this->eprintflib->printInfo( - sprintf("%s Start method up of class %s %s", EPrintfLib::SEPARATOR, get_called_class(), EPrintfLib::SEPARATOR) - ); - } - - /** - * Print an info about the ending of method up - */ - protected function endUP() - { - $this->eprintflib->printInfo( - sprintf("%s End method up of class %s %s", EPrintfLib::SEPARATOR, get_called_class(), EPrintfLib::SEPARATOR) - ); - } - - /** - * Print an info about the starting of method down - */ - protected function startDown() - { - $this->eprintflib->printInfo( - sprintf("%s Start method down of class %s %s", EPrintfLib::SEPARATOR, get_called_class(), EPrintfLib::SEPARATOR) - ); - } - - /** - * Print an info about the ending of method down - */ - protected function endDown() - { - $this->eprintflib->printInfo( - sprintf("%s End method down of class %s %s", EPrintfLib::SEPARATOR, get_called_class(), EPrintfLib::SEPARATOR) - ); - } - - /** - * Adds a column, with attributes, to a table and schema - */ - protected function addColumn($schema, $table, $fields) - { - foreach ($fields as $name => $definition) - { - if (!$this->columnExists($name, $schema, $table)) - { - if ($this->dbforge->add_column($schema.'.'.$table, array($name => $definition))) - { - $this->eprintflib->printMessage(sprintf("Column %s.%s.%s of type %s added", $schema, $table, $name, $definition["type"])); - } - else - { - $this->eprintflib->printError(sprintf("Error while adding column %s.%s.%s of type %s", $schema, $table, $name, $definition["type"])); - } - } - else - { - $this->eprintflib->printInfo(sprintf("Column %s.%s.%s already exists", $schema, $table, $name)); - } - } - } - - /** - * Modifies a column, and its attributes, of a table and schema - */ - protected function modifyColumn($schema, $table, $fields) - { - foreach ($fields as $name => $definition) - { - if ($this->columnExists($name, $schema, $table)) - { - if ($this->dbforge->modify_column($schema.'.'.$table, array($name => $definition))) - { - $this->eprintflib->printMessage(sprintf("Column %s.%s.%s has been modified", $schema, $table, $name)); - } - else - { - $this->eprintflib->printError(sprintf("Error while modifying column %s.%s.%s", $schema, $table, $name)); - } - } - else - { - $this->eprintflib->printInfo(sprintf("Column %s.%s.%s doesn't exist", $schema, $table, $name)); - } - } - } - - /** - * Drops a column from a table and schema - */ - protected function dropColumn($schema, $table, $field) - { - if ($this->columnExists($field, $schema, $table)) - { - if ($this->dbforge->drop_column($schema.'.'.$table, $field)) - { - $this->eprintflib->printMessage(sprintf("Column %s.%s.%s has been dropped", $schema, $table, $field)); - } - else - { - $this->eprintflib->printError(sprintf("Error while dropping column %s.%s.%s", $schema, $table, $field)); - } - } - else - { - $this->eprintflib->printInfo(sprintf("Column %s.%s.%s doesn't exist", $schema, $table, $field)); - } - } - - /** - * Sets a column as primary key of a table and schema - */ - protected function addPrimaryKey($schema, $table, $name, $fields) - { - $stringFields = null; - - if (is_array($fields)) - { - if (count($fields) > 0) - { - $stringFields = ""; - for ($i = 0; $i < count($fields); $i++) - { - $stringFields .= $fields[$i]; - if ($i != count($fields) - 1) - { - $stringFields .= ", "; - } - } - $query = sprintf("ALTER TABLE %s.%s ADD CONSTRAINT %s PRIMARY KEY (%s)", $schema, $table, $name, $stringFields); - } - } - else - { - $query = sprintf("ALTER TABLE %s.%s ADD CONSTRAINT %s PRIMARY KEY (%s)", $schema, $table, $name, $fields); - } - - if (@$this->db->simple_query($query)) - { - $this->eprintflib->printMessage(sprintf("Added primary key %s on table %s.%s", $name, $schema, $table)); - } - else - { - $this->eprintflib->printError(sprintf("Adding primary key %s on table %s.%s", $name, $schema, $table)); - } - } - - /** - * Sets a column as foreign key of a table and schema - */ - protected function addForeingKey($schema, $table, $name, $field, $schemaDest, $tableDest, $fieldDest, $attributes) - { - $query = sprintf( - "ALTER TABLE %s.%s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s.%s (%s) %s", - $schema, - $table, - $name, - $field, - $schemaDest, - $tableDest, - $fieldDest, - $attributes - ); - - if (@$this->db->simple_query($query)) - { - $this->eprintflib->printMessage(sprintf("Added foreign key %s on table %s.%s", $name, $schema, $table)); - } - else - { - $this->eprintflib->printError(sprintf("Adding foreign key %s on table %s.%s", $name, $schema, $table)); - } - } - - /** - * Sets a column as unique key of a table and schema - */ - protected function addUniqueKey($schema, $table, $name, $fields) - { - $stringFields = null; - - if (is_array($fields)) - { - if (count($fields) > 0) - { - $stringFields = ""; - for ($i = 0; $i < count($fields); $i++) - { - $stringFields .= $fields[$i]; - if ($i != count($fields) - 1) - { - $stringFields .= ", "; - } - } - $query = sprintf("CREATE UNIQUE INDEX %s ON %s.%s (%s)", $name, $schema, $table, $stringFields); - } - } - else - { - $query = sprintf("CREATE UNIQUE INDEX %s ON %s.%s (%s)", $name, $schema, $table, $fields); - } - - if (@$this->db->simple_query($query)) - { - $this->eprintflib->printMessage(sprintf("Added unique key %s on table %s.%s", $name, $schema, $table)); - } - else - { - $this->eprintflib->printError(sprintf("Adding unique key %s on table %s.%s", $name, $schema, $table)); - } - } - - /** - * Grants permissions to a user on a table and schema - */ - protected function grantTable($permissions, $schema, $table, $user) - { - $stringPermission = null; - - if (is_array($permissions)) - { - if (count($permissions) > 0) - { - $stringPermission = ""; - for ($i = 0; $i < count($permissions); $i++) - { - $stringPermission .= $permissions[$i]; - if ($i != count($permissions) - 1) - { - $stringPermission .= ", "; - } - } - $query = sprintf("GRANT %s ON TABLE %s.%s TO %s", $stringPermission, $schema, $table, $user); - } - } - else - { - $query = sprintf("GRANT %s ON TABLE %s.%s TO %s", $permissions, $schema, $table, $user); - } - - if (@$this->db->simple_query($query)) - { - $this->eprintflib->printMessage( - sprintf( - "Granted permissions %s on table %s.%s to user %s", - is_null($stringPermission) ? $permissions : $stringPermission, - $schema, - $table, - $user - ) - ); - } - else - { - $this->eprintflib->printError( - sprintf( - "Granting permissions %s on table %s.%s to user %s", - is_null($stringPermission) ? $permissions : $stringPermission, - $schema, - $table, - $user - ) - ); - } - } - - /** - * Creates a table in a schema with columns - */ - protected function createTable($schema, $table, $fields) - { - $this->dbforge->add_field($fields); - - if ($this->dbforge->create_table($schema.'.'.$table, true)) - { - $this->eprintflib->printMessage(sprintf("Table %s.%s created or existing", $schema, $table)); - } - else - { - $this->eprintflib->printError(sprintf("Creating table %s.%s", $schema, $table)); - } - } - - /** - * Drops a table from a schema - */ - protected function dropTable($schema, $table) - { - if ($this->dbforge->drop_table($schema.".".$table)) - { - $this->eprintflib->printMessage(sprintf("Table %s.%s has been dropped", $schema, $table)); - } - else - { - $this->eprintflib->printError(sprintf("Dropping table %s.%s", $schema, $table)); - } - } - - /** - * Initializes a sequence with the max value of a column - */ - protected function initializeSequence($schemaSrc, $sequence, $schemaDst, $table, $field) - { - $query = sprintf("SELECT SETVAL('%s.%s', (SELECT MAX(%s) FROM %s.%s))", $schemaSrc, $sequence, $field, $schemaDst, $table); - - if (@$this->db->simple_query($query)) - { - $this->eprintflib->printMessage(sprintf("Sequence %s.%s has been initialized", $schemaSrc, $sequence)); - } - else - { - $this->eprintflib->printError(sprintf("Initializing sequence %s.%s", $schemaSrc, $sequence)); - } - } - - /** - * Add comment to a column - */ - protected function addCommentToColumn($schema, $table, $field, $comment) - { - $query = sprintf("COMMENT ON COLUMN %s.%s.%s IS ?", $schema, $table, $field); - - if (@$this->db->query($query, array($comment))) - { - $this->eprintflib->printMessage(sprintf("Comment added to %s.%s.%s", $schema, $table, $field)); - } - else - { - $this->eprintflib->printError(sprintf("Error while adding comment to %s.%s.%s", $schema, $table, $field)); - } - } - - /** - * Add comment to a table - */ - protected function addCommentToTable($schema, $table, $comment) - { - $query = sprintf("COMMENT ON TABLE %s.%s IS ?", $schema, $table, $field); - - if (@$this->db->query($query, array($comment))) - { - $this->eprintflib->printMessage(sprintf("Comment added to %s.%s", $schema, $table)); - } - else - { - $this->eprintflib->printError(sprintf("Error while adding comment to %s.%s", $schema, $table)); - } - } - /** - * Grants permissions to a user on a sequence - */ - protected function grantSequence($permissions, $schema, $sequence, $user) - { - $stringPermission = null; - - if (is_array($permissions)) - { - if (count($permissions) > 0) - { - $stringPermission = ""; - for ($i = 0; $i < count($permissions); $i++) - { - $stringPermission .= $permissions[$i]; - if ($i != count($permissions) - 1) - { - $stringPermission .= ", "; - } - } - $query = sprintf("GRANT %s ON SEQUENCE %s.%s TO %s", $stringPermission, $schema, $sequence, $user); - } - } - else - { - $query = sprintf("GRANT %s ON SEQUENCE %s.%s TO %s", $permissions, $schema, $sequence, $user); - } - - if (@$this->db->simple_query($query)) - { - $this->eprintflib->printMessage( - sprintf( - "Granted permissions %s on sequence %s.%s to user %s", - is_null($stringPermission) ? $permissions : $stringPermission, - $schema, - $sequence, - $user - ) - ); - } - else - { - $this->eprintflib->printError( - sprintf( - "Granting permissions %s on sequence %s.%s to user %s", - is_null($stringPermission) ? $permissions : $stringPermission, - $schema, - $sequence, - $user - ) - ); - } - } - - /** - * Executes the given query - */ - protected function execQuery($query) - { - if (! @$this->db->simple_query($query)) - { - $error = $this->db->error(); - - if (is_array($error) && isset($error["message"])) - { - $this->eprintflib->printError($error["message"]); - } - else - { - $this->eprintflib->printError("Error while executing a query"); - } - } - - $this->eprintflib->printInfo( - "Query correctly executed: ". - substr(preg_replace("/\s+/", " ", trim($query)), 0, EPrintfLib::PRINT_QUERY_LEN). - (strlen($query) > EPrintfLib::PRINT_QUERY_LEN ? "..." : "") - ); - } -} diff --git a/application/libraries/PermissionLib.php b/application/libraries/PermissionLib.php index b84359216..348c8b87b 100644 --- a/application/libraries/PermissionLib.php +++ b/application/libraries/PermissionLib.php @@ -254,6 +254,45 @@ class PermissionLib return !$this->_inLAPersonIdsBlacklist($person_id) && $this->_hasLAPermissions(); } + /** + * Returns the study programs the person is entitled for. + * @param null $berechtigung_kurzbz If given, only study programs are retrieved according to organisational units + * assigned to that permission. + * @return array|bool array of studiengang_kz the person is entitled for. False on error. + */ + public function getSTG_isEntitledFor($berechtigung_kurzbz = null) + { + $studiengang_kz_arr = array(); + + if (self::$bb->getStgKz($berechtigung_kurzbz)) + { + return $studiengang_kz_arr = self::$bb->getStgKz($berechtigung_kurzbz); + } + else + { + return false; + } + } + + /** + * Returns the organisational units the person is entitled for. + * @param null $berechtigung_kurzbz + * @return array|bool array of oe_kurzbz the person is entitled for. False on error. + */ + public function getOE_isEntitledFor($berechtigung_kurzbz = null) + { + $oe_kurzbz_arr = array(); + + if (self::$bb->getOEkurzbz($berechtigung_kurzbz)) + { + return $oe_kurzbz_arr = self::$bb->getOEkurzbz($berechtigung_kurzbz); + } + else + { + return false; + } + } + //------------------------------------------------------------------------------------------------------------------ // Private methods diff --git a/application/libraries/PersonLogLib.php b/application/libraries/PersonLogLib.php index b56937dfe..fe9a82504 100644 --- a/application/libraries/PersonLogLib.php +++ b/application/libraries/PersonLogLib.php @@ -8,6 +8,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class PersonLogLib { const PARKED_LOGNAME = 'Parked'; + const ONHOLD_LOGNAME = 'Onhold'; /** * Constructor @@ -75,7 +76,7 @@ class PersonLogLib return $decoded_logs; } else - show_error($result->retval); + show_error(getError($result)); } /** @@ -91,26 +92,20 @@ class PersonLogLib */ public function park($person_id, $date, $taetigkeit_kurzbz, $app = 'core', $oe_kurzbz = null, $user = null) { - $logdata = array( + $onhold = $this->getOnHoldDate($person_id); + + if (hasData($onhold)) + return error("Person already on hold"); + + $logjson = array( 'name' => self::PARKED_LOGNAME ); - $data = array( - 'person_id' => $person_id, - 'zeitpunkt' => $date, - 'taetigkeit_kurzbz' => $taetigkeit_kurzbz, - 'app' => $app, - 'oe_kurzbz' => $oe_kurzbz, - 'logtype_kurzbz' => 'Processstate', - 'logdata' => json_encode($logdata), - 'insertvon' => $user - ); - - return $this->ci->PersonLogModel->insert($data); + return $this->_savePsLog($person_id, $date, $taetigkeit_kurzbz, $logjson, $app, $oe_kurzbz, $user); } /** - * Unparks a person, i.e. removes all log entries in the future + * Unparks a person, i.e. removes all log entries in the future with logname for parking * @param $person_id * @return array with deleted logids */ @@ -131,17 +126,9 @@ class PersonLogLib { $deleted[] = $log->log_id; } - else - { - return $delresult; - } } } } - else - { - return $result; - } return success($deleted); } @@ -172,4 +159,111 @@ class PersonLogLib return $parkeddate; } + + /** + * Sets person on hold, i.e. marks a person so no actions are expected for the person (e.g. as a prestudent). + * Done by adding a logentry with a special name. can be undone only manually by clicking button. + * @param $person_id + * @param $date + * @param $taetigkeit_kurzbz + * @param string $app + * @param null $oe_kurzbz + * @param null $user + * @return array + */ + public function setOnHold($person_id, $date, $taetigkeit_kurzbz, $app = 'core', $oe_kurzbz = null, $user = null) + { + $parked = $this->getParkedDate($person_id); + + if (hasData($parked)) + return error("Person already parked"); + + $logjson = array( + 'name' => self::ONHOLD_LOGNAME + ); + + return $this->_savePsLog($person_id, $date, $taetigkeit_kurzbz, $logjson, $app, $oe_kurzbz, $user); + } + + /** + * Removes on hold status, i.e. removes all log entries with logname for on hold + * @param $person_id + * @return array + */ + public function removeOnHold($person_id) + { + $deleted = array(); + + $result = $this->ci->PersonLogModel->filterLog($person_id); + if (hasData($result)) + { + foreach ($result->retval as $log) + { + $logdata = json_decode($log->logdata); + if (isset($logdata->name) && $logdata->name === self::ONHOLD_LOGNAME) + { + $delresult = $this->ci->PersonLogModel->deleteLog($log->log_id); + if (isSuccess($delresult)) + { + $deleted[] = $log->log_id; + } + } + } + } + return success($deleted); + } + + /** + * Gets date until which a person is on hold + * @param $person_id + * @return the date if person is on hold, null otherwise + */ + public function getOnHoldDate($person_id) + { + $result = $this->ci->PersonLogModel->filterLog($person_id); + + $onholddate = null; + + if (hasData($result)) + { + foreach ($result->retval as $log) + { + $logdata = json_decode($log->logdata); + if (isset($logdata->name) && $logdata->name === self::ONHOLD_LOGNAME) + { + $onholddate = $log->zeitpunkt; + break; + } + } + } + + return $onholddate; + } + + /** + * Saves a processstate log with specified parameters, including a specified log date. + * @param $person_id + * @param $date + * @param $taetigkeit_kurzbz + * @param $logjson + * @param string $app + * @param null $oe_kurzbz + * @param null $user + * @return mixed + */ + private function _savePsLog($person_id, $date, $taetigkeit_kurzbz, $logjson, $app = 'core', $oe_kurzbz = null, $user = null) + { + $data = array( + 'person_id' => $person_id, + 'zeitpunkt' => $date, + 'taetigkeit_kurzbz' => $taetigkeit_kurzbz, + 'app' => $app, + 'oe_kurzbz' => $oe_kurzbz, + 'logtype_kurzbz' => 'Processstate', + 'logdata' => json_encode($logjson), + 'insertvon' => $user + ); + + return $this->ci->PersonLogModel->insert($data); + } } diff --git a/application/libraries/TableWidgetLib.php b/application/libraries/TableWidgetLib.php new file mode 100644 index 000000000..139e5d6cb --- /dev/null +++ b/application/libraries/TableWidgetLib.php @@ -0,0 +1,238 @@ +_ci =& get_instance(); // get code igniter instance + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Checks if at least one of the permissions given as parameter (requiredPermissions) belongs + * to the authenticated user, if confirmed then is allowed to use this FilterWidget. + * If the parameter requiredPermissions is NOT given or is not present in the session, + * then NO one is allow to use this FilterWidget + * Wrapper method to permissionlib->hasAtLeastOne + */ + public function isAllowed($requiredPermissions = null) + { + $this->_ci->load->library('PermissionLib'); // Load permission library + + // Gets the required permissions from the session if they are not provided as parameter + $rq = $requiredPermissions; + if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS); + + return $this->_ci->permissionlib->hasAtLeastOne($rq, self::PERMISSION_TABLE_METHOD, self::PERMISSION_TYPE); + } + + /** + * Wrapper method to the session helper funtions to retrieve the whole session for this table widget + */ + public function getSession() + { + return getSessionElement(self::SESSION_NAME, $this->_tableUniqueId); + } + + /** + * Wrapper method to the session helper funtions to retrieve one element from the session of this table widget + */ + public function getSessionElement($name) + { + $session = getSessionElement(self::SESSION_NAME, $this->_tableUniqueId); + + if (isset($session[$name])) + { + return $session[$name]; + } + + return null; + } + + /** + * Wrapper method to the session helper funtions to set the whole session for this table widget + */ + public function setSession($data) + { + setSessionElement(self::SESSION_NAME, $this->_tableUniqueId, $data); + } + + /** + * Wrapper method to the session helper funtions to set one element in the session for this table widget + */ + public function setSessionElement($name, $value) + { + $session = getSessionElement(self::SESSION_NAME, $this->_tableUniqueId); + + $session[$name] = $value; + + setSessionElement(self::SESSION_NAME, $this->_tableUniqueId, $session); // stores the single value + } + + /** + * + */ + public function dropExpiredTableWidgets() + { + // Loads the session for all the table widgets + $tableWidgetsSession = getSession(self::SESSION_NAME); + + // If something is present in session + if ($tableWidgetsSession != null) + { + // Loops in the session for all the table widgets + foreach ($tableWidgetsSession as $tableWidget => $tableWidgetData) + { + // If this table widget is not the currrent used table widget and the it is expired... + if ($this->_tableUniqueId != $tableWidget && $tableWidgetData[self::SESSION_TIMEOUT] <= time()) + { + cleanSessionElement(self::SESSION_NAME, $tableWidget); // ...remove it + } + } + } + } + + /** + * Generate the query to retrieve the dataset for a table widget + */ + public function generateDatasetQuery($query) + { + return 'SELECT * FROM ('.$query.') '.self::DATASET_TABLE_ALIAS; + } + + /** + * Retrieves the dataset from the DB + */ + public function getDataset($datasetQuery) + { + $dataset = null; + + if ($datasetQuery != null) + { + $this->_ci->load->model('system/Filters_model', 'FiltersModel'); + + // Execute the given SQL statement suppressing error messages + $dataset = @$this->_ci->FiltersModel->execReadOnlyQuery($datasetQuery); + } + + return $dataset; + } + + /** + * Retrieves metadata from the last executed query + */ + public function getExecutedQueryMetaData() + { + return $this->_ci->FiltersModel->getExecutedQueryMetaData(); + } + + /** + * Retrieves the list of fields from the last executed query + */ + public function getExecutedQueryListFields() + { + return $this->_ci->FiltersModel->getExecutedQueryListFields(); + } + + /** + * Return an unique string that identify this table widget + * NOTE: The default value is the URI where the FilterWidget is called + * If the fhc_controller_id is present then is also used + */ + public function setTableUniqueIdByParams($params) + { + if ($params != null + && is_array($params) + && isset($params[self::TABLE_UNIQUE_ID]) + && !isEmptyString($params[self::TABLE_UNIQUE_ID])) + { + $tableUniqueId = $this->_ci->router->directory.$this->_ci->router->class.'/'. + $this->_ci->router->method.'/'. + $params[self::TABLE_UNIQUE_ID]; + + $this->setTableUniqueId($tableUniqueId); + } + } + + /** + * Set the _tableUniqueId property + */ + public function setTableUniqueId($tableUniqueId) + { + $this->_tableUniqueId = $tableUniqueId; + } +} diff --git a/application/libraries/UDFLib.php b/application/libraries/UDFLib.php index 6166b44a9..bc8552c25 100644 --- a/application/libraries/UDFLib.php +++ b/application/libraries/UDFLib.php @@ -540,7 +540,7 @@ class UDFLib { if (is_object($udfResults) && isset($udfResults->retval)) { - show_error($udfResults->retval); + show_error(getError($udfResults)); } elseif (is_string($udfResults)) { diff --git a/application/libraries/VariableLib.php b/application/libraries/VariableLib.php new file mode 100644 index 000000000..3d732984f --- /dev/null +++ b/application/libraries/VariableLib.php @@ -0,0 +1,131 @@ +_ci =& get_instance(); + + $this->_variables = null; + + $this->_ci->load->model('system/Variable_model', 'VariableModel'); + $this->_ci->load->model('organisation/studiensemester_model', 'StudiensemesterModel'); + + if (isset($loggeduid['uid']) && !isEmptyString($loggeduid['uid'])) + $this->_setVariables($loggeduid['uid']); + else + { + show_error('uid of logged user not passed!'); + } + } + + /** + * Gets an already loaded user variable by variable name. + * @param $name + * @return mixed|null + */ + public function getVar($name) + { + return isset($this->_variables[$name]) ? $this->_variables[$name] : null; + } + + /** + * Changes variables having Studiensemester as value. Sets variable value to next or previous Semester. + * @param $uid variable is set for this user + * @param $name variable name + * @param $change if positive, variable value is set to next semester, negative - previous semester + * @return array if change was successfull, uid and variable name. Infotext otherwise. + */ + public function changeStudiensemesterVar($uid, $name, $change) + { + $result = error('error when setting variable!'); + $notchangedtext = "Studiensemester variable not changed."; + + if (!isEmptyString($uid) && !isEmptyString($name) && is_numeric($change)) + { + $change = (int) $change; + $varres = $this->_ci->VariableModel->getVariables($uid, array($name)); + + if (isSuccess($varres)) + { + if (hasData($varres)) + { + $currStudiensemester = getData($varres); + + if ($change === 0) + { + $result = success($notchangedtext); + } + else + { + if ($change > 0) + { + $changedsem = $this->_ci->StudiensemesterModel->getNextFrom($currStudiensemester[$name]); + } + elseif ($change < 0) + { + $changedsem = $this->_ci->StudiensemesterModel->getPreviousFrom($currStudiensemester[$name]); + } + + if (hasData($changedsem)) + { + $changedsem = getData($changedsem); + + $result = $this->_ci->VariableModel->setVariable($uid, $name, $changedsem[0]->studiensemester_kurzbz); + //update property + $this->_setVariable($uid, $name); + } + else + { + $result = success($notchangedtext); + } + } + } + } + } + return $result; + } + + /** + * "Refreshes" variable value with given name by retrieving current value from db and saving it. + * @param $uid + * @param $name + */ + private function _setVariable($uid, $name) + { + $variable = $this->_ci->VariableModel->getVariables($uid, array($name)); + + if (hasData($variable)) + { + $variable = getData($variable); + $this->_variables[$name] = $variable[$name]; + } + } + + /** + * "Refreshes" all variable values by retrieving current values from db and saving them. + * @param $uid + */ + private function _setVariables($uid) + { + $variables = $this->_ci->VariableModel->getVariables($uid); + if (hasData($variables)) + { + $this->_variables = getData($variables); + } + } +} diff --git a/application/models/accounting/Konto_model.php b/application/models/accounting/Konto_model.php index d76b2bd46..cbd7a6f2d 100644 --- a/application/models/accounting/Konto_model.php +++ b/application/models/accounting/Konto_model.php @@ -22,8 +22,7 @@ class Konto_model extends DB_Model $this->addJoin('wawi.tbl_konto_kostenstelle', 'konto_id'); $konten = $this->loadWhere(array('kostenstelle_id' => $kostenstelle_id)); - if ($konten->error) - return error($konten->retval); + if ($konten->error) return $konten; return $konten; } diff --git a/application/models/accounting/Vertrag_model.php b/application/models/accounting/Vertrag_model.php index cd4b466d6..8725cd98d 100644 --- a/application/models/accounting/Vertrag_model.php +++ b/application/models/accounting/Vertrag_model.php @@ -10,5 +10,324 @@ class Vertrag_model extends DB_Model parent::__construct(); $this->dbTable = 'lehre.tbl_vertrag'; $this->pk = 'vertrag_id'; + + $this->load->model('accounting/Vertragvertragsstatus_model', 'VertragvertragsstatusModel'); + $this->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel'); + $this->load->model('education/Projektbetreuer_model', 'ProjektbetreuerModel'); } + + /** + * Saves Vertrag for a Lehrauftrag and sets Vertragsstatus to 'bestellt'. + * Also updates vertrag_id in tbl_lehreinheitmitarbeiter or tbl_projektbetreuer. + * @param $person_id + * @param $lehrveranstaltung_id + * @param $lehreinheit_id + * @param $projektarbeit_id + * @param $betrag Monetary amount of that Lehreinheit / Projektbetreuung. + * @param $vertragsstunden Working hours of that Lehreinheit / Projektbetreuung. + * @param $studiensemester_kurzbz + * @param $vertragstyp_kurzbz + * @return array|null On success object. On failure null. + */ + public function save($person_id, $mitarbeiter_uid, $lehrveranstaltung_id, $lehreinheit_id, $projektarbeit_id = null, $vertragsstunden, $betrag, $studiensemester_kurzbz) + { + $person_id = (isset($person_id) && is_numeric($person_id)) + ? $person_id + : show_error('peron_id must be set and numeric.'); + $lehreinheit_id = (isset($lehreinheit_id) && is_numeric($lehreinheit_id)) + ? $lehreinheit_id + : show_error('lehreinheit_id must be set and numeric.'); + $lehrveranstaltung_id = (isset($lehrveranstaltung_id) && is_numeric($lehrveranstaltung_id)) + ? $lehrveranstaltung_id + : show_error('lehrveranstaltung_id must be set and numeric.'); + $projektarbeit_id = (isset($projektarbeit_id) && is_numeric($projektarbeit_id)) + ? $projektarbeit_id + : null; + $vertragsstunden = (isset($vertragsstunden) && is_numeric($vertragsstunden)) + ? $vertragsstunden + : 0; + $betrag = (isset($betrag) && is_numeric($betrag)) + ? $betrag + : 0; + $mitarbeiter_uid = (isset($mitarbeiter_uid) && is_string($mitarbeiter_uid)) + ? $mitarbeiter_uid + : show_error('mitarbeiter_uid must be set and a string value.');; + + $vertragstyp_kurzbz = (is_null($projektarbeit_id)) ? 'Lehrauftrag' : 'Betreuung'; + + // First check if Vertrag already exists for that Lehrauftrag or for that Projektbetreuerauftrag + if ($vertragstyp_kurzbz == 'Lehrauftrag') + { + if ($this->LehreinheitmitarbeiterModel->hasVertrag($mitarbeiter_uid, $lehreinheit_id)) + { + return error('Lehrauftrag existiert bereits'); // Exit if Lehrauftrag already has Vertrag + } + } + elseif ($vertragstyp_kurzbz == 'Betreuung') + { + if ($this->ProjektbetreuerModel->hasVertrag($person_id, $projektarbeit_id)) + { + return error('Lehrauftrag existiert bereits'); // Exit if Projektbetreuung already has Vertrag + } + } + + // If Vertrag does not exist, create now + // Vertragsbezeichnung + $bezeichnung = $this->_writeVertragsbezeichung($lehrveranstaltung_id, $studiensemester_kurzbz); + + // Start DB transaction + $this->db->trans_start(false); + + // Insert Vertragsdata + $result = $this->insert( + array( + 'person_id' => $person_id, + 'lehrveranstaltung_id' => $lehrveranstaltung_id, + 'vertragstyp_kurzbz' => $vertragstyp_kurzbz, + 'bezeichnung' => $bezeichnung, + 'betrag' => $betrag, + 'insertamum' => 'NOW()', + 'insertvon' => getAuthUID(), + 'vertragsdatum' => 'NOW()', + 'vertragsstunden' => $vertragsstunden, + 'vertragsstunden_studiensemester_kurzbz' => $studiensemester_kurzbz + ) + ); + + // Retrieve primary key + $vertrag_id = $result->retval; + + // If Vertrag was created successfully, update vertrag_id + if (isSuccess($result)) + { + // if Lehrtätigkeit, update vertrag_id in tbl_lehreinheitmitarbeiter + if ($vertragstyp_kurzbz == 'Lehrauftrag') + { + $this->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel'); + $result = $this->LehreinheitmitarbeiterModel->update( + array( + 'lehreinheit_id' => $lehreinheit_id, + 'mitarbeiter_uid' =>$mitarbeiter_uid + ), + array( + 'vertrag_id' => $vertrag_id + ) + ); + } + // if (Projekt-)Betreuung, update vertrag_id in tbl_projektbetreuer + elseif ($vertragstyp_kurzbz == 'Betreuung') + { + $this->load->model('education/Projektbetreuer_model', 'ProjektbetreuerModel'); + $result = $this->ProjektbetreuerModel->update( + array( + 'person_id' => $person_id, + 'projektarbeit_id' => $projektarbeit_id + ), + array( + 'vertrag_id' => $vertrag_id + ) + ); + } + } + + // If updating vertrag_id was successfully, set Status to 'bestellt' + if (isSuccess($result)) + { + $result = $this->VertragvertragsstatusModel->setStatus($vertrag_id, $mitarbeiter_uid, 'bestellt'); + } + + // Transaction complete! + $this->db->trans_complete(); + + // Check if everything went ok during the transaction + if ($this->db->trans_status() === false || isError($result)) + { + $this->db->trans_rollback(); + return error($result->msg, EXIT_ERROR); + } + else + { + $this->db->trans_commit(); + return success($vertrag_id); + } + } + + /** + * Updates Vertrag and, if resets vertragsstatus as follows: + * - if vertragsstatus 'erteilt': delete status 'erteilt' and update date of status 'bestellt' + * - if vertragsstatus 'bestellt': update date of status 'bestellt' + * @param $vertrag_obj Object with vertrag properties vertrag_id, vertragsstunden, betrag. + * @param $mitarbeiter_uid + */ + public function updateVertrag($vertrag_id, $vertragsstunden, $betrag, $mitarbeiter_uid) + { + $vertrag_id = (isset($vertrag_id) && is_numeric($vertrag_id)) + ? $vertrag_id + : show_error('vertrag_id must be set and numeric.'); + $vertragsstunden = (isset($vertragsstunden) && is_numeric($vertragsstunden)) + ? $vertragsstunden + : 0; + $betrag = (isset($betrag) && is_numeric($betrag)) + ? $betrag + : 0; + $mitarbeiter_uid = (isset($mitarbeiter_uid) && is_string($mitarbeiter_uid)) + ? $mitarbeiter_uid + : show_error('mitarbeiter_uid must be set and a string value.'); + + // Start DB transaction + $this->db->trans_start(false); + + // Update contract + $result = $this->update( + $vertrag_id, + array( + 'vertragsstunden' => $vertragsstunden, + 'betrag' => $betrag, + 'updateamum' => $this->escape('NOW()'), + 'updatevon' => getAuthUID() + ) + ); + + // If last vertragsstatus is 'erteilt', delete the status + if (isSuccess($result)) + { + $result = $this->VertragvertragsstatusModel->getLastStatus($vertrag_id, $mitarbeiter_uid); + + $lastStatus = getData($result)[0]->vertragsstatus_kurzbz; + + if ($lastStatus == 'erteilt') + { + $result = $this->VertragvertragsstatusModel->deleteStatus($vertrag_id, 'erteilt'); + } + } + + // Update date of status 'bestellt' + if (isSuccess($result)) + { + $result = $this->VertragvertragsstatusModel->updateStatus($vertrag_id, 'bestellt'); + } + + // Transaction complete! + $this->db->trans_complete(); + + // Check if everything went ok during the transaction + if ($this->db->trans_status() === false || isError($result)) + { + $this->db->trans_rollback(); + return error($result->msg, EXIT_ERROR); + } + else + { + $this->db->trans_commit(); + return success('Contract successfully updated.'); + } + } + + /** + * Gets Lehreinheit ID corresponding to the contract. + * @param $vertrag_id + * @return array + */ + public function getLehreinheitID($vertrag_id) + { + $vertragstyp_kurzbz = null; + + $this->addSelect('vertragstyp_kurzbz'); + if ($result = getData($this->load($vertrag_id))) + { + $vertragstyp_kurzbz = $result[0]->vertragstyp_kurzbz; + } + else + { + return error('Fehler beim Laden des Vertrags.'); + } + + if ($vertragstyp_kurzbz == 'Lehrauftrag') + { + $this->LehreinheitmitarbeiterModel->addSelect('lehreinheit_id'); + if ($result = $this->LehreinheitmitarbeiterModel->loadWhere(array('vertrag_id' => $vertrag_id))) + { + return success($result->retval); + } + else + { + return error('Fehler beim Ermitteln der Lehreinheit ID'); + } + + } + elseif ($vertragstyp_kurzbz == 'Betreuung') + { + $this->addSelect('lehreinheit_id'); + $this->addJoin('lehre.tbl_projektbetreuer', 'vertrag_id'); + $this->addJoin('lehre.tbl_projektarbeit', 'projektarbeit_id'); + if ($result = $this->loadWhere(array('vertrag_id' => $vertrag_id))) + { + return success($result->retval); + } + else + { + return error('Fehler beim Ermitteln der Lehreinheit ID'); + } + } + } + + /** + * Gets (table) data of lehreinheit_id corresponding to the contract. + * @param integer $vertrag_id + * @param string $select To restrict fields, pass select string. e.g. 'lehrveranstaltung_id'. + * @return array + */ + public function getLehreinheitData($vertrag_id, $select = '*') + { + if ($result = getData($this->getLehreinheitID($vertrag_id))) + { + $this->load->model('education/Lehreinheit_model', 'LehreinheitModel'); + $this->LehreinheitModel->addSelect($select); + + if($result = $this->LehreinheitModel->load($result[0]->lehreinheit_id)) + { + return success($result->retval); + } + else + { + return error('Fehler beim Laden der Lehreinheit'); + } + } + else + { + return error('Fehler beim Ermitteln der Lehreinheit ID'); + } + } + + // ----------------------------------------------------------------------------------------------------------------- + // Private methods + + /** + * Generate contract description. + * Example: WS2017-BEE3-LIA-LAB + * @param $lehrveranstaltung_id + * @param $studiensemester_kurzbz Studiensemester of Lehrauftrag (= when the lector will teach the lehrveranstaltung) + * @return string Returns e.g. WS2017-BBE5-GAP-LAB + */ + private function _writeVertragsbezeichung($lehrveranstaltung_id, $studiensemester_kurzbz) + { + $bezeichnung = ''; + $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); + $this->LehrveranstaltungModel->addSelect('tbl_lehrveranstaltung.semester, tbl_lehrveranstaltung.kurzbz AS "lv_kurzbz", lehrform_kurzbz, public.tbl_studiengang.typ, public.tbl_studiengang.kurzbz'); + $this->LehrveranstaltungModel->addJoin('lehre.tbl_studienplan_lehrveranstaltung', 'lehrveranstaltung_id'); + $this->LehrveranstaltungModel->addJoin('lehre.tbl_studienplan', 'studienplan_id'); + $this->LehrveranstaltungModel->addJoin('lehre.tbl_studienordnung', 'studienordnung_id'); + $this->LehrveranstaltungModel->addJoin('public.tbl_studiengang', 'public.tbl_studiengang.studiengang_kz = lehre.tbl_studienordnung.studiengang_kz'); + $result = $this->LehrveranstaltungModel->load($lehrveranstaltung_id); + + if (hasData($result)) + { + $bezeichnung = $studiensemester_kurzbz. '-'; + $bezeichnung.= strtoupper($result->retval[0]->typ. $result->retval[0]->kurzbz). $result->retval[0]->semester. '-'; + $bezeichnung.= $result->retval[0]->lv_kurzbz. '-'; + $bezeichnung.= $result->retval[0]->lehrform_kurzbz; + } + + return $bezeichnung; + } } diff --git a/application/models/accounting/Vertragvertragsstatus_model.php b/application/models/accounting/Vertragvertragsstatus_model.php new file mode 100644 index 000000000..609394321 --- /dev/null +++ b/application/models/accounting/Vertragvertragsstatus_model.php @@ -0,0 +1,193 @@ +dbTable = 'lehre.tbl_vertrag_vertragsstatus'; + $this->pk = array('vertragsstatus_kurzbz', 'vertrag_id'); + $this->hasSequence = false; + } + + /** + * Check if Vertrag has the given Vertragsstatus. + * @param integer $vertrag_id + * @param string $mitarbeiter_uid + * @param string $vertragsstatus_kurzbz + * @return array + */ + public function hasStatus($vertrag_id, $mitarbeiter_uid, $vertragsstatus_kurzbz) + { + $this->addSelect('1'); + $this->addLimit(1); + + return $this->loadWhere(array( + 'vertrag_id' => $vertrag_id, + 'uid' => $mitarbeiter_uid, + 'vertragsstatus_kurzbz' => $vertragsstatus_kurzbz + )); + } + + /** + * Get the latest Vertragsstatus for the given Vertrag and Mitarbeiter + * @param integer $vertrag_id + * @param string $mitarbeiter_uid + * @return array + */ + public function getLastStatus($vertrag_id, $mitarbeiter_uid) + { + $this->addSelect('vertragsstatus_kurzbz'); + $this->addOrder('datum', 'DESC'); + $this->addLimit(1); + return $this->loadWhere( + array( + 'vertrag_id' => $vertrag_id, + 'uid' => $mitarbeiter_uid + ) + ); + } + + /** + * Set Vertragsstatus for the given Vertrag and Mitarbeiter. + * @param integer $vertrag_id + * @param string $mitarbeiter_uid + * @param string $vertragsstatus_kurzbz + * @return object On success, return success object. + * If status already exists or earlier status is missing, return error object. + */ + public function setStatus($vertrag_id, $mitarbeiter_uid, $vertragsstatus_kurzbz){ + + // Check if vertrag has already this status + $result = $this->hasStatus($vertrag_id, $mitarbeiter_uid, $vertragsstatus_kurzbz); + + // If status is already set, return error message + if (hasData($result)) + { + return error('Fehler: Status bereits vorhanden.'); + } + + // If new status should be 'akzeptiert', the latest status has to be 'erteilt' + if ($vertragsstatus_kurzbz == 'akzeptiert') + { + $result = $this->getLastStatus($vertrag_id, $mitarbeiter_uid); + $last_status = getData($result)[0]->vertragsstatus_kurzbz; + + // If latest status is not 'erteilt', return error message + if ($last_status != 'erteilt') + { + return error('Fehler: Vor Status \'angenommen\' muss erst Status \'erteilt\' gesetzt sein.'); + } + } + + // Set new status if passed all checks + return $this->insert( + array( + 'vertrag_id' => $vertrag_id, + 'vertragsstatus_kurzbz' => $vertragsstatus_kurzbz, + 'uid' => $mitarbeiter_uid, + 'datum' => $this->escape('NOW()'), + 'insertvon' => getAuthUID(), + 'insertamum' => $this->escape('NOW()') + ) + ); + } + + /** + * Updates the date of the given vertragsstatus. + * @param $vertrag_id + * @param $vertragsstatus_kurzbz + * @return array + */ + public function updateStatus($vertrag_id, $vertragsstatus_kurzbz) + { + $user = getAuthUID(); + return $this->update( + array( + 'vertrag_id' => $vertrag_id, + 'vertragsstatus_kurzbz' => $vertragsstatus_kurzbz + ), + array( + 'datum' => $this->escape('NOW()'), + 'updateamum' => $this->escape('NOW()'), + 'updatevon' => $user, + ) + ); + } + + /** + * Deletes the given vertragsstatus of the contract. + * @param $vertrag_id + * @param $vertragsstatus_kurbz + * @return array + */ + public function deleteStatus($vertrag_id, $vertragsstatus_kurzbz) + { + return $this->delete( + array( + 'vertrag_id' => $vertrag_id, + 'vertragsstatus_kurzbz' => $vertragsstatus_kurzbz + ) + ); + } + + /** + * Get all contracts, where the status had been set to 'bestellt' on given date + * @param string $string_date e.g. '01.11.2019' or special Date/Time inputs like 'YESTERDAY', 'TODAY', 'NOW' + * @param bool $further_processed If true, ALL ordered contracts of that day are retrieved, even if they were + * were ALSO approved/accepted/cancelled (further processed) on that same day. + * @return array + */ + public function getOrdered_fromDate($string_date = 'TODAY', $further_processed = false) + { + $condition = ' + vertragsstatus_kurzbz = \'bestellt\' AND + (datum)::date = date \''. $string_date .'\' + '; + + if (!$further_processed) + { + $condition .= ' + AND + vertrag_id NOT IN ( + SELECT vertrag_id + FROM lehre.tbl_vertrag_vertragsstatus + WHERE vertragsstatus_kurzbz IN (\'erteilt\', \'akzeptiert\', \'storno\') + ) + '; + } + + return $this->loadWhere($condition); + } + + /** + * Get all contracts, where the status had been set to 'erteilt' on given date + * @param string $string_date e.g. '01.11.2019' or special Date/Time inputs like 'YESTERDAY', 'TODAY', 'NOW' + * @param bool $further_processed If true, ALL contracts approved on that day are retrieved, even if they were + * were ALSO accepted/cancelled (further processed) on that same day. + * @return array + */ + public function getApproved_fromDate($string_date = 'TODAY', $further_processed = false) + { + $condition = ' + vertragsstatus_kurzbz = \'erteilt\' AND + (datum)::date = date \''. $string_date .'\' + '; + + if (!$further_processed) + { + $condition .= ' + AND + vertrag_id NOT IN ( + SELECT vertrag_id + FROM lehre.tbl_vertrag_vertragsstatus + WHERE vertragsstatus_kurzbz IN (\'akzeptiert\', \'storno\') + ) + '; + } + + return $this->loadWhere($condition); + } +} diff --git a/application/models/codex/Bisiozweck_model.php b/application/models/codex/Bisiozweck_model.php new file mode 100644 index 000000000..b456f412d --- /dev/null +++ b/application/models/codex/Bisiozweck_model.php @@ -0,0 +1,15 @@ +dbTable = 'bis.tbl_bisio_zweck'; + $this->pk = array('bisio_id', 'zweck_code'); + $this->hasSequence = false; + } +} diff --git a/application/models/codex/Bisverwendung_model.php b/application/models/codex/Bisverwendung_model.php index fa2cf84d0..20f942865 100644 --- a/application/models/codex/Bisverwendung_model.php +++ b/application/models/codex/Bisverwendung_model.php @@ -11,4 +11,34 @@ class Bisverwendung_model extends DB_Model $this->dbTable = 'bis.tbl_bisverwendung'; $this->pk = 'bisverwendung_id'; } + + /** + * Get latest (active) Verwendung of the user. + * @param string $uid + * @param bool $active If false, returns latest Verwendung no matter if actual or not (ignores ending/beginning date). + * @return array + */ + public function getLast($uid, $active = true) + { + $this->addLimit(1); + + if ($active) + { + $condition = ' + mitarbeiter_uid = '. $this->escape($uid). ' + AND ( beginn <= NOW() OR beginn IS NULL ) + AND ( ende >= NOW() OR ende IS NULL ) + ORDER BY ende DESC NULLS LAST, beginn DESC NULLS LAST + '; + } + else + { + $condition = ' + mitarbeiter_uid = '. $this->escape($uid). ' + ORDER BY ende DESC NULLS LAST, beginn DESC NULLS LAST + '; + } + + return $this->loadWhere($condition); + } } diff --git a/application/models/crm/Akte_model.php b/application/models/crm/Akte_model.php index b30e175c3..fe9db5330 100644 --- a/application/models/crm/Akte_model.php +++ b/application/models/crm/Akte_model.php @@ -186,8 +186,7 @@ class Akte_model extends DB_Model $dokumente = $this->loadWhere($where); - if($dokumente->error) - return error($dokumente->retval); + if($dokumente->error) return $dokumente; return success($dokumente->retval); } diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index b1ae9b8e9..5b74ed5e4 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -10,6 +10,8 @@ class Prestudent_model extends DB_Model parent::__construct(); $this->dbTable = 'public.tbl_prestudent'; $this->pk = 'prestudent_id'; + + $this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel'); } /** @@ -208,12 +210,11 @@ class Prestudent_model extends DB_Model return error('prestudent could not be loaded'); //Prestudentstatus - $this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel'); $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id); if ($lastStatus->error) { - return error($lastStatus->retval); + return $lastStatus; } if (count($lastStatus->retval) > 0) @@ -221,7 +222,7 @@ class Prestudent_model extends DB_Model //get Studiengangname from Studienplan and -ordnung $studienordnung = $this->PrestudentstatusModel->getStudienordnungFromPrestudent($prestudent_id); if ($studienordnung->error) - return error($studienordnung->retval); + return $studienordnung; if (count($studienordnung->retval) > 0) { @@ -238,7 +239,7 @@ class Prestudent_model extends DB_Model $language = $this->SpracheModel->load($lastStatus->retval[0]->sprache); if ($language->error) - return error($language->retval); + return $language; if (count($language->retval) > 0) $lastStatus->retval[0]->sprachedetails = $language->retval[0]; @@ -256,7 +257,7 @@ class Prestudent_model extends DB_Model ) ); if ($bewerbungstermin->error) - return error($bewerbungstermin->retval); + return $bewerbungstermin; if (count($bewerbungstermin->retval) > 0) { @@ -310,8 +311,6 @@ class Prestudent_model extends DB_Model if (!hasData($prestudents)) return $bewerbungen; - $this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel'); - foreach ($prestudents->retval as $prestudent) { $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent->prestudent_id, $studiensemester_kurzbz); @@ -424,7 +423,6 @@ class Prestudent_model extends DB_Model if (!hasData($prestudent)) return false; - $this->load->model('prestudentstatus_model', 'PrestudentstatusModel'); $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id, null, 'Interessent'); if (!hasData($lastStatus)) diff --git a/application/models/crm/Prestudentstatus_model.php b/application/models/crm/Prestudentstatus_model.php index 719ddf884..d579037e1 100644 --- a/application/models/crm/Prestudentstatus_model.php +++ b/application/models/crm/Prestudentstatus_model.php @@ -123,7 +123,7 @@ class Prestudentstatus_model extends DB_Model if ($lastStatus->error) { - return error($lastStatus->retval); + return $lastStatus; } if (count($lastStatus->retval) > 0) @@ -158,7 +158,7 @@ class Prestudentstatus_model extends DB_Model if ($lastStatus->error) { - return error($lastStatus->retval); + return $lastStatus; } if (count($lastStatus->retval) > 0) diff --git a/application/models/education/Lehreinheit_model.php b/application/models/education/Lehreinheit_model.php index 22778cb6a..10c122b94 100644 --- a/application/models/education/Lehreinheit_model.php +++ b/application/models/education/Lehreinheit_model.php @@ -28,6 +28,7 @@ class Lehreinheit_model extends DB_Model { $lehreinheiten = array(); + $this->addOrder('lehreinheit_id'); $les = $this->loadWhere( array('lehrveranstaltung_id' => $lehrveranstaltung_id, 'studiensemester_kurzbz' => $studiensemester) @@ -62,17 +63,17 @@ class Lehreinheit_model extends DB_Model if (hasData($studiengangresponse)) { $studiengang = $studiengangresponse->retval[0]; - $stgkuerzel = mb_strtoupper($studiengang->typ . $studiengang->kurzbz); + $stgkuerzel = mb_strtoupper($studiengang->typ.$studiengang->kurzbz); - $letoadd->lehreinheitgruppen[] = array( - 'semester' => $lehreinheitgruppe->semester, - 'verband' => $lehreinheitgruppe->verband, - 'gruppe' => $lehreinheitgruppe->gruppe, - 'gruppe_kurzbz' => $lehreinheitgruppe->gruppe_kurzbz, - 'direktinskription' => $lehreinheitgruppe->direktinskription, - 'studiengang_kz' => $lehreinheitgruppe->studiengang_kz, - 'studiengang_kuerzel' => $stgkuerzel - ); + $letoadd->lehreinheitgruppen[] = array( + 'semester' => $lehreinheitgruppe->semester, + 'verband' => $lehreinheitgruppe->verband, + 'gruppe' => $lehreinheitgruppe->gruppe, + 'gruppe_kurzbz' => $lehreinheitgruppe->gruppe_kurzbz, + 'direktinskription' => $lehreinheitgruppe->direktinskription, + 'studiengang_kz' => $lehreinheitgruppe->studiengang_kz, + 'studiengang_kuerzel' => $stgkuerzel + ); } } } diff --git a/application/models/education/Lehreinheitgruppe_model.php b/application/models/education/Lehreinheitgruppe_model.php index 796ae574b..2a6f9571a 100644 --- a/application/models/education/Lehreinheitgruppe_model.php +++ b/application/models/education/Lehreinheitgruppe_model.php @@ -98,8 +98,8 @@ class Lehreinheitgruppe_model extends DB_Model 'semester' => $lvadata->semester, 'bezeichnung' => $bezeichnung, 'aktiv' => true, - 'mailgrp' => false, - 'sichtbar' => true, + 'mailgrp' => true, + 'sichtbar' => false, 'generiert' => false, 'insertamum' => date('Y-m-d H:i:s'), 'insertvon' => $loggedInUser, diff --git a/application/models/education/Lehreinheitmitarbeiter_model.php b/application/models/education/Lehreinheitmitarbeiter_model.php index ee11dcd01..dd5c7c858 100644 --- a/application/models/education/Lehreinheitmitarbeiter_model.php +++ b/application/models/education/Lehreinheitmitarbeiter_model.php @@ -11,4 +11,34 @@ class Lehreinheitmitarbeiter_model extends DB_Model $this->dbTable = 'lehre.tbl_lehreinheitmitarbeiter'; $this->pk = array('mitarbeiter_uid', 'lehreinheit_id'); } + + /** + * Checks if Lehrauftrag has a contract. + * @param $mitarbeiter_uid + * @param $lehreinheit_id + * @return array|bool|int Returns vertrag_id if contract exists. False if doesnt exist. On error array. + */ + public function hasVertrag($mitarbeiter_uid, $lehreinheit_id) + { + if(is_string($mitarbeiter_uid) && is_numeric($lehreinheit_id)) + { + $result = $this->load(array( + 'mitarbeiter_uid' => $mitarbeiter_uid, + 'lehreinheit_id' => $lehreinheit_id + )); + + if (hasData($result)) + { + return (is_null($result->retval[0]->vertrag_id)) ? false : intval($result->retval[0]->vertrag_id); + } + else + { + return error($result->msg, EXIT_ERROR); + } + } + else + { + return error ('Incorrect parameter type'); + } + } } diff --git a/application/models/education/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php index 1685ddf81..4941ba9bd 100644 --- a/application/models/education/Lehrveranstaltung_model.php +++ b/application/models/education/Lehrveranstaltung_model.php @@ -10,6 +10,9 @@ class Lehrveranstaltung_model extends DB_Model parent::__construct(); $this->dbTable = 'lehre.tbl_lehrveranstaltung'; $this->pk = 'lehrveranstaltung_id'; + + $this->load->model('organisation/studiengang_model', 'StudiengangModel'); + $this->load->model('organisation/studiensemester_model', 'StudiensemesterModel'); } /** @@ -22,8 +25,6 @@ class Lehrveranstaltung_model extends DB_Model */ public function getLehrveranstaltungGroupNames($studiensemester_kurzbz, $ausbildungssemester = null, $studiengang_kz = null, $lehrveranstaltung_ids = null) { - $this->load->model('organisation/studiengang_model', 'StudiengangModel'); - $studiengang_kz_arr = array(); $ausbildungssemester_arr = array(); $lehrveranstaltung_id_arr = array(); @@ -59,13 +60,12 @@ class Lehrveranstaltung_model extends DB_Model } else { - $this->load->model('organisation/studiensemester_model', 'StudiensemesterModel'); foreach ($studiengang_kz_arr as $studiengang_kz_item) { $result = $this->StudiensemesterModel->getAusbildungssemesterByStudiensemesterAndStudiengang($studiensemester_kurzbz, $studiengang_kz_item); if (isError($result)) - return error($result->retval); + return error(getError($result)); foreach ($result->retval as $semester) { @@ -104,7 +104,7 @@ class Lehrveranstaltung_model extends DB_Model if (count($studiengang_kz_arr) > 0) $query .= " AND tbl_lehrveranstaltung.studiengang_kz IN (". implode(", ", $studiengang_kz_arr).")"; - + if (count($lehrveranstaltung_id_arr) > 0) { $query .= " AND tbl_lehrveranstaltung.lehrveranstaltung_id IN (". implode(', ', $lehrveranstaltung_id_arr).")"; @@ -144,7 +144,7 @@ class Lehrveranstaltung_model extends DB_Model WHERE vw_student_lehrveranstaltung.studiensemester_kurzbz=? AND - vw_student_lehrveranstaltung.lehrveranstaltung_id=? + vw_student_lehrveranstaltung.lehrveranstaltung_id=? ORDER BY nachname, vorname, person_id, tbl_bisio.bis DESC"; return $this->execQuery($query, array($studiensemester_kurzbz, $lehrveranstaltung_id)); @@ -214,8 +214,6 @@ class Lehrveranstaltung_model extends DB_Model */ public function getLvsWithIncomingPlaces($studiensemester_kurzbz) { - $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); - $studsemres = $this->StudiensemesterModel->load($studiensemester_kurzbz); if (!hasData($studsemres)) diff --git a/application/models/education/Projektbetreuer_model.php b/application/models/education/Projektbetreuer_model.php index 32743be82..746e4c052 100644 --- a/application/models/education/Projektbetreuer_model.php +++ b/application/models/education/Projektbetreuer_model.php @@ -11,4 +11,34 @@ class Projektbetreuer_model extends DB_Model $this->dbTable = 'lehre.tbl_projektbetreuer'; $this->pk = array('betreuerart_kurzbz', 'projektarbeit_id', 'person_id'); } + + /** + * Checks if Projektauftrag has a contract. + * @param $person_id + * @param $projektarbeit_id + * @return array|bool|int Returns vertrag_id if contract exists. False if doesnt exist. On error array. + */ + public function hasVertrag($person_id, $projektarbeit_id) + { + if (is_numeric($person_id) && is_numeric($projektarbeit_id)) + { + $result = $this->load(array( + 'person_id' => $person_id, + 'projektarbeit_id' => $projektarbeit_id + )); + + if (hasData($result)) + { + return (is_null($result->retval[0]->vertrag_id)) ? false : intval($result->retval[0]->vertrag_id); + } + else + { + return error($result->msg, EXIT_ERROR); + } + } + else + { + return error ('Incorrect parameter type'); + } + } } diff --git a/application/models/organisation/Organisationseinheit_model.php b/application/models/organisation/Organisationseinheit_model.php index f9353c7b3..3efc8472a 100644 --- a/application/models/organisation/Organisationseinheit_model.php +++ b/application/models/organisation/Organisationseinheit_model.php @@ -165,4 +165,27 @@ class Organisationseinheit_model extends DB_Model return $this->execQuery(sprintf($query, $aktivstring, $aktivstring), array($oe_kurzbz)); } + /** + * Get one parent only. + * Easily retrieve department of a studiengang or fakultät of department etc. + * @param $oe_kurzbz + * @return array|null + */ + public function getParent($oe_kurzbz) + { + if (is_string($oe_kurzbz)) + { + $condition = ' + oe_kurzbz = ( + SELECT + oe_parent_kurzbz + FROM + public.tbl_organisationseinheit + WHERE + oe_kurzbz = \''. $oe_kurzbz. '\' + ) + '; + } + return $this->loadWhere($condition); + } } diff --git a/application/models/organisation/Studienplan_model.php b/application/models/organisation/Studienplan_model.php index 2c3b36c03..0cc23b85d 100644 --- a/application/models/organisation/Studienplan_model.php +++ b/application/models/organisation/Studienplan_model.php @@ -19,7 +19,7 @@ class Studienplan_model extends DB_Model return $this->loadWhere(array("studiengang_kz" => $studiengang_kz)); } - public function getStudienplaeneBySemester($studiengang_kz, $studiensemester_kurzbz, $ausbildungssemester = null, $orgform_kurzbz = null) + public function getStudienplaeneBySemester($studiengang_kz, $studiensemester_kurzbz, $ausbildungssemester = null, $orgform_kurzbz = null, $sprache = null) { $this->addJoin("lehre.tbl_studienordnung", "studienordnung_id"); $this->addJoin("lehre.tbl_studienplan_semester", "studienplan_id"); @@ -40,6 +40,11 @@ class Studienplan_model extends DB_Model $whereArray["orgform_kurzbz"] = $orgform_kurzbz; } + if(!is_null($sprache)) + { + $whereArray["tbl_studienplan.sprache"] = $sprache; + } + return $this->StudienplanModel->loadWhere($whereArray); } diff --git a/application/models/organisation/Studiensemester_model.php b/application/models/organisation/Studiensemester_model.php index 9248b241d..9cdde7a52 100644 --- a/application/models/organisation/Studiensemester_model.php +++ b/application/models/organisation/Studiensemester_model.php @@ -13,6 +13,22 @@ class Studiensemester_model extends DB_Model $this->hasSequence = false; } + // Get next study semester + public function getNext() + { + $query = ' + SELECT * + FROM + public.tbl_studiensemester + WHERE + start > now() + ORDER BY start + LIMIT 1; + '; + + return $this->execQuery($query); + } + /** * getLastOrAktSemester */ @@ -61,7 +77,7 @@ class Studiensemester_model extends DB_Model start, ende FROM public.tbl_studiensemester - WHERE start > ( + WHERE start >= ( SELECT ende FROM public.tbl_studiensemester WHERE studiensemester_kurzbz = ? @@ -72,6 +88,26 @@ class Studiensemester_model extends DB_Model return $this->execQuery($query, array($studiensemester_kurzbz)); } + /** + * getPreviousFrom + */ + public function getPreviousFrom($studiensemester_kurzbz) + { + $query = 'SELECT studiensemester_kurzbz, + start, + ende + FROM public.tbl_studiensemester + WHERE ende <= ( + SELECT start + FROM public.tbl_studiensemester + WHERE studiensemester_kurzbz = ? + ) + ORDER BY start DESC + LIMIT 1'; + + return $this->execQuery($query, array($studiensemester_kurzbz)); + } + /** * getNearest */ diff --git a/application/models/person/Benutzer_model.php b/application/models/person/Benutzer_model.php index 46e5bdb98..dc5b95779 100644 --- a/application/models/person/Benutzer_model.php +++ b/application/models/person/Benutzer_model.php @@ -15,8 +15,7 @@ class Benutzer_model extends DB_Model public function getFromPersonId($person_id) { - /*$this->addSelect('uid, aktiv, alias');*/ - $this->loadWhere(array('person_id' => $person_id)); + return $this->loadWhere(array('person_id' => $person_id, 'aktiv' => true)); } } diff --git a/application/models/person/Benutzerfunktion_model.php b/application/models/person/Benutzerfunktion_model.php index 02a27e87a..ceb427687 100644 --- a/application/models/person/Benutzerfunktion_model.php +++ b/application/models/person/Benutzerfunktion_model.php @@ -48,7 +48,7 @@ class Benutzerfunktion_model extends DB_Model if (is_string($funktion_kurzbz)) { - $query .= " AND funktion_kurzbz = ".$funktion_kurzbz.")"; + $query .= " AND funktion_kurzbz = '".$funktion_kurzbz."'"; } elseif (is_array($funktion_kurzbz) && count($funktion_kurzbz) > 0) { @@ -104,4 +104,38 @@ class Benutzerfunktion_model extends DB_Model return $this->execQuery($query, $parametersArray); } + + /** + * Get active Studiengangsleitung(en) of the user by UID. + * @param $uid + */ + public function getSTGLByUID($uid) + { + $query = ' + SELECT + uid, + oe_kurzbz, + studiengang_kz, + typ, + tbl_studiengang.bezeichnung + FROM + public.tbl_benutzerfunktion + JOIN public.tbl_studiengang USING (oe_kurzbz) + WHERE + funktion_kurzbz = \'Leitung\' + AND (datum_von IS NULL OR datum_von <= now()) + AND (datum_bis IS NULL OR datum_bis >= now()) + AND uid = ? + ORDER BY + oe_kurzbz + '; + + $parameters_array = array(); + if (is_string($uid)) + { + $parameters_array[] = $uid; + } + + return $this->execQuery($query, $parameters_array); + } } diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index b689f4fcb..9c1146632 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -10,6 +10,9 @@ class Person_model extends DB_Model parent::__construct(); $this->dbTable = 'public.tbl_person'; $this->pk = 'person_id'; + + $this->load->model('person/kontakt_model', 'KontaktModel'); + $this->load->model('person/adresse_model', 'AdresseModel'); } /** @@ -155,29 +158,24 @@ class Person_model extends DB_Model $person = $this->load($person_id); - if($person->error) - return error($person->retval); + if($person->error) return $person; //return null if not found if(count($person->retval) < 1) return success(null); - $this->load->model('person/kontakt_model', 'KontaktModel'); - $this->load->model('person/adresse_model', 'AdresseModel'); - $this->KontaktModel->addDistinct(); $this->KontaktModel->addSelect('kontakttyp, anmerkung, kontakt, zustellung'); $this->KontaktModel->addOrder('kontakttyp'); $where = $zustellung_only === true ? array('person_id' => $person_id, 'zustellung' => true) : array('person_id' => $person_id); $kontakte = $this->KontaktModel->loadWhere($where); - if($kontakte->error) - return error($kontakte->retval); + if($kontakte->error) return $kontakte; + $where = $zustellung_only === true ? array('person_id' => $person_id, 'zustelladresse' => true) : array('person_id' => $person_id); $this->AdresseModel->addSelect('public.tbl_adresse.*, bis.tbl_nation.kurztext AS nationkurztext'); $this->AdresseModel->addJoin('bis.tbl_nation', 'tbl_adresse.nation = tbl_nation.nation_code', 'LEFT'); $adressen = $this->AdresseModel->loadWhere($where); - if($adressen->error) - return error($adressen->retval); + if($adressen->error) return $adressen; $stammdaten = $person->retval[0]; $stammdaten->kontakte = $kontakte->retval; diff --git a/application/models/ressource/Mitarbeiter_model.php b/application/models/ressource/Mitarbeiter_model.php index 1e03a0ecd..ccaeacd0d 100644 --- a/application/models/ressource/Mitarbeiter_model.php +++ b/application/models/ressource/Mitarbeiter_model.php @@ -11,4 +11,33 @@ class Mitarbeiter_model extends DB_Model $this->dbTable = 'public.tbl_mitarbeiter'; $this->pk = 'mitarbeiter_uid'; } + + /** + * Checks if the user is a Mitarbeiter. + * @param string $uid + * @param boolean null $fixangestellt + * @return array + */ + public function isMitarbeiter($uid, $fixangestellt = null) + { + $this->addSelect('1'); + + if (is_bool($fixangestellt)) + { + $result = $this->loadWhere(array('mitarbeiter_uid' => $uid, 'fixangestellt' => $fixangestellt)); + } + else // default + { + $result = $this->loadWhere(array('mitarbeiter_uid' => $uid)); + } + + if(hasData($result)) + { + return success(true); + } + else + { + return success(false); + } + } } diff --git a/application/models/system/Benutzerrolle_model.php b/application/models/system/Benutzerrolle_model.php index 13ebf57b6..765ad9bd4 100644 --- a/application/models/system/Benutzerrolle_model.php +++ b/application/models/system/Benutzerrolle_model.php @@ -11,7 +11,7 @@ class Benutzerrolle_model extends DB_Model $this->dbTable = 'system.tbl_benutzerrolle'; $this->pk = 'benutzerberechtigung_id'; } - + /** * Checks if the given user is an admin */ @@ -19,9 +19,9 @@ class Benutzerrolle_model extends DB_Model { // Join with the table tbl_benutzer $this->addJoin('public.tbl_benutzer', 'uid'); - + $result = $this->loadWhere(array('person_id' => $person_id, 'rolle_kurzbz' => 'admin')); - + if (!isError($result)) { if (hasData($result)) @@ -33,7 +33,35 @@ class Benutzerrolle_model extends DB_Model $result = success(false); } } - + return $result; } -} \ No newline at end of file + + /** + * Get user who are authorized with berechtigung and, if given, authorized for the specific organisational unit. + * @param $berechtigung_kurzbz + * @param null $oe_kurzbz + * @return array + */ + public function getBenutzerByBerechtigung($berechtigung_kurzbz, $oe_kurzbz = null) + { + $params = array(); + $query = ' + SELECT + * + FROM + system.vw_berechtigung_nichtrekursiv + WHERE + berechtigung_kurzbz = ?'; + + $params[] = $berechtigung_kurzbz; + + if (!is_null($oe_kurzbz)) + { + $query .= ' AND oe_kurzbz = ?'; + $params[] = $oe_kurzbz; + } + + return $this->execQuery($query, $params); + } +} diff --git a/application/models/system/FAS_UDF_model.php b/application/models/system/FAS_UDF_model.php new file mode 100644 index 000000000..aee49d431 --- /dev/null +++ b/application/models/system/FAS_UDF_model.php @@ -0,0 +1,169 @@ +load->model('person/Person_model', 'PersonModel'); + + $result = $this->load(array('public', 'tbl_person')); + if (isSuccess($result) && count($result->retval) == 1) + { + $jsons = json_decode($result->retval[0]->jsons); + } + + $udfs = $this->_fillMissingTextUDF($udfs, $jsons); + $udfs = $this->_fillMissingChkboxUDF($udfs, $jsons); + $udfs = $this->_fillMissingDropdownUDF($udfs, $jsons); + + $resultPerson = $this->PersonModel->update($person_id, $udfs); + } + + // + if (isset($prestudent_id)) + { + // Load model Prestudent_model + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + $result = $this->load(array('public', 'tbl_prestudent')); + if (isSuccess($result) && count($result->retval) == 1) + { + $jsons = json_decode($result->retval[0]->jsons); + } + + $udfs = $this->_fillMissingTextUDF($udfs, $jsons); + $udfs = $this->_fillMissingChkboxUDF($udfs, $jsons); + $udfs = $this->_fillMissingDropdownUDF($udfs, $jsons); + + $resultPrestudent = $this->PrestudentModel->update($prestudent_id, $udfs); + } + + if (isSuccess($resultPerson) && isSuccess($resultPrestudent)) + { + $result = success(array($resultPerson->retval, $resultPrestudent->retval)); + } + else if(isError($resultPerson)) + { + $result = $resultPerson; + } + else if(isError($resultPrestudent)) + { + $result = $resultPrestudent; + } + + return $result; + } + + /** + * + */ + private function _fillMissingChkboxUDF($udfs, $jsons) + { + $_fillMissingChkboxUDF = $udfs; + + foreach($jsons as $udfDescription) + { + if ($udfDescription->{UDFLib::TYPE} == UDFLib::CHKBOX_TYPE) + { + if (!isset($_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}])) + { + $_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] = false; + } + else + { + if ($_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] == UDF_model::STRING_FALSE) + { + $_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] = false; + } + else if ($_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] == UDF_model::STRING_TRUE) + { + $_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] = true; + } + } + } + } + + return $_fillMissingChkboxUDF; + } + + /** + * + */ + private function _fillMissingDropdownUDF($udfs, $jsons) + { + $_fillMissingDropdownUDF = $udfs; + + foreach($jsons as $udfDescription) + { + if ($udfDescription->{UDFLib::TYPE} == UDF_model::UDF_DROPDOWN_TYPE + || $udfDescription->{UDFLib::TYPE} == UDF_model::UDF_MULTIPLEDROPDOWN_TYPE) + { + if (!isset($_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}])) + { + $_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}] = null; + } + else if($_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}] == UDF_model::STRING_NULL) + { + $_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}] = null; + } + } + } + + return $_fillMissingDropdownUDF; + } + + /** + * + */ + private function _fillMissingTextUDF($udfs, $jsons) + { + $_fillMissingTextUDF = $udfs; + + foreach($jsons as $udfDescription) + { + if ($udfDescription->{UDFLib::TYPE} == 'textarea' + || $udfDescription->{UDFLib::TYPE} == 'textfield') + { + if (!isset($_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}])) + { + $_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}] = null; + } + else if(trim($_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}]) == '') + { + $_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}] = null; + } + } + } + + return $_fillMissingTextUDF; + } +} diff --git a/application/models/system/MessageToken_model.php b/application/models/system/MessageToken_model.php index bdb6136ac..cd3d8f7d9 100644 --- a/application/models/system/MessageToken_model.php +++ b/application/models/system/MessageToken_model.php @@ -37,17 +37,7 @@ class MessageToken_model extends DB_Model WHERE r.token = ? LIMIT 1'; - $result = $this->db->query($sql, array(MSG_STATUS_DELETED, $token)); - - // If no errors occurred - if ($result) - { - return success($result->result()); - } - else - { - return error($this->db->error()); - } + return $this->execQuery($sql, array(MSG_STATUS_DELETED, $token)); } /** @@ -74,25 +64,24 @@ class MessageToken_model extends DB_Model WHERE r.token = ? LIMIT 1'; - $msgs = $this->db->query($sql, array(MSG_STATUS_ARCHIVED, $token)); + $msgsResult = $this->execQuery($sql, array(MSG_STATUS_ARCHIVED, $token)); // If no errors occurred - if ($msgs) + if (isSuccess($msgsResult)) { - $msgs_result = $msgs->result(); // If at least a record is present - if (count($msgs_result) > 0) + if (hasData($msgsResult)) { - $msg = $msgs_result[0]; + $msg = getData($msgsResult)[0]; + $msgStatusResult = error(); - $msgStatusResult = false; // pessimistic expectation + $this->load->model('system/MsgStatus_model', 'MsgStatusModel'); // If the status of the message is unread if ($msg->status == MSG_STATUS_UNREAD) { // Insert the read status - $msgStatusResult = $this->db->insert( - 'public.tbl_msg_status', + $msgStatusResult = $this->MsgStatusModel->insert( array( 'message_id' => $msg->message_id, 'person_id' => $msg->receiver_id, @@ -108,31 +97,23 @@ class MessageToken_model extends DB_Model // If the status of the message is read else if ($msg->status == MSG_STATUS_READ) { - // Update updateamum to current date - $this->db->set('updateamum', 'NOW()'); - - $this->db->where('message_id', $msg->message_id); - $this->db->where('person_id', $msg->receiver_id); - $this->db->where('status', MSG_STATUS_READ); - - $msgStatusResult = $this->db->update('public.tbl_msg_status'); + $msgStatusResult = $this->MsgStatusModel->update( + array( + 'message_id' => $msg->message_id, + 'person_id' => $msg->receiver_id, + 'status' => MSG_STATUS_READ + ), + array('updateamum' => 'NOW()') + ); } - // If some of the previous DB manipulation (update or insert) has failed - if (!$msgStatusResult) - { - return error($this->db->error()); - } + return $msgStatusResult; } - - return success($msgs_result); } else { - return error($this->db->error()); + return $msgsResult; } - - return success($result->result()); } /** @@ -162,8 +143,8 @@ class MessageToken_model extends DB_Model { $sql = 'SELECT m.mitarbeiter_uid FROM public.tbl_person p - LEFT JOIN public.tbl_benutzer b USING(person_id) - LEFT JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) + JOIN public.tbl_benutzer b USING(person_id) + JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) WHERE p.person_id = ? AND b.aktiv = TRUE'; @@ -193,28 +174,6 @@ class MessageToken_model extends DB_Model LIMIT 1 '; - $result = $this->db->query($sql, array($oe_kurzbz)); - if ($result) // If no errors occurred - { - $result_arr = $result->result(); - // If data are present - if (is_array($result_arr) - && count($result_arr) > 0 - && is_object($result_arr[0]) - && isset($result_arr[0]->oe_kurzbz)) - { - return success($result_arr[0]->oe_kurzbz); - } - else - { - return error(); - } - } - else - { - return error($this->db->error()); - } - - return $result; + return $this->execQuery($sql, array($oe_kurzbz)); } } diff --git a/application/models/system/PersonLock_model.php b/application/models/system/PersonLock_model.php index 1d106b789..f0aadd327 100644 --- a/application/models/system/PersonLock_model.php +++ b/application/models/system/PersonLock_model.php @@ -29,8 +29,7 @@ class PersonLock_model extends DB_Model $result = $this->loadWhere($lockdata); - if ($result->error) - return error($result->retval); + if ($result->error) return $result; if (count($result->retval) > 0) return success($result->retval); @@ -49,8 +48,7 @@ class PersonLock_model extends DB_Model { $locked = $this->checkIfLocked($person_id, $app); - if ($locked->error) - return error($locked->retval); + if ($locked->error) return $locked; //insert only if not already locked if ($locked->retval === null) @@ -77,8 +75,7 @@ class PersonLock_model extends DB_Model foreach ($locks->retval as $lock) { $result = $this->delete($lock->lock_id); - if ($result->error) - return error($result->retval); + if ($result->error) return $result; $deleted[] = $lock; } diff --git a/application/models/system/UDF_model.php b/application/models/system/UDF_model.php index 5efb061d1..6923d1733 100644 --- a/application/models/system/UDF_model.php +++ b/application/models/system/UDF_model.php @@ -2,14 +2,6 @@ class UDF_model extends DB_Model { - // String values of booleans - const STRING_NULL = 'null'; - const STRING_TRUE = 'true'; - const STRING_FALSE = 'false'; - - const UDF_DROPDOWN_TYPE = 'dropdown'; - const UDF_MULTIPLEDROPDOWN_TYPE = 'multipledropdown'; - /** * Constructor */ @@ -38,164 +30,4 @@ class UDF_model extends DB_Model return $udfResults; } - - // ------------------------------------------------------------------------------------ - // These methods work only with the this version of FAS, not with the future versions - - /** - * Methods to save data from FAS - */ - public function saveUDFs($udfs) - { - $result = error('No way man!'); - $resultPerson = success('person'); - $resultPrestudent = success('prestudent'); - - $person_id = null; - if (isset($udfs['person_id'])) $person_id = $udfs['person_id']; - unset($udfs['person_id']); - - $prestudent_id = null; - if (isset($udfs['prestudent_id'])) $prestudent_id = $udfs['prestudent_id']; - unset($udfs['prestudent_id']); - - $jsons = array(); - - // - if (isset($person_id)) - { - // Load model Person_model - $this->load->model('person/Person_model', 'PersonModel'); - - $result = $this->load(array('public', 'tbl_person')); - if (isSuccess($result) && count($result->retval) == 1) - { - $jsons = json_decode($result->retval[0]->jsons); - } - - $udfs = $this->_fillMissingTextUDF($udfs, $jsons); - $udfs = $this->_fillMissingChkboxUDF($udfs, $jsons); - $udfs = $this->_fillMissingDropdownUDF($udfs, $jsons); - - $resultPerson = $this->PersonModel->update($person_id, $udfs); - } - - // - if (isset($prestudent_id)) - { - // Load model Prestudent_model - $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - - $result = $this->load(array('public', 'tbl_prestudent')); - if (isSuccess($result) && count($result->retval) == 1) - { - $jsons = json_decode($result->retval[0]->jsons); - } - - $udfs = $this->_fillMissingTextUDF($udfs, $jsons); - $udfs = $this->_fillMissingChkboxUDF($udfs, $jsons); - $udfs = $this->_fillMissingDropdownUDF($udfs, $jsons); - - $resultPrestudent = $this->PrestudentModel->update($prestudent_id, $udfs); - } - - if (isSuccess($resultPerson) && isSuccess($resultPrestudent)) - { - $result = success(array($resultPerson->retval, $resultPrestudent->retval)); - } - else if(isError($resultPerson)) - { - $result = $resultPerson; - } - else if(isError($resultPrestudent)) - { - $result = $resultPrestudent; - } - - return $result; - } - - /** - * - */ - private function _fillMissingChkboxUDF($udfs, $jsons) - { - $_fillMissingChkboxUDF = $udfs; - - foreach($jsons as $udfDescription) - { - if ($udfDescription->{UDFLib::TYPE} == UDFLib::CHKBOX_TYPE) - { - if (!isset($_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}])) - { - $_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] = false; - } - else - { - if ($_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] == UDF_model::STRING_FALSE) - { - $_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] = false; - } - else if ($_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] == UDF_model::STRING_TRUE) - { - $_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] = true; - } - } - } - } - - return $_fillMissingChkboxUDF; - } - - /** - * - */ - private function _fillMissingDropdownUDF($udfs, $jsons) - { - $_fillMissingDropdownUDF = $udfs; - - foreach($jsons as $udfDescription) - { - if ($udfDescription->{UDFLib::TYPE} == UDF_model::UDF_DROPDOWN_TYPE - || $udfDescription->{UDFLib::TYPE} == UDF_model::UDF_MULTIPLEDROPDOWN_TYPE) - { - if (!isset($_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}])) - { - $_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}] = null; - } - else if($_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}] == UDF_model::STRING_NULL) - { - $_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}] = null; - } - } - } - - return $_fillMissingDropdownUDF; - } - - /** - * - */ - private function _fillMissingTextUDF($udfs, $jsons) - { - $_fillMissingTextUDF = $udfs; - - foreach($jsons as $udfDescription) - { - if ($udfDescription->{UDFLib::TYPE} == 'textarea' - || $udfDescription->{UDFLib::TYPE} == 'textfield') - { - if (!isset($_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}])) - { - $_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}] = null; - } - else if(trim($_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}]) == '') - { - $_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}] = null; - } - } - } - - return $_fillMissingTextUDF; - } } diff --git a/application/models/system/Variable_model.php b/application/models/system/Variable_model.php index 9800999fe..1fcb5b274 100644 --- a/application/models/system/Variable_model.php +++ b/application/models/system/Variable_model.php @@ -10,5 +10,92 @@ class Variable_model extends DB_Model parent::__construct(); $this->dbTable = 'public.tbl_variable'; $this->pk = array('uid', 'name'); + $this->hasSequence = false; + + $this->load->model('system/Variablenname_model', 'VariablennameModel'); + } + + /** + * Gets user variables and values for a uid. + * If no value found in tbl_variable, default as defined in variablename_model is retrieved. + * @param $uid + * @param null $names optionally get only certain variables + * @return array + */ + public function getVariables($uid, $names = null) + { + if (isEmptyString($uid) || (isset($names) && !is_array($names))) + $result = error('wrong parameters passed'); + else + { + $vardata = array(); + + $qry = "SELECT name, wert FROM public.tbl_variable WHERE uid = ?"; + + if (isset($names)) + { + $qry .= " AND name IN ('".implode(',', $names)."')"; + } + $qry .= ";"; + + $varresults = $this->execQuery($qry, array($uid)); + + if (hasData($varresults)) + { + $varresults = getData($varresults); + foreach ($varresults as $varresult) + { + if (isset($varresult->wert)) + $vardata[$varresult->name] = $varresult->wert; + } + } + + $vardefaults = $this->VariablennameModel->getDefaults($names); + + if (hasData($vardefaults)) + { + $vardefaults = getData($vardefaults); + + + foreach ($vardefaults as $vardefault) + { + if (!isset($vardata[$vardefault->name]) && isset($vardefault->defaultwert)) + { + $vardata[$vardefault->name] = $vardefault->defaultwert; + } + } + } + $result = success($vardata); + } + + return $result; + } + + /** + * Sets a variable value for a uid. Adds new entry if not present, updates entry otherwise. + * @param $uid + * @param $name + * @param $wert + * @return array + */ + public function setVariable($uid, $name, $wert) + { + $result = error('error when setting variable!'); + if (!isEmptyString($uid) && !isEmptyString($name) && !isEmptyString($wert)) + { + $varres = $this->loadWhere(array('uid' => $uid, 'name' => $name)); + + if (isSuccess($varres)) + { + if (hasData($varres)) + { + $result = $this->VariableModel->update(array('uid' => $uid, 'name' => $name), array('wert' => $wert)); + } + else + $result = $this->VariableModel->insert(array('uid' => $uid, 'name' => $name, 'wert' => $wert)); + } + } + + return $result; } } diff --git a/application/models/system/Variablenname_model.php b/application/models/system/Variablenname_model.php new file mode 100644 index 000000000..7b2a2cf88 --- /dev/null +++ b/application/models/system/Variablenname_model.php @@ -0,0 +1,78 @@ + 'SELECT studiensemester_kurzbz FROM public.tbl_studiensemester WHERE ende>now() ORDER BY start LIMIT 1', + 'infocenter_studiensemester' => 'SELECT studiensemester_kurzbz FROM ( + SELECT DISTINCT ON (studienjahr_kurzbz) start, studiensemester_kurzbz + FROM public.tbl_studiensemester + ORDER BY studienjahr_kurzbz, start + ) sem + WHERE start > now() + LIMIT 1;' + ); + + /** + * Constructor + */ + public function __construct() + { + parent::__construct(); + $this->dbTable = 'public.tbl_variablenname'; + $this->pk ='name'; + } + + /** + * Gets defaults for user variables. + * If no default value present in table, SQL can be executed for retrieving the value. + * @param $names optionally get only defaults for certain variables + * @return array + */ + public function getDefaults($names = null) + { + $defaults = array(); + + $qry = "SELECT name, defaultwert FROM public.tbl_variablenname"; + + if (!isEmptyArray($names)) + { + $qry .= " WHERE name IN ?"; + } + $qry .= ";"; + + $defaultsres = $this->execQuery($qry, array('name' => $names)); + + if (hasData($defaultsres)) + { + $defaults = getData($defaultsres); + + foreach ($defaults as $default) + { + if (!isset($default->defaultwert)) + { + if (isset($this->_dynamic_defaults[$default->name])) + { + $dyndefault = $this->execQuery($this->_dynamic_defaults[$default->name]); + if (hasData($dyndefault)) + { + $dyndefault = getData($dyndefault); + + if (count($dyndefault) === 1) + { + foreach ($dyndefault[0] as $value) + { + $default->defaultwert = $value; + break; + } + } + } + } + } + } + } + + return success($defaults); + } +} diff --git a/application/models/system/Webservicelog_model.php b/application/models/system/Webservicelog_model.php index dc45b13a7..a5b23a396 100644 --- a/application/models/system/Webservicelog_model.php +++ b/application/models/system/Webservicelog_model.php @@ -1,13 +1,14 @@ dbTable = 'system.tbl_webservicelog'; $this->pk = 'webservicelog_id'; } diff --git a/application/views/home.php b/application/views/home.php index d00b98f81..79669dd88 100644 --- a/application/views/home.php +++ b/application/views/home.php @@ -3,6 +3,7 @@ $this->load->view('templates/FHC-Header', array( 'title' => 'FH-Complete', 'jquery' => true, + 'jqueryui' => true, 'bootstrap' => true, 'fontawesome' => true, 'sbadmintemplate' => true, diff --git a/application/views/lehre/lehrauftrag/Dashboard.php b/application/views/lehre/lehrauftrag/Dashboard.php new file mode 100644 index 000000000..a14cefa7a --- /dev/null +++ b/application/views/lehre/lehrauftrag/Dashboard.php @@ -0,0 +1,38 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Lehrauftrag bestellen', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'navigationwidget' => true, + 'addons' => true, + ) +); +?> + + + widgetlib->widget('NavigationWidget'); ?> +
+
+ +
+
+ +
+
+ +
+ +
+
+ + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/lehrauftrag/LehrendeUebersicht.php b/application/views/lehre/lehrauftrag/LehrendeUebersicht.php new file mode 100644 index 000000000..1ad295392 --- /dev/null +++ b/application/views/lehre/lehrauftrag/LehrendeUebersicht.php @@ -0,0 +1,39 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Lehrauftrag bestellen', + 'jquery' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'ajaxlib' => true, + 'navigationwidget' => true, + ) +); +?> + + +widgetlib->widget('NavigationWidget'); ?> +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/lehrauftrag/acceptLehrauftrag.php b/application/views/lehre/lehrauftrag/acceptLehrauftrag.php new file mode 100644 index 000000000..14ebacecb --- /dev/null +++ b/application/views/lehre/lehrauftrag/acceptLehrauftrag.php @@ -0,0 +1,204 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Lehrauftrag annehmen', + 'jquery' => true, + 'jqueryui' => true, + 'jquerycheckboxes' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => false, + 'tabulator' => true, + 'momentjs' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tablewidget' => true, + 'phrases' => array( + 'global' => array('lehrauftraegeAnnehmen'), + ), + 'customJSs' => array( + 'public/js/bootstrapper.js', + 'public/js/lehre/lehrauftrag/acceptLehrauftrag.js') + ) +); + +?> + + +
+
+ + +
+ +
+ + +
+
+
+

Wie nehme ich Lehraufträge an?

+
+ Sobald Ihnen ein oder mehrere Lehraufträge erteilt wurden, können Sie diese annehmen. +
    +
  1. Klicken Sie unten auf das Status-Icon 'Nur erteilte anzeigen' oder 'Alle anzeigen'
  2. +
  3. Wählen Sie die Lehraufträge, die Sie annehmen möchten, selbst oder alle über den Button 'Alle auswählen'.
  4. +
  5. Geben Sie Ihr CIS-Passwort ein und klicken auf Lehrauftrag annehmen.
  6. +
+
+
+ +

Warum kann ich manche Lehraufträge nicht auswählen?

+
+ Nur Lehraufträge mit dem Status 'erteilt' können gewählt werden.
+ Angenommene Lehraufträge oder Lehraufträge in Bearbeitung werden nur zu Ihrer Information angezeigt. +
+
+ +

Filter

+
+
+ + + + + + + + + + + + + +
Alle
Alle Lehraufträge mit jedem Status
Bestellt
Nur bestellte UND bestellte Lehraufträge, die in Bearbeitung sind
Erteilt
Nur erteilte UND geänderte Lehraufträge, die in Bearbeitung sind
Angenommen
Nur von Ihnen angenommene Lehraufträge
+
+
+
+ +

Auswahl

+
+
    +
  • Einzeln auswählen: Strg + Klick auf einzelne Zeile(n)
  • +
  • Bereich auswählen: Shift + Klick auf Anfangs- und Endzeile
  • +
  • Alle auswählen: Button 'Alle auswählen'
  • +
+
+
+ +

Ansicht

+
+ Spaltenbreite verändern +

+ Um die Spaltenbreite zu verändern, fährt man im Spaltenkopf langsam mit dem Mauszeiger auf + den rechten Rand der entprechenden Spalte.
+ Sobald sich der Mauszeiger in einen Doppelpfeil verwandelt, wird die Maustaste geklickt und + mit gedrückter Maustaste die Spalte nach rechts erweitert oder nach links verkleinert. +

+
+
+
+
+
+ + +
+
+
+
+ widgetlib->widget( + 'Studiensemester_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $studiensemester_selected + ), + array( + 'name' => 'studiensemester', + 'id' => 'studiensemester' + ) + ); + ?> +
+ +
+
+
+ + +
+
+ load->view('lehre/lehrauftrag/acceptLehrauftragData.php'); ?> +
+
+
+ + +
+
+ +
+
+
+ + + + +
+
+
+
+
+ + +
+
+

+ p->t('global', 'stornierteLehrauftraege')); ?>: + + + + + +

+
+
+ load->view('lehre/lehrauftrag/cancelledLehrauftragData.php'); ?> +
+
+
+
+
+
+
+
+ + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/lehrauftrag/acceptLehrauftragData.php b/application/views/lehre/lehrauftrag/acceptLehrauftragData.php new file mode 100644 index 000000000..704ce5861 --- /dev/null +++ b/application/views/lehre/lehrauftrag/acceptLehrauftragData.php @@ -0,0 +1,398 @@ + $query, + 'tableUniqueId' => 'acceptLehrauftrag', + 'requiredPermissions' => 'lehre/lehrauftrag_akzeptieren', + 'datasetRepresentation' => 'tabulator', + 'columnsAliases' => array( // TODO: use phrasen + 'Status', // alias for row_index, because row_index is formatted to display the status icons + 'LV-Teil', + 'LV-ID', + 'PA-ID', + 'Studiensemester', + 'Studiengang-KZ', + 'Studiengang', + 'Semester', + 'OrgForm', + 'Person-ID', + 'Typ', + 'LV- / Projektbezeichnung', + 'Organisationseinheit', + 'Gruppe', + 'Stunden', + 'Betrag', + 'Vertrag-ID', + 'Vertrag-Stunden', + 'Vertrag-Betrag', + 'UID', + 'Bestellt', + 'Erteilt', + 'Angenommen', + 'Bestellt von', + 'Erteilt von', + 'Angenommen von' + ), + 'datasetRepOptions' => '{ + height: 550, + layout: "fitColumns", // fit columns to width of table + responsiveLayout: "hide", // hide columns that dont fit on the table + movableColumns: true, // allows changing column + placeholder: func_placeholder(), + headerFilterPlaceholder: " ", + index: "row_index", // assign specific column as unique id (important for row indexing) + selectable: true, // allow row selection + selectableRangeMode: "click", // allow range selection using shift end click on end of range + selectablePersistence:false, // deselect previously selected rows when table is filtered, sorted or paginated + selectableCheck: function(row){ + return func_selectableCheck(row); + }, + footerElement: func_footerElement(), + rowUpdated:function(row){ + func_rowUpdated(row); + }, + rowSelectionChanged:function(data, rows){ + func_rowSelectionChanged(data, rows); + }, + rowFormatter:function(row){ + func_rowFormatter(row); + }, + tableBuilt: function(){ + func_tableBuilt(this); + }, + renderComplete:function(){ + func_renderComplete(this); + }, + renderStarted:function(){ + func_renderStarted(this); + } + }', // tabulator properties + 'datasetRepFieldsDefs' => '{ + row_index: {visible:false}, // necessary for row indexing + lehreinheit_id: {headerFilter:"input", bottomCalc:"count", bottomCalcFormatter:function(cell){return "Anzahl: " + cell.getValue();}, width: "7%"}, + lehrveranstaltung_id: {headerFilter:"input", width: "5%"}, + projektarbeit_id: {visible: false}, + studiensemester_kurzbz: {visible: false}, + studiengang_kz: {visible: false}, + stg_typ_kurzbz: {headerFilter:"input", width: "5%"}, + semester: {headerFilter:"input"}, + orgform_kurzbz: {headerFilter:"input"}, + person_id: {visible: false}, + typ: {headerFilter:"input", width: "7%"}, + auftrag: {headerFilter:"input", width: "15%"}, + lv_oe_kurzbz: {headerFilter:"input", width: "8%"}, + gruppe: {headerFilter:"input", width: "5%"}, + stunden: {align:"right", formatter: form_formatNulltoStringNumber, formatterParams:{precision:1}, + headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator, + bottomCalc:"sum", bottomCalcParams:{precision:1}, width: "5%"}, + betrag: {align:"right", width: "6%", formatter: form_formatNulltoStringNumber, + headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator, + bottomCalc:"sum", bottomCalcParams:{precision:2}, bottomCalcFormatter:"money", bottomCalcFormatterParams:{decimal: ",", thousand: ".", symbol:"€"}, + width: "8%"}, + vertrag_id: {visible: false}, + vertrag_stunden: {visible: false}, + vertrag_betrag: {visible: false}, + mitarbeiter_uid: {visible: false}, + bestellt: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: bestellt_tooltip, width: "8%"}, + erteilt: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: erteilt_tooltip, width: "8%"}, + akzeptiert: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: akzeptiert_tooltip, width: "8%"}, + bestellt_von: {visible: false}, + erteilt_von: {visible: false}, + akzeptiert_von: {visible: false} + }', // col properties +); + +echo $this->widgetlib->widget('TableWidget', $filterWidgetArray); + +?> diff --git a/application/views/lehre/lehrauftrag/approveLehrauftrag.php b/application/views/lehre/lehrauftrag/approveLehrauftrag.php new file mode 100644 index 000000000..f36ae7dc7 --- /dev/null +++ b/application/views/lehre/lehrauftrag/approveLehrauftrag.php @@ -0,0 +1,240 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Lehrauftrag erteilen', + 'jquery' => true, + 'jqueryui' => true, + 'jquerycheckboxes' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'tabulator' => true, + 'momentjs' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tablewidget' => true, + 'navigationwidget' => true, + 'phrases' => array( + 'global' => array('lehrauftraegeErteilen'), + ), + 'customJSs' => array( + 'public/js/bootstrapper.js', + 'public/js/lehre/lehrauftrag/approveLehrauftrag.js' + ) + ) +); + +?> + + + widgetlib->widget('NavigationWidget'); ?> +
+
+ + +
+ +
+ + +
+
+
+ +

Lehrauftrag Standard-Bestellprozess

+
+ + + + + + + + + + + + + + + +
BESTELLEN
(Studiengangsleitung)
ERTEILEN
(Department-/Kompetenzfeldleitung)
ANNEHMEN
(LektorIn)
+
+
+ +

Lehraufträge erteilen

+
+ Sobald Lehraufträge bestellt wurden, können Sie diese hier erteilen.
+ Erteilte Lehraufträge können von den Lehrenden angenommen werden.
+
    +
  1. Klicken Sie unten auf das Status-Icon 'Nur bestellte anzeigen' oder 'Alle anzeigen'
  2. +
  3. Wählen Sie die zu erteilenden Lehraufträge selbst oder alle über den Button 'Alle auswählen'.
  4. +
  5. Klicken Sie auf Lehrauftrag erteilen.
  6. +
+
+
+ +

Geänderte Lehraufträge

+
+ Im FAS können Änderungen an Stunden/Stundensatz eines Lehrauftrags durchgeführt werden, solange dieser nicht vom Lehrenden angenommen wurde.
+ Wenn Änderungen an bereits bestellten oder erteilten Lehraufträgen vorgenommen wurden, müssen diese vom Studiengang erneut bestellt werden.
+ Bei bereits erteilten Lehraufträgen wird zusätzlich der Status 'erteilt' zurückgesetzt. +
+
+ +

Warum kann ich manche Lehraufträge nicht auswählen?

+
+ Nur Lehraufträge mit dem Status 'bestellt' können gewählt werden.
+ Neue, Bestellte, Akzeptierte oder geänderte Lehraufträge werden nur zu Ihrer Information angezeigt und sind daher NICHT wählbar. +
+
+ +

Filter

+
+ + + + + + + + + + + + + + + + + + + + +
Alle
Alle Lehraufträge mit jedem Status, auch geänderte und Dummy-Aufträge
Neu
Nur Lehraufträge, die im FAS über die Zuteilung eines Lehrenden zu einer Lehreinheit/einem Projekt angelegt und noch nicht bestellt worden sind
Bestellt
Nur bestellte UND geänderte bestellte Lehraufträge
Erteilt
Nur erteilte UND geänderte erteilte Lehraufträge
Angenommen
Nur vom Lehrenden angenommene Lehraufträge
Geändert
Nur Lehraufträge, die geändert wurden, nachdem sie bereits bestellt oder erteilt worden sind
Dummies
Nur Lehraufträge, die mit einem Dummylektor angelegt sind
+
+
+ +

Auswahl

+
+
    +
  • Einzeln auswählen: Strg + Klick auf einzelne Zeile(n)
  • +
  • Bereich auswählen: Shift + Klick auf Anfangs- und Endzeile
  • +
  • Alle auswählen: Button 'Alle auswählen'
  • +
+
+
+ +

Ansicht

+
+ Spaltenbreite verändern +

+ Um die Spaltenbreite zu verändern, fährt man im Spaltenkopf langsam mit dem Mauszeiger auf + den rechten Rand der entprechenden Spalte.
+ Sobald sich der Mauszeiger in einen Doppelpfeil verwandelt, wird die Maustaste geklickt und + mit gedrückter Maustaste die Spalte nach rechts erweitert oder nach links verkleinert. +

+
+
+ +
+
+
+ + +
+
+
+
+ widgetlib->widget( + 'Studiensemester_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $studiensemester_selected + ), + array( + 'name' => 'studiensemester', + 'id' => 'studiensemester' + ) + ); + ?> +
+
+ widgetlib->widget( + 'Organisationseinheit_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $organisationseinheit_selected, + 'organisationseinheit' => $organisationseinheit + ), + array( + 'name' => 'organisationseinheit', + 'id' => 'organisationseinheit' + ) + ); + ?> +
+
+ widgetlib->widget( + 'Ausbildungssemester_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $ausbildungssemester_selected, + 'number_semester' => 6 + ), + array( + 'name' => 'ausbildungssemester', + 'id' => 'ausbildungssemester' + ) + ); + ?> +
+ +
+
+
+ + +
+
+ load->view('lehre/lehrauftrag/approveLehrauftragData.php'); ?> +
+
+
+ + +
+
+ + +
+
+ +
+
+
+ + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/lehrauftrag/approveLehrauftragData.php b/application/views/lehre/lehrauftrag/approveLehrauftragData.php new file mode 100644 index 000000000..4db115626 --- /dev/null +++ b/application/views/lehre/lehrauftrag/approveLehrauftragData.php @@ -0,0 +1,418 @@ + $query, + 'tableUniqueId' => 'approveLehrauftrag', + 'requiredPermissions' => 'lehre/lehrauftrag_erteilen', + 'datasetRepresentation' => 'tabulator', + 'columnsAliases' => array( // TODO: use phrasen + 'Status', // alias for row_index, because row_index is formatted to display the status icons + 'Personalnummer', + 'LV-Teil', + 'LV-ID', + 'LV', + 'PA-ID', + 'Studiensemester', + 'Studiengang-KZ', + 'Studiengang', + 'Semester', + 'OrgForm', + 'Person-ID', + 'Typ', + 'LV- / Projektbezeichnung', + 'Organisationseinheit', + 'Gruppe', + 'Lektor', + 'Stunden', + 'Betrag', + 'Vertrag-ID', + 'Vertrag-Stunden', + 'Vertrag-Betrag', + 'UID', + 'Bestellt', + 'Erteilt', + 'Angenommen', + 'Bestellt von', + 'Erteilt von', + 'Angenommen von' + ), + 'datasetRepOptions' => '{ + height: 700, + layout: "fitColumns", // fit columns to width of table + responsiveLayout: "hide", // hide columns that dont fit on the table + movableColumns: true, // allows changing column + placeholder: func_placeholder(), + headerFilterPlaceholder: " ", + groupBy:"lehrveranstaltung_id", + groupToggleElement:"header", //toggle group on click anywhere in the group header + groupHeader: function(value, count, data, group){ + return func_groupHeader(data); + }, + columnCalcs:"both", // show column calculations at top and bottom of table and in groups + index: "row_index", // assign specific column as unique id (important for row indexing) + selectable: true, // allow row selection + selectableRangeMode: "click", // allow range selection using shift end click on end of range + selectablePersistence:false, // deselect previously selected rows when table is filtered, sorted or paginated + selectableCheck: function(row){ + return func_selectableCheck(row); + }, + initialFilter: func_initialFilter(), + footerElement: func_footerElement(), + rowUpdated:function(row){ + func_rowUpdated(row); + }, + rowSelectionChanged:function(data, rows){ + func_rowSelectionChanged(data, rows); + }, + rowFormatter:function(row) + { + func_rowFormatter(row); + }, + renderStarted:function(){ + func_renderStarted(this); + }, + tableBuilt: function(){ + func_tableBuilt(this); + } + }', // tabulator properties + 'datasetRepFieldsDefs' => '{ + // column status is built dynamically in funcTableBuilt(), + row_index: {visible:false}, // necessary for row indexing + personalnummer: {visible: false}, + lehreinheit_id: {headerFilter:"input", bottomCalc:"count", width: "7%", + bottomCalcFormatter:function(cell){return "Anzahl: " + cell.getValue();},}, + lehrveranstaltung_id: {headerFilter:"input"}, + lv_bezeichnung: {visible: false}, + projektarbeit_id: {visible: false}, + studiensemester_kurzbz: {headerFilter:"input"}, + studiengang_kz: {visible: false}, + stg_typ_kurzbz: {headerFilter:"input", width: "5%"}, + semester: {headerFilter:"input"}, + orgform_kurzbz: {headerFilter:"input"}, + person_id: {visible: false}, + typ: {headerFilter:"input"}, + auftrag: {headerFilter:"input", width:"20%"}, + lv_oe_kurzbz: {headerFilter:"input"}, + gruppe: {headerFilter:"input"}, + lektor: {headerFilter:"input", widthGrow: 3}, + stunden: {align:"right", formatter: form_formatNulltoStringNumber, formatterParams:{precision:1}, + headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator, + bottomCalc:"sum", bottomCalcParams:{precision:1}}, + betrag: {align:"right", width: "8%", formatter: form_formatNulltoStringNumber, + headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator, + bottomCalc:"sum", bottomCalcParams:{precision:2}, bottomCalcFormatter:"money", bottomCalcFormatterParams:{decimal: ",", thousand: ".", symbol:"€"}}, + vertrag_id: {visible: false}, + vertrag_stunden: {visible: false}, + vertrag_betrag: {visible: false}, + mitarbeiter_uid: {visible: false}, + bestellt: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: bestellt_tooltip, width: "8%"}, + erteilt: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: erteilt_tooltip, width: "8%"}, + akzeptiert: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: akzeptiert_tooltip, width: "8%"}, + bestellt_von: {visible: false}, + erteilt_von: {visible: false}, + akzeptiert_von: {visible: false}, + }', // col properties +); + +echo $this->widgetlib->widget('TableWidget', $filterWidgetArray); + +?> diff --git a/application/views/lehre/lehrauftrag/cancelledLehrauftragData.php b/application/views/lehre/lehrauftrag/cancelledLehrauftragData.php new file mode 100644 index 000000000..d5af1b081 --- /dev/null +++ b/application/views/lehre/lehrauftrag/cancelledLehrauftragData.php @@ -0,0 +1,104 @@ + $query, + 'tableUniqueId' => 'cancelledLehrauftrag', + 'requiredPermissions' => 'lehre/lehrauftrag_akzeptieren', + 'datasetRepresentation' => 'tabulator', + 'columnsAliases' => array( // TODO: use phrasen + 'Status', + 'Studiensemester', + 'Typ', + 'LV- / Projektbezeichnung', + 'Stunden', + 'Betrag', + 'Storniert am' + ), + 'datasetRepOptions' => '{ + layout: "fitColumns", // fit columns to width of table + responsiveLayout: "hide", // hide columns that dont fit on the table + movableColumns: true, // allows changing column + placeholder: func_placeholder(), + rowFormatter:function(row){ + func_rowFormatter(row); + }, + selectableCheck: function(row){ + return func_selectableCheck(row); + }, + renderComplete:function(){ + func_renderComplete(this); + }, + tableBuilt: function(){ + func_tableBuilt(this); + } + }', // tabulator properties + 'datasetRepFieldsDefs' => '{ + vertrag_id: {visible: false}, + vertragsstunden_studiensemester_kurzbz: {visible: false}, + vertragstyp_kurzbz: {widthGrow: 2}, + bezeichnung: {widthGrow: 2}, + vertragsstunden: { + align:"right", formatter: form_formatNulltoStringNumber, formatterParams:{precision:1}, + bottomCalc:"sum", bottomCalcParams:{precision:1} + }, + betrag: { + align:"right", formatter: form_formatNulltoStringNumber, + bottomCalc:"sum", bottomCalcParams:{precision:2}, bottomCalcFormatter:"money", bottomCalcFormatterParams:{decimal: ",", thousand: ".", symbol:"€"} + }, + storniert: {align:"center", mutator: mut_formatStringDate, tooltip: storniert_tooltip}, + storniert_von: {visible: false}, + letzterStatus_vorStorniert: {visible: false} + }', // col properties +); + +echo $this->widgetlib->widget('TableWidget', $tableWidgetArray); + +?> diff --git a/application/views/lehre/lehrauftrag/orderLehrauftrag.php b/application/views/lehre/lehrauftrag/orderLehrauftrag.php new file mode 100644 index 000000000..b04aa7985 --- /dev/null +++ b/application/views/lehre/lehrauftrag/orderLehrauftrag.php @@ -0,0 +1,242 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Lehrauftrag bestellen', + 'jquery' => true, + 'jqueryui' => true, + 'jquerycheckboxes' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'tabulator' => true, + 'momentjs' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tablewidget' => true, + 'navigationwidget' => true, + 'phrases' => array( + 'global' => array('lehrauftraegeBestellen'), + ), + 'customJSs' => array( + 'public/js/bootstrapper.js', + 'public/js/lehre/lehrauftrag/orderLehrauftrag.js' + ) + ) +); +?> + + + widgetlib->widget('NavigationWidget'); ?> +
+
+ + +
+ +
+ + +
+
+
+ +

Lehrauftrag Standard-Bestellprozess

+
+ + + + + + + + + + + + + + + +
BESTELLEN
(Studiengangsleitung)
ERTEILEN
(Department-/Kompetenzfeldleitung)
ANNEHMEN
(LektorIn)
+
+
+ +

Lehraufträge bestellen

+
+ Sobald im FAS ein Lehrauftrag/eine Projektbetreuung angelegt wurde, können Sie diese hier bestellen.
+ Bestellte Lehraufträge sind zur Erteilung freigegeben.
+
    +
  1. Klicken Sie unten auf das Status-Icon 'Nur neue anzeigen', 'Nur geänderte anzeigen' oder 'Alle anzeigen'
  2. +
  3. Wählen Sie die zu bestellenden Lehraufträge selbst oder über den Button 'Alle auswählen'.
  4. +
  5. Klicken Sie auf Lehrauftrag bestellen.
  6. +
+ Für jeden bestellten Lehrauftrag legt das System einen Vertrag an. +
+
+ +

Geänderte Lehraufträge

+
+ Im FAS können Änderungen an Stunden/Stundensatz eines Lehrauftrags durchgeführt werden, solange dieser nicht vom Lehrenden angenommen wurde.
+ Diese müssen dann erneut bestellt werden.

+ Wenn Änderungen an bereits bestellten oder erteilten Lehraufträgen vorgenommen wurden, werden diese in einem tooltip angezeigt.
+ Fahren Sie dazu mit der Maus über dem Status-Icon am Beginn der Zeile.
+
+
+ +

Warum kann ich manche Lehraufträge nicht auswählen?

+
+ Nur Lehraufträge mit dem Status 'neu' und 'geändert' können bestellt werden.
+ Erteilte oder akzeptierte Lehraufträge werden nur zu Ihrer Information angezeigt und sind daher NICHT wählbar. +
+
+ +

Filter

+
+ + + + + + + + + + + + + + + + + + + + +
Alle
Alle Lehraufträge mit jedem Status, auch geänderte und Dummy-Aufträge
Neu
Nur Lehraufträge, die im FAS über die Zuteilung eines Lehrenden zu einer Lehreinheit/einem Projekt angelegt und noch nicht bestellt worden sind
Bestellt
Nur bestellte UND geänderte bestellte Lehraufträge
Erteilt
Nur erteilte UND geänderte erteilte Lehraufträge
Angenommen
Nur vom Lehrenden angenommene Lehraufträge
Geändert
Nur Lehraufträge, die geändert wurden, nachdem sie bereits bestellt oder erteilt worden sind
Dummies
Nur Lehraufträge, die mit einem Dummylektor angelegt sind
+
+
+ +

Auswahl

+
+
    +
  • Einzeln auswählen: Strg + Klick auf einzelne Zeile(n)
  • +
  • Bereich auswählen: Shift + Klick auf Anfangs- und Endzeile
  • +
  • Alle auswählen: Button 'Alle auswählen'
  • +
+
+
+ +

Ansicht

+
+ Spaltenbreite verändern +

+ Um die Spaltenbreite zu verändern, fährt man im Spaltenkopf langsam mit dem Mauszeiger auf + den rechten Rand der entprechenden Spalte.
+ Sobald sich der Mauszeiger in einen Doppelpfeil verwandelt, wird die Maustaste geklickt und + mit gedrückter Maustaste die Spalte nach rechts erweitert oder nach links verkleinert. +

+
+
+ +
+
+
+ + +
+
+
+
+ widgetlib->widget( + 'Studiensemester_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $studiensemester_selected + ), + array( + 'name' => 'studiensemester', + 'id' => 'studiensemester' + ) + ); + ?> +
+
+ widgetlib->widget( + 'Studiengang_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $studiengang_selected, + 'studiengang' => $studiengang + ), + array( + 'name' => 'studiengang', + 'id' => 'studiengang' + ) + ); + ?> +
+
+ widgetlib->widget( + 'Ausbildungssemester_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $ausbildungssemester_selected, + 'number_semester' => 6 + ), + array( + 'name' => 'ausbildungssemester', + 'id' => 'ausbildungssemester' + ) + ); + ?> +
+ +
+
+
+ + +
+
+ load->view('lehre/lehrauftrag/orderLehrauftragData.php'); ?> +
+
+
+ + +
+
+ + +
+
+ +
+
+
+ + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/lehrauftrag/orderLehrauftragData.php b/application/views/lehre/lehrauftrag/orderLehrauftragData.php new file mode 100644 index 000000000..66468e541 --- /dev/null +++ b/application/views/lehre/lehrauftrag/orderLehrauftragData.php @@ -0,0 +1,456 @@ + $query, + 'tableUniqueId' => 'orderLehrauftrag', + 'requiredPermissions' => 'lehre/lehrauftrag_bestellen', + 'datasetRepresentation' => 'tabulator', + 'columnsAliases' => array( // TODO: use phrasen + 'Status', // alias for row_index, because row_index is formatted to display the status icons + 'Personalnummer', + 'LV-Teil', + 'LV-ID', + 'LV', + 'PA-ID', + 'Studiensemester', + 'Studiengang-KZ', + 'Studiengang', + 'Semester', + 'Studienplan', + 'OrgForm', + 'Person-ID', + 'Typ', + 'LV- / Projektbezeichnung', + 'Organisationseinheit', + 'Gruppe', + 'Lektor', + 'Stunden', + 'Stundensatz', + 'Betrag', + 'Vertrag-ID', + 'Vertrag-Stunden', + 'Vertrag-Betrag', + 'UID', + 'Bestellt', + 'Erteilt', + 'Angenommen', + 'Bestellt von', + 'Erteilt von', + 'Angenommen von' + ), + 'datasetRepOptions' => '{ + height: 700, + layout:"fitColumns", // fit columns to width of table + responsiveLayout:"hide", // hide columns that dont fit on the table + movableColumns: true, // allows changing column + placeholder: func_placeholder(), + headerFilterPlaceholder: " ", + groupBy:"lehrveranstaltung_id", + groupToggleElement:"header", //toggle group on click anywhere in the group header + groupHeader: function(value, count, data, group){ + return func_groupHeader(data); + }, + footerElement: func_footerElement(), + columnCalcs:"both", // show column calculations at top and bottom of table and in groups + index: "row_index", // assign specific column as unique id (important for row indexing) + selectable: true, // allows row selection + selectableRangeMode: "click", // allows range selection using shift end click on end of range + selectablePersistence:false, // deselect previously selected rows when table is filtered, sorted or paginated + selectableCheck: function(row){ + return func_selectableCheck(row); + }, + rowUpdated:function(row){ + func_rowUpdated(row); + }, + rowSelectionChanged:function(data, rows){ + func_rowSelectionChanged(data, rows); + }, + rowFormatter:function(row){ + func_rowFormatter(row); + }, + renderStarted:function(){ + func_renderStarted(this); + }, + tableBuilt: function(){ + func_tableBuilt(this); + }, + dataLoaded: function(data){ + func_dataLoaded(data, this); + }, + }', // tabulator properties + 'datasetRepFieldsDefs' => '{ + // column status is built dynamically in funcTableBuilt() + row_index: {visible: false}, + personalnummer: {visible: false}, + lehreinheit_id: {headerFilter:"input", bottomCalc:"count", width: "7%", + bottomCalcFormatter:function(cell){return "Anzahl: " + cell.getValue();}}, + lehrveranstaltung_id: {headerFilter:"input"}, + lv_bezeichnung: {visible: false}, + projektarbeit_id: {visible: false}, + studiensemester_kurzbz: {headerFilter:"input"}, + studiengang_kz: {visible: false}, + stg_typ_kurzbz: {headerFilter:"input", width: "5%"}, + semester: {headerFilter:"input"}, + studienplan_bezeichnung: {headerFilter:"input", width: "7%"}, + orgform_kurzbz: {headerFilter:"input"}, + person_id: {visible: false}, + typ: {headerFilter:"input"}, + auftrag: {headerFilter:"input", width:"15%"}, + lv_oe_kurzbz: {headerFilter:"input"}, + gruppe: {headerFilter:"input"}, + lektor: {headerFilter:"input", widthGrow: 3}, + stunden: {align:"right", formatter: form_formatNulltoStringNumber, formatterParams:{precision:1}, + headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator, + bottomCalc:"sum", bottomCalcParams:{precision:1}}, + stundensatz: {visible: false}, + betrag: {align:"right", width: "8%", formatter: form_formatNulltoStringNumber, + headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator, + bottomCalc:"sum", bottomCalcParams:{precision:2}, bottomCalcFormatter:"money", + bottomCalcFormatterParams:{decimal: ",", thousand: ".", symbol:"€"}}, + vertrag_id: {visible: false}, + vertrag_stunden: {visible: false}, + vertrag_betrag: {visible: false}, + mitarbeiter_uid: {visible: false}, + bestellt: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: bestellt_tooltip, width: "8%"}, + erteilt: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: erteilt_tooltip, width: "8%"}, + akzeptiert: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: akzeptiert_tooltip, width: "8%"}, + bestellt_von: {visible: false}, + erteilt_von: {visible: false}, + akzeptiert_von: {visible: false} + }', // col properties +); + +echo $this->widgetlib->widget('TableWidget', $filterWidgetArray); + +?> diff --git a/application/views/organisation/studienjahrEdit.php b/application/views/organisation/studienjahrEdit.php index 4a23217b1..df0397cdf 100644 --- a/application/views/organisation/studienjahrEdit.php +++ b/application/views/organisation/studienjahrEdit.php @@ -7,7 +7,7 @@ $this->load->view('templates/header', array('title' => 'StudienjahrEdit', 'jquer

Studienjahr bearbeiten: studienjahr_kurzbz; ?>

-
"> + "> diff --git a/application/views/organisation/studiensemesterEdit.php b/application/views/organisation/studiensemesterEdit.php index 9f0abc0cb..98c4ca243 100644 --- a/application/views/organisation/studiensemesterEdit.php +++ b/application/views/organisation/studiensemesterEdit.php @@ -8,7 +8,7 @@ $this->load->view('templates/header', array('title' => 'StudiensemesterEdit', 'd

Studiensemester bearbeiten: studiensemester_kurzbz; ?>

"> + action="">
diff --git a/application/views/person/gradelist/gradelist.php b/application/views/person/gradelist/gradelist.php index dbdcf66f8..9ae485c02 100644 --- a/application/views/person/gradelist/gradelist.php +++ b/application/views/person/gradelist/gradelist.php @@ -37,7 +37,8 @@ p->t('lehre', 'gewichteternotendurchschnitt'); ?> :
- p->t('lehre', 'ects'); ?>: + p->t('lehre', 'ects'); ?> + :

p->t('lehre','notendurchschnitt');?>: + p->t('lehre','gewichteternotendurchschnitt');?>: + diff --git a/application/views/system/udf.php b/application/views/system/fas_udf.php similarity index 91% rename from application/views/system/udf.php rename to application/views/system/fas_udf.php index 10ba15698..d4a01b9e9 100644 --- a/application/views/system/udf.php +++ b/application/views/system/fas_udf.php @@ -47,7 +47,7 @@ } } ?> - +
diff --git a/application/views/system/infocenter/infocenter.php b/application/views/system/infocenter/infocenter.php index ebc99ba93..4005518a1 100644 --- a/application/views/system/infocenter/infocenter.php +++ b/application/views/system/infocenter/infocenter.php @@ -18,7 +18,7 @@ 'global' => array('mailAnXversandt'), 'ui' => array('bitteEintragWaehlen') ), - 'customCSSs' => 'public/css/sbadmin2/tablesort_bootstrap.css', + 'customCSSs' => array('public/css/sbadmin2/tablesort_bootstrap.css', 'public/css/infocenter/infocenterPersonDataset.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/infocenter/infocenterPersonDataset.js') ) ); diff --git a/application/views/system/infocenter/infocenterData.php b/application/views/system/infocenter/infocenterData.php index d888f6cd7..0c7030059 100644 --- a/application/views/system/infocenter/infocenterData.php +++ b/application/views/system/infocenter/infocenterData.php @@ -7,20 +7,14 @@ $TAETIGKEIT_KURZBZ = '\'bewerbung\', \'kommunikation\''; $LOGDATA_NAME = '\'Login with code\', \'Login with user\', \'New application\', \'Interessent rejected\''; $LOGDATA_NAME_PARKED = '\'Parked\''; + $LOGDATA_NAME_ONHOLD = '\'Onhold\''; $LOGTYPE_KURZBZ = '\'Processstate\''; $STATUS_KURZBZ = '\'Wartender\', \'Bewerber\', \'Aufgenommener\', \'Student\''; $ADDITIONAL_STG = '10021,10027'; $AKTE_TYP = '\'identity\', \'zgv_bakk\''; + $STUDIENSEMESTER = '\''.$this->variablelib->getVar('infocenter_studiensemester').'\''; $query = ' - WITH currentOrNextStudiensemester AS ( - SELECT ss.studiensemester_kurzbz - FROM public.tbl_studiensemester ss - WHERE ss.ende > NOW() - ORDER BY ss.ende - LIMIT 3 - ) - SELECT p.person_id AS "PersonId", p.vorname AS "Vorname", @@ -31,6 +25,7 @@ pl.zeitpunkt AS "LockDate", pl.lockuser AS "LockUser", pd.parkdate AS "ParkDate", + ohd.onholddate AS "OnholdDate", ( SELECT l.zeitpunkt FROM system.tbl_log l @@ -100,13 +95,14 @@ OR sg.studiengang_kz in('.$ADDITIONAL_STG.') ) - AND pss.studiensemester_kurzbz IN (SELECT cnss.studiensemester_kurzbz FROM currentOrNextStudiensemester cnss) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' AND NOT EXISTS ( SELECT 1 FROM tbl_prestudentstatus spss WHERE spss.prestudent_id = pss.prestudent_id AND spss.status_kurzbz = '.$REJECTED_STATUS.' - AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > NOW()) + AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > + (SELECT start FROM public.tbl_studiensemester sss WHERE studiensemester_kurzbz = '.$STUDIENSEMESTER.')) ) ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC LIMIT 1 @@ -125,13 +121,14 @@ OR sg.studiengang_kz in('.$ADDITIONAL_STG.') ) - AND pss.studiensemester_kurzbz IN (SELECT cnss.studiensemester_kurzbz FROM currentOrNextStudiensemester cnss) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' AND NOT EXISTS ( SELECT 1 FROM tbl_prestudentstatus spss WHERE spss.prestudent_id = pss.prestudent_id AND spss.status_kurzbz = '.$REJECTED_STATUS.' - AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > NOW()) + AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > + (SELECT start FROM public.tbl_studiensemester sss WHERE studiensemester_kurzbz = '.$STUDIENSEMESTER.')) ) LIMIT 1 ) AS "AnzahlAbgeschickt", @@ -149,13 +146,14 @@ OR sg.studiengang_kz in('.$ADDITIONAL_STG.') ) - AND pss.studiensemester_kurzbz IN (SELECT cnss.studiensemester_kurzbz FROM currentOrNextStudiensemester cnss) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' AND NOT EXISTS ( SELECT 1 FROM tbl_prestudentstatus spss WHERE spss.prestudent_id = pss.prestudent_id AND spss.status_kurzbz = '.$REJECTED_STATUS.' - AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > NOW()) + AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > + (SELECT start FROM public.tbl_studiensemester sss WHERE studiensemester_kurzbz = '.$STUDIENSEMESTER.')) ) LIMIT 1 ) AS "StgAbgeschickt", @@ -173,13 +171,15 @@ OR sg.studiengang_kz in('.$ADDITIONAL_STG.') ) - AND pss.studiensemester_kurzbz IN (SELECT cnss.studiensemester_kurzbz FROM currentOrNextStudiensemester cnss) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' + AND NOT EXISTS ( SELECT 1 FROM tbl_prestudentstatus spss WHERE spss.prestudent_id = pss.prestudent_id AND spss.status_kurzbz = '.$REJECTED_STATUS.' - AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > NOW()) + AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > + (SELECT start FROM public.tbl_studiensemester sss WHERE studiensemester_kurzbz = '.$STUDIENSEMESTER.')) ) LIMIT 1 ) AS "StgNichtAbgeschickt", @@ -196,13 +196,14 @@ OR sg.studiengang_kz in('.$ADDITIONAL_STG.') ) - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.start >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' AND NOT EXISTS ( SELECT 1 FROM tbl_prestudentstatus spss WHERE spss.prestudent_id = pss.prestudent_id AND spss.status_kurzbz = '.$REJECTED_STATUS.' - AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > NOW()) + AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > + (SELECT start FROM public.tbl_studiensemester sss WHERE studiensemester_kurzbz = '.$STUDIENSEMESTER.')) ) LIMIT 1 ) AS "StgAktiv", @@ -229,6 +230,14 @@ AND l.logdata->>\'name\' = '.$LOGDATA_NAME_PARKED.' AND l.zeitpunkt >= NOW() ) pd USING(person_id) + LEFT JOIN ( + SELECT l.person_id, + l.zeitpunkt AS onholddate + FROM system.tbl_log l + WHERE l.logtype_kurzbz = '.$LOGTYPE_KURZBZ.' + AND l.logdata->>\'name\' = '.$LOGDATA_NAME_ONHOLD.' + AND l.zeitpunkt >= NOW() + ) ohd USING(person_id) WHERE EXISTS ( SELECT 1 @@ -252,7 +261,7 @@ WHERE spss.prestudent_id = sps.prestudent_id AND spss.status_kurzbz = '.$INTERESSENT_STATUS.' AND spss.bestaetigtam IS NULL - AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > NOW()) + AND spss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' ) ) ORDER BY "LastAction" ASC'; @@ -265,7 +274,6 @@ 'filter_id' => $this->input->get('filter_id'), 'requiredPermissions' => 'infocenter', 'datasetRepresentation' => 'tablesorter', - 'reloadDataset' => ($this->input->get('reloadDataset')=='true'?true:false), 'customMenu' => true, 'checkboxes' => 'PersonId', 'additionalColumns' => array('Details'), @@ -279,6 +287,7 @@ ucfirst($this->p->t('global', 'sperrdatum')), ucfirst($this->p->t('global', 'gesperrtVon')), ucfirst($this->p->t('global', 'parkdatum')), + ucfirst($this->p->t('global', 'rueckstelldatum')), ucfirst($this->p->t('global', 'letzteAktion')), 'Aktionstyp', 'AnzahlAktePflicht', @@ -341,6 +350,11 @@ $datasetRaw->{'ParkDate'} = '-'; } + if ($datasetRaw->{'OnholdDate'} == null) + { + $datasetRaw->{'OnholdDate'} = '-'; + } + if ($datasetRaw->{'StgAbgeschickt'} == null) { $datasetRaw->{'StgAbgeschickt'} = '-'; @@ -377,6 +391,11 @@ $mark = FilterWidget::DEFAULT_MARK_ROW_CLASS; } + if ($datasetRaw->OnholdDate != null) + { + $mark = "onhold"; + } + // Parking has priority over locking if ($datasetRaw->ParkDate != null) { diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index 86493134c..11b8ef094 100644 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -34,7 +34,14 @@ 'nichtsZumAusparken', 'fehlerBeimAusparken', 'fehlerBeimParken', - 'bewerberGeparktBis' + 'bewerberGeparktBis', + 'bewerberOnHold', + 'bewerberOnHoldEntfernen', + 'bewerberOnHoldBis', + 'nichtsZumEntfernen', + 'fehlerBeimEntfernen', + 'rueckstelldatumUeberschritten', + 'parkenZurueckstellenInfo' ), 'ui' => array( 'gespeichert', @@ -176,7 +183,7 @@
-
+
load->view('system/infocenter/logs.php'); ?>
diff --git a/application/views/system/infocenter/infocenterFreigegeben.php b/application/views/system/infocenter/infocenterFreigegeben.php index 40f69528d..15e73f1b6 100644 --- a/application/views/system/infocenter/infocenterFreigegeben.php +++ b/application/views/system/infocenter/infocenterFreigegeben.php @@ -18,7 +18,7 @@ 'global' => array('mailAnXversandt'), 'ui' => array('bitteEintragWaehlen') ), - 'customCSSs' => 'public/css/sbadmin2/tablesort_bootstrap.css', + 'customCSSs' => array('public/css/sbadmin2/tablesort_bootstrap.css', 'public/css/infocenter/infocenterPersonDataset.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/infocenter/infocenterPersonDataset.js') ) ); diff --git a/application/views/system/infocenter/infocenterFreigegebenData.php b/application/views/system/infocenter/infocenterFreigegebenData.php index 059e30a80..729fabb04 100644 --- a/application/views/system/infocenter/infocenterFreigegebenData.php +++ b/application/views/system/infocenter/infocenterFreigegebenData.php @@ -8,6 +8,7 @@ $REJECTED_STATUS = '\'Abgewiesener\''; $ADDITIONAL_STG = '10021,10027,10002'; $STATUS_KURZBZ = '\'Wartender\', \'Bewerber\', \'Aufgenommener\', \'Student\''; + $STUDIENSEMESTER = '\''.$this->variablelib->getVar('infocenter_studiensemester').'\''; $query = ' SELECT @@ -58,7 +59,7 @@ sg.studiengang_kz in('.$ADDITIONAL_STG.') ) AND pss.bestaetigtam is not null - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC LIMIT 1 ) AS "Studiensemester", @@ -74,7 +75,7 @@ OR sg.studiengang_kz in('.$ADDITIONAL_STG.') ) - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC LIMIT 1 ) AS "SendDate", @@ -90,7 +91,7 @@ OR sg.studiengang_kz in('.$ADDITIONAL_STG.') ) - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' AND NOT EXISTS ( SELECT 1 FROM tbl_prestudentstatus spss @@ -112,7 +113,7 @@ OR sg.studiengang_kz in('.$ADDITIONAL_STG.') ) - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' LIMIT 1 ) AS "StgAbgeschickt", ( @@ -128,13 +129,14 @@ OR sg.studiengang_kz in('.$ADDITIONAL_STG.') ) - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' AND NOT EXISTS ( SELECT 1 FROM tbl_prestudentstatus spss WHERE spss.prestudent_id = pss.prestudent_id AND spss.status_kurzbz = '.$REJECTED_STATUS.' - AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > NOW()) + AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > + (SELECT start FROM public.tbl_studiensemester sss WHERE studiensemester_kurzbz = '.$STUDIENSEMESTER.')) ) LIMIT 1 ) AS "StgAktiv", @@ -145,7 +147,7 @@ LEFT JOIN public.tbl_status_grund sg USING(statusgrund_id) WHERE pss.status_kurzbz = '.$INTERESSENT_STATUS.' AND ps.person_id = p.person_id - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' LIMIT 1 ) AS "Statusgrund", ( @@ -162,7 +164,7 @@ ) rtp ON(rtp.person_id = ps.person_id AND rtp.studiensemester_kurzbz = pss.studiensemester_kurzbz) WHERE pss.status_kurzbz = '.$INTERESSENT_STATUS.' AND ps.person_id = p.person_id - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC LIMIT 1 ) AS "ReihungstestAngetreten", @@ -179,7 +181,7 @@ ) rtp ON(rtp.person_id = ps.person_id AND rtp.studiensemester_kurzbz = pss.studiensemester_kurzbz) WHERE pss.status_kurzbz = '.$INTERESSENT_STATUS.' AND ps.person_id = p.person_id - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.studiensemester_kurzbz = \'WS2019\') + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC LIMIT 1 ) AS "ReihungstestApplied", @@ -204,6 +206,7 @@ FROM public.tbl_prestudent ps JOIN public.tbl_studiengang sg USING(studiengang_kz) WHERE ps.person_id = p.person_id + AND ps.reihungstestangetreten = FALSE AND (sg.typ IN ('.$STUDIENGANG_TYP.') OR sg.studiengang_kz in('.$ADDITIONAL_STG.') @@ -215,7 +218,7 @@ AND pss.status_kurzbz = '.$INTERESSENT_STATUS.' AND pss.bestaetigtam IS NOT NULL AND pss.bewerbung_abgeschicktamum IS NOT NULL - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' AND NOT EXISTS ( SELECT 1 FROM tbl_prestudentstatus spss diff --git a/application/views/system/infocenter/infocenterReihungstestAbsolviert.php b/application/views/system/infocenter/infocenterReihungstestAbsolviert.php index d40b7a572..79f75885b 100644 --- a/application/views/system/infocenter/infocenterReihungstestAbsolviert.php +++ b/application/views/system/infocenter/infocenterReihungstestAbsolviert.php @@ -18,7 +18,7 @@ 'global' => array('mailAnXversandt'), 'ui' => array('bitteEintragWaehlen') ), - 'customCSSs' => 'public/css/sbadmin2/tablesort_bootstrap.css', + 'customCSSs' => array('public/css/sbadmin2/tablesort_bootstrap.css', 'public/css/infocenter/infocenterPersonDataset.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/infocenter/infocenterPersonDataset.js') ) ); diff --git a/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php b/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php index ff488b6dc..22b122bb0 100644 --- a/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php +++ b/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php @@ -6,6 +6,7 @@ $TAETIGKEIT_KURZBZ = '\'bewerbung\', \'kommunikation\''; $LOGDATA_NAME = '\'Login with code\', \'Login with user\', \'New application\''; $ADDITIONAL_STG = '10021,10027'; + $STUDIENSEMESTER = '\''.$this->variablelib->getVar('infocenter_studiensemester').'\''; $query = ' SELECT @@ -46,7 +47,7 @@ OR sg.studiengang_kz in('.$ADDITIONAL_STG.') ) - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC LIMIT 1 ) AS "Studiensemester", @@ -62,7 +63,7 @@ OR sg.studiengang_kz in('.$ADDITIONAL_STG.') ) - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC LIMIT 1 ) AS "SendDate", @@ -78,7 +79,7 @@ OR sg.studiengang_kz in('.$ADDITIONAL_STG.') ) - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' LIMIT 1 ) AS "AnzahlAbgeschickt", ( @@ -93,7 +94,7 @@ OR sg.studiengang_kz in('.$ADDITIONAL_STG.') ) - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' LIMIT 1 ) AS "StgAbgeschickt", ( @@ -103,7 +104,7 @@ LEFT JOIN public.tbl_status_grund sg USING(statusgrund_id) WHERE pss.status_kurzbz = '.$INTERESSENT_STATUS.' AND ps.person_id = p.person_id - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' LIMIT 1 ) AS "Statusgrund", ( @@ -120,7 +121,7 @@ ) rtp ON(rtp.person_id = ps.person_id AND rtp.studiensemester_kurzbz = pss.studiensemester_kurzbz) WHERE pss.status_kurzbz = '.$INTERESSENT_STATUS.' AND ps.person_id = p.person_id - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC LIMIT 1 ) AS "ReihungstestAngetreten", @@ -137,7 +138,7 @@ ) rtp ON(rtp.person_id = ps.person_id AND rtp.studiensemester_kurzbz = pss.studiensemester_kurzbz) WHERE pss.status_kurzbz = '.$INTERESSENT_STATUS.' AND ps.person_id = p.person_id - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC LIMIT 1 ) AS "ReihungstestApplied", @@ -155,7 +156,7 @@ ) rtp ON(rtp.person_id = ps.person_id AND rtp.studiensemester_kurzbz = pss.studiensemester_kurzbz) WHERE pss.status_kurzbz = '.$INTERESSENT_STATUS.' AND ps.person_id = p.person_id - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC LIMIT 1 ) AS "ReihungstestDatum", @@ -191,7 +192,7 @@ AND pss.status_kurzbz = '.$INTERESSENT_STATUS.' AND pss.bestaetigtam IS NOT NULL AND pss.bewerbung_abgeschicktamum IS NOT NULL - AND pss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende >= NOW()) + AND pss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' ) ) ORDER BY "LastAction" DESC'; diff --git a/application/views/system/logs/logsViewer.php b/application/views/system/logs/logsViewer.php new file mode 100644 index 000000000..96790b479 --- /dev/null +++ b/application/views/system/logs/logsViewer.php @@ -0,0 +1,47 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Logs viewer', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'tablesorter' => true, + 'ajaxlib' => true, + 'filterwidget' => true, + 'navigationwidget' => true, + 'phrases' => array( + 'global' => array('mailAnXversandt'), + 'ui' => array('bitteEintragWaehlen') + ), + 'customCSSs' => 'public/css/sbadmin2/tablesort_bootstrap.css', + 'customJSs' => array('public/js/bootstrapper.js') + ) + ); +?> + + +
+ + widgetlib->widget('NavigationWidget'); ?> + +
+
+
+
+ +
+
+
+ load->view('system/logs/logsViewerData.php'); ?> +
+
+
+
+ + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/system/logs/logsViewerData.php b/application/views/system/logs/logsViewerData.php new file mode 100644 index 000000000..13a4207ab --- /dev/null +++ b/application/views/system/logs/logsViewerData.php @@ -0,0 +1,65 @@ + ' + SELECT wsl.webservicelog_id AS "LogId", + wsl.request_id AS "RequestId", + wsl.execute_time AS "ExecutionTime", + wsl.execute_user AS "ExecutedBy", + wsl.beschreibung AS "Description", + wsl.request_data AS "Data", + wsl.webservicetyp_kurzbz AS "WebserviceType" + FROM system.tbl_webservicelog wsl + ORDER BY wsl.execute_time DESC + ', + 'requiredPermissions' => 'admin', + 'datasetRepresentation' => 'tablesorter', + 'columnsAliases' => array( + 'Log id', + 'Request id', + 'Execution time', + 'Executed by', + 'Producer', + 'Data', + 'Webservice type' + ), + 'formatRow' => function($datasetRaw) { + + $datasetRaw->ExecutionTime = date_format(date_create($datasetRaw->ExecutionTime), 'd.m.Y H:i:s'); + + return $datasetRaw; + }, + 'markRow' => function($datasetRaw) { + + $mark = ''; + + if ($datasetRaw->RequestId == 'Cronjob error') + { + $mark = 'text-red'; + } + + if ($datasetRaw->RequestId == 'Cronjob info') + { + $mark = 'text-green'; + } + + if ($datasetRaw->RequestId == 'Cronjob warning') + { + $mark = 'text-orange'; + } + + if ($datasetRaw->RequestId == 'Cronjob debug') + { + $mark = 'text-info'; + } + + return $mark; + } + ); + + $filterWidgetArray['app'] = 'core'; + $filterWidgetArray['datasetName'] = 'logs'; + $filterWidgetArray['filter_id'] = $this->input->get('filter_id'); + + echo $this->widgetlib->widget('FilterWidget', $filterWidgetArray); +?> diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index 2d6a92ace..5defaa0d3 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -30,6 +30,7 @@ $pivotui = isset($pivotui) ? $pivotui : false; $sbadmintemplate = isset($sbadmintemplate) ? $sbadmintemplate : false; $tablesorter = isset($tablesorter) ? $tablesorter : false; + $tablewidget = isset($tablewidget) ? $tablewidget : false; $tabulator = isset($tabulator) ? $tabulator : false; $tinymce = isset($tinymce) ? $tinymce : false; $widgets = isset($widgets) ? $widgets : false; @@ -198,6 +199,9 @@ // PhrasesLib JS if ($phrases != null) generateJSsInclude('public/js/PhrasesLib.js'); + // TableWidget JS + if ($tablewidget === true) generateJSsInclude('public/js/TableWidget.js'); + // Load addon hooks JS // NOTE: keep it as the latest but one if ($addons === true) generateAddonsJSsInclude($calledPath.'/'.$calledMethod); diff --git a/application/views/widgets/filter/filter.php b/application/views/widgets/filter/filter.php index dc20e58b6..a9b8ad1f1 100644 --- a/application/views/widgets/filter/filter.php +++ b/application/views/widgets/filter/filter.php @@ -1,4 +1,5 @@ -
+ +
@@ -6,40 +7,7 @@
- -
-
- -
-
- -
- -
- -
- - -
- -
- -
- - -
- -
-
-
-
-
- -
+
diff --git a/application/views/widgets/filter/filterOptions.php b/application/views/widgets/filter/filterOptions.php new file mode 100644 index 000000000..6f1dd3885 --- /dev/null +++ b/application/views/widgets/filter/filterOptions.php @@ -0,0 +1,35 @@ + + +
+
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ +
+ + +
+ +
+
+
+
+
+ +
diff --git a/application/views/widgets/filter/tableDataset.php b/application/views/widgets/filter/tableDataset.php index ca917503a..2f1b94e61 100644 --- a/application/views/widgets/filter/tableDataset.php +++ b/application/views/widgets/filter/tableDataset.php @@ -1,8 +1,7 @@ -
+
-
diff --git a/application/views/widgets/filter/tabulatorDataset.php b/application/views/widgets/filter/tabulatorDataset.php new file mode 100644 index 000000000..f5efc50b3 --- /dev/null +++ b/application/views/widgets/filter/tabulatorDataset.php @@ -0,0 +1 @@ +
diff --git a/application/views/widgets/table/pivotUIDataset.php b/application/views/widgets/table/pivotUIDataset.php new file mode 100644 index 000000000..0b43fcdac --- /dev/null +++ b/application/views/widgets/table/pivotUIDataset.php @@ -0,0 +1 @@ +
diff --git a/application/views/widgets/table/table.php b/application/views/widgets/table/table.php new file mode 100644 index 000000000..e73aec335 --- /dev/null +++ b/application/views/widgets/table/table.php @@ -0,0 +1,17 @@ + +
+
+ + +
+ + +
+ +
+ + +
+ +
+
diff --git a/application/views/widgets/table/tableDataset.php b/application/views/widgets/table/tableDataset.php new file mode 100644 index 000000000..7c2f26ea5 --- /dev/null +++ b/application/views/widgets/table/tableDataset.php @@ -0,0 +1,7 @@ + + + + + + +
diff --git a/application/views/widgets/table/tabulatorDataset.php b/application/views/widgets/table/tabulatorDataset.php new file mode 100644 index 000000000..4984284bc --- /dev/null +++ b/application/views/widgets/table/tabulatorDataset.php @@ -0,0 +1 @@ +
diff --git a/application/widgets/Ausbildungssemester_widget.php b/application/widgets/Ausbildungssemester_widget.php new file mode 100644 index 000000000..8200d8a63 --- /dev/null +++ b/application/widgets/Ausbildungssemester_widget.php @@ -0,0 +1,43 @@ +id = $i; + $ausbildungssemester_obj->description = $i; + + $ausbildungssemester_arr []= $ausbildungssemester_obj; + } + + $this->setElementsArray( + success($ausbildungssemester_arr), + true, + $this->p->t('lehre', 'ausbildungssemester'), + 'No Ausbildungssemester found' + ); + + $this->loadDropDownView($widgetData); + } +} \ No newline at end of file diff --git a/application/widgets/FilterWidget.php b/application/widgets/FilterWidget.php index 84a4d138b..1cef91c15 100644 --- a/application/widgets/FilterWidget.php +++ b/application/widgets/FilterWidget.php @@ -7,9 +7,11 @@ class FilterWidget extends Widget { // Paths of the views const WIDGET_URL_FILTER = 'widgets/filter/filter'; + const WIDGET_URL_FILTER_OPTIONS = 'widgets/filter/filterOptions'; const WIDGET_URL_SELECT_FIELDS = 'widgets/filter/selectFields'; const WIDGET_URL_DATASET_TABLESORTER = 'widgets/filter/tableDataset'; const WIDGET_URL_DATASET_PIVOTUI = 'widgets/filter/pivotUIDataset'; + const WIDGET_URL_DATASET_TABULATOR = 'widgets/filter/tabulatorDataset'; const WIDGET_URL_SELECT_FILTERS = 'widgets/filter/selectFilters'; const WIDGET_URL_SAVE_FILTER = 'widgets/filter/saveFilter'; @@ -40,16 +42,23 @@ class FilterWidget extends Widget // To have a column in the GUI with checkboxes to select rows in the table private $_checkboxes; - // To hide the GUI to operate or save the filter widget - private $_hideHeader; - private $_hideSave; + // To hide the GUI to operate with the filter widget or to save a custom filter + private $_hideOptions; // if true hides all the options + private $_hideSelectFields; // if true hides the fields selection + private $_hideSelectFilters; // if true hides the filters selections + private $_hideSave; // if true hides the GUI to save a custom filter + private $_hideMenu; // if true then the menu is not shown private $_customMenu; // if true then method _setFilterMenu is NOT called private $_datasetRepresentation; // dataset representation (ex: tablesorter, pivotUI, ...) private $_datasetRepresentationOptions; // dataset representation options for tablesorter, pivotUI, ... + private $_datasetRepFieldsDefs; // dataset representation attributes for each record field + private $_reloadDataset; // Force Reload of Dataset + private $_sessionTimeout; // session expiring time + private static $_FilterWidgetInstance; // static property that contains the instance of itself /** @@ -61,18 +70,20 @@ class FilterWidget extends Widget self::$_FilterWidgetInstance = $this; // set static property $_FilterWidgetInstance with this instance - $this->load->library('FiltersLib'); // Loads the FiltersLib that contains all the used logic + $this->load->library('FilterWidgetLib'); // Loads the FilterWidgetLib that contains all the used logic $this->_initFilterWidget($args); // checks parameters and initialize properties + $this->filterwidgetlib->setFilterUniqueIdByParams($args); + // Let's start if it's allowed // NOTE: If it is NOT allowed then no data are loaded - if ($this->filterslib->isAllowed($this->_requiredPermissions)) + if ($this->filterwidgetlib->isAllowed($this->_requiredPermissions)) { $this->_startFilterWidget(); // If a custom menu is not used, then default menu is used - if ($this->_customMenu != true) $this->_setFilterMenu(); + if ($this->_hideMenu != true && $this->_customMenu != true) $this->_setFilterMenu(); } } @@ -84,18 +95,33 @@ class FilterWidget extends Widget */ public function display($widgetData) { - $this->view(self::WIDGET_URL_FILTER); // GUI starts here + $this->view(self::WIDGET_URL_FILTER, array( + 'app' => $this->_app, + 'dataset' => $this->_datasetName, + 'filterid' => $this->_filterId + )); // GUI starts here } //------------------------------------------------------------------------------------------------------------------ // Public static methods used to load views and to access statically to some properies of the FilterWidget + /** + * Loads the view related to the filter options + */ + public static function loadViewFilterOptions() + { + if (self::$_FilterWidgetInstance->_hideOptions != true) + { + self::_loadView(self::WIDGET_URL_FILTER_OPTIONS); + } + } + /** * Loads the view related to the selected fields */ public static function loadViewSelectFields() { - if (self::$_FilterWidgetInstance->_hideHeader != true) + if (self::$_FilterWidgetInstance->_hideSelectFields != true) { self::_loadView(self::WIDGET_URL_SELECT_FIELDS); } @@ -106,7 +132,7 @@ class FilterWidget extends Widget */ public static function loadViewSelectFilters() { - if (self::$_FilterWidgetInstance->_hideHeader != true) + if (self::$_FilterWidgetInstance->_hideSelectFilters != true) { self::_loadView(self::WIDGET_URL_SELECT_FILTERS); } @@ -128,15 +154,20 @@ class FilterWidget extends Widget */ public static function loadViewDataset() { - if (self::$_FilterWidgetInstance->_datasetRepresentation == FiltersLib::DATASET_REP_TABLESORTER) + if (self::$_FilterWidgetInstance->_datasetRepresentation == FilterWidgetLib::DATASET_REP_TABLESORTER) { self::_loadView(self::WIDGET_URL_DATASET_TABLESORTER); } - if (self::$_FilterWidgetInstance->_datasetRepresentation == FiltersLib::DATASET_REP_PIVOTUI) + if (self::$_FilterWidgetInstance->_datasetRepresentation == FilterWidgetLib::DATASET_REP_PIVOTUI) { self::_loadView(self::WIDGET_URL_DATASET_PIVOTUI); } + + if (self::$_FilterWidgetInstance->_datasetRepresentation == FilterWidgetLib::DATASET_REP_TABULATOR) + { + self::_loadView(self::WIDGET_URL_DATASET_TABULATOR); + } } //------------------------------------------------------------------------------------------------------------------ @@ -157,122 +188,158 @@ class FilterWidget extends Widget $this->_datasetName = null; $this->_filterKurzbz = null; $this->_filterId = null; - $this->_reloadDataset = null; + $this->_reloadDataset = true; // by default the dataset is NOT cached in session $this->_query = null; $this->_additionalColumns = null; $this->_columnsAliases = null; $this->_formatRow = null; $this->_markRow = null; $this->_checkboxes = null; - $this->_hideHeader = null; + $this->_hideOptions = null; + $this->_hideSelectFields = null; + $this->_hideSelectFilters = null; $this->_hideSave = null; + $this->_hideMenu = null; $this->_customMenu = null; $this->_datasetRepresentation = null; $this->_datasetRepresentationOptions = null; + $this->_datasetRepFieldsDefs = null; + $this->_sessionTimeout = FilterWidgetLib::SESSION_DEFAULT_TIMEOUT; // Retrieved the required permissions parameter if present - if (isset($args[FiltersLib::REQUIRED_PERMISSIONS_PARAMETER])) + if (isset($args[FilterWidgetLib::REQUIRED_PERMISSIONS])) { - $this->_requiredPermissions = $args[FiltersLib::REQUIRED_PERMISSIONS_PARAMETER]; + $this->_requiredPermissions = $args[FilterWidgetLib::REQUIRED_PERMISSIONS]; } // Parameters needed to retrieve univocally a filter from DB - if (isset($args[FiltersLib::APP_PARAMETER])) + if (isset($args[FilterWidgetLib::APP])) { - $this->_app = $args[FiltersLib::APP_PARAMETER]; + $this->_app = $args[FilterWidgetLib::APP]; } - if (isset($args[FiltersLib::DATASET_NAME_PARAMETER])) + if (isset($args[FilterWidgetLib::DATASET_NAME])) { - $this->_datasetName = $args[FiltersLib::DATASET_NAME_PARAMETER]; + $this->_datasetName = $args[FilterWidgetLib::DATASET_NAME]; } - if (isset($args[FiltersLib::FILTER_KURZBZ_PARAMETER])) + if (isset($args[FilterWidgetLib::FILTER_KURZBZ])) { - $this->_filterKurzbz = $args[FiltersLib::FILTER_KURZBZ_PARAMETER]; + $this->_filterKurzbz = $args[FilterWidgetLib::FILTER_KURZBZ]; } - if (isset($args[FiltersLib::FILTER_ID])) + if (isset($args[FilterWidgetLib::FILTER_ID])) { - $this->_filterId = $args[FiltersLib::FILTER_ID]; + $this->_filterId = $args[FilterWidgetLib::FILTER_ID]; } // How to retrieve data for the filter: SQL statement or a result from DB - if (isset($args[FiltersLib::QUERY_PARAMETER])) + if (isset($args[FilterWidgetLib::QUERY])) { - $this->_query = $args[FiltersLib::QUERY_PARAMETER]; + $this->_query = $args[FilterWidgetLib::QUERY]; } - if (isset($args[FiltersLib::DATASET_RELOAD_PARAMETER])) + if (isset($args[FilterWidgetLib::DATASET_RELOAD])) { - $this->_reloadDataset = $args[FiltersLib::DATASET_RELOAD_PARAMETER]; + $this->_reloadDataset = $args[FilterWidgetLib::DATASET_RELOAD]; } // Parameter is used to add extra columns to the dataset - if (isset($args[FiltersLib::ADDITIONAL_COLUMNS]) - && is_array($args[FiltersLib::ADDITIONAL_COLUMNS]) - && count($args[FiltersLib::ADDITIONAL_COLUMNS]) > 0) + if (isset($args[FilterWidgetLib::ADDITIONAL_COLUMNS]) + && is_array($args[FilterWidgetLib::ADDITIONAL_COLUMNS]) + && count($args[FilterWidgetLib::ADDITIONAL_COLUMNS]) > 0) { - $this->_additionalColumns = $args[FiltersLib::ADDITIONAL_COLUMNS]; + $this->_additionalColumns = $args[FilterWidgetLib::ADDITIONAL_COLUMNS]; } // Parameter is used to add use aliases for the columns fo the dataset - if (isset($args[FiltersLib::COLUMNS_ALIASES]) - && is_array($args[FiltersLib::COLUMNS_ALIASES]) - && count($args[FiltersLib::COLUMNS_ALIASES]) > 0) + if (isset($args[FilterWidgetLib::COLUMNS_ALIASES]) + && is_array($args[FilterWidgetLib::COLUMNS_ALIASES]) + && count($args[FilterWidgetLib::COLUMNS_ALIASES]) > 0) { - $this->_columnsAliases = $args[FiltersLib::COLUMNS_ALIASES]; + $this->_columnsAliases = $args[FilterWidgetLib::COLUMNS_ALIASES]; } // Parameter that contains a function to format the rows of the dataset - if (isset($args[FiltersLib::FORMAT_ROW]) && is_callable($args[FiltersLib::FORMAT_ROW])) + if (isset($args[FilterWidgetLib::FORMAT_ROW]) && is_callable($args[FilterWidgetLib::FORMAT_ROW])) { - $this->_formatRow = $args[FiltersLib::FORMAT_ROW]; + $this->_formatRow = $args[FilterWidgetLib::FORMAT_ROW]; } // Parameter that contains a function to mark in the GUI the rows of the dataset - if (isset($args[FiltersLib::MARK_ROW]) && is_callable($args[FiltersLib::MARK_ROW])) + if (isset($args[FilterWidgetLib::MARK_ROW]) && is_callable($args[FilterWidgetLib::MARK_ROW])) { - $this->_markRow = $args[FiltersLib::MARK_ROW]; + $this->_markRow = $args[FilterWidgetLib::MARK_ROW]; } // Parameter used to specify the column of the dataset that will be used // as id of the checkboxes column in the GUI - if (isset($args[FiltersLib::CHECKBOXES])) + if (isset($args[FilterWidgetLib::CHECKBOXES])) { - $this->_checkboxes = $args[FiltersLib::CHECKBOXES]; + $this->_checkboxes = $args[FilterWidgetLib::CHECKBOXES]; } - // To specify if the header to operate with the FilterWidget is shown or not - if (isset($args[FiltersLib::HIDE_HEADER]) && is_bool($args[FiltersLib::HIDE_HEADER])) + // To specify if the filter options are shown ot not + if (isset($args[FilterWidgetLib::HIDE_OPTIONS]) && is_bool($args[FilterWidgetLib::HIDE_OPTIONS])) { - $this->_hideHeader = $args[FiltersLib::HIDE_HEADER]; + $this->_hideOptions = $args[FilterWidgetLib::HIDE_OPTIONS]; + } + + // To specify if the form to select fields is shown or not + if (isset($args[FilterWidgetLib::HIDE_SELECT_FIELDS]) && is_bool($args[FilterWidgetLib::HIDE_SELECT_FIELDS])) + { + $this->_hideSelectFields = $args[FilterWidgetLib::HIDE_SELECT_FIELDS]; + } + + // To specify if the form to select filters is shown or not + if (isset($args[FilterWidgetLib::HIDE_SELECT_FILTERS]) && is_bool($args[FilterWidgetLib::HIDE_SELECT_FILTERS])) + { + $this->_hideSelectFilters = $args[FilterWidgetLib::HIDE_SELECT_FILTERS]; } // To specify if the form to save a custom FilterWidget is shown or not - if (isset($args[FiltersLib::HIDE_SAVE]) && is_bool($args[FiltersLib::HIDE_SAVE])) + if (isset($args[FilterWidgetLib::HIDE_SAVE]) && is_bool($args[FilterWidgetLib::HIDE_SAVE])) { - $this->_hideSave = $args[FiltersLib::HIDE_SAVE]; + $this->_hideSave = $args[FilterWidgetLib::HIDE_SAVE]; + } + + // If the menu should be shown or not + if (isset($args[FilterWidgetLib::HIDE_MENU]) && is_bool($args[FilterWidgetLib::HIDE_MENU])) + { + $this->_hideMenu = $args[FilterWidgetLib::HIDE_MENU]; } // If a custom menu is set - if (isset($args[FiltersLib::CUSTOM_MENU]) && is_bool($args[FiltersLib::CUSTOM_MENU])) + if (isset($args[FilterWidgetLib::CUSTOM_MENU]) && is_bool($args[FilterWidgetLib::CUSTOM_MENU])) { - $this->_customMenu = $args[FiltersLib::CUSTOM_MENU]; + $this->_customMenu = $args[FilterWidgetLib::CUSTOM_MENU]; } // To specify how to represent the dataset (ex: tablesorter, pivotUI, ...) - if (isset($args[FiltersLib::DATASET_REPRESENTATION]) - && ($args[FiltersLib::DATASET_REPRESENTATION] == FiltersLib::DATASET_REP_TABLESORTER - || $args[FiltersLib::DATASET_REPRESENTATION] == FiltersLib::DATASET_REP_PIVOTUI)) + if (isset($args[FilterWidgetLib::DATASET_REPRESENTATION]) + && ($args[FilterWidgetLib::DATASET_REPRESENTATION] == FilterWidgetLib::DATASET_REP_TABLESORTER + || $args[FilterWidgetLib::DATASET_REPRESENTATION] == FilterWidgetLib::DATASET_REP_PIVOTUI + || $args[FilterWidgetLib::DATASET_REPRESENTATION] == FilterWidgetLib::DATASET_REP_TABULATOR)) { - $this->_datasetRepresentation = $args[FiltersLib::DATASET_REPRESENTATION]; + $this->_datasetRepresentation = $args[FilterWidgetLib::DATASET_REPRESENTATION]; } // To specify options for the dataset representation (ex: tablesorter, pivotUI, ...) - if (isset($args[FiltersLib::DATASET_REP_OPTIONS]) && !isEmptyString($args[FiltersLib::DATASET_REP_OPTIONS])) + if (isset($args[FilterWidgetLib::DATASET_REP_OPTIONS]) && !isEmptyString($args[FilterWidgetLib::DATASET_REP_OPTIONS])) { - $this->_datasetRepresentationOptions = $args[FiltersLib::DATASET_REP_OPTIONS]; + $this->_datasetRepresentationOptions = $args[FilterWidgetLib::DATASET_REP_OPTIONS]; + } + + // To specify how to represent each record field + if (isset($args[FilterWidgetLib::DATASET_REP_FIELDS_DEFS]) && !isEmptyString($args[FilterWidgetLib::DATASET_REP_FIELDS_DEFS])) + { + $this->_datasetRepFieldsDefs = $args[FilterWidgetLib::DATASET_REP_FIELDS_DEFS]; + } + + // To specify the expiring session time + if (isset($args[FilterWidgetLib::SESSION_TIMEOUT]) && is_numeric($args[FilterWidgetLib::SESSION_TIMEOUT])) + { + $this->_sessionTimeout = $args[FilterWidgetLib::SESSION_TIMEOUT]; } } @@ -281,40 +348,55 @@ class FilterWidget extends Widget */ private function _checkParameters($args) { + // If no options are given to this widget... if (!is_array($args) || (is_array($args) && count($args) == 0)) { show_error('Second parameter of the widget call must be a NOT empty associative array'); } - else + else // ...otherwise { - if ((!isset($args[FiltersLib::APP_PARAMETER]) && !isset($args[FiltersLib::DATASET_NAME_PARAMETER])) - && !isset($args[FiltersLib::FILTER_ID])) + // Parameters (app AND dataset name) OR filter id are mandatory + if ((!isset($args[FilterWidgetLib::APP]) && !isset($args[FilterWidgetLib::DATASET_NAME])) + && !isset($args[FilterWidgetLib::FILTER_ID])) { show_error( - 'The parameters ("'.FiltersLib::APP_PARAMETER.'" and "'.FiltersLib::DATASET_NAME_PARAMETER.') OR "'. - FiltersLib::FILTER_ID.'" must be specified' + 'The parameters ("'.FilterWidgetLib::APP.'" AND "'.FilterWidgetLib::DATASET_NAME.') OR "'. + FilterWidgetLib::FILTER_ID.'" must be specified' ); } - if (!isset($args[FiltersLib::QUERY_PARAMETER])) + // The query parameter is mandatory + if (!isset($args[FilterWidgetLib::QUERY])) { - show_error('The parameters "'.FiltersLib::QUERY_PARAMETER.'" must be specified'); + show_error('The parameter "'.FilterWidgetLib::QUERY.'" must be specified'); } - if (!isset($args[FiltersLib::DATASET_REPRESENTATION])) + // The dataset representation parameter is mandatory + if (!isset($args[FilterWidgetLib::DATASET_REPRESENTATION])) { - show_error('The parameter "'.FiltersLib::DATASET_REPRESENTATION.'" must be specified'); + show_error('The parameter "'.FilterWidgetLib::DATASET_REPRESENTATION.'" must be specified'); } - if (isset($args[FiltersLib::DATASET_REPRESENTATION]) - && $args[FiltersLib::DATASET_REPRESENTATION] != FiltersLib::DATASET_REP_TABLESORTER - && $args[FiltersLib::DATASET_REPRESENTATION] != FiltersLib::DATASET_REP_PIVOTUI) + // Checks if the dataset representation parameter is valid + if (isset($args[FilterWidgetLib::DATASET_REPRESENTATION]) + && $args[FilterWidgetLib::DATASET_REPRESENTATION] != FilterWidgetLib::DATASET_REP_TABLESORTER + && $args[FilterWidgetLib::DATASET_REPRESENTATION] != FilterWidgetLib::DATASET_REP_PIVOTUI + && $args[FilterWidgetLib::DATASET_REPRESENTATION] != FilterWidgetLib::DATASET_REP_TABULATOR) { show_error( - 'The parameter "'.FiltersLib::DATASET_REPRESENTATION. - '" must be IN ("'.FiltersLib::DATASET_REP_TABLESORTER.'", "'.FiltersLib::DATASET_REP_PIVOTUI.'")' + 'The parameter "'.FilterWidgetLib::DATASET_REPRESENTATION. + '" must be IN ("' + .FilterWidgetLib::DATASET_REP_TABLESORTER.'", "' + .FilterWidgetLib::DATASET_REP_PIVOTUI.'", "' + .FilterWidgetLib::DATASET_REP_TABULATOR.'")' ); } + + // If given the session timeout parameter must be a number + if (isset($args[FilterWidgetLib::SESSION_TIMEOUT]) && !is_numeric($args[FilterWidgetLib::SESSION_TIMEOUT])) + { + show_error('The parameter "'.FilterWidgetLib::SESSION_TIMEOUT.'" must be a number'); + } } } @@ -323,52 +405,53 @@ class FilterWidget extends Widget */ private function _startFilterWidget() { + // Looks for expired filter widgets in session and drops them + $this->filterwidgetlib->dropExpiredFilterWidgets(); + // Read the all session for this filter widget - $session = $this->filterslib->getSession(); + $session = $this->filterwidgetlib->getSession(); // If session is NOT empty -> a filter was already loaded if ($session != null) { // Retrieve the filterId stored in the session - $sessionFilterId = $this->filterslib->getSessionElement(FiltersLib::FILTER_ID); + $sessionFilterId = $this->filterwidgetlib->getSessionElement(FilterWidgetLib::FILTER_ID); // If the filter loaded in session is NOT the same that is being requested then empty the session if ($this->_filterId != $sessionFilterId) { - $this->filterslib->setSession(null); + $this->filterwidgetlib->setSession(null); $session = null; } else // else if the filter loaded in session is the same that is being requested { - // Get SESSION_RELOAD_DATASET from the session - $sessionReloadDataset = $this->filterslib->getSessionElement(FiltersLib::SESSION_RELOAD_DATASET); + // Get SESSION_DATASET_RELOAD from the session + $sessionReloadDataset = $this->filterwidgetlib->getSessionElement(FilterWidgetLib::SESSION_DATASET_RELOAD); // if Filter changed or reload is forced by parameter then reload the Dataset if ($this->_reloadDataset === true || $sessionReloadDataset === true) { // Set as false to stop changing the dataset - $this->filterslib->setSessionElement(FiltersLib::SESSION_RELOAD_DATASET, false); + $this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_DATASET_RELOAD, false); // Generate dataset query using filters from the session - $datasetQuery = $this->filterslib->generateDatasetQuery( + $datasetQuery = $this->filterwidgetlib->generateDatasetQuery( $this->_query, - $this->filterslib->getSessionElement(FiltersLib::SESSION_FILTERS) + $this->filterwidgetlib->getSessionElement(FilterWidgetLib::SESSION_FILTERS) ); // Then retrieve dataset from DB - $dataset = $this->filterslib->getDataset($datasetQuery); + $dataset = $this->filterwidgetlib->getDataset($datasetQuery); // Save changes into session if data are valid if (!isError($dataset)) { $this->_formatDataset($dataset); // marks rows using markRow and format rowns using formatRow - $this->load->model('system/Filters_model', 'FiltersModel'); - // Set the new dataset and its attributes in the session - $this->filterslib->setSessionElement(FiltersLib::SESSION_METADATA, $this->FiltersModel->getExecutedQueryMetaData()); - $this->filterslib->setSessionElement(FiltersLib::SESSION_ROW_NUMBER, count($dataset->retval)); - $this->filterslib->setSessionElement(FiltersLib::SESSION_DATASET, $dataset->retval); + $this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_METADATA, $this->FiltersModel->getExecutedQueryMetaData()); + $this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_ROW_NUMBER, count($dataset->retval)); + $this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_DATASET, $dataset->retval); } } } @@ -378,7 +461,7 @@ class FilterWidget extends Widget if ($session == null) { // Load filter definition data from DB - $definition = $this->filterslib->loadDefinition( + $definition = $this->filterwidgetlib->loadDefinition( $this->_filterId, $this->_app, $this->_datasetName, @@ -386,53 +469,54 @@ class FilterWidget extends Widget ); // Checks and parse json present into the definition - $parsedFilterJson = $this->filterslib->parseFilterJson($definition); + $parsedFilterJson = $this->filterwidgetlib->parseFilterJson($definition); if ($parsedFilterJson != null) // if the json is valid { // Generate dataset query - $datasetQuery = $this->filterslib->generateDatasetQuery($this->_query, $parsedFilterJson->filters); + $datasetQuery = $this->filterwidgetlib->generateDatasetQuery($this->_query, $parsedFilterJson->filters); // Then retrieve dataset from DB - $dataset = $this->filterslib->getDataset($datasetQuery); + $dataset = $this->filterwidgetlib->getDataset($datasetQuery); // Try to load the name of the filter using the PhrasesLib - $filterName = $this->filterslib->getFilterName($parsedFilterJson); + $filterName = $this->filterwidgetlib->getFilterName($parsedFilterJson); // Save changes into session if data are valid if (!isError($dataset)) { $this->_formatDataset($dataset); // marks rows using markRow and format rowns using formatRow - $this->load->model('system/Filters_model', 'FiltersModel'); - // Stores an array that contains all the data useful for - $this->filterslib->setSession( + $this->filterwidgetlib->setSession( array( - FiltersLib::FILTER_ID => $this->_filterId, // the current filter id - FiltersLib::APP_PARAMETER => $this->_app, // the current app parameter - FiltersLib::DATASET_NAME_PARAMETER => $this->_datasetName, // the carrent dataset name - FiltersLib::SESSION_FILTER_NAME => $filterName, // the current filter name - FiltersLib::SESSION_FIELDS => $this->FiltersModel->getExecutedQueryListFields(), // all the fields of the dataset - FiltersLib::SESSION_SELECTED_FIELDS => $this->_getColumnsNames($parsedFilterJson->columns), // all the selected fields - FiltersLib::SESSION_COLUMNS_ALIASES => $this->_columnsAliases, // all the fields aliases - FiltersLib::SESSION_ADDITIONAL_COLUMNS => $this->_additionalColumns, // additional columns - FiltersLib::SESSION_CHECKBOXES => $this->_checkboxes, // the name of the field used to build the checkboxes column - FiltersLib::SESSION_FILTERS => $parsedFilterJson->filters, // all the filters used to filter the dataset - FiltersLib::SESSION_METADATA => $this->FiltersModel->getExecutedQueryMetaData(), // the metadata of the dataset - FiltersLib::SESSION_ROW_NUMBER => count($dataset->retval), // the number of loaded rows by this filter - FiltersLib::SESSION_DATASET => $dataset->retval, // the entire dataset - FiltersLib::SESSION_RELOAD_DATASET => false, // if the dataset must be reloaded, not needed the first time - FiltersLib::SESSION_DATASET_REPRESENTATION => $this->_datasetRepresentation, // the choosen dataset representation - FiltersLib::SESSION_DATASET_REP_OPTIONS => $this->_datasetRepresentationOptions // the choosen dataset representation options + FilterWidgetLib::FILTER_ID => $this->_filterId, // the current filter id + FilterWidgetLib::APP => $this->_app, // the current app parameter + FilterWidgetLib::DATASET_NAME => $this->_datasetName, // the carrent dataset name + FilterWidgetLib::SESSION_FILTER_NAME => $filterName, // the current filter name + FilterWidgetLib::SESSION_FIELDS => $this->FiltersModel->getExecutedQueryListFields(), // all the fields of the dataset + FilterWidgetLib::SESSION_SELECTED_FIELDS => $this->_getColumnsNames($parsedFilterJson->columns), // all the selected fields + FilterWidgetLib::SESSION_COLUMNS_ALIASES => $this->_columnsAliases, // all the fields aliases + FilterWidgetLib::SESSION_ADDITIONAL_COLUMNS => $this->_additionalColumns, // additional columns + FilterWidgetLib::SESSION_CHECKBOXES => $this->_checkboxes, // the name of the field used to build the checkboxes column + FilterWidgetLib::SESSION_FILTERS => $parsedFilterJson->filters, // all the filters used to filter the dataset + FilterWidgetLib::SESSION_METADATA => $this->FiltersModel->getExecutedQueryMetaData(), // the metadata of the dataset + FilterWidgetLib::SESSION_ROW_NUMBER => count($dataset->retval), // the number of loaded rows by this filter + FilterWidgetLib::SESSION_DATASET => $dataset->retval, // the entire dataset + FilterWidgetLib::SESSION_DATASET_RELOAD => false, // if the dataset must be reloaded, not needed the first time + FilterWidgetLib::SESSION_DATASET_REPRESENTATION => $this->_datasetRepresentation, // the choosen dataset representation + FilterWidgetLib::SESSION_DATASET_REP_OPTIONS => $this->_datasetRepresentationOptions, // the choosen dataset representation options + FilterWidgetLib::SESSION_DATASET_REP_FIELDS_DEFS => $this->_datasetRepFieldsDefs // the choosen dataset representation record fields definition ) ); } } } + // NOTE: latest operations to be performed in the session to be shure that they are always present // To be always stored in the session, otherwise is not possible to load data from Filters controller - // NOTE: must the latest operation to be performed in the session to be shure that is always present - $this->filterslib->setSessionElement(FiltersLib::REQUIRED_PERMISSIONS_PARAMETER, $this->_requiredPermissions); + $this->filterwidgetlib->setSessionElement(FilterWidgetLib::REQUIRED_PERMISSIONS, $this->_requiredPermissions); + // Renew or set the session expiring time + $this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_TIMEOUT, strtotime('+'.$this->_sessionTimeout.' minutes', time())); } /** @@ -441,7 +525,7 @@ class FilterWidget extends Widget private function _setFilterMenu() { // Generates the filters structure array - $filterMenu = $this->filterslib->generateFilterMenu( + $filterMenu = $this->filterwidgetlib->generateFilterMenu( $this->router->directory.$this->router->class.'/'.$this->router->method ); } diff --git a/application/widgets/Organisationseinheit_widget.php b/application/widgets/Organisationseinheit_widget.php index 67d1598b0..e4fbfe2ba 100644 --- a/application/widgets/Organisationseinheit_widget.php +++ b/application/widgets/Organisationseinheit_widget.php @@ -5,16 +5,34 @@ class Organisationseinheit_widget extends DropdownWidget public function display($widgetData) { $this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); - + if (isset($widgetData['typ'])) - $typ = $widgetData['typ']; + { + $this->setElementsArray($this->OrganisationseinheitModel->getRecursiveList($widgetData['typ'])); + } + // If 'organisationseinheit' (array of specific oe_kurzbz) is given, retrieve these organisational units only + elseif (isset($widgetData['organisationseinheit']) && !empty($widgetData['organisationseinheit'])) + { + $condition = ' + oe_kurzbz IN (\''. implode('\',\'', $widgetData['organisationseinheit']) . '\') AND + aktiv = TRUE + '; + $this->addSelectToModel($this->OrganisationseinheitModel, 'oe_kurzbz', 'organisationseinheittyp_kurzbz || \' \' || bezeichnung'); + $this->OrganisationseinheitModel->addOrder('organisationseinheittyp_kurzbz', 'ASC'); + $this->setElementsArray( + $this->OrganisationseinheitModel->loadWhere($condition), + true, + $this->p->t('lehre', 'organisationseinheit'), + 'No organisational units found' + ); + } + // Default: retrieve tree of all organisational units else - $typ = null; - - // NOTE: no need to call addSelectToModel because getRecursiveList already returns - // the correct names of the fields - - $this->setElementsArray($this->OrganisationseinheitModel->getRecursiveList($typ)); + { + // NOTE: no need to call addSelectToModel because getRecursiveList already returns + // the correct names of the fields + $this->setElementsArray($this->OrganisationseinheitModel->getRecursiveList()); + } $this->loadDropDownView($widgetData); } diff --git a/application/widgets/Studiengang_widget.php b/application/widgets/Studiengang_widget.php index a09c865f5..250f2a9bc 100644 --- a/application/widgets/Studiengang_widget.php +++ b/application/widgets/Studiengang_widget.php @@ -8,15 +8,29 @@ class Studiengang_widget extends DropdownWidget $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); $this->StudiengangModel->addOrder('kurzbzlang'); - $this->addSelectToModel($this->StudiengangModel, 'studiengang_kz', '\'(\' || kurzbzlang || \') \' || bezeichnung'); - - $this->setElementsArray( - $this->StudiengangModel->loadWhere(array('aktiv' => true)), - true, - 'Select a studiengang...', - 'No studiengaenge found' - ); - + $this->addSelectToModel($this->StudiengangModel, 'studiengang_kz', '\'(\' || upper(typ||kurzbz) || \') \' || tbl_studiengang.bezeichnung'); + + // If 'studiengang' (array of specific studiengaenge) is given, retrieve these studiengaenge only + if (isset($widgetData['studiengang']) && !empty($widgetData['studiengang'])) + { + $condition = ' + studiengang_kz IN ('. implode(',', $widgetData['studiengang']) . ') AND + aktiv = true + '; + } + // Default: retrieve all studiengaenge + else + { + $condition = array('aktiv' => true); + } + + $this->setElementsArray( + $this->StudiengangModel->loadWhere($condition), + true, + $this->p->t('lehre', 'studiengang'), + 'No studiengaenge found' + ); + $this->loadDropDownView(); } } \ No newline at end of file diff --git a/application/widgets/Studiensemester_widget.php b/application/widgets/Studiensemester_widget.php index bc1c0a201..dc6e28d38 100644 --- a/application/widgets/Studiensemester_widget.php +++ b/application/widgets/Studiensemester_widget.php @@ -6,14 +6,14 @@ class Studiensemester_widget extends DropdownWidget { // Studiensemester $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); - $this->StudiensemesterModel->addOrder('studiensemester_kurzbz', 'DESC'); + $this->StudiensemesterModel->addOrder('start', 'DESC'); $this->addSelectToModel($this->StudiensemesterModel, 'studiensemester_kurzbz', 'studiensemester_kurzbz'); $this->setElementsArray( $this->StudiensemesterModel->load(), true, - 'Select a studiensemester...', + $this->p->t('lehre', 'studiensemester'), 'No studiensemester found' ); diff --git a/application/widgets/TableWidget.php b/application/widgets/TableWidget.php new file mode 100644 index 000000000..5a000601f --- /dev/null +++ b/application/widgets/TableWidget.php @@ -0,0 +1,440 @@ +load->library('TableWidgetLib'); // Loads the TableWidgetLib that contains all the used logic + + $this->_initTableWidget($args); // checks parameters and initialize properties + + $this->tablewidgetlib->setTableUniqueIdByParams($args); + + // Let's start if it's allowed + // NOTE: If it is NOT allowed then no data are loaded + if ($this->tablewidgetlib->isAllowed($this->_requiredPermissions)) + { + $this->_startTableWidget($args[TableWidgetLib::TABLE_UNIQUE_ID]); + } + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Called when echoing the table widget call + */ + public function display($widgetData) + { + $this->view(self::WIDGET_URL_TABLE, array( + 'tableUniqueId' => $widgetData[TableWidgetLib::TABLE_UNIQUE_ID] + )); // GUI starts here + } + + //------------------------------------------------------------------------------------------------------------------ + // Public static methods used to load views and to access statically to some properies of the TableWidget + + /** + * Loads the view related to the dataset, here is decided how to represent the dataset (ex: tablesorter, pivotUI, ...) + */ + public static function loadViewDataset() + { + if (self::$_TableWidgetInstance->_datasetRepresentation == TableWidgetLib::DATASET_REP_TABLESORTER) + { + self::_loadView(self::WIDGET_URL_DATASET_TABLESORTER); + } + + if (self::$_TableWidgetInstance->_datasetRepresentation == TableWidgetLib::DATASET_REP_PIVOTUI) + { + self::_loadView(self::WIDGET_URL_DATASET_PIVOTUI); + } + + if (self::$_TableWidgetInstance->_datasetRepresentation == TableWidgetLib::DATASET_REP_TABULATOR) + { + self::_loadView(self::WIDGET_URL_DATASET_TABULATOR); + } + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Checks parameters and initialize all the properties of this TableWidget + */ + private function _initTableWidget($args) + { + $this->_checkParameters($args); + + // If here then everything is ok + + // Initialize class properties + $this->_requiredPermissions = null; + $this->_reloadDataset = true; // by default the dataset is NOT cached in session + $this->_query = null; + $this->_additionalColumns = null; + $this->_columnsAliases = null; + $this->_formatRow = null; + $this->_markRow = null; + $this->_checkboxes = null; + $this->_datasetRepresentation = null; + $this->_datasetRepresentationOptions = null; + $this->_datasetRepFieldsDefs = null; + $this->_sessionTimeout = TableWidgetLib::SESSION_DEFAULT_TIMEOUT; + + // Retrieved the required permissions parameter if present + if (isset($args[TableWidgetLib::REQUIRED_PERMISSIONS])) + { + $this->_requiredPermissions = $args[TableWidgetLib::REQUIRED_PERMISSIONS]; + } + + // How to retrieve data for the table: SQL statement or a result from DB + if (isset($args[TableWidgetLib::QUERY])) + { + $this->_query = $args[TableWidgetLib::QUERY]; + } + + if (isset($args[TableWidgetLib::DATASET_RELOAD])) + { + $this->_reloadDataset = $args[TableWidgetLib::DATASET_RELOAD]; + } + + // Parameter is used to add extra columns to the dataset + if (isset($args[TableWidgetLib::ADDITIONAL_COLUMNS]) + && is_array($args[TableWidgetLib::ADDITIONAL_COLUMNS]) + && count($args[TableWidgetLib::ADDITIONAL_COLUMNS]) > 0) + { + $this->_additionalColumns = $args[TableWidgetLib::ADDITIONAL_COLUMNS]; + } + + // Parameter is used to add use aliases for the columns fo the dataset + if (isset($args[TableWidgetLib::COLUMNS_ALIASES]) + && is_array($args[TableWidgetLib::COLUMNS_ALIASES]) + && count($args[TableWidgetLib::COLUMNS_ALIASES]) > 0) + { + $this->_columnsAliases = $args[TableWidgetLib::COLUMNS_ALIASES]; + } + + // Parameter that contains a function to format the rows of the dataset + if (isset($args[TableWidgetLib::FORMAT_ROW]) && is_callable($args[TableWidgetLib::FORMAT_ROW])) + { + $this->_formatRow = $args[TableWidgetLib::FORMAT_ROW]; + } + + // Parameter that contains a function to mark in the GUI the rows of the dataset + if (isset($args[TableWidgetLib::MARK_ROW]) && is_callable($args[TableWidgetLib::MARK_ROW])) + { + $this->_markRow = $args[TableWidgetLib::MARK_ROW]; + } + + // Parameter used to specify the column of the dataset that will be used + // as id of the checkboxes column in the GUI + if (isset($args[TableWidgetLib::CHECKBOXES])) + { + $this->_checkboxes = $args[TableWidgetLib::CHECKBOXES]; + } + + // To specify how to represent the dataset (ex: tablesorter, pivotUI, ...) + if (isset($args[TableWidgetLib::DATASET_REPRESENTATION]) + && ($args[TableWidgetLib::DATASET_REPRESENTATION] == TableWidgetLib::DATASET_REP_TABLESORTER + || $args[TableWidgetLib::DATASET_REPRESENTATION] == TableWidgetLib::DATASET_REP_PIVOTUI + || $args[TableWidgetLib::DATASET_REPRESENTATION] == TableWidgetLib::DATASET_REP_TABULATOR)) + { + $this->_datasetRepresentation = $args[TableWidgetLib::DATASET_REPRESENTATION]; + } + + // To specify options for the dataset representation (ex: tablesorter, pivotUI, ...) + if (isset($args[TableWidgetLib::DATASET_REP_OPTIONS]) && !isEmptyString($args[TableWidgetLib::DATASET_REP_OPTIONS])) + { + $this->_datasetRepresentationOptions = $args[TableWidgetLib::DATASET_REP_OPTIONS]; + } + + // To specify how to represent each record field + if (isset($args[TableWidgetLib::DATASET_REP_FIELDS_DEFS]) && !isEmptyString($args[TableWidgetLib::DATASET_REP_FIELDS_DEFS])) + { + $this->_datasetRepFieldsDefs = $args[TableWidgetLib::DATASET_REP_FIELDS_DEFS]; + } + + // To specify the expiring session time + if (isset($args[TableWidgetLib::SESSION_TIMEOUT]) && is_numeric($args[TableWidgetLib::SESSION_TIMEOUT])) + { + $this->_sessionTimeout = $args[TableWidgetLib::SESSION_TIMEOUT]; + } + } + + /** + * Checks the required parameters used to call this TableWidget + */ + private function _checkParameters($args) + { + // If no options are given to this widget... + if (!is_array($args) || (is_array($args) && count($args) == 0)) + { + show_error('Second parameter of the widget call must be a NOT empty associative array'); + } + else // ...otherwise + { + // The unique id parameter is mandatory + if (!isset($args[TableWidgetLib::TABLE_UNIQUE_ID])) + { + show_error('The parameter "'.TableWidgetLib::TABLE_UNIQUE_ID.'" must be specified'); + } + + // The query parameter is mandatory + if (!isset($args[TableWidgetLib::QUERY])) + { + show_error('The parameter "'.TableWidgetLib::QUERY.'" must be specified'); + } + + // The dataset representation parameter is mandatory + if (!isset($args[TableWidgetLib::DATASET_REPRESENTATION])) + { + show_error('The parameter "'.TableWidgetLib::DATASET_REPRESENTATION.'" must be specified'); + } + + // Checks if the dataset representation parameter is valid + if (isset($args[TableWidgetLib::DATASET_REPRESENTATION]) + && $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_TABLESORTER + && $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_PIVOTUI + && $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_TABULATOR) + { + show_error( + 'The parameter "'.TableWidgetLib::DATASET_REPRESENTATION. + '" must be IN ("' + .TableWidgetLib::DATASET_REP_TABLESORTER.'", "' + .TableWidgetLib::DATASET_REP_PIVOTUI.'", "' + .TableWidgetLib::DATASET_REP_TABULATOR.'")' + ); + } + + // If given the session timeout parameter must be a number + if (isset($args[TableWidgetLib::SESSION_TIMEOUT]) && !is_numeric($args[TableWidgetLib::SESSION_TIMEOUT])) + { + show_error('The parameter "'.TableWidgetLib::SESSION_TIMEOUT.'" must be a number'); + } + } + } + + /** + * Contains all the logic used to load all the data needed to the TableWidget + */ + private function _startTableWidget($tableUniqueId) + { + // Looks for expired table widgets in session and drops them + $this->tablewidgetlib->dropExpiredTableWidgets(); + + // Read the all session for this table widget + $session = $this->tablewidgetlib->getSession(); + + // If session is NOT empty -> a table was already loaded + if ($session != null) + { + // Get SESSION_DATASET_RELOAD from the session + $sessionReloadDataset = $this->tablewidgetlib->getSessionElement(TableWidgetLib::SESSION_DATASET_RELOAD); + + // if Filter changed or reload is forced by parameter then reload the Dataset + if ($this->_reloadDataset === true || $sessionReloadDataset === true) + { + // Set as false to stop changing the dataset + $this->tablewidgetlib->setSessionElement(TableWidgetLib::SESSION_DATASET_RELOAD, false); + + // Generate dataset query using tables from the session + $datasetQuery = $this->tablewidgetlib->generateDatasetQuery($this->_query); + + // Then retrieve dataset from DB + $dataset = $this->tablewidgetlib->getDataset($datasetQuery); + + // Save changes into session if data are valid + if (!isError($dataset)) + { + $this->_formatDataset($dataset); // marks rows using markRow and format rowns using formatRow + + // Set the new dataset and its attributes in the session + $this->tablewidgetlib->setSessionElement(TableWidgetLib::SESSION_METADATA, $this->tablewidgetlib->getExecutedQueryMetaData()); + $this->tablewidgetlib->setSessionElement(TableWidgetLib::SESSION_ROW_NUMBER, count($dataset->retval)); + $this->tablewidgetlib->setSessionElement(TableWidgetLib::SESSION_DATASET, $dataset->retval); + } + } + } + + // If the session is empty -> first time that this table is loaded + if ($session == null) + { + // Generate dataset query + $datasetQuery = $this->tablewidgetlib->generateDatasetQuery($this->_query); + + // Then retrieve dataset from DB + $dataset = $this->tablewidgetlib->getDataset($datasetQuery); + + // Save changes into session if data are valid + if (!isError($dataset)) + { + $this->_formatDataset($dataset); // marks rows using markRow and format rowns using formatRow + + // Stores an array that contains all the data useful for + $this->tablewidgetlib->setSession( + array( + TableWidgetLib::TABLE_UNIQUE_ID => $tableUniqueId, // table unique id + TableWidgetLib::SESSION_FIELDS => $this->tablewidgetlib->getExecutedQueryListFields(), // all the fields of the dataset + TableWidgetLib::SESSION_COLUMNS_ALIASES => $this->_columnsAliases, // all the fields aliases + TableWidgetLib::SESSION_ADDITIONAL_COLUMNS => $this->_additionalColumns, // additional columns + TableWidgetLib::SESSION_CHECKBOXES => $this->_checkboxes, // the name of the field used to build the checkboxes column + TableWidgetLib::SESSION_METADATA => $this->tablewidgetlib->getExecutedQueryMetaData(), // the metadata of the dataset + TableWidgetLib::SESSION_ROW_NUMBER => count($dataset->retval), // the number of loaded rows by this table + TableWidgetLib::SESSION_DATASET => $dataset->retval, // the entire dataset + TableWidgetLib::SESSION_DATASET_RELOAD => false, // if the dataset must be reloaded, not needed the first time + TableWidgetLib::SESSION_DATASET_REPRESENTATION => $this->_datasetRepresentation, // the choosen dataset representation + TableWidgetLib::SESSION_DATASET_REP_OPTIONS => $this->_datasetRepresentationOptions, // the choosen dataset representation options + TableWidgetLib::SESSION_DATASET_REP_FIELDS_DEFS => $this->_datasetRepFieldsDefs // the choosen dataset representation record fields definition + ) + ); + } + } + + // NOTE: must the latest operation to be performed in the session to be shure that is always present + // To be always stored in the session, otherwise is not possible to load data from Filters controller + $this->tablewidgetlib->setSessionElement(TableWidgetLib::REQUIRED_PERMISSIONS, $this->_requiredPermissions); + // Renew or set the session expiring time + $this->tablewidgetlib->setSessionElement(TableWidgetLib::SESSION_TIMEOUT, strtotime('+'.$this->_sessionTimeout.' minutes', time())); + } + + /** + * Calls the method _markRow and _formatRow to marks rows using markRow and format rowns using formatRow + * NOTE: this method operates directly on the retrieved dataset: parameter passed by reference + */ + private function _formatDataset(&$rawDataset) + { + if (hasData($rawDataset) && is_array($rawDataset->retval)) + { + // For each row of the data set + for ($rowCounter = 0; $rowCounter < count($rawDataset->retval); $rowCounter++) + { + // Calls the methods to mark and to format a row + // NOTE: keep this order! the markRow function given as parameter is supposing to work + // on a raw dataset, NOT on a formatted one + $rawDataset->retval[$rowCounter]->MARK_ROW_CLASS = $this->_markRow($rawDataset->retval[$rowCounter]); + $this->_formatRow($rawDataset->retval[$rowCounter]); + } + } + } + + /** + * Formats the columns of all the rows of the entire dataset + * - converts booleans into strings "true" and "false" + * - format dates using the format string defined in DEFAULT_DATE_FORMAT + * Calls the parameter formatRow if it was given and if it is a valid funtion + * NOTE: this method operates directly on the retrieved dataset: parameter passed by reference + */ + private function _formatRow(&$rawDatasetRow) + { + // For each column of the row + foreach ($rawDatasetRow as $columnName => $columnValue) + { + // Basic conversions + if (is_bool($columnValue)) + { + $rawDatasetRow->{$columnName} = ($columnValue === true ? 'true' : 'false'); + } + elseif (DateTime::createFromFormat('Y-m-d H:i:s', $columnValue) !== false) + { + $rawDatasetRow->{$columnName} = date(self::DEFAULT_DATE_FORMAT, strtotime($columnValue)); + } + } + + // If a valid function call the given formatRow + if ($this->_formatRow != null && is_callable($this->_formatRow)) + { + $formatRowFunction = $this->_formatRow; + $rawDatasetRow = $formatRowFunction($rawDatasetRow); + } + } + + /** + * Returns a string that contains a class name used to mark rows in the dataset table + * Calls the parameter markRow if it was given and if it is a valid funtion + */ + private function _markRow($rawDatasetRow) + { + // If a valid function call the given markRow + if ($this->_markRow != null && is_callable($this->_markRow)) + { + $markRowFunction = $this->_markRow; + $class = $markRowFunction($rawDatasetRow); + } + + return !isset($class) ? '' : $class; + } + + /** + * Utility method that retrieves the name of the columns present in a table JSON definition + */ + private function _getColumnsNames($columns) + { + $columnsNames = array(); + + foreach ($columns as $key => $obj) + { + if (isset($obj->name)) + { + $columnsNames[] = $obj->name; + } + } + + return $columnsNames; + } + + /** + * Loads a view using the given viewName and eventually other parameters + */ + private static function _loadView($viewName, $parameters = null) + { + $ci =& get_instance(); + $ci->load->view($viewName, $parameters); + } +} diff --git a/application/widgets/html/DropdownWidget.php b/application/widgets/html/DropdownWidget.php index 5c28e5a9f..eba79900d 100644 --- a/application/widgets/html/DropdownWidget.php +++ b/application/widgets/html/DropdownWidget.php @@ -107,7 +107,7 @@ class DropdownWidget extends HTMLWidget { if (is_object($elements) && isset($elements->retval)) { - show_error($elements->retval); + show_error(getError($elements)); } else if (is_string($elements)) { diff --git a/cis/infoterminal/index.php b/cis/infoterminal/index.php index acbd7b0e4..a3a7dfb91 100644 --- a/cis/infoterminal/index.php +++ b/cis/infoterminal/index.php @@ -20,13 +20,7 @@ * Rudolf Hangl < rudolf.hangl@technikum-wien.at > * Gerald Simane-Sequens < gerald.simane-sequens@technikum-wien.at > */ - -// ------------------------------------------------------------------------------------------ -// Session Starten - Merk Anwenderdaten -// ------------------------------------------------------------------------------------------ - $SESSIONID=trim((isset($_REQUEST['SESSIONID']) ? $_REQUEST['SESSIONID']:'')); - if (session_start($SESSIONID)) - $SESSIONID=@session_id(); +session_start(); require_once('../../config/cis.config.inc.php'); require_once('../../include/wochenplan.class.php'); @@ -1980,6 +1974,9 @@ function personen_id_read_mitarbeiter_oder_student($db,$person_id) */ function read_create_html_news($db,$fachbereich_kurzbz,$studiengang_kz,$semester) { + if(defined('CIS_INFOSCREEN_NEWS_ANZEIGEN') && CIS_INFOSCREEN_NEWS_ANZEIGEN==false) + return ''; + // ------------------------------------------------------------------------------------------ // Lesen Newstickerzeilen // ------------------------------------------------------------------------------------------ diff --git a/cis/private/bildupload.php b/cis/private/bildupload.php index 968f67ab0..b8ce66422 100644 --- a/cis/private/bildupload.php +++ b/cis/private/bildupload.php @@ -23,8 +23,6 @@ */ // Oberflaeche zum Upload von Bildern - -//session_cache_limiter('none'); //muss gesetzt werden damit der upload in chrome und das automatische updaten des profilbildes funktioniert require_once('../../config/cis.config.inc.php'); require_once('../../include/functions.inc.php'); require_once('../../include/person.class.php'); @@ -32,67 +30,52 @@ require_once('../../include/benutzer.class.php'); require_once('../../include/akte.class.php'); require_once('../../include/phrasen.class.php'); require_once('../../include/fotostatus.class.php'); - $user = get_uid(); $sprache = getSprache(); $p = new phrasen($sprache); - echo ' + - - '. - cropCss().' - - - - - - - - - + + '.$p->t('profil/Bildupload').' +

'.$p->t('profil/Bildupload').'

'; - function resize($filename, $width, $height) { - $ext = explode('.',$_FILES['bild']['name']); - $ext = strtolower($ext[count($ext)-1]); + $ext = explode('.',$_FILES['bild']['name']); + $ext = strtolower($ext[count($ext)-1]); + // Hoehe und Breite neu berechnen + list($width_orig, $height_orig) = getimagesize($filename); + if ($width && ($width_orig < $height_orig)) + { + $width = ($height / $height_orig) * $width_orig; + } + else + { + $height = ($width / $width_orig) * $height_orig; + } - // Hoehe und Breite neu berechnen - list($width_orig, $height_orig) = getimagesize($filename); + $image_p = imagecreatetruecolor($width, $height); - if ($width && ($width_orig < $height_orig)) - { - $width = ($height / $height_orig) * $width_orig; - } - else - { - $height = ($width / $width_orig) * $height_orig; - } + $image = imagecreatefromjpeg($filename); - $image_p = imagecreatetruecolor($width, $height); + //Bild nur verkleinern aber nicht vergroessern + if($width_orig>$width || $height_orig>$height) + imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); + else + $image_p = $image; - $image = imagecreatefromjpeg($filename); + imagejpeg($image_p, $filename, 80); - //Bild nur verkleinern aber nicht vergroessern - if($width_orig>$width || $height_orig>$height) - imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); - else - $image_p = $image; - - imagejpeg($image_p, $filename, 80); - - @imagedestroy($image_p); - @imagedestroy($image); + @imagedestroy($image_p); + @imagedestroy($image); } - - if(isset($_GET['person_id'])) { $benutzer = new benutzer(); @@ -107,269 +90,132 @@ if(isset($_GET['person_id'])) } else die($p->t('global/fehlerBeiDerParameteruebergabe')); +//Bei Upload des Bildes +if(isset($_POST['submitbild'])) +{ + if(isset($_FILES['bild']['tmp_name'])) + { + //Extension herausfiltern + $ext = explode('.',$_FILES['bild']['name']); + $ext = mb_strtolower($ext[count($ext)-1]); + $width=101; + $height=130; -echo '
'; -echo $p->t('profil/BilduploadInfotext',array($p->t('dms_link/bildRichtlinien'))).'

'; -echo '
- '.$p->t('profil/fotoAuswählen').' -
- -
- - '; + //--check that it's a jpeg + if ($ext=='jpg' || $ext=='jpeg') + { + $filename = $_FILES['bild']['tmp_name']; -if (isset($_POST['src'])) { - $src = $_POST['src']; - echo $src; + //groesse auf maximal 827x1063 begrenzen + resize($filename, 827, 1063); + + $fp = fopen($filename,'r'); + //auslesen + $content = fread($fp, filesize($filename)); + fclose($fp); + + $akte = new akte(); + + if($akte->getAkten($_GET['person_id'], 'Lichtbil')) + { + if(count($akte->result)>0) + { + $akte = $akte->result[0]; + $akte->new = false; + } + else + $akte->new = true; + } + else + { + $akte->new = true; + } + + $akte->dokument_kurzbz = 'Lichtbil'; + $akte->person_id = $_GET['person_id']; + $akte->inhalt = base64_encode($content); + $akte->mimetype = "image/jpg"; + $akte->erstelltam = date('Y-m-d H:i:s'); + $akte->gedruckt = false; + $akte->titel = "Lichtbild_".$_GET['person_id'].".jpg"; + $akte->bezeichnung = "Lichtbild gross"; + $akte->updateamum = date('Y-m-d H:i:s'); + $akte->updatevon = $user; + $akte->insertamum = date('Y-m-d H:i:s'); + $akte->insertvon = $user; + $akte->uid = ''; + + if(!$akte->save()) + { + echo '
Fehler: '.$akte->errormsg.'
'; + } + + //groesse auf maximal 101x130 begrenzen + resize($filename, 101, 130); + + //in DB speichern + //File oeffnen + $fp = fopen($filename,'r'); + //auslesen + $content = fread($fp, filesize($filename)); + fclose($fp); + //in base64-Werte umrechnen + $content = base64_encode($content); + $person = new person(); + if($person->load($_GET['person_id'])) + { + //base64 Wert in die Datenbank speichern + $person->foto = $content; + $person->new = false; + if($person->save()) + { + $fs = new fotostatus(); + $fs->person_id=$person->person_id; + $fs->fotostatus_kurzbz='hochgeladen'; + $fs->datum = date('Y-m-d'); + $fs->insertamum = date('Y-m-d H:i:s'); + $fs->insertvon = $user; + $fs->updateamum = date('Y-m-d H:i:s'); + $fs->updatevon = $user; + if(!$fs->save(true)) + echo '
Fehler beim Setzen des Bildstatus
'; + else + { + + echo "
Bild wurde erfolgreich gespeichert
+ "; + } + } + else + echo '
'.$person->errormsg.'
'; + } + else + echo '
'.$person->errormsg.'
'; + } + else + echo '
'.$p->t('profil/nurJPGBilder').'
'; + } } -function cropCss() { - return ' - '; -} +//echo '
'; +echo $p->t('profil/BilduploadInfotext',array($p->t('dms_link/bildRichtlinien'))).'

+ + '.$p->t('profil/Bild').':
+ + + '; ?> +
diff --git a/cis/private/coodle/coodle_worker.php b/cis/private/coodle/coodle_worker.php index a16fe553c..8f986e540 100644 --- a/cis/private/coodle/coodle_worker.php +++ b/cis/private/coodle/coodle_worker.php @@ -314,6 +314,24 @@ switch($work) echo $coodletermin->errormsg; break; + + case 'countTermine': + if(isset($_POST['coodle_id'])) + $coodle_id = $_POST['coodle_id']; + else + die('CoodleID fehlt'); + + $coodle = new coodle(); + if ($coodle->getTermine($coodle_id)) + { + echo count($coodle->result); + } + else + { + echo $coodle->errormsg; + } + + break; default: die('Invalid Work Parameter'); } diff --git a/cis/private/coodle/termin.php b/cis/private/coodle/termin.php index 8f0a2cfb7..dd61878c0 100644 --- a/cis/private/coodle/termin.php +++ b/cis/private/coodle/termin.php @@ -76,11 +76,12 @@ if(isset($_POST['action']) && $_POST['action']=='start') // Start der Umfrage $coodle_termine = new coodle(); $coodle_termine->getTermine($coodle_id); - if(count($coodle_termine->result)>0) + // Die Terminoption "keine Auswahl wird immer benötigt. Deshalb > 1 + if(count($coodle_termine->result) > 1) { $coodle_ressource = new coodle(); $coodle_ressource->getRessourcen($coodle_id); - if(count($coodle_ressource->result)>0) + if(count($coodle_ressource->result) > 0) { // Status aendern $coodle->coodle_status_kurzbz='laufend'; @@ -135,16 +136,18 @@ if(isset($_POST['action']) && $_POST['action']=='start') Bitte folgen Sie dem Link, um Ihre Terminwünsche bekannt zu geben: Link zur Terminumfrage

+ '.($coodle->beschreibung != '' ? ' Beschreibung:

- '.$coodle->beschreibung.'

+ '.$coodle->beschreibung.'

' : '').' '.nl2br($sign); $text=$anrede."!\n\nSie wurden zu einer Terminumfrage zum Thema \"".$db->convert_html_chars($coodle->titel)."\" eingeladen.\n Bitte folgen Sie dem Link, um Ihre Terminwünsche bekannt zu geben:\n $link\n\n + ".($coodle->beschreibung != "" ? " Beschreibung:\n\n ".strip_tags($coodle->beschreibung)." - \n\n + \n\n" : "")." $sign"; $mail = new mail($email, $von,'Terminumfrage - '.$coodle->titel, $text); @@ -317,7 +320,6 @@ echo '

- '.$p->t('coodle/ressourcenBeschreibung').' + '.$p->t('coodle/ressourcenBeschreibung'); + echo '

'.$p->t('coodle/externePersonhinzu').'

'.$p->t('coodle/umfrageStarten').'

-
+ - +

'.$p->t('coodle/startBeschreibung').' diff --git a/cis/private/lehre/benotungstool/nachpruefungeintragen.php b/cis/private/lehre/benotungstool/nachpruefungeintragen.php index f1afe0420..0ad985e76 100644 --- a/cis/private/lehre/benotungstool/nachpruefungeintragen.php +++ b/cis/private/lehre/benotungstool/nachpruefungeintragen.php @@ -170,7 +170,9 @@ if (isset($_REQUEST["submit"]) && ($_REQUEST["student_uid"] != '') ) if($pr->getPruefungen($student_uid, "Termin1", $lvid, $stsem)) { if ($pr->result) + { $termin1 = 1; + } else { $lvnote = new lvgesamtnote(); @@ -183,6 +185,7 @@ if (isset($_REQUEST["submit"]) && ($_REQUEST["student_uid"] != '') ) else { $pr_note = 9; + $pr_punkte = ''; $benotungsdatum = $jetzt; } diff --git a/cis/private/lehre/fotoliste.pdf.php b/cis/private/lehre/fotoliste.pdf.php index 8054955ca..3fc04355f 100644 --- a/cis/private/lehre/fotoliste.pdf.php +++ b/cis/private/lehre/fotoliste.pdf.php @@ -1,306 +1,310 @@ - - * - * Description: This file creates a studentlist with students' profile fotos - * by a given studiengangs- and lehrveranstaltungs ID (and eventually a given lehreinheit ID). - * If fotos are locked by student, a dummy picture is inserted instead of the students foto. - * EXCEPTION: if user has admins or assitents rights, ALL students' fotos are iserted (even locked ones) - * - */ - -require_once('../../../config/cis.config.inc.php'); -require_once('../../../include/dokument_export.class.php'); -require_once('../../../include/lehrveranstaltung.class.php'); -require_once('../../../include/lehreinheit.class.php'); -require_once('../../../include/benutzerberechtigung.class.php'); -require_once('../../../include/studiensemester.class.php'); -require_once('../../../include/functions.inc.php'); -require_once('../../../include/erhalter.class.php'); -require_once('../../../include/datum.class.php'); - - -$doc = new dokument_export('fotoliste'); -$output = 'pdf'; -$show_all_fotos = false; - - -//check user access & $_GET vars -if (!$db = new basis_db()) - die('Es konnte keine Verbindung zum Server aufgebaut werden.'); - -$user = get_uid(); - - -if (isset($_GET['lvid']) && is_numeric($_GET['lvid'])) - $lvid = $_GET['lvid']; -else - die('Eine gueltige LvID muss uebergeben werden'); - -isset($_GET['stsem']) ? $studiensemester = $_GET['stsem'] : die('Ein Studiensemester muss uebergeben werden'); - -$lv = new lehrveranstaltung(); -$lv->load($lvid); - -$berechtigung = new benutzerberechtigung(); -$berechtigung->getBerechtigungen($user); - -if (!$berechtigung->isBerechtigt('admin') && !$berechtigung->isBerechtigt('assistenz') && !$berechtigung->isBerechtigt('lehre', $lv->oe_kurzbz, 's') && !check_lektor_lehrveranstaltung($user, $lvid, $studiensemester)) - die('Sie muessen LektorIn der LV sein oder das Recht "ADMIN", "ASSISTENZ" oder "LEHRE" haben, um diese Seite aufrufen zu koennen'); - -if ($berechtigung->isBerechtigt('admin') || $berechtigung->isBerechtigt('assistenz')) - $show_all_fotos = true; - -if (isset($_GET['output']) && ($output = 'odt' || $output = 'doc')) - $output = $_GET['output']; -isset($_GET['stg_kz']) ? $studiengang = $_GET['stg_kz'] : $studiengang = NULL; -isset($_GET['lehreinheit_id']) ? $lehreinheit = $_GET['lehreinheit_id'] : $lehreinheit = NULL; - - -//**************************** overall lehrveranstaltungs data ******************************* -//load overall lehrveranstaltungs-data -$qry = "SELECT DISTINCT ON - (kuerzel, semester, verband, gruppe, gruppe_kurzbz) - UPPER(stg_typ || stg_kurzbz) as kuerzel, - lv_bezeichnung, - stg_bez, - semester, - verband, - gruppe, - gruppe_kurzbz, - stg_typ - FROM - campus.vw_lehreinheit - WHERE - lehrveranstaltung_id=" . $db->db_add_param($lvid, FHC_INTEGER) . " - AND - studiensemester_kurzbz=" . $db->db_add_param($studiensemester); -if ($lehreinheit != '') - $qry .= " AND lehreinheit_id=" . $db->db_add_param($lehreinheit, FHC_INTEGER); - -$gruppen_string = ''; -$gruppen_string_arr = array(); -$stg_typ = ''; - -//structure overall lehrveranstaltungs data -if ($result = $db->db_query($qry)) { - while ($row = $db->db_fetch_object($result)) { - //lehrveranstaltung - $lv_bezeichnung = $row->lv_bezeichnung; - //studiengang - $stg_bezeichnung = $row->stg_bez; - //studiengangstyp - $stg_typ = $row->stg_typ; - //collect all gruppenkürzel - if ($row->gruppe_kurzbz == '') - $gruppen_string = trim($row->kuerzel . '-' . $row->semester . $row->verband . $row->gruppe); - else - $gruppen_string = $row->gruppe_kurzbz; - - $gruppen_string_arr[] = $gruppen_string; - } -} - -//concatinate distinct gruppenkürzel -$studiengruppe = implode(", ", array_unique($gruppen_string_arr)); - -//get studiengangstyp-bezeichnung -$qry = "SELECT - bezeichnung - FROM - public.tbl_studiengangstyp - WHERE - typ =" . $db->db_add_param($stg_typ); - -if ($result = $db->db_query($qry)) { - $row = $db->db_fetch_object($result); - $stg_typ_bezeichnung = $row->bezeichnung; -} - - -//add overall lehrveranstaltungs-data for XML -$data = array( - 'lehrveranstaltung' => $lv_bezeichnung, - 'studiengang' => $stg_bezeichnung, - 'studiengangs_typ' => $stg_typ_bezeichnung, - 'studiensemester' => $studiensemester, - 'studiengruppe' => $studiengruppe -); - - - -//**************************** students data ******************************* -//load students-data -$qry = 'SELECT DISTINCT ON - (nachname, vorname, person_id) - vorname, - nachname, - matrikelnr, - tbl_studentlehrverband.semester, - tbl_studentlehrverband.verband, - tbl_studentlehrverband.gruppe, - (SELECT - status_kurzbz - FROM - public.tbl_prestudentstatus - WHERE - prestudent_id=tbl_student.prestudent_id - ORDER BY - datum DESC, insertamum DESC, ext_id DESC LIMIT 1) as status, - tbl_studiengang.kurzbz, - tbl_studiengang.typ, - tbl_bisio.bisio_id, - tbl_bisio.von, - tbl_bisio.bis, - tbl_student.studiengang_kz AS stg_kz_student, - tbl_zeugnisnote.note, - tbl_mitarbeiter.mitarbeiter_uid, - tbl_person.matr_nr, - tbl_person.geschlecht, - tbl_person.foto, - tbl_person.foto_sperre - FROM - campus.vw_student_lehrveranstaltung - JOIN public.tbl_benutzer USING(uid) - JOIN public.tbl_person USING(person_id) - LEFT JOIN public.tbl_student ON(uid=student_uid) - LEFT JOIN public.tbl_studiengang ON(tbl_studiengang.studiengang_kz=tbl_student.studiengang_kz) - LEFT JOIN public.tbl_mitarbeiter ON(uid=mitarbeiter_uid) - LEFT JOIN public.tbl_studentlehrverband USING(student_uid,studiensemester_kurzbz) - LEFT JOIN lehre.tbl_zeugnisnote ON(vw_student_lehrveranstaltung.lehrveranstaltung_id=tbl_zeugnisnote.lehrveranstaltung_id - AND tbl_zeugnisnote.student_uid=tbl_student.student_uid - AND tbl_zeugnisnote.studiensemester_kurzbz=tbl_studentlehrverband.studiensemester_kurzbz) - LEFT JOIN bis.tbl_bisio ON(uid=tbl_bisio.student_uid) - WHERE - vw_student_lehrveranstaltung.lehrveranstaltung_id=' . $db->db_add_param($lvid, FHC_INTEGER) . ' AND - vw_student_lehrveranstaltung.studiensemester_kurzbz=' . $db->db_add_param($studiensemester); - -if ($lehreinheit != '') - $qry .= ' AND vw_student_lehrveranstaltung.lehreinheit_id=' . $db->db_add_param($lehreinheit, FHC_INTEGER); - -$qry .= ' ORDER BY nachname, vorname, person_id, tbl_bisio.bis DESC'; - -$stsem_obj = new studiensemester(); -$stsem_obj->load($studiensemester); -$stsemdatumvon = $stsem_obj->start; -$stsemdatumbis = $stsem_obj->ende; - -$erhalter = new erhalter(); -$erhalter->getAll(); - -$a_o_kz = '9' . sprintf("%03s", $erhalter->result[0]->erhalter_kz); //Stg_Kz AO-Studierende auslesen (9005 fuer FHTW) -$anzahl_studierende = 0; -$datum = new datum(); -$zusatz = ''; - -//structure students data -if ($result = $db->db_query($qry)) { - while ($row = $db->db_fetch_object($result)) { - if ($row->status != 'Abbrecher' && $row->status != 'Unterbrecher') { - $anzahl_studierende++; - - if ($row->status == 'Incoming') //Incoming - $zusatz = '(i)'; - else - $zusatz = ''; - - if ($row->bisio_id != '' && $row->status != 'Incoming' && ($row->bis > $stsemdatumvon || $row->bis == '') && $row->von < $stsemdatumbis) //Outgoing - $zusatz .= '(o)(ab ' . $datum->formatDatum($row->von, 'd.m.Y') . ')'; - - if ($row->note == 6) //angerechnet - $zusatz .= '(ar)'; - - if ($row->mitarbeiter_uid != '') //mitarbeiter - $zusatz .= '(ma)'; - - if ($row->stg_kz_student == $a_o_kz) //Außerordentliche Studierende - $zusatz .= '(a.o.)'; - - //allow admin and assistenz to see ALL fotos (even if locked by user) - if ($show_all_fotos) - $row->foto_sperre = 'f'; - - //create foto (if not locked by student OR if fotolist is created by admin or assistenz) - $foto_url = ''; - - if ($row->foto_sperre == 'f' && $row->foto != '') { - $foto_src = $row->foto; - $foto_url = sys_get_temp_dir() . '/foto' . trim($row->matrikelnr) . '.jpg'; - $foto_url_arr[] = $foto_url; - - //create writeable file - if (!$foto = fopen($foto_url, 'w')) - die("Das Bild konnte nicht erstellt werden"); - //add foto base64-code - if (!fwrite($foto, base64_decode($foto_src))) - { - die("Das Bild konnte nicht erstellt werden"); - } - - //add foto to document - $doc->addImage($foto_url, trim($row->matrikelnr) . '.jpg', 'image/jpg'); - } - elseif ($row->foto_sperre == 't') - { - $foto_url = 'gesperrt'; - } - - //create studiengruppe - $student_studiengruppe = strtoupper($row->typ.$row->kurzbz.'-'.$row->semester); - - //add studierenden data for XML - $data[] = array('studierende' => array( - 'vorname' => $row->vorname, - 'nachname' => mb_strtoupper($row->nachname, 'UTF-8'), - 'personenkennzeichen' => trim($row->matrikelnr), - 'geschlecht' => $row->geschlecht, - 'foto_gesperrt' => $row->foto_sperre, // f/t - 'foto_url' => $foto_url, - 'studiengruppe' => $student_studiengruppe, - 'verband' => trim($row->verband), - 'gruppe' => trim($row->gruppe), - 'zusatz' => $zusatz - )); - } - } - //Anzahl Studierende in Array $data (an erster Stelle) einfuegen - $data = array_reverse($data, true); - $data['anzahl_studierende'] = $anzahl_studierende; - $data = array_reverse($data, true); -} - -//add data to fotoliste.xsl -$doc->addDataArray($data, 'fotoliste'); - -//set doc name -$doc->setFilename('Fotoliste_'.$stg_bezeichnung.'_'.$studiensemester.'_'.$lv_bezeichnung); - -//create doc in format required -if (!$doc->create($output)) - die($doc->errormsg); - -//download doc -$doc->output(); - -//unlink doc from tmp-folder -$doc->close(); - -//unlink fotos from tmp-folder -foreach ($foto_url_arr as $foto_url) - unlink($foto_url); + + * + * Description: This file creates a studentlist with students' profile fotos + * by a given studiengangs- and lehrveranstaltungs ID (and eventually a given lehreinheit ID). + * If fotos are locked by student, a dummy picture is inserted instead of the students foto. + * EXCEPTION: if user has admins or assitents rights, ALL students' fotos are iserted (even locked ones) + * + */ + +require_once('../../../config/cis.config.inc.php'); +require_once('../../../include/dokument_export.class.php'); +require_once('../../../include/lehrveranstaltung.class.php'); +require_once('../../../include/lehreinheit.class.php'); +require_once('../../../include/benutzerberechtigung.class.php'); +require_once('../../../include/studiensemester.class.php'); +require_once('../../../include/studiengang.class.php'); +require_once('../../../include/functions.inc.php'); +require_once('../../../include/erhalter.class.php'); +require_once('../../../include/datum.class.php'); + + +$doc = new dokument_export('fotoliste'); +$output = 'pdf'; +$show_all_fotos = false; + + +//check user access & $_GET vars +if (!$db = new basis_db()) + die('Es konnte keine Verbindung zum Server aufgebaut werden.'); + +$user = get_uid(); + + +if (isset($_GET['lvid']) && is_numeric($_GET['lvid'])) + $lvid = $_GET['lvid']; +else + die('Eine gueltige LvID muss uebergeben werden'); + +isset($_GET['stsem']) ? $studiensemester = $_GET['stsem'] : die('Ein Studiensemester muss uebergeben werden'); + +$lv = new lehrveranstaltung(); +$lv->load($lvid); + +$stg = new studiengang(); +$stg->load($lv->studiengang_kz); + +$berechtigung = new benutzerberechtigung(); +$berechtigung->getBerechtigungen($user); + +if (!$berechtigung->isBerechtigt('admin') && !$berechtigung->isBerechtigt('assistenz') && !$berechtigung->isBerechtigt('lehre', $lv->oe_kurzbz, 's') && !check_lektor_lehrveranstaltung($user, $lvid, $studiensemester)) + die('Sie muessen LektorIn der LV sein oder das Recht "ADMIN", "ASSISTENZ" oder "LEHRE" haben, um diese Seite aufrufen zu koennen'); + +if ($berechtigung->isBerechtigt('admin') || $berechtigung->isBerechtigt('assistenz')) + $show_all_fotos = true; + +if (isset($_GET['output']) && ($output = 'odt' || $output = 'doc')) + $output = $_GET['output']; +isset($_GET['stg_kz']) ? $studiengang = $_GET['stg_kz'] : $studiengang = NULL; +isset($_GET['lehreinheit_id']) ? $lehreinheit = $_GET['lehreinheit_id'] : $lehreinheit = NULL; + + +//**************************** overall lehrveranstaltungs data ******************************* +//load overall lehrveranstaltungs-data +$qry = "SELECT DISTINCT ON + (kuerzel, semester, verband, gruppe, gruppe_kurzbz) + UPPER(stg_typ || stg_kurzbz) as kuerzel, + lv_bezeichnung, + stg_bez, + semester, + verband, + gruppe, + gruppe_kurzbz, + stg_typ + FROM + campus.vw_lehreinheit + WHERE + lehrveranstaltung_id=" . $db->db_add_param($lvid, FHC_INTEGER) . " + AND + studiensemester_kurzbz=" . $db->db_add_param($studiensemester); +if ($lehreinheit != '') + $qry .= " AND lehreinheit_id=" . $db->db_add_param($lehreinheit, FHC_INTEGER); + +$gruppen_string = ''; +$gruppen_string_arr = array(); +$stg_typ = $stg->typ; +$stg_bezeichnung = $stg->bezeichnung; + +//structure overall lehrveranstaltungs data +if ($result = $db->db_query($qry)) { + while ($row = $db->db_fetch_object($result)) { + //lehrveranstaltung + $lv_bezeichnung = $row->lv_bezeichnung; + + //collect all gruppenkürzel + if ($row->gruppe_kurzbz == '') + $gruppen_string = trim($row->kuerzel . '-' . $row->semester . $row->verband . $row->gruppe); + else + $gruppen_string = $row->gruppe_kurzbz; + + $gruppen_string_arr[] = $gruppen_string; + } +} + +//concatinate distinct gruppenkürzel +$studiengruppe = implode(", ", array_unique($gruppen_string_arr)); + +//get studiengangstyp-bezeichnung +$qry = "SELECT + bezeichnung + FROM + public.tbl_studiengangstyp + WHERE + typ =" . $db->db_add_param($stg_typ); + +if ($result = $db->db_query($qry)) { + $row = $db->db_fetch_object($result); + $stg_typ_bezeichnung = $row->bezeichnung; +} + + +//add overall lehrveranstaltungs-data for XML +$data = array( + 'lehrveranstaltung' => $lv_bezeichnung, + 'studiengang' => $stg_bezeichnung, + 'studiengangs_typ' => $stg_typ_bezeichnung, + 'studiensemester' => $studiensemester, + 'studiengruppe' => $studiengruppe +); + + + +//**************************** students data ******************************* +//load students-data +$qry = 'SELECT DISTINCT ON + (nachname, vorname, person_id) + vorname, + nachname, + matrikelnr, + tbl_studentlehrverband.semester, + tbl_studentlehrverband.verband, + tbl_studentlehrverband.gruppe, + (SELECT + status_kurzbz + FROM + public.tbl_prestudentstatus + WHERE + prestudent_id=tbl_student.prestudent_id + ORDER BY + datum DESC, insertamum DESC, ext_id DESC LIMIT 1) as status, + tbl_studiengang.kurzbz, + tbl_studiengang.typ, + tbl_bisio.bisio_id, + tbl_bisio.von, + tbl_bisio.bis, + tbl_student.studiengang_kz AS stg_kz_student, + tbl_zeugnisnote.note, + tbl_mitarbeiter.mitarbeiter_uid, + tbl_person.person_id, + tbl_person.matr_nr, + tbl_person.geschlecht, + tbl_person.foto, + tbl_person.foto_sperre + FROM + campus.vw_student_lehrveranstaltung + JOIN public.tbl_benutzer USING(uid) + JOIN public.tbl_person USING(person_id) + LEFT JOIN public.tbl_student ON(uid=student_uid) + LEFT JOIN public.tbl_studiengang ON(tbl_studiengang.studiengang_kz=tbl_student.studiengang_kz) + LEFT JOIN public.tbl_mitarbeiter ON(uid=mitarbeiter_uid) + LEFT JOIN public.tbl_studentlehrverband USING(student_uid,studiensemester_kurzbz) + LEFT JOIN lehre.tbl_zeugnisnote ON(vw_student_lehrveranstaltung.lehrveranstaltung_id=tbl_zeugnisnote.lehrveranstaltung_id + AND tbl_zeugnisnote.student_uid=tbl_student.student_uid + AND tbl_zeugnisnote.studiensemester_kurzbz=tbl_studentlehrverband.studiensemester_kurzbz) + LEFT JOIN bis.tbl_bisio ON(uid=tbl_bisio.student_uid) + WHERE + vw_student_lehrveranstaltung.lehrveranstaltung_id=' . $db->db_add_param($lvid, FHC_INTEGER) . ' AND + vw_student_lehrveranstaltung.studiensemester_kurzbz=' . $db->db_add_param($studiensemester); + +if ($lehreinheit != '') + $qry .= ' AND vw_student_lehrveranstaltung.lehreinheit_id=' . $db->db_add_param($lehreinheit, FHC_INTEGER); + +$qry .= ' ORDER BY nachname, vorname, person_id, tbl_bisio.bis DESC'; + +$stsem_obj = new studiensemester(); +$stsem_obj->load($studiensemester); +$stsemdatumvon = $stsem_obj->start; +$stsemdatumbis = $stsem_obj->ende; + +$erhalter = new erhalter(); +$erhalter->getAll(); + +$a_o_kz = '9' . sprintf("%03s", $erhalter->result[0]->erhalter_kz); //Stg_Kz AO-Studierende auslesen (9005 fuer FHTW) +$anzahl_studierende = 0; +$datum = new datum(); +$zusatz = ''; +$foto_url_arr = array(); + +//structure students data +if ($result = $db->db_query($qry)) { + while ($row = $db->db_fetch_object($result)) { + if ($row->status != 'Abbrecher' && $row->status != 'Unterbrecher') { + $anzahl_studierende++; + + if ($row->status == 'Incoming') //Incoming + $zusatz = '(i)'; + else + $zusatz = ''; + + if ($row->bisio_id != '' && $row->status != 'Incoming' && ($row->bis > $stsemdatumvon || $row->bis == '') && $row->von < $stsemdatumbis) //Outgoing + $zusatz .= '(o)(ab ' . $datum->formatDatum($row->von, 'd.m.Y') . ')'; + + if ($row->note == 6) //angerechnet + $zusatz .= '(ar)'; + + if ($row->mitarbeiter_uid != '') //mitarbeiter + $zusatz .= '(ma)'; + + if ($row->stg_kz_student == $a_o_kz) //Außerordentliche Studierende + $zusatz .= '(a.o.)'; + + //allow admin and assistenz to see ALL fotos (even if locked by user) + if ($show_all_fotos) + $row->foto_sperre = 'f'; + + //create foto (if not locked by student OR if fotolist is created by admin or assistenz) + $foto_url = ''; + + if ($row->foto_sperre == 'f' && $row->foto != '') { + $foto_src = $row->foto; + $foto_url = sys_get_temp_dir() . '/foto' . trim($row->person_id) . '.jpg'; + $foto_url_arr[] = $foto_url; + + //create writeable file + if (!$foto = fopen($foto_url, 'w')) + die("Das Bild konnte nicht erstellt werden"); + //add foto base64-code + if (!fwrite($foto, base64_decode($foto_src))) + { + die("Das Bild konnte nicht erstellt werden"); + } + + //add foto to document + $doc->addImage($foto_url, trim($row->person_id) . '.jpg', 'image/jpg'); + } + elseif ($row->foto_sperre == 't') + { + $foto_url = 'gesperrt'; + } + + //create studiengruppe + $student_studiengruppe = strtoupper($row->typ.$row->kurzbz.'-'.$row->semester); + + //add studierenden data for XML + $data[] = array('studierende' => array( + 'vorname' => $row->vorname, + 'nachname' => mb_strtoupper($row->nachname, 'UTF-8'), + 'personenkennzeichen' => trim($row->matrikelnr), + 'geschlecht' => $row->geschlecht, + 'foto_gesperrt' => $row->foto_sperre, // f/t + 'foto_url' => $foto_url, + 'studiengruppe' => $student_studiengruppe, + 'verband' => trim($row->verband), + 'gruppe' => trim($row->gruppe), + 'zusatz' => $zusatz + )); + } + } + //Anzahl Studierende in Array $data (an erster Stelle) einfuegen + $data = array_reverse($data, true); + $data['anzahl_studierende'] = $anzahl_studierende; + $data = array_reverse($data, true); +} + +//add data to fotoliste.xsl +$doc->addDataArray($data, 'fotoliste'); + +//set doc name +$doc->setFilename('Fotoliste_'.$stg_bezeichnung.'_'.$studiensemester.'_'.$lv_bezeichnung); + +//create doc in format required +if (!$doc->create($output)) + die($doc->errormsg); + +//download doc +$doc->output(); + +//unlink doc from tmp-folder +$doc->close(); + +//unlink fotos from tmp-folder +foreach ($foto_url_arr as $foto_url) + unlink($foto_url); diff --git a/cis/private/lehre/notenliste.php b/cis/private/lehre/notenliste.php index 5cdea3111..56fd4a36d 100644 --- a/cis/private/lehre/notenliste.php +++ b/cis/private/lehre/notenliste.php @@ -1,441 +1,445 @@ -, - * Andreas Oesterreicher - * Rudolf Hangl < rudolf.hangl@technikum-wien.at > - * Gerald Simane-Sequens < gerald.simane-sequens@technikum-wien.at > - */ -/* - * Erstellt eine Liste mit den Noten des eingeloggten Studenten - * das betreffende Studiensemester kann ausgewaehlt werden - */ -require_once('../../../config/cis.config.inc.php'); -require_once('../../../config/global.config.inc.php'); -require_once('../../../include/functions.inc.php'); -require_once('../../../include/studiensemester.class.php'); -require_once('../../../include/datum.class.php'); -require_once('../../../include/note.class.php'); -require_once('../../../include/phrasen.class.php'); -require_once('../../../include/studiengang.class.php'); -require_once('../../../include/studienordnung.class.php'); -require_once('../../../include/lehrveranstaltung.class.php'); -require_once('../../../include/pruefung.class.php'); -require_once('../../../include/benutzerberechtigung.class.php'); -require_once('../../../include/prestudent.class.php'); - -$sprache = getSprache(); -$p = new phrasen($sprache); - -if (! $db = new basis_db()) - die($p->t('global/fehlerBeimOeffnenDerDatenbankverbindung')); - -if (isset($_GET['stsem'])) - $stsem = $_GET['stsem']; -else - $stsem = ''; - -echo ' - - - - - - - - - - - - ' . $p->t('tools/leistungsbeurteilung') . ' - - - - - -

' . $p->t('tools/leistungsbeurteilung') . '

'; - -$user = get_uid(); - -if (isset($_GET['uid'])) -{ - // Administratoren duerfen die UID als Parameter uebergeben um die Notenliste - // von anderen Personen anzuzeigen - - $rechte = new benutzerberechtigung(); - $rechte->getBerechtigungen($user); - if ($rechte->isBerechtigt('admin')) - { - $user = $_GET['uid']; - $getParam = "&uid=" . $user; - } - else - $getParam = ""; -} -else - $getParam = ''; - -$datum_obj = new datum(); - -$error = ''; - -if (! check_student($user)) -{ - $error .= $p->t('tools/mussAlsStudentEingeloggtSein'); -} -else -{ - $qry = "SELECT vw_student.vorname, vw_student.nachname, vw_student.prestudent_id, tbl_studiengang.studiengang_kz - FROM public.tbl_studiengang JOIN campus.vw_student USING (studiengang_kz) - WHERE campus.vw_student.uid = " . $db->db_add_param($user) . ";"; - - if (! $result = $db->db_query($qry)) - die($p->t('tools/studentWurdeNichtGefunden')); - else - { - $row = $db->db_fetch_object($result); - - $vorname = $row->vorname; - $nachname = $row->nachname; - $prestudent_id = $row->prestudent_id; - $stg_obj = new studiengang(); - $stg_obj->load($row->studiengang_kz); - $stg_name = $stg_obj->bezeichnung_arr[$sprache]; - $prestudent_id = $row->prestudent_id; - $prestudent = new prestudent($prestudent_id); - if ($prestudent->getLastStatus($prestudent_id)) - { - $studienplan_id = $prestudent->studienplan_id; - $studienordnung = new studienordnung(); - if ($studienordnung->getStudienordnungFromStudienplan($studienplan_id)) - { - $studiengangbezeichnung_sto = $sprache === 'English' ? $studienordnung->__get('studiengangbezeichnung_englisch') : $studienordnung->__get('studiengangbezeichnung'); - } - } - - $studiengang_bezeichnung = empty($studiengangbezeichnung_sto) ? $stg_name : $studiengangbezeichnung_sto; - } - - $notenarr = array(); - $note = new note(); - $note->getAll(); - foreach ($note->result as $row) - { - $notenarr[$row->note]['bezeichnung'] = $row->bezeichnung; - $notenarr[$row->note]['notenwert'] = $row->notenwert; - } - - // Aktuelles Studiensemester ermitteln - - $stsem_obj = new studiensemester(); - if ($stsem == '') - $stsem = $stsem_obj->getaktorNext(); - - // Erstes und letztes Studiensemester mit Studenten-Status ermitteln - $prestudent = new prestudent(); - // Wenn Incoming, dann Incomingstatus laden, sonst Studentenstatus - $prestudent->getPrestudentRolle($prestudent_id, 'Incoming'); - if(count($prestudent->result) > 0) - { - $prestudent->getFirstStatus($prestudent_id, 'Incoming'); - $firstStudiensemester = $prestudent->studiensemester_kurzbz; - $prestudent->getLastStatus($prestudent_id, null, 'Incoming'); - $lastStudiensemester = $prestudent->studiensemester_kurzbz; - } - else - { - $prestudent->getFirstStatus($prestudent_id, 'Student'); - $firstStudiensemester = $prestudent->studiensemester_kurzbz; - $prestudent->getLastStatus($prestudent_id, null, 'Student'); - $lastStudiensemester = $prestudent->studiensemester_kurzbz; - } - - $stsem_obj->getStudiensemesterBetween($firstStudiensemester, $lastStudiensemester); - - echo "
"; - echo "".$p->t('global/name').": $vorname $nachname
"; - echo "".$p->t('global/studiengang').": $studiengang_bezeichnung
"; - echo "".$p->t('global/studiensemester')."
"; - - // echo "Datum: ".date('d.m.Y')."
"; - echo "
"; - if ($notenImAktuellenStSem == false) - { - $stsem = 'alle'; - } - // Lehrveranstaltungen und Noten holen - if ($stsem != "alle") - { - $sqlFilter = " AND tbl_zeugnisnote.studiensemester_kurzbz = " . $db->db_add_param($stsem) . " - AND (tbl_lvgesamtnote.studiensemester_kurzbz = " . $db->db_add_param($stsem) . " OR tbl_lvgesamtnote.studiensemester_kurzbz is null) "; - } - else - $sqlFilter = ""; - - $qry = "SELECT - tbl_lehrveranstaltung.lehrveranstaltung_id, tbl_zeugnisnote.note, tbl_zeugnisnote.punkte, - tbl_lvgesamtnote.note as lvnote, tbl_lvgesamtnote.punkte as lvpunkte, - tbl_zeugnisnote.benotungsdatum, tbl_lvgesamtnote.freigabedatum, - tbl_lvgesamtnote.benotungsdatum as lvbenotungsdatum, - tbl_zeugnisnote.studiensemester_kurzbz AS studiensemester_zeugnis, tbl_lvgesamtnote.studiensemester_kurzbz AS studiensemester_lvnote, - tbl_lehrveranstaltung.zeugnis, tbl_lehrveranstaltung.ects - FROM - lehre.tbl_lehrveranstaltung, lehre.tbl_zeugnisnote - LEFT OUTER JOIN - campus.tbl_lvgesamtnote - USING (lehrveranstaltung_id, student_uid, studiensemester_kurzbz) - WHERE - tbl_zeugnisnote.student_uid = " . $db->db_add_param($user) . $sqlFilter . " - AND tbl_lehrveranstaltung.lehrveranstaltung_id = tbl_zeugnisnote.lehrveranstaltung_id - ORDER BY bezeichnung"; - - if ($result = $db->db_query($qry)) - { - // Tabelle anzeigen - $tbl = ""; - $tblHead = " - - "; - if ($stsem == "alle") - $tblHead .= ""; - - $tblHead .= ""; - if (defined('CIS_GESAMTNOTE_PUNKTE') && CIS_GESAMTNOTE_PUNKTE) - $tblHead .= ""; - - $tblHead .= " "; - if (defined('CIS_GESAMTNOTE_PUNKTE') && CIS_GESAMTNOTE_PUNKTE) - $tblHead .= ""; - - $tblHead .= " - - - - "; - $tblBody = ""; - $i = 0; - $legende = false; - $notenSummenArray = array(); - while ($row = $db->db_fetch_object($result)) - { - $lv_obj = new lehrveranstaltung(); - $lv_obj->load($row->lehrveranstaltung_id); - - $i ++; - $tblBody .= ""; - if ($stsem == "alle") - $tblBody .= ""; - - // LV Gesamtnote Punkte - if (defined('CIS_GESAMTNOTE_PUNKTE') && CIS_GESAMTNOTE_PUNKTE) - { - $lvpunkte = ($row->lvpunkte != '' ? (float) $row->lvpunkte : ''); - $tblBody .= ""; - } - - if ($row->note != $row->lvnote && $row->lvnote != NULL) - { - $markier = " style='background-color: #FFD999;'"; - $legende = true; - } - else - $markier = ""; - $tblBody .= ""; - - if (defined('CIS_GESAMTNOTE_PUNKTE') && CIS_GESAMTNOTE_PUNKTE) - { - $punkte = ($row->punkte != '' ? ((float) $row->punkte) : ''); - $tblBody .= ""; - } - - $tblBody .= ''; - - $pruefung = new pruefung(); - $pruefung->getPruefungen($user, null, $row->lehrveranstaltung_id, $stsem); - - if (count($pruefung->result) > 0) - { - $tblBody .= ''; - } - else - $tblBody .= ''; - - $tblBody .= ""; - } - // Durchschnitt und gewichteten Durchschnitt berechnen - $notenSumme = 0; - $notenSummeGewichtet = 0; - $ectsSumme = 0; - $anzahlLv = 0; - foreach ($notenSummenArray AS $key => $value) - { - if ($value['notenwert'] != '') - { - $anzahlLv++; - $notenSumme += $value['notenwert']; - $ectsSumme += $value['ects']; - $notenSummeGewichtet += $value['notenwert'] * $value['ects']; - } - } - - $tblBody .= ""; - $tblFoot = ""; - - if ($anzahlLv != 0) - $notenDurchschnitt = round($notenSumme / $anzahlLv, 2); - else - $notenDurchschnitt = 0; - - if ($ectsSumme != 0) - $notenDurchschnittGewichtet = round($notenSummeGewichtet / $ectsSumme, 2); - else - $notenDurchschnittGewichtet = 0; - - $tblFoot .= ''; - $tblFoot .= ''; - $tblFoot .= ''; - $tblFoot .= ''; - $tblFoot .= ""; - - $tblFoot .= ''; - $tblFoot .= ''; - $tblFoot .= ''; - $tblFoot .= ''; - - $tblFoot .= ""; - - $tblFoot .= ""; - - $tbl .= $tblHead.$tblFoot.$tblBody; - - $tbl .= "
" . $p->t('global/lehrveranstaltung') . "" . $p->t('global/studiensemester') . "" . $p->t('benotungstool/lvNote') . "" . $p->t('benotungstool/punkte') . "" . $p->t('benotungstool/zeugnisnote') . "" . $p->t('benotungstool/punkte') . "" . $p->t('tools/benotungsdatumDerZeugnisnote') . "" . $p->t('benotungstool/pruefung') . "
" . $lv_obj->bezeichnung_arr[$sprache] . ($lv_obj->lehrform_kurzbz != "" && $lv_obj->lehrform_kurzbz != " - " ? " (" . $lv_obj->lehrform_kurzbz . ")" : "") . "" . ($row->studiensemester_zeugnis != '' ? $row->studiensemester_zeugnis : $row->studiensemester_lvnote) . ""; - - $tblBody .= ""; - - // Nur freigegebene Noten anzeigen - if ($row->freigabedatum >= $row->lvbenotungsdatum) - { - if (isset($notenarr[$row->lvnote])) - $tblBody .= $notenarr[$row->lvnote]['bezeichnung']; - else - $tblBody .= $row->lvnote; - - // Nur Noten, die aufs Zeugnis gedruckt werden für Durchschnittsberechnung addieren - if ($row->zeugnis == true) - { - $notenSummenArray[$row->lehrveranstaltung_id]['notenwert'] = (isset($notenarr[$row->note]['notenwert']) ? $notenarr[$row->note]['notenwert'] : ''); - $notenSummenArray[$row->lehrveranstaltung_id]['ects'] = $row->ects; - } - } - $tblBody .= "" . $lvpunkte . ""; - - if (isset($notenarr[$row->note])) - $tblBody .= $notenarr[$row->note]['bezeichnung']; - else - $tblBody .= $row->note; - - $tblBody .= "" . $punkte . "' . $datum_obj->formatDatum($row->benotungsdatum, 'Y-m-d') . ''; - foreach ($pruefung->result as $row) - { - if (isset($notenarr[$row->note])) - $note = $notenarr[$row->note]['bezeichnung']; - else - $note = $row->note; - - if ($row->punkte != '') - $punkte = ' (' . (float) $row->punkte . ')'; - else - $punkte = ''; - - $tblBody .= $row->pruefungstyp_beschreibung . ' ' . $datum_obj->formatDatum($row->datum, 'd.m.Y') . ' ' . $note . $punkte . '
'; - } - $tblBody .= '
' . $p->t("tools/notendurchschnittDerZeugnisnote") . ''.$notenDurchschnitt.'
' . $p->t("tools/gewichteterNotendurchschnittDerZeugnisnote") . ''.$notenDurchschnittGewichtet.'
"; - $tbl .= ""; - if ($legende) - { - $tbl .= ""; - } - $tbl .= "
*" . $p->t('tools/legendeNotendurchschnitt') . "
**" . $p->t('tools/legendeGewichteterNotendurchschnitt') . "
" . $p->t('tools/hinweistextMarkierung') . "
"; - if ($i == 0) - echo $p->t('tools/nochKeineBeurteilungEingetragen'); - else - { - $tbl .= "


"; - echo $tbl; - } - } - else - { - $error .= $p->t('tools/fehlerBeimAuslesenDerNoten'); - } -} -echo $error; -echo ' -'; -?> +, + * Andreas Oesterreicher + * Rudolf Hangl < rudolf.hangl@technikum-wien.at > + * Gerald Simane-Sequens < gerald.simane-sequens@technikum-wien.at > + */ +/* + * Erstellt eine Liste mit den Noten des eingeloggten Studenten + * das betreffende Studiensemester kann ausgewaehlt werden + */ +require_once('../../../config/cis.config.inc.php'); +require_once('../../../config/global.config.inc.php'); +require_once('../../../include/functions.inc.php'); +require_once('../../../include/studiensemester.class.php'); +require_once('../../../include/datum.class.php'); +require_once('../../../include/note.class.php'); +require_once('../../../include/phrasen.class.php'); +require_once('../../../include/studiengang.class.php'); +require_once('../../../include/studienordnung.class.php'); +require_once('../../../include/lehrveranstaltung.class.php'); +require_once('../../../include/pruefung.class.php'); +require_once('../../../include/benutzerberechtigung.class.php'); +require_once('../../../include/prestudent.class.php'); + +$sprache = getSprache(); +$p = new phrasen($sprache); + +if (! $db = new basis_db()) + die($p->t('global/fehlerBeimOeffnenDerDatenbankverbindung')); + +if (isset($_GET['stsem'])) + $stsem = $_GET['stsem']; +else + $stsem = ''; + +echo ' + + + + + + + + + + + + ' . $p->t('tools/leistungsbeurteilung') . ' + + + + + +

' . $p->t('tools/leistungsbeurteilung') . '

'; + +$user = get_uid(); + +if (isset($_GET['uid'])) +{ + // Administratoren duerfen die UID als Parameter uebergeben um die Notenliste + // von anderen Personen anzuzeigen + + $rechte = new benutzerberechtigung(); + $rechte->getBerechtigungen($user); + if ($rechte->isBerechtigt('admin')) + { + $user = $_GET['uid']; + $getParam = "&uid=" . $user; + } + else + $getParam = ""; +} +else + $getParam = ''; + +$datum_obj = new datum(); + +$error = ''; + +if (! check_student($user)) +{ + $error .= $p->t('tools/mussAlsStudentEingeloggtSein'); +} +else +{ + $qry = "SELECT vw_student.vorname, vw_student.nachname, vw_student.prestudent_id, tbl_studiengang.studiengang_kz + FROM public.tbl_studiengang JOIN campus.vw_student USING (studiengang_kz) + WHERE campus.vw_student.uid = " . $db->db_add_param($user) . ";"; + + if (! $result = $db->db_query($qry)) + die($p->t('tools/studentWurdeNichtGefunden')); + else + { + $row = $db->db_fetch_object($result); + + $vorname = $row->vorname; + $nachname = $row->nachname; + $prestudent_id = $row->prestudent_id; + $stg_obj = new studiengang(); + $stg_obj->load($row->studiengang_kz); + $stg_name = $stg_obj->bezeichnung_arr[$sprache]; + $prestudent_id = $row->prestudent_id; + $prestudent = new prestudent($prestudent_id); + if ($prestudent->getLastStatus($prestudent_id)) + { + $studienplan_id = $prestudent->studienplan_id; + $studienordnung = new studienordnung(); + if ($studienordnung->getStudienordnungFromStudienplan($studienplan_id)) + { + $studiengangbezeichnung_sto = $sprache === 'English' ? $studienordnung->__get('studiengangbezeichnung_englisch') : $studienordnung->__get('studiengangbezeichnung'); + } + } + + $studiengang_bezeichnung = empty($studiengangbezeichnung_sto) ? $stg_name : $studiengangbezeichnung_sto; + } + + $notenarr = array(); + $note = new note(); + $note->getAll(); + foreach ($note->result as $row) + { + $notenarr[$row->note]['bezeichnung'] = $row->bezeichnung; + $notenarr[$row->note]['notenwert'] = $row->notenwert; + } + + // Aktuelles Studiensemester ermitteln + + $stsem_obj = new studiensemester(); + if ($stsem == '') + $stsem = $stsem_obj->getaktorNext(); + + // Erstes und letztes Studiensemester mit Studenten-Status ermitteln + $prestudent = new prestudent(); + // Wenn Incoming, dann Incomingstatus laden, sonst Studentenstatus + $prestudent->getPrestudentRolle($prestudent_id, 'Incoming'); + if(count($prestudent->result) > 0) + { + $prestudent->getFirstStatus($prestudent_id, 'Incoming'); + $firstStudiensemester = $prestudent->studiensemester_kurzbz; + $prestudent->getLastStatus($prestudent_id, null, 'Incoming'); + $lastStudiensemester = $prestudent->studiensemester_kurzbz; + } + else + { + $prestudent->getFirstStatus($prestudent_id, 'Student'); + $firstStudiensemester = $prestudent->studiensemester_kurzbz; + $prestudent->getLastStatus($prestudent_id, null, 'Student'); + $lastStudiensemester = $prestudent->studiensemester_kurzbz; + } + + $stsem_obj->getStudiensemesterBetween($firstStudiensemester, $lastStudiensemester); + + echo "
"; + echo "".$p->t('global/name').": $vorname $nachname
"; + echo "".$p->t('global/studiengang').": $studiengang_bezeichnung
"; + echo "".$p->t('global/studiensemester')."
"; + + // echo "Datum: ".date('d.m.Y')."
"; + echo "
"; + if ($notenImAktuellenStSem == false) + { + $stsem = 'alle'; + } + // Lehrveranstaltungen und Noten holen + if ($stsem != "alle") + { + $sqlFilter = " AND tbl_zeugnisnote.studiensemester_kurzbz = " . $db->db_add_param($stsem) . " + AND (tbl_lvgesamtnote.studiensemester_kurzbz = " . $db->db_add_param($stsem) . " OR tbl_lvgesamtnote.studiensemester_kurzbz is null) "; + } + else + $sqlFilter = ""; + + $qry = "SELECT + tbl_lehrveranstaltung.lehrveranstaltung_id, tbl_zeugnisnote.note, tbl_zeugnisnote.punkte, + tbl_lvgesamtnote.note as lvnote, tbl_lvgesamtnote.punkte as lvpunkte, + tbl_zeugnisnote.benotungsdatum, tbl_lvgesamtnote.freigabedatum, + tbl_lvgesamtnote.benotungsdatum as lvbenotungsdatum, + tbl_zeugnisnote.studiensemester_kurzbz AS studiensemester_zeugnis, tbl_lvgesamtnote.studiensemester_kurzbz AS studiensemester_lvnote, + tbl_lehrveranstaltung.zeugnis, tbl_lehrveranstaltung.ects + FROM + lehre.tbl_lehrveranstaltung, lehre.tbl_zeugnisnote + LEFT OUTER JOIN campus.tbl_lvgesamtnote USING (lehrveranstaltung_id, student_uid, studiensemester_kurzbz) + LEFT OUTER JOIN lehre.tbl_note on tbl_zeugnisnote.note = tbl_note.note + WHERE + tbl_zeugnisnote.student_uid = " . $db->db_add_param($user) . $sqlFilter . " + AND tbl_lehrveranstaltung.lehrveranstaltung_id = tbl_zeugnisnote.lehrveranstaltung_id"; + + if(defined('CIS_NOTENLISTE_OFFIZIELL_ANZEIGEN') && CIS_NOTENLISTE_OFFIZIELL_ANZEIGEN) + $qry .= " AND tbl_note.offiziell = true"; + + $qry .= " ORDER BY tbl_lehrveranstaltung.bezeichnung"; + + if ($result = $db->db_query($qry)) + { + // Tabelle anzeigen + $tbl = ""; + $tblHead = " + + "; + if ($stsem == "alle") + $tblHead .= ""; + + $tblHead .= ""; + if (defined('CIS_GESAMTNOTE_PUNKTE') && CIS_GESAMTNOTE_PUNKTE) + $tblHead .= ""; + + $tblHead .= " "; + if (defined('CIS_GESAMTNOTE_PUNKTE') && CIS_GESAMTNOTE_PUNKTE) + $tblHead .= ""; + + $tblHead .= " + + + + "; + $tblBody = ""; + $i = 0; + $legende = false; + $notenSummenArray = array(); + while ($row = $db->db_fetch_object($result)) + { + $lv_obj = new lehrveranstaltung(); + $lv_obj->load($row->lehrveranstaltung_id); + + $i ++; + $tblBody .= ""; + if ($stsem == "alle") + $tblBody .= ""; + + // LV Gesamtnote Punkte + if (defined('CIS_GESAMTNOTE_PUNKTE') && CIS_GESAMTNOTE_PUNKTE) + { + $lvpunkte = ($row->lvpunkte != '' ? (float) $row->lvpunkte : ''); + $tblBody .= ""; + } + + if ($row->note != $row->lvnote && $row->lvnote != NULL) + { + $markier = " style='background-color: #FFD999;'"; + $legende = true; + } + else + $markier = ""; + $tblBody .= ""; + + if (defined('CIS_GESAMTNOTE_PUNKTE') && CIS_GESAMTNOTE_PUNKTE) + { + $punkte = ($row->punkte != '' ? ((float) $row->punkte) : ''); + $tblBody .= ""; + } + + $tblBody .= ''; + + $pruefung = new pruefung(); + $pruefung->getPruefungen($user, null, $row->lehrveranstaltung_id, $stsem); + + if (count($pruefung->result) > 0) + { + $tblBody .= ''; + } + else + $tblBody .= ''; + + $tblBody .= ""; + } + // Durchschnitt und gewichteten Durchschnitt berechnen + $notenSumme = 0; + $notenSummeGewichtet = 0; + $ectsSumme = 0; + $anzahlLv = 0; + foreach ($notenSummenArray AS $key => $value) + { + $anzahlLv++; + $notenSumme += $value['notenwert']; + $ectsSumme += $value['ects']; + $notenSummeGewichtet += $value['notenwert'] * $value['ects']; + } + + $tblBody .= ""; + $tblFoot = ""; + + if ($anzahlLv != 0) + $notenDurchschnitt = round($notenSumme / $anzahlLv, 2); + else + $notenDurchschnitt = 0; + + if ($ectsSumme != 0) + $notenDurchschnittGewichtet = round($notenSummeGewichtet / $ectsSumme, 2); + else + $notenDurchschnittGewichtet = 0; + + $tblFoot .= ''; + $tblFoot .= ''; + $tblFoot .= ''; + $tblFoot .= ''; + $tblFoot .= ""; + + $tblFoot .= ''; + $tblFoot .= ''; + $tblFoot .= ''; + $tblFoot .= ''; + + $tblFoot .= ""; + + $tblFoot .= ""; + + $tbl .= $tblHead.$tblFoot.$tblBody; + + $tbl .= "
" . $p->t('global/lehrveranstaltung') . "" . $p->t('global/studiensemester') . "" . $p->t('benotungstool/lvNote') . "" . $p->t('benotungstool/punkte') . "" . $p->t('benotungstool/zeugnisnote') . "" . $p->t('benotungstool/punkte') . "" . $p->t('tools/benotungsdatumDerZeugnisnote') . "" . $p->t('benotungstool/pruefung') . "
" . $lv_obj->bezeichnung_arr[$sprache] . ($lv_obj->lehrform_kurzbz != "" && $lv_obj->lehrform_kurzbz != " - " ? " (" . $lv_obj->lehrform_kurzbz . ")" : "") . "" . ($row->studiensemester_zeugnis != '' ? $row->studiensemester_zeugnis : $row->studiensemester_lvnote) . ""; + + $tblBody .= ""; + + // Nur freigegebene Noten anzeigen + if ($row->freigabedatum >= $row->lvbenotungsdatum) + { + if (isset($notenarr[$row->lvnote])) + $tblBody .= $notenarr[$row->lvnote]['bezeichnung']; + else + $tblBody .= $row->lvnote; + + // Nur Noten, die aufs Zeugnis gedruckt werden für Durchschnittsberechnung addieren + if ($row->zeugnis == true) + { + // Noten ohne Wert werden entfernen + if(isset($notenarr[$row->note]['notenwert'])) + { + $notenSummenArray[$row->lehrveranstaltung_id]['notenwert'] = $notenarr[$row->note]['notenwert']; + $notenSummenArray[$row->lehrveranstaltung_id]['ects'] = $row->ects; + } + } + } + $tblBody .= "" . $lvpunkte . ""; + + if (isset($notenarr[$row->note])) + $tblBody .= $notenarr[$row->note]['bezeichnung']; + else + $tblBody .= $row->note; + + $tblBody .= "" . $punkte . "' . $datum_obj->formatDatum($row->benotungsdatum, 'Y-m-d') . ''; + foreach ($pruefung->result as $row) + { + if (isset($notenarr[$row->note])) + $note = $notenarr[$row->note]['bezeichnung']; + else + $note = $row->note; + + if ($row->punkte != '') + $punkte = ' (' . (float) $row->punkte . ')'; + else + $punkte = ''; + + $tblBody .= $row->pruefungstyp_beschreibung . ' ' . $datum_obj->formatDatum($row->datum, 'd.m.Y') . ' ' . $note . $punkte . '
'; + } + $tblBody .= '
' . $p->t("tools/notendurchschnittDerZeugnisnote") . ''.$notenDurchschnitt.'
' . $p->t("tools/gewichteterNotendurchschnittDerZeugnisnote") . ''.$notenDurchschnittGewichtet.'
"; + $tbl .= ""; + if ($legende) + { + $tbl .= ""; + } + $tbl .= "
*" . $p->t('tools/legendeNotendurchschnitt') . "
**" . $p->t('tools/legendeGewichteterNotendurchschnitt') . "
" . $p->t('tools/hinweistextMarkierung') . "
"; + if ($i == 0) + echo $p->t('tools/nochKeineBeurteilungEingetragen'); + else + { + $tbl .= "


"; + echo $tbl; + } + } + else + { + $error .= $p->t('tools/fehlerBeimAuslesenDerNoten'); + } +} +echo $error; +echo ' +'; +?> diff --git a/cis/private/lehre/pruefung/pruefung.js.php b/cis/private/lehre/pruefung/pruefung.js.php index 70c410cde..b207c94e5 100644 --- a/cis/private/lehre/pruefung/pruefung.js.php +++ b/cis/private/lehre/pruefung/pruefung.js.php @@ -352,7 +352,9 @@ function writePruefungsTable(e, data, anmeldung) var termin = d.von.split(" "); var time = termin[1].substring(0,5); termin = termin[0].split("-"); - termin = new Date(termin[0], termin[1]-1,termin[2]); + var minimumFrist = new Date(termin[0], termin[1]-1,termin[2]); + minimumFrist.setMonth(minimumFrist.getMonth() - 2); + termin = new Date(termin[0], termin[1]-1,termin[2]); var frist = termin; termin = termin.getDate()+"."+(termin.getMonth()+1)+"."+termin.getFullYear(); frist = frist.getTime(); @@ -374,26 +376,29 @@ function writePruefungsTable(e, data, anmeldung) button = "

"+frist+"'>

"; } - else + else if(new Date() > minimumFrist) { button = "

"+frist+"'>

"; } } else - { + { button = "

' onclick='openAnmeldung(\""+e.lehrveranstaltung[0].lehrveranstaltung_id+"\", \""+e.pruefung.studiensemester_kurzbz+"\");'>

"; } row += button; - if(d.max === null) - { - teilnehmer += "t('pruefung/unbegrenzt'); ?>
"; - } - else - { - teilnehmer += "

"+(d.max - d.teilnehmer)+"/"+d.max+"

"; - } + if(new Date() > minimumFrist) + { + if(d.max === null) + { + teilnehmer += "t('pruefung/unbegrenzt'); ?>
"; + } + else + { + teilnehmer += "

"+(d.max - d.teilnehmer)+"/"+d.max+"

"; + } + } }); row += ""+teilnehmer+""; return row; @@ -570,8 +575,8 @@ function saveAnmeldung(lehrveranstaltung_id, termin_id) studienverpflichtung_id = $("#studienverpflichtung option:selected").val(); var studiengang_kz = null; - if($('#select_studiengang').length) - studiengang_kz = $('#select_studiengang option:selected').val(); + if($('#prestudent_studiengang').length) + studiengang_kz = $('#prestudent_studiengang option:selected').val(); $.ajax({ dataType: 'json', @@ -753,9 +758,10 @@ function convertDateTime(string, type) * Lädt die Anmeldungen zu einer Prüfung * @param {type} pruefungstermin_id ID des Prüfungstermins * @param {type} lehrveranstaltung_id ID der Lehrveranstaltung + * @param saveReihungAfterShow speichert Reihung neu wenn true * @returns {undefined} */ -function showAnmeldungen(pruefungstermin_id, lehrveranstaltung_id) +function showAnmeldungen(pruefungstermin_id, lehrveranstaltung_id, saveReihungAfterShow = false) { $("#kommentar").empty(); $("#kommentarSpeichernButton").empty(); @@ -773,6 +779,9 @@ function showAnmeldungen(pruefungstermin_id, lehrveranstaltung_id) writeAnmeldungen(data); $("#sortable").sortable(); $("#sortable").disableSelection(); + + if(saveReihungAfterShow) + saveReihung(pruefungstermin_id, lehrveranstaltung_id); } }); } @@ -791,6 +800,8 @@ function writeAnmeldungen(data) var liste = "
    "; var count = 0; var studiensemester = $("#filter_studiensemester option:selected").val(); + var listenLinks = "t('pruefung/listeDrucken'); ?>
    " + + "t('pruefung/listeOhneNamenDrucken'); ?>"; data.result.anmeldungen.forEach(function(d){ count++; var vorname = d.student.vorname !== "null" ? d.student.vorname : ""; @@ -799,7 +810,8 @@ function writeAnmeldungen(data) { case 'angemeldet': liste += "
  • "+vorname+" "+nachname+""; - liste += "
    "+count+"
    ' onclick='anmeldungBestaetigen(\""+d.pruefungsanmeldung_id+"\", \""+terminId+"\", \""+lehrveranstaltung_id+"\");'>
    "; + liste += "
    "+count+"
    ' onclick='anmeldungBestaetigen(\""+d.pruefungsanmeldung_id+"\", \""+terminId+"\", \""+lehrveranstaltung_id+"\");'>"; + liste += "
    "; if(d.wuensche !== null) { liste += ""; @@ -825,7 +837,7 @@ function writeAnmeldungen(data) $("#reihungSpeichernButton").html("' onclick='saveReihung(\""+terminId+"\", \""+lehrveranstaltung_id+"\");'>' onclick='alleBestaetigen(\""+terminId+"\", \""+lehrveranstaltung_id+"\");'>"); $("#lvdaten").html(lv_bezeichnung+" ("+prf_termin+")"); $("#anmeldeDaten").html(liste); - $("#listeDrucken").html("t('pruefung/listeDrucken'); ?>"); + $("#listeDrucken").html(listenLinks); if(ort_kurzbz !== null) { $("#raumLink").html("t('pruefung/pruefungsraum'); ?>"+ort_kurzbz); @@ -880,28 +892,31 @@ function saveReihung(terminId, lehrveranstaltung_id) anmeldung.uid = v.id; reihung.push(anmeldung); }); - $.ajax({ - dataType: 'json', - url: "./pruefungsanmeldung.json.php", - type: "POST", - data: { - method: "saveReihung", - reihung: reihung - }, - error: loadError, - success: function(data){ - if(data.error === 'false' && data.result === true) - { - messageBox("message", "t('pruefung/reihunghErfolgreichGeaendert'); ?>", "green", "highlight", 1000); - } - else - { - messageBox("message", data.errormsg, "red", "highlight", 1000); - } - showAnmeldungen(terminId, lehrveranstaltung_id); - } - }); + if (reihung.length > 0) { + $.ajax({ + dataType: 'json', + url: "./pruefungsanmeldung.json.php", + type: "POST", + data: { + method: "saveReihung", + reihung: reihung + }, + error: loadError, + success: function(data){ + if(data.error === 'false' && data.result === true) + { + messageBox("message", "t('pruefung/reihunghErfolgreichGeaendert'); ?>", "green", "highlight", 1000); + } + else + { + messageBox("message", data.errormsg, "red", "highlight", 1000); + } + + showAnmeldungen(terminId, lehrveranstaltung_id); + } + }); + } } /** @@ -938,6 +953,43 @@ function anmeldungBestaetigen(pruefungsanmeldung_id, termin_id, lehrveranstaltun }); } +/** + * Löscht eine Prüfungsanmeldung + * @param {type} pruefungsanmeldung_id ID der Prüfungsanmeldung + * @param {type} termin_id ID des Prüfungstermines + * @param {type} lehrveranstaltung_id ID der Lehrveranstaltung + * @returns {undefined} + */ +function anmeldungLoeschen(pruefungsanmeldung_id, termin_id, lehrveranstaltung_id) +{ + if (!confirm("Möchten Sie die Anmeldung wirklich löschen?")) + return undefined; + + $.ajax({ + dataType: 'json', + url: "./pruefungsanmeldung.json.php", + type: "POST", + data: { + method: "anmeldungLoeschen", + pruefungsanmeldung_id: pruefungsanmeldung_id + }, + error: loadError, + success: function(data){ + if(data.error === 'false' && data.result === true) + { + if(termin_id !== 'undefined' && lehrveranstaltung_id !== 'undefined') + { + showAnmeldungen(termin_id, lehrveranstaltung_id, true); + } + } + else + { + messageBox("message", data.errormsg, "red", "highlight", 1000); + } + } + }); +} + /** * Ändert den Status aller Anmeldungen eines Termins auf "bestätigt" * @param {type} termin_id ID des Prüfungstermines @@ -1167,7 +1219,8 @@ function loadStudiensemester() url: "./pruefungstermin.json.php", type: "POST", data: { - method: "loadStudiensemester" + method: "loadStudiensemester", + prevSemester: 5 }, error: loadError, success: function(data){ diff --git a/cis/private/lehre/pruefung/pruefungsanmeldung.json.php b/cis/private/lehre/pruefung/pruefungsanmeldung.json.php index a446c73e2..ce7479cf0 100644 --- a/cis/private/lehre/pruefung/pruefungsanmeldung.json.php +++ b/cis/private/lehre/pruefung/pruefungsanmeldung.json.php @@ -97,6 +97,9 @@ switch($method) case 'anmeldungBestaetigen': $data = anmeldungBestaetigen($uid); break; + case 'anmeldungLoeschen': + $data = anmeldungLoeschen(); + break; case 'alleBestaetigen': $data = alleBestaetigen($uid); break; @@ -178,7 +181,10 @@ function getPruefungByLv($aktStudiensemester = null, $uid = null) $lveranstaltung = new lehrveranstaltung($lehreinheiten[0]->lehrfach_id); $oe = new organisationseinheit($lveranstaltung->oe_kurzbz); $prf->organisationseinheit = $oe->bezeichnung; - array_push($pruefungen, $prf); + + // nur hinzufügen wenn zumindest 1 Termin vorhanden ist + if (!empty($prf->pruefung->termine)) + array_push($pruefungen, $prf); } } $anmeldung = new pruefungsanmeldung(); @@ -265,7 +271,10 @@ function getPruefungByLvFromStudiengang($aktStudiensemester = null, $uid = null) $lveranstaltung = new lehrveranstaltung($lehreinheiten[0]->lehrfach_id); $oe = new organisationseinheit($lveranstaltung->oe_kurzbz); $prf->organisationseinheit = $oe->bezeichnung; - array_push($pruefungen, $prf); + + // nur hinzufügen wenn zumindest 1 Termin vorhanden ist + if (!empty($prf->pruefung->termine)) + array_push($pruefungen, $prf); } } @@ -623,24 +632,11 @@ function saveAnmeldung($aktStudiensemester = null, $uid = null) { foreach ($prestudenten as $ps) { - if($ps->studiengang_kz === $studiengang_kz) + if ($ps->getLaststatus($ps->prestudent_id, $stdsem)) { - if ($ps->getLaststatus($ps->prestudent_id, $stdsem)) + if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher")) { - if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher")) - { - $prestudent_id = $ps->prestudent_id; - } - else - { - if ($ps->getLaststatus($ps->prestudent_id, $stdsem_lv_besuch)) - { - if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher")) - { - $prestudent_id = $ps->prestudent_id; - } - } - } + $prestudent_id = $ps->prestudent_id; } else { @@ -653,6 +649,16 @@ function saveAnmeldung($aktStudiensemester = null, $uid = null) } } } + else + { + if ($ps->getLaststatus($ps->prestudent_id, $stdsem_lv_besuch)) + { + if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher")) + { + $prestudent_id = $ps->prestudent_id; + } + } + } } } else @@ -805,7 +811,10 @@ function getAllPruefungen($aktStudiensemester = null, $uid = null) $lveranstaltung = new lehrveranstaltung($lehreinheiten[0]->lehrfach_id); $oe = new organisationseinheit($lveranstaltung->oe_kurzbz); $prf->organisationseinheit = $oe->bezeichnung; - array_push($pruefungen, $prf); + + // nur hinzufügen wenn zumindest 1 Termin vorhanden ist + if (!empty($prf->pruefung->termine)) + array_push($pruefungen, $prf); } } @@ -1057,6 +1066,30 @@ function anmeldungBestaetigen($uid) return $data; } +/** + * Löscht eine Prüfungsanmeldung + * @return Array + */ +function anmeldungLoeschen() +{ + $pruefungsanmeldung_id = $_REQUEST["pruefungsanmeldung_id"]; + $anmeldung = new pruefungsanmeldung(); + + if($anmeldung->delete($pruefungsanmeldung_id)) + { + $data['result']=true; + $data['error']='false'; + $data['errormsg']=''; + } + else + { + $data['error']='true'; + $data['errormsg']=$anmeldung->errormsg; + } + + return $data; +} + /** * Lädt alle Studiengänge * @return Array @@ -1168,7 +1201,12 @@ function getAllFreieRaeume($terminId) $teilnehmer = $teilnehmer !== false ? $teilnehmer : 0; $pruefungstermin->getAll($pruefungstermin->von, $pruefungstermin->bis, TRUE); - if($ort->search($datum_von[0], $datum_von[1], $datum_bis[1], null, $teilnehmer, true)) + if(defined('CIS_PRUEFUNGSANMELDUNG_ERLAUBE_TERMINKOLLISION') && CIS_PRUEFUNGSANMELDUNG_ERLAUBE_TERMINKOLLISION) + $ortSuccess = $ort->getOrte(true, null, true); + else + $ortSuccess = $ort->search($datum_von[0], $datum_von[1], $datum_bis[1], null, $teilnehmer, true); + + if($ortSuccess) { foreach($pruefungstermin->result as $termin) { @@ -1206,6 +1244,7 @@ function compareRaeume($a, $b) function saveRaum($terminId, $ort_kurzbz, $uid) { + $terminkollision = defined('CIS_PRUEFUNGSANMELDUNG_ERLAUBE_TERMINKOLLISION') ? CIS_PRUEFUNGSANMELDUNG_ERLAUBE_TERMINKOLLISION : false; $pruefungstermin = new pruefungstermin($terminId); $stunde = new stunde(); $datum_von = explode(" ", $pruefungstermin->von); @@ -1218,7 +1257,7 @@ function saveRaum($terminId, $ort_kurzbz, $uid) if($reservierung->isReserviert($ort_kurzbz, $datum_von[0], $h)) $reserviert = true; } - if(!$reserviert || $pruefungstermin->sammelklausur == TRUE) + if($terminkollision || !$reserviert || $pruefungstermin->sammelklausur == TRUE) { $pruefung = new pruefungCis($pruefungstermin->pruefung_id); $mitarbeiter = new mitarbeiter($pruefung->mitarbeiter_uid); diff --git a/cis/private/lehre/pruefung/pruefungsanmeldung.php b/cis/private/lehre/pruefung/pruefungsanmeldung.php index cd3b49621..f32c508e7 100644 --- a/cis/private/lehre/pruefung/pruefungsanmeldung.php +++ b/cis/private/lehre/pruefung/pruefungsanmeldung.php @@ -150,8 +150,8 @@ $studiensemester->getAll(); { $("#accordion").accordion({ header: "h2", - autoHeight: false - }); + heightStyle: "content" + }); $("#accordion").attr("style", "visibility: visible;"); } }); diff --git a/cis/private/lehre/pruefung/pruefungsanmeldungen_liste.php b/cis/private/lehre/pruefung/pruefungsanmeldungen_liste.php index d647289fa..39ec68ad4 100644 --- a/cis/private/lehre/pruefung/pruefungsanmeldungen_liste.php +++ b/cis/private/lehre/pruefung/pruefungsanmeldungen_liste.php @@ -35,6 +35,7 @@ require_once('../../../../include/datum.class.php'); require_once('../../../../include/phrasen.class.php'); require_once('../../../../include/globals.inc.php'); require_once('../../../../include/sprache.class.php'); +require_once('../../../../include/studiengang.class.php'); $sprache = getSprache(); $lang = new sprache(); @@ -230,6 +231,7 @@ $rechte->getBerechtigungen($uid); t('global/vorname'); ?> t('global/nachname'); ?> t('pruefung/matrikelnummer'); ?> + t('pruefung/studiengangAbkuerzung'); ?> t('global/datum'); ?> t('benotungstool/note'); ?> t('global/anmerkung'); ?> @@ -242,6 +244,7 @@ $rechte->getBerechtigungen($uid); foreach($anmeldungen as $anmeldung) { $student = new student($anmeldung->uid); + $studiengang = new studiengang($student->studiengang_kz); $prfTermin = new pruefungstermin($anmeldung->pruefungstermin_id); if($einzeln) @@ -262,6 +265,7 @@ $rechte->getBerechtigungen($uid); echo ''.$student->vorname.''; echo ''.$student->nachname.''; echo ''.$student->matr_nr.''; + echo ''.$studiengang->kurzbzlang.''; echo ''.$date.''; echo ''; echo ''; diff --git a/cis/private/lehre/pruefung/pruefungsanmeldungen_liste_ohne_namen.php b/cis/private/lehre/pruefung/pruefungsanmeldungen_liste_ohne_namen.php new file mode 100644 index 000000000..207ba4dd7 --- /dev/null +++ b/cis/private/lehre/pruefung/pruefungsanmeldungen_liste_ohne_namen.php @@ -0,0 +1,302 @@ + + */ + +require_once('../../../../config/cis.config.inc.php'); +require_once('../../../../include/functions.inc.php'); +require_once('../../../../include/benutzerberechtigung.class.php'); +require_once('../../../../include/pruefungsanmeldung.class.php'); +require_once('../../../../include/pruefungCis.class.php'); +require_once('../../../../include/pruefungstermin.class.php'); +require_once('../../../../include/studiensemester.class.php'); +require_once('../../../../include/lehrveranstaltung.class.php'); +require_once('../../../../include/mitarbeiter.class.php'); +require_once('../../../../include/student.class.php'); +require_once('../../../../include/datum.class.php'); +require_once('../../../../include/phrasen.class.php'); +require_once('../../../../include/globals.inc.php'); +require_once('../../../../include/sprache.class.php'); +require_once('../../../../include/studiengang.class.php'); + +$sprache = getSprache(); +$lang = new sprache(); +$lang->load($sprache); +$p = new phrasen($sprache); + +$uid = get_uid(); +$rechte = new benutzerberechtigung(); +$rechte->getBerechtigungen($uid); +?> + + + + + + + + + +
    +
    +

    t('pruefung/anmeldungsliste'); ?>

    + result) && !$rechte->isBerechtigt('lehre/pruefungsanmeldungAdmin')) + die('Sie haben keine Berechtigung für diese Seite'); + + $termin_id = filter_input(INPUT_GET,"termin_id"); + $lehrveranstaltung_id = filter_input(INPUT_GET,"lehrveranstaltung_id"); + $studiensemester = filter_input(INPUT_GET, "studiensemester"); + + if(is_null($lehrveranstaltung_id)) + { + die($p->t('pruefung/fehlenderParam_lvid')); + } + else if(is_null($termin_id)) + { + die($p->t('pruefung/fehlenderParam_terminid')); + } + else if(is_null($studiensemester)) + { + die($p->t('pruefung/fehlenderParam_studiensemester')); + } + else + { + $datum = new datum(); + $stdsem = new studiensemester($studiensemester); + $pruefungsanmeldung = new pruefungsanmeldung(); + $anmeldungen = $pruefungsanmeldung->getAnmeldungenByTermin($termin_id, $lehrveranstaltung_id, $studiensemester, "bestaetigt"); + $lehrveranstaltung = new lehrveranstaltung($lehrveranstaltung_id); + $einzeln = FALSE; + if(!empty($anmeldungen)) + { + $pruefung = new pruefungCis($anmeldungen[0]->pruefung_id); + $pruefungstermin = new pruefungstermin($anmeldungen[0]->pruefungstermin_id); + $mitarbeiter = new mitarbeiter($pruefung->mitarbeiter_uid); + if($pruefung->einzeln) + { + $einzeln = TRUE; + $pruefungsintervall = $pruefung->pruefungsintervall; + } + + ?> + t('global/lehrveranstaltung'); ?>: bezeichnung?>
    + t('global/studiensemester'); ?>: bezeichnung?>
    + t('pruefung/pruefer'); ?>: getFullName(FALSE)?>
    + + + + + + + + + + + + + uid); + $studiengang = new studiengang($student->studiengang_kz); + $prfTermin = new pruefungstermin($anmeldung->pruefungstermin_id); + + if($einzeln) + { + $date = $datum->formatDatum($prfTermin->von, "Y-m-d H:i:s"); + $date = strtotime($date); + $date = $date+(60*$pruefungsintervall*($anmeldung->reihung-1)); + $date = $datum->formatDatum($prfTermin->von,"d.m.Y").' - '.date("H:i",$date); + $count++; + } + else + { + $date = $datum->formatDatum($prfTermin->von,"d.m.Y - H:i"); + $count++; + } + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> + + + + t('pruefung/keineBestaetigtenAnmeldungenVorhanden'); ?>
    + + +
    #t('pruefung/matrikelnummer'); ?>t('pruefung/studiengangAbkuerzung'); ?>t('global/datum'); ?>t('benotungstool/note'); ?>t('global/anmerkung'); ?>
    '.$count.''.$student->matr_nr.''.$studiengang->kurzbzlang.''.$date.'
    +
    + + + + + + + + + + + + + + + diff --git a/cis/private/lehre/pruefung/pruefungsanmeldungen_verwalten.php b/cis/private/lehre/pruefung/pruefungsanmeldungen_verwalten.php index 21de64fcc..22bca21cc 100644 --- a/cis/private/lehre/pruefung/pruefungsanmeldungen_verwalten.php +++ b/cis/private/lehre/pruefung/pruefungsanmeldungen_verwalten.php @@ -252,7 +252,7 @@ if (empty($pruefung->result) && !$rechte->isBerechtigt('lehre/pruefungsanmeldung '; $aktuellesSemester = $studiensemester->getaktorNext(); - $studiensemester->getAll(); + $studiensemester->getPlusMinus(null, 5); foreach($studiensemester->studiensemester as $sem) { /*@var $sem studiensemester */ diff --git a/cis/private/lehre/pruefung/pruefungstermin.json.php b/cis/private/lehre/pruefung/pruefungstermin.json.php index 36ca332bd..978c3e69e 100644 --- a/cis/private/lehre/pruefung/pruefungstermin.json.php +++ b/cis/private/lehre/pruefung/pruefungstermin.json.php @@ -61,7 +61,8 @@ switch($method) case 'loadStudiensemester': $studiensemester = new studiensemester(); $aktStudiensemester = $studiensemester->getaktorNext(); - $data = loadStudiensemester($aktStudiensemester); + $prevSemester = empty($_POST["prevSemester"]) ? 0 : $_POST["prevSemester"]; + $data = loadStudiensemester($aktStudiensemester, $prevSemester); break; case 'getPruefungsfensterByStudiensemester': $studiensemester = new studiensemester(); @@ -223,12 +224,15 @@ function loadPruefungstypen($abschluss) /** * Lädt alle Studiensemester aus der Datenbank * @param String $aktStudiensemester das Aktuelle Studiensemester + * @param int $prevSemester wie viele vergangene Semester sollen geladen werden * @return Array */ -function loadStudiensemester($aktStudiensemester = null) +function loadStudiensemester($aktStudiensemester = null, $prevSemester = 0) { $studiensemester = new studiensemester(); - if($studiensemester->getAll()) + $prevSemester == 0 ? $studiensemester->getAll() : $studiensemester->getPlusMinus(null, $prevSemester); + + if(!empty($studiensemester->studiensemester)) { $data['result']=$studiensemester->studiensemester; if(!is_null($aktStudiensemester)) diff --git a/cis/private/lehre/pruefung/pruefungstermin_festlegen.php b/cis/private/lehre/pruefung/pruefungstermin_festlegen.php index e6f708d97..fdbce10d6 100644 --- a/cis/private/lehre/pruefung/pruefungstermin_festlegen.php +++ b/cis/private/lehre/pruefung/pruefungstermin_festlegen.php @@ -224,7 +224,8 @@ if (empty($lehrveranstaltung->lehrveranstaltungen) && !$rechte->isBerechtigt('le - - - + @@ -260,7 +273,7 @@ if ($num_rows_repl>0) { echo '

    '.$p->t('lvplan/reservierungen').'

    '; echo '
    t('pruefung/derLektor'); ?>getFullName(FALSE); ?>
    t('pruefung/dieKommission'); ?>
    t('pruefung/pruefungIntervall'); ?>: diff --git a/cis/private/lvplan/index.php b/cis/private/lvplan/index.php index ddbddf586..260ee8066 100644 --- a/cis/private/lvplan/index.php +++ b/cis/private/lvplan/index.php @@ -314,8 +314,14 @@ function LoadGruppe(type)
    -

    '.$p->t("lvplan/saalplan").'

    +
    '; + + if(!defined('CIS_LVPLAN_SAALPLAN_ANZEIGEN') || CIS_LVPLAN_SAALPLAN_ANZEIGEN) + { + echo '

    '.$p->t("lvplan/saalplan").'

    '; + } + + echo '
    '; @@ -328,21 +334,24 @@ function LoadGruppe(type)
    + '; + + if(!defined('CIS_LVPLAN_SAALPLAN_ANZEIGEN') || CIS_LVPLAN_SAALPLAN_ANZEIGEN) + { echo ' '; + } if ($raumres) { diff --git a/cis/private/lvplan/stpl_detail.php b/cis/private/lvplan/stpl_detail.php index 3aecd1fa6..87d4a70ff 100644 --- a/cis/private/lvplan/stpl_detail.php +++ b/cis/private/lvplan/stpl_detail.php @@ -35,6 +35,7 @@ require_once('../../../include/ort.class.php'); require_once('../../../include/functions.inc.php'); require_once('../../../include/datum.class.php'); require_once('../../../include/phrasen.class.php'); +require_once('../../../include/mitarbeiter.class.php'); $sprache = getSprache(); $p = new phrasen($sprache); @@ -155,9 +156,12 @@ $num_rows_stpl = $db->db_num_rows($erg_stpl); $sql_query=" SELECT vw_reservierung.*, vw_mitarbeiter.titelpre, vw_mitarbeiter.titelpost, - vw_mitarbeiter.vorname,vw_mitarbeiter.nachname + vw_mitarbeiter.vorname, vw_mitarbeiter.nachname, reserviert_von.titelpre AS titelpre_reserviertvon, reserviert_von.titelpost AS titelpost_reserviertvon, + reserviert_von.vorname AS vorname_reserviertvon, reserviert_von.nachname AS nachname_reserviertvon FROM - campus.vw_reservierung, campus.vw_mitarbeiter + campus.vw_reservierung + JOIN campus.vw_mitarbeiter ON vw_reservierung.uid=vw_mitarbeiter.uid + LEFT JOIN campus.vw_mitarbeiter reserviert_von ON vw_reservierung.insertvon=reserviert_von.uid WHERE datum=".$db->db_add_param($datum)." AND stunde=".$db->db_add_param($stunde); @@ -166,7 +170,6 @@ if (isset($ort_kurzbz) && $type=='ort') $sql_query.=" AND vw_reservierung.ort_kurzbz=".$db->db_add_param($ort_kurzbz); if ($type=='lektor') $sql_query.=" AND vw_reservierung.uid=".$db->db_add_param($pers_uid); -$sql_query.=" AND vw_reservierung.uid=vw_mitarbeiter.uid"; if ($type=='verband' || $type=='student') { $sql_query.=" AND studiengang_kz=".$db->db_add_param($stg_kz)." @@ -231,11 +234,21 @@ if ($num_rows_stpl>0) $titel = trim($row->titel); $gesamtanzahl = ($anzahl_grp!=0?$anzahl_grp:$anzahl_lvb); $ort->load($ortkurzbz); - + + // no profile link for fake Mitarbeiter like Dummylektor, Personalnr must be > 0 + $profileLink = true; + $mitarbeiter = new mitarbeiter(); + + if ($mitarbeiter->load($row->uid)) + { + if (isset($mitarbeiter->personalnummer) && is_numeric($mitarbeiter->personalnummer) && (int)$mitarbeiter->personalnummer < 0) + $profileLink = false; + } + echo '
    '.$db->convert_html_chars($unr).''.$db->convert_html_chars($titelpre.' '.$pers_vorname.' '.$pers_nachname.' '.$titelpost).''.($profileLink ? '' : '').$db->convert_html_chars($titelpre.' '.$pers_vorname.' '.$pers_nachname.' '.$titelpost).($profileLink ? '' : '').' '.(!empty($ortkurzbz)?($ort->content_id!=''?''.$db->convert_html_chars($ortkurzbz).'':$db->convert_html_chars($ortkurzbz)):$db->convert_html_chars($ortkurzbz)).' '.$db->convert_html_chars($lehrfachkurzbz).' '.$db->convert_html_chars($bezeichnung).'
    '; - echo ''; + echo ''; $i=0; $ort = new ort(); while($row = $db->db_fetch_object($erg_repl)) @@ -274,13 +287,20 @@ if ($num_rows_repl>0) $pers_nachname=$row->nachname; $pers_email=$row->uid.'@'.DOMAIN; $beschreibung=$row->beschreibung; + $reserviertvon=$row->insertvon; + $titelpre_reserviertvon=$row->titelpre_reserviertvon; + $titelpost_reserviertvon=$row->titelpost_reserviertvon; + $pers_vorname_reserviertvon=$row->vorname_reserviertvon; + $pers_nachname_reserviertvon=$row->nachname_reserviertvon; + $ort->load($ortkurzbz); echo ''; - echo ''; + echo ''; echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; } echo '
    '.$p->t('global/titel').''.$p->t('lvplan/ort').''.$p->t('global/person').''.$p->t('global/beschreibung').'
    '.$p->t('global/titel').''.$p->t('lvplan/ort').''.$p->t('global/person').''.$p->t('global/beschreibung').''.$p->t('lvplan/reserviertVon').'
    '.$db->convert_html_chars($titel).''.$db->convert_html_chars($titel).''.(!empty($ortkurzbz)?($ort->content_id!=''?''.$db->convert_html_chars($ortkurzbz).'':$db->convert_html_chars($ortkurzbz)):$db->convert_html_chars($ortkurzbz)).''.$db->convert_html_chars($titelpre.' '.$pers_vorname.' '.$pers_nachname.' '.$titelpost).''.$db->convert_html_chars($beschreibung).'
    '.$db->convert_html_chars($titelpre.' '.$pers_vorname.' '.$pers_nachname.' '.$titelpost).''.$db->convert_html_chars($beschreibung).''.$db->convert_html_chars($titelpre_reserviertvon.' '.$pers_vorname_reserviertvon.' '.$pers_nachname_reserviertvon.' '.$titelpost_reserviertvon).'

    '; } diff --git a/cis/private/lvplan/stpl_reserve_list.php b/cis/private/lvplan/stpl_reserve_list.php index a882b8344..21328050b 100644 --- a/cis/private/lvplan/stpl_reserve_list.php +++ b/cis/private/lvplan/stpl_reserve_list.php @@ -23,15 +23,15 @@ require_once('../../../config/cis.config.inc.php'); require_once('../../../include/functions.inc.php'); require_once('../../../include/datum.class.php'); require_once('../../../include/benutzerberechtigung.class.php'); -require_once('../../../include/phrasen.class.php'); -require_once('../../../include/reservierung.class.php'); +require_once('../../../include/phrasen.class.php'); +require_once('../../../include/reservierung.class.php'); if (!$db = new basis_db()) die($p->t('global/fehlerBeimOeffnenDerDatenbankverbindung')); - -$sprache = getSprache(); -$p=new phrasen($sprache); - + +$sprache = getSprache(); +$p=new phrasen($sprache); + $uid = get_uid(); if (isset($_GET['id'])) @@ -67,7 +67,7 @@ if(!$rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) $reservierung = new reservierung(); if($reservierung->load($id)) { - if($reservierung->uid==$uid || $reservierung->insertvon==$uid || $rechte->isBerechtigt('lehre/reservierung', null, 'suid')) + if(($reservierung->uid==$uid || $reservierung->insertvon==$uid) && $rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) { if($reservierung->delete($id)) echo ''.$p->t('lvplan/reservierungWurdeGeloescht').'
    '; @@ -79,25 +79,31 @@ if(!$rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) echo ''.$p->t('global/keineBerechtigung').'
    '; } } - else + else echo ''.$p->t('global/fehleraufgetreten').'!
    '; } //Aktuelle Reservierungen abfragen. $datum = time(); $datum = date("Y-m-d",$datum); - + //EIGENE - $sql_query="SELECT * FROM campus.vw_reservierung - WHERE datum>=".$db->db_add_param($datum)." - AND (uid=".$db->db_add_param($uid)." OR insertvon=".$db->db_add_param($uid).") + $sql_query="SELECT vw_reservierung.*, vw_mitarbeiter.titelpre, vw_mitarbeiter.titelpost, + vw_mitarbeiter.vorname, vw_mitarbeiter.nachname, reserviert_von.titelpre AS titelpre_reserviertvon, + reserviert_von.titelpost AS titelpost_reserviertvon, reserviert_von.vorname AS vorname_reserviertvon, + reserviert_von.nachname AS nachname_reserviertvon + FROM campus.vw_reservierung + JOIN campus.vw_mitarbeiter ON vw_reservierung.uid=vw_mitarbeiter.uid + LEFT JOIN campus.vw_mitarbeiter reserviert_von ON vw_reservierung.insertvon=reserviert_von.uid + WHERE datum>=".$db->db_add_param($datum)." + AND (vw_reservierung.uid=".$db->db_add_param($uid)." OR vw_reservierung.insertvon=".$db->db_add_param($uid).") ORDER BY datum, titel, ort_kurzbz, stunde"; if (!$erg_res=$db->db_query($sql_query)) die($db->db_last_error()); $num_rows_res=$db->db_num_rows($erg_res); - + if ($num_rows_res>0) { echo $p->t('lvplan/eigeneReservierungen').':
    '; @@ -108,8 +114,9 @@ if(!$rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) '.$p->t('global/titel').' '.$p->t('global/stunde').' '.$p->t('lvplan/raum').' - '.$p->t('global/uid').' + '.$p->t('global/person').' '.$p->t('global/beschreibung').' + '.$p->t('lvplan/reserviertVon').' '.$p->t('global/aktion').' '; for ($i=0; $i<$num_rows_res; $i++) @@ -124,6 +131,14 @@ if(!$rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) $beschreibung=$db->db_result($erg_res,$i,"beschreibung"); $insertamum=$db->db_result($erg_res,$i,"insertamum"); $insertvon=$db->db_result($erg_res,$i,"insertvon"); + $titelpre=$db->db_result($erg_res,$i,"titelpre"); + $titelpost=$db->db_result($erg_res,$i,"titelpost"); + $pers_vorname=$db->db_result($erg_res,$i,"vorname"); + $pers_nachname=$db->db_result($erg_res,$i,"nachname"); + $titelpre_reserviertvon=$db->db_result($erg_res,$i,"titelpre_reserviertvon"); + $titelpost_reserviertvon=$db->db_result($erg_res,$i,"titelpost_reserviertvon"); + $pers_vorname_reserviertvon=$db->db_result($erg_res,$i,"vorname_reserviertvon"); + $pers_nachname_reserviertvon=$db->db_result($erg_res,$i,"nachname_reserviertvon"); $datum1 = $datum_obj->formatDatum($datum1, 'd.m.Y'); if($insertamum!='') $insertamum = $datum_obj->formatDatum($insertamum, 'd.m.Y H:i:s'); @@ -132,11 +147,12 @@ if(!$rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) echo ''.$db->convert_html_chars($titel).''; echo ''.$db->convert_html_chars($stunde).''; echo ''.$db->convert_html_chars($ort_kurzbz).''; - echo ''.$db->convert_html_chars($pers_uid).''; + echo ''.$db->convert_html_chars($titelpre.' '.$pers_vorname.' '.$pers_nachname.' '.$titelpost).''; echo ''.$db->convert_html_chars($beschreibung).' '; + echo ''.$db->convert_html_chars($titelpre_reserviertvon.' '.$pers_vorname_reserviertvon.' '.$pers_nachname_reserviertvon.' '.$titelpost_reserviertvon).''; $z=$i-1; - if (($pers_uid==$uid)|| ($insertvon==$uid) || $rechte->isBerechtigt('lehre/reservierung', null, 'suid')) - echo 'Delete'; + if (($pers_uid==$uid || $insertvon==$uid) && $rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) + echo 'Delete'; echo ''; } echo ''; @@ -145,68 +161,7 @@ if(!$rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) echo '

    '; flush(); - - if(isset($_GET['alle'])) - { - //ALLE - $sql_query="SELECT * FROM campus.vw_reservierung - WHERE datum>=".$db->db_add_param($datum)." - ORDER BY datum, titel, ort_kurzbz, stunde"; - if (!$erg_res=$db->db_query($sql_query)) - die($db->db_last_error()); - - $num_rows_res=$db->db_num_rows($erg_res); - if ($num_rows_res>0) - { - echo $p->t('lvplan/alleReservierungen').':
    '; - echo ''; - echo ' - - - - - - - - - '; - - for ($i=0; $i<$num_rows_res; $i++) - { - $zeile=$i % 2; - $id=$db->db_result($erg_res,$i,"reservierung_id"); - $datum=$db->db_result($erg_res,$i,"datum"); - $titel=$db->db_result($erg_res,$i,"titel"); - $stunde=$db->db_result($erg_res,$i,"stunde"); - $ort_kurzbz=$db->db_result($erg_res,$i,"ort_kurzbz"); - $pers_uid=$db->db_result($erg_res,$i,"uid"); - $beschreibung=$db->db_result($erg_res,$i,"beschreibung"); - $insertamum=$db->db_result($erg_res,$i,"insertamum"); - $insertvon=$db->db_result($erg_res,$i,"insertvon"); - - $datum = $datum_obj->formatDatum($datum, 'd.m.Y'); - if($insertamum!='') - $insertamum = $datum_obj->formatDatum($insertamum, 'd.m.Y H:i:s'); - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - $z=$i-1; - if (($pers_uid==$uid) || ($insertvon==$uid) || $rechte->isBerechtigt('lehre/reservierung', null, 'suid')) - echo ''; - echo ''; - } - echo '
    '.$p->t('global/datum').''.$p->t('global/titel').''.$p->t('global/stunde').''.$p->t('lvplan/raum').''.$p->t('global/person').''.$p->t('global/beschreibung').''.$p->t('global/aktion').'
    '.$db->convert_html_chars($datum).''.$db->convert_html_chars($titel).''.$db->convert_html_chars($stunde).''.$db->convert_html_chars($ort_kurzbz).''.$db->convert_html_chars($pers_uid).''.$db->convert_html_chars($beschreibung).' Delete
    '; - flush(); - } - } - else - echo ''.$p->t('lvplan/alleReservierungenAnzeigen').''; - ?> diff --git a/cis/private/lvplan/stpl_week.php b/cis/private/lvplan/stpl_week.php index 56b06f292..c7da148dd 100644 --- a/cis/private/lvplan/stpl_week.php +++ b/cis/private/lvplan/stpl_week.php @@ -362,13 +362,13 @@ if (isset($reservtodelete)) $reservierung = new reservierung(); $reservdelcount = 0; - $reservberechtigt = $rechte->isBerechtigt('lehre/reservierung', null, 'suid'); + $reservberechtigt = $rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid'); foreach ($reservtodelete as $delete_id) { if ($reservierung->load($delete_id)) { - if ($reservberechtigt || $reservierung->uid==$uid || $reservierung->insertvon==$uid) + if ($reservberechtigt && ($reservierung->insertvon==$uid || $reservierung->uid==$uid)) { if($reservierung->delete($delete_id)) $reservdelcount++; diff --git a/cis/private/profile/index.php b/cis/private/profile/index.php index 5f93930cc..dbef13bfd 100644 --- a/cis/private/profile/index.php +++ b/cis/private/profile/index.php @@ -66,6 +66,9 @@ if (isset($_GET['uid']) && $_GET['uid'] != $uid) $uid = stripslashes($_GET['uid']); $ansicht = true; } + +$adminOrOwnUser = $rechte->isBerechtigt('admin') || !$ansicht; + if ($rechte->isBerechtigt('basis/kontakt')) $ansicht = false; @@ -127,6 +130,9 @@ if (!$user->load($uid)) if ($type == 'mitarbeiter') { + if (isset($user->personalnummer) && is_numeric($user->personalnummer) && (int)$user->personalnummer < 0) + die($p->t('profil/keinGueltigesProfil')); + $vorwahl = ''; $kontakt = new kontakt(); $kontakt->loadFirmaKontakttyp($user->standort_id,'telefon'); @@ -156,12 +162,7 @@ echo ' $(document).ready(function() { - $("#t1").tablesorter( - { - sortList: [[0,0]], - widgets: ["zebra"] - }); - $("#t2").tablesorter( + $("#t1, #t2, #tfuture").tablesorter( { sortList: [[0,0]], widgets: ["zebra"] @@ -504,36 +505,55 @@ echo ' if (!defined('CIS_PROFIL_FUNKTIONEN_ANZEIGEN') || CIS_PROFIL_FUNKTIONEN_ANZEIGEN) { //Funktionen - $qry = "SELECT + $baseqry = "SELECT *, tbl_benutzerfunktion.oe_kurzbz as oe_kurzbz, tbl_organisationseinheit.bezeichnung as oe_bezeichnung, tbl_benutzerfunktion.semester, tbl_benutzerfunktion.bezeichnung as bf_bezeichnung, - tbl_benutzerfunktion.datum_von, tbl_benutzerfunktion.datum_bis + tbl_benutzerfunktion.wochenstunden, tbl_benutzerfunktion.datum_von, tbl_benutzerfunktion.datum_bis FROM public.tbl_benutzerfunktion JOIN public.tbl_funktion USING(funktion_kurzbz) JOIN public.tbl_organisationseinheit USING(oe_kurzbz) WHERE - uid=".$db->db_add_param($uid)." AND - (tbl_benutzerfunktion.datum_bis is null OR tbl_benutzerfunktion.datum_bis>=now())"; + uid=".$db->db_add_param($uid); - if ($result_funktion = $db->db_query($qry)) + $currfunkqry = $baseqry . " AND ((tbl_benutzerfunktion.datum_bis is null OR tbl_benutzerfunktion.datum_bis>=now()) + AND (tbl_benutzerfunktion.datum_von is null OR tbl_benutzerfunktion.datum_von<=now()))"; + $futurefunkqry = $baseqry . " AND (tbl_benutzerfunktion.datum_von>now())"; + + printFunctionsTable($currfunkqry, 'profil/funktionen', 't1', true); + printFunctionsTable($futurefunkqry, 'profil/zukuenftigeFunktionen', 'tfuture'); +} + +/** + * Print html table containing user functions. + * @param $query string execute for getting data + * @param $tableid string html table id + * @param $showVertragsstunden bool show Vertragsstunden sum near Wochenstunden sum + */ +function printFunctionsTable($query, $headingphrase, $tableid, $showVertragsstunden = false) +{ + global $db, $p, $datum_obj, $uid, $adminOrOwnUser; + + if ($result_funktion = $db->db_query($query)) { if ($db->db_num_rows($result_funktion) > 0) { - echo ''.$p->t('profil/funktionen').' - + echo ''.$p->t($headingphrase).''; + echo ' +
    - - - - + '. + ($adminOrOwnUser ? '' : ''). + ''; + $wochenstunden_sum = 0.00; + while($row_funktion = $db->db_fetch_object($result_funktion)) { echo " @@ -544,13 +564,50 @@ if (!defined('CIS_PROFIL_FUNKTIONEN_ANZEIGEN') || CIS_PROFIL_FUNKTIONEN_ANZEIGEN echo ' - '.$row_funktion->bf_bezeichnung; echo " - - - - "; + ". + ($adminOrOwnUser ? "" : ""). + ""; + + if(isset($row_funktion->wochenstunden) && $adminOrOwnUser) + $wochenstunden_sum += (double)$row_funktion->wochenstunden; } - echo '
    '.$p->t('global/bezeichnung').' '.$p->t('global/organisationseinheit').''.$p->t('global/semester').''.$p->t('global/institut').' '.$p->t('profil/gueltigvon').''.$p->t('profil/gueltigbis').'
    '.$p->t('profil/gueltigbis').''.$p->t('profil/wochenstunden').'
    ".$row_funktion->organisationseinheittyp_kurzbz.' '.$row_funktion->oe_bezeichnung."$row_funktion->semester$row_funktion->fachbereich_kurzbz ".$datum_obj->formatDatum($row_funktion->datum_von,'d.m.Y')."".$datum_obj->formatDatum($row_funktion->datum_bis,'d.m.Y')."
    ".$datum_obj->formatDatum($row_funktion->datum_bis,'d.m.Y')."".number_format($row_funktion->wochenstunden, 2)."

    '; + echo '
    '; + + //vertragsstunden + if ($showVertragsstunden === true && $adminOrOwnUser) + { + $vertragsstunden = 0.00; + $qry = "SELECT sum(vertragsstunden) AS vertragsstdsumme from bis.tbl_bisverwendung + WHERE mitarbeiter_uid = ".$db->db_add_param($uid)." + AND (ende > now() OR ende IS NULL)"; + + if ($result_vertragsstd = $db->db_query($qry)) + { + if ($db->db_num_rows($result_vertragsstd) > 0) + { + while($row_vertragsstd = $db->db_fetch_object($result_vertragsstd)) + { + $vertragsstunden = $row_vertragsstd->vertragsstdsumme; + } + } + } + } + + if ($adminOrOwnUser) + { + echo " + + + + + Summe Wochenstunden".($showVertragsstunden === true ? " (".$p->t('profil/vertragsstunden').")" : "")." +  ".number_format($wochenstunden_sum, 2).($showVertragsstunden === true ? + " (".number_format($vertragsstunden, 2).")" : "")." + + "; + } + echo ""; } } } diff --git a/cis/private/profile/lva_liste.php b/cis/private/profile/lva_liste.php index 95b9cf50b..c4f54ce94 100644 --- a/cis/private/profile/lva_liste.php +++ b/cis/private/profile/lva_liste.php @@ -247,7 +247,14 @@ require_once('../../../include/benutzerberechtigung.class.php'); echo ''.$row->raumtypalternativ.''; echo ''.$row->stundenblockung.''; echo ''.$row->wochenrythmus.''; - echo ''.$row->semesterstunden.''; + if(getSprache()=='German') + { + echo ''.number_format($row->semesterstunden,2,$dec_point=",",$thousands_sep=".").''; + } + else + { + echo ''.number_format($row->semesterstunden,2,$dec_point=".",$thousands_sep=",").''; + } echo ''.$row->start_kw.''; $lvangebot->getAllFromLvId($row->lehrveranstaltung_id, $row->studiensemester_kurzbz); @@ -276,7 +283,7 @@ require_once('../../../include/benutzerberechtigung.class.php'); echo ' '; echo ' '; - + echo ' '; echo ' '; echo ' '; echo ' '; @@ -286,7 +293,14 @@ require_once('../../../include/benutzerberechtigung.class.php'); echo ' '; echo ' '; echo ''.$p->t('lvaliste/summe').''; - echo ''.number_format($summe_std,2).''; + if(getSprache()=='German') + { + echo ''.number_format($summe_std,2,$dec_point=",",$thousands_sep=".").''; + } + else + { + echo ''.number_format($summe_std,2,$dec_point=".",$thousands_sep=",").''; + } echo ' '; echo ''; echo ''; @@ -304,19 +318,21 @@ require_once('../../../include/benutzerberechtigung.class.php'); tbl_lehrveranstaltung.bezeichnung, tbl_projektarbeit.titel, (SELECT nachname || ' ' || vorname FROM public.tbl_benutzer JOIN public.tbl_person USING(person_id) WHERE uid=student_uid) as student, tbl_lehrveranstaltung.studiengang_kz, tbl_lehrveranstaltung.semester, - tbl_studiengang.email + tbl_studiengang.email, tbl_betreuerart.beschreibung AS beutreuerart_beschreibung, tbl_projektbetreuer.stunden FROM - lehre.tbl_lehreinheit, lehre.tbl_lehrveranstaltung, lehre.tbl_projektarbeit, lehre.tbl_projektbetreuer, public.tbl_studiengang + lehre.tbl_lehreinheit, lehre.tbl_lehrveranstaltung, lehre.tbl_projektarbeit, lehre.tbl_projektbetreuer, public.tbl_studiengang, lehre.tbl_betreuerart WHERE tbl_lehreinheit.lehreinheit_id=tbl_projektarbeit.lehreinheit_id AND tbl_lehreinheit.lehrveranstaltung_id=tbl_lehrveranstaltung.lehrveranstaltung_id AND tbl_lehreinheit.studiensemester_kurzbz=".$db->db_add_param($stdsem)." AND tbl_projektarbeit.projektarbeit_id=tbl_projektbetreuer.projektarbeit_id AND tbl_lehrveranstaltung.studiengang_kz=tbl_studiengang.studiengang_kz AND + tbl_projektbetreuer.betreuerart_kurzbz=tbl_betreuerart.betreuerart_kurzbz AND tbl_projektbetreuer.person_id=".$db->db_add_param($mitarbeiter->person_id, FHC_INTEGER); $stg_obj = new studiengang(); $stg_obj->getAll(null,null); + $summe_std = 0; if($result = $db->db_query($qry)) { @@ -328,8 +344,10 @@ require_once('../../../include/benutzerberechtigung.class.php'); echo ''; echo ''.$p->t('lvaliste/studiengang').''; echo ''.$p->t('lvaliste/semester').''; + echo ''.$p->t('lvaliste/stunden').''; echo ''.$p->t('lvaliste/lvBezeichnung').''; echo ''.$p->t('lvaliste/student').''; + echo ''.$p->t('lvaliste/betreuungsart').''; echo ''.$p->t('lvaliste/titelProjektarbeit').''; echo ''; while($row = $db->db_fetch_object($result)) @@ -337,12 +355,46 @@ require_once('../../../include/benutzerberechtigung.class.php'); echo ''; echo ''.$stg_obj->kuerzel_arr[$row->studiengang_kz].''; echo ''.$row->semester.''; + if(getSprache()=='German') + { + echo ''.number_format($row->stunden,2,$dec_point =",", $thousands_sep ="."). ''; + } + else + { + echo ''.number_format($row->stunden,2,$dec_point =".", $thousands_sep =","). ''; + } echo ''.$row->bezeichnung.''; echo ''.$row->student.''; + echo ''.$row->beutreuerart_beschreibung.''; echo ''.$row->titel.''; - echo ''; + $summe_std+=$row->stunden; } + echo ''; + echo ''; + echo ''; + if(!defined('CIS_LVALISTE_NOTENEINGABE_ANZEIGEN') || CIS_LVALISTE_NOTENEINGABE_ANZEIGEN) + { + echo ' '; + } + if($lvinfo) + + echo ''.$p->t('lvaliste/summe').''; + + if(getSprache()=='German') + { + echo ''.number_format($summe_std,2,$dec_point=",",$thousands_sep=".").''; + } + else + { + echo ''.number_format($summe_std,2,$dec_point=".",$thousands_sep=",").''; + } + + + echo ' '; + + echo ''; + echo ''; } } @@ -423,6 +475,7 @@ require_once('../../../include/benutzerberechtigung.class.php'); echo ''; echo ''.$stg_obj->kuerzel_arr[$row->studiengang_kz].''; echo ''.$row->semester.''; + echo ''.$row->stunden.''; echo ''.$row->fachbereich_kurzbz.''; echo ''.$row->bezeichnung.''; echo ''.$lektoren.''; diff --git a/cis/private/profile/studienplan.php b/cis/private/profile/studienplan.php index dab3e4d73..6097ed136 100644 --- a/cis/private/profile/studienplan.php +++ b/cis/private/profile/studienplan.php @@ -235,7 +235,7 @@ $studiensemester_start = $prestudent->studiensemester_kurzbz; $ausbildungssemester_start = $prestudent->ausbildungssemester; $orgform_kurzbz = $prestudent->orgform_kurzbz; -$prestudent->getLastStatus($student->prestudent_id, 'Student'); +$prestudent->getLastStatus($student->prestudent_id, '', 'Student'); $studienplan_id = $prestudent->studienplan_id; $studienplan = new studienplan(); diff --git a/cis/private/profile/zahlungen.php b/cis/private/profile/zahlungen.php index 3abb0a900..ea2c70c79 100644 --- a/cis/private/profile/zahlungen.php +++ b/cis/private/profile/zahlungen.php @@ -1,190 +1,277 @@ -, - * Andreas Oesterreicher and - * Rudolf Hangl . - */ - - require_once('../../../config/cis.config.inc.php'); - require_once('../../../include/functions.inc.php'); - require_once('../../../include/studiensemester.class.php'); - require_once('../../../include/konto.class.php'); - require_once('../../../include/person.class.php'); - require_once('../../../include/benutzer.class.php'); - require_once('../../../include/datum.class.php'); - require_once('../../../include/studiengang.class.php'); - require_once('../../../include/phrasen.class.php'); - require_once('../../../include/benutzerberechtigung.class.php'); - - $sprache = getSprache(); - $p = new phrasen($sprache); - $uid=get_uid(); - - if(isset($_GET['uid'])) - { - // Administratoren duerfen die UID als Parameter uebergeben um die Zahlungen - // von anderen Personen anzuzeigen - - $rechte = new benutzerberechtigung(); - $rechte->getBerechtigungen($uid); - if($rechte->isBerechtigt('admin')) - { - $uid = $_GET['uid']; - $getParam = "&uid=" . $uid; - } - else - $getParam = ""; - } - else - $getParam=''; - - $datum_obj = new datum(); - - echo ' - - - - '.$p->t('tools/zahlungen').' - - - - - - - - - - - - '; - - $studiengang = new studiengang(); - $studiengang->getAll(null,null); - - $stg_arr = array(); - foreach ($studiengang->result as $row) - $stg_arr[$row->studiengang_kz]=$row->kuerzel; - - $benutzer = new benutzer(); - if(!$benutzer->load($uid)) - die('Benutzer wurde nicht gefunden'); - - echo '

    '.$p->t('tools/zahlungen').' - '.$benutzer->vorname.' '.$benutzer->nachname.'

    '; - - $konto = new konto(); - $konto->getBuchungstyp(); - $buchungstyp = array(); - - foreach ($konto->result as $row) - $buchungstyp[$row->buchungstyp_kurzbz]=$row->beschreibung; - - $konto = new konto(); - $konto->getBuchungen($benutzer->person_id); - if(count($konto->result)>0) - { - echo '

    '; - echo ''; - echo ' - - - - - - - '; - echo ''; - - foreach ($konto->result as $row) - { - $i=0; //Zaehler fuer Anzahl Gegenbuchungen - $buchungsnummern=''; - - if(!isset($row['parent'])) - continue; - $betrag = $row['parent']->betrag; - - - if(isset($row['childs'])) - { - foreach ($row['childs'] as $key => $row_child) - { - $betrag += $row_child->betrag; - $betrag = round($betrag, 2); - $buchungsnummern .= ';'.$row['childs'][$key]->buchungsnr; - $i = $key; //Zaehler auf letzten Gegenbuchungseintrag setzen - } - } - else - $buchungsnummern = $row['parent']->buchungsnr; - - if($betrag<0) - $style='style="background-color: #FF8888;"'; - elseif($betrag>0) - $style='style="background-color: #88DD88;"'; - else - $style=''; - - echo ""; - echo ''; - echo ''; - echo ''; - echo ''; - - echo ''; - echo ''; - echo ''; - } - echo ''; - } - echo '
    '.$p->t('global/datum').''.$p->t('tools/zahlungstyp').''.$p->t('lvplan/stg').''.$p->t('global/studiensemester').''.$p->t('tools/buchungstext').''.$p->t('tools/betrag').''.$p->t('tools/zahlungsbestaetigung').'
    '.date('d.m.Y',$datum_obj->mktime_fromdate(isset($row['childs'][$i])?$row['childs'][$i]->buchungsdatum:$row['parent']->buchungsdatum)).''.$buchungstyp[$row['parent']->buchungstyp_kurzbz].''.$stg_arr[$row['parent']->studiengang_kz].''.$row['parent']->studiensemester_kurzbz.''.$row['parent']->buchungstext.''.($betrag<0?'-':($betrag>0?'+':'')).sprintf('%.2f',abs($row['parent']->betrag)).' €'; - if($betrag>=0 && $row['parent']->betrag<=0) - echo ''.$p->t('tools/bestaetigungDrucken').''; - elseif($row['parent']->betrag>0) - { - //Auszahlung - } - else - { - echo ''.$p->t('tools/offen').' ('.sprintf('%.2f',$betrag*-1).' €)'; - - echo '
    '; - } - else - { - echo $p->t('tools/keineZahlungenVorhanden'); - } - echo ''; -?> +, + * Andreas Oesterreicher and + * Rudolf Hangl . + */ + + require_once('../../../config/cis.config.inc.php'); + require_once('../../../include/functions.inc.php'); + require_once('../../../include/studiensemester.class.php'); + require_once('../../../include/konto.class.php'); + require_once('../../../include/person.class.php'); + require_once('../../../include/benutzer.class.php'); + require_once('../../../include/datum.class.php'); + require_once('../../../include/studiengang.class.php'); + require_once('../../../include/phrasen.class.php'); + require_once('../../../include/benutzerberechtigung.class.php'); + + $sprache = getSprache(); + $p = new phrasen($sprache); + $uid=get_uid(); + + if(isset($_GET['uid'])) + { + // Administratoren duerfen die UID als Parameter uebergeben um die Zahlungen + // von anderen Personen anzuzeigen + + $rechte = new benutzerberechtigung(); + $rechte->getBerechtigungen($uid); + if($rechte->isBerechtigt('admin')) + { + $uid = $_GET['uid']; + $getParam = "&uid=" . $uid; + } + else + $getParam = ""; + } + else + $getParam=''; + + $datum_obj = new datum(); + + echo ' + + + + '.$p->t('tools/zahlungen').' + + '; + + include('../../../include/meta/jquery.php'); + include('../../../include/meta/jquery-tablesorter.php'); + +echo ' + + + + + + '; + + $studiengang = new studiengang(); + $studiengang->getAll(null,null); + + $stg_arr = array(); + foreach ($studiengang->result as $row) + $stg_arr[$row->studiengang_kz]=$row->kuerzel; + + $benutzer = new benutzer(); + if(!$benutzer->load($uid)) + die('Benutzer wurde nicht gefunden'); + + echo '

    '.$p->t('tools/zahlungen').' - '.$benutzer->vorname.' '.$benutzer->nachname.'

    '; + + $konto = new konto(); + $konto->getBuchungstyp(); + $buchungstyp = array(); + + foreach ($konto->result as $row) + $buchungstyp[$row->buchungstyp_kurzbz]=$row->beschreibung; + + $konto = new konto(); + $konto->getBuchungen($benutzer->person_id); + if(count($konto->result)>0) + { + echo '

    '; + echo ''; + echo ' + + + + + + + '; + echo ''; + + foreach ($konto->result as $row) + { + $i=0; //Zaehler fuer Anzahl Gegenbuchungen + $buchungsnummern=''; + + if(!isset($row['parent'])) + continue; + $betrag = $row['parent']->betrag; + + + if(isset($row['childs'])) + { + foreach ($row['childs'] as $key => $row_child) + { + $betrag += $row_child->betrag; + $betrag = round($betrag, 2); + $buchungsnummern .= ';'.$row['childs'][$key]->buchungsnr; + $i = $key; //Zaehler auf letzten Gegenbuchungseintrag setzen + } + } + else + $buchungsnummern = $row['parent']->buchungsnr; + + if($betrag<0) + $style='style="background-color: #FF8888;"'; + elseif($betrag>0) + $style='style="background-color: #88DD88;"'; + else + $style=''; + + echo ""; + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + echo ''; + echo ''; + } + echo ''; + } + echo '
    '.$p->t('global/datum').''.$p->t('tools/zahlungstyp').''.$p->t('lvplan/stg').''.$p->t('global/studiensemester').''.$p->t('tools/buchungstext').''.$p->t('tools/betrag').''.$p->t('tools/zahlungsbestaetigung').'
    '.date('d.m.Y',$datum_obj->mktime_fromdate(isset($row['childs'][$i])?$row['childs'][$i]->buchungsdatum:$row['parent']->buchungsdatum)).''.$buchungstyp[$row['parent']->buchungstyp_kurzbz].''.$stg_arr[$row['parent']->studiengang_kz].''.$row['parent']->studiensemester_kurzbz.''.$row['parent']->buchungstext.'€ '.($betrag<0?'-':($betrag>0?'+':'')).sprintf('%.2f',abs($row['parent']->betrag)).''; + if($betrag>=0 && $row['parent']->betrag<=0) + { + echo ''.$p->t('tools/bestaetigungDrucken').''; + } + elseif($row['parent']->betrag>0) + { + //Auszahlung + } + else + { + echo ''.$p->t('tools/offen').'(€ '.sprintf('%.2f',$betrag*-1).')'; + + echo '
    '; + } + else + { + echo $p->t('tools/keineZahlungenVorhanden'); + } + echo ''; +?> diff --git a/cis/private/profile/zeitwunsch.php b/cis/private/profile/zeitwunsch.php index ef0840c87..ff4c35ebd 100644 --- a/cis/private/profile/zeitwunsch.php +++ b/cis/private/profile/zeitwunsch.php @@ -29,7 +29,10 @@ require_once('../../../include/globals.inc.php'); require_once('../../../include/functions.inc.php'); require_once('../../../include/datum.class.php'); require_once('../../../include/zeitwunsch.class.php'); +require_once('../../../include/studiensemester.class.php'); +require_once('../../../include/zeitaufzeichnung_gd.class.php'); require_once('../../../include/benutzer.class.php'); +require_once('../../../include/mitarbeiter.class.php'); require_once('../../../include/phrasen.class.php'); require_once('../../../include/sprache.class.php'); @@ -46,6 +49,7 @@ $uid = get_uid(); if(!check_lektor($uid)) die($p->t('global/keineBerechtigungFuerDieseSeite')); + $PHP_SELF = $_SERVER['PHP_SELF']; if(isset($_GET['type'])) @@ -107,6 +111,57 @@ $person = new benutzer(); if(!$person->load($uid)) die($person->errormsg); +$ma = new mitarbeiter($uid); +$fixangestellt = $ma->fixangestellt; + +// Nächstes Studiensemester +$ss = new Studiensemester(); +$ss->getNextStudiensemester(); +$next_ss = $ss->studiensemester_kurzbz; +$current_ss = $ss->getakt(); + +// Erklärung zu Pausen bei geteilten Arbeitszeiten speichern +if (isset($_GET['selbstverwaltete-pause-akt']) && !empty($_GET['submit-akt'])) +{ + $selbstverwaltete_pause = ($_GET['selbstverwaltete-pause-akt'] == 'yes') ? true : false; + + $zeitaufzeichnung_gd = new Zeitaufzeichnung_gd(); + $zeitaufzeichnung_gd->uid = $uid; + $zeitaufzeichnung_gd->studiensemester_kurzbz = $current_ss; + $zeitaufzeichnung_gd->selbstverwaltete_pause = $selbstverwaltete_pause; + $za_gd = new Zeitaufzeichnung_gd(); + $za_gd->load($uid, $current_ss); + if ($za_gd->uid) + { + echo 'Bereits eingetragen'; + } + else if (!$zeitaufzeichnung_gd->save()) + { + echo $zeitaufzeichnung_gd->errormsg; + } + +} +if (isset($_GET['selbstverwaltete-pause']) && !empty($_GET['submit'])) +{ + $selbstverwaltete_pause = ($_GET['selbstverwaltete-pause'] == 'yes') ? true : false; + + $zeitaufzeichnung_gd = new Zeitaufzeichnung_gd(); + $zeitaufzeichnung_gd->uid = $uid; + $zeitaufzeichnung_gd->studiensemester_kurzbz = $next_ss; + $zeitaufzeichnung_gd->selbstverwaltete_pause = $selbstverwaltete_pause; + $za_gd = new Zeitaufzeichnung_gd(); + $za_gd->load($uid, $next_ss); + if ($za_gd->uid) + { + echo 'Bereits eingetragen'; + } + else if (!$zeitaufzeichnung_gd->save()) + { + echo $zeitaufzeichnung_gd->errormsg; + } + +} + ?> @@ -143,8 +198,56 @@ if(!$person->load($uid)) +
    + + + + + + /** * Sendet eine Email an den Ersteller der Umfrage - * + * * @param type $ersteller */ function sendBenachrichtigung($coodle_id, $teilnehmer_id) @@ -710,16 +903,16 @@ function sendBenachrichtigung($coodle_id, $teilnehmer_id) global $uid; global $coodle; $coodle_send = new coodle(); - - if (! $coodle_send->load($coodle_id)) + + if (!$coodle_send->load($coodle_id)) { die("Fehler beim senden aufgetreten"); } - + $mitarbeiter = new mitarbeiter(); $person = new person(); $teilnehmer = new coodle(); - + $teilnehmer->getRessourceFromId($teilnehmer_id); if ($teilnehmer->zugangscode != '') $tn = $teilnehmer->name; @@ -727,50 +920,50 @@ function sendBenachrichtigung($coodle_id, $teilnehmer_id) { $mitarbeiter->load($teilnehmer->uid); $person->load($mitarbeiter->person_id); - $tn = $person->vorname . " " . $person->nachname; + $tn = $person->vorname." ".$person->nachname; } $mitarbeiter->load($coodle_send->ersteller_uid); $person->load($mitarbeiter->person_id); - + $email = ''; - + $name = ''; - $name .= ($person->titelpre != '') ? $person->titelpre . ' ' : ''; - $name .= $person->vorname . ' ' . $person->nachname; - $name .= ($person->titelpost != '') ? ' ' . $person->titelpost : ''; - + $name .= ($person->titelpre != '') ? $person->titelpre.' ' : ''; + $name .= $person->vorname.' '.$person->nachname; + $name .= ($person->titelpost != '') ? ' '.$person->titelpost : ''; + if ($person->geschlecht == 'w') - $email .= 'Sehr geehrte Frau ' . $name . "!

    "; + $email .= 'Sehr geehrte Frau '.$name."!

    "; else - $email .= "Sehr geehrter Herr " . $name . "!

    "; - - $link = APP_ROOT . 'cis/public/coodle.php?coodle_id=' . urlencode($coodle_id) . '&uid=' . urlencode($uid); - $email .= $tn . ' hat einen Termin zu Ihrer Coodle-Umfrage mit dem Thema "' . $coodle->titel . '" ausgewählt.
    Link zu Ihrer Coodle Umfrage

    Mit freundlichen Grüßen

    + $email .= "Sehr geehrter Herr ".$name."!

    "; + + $link = APP_ROOT.'cis/public/coodle.php?coodle_id='.urlencode($coodle_id).'&uid='.urlencode($uid); + $email .= $tn.' hat einen Termin zu Ihrer Coodle-Umfrage mit dem Thema "'.$coodle->titel.'" ausgewählt.
    Link zu Ihrer Coodle Umfrage

    Mit freundlichen Grüßen

    Fachhochschule Technikum Wien
    Höchstädtplatz 6
    1200 Wien'; - - $mail = new mail($coodle_send->ersteller_uid . '@' . DOMAIN, 'no-reply', 'Feedback zu Ihrer Coodle Umfrage "' . $coodle->titel . '"', 'Bitte sehen Sie sich die Nachricht in HTML Sicht an, um den Link vollständig darzustellen.'); + + $mail = new mail($coodle_send->ersteller_uid.'@'.DOMAIN, 'no-reply', 'Feedback zu Ihrer Coodle Umfrage "'.$coodle->titel.'"', 'Bitte sehen Sie sich die Nachricht in HTML Sicht an, um den Link vollständig darzustellen.'); $mail->setHTMLContent($email); - if (! $mail->send()) + if (!$mail->send()) die("Fehler beim senden des Mails aufgetreten"); } /** * Funktion sendet den ausgewählten Termin an alle Ressourcen aus der übergebenen Coodleumfrage - * - * @global phrasen $p + * * @param type $coodle_id * @param type $auswahl + * @global phrasen $p */ function sendEmail($coodle_id) { - global $mailMessage; + global $mailMessage, $tagbez, $sprache_index; global $p; $coodle_help = new coodle(); $termin_id = $coodle_help->getTerminAuswahl($coodle_id); $coodle_help->loadTermin($termin_id); - + $coodle_ressource = new coodle(); $coodle_ressource->getRessourcen($coodle_id); $coodle = new coodle(); @@ -791,8 +984,8 @@ function sendEmail($coodle_id) { $benutzer = new benutzer(); $benutzer->load($row->uid); - $name = trim($benutzer->titelpre . ' ' . $benutzer->vorname . ' ' . $benutzer->nachname . ' ' . $benutzer->titelpost); - $mail = $row->uid . '@' . DOMAIN; + $name = trim($benutzer->titelpre.' '.$benutzer->vorname.' '.$benutzer->nachname.' '.$benutzer->titelpost); + $mail = $row->uid.'@'.DOMAIN; } else { @@ -805,23 +998,23 @@ function sendEmail($coodle_id) $partstat = 'ACCEPTED'; else $partstat = 'TENTATIVE'; - - $teilnehmer .= 'ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=' . $partstat . ';CN=' . $name . "\n :MAILTO:" . $mail . "\n"; + + $teilnehmer .= 'ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT='.$partstat.';CN='.$name."\n :MAILTO:".$mail."\n"; } } - $date = new DateTime($coodle_help->datum . ' ' . $coodle_help->uhrzeit); + $date = new DateTime($coodle_help->datum.' '.$coodle_help->uhrzeit); // Datum des Termins ins richtige Format bringen $dtstart = $date->format('Ymd\THis'); - + // Ende Datum berechnen - $interval = new DateInterval('PT' . $coodle->dauer . 'M'); + $interval = new DateInterval('PT'.$coodle->dauer.'M'); $date->add($interval); $dtend = $date->format('Ymd\THis'); $date = new DateTime(); $dtstamp = $date->format('Ymd\THis'); $benutzer = new benutzer(); $benutzer->load($coodle->ersteller_uid); - $erstellername = trim($benutzer->titelpre . ' ' . $benutzer->vorname . ' ' . $benutzer->nachname . ' ' . $benutzer->titelpost); + $erstellername = trim($benutzer->titelpre.' '.$benutzer->vorname.' '.$benutzer->nachname.' '.$benutzer->titelpost); // Ical File erstellen $ical = "BEGIN:VCALENDAR PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN @@ -845,50 +1038,52 @@ TZOFFSETTO:+0100 END:STANDARD END:VTIMEZONE BEGIN:VEVENT -ORGANIZER:MAILTO:" . $erstellername . " <" . $coodle->ersteller_uid . "@" . DOMAIN . " -" . $teilnehmer . " -DTSTART;TZID=Europe/Vienna:" . $dtstart . " -DTEND;TZID=Europe/Vienna:" . $dtend . " -LOCATION:" . $ort . " +ORGANIZER:MAILTO:".$erstellername." <".$coodle->ersteller_uid."@".DOMAIN." +".$teilnehmer." +DTSTART;TZID=Europe/Vienna:".$dtstart." +DTEND;TZID=Europe/Vienna:".$dtend." +LOCATION:".$ort." TRANSP:OPAQUE SEQUENCE:0 -UID:FHCompleteCoodle" . $coodle_id . " -DTSTAMP;TZID=Europe/Vienna:" . $dtstamp . " -DESCRIPTION:" . strip_tags(html_entity_decode($coodle->beschreibung, ENT_QUOTES, 'UTF-8')) . " -SUMMARY:" . strip_tags($coodle->titel) . " +UID:FHCompleteCoodle".$coodle_id." +DTSTAMP;TZID=Europe/Vienna:".$dtstamp." +DESCRIPTION:".strip_tags(html_entity_decode($coodle->beschreibung, ENT_QUOTES, 'UTF-8'))." +SUMMARY:".strip_tags($coodle->titel)." PRIORITY:5 CLASS:PUBLIC END:VEVENT END:VCALENDAR"; - + if (count($coodle_ressource->result) > 0) { + $mailMessageError = ''; + $mailMessageSuccess = '
    '; foreach ($coodle_ressource->result as $row) { if ($row->uid != '') { $benutzer = new benutzer(); - if (! $benutzer->load($row->uid)) + if (!$benutzer->load($row->uid)) { - $mailMessage .= "Fehler beim Laden des Benutzers " . $coodle_ressource->convert_html_chars($row->uid); + $mailMessageError .= "Fehler beim Laden des Benutzers ".$coodle_ressource->convert_html_chars($row->uid); continue; } - + if ($benutzer->geschlecht == 'w') $anrede = "Sehr geehrte Frau "; else $anrede = "Sehr geehrter Herr "; - - $anrede .= $benutzer->titelpre . ' ' . $benutzer->vorname . ' ' . $benutzer->nachname . ' ' . $benutzer->titelpost; - + + $anrede .= $benutzer->titelpre.' '.$benutzer->vorname.' '.$benutzer->nachname.' '.$benutzer->titelpost; + // Interner Teilnehmer - $email = $row->uid . '@' . DOMAIN; + $email = $row->uid.'@'.DOMAIN; } elseif ($row->email != '') { // Externe Teilnehmer $email = $row->email; - $anrede = 'Sehr geehrte(r) Herr/Frau ' . $row->name; + $anrede = 'Sehr geehrte(r) Herr/Frau '.$row->name; } else { @@ -897,30 +1092,44 @@ END:VCALENDAR"; } $anrede = trim($anrede); $sign = $p->t('mail/signatur'); - + $datum = new datum(); - - $html = $anrede . '!

    - Die Terminumfrage zum Thema "' . $coodle_ressource->convert_html_chars($coodle->titel) . '" ist beendet. + + $html = $anrede.'!

    + Die Terminumfrage zum Thema "'.$coodle_ressource->convert_html_chars($coodle->titel).'" ist beendet.
    - Der Termin wurde auf den ' . $datum->formatDatum($coodle_help->datum, 'd.m.Y') . ' ' . $coodle_help->uhrzeit . ' festgelegt. -

    ' . nl2br($sign); - - $text = $anrede . "!\n\nDie Terminumfrage zum Thema \"" . $coodle_help->convert_html_chars($coodle->titel) . '"\" ist beendet.\n - Der Termin wurde auf den ' . $datum->formatDatum($coodle_help->datum, 'd.m.Y') . ' ' . $coodle_help->uhrzeit . " festgelegt\n. + Der Termin wurde auf + '.substr($tagbez[$sprache_index][$datum->formatDatum($coodle_help->datum, 'N')], 0, 2).', '. + $datum->formatDatum($coodle_help->datum, 'd.m.Y').' '. + $datum->formatDatum($coodle_help->uhrzeit, 'H:i').' + festgelegt. +

    '.nl2br($sign); + + $text = $anrede."!\n\nDie Terminumfrage zum Thema \"".$coodle_help->convert_html_chars($coodle->titel).'"\" ist beendet.\n + Der Termin wurde auf + '.substr($tagbez[$sprache_index][$datum->formatDatum($coodle_help->datum, 'N')], 0, 2).', '. + $datum->formatDatum($coodle_help->datum, 'd.m.Y').' '. + $datum->formatDatum($coodle_help->uhrzeit, 'H:i')." + festgelegt\n. \n\n$sign"; - - $mail = new mail($email, 'no-reply@' . DOMAIN, 'Terminbestätigung - ' . $coodle->titel, $text); + + $mail = new mail($email, 'no-reply@'.DOMAIN, 'Terminbestätigung - '.$coodle->titel, $text); $mail->setHTMLContent($html); // ICal Termineinladung hinzufuegen $mail->addAttachmentPlain($ical, 'text/calendar', 'meeting.ics'); if ($mail->send()) { - $mailMessage .= $p->t('coodle/mailVersandtAn', array( - $email - )) . "
    "; + $mailMessageSuccess .= $p->t('coodle/mailVersandtAn', array( + $email + ))."
    "; } } + if ($mailMessageError != '') + { + $mailMessageError = '
    '.$mailMessageError.'
    '; + } + $mailMessageSuccess .= '
    '; + $mailMessage = $mailMessageError.$mailMessageSuccess; } else { @@ -931,7 +1140,7 @@ END:VCALENDAR"; /** * * Prueft ob ein Raum belegt ist - * + * * @param $ort_kurzbz * @param $datum * @param array $stunden @@ -946,14 +1155,14 @@ function RaumBelegt($ort_kurzbz, $datum, $stunden) { return true; } - + // Stundenplan abfragen $stundenplan = new stundenplan('stundenplan'); if ($stundenplan->isBelegt($ort_kurzbz, $datum, $stunde)) { return true; } - + // Stundenplan DEV abfragen $stundenplan = new stundenplan('stundenplandev'); if ($stundenplan->isBelegt($ort_kurzbz, $datum, $stunde)) @@ -963,4 +1172,5 @@ function RaumBelegt($ort_kurzbz, $datum, $stunden) } return false; } + ?> \ No newline at end of file diff --git a/cis/public/ical_coodle.php b/cis/public/ical_coodle.php new file mode 100644 index 000000000..a4be8b52f --- /dev/null +++ b/cis/public/ical_coodle.php @@ -0,0 +1,135 @@ + + */ +/** + * Dieses Script liefert die iCal Informationen für die vorreservierten Coodle Termine + * + * Aufruf: http://www.example.com/cis/public/ical_coodle.php/[uid] + */ +require_once('../../config/cis.config.inc.php'); +require_once('../../include/benutzer.class.php'); +require_once('../../include/functions.inc.php'); +require_once('../../include/coodle.class.php'); +require_once('../../include/ical.class.php'); + +$uid = mb_substr($_SERVER['PATH_INFO'],1); + +$bn = new benutzer(); +if(!$bn->load($uid)) + die('User invalid'); + +header("Content-Type: text/calendar; charset=UTF-8"); + +echo "BEGIN:VCALENDAR\n"; +echo "VERSION:2.0\n"; +echo "PRODID:-//FH TECHNIKUM WIEN//EN\n"; +//echo "METHOD:PUBLISH\n"; +//echo 'ORGANIZER;CN=',$bn->vorname,' ',$bn->nachname,':mailto:',$uid,'@',DOMAIN,"\n"; +//echo 'DTSTAMP;TZID=Europe/Vienna:',date('Ymd', mktime(date('H'),date('i'),date('s'),date('m'),date('d')-5,date('Y'))),'T',date('Hms'),"\n"; +echo 'DTSTART;TZID=Europe/Vienna:',date('Ymd', mktime(0,0,0,date('m'),date('d')-5,date('Y'))),"T000000\n"; +echo 'DTEND;TZID=Europe/Vienna:',date('Ymd', mktime(0,0,0,date('m'),date('d')+30,date('Y'))),"T000000\n"; +echo "BEGIN:VTIMEZONE +TZID:Europe/Vienna +BEGIN:DAYLIGHT +TZOFFSETFROM:+0100 +RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU +DTSTART:19810329T020000 +TZNAME:GMT+02:00 +TZOFFSETTO:+0200 +END:DAYLIGHT +BEGIN:STANDARD +TZOFFSETFROM:+0200 +RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU +DTSTART:19961027T030000 +TZNAME:GMT+01:00 +TZOFFSETTO:+0100 +END:STANDARD +END:VTIMEZONE\n"; +//echo 'URL:',APP_ROOT,'cis/public/ical_coodle.php/',$uid,"\n"; +echo "BEGIN:VEVENT"; +// Alle Umfragen holen an denen der User beteiligt ist +$umfragen = new coodle(); +$umfragen->getCoodleFromUser($uid); +$i = 0; +foreach($umfragen->result as $umfrage) +{ + if($umfrage->coodle_status_kurzbz=='laufend') + { + // Bei laufenden Umfragen werden alle angekreuzten Vorschlaege zur FreeBusy hinzugefuegt + $ressource = new coodle(); + if($ressource_id = $ressource->RessourceExists($umfrage->coodle_id, $uid)) + { + // Terminvorschlaege laden die angekreuzt wurden + $termine = new coodle(); + $termine->getRessourceTermin($umfrage->coodle_id, $ressource_id); + foreach($termine->result as $termin) + { + //Start und Ende berechnen + $date = new DateTime($termin->datum.' '.$termin->uhrzeit); + $dtstart = $date->format('Ymd\THis'); + $interval =new DateInterval('PT'.$umfrage->dauer.'M'); + $date->add($interval); + $uhrzeit_ende = $date->format('H:i:s'); + $dtende = $date->format('Ymd\THis'); + + if ($i > 0) + { + echo "\nBEGIN:VEVENT"; + } + echo "\nUID:Coodle_Terminoption".$dtstart."_".$dtende.""; + echo "\nSUMMARY:Coodle Terminoption"; + echo "\nDTSTART;TZID=Europe/Vienna:$dtstart"; + echo "\nDTEND;TZID=Europe/Vienna:$dtende"; + echo "\nTRANSP:OPAQUE"; + echo "\nEND:VEVENT"; + + $i++; + } + } + } + // Bei abgeschlossene Umfragen wird ein iCal File mitgeschickt, + // deshalb müssen diese Termine nicht berücksichtigt werden + /*elseif($umfrage->coodle_status_kurzbz=='abgeschlossen') + { + // Bei abgeschlossenen Umfragen wird nur mehr der ausgewaehlte Termin zur FreeBusy hinzugefuegt + $termin = new coodle(); + $coodle_termin_id=$termin->getTerminAuswahl($umfrage->coodle_id); + if($termin->loadTermin($coodle_termin_id)) + { + //Start und Ende berechnen + $date = new DateTime($termin->datum.' '.$termin->uhrzeit); + $dtstart = $date->format('Ymd\THis'); + $interval =new DateInterval('PT'.$umfrage->dauer.'M'); + $date->add($interval); + $uhrzeit_ende = $date->format('H:i:s'); + $dtende = $date->format('Ymd\THis'); + + echo "\nBEGIN:VEVENT"; + echo "\nSUMMARY:Coodle Terminzusage"; + echo "\nDTSTART;TZID=Europe/Vienna: $dtstart"; + echo "\nDTEND;TZID=Europe/Vienna: $dtende"; + echo "\nTRANSP:OPAQUE"; + echo "\nEND:VEVENT"; + } + }*/ + // stornierte Umfragen werden nicht beruecksichtigt +} + +echo "\nEND:VCALENDAR"; +?> \ No newline at end of file diff --git a/cis/testtool/admin/copy_gebiet.php b/cis/testtool/admin/copy_gebiet.php new file mode 100644 index 000000000..970ce2e0e --- /dev/null +++ b/cis/testtool/admin/copy_gebiet.php @@ -0,0 +1,328 @@ +, + * Andreas Oesterreicher , + * Rudolf Hangl and + * Gerald Simane-Sequens + */ +/** + * Kopiert ein Testtool-Gebiet mit allen Fragen und Antworten aber ohne Zuordnungen zu Studiengängen und dgl. + */ + +require_once('../../../config/cis.config.inc.php'); +require_once('../../../include/functions.inc.php'); +require_once('../../../include/gebiet.class.php'); +require_once('../../../include/benutzerberechtigung.class.php'); +require_once('../../../include/studiengang.class.php'); +require_once('../../../include/sprache.class.php'); +require_once('../../../include/frage.class.php'); +require_once('../../../include/antwort.class.php'); +require_once('../../../include/vorschlag.class.php'); + +if (!$user = get_uid()) + die('Sie sind nicht angemeldet. Es wurde keine Benutzer UID gefunden ! Zurück'); + +$rechte = new benutzerberechtigung(); +$rechte->getBerechtigungen($user); + +$sprache = new sprache(); +$sprache->getAll(true, 'index'); + +$sprache_user = getSprache(); + +$db = new basis_db(); + +echo ' + + + + + + + + + + + + + + +
    +'; + +$stg_kz = (isset($_GET['stg_kz'])?$_GET['stg_kz']:'-1'); +$gebietToCopy = (isset($_POST['gebietToCopy'])?$_POST['gebietToCopy']:(isset($_GET['gebietToCopy'])?$_GET['gebietToCopy']:'')); +$gebiet = new gebiet(); + +echo 'Zurück zur Admin Seite

    '; +echo '

    Gebiet kopieren

    '; +echo '

    Kopiert ein Gebiet mit allen Fragen und Antworten aber ohne Zuordnungen zu Studiengängen und dgl.

    '; + +if(!$rechte->isBerechtigt('basis/testtool')) + die($rechte->errormsg); + +$returnmsg = ''; +//Speichern der Daten +if (isset($_POST['copyGebiet']) && $_POST['copyGebiet'] == 'copyGebiet') +{ + if (!$rechte->isBerechtigt('basis/testtool', null, 'suid')) + die($rechte->errormsg); + + if (isset($_POST['kurzbz']) && $_POST['kurzbz'] != '') + { + //Test, ob kurzbz schon vorhanden + if ($result = $db->db_query('SELECT kurzbz FROM testtool.tbl_gebiet WHERE kurzbz = '.$db->db_add_param($_POST['kurzbz']).' LIMIT 1;')) + { + if ($db->db_num_rows($result) == 0) + { + $gebietToCopy = $_POST['gebietToCopy']; + + // Zu kopierendes Gebiet laden + $gebiet = new gebiet($gebietToCopy); + + $bezeichnung_mehrsprachig = array(); + foreach ($sprache->result as $row_sprache) + { + $bezeichnung_mehrsprachig[$row_sprache->sprache] = $_POST['bezeichnung_mehrsprachig_'.$row_sprache->sprache]; + } + $gebiet->bezeichnung_mehrsprachig = $bezeichnung_mehrsprachig; + + $gebiet->kurzbz = $_POST['kurzbz']; + $gebiet->bezeichnung = $_POST['bezeichnung_intern']; + $gebiet->beschreibung = $_POST['beschreibung']; + $gebiet->insertamum = date('Y-m-d H:i:s'); + $gebiet->insertvon = $user; + + // Neues Gebiet speichern + if ($gebiet->save(true)) + { + $returnmsg .= '

    Gebiet erfolgreich kopiert

    '; + + // Array mit allen Fragen und Antworten anlegen + $frageAntwortArray = array(); + + // Fragen laden + $fragenToCopy = new frage(); + $fragenToCopy->getFragenGebiet($gebietToCopy); + // Sprachen laden und für jede Sprache die Fragen und Antworten laden + foreach ($sprache->result as $row_sprache) + { + $fragenSpracheToCopy = new frage(); + $indexFrageSprache = 0; + foreach ($fragenToCopy->result AS $copyFrage) + { + if ($fragenSpracheToCopy->getFrageSprache($copyFrage->frage_id, $row_sprache->sprache, true)) + { + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['nummer'] = $fragenSpracheToCopy->nummer; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['demo'] = $fragenSpracheToCopy->demo; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['kategorie_kurzbz'] = $fragenSpracheToCopy->kategorie_kurzbz; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['level'] = $fragenSpracheToCopy->level; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['aktiv'] = $fragenSpracheToCopy->aktiv; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['text'] = $fragenSpracheToCopy->text; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['bild'] = $fragenSpracheToCopy->bild; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['audio'] = $fragenSpracheToCopy->audio; + + // Vorschläge laden + $vorschlagSprachenToCopy = new vorschlag(); + $vorschlagSprachenToCopy->getVorschlag($copyFrage->frage_id, $row_sprache->sprache, false); + + $indexVorschlagSprache = 0; + foreach ($vorschlagSprachenToCopy->result AS $vorschlagSprache) + { + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['vorschlaege'][$indexVorschlagSprache]['nummer'] = $vorschlagSprache->nummer; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['vorschlaege'][$indexVorschlagSprache]['punkte'] = $vorschlagSprache->punkte; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['vorschlaege'][$indexVorschlagSprache]['text'] = $vorschlagSprache->text; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['vorschlaege'][$indexVorschlagSprache]['bild'] = $vorschlagSprache->bild; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['vorschlaege'][$indexVorschlagSprache]['audio'] = $vorschlagSprache->audio; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['vorschlaege'][$indexVorschlagSprache]['aktiv'] = $vorschlagSprache->aktiv; + $indexVorschlagSprache++; + } + } + $indexFrageSprache++; + } + } + + // Einfügen der Fragen und Antworten aus dem Array in das neue Gebiet + $anzahlFragenKopiert = 0; + + foreach ($frageAntwortArray AS $fragesprache => $index) + { + foreach ($index AS $frage => $value) + { + $newfragen = new frage(); + $newfragen->new = true; + + $newfragen->kategorie_kurzbz = $value["kategorie_kurzbz"]; + $newfragen->gebiet_id = $gebiet->gebiet_id; + $newfragen->level = $value["level"]; + $newfragen->nummer = $value["nummer"]; + $newfragen->demo = $value["demo"]; + $newfragen->insertamum = date('Y-m-d H:i:s'); + $newfragen->insertvon = $user; + $newfragen->aktiv = $value["aktiv"]; + + if ($newfragen->save()) + { + $newfragen->sprache = $fragesprache; + $newfragen->text = $value["text"]; + $newfragen->bild = $value["bild"]; + $newfragen->audio = $value["audio"]; + $newfragen->insertamum = date('Y-m-d H:i:s'); + $newfragen->insertvon = $user; + + if ($newfragen->save_fragesprache()) + { + if (isset($value["vorschlaege"])) + { + foreach ($value["vorschlaege"] AS $vorschlag => $content) + { + // Vorschläge speichern + $newvorschlaege = new vorschlag(); + $newvorschlaege->new = true; + + $newvorschlaege->frage_id = $newfragen->frage_id; + $newvorschlaege->nummer = $content["nummer"]; + $newvorschlaege->punkte = $content["punkte"]; + $newvorschlaege->aktiv = $content["aktiv"]; + $newvorschlaege->insertamum = date('Y-m-d H:i:s'); + $newvorschlaege->insertvon = $user; + + if ($newvorschlaege->save()) + { + $newvorschlaege->sprache = $fragesprache; + $newvorschlaege->text = $content["text"]; + $newvorschlaege->bild = $content["bild"]; + $newvorschlaege->audio = $content["audio"]; + $newvorschlaege->insertamum = date('Y-m-d H:i:s'); + $newvorschlaege->insertvon = $user; + + if ($newvorschlaege->save_vorschlagsprache()) + { + $anzahlFragenKopiert++; + } + } + } + } + } + else + { + $returnmsg .= '

    Fehler beim Speichern der Fragesprache '.$fragesprache.' bei Frage: '.$newfragen->frage_id.'

    '; + } + } + else + { + $returnmsg .= '

    Fehler beim Speichern der Frage: '.$newfragen->frage_id.'

    '; + } + } + } + } + else + { + $returnmsg .= '

    Fehler beim Speichern: '.$gebiet->errormsg.'

    '; + } + } + else + $returnmsg .= '

    Kurzbezeichnung ist schon vorhanden

    '; + } + } + else + { + $returnmsg .= '

    Bitte füllen Sie alle Pflichtfelder aus

    '; + } +} + + +$studiengang = new studiengang(); +$studiengang->getAll('typ, kurzbz', false); + +echo '

    '.$returnmsg.'

    '; +echo ' +
    +
    +

    Zustimmung zur Verplanung in geteilter Arbeitszeit

    + +
    +

    + t('zeitwunsch/geteilteArbeitszeit'); + $gd = new zeitaufzeichnung_gd(); + $gd->load($uid, $current_ss); + if ( ! $gd->uid ) + { + echo '

    Zustimmung für '.$current_ss.': '; + echo 'ja'; + echo 'nein'; + echo '




    '; + } + else + { + $zustimmung = ($gd->selbstverwaltete_pause) ? ' erteilt' : 'abgelehnt'; + echo '

    Zustimmung für '.$current_ss.': '.$zustimmung.' am '.$datum_obj->formatDatum($gd->insertamum,'d.m.Y H:i:s').'

    '; + } + $gd = new zeitaufzeichnung_gd(); + $gd->load($uid, $next_ss); + if ( ! $gd->uid ) + { + echo '

    Zustimmung für '.$next_ss.': '; + echo 'ja'; + echo 'nein'; + echo '




    '; + } + else + { + $zustimmung = ($gd->selbstverwaltete_pause) ? ' erteilt' : 'abgelehnt'; + echo '

    Zustimmung für '.$next_ss.': '.$zustimmung.' am '.$datum_obj->formatDatum($gd->insertamum,'d.m.Y H:i:s').'

    '; + } + //var_dump($gd); + ?> + +

    +
    +

    +

    t('zeitwunsch/zeitwunsch');?>

    @@ -206,12 +309,16 @@ if(!$person->load($uid)) ?> -
    "; - echo $p->t('zeitwunsch/formularZumEintragenDerZeitsperren', array($href)); - ?> - -

    t('zeitwunsch/erklärung');?>:

    + +
    + +

    t('zeitwunsch/erklärung');?>:

    + + "; + echo $p->t('zeitwunsch/formularZumEintragenDerZeitsperren', array($href)); + ?> +

    t('zeitwunsch/kontrollierenSieIhreZeitwuensche');?>!

    diff --git a/cis/private/tools/ampelverwaltung.php b/cis/private/tools/ampelverwaltung.php index 893ac8764..96a92d2bb 100644 --- a/cis/private/tools/ampelverwaltung.php +++ b/cis/private/tools/ampelverwaltung.php @@ -37,8 +37,8 @@ $person = new person(); $person->getPersonFromBenutzer($user); -$show = (isset($_POST['show']) ? $_POST['show'] : 'aktuell'); //show: alle / aktuell -$is_popup = (isset($_GET['verpflichtend']) && $_GET['verpflichtend'] == true) ? true : false; +$show = (isset($_POST['show']) ? $_POST['show'] : 'aktuell'); //show: alle / aktuell +$is_popup = (isset($_GET['verpflichtend']) && $_GET['verpflichtend'] == true) ? true : false; //Leiter OEs holen $benutzerfunktion = new benutzerfunktion(); $benutzerfunktion->getBenutzerFunktionen('Leitung', '', '', $user); @@ -80,7 +80,7 @@ if($type=='bestaetigen' && is_numeric($ampel_id)) $message=''; if($ampel->load($ampel_id)) { - if($ampel->isZugeteilt($user, $ampel->benutzer_select)) + if($ampel->isZugeteilt($user, $ampel->benutzer_select)) { if(!$ampel->isBestaetigt($user, $ampel_id)) { @@ -88,7 +88,7 @@ if($type=='bestaetigen' && is_numeric($ampel_id)) { echo ''; header('Refresh:0'); - exit; + exit; } else $message = ''.$ampel->errormsg.''; @@ -99,7 +99,7 @@ if($type=='bestaetigen' && is_numeric($ampel_id)) } else $message = ''.$p->t('tools/ampelNichtGefunden').''; - + if ($message != '') echo ''; } @@ -107,7 +107,7 @@ if($type=='bestaetigen' && is_numeric($ampel_id)) //get all user ampeln list( - $user_ampel_arr, + $user_ampel_arr, $cnt_ueberfaellig) = //counts overdue ampeln (not expired) getUserAmpelData($user); @@ -118,7 +118,7 @@ if (!empty($user_ampel_arr)) } //filter ampeln for popup (if at least one mandatory, which is neither expired nor before vorlaufzeit) -if ($is_popup) +if ($is_popup) { list( $user_ampel_arr, @@ -135,14 +135,14 @@ if (!$is_popup && $show == 'aktuell') function getUserAmpelData($user) { $cnt_ueberfaellig = 0; - + $ampel = new ampel(); $ampel->loadUserAmpel($user, true); $user_ampel_arr = array(); - + $datum = new datum(); $now = $datum->mktime_fromdate(date('Y-m-d')); - + foreach($ampel->result as $row) { $deadline = $datum->mktime_fromdate($row->deadline); @@ -150,23 +150,23 @@ function getUserAmpelData($user) $verfallszeit = $row->verfallszeit; $bestaetigt = $ampel->isBestaetigt($user, $row->ampel_id); $verpflichtend = $row->verpflichtend; // 't'/'f' - + $datum_liegt_vor_vorlaufzeit = false; $datum_liegt_nach_verfallszeit = false; - + if (!is_null($vorlaufzeit)) - $datum_liegt_vor_vorlaufzeit = $now < strtotime('-' . $vorlaufzeit . ' day', $deadline); - + $datum_liegt_vor_vorlaufzeit = $now < strtotime('-' . $vorlaufzeit . ' day', $deadline); + if (!is_null($verfallszeit)) $datum_liegt_nach_verfallszeit = $now > strtotime('+' . $verfallszeit . ' day', $deadline); //default $show_ampel = true; //true while actual date is not before vorlaufzeit $abgelaufen = false; //false while actual date is not after verfallszeit - $active = true; //true while not confirmed or expired + $active = true; //true while not confirmed or expired $status = 'gelb'; //yellow while not overdue (red) or confirmed (green) $status_ampel = ''; //ampel image - + if ($bestaetigt) $status = 'gruen'; @@ -174,21 +174,21 @@ function getUserAmpelData($user) if ($datum_liegt_vor_vorlaufzeit) $show_ampel = false; - + if ($datum_liegt_nach_verfallszeit) $abgelaufen = true; - if ($now >= $deadline && !$bestaetigt) + if ($now >= $deadline && !$bestaetigt) { if (!$abgelaufen) $cnt_ueberfaellig++; $status = 'rot'; } - + if ($bestaetigt || $abgelaufen) $active = false; - + //assign png-image to ampelstatus switch($status) { @@ -205,7 +205,7 @@ function getUserAmpelData($user) $status_ampel= ''; break; } - + $user_ampel_arr[] = array( 'ampel_id' => $row->ampel_id, 'kurzbz' => $row->kurzbz, @@ -216,23 +216,23 @@ function getUserAmpelData($user) 'bestaetigt' => $bestaetigt, 'deadline' => $row->deadline, 'vorlaufzeit' => $row->vorlaufzeit, - 'verfallszeit' => $row->verfallszeit, + 'verfallszeit' => $row->verfallszeit, 'beschreibung' => $row->beschreibung, 'abgelaufen' => $abgelaufen, 'active' => $active); } - + return array($user_ampel_arr, $cnt_ueberfaellig); } function sortUserAmpelData($user_ampel_arr) { //first: sort deadline $deadline_arr = array(); - foreach ($user_ampel_arr as $key => $val) + foreach ($user_ampel_arr as $key => $val) { $deadline_arr[$key] = $val['deadline']; } - + array_multisort($deadline_arr, SORT_DESC, $user_ampel_arr); //second: sort inactive after active @@ -247,7 +247,7 @@ function sortUserAmpelData($user_ampel_arr) else { $inactive_ampel_arr[] = $user_ampel; - } + } } return $user_ampel_arr = array_merge($active_ampel_arr, $inactive_ampel_arr); } @@ -292,7 +292,7 @@ function getActualUserAmpelData($user_ampel_arr, $semester_start) @@ -506,6 +646,29 @@ if($kartennummer != '') $kunde_uid = $betriebsmittel->uid; } //Speichern der Daten + +function checkVals ($oe_val, $project_val, $phase_val, $service_val) +{ + $error = 0; + if ($service_val && ( filter_var($service_val, FILTER_VALIDATE_INT) === false )) + $error = 1; + if ($phase_val && ( filter_var($phase_val, FILTER_VALIDATE_INT) === false )) + $error = 1; + if ($oe_val) + { + $oecheck = new organisationseinheit($oe_val); + if ($oecheck->errormsg) + $error = 1; + } + if ($project_val) + { + $procheck = new projekt($project_val); + if ($procheck->errormsg) + $error = 1; + } + return $error; +} + if(isset($_POST['save']) || isset($_POST['edit']) || isset($_POST['import'])) { $zeit = new zeitaufzeichnung(); @@ -530,13 +693,35 @@ if(isset($_POST['save']) || isset($_POST['edit']) || isset($_POST['import'])) { if($data[0] == $user) { + if (!isset($data[5])) + $data[5] = NULL; + if (!isset($data[6])) + $data[6] = NULL; + if (!isset($data[7])) + $data[7] = NULL; + if (!isset($data[8])) + $data[8] = NULL; if ($datum->formatDatum($data[2], $format='Y-m-d H:i:s') < $sperrdatum) echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': Eingabe nicht möglich da vor dem Sperrdatum ('.$data[2].')
    '; + //elseif (isset($data[8]) && ( filter_var($data[8], FILTER_VALIDATE_INT) === false )) + //{ + // echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': Service ID ist keine Zahl ('.$data[8].')
    '; + //} + elseif (checkVals($data[5],$data[6],$data[7],$data[8])) + { + echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': Fehlerhafte Werte ('.$data[2].')
    '; + } else { if ($data[1] == 'LehreIntern') $data[1] = 'Lehre'; $zeit->new = true; + $zeit->beschreibung = NULL; + $zeit->oe_kurzbz_1 = NULL; + $zeit->projekt_kurzbz = NULL; + $zeit->projektphase_id = NULL; + $zeit->service_id = NULL; + $zeit->insertamum = date('Y-m-d H:i:s'); $zeit->updateamum = date('Y-m-d H:i:s'); $zeit->updatevon = $user; @@ -548,7 +733,13 @@ if(isset($_POST['save']) || isset($_POST['edit']) || isset($_POST['import'])) if (isset($data[4])) $zeit->beschreibung = $data[4]; if (isset($data[5])) - $zeit->service_id = $data[5]; + $zeit->oe_kurzbz_1 = $data[5]; + if (isset($data[6])) + $zeit->projekt_kurzbz = $data[6]; + if (isset($data[7])) + $zeit->projektphase_id = $data[7]; + if (isset($data[8])) + $zeit->service_id = $data[8]; $tag = $datum->formatDatum($data[2], $format='Y-m-d'); if(!in_array($tag, $importtage_array)) @@ -571,10 +762,10 @@ if(isset($_POST['save']) || isset($_POST['edit']) || isset($_POST['import'])) $pause->aktivitaet_kurzbz = 'Pause'; $pause->start = $ende_vorher; $pause->ende = $zeit->start; - $zeit->beschreibung = ''; + $pause->beschreibung = ''; if(!$pause->save()) { - echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': '.$pause->errormsg.''; + echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': '.$pause->errormsg.'
    '; } } } @@ -591,7 +782,7 @@ if(isset($_POST['save']) || isset($_POST['edit']) || isset($_POST['import'])) */ if(!$zeit->save()) { - echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': '.$zeit->errormsg.'('.$zeit->start.')'; + echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': '.$zeit->errormsg.'('.$zeit->start.')
    '; } else $anzahl++; @@ -601,6 +792,10 @@ if(isset($_POST['save']) || isset($_POST['edit']) || isset($_POST['import'])) } } + else if (strpos($data[0],'#') === false) + { + echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': Falsche UID nicht importiert ('.$data[0].')
    '; + } } if($anzahl>0) { @@ -645,14 +840,81 @@ if(isset($_POST['save']) || isset($_POST['edit']) || isset($_POST['import'])) $zeit->updateamum = date('Y-m-d H:i:s'); $zeit->updatevon = $user; $zeit->projekt_kurzbz = $projekt_kurzbz; + $zeit->projektphase_id = $projektphase_id; $zeit->service_id = $service_id; $zeit->kunde_uid = $kunde_uid; - - if(!$zeit->save()) + $saveerror = 0; + if (isset($_POST['genPause']) && (isset($_POST['save']) || isset($_POST['edit']))) { - echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': '.$zeit->errormsg.''; + + $p_start = $datum->formatDatum($von_pause, $format='Y-m-d H:i:s'); + $p_end = $datum->formatDatum($bis_pause, $format='Y-m-d H:i:s'); + + // checken ob Pause innerhalb der Arbeitszeit ist + if ($zeit->start > $p_start || $zeit->ende < $p_end) + { + echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': Pause außerhalb der Arbeitszeit
    '; + $saveerror = 1; + + } + elseif ($p_start > $p_end) + { + echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': Fehlerhafte Pausenzeiten
    '; + $saveerror = 1; + } + else + { + //Eintrag Arbeit bis zur Pause + $zeit->ende = $datum->formatDatum($von_pause, $format='Y-m-d H:i:s'); + if(!$zeit->save()) + { + echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': '.$zeit->errormsg.'
    '; + $saveerror = 1; + } + //Eintrag für die Pause + $pause = new zeitaufzeichnung(); + $pause->new = true; + $pause->insertamum = date('Y-m-d H:i:s'); + $pause->updateamum = date('Y-m-d H:i:s'); + $pause->updatevon = $user; + $pause->insertvon = $user; + $pause->uid = $user; + $pause->aktivitaet_kurzbz = 'Pause'; + $pause->start = $datum->formatDatum($von_pause, $format='Y-m-d H:i:s'); + $pause->ende = $datum->formatDatum($bis_pause, $format='Y-m-d H:i:s'); + $pause->beschreibung = ''; + if(!$pause->save()) + { + echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': '.$pause->errormsg.'
    '; + $saveerror = 1; + } + // Eintrag Arbeit ab der Pause + if ($zeit->new == false) + { + $zeit->new = true; + $zeit->insertamum = date('Y-m-d H:i:s'); + $zeit->insertvon = $user; + } + + $zeit->start = $datum->formatDatum($bis_pause, $format='Y-m-d H:i:s'); + $zeit->ende = $datum->formatDatum($bis, $format='Y-m-d H:i:s'); + if(!$zeit->save()) + { + echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': '.$zeit->errormsg.'
    '; + $saveerror = 1; + } + } } - else + elseif (!isset($_POST['genPause'])) + { + if(!$zeit->save()) + { + echo ''.$p->t("global/fehlerBeimSpeichernDerDaten").': '.$zeit->errormsg.''; + $saveerror = 1; + } + } + + if ($saveerror == 0) { echo ''.$p->t("global/datenWurdenGespeichert").''; @@ -667,12 +929,14 @@ if(isset($_POST['save']) || isset($_POST['edit']) || isset($_POST['import'])) $oe_kurzbz_1 = ''; $oe_kurzbz_2 = ''; $projekt_kurzbz = ''; + $projektphase_id = ''; $service_id = ''; $kunde_uid = ''; } } } + //Datensatz loeschen if(isset($_GET['type']) && $_GET['type']=='delete') { @@ -719,8 +983,20 @@ if(isset($_GET['type']) && $_GET['type']=='edit') $oe_kurzbz_1 = $zeit->oe_kurzbz_1; $oe_kurzbz_2 = $zeit->oe_kurzbz_2; $projekt_kurzbz = $zeit->projekt_kurzbz; + $projektphase_id = $zeit->projektphase_id; $service_id = $zeit->service_id; $kunde_uid = $zeit->kunde_uid; + + $projektphase = new projektphase(); + + $projektphasen = array(); + if($projektphase->getProjektphasen($projekt_kurzbz)) + { + foreach ($projektphase->result as $row) + { + $projektphasen[] = $row; + } + } } else { @@ -747,7 +1023,7 @@ if($projekt->getProjekteMitarbeiter($user, true)) CSV Export"; if($anzprojekte > 0) - echo " | ".$p->t("zeitaufzeichnung/projektexport").""; + echo " | ".$p->t("zeitaufzeichnung/projektexport").""; echo "'; echo ''; echo ''; echo ''; + if ($passuid) + echo ''; echo ''; echo ''; echo ''; @@ -828,87 +1106,6 @@ if($projekt->getProjekteMitarbeiter($user, true)) echo ''; } - //Projekte werden nicht angezeigt wenn es keine gibt - if($anzprojekte > 0) - { - //Projekt - echo ' - - '; - echo ''; - } - if($za_simple == 0) - { - //OE_KURZBZ_1 - echo ' - '; - } - //Aktivitaet echo ''; echo ''; + + if($za_simple >= 0) + { + $oestyle = ''; + if($za_simple == 0) + $oestyle = 'style="width:200px;"'; + + //OE_KURZBZ_1 + echo ' + '; + } + + //Projekte werden nicht angezeigt wenn es keine gibt + if($anzprojekte > 0) + { + //Projekt + echo ' + + '; + } + if ($za_simple == 0) { - // Service - echo ' - - + + + echo ' + '; + + // person für Kundenvoransicht laden + $kunde_name = ''; + if($kunde_uid != '') + { + $user_kunde = new benutzer(); + + if($user_kunde->load($kunde_uid)) + $kunde_name=$user_kunde->vorname.' '.$user_kunde->nachname; + } + echo ' + + + '; - - // person für Kundenvoransicht laden - $kunde_name = ''; - if($kunde_uid != '') - { - $user_kunde = new benutzer(); - - if($user_kunde->load($kunde_uid)) - $kunde_name=$user_kunde->vorname.' '.$user_kunde->nachname; - } - echo ' - - - - '; - echo ''; + echo ''; } //Start/Ende @@ -1017,6 +1332,16 @@ if($projekt->getProjekteMitarbeiter($user, true)) '; + echo ' + + + + + '; //Beschreibung echo ''; echo ' -

    '.$p->t('zeitaufzeichnung/projektexport').''.$p->t('zeitaufzeichnung/monat').' '.$p->t('zeitaufzeichnung/jahr').'

    '.$p->t("zeitaufzeichnung/projekt").'
    '.$p->t("zeitaufzeichnung/organisationseinheiten").'     '; - - //OE_KURZBZ_2 - echo '
    '.$p->t("zeitaufzeichnung/aktivitaet").''; @@ -918,7 +1115,7 @@ if($projekt->getProjekteMitarbeiter($user, true)) // $qry = "SELECT * FROM fue.tbl_aktivitaet where sort != 5 or sort is null ORDER by sort,beschreibung"; if($result = $db->db_query($qry)) { - echo ''; if ($za_simple == 0) echo ''; //else @@ -936,49 +1133,167 @@ if($projekt->getProjekteMitarbeiter($user, true)) } echo '
    '.$p->t("zeitaufzeichnung/organisationseinheiten").'     '; + if($za_simple == 0) + { + //OE_KURZBZ_2 + echo ''; + } + echo '
    '.$p->t("zeitaufzeichnung/projekt").''; + + //Projektphase + $showprojphases = isset($projektphasen) && is_array($projektphasen) && count($projektphasen) > 0 && $projektfound; + $hiddentext = $showprojphases ? "" : " style='display:none'"; + + echo + '    '. + $p->t("zeitaufzeichnung/projektphase").' + '; + } + echo '
    '.$p->t('zeitaufzeichnung/service').'
    '.$p->t('zeitaufzeichnung/service').'
    '.$p->t("zeitaufzeichnung/kunde").' '.$p->t("zeitaufzeichnung/oderKartennummerOptional").' +
    '.$p->t("zeitaufzeichnung/kunde").' '.$p->t("zeitaufzeichnung/oderKartennummerOptional").' -
     
     
      + + '.$p->t("zeitaufzeichnung/pauseEinfuegen").' - + +
    '.$p->t("global/beschreibung").'
    '; @@ -1101,7 +1426,7 @@ if($projekt->getProjekteMitarbeiter($user, true)) { //Uebersichtstabelle $woche=date('W'); - $colspan=($za_simple)?10:13; + $colspan=($za_simple)?12:14; echo ' @@ -1169,7 +1494,11 @@ if($projekt->getProjekteMitarbeiter($user, true)) } list($h2, $m2) = explode(':', $elsumme); $elsumme = $h2*3600+$m2*60; - if ($tagessaldo > 18000 && $tagessaldo < 19800 && $pflichtpause==false && $elsumme == 0) + if ($datum->formatDatum($tag, 'Y-m-d') >= '2019-11-06') + { + $pausesumme = $pausesumme; + } + else if ($tagessaldo > 18000 && $tagessaldo < 19800 && $pflichtpause==false && $elsumme == 0) { $pausesumme = $tagessaldo-18000; } @@ -1177,14 +1506,22 @@ if($projekt->getProjekteMitarbeiter($user, true)) { $pausesumme = $pausesumme+1800; } + if ($elsumme > 0){ $pausesumme = $pausesumme + $elsumme; $pflichtpause = true; } $tagessaldo = $tagessaldo-$pausesumme; + // fehlende Pausen berechnen + $pausefehlt_str = ''; + if ($tagessaldo > 19800 && $pausesumme < 1800) + $pausefehlt_str = '-- Pause fehlt oder zu kurz --'; + elseif ($tagessaldo > 18000 && $tagessaldo < 19800 && $pausesumme < $tagessaldo - 18000) + $pausefehlt_str = '-- Pause fehlt oder zu kurz --'; + $tagessaldo = date('H:i', ($tagessaldo)); - $colspan = ($za_simple)?4:7; + $colspan = ($za_simple)?6:8; echo ' @@ -1281,7 +1618,7 @@ if($projekt->getProjekteMitarbeiter($user, true)) // Diestreisen NEU if (array_key_exists($datumtag, $dr_arr)) { - $colspan=($za_simple)?4:7; + $colspan=($za_simple)?6:8; echo ''; + echo ''; + echo ''; if(!$za_simple) { - echo ' - '; + echo ''; } echo ''; if(!$za_simple) @@ -1417,11 +1757,12 @@ function printTableHeadings($fieldheadings, $za_simple = false){ echo ' - '; + + + '; if (!$za_simple) { - echo ' - '; + echo ''; } echo ''; if (!$za_simple) @@ -1477,8 +1818,8 @@ function getDataForCSV($rawdata, $fieldheadings, $za_simple = false) $datum = new datum(); $csvData = array(); //headers schreiben - $csvData[] = ($za_simple) ? array($fieldheadings['user'], $fieldheadings['datum'], $fieldheadings['start'], $fieldheadings['ende'], $fieldheadings['projekt'], $fieldheadings['aktivitaet'], $fieldheadings['beschreibung']) - : array($fieldheadings['user'], $fieldheadings['datum'], $fieldheadings['start'], $fieldheadings['ende'], $fieldheadings['projekt'], $fieldheadings['oe1'], $fieldheadings['oe2'], $fieldheadings['aktivitaet'], $fieldheadings['service'], $fieldheadings['kunde'], $fieldheadings['beschreibung']); + $csvData[] = ($za_simple) ? array($fieldheadings['user'], $fieldheadings['datum'], $fieldheadings['start'], $fieldheadings['ende'], $fieldheadings['projekt'], $fieldheadings['ap'], $fieldheadings['oe1'], $fieldheadings['aktivitaet'], $fieldheadings['beschreibung']) + : array($fieldheadings['user'], $fieldheadings['datum'], $fieldheadings['start'], $fieldheadings['ende'], $fieldheadings['projekt'], $fieldheadings['ap'], $fieldheadings['oe1'], $fieldheadings['oe2'], $fieldheadings['aktivitaet'], $fieldheadings['service'], $fieldheadings['kunde'], $fieldheadings['beschreibung']); foreach ($rawdata as $zeitauf) { //Newline characters bei Beschreibung ersetzen @@ -1491,13 +1832,13 @@ function getDataForCSV($rawdata, $fieldheadings, $za_simple = false) if($za_simple) { $csvData[] = array($zeitauf->uid, $hauptdatum, $datum->formatDatum($zeitauf->start, 'H:i'), - $bisdatum, $zeitauf->projekt_kurzbz, $zeitauf->aktivitaet_kurzbz, $beschreibung); + $bisdatum, $zeitauf->projekt_kurzbz, $zeitauf->projektphase_id, $zeitauf->oe_kurzbz_1, $zeitauf->aktivitaet_kurzbz, $beschreibung); } else { $servicebez = ($service->load($zeitauf->service_id))?$service->bezeichnung:""; $csvData[] = array($zeitauf->uid, $hauptdatum, $datum->formatDatum($zeitauf->start, 'H:i'), $bisdatum, - $zeitauf->projekt_kurzbz, $zeitauf->oe_kurzbz_1, $zeitauf->oe_kurzbz_2, $zeitauf->aktivitaet_kurzbz, $servicebez, $zeitauf->kunde_uid, $beschreibung); + $zeitauf->projekt_kurzbz, $zeitauf->projektphase_id, $zeitauf->oe_kurzbz_1, $zeitauf->oe_kurzbz_2, $zeitauf->aktivitaet_kurzbz, $servicebez, $zeitauf->kunde_uid, $beschreibung); } } return $csvData; diff --git a/cis/private/tools/zeitaufzeichnung_projektliste.php b/cis/private/tools/zeitaufzeichnung_projektliste.php index 17adfba97..c578ccb88 100644 --- a/cis/private/tools/zeitaufzeichnung_projektliste.php +++ b/cis/private/tools/zeitaufzeichnung_projektliste.php @@ -29,9 +29,11 @@ require_once('../../../include/phrasen.class.php'); require_once('../../../include/datum.class.php'); require_once('../../../include/Excel/excel.php'); require_once('../../../include/benutzer.class.php'); +require_once('../../../include/benutzerberechtigung.class.php'); require_once('../../../include/mitarbeiter.class.php'); require_once('../../../include/zeitaufzeichnung.class.php'); require_once('../../../include/projekt.class.php'); +require_once('../../../include/projektphase.class.php'); if (!isset($_GET['projexpmonat'])) die("Parameter monat fehlt"); @@ -45,6 +47,24 @@ $sprache_obj->load($sprache); $sprache_index = $sprache_obj->index; $uid = get_uid(); + +//Wenn User Administrator ist und UID uebergeben wurde, dann die Zeitaufzeichnung +//des uebergebenen Users anzeigen +if (isset($_GET['uid'])) +{ + $rechte = new benutzerberechtigung(); + $rechte->getBerechtigungen($uid); + + if ($rechte->isBerechtigt('admin')) + { + $uid = $_GET['uid']; + } + else + { + die($p->t('global/FuerDieseAktionBenoetigenSieAdministrationsrechte')); + } +} + $benutzer = new benutzer(); if (!$benutzer->load($uid)) die($p->t("zeitaufzeichnung/benutzerWurdeNichtGefunden", array($uid))); @@ -61,17 +81,19 @@ $daysinmonth = cal_days_in_month(CAL_GREGORIAN, $month, $year); $date = new datum(); $ztauf = new zeitaufzeichnung(); +$projektphaseclass = new projektphase(); $activitiesToIgnore = array('DienstreiseMT', 'Ersatzruhe');//aktivitaetstypen which shouldn't be added to worktime $ztauf->getListeUserFromTo($uid, $year.'-'.$month.'-01', $year.'-'.$month.'-'.$daysinmonth, $activitiesToIgnore); //objects for one projectline of list (corresponds to one day) -$projectlines = []; +$projektlines = array(); $dayStart = $dayEnd = ''; -$projectnames = $tosubtract = $allpauseranges = []; +$projektnames = $projektphasenames = $tosubtract = $allpauseranges = array(); $activitiesToSubtract = ['Pause', 'LehreExtern', 'Arztbesuch', 'Behoerde'];//aktivitaetstypen which should be subtracted fromworktime $ztaufdata = $ztauf->result; -$monthsums = [0 => 0.00]; +$totalmonthsum = 0.00; +$projektmonthsums = array(); //sort list by startdate ascending (if not already done in zeitaufzeichnung class) usort($ztaufdata, function ($ztaufa, $ztaufb) @@ -85,12 +107,13 @@ usort($ztaufdata, function ($ztaufa, $ztaufb) for ($i = 0; $i < count($ztaufdata); $i++) { $ztaufrow = $ztaufdata[$i]; + //make sure dates are in correct format $ztaufrow->start = $date->formatDatum($ztaufrow->start, $format = 'Y-m-d H:i:s'); $ztaufrow->ende = $date->formatDatum($ztaufrow->ende, $format = 'Y-m-d H:i:s'); $day = intval($date->formatDatum($ztaufrow->ende, 'd')); //first entry for a day - $isFirstEntry = !isset($projectlines[$day]); + $isFirstEntry = !isset($projektlines[$day]); //last entry for a day (next entry is different day) $isLastEntry = !array_key_exists($i + 1, $ztaufdata) || intval($date->formatDatum($ztaufdata[$i + 1]->ende, 'd')) != $day; @@ -137,18 +160,19 @@ for ($i = 0; $i < count($ztaufdata); $i++) if ($isFirstEntry) { - $projectlines[$day] = new stdClass(); - $projectlines[$day]->arbeitszeit = ''; - $projectlines[$day]->projekte = []; + $projektlines[$day] = new stdClass(); + $projektlines[$day]->arbeitszeit = ''; + $projektlines[$day]->projekte = []; } if (isset($ztaufrow->projekt_kurzbz)) { //Project already in projectline - add to worktime and description - if (array_key_exists($ztaufrow->projekt_kurzbz, $projectlines[$day]->projekte)) + if (array_key_exists($ztaufrow->projekt_kurzbz, $projektlines[$day]->projekte)) { - $laststart =& $projectlines[$day]->projekte[$ztaufrow->projekt_kurzbz]->laststart; - $lastende =& $projectlines[$day]->projekte[$ztaufrow->projekt_kurzbz]->lastende; + $currproj =& $projektlines[$day]->projekte[$ztaufrow->projekt_kurzbz]; + $laststart =& $currproj->laststart; + $lastende =& $currproj->lastende; $toadd = 0.00; //case 1: there is no overlap, just add project time difference @@ -157,56 +181,107 @@ for ($i = 0; $i < count($ztaufdata); $i++) $toadd = $date->convertTimeStringToHours($ztaufrow->diff); $laststart = $ztaufrow->start; $lastende = $ztaufrow->ende; - $newprojecttime = new stdClass(); - $newprojecttime->start = $ztaufrow->start; - $newprojecttime->ende = $ztaufrow->ende; - $projectlines[$day]->projekte[$ztaufrow->projekt_kurzbz]->alleZeiten[] = $newprojecttime; + $newprojekttime = new stdClass(); + $newprojekttime->start = $ztaufrow->start; + $newprojekttime->ende = $ztaufrow->ende; + $currproj->alleZeiten[] = $newprojekttime; + if (isset($ztaufrow->projektphase_id)) + $currproj->projektphasen[$ztaufrow->projektphase_id]->alleZeiten[] = $newprojekttime; } //case 2: overlap - add only part of the time elseif ($ztaufrow->start < $lastende && $ztaufrow->ende > $lastende) { $toadd = ($date->mktime_fromtimestamp($ztaufrow->ende) - $date->mktime_fromtimestamp($lastende)) / 3600; $lastende = $ztaufrow->ende; - $alleZeiten =& $projectlines[$day]->projekte[$ztaufrow->projekt_kurzbz]->alleZeiten; + + $alleZeiten =& $currproj->alleZeiten; $index = count($alleZeiten); $alleZeiten[$index - 1]->ende = $ztaufrow->ende; + + //check if overlap in projektphase, change ende accordingly + if (isset($ztaufrow->projektphase_id)) + { + $projektphaseAlleZeiten =& $currproj->projektphasen[$ztaufrow->projektphase_id]->alleZeiten; + $projektphaselastendeidx = count($projektphaseAlleZeiten); + $projektphaselastende =& $projektphaseAlleZeiten[$projektphaselastendeidx - 1]; + if ($ztaufrow->start < $projektphaselastende && $ztaufrow->ende > $projektphaselastende) + $projektphaselastende->ende = $ztaufrow->ende; + } + } + $currproj->stunden +=$toadd; + //add to projektphase + if (isset($ztaufrow->projektphase_id)) + { + $currproj->projektphasen[$ztaufrow->projektphase_id]->stunden += $toadd; } - $projectlines[$day]->projekte[$ztaufrow->projekt_kurzbz]->stunden += $toadd; //concatenate descriptions "working packages" for each project if (!empty($ztaufrow->beschreibung)) { - $packagecounter = ++$projectlines[$day]->projekte[$ztaufrow->projekt_kurzbz]->arbeitspakete; + $packagecounter = ++$currproj->arbeitspakete; if ($packagecounter == 1) - $projectlines[$day]->projekte[$ztaufrow->projekt_kurzbz]->beschreibung = $ztaufrow->beschreibung; + $currproj->beschreibung = $ztaufrow->beschreibung; else - $projectlines[$day]->projekte[$ztaufrow->projekt_kurzbz]->beschreibung .= " | ".str_replace(array("\r\n", "\r", "\n"), " ", $ztaufrow->beschreibung); + $currproj->beschreibung .= " | ".str_replace(array("\r\n", "\r", "\n"), " ", $ztaufrow->beschreibung); } } else { //add new project to projectline - $newproject = new stdClass(); - $newproject->laststart = $ztaufrow->start; - $newproject->lastende = $ztaufrow->ende; - $newprojecttime = new stdClass(); - $newprojecttime->start = $ztaufrow->start; - $newprojecttime->ende = $ztaufrow->ende; - $newproject->alleZeiten = []; - $newproject->alleZeiten[] = $newprojecttime; - $newproject->stunden = $date->convertTimeStringToHours($ztaufrow->diff); - $newproject->arbeitspakete = 0;//counter for tracking number of descriptions (work packages) - $newproject->beschreibung = ''; + $stunden = $date->convertTimeStringToHours($ztaufrow->diff); + + $newprojekt = new stdClass(); + $newprojekt->laststart = $ztaufrow->start; + $newprojekt->lastende = $ztaufrow->ende; + $newprojekttime = new stdClass(); + $newprojekttime->start = $ztaufrow->start; + $newprojekttime->ende = $ztaufrow->ende; + $newprojekt->alleZeiten = []; + $newprojekt->alleZeiten[] = $newprojekttime; + $newprojekt->stunden = $stunden; + $newprojekt->arbeitspakete = 0;//counter for tracking number of descriptions (work packages) + $newprojekt->beschreibung = ''; if (!empty($ztaufrow->beschreibung)) { - $newproject->beschreibung = str_replace(array("\r\n", "\r", "\n"), " ", $ztaufrow->beschreibung); - $newproject->arbeitspakete++; + $newprojekt->beschreibung = str_replace(array("\r\n", "\r", "\n"), " ", $ztaufrow->beschreibung); + $newprojekt->arbeitspakete++; } - $projectlines[$day]->projekte[$ztaufrow->projekt_kurzbz] = $newproject; - //add new project to array with unique project names - if (!in_array($ztaufrow->projekt_kurzbz, $projectnames)) - $projectnames[] = $ztaufrow->projekt_kurzbz; + //add projektphasen of project + $projektphasen = array(); + + if ($projektphaseclass->getProjektphasen($ztaufrow->projekt_kurzbz)) + { + $projektphasenames[$ztaufrow->projekt_kurzbz] = array(); + + foreach ($projektphaseclass->result as $ppitem) + { + $phasetoadd = new stdClass(); + $phasetoadd->bezeichnung = $ppitem->bezeichnung; + $phasetoadd->stunden = 0; + $phasetoadd->alleZeiten = array(); + + if ($ppitem->projektphase_id == $ztaufrow->projektphase_id) + { + $phasetoadd->stunden += $stunden; + $phasetoadd->alleZeiten[] = $newprojekttime; + } + + $projektphasen[$ppitem->projektphase_id] = $phasetoadd; + + //add new projektphase to array with unique projekt phase names + if (!in_array($ppitem->bezeichnung, $projektphasenames[$ztaufrow->projekt_kurzbz])) + $projektphasenames[$ztaufrow->projekt_kurzbz][] = $ppitem->bezeichnung; + } + } + + $newprojekt->projektphasen = $projektphasen; + + $projektlines[$day]->projekte[$ztaufrow->projekt_kurzbz] = $newprojekt; + + //add new projekt to array with unique projekt names + if (!in_array($ztaufrow->projekt_kurzbz, $projektnames)) + $projektnames[] = $ztaufrow->projekt_kurzbz; } } @@ -215,7 +290,7 @@ for ($i = 0; $i < count($ztaufdata); $i++) $worktime_unix = $date->mktime_fromtimestamp($dayEnd) - $date->mktime_fromtimestamp($dayStart); $worktimehours = $worktime_unix / 3600; - $projectlines[$day]->arbeitszeit = $worktimehours; + $projektlines[$day]->arbeitszeit = $worktimehours; $pauseSubtracted = 0.00; $lehreExternExists = false; @@ -224,42 +299,71 @@ for ($i = 0; $i < count($ztaufdata); $i++) { if ($subtraction->typ == $activitiesToSubtract[0]) { - $projectlines[$day]->arbeitszeit -= $subtraction->diff; + $projektlines[$day]->arbeitszeit -= $subtraction->diff; $pauseSubtracted += $subtraction->diff; } elseif ($subtraction->typ == $activitiesToSubtract[1] && $subtraction->start >= $dayStart && $subtraction->ende <= $dayEnd) { - $projectlines[$day]->arbeitszeit -= $subtraction->diff; + $projektlines[$day]->arbeitszeit -= $subtraction->diff; $lehreExternExists = true; } elseif ($subtraction->typ == $activitiesToSubtract[2] || $subtraction->typ == $activitiesToSubtract[3]) { - $projectlines[$day]->arbeitszeit -= $subtraction->diff; + $projektlines[$day]->arbeitszeit -= $subtraction->diff; } } - //subtract pauses from project worktimes + //subtract pauses from projekt worktimes foreach ($allpauseranges as $pauserange) { - foreach ($projectlines[$day]->projekte as $name => $project) + foreach ($projektlines[$day]->projekte as $name => $projekt) { - foreach ($projectlines[$day]->projekte[$name]->alleZeiten as $zeit) + $proj =& $projektlines[$day]->projekte[$name]; + foreach ($proj->alleZeiten as $zeit) { - //pause between project start and end + $subtraction = 0.00; + + //pause between projekt start and end if ($pauserange->start >= $zeit->start && $pauserange->ende <= $zeit->ende) { - $projectlines[$day]->projekte[$name]->stunden -= ($date->mktime_fromtimestamp($pauserange->ende) - $date->mktime_fromtimestamp($pauserange->start)) / 3600; - break; + $subtraction = $date->mktime_fromtimestamp($pauserange->ende) - $date->mktime_fromtimestamp($pauserange->start); } - //pause and project time overlap at project time end + //pause and projekt time overlap at projekt time end elseif ($pauserange->start < $zeit->ende && $pauserange->start > $zeit->start) { - $projectlines[$day]->projekte[$name]->stunden -= ($date->mktime_fromtimestamp($zeit->ende) - $date->mktime_fromtimestamp($pauserange->start)) / 3600; + $subtraction = $date->mktime_fromtimestamp($zeit->ende) - $date->mktime_fromtimestamp($pauserange->start); + //$proj->stunden -= ($date->mktime_fromtimestamp($zeit->ende) - $date->mktime_fromtimestamp($pauserange->start)) / 3600; } - //pause and project time overlap at project time start + //pause and projekt time overlap at projekt time start elseif ($pauserange->ende > $zeit->start && $pauserange->ende < $zeit->ende) { - $projectlines[$day]->projekte[$name]->stunden -= ($date->mktime_fromtimestamp($pauserange->ende) - $date->mktime_fromtimestamp($zeit->start)) / 3600; + $subtraction = $date->mktime_fromtimestamp($pauserange->ende) - $date->mktime_fromtimestamp($zeit->start); + } + $proj->stunden -= $subtraction / 3600; + } + + //subtract from projektphasen + foreach ($proj->projektphasen as $phase_id => $phase) + { + foreach ($phase->alleZeiten as $zeit) + { + $subtraction = 0.00; + //pause between projektphase start and end + if ($pauserange->start >= $zeit->start && $pauserange->ende <= $zeit->ende) + { + $subtraction = ($date->mktime_fromtimestamp($pauserange->ende) - $date->mktime_fromtimestamp($pauserange->start)); + } + //pause and projekt time overlap at projektphase time end + elseif ($pauserange->start < $zeit->ende && $pauserange->start > $zeit->start) + { + $subtraction = $date->mktime_fromtimestamp($zeit->ende) - $date->mktime_fromtimestamp($pauserange->start); + } + //pause and projekt time overlap at projektphase time start + elseif ($pauserange->ende > $zeit->start && $pauserange->ende < $zeit->ende) + { + $subtraction = $date->mktime_fromtimestamp($pauserange->ende) - $date->mktime_fromtimestamp($zeit->start); + } + $proj->projektphasen[$phase_id]->stunden -= $subtraction / 3600; } } } @@ -268,29 +372,47 @@ for ($i = 0; $i < count($ztaufdata); $i++) //worktime with no break greater 6 -> compulsory break of half an hour if ($pauseSubtracted < 0.5 && !$lehreExternExists) { - if ($projectlines[$day]->arbeitszeit >= 6.5) - $projectlines[$day]->arbeitszeit -= 0.5; + if ($projektlines[$day]->arbeitszeit >= 6.5) + $projektlines[$day]->arbeitszeit -= 0.5; //ensure that no worktime gets smaller than 6 hours because of compulsory break - elseif ($projectlines[$day]->arbeitszeit > 6) - $projectlines[$day]->arbeitszeit -= $projectlines[$day]->arbeitszeit - 6; + elseif ($projektlines[$day]->arbeitszeit > 6) + $projektlines[$day]->arbeitszeit -= $projektlines[$day]->arbeitszeit - 6; } - $projectlines[$day]->arbeitszeit = round($projectlines[$day]->arbeitszeit, 2); + $projektlines[$day]->arbeitszeit = round($projektlines[$day]->arbeitszeit, 2); - foreach ($projectlines[$day]->projekte as $name => $project) + //calculate sums + foreach ($projektlines[$day]->projekte as $name => $projekt) { - $projecthours =& $projectlines[$day]->projekte[$name]->stunden; - $projecthours = round($projecthours, 2); - if (array_key_exists($name, $monthsums)) - $monthsums[$name] += $projecthours; + $projekthours =& $projektlines[$day]->projekte[$name]->stunden; + $projekthours = round($projekthours, 2); + + if (isset($projektmonthsums[$name]->sum)) + { + $projektmonthsums[$name]->sum += $projekthours; + foreach ($projekt->projektphasen as $projektphase) + { + $projektmonthsums[$name]->projektphasen[$projektphase->bezeichnung] += round($projektphase->stunden, 2, 0); + } + } else - $monthsums[$name] = $projecthours; + { + $monthsum = new stdClass(); + $monthsum->sum = $projekthours; + $monthsum->projektphasen = array(); + + foreach ($projekt->projektphasen as $projektphase) + { + $monthsum->projektphasen[$projektphase->bezeichnung] = round($projektphase->stunden, 2, 0); + } + $projektmonthsums[$name] = $monthsum; + } } $dayStart = $dayEnd = ''; $tosubtract = $allpauseranges = []; - $monthsums[0] += $projectlines[$day]->arbeitszeit; + $totalmonthsum += $projektlines[$day]->arbeitszeit; } } @@ -301,10 +423,6 @@ $workbook->setVersion(8); // sending HTTP headers $workbook->send('Projektliste_'.$month.'_'.$year.'.xls'); -// Creating a worksheet -$worksheet =& $workbook->addWorksheet($p->t('zeitaufzeichnung/projektliste')); -$worksheet->setInputEncoding('utf-8'); - // Define formats $format_heading_left =& $workbook->addFormat(); $format_heading_left->setBold(); @@ -365,6 +483,12 @@ $format_cell_rightline->setBorder(1); $format_cell_rightline->setVAlign('vcenter'); $format_cell_rightline->setRight(2); +$format_cell_leftrightline =& $workbook->addFormat(); +$format_cell_leftrightline->setBottom(1); +$format_cell_leftrightline->setVAlign('vcenter'); +$format_cell_leftrightline->setLeft(2); +$format_cell_leftrightline->setRight(2); + $format_cell_centered =& $workbook->addFormat(); $format_cell_centered->setBorder(1); $format_cell_centered->setAlign('center'); @@ -372,7 +496,6 @@ $format_cell_centered->setVAlign('vcenter'); $format_cell_centered_leftline =& $workbook->addFormat(); $format_cell_centered_leftline->setRight(1); -$format_cell_centered_leftline->setLeft(1); $format_cell_centered_leftline->setBottom(1); $format_cell_centered_leftline->setAlign('center'); $format_cell_centered_leftline->setVAlign('vcenter'); @@ -384,6 +507,20 @@ $format_cell_centered_rightline->setAlign('center'); $format_cell_centered_rightline->setVAlign('vcenter'); $format_cell_centered_rightline->setRight(2); +$format_cell_centered_leftrightline =& $workbook->addFormat(); +$format_cell_centered_leftrightline->setBottom(1); +$format_cell_centered_leftrightline->setAlign('center'); +$format_cell_centered_leftrightline->setVAlign('vcenter'); +$format_cell_centered_leftrightline->setLeft(2); +$format_cell_centered_leftrightline->setRight(2); + +$format_cell_centered_topbottomline =& $workbook->addFormat(); +$format_cell_centered_topbottomline->setBorder(1); +$format_cell_centered_topbottomline->setAlign('center'); +$format_cell_centered_topbottomline->setVAlign('vcenter'); +$format_cell_centered_topbottomline->setBottom(2); +$format_cell_centered_topbottomline->setTop(2); + $format_cell_centered_topbottomleftline =& $workbook->addFormat(); $format_cell_centered_topbottomleftline->setBorder(1); $format_cell_centered_topbottomleftline->setAlign('center'); @@ -406,178 +543,243 @@ $format_cell_centered_alllines->setAlign('center'); $format_cell_centered_alllines->setVAlign('vcenter'); //define column widths -$nrProjects = count($projectnames); +$nrProjects = count($projektnames); +$totalwidth = 150; $daywidth = 4; $totalworktimewidth = 13; -$worktimewidth = 8; -$worksheet->setColumn(0, 1, $daywidth); -$worksheet->setColumn(2, 2, $totalworktimewidth); +$worktimewidth = 14; +$timecolumnswidth = 2 * $daywidth + $totalworktimewidth + $worktimewidth; -//calculate max width for project descriptions -$maxwidthprojects = $totalworktimewidth * (12 - $nrProjects); -$projectcolumnwidths = array_fill_keys($projectnames, $worktimewidth); - -//set project column width depending on project description widths -foreach ($projectlines as $line) +if ($nrProjects < 1)//no projekts - merge all cells and write notice { - foreach ($line->projekte as $key => $project) + $projektnames[] = "Keine Projekte vorhanden"; +} + +foreach ($projektnames as $projektname) +{ + //Creating a worksheet + $worksheet =& $workbook->addWorksheet($projektname); + $worksheet->setInputEncoding('utf-8'); + + //general options + $worksheet->setLandscape(); + $worksheet->hideGridlines(); + $worksheet->hideScreenGridlines(); + $worksheet->setmargins(0.4); + + //fixed width columns + $worksheet->setColumn(0, 1, $daywidth); + $worksheet->setColumn(2, 2, $totalworktimewidth); + + //calculate number of columns of projekt with phases + $nrPhases = isset($projektphasenames[$projektname]) ? count($projektphasenames[$projektname]) : 0; + + //get taetigkeiten column width - + //minimum is wordlength, maximum restwidth after subraction of projektphase minimum width + $mintaetigkeitenwidth = strlen($p->t('zeitaufzeichnung/taetigkeit')); + $maxtaetigkeitenlimit = $totalwidth - $timecolumnswidth - $nrPhases * $worktimewidth; + + if (isset($projektlines->projekte[$projektname])) { - if ($projectcolumnwidths[$key] < strlen($project->beschreibung)) - $projectcolumnwidths[$key] = strlen($project->beschreibung); - } -} - -//distribute width remainder evenly among projects -if ($nrProjects != 0) - $remwidth = ($maxwidthprojects - array_sum($projectcolumnwidths)) / $nrProjects; - -foreach ($projectcolumnwidths as $projectname => $width) - $projectcolumnwidths[$projectname] += $remwidth; - -//calculating spaces for centering global header texts -$numberspaces = ($maxwidthprojects - 10 - strlen($username)); -$spacesstringFirst = ''; - -while ($numberspaces > 0) -{ - $spacesstringFirst .= ' '; - $numberspaces--; -} - -$numberspaces = ($maxwidthprojects - 14 - strlen($persnr)); -$spacesstringSecond = ''; -while ($numberspaces > 0) -{ - $spacesstringSecond .= ' '; - $numberspaces--; -} - -$spalte = $zeile = 0; - -//set language options -$decpoint = $sprache_index === '2' ? '.' : ','; -$thousandsep = $sprache_index === '2' ? ',' : '.'; - -//write global header -$lastspalte = ($nrProjects > 0) ? 2 + count($projectnames) * 2 : 14; -$worksheet->setMerge($zeile, $spalte, $zeile + 1, $spalte + 2); -$worksheet->write($zeile, $spalte, $monthtext.' '.$year, $format_heading_left); -$worksheet->write($zeile + 1, $spalte, $monthtext.' '.$year, $format_heading_left); -for ($i = 1; $i < 3; $i++) -{ - $worksheet->write($zeile, $spalte + $i, '', $format_heading_topline); - $worksheet->write($zeile + 1, $spalte + $i, '', $format_heading_bottomline); -} -$worksheet->setMerge($zeile, $spalte + 3, $zeile, $lastspalte); -$worksheet->setMerge($zeile + 1, $spalte + 3, $zeile + 1, $lastspalte); -$worksheet->write($zeile, $spalte + 3, $p->t('zeitaufzeichnung/projektlistegedruckt').$spacesstringFirst.$username, $format_heading_right); -for ($i = 4; $i < $lastspalte; $i++) -{ - $worksheet->write($zeile, $i, '', $format_heading_topline); - $worksheet->write($zeile + 1, $i, '', $format_heading_bottomline); -} -$worksheet->write($zeile, $lastspalte, '', $format_heading_right); -$worksheet->write($zeile + 1, $spalte + 3, date('d.m.Y H:i').$spacesstringSecond.$p->t('zeitaufzeichnung/personalnr').$persnr, $format_heading_right_bottomline); -$worksheet->write($zeile + 1, $lastspalte, '', $format_heading_right_bottomline); -$zeile += 3; - -//general options -$worksheet->setLandscape(); -$worksheet->hideGridlines(); -$worksheet->hideScreenGridlines(); - -//write table header -$worksheet->setMerge($zeile, $spalte, $zeile + 1, $spalte + 1); -$worksheet->write($zeile, $spalte, $p->t('zeitaufzeichnung/tag'), $format_bold_centered_alllines); -$worksheet->write($zeile + 1, $spalte, '', $format_bold_centered_alllines); -$worksheet->write($zeile, $spalte + 1, $p->t('zeitaufzeichnung/tag'), $format_bold_centered_alllines); -$worksheet->write($zeile + 1, ++$spalte, '', $format_bold_centered_alllines); -$worksheet->setMerge($zeile, ++$spalte, $zeile + 1, $spalte); -$worksheet->write($zeile, $spalte, $p->t('zeitaufzeichnung/arbeitszeit'), $format_bold_centered_alllines); -$worksheet->write($zeile + 1, $spalte, '', $format_bold_centered_alllines); -$spalte++; - -foreach ($projectnames as $project) -{ - $worksheet->setMerge($zeile, $spalte, $zeile, $spalte + 1); - $worksheet->write($zeile, $spalte, $project, $format_bold_centered_toprightline); - $worksheet->write($zeile, $spalte + 1, '', $format_bold_centered_toprightline); - $worksheet->write($zeile + 1, $spalte, $p->t('zeitaufzeichnung/stunden'), $format_bold_centered_bottomline); - $worksheet->write($zeile + 1, $spalte + 1, $p->t('zeitaufzeichnung/taetigkeit'), $format_bold_centered_bottomrightline); - $spalte += 2; -} -$zeile += 2; - -//write table body -for ($daysnmbr = 1; $daysnmbr <= $daysinmonth; $daysnmbr++) -{ - //write day and weekday - $spalte = 0; - $monthstr = ($month < 10) ? '0'.$month : $month; - $daystr = ($daysnmbr < 10) ? '0'.$daysnmbr : $daysnmbr; - $datestring = $year.'-'.$monthstr.'-'.$daystr; - $weekday = substr($tagbez[$sprache_index][$date->formatDatum($datestring, 'N')], 0, 2); - $worksheet->write($zeile, $spalte++, $weekday, $format_cell_centered_leftline); - $worksheet->write($zeile, $spalte++, $daysnmbr, $format_cell_centered_rightline); - - if (array_key_exists($daysnmbr, $projectlines)) - { - //write worktime - $worksheet->writeString($zeile, $spalte++, number_format($projectlines[$daysnmbr]->arbeitszeit, 2, $decpoint, $thousandsep), $format_cell_centered_rightline); - $spaltetemp = $spalte; - //write projects - foreach ($projectnames as $project) + foreach ($projektlines->projekte[$projektname] as $projekt) { - if (array_key_exists($project, $projectlines[$daysnmbr]->projekte)) + $projektbeschreibunglength = strlen($projekt->beschreibung); + if ($projektbeschreibunglength >= $maxtaetigkeitenlimit) { - $worksheet->setColumn($spalte, $spalte, $worktimewidth); - $worksheet->writeString($zeile, $spalte++, number_format($projectlines[$daysnmbr]->projekte[$project]->stunden, 2, $decpoint, $thousandsep), $format_cell_centered_leftline); - $worksheet->setColumn($spalte, $spalte, $projectcolumnwidths[$project]); - $worksheet->write($zeile, $spalte++, $projectlines[$daysnmbr]->projekte[$project]->beschreibung, $format_cell_rightline); - } - else - { - $worksheet->write($zeile, $spalte++, '', $format_cell_centered_leftline); - $worksheet->write($zeile, $spalte++, '', $format_cell_rightline); + $mintaetigkeitenwidth = $maxtaetigkeitenlimit; + break; } + elseif ($projektbeschreibunglength > $mintaetigkeitenwidth) + $mintaetigkeitenwidth = $projektbeschreibunglength; } } + + //get projektphase width, width depending on bezeichnung + $phasewidth = 0; + $phasewidthlimit = $nrPhases > 0 + ? ($totalwidth - $timecolumnswidth - $mintaetigkeitenwidth) / $nrPhases + : $totalwidth - 4 * $daywidth - $worktimewidth - $mintaetigkeitenwidth; + + if (isset($projektphasenames[$projektname])) + { + foreach ($projektphasenames[$projektname] as $projektphasename) + { + $projektphasewidth = strlen($projektphasename); + if ($projektphasewidth >= $phasewidthlimit) + { + $phasewidth = $phasewidthlimit; + break; + } + elseif ($projektphasewidth > $phasewidth) + $phasewidth = $projektphasewidth; + } + } + + //width remainder used for taetigkeit + $taetigkeitenwidth = $totalwidth - $timecolumnswidth - $phasewidth * $nrPhases; + + $lastspalte = 4 + $nrPhases; + + //calculating spaces for centering global header texts +/* $usernamelength = strlen($username) * 1.77; + $numberspacesfirstrow = $totalwidth - $daywidth * 2 - $worktimewidth - $usernamelength; + $numberspacessecondrow = $numberspacesfirstrow + $usernamelength - strlen($p->t('zeitaufzeichnung/personalnr').$persnr) - 4; + + $spacesstringfirstrow = str_repeat(' ', $numberspacesfirstrow); + $spacesstringsecondrow = str_repeat(' ', $numberspacessecondrow);*/ + + $spalte = $zeile = 0; + + //set language options + $decpoint = $sprache_index === '2' ? '.' : ','; + $thousandsep = $sprache_index === '2' ? ',' : '.'; + + //write global header + $worksheet->setMerge($zeile, $spalte, $zeile + 1, $spalte + 2); + $worksheet->write($zeile, $spalte, $monthtext.' '.$year, $format_heading_left); + $worksheet->write($zeile + 1, $spalte, $monthtext.' '.$year, $format_heading_left); + for ($i = 1; $i < 3; $i++) + { + $worksheet->write($zeile, $spalte + $i, '', $format_heading_topline); + $worksheet->write($zeile + 1, $spalte + $i, '', $format_heading_bottomline); + } + $worksheet->setMerge($zeile, $spalte + 3, $zeile, $lastspalte); + $worksheet->setMerge($zeile + 1, $spalte + 3, $zeile + 1, $lastspalte); + $worksheet->write($zeile, $spalte + 3, /*$p->t('zeitaufzeichnung/projektlistegedruckt').$spacesstringfirstrow.*/$username, $format_heading_right); + for ($i = 4; $i < $lastspalte; $i++) + { + $worksheet->write($zeile, $i, '', $format_heading_topline); + $worksheet->write($zeile + 1, $i, '', $format_heading_bottomline); + } + $worksheet->write($zeile, $lastspalte, '', $format_heading_right); + $worksheet->write($zeile + 1, $spalte + 3, /*date('d.m.Y H:i').$spacesstringsecondrow.*/$p->t('zeitaufzeichnung/personalnr').$persnr, $format_heading_right_bottomline); + $worksheet->write($zeile + 1, $lastspalte, '', $format_heading_right_bottomline); + $zeile += 3; + + $spalte = 0; + + //write table header + $worksheet->setMerge($zeile, $spalte, $zeile + 1, $spalte + 1); + $worksheet->write($zeile, $spalte, $p->t('zeitaufzeichnung/tag'), $format_bold_centered_alllines); + $worksheet->write($zeile + 1, $spalte, '', $format_bold_centered_alllines); + $worksheet->write($zeile, $spalte + 1, $p->t('zeitaufzeichnung/tag'), $format_bold_centered_alllines); + $worksheet->write($zeile + 1, ++$spalte, '', $format_bold_centered_alllines); + $worksheet->setMerge($zeile, ++$spalte, $zeile + 1, $spalte); + $worksheet->write($zeile, $spalte, $p->t('zeitaufzeichnung/arbeitszeit'), $format_bold_centered_alllines); + $worksheet->write($zeile + 1, $spalte, '', $format_bold_centered_alllines); + $spalte++; + + if (isset($projektphasenames[$projektname])) + { + $phasenames = $projektphasenames[$projektname]; + $phasenameslength = count($phasenames); + } else { - //write empty cells until end of table - $worksheet->writeString($zeile, $spalte, number_format(0, 2, $decpoint, $thousandsep), $format_cell_centered_leftline); - $toskip = count($projectnames) * 2; - for ($i = 0; $i <= $toskip; $i++) - { - if ($i % 2 == 0) - $worksheet->write($zeile, $spalte, '', $format_cell_centered_rightline); - else - $worksheet->write($zeile, $spalte, '', $format_cell_centered); - $spalte++; - } + $phasenames = array(); + $phasenameslength = 0; } - $zeile++; + $worksheet->write($zeile, $spalte + $phasenameslength + 1, '', $format_bold_centered_toprightline); + $worksheet->write($zeile + 1, $spalte, $p->t('zeitaufzeichnung/projektstunden'), $format_bold_centered_bottomline); + + for($i = 0; $i < $phasenameslength; $i++) + $worksheet->write($zeile, $spalte + 1 + $i, '', $format_bold_centered_toprightline); + + $worksheet->setMerge($zeile, $spalte, $zeile, $spalte + 1 + $phasenameslength); + $worksheet->write($zeile, $spalte, $projektname, $format_bold_centered_toprightline); + + for ($i = 0; $i < $phasenameslength; $i++) + $worksheet->write($zeile + 1, $spalte + 1 + $i, $phasenames[$i], $format_bold_centered_bottomline); + + $worksheet->setColumn($spalte + $phasenameslength + 1, $spalte + $phasenameslength + 1, $taetigkeitenwidth); + $worksheet->write($zeile + 1, $spalte + $phasenameslength + 1, $p->t('zeitaufzeichnung/taetigkeit'), $format_bold_centered_bottomrightline); + $spalte = $spalte + 2 + $phasenameslength; + $zeile += 2; + + //write table body + for ($daysnmbr = 1; $daysnmbr <= $daysinmonth; $daysnmbr++) + { + //write day and weekday + $spalte = 0; + $monthstr = ($month < 10) ? '0'.$month : $month; + $daystr = ($daysnmbr < 10) ? '0'.$daysnmbr : $daysnmbr; + $datestring = $year.'-'.$monthstr.'-'.$daystr; + $weekday = substr($tagbez[$sprache_index][$date->formatDatum($datestring, 'N')], 0, 2); + $worksheet->write($zeile, $spalte++, $weekday, $format_cell_centered_leftline); + $worksheet->write($zeile, $spalte++, $daysnmbr, $format_cell_centered_rightline); + + if (array_key_exists($daysnmbr, $projektlines)) + { + //write worktime + $worksheet->writeString($zeile, $spalte++, number_format($projektlines[$daysnmbr]->arbeitszeit, 2, $decpoint, $thousandsep), $format_cell_centered_rightline); + $spaltetemp = $spalte; + //write projekt + if (array_key_exists($projektname, $projektlines[$daysnmbr]->projekte)) + { + $projekt = $projektlines[$daysnmbr]->projekte[$projektname]; + + $worksheet->setColumn($spalte, $spalte, $worktimewidth); + $worksheet->writeString($zeile, $spalte++, number_format($projekt->stunden, 2, $decpoint, $thousandsep), $format_cell_centered_leftrightline); + + foreach ($projekt->projektphasen as $projektphase) + { + $worksheet->setColumn($spalte, $spalte, $phasewidth); + $worksheet->writeString($zeile, $spalte++, number_format($projektphase->stunden, 2, $decpoint, $thousandsep), $format_cell_centered); + } + + $worksheet->setColumn($spalte, $spalte, $phasewidth); + $worksheet->write($zeile, $spalte++, $projekt->beschreibung, $format_cell_leftrightline); + } + } + else + { + $worksheet->writeString($zeile, $spalte++, number_format(0, 2, $decpoint, $thousandsep), $format_cell_centered_leftrightline); + } + + if (!array_key_exists($daysnmbr, $projektlines) || !array_key_exists($projektname, $projektlines[$daysnmbr]->projekte)) + { + if (isset($projektphasenames[$projektname])) + { + //write empty cells until end of table + $worksheet->write($zeile, $spalte, '', $format_cell_centered_leftrightline); + $toskip = count($projektphasenames[$projektname]); + for ($i = 0; $i <= $toskip; $i++) + { + if ($i == 0) + $format = $format_cell_centered_leftrightline; + else + $format = $format_cell_centered; + + $worksheet->write($zeile, $spalte++, '', $format); + } + $worksheet->write($zeile, $spalte, '', $format_cell_centered_leftrightline); + } + } + $zeile++; + } + + //write monthly sums + $spalte = 0; + $worksheet->setMerge($zeile, $spalte, $zeile, $spalte + 1); + $worksheet->write($zeile, $spalte, $p->t('zeitaufzeichnung/summe'), $format_bold_centered_alllines); + $worksheet->write($zeile, $spalte + 1, '', $format_bold_centered_alllines); + $spalte += 2; + $worksheet->writeString($zeile, $spalte++, number_format($totalmonthsum, 2, $decpoint, $thousandsep), $format_cell_centered_alllines); + + if (isset($projektmonthsums[$projektname])) + { + $worksheet->writeString($zeile, $spalte++, number_format($projektmonthsums[$projektname]->sum, 2, $decpoint, $thousandsep), $format_cell_centered_alllines); + + foreach ($projektmonthsums[$projektname]->projektphasen as $projektphase) + { + $worksheet->writeString($zeile, $spalte++, number_format($projektphase, 2, $decpoint, $thousandsep), $format_cell_centered_topbottomline); + } + + $worksheet->write($zeile, $spalte++, '', $format_cell_centered_alllines); + } + $zeile += 2; + + $worksheet->fitToPages(1, 1); } -if ($nrProjects < 1) - //no projects - merge all cells and write notice -{ - $worksheet->setMerge(3, 3, 4 + $daysinmonth, $lastspalte); - $worksheet->write(3, 3, $p->t('zeitaufzeichnung/keineprojekte'), $format_bold_centered_alllines); - $worksheet->write(3, $lastspalte, '', $format_bold_centered_alllines); -} - -//write monthly sums -$spalte = 0; -$worksheet->setMerge($zeile, $spalte, $zeile, $spalte + 1); -$worksheet->write($zeile, $spalte, $p->t('zeitaufzeichnung/summe'), $format_bold_centered_alllines); -$worksheet->write($zeile, $spalte + 1, '', $format_bold_centered_alllines); -$spalte += 2; -$worksheet->writeString($zeile, $spalte++, number_format($monthsums[0], 2, $decpoint, $thousandsep), $format_cell_centered_alllines); -foreach ($projectnames as $project) -{ - $worksheet->writeString($zeile, $spalte++, number_format($monthsums[$project], 2, $decpoint, $thousandsep), $format_cell_centered_topbottomleftline); - $worksheet->write($zeile, $spalte++, '', $format_cell_centered_topbottomrightline); -} -$worksheet->fitToPages(1, 1); $workbook->close(); diff --git a/cis/private/tools/zeitaufzeichnung_projektphasen.php b/cis/private/tools/zeitaufzeichnung_projektphasen.php new file mode 100644 index 000000000..8ec421395 --- /dev/null +++ b/cis/private/tools/zeitaufzeichnung_projektphasen.php @@ -0,0 +1,28 @@ +getProjektphasen($projekt_kurzbz)) + { + $result_obj = array(); + foreach($projektphase->result as $row) + { + $item['projektphase_id']=$row->projektphase_id; + $item['bezeichnung']=$row->bezeichnung; + $result_obj[]=$item; + } + echo json_encode($result_obj); + } + exit; +} diff --git a/cis/public/coodle.php b/cis/public/coodle.php index 2ad68c48f..48c585d6b 100644 --- a/cis/public/coodle.php +++ b/cis/public/coodle.php @@ -19,22 +19,26 @@ * Authors: Karl Burkhart , * Andreas Österreicher */ -require_once ('../../config/cis.config.inc.php'); -require_once ('../../include/phrasen.class.php'); -require_once ('../../include/functions.inc.php'); -require_once ('../../include/coodle.class.php'); -require_once ('../../include/datum.class.php'); -require_once ('../../include/mail.class.php'); -require_once ('../../include/benutzer.class.php'); -require_once ('../../include/reservierung.class.php'); -require_once ('../../include/stunde.class.php'); -require_once ('../../include/stundenplan.class.php'); -require_once ('../../include/mitarbeiter.class.php'); +require_once('../../config/cis.config.inc.php'); +require_once('../../include/phrasen.class.php'); +require_once('../../include/functions.inc.php'); +require_once('../../include/coodle.class.php'); +require_once('../../include/datum.class.php'); +require_once('../../include/mail.class.php'); +require_once('../../include/benutzer.class.php'); +require_once('../../include/reservierung.class.php'); +require_once('../../include/stunde.class.php'); +require_once('../../include/stundenplan.class.php'); +require_once('../../include/mitarbeiter.class.php'); +require_once('../../include/globals.inc.php'); header("Content-Type: text/html; charset=utf-8"); $sprache = getSprache(); $p = new phrasen($sprache); +$sprache_obj = new sprache(); +$sprache_obj->load($sprache); +$sprache_index = $sprache_obj->index; $datum_obj = new datum(); $message = ''; $mailMessage = ''; @@ -45,27 +49,27 @@ $abgeschlossen = false; $coodle_id = (isset($_GET['coodle_id']) ? $_GET['coodle_id'] : ''); $coodle = new coodle(); -if (! $coodle->load($coodle_id)) +if (!$coodle->load($coodle_id)) die($coodle->errormsg); // Überprüfen ob Coodle Status laufend oder abgeschlossen hat -if (! $coodle->checkStatus($coodle_id)) +if (!$coodle->checkStatus($coodle_id)) die($p->t('coodle/umfrageNichtGueltig')); // authentifizierung -if (! isset($_GET['zugangscode'])) +if (!isset($_GET['zugangscode'])) { $uid = get_uid(); - if (! $coodle->checkBerechtigung($coodle_id, $uid)) + if (!$coodle->checkBerechtigung($coodle_id, $uid)) die($p->t('coodle/keineBerechtigung')); - + // überprüfen ob ersteller gleich uid ist if ($coodle->ersteller_uid == $uid) $ersteller = true; } else { - if (! $coodle->checkBerechtigung($coodle_id, '', $_GET['zugangscode'])) + if (!$coodle->checkBerechtigung($coodle_id, '', $_GET['zugangscode'])) die($p->t('coodle/keineBerechtigung')); } @@ -75,7 +79,7 @@ if (isset($_POST['save'])) $coodle_help = new coodle(); $error = false; $teilnehmer_uid = ''; - + // Ressource ID von Zugangscode oder UID holen und Beiträge löschen if (isset($_GET['zugangscode'])) { @@ -93,7 +97,7 @@ if (isset($_POST['save'])) $teilnehmer_uid = $coodle_help->coodle_ressource_id; } } - + // Einträge speichern foreach ($_POST as $key => $value) { @@ -102,28 +106,30 @@ if (isset($_POST['save'])) $termin = explode('_', $key); $ressource_id = $termin[1]; $termin_id = $termin[2]; - + $coodle_ressource_termin = new coodle(); $coodle_ressource_termin->coodle_ressource_id = $ressource_id; $coodle_ressource_termin->coodle_termin_id = $termin_id; $coodle_ressource_termin->new = true; - - if (! $coodle_ressource_termin->saveRessourceTermin()) + + if (!$coodle_ressource_termin->saveRessourceTermin()) $error = true; } } - + if ($error) { - $message .= "" . $p->t('global/fehlerBeimSpeichernDerDaten') . "
    "; + $message .= '
    + Error! '.$p->t('global/fehlerBeimSpeichernDerDaten').' +
    '; } else { $coodle_help->load($coodle_id); // email an ersteller senden wenn option aktiviert - if ($coodle_help->mailversand && (! isset($_POST['auswahl_termin']))) + if ($coodle_help->mailversand && (!isset($_POST['auswahl_termin']))) sendBenachrichtigung($coodle_id, $teilnehmer_uid); - + $saveOk = true; } } @@ -140,43 +146,49 @@ if (isset($_POST['auswahl_termin'])) $coodle_help = new coodle(); $coodle_help->loadTermin($auswahl); $coodle_help->auswahl = true; - + // alle termine der coodle_id auf false setzen - if (! $coodle_help->setTerminFalse($coodle_id)) + if (!$coodle_help->setTerminFalse($coodle_id)) exit('Fehler beim Update aufgetreten'); - - if (! $coodle_help->saveTermin(false)) - $message .= "" . $p->t('global/fehlerBeimSpeichernDerDaten') . "
    "; + + if (!$coodle_help->saveTermin(false)) + { + $message .= '
    + Error! '.$p->t('global/fehlerBeimSpeichernDerDaten').' +
    '; + } else + { $saveOk = true; - + } + $coodle_status = new coodle(); $coodle_status->load($coodle_id); $coodle_status->coodle_status_kurzbz = 'abgeschlossen'; $coodle_status->new = false; $coodle_status->save(); - + sendEmail($coodle_id); - + if ($coodle_help->datum < RES_TAGE_LEKTOR_BIS) { // Raum reservieren $coodle_raum = new coodle(); $coodle_raum->getRaumeFromId($coodle_id); - + // Ende Uhrzeit berechnen - $date = new DateTime($coodle_help->datum . ' ' . $coodle_help->uhrzeit); - $interval = new DateInterval('PT' . $coodle->dauer . 'M'); + $date = new DateTime($coodle_help->datum.' '.$coodle_help->uhrzeit); + $interval = new DateInterval('PT'.$coodle->dauer.'M'); $date->add($interval); $uhrzeit_ende = $date->format('H:i:s'); - + foreach ($coodle_raum->result as $raum) { $stunde = new stunde(); $stunden = $stunde->getStunden($coodle_help->uhrzeit, $uhrzeit_ende); - + // Pruefen ob der Raum frei ist - if (! RaumBelegt($raum->ort_kurzbz, $coodle_help->datum, $stunden)) + if (!RaumBelegt($raum->ort_kurzbz, $coodle_help->datum, $stunden)) { $reservierung_error = false; // Stunden reservieren @@ -192,33 +204,37 @@ if (isset($_POST['auswahl_termin'])) $raum_reservierung->beschreibung = mb_substr($coodle->titel, 0, 32); $raum_reservierung->insertamum = date('Y-m-d H:i:s'); $raum_reservierung->insertvon = $uid; - + // $message.= "Reserviere $raum->ort_kurzbz Stunde $stunde:"; - if (! $raum_reservierung->save(true)) + if (!$raum_reservierung->save(true)) $reservierung_error = true; } - $message .= $p->t('coodle/raumErfolgreichReserviert', array( - $raum->ort_kurzbz - )) . '
    '; + $message .= '
    + '.$p->t('coodle/raumErfolgreichReserviert', array($raum->ort_kurzbz)).' +
    '; } else { - $message .= '' . $p->t('coodle/raumBelegt', array( - $raum->ort_kurzbz - )) . '
    '; + $message .= '
    + '.$p->t('coodle/raumBelegt', array($raum->ort_kurzbz)).' +
    '; } } } else { - $message .= '' . $p->t('coodle/raumNichtReserviert', array( - $datum_obj->formatDatum(RES_TAGE_LEKTOR_BIS, 'd.m.Y') - )) . '
    '; + $message .= '
    + '.$p->t('coodle/raumNichtReserviert', array($datum_obj->formatDatum(RES_TAGE_LEKTOR_BIS, 'd.m.Y'))).' +
    '; } } } else - $message .= '' . $p - t('global/keineBerechtigung') . ''; + { + $message .= '
    + '.$p->t('global/keineBerechtigung').' +
    '; + } } $coodle->load($coodle_id); @@ -238,463 +254,640 @@ if (isset($_GET['resend'])) - + - <?php echo $p->t('coodle/terminauswahl');?> + + <?php echo $p->t('coodle/terminauswahl'); ?> - -' . $p->t('coodle/coodle') . ''; +
    +
    + '.$p->t('coodle/coodle').''; -if (! isset($_GET['zugangscode'])) - echo "<< " . $p->t('coodle/zurueckZurUebersicht') . ""; -echo '

    '; -echo '
    '; - -$coodle_help = new coodle(); -$coodle_help->load($coodle_id); - -$alt = strtotime($coodle_help->insertamum); - -$differenz = time() - $alt; -$differenz = $differenz / 86400; -$benutzer = new benutzer(); -$benutzer->load($coodle->ersteller_uid); -// $ersteller_name = trim($benutzer->titelpre.' '.$benutzer->vorname.' '.$benutzer->nachname.' '.$benutzer->titelpost); -$ersteller_name = trim($benutzer->vorname . ' ' . $benutzer->nachname); -echo '

    ' . $coodle->titel . '

    '; -$erstellt = array( - $ersteller_name, - round($differenz) -); -echo '' . $p->t('coodle/erstelltVon', $erstellt) . '
    '; -echo '' . $p->t('coodle/dauer') . ': ' . $coodle->dauer . ' min.

    '; - -echo $coodle->beschreibung; - -echo '
    '; - -if ($abgeschlossen) -{ - $datum = new datum(); - $coodle_abgeschlossen = new coodle(); - $termin_id = $coodle_abgeschlossen->getTerminAuswahl($coodle_id); - $coodle_abgeschlossen->loadTermin($termin_id); - echo '

    ' . $p->t('coodle/umfrageAbgeschlossen', array( - $datum->formatDatum($coodle_abgeschlossen->datum, 'd.m.Y') . ' ' . $coodle_abgeschlossen->uhrzeit - )) . '
    '; -} - -echo '

    -
    '; - -$coodle_ressourcen = new coodle(); -$coodle_ressourcen->getRessourcen($coodle_id); - -// alle termine der coodle umfrage holen -$coodle_termine = new coodle(); -$coodle_termine->getTermine($coodle_id); - -$datum = new datum(); -$datum_colspan = ''; -$mailadressen = '?subject=Coodle%20Umfrage%20' . htmlspecialchars($coodle->titel) . '&bcc='; - -echo "
    -
    - -
    '; // Zusaetzlicher span fuer Addon Informationen @@ -1194,7 +1531,7 @@ if($projekt->getProjekteMitarbeiter($user, true)) $langindex = 1; else $langindex = 2; - echo ''.$tagbez[$langindex][$datum->formatDatum($tag,'N')].' '.$datum->formatDatum($tag,'d.m.Y').' '.$zeitsperre_text.''; + echo ''.$tagbez[$langindex][$datum->formatDatum($tag,'N')].' '.$datum->formatDatum($tag,'d.m.Y').' '.$zeitsperre_text.''.$pausefehlt_str; if ($ersumme != '00:00') $erstr = ' (+ '.$ersumme.' ER)'; else @@ -1203,8 +1540,8 @@ if($projekt->getProjekteMitarbeiter($user, true)) } echo ' - '.$p->t("zeitaufzeichnung/arbeitszeit").': '.$datum->formatDatum($tagesbeginn, $format='H:i').'-'.$datum->formatDatum($tagesende, $format='H:i').' '.$p->t("eventkalender/uhr").'
    LehreExtern / - '.$p->t("zeitaufzeichnung/pause").' '.($pflichtpause==false?$p->t("zeitaufzeichnung/inklusivePflichtpause"):'').': + '.$p->t("zeitaufzeichnung/arbeitszeit").': '.$datum->formatDatum($tagesbeginn, $format='H:i').'-'.$datum->formatDatum($tagesende, $format='H:i').' '.$p->t("eventkalender/uhr").'
    + '.$p->t("zeitaufzeichnung/pause").':
    '.$tagessaldo.$erstr.'
    '.date('H:i', ($pausesumme-3600)).'
    '; @@ -1259,7 +1596,7 @@ if($projekt->getProjekteMitarbeiter($user, true)) '; - $colspan=($za_simple)?10:13; + $colspan=($za_simple)?12:14; echo '
     
    '.$p->t('zeitaufzeichnung/dienstreise'); if (array_key_exists('start', $dr_arr[$datumtag]) && !array_key_exists('ende', $dr_arr[$datumtag])) echo ' '.$p->t('global/beginn'); @@ -1335,14 +1672,17 @@ if($projekt->getProjekteMitarbeiter($user, true)) $summe = $row->summe; $service = new service(); $service->load($row->service_id); + $projektphase = new projektphase($row->projektphase_id); + $ap = $projektphase->bezeichnung; echo '
    '.$db->convert_html_chars($row->zeitaufzeichnung_id).' '.$db->convert_html_chars($row->uid).' '.$db->convert_html_chars($row->projekt_kurzbz).' '.$db->convert_html_chars($ap).' '.$db->convert_html_chars($row->oe_kurzbz_1).' '.$db->convert_html_chars($row->oe_kurzbz_1).' '.$db->convert_html_chars($row->oe_kurzbz_2).' '.$db->convert_html_chars($row->oe_kurzbz_2).''.$db->convert_html_chars($row->aktivitaet_kurzbz).'
    '.$fieldheadings['id'].' '.$fieldheadings['user'].''.$fieldheadings['projekt'].''.$fieldheadings['projekt'].''.$fieldheadings['ap'].''.$fieldheadings['oe1'].''.$fieldheadings['oe1'].''.$fieldheadings['oe2'].''.$fieldheadings['oe2'].''.$fieldheadings['aktivitaet'].'
    - "; -// Für Colspan bei Datum -$max_colspan = array(); -foreach ($coodle_termine->result as $termin) -{ - $max_colspan[] .= $termin->datum; -} - -foreach ($coodle_termine->result as $termin) -{ - $class_auswahl = 'normal'; - $time = strtotime($termin->uhrzeit); - $coodle_auswahl = new coodle(); - - // Falls es schon eine Auswahl gibt - hervorheben - if ($coodle_auswahl->checkTerminAuswahl($coodle_id, $termin->coodle_termin_id)) - $class_auswahl = 'auswahl'; - - // Colspan für Datum berechnen - $count = array_count_values($max_colspan); - $colspan = $count[$termin->datum]; - - if ($datum_colspan != $termin->datum && $termin->datum != '1900-01-01') - echo ""; - - $datum_colspan = $termin->datum; -} -if ($ersteller) - echo ''; -echo ""; - -foreach ($coodle_termine->result as $termin) -{ - $class_auswahl = 'normal_uhrzeit'; - $time = strtotime($termin->uhrzeit); - // Endzeit berechnen - $ende = $time + ($coodle->dauer * 60); - - $coodle_auswahl = new coodle(); - - // Falls es schon eine Auswahl gibt - hervorheben - if ($coodle_auswahl->checkTerminAuswahl($coodle_id, $termin->coodle_termin_id)) - $class_auswahl = 'auswahl_uhrzeit'; - - if ($termin->datum != '1900-01-01') - echo ""; - else - echo ''; -} -echo ""; - -foreach ($coodle_ressourcen->result as $ressource) -{ - $name = ''; - $benutzer = new benutzer(); - - // wenn uid gesetzt ist nimm uid - if ($ressource->uid != '') - { - $benutzer->load($ressource->uid); - // $name .= ($benutzer->titelpre!='')?$benutzer->titelpre.' ':''; - $name .= $benutzer->vorname . ' '; - $name .= $benutzer->nachname . ' '; - // $name .= $benutzer->titelpost; - - $mailadressen .= $ressource->uid . '@' . DOMAIN . ';'; - - $ressource->anzeigename = $name; - $ressource->vorname = $benutzer->vorname; - $ressource->nachname = $benutzer->nachname; - } - - // wenn uid nicht gesetzt ist nimm zugangscode - if ($ressource->zugangscode != '' && $ressource->uid == '') - { - $name = $ressource->name; - $ressource->anzeigename = $name; - $ressource->vorname = $name; - $ressource->nachname = $name; - - $mailadressen .= ';' . $ressource->email; - } -} - -// Sortiert die Ressourcen alphabetisch nach anzeigename -function sortRessourcen($a, $b) -{ - return strcmp($a->nachname . '' . $a->vorname, $b->nachname . '' . $b->vorname); -} -usort($coodle_ressourcen->result, "sortRessourcen"); - -$owner = false; -// ressourcen durchlaufen -foreach ($coodle_ressourcen->result as $ressource) -{ - $owner = false; - // Ist der User ident mit einer Ressource - if (isset($_GET['zugangscode']) && $_GET['zugangscode'] == $ressource->zugangscode) - $owner = true; - if (! isset($_GET['zugangscode']) && $ressource->uid == $uid) - $owner = true; - - if ($coodle_help->teilnehmer_anonym && ! $owner) - continue; - else - { - - // Ort-Ressourcen ueberspringen - if ($ressource->ort_kurzbz != '') - continue; - - $class = 'normal'; - // eigene Reihe farbig hervorheben - if ($owner) - $class = 'owner'; - // Bei anonymen TeilnehmerInnen entfaellt das Hervorheben - if ($coodle_help->teilnehmer_anonym) - $class = 'normal'; - - echo ""; - - $termin_datum = ''; - $disabled = false; - $checked = false; - - $coodle_ressource = new coodle(); - if (isset($_GET['zugangscode'])) + if (!isset($_GET['zugangscode'])) { - $coodle_ressource->getRessourceFromUser($coodle_id, '', $_GET['zugangscode']); - if ($ressource->coodle_ressource_id != $coodle_ressource->coodle_ressource_id) - $disabled = true; + echo ''.$p->t('coodle/zurueckZurUebersicht').''; + echo '

    '; + } + + if ($saveOk === true) + { + echo ' +
    + '.$p->t('global/erfolgreichgespeichert').' +
    + '; } else { - $coodle_ressource->getRessourceFromUser($coodle_id, $uid); - if ($ressource->coodle_ressource_id != $coodle_ressource->coodle_ressource_id) - $disabled = true; - } - - if ($abgeschlossen) - $disabled = true; - - // termine zu ressourcen anzeigen - foreach ($coodle_termine->result as $termin) - { - $checked = false; - $style = ''; - if ($coodle_termine->checkTermin($termin->coodle_termin_id, $ressource->coodle_ressource_id)) - $checked = true; - - if ($termin_datum != '' && $termin_datum != $termin->datum) - $style = 'style="border-left: 1px solid #DCDDDF;"'; - - if ($coodle_help->termine_anonym && ! $owner && ! $ersteller) - echo ""; - else + echo '
    '; + + $coodle_help = new coodle(); + $coodle_help->load($coodle_id); + + $alt = strtotime($coodle_help->insertamum); + + $differenz = time() - $alt; + $differenz = $differenz / 86400; + $benutzer = new benutzer(); + $benutzer->load($coodle->ersteller_uid); + // $ersteller_name = trim($benutzer->titelpre.' '.$benutzer->vorname.' '.$benutzer->nachname.' '.$benutzer->titelpost); + $ersteller_name = trim($benutzer->vorname.' '.$benutzer->nachname); + echo '

    '.$coodle->titel.'

    '; + $erstellt = array( + $ersteller_name, + round($differenz) + ); + echo ''.$p->t('coodle/erstelltVon', $erstellt).'
    '; + echo ''.$p->t('coodle/dauer').': '.$coodle->dauer.' min.

    '; + + echo $coodle->beschreibung; + + echo '
    '; + + if ($abgeschlossen) { - if ($disabled) + $datum = new datum(); + $coodle_abgeschlossen = new coodle(); + $termin_id = $coodle_abgeschlossen->getTerminAuswahl($coodle_id); + $coodle_abgeschlossen->loadTermin($termin_id); + echo '
    '.$p->t('coodle/umfrageAbgeschlossen', array( + substr($tagbez[$sprache_index][$datum->formatDatum($coodle_abgeschlossen->datum, 'N')], 0, 2).', '. + $datum->formatDatum($coodle_abgeschlossen->datum, 'd.m.Y').' '. + $datum->formatDatum($coodle_abgeschlossen->uhrzeit, 'H:i') + )).'
    '; + } + + echo '
    +
    '; + + $coodle_ressourcen = new coodle(); + $coodle_ressourcen->getRessourcen($coodle_id); + $mailadressen = '?subject=Coodle%20Umfrage%20'.htmlspecialchars($coodle->titel).'&bcc='; + + foreach ($coodle_ressourcen->result as $ressource) + { + $name = ''; + $benutzer = new benutzer(); + + // wenn uid gesetzt ist nimm uid + if ($ressource->uid != '') { - if ($checked) - echo '
    '; - else - echo ''; + $benutzer->load($ressource->uid); + // $name .= ($benutzer->titelpre!='')?$benutzer->titelpre.' ':''; + $name .= $benutzer->vorname.' '; + $name .= $benutzer->nachname.' '; + // $name .= $benutzer->titelpost; + + $mailadressen .= $ressource->uid.'@'.DOMAIN.';'; + + $ressource->anzeigename = $name; + $ressource->vorname = $benutzer->vorname; + $ressource->nachname = $benutzer->nachname; + } + + // wenn uid nicht gesetzt ist nimm zugangscode + if ($ressource->zugangscode != '' && $ressource->uid == '') + { + $name = $ressource->name; + $ressource->anzeigename = $name; + $ressource->vorname = $name; + $ressource->nachname = $name; + + $mailadressen .= ';'.$ressource->email; + } + } + + // alle termine der coodle umfrage holen + $coodle_termine = new coodle(); + $coodle_termine->getTermine($coodle_id); + + $datum = new datum(); + $datum_colspan = ''; + + echo "
    + + +
    " . $datum->formatDatum($termin->datum, 'd.m.Y') . "
    " . date('H:i', $time) . " -
    " . date('H:i', $ende) . "  
    ' . $p->t('coodle/keinTerminMoeglich') . '
    " . $ressource->anzeigename . "
    + "; + // Für Colspan bei Datum + $max_colspan = array(); + foreach ($coodle_termine->result as $termin) + { + $max_colspan[] .= $termin->datum; + } + + foreach ($coodle_termine->result as $termin) + { + $class_auswahl = 'normal'; + $time = strtotime($termin->uhrzeit); + $coodle_auswahl = new coodle(); + + // Falls es schon eine Auswahl gibt - hervorheben + if ($coodle_auswahl->checkTerminAuswahl($coodle_id, $termin->coodle_termin_id)) + { + $class_auswahl = 'auswahl'; + } + + // Colspan für Datum berechnen + $count = array_count_values($max_colspan); + $colspan = $count[$termin->datum]; + + if ($datum_colspan != $termin->datum && $termin->datum != '1900-01-01') + { + echo ""; + } + + $datum_colspan = $termin->datum; + } + if ($ersteller) + { + echo ''; + } + echo ""; + echo ''; + + foreach ($coodle_termine->result as $termin) + { + $class_auswahl = 'normal_uhrzeit'; + $time = strtotime($termin->uhrzeit); + // Endzeit berechnen + $ende = $time + ($coodle->dauer * 60); + + $coodle_auswahl = new coodle(); + + // Falls es schon eine Auswahl gibt - hervorheben + if ($coodle_auswahl->checkTerminAuswahl($coodle_id, $termin->coodle_termin_id)) + { + $class_auswahl = 'auswahl_uhrzeit'; + } + + if ($termin->datum != '1900-01-01') + { + echo ""; } else { - // Der 01.01.1900 wird fuer "Keine Auswahl" verwendet. Beim anklicken der Checkbox werden alle anderen Checkboxen deaktiviert - echo ''; + echo ''; } } - - $termin_datum = $termin->datum; - } - if ($ersteller) - echo ""; - echo ''; - } -} + echo ""; -$disabled = $abgeschlossen ? 'disabled' : ''; + // Sortiert die Ressourcen alphabetisch nach anzeigename + function sortRessourcen($a, $b) + { + return strcmp($a->nachname.''.$a->vorname, $b->nachname.''.$b->vorname); + } -// Counter fuer Anzahl der Auswahlen pro Termin -$counter_arr = array(); -foreach ($coodle_termine->result as $termin) -{ - $countTermine = new coodle(); - $countTermine->countTermin($termin->coodle_termin_id); - - $counter_arr[] = $countTermine->anzahl; -} -if ($coodle_help->teilnehmer_anonym) - echo ''; -elseif ($coodle_help->termine_anonym) - echo ''; + usort($coodle_ressourcen->result, "sortRessourcen"); -echo ''; -foreach ($coodle_termine->result as $termin) -{ - $countTermine = new coodle(); - $countTermine->countTermin($termin->coodle_termin_id); - - if ($countTermine->anzahl == max($counter_arr)) - echo ''; - else - echo ''; -} -if ($ersteller) - echo ''; -echo ""; + $owner = false; + // ressourcen durchlaufen + foreach ($coodle_ressourcen->result as $ressource) + { + $owner = false; + // Ist der User ident mit einer Ressource + if (isset($_GET['zugangscode']) && $_GET['zugangscode'] == $ressource->zugangscode) + { + $owner = true; + } + if (!isset($_GET['zugangscode']) && $ressource->uid == $uid) + { + $owner = true; + } -if ($ersteller) -{ - // buttons für auswahl des endgültigen termins - echo ''; - foreach ($coodle_termine->result as $termin) - { - $checked = ($termin->auswahl) ? 'checked' : ''; - if ($termin->datum != '1900-01-01') - echo ''; - else - echo ''; - } - echo ''; - echo ""; -} -if ($ersteller && $abgeschlossen) - echo ' '; -echo ' - "; + + $termin_datum = ''; + $disabled = false; + $checked = false; + + $coodle_ressource = new coodle(); + if (isset($_GET['zugangscode'])) + { + $coodle_ressource->getRessourceFromUser($coodle_id, '', $_GET['zugangscode']); + if ($ressource->coodle_ressource_id != $coodle_ressource->coodle_ressource_id) + { + $disabled = true; + } + } + else + { + $coodle_ressource->getRessourceFromUser($coodle_id, $uid); + if ($ressource->coodle_ressource_id != $coodle_ressource->coodle_ressource_id) + { + $disabled = true; + } + } + + if ($abgeschlossen) + { + $disabled = true; + } + + // termine zu ressourcen anzeigen + foreach ($coodle_termine->result as $termin) + { + $checked = false; + $style = ''; + if ($coodle_termine->checkTermin($termin->coodle_termin_id, $ressource->coodle_ressource_id)) + { + $checked = true; + } + + if ($termin_datum != '' && $termin_datum != $termin->datum) + { + $style = 'style="border-left: 1px solid #DCDDDF;"'; + } + + if ($coodle_help->termine_anonym && !$owner && !$ersteller) + { + echo ""; + } + else + { + if ($disabled) + { + if ($checked) + { + echo ''; + } + else + { + echo ''; + } + } + else + { + // Der 01.01.1900 wird fuer "Keine Auswahl" verwendet. Beim anklicken der Checkbox werden alle anderen Checkboxen deaktiviert + echo ' '; + } + } + + $termin_datum = $termin->datum; + } + if ($ersteller) + { + echo ""; + } + echo ''; + } + } + + $disabled = $abgeschlossen ? 'disabled' : ''; + + // Counter fuer Anzahl der Auswahlen pro Termin + $counter_arr = array(); + foreach ($coodle_termine->result as $termin) + { + $countTermine = new coodle(); + $countTermine->countTermin($termin->coodle_termin_id); + + $counter_arr[] = $countTermine->anzahl; + } + if ($coodle_help->teilnehmer_anonym) + { + echo ''; + } + elseif ($coodle_help->termine_anonym) + { + echo ''; + } + + echo ''; + foreach ($coodle_termine->result as $termin) + { + $countTermine = new coodle(); + $countTermine->countTermin($termin->coodle_termin_id); + + if ($countTermine->anzahl == max($counter_arr)) + { + echo ''; + } + else + { + echo ''; + } + } + if ($ersteller) + { + echo ''; + } + echo ""; + + if ($ersteller) + { + // buttons für auswahl des endgültigen termins + echo ''; + foreach ($coodle_termine->result as $termin) + { + $checked = ($termin->auswahl) ? 'checked' : ''; + if ($termin->datum != '1900-01-01') + { + echo ''; + } + else + { + echo ''; + } + } + echo ''; + echo ""; + } + + echo ' '; + echo ' +
    + ".substr($monatsname[$sprache_index][$datum->formatDatum($termin->datum, 'n') - 1], 0, 3)."
    + ".$datum->formatDatum($termin->datum, 'd')."
    + ".substr($tagbez[$sprache_index][$datum->formatDatum($termin->datum, 'N')], 0, 2)." +
    '; + if ($ersteller && $abgeschlossen) + { + echo ''; + } + echo '".date('H:i', $time)." -
    ".date('H:i', $ende)."  
    - datum == '1900-01-01' ? 'id="disableCheckboxes"' : '') . ' - name="check_' . $ressource->coodle_ressource_id . '_' . $termin->coodle_termin_id . '"> - '.$p->t('coodle/keinTerminMoeglich').'
    Die TeilnehmerInnen dieser Umfrage sind anonym
    Die Terminwahl dieser Umfrage erfolgt anonym
    Summe der Einträge' . $p->t('coodle/keineAuswahl') . '
    ' . $p->t('coodle/auswahlEndtermin') . '
    Mail an alle schicken
    '; + if ($coodle_help->teilnehmer_anonym && !$owner) + { + continue; + } + else + { -if ($ersteller && $abgeschlossen) - echo ''; -if ($saveOk === true) - echo '
    - ' . $p->t('global/erfolgreichgespeichert') . ' + // Ort-Ressourcen ueberspringen + if ($ressource->ort_kurzbz != '') + { + continue; + } + + $class = 'normal'; + // eigene Reihe farbig hervorheben + if ($owner) + { + $class = 'owner'; + } + // Bei anonymen TeilnehmerInnen entfaellt das Hervorheben + if ($coodle_help->teilnehmer_anonym) + { + $class = 'normal'; + } + + echo "
    ".$ressource->anzeigename." +
    + +
    +
    Die TeilnehmerInnen dieser Umfrage sind anonym
    Die Terminwahl dieser Umfrage erfolgt anonym
    Summe der Einträge'.$p->t('coodle/keineAuswahl').'
    '.$p->t('coodle/auswahlEndtermin').'
    '; + if ($saveOk === true) + { + echo ' +
    + '.$p->t('global/erfolgreichgespeichert').'
    '; -echo "
    - " . $message . '
    ' . $mailMessage; - + } + echo '
    '; + } + + // Benutzer mit CIS-Account können die Terminzusagen als iCal importieren + if (isset($uid) && $uid != '') + { + echo '

    + + Sie können ihre vorläufigen Terminzusagen in ihr Kalendersystem einbinden.
    + Importieren Sie dazu die .ics-Datei aus folgendem Link in ihren Kalender:
    + + '.APP_ROOT.'cis/public/ical_coodle.php/'.$uid.' + +

    + Die Datei enthält ihre Terminzusagen aus allen laufenden Umfragen in anonymisierter Form. +
    '; + } + + if ($ersteller && $abgeschlossen) + { + echo '  '; + } + echo ''; + + echo '
    '.$message; + + echo $mailMessage; + ?> - + @@ -702,7 +895,7 @@ echo "
    + + + + + + + + + + + + + '; + +foreach ($sprache->result as $row) +{ + echo ' + + + '; +} +echo ' + + + + + + + + +
    Zu kopierendes Gebiet: '; + //Dropdown bestehender Gebiete + $gebiete = new gebiet(); + $gebiete->getAll(); + echo ''; +echo '
    Daten neues Gebiet
    Kurzbezeichnung
    Bezeichnung (intern)
    Bezeichnung '.$row->bezeichnung_arr[$sprache_user].'
    Beschreibung (intern)
    + + +'; + +echo ''; +?> diff --git a/cis/testtool/admin/index.php b/cis/testtool/admin/index.php index d433a747e..a6a4be483 100644 --- a/cis/testtool/admin/index.php +++ b/cis/testtool/admin/index.php @@ -690,6 +690,7 @@ if (($anzahl !== 0) || ($stg_kz == '-1') && ($stg_kz !== '')) echo " Prüfen | "; echo " Bearbeiten |"; echo " Neues Gebiet | "; + echo " Gebiet kopieren"; //echo " PDF exportieren"; //echo "
    Gebiet_id=".$gebiet_id.""; echo ''; @@ -965,7 +966,7 @@ if ($frage_id != '') echo ""; echo ""; echo ''; - echo "Punkte:"; + echo "Punkte:"; echo ""; echo ""; echo ""; diff --git a/cis/testtool/frage.php b/cis/testtool/frage.php index 33ec654c6..f15c2c2d2 100644 --- a/cis/testtool/frage.php +++ b/cis/testtool/frage.php @@ -42,51 +42,20 @@ if (!$db = new basis_db()) $PHP_SELF=$_SERVER["PHP_SELF"]; -function getSpracheUser() -{ - if(isset($_SESSION['sprache_user'])) - { - $sprache_user=$_SESSION['sprache_user']; - } - else - { - if(isset($_COOKIE['sprache_user'])) - { - $sprache_user=$_COOKIE['sprache_user']; - } - else - { - $sprache_user=DEFAULT_LANGUAGE; - } - setSpracheUser($sprache_user); - } - return $sprache_user; -} - -function setSpracheUser($sprache) -{ - $_SESSION['sprache_user']=$sprache; - setcookie('sprache_user',$sprache,time()+60*60*24*30,'/'); -} - -if(isset($_GET['sprache_user'])) -{ - $sprache_user = new sprache(); - if($sprache_user->load($_GET['sprache_user'])) - { - setSpracheUser($_GET['sprache_user']); - } - else - setSpracheUser(DEFAULT_LANGUAGE); -} - -$sprache_user = getSpracheUser(); -$p = new phrasen($sprache_user); - -$sprache = getSprache(); - +// Start session session_start(); +// If language is changed by language select menu, reset language variables +if (isset($_GET['sprache_user']) && !empty($_GET['sprache_user'])) +{ + $_SESSION['sprache_user'] = $_GET['sprache_user']; + $sprache_user = $_GET['sprache_user']; +} + +// Set language variable, which impacts the question language +$sprache_user = (isset($_SESSION['sprache_user']) && !empty($_SESSION['sprache_user'])) ? $_SESSION['sprache_user'] : DEFAULT_LANGUAGE; +$p = new phrasen($sprache_user); + if(isset($_GET['gebiet_id'])) $gebiet_id = $_GET['gebiet_id']; else @@ -191,7 +160,7 @@ $gebiet = new gebiet($gebiet_id); if($gebiet->level_start!='') $levelgebiet=true; -else +else $levelgebiet=false; list($stunde, $minute, $sekunde) = explode(':',$gebiet->zeit); @@ -209,20 +178,20 @@ if(isset($_GET['start']) && !$gestartet) $frage = new frage(); if(!$frage->generateFragenpool($_SESSION['pruefling_id'], $gebiet_id)) die($p->t('testtool/fehlerBeimGenerierenDesFragenpools').':'.$frage->errormsg); - + //Erste Frage des Pools holen if(!$frage_id = $frage->getNextFrage($gebiet_id, $_SESSION['pruefling_id'])) die($p->t('testtool/esWurdeKeineFrageGefunden')); - + //Beginnzeit Speichern $prueflingfrage = new frage(); if(!$prueflingfrage->getPrueflingfrage($_SESSION['pruefling_id'], $frage_id)) die($p->t('testtool/fehler').':'.$prueflingfrage->errormsg); - + $prueflingfrage->begintime = date('Y-m-d H:i:s'); if(!$prueflingfrage->save_prueflingfrage(false)) die($p->t('testtool/fehlerBeimStartvorgang')); - + echo ''; } @@ -232,46 +201,46 @@ if(isset($_POST['submitantwort']) && isset($_GET['frage_id'])) // vor dem Speichern der Antworten, alle Antworten zu der Frage loeschen // und die Antworten neu anlegen // Unterscheidung ob mehrere oder nur eine Antwort uebergeben wird - + if($levelgebiet && !isset($_POST['vorschlag_id'])) { echo ''.$p->t('testtool/beiDiesemGebietMuessenSieJedeFrageBeantworten').''; } else { - + $error=false; - + $db->db_query('BEGIN;'); - + // alle vorhandenen Antworten zu dieser Frage loeschen $qry = "DELETE FROM testtool.tbl_antwort WHERE antwort_id in( SELECT antwort_id FROM testtool.tbl_antwort JOIN testtool.tbl_vorschlag USING(vorschlag_id) WHERE frage_id=".$db->db_add_param($_GET['frage_id'])." AND pruefling_id=".$db->db_add_param($_SESSION['pruefling_id']).")"; - + $db->db_query($qry); - - // Antwort nur Speichern wenn eine Antwort gewaehlt wurde + + // Antwort nur Speichern wenn eine Antwort gewaehlt wurde if(isset($_POST['vorschlag_id']) && $_POST['vorschlag_id']!='') { $vorschlaege = array(); //Falls nur eine einzelne Antwort kommt, diese auch in ein Array packen if(!is_array($_POST['vorschlag_id'])) $vorschlaege[0]=$_POST['vorschlag_id']; - else + else $vorschlaege = $_POST['vorschlag_id']; - + //alle Antworten Speichern - foreach ($vorschlaege as $vorschlag_id) + foreach ($vorschlaege as $vorschlag_id) { if($vorschlag_id!='') { $antwort = new antwort(); - + $antwort->new = true; $antwort->vorschlag_id = $vorschlag_id; $antwort->pruefling_id = $_SESSION['pruefling_id']; - + if(!$antwort->save()) { $errormsg = $antwort->errormsg; @@ -279,7 +248,7 @@ if(isset($_POST['submitantwort']) && isset($_GET['frage_id'])) } } } - + if(!$error) { //Endzeit der Frage eintragen @@ -290,7 +259,7 @@ if(isset($_POST['submitantwort']) && isset($_GET['frage_id'])) $error = true; } $prueflingfrage->endtime = date('Y-m-d H:i:s'); - + if(!$prueflingfrage->save_prueflingfrage(false)) { $errormsg = $prueflingfrage->errormsg; @@ -298,32 +267,32 @@ if(isset($_POST['submitantwort']) && isset($_GET['frage_id'])) } } } - + if($error) { $db->db_query('ROLLBACK;'); die($p->t('testtool/fehler').':'.$errormsg); } - else + else { $db->db_query('COMMIT;'); } - + $frage = new frage(); - + if($levelgebiet) { //bei gelevelten Fragen die naechste Frage holen $frage->generateFragenpool($_SESSION['pruefling_id'], $gebiet_id); } - + $frage_id = $frage->getNextFrage($gebiet_id, $_SESSION['pruefling_id'], $frage_id); } } //Schauen ob dieses Gebiet schon gestartet wurde $qry = "SELECT begintime - FROM + FROM testtool.tbl_pruefling_frage JOIN testtool.tbl_frage USING(frage_id) WHERE pruefling_id=".$db->db_add_param($_SESSION['pruefling_id'], FHC_INTEGER)." AND gebiet_id=".$db->db_add_param($gebiet_id, FHC_INTEGER)." ORDER BY begintime ASC LIMIT 1"; @@ -352,7 +321,7 @@ else $info=''; //Name und Studiengang anzeigen -$qry_pruefling = "SELECT vorname, nachname, stg_bez, tbl_studiengangstyp.bezeichnung FROM testtool.vw_pruefling +$qry_pruefling = "SELECT vorname, nachname, stg_bez, tbl_studiengangstyp.bezeichnung FROM testtool.vw_pruefling JOIN public.tbl_studiengang USING (studiengang_kz) JOIN public.tbl_studiengangstyp USING (typ) WHERE pruefling_id=".$db->db_add_param($_SESSION['pruefling_id']); @@ -373,7 +342,7 @@ if($levelgebiet) $qry = "SELECT count(*) as anzahl FROM testtool.tbl_pruefling_frage JOIN testtool.tbl_frage USING(frage_id) WHERE pruefling_id=".$db->db_add_param($_SESSION['pruefling_id'], FHC_INTEGER)." AND gebiet_id=".$db->db_add_param($gebiet_id, FHC_INTEGER); - + if($result_aktuell = $db->db_query($qry)) { if($row_aktuell = $db->db_fetch_object($result_aktuell)) @@ -433,8 +402,8 @@ if($demo) else { //Wenn es sich um eine Testfrage handelt, dann wird die verbleibende Zeit angezeigt - $qry = "SELECT '$gebiet->zeit'-(now()-min(begintime)) as time - FROM testtool.tbl_pruefling_frage JOIN testtool.tbl_frage USING(frage_id) + $qry = "SELECT '$gebiet->zeit'-(now()-min(begintime)) as time + FROM testtool.tbl_pruefling_frage JOIN testtool.tbl_frage USING(frage_id) WHERE gebiet_id=".$db->db_add_param($gebiet_id, FHC_INTEGER)." AND pruefling_id=".$db->db_add_param($_SESSION['pruefling_id'], FHC_INTEGER); $result = $db->db_query($qry); $row = $db->db_fetch_object($result); @@ -450,7 +419,7 @@ else echo $p->t('testtool/bearbeitungszeit').': '; echo ""; - + if($zeit<0) die('
    '.$p->t('testtool/dieZeitIstAbgelaufen').'
    '); } @@ -470,17 +439,17 @@ else { // wenn keine Frage uebergeben wurde und die maximale Fragenanzahl erreicht wurde // dann ist das Gebiet fertig - $qry = "SELECT count(*) as anzahl FROM testtool.tbl_pruefling_frage JOIN testtool.tbl_frage USING(frage_id) + $qry = "SELECT count(*) as anzahl FROM testtool.tbl_pruefling_frage JOIN testtool.tbl_frage USING(frage_id) WHERE gebiet_id=".$db->db_add_param($gebiet_id, FHC_INTEGER)." AND pruefling_id=".$db->db_add_param($_SESSION['pruefling_id'], FHC_INTEGER)." AND tbl_pruefling_frage.endtime is not null"; $result = $db->db_query($qry); $row = $db->db_fetch_object($result); - + if($row->anzahl>=$gebiet->maxfragen) { die(""); } } - + $frage_id = $frage->getNextFrage($gebiet_id, $_SESSION['pruefling_id'], null, $demo, $levelgebiet); $frage->load($frage_id); } @@ -489,7 +458,7 @@ else if($frage->frage_id!='') { $frage_id = $frage->frage_id; - $frage->getFrageSprache($frage_id, $_SESSION['sprache']); + $frage->getFrageSprache($frage_id, $_SESSION['sprache_user']); if(!$demo) { @@ -502,7 +471,7 @@ if($frage->frage_id!='') $prueflingfrage = new frage(); if(!$prueflingfrage->getPrueflingfrage($_SESSION['pruefling_id'], $frage_id)) die($p->t('testtool/dieseFrageIstNichtFuerSieBestimmt')); - + if($prueflingfrage->begintime=='') { $prueflingfrage->begintime = date('Y-m-d H:i:s'); @@ -515,8 +484,8 @@ if($frage->frage_id!='') //Kopfzeile mit Weiter Button und Sprung direkt zu einer Frage if(!$demo && !$levelgebiet) { - $qry = "SELECT tbl_pruefling_frage.nummer, tbl_pruefling_frage.frage_id - FROM testtool.tbl_pruefling_frage JOIN testtool.tbl_frage USING(frage_id) + $qry = "SELECT tbl_pruefling_frage.nummer, tbl_pruefling_frage.frage_id + FROM testtool.tbl_pruefling_frage JOIN testtool.tbl_frage USING(frage_id) WHERE gebiet_id=".$db->db_add_param($gebiet_id, FHC_INTEGER)." AND pruefling_id=".$db->db_add_param($_SESSION['pruefling_id'], FHC_INTEGER)." AND demo=false ORDER BY nummer"; echo " @@ -546,9 +515,9 @@ if($frage->frage_id!='') { if($demo) $value=''; - else + else $value=$p->t('testtool/blaettern').' >>'; - + echo " $value"; } else @@ -574,8 +543,8 @@ if($frage->frage_id!='') { echo '
    -


    -
    +


    +
    '; } $timestamp = time(); @@ -583,13 +552,13 @@ if($frage->frage_id!='') //Sound einbinden if($frage->audio!='') { - echo ' + echo '
    -
    '; } @@ -597,15 +566,15 @@ if($frage->frage_id!='') $display_well = $frage->nummer == 0 ? '' : 'well'; // don't style frage 0 because this is always the introduction to gebiet echo '
    -
    +
    '. $frage->text. '
    -
    -
    +
    +
    '; //Vorschlaege laden $vs = new vorschlag(); - $vs->getVorschlag($frage->frage_id, $_SESSION['sprache'], $gebiet->zufallvorschlag); + $vs->getVorschlag($frage->frage_id, $_SESSION['sprache_user'], $gebiet->zufallvorschlag); $letzte = $frage->getNextFrage($gebiet_id, $_SESSION['pruefling_id'], $frage_id, $demo); echo "
    frage_id\" method=\"POST\" ".(!$letzte && !$levelgebiet?"onsubmit=\"letzteFrage()\"":"").">"; echo ' @@ -617,22 +586,22 @@ if($frage->frage_id!='') $beantwortet = false; $cnt = 0; // counter für foreach-Schleife $len = count($vs->result); - + //Antworten laden falls bereits vorhanden $antwort = new antwort(); $antwort->getAntwort($_SESSION['pruefling_id'],$frage->frage_id); - + //Vorschlaege anzeigen foreach ($vs->result as $vorschlag) { echo ""; - + //Bei multipleresponse checkboxen anzeigen ansonsten radiobuttons if($gebiet->multipleresponse) $type='checkbox'; - else + else $type='radio'; - + //Antworten markieren wenn die Frage bereits beantwortet wurde $checked=false; reset($antwort->result); @@ -644,15 +613,15 @@ if($frage->frage_id!='') $beantwortet = true; } } - + echo ''; - + echo '
    '; if($vorschlag->bild!='') - echo "
    "; + echo "
    "; if($vorschlag->audio!='') { - echo '
    '; echo ""; + echo '
'; echo '




'; } else @@ -725,7 +695,5 @@ else echo "

".$p->t("testtool/startDrueckenUmZuBeginnen")."
"; } ?> - - diff --git a/cis/testtool/gebietfertig.php b/cis/testtool/gebietfertig.php index 45142e8c2..d8f9982d0 100644 --- a/cis/testtool/gebietfertig.php +++ b/cis/testtool/gebietfertig.php @@ -19,6 +19,7 @@ * Andreas Oesterreicher , * Rudolf Hangl , * Manfred Kindl + * Cristina Hainberger */ require_once('../../config/cis.config.inc.php'); @@ -29,45 +30,18 @@ require_once '../../include/phrasen.class.php'; if (!$db = new basis_db()) die('Fehler beim Oeffnen der Datenbankverbindung'); -function getSpracheUser() +// Start session +session_start(); + +// If language is changed by language select menu, reset language variables +if (isset($_GET['sprache_user']) && !empty($_GET['sprache_user'])) { - if(isset($_SESSION['sprache_user'])) - { - $sprache_user=$_SESSION['sprache_user']; - } - else - { - if(isset($_COOKIE['sprache_user'])) - { - $sprache_user=$_COOKIE['sprache_user']; - } - else - { - $sprache_user=DEFAULT_LANGUAGE; - } - setSpracheUser($sprache_user); - } - return $sprache_user; + $_SESSION['sprache_user'] = $_GET['sprache_user']; + $sprache_user = $_GET['sprache_user']; } -function setSpracheUser($sprache) -{ - $_SESSION['sprache_user']=$sprache; - setcookie('sprache_user',$sprache,time()+60*60*24*30,'/'); -} - -if(isset($_GET['sprache_user'])) -{ - $sprache_user = new sprache(); - if($sprache_user->load($_GET['sprache_user'])) - { - setSpracheUser($_GET['sprache_user']); - } - else - setSpracheUser(DEFAULT_LANGUAGE); -} - -$sprache_user = getSpracheUser(); +// Set language variable +$sprache_user = (isset($_SESSION['sprache_user']) && !empty($_SESSION['sprache_user'])) ? $_SESSION['sprache_user'] : DEFAULT_LANGUAGE; $p = new phrasen($sprache_user); ?> diff --git a/cis/testtool/login.php b/cis/testtool/login.php index 40afeac4a..e42a623b2 100644 --- a/cis/testtool/login.php +++ b/cis/testtool/login.php @@ -38,69 +38,37 @@ require_once '../../include/datum.class.php'; if (!$db = new basis_db()) die('Fehler beim Oeffnen der Datenbankverbindung'); -//if(isset($_GET['lang'])) -// setSprache($_GET['lang']); +// Start session +session_start(); -$date = new datum(); - -function getSpracheUser() +// Logout (triggered by logout button in menu.php) +if (isset($_GET['logout']) && $_GET['logout'] == true) { - if(isset($_SESSION['sprache_user'])) - { - $sprache_user=$_SESSION['sprache_user']; - } - else - { - if(isset($_COOKIE['sprache_user'])) - { - $sprache_user=$_COOKIE['sprache_user']; - } - else - { - $sprache_user=DEFAULT_LANGUAGE; - } - setSpracheUser($sprache_user); - } - return $sprache_user; -} + // Unset global vars + unset($_GET['logout']); + unset($_GET['sprache_user']); + $_POST = []; + $_SESSION = []; -function setSpracheUser($sprache) -{ - $_SESSION['sprache_user']=$sprache; - setcookie('sprache_user',$sprache,time()+60*60*24*30,'/'); -} + // Destroy session + session_destroy(); -if(isset($_GET['sprache_user'])) -{ - $sprache_user = new sprache(); - if($sprache_user->load($_GET['sprache_user'])) - { - setSpracheUser($_GET['sprache_user']); - } - else - setSpracheUser(DEFAULT_LANGUAGE); + echo ' + + '; } -$sprache_user = getSpracheUser(); -$p = new phrasen($sprache_user); - $gebdatum=''; +$date = new datum(); -session_start(); -$reload=false; -$reload_parent=false; +$reload_menu=false; $sg_var = new studiengang(); -if (isset($_GET['logout'])) -{ - if(isset($_SESSION['prestudent_id'])) - { - $reload = true; - session_destroy(); - } -} - if(isset($_POST['gebdatum']) && $_POST['gebdatum']!='') { $gebdatum = $date->formatDatum($_POST['gebdatum'],'Y-m-d'); @@ -178,7 +146,6 @@ if (isset($_POST['prestudent']) && isset($gebdatum)) $_SESSION['vorname']=$ps->vorname; $_SESSION['gebdatum']=$ps->gebdatum; $stg_obj = new studiengang($studiengang); - $_SESSION['sprache']=$stg_obj->sprache; $_SESSION['semester']=$semester; $stg_obj->getStudiengangTyp($stg_obj->typ); @@ -215,7 +182,6 @@ if (isset($_POST['prestudent']) && isset($gebdatum)) break; } } - // Sprachvorgaben zu STG mit höchster Prio ermitteln // * 1. Sprache über Ablauf Vorgaben ermitteln @@ -246,11 +212,11 @@ if (isset($_POST['prestudent']) && isset($gebdatum)) // * 4. Sprache setzen. Falls keine Sprache vorhanden -> DEFAULT language verwenden if (empty($rt_sprache)) { - $_SESSION['sprache'] = DEFAULT_LANGUAGE; + $_SESSION['sprache_user'] = DEFAULT_LANGUAGE; } else { - $_SESSION['sprache'] = $rt_sprache; + $_SESSION['sprache_user'] = $rt_sprache; } } else @@ -269,8 +235,38 @@ if (isset($_POST['prestudent']) && isset($gebdatum)) } } +// Set language of user. +// NOTE: don't move the code in order to check first the right studies' reihungstest language +// (in case it was overruled by other STG with higher priority) + +// Start with default language on first login (before any prestudent has been selected) +$sprache_user = DEFAULT_LANGUAGE; +if (isset($_SESSION['sprache_user']) && !empty($_SESSION['sprache_user'])) +{ + // If session var already exists, overwrite language var + // (session var changes e.g. when user selects other language with language-select-menu) + $sprache_user = $_SESSION['sprache_user']; +} +elseif (isset($_SESSION['prestudent_id'])) +{ + // If session var does not exist but prestudent is known, set the session var + $_SESSION['sprache_user'] = DEFAULT_LANGUAGE; +} + +// If language is changed by language select menu, reset language variables +if(isset($_GET['sprache_user']) && !empty($_GET['sprache_user'])) +{ + $sprache_user = $_GET['sprache_user']; + $_SESSION['sprache_user'] = $_GET['sprache_user']; +} + +// NOTE: leave phrasen here, as the final users language is not defined until here +$p = new phrasen($sprache_user); + if (isset($_SESSION['prestudent_id'])) - $prestudent_id=$_SESSION['prestudent_id']; +{ + $prestudent_id=$_SESSION['prestudent_id']; +} else { //$prestudent_id=null; @@ -279,10 +275,6 @@ else $ps->getPrestudentRT($datum); } -if(isset($_GET['type']) && $_GET['type']=='sprachechange' && isset($_GET['sprache'])) -{ - setSprache($_GET['sprache']); -} if(isset($_SESSION['prestudent_id']) && !isset($_SESSION['pruefling_id'])) { @@ -303,7 +295,7 @@ if(isset($_SESSION['prestudent_id']) && !isset($_SESSION['pruefling_id'])) if($pruefling->save()) { $_SESSION['pruefling_id']=$pruefling->pruefling_id; - $reload_parent=true; + $reload_menu=true; } } @@ -327,19 +319,19 @@ if(isset($_POST['save']) && isset($_SESSION['prestudent_id'])) { $_SESSION['pruefling_id']=$pruefling->pruefling_id; $_SESSION['semester']=$pruefling->semester; - $reload_parent=true; + $reload_menu=true; } } ?> - + - - - - + + + + parent.menu.location.reload();'; - - if($reload) - echo ""; ?>
-
studiengang_kz); $pruefling = new pruefling(); @@ -399,7 +386,7 @@ if (isset($prestudent_id)) $ps = new Prestudent(); // * prinzipiell STG der session übernehmem - $firstPrio_studiengang_kz = $prestudent->studiengang_kz;; + $firstPrio_studiengang_kz = $prestudent->studiengang_kz; // * wenn STG des eingeloggten Prestudenten vom Typ Bachelor ist, dann höchste Prio aller // Bachelor-STG ermitteln, an denen die Person noch interessiert ist @@ -419,15 +406,28 @@ if (isset($prestudent_id)) // Sprachwahl zu STG mit höchster Prio ermitteln $ablauf = new Ablauf(); $sprachwahl = false; - if ($ablauf->getAblaufVorgabeStudiengang($firstPrio_studiengang_kz) && is_bool($ablauf->result[0]->sprachwahl)) + if (isset($ablauf->result[0]) + && $ablauf->getAblaufVorgabeStudiengang($firstPrio_studiengang_kz) + && is_bool($ablauf->result[0]->sprachwahl)) { $sprachwahl = $ablauf->result[0]->sprachwahl; } + // If language can be switched, display language select menu on the top + if ($sprachwahl) + { + $_SESSION['sprache_auswahl'] = true; + ?> + + '; echo '

'. $p->t('testtool/begruessungstext'). '


-

'. $p->t('testtool/anmeldedaten'). '


+

'. $p->t('testtool/anmeldedaten'). '


'; echo ' @@ -449,15 +449,15 @@ if (isset($prestudent_id)) echo '
'; echo '

'. $p->t('testtool/fuerFolgendeStgAngemeldet'). '


- - + +
- - + + '; // * wenn Prestudent an 1 - n Bachelor-Studiengängen interessiert ist, dann STG anführen @@ -521,8 +521,8 @@ if (isset($prestudent_id)) echo ''; } - echo ' - + echo ' +
'. $p->t('global/studiengang'). ' Status
'. $ps_master->status_mehrsprachig[$sprache_user]. '
'; @@ -538,53 +538,6 @@ if (isset($prestudent_id)) //echo ''; echo ''; echo ''; - - //Wenn die Sprachwahl fuer den priorisierten Studiengang aktiviert ist, dann die Sprachen anzeigen - if($sprachwahl==true) - { - //Liste der Sprachen, die in den Gebieten vorkommen koennen - $qry = "SELECT distinct sprache - FROM - testtool.tbl_pruefling - JOIN testtool.tbl_ablauf USING(studiengang_kz) - JOIN testtool.tbl_frage USING(gebiet_id) - JOIN testtool.tbl_frage_sprache USING(frage_id) - WHERE - tbl_pruefling.pruefling_id=".$db->db_add_param($pruefling->pruefling_id)." - ORDER BY sprache DESC"; - - if($result = $db->db_query($qry)) - { - echo ' -

'. $p->t('testtool/spracheDerTestfragen').':


-
- '; - - while($row = $db->db_fetch_object($result)) - { - $selected = ($_SESSION['sprache'] == $row->sprache) ? 'active' : ''; - $row_sprache = $row->sprache; - if ($sprache_user == 'German') - { - if($row->sprache == 'English') - { - $row_sprache = 'Englisch'; - } - elseif ($row->sprache == 'German') - { - $row_sprache = 'Deutsch'; - } - } - echo " - - "; - } - echo '
'; - } - } - echo '

'; echo '
@@ -594,22 +547,45 @@ if (isset($prestudent_id)) if($pruefling->pruefling_id!='') { $_SESSION['pruefling_id']=$pruefling->pruefling_id; - //echo ''; } } else { echo ''.$p->t('testtool/keinPrueflingseintragVorhanden').''; } + echo '
'; } -else +else // LOGIN Site (vor Login) { - //LOGIN FORM (Startseite vor Login) $prestudent_id_dummy_student = (defined('PRESTUDENT_ID_DUMMY_STUDENT')?PRESTUDENT_ID_DUMMY_STUDENT:''); + echo '
'; - echo '
- '; + echo '\n'; foreach($ps->result as $prestd) { $stg = new studiengang(); @@ -618,7 +594,8 @@ else $selected = 'selected'; else $selected=''; - echo '\n'; + echo ' + \n'; } // An der FHTW gibt es 3 Testuser für den Camus International if (CAMPUS_NAME == 'FH Technikum Wien') @@ -628,19 +605,26 @@ else echo '\n'; } echo ''; - echo '  '.$p->t('global/geburtsdatum').': '; - echo ''; - echo ''; - echo '
'; + echo '
'; // end col-xs + echo '
'; // end form-group - echo '


-
- '.$p->t('testtool/willkommenstextTitel').'

- '.$p->t('testtool/willkommenstext').' -
'; + // Datepicker input + echo '
'; + echo ''; + echo '
'; + echo ''; + echo '
'; // end col-xs + echo '
'; // end form-group + + // Login button + echo ''; + + echo ''; // end form + + echo '
'; // end row + echo ''; // end col-xs-11 } ?> - diff --git a/cis/testtool/menu.php b/cis/testtool/menu.php index af716542a..4d075ee9a 100644 --- a/cis/testtool/menu.php +++ b/cis/testtool/menu.php @@ -19,6 +19,7 @@ * Andreas Oesterreicher , * Rudolf Hangl , * Manfred Kindl + * Cristina Hainberger */ require_once('../../config/cis.config.inc.php'); @@ -27,56 +28,25 @@ require_once('../../include/basis_db.class.php'); require_once('../../include/sprache.class.php'); require_once '../../include/phrasen.class.php'; require_once '../../include/studiengang.class.php'; +require_once('../../include/gebiet.class.php'); if (!$db = new basis_db()) die('Fehler beim Oeffnen der Datenbankverbindung'); -require_once('../../include/gebiet.class.php'); - -function getSpracheUser() -{ - if(isset($_SESSION['sprache_user'])) - { - $sprache_user=$_SESSION['sprache_user']; - } - else - { - if(isset($_COOKIE['sprache_user'])) - { - $sprache_user=$_COOKIE['sprache_user']; - } - else - { - $sprache_user=DEFAULT_LANGUAGE; - } - setSpracheUser($sprache_user); - } - return $sprache_user; -} - -function setSpracheUser($sprache) -{ - $_SESSION['sprache_user']=$sprache; - setcookie('sprache_user',$sprache,time()+60*60*24*30,'/'); -} - -if(isset($_GET['sprache_user'])) -{ - $sprache_user = new sprache(); - if($sprache_user->load($_GET['sprache_user'])) - { - setSpracheUser($_GET['sprache_user']); - } - else - setSpracheUser(DEFAULT_LANGUAGE); -} - -$sprache_user = getSpracheUser(); -$p = new phrasen($sprache_user); -$sprache = getSprache(); - +// Start session session_start(); +// If language is changed by language select menu, reset language and session variables +if(isset($_GET['sprache_user']) && !empty($_GET['sprache_user'])) +{ + $sprache_user = $_GET['sprache_user']; + $_SESSION['sprache_user'] = $_GET['sprache_user']; +} + +// Set language variable, which impacts the navigation menu +$sprache_user = (isset($_SESSION['sprache_user']) && !empty($_SESSION['sprache_user'])) ? $_SESSION['sprache_user'] : DEFAULT_LANGUAGE; +$p = new phrasen($sprache_user); + ?> @@ -89,6 +59,9 @@ session_start(); - '.$p->t('testtool/einleitung').' + '.$p->t('testtool/einleitung').' '; } @@ -183,13 +156,13 @@ if (isset($_SESSION['pruefling_id'])) /* Filter out all Abgewiesene */ AND NOT EXISTS ( - SELECT - 1 + SELECT + 1 FROM tbl_prestudentstatus - WHERE - status_kurzbz = 'Abgewiesener' - AND + WHERE + status_kurzbz = 'Abgewiesener' + AND prestudent_id = ps_status.prestudent_id ) @@ -220,7 +193,7 @@ if (isset($_SESSION['pruefling_id'])) ) - SELECT DISTINCT ON + SELECT DISTINCT ON (gebiet_id, semester) semester, gebiet_id, @@ -231,7 +204,7 @@ if (isset($_SESSION['pruefling_id'])) FROM ( SELECT * - FROM ( + FROM ( (SELECT prestudent_data.semester AS ps_sem, gebiet_id, @@ -252,9 +225,9 @@ if (isset($_SESSION['pruefling_id'])) OR (prestudent_data.semester= 3 AND tbl_ablauf.semester IN (1,3)) ) - + UNION - + ( SELECT prestudent_data.semester AS ps_sem, @@ -278,15 +251,12 @@ if (isset($_SESSION['pruefling_id'])) ) ) temp ) temp2 - + GROUP BY semester, gebiet_id, bezeichnung, - bezeichnung_mehrsprachig_1, - bezeichnung_mehrsprachig_2, - bezeichnung_mehrsprachig_3, - bezeichnung_mehrsprachig_4 + ". $bezeichnung_mehrsprachig_sel ." ORDER BY semester, @@ -296,8 +266,6 @@ if (isset($_SESSION['pruefling_id'])) $result = $db->db_query($qry); $lastsemester = ''; $quereinsteiger_stg = ''; - $gebiet_hasMathML = false; // true, wenn irgendein Gebiet eine/n Frage/Vorschlag im MathML-Format enthält - $invalid_gebiete = false; while($row = $db->db_fetch_object($result)) { //Jedes Semester in einer eigenen Tabelle anzeigen @@ -404,7 +372,7 @@ if (isset($_SESSION['pruefling_id'])) // Link zum Logout echo ' - Logout + Logout '; echo ''; @@ -425,7 +393,7 @@ else // show message to use Mozilla Firefox if ((ua.indexOf("Firefox") > -1) == false) { - let hasMathML = ""; + let hasMathML = ""; let userLang = ""; if (hasMathML == true) { @@ -442,7 +410,7 @@ else // Error massage if check_gebiet function returns false $(function() { - var invalid_gebiete = ""; + var invalid_gebiete = ""; if(invalid_gebiete == true) { $('#tr-einleitung').append('' + diff --git a/cis/testtool/topbar.php b/cis/testtool/topbar.php index c4ca24357..8fd10a3f0 100644 --- a/cis/testtool/topbar.php +++ b/cis/testtool/topbar.php @@ -16,57 +16,33 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * Authors: Manfred Kindl . + * Cristina Hainberger */ require_once('../../config/cis.config.inc.php'); require_once('../../include/basis_db.class.php'); require_once('../../include/sprache.class.php'); require_once '../../include/phrasen.class.php'; +require_once('../../include/gebiet.class.php'); if (!$db = new basis_db()) die('Fehler beim Oeffnen der Datenbankverbindung'); - -require_once('../../include/gebiet.class.php'); - -function getSpracheUser() + +// Start session +session_start(); + +// If language is changed by language select menu, reset session- and language variable +if (isset($_GET['sprache_user']) && !empty($_GET['sprache_user'])) { - if(isset($_SESSION['sprache_user'])) - { - $sprache_user=$_SESSION['sprache_user']; - } - else - { - if(isset($_COOKIE['sprache_user'])) - { - $sprache_user=$_COOKIE['sprache_user']; - } - else - { - $sprache_user=DEFAULT_LANGUAGE; - } - setSpracheUser($sprache_user); - } - return $sprache_user; + $_SESSION['sprache_user'] = $_GET['sprache_user']; + $sprache_user = $_GET['sprache_user']; } -function setSpracheUser($sprache) -{ - $_SESSION['sprache_user']=$sprache; - setcookie('sprache_user',$sprache,time()+60*60*24*30,'/'); -} +// Set language variable, which impacts the language displayed in the language select menu +$sprache_user = (isset($_SESSION['sprache_user']) && !empty($_SESSION['sprache_user'])) ? $_SESSION['sprache_user'] : DEFAULT_LANGUAGE; -if(isset($_GET['sprache_user'])) -{ - $sprache_user = new sprache(); - if($sprache_user->load($_GET['sprache_user'])) - { - setSpracheUser($_GET['sprache_user']); - } - else - setSpracheUser(DEFAULT_LANGUAGE); -} - -$sprache_user = getSpracheUser(); +// The language select menu is only displayed if RT-Ablauf of STG allows to switch language +$display = (isset($_SESSION['sprache_auswahl']) && $_SESSION['sprache_auswahl'] == true) ? '' : 'hidden'; $p = new phrasen($sprache_user); ?> @@ -85,16 +61,15 @@ $p = new phrasen($sprache_user); @@ -104,15 +79,17 @@ echo ' -
+ + +
- @@ -140,4 +117,3 @@ echo ' + '; + + include('../include/meta/jquery.php'); + include('../include/meta/jquery-tablesorter.php'); + +echo ' + + + +
+

Content-Übersicht

'; + echo '

'; + echo ''; + echo ' + + + + + + + + + + + + '; + echo ''; + +$qry = " +SELECT + content.content_id, + tbl_contentsprache.titel, + content.template_kurzbz, + content.oe_kurzbz, + content.aktiv, + content.insertamum||' von '||content.insertvon AS content_eingefuegt, + content.updateamum||' von '||content.updatevon AS content_aktualisiert, + ( + SELECT ARRAY_TO_STRING(array_agg(verwendung), '
') AS verwendung_in + FROM ( + SELECT + 'Infoscreen ID'||infoscreen_id AS art + FROM campus.tbl_infoscreen_content + WHERE content_id=content.content_id + + UNION + + SELECT + 'Software ID'||software_id AS art + FROM addon.tbl_software + WHERE content_id=content.content_id + + UNION + + SELECT + 'Ort '||ort_kurzbz AS art + FROM public.tbl_ort + WHERE content_id=content.content_id + + UNION + + SELECT + 'Service ID'||service_id AS art + FROM public.tbl_service + WHERE content_id=content.content_id + + UNION + + SELECT + 'Statistik '||statistik_kurzbz AS art + FROM public.tbl_statistik + WHERE content_id=content.content_id + + UNION + + SELECT + 'Gebiet '||tbl_gebiet.bezeichnung||' in Studiengang '||tbl_ablauf.studiengang_kz AS art + FROM testtool.tbl_ablauf_vorgaben + JOIN testtool.tbl_ablauf USING (ablauf_vorgaben_id) + JOIN testtool.tbl_gebiet USING (gebiet_id) + WHERE content_id=content.content_id + + UNION + + SELECT + 'Verlinkung von '||content_id AS art + FROM campus.tbl_contentsprache + WHERE content::text LIKE '%content.php?content_id='||content.content_id||'%' + /*WHERE content::text ~* '[\w\d\s]*content\.php\?content_id=1245[\w\d\s]*'*/ + ) verwendung + ) AS verwendung_in, + tbl_contentsprache.sprache, + tbl_contentsprache.version, + tbl_contentsprache.insertamum||' von '||tbl_contentsprache.insertvon AS contentsprache_eingefuegt, + tbl_contentsprache.updateamum||' von '||tbl_contentsprache.updatevon AS contentsprache_aktualisiert, + tbl_contentsprache.sichtbar +FROM campus.tbl_content content + JOIN campus.tbl_contentsprache USING (content_id) +WHERE version=campus.get_highest_content_version (content.content_id) +AND template_kurzbz NOT IN ('news') +/*ORDER BY content_id ASC, sprache DESC, version DESC +LIMIT 200*/"; + +if($db->db_query($qry)) +{ + while ($row = $db->db_fetch_object()) + { + echo ' + + + + + + + + + + + + + + + '; + } +} +echo '
Content IDTitelArtOEContent-AktivEingefügtAktualisiertVerwendet inSpracheVersionEingefügtAktualisiertVersion sichtbar
'.$row->content_id.''.$row->titel.''.$row->template_kurzbz.''.$row->oe_kurzbz.''.($row->aktiv == 't' ? 'Ja':'Nein').''.$row->content_eingefuegt.''.$row->content_aktualisiert.''.$row->verwendung_in.''.$row->sprache.''.$row->version.''.$row->contentsprache_eingefuegt.''.$row->contentsprache_aktualisiert.''.($row->sichtbar == 't' ? 'Ja':'Nein').'
'; +echo '
+ '; + + +?> \ No newline at end of file diff --git a/cms/dms.php b/cms/dms.php index 3b56a3a23..7e587b6ec 100644 --- a/cms/dms.php +++ b/cms/dms.php @@ -83,6 +83,7 @@ if($doc->isLocked($id)) if (CAMPUS_NAME == 'FH Technikum Wien') { $dokumente_arr[] .= 'ZgvBaPre'; + $dokumente_arr[] .= 'ZgvMaPre'; $dokumente_arr[] .= 'InvitLet'; } if ($person_id!=$akte_person || !in_array($akte_dokument_kurzbz, $dokumente_arr)) diff --git a/cms/news.php b/cms/news.php index 1f5d4a931..2686b19aa 100644 --- a/cms/news.php +++ b/cms/news.php @@ -436,11 +436,10 @@ function getStgContent($studiengang_kz, $semester, $sprache) if(CIS_EXT_MENU) { $xml.=' - t('global/lehrziele').']]> t('global/allgemeinerdownload').']]> - t('global/newsgroups').']]> kuerzel).']]> kurzbzlang).']]> + '; } diff --git a/composer.json b/composer.json index 5003468c2..036543dba 100644 --- a/composer.json +++ b/composer.json @@ -177,9 +177,9 @@ "type": "package", "package": { "name": "nicolaskruchten/pivottable", - "version": "2.15.0", + "version": "2.23.0", "dist": { - "url": "https://github.com/nicolaskruchten/pivottable/archive/v2.15.0.zip", + "url": "https://github.com/nicolaskruchten/pivottable/archive/v2.23.0.zip", "type": "zip" } } @@ -244,64 +244,70 @@ "require": { "php": ">=5.6.40", - "afarkas/html5shiv": "^3.7", - "alvaro-prieto/colResizable": "^1.6", + "afarkas/html5shiv": "3.7.*", - "borgar/textile-js": "2.0.4", - "BlackrockDigital/startbootstrap-sb-admin-2": "^3.3", - - "christianbach/tablesorter": "^1.0", + "chriskacerguis/codeigniter-restserver": "3.0.*", + "christianbach/tablesorter": "1.0.*", "codeigniter/framework": "3.*", - "components/jquery": "^3.2", - "components/jqueryui": "^1.12", - "components/font-awesome": "^4.7", - "components/angular.js": "1.3.16", + "components/jquery": "3.*", + "components/jqueryui": "1.*", + "components/font-awesome": "5.*", + "components/angular.js": "1.3.*", "easyrdf/easyrdf": "0.9.*", - "fgelinas/timepicker": "^0.3.3", "fzaninotto/faker": "1.*", - "joeldbirch/superfish": "^1.7", - "jquery/jqueryV1": "^1.12", - "jquery/jqueryV2": "^2.2", - "jquery/sizzle": "^1.0", - "jquery-archive/jquery-metadata": "^1.0", - "json-forms": "1.4.0", - "jsoneditor": "5.5.6", - "kingsquare/json-schema-form": "*", - "ludo/jquery-treetable": "^3.2", - - "moment/momentjs": "2.24.0", "michelf/php-markdown": "1.5.0", "ml/json-ld": "1.*", - "mottie/tablesorter": "^2.29", + "mottie/tablesorter": "2.*", - "nategood/httpful": "^0.2.20", - "netcarver/textile": "^3.5", - "nicolaskruchten/pivottable": "^2.15.0", + "nategood/httpful": "0.2.*", + "netcarver/textile": "3.7.*", - "olifolkerd/tabulator": "4.2.7", + "phpseclib/phpseclib": "2.0.*", - "phpseclib/phpseclib": "^2.0", + "tinymce/tinymce": "4.9.*", - "rmariuzzo/jquery-checkboxes": "1.0.7", - "rougin/combustor": "1.1.*", - "rougin/refinery": "*", - - "scottjehl/Respond": "^1.4", - - "tapmodo/Jcrop": "^2.0", - "tinymce/tinymce": "4.*", - "tomazdragar/SimpleCropper": "^1.0", - "twbs/bootstrap": "^3.3", + "twbs/bootstrap": "3.4.*", "zetacomponents/workflow": "1.*", "zetacomponents/document": "1.*", "zetacomponents/workflow-database-tiein": "1.*", - "zetacomponents/workflow-event-log-tiein": "1.*" + "zetacomponents/workflow-event-log-tiein": "1.*", + + + "alvaro-prieto/colResizable": "1.6", + + "BlackrockDigital/startbootstrap-sb-admin-2": "3.3.*", + "borgar/textile-js": "2.0.4", + + "fgelinas/timepicker": "0.3.3", + + "joeldbirch/superfish": "1.7.*", + "jquery/jqueryV1": "1.*", + "jquery/jqueryV2": "2.*", + "jquery/sizzle": "1.0.*", + "jquery-archive/jquery-metadata": "1.0.*", + "json-forms": "1.4.0", + "jsoneditor": "5.5.6", + + "ludo/jquery-treetable": "3.2.0", + + "moment/momentjs": "2.24.0", + + "nicolaskruchten/pivottable": "2.23.0", + + "olifolkerd/tabulator": "4.2.7", + + "rmariuzzo/jquery-checkboxes": "1.0.7", + + "scottjehl/Respond": "1.4.2", + + "tapmodo/Jcrop": "2.0.4", + "tomazdragar/SimpleCropper": "1.0" }, "config": { "bin-dir": "vendor/bin" diff --git a/composer.lock b/composer.lock index 85e506cc4..10282a10a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "e3de1eee238160400fb63f68735b4144", - "content-hash": "5b71e8a3c356d52e43d788eb6f018151", + "hash": "5fa45f7d529152ca14fc108e2454033f", + "content-hash": "c95c49b4e8106a5aa05a11720c0f6f72", "packages": [ { "name": "BlackrockDigital/startbootstrap-sb-admin-2", @@ -71,6 +71,45 @@ }, "type": "library" }, + { + "name": "chriskacerguis/codeigniter-restserver", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/chriskacerguis/codeigniter-restserver.git", + "reference": "3a5ba0dffdebd24cc215ef714b72208c88304203" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/chriskacerguis/codeigniter-restserver/zipball/3a5ba0dffdebd24cc215ef714b72208c88304203", + "reference": "3a5ba0dffdebd24cc215ef714b72208c88304203", + "shasum": "" + }, + "require": { + "codeigniter/framework": "^3.0.4", + "php": ">=5.4.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "application/libraries/Format.php", + "application/libraries/REST_Controller.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Kacerguis", + "role": "Developer" + } + ], + "description": "REST Server for the CodeIgniter framework", + "homepage": "https://github.com/chriskacerguis/codeigniter-restserver", + "time": "2017-09-23 16:44:55" + }, { "name": "christianbach/tablesorter", "version": "1.0.1", @@ -91,16 +130,16 @@ }, { "name": "codeigniter/framework", - "version": "3.1.10", + "version": "3.1.11", "source": { "type": "git", "url": "https://github.com/bcit-ci/CodeIgniter.git", - "reference": "c576995304fc3609cca0b7b92d1b2cd611ec82f5" + "reference": "b73eb19aed66190c10c9cad476da7c36c271d6dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bcit-ci/CodeIgniter/zipball/c576995304fc3609cca0b7b92d1b2cd611ec82f5", - "reference": "c576995304fc3609cca0b7b92d1b2cd611ec82f5", + "url": "https://api.github.com/repos/bcit-ci/CodeIgniter/zipball/b73eb19aed66190c10c9cad476da7c36c271d6dc", + "reference": "b73eb19aed66190c10c9cad476da7c36c271d6dc", "shasum": "" }, "require": { @@ -120,7 +159,7 @@ ], "description": "The CodeIgniter framework", "homepage": "https://codeigniter.com", - "time": "2019-01-16 15:49:35" + "time": "2019-09-19 12:08:45" }, { "name": "components/angular.js", @@ -428,51 +467,51 @@ }, { "name": "components/font-awesome", - "version": "4.7.0", + "version": "5.12.0", "source": { "type": "git", "url": "https://github.com/components/font-awesome.git", - "reference": "885308b939369d147bec93174722786bc2c4eedd" + "reference": "d8646ec635a00b06cc219b7dffed3418444975cc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/components/font-awesome/zipball/885308b939369d147bec93174722786bc2c4eedd", - "reference": "885308b939369d147bec93174722786bc2c4eedd", + "url": "https://api.github.com/repos/components/font-awesome/zipball/d8646ec635a00b06cc219b7dffed3418444975cc", + "reference": "d8646ec635a00b06cc219b7dffed3418444975cc", "shasum": "" }, "type": "component", "extra": { "component": { "styles": [ - "css/font-awesome.css" + "css/all.css" ], "files": [ - "css/font-awesome.min.css", - "css/font-awesome.css.map", - "fonts/*" + "css/all.min.css", + "webfonts/*" ] } }, "notification-url": "https://packagist.org/downloads/", "license": [ + "CC-BY-4.0", "MIT", "OFL-1.1" ], - "description": "The iconic font designed for use with Twitter Bootstrap.", - "time": "2016-10-25 10:56:23" + "description": "Font Awesome, the iconic SVG, font, and CSS framework.", + "time": "2020-01-08 10:17:47" }, { "name": "components/jquery", - "version": "3.3.1", + "version": "3.4.1", "source": { "type": "git", "url": "https://github.com/components/jquery.git", - "reference": "459648cda77875519c5da3ae1dd0ed5d170aa649" + "reference": "901828b7968b18319e377dc23d466f28426ee083" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/components/jquery/zipball/459648cda77875519c5da3ae1dd0ed5d170aa649", - "reference": "459648cda77875519c5da3ae1dd0ed5d170aa649", + "url": "https://api.github.com/repos/components/jquery/zipball/901828b7968b18319e377dc23d466f28426ee083", + "reference": "901828b7968b18319e377dc23d466f28426ee083", "shasum": "" }, "type": "component", @@ -501,7 +540,7 @@ ], "description": "jQuery JavaScript Library", "homepage": "http://jquery.com", - "time": "2018-03-04 13:23:48" + "time": "2019-10-23 05:15:13" }, { "name": "components/jqueryui", @@ -662,16 +701,16 @@ }, { "name": "fzaninotto/faker", - "version": "v1.8.0", + "version": "v1.9.1", "source": { "type": "git", "url": "https://github.com/fzaninotto/Faker.git", - "reference": "f72816b43e74063c8b10357394b6bba8cb1c10de" + "reference": "fc10d778e4b84d5bd315dad194661e091d307c6f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/f72816b43e74063c8b10357394b6bba8cb1c10de", - "reference": "f72816b43e74063c8b10357394b6bba8cb1c10de", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/fc10d778e4b84d5bd315dad194661e091d307c6f", + "reference": "fc10d778e4b84d5bd315dad194661e091d307c6f", "shasum": "" }, "require": { @@ -680,12 +719,12 @@ "require-dev": { "ext-intl": "*", "phpunit/phpunit": "^4.8.35 || ^5.7", - "squizlabs/php_codesniffer": "^1.5" + "squizlabs/php_codesniffer": "^2.9.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8-dev" + "dev-master": "1.9-dev" } }, "autoload": { @@ -708,7 +747,7 @@ "faker", "fixtures" ], - "time": "2018-07-12 10:23:15" + "time": "2019-12-12 13:22:17" }, { "name": "joeldbirch/superfish", @@ -852,57 +891,6 @@ ], "time": "2014-08-25 02:48:14" }, - { - "name": "kevinlebrun/colors.php", - "version": "1.0.3", - "source": { - "type": "git", - "url": "https://github.com/kevinlebrun/colors.php.git", - "reference": "cdda5eee41314b87cd5a8bb91b1ffc7c0210e673" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/kevinlebrun/colors.php/zipball/cdda5eee41314b87cd5a8bb91b1ffc7c0210e673", - "reference": "cdda5eee41314b87cd5a8bb91b1ffc7c0210e673", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*", - "satooshi/php-coveralls": "1.0.*", - "squizlabs/php_codesniffer": "1.*" - }, - "type": "library", - "autoload": { - "psr-0": { - "Colors": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kevin Le Brun", - "email": "lebrun.k@gmail.com", - "homepage": "http://kevinlebrun.fr", - "role": "developer" - } - ], - "description": "Colors for PHP CLI scripts", - "homepage": "https://github.com/kevinlebrun/colors.php", - "keywords": [ - "cli", - "color", - "colors", - "console", - "shell" - ], - "time": "2018-05-30 08:34:23" - }, { "name": "kingsquare/json-schema-form", "version": "0.6", @@ -1108,16 +1096,16 @@ }, { "name": "mottie/tablesorter", - "version": "v2.31.1", + "version": "v2.31.2", "source": { "type": "git", "url": "https://github.com/Mottie/tablesorter.git", - "reference": "fa56764ad5630ed3ab9da4a30fdb8dd34bfbaf1f" + "reference": "6a32e5acc294be5b6c420c83d70d66e096533d8f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Mottie/tablesorter/zipball/fa56764ad5630ed3ab9da4a30fdb8dd34bfbaf1f", - "reference": "fa56764ad5630ed3ab9da4a30fdb8dd34bfbaf1f", + "url": "https://api.github.com/repos/Mottie/tablesorter/zipball/6a32e5acc294be5b6c420c83d70d66e096533d8f", + "reference": "6a32e5acc294be5b6c420c83d70d66e096533d8f", "shasum": "" }, "require": { @@ -1138,11 +1126,11 @@ ], "authors": [ { - "name": "Rob Garrison", - "email": "wowmotty@gmail.com" + "name": "Christian Bach" }, { - "name": "Christian Bach" + "name": "Rob Garrison", + "email": "wowmotty@gmail.com" } ], "description": "tablesorter (FORK) is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell.", @@ -1155,7 +1143,7 @@ "sorting", "table" ], - "time": "2018-11-20 21:54:28" + "time": "2019-12-01 13:49:52" }, { "name": "nategood/httpful", @@ -1209,16 +1197,16 @@ }, { "name": "netcarver/textile", - "version": "v3.7.2", + "version": "v3.7.6", "source": { "type": "git", "url": "https://github.com/textile/php-textile.git", - "reference": "c24d68d9f4d099f9c2434e71024f2a6140dc1594" + "reference": "1846fd5aeace2a0dd57c4f770f693d12bcd7fa26" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/textile/php-textile/zipball/c24d68d9f4d099f9c2434e71024f2a6140dc1594", - "reference": "c24d68d9f4d099f9c2434e71024f2a6140dc1594", + "url": "https://api.github.com/repos/textile/php-textile/zipball/1846fd5aeace2a0dd57c4f770f693d12bcd7fa26", + "reference": "1846fd5aeace2a0dd57c4f770f693d12bcd7fa26", "shasum": "" }, "require": { @@ -1258,14 +1246,14 @@ "plaintext", "textile" ], - "time": "2019-06-08 17:57:17" + "time": "2020-01-08 21:13:37" }, { "name": "nicolaskruchten/pivottable", - "version": "2.15.0", + "version": "2.23.0", "dist": { "type": "zip", - "url": "https://github.com/nicolaskruchten/pivottable/archive/v2.15.0.zip", + "url": "https://github.com/nicolaskruchten/pivottable/archive/v2.23.0.zip", "reference": null, "shasum": null }, @@ -1284,16 +1272,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "2.0.18", + "version": "2.0.23", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "60519001db8d791215a822efd366d24cafee9e63" + "reference": "c78eb5058d5bb1a183133c36d4ba5b6675dfa099" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/60519001db8d791215a822efd366d24cafee9e63", - "reference": "60519001db8d791215a822efd366d24cafee9e63", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/c78eb5058d5bb1a183133c36d4ba5b6675dfa099", + "reference": "c78eb5058d5bb1a183133c36d4ba5b6675dfa099", "shasum": "" }, "require": { @@ -1372,115 +1360,7 @@ "x.509", "x509" ], - "time": "2019-06-13 06:15:54" - }, - { - "name": "psr/log", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", - "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2018-11-20 15:27:04" - }, - { - "name": "rdlowrey/auryn", - "version": "v1.4.2", - "source": { - "type": "git", - "url": "https://github.com/rdlowrey/auryn.git", - "reference": "8c4dc07943599ba84f4f89eab8cf43efeef80395" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/rdlowrey/auryn/zipball/8c4dc07943599ba84f4f89eab8cf43efeef80395", - "reference": "8c4dc07943599ba84f4f89eab8cf43efeef80395", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "athletic/athletic": "~0.1", - "fabpot/php-cs-fixer": "~1.9", - "phpunit/phpunit": "^4.7" - }, - "type": "library", - "autoload": { - "psr-4": { - "Auryn\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Dan Ackroyd", - "email": "Danack@basereality.com", - "homepage": "http://www.basereality.com", - "role": "Developer" - }, - { - "name": "Levi Morrison", - "email": "levim@php.net", - "homepage": "http://morrisonlevi.github.com/", - "role": "Developer" - }, - { - "name": "Daniel Lowrey", - "email": "rdlowrey@gmail.com", - "homepage": "https://github.com/rdlowrey", - "role": "Creator / Main Developer" - } - ], - "description": "Auryn is a dependency injector for bootstrapping object-oriented PHP applications.", - "homepage": "https://github.com/rdlowrey/auryn", - "keywords": [ - "dependency injection", - "dic", - "ioc" - ], - "time": "2017-05-15 06:26:46" + "time": "2019-09-17 03:41:22" }, { "name": "rmariuzzo/jquery-checkboxes", @@ -1493,299 +1373,6 @@ }, "type": "library" }, - { - "name": "rougin/blueprint", - "version": "v0.1.5", - "source": { - "type": "git", - "url": "https://github.com/rougin/blueprint.git", - "reference": "979dac046fb5d251dea6e8140b85463c7928a5e2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/rougin/blueprint/zipball/979dac046fb5d251dea6e8140b85463c7928a5e2", - "reference": "979dac046fb5d251dea6e8140b85463c7928a5e2", - "shasum": "" - }, - "require": { - "kevinlebrun/colors.php": "^1.0", - "php": ">=5.3.0", - "rdlowrey/auryn": "^1.0", - "symfony/console": "^2.7", - "symfony/yaml": "^2.7", - "twig/twig": "^1.19" - }, - "require-dev": { - "phpunit/phpunit": "4.*", - "scrutinizer/ocular": "~1.1" - }, - "bin": [ - "bin/blueprint", - "bin/blueprint.php" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.2-dev" - } - }, - "autoload": { - "psr-4": { - "Rougin\\Blueprint\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "description": "A tool for generating files for your PHP projects", - "keywords": [ - "blueprint", - "generator", - "php", - "template" - ], - "time": "2016-02-01 16:31:13" - }, - { - "name": "rougin/combustor", - "version": "v1.1.4", - "source": { - "type": "git", - "url": "https://github.com/rougin/combustor.git", - "reference": "ed775e2e1738b7682f2ca9e8ab6f968a7c8507dd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/rougin/combustor/zipball/ed775e2e1738b7682f2ca9e8ab6f968a7c8507dd", - "reference": "ed775e2e1738b7682f2ca9e8ab6f968a7c8507dd", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "rougin/blueprint": "0.1.*", - "rougin/describe": "1.2.*", - "rougin/spark-plug": "0.2.*" - }, - "require-dev": { - "phpunit/phpunit": "4.*", - "scrutinizer/ocular": "~1.1" - }, - "suggest": { - "rougin/codeigniter": "Yet another way to install CodeIgniter via Composer", - "rougin/refinery": "A command line interface for Migrations Class in CodeIgniter" - }, - "bin": [ - "bin/combustor", - "bin/combustor.php" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, - "autoload": { - "psr-4": { - "Rougin\\Combustor\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Rougin Royce Gutib", - "email": "rougingutib@gmail.com", - "homepage": "http://rougin.github.io", - "role": "Developer" - } - ], - "description": "A tool for speeding up workflow in CodeIgniter", - "homepage": "https://github.com/rougin/combustor", - "keywords": [ - "codeigniter", - "combustor", - "generator", - "php" - ], - "time": "2016-02-14 10:36:58" - }, - { - "name": "rougin/describe", - "version": "v1.2.2", - "source": { - "type": "git", - "url": "https://github.com/rougin/describe.git", - "reference": "bd6b934d3ab2b28ddc936a5eb0cafa2eed02e360" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/rougin/describe/zipball/bd6b934d3ab2b28ddc936a5eb0cafa2eed02e360", - "reference": "bd6b934d3ab2b28ddc936a5eb0cafa2eed02e360", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "4.*", - "scrutinizer/ocular": "~1.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.5-dev" - } - }, - "autoload": { - "psr-4": { - "Rougin\\Describe\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Rougin Royce Gutib", - "email": "rougingutib@gmail.com", - "homepage": "http://rougin.github.io", - "role": "Developer" - } - ], - "description": "Get the information about the database you're working on in PHP", - "homepage": "https://github.com/rougin/describe", - "keywords": [ - "database", - "describe", - "php" - ], - "time": "2016-03-24 18:17:47" - }, - { - "name": "rougin/refinery", - "version": "v0.1.6", - "source": { - "type": "git", - "url": "https://github.com/rougin/refinery.git", - "reference": "d32a49dfb61072dcf9619b181de9d9c762e6e26c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/rougin/refinery/zipball/d32a49dfb61072dcf9619b181de9d9c762e6e26c", - "reference": "d32a49dfb61072dcf9619b181de9d9c762e6e26c", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "rougin/blueprint": "0.1.*", - "rougin/describe": "1.2.*", - "rougin/spark-plug": "0.2.*" - }, - "require-dev": { - "phpunit/phpunit": "4.*", - "scrutinizer/ocular": "~1.1" - }, - "suggest": { - "rougin/codeigniter": "Yet another way to install CodeIgniter via Composer", - "rougin/combustor": "A tool for speeding up web development in CodeIgniter" - }, - "bin": [ - "bin/refinery", - "bin/refinery.php" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.2-dev" - } - }, - "autoload": { - "psr-4": { - "Rougin\\Refinery\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Rougin Royce Gutib", - "email": "rougingutib@gmail.com", - "homepage": "http://rougin.github.io", - "role": "Developer" - } - ], - "description": "'Ready-to-eat' migrations for Codeigniter", - "homepage": "https://github.com/rougin/refinery", - "keywords": [ - "database", - "migrations", - "php", - "refinery" - ], - "time": "2016-03-04 16:55:32" - }, - { - "name": "rougin/spark-plug", - "version": "v0.2.0", - "source": { - "type": "git", - "url": "https://github.com/rougin/spark-plug.git", - "reference": "71b7bafacf2854d4dc296cfdf354a6cf54417f9b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/rougin/spark-plug/zipball/71b7bafacf2854d4dc296cfdf354a6cf54417f9b", - "reference": "71b7bafacf2854d4dc296cfdf354a6cf54417f9b", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "4.*", - "scrutinizer/ocular": "~1.1" - }, - "suggest": { - "rougin/codeigniter": "Yet another way to install CodeIgniter via Composer", - "rougin/combustor": "A tool for speeding up web development in CodeIgniter", - "rougin/refinery": "A command line interface for Migrations Class in CodeIgniter" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.3-dev" - } - }, - "autoload": { - "psr-4": { - "Rougin\\SparkPlug\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Rougin Royce Gutib", - "email": "rougingutib@gmail.com", - "homepage": "http://rougin.github.io", - "role": "Developer" - } - ], - "description": "Yet another way to access CodeIgniter's instance", - "homepage": "https://github.com/rougin/spark-plug", - "keywords": [ - "codeigniter", - "instance", - "php", - "spark-plug" - ], - "time": "2015-10-23 08:27:10" - }, { "name": "scottjehl/Respond", "version": "1.4.2", @@ -1797,136 +1384,18 @@ }, "type": "library" }, - { - "name": "symfony/console", - "version": "v2.8.50", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12", - "reference": "cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/debug": "^2.7.2|~3.0.0", - "symfony/polyfill-mbstring": "~1.0" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1|~3.0.0", - "symfony/process": "~2.1|~3.0.0" - }, - "suggest": { - "psr/log-implementation": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Console Component", - "homepage": "https://symfony.com", - "time": "2018-11-20 15:55:20" - }, - { - "name": "symfony/debug", - "version": "v3.0.9", - "source": { - "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "697c527acd9ea1b2d3efac34d9806bf255278b0a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/697c527acd9ea1b2d3efac34d9806bf255278b0a", - "reference": "697c527acd9ea1b2d3efac34d9806bf255278b0a", - "shasum": "" - }, - "require": { - "php": ">=5.5.9", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/class-loader": "~2.8|~3.0", - "symfony/http-kernel": "~2.8|~3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Debug Component", - "homepage": "https://symfony.com", - "time": "2016-07-30 07:22:48" - }, { "name": "symfony/polyfill-ctype", - "version": "v1.11.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "82ebae02209c21113908c229e9883c419720738a" + "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", - "reference": "82ebae02209c21113908c229e9883c419720738a", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", + "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", "shasum": "" }, "require": { @@ -1938,7 +1407,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -1954,13 +1423,13 @@ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - }, { "name": "Gert de Pagter", "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony polyfill for ctype functions", @@ -1971,116 +1440,7 @@ "polyfill", "portable" ], - "time": "2019-02-06 07:57:58" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.11.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.11-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "time": "2019-02-06 07:57:58" - }, - { - "name": "symfony/yaml", - "version": "v2.8.50", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "02c1859112aa779d9ab394ae4f3381911d84052b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/02c1859112aa779d9ab394ae4f3381911d84052b", - "reference": "02c1859112aa779d9ab394ae4f3381911d84052b", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/polyfill-ctype": "~1.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2018-11-11 11:18:13" + "time": "2019-11-27 13:56:44" }, { "name": "tapmodo/Jcrop", @@ -2095,16 +1455,16 @@ }, { "name": "tinymce/tinymce", - "version": "4.9.4", + "version": "4.9.7", "source": { "type": "git", "url": "https://github.com/tinymce/tinymce-dist.git", - "reference": "3a997f24eb54d890b1c88f22cff03092e0b73378" + "reference": "e14935a4ba07beb716ccdb192ee9823dbb4a73d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tinymce/tinymce-dist/zipball/3a997f24eb54d890b1c88f22cff03092e0b73378", - "reference": "3a997f24eb54d890b1c88f22cff03092e0b73378", + "url": "https://api.github.com/repos/tinymce/tinymce-dist/zipball/e14935a4ba07beb716ccdb192ee9823dbb4a73d5", + "reference": "e14935a4ba07beb716ccdb192ee9823dbb4a73d5", "shasum": "" }, "type": "component", @@ -2137,7 +1497,7 @@ "tinymce", "wysiwyg" ], - "time": "2019-03-20 13:56:58" + "time": "2019-12-19 06:05:16" }, { "name": "tomazdragar/SimpleCropper", @@ -2202,26 +1562,26 @@ }, { "name": "twig/twig", - "version": "v1.42.2", + "version": "v1.42.4", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "21707d6ebd05476854805e4f91b836531941bcd4" + "reference": "e587180584c3d2d6cb864a0454e777bb6dcb6152" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/21707d6ebd05476854805e4f91b836531941bcd4", - "reference": "21707d6ebd05476854805e4f91b836531941bcd4", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/e587180584c3d2d6cb864a0454e777bb6dcb6152", + "reference": "e587180584c3d2d6cb864a0454e777bb6dcb6152", "shasum": "" }, "require": { - "php": ">=5.4.0", + "php": ">=5.5.0", "symfony/polyfill-ctype": "^1.8" }, "require-dev": { "psr/container": "^1.0", - "symfony/debug": "^2.7", - "symfony/phpunit-bridge": "^3.4.19|^4.1.8|^5.0" + "symfony/debug": "^3.4|^4.2", + "symfony/phpunit-bridge": "^4.4@dev|^5.0" }, "type": "library", "extra": { @@ -2248,15 +1608,15 @@ "homepage": "http://fabien.potencier.org", "role": "Lead Developer" }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" - }, { "name": "Twig Team", "homepage": "https://twig.symfony.com/contributors", "role": "Contributors" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" } ], "description": "Twig, the flexible, fast, and secure template language for PHP", @@ -2264,7 +1624,7 @@ "keywords": [ "templating" ], - "time": "2019-06-18 15:35:16" + "time": "2019-11-11 16:49:32" }, { "name": "zetacomponents/base", diff --git a/config/cis.config-default.inc.php b/config/cis.config-default.inc.php index 3f75b0af3..64fcb9a7c 100644 --- a/config/cis.config-default.inc.php +++ b/config/cis.config-default.inc.php @@ -216,6 +216,8 @@ define('CIS_DOKUMENTE_SELFSERVICE', true); //**** INFOSCREEN **** //Gibt an, ob der Lageplan im Infoterminal angezeigt werden soll. define('CIS_INFOSCREEN_LAGEPLAN_ANZEIGEN',true); +//Gibt an, ob News im Infoterminal angezeigt werden soll. +define('CIS_INFOSCREEN_NEWS_ANZEIGEN',false); //User, welcher für das Anlegen von Anrechnungen bei der Prüfungsanmeldung verwendet wird define('CIS_PRUEFUNGSANMELDUNG_USER','p.pruefungsanmeldung'); @@ -234,6 +236,9 @@ define('CIS_PRUEFUNGSANMELDUNG_ANRECHNUNG', true); //Gibt an, ob der Bereich zur Anmeldung zu Pruefungen des gesamten Studiengangs angezeigt werden soll define('CIS_PRUEFUNGSANMELDUNG_LEHRVERANSTALTUNGEN_AUS_STUDIENGANG', true); +//Gibt an, ob mehrere Pruefungen zur selben Zeit im selben Raum stattfinden duerfen +define('CIS_PRUEFUNGSANMELDUNG_ERLAUBE_TERMINKOLLISION', true); + //Gibt an, wie viele Semester aus der Vergangenheit unter Meine LV angezeigt werden define('CIS_MEINELV_ANZAHL_SEMESTER_PAST', 3); @@ -245,4 +250,8 @@ define('CIS_LVMENUE_CUTLENGTH', 21); // Gibt an, auf welche Seite TicketIds ala #1234 im Jahresplan verlinkt werden zB zur Verlinkung in Bugtracker define('JAHRESPLAN_TICKET_LINK','https://bug.technikum-wien.at/otrs/index.pl?Action=AgentTicketZoom;TicketNumber='); + +//Gibt an ob der Block zu Verplanung in geteilter Arbeitszeit bei den Zeitwünschen angezeigt wird. Default: false +define('CIS_ZEITWUNSCH_GD', false); + ?> diff --git a/config/global.config-default.inc.php b/config/global.config-default.inc.php index 1386a6199..308058fba 100644 --- a/config/global.config-default.inc.php +++ b/config/global.config-default.inc.php @@ -9,6 +9,9 @@ define('DEFAULT_LEHREINHEIT_LEHRFORM','UE'); // Defaul Trennzeichen fuer E-Mail Empfaenger wenn nicht ueber Variablen ueberschrieben define('DEFAULT_EMAILADRESSENTRENNZEICHEN',','); +// Gibt an ob neue Mitarbeiter per default fixangestellt sind oder nicht +define('DEFAULT_MITARBEITER_FIXANGESTELLT', true); + //Anzeigeoptionen für Lehrveranstaltungen im CIS define('CIS_LEHRVERANSTALTUNG_NEWSGROUPS_ANZEIGEN',true); define('CIS_LEHRVERANSTALTUNG_FEEDBACK_ANZEIGEN',true); @@ -96,6 +99,9 @@ define('FAS_GESAMTNOTE_PRUEFUNGSHONORAR',false); // Aus Datenschutzgründen ist dies per default deaktiviert define('CIS_GESAMTNOTE_FREIGABEMAIL_NOTE', false); +// Gibt an ob in der Notenliste der Studierenden nur offizielle Noten oder alle angezeigt werden +define('CIS_NOTENLISTE_OFFIZIELL_ANZEIGEN', false); + // Grenzwerte für Anwesenheit define('FAS_ANWESENHEIT_ROT', 70); define('FAS_ANWESENHEIT_GELB', 90); @@ -120,12 +126,19 @@ define('FAS_UDF', true); // Legt fest ob Aufnahmegruppen bei Reihungstests verwaltet werden true|false define('FAS_REIHUNGSTEST_AUFNAHMEGRUPPEN',false); +// Legt fest, ob Vertragsdetails zum Lehrauftrag im Reiter LektorInnenzuteilung angezeigt werden +define('FAS_LV_LEKTORINNENZUTEILUNG_VERTRAGSDETAILS_ANZEIGEN', false); + +// Legt fest, ob Vertragsdetails zum Projektauftrag im Reiter Projektarbeit angezeigt werden +define('FAS_STUDIERENDE_PROJEKTARBEIT_VERTRAGSDETAILS_ANZEIGEN', false); + // Anzeigeoptionen für LV-Plan Menü define('CIS_LVPLAN_EXPORT_ANZEIGEN',true); define('CIS_LVPLAN_PERSONENAUSWAHL_ANZEIGEN',true); define('CIS_LVPLAN_LEHRVERBANDAUSWAHL_ANZEIGEN',true); define('CIS_LVPLAN_ARCHIVAUSWAHL_ANZEIGEN',true); define('CIS_LVPLAN_ZUSATZMENUE_ANZEIGEN',true); +define('CIS_LVPLAN_SAALPLAN_ANZEIGEN',true); //Anmerkung bei Unterrichtseinheiten im LV-Plan anzeigen. Anmerkungen bei LV-Plan Sync mitkopieren. define('LVPLAN_ANMERKUNG_ANZEIGEN',true); @@ -192,6 +205,9 @@ define('SET_UID_AS_PERSONENKENNZEICHEN',false); // Legt fest ob fuer Studierende eine Alias EMail Adresse generiert wird (true|false) define('GENERATE_ALIAS_STUDENT',true); +// gibt an ob beim Anlegen von Mitarbeitern ein Alias generiert wird. +define('GENERATE_ALIAS_MITARBEITERIN',true); + // Wie viele Tage nach Semesterstart soll bei der Neuanlage von Studierenden noch das aktuelle Semester vorgeschlagen werden. define('VILESCI_PERSON_NEU_STUDIENSEMESTER_UEBERGANGSFRIST',30); @@ -241,7 +257,7 @@ define('LOG_CONTENT', false); // ContentID of default content-template for reports. New contents will be childs of this. define('REPORT_CONTENT_TEMPLATE', ''); -// Schwund in %, der bei Arbeitsplätzen herausgerechnet werden soll. +// Schwund in %, der bei Arbeitsplätzen herausgerechnet werden soll. // zB 5. Dann werden bei 20 Plätzen 5% Schwund herausgerechnet und nur 19 Plätze zurückgegeben define('REIHUNGSTEST_ARBEITSPLAETZE_SCHWUND', 0); @@ -255,8 +271,4 @@ define('STATUSGRUND_ID_EINSTIEG_SOMMERSEMESTER', null); // Studiengangs_kz des Studiengangs "Qualifikationskurse". Der Studiengang hat eine Sonderstellung zB für das Bewerbungstool. define('STUDIENGANG_KZ_QUALIFIKATIONKURSE', null); - -// EinsteigerInnen ins Sommersemester werden mit einem Statusgrund versehen. -// Die ID dieses Statusgrundes kann hier eingegeben werden. Es wird zB vom Infocenter-Tool gesetzt und im Bewerbungstool abgefragt -define('STATUSGRUND_ID_EINSTIEG_SOMMERSEMESTER', null); ?> diff --git a/content/akteupload.php b/content/akteupload.php index d29be6670..f8c459845 100644 --- a/content/akteupload.php +++ b/content/akteupload.php @@ -168,7 +168,7 @@ if(isset($_POST['submitbild'])) if(isset($_GET['person_id'])) { $dokument = new dokument(); - $dokument->getAllDokumente('Zeugnis'); + $dokument->getAllDokumente('Zeugnis,DiplSupp,Bescheid'); echo " diff --git a/content/dragboard.js.php b/content/dragboard.js.php index 18a8d6186..2a96e0cda 100644 --- a/content/dragboard.js.php +++ b/content/dragboard.js.php @@ -116,7 +116,7 @@ var studentDDObserver= uid = tree.view.getCellText(v,col); if(uid=='') { - alert('Es koennen nur Personen mit UID (Studenten/Mitarbeiter) verschoben werden'); + alert('Es koennen nur Personen mit UID (Studierende/Mitarbeitende) verschoben werden'); return false; } paramList += ';'+uid; @@ -295,7 +295,7 @@ var LektorFunktionDDObserver= if(stg=='') { - alert('Mitarbeiter kann nur auf einen Studiengang gezogen werden'); + alert('MitarbeiterIn kann nur auf einen Studiengang gezogen werden'); return false; } diff --git a/content/fas.xul.php b/content/fas.xul.php index 85deaa818..2aecae047 100644 --- a/content/fas.xul.php +++ b/content/fas.xul.php @@ -110,7 +110,7 @@ foreach($addon_obj->result as $addon) - + @@ -377,14 +377,14 @@ foreach($addon_obj->result as $addon) label = "&menu-statistic-notenspiegel.label;" command = "menu-statistic-notenspiegel:command" accesskey = "&menu-statistic-notenspiegel.accesskey;"/> - + diff --git a/content/fasoverlay.js.php b/content/fasoverlay.js.php index 2fafb5ea8..84e9033fa 100644 --- a/content/fasoverlay.js.php +++ b/content/fasoverlay.js.php @@ -103,24 +103,24 @@ var LektorTreeListener = function LektorTreeSelectMitarbeiter() { var tree=document.getElementById('tree-lektor'); - var items = tree.view.rowCount; //Anzahl der Zeilen ermitteln - if(LektorTreeOpenStudiengang!=null) + if (tree.view != null) { - for(var i=0;icontent/statistik/notenspiegel_erweitert.php?studiengang_kz='+studiengang_kz+'&semester='+semester+'&typ='+typ+'&orgform='+orgform,'Notenspiegel'); } -function StatistikPrintNotenspiegelStudent() +function StatistikPrintStudienverlaufStudent() { var tree = document.getElementById('student-tree'); var data=''; //Wenn nichts markiert wurde -> alle exportieren if(tree.currentIndex==-1) { - alert("Bitte zuerst einen Studenten markieren"); + alert("Bitte zuerst eine/n Studierende/n markieren"); return; } var student_uid = getTreeCellText(tree, 'student-treecol-uid', tree.currentIndex); if (student_uid == '') { - alert('Markierte Person ist kein Student'); + alert('Markierte Person ist kein/e StudentIn'); return; } - window.open('index.ci.php/person/gradelist/index/'+student_uid,'Notenspiegel'); + window.open('index.ci.php/person/gradelist/index/'+student_uid,'Studienverlauf'); } // **** @@ -1523,7 +1573,7 @@ function OpenAboutDialog() // **** function OpenManual() { - window.open('http://fhcomplete.technikum-wien.at/dokuwiki/doku.php?','_blank'); + window.open('https://wiki.fhcomplete.org/doku.php?','_blank'); } // **** @@ -1843,7 +1893,7 @@ function PrintStudienblatt(event) } catch(e) { - check = confirm('Achtung: Beim letzten (aktuellen) PreStudent-Status ist KEIN STUDIENPLAN eingetragen.\nDas Studienblatt ist moeglicherweise unvollstaendig.\nMoechten Sie es dennoch erstellen?'); + check = confirm('Achtung: Beim letzten (aktuellen) PreStudentInnen-Status ist KEIN STUDIENPLAN eingetragen.\nDas Studienblatt ist moeglicherweise unvollstaendig.\nMoechten Sie es dennoch erstellen?'); if (check == false) return false; } @@ -1856,7 +1906,7 @@ function PrintStudienblatt(event) if(studienplan_id=='') { - check = confirm('Achtung: Beim letzten (aktuellen) PreStudent-Status ist KEIN STUDIENPLAN eingetragen.\nDas Studienblatt ist moeglicherweise unvollstaendig.\nMoechten Sie es dennoch erstellen?'); + check = confirm('Achtung: Beim letzten (aktuellen) PreStudentInnen-Status ist KEIN STUDIENPLAN eingetragen.\nDas Studienblatt ist moeglicherweise unvollstaendig.\nMoechten Sie es dennoch erstellen?'); if (check == false) return false; } @@ -1919,7 +1969,7 @@ function PrintStudienblatt(event) } else { - alert('Bitte zuerst einen Studenten auswaehlen'); + alert('Bitte zuerst eine/n Studierende/n auswaehlen'); } } @@ -1951,7 +2001,7 @@ function PrintStudienblattEnglisch(event) } catch(e) { - check = confirm('Achtung: Beim letzten (aktuellen) PreStudent-Status ist KEIN STUDIENPLAN eingetragen.\nDas Studienblatt ist moeglicherweise unvollstaendig.\nMoechten Sie es dennoch erstellen?'); + check = confirm('Achtung: Beim letzten (aktuellen) PreStudentInnen-Status ist KEIN STUDIENPLAN eingetragen.\nDas Studienblatt ist moeglicherweise unvollstaendig.\nMoechten Sie es dennoch erstellen?'); if (check == false) return false; } @@ -1965,7 +2015,7 @@ function PrintStudienblattEnglisch(event) if(studienplan_id=='') { - check = confirm('Achtung: Beim letzten (aktuellen) PreStudent-Status ist KEIN STUDIENPLAN eingetragen.\nDas Studienblatt ist moeglicherweise unvollstaendig.\nMoechten Sie es dennoch erstellen?'); + check = confirm('Achtung: Beim letzten (aktuellen) PreStudentInnen-Status ist KEIN STUDIENPLAN eingetragen.\nDas Studienblatt ist moeglicherweise unvollstaendig.\nMoechten Sie es dennoch erstellen?'); if (check == false) return false; } @@ -2028,7 +2078,7 @@ function PrintStudienblattEnglisch(event) } else { - alert('Bitte zuerst einen Studenten auswaehlen'); + alert('Bitte zuerst eine/n Studierende/n auswaehlen'); } } diff --git a/content/fasoverlay.xul.php b/content/fasoverlay.xul.php index 88559cb10..51564dc19 100644 --- a/content/fasoverlay.xul.php +++ b/content/fasoverlay.xul.php @@ -228,13 +228,13 @@ echo ' - + - + diff --git a/content/funktionen.xul.php b/content/funktionen.xul.php index 0f487370a..9bbe10686 100644 --- a/content/funktionen.xul.php +++ b/content/funktionen.xul.php @@ -101,7 +101,7 @@ else class="sortDirectionIndicator" sort="rdf:http://www.technikum-wien.at/bnfunktion/rdf#uid"/> -
- + - - + + + + + + + + + + + + - - - - - + + + + + + @@ -362,7 +362,7 @@ echo ''; - + @@ -486,7 +486,7 @@ echo ''; - @@ -515,6 +515,10 @@ echo ''; sort="rdf:http://www.technikum-wien.at/prestudentrolle/rdf#ausbildungssemester" sorthints="integer"/> + @@ -126,17 +133,16 @@ echo ''; + + + + - + @@ -194,28 +234,28 @@ echo ''; + + + + + '; class="sortDirectionIndicator" sort="rdf:http://www.technikum-wien.at/projektbetreuer/rdf#projektarbeit_id" /> +