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/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/jobs/Prestudentstatus.php b/application/controllers/jobs/Prestudentstatus.php index 27cafeb0e..e5b015753 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) { 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/Filters.php b/application/controllers/system/Filters.php index 3bdb6dde2..b29bd2bb0 100644 --- a/application/controllers/system/Filters.php +++ b/application/controllers/system/Filters.php @@ -216,6 +216,16 @@ class Filters extends FHC_Controller $this->outputJsonSuccess('Success'); } + /** + * Reloads the dataset + */ + public function reloadDataset() + { + $this->filterslib->reloadDataset(); + + $this->outputJsonSuccess('Success'); + } + //------------------------------------------------------------------------------------------------------------------ // Private methods diff --git a/application/controllers/system/LogsViewer.php b/application/controllers/system/LogsViewer.php new file mode 100644 index 000000000..55cf38d82 --- /dev/null +++ b/application/controllers/system/LogsViewer.php @@ -0,0 +1,44 @@ + 'admin: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/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/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index d59c058cf..c803520ed 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -136,6 +136,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 } diff --git a/application/core/APIv1_Controller.php b/application/core/APIv1_Controller.php index 6432c87db..b0c98c6e5 100644 --- a/application/core/APIv1_Controller.php +++ b/application/core/APIv1_Controller.php @@ -1,9 +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/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/FiltersLib.php b/application/libraries/FiltersLib.php index 6346150d8..6875d16ec 100644 --- a/application/libraries/FiltersLib.php +++ b/application/libraries/FiltersLib.php @@ -528,6 +528,14 @@ class FiltersLib return $applyFilters; } + /** + * Reloads dataset by setting session variable to true + */ + public function reloadDataset() + { + $this->setSessionElement(self::SESSION_RELOAD_DATASET, true); + } + /** * Add a filter (SQL where clause) to be applied to the current filter */ 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/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/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/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index ffc6afb0e..32673d10d 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,7 +210,6 @@ 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) @@ -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/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/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php index 1685ddf81..1235769ac 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,7 +60,6 @@ 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); @@ -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/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..9878ab5be 100644 --- a/application/models/organisation/Studiensemester_model.php +++ b/application/models/organisation/Studiensemester_model.php @@ -61,7 +61,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 +72,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/Person_model.php b/application/models/person/Person_model.php index b689f4fcb..1291427b6 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'); } /** @@ -162,9 +165,6 @@ class Person_model extends DB_Model 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'); 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/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..ada1d330c --- /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 null $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 (isset($names) && is_array($names)) + { + $qry .= " WHERE name IN ('".implode(',', $names)."')"; + } + $qry .= ";"; + + $defaultsres = $this->execQuery($qry); + + 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/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..04b99b057 100644 --- a/application/views/system/infocenter/infocenterData.php +++ b/application/views/system/infocenter/infocenterData.php @@ -11,16 +11,9 @@ $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", @@ -100,13 +93,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 +119,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 +144,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 +169,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 +194,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", @@ -252,7 +251,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'; 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..89ba2ec38 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", @@ -215,7 +217,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..2dfcfc9d0 --- /dev/null +++ b/application/views/system/logs/logsViewerData.php @@ -0,0 +1,66 @@ + ' + 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', + 'reloadDataset' => ($this->input->get('reloadDataset') == 'true' ? true : false), + '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/cis/infoterminal/index.php b/cis/infoterminal/index.php index d11ce070b..a3a7dfb91 100644 --- a/cis/infoterminal/index.php +++ b/cis/infoterminal/index.php @@ -1974,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/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/fotoliste.pdf.php b/cis/private/lehre/fotoliste.pdf.php index 8054955ca..8565470c6 100644 --- a/cis/private/lehre/fotoliste.pdf.php +++ b/cis/private/lehre/fotoliste.pdf.php @@ -31,6 +31,7 @@ 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'); @@ -58,6 +59,9 @@ isset($_GET['stsem']) ? $studiensemester = $_GET['stsem'] : die('Ein Studienseme $lv = new lehrveranstaltung(); $lv->load($lvid); +$stg = new studiengang(); +$stg->load($lv->studiengang_kz); + $berechtigung = new benutzerberechtigung(); $berechtigung->getBerechtigungen($user); @@ -96,17 +100,15 @@ if ($lehreinheit != '') $gruppen_string = ''; $gruppen_string_arr = array(); -$stg_typ = ''; +$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; - //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); @@ -237,8 +239,8 @@ if ($result = $db->db_query($qry)) { $row->foto_sperre = 'f'; //create foto (if not locked by student OR if fotolist is created by admin or assistenz) - $foto_url = ''; - + $foto_url = ''; + if ($row->foto_sperre == 'f' && $row->foto != '') { $foto_src = $row->foto; $foto_url = sys_get_temp_dir() . '/foto' . trim($row->matrikelnr) . '.jpg'; diff --git a/cis/private/lehre/notenliste.php b/cis/private/lehre/notenliste.php index 33221ac1a..56fd4a36d 100644 --- a/cis/private/lehre/notenliste.php +++ b/cis/private/lehre/notenliste.php @@ -308,8 +308,12 @@ else // 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; + // 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 .= ""; @@ -379,13 +383,10 @@ else $anzahlLv = 0; foreach ($notenSummenArray AS $key => $value) { - if ($value['notenwert'] != '') - { - $anzahlLv++; - $notenSumme += $value['notenwert']; - $ectsSumme += $value['ects']; - $notenSummeGewichtet += $value['notenwert'] * $value['ects']; - } + $anzahlLv++; + $notenSumme += $value['notenwert']; + $ectsSumme += $value['ects']; + $notenSummeGewichtet += $value['notenwert'] * $value['ects']; } $tblBody .= ""; diff --git a/cis/private/lehre/pruefung/pruefung.js.php b/cis/private/lehre/pruefung/pruefung.js.php index 5662898d9..9ef84e889 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; diff --git a/cis/private/lehre/pruefung/pruefungsanmeldung.json.php b/cis/private/lehre/pruefung/pruefungsanmeldung.json.php index a446c73e2..b4eba2f6d 100644 --- a/cis/private/lehre/pruefung/pruefungsanmeldung.json.php +++ b/cis/private/lehre/pruefung/pruefungsanmeldung.json.php @@ -178,7 +178,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 +268,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); } } @@ -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); } } @@ -1206,6 +1215,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 +1228,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/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 t('pruefung/pruefungIntervall'); ?>: diff --git a/cis/private/lvplan/stpl_reserve_list.php b/cis/private/lvplan/stpl_reserve_list.php index 82f70b612..5e6e1fa85 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,17 +79,17 @@ 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)." + $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).") ORDER BY datum, titel, ort_kurzbz, stunde"; @@ -97,7 +97,7 @@ if(!$rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) die($db->db_last_error()); $num_rows_res=$db->db_num_rows($erg_res); - + if ($num_rows_res>0) { echo $p->t('lvplan/eigeneReservierungen').':
'; @@ -135,7 +135,7 @@ if(!$rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) echo ''.$db->convert_html_chars($pers_uid).''; echo ''.$db->convert_html_chars($beschreibung).' '; $z=$i-1; - if (($pers_uid==$uid || $insertvon==$uid) && $rechte->isBerechtigt('lehre/reservierung', null, 'suid')) + if (($pers_uid==$uid || $insertvon==$uid) && $rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) echo 'Delete'; echo ''; } @@ -145,7 +145,7 @@ if(!$rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) echo '

'; flush(); - + ?> diff --git a/cis/private/lvplan/stpl_week.php b/cis/private/lvplan/stpl_week.php index edc50e8c2..c7da148dd 100644 --- a/cis/private/lvplan/stpl_week.php +++ b/cis/private/lvplan/stpl_week.php @@ -362,7 +362,7 @@ 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) { diff --git a/cis/private/profile/lva_liste.php b/cis/private/profile/lva_liste.php index 33eb7da3b..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,7 +318,7 @@ 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_betreuerart.beschreibung AS beutreuerart_beschreibung + 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_betreuerart WHERE @@ -318,6 +332,7 @@ require_once('../../../include/benutzerberechtigung.class.php'); $stg_obj = new studiengang(); $stg_obj->getAll(null,null); + $summe_std = 0; if($result = $db->db_query($qry)) { @@ -329,6 +344,7 @@ 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').''; @@ -339,13 +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 ''; } } @@ -426,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/zeitwunsch.php b/cis/private/profile/zeitwunsch.php index 73ba51bf9..ff4c35ebd 100644 --- a/cis/private/profile/zeitwunsch.php +++ b/cis/private/profile/zeitwunsch.php @@ -118,8 +118,29 @@ $fixangestellt = $ma->fixangestellt; $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; @@ -191,10 +212,24 @@ if (isset($_GET['selbstverwaltete-pause']) && !empty($_GET['submit'])) 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 '

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




'; @@ -202,7 +237,7 @@ if (isset($_GET['selbstverwaltete-pause']) && !empty($_GET['submit'])) 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').'

'; + echo '

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

'; } //var_dump($gd); ?> diff --git a/cis/private/tools/notebook_registration.php b/cis/private/tools/notebook_registration.php index b5704b572..cd557431e 100644 --- a/cis/private/tools/notebook_registration.php +++ b/cis/private/tools/notebook_registration.php @@ -38,7 +38,7 @@ else function ip_increment($ip = "") { - $ip = split("\.", $ip); + $ip = explode(".", $ip); if($ip[3] > 0 && $ip[3] < 254) { @@ -67,7 +67,13 @@ function ip_increment($ip = "") + Wollen Sie als Mitarbeiter ein Notebook registrieren, wenden Sie sich bitte an den Support.'; + echo '
'; + exit; + } if (!$txtUID) $txtUID = $user; // wenn die übergebene UID nicht gleich dem @@ -128,7 +134,7 @@ function ip_increment($ip = "") { $VLAN = $mfiles->match[1]; $fuser = $mfiles->match[2]; - $fuser = split(" ", $fuser); + $fuser = explode(" ", $fuser); $fuser = $fuser[0]; //hier könnte man noch eine email oder dgl. schicken if ($fuser != $txtUID) @@ -240,21 +246,21 @@ function ip_increment($ip = "") else if ($error == 3) echo '

'.$p->t("notebookregister/MACadresseBereitsVerwendet").'.

'; - if(isset($mac_result) && $mac_result!='') + if(isset($mac_result) && $mac_result!=='') { - if($mac_result == 0) + if($mac_result === 0) { echo '

'.$p->t("notebookregister/MACadresseErfolgreichEingetragen").'.

'; } - else if($mac_result == 1) + else if($mac_result === 1) { echo '

'.$p->t("notebookregister/MACadresseErfolgreichGeaendert").'.

'; } - else if($mac_result == 2) + else if($mac_result === 2) { echo '

'.$p->t("notebookregister/MACadresseFehlerhaft").'.

'; } - else if($mac_result == 3) + else if($mac_result === 3) { echo '

'.$p->t("notebookregister/MACadresseNichtFreigeschalten").'.

'; } diff --git a/cis/private/tools/zeitaufzeichnung.php b/cis/private/tools/zeitaufzeichnung.php index bb509ef90..acc5f83d0 100644 --- a/cis/private/tools/zeitaufzeichnung.php +++ b/cis/private/tools/zeitaufzeichnung.php @@ -33,6 +33,7 @@ require_once('../../../include/zeitaufzeichnung.class.php'); require_once('../../../include/zeitsperre.class.php'); require_once('../../../include/datum.class.php'); require_once('../../../include/projekt.class.php'); +require_once('../../../include/projektphase.class.php'); require_once('../../../include/phrasen.class.php'); require_once('../../../include/organisationseinheit.class.php'); require_once('../../../include/service.class.php'); @@ -81,8 +82,8 @@ else { $datum = new datum(); $fieldheadings = array( - 'id' => $p->t("zeitaufzeichnung/id"), 'user' => $p->t("zeitaufzeichnung/user"), 'projekt' => $p->t("zeitaufzeichnung/projekt"), - 'oe1' => $p->t("zeitaufzeichnung/oe").'1', 'oe2' => $p->t("zeitaufzeichnung/oe").'2', 'aktivitaet' => $p->t("zeitaufzeichnung/aktivitaet"), + 'id' => $p->t("zeitaufzeichnung/id"), 'user' => $p->t("zeitaufzeichnung/user"), 'projekt' => $p->t("zeitaufzeichnung/projekt"), 'ap' => $p->t("zeitaufzeichnung/projektphase"), + 'oe1' => $p->t("zeitaufzeichnung/oe"), 'oe2' => $p->t("zeitaufzeichnung/oe").'2', 'aktivitaet' => $p->t("zeitaufzeichnung/aktivitaet"), 'service' => $p->t("zeitaufzeichnung/service"), 'start' => $p->t("zeitaufzeichnung/start"), 'ende' => $p->t("zeitaufzeichnung/ende"), 'dauer' => $p->t("zeitaufzeichnung/dauer"), 'kunde' => $p->t("zeitaufzeichnung/kunde"), 'beschreibung' => $p->t("global/beschreibung"), 'aktion' => $p->t("global/aktion"), 'datum' => $p->t("global/datum") @@ -91,12 +92,12 @@ $fieldheadings = array( if ($rechte->isBerechtigt('basis/servicezeitaufzeichnung')) { $za_simple = 0; - $activities = array('Design', 'Operativ', 'Betrieb', 'Pause', 'Lehre', 'Arztbesuch', 'DienstreiseMT', 'Behoerde', 'Ersatzruhe'); + $activities = array('Design', 'Operativ', 'Betrieb', 'Pause', 'FuE', 'Lehre', 'Arztbesuch', 'DienstreiseMT', 'Behoerde', 'Ersatzruhe'); } else { $za_simple = 1; - $activities = array('Arbeit', 'Pause', 'Lehre', 'Arztbesuch', 'DienstreiseMT', 'Behoerde', 'Ersatzruhe'); + $activities = array('Admin', 'FuE','Lehre', 'Pause', 'Arztbesuch', 'DienstreiseMT', 'Behoerde', 'Ersatzruhe'); } $activities_str = "'".implode("','", $activities)."'"; @@ -110,13 +111,12 @@ else if (defined('CIS_ZEITAUFZEICHNUNG_GESPERRT_BIS') && CIS_ZEITAUFZEICHNUNG_GE else $gesperrt_bis = '2015-08-31'; -//var_dump($gesperrt_bis); - $sperrdatum = date('c', strtotime($gesperrt_bis)); // Uses urlencode to avoid XSS issues $zeitaufzeichnung_id = urlencode(isset($_GET['zeitaufzeichnung_id'])?$_GET['zeitaufzeichnung_id']:''); $projekt_kurzbz = (isset($_POST['projekt'])?$_POST['projekt']:''); +$projektphase_id = (isset($_POST['projektphase'])?$_POST['projektphase']:''); $oe_kurzbz_1 = (isset($_POST['oe_kurzbz_1'])?$_POST['oe_kurzbz_1']:''); $oe_kurzbz_2 = (isset($_POST['oe_kurzbz_2'])?$_POST['oe_kurzbz_2']:''); $aktivitaet_kurzbz = (isset($_POST['aktivitaet'])?$_POST['aktivitaet']:''); @@ -252,6 +252,13 @@ echo ' } }); + $("#projekt").change( + function() + { + getProjektphasen($(this).val()); + } + ) + }); function setbisdatum() @@ -489,6 +496,49 @@ echo ' } return true; } + + function getProjektphasen(projekt_kurzbz) + { + $.ajax + ( + { + type: "GET", + url: "zeitaufzeichnung_projektphasen.php", + dataType: "json", + data: + { + "projekt_kurzbz":projekt_kurzbz + }, + success: function(json) + { + //remove Projektphasen from html if any + $("#projektphase").children("option").each( + function() + { + if ($(this).prop("id") !== "projektphasekeineausw") + $(this).remove(); + } + ); + //append Projektphasen if any + if (json.length > 0) + { + var projphasenhtml = ""; + for (var i = 0; i < json.length; i++) + { + projphasenhtml += "'; + $trennlinie = true; + $service = new service(); + $service->getFrequentServices($user, '180','3'); + foreach($service->result as $row) { - echo ''; - $trennlinie = false; + if($row->service_id==$service_id) + $selected='selected'; + else + $selected=''; + + if ($row->anzahl =='0' && $trennlinie==true) + { + echo ''; + $trennlinie = false; + } + echo ''; } - echo ''; - } - 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 ' + + '.$p->t("zeitaufzeichnung/kunde").' + '.$p->t("zeitaufzeichnung/oderKartennummerOptional").' + '; - - // 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 ' - - '.$p->t("zeitaufzeichnung/kunde").' - '.$p->t("zeitaufzeichnung/oderKartennummerOptional").' - - '; - echo ' '; + echo ' '; } //Start/Ende @@ -1101,7 +1257,7 @@ if($projekt->getProjekteMitarbeiter($user, true)) { //Uebersichtstabelle $woche=date('W'); - $colspan=($za_simple)?10:13; + $colspan=($za_simple)?12:14; echo ' @@ -1184,7 +1340,7 @@ if($projekt->getProjekteMitarbeiter($user, true)) $tagessaldo = $tagessaldo-$pausesumme; $tagessaldo = date('H:i', ($tagessaldo)); - $colspan = ($za_simple)?4:7; + $colspan = ($za_simple)?6:8; echo ' @@ -1281,7 +1437,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 +1576,12 @@ function printTableHeadings($fieldheadings, $za_simple = false){ echo ' - '; + + + '; if (!$za_simple) { - echo ' - '; + echo ''; } echo ''; if (!$za_simple) @@ -1477,8 +1637,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 +1651,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..b8b19a0a9 100644 --- a/cis/private/tools/zeitaufzeichnung_projektliste.php +++ b/cis/private/tools/zeitaufzeichnung_projektliste.php @@ -32,6 +32,7 @@ require_once('../../../include/benutzer.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"); @@ -61,17 +62,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 +88,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 +141,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 +162,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 +271,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 +280,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 +353,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 +404,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 +464,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 +477,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 +488,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 +524,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..da557217b 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,47 @@ 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 +202,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 +252,564 @@ 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 '
'; + if (!isset($_GET['zugangscode'])) + { + echo "<< ".$p->t('coodle/zurueckZurUebersicht').""; + echo '

'; + } + echo '
'; -$coodle_help = new coodle(); -$coodle_help->load($coodle_id); + $coodle_help = new coodle(); + $coodle_help->load($coodle_id); -$alt = strtotime($coodle_help->insertamum); + $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.

'; + $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 $coodle->beschreibung; -echo '
'; + 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 - )) . '
'; -} + 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( + 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 '

+ echo '
'; -$coodle_ressourcen = new coodle(); -$coodle_ressourcen->getRessourcen($coodle_id); + $coodle_ressourcen = new coodle(); + $coodle_ressourcen->getRessourcen($coodle_id); + $mailadressen = '?subject=Coodle%20Umfrage%20'.htmlspecialchars($coodle->titel).'&bcc='; -// alle termine der coodle umfrage holen -$coodle_termine = new coodle(); -$coodle_termine->getTermine($coodle_id); + foreach ($coodle_ressourcen->result as $ressource) + { + $name = ''; + $benutzer = new benutzer(); -$datum = new datum(); -$datum_colspan = ''; -$mailadressen = '?subject=Coodle%20Umfrage%20' . htmlspecialchars($coodle->titel) . '&bcc='; + // 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; -echo "
+ $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 "
-
'; // Zusaetzlicher span fuer Addon Informationen @@ -1259,7 +1415,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 +1491,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'])) - { - $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 + // Für Colspan bei Datum + $max_colspan = array(); 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 ""; + $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 + echo ''; + } + echo ""; + + // 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 { - if ($disabled) + + // 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 ($checked) - echo ''; - else - echo ''; + $coodle_ressource->getRessourceFromUser($coodle_id, '', $_GET['zugangscode']); + if ($ressource->coodle_ressource_id != $coodle_ressource->coodle_ressource_id) + $disabled = true; } else { - // Der 01.01.1900 wird fuer "Keine Auswahl" verwendet. Beim anklicken der Checkbox werden alle anderen Checkboxen deaktiviert - echo ''; + $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 ''; } - - $termin_datum = $termin->datum; + } + + $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 ''; - } -} + echo ''; + echo ""; -$disabled = $abgeschlossen ? 'disabled' : ''; + 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 ""; + } -// 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 ' '; + echo ' +
" . $datum->formatDatum($termin->datum, 'd.m.Y') . "
" . date('H:i', $time) . " -
" . date('H:i', $ende) . "  
' . $p->t('coodle/keinTerminMoeglich') . '
" . $ressource->anzeigename . " + ".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)."  
'.$p->t('coodle/keinTerminMoeglich').'
".$ressource->anzeigename." - datum == '1900-01-01' ? 'id="disableCheckboxes"' : '') . ' - name="check_' . $ressource->coodle_ressource_id . '_' . $termin->coodle_termin_id . '"> - +
+ +
+
Die TeilnehmerInnen dieser Umfrage sind anonym
Die Terminwahl dieser Umfrage erfolgt anonym
Summe der Einträge
'.$p->t('coodle/keineAuswahl').'
'.$p->t('coodle/auswahlEndtermin').'
Die TeilnehmerInnen dieser Umfrage sind anonym
Die Terminwahl dieser Umfrage erfolgt anonym
'; + echo '
'; -echo 'Summe der Einträge'; -foreach ($coodle_termine->result as $termin) -{ - $countTermine = new coodle(); - $countTermine->countTermin($termin->coodle_termin_id); - - if ($countTermine->anzahl == max($counter_arr)) - echo '' . $countTermine->anzahl . ''; - else - echo '' . $countTermine->anzahl . ''; -} -if ($ersteller) - echo '' . $p->t('coodle/keineAuswahl') . ''; -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) -{ - // buttons für auswahl des endgültigen termins - echo '' . $p->t('coodle/auswahlEndtermin') . ''; - 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 ' Mail an alle schicken'; -echo ' ' . $p->t('coodle/auswahlHinweis') . ' - '; + if ($ersteller && $abgeschlossen) + echo '  '; + if ($saveOk === true) + echo '
+ '.$p->t('global/erfolgreichgespeichert').' +
'; + echo '
'; + + echo '
'.$message; + + echo $mailMessage; -if ($ersteller && $abgeschlossen) - echo ''; -if ($saveOk === true) - echo '
- ' . $p->t('global/erfolgreichgespeichert') . ' -
'; -echo " - - " . $message . '
' . $mailMessage; - ?> - + @@ -702,7 +817,7 @@ echo " /** * Sendet eine Email an den Ersteller der Umfrage - * + * * @param type $ersteller */ function sendBenachrichtigung($coodle_id, $teilnehmer_id) @@ -710,16 +825,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 +842,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 +906,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 +920,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 +960,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 +1014,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 +1062,7 @@ END:VCALENDAR"; /** * * Prueft ob ein Raum belegt ist - * + * * @param $ort_kurzbz * @param $datum * @param array $stunden @@ -946,14 +1077,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 +1094,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/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 '