diff --git a/application/controllers/jobs/OneTimeMessages.php b/application/controllers/jobs/OneTimeMessages.php
new file mode 100644
index 000000000..39e0a946c
--- /dev/null
+++ b/application/controllers/jobs/OneTimeMessages.php
@@ -0,0 +1,122 @@
+load->model('CL/Messages_model', 'CLMessagesModel');
+ }
+
+ /**
+ * Sends the same message to all the applicants whith:
+ * - Status set as "Wartender"
+ * - The given study course type (b = bachelor, m = master)
+ * - The given semester (ex WS2020)
+ * - How long since applicant (months)
+ * - The given template id to be used as message subject and body (vorlage_kurzbz)
+ * The sender of all the messages is specified by the parameter senderId (sender person_id)
+ */
+ public function sendMessageToApplicantsStillWaiting($senderId, $studyCourseType, $semester, $months, $messageTemplate)
+ {
+ $this->logInfo('Send message to applicants still waiting start');
+
+ $queryParams = array(
+ $semester,
+ $studyCourseType,
+ $semester,
+ $studyCourseType,
+ $semester,
+ $studyCourseType
+ );
+
+ $dbModel = new DB_Model();
+
+ $dbPrestudents = $dbModel->execReadOnlyQuery(
+ 'SELECT p.prestudent_id
+ FROM public.tbl_prestudent p
+ JOIN public.tbl_prestudentstatus ps USING (prestudent_id)
+ JOIN public.tbl_studiengang s USING (studiengang_kz)
+ WHERE ps.status_kurzbz = \'Wartender\'
+ AND ps.studiensemester_kurzbz = ?
+ AND ps.datum <= NOW() - \''.$months.' months\'::interval
+ AND s.typ = ?
+ AND NOT EXISTS (
+ SELECT pp.person_id
+ FROM public.tbl_prestudent pp
+ JOIN public.tbl_prestudentstatus pss USING (prestudent_id)
+ JOIN public.tbl_studiengang ss USING (studiengang_kz)
+ WHERE pss.status_kurzbz = \'Aufgenommener\'
+ AND pss.studiensemester_kurzbz = ?
+ AND ss.typ = ?
+ AND pp.person_id = p.person_id
+ )
+ AND NOT EXISTS (
+ SELECT pp.person_id
+ FROM public.tbl_prestudent pp
+ JOIN public.tbl_prestudentstatus pss USING (prestudent_id)
+ JOIN public.tbl_studiengang ss USING (studiengang_kz)
+ WHERE pss.status_kurzbz = \'Student\'
+ AND pss.studiensemester_kurzbz = ?
+ AND ss.typ = ?
+ AND pp.person_id = p.person_id
+ )',
+ $queryParams
+ );
+
+ if (isError($dbPrestudents))
+ {
+ $this->logError(getError($dbPrestudents), $queryParams);
+ }
+ elseif (!hasData($dbPrestudents))
+ {
+ $this->logInfo('There were no users to send message');
+ }
+ else
+ {
+ $prestudentIdsArray = array();
+
+ foreach (getData($dbPrestudents) as $dbPrestudent)
+ {
+ $prestudentIdsArray[] = $dbPrestudent->prestudent_id;
+ }
+
+ $sendMessage = $this->CLMessagesModel->sendExplicitTemplateSenderId(
+ $senderId, // sender person id
+ $prestudentIdsArray, // prestudents id
+ null, // organization unit
+ $messageTemplate, // template id
+ null // extra variables
+ );
+
+ if (isError($sendMessage))
+ {
+ $this->logError(
+ getError($sendMessage),
+ array(
+ 'prestudents' => $prestudentIdsArray,
+ 'template' => $messageTemplate
+ )
+ );
+ }
+
+ $this->logInfo('Total amount of prestudents: '.count($prestudentIdsArray));
+ }
+
+ $this->logInfo('Send message to applicants still waiting end');
+ }
+}
diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php
index 1127106ad..43de8bb60 100644
--- a/application/controllers/system/infocenter/InfoCenter.php
+++ b/application/controllers/system/infocenter/InfoCenter.php
@@ -1378,7 +1378,7 @@ class InfoCenter extends Auth_Controller
{
if (isset($prestudentstatus->bestaetigtam))
{
- //if statusgrund set - RTfreigabe, otherwise Stgfreigabe
+ //if statusgrund set - freigegeben for Studiengang, otherwise freigegeben for RT
if (isset($prestudentstatus->statusgrund_id))
{
if (isset($prestudentstatus->bezeichnung_statusgrund[0])
@@ -1392,23 +1392,37 @@ class InfoCenter extends Auth_Controller
$zgvpruefung->isRtFreigegeben = true;
}
}
- }
+ }
- //application priority change possible?
- $zgvpruefung->changeup = false;
- $zgvpruefung->changedown = false;
+ //application priority change possible?
+ $zgvpruefung->changeup = false;
+ $zgvpruefung->changedown = false;
+ $zgvpruefung->hasBewerber = false;
- if (isset($zgvpruefung->prestudentstatus->status_kurzbz) && $zgvpruefung->prestudentstatus->status_kurzbz == self::INTERESSENTSTATUS)
- {
- if (isset($zgvpruefung->prestudentstatus->studiensemester_kurzbz))
- {
- $studiensemester = $zgvpruefung->prestudentstatus->studiensemester_kurzbz;
- $zgvpruefung->changeup = $this->PrestudentModel->checkPrioChange($zgvpruefung->prestudent_id, $studiensemester, -1);
- $zgvpruefung->changedown = $this->PrestudentModel->checkPrioChange($zgvpruefung->prestudent_id, $studiensemester, 1);
- }
- }
+ if (isset($zgvpruefung->prestudentstatus->status_kurzbz) && $zgvpruefung->prestudentstatus->status_kurzbz == self::INTERESSENTSTATUS)
+ {
+ if (isset($zgvpruefung->prestudentstatus->studiensemester_kurzbz))
+ {
+ $studiensemester = $zgvpruefung->prestudentstatus->studiensemester_kurzbz;
+ //show warning if there is already another bewerber (RT result already exists)
+ $bewerber = $this->PersonModel->hasBewerber($person_id, $studiensemester, 'b');
- $zgvpruefungen[] = $zgvpruefung;
+ if (hasData($bewerber))
+ {
+ $bewerbercnt = getData($bewerber);
+
+ if (is_numeric($bewerbercnt[0]->anzahl_bewerber) && $bewerbercnt[0]->anzahl_bewerber > 0)
+ {
+ $zgvpruefung->hasBewerber = true;
+ }
+ }
+
+ $zgvpruefung->changeup = $this->PrestudentModel->checkPrioChange($zgvpruefung->prestudent_id, $studiensemester, -1);
+ $zgvpruefung->changedown = $this->PrestudentModel->checkPrioChange($zgvpruefung->prestudent_id, $studiensemester, 1);
+ }
+ }
+
+ $zgvpruefungen[] = $zgvpruefung;
}
$this->_sortPrestudents($zgvpruefungen);
diff --git a/application/controllers/system/messages/MessageClient.php b/application/controllers/system/messages/MessageClient.php
index a0cc5c518..5adb49296 100644
--- a/application/controllers/system/messages/MessageClient.php
+++ b/application/controllers/system/messages/MessageClient.php
@@ -34,7 +34,7 @@ class MessageClient extends FHC_Controller
public function read()
{
// Loads the view to read messages
- $this->load->view('system/messages/ajaxRead');
+ $this->load->view('system/messages/ajaxRead', $this->CLMessagesModel->prepareAjaxRead());
}
/**
diff --git a/application/helpers/hlp_sancho_helper.php b/application/helpers/hlp_sancho_helper.php
index 5d2d9f1f1..1653c44e7 100644
--- a/application/helpers/hlp_sancho_helper.php
+++ b/application/helpers/hlp_sancho_helper.php
@@ -89,7 +89,7 @@ function _parseMailContent($vorlage_kurzbz, $vorlage_data)
$ci =& get_instance();
$ci->load->library('VorlageLib');
- $result = $ci->vorlagelib->getVorlagetextByVorlage($vorlage_kurzbz);
+ $result = $ci->vorlagelib->loadVorlagetext($vorlage_kurzbz);
if (isSuccess($result))
{
diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php
index cbb42543f..67e7ff969 100644
--- a/application/models/CL/Messages_model.php
+++ b/application/models/CL/Messages_model.php
@@ -91,6 +91,23 @@ class Messages_model extends CI_Model
}
}
+ /**
+ * Prepares data for the view system/messages/ajaxRead
+ */
+ public function prepareAjaxRead()
+ {
+ $psResult = $this->PrestudentModel->loadWhere(array('person_id' => getAuthPersonId()));
+
+ if (isError($psResult)) show_error('An error occurred while loading this page, please contact the site administrator');
+
+ if (hasData($psResult))
+ {
+ return array('writeButton' => '');
+ }
+
+ return array('writeButton' => '');
+ }
+
/**
* Prepares data for the view system/messages/ajaxWrite
*/
@@ -267,15 +284,10 @@ class Messages_model extends CI_Model
$sender = getData($senderResult)[0]; // Found sender data
- // Check if the receiver is an employee
- $isEmployee = false; // not by default
- $isEmployeeResult = $this->MessageTokenModel->isEmployee($message->receiver_id);
- if (isError($isEmployeeResult)) show_error(getError($isEmployeeResult));
- if (hasData($isEmployeeResult)) $isEmployee = true;
-
- // If the sender is not an employee and are present configurations to reply
+ // If the sender is not the system sender and are present configurations to reply
$hrefReply = '';
- if (!$isEmployee && !isEmptyString($this->config->item(MessageLib::CFG_REDIRECT_VIEW_MESSAGE_URL)))
+ if ($message->sender_id != $this->config->item(MessageLib::CFG_SYSTEM_PERSON_ID)
+ && !isEmptyString($this->config->item(MessageLib::CFG_REDIRECT_VIEW_MESSAGE_URL)))
{
$hrefReply = $this->config->item(MessageLib::CFG_MESSAGE_SERVER).
$this->config->item(MessageLib::CFG_REDIRECT_VIEW_MESSAGE_URL).
@@ -422,10 +434,10 @@ class Messages_model extends CI_Model
return success('Messages sent successfully');
}
-
+
/**
- * Sends a new message using the given template and information present in parameter prestudents
- * Extra variables can be added using parameter $msgVars
+ * Wrapper method for sendExplicitTemplateSenderId
+ * The sender id is retrieved from the authentication session, if not present an error would be raised
*/
public function sendExplicitTemplate($prestudents, $oe_kurzbz, $vorlage_kurzbz, $msgVars)
{
@@ -433,6 +445,15 @@ class Messages_model extends CI_Model
$sender_id = getAuthPersonId();
if (!is_numeric($sender_id)) show_error('The current logged user person_id is not defined');
+ return $this->sendExplicitTemplateSenderId($sender_id, $prestudents, $oe_kurzbz, $vorlage_kurzbz, $msgVars);
+ }
+
+ /**
+ * Sends a new message using the given template and information present in parameter prestudents
+ * Extra variables can be added using parameter $msgVars
+ */
+ public function sendExplicitTemplateSenderId($sender_id, $prestudents, $oe_kurzbz, $vorlage_kurzbz, $msgVars)
+ {
// Retrieves message vars data for the given user/s
$msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents);
if (isError($msgVarsData)) show_error(getError($msgVarsData));
@@ -454,12 +475,12 @@ class Messages_model extends CI_Model
if (is_array($msgVars)) $msgVarsDataArray = array_merge($msgVarsDataArray, $msgVars);
$message = $this->messagelib->sendMessageUserTemplate(
- $msgVarsDataArray['person_id'], // receiversPersonId
- $vorlage_kurzbz, // vorlage
- $msgVarsDataArray, // parseData
- null, // orgform
- $sender_id, // sender_id
- $oe_kurzbz // senderOU
+ $msgVarsDataArray['person_id'], // receiversPersonId
+ $vorlage_kurzbz, // vorlage
+ $msgVarsDataArray, // parseData
+ null, // orgform
+ $sender_id, // sender_id
+ $oe_kurzbz // senderOU
);
if (isError($message)) return $message;
diff --git a/application/views/system/infocenter/infocenterFreigegebenData.php b/application/views/system/infocenter/infocenterFreigegebenData.php
index 729fabb04..aab69b651 100644
--- a/application/views/system/infocenter/infocenterFreigegebenData.php
+++ b/application/views/system/infocenter/infocenterFreigegebenData.php
@@ -185,6 +185,25 @@
ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC
LIMIT 1
) AS "ReihungstestApplied",
+ (
+ SELECT rtp.datum
+ FROM public.tbl_prestudentstatus pss
+ JOIN public.tbl_prestudent ps USING(prestudent_id)
+ LEFT JOIN (
+ SELECT rtp.person_id,
+ rt.studiensemester_kurzbz,
+ rtp.teilgenommen,
+ rt.datum
+ FROM public.tbl_rt_person rtp
+ JOIN tbl_reihungstest rt ON(rtp.rt_id = rt.reihungstest_id)
+ WHERE rt.stufe = 1
+ ) 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 = '.$STUDIENSEMESTER.'
+ ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC
+ LIMIT 1
+ ) AS "ReihungstestDate",
(
SELECT ps.zgvnation
FROM public.tbl_prestudent ps
@@ -258,6 +277,7 @@
'Statusgrund',
'Reihungstest angetreten',
'Reihungstest angemeldet',
+ 'Reihungstest date',
'ZGV Nation'
),
'formatRow' => function($datasetRaw) {
@@ -337,6 +357,16 @@
{
$datasetRaw->{'ReihungstestApplied'} = 'Nein';
}
+
+ if ($datasetRaw->{'ReihungstestDate'} == null)
+ {
+ $datasetRaw->{'ReihungstestDate'} = '-';
+ }
+ else
+ {
+ $datasetRaw->{'ReihungstestDate'} = date_format(date_create($datasetRaw->{'ReihungstestDate'}),'Y-m-d');
+ }
+
if ($datasetRaw->{'ZGVNation'} == null)
{
$datasetRaw->{'ZGVNation'} = '-';
diff --git a/application/views/system/infocenter/zgvpruefungen.php b/application/views/system/infocenter/zgvpruefungen.php
index 5accd22a4..41b549616 100644
--- a/application/views/system/infocenter/zgvpruefungen.php
+++ b/application/views/system/infocenter/zgvpruefungen.php
@@ -34,12 +34,14 @@
//set bootstrap columns for zgv form
$columns = array(3, 3, 3, 3);
- $headercolumns = array(7, 5);
if (!$infoonly && isset($zgvpruefung->prestudentstatus->bewerbungsnachfrist) && isset($zgvpruefung->prestudentstatus->bewerbungstermin))
{
- $headercolumns[0] = 4;
- $headercolumns[1] = 8;
+ $headercolumns = $zgvpruefung->hasBewerber === true ? array(3, 5, 4) : array(4, 8);
}
+ else
+ {
+ $headercolumns = $zgvpruefung->hasBewerber === true ? array(4, 4, 4) : array(7, 5);
+ }
if (!$first)
echo '
';
@@ -68,6 +70,11 @@
?>
+ hasBewerber === true): ?>
+