diff --git a/application/controllers/jobs/ReihungstestJob.php b/application/controllers/jobs/ReihungstestJob.php
index ab6c429a0..010c8fb31 100644
--- a/application/controllers/jobs/ReihungstestJob.php
+++ b/application/controllers/jobs/ReihungstestJob.php
@@ -21,6 +21,10 @@ class ReihungstestJob extends JOB_Controller
// Load helpers
$this->load->helper('hlp_sancho_helper');
+
+ // Loads CLMessagesModel
+ $this->load->model('CL/Messages_model', 'CLMessagesModel');
+
}
/**
@@ -346,6 +350,7 @@ class ReihungstestJob extends JOB_Controller
// Get placement tests with testdate within the next 2 weeks
$resultNextTestDates = $this->ReihungstestModel->getNextPlacementtests($degreeProgram, 14);
+
if (hasData($resultNextTestDates))
{
$nextTestDates = $resultNextTestDates->retval;
@@ -393,7 +398,8 @@ class ReihungstestJob extends JOB_Controller
{
foreach ($testsOndate as $reihungstest)
{
- // Loads applicants of a test
+ // Loads applicants of a test with prestudent ID
+ $applicants_arr = '';
$applicants = $this->ReihungstestModel->getApplicantsOfPlacementTest($reihungstest->reihungstest_id);
if (hasData($applicants))
@@ -405,34 +411,37 @@ class ReihungstestJob extends JOB_Controller
show_error(getError($applicants));
}
- foreach ($applicants_arr as $applicant)
+ if(!empty($applicants_arr))
{
- $mailcontent_data_arr = array();
- $mailcontent_data_arr['anrede'] = $applicant->anrede;
- $mailcontent_data_arr['nachname'] = $applicant->nachname;
- $mailcontent_data_arr['vorname'] = $applicant->vorname;
- $mailcontent_data_arr['rt_datum'] = date_format(date_create($reihungstest->datum), 'd.m.Y');
- $mailcontent_data_arr['rt_uhrzeit'] = date_format(date_create($reihungstest->uhrzeit), 'H:i');
- $mailcontent_data_arr['rt_raum'] = $applicant->planbezeichnung;
- if ($applicant->lageplan == '')
+ foreach ($applicants_arr as $applicant)
{
- $mailcontent_data_arr['wegbeschreibung'] = 'Für diesen Raum liegt noch keine Wegbeschreibung vor.
No directions were found for this room';
- }
- else
- {
- $mailcontent_data_arr['wegbeschreibung'] = $applicant->lageplan;
- }
+ $mailcontent_data_arr = array();
+ $mailcontent_data_arr['anrede'] = $applicant->anrede;
+ $mailcontent_data_arr['nachname'] = $applicant->nachname;
+ $mailcontent_data_arr['vorname'] = $applicant->vorname;
+ $mailcontent_data_arr['rt_datum'] = date_format(date_create($reihungstest->datum), 'd.m.Y');
+ $mailcontent_data_arr['rt_uhrzeit'] = date_format(date_create($reihungstest->uhrzeit), 'H:i');
+ $mailcontent_data_arr['rt_raum'] = $applicant->planbezeichnung;
+ if ($applicant->lageplan == '')
+ {
+ $mailcontent_data_arr['wegbeschreibung'] = 'Für diesen Raum liegt noch keine Wegbeschreibung vor.
No directions were found for this room';
+ }
+ else
+ {
+ $mailcontent_data_arr['wegbeschreibung'] = $applicant->lageplan;
+ }
- sendSanchoMail(
- 'Sancho_RemindApplicantsOfTest',
- $mailcontent_data_arr,
- $applicant->email,
- 'Ihre Anmeldung zum Reihungstest - Reminder / Your registration for the placement test - Reminder',
- DEFAULT_SANCHO_HEADER_IMG,
- DEFAULT_SANCHO_FOOTER_IMG,
- $from,
- '',
- $bcc);
+ $sender_id = $this->config->item('system_person_id');
+
+ $sendMessage = $this->CLMessagesModel->sendExplicitTemplateSenderId
+ (
+ $sender_id,
+ $applicant->prestudent_id,
+ 'infocenter',
+ 'Sancho_RemindApplicantsOfTest',
+ $mailcontent_data_arr
+ );
+ }
}
}
}
@@ -822,7 +831,7 @@ class ReihungstestJob extends JOB_Controller
JOIN lehre.tbl_studienordnung USING (studienordnung_id)
JOIN PUBLIC.tbl_studiengang ON (tbl_studienordnung.studiengang_kz = tbl_studiengang.studiengang_kz)
WHERE get_rolle_prestudent (tbl_prestudent.prestudent_id, ?) IN ('Aufgenommener','Bewerber','Wartender','Abgewiesener')
- AND studiensemester_kurzbz = ?
+ AND studiensemester_kurzbz = ?
AND tbl_studiengang.typ IN ('b', 'm')
)
SELECT * FROM prst
diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php
index 4975af382..dbcd74814 100644
--- a/application/models/CL/Messages_model.php
+++ b/application/models/CL/Messages_model.php
@@ -50,7 +50,7 @@ class Messages_model extends CI_Model
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
// Loads model Benutzer_model
$this->load->model('person/Benutzer_model', 'BenutzerModel');
-
+
}
//------------------------------------------------------------------------------------------------------------------
@@ -407,7 +407,7 @@ class Messages_model extends CI_Model
{
// 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);
@@ -446,7 +446,7 @@ class Messages_model extends CI_Model
return success('Messages sent successfully');
}
-
+
/**
* Wrapper method for sendExplicitTemplateSenderId
* The sender id is retrieved from the authentication session, if not present an error would be raised
@@ -459,7 +459,7 @@ class Messages_model extends CI_Model
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
@@ -472,7 +472,7 @@ 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');
@@ -492,8 +492,8 @@ class Messages_model extends CI_Model
{
/**
* 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
+ * 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);
@@ -629,7 +629,7 @@ 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);
@@ -655,10 +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(
@@ -868,14 +868,14 @@ 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
@@ -885,7 +885,7 @@ class Messages_model extends CI_Model
$obj = new stdClass();
$obj->id = $id;
$obj->description = $description;
-
+
$user_fields[] = $obj;
}
@@ -917,7 +917,7 @@ 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.
@@ -927,20 +927,20 @@ class Messages_model extends CI_Model
{
// 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($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/Reihungstest_model.php b/application/models/crm/Reihungstest_model.php
index ec1982ea6..d13fe150a 100644
--- a/application/models/crm/Reihungstest_model.php
+++ b/application/models/crm/Reihungstest_model.php
@@ -10,8 +10,8 @@ class Reihungstest_model extends DB_Model
parent::__construct();
$this->dbTable = 'public.tbl_reihungstest';
$this->pk = 'reihungstest_id';
- }
-
+ }
+
/**
* Gets a test from a test id only if it is available
*/
@@ -35,15 +35,15 @@ class Reihungstest_model extends DB_Model
WHERE rt_id = tbl_reihungstest.reihungstest_id
) > 0
AND reihungstest_id = ?';
-
+
return $this->execQuery($query, array($reihungstest_id));
}
-
+
/**
* Checks if there are active studyplans which have no public placement tests assigned yet.
* Only check assignment to studyplans that are
- * - Bachelor,
- * - active,
+ * - Bachelor,
+ * - active,
* - set as online application
* - valid for 1st terms
* @return array Returns object array with studyplans that have no public placement tests assigned yet.
@@ -51,20 +51,20 @@ class Reihungstest_model extends DB_Model
public function checkMissingReihungstest()
{
$query = '
- SELECT
+ SELECT
bezeichnung
FROM
lehre.tbl_studienplan
WHERE
studienplan_id
- IN
+ IN
(
- SELECT DISTINCT
+ SELECT DISTINCT
studienplan_id
- FROM
+ FROM
public.tbl_studiensemester
JOIN
- lehre.tbl_studienplan_semester
+ lehre.tbl_studienplan_semester
USING (studiensemester_kurzbz)
JOIN
lehre.tbl_studienplan
@@ -81,31 +81,31 @@ class Reihungstest_model extends DB_Model
tbl_studiensemester.onlinebewerbung = \'t\'
AND
tbl_studienplan.onlinebewerbung_studienplan = \'t\'
- AND
+ AND
semester = 1
AND
typ = \'b\'
EXCEPT
- SELECT DISTINCT
+ SELECT DISTINCT
studienplan_id
- FROM
- public.tbl_reihungstest
+ FROM
+ public.tbl_reihungstest
JOIN
public.tbl_rt_studienplan
USING (reihungstest_id)
- WHERE
- datum >= now()
- AND
+ WHERE
+ datum >= now()
+ AND
oeffentlich = \'t\'
)
';
-
+
return $this->execQuery($query);
}
-
- /**
+
+ /**
* Gets amount of free places.
* @return array Returns object array with faculty and amount of free places
* for each public actual placement test date.
@@ -132,9 +132,9 @@ class Reihungstest_model extends DB_Model
SELECT
sum(arbeitsplaetze) - ceil(sum(arbeitsplaetze)/100.0*'. REIHUNGSTEST_ARBEITSPLAETZE_SCHWUND. ')
FROM
- public.tbl_rt_ort
+ public.tbl_rt_ort
JOIN
- public.tbl_ort
+ public.tbl_ort
ON (tbl_rt_ort.ort_kurzbz = tbl_ort.ort_kurzbz)
WHERE
tbl_rt_ort.rt_id = tbl_reihungstest.reihungstest_id
@@ -170,27 +170,27 @@ class Reihungstest_model extends DB_Model
oe_kurzbz
FROM
public.tbl_rt_studienplan
- JOIN
+ JOIN
lehre.tbl_studienplan sp USING (studienplan_id)
- JOIN
+ JOIN
lehre.tbl_studienordnung USING (studienordnung_id)
JOIN
public.tbl_studiengang sg USING (studiengang_kz)
WHERE
tbl_rt_studienplan.reihungstest_id = tbl_reihungstest.reihungstest_id
)
- AND
+ AND
aktiv = true
-
+
UNION ALL
-
+
SELECT
o.oe_kurzbz, o.oe_parent_kurzbz, o.organisationseinheittyp_kurzbz
FROM
public.tbl_organisationseinheit o, meine_oes
WHERE
o.oe_kurzbz = meine_oes.oe_parent_kurzbz
- AND
+ AND
aktiv = true
)
SELECT
@@ -207,7 +207,7 @@ class Reihungstest_model extends DB_Model
JOIN
public.tbl_studiengang
USING (studiengang_kz)
- WHERE
+ WHERE
tbl_reihungstest.datum >= now()
AND
tbl_reihungstest.oeffentlich = \'t\'
@@ -221,10 +221,10 @@ class Reihungstest_model extends DB_Model
fakultaet,
freie_plaetze
';
-
+
return $this->execQuery($query);
}
-
+
/**
* Checks if a registration date (Anmeldefrist) of a placement test has been reached yesterday.
* @param integer $studiengang_kz Optional. Kennzahl of degree program whose registration date should be checked.
@@ -239,9 +239,9 @@ class Reihungstest_model extends DB_Model
SELECT CURRENT_DATE - 1
)
';
-
+
$parametersArray = array();
-
+
if (!isEmptyString($studiengang_kz))
{
$query .= ' AND studiengang_kz = ?';
@@ -250,7 +250,7 @@ class Reihungstest_model extends DB_Model
return $this->execQuery($query, $parametersArray);
}
-
+
/**
* Loads all applicants of a placement test for runZentraleReihungstestAnmeldefristAssistenzJob
* @param integer $reihungstest_id ID of placement test
@@ -326,11 +326,11 @@ class Reihungstest_model extends DB_Model
AND tbl_prestudentstatus.studiensemester_kurzbz = rt.studiensemester_kurzbz
AND bewerbung_abgeschicktamum IS NOT NULL
AND bestaetigtam IS NOT NULL
- ORDER BY studiengang_kz,
- orgform_kurzbz,
- prioritaet,
- nachname,
- vorname,
+ ORDER BY studiengang_kz,
+ orgform_kurzbz,
+ prioritaet,
+ nachname,
+ vorname,
person_id
';
@@ -439,36 +439,37 @@ class Reihungstest_model extends DB_Model
public function getApplicantsOfPlacementTest($reihungstest_id)
{
$query = '
- SELECT DISTINCT tbl_rt_person.person_id,
- anrede,
- nachname,
- vorname,
- (
- SELECT kontakt
- FROM PUBLIC.tbl_kontakt
- WHERE kontakttyp = \'email\'
- AND zustellung = true
- AND person_id = tbl_rt_person.person_id
- ORDER BY insertamum DESC,
- updateamum DESC LIMIT 1
- ) AS "email",
- tbl_ort.planbezeichnung,
- tbl_ort.lageplan
- FROM PUBLIC.tbl_rt_person
- JOIN PUBLIC.tbl_person ON (tbl_rt_person.person_id = tbl_person.person_id)
- JOIN PUBLIC.tbl_reihungstest rt ON (rt_id = reihungstest_id)
- JOIN PUBLIC.tbl_prestudent ps ON (ps.person_id = tbl_rt_person.person_id)
- JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id)
- LEFT JOIN bis.tbl_zgv ON (ps.zgv_code = tbl_zgv.zgv_code)
- LEFT JOIN PUBLIC.tbl_ort ON (tbl_rt_person.ort_kurzbz = tbl_ort.ort_kurzbz)
- WHERE rt_id = ?
- AND get_rolle_prestudent(prestudent_id, rt.studiensemester_kurzbz) = \'Interessent\'
- AND tbl_prestudentstatus.studiensemester_kurzbz = rt.studiensemester_kurzbz
- AND bewerbung_abgeschicktamum IS NOT NULL
- AND bestaetigtam IS NOT NULL
- ORDER BY nachname,
- vorname,
- person_id
+ SELECT *
+ FROM
+ (SELECT DISTINCT tbl_rt_person.person_id, ps.prestudent_id, anrede, nachname, vorname,
+ (
+ SELECT kontakt
+ FROM PUBLIC.tbl_kontakt
+ WHERE kontakttyp = \'email\'
+ AND zustellung = true
+ AND person_id = tbl_rt_person.person_id
+ ORDER BY insertamum DESC,
+ updateamum DESC LIMIT 1
+ ) AS "email",
+ tbl_ort.planbezeichnung,
+ tbl_ort.lageplan,
+ row_number () over (partition by tbl_rt_person.person_id order by ps.priorisierung) as row_number
+ FROM PUBLIC.tbl_rt_person
+ JOIN PUBLIC.tbl_person ON (tbl_rt_person.person_id = tbl_person.person_id)
+ JOIN PUBLIC.tbl_reihungstest rt ON (rt_id = reihungstest_id)
+ JOIN PUBLIC.tbl_prestudent ps ON (ps.person_id = tbl_rt_person.person_id)
+ JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id)
+ LEFT JOIN bis.tbl_zgv ON (ps.zgv_code = tbl_zgv.zgv_code)
+ LEFT JOIN PUBLIC.tbl_ort ON (tbl_rt_person.ort_kurzbz = tbl_ort.ort_kurzbz)
+ WHERE rt_id = ?
+ AND get_rolle_prestudent(prestudent_id, rt.studiensemester_kurzbz) = \'Interessent\'
+ AND tbl_prestudentstatus.studiensemester_kurzbz = rt.studiensemester_kurzbz
+ AND bewerbung_abgeschicktamum IS NOT NULL
+ AND bestaetigtam IS NOT NULL
+ ORDER BY nachname,
+ vorname,
+ person_id)
+ temp where row_number = 1
';
return $this->execQuery($query, array($reihungstest_id));
@@ -511,4 +512,4 @@ class Reihungstest_model extends DB_Model
return $this->execQuery($query, array($date, $studiengang_kz));
}
-}
\ No newline at end of file
+}