diff --git a/application/controllers/jobs/LehrauftragJob.php b/application/controllers/jobs/LehrauftragJob.php
index 2f6b928c7..4ba327a2f 100644
--- a/application/controllers/jobs/LehrauftragJob.php
+++ b/application/controllers/jobs/LehrauftragJob.php
@@ -20,31 +20,31 @@ class LehrauftragJob extends JOB_Controller
{
const BERECHTIGUNG_LEHRAUFTRAG_ERTEILEN = 'lehre/lehrauftrag_erteilen';
const BERECHTIGUNG_LEHRAUFTRAG_AKZEPTIEREN = 'lehre/lehrauftrag_akzeptieren';
-
+
const LEHRAUFTRAG_ERTEILEN_URI = 'lehre/lehrauftrag/LehrauftragErteilen';
const LEHRAUFTRAG_AKZEPTIEREN_URI = '/lehre/lehrauftrag/LehrauftragAkzeptieren';
-
+
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
-
+
// Load models
$this->load->model('accounting/Vertrag_model', 'VertragModel');
$this->load->model('accounting/Vertragvertragsstatus_model', 'VertragvertragsstatusModel');
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
$this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel');
-
+
// Load libraries
$this->load->library('PermissionLib');
-
+
// Load helpers
$this->load->helper('hlp_sancho_helper');
}
-
+
/**
* This daily job sends information about all lehr-/projektauftraege ordered (and not approved) the day bofore.
* Receivers: Department-/Kompetenzfeldleiter
@@ -62,7 +62,7 @@ class LehrauftragJob extends JOB_Controller
foreach ($vertrag_arr as $vertrag)
{
$result = $this->VertragModel->getLehreinheitData($vertrag->vertrag_id, 'lehrveranstaltung_id, studiensemester_kurzbz');
-
+
if (hasData($result))
{
$obj = new StdClass();
@@ -72,7 +72,7 @@ class LehrauftragJob extends JOB_Controller
}
}
}
-
+
/**
* Build the data array to be used in the email. Data array is clustered as follows:
* Array
@@ -90,7 +90,7 @@ class LehrauftragJob extends JOB_Controller
foreach ($lehreinheit_data_arr as $lehreinheit_data)
{
$result = $this->_getLVData($lehreinheit_data->lehrveranstaltung_id);
-
+
if (hasData($result))
{
// Search if studiensemester exists in data_arr
@@ -102,12 +102,12 @@ class LehrauftragJob extends JOB_Controller
$data = array(
'studiensemester_kurzbz' => $lehreinheit_data->studiensemester_kurzbz
);
-
+
$data []= array(
'oe_kurzbz' => $result->retval[0]->oe_kurzbz,
'oe_bezeichnung' => $result->retval[0]->lv_oe_bezeichnung
);
-
+
// Add stg data to oe, start amount with 1
$data[0][] = array(
'stg_kz' => $result->retval[0]->studiengang_kz,
@@ -115,7 +115,7 @@ class LehrauftragJob extends JOB_Controller
'stg_bezeichnung' => $result->retval[0]->lv_stg_bezeichnung,
'amount' => 1
);
-
+
// Push to final data_arr
$data_arr []= $data;
}
@@ -124,7 +124,7 @@ class LehrauftragJob extends JOB_Controller
{
// Search if oe exists inside existing studiensemester of data_arr
$oe_index = array_search($result->retval[0]->oe_kurzbz, array_column($data_arr[$ss_index], 'oe_kurzbz'));
-
+
// If oe is new, add oe and stg to studiensemester
if ($oe_index === false)
{
@@ -132,7 +132,7 @@ class LehrauftragJob extends JOB_Controller
$data_arr[$ss_index][] = array(
'oe_kurzbz' => $result->retval[0]->oe_kurzbz,
'oe_bezeichnung' => $result->retval[0]->lv_oe_bezeichnung,
-
+
// Add stg data to oe, start amount with 1
array(
'stg_kz' => $result->retval[0]->studiengang_kz,
@@ -147,7 +147,7 @@ class LehrauftragJob extends JOB_Controller
{
// Search if stg exists inside existing oe of data_arr
$stg_index = array_search($result->retval[0]->studiengang_kz, array_column($data_arr[$ss_index][$oe_index], 'stg_kz'));
-
+
// If stg is new, add stg to oe, start amount with 1
if ($stg_index === false)
{
@@ -168,7 +168,7 @@ class LehrauftragJob extends JOB_Controller
}
}
}
-
+
/**
* Cluster data by uid of entitled mail receivers.
* Returning array is clustered as follows:
@@ -186,7 +186,7 @@ class LehrauftragJob extends JOB_Controller
* [amount] // amount of new ordered lehrauftraege of that stg
*/
$data_arr = $this->_clusterData_byReceiver($data_arr);
-
+
// Send email
if(!$this->_sendMail_toApprove($data_arr))
{
@@ -197,7 +197,7 @@ class LehrauftragJob extends JOB_Controller
$this->logError('Error when sending emails in job MailLehrauftragToApprove');
}
}
-
+
/**
* This daily job sends information about all lehr-/projektauftraege approved the day bofore.
* Receivers: lectors
@@ -208,7 +208,7 @@ class LehrauftragJob extends JOB_Controller
$this->VertragvertragsstatusModel->addSelect('vertrag_id, uid');
$this->VertragvertragsstatusModel->addOrder('uid');
$result = $this->VertragvertragsstatusModel->getApproved_fromDate('YESTERDAY');
-
+
/**
* Build the data array to be used in the email. Data array is clustered as follows:
* Array
@@ -228,10 +228,10 @@ class LehrauftragJob extends JOB_Controller
{
$studiensemester = $studiensemester[0]->vertragsstunden_studiensemester_kurzbz;
}
-
+
// Search if uid exists in data_arr
$uid_index = array_search($vertrag->uid, array_column($data_arr, 'uid'));
-
+
// If uid is new, add uid, studiensemester and start amount with 1
if ($uid_index === false)
{
@@ -249,7 +249,7 @@ class LehrauftragJob extends JOB_Controller
{
$data_arr[$uid_index]['studiensemester'] .= ' und '. $studiensemester;
}
-
+
// Increase amount +1
$data_arr[$uid_index]['amount']++;
}
@@ -266,11 +266,11 @@ class LehrauftragJob extends JOB_Controller
$this->logError('Error when sending emails in job MailLehrauftragToAccept');
}
}
-
+
//******************************************************************************************************************
// PRIVATE FUNCTIONS
//******************************************************************************************************************
-
+
/**
* Get data of given lehrveranstaltung.
* @param $lehrveranstaltung_id
@@ -286,7 +286,7 @@ class LehrauftragJob extends JOB_Controller
stg.typ AS "stg_typ",
stg.kurzbz AS "stg_kurzbz"
');
-
+
$this->LehrveranstaltungModel->addJoin('lehre.tbl_studienplan_lehrveranstaltung stpllv', 'lehrveranstaltung_id');
$this->LehrveranstaltungModel->addJoin('lehre.tbl_studienplan stpl', 'studienplan_id');
$this->LehrveranstaltungModel->addJoin('lehre.tbl_studienordnung sto', 'studienordnung_id');
@@ -294,10 +294,10 @@ class LehrauftragJob extends JOB_Controller
$this->LehrveranstaltungModel->addJoin('public.tbl_organisationseinheit oe', 'ON oe.oe_kurzbz = tbl_lehrveranstaltung.oe_kurzbz');
$this->LehrveranstaltungModel->addOrder('stpllv.insertamum', 'DESC');
$this->LehrveranstaltungModel->addLimit(1);
-
+
return $this->LehrveranstaltungModel->load($lehrveranstaltung_id);
}
-
+
/**
* Send Sancho eMail about ordered Lehrauftraege.
* @param $data_arr
@@ -310,12 +310,12 @@ class LehrauftragJob extends JOB_Controller
// Set mail recipients (department assistance/leader)
$to = $data['uid']. '@'. DOMAIN;
$html_table = $this->_renderData_LehrauftraegeToApprove($data);
-
+
// Prepare mail content
$content_data_arr = array(
'table' => $html_table
);
-
+
sendSanchoMail(
'LehrauftragNeueBestellungen',
$content_data_arr,
@@ -326,7 +326,7 @@ class LehrauftragJob extends JOB_Controller
);
}
}
-
+
/**
* Cluster the data array by entitled mail receiver.
* Returning array is clustered as follows:
@@ -409,7 +409,7 @@ class LehrauftragJob extends JOB_Controller
return $mail_data_arr;
}
-
+
/**
* Render the data array for the mail template returing a HTML table.
* @param $data_arr Data to be used in HTML table
@@ -425,11 +425,11 @@ class LehrauftragJob extends JOB_Controller
if (isset($studiensemester_container['studiensemester_kurzbz']))
{
$studiensemester = $studiensemester_container['studiensemester_kurzbz'];
-
+
// Link to LehrauftragErteilen
$url = site_url(self::LEHRAUFTRAG_ERTEILEN_URI).'?studiensemester='. $studiensemester;
}
-
+
// HTML table header
$html .= '
@@ -446,7 +446,7 @@ class LehrauftragJob extends JOB_Controller
'
;
-
+
// HTML table body
foreach ($studiensemester_container as $oe_container)
{
@@ -456,7 +456,7 @@ class LehrauftragJob extends JOB_Controller
{
$oe_bezeichnung = $oe_container['oe_bezeichnung'];
}
-
+
foreach ($oe_container as $stg_data)
{
if (is_array($stg_data)) // is_array 'trims' the outer associative keys [oe_kurzbz] and [oe_bezeichnung]
@@ -473,7 +473,7 @@ class LehrauftragJob extends JOB_Controller
}
}
}
-
+
// HTML table body end and link
$html .= '
@@ -484,10 +484,10 @@ class LehrauftragJob extends JOB_Controller
';
}
}
-
+
return $html;
}
-
+
/**
* Send Sancho eMail about ordered Lehrauftraege.
* @param $data_arr
@@ -499,24 +499,24 @@ class LehrauftragJob extends JOB_Controller
{
// Set mail recipient (lector)
$to = $data['uid']. '@'. DOMAIN;
-
+
// Link to LehrauftragAkzeptieren
$url = CIS_ROOT. 'cis/index.php?menu='.
CIS_ROOT. 'cis/menu.php?content_id=&content='.
CIS_ROOT. index_page(). self::LEHRAUFTRAG_AKZEPTIEREN_URI;
-
+
// Get first name
$first_name = '';
$this->load->model('person/Benutzer_model', 'BenutzerModel');
$this->BenutzerModel->addSelect('vorname');
$this->BenutzerModel->addJoin('public.tbl_person', 'person_id');
$result = $this->BenutzerModel->loadWhere(array('uid' => $data['uid']));
-
+
if (hasData($result))
{
$first_name = $result->retval[0]->vorname;
}
-
+
// Prepare mail content
$content_data_arr = array(
'vorname' => $first_name,
@@ -524,7 +524,7 @@ class LehrauftragJob extends JOB_Controller
'anzahl' => $data['amount'],
'link' => anchor($url, 'Lehraufträge Übersicht')
);
-
+
sendSanchoMail(
'LehrauftragNeueErteilte',
$content_data_arr,
@@ -532,5 +532,6 @@ class LehrauftragJob extends JOB_Controller
'Neu erteilte Lehraufträge zum Annehmen bereit'
);
}
+ return true;
}
}
diff --git a/application/controllers/lehre/Pruefungsprotokoll.php b/application/controllers/lehre/Pruefungsprotokoll.php
index d9793ef06..467a7dc71 100644
--- a/application/controllers/lehre/Pruefungsprotokoll.php
+++ b/application/controllers/lehre/Pruefungsprotokoll.php
@@ -115,9 +115,11 @@ class Pruefungsprotokoll extends Auth_Controller
public function saveProtokoll()
{
$abschlusspruefung_id = $this->input->post('abschlusspruefung_id');
- $data = $this->input->post('protocoldata');
+ $freigebendata = $this->input->post('freigebendata');
+ $protocoldata = $this->input->post('protocoldata');
- if (isset($abschlusspruefung_id) && is_numeric($abschlusspruefung_id) && isset($data))
+ if (isset($abschlusspruefung_id) && is_numeric($abschlusspruefung_id)
+ && isset($freigebendata['freigeben']) && isset($protocoldata))
{
// check permission
$berechtigt = $this->_getAbschlusspruefungBerechtigt($abschlusspruefung_id);
@@ -125,15 +127,14 @@ class Pruefungsprotokoll extends Auth_Controller
$this->outputJsonError(getError($berechtigt));
else
{
- $freigabe = isset($data['freigabedatum']) && $data['freigabedatum'];
+ $freigabe = $freigebendata['freigeben'] === 'true';
if ($freigabe)
{
// Verify password
- $password = $data['password'];
- unset($data['password']);
- if (!isEmptyString($password))
+ if (isset($freigebendata['password']) && !isEmptyString($freigebendata['password']))
{
+ $password = $freigebendata['password'];
$result = $this->authlib->checkUserAuthByUsernamePassword($this->_uid, $password);
if (isError($result))
{
@@ -146,7 +147,8 @@ class Pruefungsprotokoll extends Auth_Controller
}
}
- $data = $this->_prepareAbschlusspruefungDataForSave($data);
+ $data = $this->_prepareAbschlusspruefungDataForSave($protocoldata, $freigabe);
+
$result = $this->AbschlusspruefungModel->update($abschlusspruefung_id, $data);
if (hasData($result))
@@ -213,7 +215,7 @@ class Pruefungsprotokoll extends Auth_Controller
* @param $data
* @return array
*/
- private function _prepareAbschlusspruefungDataForSave($data)
+ private function _prepareAbschlusspruefungDataForSave($data, $freigabe)
{
$nullfields = array('uhrzeit', 'endezeit', 'abschlussbeurteilung_kurzbz', 'protokoll');
foreach ($data as $idx => $item)
@@ -222,7 +224,7 @@ class Pruefungsprotokoll extends Auth_Controller
$data[$idx] = null;
}
- if (isset($data['freigabedatum']) && $data['freigabedatum'])
+ if ($freigabe === true)
$data['freigabedatum'] = date('Y-m-d');
return $data;
diff --git a/application/controllers/lehre/lehrauftrag/Lehrauftrag.php b/application/controllers/lehre/lehrauftrag/Lehrauftrag.php
index b7140c7c3..8a096338e 100644
--- a/application/controllers/lehre/lehrauftrag/Lehrauftrag.php
+++ b/application/controllers/lehre/lehrauftrag/Lehrauftrag.php
@@ -92,7 +92,8 @@ class Lehrauftrag extends Auth_Controller
// Retrieve studiengaenge the user is entitled for to populate studiengang dropdown
if (!$studiengang_kz_arr = $this->permissionlib->getSTG_isEntitledFor(self::BERECHTIGUNG_LEHRAUFTRAG_BESTELLEN)) {
- show_error('Fehler bei Berechtigungsprüfung');
+ show_error('Keine Studiengänge gefunden.
+ Es muss eine passende Organisationseinheit hinterlegt werden. ');
}
// If studiengang_kz get param was set, check against entitled stg
diff --git a/application/core/CLI_Controller.php b/application/core/CLI_Controller.php
index 79e2a1283..7e1e2a1ab 100644
--- a/application/core/CLI_Controller.php
+++ b/application/core/CLI_Controller.php
@@ -3,7 +3,8 @@
if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- *
+ * This is the super class for all those controllers that can only be called from command line
+ * It provides also an helper to display the possible calls
*/
abstract class CLI_Controller extends FHC_Controller
{
@@ -15,9 +16,9 @@ abstract class CLI_Controller extends FHC_Controller
/**
* Constructor
*/
- public function __construct()
+ public function __construct()
{
- parent::__construct();
+ parent::__construct();
// Checks if the controller is called from command line
$this->_isAllowed();
@@ -103,3 +104,4 @@ abstract class CLI_Controller extends FHC_Controller
}
}
}
+
diff --git a/application/core/JOB_Controller.php b/application/core/JOB_Controller.php
index ea779b169..8b32ba0f5 100644
--- a/application/core/JOB_Controller.php
+++ b/application/core/JOB_Controller.php
@@ -3,26 +3,36 @@
if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- *
+ * This is the super class for a job.
+ * All the controllers that extends this class can only be called from command line.
+ * Provides utility methods to log into database
*/
abstract class JOB_Controller extends CLI_Controller
{
/**
* Constructor
*/
- public function __construct()
+ public function __construct()
{
- parent::__construct();
+ parent::__construct();
// Loads LogLib with different debug trace levels to get data of the job that extends this class
// It also specify parameters to set database fields
- $this->load->library('LogLib', array(
- 'classIndex' => 5,
- 'functionIndex' => 5,
- 'lineIndex' => 4,
- 'dbLogType' => 'job', // required
- 'dbExecuteUser' => 'Cronjob system'
- ));
+ $this->load->library(
+ 'LogLib',
+ array(
+ 'classIndex' => 5,
+ 'functionIndex' => 5,
+ 'lineIndex' => 4,
+ 'dbLogType' => 'job', // required
+ 'dbExecuteUser' => 'Cronjob system',
+ 'requestId' => 'JOB',
+ 'requestDataFormatter' => function($data) {
+ return json_encode($data);
+ }
+ ),
+ 'LogLibJob' // library alias case sensitive
+ );
}
//------------------------------------------------------------------------------------------------------------------
@@ -33,7 +43,7 @@ abstract class JOB_Controller extends CLI_Controller
*/
protected function logInfo($response, $parameters = null)
{
- $this->_log(LogLib::INFO, 'Cronjob info', $response, $parameters);
+ $this->_log(LogLib::INFO, $response, $parameters);
}
/**
@@ -41,7 +51,7 @@ abstract class JOB_Controller extends CLI_Controller
*/
protected function logDebug($response, $parameters = null)
{
- $this->_log(LogLib::DEBUG, 'Cronjob debug', $response, $parameters);
+ $this->_log(LogLib::DEBUG, $response, $parameters);
}
/**
@@ -49,7 +59,7 @@ abstract class JOB_Controller extends CLI_Controller
*/
protected function logWarning($response, $parameters = null)
{
- $this->_log(LogLib::WARNING, 'Cronjob warning', $response, $parameters);
+ $this->_log(LogLib::WARNING, $response, $parameters);
}
/**
@@ -57,7 +67,7 @@ abstract class JOB_Controller extends CLI_Controller
*/
protected function logError($response, $parameters = null)
{
- $this->_log(LogLib::ERROR, 'Cronjob error', $response, $parameters);
+ $this->_log(LogLib::ERROR, $response, $parameters);
}
//------------------------------------------------------------------------------------------------------------------
@@ -66,7 +76,7 @@ abstract class JOB_Controller extends CLI_Controller
/**
* Writes a log to database
*/
- private function _log($level, $requestId, $response, $parameters)
+ private function _log($level, $response, $parameters)
{
$data = new stdClass();
@@ -76,17 +86,18 @@ abstract class JOB_Controller extends CLI_Controller
switch($level)
{
case LogLib::INFO:
- $this->loglib->logInfoDB($requestId, json_encode(success($data, LogLib::INFO)));
+ $this->LogLibJob->logInfoDB($data);
break;
case LogLib::DEBUG:
- $this->loglib->logDebugDB($requestId, json_encode(success($data, LogLib::DEBUG)));
+ $this->LogLibJob->logDebugDB($data);
break;
case LogLib::WARNING:
- $this->loglib->logWarningDB($requestId, json_encode(error($data, LogLib::WARNING)));
+ $this->LogLibJob->logWarningDB($data);
break;
case LogLib::ERROR:
- $this->loglib->logErrorDB($requestId, json_encode(error($data, LogLib::ERROR)));
+ $this->LogLibJob->logErrorDB($data);
break;
}
}
}
+
diff --git a/application/core/JQW_Controller.php b/application/core/JQW_Controller.php
index ab63e7ffd..72a2a972b 100644
--- a/application/core/JQW_Controller.php
+++ b/application/core/JQW_Controller.php
@@ -5,9 +5,10 @@ if (!defined("BASEPATH")) exit("No direct script access allowed");
/**
* Job Queue Worker
*
- * This controller acts as interface of the JobsQueueLib that contains all the needed functionalities to operate with
- * the Jobs Queue System
- * This is an abstract class that provide basic functionalities, it has to be extended to broaden its logic
+ * This controller acts as interface of the JobsQueueLib that contains
+ * all the needed functionalities to operate with the Jobs Queue System
+ * This is an abstract class that provide basic functionalities,
+ * it has to be extended to broaden its logic
*/
abstract class JQW_Controller extends JOB_Controller
{
@@ -18,14 +19,13 @@ abstract class JQW_Controller extends JOB_Controller
{
parent::__construct();
- // Loads LogLib with different parameters
- $this->load->library('LogLib', array(
- 'classIndex' => 5,
- 'functionIndex' => 5,
- 'lineIndex' => 4,
- 'dbLogType' => 'job', // required
- 'dbExecuteUser' => 'Jobs queue system'
- ));
+ // Changes the needed configs for LogLib
+ $this->LogLibJob->setConfigs(
+ array(
+ 'dbExecuteUser' => 'Jobs queue system',
+ 'requestId' => 'JQW'
+ )
+ );
// Loads JobsQueueLib library
$this->load->library('JobsQueueLib');
diff --git a/application/libraries/FilterWidgetLib.php b/application/libraries/FilterWidgetLib.php
index f909c7083..0a4526680 100644
--- a/application/libraries/FilterWidgetLib.php
+++ b/application/libraries/FilterWidgetLib.php
@@ -93,6 +93,7 @@ class FilterWidgetLib
const OP_NOT_SET = 'nset';
// Filter options values
+ const OPT_MINUTES = 'minutes';
const OPT_HOURS = 'hours';
const OPT_DAYS = 'days';
const OPT_MONTHS = 'months';
@@ -887,7 +888,8 @@ class FilterWidgetLib
&& isset($filterDefinition->option)
&& ($filterDefinition->option == self::OPT_HOURS
|| $filterDefinition->option == self::OPT_DAYS
- || $filterDefinition->option == self::OPT_MONTHS))
+ || $filterDefinition->option == self::OPT_MONTHS
+ || $filterDefinition->option == self::OPT_MINUTES))
{
$condition = '< (NOW() - \''.$filterDefinition->condition.' '.$filterDefinition->option.'\'::interval)';
}
@@ -903,7 +905,8 @@ class FilterWidgetLib
&& isset($filterDefinition->option)
&& ($filterDefinition->option == self::OPT_HOURS
|| $filterDefinition->option == self::OPT_DAYS
- || $filterDefinition->option == self::OPT_MONTHS))
+ || $filterDefinition->option == self::OPT_MONTHS
+ || $filterDefinition->option == self::OPT_MINUTES))
{
$condition = '> (NOW() - \''.$filterDefinition->condition.' '.$filterDefinition->option.'\'::interval)';
}
diff --git a/application/libraries/LogLib.php b/application/libraries/LogLib.php
index b98575150..ffdec5f03 100644
--- a/application/libraries/LogLib.php
+++ b/application/libraries/LogLib.php
@@ -42,6 +42,8 @@ class LogLib
const P_NAME_LINE_INDEX = 'lineIndex';
const P_NAME_DB_LOG_TYPE = 'dbLogType';
const P_NAME_DB_EXECUTE_USER = 'dbExecuteUser';
+ const P_NAME_REQUEST_ID = 'requestId';
+ const P_NAME_REQUEST_DATA_FORMATTER = 'requestDataFormatter';
// Properties used to retrieve caller data
private $_classIndex;
@@ -52,6 +54,9 @@ class LogLib
private $_dbLogType;
private $_dbExecuteUser;
+ private $_requestId; // is it possible to specify a request id when loading this library
+ private $_requestDataFormatter; // is possible to provide a function to format request data
+
/**
* Set properties to a default value or overwrites them with the given parameters
*/
@@ -63,7 +68,18 @@ class LogLib
$this->_lineIndex = self::LINE_INDEX;
$this->_dbLogType = null;
$this->_dbExecuteUser = self::DB_EXECUTE_USER;
+ $this->_requestId = null;
+ $this->_requestDataFormatter = null;
+ // If parameters are given then overwrite the default values
+ if (!isEmptyArray($params)) $this->setConfigs($params);
+ }
+
+ /**
+ * Store configuration parameters for this lib
+ */
+ public function setConfigs($params)
+ {
// If parameters are given then overwrite the default values
if (!isEmptyArray($params))
{
@@ -72,6 +88,8 @@ class LogLib
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];
+ if (isset($params[self::P_NAME_REQUEST_ID])) $this->_requestId = $params[self::P_NAME_REQUEST_ID];
+ if (isset($params[self::P_NAME_REQUEST_DATA_FORMATTER])) $this->_requestDataFormatter = $params[self::P_NAME_REQUEST_DATA_FORMATTER];
}
}
@@ -108,33 +126,33 @@ class LogLib
/**
* Writes an info log to database
*/
- public function logInfoDB($requestId, $data)
+ public function logInfoDB($data, $requestId = null)
{
- $this->_logDB(self::INFO, $requestId, $data);
+ $this->_logDB(self::INFO, $data, $requestId);
}
/**
* Writes a debug log to database
*/
- public function logDebugDB($requestId, $data)
+ public function logDebugDB($data, $requestId = null)
{
- $this->_logDB(self::DEBUG, $requestId, $data);
+ $this->_logDB(self::DEBUG, $data, $requestId);
}
/**
* Writes an warning log to database
*/
- public function logWarningDB($requestId, $data)
+ public function logWarningDB($data, $requestId = null)
{
- $this->_logDB(self::WARNING, $requestId, $data);
+ $this->_logDB(self::WARNING, $data, $requestId);
}
/**
* Writes an error log to database
*/
- public function logErrorDB($requestId, $data)
+ public function logErrorDB($data, $requestId = null)
{
- $this->_logDB(self::ERROR, $requestId, $data);
+ $this->_logDB(self::ERROR, $data, $requestId);
}
// --------------------------------------------------------------------------------------------------------------
@@ -151,8 +169,15 @@ class LogLib
/**
* Writes logs to database
*/
- private function _logDB($level, $requestId, $data)
+ private function _logDB($level, $data, $requestId, $executionTime = null)
{
+ // If there isn't a valid request id provided during the loading of this library or when any log to db method is called
+ // NOTE: this message will be displayed only to the developer AND stops the execution
+ if (isEmptyString($this->_requestId) && isEmptyString($requestId))
+ {
+ show_error('To log to database you need to specify or give the "'.self::P_NAME_REQUEST_ID.'" parameter when the LogLib is loaded or when log'.ucfirst($level).'DB is called');
+ }
+
// 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)
@@ -175,14 +200,21 @@ class LogLib
// Get caller data
$callerData = $this->_getCaller();
+ // If a request data formatter was defined then use it
+ $request_data = $data;
+ if ($this->_requestDataFormatter != null && is_callable($this->_requestDataFormatter))
+ {
+ $request_data = call_user_func_array($this->_requestDataFormatter, array($data));
+ }
+
// Writes a log to database
$ci->WebservicelogModel->insert(array(
'webservicetyp_kurzbz' => $this->_dbLogType,
- 'request_id' => $requestId,
+ 'request_id' => (!isEmptyString($requestId) ? $requestId : $this->_requestId).' - '.$level,
'beschreibung' => $this->_getDatabaseDescription($callerData),
- 'request_data' => $data,
+ 'request_data' => $request_data,
'execute_user' => $this->_dbExecuteUser,
- 'execute_time' => 'NOW()' // current time
+ 'execute_time' => $executionTime == null ? 'NOW()' : $executionTime // default current time, if not otherwise specified
));
}
}
@@ -251,3 +283,4 @@ class LogLib
return $formatted;
}
}
+
diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php
index fd2051f48..be496fe4a 100644
--- a/application/libraries/MessageLib.php
+++ b/application/libraries/MessageLib.php
@@ -215,6 +215,31 @@ class MessageLib
return $messageVars; // otherwise returns the error
}
+
+ /**
+ * Retrieves message vars of the logged in user from view vw_msg_vars_user
+ */
+ public function getMessageVarsLoggedInUser()
+ {
+ // Retrieves message vars from view vw_msg_vars
+ $messageVars = $this->_ci->MessageModel->getMsgVarsLoggedInUser();
+ if (isSuccess($messageVars)) // if everything is ok
+ {
+ $variablesArray = array();
+ $tmpVariablesArray = getData($messageVars);
+
+ // Starts from 1 to skip the first element which is uid
+ for ($i = 1; $i < count($tmpVariablesArray); $i++)
+ {
+ $variablesArray['{'.str_replace(' ', '_', strtolower($tmpVariablesArray[$i])).'}']
+ = strtoupper($tmpVariablesArray[$i]);
+ }
+
+ return success($variablesArray);
+ }
+
+ return $messageVars; // otherwise returns the error
+ }
/**
* Retrieves organisation units for each role that a user plays inside that organisation unit
@@ -595,11 +620,24 @@ class MessageLib
$this->_ci->load->model('person/Benutzer_model', 'BenutzerModel');
// And the receiver has an active account for the given organisation unit
- $benutzerResult = $this->_ci->BenutzerModel->getActiveUserByPersonIdAndOrganisationUnit($message->receiver_id, $message->sender_ou);
+ $benutzerResult = $this->_ci->BenutzerModel->getActiveUserByPersonIdAndOrganisationUnit(
+ $message->receiver_id,
+ $message->sender_ou
+ );
+
if (isError($benutzerResult)) return $benutzerResult; // if an error occured then return it
- // Use the uid + domain email
- if (hasData($benutzerResult)) $message->receiverContact = getData($benutzerResult)[0]->uid .'@'.DOMAIN;
+ // If an active user for the given organization unit was found
+ if (hasData($benutzerResult))
+ {
+ // Checks if the user was NOT created in the last 24 hours
+ if (getData($benutzerResult)[0]->insertamum < date('Y-m-d H:i:s', strtotime('-1 day')))
+ {
+ // Use the uid + domain email
+ $message->receiverContact = getData($benutzerResult)[0]->uid .'@'.DOMAIN;
+ }
+ // otherwise do NOT use the internal email account
+ }
}
// Otherwise try with the private email
@@ -644,7 +682,7 @@ class MessageLib
// If there are presetudent
if (hasData($prestudentResults))
{
- $inArray = true;
+ $privateOnly = false;
$organisationUnits = getData($prestudentResults);
// Look if any of the organization units of this prestudent are in the list of the
@@ -652,16 +690,21 @@ class MessageLib
foreach ($organisationUnits as $organisationUnit)
{
// If the recipient organisation unit is NOT in the list of organisation units that sent only to private emails
+ // NOTE: done in this way because it is easyer to check the result of array_search
if (array_search($organisationUnit, $this->_ci->config->item(self::CFG_OU_RECEIVERS_PRIVATE)) === false)
{
- $inArray = false;
+ // NOP
+ }
+ else // otherwise If the recipient organisation unit is the list of organisation units that sent only to private emails
+ {
+ $privateOnly = true;
break;
}
}
// If the recipient prestudent organization unit is not in in the list of the
// organization units that will not send the notice email to the internal account
- if (!$inArray)
+ if ($privateOnly)
{
// Then use the private email
$privateEmailResult = $this->_getPrivateEmail($message->receiver_id);
@@ -676,10 +719,37 @@ class MessageLib
$this->_ci->BenutzerModel->addOrder('updateamum', 'DESC');
$this->_ci->BenutzerModel->addOrder('insertamum', 'DESC');
- $benutzerResult = $this->_ci->BenutzerModel->loadWhere(array('person_id' => $message->receiver_id));
+ $benutzerResult = $this->_ci->BenutzerModel->loadWhere(
+ array(
+ 'person_id' => $message->receiver_id
+ )
+ );
if (isError($benutzerResult)) return $benutzerResult; // if an error occured then return it
- $message->receiverContact = getData($benutzerResult)[0]->uid .'@'.DOMAIN; // Use the uid + domain email
+ // If an active user for the given organization unit was found
+ if (hasData($benutzerResult))
+ {
+ // For each benutzer found for this person
+ foreach (getData($benutzerResult) as $benutzer)
+ {
+ // Checks if the user was NOT created in the last 24 hours
+ if (getData($benutzerResult)[0]->insertamum < date('Y-m-d H:i:s', strtotime('-1 day')))
+ {
+ // Use the uid + domain as email address
+ $message->receiverContact = getData($benutzerResult)[0]->uid .'@'.DOMAIN;
+ }
+ }
+ }
+
+ // Otherwise try with the private email
+ if (isEmptyString($message->receiverContact))
+ {
+ // Then use the private email
+ $privateEmailResult = $this->_getPrivateEmail($message->receiver_id);
+ if (isError($privateEmailResult)) return $privateEmailResult; // if an error occured then return it
+
+ if (hasData($privateEmailResult)) $message->receiverContact = getData($privateEmailResult);
+ }
}
}
}
diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php
index 17824bbb8..9ffd12cf6 100644
--- a/application/models/CL/Messages_model.php
+++ b/application/models/CL/Messages_model.php
@@ -48,6 +48,9 @@ class Messages_model extends CI_Model
$this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel');
// Loads model Prestudent_model
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
+ // Loads model Benutzer_model
+ $this->load->model('person/Benutzer_model', 'BenutzerModel');
+
}
//------------------------------------------------------------------------------------------------------------------
@@ -402,7 +405,10 @@ class Messages_model extends CI_Model
// Looping on receivers data
foreach (getData($msgVarsData) as $receiver)
{
- $msgVarsDataArray = $this->_lowerReplaceSpaceArrayKeys((array)$receiver); // replaces array keys
+ // Merge receivers data with logged in user data
+ $msgVarsDataArray = $this->_addMsgVarsDataOfLoggedInUser($receiver);
+
+ $msgVarsDataArray = $this->_lowerReplaceSpaceArrayKeys((array)getData($msgVarsDataArray)[0]); // replaces array keys
$parsedSubject = parseText($subject, $msgVarsDataArray);
$parsedBody = parseText($body, $msgVarsDataArray);
@@ -466,6 +472,15 @@ class Messages_model extends CI_Model
if (!hasData($msgVarsData)) show_error('No recipients were given');
$prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents);
+
+ // Get the senders uid (if user is an active employee)
+ $this->BenutzerModel->addSelect('uid');
+ $this->BenutzerModel->addJoin('public.tbl_mitarbeiter ma', 'ma.mitarbeiter_uid = uid');
+ if (!$result = getData($this->BenutzerModel->getFromPersonId($sender_id)))
+ {
+ show_error('No sender_uid found');
+ }
+ $sender_uid = $result[0]->uid;
// Adds the organisation unit to each prestudent
if (isEmptyString($oe_kurzbz) && hasData($msgVarsData) && hasData($prestudentsData))
@@ -475,7 +490,15 @@ class Messages_model extends CI_Model
foreach (getData($msgVarsData) as $receiver)
{
- $msgVarsDataArray = $this->_lowerReplaceSpaceArrayKeys((array)$receiver); // replaces array keys
+ /**
+ * Merge receivers data with senders data
+ * NOTE: _addMsgVarsDataOfLoggedInUser usually retrieves data of the logged in user that is set in the
+ * templates user fields. As sendExplicitTemplateSenderId is run by a job, a sender uid is passed to be used
+ * instead the logged in user.
+ */
+ $msgVarsDataArray = $this->_addMsgVarsDataOfLoggedInUser($receiver, $sender_uid);
+
+ $msgVarsDataArray = $this->_lowerReplaceSpaceArrayKeys((array)getData($msgVarsDataArray)[0]); // replaces array keys
// Additional message variables
if (is_array($msgVars)) $msgVarsDataArray = array_merge($msgVarsDataArray, $msgVars);
@@ -606,6 +629,9 @@ class Messages_model extends CI_Model
$parseMessageText = error('The given person_id is not a valid number');
if (is_numeric($person_id)) $parseMessageText = $this->MessageModel->getMsgVarsDataByPersonId($person_id);
+
+ // Add message vars data of the logged in user
+ $parseMessageText = $this->_addMsgVarsDataOfLoggedInUser($parseMessageText);
if (hasData($parseMessageText))
{
@@ -629,7 +655,10 @@ class Messages_model extends CI_Model
$parseMessageText = error('The given prestudent_id is not a valid number');
if (is_numeric($prestudent_id)) $parseMessageText = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id);
-
+
+ // Add message vars data of the logged in user
+ $parseMessageText = $this->_addMsgVarsDataOfLoggedInUser($parseMessageText);
+
if (hasData($parseMessageText))
{
$parseMessageText = success(
@@ -839,6 +868,26 @@ class Messages_model extends CI_Model
$variables[] = $tmpVar;
}
+
+ // ---------------------------------------------------------------------------------------
+ // Retrieves message vars of logged in user from database view vw_msg_vars_person
+ $result = null;
+
+ // If data contains a prestudent id
+ $result = $this->messagelib->getMessageVarsLoggedInUser();
+
+ if (isError($result)) show_error(getError($result));
+
+ // Then builds an array that contains objects with field name and field description of logged in user data
+ $user_fields = array();
+ foreach (getData($result) as $id => $description)
+ {
+ $obj = new stdClass();
+ $obj->id = $id;
+ $obj->description = $description;
+
+ $user_fields[] = $obj;
+ }
// ---------------------------------------------------------------------------------------
// Retrieves the sender id
@@ -859,6 +908,7 @@ class Messages_model extends CI_Model
'subject' => $replySubject,
'body' => $replyBody,
'variables' => $variables,
+ 'user_fields' => $user_fields,
'organisationUnits' => getData($organisationUnits),
'senderIsAdmin' => getData($senderIsAdmin),
'recipientsArray' => $recipientsArray,
@@ -867,4 +917,30 @@ class Messages_model extends CI_Model
'type' => $type
);
}
+
+ /**
+ * Adds message vars data of the logged in user to the given object (that should also have message vars data)
+ * @param object $otherMsgVarsDataObj Can be success object or simple object.
+ * @return object Returns success object.
+ */
+ public function _addMsgVarsDataOfLoggedInUser($otherMsgVarsDataObj, $uid = null)
+ {
+ // First check if param type is object
+ if (!is_object($otherMsgVarsDataObj)) show_error('Must pass an object to merge with data of logged in user');
+
+ // If it is a return object, extract the simple data object
+ if (isSuccess($otherMsgVarsDataObj))
+ {
+ $otherMsgVarsDataObj = getData($otherMsgVarsDataObj)[0];
+ }
+
+ // Retrieve message vars data of the logged in user
+ if (!$msgVarsDataLoggedInUser = getData($this->MessageModel->getMsgVarsDataByLoggedInUser($uid))[0])
+ {
+ return success($otherMsgVarsDataObj); // If failed, return at least given object as expected success object
+ }
+
+ return success(array((object)(array_merge((array) $otherMsgVarsDataObj, (array) $msgVarsDataLoggedInUser))));
+
+ }
}
diff --git a/application/models/crm/Konto_model.php b/application/models/crm/Konto_model.php
index 286d3189e..a3b5cdbb6 100644
--- a/application/models/crm/Konto_model.php
+++ b/application/models/crm/Konto_model.php
@@ -11,4 +11,61 @@ class Konto_model extends DB_Model
$this->dbTable = 'public.tbl_konto';
$this->pk = 'buchungsnr';
}
+
+ /**
+ * Sets a Payment as paid
+ */
+ public function setPaid($buchungsnr)
+ {
+ // get payment
+ $buchungResult = $this->loadWhere(array('buchungsnr' => $buchungsnr));
+
+ if(isSuccess($buchungResult) && hasData($buchungResult))
+ {
+ // get already paid amount
+ $this->addSelect('sum(betrag) as bezahlt');
+ $this->addGroupBy('buchungsnr_verweis');
+ $buchungVerweisResult = $this->loadWhere(array('buchungsnr_verweis' => $buchungsnr));
+
+ if(isSuccess($buchungVerweisResult))
+ {
+ if(hasData($buchungVerweisResult))
+ {
+ $betragBezahltResult = getData($buchungVerweisResult);
+ $betragBezahlt = $betragBezahltResult->bezahlt;
+ }
+ else
+ $betragBezahlt = 0;
+
+ $buchung = getData($buchungResult);
+ $buchung = $buchung[0];
+
+ // calculate open amount
+ $betragOffen = $betragBezahlt - $buchung->betrag*(-1);
+
+ $data = array(
+ 'person_id' => $buchung->person_id,
+ 'studiengang_kz' => $buchung->studiengang_kz,
+ 'studiensemester_kurzbz' => $buchung->studiensemester_kurzbz,
+ 'buchungsnr_verweis' => $buchungsnr,
+ 'betrag' => str_replace(',','.',$betragOffen*(-1)),
+ 'buchungsdatum' => date('Y-m-d'),
+ 'buchungstext' => $buchung->buchungstext,
+ 'insertamum' => date('Y-m-d H:i:s'),
+ 'insertvon' => '',
+ 'buchungstyp_kurzbz' => $buchung->buchungstyp_kurzbz,
+ );
+
+ return $this->insert($data);
+ }
+ else
+ {
+ return error('Failed to load Payment');
+ }
+ }
+ else
+ {
+ return error('Failed to load Payment');
+ }
+ }
}
diff --git a/application/models/education/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php
index 4941ba9bd..d80d02b41 100644
--- a/application/models/education/Lehrveranstaltung_model.php
+++ b/application/models/education/Lehrveranstaltung_model.php
@@ -119,9 +119,10 @@ class Lehrveranstaltung_model extends DB_Model
* Gets all students of a Lehrveranstaltung
* @param $studiensemester_kurzbz
* @param $lehrveranstaltung_id
+ * @param $active optional, if true, only active students retrieved, false - only inactive, all students otherwise
* @return array|null
*/
- public function getStudentsByLv($studiensemester_kurzbz, $lehrveranstaltung_id)
+ public function getStudentsByLv($studiensemester_kurzbz, $lehrveranstaltung_id, $active = null)
{
$query = "SELECT
distinct on(nachname, vorname, person_id) vorname, nachname, matrikelnr,
@@ -144,8 +145,18 @@ class Lehrveranstaltung_model extends DB_Model
WHERE
vw_student_lehrveranstaltung.studiensemester_kurzbz=?
AND
- vw_student_lehrveranstaltung.lehrveranstaltung_id=?
- ORDER BY nachname, vorname, person_id, tbl_bisio.bis DESC";
+ vw_student_lehrveranstaltung.lehrveranstaltung_id=?";
+
+ if (isset($active))
+ {
+ if ($active === true)
+ $query .= " AND tbl_benutzer.aktiv";
+ elseif ($active === false)
+ $query .= " AND tbl_benutzer.aktiv = false";
+ }
+
+ $query .=
+ " ORDER BY nachname, vorname, person_id, tbl_bisio.bis DESC";
return $this->execQuery($query, array($studiensemester_kurzbz, $lehrveranstaltung_id));
}
diff --git a/application/models/organisation/Organisationseinheit_model.php b/application/models/organisation/Organisationseinheit_model.php
index 6439bc8d6..bec4aee47 100644
--- a/application/models/organisation/Organisationseinheit_model.php
+++ b/application/models/organisation/Organisationseinheit_model.php
@@ -33,7 +33,7 @@ class Organisationseinheit_model extends DB_Model
FROM tree JOIN tbl_organisationseinheit oe ON (tree.oe_kurzbz = oe.oe_parent_kurzbz)
)
SELECT oe_kurzbz AS id,
- SUBSTRING(REGEXP_REPLACE(path, '[A-z]+\|', '-', 'g') || bezeichnung, 2) AS description
+ SUBSTRING(REGEXP_REPLACE(path, '[A-z0-9]+\|', '-', 'g') || bezeichnung, 2) AS description
FROM tree";
$parametersArray = array();
diff --git a/application/models/organisation/Studiensemester_model.php b/application/models/organisation/Studiensemester_model.php
index 6e3e48a98..07783cf0d 100644
--- a/application/models/organisation/Studiensemester_model.php
+++ b/application/models/organisation/Studiensemester_model.php
@@ -59,7 +59,7 @@ class Studiensemester_model extends DB_Model
$days = 62;
}
- $query = 'SELECT studiensemester_kurzbz
+ $query = 'SELECT studiensemester_kurzbz, start, ende
FROM public.tbl_studiensemester
WHERE start < NOW() + \'' . $days . ' DAYS\':: INTERVAL
ORDER BY start DESC
@@ -132,7 +132,7 @@ class Studiensemester_model extends DB_Model
$query .= ' WHERE SUBSTRING(studiensemester_kurzbz FROM 1 FOR 2) = \'' . $ss . '\'';
}
- $query .= ' ORDER BY delta LIMIT 1';
+ $query .= ' ORDER BY delta, start LIMIT 1';
return $this->execQuery($query);
}
@@ -188,7 +188,7 @@ class Studiensemester_model extends DB_Model
{
$query = "SELECT studiensemester_kurzbz, start, ende FROM public.vw_studiensemester
WHERE studiensemester_kurzbz <> ?
- ORDER BY delta LIMIT 1";
+ ORDER BY delta, start LIMIT 1";
return $this->execQuery($query, array($studiensemester_kurzbz));
}
diff --git a/application/models/person/Benutzer_model.php b/application/models/person/Benutzer_model.php
index 45edf5122..c1e76ce38 100644
--- a/application/models/person/Benutzer_model.php
+++ b/application/models/person/Benutzer_model.php
@@ -23,13 +23,17 @@ class Benutzer_model extends DB_Model
*/
public function getActiveUserByPersonIdAndOrganisationUnit($person_id, $oe_kurzbz)
{
- $sql = 'SELECT b.uid
- FROM public.tbl_benutzer b
- JOIN public.tbl_prestudent ps USING (person_id)
- JOIN public.tbl_studiengang sg USING (studiengang_kz)
- WHERE ps.person_id = ?
- AND sg.oe_kurzbz = ?
- AND b.aktiv = TRUE';
+ $sql = 'SELECT
+ b.uid,
+ b.insertamum
+ FROM
+ public.tbl_prestudent ps
+ JOIN public.tbl_studiengang sg USING (studiengang_kz)
+ JOIN public.tbl_student USING(prestudent_id)
+ JOIN public.tbl_benutzer b ON(uid = student_uid)
+ WHERE ps.person_id = ?
+ AND sg.oe_kurzbz = ?
+ AND b.aktiv = TRUE';
return $this->execQuery($sql, array($person_id, $oe_kurzbz));
}
diff --git a/application/models/person/Kontakt_model.php b/application/models/person/Kontakt_model.php
index 50ef18e15..c35794fc8 100644
--- a/application/models/person/Kontakt_model.php
+++ b/application/models/person/Kontakt_model.php
@@ -169,4 +169,33 @@ class Kontakt_model extends DB_Model
return $this->execQuery($qry, array($person_id));
}
+
+ /**
+ * Loads main contact, i.e. most recent Zustellkontakt with the given kontakttypes.
+ * @param $person_id
+ * @param $kontakttypen array of kontakttypen, one chronologically last Zustellkontakt for all given types
+ * @return object
+ */
+ public function getZustellKontakt($person_id, $kontakttypen)
+ {
+ if (is_string($kontakttypen))
+ $kontakttypen = array($kontakttypen);
+
+ if (!isEmptyArray($kontakttypen))
+ {
+ $qry = "
+ SELECT
+ kontakt
+ FROM
+ public.tbl_kontakt
+ WHERE person_id = ?
+ AND kontakttyp IN ?
+ ORDER BY zustellung DESC NULLS LAST, updateamum DESC, insertamum DESC
+ LIMIT 1";
+
+ return $this->execQuery($qry, array($person_id, $kontakttypen));
+ }
+ else
+ return success(array());
+ }
}
diff --git a/application/models/ressource/Mitarbeiter_model.php b/application/models/ressource/Mitarbeiter_model.php
index abf71e1b9..90c30927f 100644
--- a/application/models/ressource/Mitarbeiter_model.php
+++ b/application/models/ressource/Mitarbeiter_model.php
@@ -50,7 +50,7 @@ class Mitarbeiter_model extends DB_Model
* @param $personaccount wenn true werden alle geladen die personalnr >= 0 haben, also "echte" Personaccounts
* @return array
*/
- public function getPersonal($aktiv, $fix, $verwendung, $personaccount = null)
+ public function getPersonal($aktiv, $fix, $verwendung, $personaccount = null, $uids = null)
{
$qry = "SELECT DISTINCT ON(mitarbeiter_uid) staatsbuergerschaft, geburtsnation, sprache, anrede, titelpost, titelpre,
nachname, vorname, vornamen, gebdatum, gebort, gebzeit, tbl_person.anmerkung AS person_anmerkung, homepage, svnr, ersatzkennzeichen, familienstand,
@@ -88,7 +88,14 @@ class Mitarbeiter_model extends DB_Model
elseif ($personaccount === false)
$qry .= " AND tbl_mitarbeiter.personalnummer < 0";
- return $this->execQuery($qry);
+ $params = array();
+ if (!isEmptyArray($uids))
+ {
+ $qry .= " AND tbl_mitarbeiter.mitarbeiter_uid IN ?";
+ $params[] = $uids;
+ }
+
+ return $this->execQuery($qry, $params);
}
/**
diff --git a/application/models/system/Message_model.php b/application/models/system/Message_model.php
index 764c3ae14..d9f8585ed 100644
--- a/application/models/system/Message_model.php
+++ b/application/models/system/Message_model.php
@@ -171,6 +171,23 @@ class Message_model extends DB_Model
return error($this->db->error(), FHC_DB_ERROR);
}
}
+
+ /**
+ * Get message variables for logged in user
+ */
+ public function getMsgVarsLoggedInUser()
+ {
+ $result = $this->db->query('SELECT * FROM public.vw_msg_vars_user WHERE 0 = 1');
+
+ if ($result)
+ {
+ return success($result->list_fields());
+ }
+ else
+ {
+ return error($this->db->error(), FHC_DB_ERROR);
+ }
+ }
/**
* getMsgVarsDataByPrestudentId
@@ -191,4 +208,26 @@ class Message_model extends DB_Model
return $this->execQuery(sprintf($query, is_array($person_id) ? 'IN' : '='), array($person_id));
}
+
+ /**
+ * Get message vars data for logged in user
+ * @param string uid The UID should ONLY be passed if this method is called by a cronjob.
+ * This is to enable jobs to use templates which use logged-in-user fields ('Eigene Felder').
+ * @return array|null
+ */
+ public function getMsgVarsDataByLoggedInUser($uid = null)
+ {
+ if (is_string($uid))
+ {
+ $params = array($uid);
+ }
+ else
+ {
+ $params = array(getAuthUID());
+ }
+
+ $query = 'SELECT * FROM public.vw_msg_vars_user WHERE my_uid = ?';
+
+ return $this->execQuery($query, $params);
+ }
}
diff --git a/application/views/person/bpk/bpkData.php b/application/views/person/bpk/bpkData.php
index 7e375030f..3580ed4bc 100644
--- a/application/views/person/bpk/bpkData.php
+++ b/application/views/person/bpk/bpkData.php
@@ -3,7 +3,7 @@
'query' => '
SELECT
person_id, vorname, nachname, geschlecht, svnr, ersatzkennzeichen, matr_nr,
- staatsbuergerschaft, gebdatum
+ staatsbuergerschaft, gebdatum, false AS mitarbeiter
FROM
public.tbl_person
WHERE
@@ -11,6 +11,17 @@
AND bpk is null
AND EXISTS(SELECT 1 FROM public.tbl_benutzer JOIN public.tbl_student ON(uid=student_uid) AND
person_id=tbl_person.person_id AND tbl_benutzer.aktiv=true)
+ UNION
+ SELECT
+ person_id, vorname, nachname, geschlecht, svnr, ersatzkennzeichen, matr_nr,
+ staatsbuergerschaft, gebdatum, true AS mitarbeiter
+ FROM
+ public.tbl_person
+ JOIN public.tbl_benutzer USING(person_id)
+ JOIN public.tbl_mitarbeiter ON (mitarbeiter_uid=uid)
+ WHERE
+ bpk is null
+ AND tbl_benutzer.aktiv=true
',
'requiredPermissions' => 'admin',
'datasetRepresentation' => 'tablesorter',
@@ -25,6 +36,7 @@
ucfirst($this->p->t('person', 'matrikelnummer')),
ucfirst($this->p->t('person', 'staatsbuergerschaft')),
ucfirst($this->p->t('person', 'geburtsdatum')),
+ 'Mitarbeiter'
),
'formatRow' => function($datasetRaw) {
@@ -45,6 +57,11 @@
{
$datasetRaw->{'svnr'} = '-';
}
+ if ($datasetRaw->{'matr_nr'} == null)
+ {
+ $datasetRaw->{'matr_nr'} = '-';
+ }
+ $datasetRaw->{'mitarbeiter'} = $datasetRaw->{'mitarbeiter'} == 'true' ? 'ja' : 'nein';
return $datasetRaw;
}
diff --git a/application/views/system/logs/logsViewerData.php b/application/views/system/logs/logsViewerData.php
index 13a4207ab..f8476df6a 100644
--- a/application/views/system/logs/logsViewerData.php
+++ b/application/views/system/logs/logsViewerData.php
@@ -25,7 +25,7 @@
),
'formatRow' => function($datasetRaw) {
- $datasetRaw->ExecutionTime = date_format(date_create($datasetRaw->ExecutionTime), 'd.m.Y H:i:s');
+ $datasetRaw->ExecutionTime = date_format(date_create($datasetRaw->ExecutionTime), 'd.m.Y H:i:s:u');
return $datasetRaw;
},
@@ -33,22 +33,22 @@
$mark = '';
- if ($datasetRaw->RequestId == 'Cronjob error')
+ if (strpos($datasetRaw->RequestId, 'error') != false)
{
$mark = 'text-red';
}
- if ($datasetRaw->RequestId == 'Cronjob info')
+ if (strpos($datasetRaw->RequestId, 'info') != false)
{
$mark = 'text-green';
}
- if ($datasetRaw->RequestId == 'Cronjob warning')
+ if (strpos($datasetRaw->RequestId, 'warning') != false)
{
$mark = 'text-orange';
}
- if ($datasetRaw->RequestId == 'Cronjob debug')
+ if (strpos($datasetRaw->RequestId, 'debug') != false)
{
$mark = 'text-info';
}
@@ -63,3 +63,4 @@
echo $this->widgetlib->widget('FilterWidget', $filterWidgetArray);
?>
+
diff --git a/application/views/system/messages/htmlWriteTemplate.php b/application/views/system/messages/htmlWriteTemplate.php
index 199a88cfa..95ab12630 100644
--- a/application/views/system/messages/htmlWriteTemplate.php
+++ b/application/views/system/messages/htmlWriteTemplate.php
@@ -83,19 +83,41 @@
19 ? 19 : count($variables);
echo $this->widgetlib->widget(
'MultipleDropdown_widget',
array('elements' => success($variables)),
array(
'name' => 'variables[]',
'id' => 'variables',
- 'size' => count($variables),
+ 'size' => $size,
'multiple' => true
)
);
?>
-
+
+