mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-16 14:32:18 +00:00
New Cronjobs for Reihungstests
- runZentraleReihungstestAnmeldefristAssistenzJob - runZentraleReihungstestNachtraeglichHinzugefuegtJob - runRemindApplicantsOfPlacementTestJob - New function getWorkingDays returns business days between two dates - New function checkReachedRegistrationDate - New function getApplicantsOfPlacementTestForCronjob - New function getApplicantAssignedAfterDate - New function getApplicantsOfPlacementTest - New function getTestsOnDate - New function loadStudiengaengeFromTyp
This commit is contained in:
@@ -42,6 +42,7 @@ class ReihungstestJob extends FHC_Controller
|
||||
|
||||
// Load models
|
||||
$this->load->model('crm/Reihungstest_model', 'ReihungstestModel');
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
|
||||
// Load helpers
|
||||
$this->load->helper('hlp_sancho_helper');
|
||||
@@ -102,6 +103,304 @@ class ReihungstestJob extends FHC_Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function runZentraleReihungstestAnmeldefristAssistenzJob()
|
||||
{
|
||||
// Get placement tests where registration date was yesterday
|
||||
$result = $this->ReihungstestModel->checkReachedRegistrationDate(11000);
|
||||
|
||||
$reachedRegistration_rt_arr = array();
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
$reachedRegistration_rt_arr = $result->retval;
|
||||
}
|
||||
elseif (isError($result))
|
||||
{
|
||||
show_error($result->error);
|
||||
}
|
||||
|
||||
$applicants_arr = array();
|
||||
|
||||
foreach ($reachedRegistration_rt_arr as $reihungstest)
|
||||
{
|
||||
$applicants = $this->ReihungstestModel->getApplicantsOfPlacementTestForCronjob($reihungstest->reihungstest_id);
|
||||
|
||||
if (hasData($applicants))
|
||||
{
|
||||
$applicants_arr = $applicants->retval;
|
||||
}
|
||||
elseif (isError($applicants))
|
||||
{
|
||||
show_error($applicants->error);
|
||||
}
|
||||
|
||||
// Get all Bachelor-Degree-Programs with Mailadress
|
||||
$bachelorStudiengeange = $this->StudiengangModel->loadStudiengaengeFromTyp('b');
|
||||
|
||||
if (hasData($bachelorStudiengeange))
|
||||
{
|
||||
$bachelorStudiengeange_arr = $bachelorStudiengeange->retval;
|
||||
}
|
||||
elseif (isError($bachelorStudiengeange))
|
||||
{
|
||||
show_error($bachelorStudiengeange->error);
|
||||
}
|
||||
|
||||
// If a person ist an applicant of this degree-program send mail with application data
|
||||
// Otherwise inform assistant, that no applicant is registered in this test
|
||||
foreach ($bachelorStudiengeange_arr as $bachelorStudiengang)
|
||||
{
|
||||
$studiengang_kuerzel = strtoupper($bachelorStudiengang->typ.$bachelorStudiengang->kurzbz);
|
||||
$applicants_list = '';
|
||||
$applicantCounter = 0;
|
||||
$rowstyle = 'style="background-color: #EEEEEE; padding: 4px;"';
|
||||
$mailReceipients = ''; // String with all mailadresses
|
||||
$mailcontent_data_arr = array();
|
||||
foreach ($applicants_arr as $applicant)
|
||||
{
|
||||
if ($bachelorStudiengang->studiengang_kz == $applicant->studiengang_kz)
|
||||
{
|
||||
$mailReceipients .= $applicant->email. ';';
|
||||
$applicantCounter ++;
|
||||
$applicants_list .= '
|
||||
<tr '.$rowstyle.'>
|
||||
<td>'. $applicant->orgform_kurzbz. '</td>
|
||||
<td>'. $applicant->ausbildungssemester. '</td>
|
||||
<td>'. $applicant->nachname. '</td>
|
||||
<td>'. $applicant->vorname. '</td>
|
||||
<td>'. $applicant->zgv_kurzbz. '</td>
|
||||
<td>'. $applicant->prioritaet. '</td>
|
||||
<td>'. $applicant->qualifikationskurs. '</td>
|
||||
<td><a href="mailto:'. $applicant->email. '">'. $applicant->email. '</a></td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
}
|
||||
if ($applicantCounter == 0)
|
||||
{
|
||||
$mailcontent = '<p style="font-family: verdana, sans-serif;">Der Anmeldeschluss für den zentralen Reihungstest am ' . date_format(date_create($reihungstest->datum), 'd.m.Y') . ' um ' . $reihungstest->uhrzeit . ' Uhr wurde gestern erreicht.</p>';
|
||||
$mailcontent .= '<p style="font-family: verdana, sans-serif;"><b>Für den Studiengang '.$studiengang_kuerzel.' nehmen keine InteressentInnen an diesem Reihungstest teil</b></p>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$headerstyle = 'style="background: #DCE4EF; border: 1px solid #FFF; padding: 4px; text-align: left;"';
|
||||
|
||||
$mailcontent = '<p style="font-family: verdana, sans-serif;">Der Anmeldeschluss für den zentralen Reihungstest am ' . date_format(date_create($reihungstest->datum), 'd.m.Y') . ' um ' . $reihungstest->uhrzeit . ' Uhr wurde gestern erreicht.</p>';
|
||||
$mailcontent .= '
|
||||
<p style="font-family: verdana, sans-serif;">Folgende ' . $applicantCounter . ' InteressentInnen des Studiengangs ' . $studiengang_kuerzel . ' nehmen daran teil:</p>
|
||||
<table width="100%" style="cellpadding: 3px; font-family: verdana, sans-serif; border: 1px solid #000000;">
|
||||
<thead>
|
||||
<th '.$headerstyle.'>OrgForm</th>
|
||||
<th '.$headerstyle.'>Semester</th>
|
||||
<th '.$headerstyle.'>Nachname</th>
|
||||
<th '.$headerstyle.'>Vorname</th>
|
||||
<th '.$headerstyle.'>ZGV</th>
|
||||
<th '.$headerstyle.'>Priorität</th>
|
||||
<th '.$headerstyle.'>Qualikurs</th>
|
||||
<th '.$headerstyle.'>E-Mail</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
';
|
||||
$mailcontent .= $applicants_list;
|
||||
$mailcontent .= '
|
||||
</tbody>
|
||||
</table>
|
||||
';
|
||||
$mailcontent .= '<p style="font-family: verdana, sans-serif;"><a href="mailto:?bcc=' . $mailReceipients . '">Mail an alle schicken</a></p>';
|
||||
}
|
||||
$mailcontent_data_arr['table'] = $mailcontent;
|
||||
//$mailcontent_data_arr['link'] = $this->VILESCI_RT_VERWALTUNGS_URL;
|
||||
//var_dump($mailcontent_data_arr);
|
||||
// Send email in Sancho design
|
||||
if (!isEmptyString($mailcontent))
|
||||
{
|
||||
sendSanchoMail(
|
||||
'Sancho_ReihungstestteilnehmerJob',
|
||||
$mailcontent_data_arr,
|
||||
array($bachelorStudiengang->email,'kindlm@technikum-wien.at'),
|
||||
'Anmeldeschluss Reihungstest ' . date_format(date_create($reihungstest->datum), 'd.m.Y') . ' ' . $reihungstest->uhrzeit . ' Uhr',
|
||||
'sancho_header_min_bw.jpg',
|
||||
'sancho_footer_min_bw.jpg');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Checks, if an applicant was assigned to a test after Anmeldefrist
|
||||
public function runZentraleReihungstestNachtraeglichHinzugefuegtJob()
|
||||
{
|
||||
// Get applicants that have been added to a test after Anmeldefrist
|
||||
$result = $this->ReihungstestModel->getApplicantAssignedAfterDate(11000);
|
||||
|
||||
$applicants_after_anmeldefrist_arr = array();
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
$applicants_after_anmeldefrist_arr = $result->retval;
|
||||
}
|
||||
elseif (isError($result))
|
||||
{
|
||||
show_error($result->error);
|
||||
}
|
||||
|
||||
$studiengang = '';
|
||||
$mailReceipients = ''; // String with all mailadresses
|
||||
$mailcontent_data_arr = array();
|
||||
$headerstyle = 'style="background: #DCE4EF; border: 1px solid #FFF; padding: 4px; text-align: left;"';
|
||||
$rowstyle = 'style="background-color: #EEEEEE; padding: 4px;"';
|
||||
$mailcontent = '';
|
||||
$applicants_list = '';
|
||||
|
||||
if (count($applicants_after_anmeldefrist_arr) > 0)
|
||||
{
|
||||
foreach ($applicants_after_anmeldefrist_arr as $applicant)
|
||||
{
|
||||
if ($studiengang != $applicant->studiengang_kz)
|
||||
{
|
||||
if ($studiengang != '' && $studiengang != $applicant->studiengang_kz)
|
||||
{
|
||||
$bachelorStudiengang = $this->StudiengangModel->load($studiengang);
|
||||
$mailcontent .= $applicants_list;
|
||||
$mailcontent .= '</tbody></table>';
|
||||
$mailcontent .= '<p style="font-family: verdana, sans-serif;"><a href="mailto:?bcc=' . $mailReceipients . '">Mail an alle schicken</a></p>';
|
||||
$mailcontent_data_arr['table'] = $mailcontent;
|
||||
sendSanchoMail(
|
||||
'Sancho_ReihungstestteilnehmerJob',
|
||||
$mailcontent_data_arr,
|
||||
array($bachelorStudiengang->retval[0]->email,'kindlm@technikum-wien.at'),
|
||||
'InteressentIn nach Reihungstest-Anmeldeschluss hinzugefügt',
|
||||
'sancho_header_min_bw.jpg',
|
||||
'sancho_footer_min_bw.jpg');
|
||||
$applicants_list = '';
|
||||
$mailcontent_data_arr = array();
|
||||
}
|
||||
|
||||
$mailcontent = '<p style="font-family: verdana, sans-serif;">Folgende InteressentInnen wurden <b>nach</b> der Anmeldefrist zu einem Reihungstest hinzugefügt.</p>';
|
||||
$mailcontent .= '
|
||||
<table width="100%" style="cellpadding: 3px; font-family: verdana, sans-serif; border: 1px solid #000000;">
|
||||
<thead>
|
||||
<th ' . $headerstyle . '>Datum des Tests</th>
|
||||
<th ' . $headerstyle . '>Uhrzeit des Tests</th>
|
||||
<th ' . $headerstyle . '>OrgForm</th>
|
||||
<th ' . $headerstyle . '>Semester</th>
|
||||
<th ' . $headerstyle . '>Nachname</th>
|
||||
<th ' . $headerstyle . '>Vorname</th>
|
||||
<th ' . $headerstyle . '>ZGV</th>
|
||||
<th ' . $headerstyle . '>Priorität</th>
|
||||
<th ' . $headerstyle . '>Qualikurs</th>
|
||||
<th ' . $headerstyle . '>E-Mail</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
';
|
||||
}
|
||||
|
||||
$studiengang = $applicant->studiengang_kz;
|
||||
$mailReceipients .= $applicant->email . ';';
|
||||
$applicants_list .= '
|
||||
<tr ' . $rowstyle . '>
|
||||
<td>' . date_format(date_create($applicant->datum), 'd.m.Y') . '</td>
|
||||
<td>' . $applicant->uhrzeit . '</td>
|
||||
<td>' . $applicant->orgform_kurzbz . '</td>
|
||||
<td>' . $applicant->ausbildungssemester . '</td>
|
||||
<td>' . $applicant->nachname . '</td>
|
||||
<td>' . $applicant->vorname . '</td>
|
||||
<td>' . $applicant->zgv_kurzbz . '</td>
|
||||
<td>' . $applicant->prioritaet . '</td>
|
||||
<td>' . $applicant->qualifikationskurs . '</td>
|
||||
<td><a href="mailto:' . $applicant->email . '">' . $applicant->email . '</a></td>
|
||||
</tr>
|
||||
';
|
||||
};
|
||||
$bachelorStudiengang = $this->StudiengangModel->load($studiengang);
|
||||
$mailcontent .= $applicants_list;
|
||||
$mailcontent .= '</tbody></table>';
|
||||
$mailcontent .= '<p style="font-family: verdana, sans-serif;"><a href="mailto:?bcc=' . $mailReceipients . '">Mail an alle schicken</a></p>';
|
||||
$mailcontent_data_arr['table'] = $mailcontent;
|
||||
sendSanchoMail(
|
||||
'Sancho_ReihungstestteilnehmerJob',
|
||||
$mailcontent_data_arr,
|
||||
array($bachelorStudiengang->retval[0]->email,'kindlm@technikum-wien.at'),
|
||||
'InteressentIn nach Reihungstest-Anmeldeschluss hinzugefügt',
|
||||
'sancho_header_min_bw.jpg',
|
||||
'sancho_footer_min_bw.jpg');
|
||||
}
|
||||
}
|
||||
|
||||
public function runRemindApplicantsOfPlacementTestJob()
|
||||
{
|
||||
// Get placement tests with testdate within 3 working days
|
||||
|
||||
// Check if today +3 days is working day
|
||||
$todayPlus3 = date('Y-m-d', strtotime("+3 days"));
|
||||
|
||||
if (getWorkingDays($todayPlus3, $todayPlus3) == 0)
|
||||
{
|
||||
// If not increase counting days till next working day
|
||||
for ($i = 3; $i < 100; $i++)
|
||||
{
|
||||
$dateToCheck = date('Y-m-d', strtotime("+".$i." days"));
|
||||
if (getWorkingDays($dateToCheck, $dateToCheck) == 1)
|
||||
{
|
||||
$nextWorkingDay = $dateToCheck;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$nextWorkingDay = date('Y-m-d', strtotime("+3 days"));
|
||||
}
|
||||
|
||||
// Check if a placement test happens on $nextWorkingDay
|
||||
$result = $this->ReihungstestModel->getTestsOnDate($nextWorkingDay, 11000);
|
||||
|
||||
$testsOndate = array();
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
$testsOndate = $result->retval;
|
||||
}
|
||||
elseif (isError($result))
|
||||
{
|
||||
show_error($result->error);
|
||||
}
|
||||
|
||||
$applicants_arr = array();
|
||||
|
||||
foreach ($testsOndate as $reihungstest)
|
||||
{
|
||||
// Loads applicants of a test
|
||||
$applicants = $this->ReihungstestModel->getApplicantsOfPlacementTest($reihungstest->reihungstest_id);
|
||||
|
||||
if (hasData($applicants))
|
||||
{
|
||||
$applicants_arr = $applicants->retval;
|
||||
}
|
||||
elseif (isError($applicants))
|
||||
{
|
||||
show_error($applicants->error);
|
||||
}
|
||||
|
||||
foreach ($applicants_arr as $applicant)
|
||||
{
|
||||
$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;
|
||||
$mailcontent_data_arr['wegbeschreibung'] = $applicant->lageplan;
|
||||
|
||||
sendSanchoMail(
|
||||
'Sancho_RemindApplicantsOfTest',
|
||||
$mailcontent_data_arr,
|
||||
array($applicant->email,'kindlm@technikum-wien.at'),
|
||||
'Ihre Anmeldung zum Reihungstest - Reminder / Your registration for the placement test - Reminder');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Private methods
|
||||
/**
|
||||
@@ -118,7 +417,8 @@ class ReihungstestJob extends FHC_Controller
|
||||
// Prepare HTML table with study plans that have no placement tests yet
|
||||
if (!empty($missing_rt_arr))
|
||||
{
|
||||
$studienplan_list = '
|
||||
$studienplan_list
|
||||
= '
|
||||
<table'. $style_tbl2.'>
|
||||
';
|
||||
|
||||
|
||||
@@ -167,3 +167,100 @@ function isEmptyArray($array)
|
||||
{
|
||||
return ($array == null) || ($array != null && !is_array($array) || (is_array($array) && count($array) == 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* The function returns the number of business days between two dates and it skips the (static) holidays
|
||||
* @param string $startDate Date (YYYY-MM-DD) to start counting from (included)
|
||||
* @param string $endDate Date (YYYY-MM-DD) to end counting (included)
|
||||
* @param array $dynamic_holidays Optional. Static holidays that have the same date every year are included automatically.
|
||||
* You can give an array with dates (YYYY-MM-DD) that should be included furthermore
|
||||
* @return integer Number of working days between $startDate and $endDate
|
||||
*/
|
||||
function getWorkingDays($startDate, $endDate, $dynamic_holidays = array())
|
||||
{
|
||||
//Get year of $startDate
|
||||
$startYear = substr($startDate, 0, 4);
|
||||
//Get year of $endDate
|
||||
$endYear = substr($endDate, 0, 4);
|
||||
|
||||
$datediff = $endYear - $startYear;
|
||||
$austrian_holidays = array();
|
||||
for ($i = 0; $i <= $datediff; $i++)
|
||||
{
|
||||
$austrian_holidays[] = $startYear.'-01-01'; // Neujahr
|
||||
$austrian_holidays[] = $startYear.'-01-06'; // 3 Könige
|
||||
$austrian_holidays[] = $startYear.'-05-01'; // Staatsfeiertag
|
||||
$austrian_holidays[] = $startYear.'-08-15'; // Maria Himmelfahrt
|
||||
$austrian_holidays[] = $startYear.'-10-26'; // Nationalfeiertag
|
||||
$austrian_holidays[] = $startYear.'-11-01'; // Allerheiligen
|
||||
$austrian_holidays[] = $startYear.'-12-08'; // Maria Empfängnis
|
||||
$austrian_holidays[] = $startYear.'-12-25'; // Weihnachten
|
||||
$austrian_holidays[] = $startYear.'-12-26'; // Stefanitag
|
||||
$startYear++;
|
||||
}
|
||||
if (count($dynamic_holidays) > 0)
|
||||
{
|
||||
$austrian_holidays = array_merge($austrian_holidays, $dynamic_holidays);
|
||||
}
|
||||
// do strtotime calculations just once
|
||||
$endDate = strtotime($endDate);
|
||||
$startDate = strtotime($startDate);
|
||||
|
||||
//The total number of days between the two dates. We compute the no. of seconds and divide it to 60*60*24
|
||||
//We add one to inlude both dates in the interval.
|
||||
$days = ($endDate - $startDate) / 86400 + 1;
|
||||
|
||||
$no_full_weeks = floor($days / 7);
|
||||
$no_remaining_days = fmod($days, 7);
|
||||
|
||||
//It will return 1 if it's Monday,.. ,7 for Sunday
|
||||
$the_first_day_of_week = date("N", $startDate);
|
||||
$the_last_day_of_week = date("N", $endDate);
|
||||
|
||||
//---->The two can be equal in leap years when february has 29 days, the equal sign is added here
|
||||
//In the first case the whole interval is within a week, in the second case the interval falls in two weeks.
|
||||
if ($the_first_day_of_week <= $the_last_day_of_week)
|
||||
{
|
||||
if ($the_first_day_of_week <= 6 && 6 <= $the_last_day_of_week) $no_remaining_days--;
|
||||
if ($the_first_day_of_week <= 7 && 7 <= $the_last_day_of_week) $no_remaining_days--;
|
||||
}
|
||||
else {
|
||||
// (edit by Tokes to fix an edge case where the start day was a Sunday
|
||||
// and the end day was NOT a Saturday)
|
||||
|
||||
// the day of the week for start is later than the day of the week for end
|
||||
if ($the_first_day_of_week == 7) {
|
||||
// if the start date is a Sunday, then we definitely subtract 1 day
|
||||
$no_remaining_days--;
|
||||
|
||||
if ($the_last_day_of_week == 6) {
|
||||
// if the end date is a Saturday, then we subtract another day
|
||||
$no_remaining_days--;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// the start date was a Saturday (or earlier), and the end date was (Mon..Fri)
|
||||
// so we skip an entire weekend and subtract 2 days
|
||||
$no_remaining_days -= 2;
|
||||
}
|
||||
}
|
||||
|
||||
//The no. of business days is: (number of weeks between the two dates) * (5 working days) + the remainder
|
||||
//---->february in none leap years gave a remainder of 0 but still calculated weekends between first and last day, this is one way to fix it
|
||||
$workingDays = $no_full_weeks * 5;
|
||||
if ($no_remaining_days > 0 )
|
||||
{
|
||||
$workingDays += $no_remaining_days;
|
||||
}
|
||||
|
||||
//We subtract the holidays
|
||||
foreach($austrian_holidays as $key=>$value)
|
||||
{
|
||||
$time_stamp=strtotime($value);
|
||||
//If the holiday doesn't fall in weekend
|
||||
if ($startDate <= $time_stamp && $time_stamp <= $endDate && date("N",$time_stamp) != 6 && date("N",$time_stamp) != 7)
|
||||
$workingDays--;
|
||||
}
|
||||
|
||||
return $workingDays;
|
||||
}
|
||||
@@ -29,7 +29,7 @@ const DEFAULT_SANCHO_FOOTER_IMG = 'sancho_footer_DEFAULT.jpg';
|
||||
/**
|
||||
* Send single Mail with Sancho Design and Layout.
|
||||
* @param string $vorlage_kurzbz Name of the template for specific mail content.
|
||||
* @param array $vorlage_data Associative array with specific mail content varibales
|
||||
* @param array $vorlage_data Associative array with specific mail content variables
|
||||
* to be replaced in the content template.
|
||||
* @param string $to Email-adress.
|
||||
* @param string $subject Subject of mail.
|
||||
|
||||
@@ -224,4 +224,270 @@ class Reihungstest_model extends DB_Model
|
||||
|
||||
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.
|
||||
* @return array Returns object array with reihungstest_ids whose registration date has been reached yesterday.
|
||||
*/
|
||||
public function checkReachedRegistrationDate($studiengang_kz = null)
|
||||
{
|
||||
$query = '
|
||||
SELECT *
|
||||
FROM PUBLIC.tbl_reihungstest
|
||||
WHERE anmeldefrist = (
|
||||
SELECT CURRENT_DATE - 1
|
||||
)
|
||||
';
|
||||
|
||||
$parametersArray = array();
|
||||
|
||||
if (!isEmptyString($studiengang_kz))
|
||||
{
|
||||
$query .= ' AND studiengang_kz = ?';
|
||||
array_push($parametersArray, $studiengang_kz);
|
||||
}
|
||||
|
||||
return $this->execQuery($query, $parametersArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all applicants of a placement test for runZentraleReihungstestAnmeldefristAssistenzJob
|
||||
* @param integer $reihungstest_id ID of placement test
|
||||
* @return array Returns object array with data of applicants.
|
||||
*/
|
||||
public function getApplicantsOfPlacementTestForCronjob($reihungstest_id)
|
||||
{
|
||||
$query = '
|
||||
SELECT tbl_rt_person.person_id,
|
||||
ps.prestudent_id,
|
||||
tbl_studienplan.orgform_kurzbz,
|
||||
tbl_prestudentstatus.studienplan_id,
|
||||
tbl_prestudentstatus.ausbildungssemester,
|
||||
nachname,
|
||||
vorname,
|
||||
tbl_zgv.zgv_kurzbz,
|
||||
ps.studiengang_kz,
|
||||
CASE WHEN tbl_prestudentstatus.statusgrund_id=9
|
||||
THEN \'Ja\'
|
||||
ELSE \'Nein\'
|
||||
END AS "qualifikationskurs",
|
||||
(
|
||||
SELECT count(*) AS prio_relativ
|
||||
FROM (
|
||||
SELECT *,
|
||||
(
|
||||
SELECT status_kurzbz
|
||||
FROM PUBLIC.tbl_prestudentstatus
|
||||
WHERE prestudent_id = pst.prestudent_id
|
||||
ORDER BY datum DESC,
|
||||
tbl_prestudentstatus.insertamum DESC LIMIT 1
|
||||
) AS laststatus
|
||||
FROM PUBLIC.tbl_prestudent pst
|
||||
JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id)
|
||||
WHERE person_id = (
|
||||
SELECT person_id
|
||||
FROM PUBLIC.tbl_prestudent
|
||||
WHERE prestudent_id = ps.prestudent_id
|
||||
)
|
||||
AND studiensemester_kurzbz = (
|
||||
SELECT studiensemester_kurzbz
|
||||
FROM PUBLIC.tbl_prestudentstatus
|
||||
WHERE prestudent_id = ps.prestudent_id
|
||||
AND status_kurzbz = \'Interessent\' LIMIT 1
|
||||
)
|
||||
AND status_kurzbz = \'Interessent\'
|
||||
) prest
|
||||
WHERE laststatus NOT IN (\'Abbrecher\', \'Abgewiesener\', \'Absolvent\')
|
||||
AND priorisierung <= (
|
||||
SELECT priorisierung
|
||||
FROM PUBLIC.tbl_prestudent
|
||||
WHERE prestudent_id = ps.prestudent_id
|
||||
)
|
||||
) AS "prioritaet",
|
||||
(
|
||||
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"
|
||||
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)
|
||||
JOIN lehre.tbl_studienplan ON (tbl_prestudentstatus.studienplan_id = tbl_studienplan.studienplan_id)
|
||||
LEFT JOIN bis.tbl_zgv ON (ps.zgv_code = tbl_zgv.zgv_code)
|
||||
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 studiengang_kz,
|
||||
orgform_kurzbz,
|
||||
prioritaet,
|
||||
nachname,
|
||||
vorname,
|
||||
person_id
|
||||
';
|
||||
|
||||
return $this->execQuery($query, array($reihungstest_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an Applicant was assigned to a plament test after Anmeldefrist and before Test-Date
|
||||
* @param integer $studiengang_kz Kennzahl of degree program those tests should be checked
|
||||
* @return array Returns object array with data of applicants.
|
||||
*/
|
||||
public function getApplicantAssignedAfterDate($studiengang_kz)
|
||||
{
|
||||
$query = '
|
||||
SELECT tbl_rt_person.person_id,
|
||||
ps.prestudent_id,
|
||||
rt.datum,
|
||||
rt.uhrzeit,
|
||||
tbl_studienplan.orgform_kurzbz,
|
||||
tbl_prestudentstatus.studienplan_id,
|
||||
tbl_prestudentstatus.ausbildungssemester,
|
||||
nachname,
|
||||
vorname,
|
||||
tbl_zgv.zgv_kurzbz,
|
||||
ps.studiengang_kz,
|
||||
CASE WHEN tbl_prestudentstatus.statusgrund_id=9
|
||||
THEN \'Ja\'
|
||||
ELSE \'Nein\'
|
||||
END AS "qualifikationskurs",
|
||||
(
|
||||
SELECT count(*) AS prio_relativ
|
||||
FROM (
|
||||
SELECT *,
|
||||
(
|
||||
SELECT status_kurzbz
|
||||
FROM PUBLIC.tbl_prestudentstatus
|
||||
WHERE prestudent_id = pst.prestudent_id
|
||||
ORDER BY datum DESC,
|
||||
tbl_prestudentstatus.insertamum DESC LIMIT 1
|
||||
) AS laststatus
|
||||
FROM PUBLIC.tbl_prestudent pst
|
||||
JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id)
|
||||
WHERE person_id = (
|
||||
SELECT person_id
|
||||
FROM PUBLIC.tbl_prestudent
|
||||
WHERE prestudent_id = ps.prestudent_id
|
||||
)
|
||||
AND studiensemester_kurzbz = (
|
||||
SELECT studiensemester_kurzbz
|
||||
FROM PUBLIC.tbl_prestudentstatus
|
||||
WHERE prestudent_id = ps.prestudent_id
|
||||
AND status_kurzbz = \'Interessent\' LIMIT 1
|
||||
)
|
||||
AND status_kurzbz = \'Interessent\'
|
||||
) prest
|
||||
WHERE laststatus NOT IN (\'Abbrecher\', \'Abgewiesener\', \'Absolvent\')
|
||||
AND priorisierung <= (
|
||||
SELECT priorisierung
|
||||
FROM PUBLIC.tbl_prestudent
|
||||
WHERE prestudent_id = ps.prestudent_id
|
||||
)
|
||||
) AS "prioritaet",
|
||||
(
|
||||
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"
|
||||
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)
|
||||
JOIN lehre.tbl_studienplan ON (tbl_prestudentstatus.studienplan_id = tbl_studienplan.studienplan_id)
|
||||
LEFT JOIN bis.tbl_zgv ON (ps.zgv_code = tbl_zgv.zgv_code)
|
||||
WHERE rt.studiengang_kz = ?
|
||||
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
|
||||
AND anmeldefrist < (SELECT CURRENT_DATE)
|
||||
AND rt.datum > (SELECT CURRENT_DATE)
|
||||
--AND tbl_rt_person.insertamum > anmeldefrist
|
||||
--AND tbl_rt_person.insertamum < rt.datum
|
||||
AND tbl_rt_person.insertamum::date = (SELECT CURRENT_DATE -1)
|
||||
ORDER BY studiengang_kz,
|
||||
orgform_kurzbz,
|
||||
prioritaet,
|
||||
nachname,
|
||||
vorname,
|
||||
person_id
|
||||
';
|
||||
|
||||
return $this->execQuery($query, array($studiengang_kz));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all applicants of a placement test
|
||||
* @param integer $reihungstest_id ID of placement test
|
||||
* @return array Returns object array with data of applicants.
|
||||
*/
|
||||
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
|
||||
';
|
||||
|
||||
return $this->execQuery($query, array($reihungstest_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all placement tests of the given day and optional degree program
|
||||
* @param string $date Date of the tests to be loaded (YYYY-MM-DD)
|
||||
* @param integer $studiengang_kz Optional. Kennzahl of degree program to load
|
||||
* @return array Returns object array with data of applicants.
|
||||
*/
|
||||
public function getTestsOnDate($date, $studiengang_kz = null)
|
||||
{
|
||||
$query = '
|
||||
SELECT *
|
||||
FROM PUBLIC.tbl_reihungstest
|
||||
WHERE datum = ?
|
||||
AND studiengang_kz = ?
|
||||
';
|
||||
|
||||
return $this->execQuery($query, array($date, $studiengang_kz));
|
||||
}
|
||||
}
|
||||
@@ -429,4 +429,23 @@ class Studiengang_model extends DB_Model
|
||||
|
||||
return $this->execQuery($query, array($studiensemester_kurzbz));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads degree programs of the given type
|
||||
* @param string $typ Type of degree programs to be loaded
|
||||
* @return array
|
||||
*/
|
||||
public function loadStudiengaengeFromTyp($typ)
|
||||
{
|
||||
$query = "SELECT
|
||||
distinct tbl_studiengang.*
|
||||
FROM
|
||||
public.tbl_studiengang
|
||||
WHERE
|
||||
tbl_studiengang.typ=?
|
||||
ORDER BY
|
||||
kurzbz";
|
||||
|
||||
return $this->execQuery($query, array($typ));
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 58 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 21 KiB |
Reference in New Issue
Block a user