mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-23 18:02:18 +00:00
Merge branch 'feature-10965/beurteilungsformular_pdf_export' into feature-10963/Beurteilungsformular_datenbankanpassungen
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* FH-Complete
|
||||
*
|
||||
* @package FHC-API
|
||||
* @author FHC-Team
|
||||
* @copyright Copyright (c) 2021, fhcomplete.org
|
||||
* @license GPLv3
|
||||
* @link http://fhcomplete.org
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class AnrechnungJob extends JOB_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Grades in FAS to angerechnet if the request was successfull
|
||||
* @return void
|
||||
*/
|
||||
public function setAnrechnungGrades()
|
||||
{
|
||||
$this->logInfo('Start Anrechnung Grades Job');
|
||||
// get all accepted requests that are not in the grades table yet
|
||||
|
||||
// get all placement tests with incorrect studyplan
|
||||
$qry = "
|
||||
SELECT
|
||||
student_uid, lehrveranstaltung_id, studiensemester_kurzbz, genehmigt_von
|
||||
FROM
|
||||
lehre.tbl_anrechnung
|
||||
JOIN public.tbl_student USING(prestudent_id)
|
||||
WHERE
|
||||
genehmigt_von is not null
|
||||
AND EXISTS(
|
||||
SELECT 1 FROM lehre.tbl_anrechnung_anrechnungstatus
|
||||
WHERE anrechnung_id = tbl_anrechnung.anrechnung_id
|
||||
AND status_kurzbz='approved'
|
||||
AND datum>=now()-'5 days'::interval
|
||||
)
|
||||
AND NOT EXISTS(
|
||||
SELECT 1 FROM lehre.tbl_zeugnisnote
|
||||
WHERE
|
||||
lehrveranstaltung_id = tbl_anrechnung.lehrveranstaltung_id
|
||||
AND studiensemester_kurzbz = tbl_anrechnung.studiensemester_kurzbz
|
||||
AND student_uid = tbl_student.student_uid
|
||||
)
|
||||
";
|
||||
|
||||
$db = new DB_Model();
|
||||
$result_grades = $db->execReadOnlyQuery($qry);
|
||||
|
||||
$cnt = 0;
|
||||
if (hasData($result_grades))
|
||||
{
|
||||
$grades = getData($result_grades);
|
||||
foreach ($grades as $anrechnung)
|
||||
{
|
||||
$cnt++;
|
||||
// Set zeugnisnote to angerechnet (= note 6)
|
||||
$ret = $this->ZeugnisnoteModel->insert(array(
|
||||
'lehrveranstaltung_id' => $anrechnung->lehrveranstaltung_id,
|
||||
'student_uid' => $anrechnung->student_uid,
|
||||
'studiensemester_kurzbz' => $anrechnung->studiensemester_kurzbz,
|
||||
'uebernahmedatum' => (new DateTime())->format('Y-m-d H:m:i'),
|
||||
'benotungsdatum' => (new DateTime())->format('Y-m-d H:m:i'),
|
||||
'note' => 6,
|
||||
'insertvon' => $anrechnung->genehmigt_von,
|
||||
'bemerkung' => 'Digitale Anrechnung'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->logInfo('End Anrechnung Grades Job', array('Number of Grades added'=>$cnt));
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class ReihungstestJob extends CLI_Controller
|
||||
class ReihungstestJob extends JOB_Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
@@ -17,6 +17,7 @@ class ReihungstestJob extends CLI_Controller
|
||||
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
$this->load->model('organisation/Studienplan_model', 'StudienplanModel');
|
||||
$this->load->model('crm/buchungstyp_model', 'BuchungstypModel');
|
||||
|
||||
// Load helpers
|
||||
$this->load->helper('hlp_sancho_helper');
|
||||
@@ -799,24 +800,39 @@ class ReihungstestJob extends CLI_Controller
|
||||
* @param string $bcc. Optional. BCC-Mailadress to send the Mails to
|
||||
* @param string $from. Optional. Sender-Mailadress shown to recipient
|
||||
*/
|
||||
public function prioritizationJob($bcc = null, $from = null)
|
||||
public function prioritizationJob($studiensemester, $bcc = null, $from = null)
|
||||
{
|
||||
$qry = " SELECT DISTINCT
|
||||
get_rolle_prestudent (tbl_prestudent.prestudent_id, 'WS2020') AS laststatus, /* Todo: Studiensemester dynamisch ermitteln oder als Parameter */
|
||||
tbl_prestudentstatus.studiensemester_kurzbz,
|
||||
tbl_prestudent.*
|
||||
if (!isset($studiensemester) || isEmptyString($studiensemester))
|
||||
{
|
||||
$this->logError("Studiensemster not passed as parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
$qry = "WITH prst AS (
|
||||
SELECT DISTINCT
|
||||
get_rolle_prestudent (tbl_prestudent.prestudent_id, ?) AS laststatus,
|
||||
tbl_prestudentstatus.studiensemester_kurzbz,
|
||||
tbl_prestudentstatus.datum AS prestudenstatus_datum,
|
||||
tbl_prestudent.*,
|
||||
tbl_studiengang.typ AS studiengang_typ
|
||||
FROM PUBLIC.tbl_person
|
||||
JOIN PUBLIC.tbl_prestudent USING (person_id)
|
||||
JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id)
|
||||
JOIN lehre.tbl_studienplan USING (studienplan_id)
|
||||
JOIN lehre.tbl_studienordnung USING (studienordnung_id)
|
||||
JOIN PUBLIC.tbl_studiengang ON (tbl_studienordnung.studiengang_kz = tbl_studiengang.studiengang_kz)
|
||||
WHERE tbl_prestudentstatus.datum >= (SELECT CURRENT_DATE -1)
|
||||
AND get_rolle_prestudent (tbl_prestudent.prestudent_id, 'WS2020') IN ('Aufgenommener','Bewerber','Wartender')
|
||||
AND studiensemester_kurzbz = 'WS2020' /* Todo: Studiensemester dynamisch ermitteln oder als Parameter */
|
||||
AND tbl_studiengang.typ = 'b'
|
||||
ORDER BY studiengang_kz, laststatus
|
||||
";
|
||||
JOIN PUBLIC.tbl_prestudent USING (person_id)
|
||||
JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id)
|
||||
JOIN lehre.tbl_studienplan USING (studienplan_id)
|
||||
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 tbl_studiengang.typ IN ('b', 'm')
|
||||
)
|
||||
SELECT * FROM prst
|
||||
WHERE prestudenstatus_datum >= (SELECT CURRENT_DATE - 1)
|
||||
AND (studiengang_typ = 'b' OR (studiengang_typ = 'm' AND EXISTS (SELECT 1 /* Master Studiengänge berücksichtigen wenn auch Bachelor im gleichen Semester */
|
||||
FROM prst prstb
|
||||
WHERE studiengang_typ = 'b'
|
||||
AND laststatus != 'Abgewiesener'
|
||||
AND prstb.person_id = prst.person_id )))
|
||||
ORDER BY studiengang_kz, laststatus";
|
||||
|
||||
// Encode Params
|
||||
if ($bcc != '')
|
||||
@@ -837,26 +853,22 @@ class ReihungstestJob extends CLI_Controller
|
||||
}
|
||||
|
||||
$db = new DB_Model();
|
||||
$result_prestudents = $db->execReadOnlyQuery($qry);
|
||||
$result_prestudents = $db->execReadOnlyQuery($qry, array_pad(array(), 3, $studiensemester));
|
||||
$mailArray = array();
|
||||
|
||||
if (hasdata($result_prestudents))
|
||||
{
|
||||
foreach ($result_prestudents->retval as $row_ps)
|
||||
{
|
||||
// Wenn der letzte Status "Aufgenommener" ist, alle niedrigeren Prios auf "Abgewiesen" setzen
|
||||
// falls diese Bewerber oder Warteliste sind
|
||||
// Danach Kaution einbuchen
|
||||
if ($row_ps->laststatus == 'Aufgenommener')
|
||||
{
|
||||
// Alle niedrigeren Prios laden
|
||||
$qryNiedrPrios = "
|
||||
// Alle niedrigeren Prios laden
|
||||
$qryNiedrPrios = "
|
||||
SELECT DISTINCT
|
||||
get_rolle_prestudent (tbl_prestudent.prestudent_id, '".$row_ps->studiensemester_kurzbz."') AS laststatus,
|
||||
tbl_studienplan.orgform_kurzbz,
|
||||
tbl_person.nachname,
|
||||
tbl_person.vorname,
|
||||
tbl_prestudent.*
|
||||
tbl_prestudent.*,
|
||||
tbl_studiengang.typ AS studiengang_typ
|
||||
FROM PUBLIC.tbl_person
|
||||
JOIN PUBLIC.tbl_prestudent USING (person_id)
|
||||
JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id)
|
||||
@@ -866,18 +878,30 @@ class ReihungstestJob extends CLI_Controller
|
||||
AND tbl_prestudent.prestudent_id != ".$row_ps->prestudent_id."
|
||||
AND get_rolle_prestudent (tbl_prestudent.prestudent_id, '".$row_ps->studiensemester_kurzbz."') IN ('Aufgenommener','Bewerber','Wartender')
|
||||
AND studiensemester_kurzbz = '".$row_ps->studiensemester_kurzbz."'
|
||||
AND tbl_studiengang.typ = 'b'
|
||||
AND tbl_studiengang.typ IN ('b', 'm')
|
||||
AND priorisierung > ".$row_ps->priorisierung."
|
||||
ORDER BY studiengang_kz, laststatus
|
||||
";
|
||||
|
||||
// Wenn der letzte Status "Aufgenommener" ist, alle niedrigeren Prios auf "Abgewiesen" setzen
|
||||
// falls diese Bewerber oder Warteliste sind
|
||||
// Danach Kaution einbuchen
|
||||
if ($row_ps->laststatus == 'Aufgenommener')
|
||||
{
|
||||
$resultNiedrPrios = $db->execReadOnlyQuery($qryNiedrPrios);
|
||||
|
||||
if (hasdata($resultNiedrPrios))
|
||||
{
|
||||
foreach ($resultNiedrPrios->retval as $rowNiedrPrios)
|
||||
{
|
||||
if ($rowNiedrPrios->laststatus == 'Bewerber')
|
||||
// nur Info wenn aufgenommen oder master
|
||||
if ($rowNiedrPrios->laststatus == 'Aufgenommener' || $rowNiedrPrios->studiengang_typ == 'm')
|
||||
{
|
||||
// Mail zur Info an Assistenz schicken, dass in höherer Prio aufgenommen wurde
|
||||
$mailArray[$rowNiedrPrios->studiengang_kz][$rowNiedrPrios->orgform_kurzbz]['AufnahmeHoeherePrio'][]
|
||||
= $rowNiedrPrios->nachname.' '.$rowNiedrPrios->vorname.' ('.$rowNiedrPrios->prestudent_id.')';
|
||||
}
|
||||
elseif ($rowNiedrPrios->laststatus == 'Bewerber')
|
||||
{
|
||||
// Abgewiesenen-Status mit Statusgrund "Aufnahme anderer Studiengang" (ID 5) setzen
|
||||
$lastStatus = $this->PrestudentstatusModel->getLastStatus($rowNiedrPrios->prestudent_id);
|
||||
@@ -929,43 +953,63 @@ class ReihungstestJob extends CLI_Controller
|
||||
= $rowNiedrPrios->nachname.' '.$rowNiedrPrios->vorname.' ('.$rowNiedrPrios->prestudent_id.')';
|
||||
}
|
||||
}
|
||||
elseif ($rowNiedrPrios->laststatus == 'Aufgenommener')
|
||||
{
|
||||
// Mail zur Info an Assistenz schicken, dass in höherer Prio aufgenommen wurde
|
||||
$mailArray[$rowNiedrPrios->studiengang_kz][$rowNiedrPrios->orgform_kurzbz]['AufnahmeHoeherePrio'][]
|
||||
= $rowNiedrPrios->nachname.' '.$rowNiedrPrios->vorname.' ('.$rowNiedrPrios->prestudent_id.')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Kaution einbuchen für $row_ps->prestudent_id
|
||||
// Kaution einbuchen für $row_ps->prestudent_id (für aufgenommenen Bachelor)
|
||||
// Vorher prüfen, ob schon eine Kaution gebucht ist
|
||||
// Todo: Betrag automatisch aus tbl_buchungstyp laden
|
||||
|
||||
$qryKautionExists = "
|
||||
if ($row_ps->studiengang_typ == 'b')
|
||||
{
|
||||
$qryKautionExists = "
|
||||
SELECT count(*) as anzahl
|
||||
FROM public.tbl_konto
|
||||
WHERE person_id = ".$row_ps->person_id."
|
||||
AND studiensemester_kurzbz = '".$row_ps->studiensemester_kurzbz."'
|
||||
AND buchungstyp_kurzbz = 'Kaution'";
|
||||
WHERE person_id = " . $row_ps->person_id . "
|
||||
AND studiensemester_kurzbz = '" . $row_ps->studiensemester_kurzbz . "'
|
||||
AND buchungstyp_kurzbz = 'StudiengebuehrAnzahlung'";
|
||||
|
||||
$resultKautionExists = $db->execReadOnlyQuery($qryKautionExists);
|
||||
if (hasdata($resultKautionExists))
|
||||
{
|
||||
if ($resultKautionExists->retval[0]->anzahl == '0')
|
||||
$resultKautionExists = $db->execReadOnlyQuery($qryKautionExists);
|
||||
if (hasdata($resultKautionExists))
|
||||
{
|
||||
// Todo: Zahlungsreferenz generieren (StudiengangsOE+Buchungsnummer)
|
||||
$this->KontoModel->insert(array(
|
||||
"person_id" => $row_ps->person_id,
|
||||
"studiengang_kz" => $row_ps->studiengang_kz,
|
||||
"studiensemester_kurzbz" => $row_ps->studiensemester_kurzbz,
|
||||
"betrag" => -150,
|
||||
"buchungsdatum" => date('Y-m-d'),
|
||||
"buchungstext" => 'Kaution',
|
||||
"buchungstyp_kurzbz" => 'Kaution',
|
||||
"insertvon" => 'prioritizationJob',
|
||||
"insertamum" => date('Y-m-d H:i:s')
|
||||
));
|
||||
if ($resultKautionExists->retval[0]->anzahl == '0')
|
||||
{
|
||||
// Betrag automatisch aus tbl_buchungstyp laden
|
||||
$this->BuchungstypModel->addSelect('buchungstyp_kurzbz, standardbetrag, standardtext');
|
||||
$buchungstypRes = $this->BuchungstypModel->loadWhere(array('buchungstyp_kurzbz' => 'StudiengebuehrAnzahlung'));
|
||||
|
||||
if (hasData($buchungstypRes))
|
||||
{
|
||||
$buchungstypData = getData($buchungstypRes)[0];
|
||||
|
||||
$this->KontoModel->insert(array(
|
||||
"person_id" => $row_ps->person_id,
|
||||
"studiengang_kz" => $row_ps->studiengang_kz,
|
||||
"studiensemester_kurzbz" => $row_ps->studiensemester_kurzbz,
|
||||
"betrag" => $buchungstypData->standardbetrag,
|
||||
"buchungsdatum" => date('Y-m-d'),
|
||||
"buchungstext" => $buchungstypData->standardtext,
|
||||
"buchungstyp_kurzbz" => $buchungstypData->buchungstyp_kurzbz,
|
||||
"insertvon" => 'prioritizationJob',
|
||||
"insertamum" => date('Y-m-d H:i:s')
|
||||
));
|
||||
}
|
||||
else
|
||||
$this->logError('No Buchungstyp found for Studiengebühr Anzahlung');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($row_ps->laststatus == 'Abgewiesener')
|
||||
{
|
||||
$resultNiedrPrios = $db->execReadOnlyQuery($qryNiedrPrios);
|
||||
|
||||
if (hasdata($resultNiedrPrios))
|
||||
{
|
||||
foreach ($resultNiedrPrios->retval as $rowNiedrPrios)
|
||||
{
|
||||
// Mail zur Info an Assistenz schicken, dass in höherer Prio abgewiesen wurde
|
||||
$mailArray[$rowNiedrPrios->studiengang_kz][$rowNiedrPrios->orgform_kurzbz]['AbgewiesenHoeherePrio'][]
|
||||
= $rowNiedrPrios->nachname . ' ' . $rowNiedrPrios->vorname . ' (' . $rowNiedrPrios->prestudent_id . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1015,6 +1059,19 @@ class ReihungstestJob extends CLI_Controller
|
||||
}
|
||||
$mailcontent .= '</tbody></table>';
|
||||
}
|
||||
if (isset($value['AbgewiesenHoeherePrio']) && !isEmptyArray($value['AbgewiesenHoeherePrio']))
|
||||
{
|
||||
$mailcontent .= '<p style="font-family: verdana, sans-serif;">
|
||||
Folgende Bewerber wurden in einem höher priorisierten Studiengang abgewiesen:</p>';
|
||||
$mailcontent .= '<table style="border-collapse: collapse; border: 1px solid grey;">';
|
||||
$mailcontent .= ' <tbody>';
|
||||
sort($value['AbgewiesenHoeherePrio']);
|
||||
foreach ($value['AbgewiesenHoeherePrio'] AS $key=>$bewerber)
|
||||
{
|
||||
$mailcontent .= '<tr><td style="font-family: verdana, sans-serif; border: 1px solid grey; padding: 3px">'.$bewerber.'</td></tr>';
|
||||
}
|
||||
$mailcontent .= '</tbody></table>';
|
||||
}
|
||||
if ($bcc != '' && isset($value['AbgewiesenWeilBewerber']) && !isEmptyArray($value['AbgewiesenWeilBewerber']))
|
||||
{
|
||||
$mailcontent .= '<p style="font-family: verdana, sans-serif;">
|
||||
|
||||
@@ -0,0 +1,531 @@
|
||||
<?php
|
||||
|
||||
//if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class approveAnrechnungDetail extends Auth_Controller
|
||||
{
|
||||
const BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN = 'lehre/anrechnung_genehmigen';
|
||||
|
||||
const REVIEW_ANRECHNUNG_URI = '/lehre/anrechnung/ReviewAnrechnungUebersicht';
|
||||
|
||||
const ANRECHNUNGSTATUS_PROGRESSED_BY_STGL = 'inProgressDP';
|
||||
const ANRECHNUNGSTATUS_PROGRESSED_BY_KF = 'inProgressKF';
|
||||
const ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR = 'inProgressLektor';
|
||||
const ANRECHNUNGSTATUS_APPROVED = 'approved';
|
||||
const ANRECHNUNGSTATUS_REJECTED = 'rejected';
|
||||
|
||||
const ANRECHNUNG_NOTIZTITEL_NOTIZ_BY_STGL = 'AnrechnungNotizSTGL';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Set required permissions
|
||||
parent::__construct(
|
||||
array(
|
||||
'index' => 'lehre/anrechnung_genehmigen:rw',
|
||||
'download' => 'lehre/anrechnung_genehmigen:rw',
|
||||
'approve' => 'lehre/anrechnung_genehmigen:rw',
|
||||
'reject' => 'lehre/anrechnung_genehmigen:rw',
|
||||
'requestRecommendation' => 'lehre/anrechnung_genehmigen:rw'
|
||||
)
|
||||
);
|
||||
|
||||
// Load models
|
||||
$this->load->model('education/Anrechnung_model', 'AnrechnungModel');
|
||||
$this->load->model('education/Anrechnungstatus_model', 'AnrechnungstatusModel');
|
||||
$this->load->model('content/DmsVersion_model', 'DmsVersionModel');
|
||||
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
|
||||
// Load libraries
|
||||
$this->load->library('WidgetLib');
|
||||
$this->load->library('PermissionLib');
|
||||
$this->load->library('AnrechnungLib');
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
// Load helpers
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->helper('hlp_sancho_helper');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'global',
|
||||
'ui',
|
||||
'anrechnung',
|
||||
'person',
|
||||
'lehre',
|
||||
'table'
|
||||
)
|
||||
);
|
||||
|
||||
$this->_setAuthUID();
|
||||
|
||||
$this->setControllerId();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$anrechnung_id = $this->input->get('anrechnung_id');
|
||||
|
||||
if (!is_numeric($anrechnung_id))
|
||||
{
|
||||
show_error('Missing correct parameter');
|
||||
}
|
||||
|
||||
// Check if user is entitled to read the Anrechnung
|
||||
self::_checkIfEntitledToReadAnrechnung($anrechnung_id);
|
||||
|
||||
// Get Anrechung data
|
||||
if (!$anrechnungData = getData($this->anrechnunglib->getAnrechnungData($anrechnung_id)))
|
||||
{
|
||||
show_error('Missing data for Anrechnung.');
|
||||
}
|
||||
|
||||
// Get Empfehlung data
|
||||
if(!$empfehlungData = getData($this->anrechnunglib->getEmpfehlungData($anrechnung_id)))
|
||||
{
|
||||
show_error('Missing data for recommendation');
|
||||
}
|
||||
|
||||
// Get Genehmigung data
|
||||
if(!$genehmigungData = getData($this->anrechnunglib->getGenehmigungData($anrechnung_id)))
|
||||
{
|
||||
show_error('Missing data for recommendation');
|
||||
}
|
||||
|
||||
$viewData = array(
|
||||
'antragData' => $this->anrechnunglib->getAntragData(
|
||||
$student_uid = $this->StudentModel->getUID($anrechnungData->prestudent_id),
|
||||
$anrechnungData->studiensemester_kurzbz,
|
||||
$anrechnungData->lehrveranstaltung_id
|
||||
),
|
||||
'anrechnungData' => $anrechnungData,
|
||||
'empfehlungData' => $empfehlungData,
|
||||
'genehmigungData' => $genehmigungData
|
||||
);
|
||||
|
||||
$this->load->view('lehre/anrechnung/approveAnrechnungDetail.php', $viewData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve Anrechnungen.
|
||||
*/
|
||||
public function approve()
|
||||
{
|
||||
$data = $this->input->post('data');
|
||||
|
||||
if(isEmptyArray($data))
|
||||
{
|
||||
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
|
||||
}
|
||||
|
||||
// Get statusbezeichnung for 'approved'
|
||||
$this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
|
||||
$approved = getData($this->AnrechnungstatusModel->load('approved'))[0];
|
||||
$approved = getUserLanguage() == 'German'
|
||||
? $approved->bezeichnung_mehrsprachig[0]
|
||||
: $approved->bezeichnung_mehrsprachig[1];
|
||||
|
||||
if (!$person = getData($this->PersonModel->getByUID($this->_uid))[0])
|
||||
{
|
||||
show_error('Failed retrieving person data');
|
||||
}
|
||||
|
||||
foreach ($data as $item)
|
||||
{
|
||||
// Approve Anrechnung
|
||||
if(getData($this->anrechnunglib->approveAnrechnung($item['anrechnung_id'])))
|
||||
{
|
||||
$json[]= array(
|
||||
'anrechnung_id' => $item['anrechnung_id'],
|
||||
'status_kurzbz' => self::ANRECHNUNGSTATUS_APPROVED,
|
||||
'status_bezeichnung' => $approved,
|
||||
'abgeschlossen_am' => (new DateTime())->format('d.m.Y'),
|
||||
'abgeschlossen_von' => $person->vorname. ' '. $person->nachname
|
||||
);
|
||||
|
||||
if(!$this->_sendSanchoMailToStudent($item['anrechnung_id'], self::ANRECHNUNGSTATUS_APPROVED))
|
||||
{
|
||||
show_error('Failed sending mail');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Output json to ajax
|
||||
if (isset($json) && !isEmptyArray($json))
|
||||
{
|
||||
return $this->outputJsonSuccess($json);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->outputJsonError('Es wurden keine Anrechnungen genehmigt.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reject Anrechnungen.
|
||||
*/
|
||||
public function reject()
|
||||
{
|
||||
$data = $this->input->post('data');
|
||||
|
||||
if(isEmptyArray($data))
|
||||
{
|
||||
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
|
||||
}
|
||||
|
||||
// Get statusbezeichnung for 'rejected'
|
||||
$this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
|
||||
$rejected = getData($this->AnrechnungstatusModel->load('rejected'))[0];
|
||||
$rejected = getUserLanguage() == 'German'
|
||||
? $rejected->bezeichnung_mehrsprachig[0]
|
||||
: $rejected->bezeichnung_mehrsprachig[1];
|
||||
|
||||
if (!$person = getData($this->PersonModel->getByUID($this->_uid))[0])
|
||||
{
|
||||
show_error('Failed retrieving person data');
|
||||
}
|
||||
|
||||
foreach ($data as $item)
|
||||
{
|
||||
// Reject Anrechnung
|
||||
if(getData($this->anrechnunglib->rejectAnrechnung($item['anrechnung_id'], $item['begruendung'])))
|
||||
{
|
||||
$json[]= array(
|
||||
'anrechnung_id' => $item['anrechnung_id'],
|
||||
'status_kurzbz' => self::ANRECHNUNGSTATUS_REJECTED,
|
||||
'status_bezeichnung' => $rejected,
|
||||
'abgeschlossen_am' => (new DateTime())->format('d.m.Y'),
|
||||
'abgeschlossen_von' => $person->vorname. ' '. $person->nachname
|
||||
);
|
||||
|
||||
if(!$this->_sendSanchoMailToStudent($item['anrechnung_id'], self::ANRECHNUNGSTATUS_REJECTED))
|
||||
{
|
||||
show_error('Failed sending mail');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Output json to ajax
|
||||
if (isset($json) && !isEmptyArray($json))
|
||||
{
|
||||
return $this->outputJsonSuccess($json);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->outputJsonError('Es wurden keine Anrechnungen genehmigt.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request recommendation for Anrechnungen.
|
||||
*/
|
||||
public function requestRecommendation()
|
||||
{
|
||||
$data = $this->input->post('data');
|
||||
|
||||
if(isEmptyArray($data))
|
||||
{
|
||||
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
|
||||
}
|
||||
|
||||
// Get statusbezeichnung for 'inProgressLektor'
|
||||
$this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
|
||||
$inProgressLektor = getData($this->AnrechnungstatusModel->load('inProgressLektor'))[0];
|
||||
$inProgressLektor = getUserLanguage() == 'German'
|
||||
? $inProgressLektor->bezeichnung_mehrsprachig[0]
|
||||
: $inProgressLektor->bezeichnung_mehrsprachig[1];
|
||||
|
||||
foreach ($data as $item)
|
||||
{
|
||||
// Approve Anrechnung
|
||||
if(getData($this->anrechnunglib->requestRecommendation($item['anrechnung_id'])))
|
||||
{
|
||||
$json[]= array(
|
||||
'anrechnung_id' => $item['anrechnung_id'],
|
||||
'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR,
|
||||
'status_bezeichnung' => $inProgressLektor,
|
||||
'empfehlung_anrechnung' => null,
|
||||
'empfehlung_angefordert_am' => (new DateTime())->format('d.m.Y')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Output json to ajax
|
||||
if (isset($json) && !isEmptyArray($json))
|
||||
{
|
||||
/**
|
||||
* Send mails to lectors
|
||||
* NOTE: mails are sent at the end to ensure sending only ONE mail to each LV-Leitung or lector
|
||||
* even if they are required for more recommendations
|
||||
* */
|
||||
if (!$this->_sendSanchoMailToLectors($json))
|
||||
{
|
||||
show_error('Failed sending emails');
|
||||
}
|
||||
|
||||
return $this->outputJsonSuccess($json);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->outputJsonError('Es wurden keine Empfehlungen angefordert');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download and open uploaded document (Nachweisdokument).
|
||||
*/
|
||||
public function download()
|
||||
{
|
||||
$dms_id = $this->input->get('dms_id');
|
||||
|
||||
if (!is_numeric($dms_id))
|
||||
{
|
||||
show_error('Wrong parameter');
|
||||
}
|
||||
|
||||
// Check if user is entitled to read dms doc
|
||||
self::_checkIfEntitledToReadDMSDoc($dms_id);
|
||||
|
||||
$this->dmslib->download($dms_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the UID of the logged user and checks if it is valid
|
||||
*/
|
||||
private function _setAuthUID()
|
||||
{
|
||||
$this->_uid = getAuthUID();
|
||||
|
||||
if (!$this->_uid) show_error('User authentification failed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user is entitled to read this Anrechnung
|
||||
* @param $anrechnung_id
|
||||
*/
|
||||
private function _checkIfEntitledToReadAnrechnung($anrechnung_id)
|
||||
{
|
||||
$result = $this->AnrechnungModel->load($anrechnung_id);
|
||||
|
||||
if(!$result = getData($result)[0])
|
||||
{
|
||||
show_error('Failed loading Anrechnung');
|
||||
}
|
||||
|
||||
$result = $this->LehrveranstaltungModel->loadWhere(array(
|
||||
'lehrveranstaltung_id' => $result->lehrveranstaltung_id
|
||||
));
|
||||
|
||||
if(!$result = getData($result)[0])
|
||||
{
|
||||
show_error('Failed loading Lehrveranstaltung');
|
||||
}
|
||||
|
||||
// Get STGL
|
||||
$result = $this->StudiengangModel->getLeitung($result->studiengang_kz);
|
||||
|
||||
if($result = getData($result)[0])
|
||||
{
|
||||
if ($result->uid == $this->_uid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
show_error('You are not entitled to read this Anrechnung');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user is entitled to read dms doc
|
||||
* @param $dms_id
|
||||
*/
|
||||
private function _checkIfEntitledToReadDMSDoc($dms_id)
|
||||
{
|
||||
$result = $this->AnrechnungModel->loadWhere(array('dms_id' => $dms_id));
|
||||
|
||||
if(!$result = getData($result)[0])
|
||||
{
|
||||
show_error('Failed retrieving Anrechnung');
|
||||
}
|
||||
|
||||
$result = $this->LehrveranstaltungModel->loadWhere(array(
|
||||
'lehrveranstaltung_id' => $result->lehrveranstaltung_id
|
||||
));
|
||||
|
||||
if(!$result = getData($result)[0])
|
||||
{
|
||||
show_error('Failed loading Lehrveranstaltung');
|
||||
}
|
||||
|
||||
// Get STGL
|
||||
$result = $this->StudiengangModel->getLeitung($result->studiengang_kz);
|
||||
|
||||
if($result = getData($result)[0])
|
||||
{
|
||||
if ($result->uid == $this->_uid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
show_error('You are not entitled to read this document');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send mail to student to inform if Anrechnung was approved or rejected
|
||||
* @param $mail_params
|
||||
*/
|
||||
private function _sendSanchoMailToStudent($anrechnung_id, $status_kurzbz)
|
||||
{
|
||||
$result = getData($this->anrechnunglib->getStudentData($anrechnung_id))[0];
|
||||
|
||||
// Get student name and mail address
|
||||
$to = $result->uid. '@'. DOMAIN;
|
||||
|
||||
$anrede = $result->geschlecht == 'w' ? 'Sehr geehrte Frau ' : 'Sehr geehrter Herr ';
|
||||
|
||||
$text = $status_kurzbz == self::ANRECHNUNGSTATUS_APPROVED
|
||||
? 'Ihrem Antrag auf Anerkennung nachgewiesener Kenntnisse der Lehrveranstaltung "'.
|
||||
$result->lv_bezeichnung. '" wurde stattgegeben.'
|
||||
: 'wir haben Ihren Antrag auf Anerkennung nachgewiesener Kenntnisse geprüft und können die Lehrveranstaltung "'.
|
||||
$result->lv_bezeichnung. '" leider nicht anrechnen, weil die Gleichwertigkeit nicht festgestellt werden konnte.';
|
||||
|
||||
// Prepare mail content
|
||||
$body_fields = array(
|
||||
'anrede_name' => $anrede. $result->vorname. ' '. $result->nachname,
|
||||
'text' => $text
|
||||
);
|
||||
|
||||
sendSanchoMail(
|
||||
'AnrechnungGenehmigen',
|
||||
$body_fields,
|
||||
$to,
|
||||
'Anerkennung nachgewiesener Kenntnisse: Ihr Antrag ist abgeschlossen'
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send mail to lectors asking for recommendation. (first to LV-Leitung, if not present to all lectors of lv)
|
||||
* @param $mail_params
|
||||
* @return bool
|
||||
*/
|
||||
private function _sendSanchoMailToLectors($mail_params)
|
||||
{
|
||||
// Get Lehrveranstaltungen
|
||||
$anrechnung_arr = array();
|
||||
|
||||
foreach ($mail_params as $item)
|
||||
{
|
||||
$this->AnrechnungModel->addSelect('lehrveranstaltung_id, studiensemester_kurzbz');
|
||||
$anrechnung_arr[]= array(
|
||||
'lehrveranstaltung_id' => $this->AnrechnungModel->load($item['anrechnung_id'])->retval[0]->lehrveranstaltung_id,
|
||||
'studiensemester_kurzbz' => $this->AnrechnungModel->load($item['anrechnung_id'])->retval[0]->studiensemester_kurzbz
|
||||
);
|
||||
}
|
||||
|
||||
$anrechnung_arr = array_unique($anrechnung_arr, SORT_REGULAR);
|
||||
|
||||
|
||||
/**
|
||||
* Get lectors (prio for LV-Leitung, if not present to all lectors of LV.
|
||||
* Anyway this function will receive a unique array to avoid sending more mails to one and the same lector.
|
||||
* **/
|
||||
$lector_arr = $this->_getLectors($anrechnung_arr);
|
||||
|
||||
// Send mail to lectors
|
||||
foreach ($lector_arr as $lector)
|
||||
{
|
||||
$to = $lector->uid;
|
||||
$vorname = $lector->vorname;
|
||||
|
||||
// Get full name of stgl
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
if (!$stgl_name = getData($this->PersonModel->getFullName($this->_uid)))
|
||||
{
|
||||
show_error ('Failed retrieving person');
|
||||
}
|
||||
|
||||
// Link to Antrag genehmigen
|
||||
$url =
|
||||
CIS_ROOT. 'cis/index.php?menu='.
|
||||
CIS_ROOT. 'cis/menu.php?content_id=&content='.
|
||||
CIS_ROOT. index_page(). self::REVIEW_ANRECHNUNG_URI;
|
||||
|
||||
// Prepare mail content
|
||||
$body_fields = array(
|
||||
'vorname' => $vorname,
|
||||
'stgl_name' => $stgl_name,
|
||||
'link' => anchor($url, 'Anrechnungsanträge Übersicht')
|
||||
);
|
||||
|
||||
sendSanchoMail(
|
||||
'AnrechnungEmpfehlungAnfordern',
|
||||
$body_fields,
|
||||
$to,
|
||||
'Anerkennung nachgewiesener Kenntnisse: Deine Empfehlung wird benötigt'
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lectors (prio for LV-Leitung, if not present to all lectors of LV.
|
||||
* Anyway this function will receive a unique array to avoid sending more mails to one and the same lector.
|
||||
* @param $anrechnung_arr
|
||||
* @return array
|
||||
*/
|
||||
private function _getLectors($anrechnung_arr)
|
||||
{
|
||||
$lector_arr = array();
|
||||
|
||||
// Get lectors
|
||||
foreach($anrechnung_arr as $anrechnung)
|
||||
{
|
||||
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
$result = $this->LehrveranstaltungModel->getLecturersByLv($anrechnung['studiensemester_kurzbz'], $anrechnung['lehrveranstaltung_id']);
|
||||
|
||||
if (!$result = getData($result))
|
||||
{
|
||||
show_error('Failed retrieving lectors of Lehrveranstaltung');
|
||||
}
|
||||
|
||||
// Check if lv has LV-Leitung
|
||||
$key = array_search(true, array_column($result, 'lvleiter'));
|
||||
|
||||
// If lv has LV-Leitung, keep only the one
|
||||
if ($key !== false)
|
||||
{
|
||||
$lector_arr[]= $result[$key];
|
||||
}
|
||||
// ...otherwise keep all lectors
|
||||
else
|
||||
{
|
||||
$lector_arr = array_merge($lector_arr, $result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTE: This step is only done to make the array unique by uid, vorname and nachname in the following step
|
||||
* (e.g. if same lector is ones LV-Leitung and another time not, then array_unique would leave both.
|
||||
* But we wish to send only one email by to that one person)
|
||||
* **/
|
||||
foreach ($lector_arr as $lector)
|
||||
{
|
||||
unset($lector->lvleiter);
|
||||
}
|
||||
|
||||
// Now make the lector array aka mail receivers unique
|
||||
$lector_arr = array_unique($lector_arr, SORT_REGULAR);
|
||||
|
||||
return $lector_arr;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,461 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class approveAnrechnungUebersicht extends Auth_Controller
|
||||
{
|
||||
const BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN = 'lehre/anrechnung_genehmigen';
|
||||
|
||||
const REVIEW_ANRECHNUNG_URI = '/lehre/anrechnung/ReviewAnrechnungUebersicht';
|
||||
|
||||
const ANRECHNUNGSTATUS_PROGRESSED_BY_STGL = 'inProgressDP';
|
||||
const ANRECHNUNGSTATUS_PROGRESSED_BY_KF = 'inProgressKF';
|
||||
const ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR = 'inProgressLektor';
|
||||
const ANRECHNUNGSTATUS_APPROVED = 'approved';
|
||||
const ANRECHNUNGSTATUS_REJECTED = 'rejected';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Set required permissions
|
||||
parent::__construct(
|
||||
array(
|
||||
'index' => 'lehre/anrechnung_genehmigen:rw',
|
||||
'download' => 'lehre/anrechnung_genehmigen:rw',
|
||||
'approve' => 'lehre/anrechnung_genehmigen:rw',
|
||||
'reject' => 'lehre/anrechnung_genehmigen:rw',
|
||||
'requestRecommendation' => 'lehre/anrechnung_genehmigen:rw'
|
||||
)
|
||||
);
|
||||
|
||||
// Load models
|
||||
$this->load->model('education/Anrechnung_model', 'AnrechnungModel');
|
||||
$this->load->model('education/Anrechnungstatus_model', 'AnrechnungstatusModel');
|
||||
$this->load->model('content/DmsVersion_model', 'DmsVersionModel');
|
||||
|
||||
// Load libraries
|
||||
$this->load->library('WidgetLib');
|
||||
$this->load->library('PermissionLib');
|
||||
$this->load->library('AnrechnungLib');
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
// Load helpers
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->helper('hlp_sancho_helper');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'global',
|
||||
'ui',
|
||||
'anrechnung',
|
||||
'person',
|
||||
'lehre',
|
||||
'table'
|
||||
)
|
||||
);
|
||||
|
||||
$this->_setAuthUID();
|
||||
|
||||
$this->setControllerId();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$studiensemester_kurzbz = $this->input->get('studiensemester');
|
||||
|
||||
// Retrieve studiengaenge the user is entitled for
|
||||
if (!$studiengang_kz_arr = $this->permissionlib->getSTG_isEntitledFor(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN))
|
||||
{
|
||||
show_error(getError($studiengang_kz_arr));
|
||||
}
|
||||
|
||||
if (!is_string($studiensemester_kurzbz))
|
||||
{
|
||||
$studiensemester = $this->StudiensemesterModel->getNearest();
|
||||
if (hasData($studiensemester))
|
||||
{
|
||||
$studiensemester_kurzbz = $studiensemester->retval[0]->studiensemester_kurzbz;
|
||||
}
|
||||
elseif (isError($studiensemester))
|
||||
{
|
||||
show_error(getError($studiensemester));
|
||||
}
|
||||
}
|
||||
|
||||
$viewData = array(
|
||||
'studiensemester_selected' => $studiensemester_kurzbz,
|
||||
'studiengaenge_entitled' => $studiengang_kz_arr
|
||||
);
|
||||
|
||||
$this->load->view('lehre/anrechnung/approveAnrechnungUebersicht.php', $viewData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve Anrechnungen.
|
||||
*/
|
||||
public function approve()
|
||||
{
|
||||
$data = $this->input->post('data');
|
||||
|
||||
if(isEmptyArray($data))
|
||||
{
|
||||
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
|
||||
}
|
||||
|
||||
// Get statusbezeichnung for 'approved'
|
||||
$this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
|
||||
$approved = getData($this->AnrechnungstatusModel->load('approved'))[0];
|
||||
$approved = getUserLanguage() == 'German'
|
||||
? $approved->bezeichnung_mehrsprachig[0]
|
||||
: $approved->bezeichnung_mehrsprachig[1];
|
||||
|
||||
foreach ($data as $item)
|
||||
{
|
||||
// Approve Anrechnung
|
||||
if(getData($this->anrechnunglib->approveAnrechnung($item['anrechnung_id'])))
|
||||
{
|
||||
$json[]= array(
|
||||
'anrechnung_id' => $item['anrechnung_id'],
|
||||
'status_kurzbz' => self::ANRECHNUNGSTATUS_APPROVED,
|
||||
'status_bezeichnung' => $approved
|
||||
);
|
||||
|
||||
if(!$this->_sendSanchoMailToStudent($item['anrechnung_id'], self::ANRECHNUNGSTATUS_APPROVED))
|
||||
{
|
||||
show_error('Failed sending mail');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Output json to ajax
|
||||
if (isset($json) && !isEmptyArray($json))
|
||||
{
|
||||
return $this->outputJsonSuccess($json);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->outputJsonError('Es wurden keine Anrechnungen genehmigt.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reject Anrechnungen.
|
||||
*/
|
||||
public function reject()
|
||||
{
|
||||
$data = $this->input->post('data');
|
||||
|
||||
if(isEmptyArray($data))
|
||||
{
|
||||
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
|
||||
}
|
||||
|
||||
// Get statusbezeichnung for 'rejected'
|
||||
$this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
|
||||
$rejected = getData($this->AnrechnungstatusModel->load('rejected'))[0];
|
||||
$rejected = getUserLanguage() == 'German'
|
||||
? $rejected->bezeichnung_mehrsprachig[0]
|
||||
: $rejected->bezeichnung_mehrsprachig[1];
|
||||
|
||||
foreach ($data as $item)
|
||||
{
|
||||
// Reject Anrechnung
|
||||
if(getData($this->anrechnunglib->rejectAnrechnung($item['anrechnung_id'], $item['begruendung'])))
|
||||
{
|
||||
$json[]= array(
|
||||
'anrechnung_id' => $item['anrechnung_id'],
|
||||
'status_kurzbz' => self::ANRECHNUNGSTATUS_REJECTED,
|
||||
'status_bezeichnung' => $rejected
|
||||
);
|
||||
|
||||
if(!$this->_sendSanchoMailToStudent($item['anrechnung_id'], self::ANRECHNUNGSTATUS_REJECTED))
|
||||
{
|
||||
show_error('Failed sending mail');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Output json to ajax
|
||||
if (isset($json) && !isEmptyArray($json))
|
||||
{
|
||||
return $this->outputJsonSuccess($json);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->outputJsonError('Es wurden keine Anrechnungen genehmigt.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request recommendation for Anrechnungen.
|
||||
*/
|
||||
public function requestRecommendation()
|
||||
{
|
||||
$data = $this->input->post('data');
|
||||
|
||||
if(isEmptyArray($data))
|
||||
{
|
||||
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
|
||||
}
|
||||
|
||||
// Get statusbezeichnung for 'inProgressLektor'
|
||||
$this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
|
||||
$inProgressLektor = getData($this->AnrechnungstatusModel->load('inProgressLektor'))[0];
|
||||
$inProgressLektor = getUserLanguage() == 'German'
|
||||
? $inProgressLektor->bezeichnung_mehrsprachig[0]
|
||||
: $inProgressLektor->bezeichnung_mehrsprachig[1];
|
||||
|
||||
foreach ($data as $item)
|
||||
{
|
||||
// Approve Anrechnung
|
||||
if(getData($this->anrechnunglib->requestRecommendation($item['anrechnung_id'])))
|
||||
{
|
||||
$json[]= array(
|
||||
'anrechnung_id' => $item['anrechnung_id'],
|
||||
'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR,
|
||||
'status_bezeichnung' => $inProgressLektor,
|
||||
'empfehlung_anrechnung' => null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Output json to ajax
|
||||
if (isset($json) && !isEmptyArray($json))
|
||||
{
|
||||
/**
|
||||
* Send mails to lectors
|
||||
* NOTE: mails are sent at the end to ensure sending only ONE mail to each LV-Leitung or lector
|
||||
* even if they are required for more recommendations
|
||||
* */
|
||||
if (!$this->_sendSanchoMailToLectors($json))
|
||||
{
|
||||
show_error('Failed sending emails');
|
||||
}
|
||||
|
||||
return $this->outputJsonSuccess($json);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->outputJsonError('Es wurden keine Empfehlungen angefordert');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download and open uploaded document (Nachweisdokument).
|
||||
*/
|
||||
public function download()
|
||||
{
|
||||
$dms_id = $this->input->get('dms_id');
|
||||
|
||||
if (!is_numeric($dms_id))
|
||||
{
|
||||
show_error('Wrong parameter');
|
||||
}
|
||||
|
||||
// Check if user is entitled to read dms doc
|
||||
self::_checkIfEntitledToReadDMSDoc($dms_id);
|
||||
|
||||
$this->dmslib->download($dms_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the UID of the logged user and checks if it is valid
|
||||
*/
|
||||
private function _setAuthUID()
|
||||
{
|
||||
$this->_uid = getAuthUID();
|
||||
|
||||
if (!$this->_uid) show_error('User authentification failed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user is entitled to read dms doc
|
||||
* @param $dms_id
|
||||
*/
|
||||
private function _checkIfEntitledToReadDMSDoc($dms_id)
|
||||
{
|
||||
$result = $this->AnrechnungModel->loadWhere(array('dms_id' => $dms_id));
|
||||
|
||||
if(!$result = getData($result)[0])
|
||||
{
|
||||
show_error('Failed retrieving Anrechnung');
|
||||
}
|
||||
|
||||
$result = $this->LehrveranstaltungModel->loadWhere(array(
|
||||
'lehrveranstaltung_id' => $result->lehrveranstaltung_id
|
||||
));
|
||||
|
||||
|
||||
if(!$result = getData($result)[0])
|
||||
{
|
||||
show_error('Failed loading Lehrveranstaltung');
|
||||
}
|
||||
|
||||
// Get STGL
|
||||
$result = $this->StudiengangModel->getLeitung($result->studiengang_kz);
|
||||
|
||||
if($result = getData($result)[0])
|
||||
{
|
||||
if ($result->uid == $this->_uid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
show_error('You are not entitled to read this document');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send mail to student to inform if Anrechnung was approved or rejected
|
||||
* @param $mail_params
|
||||
*/
|
||||
private function _sendSanchoMailToStudent($anrechnung_id, $status_kurzbz)
|
||||
{
|
||||
$result = getData($this->anrechnunglib->getStudentData($anrechnung_id))[0];
|
||||
|
||||
// Get student name and mail address
|
||||
$to = $result->uid. '@'. DOMAIN;
|
||||
|
||||
$anrede = $result->geschlecht == 'w' ? 'Sehr geehrte Frau ' : 'Sehr geehrter Herr ';
|
||||
|
||||
$text = $status_kurzbz == self::ANRECHNUNGSTATUS_APPROVED
|
||||
? 'Ihrem Antrag auf Anerkennung nachgewiesener Kenntnisse der Lehrveranstaltung "'.
|
||||
$result->lv_bezeichnung. '" wurde stattgegeben.'
|
||||
: 'wir haben Ihren Antrag auf Anerkennung nachgewiesener Kenntnisse geprüft und können die Lehrveranstaltung "'.
|
||||
$result->lv_bezeichnung. '" leider nicht anrechnen, weil die Gleichwertigkeit nicht festgestellt werden konnte.';
|
||||
|
||||
// Prepare mail content
|
||||
$body_fields = array(
|
||||
'anrede_name' => $anrede. $result->vorname. ' '. $result->nachname,
|
||||
'text' => $text
|
||||
);
|
||||
|
||||
sendSanchoMail(
|
||||
'AnrechnungGenehmigen',
|
||||
$body_fields,
|
||||
$to,
|
||||
'Anerkennung nachgewiesener Kenntnisse: Ihr Antrag ist abgeschlossen'
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send mail to lectors asking for recommendation. (first to LV-Leitung, if not present to all lectors of lv)
|
||||
* @param $mail_params
|
||||
* @return bool
|
||||
*/
|
||||
private function _sendSanchoMailToLectors($mail_params)
|
||||
{
|
||||
// Get Lehrveranstaltungen
|
||||
$anrechnung_arr = array();
|
||||
|
||||
foreach ($mail_params as $item)
|
||||
{
|
||||
$this->AnrechnungModel->addSelect('lehrveranstaltung_id, studiensemester_kurzbz');
|
||||
$anrechnung_arr[]= array(
|
||||
'lehrveranstaltung_id' => $this->AnrechnungModel->load($item['anrechnung_id'])->retval[0]->lehrveranstaltung_id,
|
||||
'studiensemester_kurzbz' => $this->AnrechnungModel->load($item['anrechnung_id'])->retval[0]->studiensemester_kurzbz
|
||||
);
|
||||
}
|
||||
|
||||
$anrechnung_arr = array_unique($anrechnung_arr, SORT_REGULAR);
|
||||
|
||||
|
||||
/**
|
||||
* Get lectors (prio for LV-Leitung, if not present to all lectors of LV.
|
||||
* Anyway this function will receive a unique array to avoid sending more mails to one and the same lector.
|
||||
* **/
|
||||
$lector_arr = $this->_getLectors($anrechnung_arr);
|
||||
|
||||
// Send mail to lectors
|
||||
foreach ($lector_arr as $lector)
|
||||
{
|
||||
$to = $lector->uid;
|
||||
$vorname = $lector->vorname;
|
||||
|
||||
// Get full name of stgl
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
if (!$stgl_name = getData($this->PersonModel->getFullName($this->_uid)))
|
||||
{
|
||||
show_error ('Failed retrieving person');
|
||||
}
|
||||
|
||||
// Link to Antrag genehmigen
|
||||
$url =
|
||||
CIS_ROOT. 'cis/index.php?menu='.
|
||||
CIS_ROOT. 'cis/menu.php?content_id=&content='.
|
||||
CIS_ROOT. index_page(). self::REVIEW_ANRECHNUNG_URI;
|
||||
|
||||
// Prepare mail content
|
||||
$body_fields = array(
|
||||
'vorname' => $vorname,
|
||||
'stgl_name' => $stgl_name,
|
||||
'link' => anchor($url, 'Anrechnungsanträge Übersicht')
|
||||
);
|
||||
|
||||
sendSanchoMail(
|
||||
'AnrechnungEmpfehlungAnfordern',
|
||||
$body_fields,
|
||||
$to,
|
||||
'Anerkennung nachgewiesener Kenntnisse: Deine Empfehlung wird benötigt'
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lectors (prio for LV-Leitung, if not present to all lectors of LV.
|
||||
* Anyway this function will receive a unique array to avoid sending more mails to one and the same lector.
|
||||
* @param $anrechnung_arr
|
||||
* @return array
|
||||
*/
|
||||
private function _getLectors($anrechnung_arr)
|
||||
{
|
||||
$lector_arr = array();
|
||||
|
||||
// Get lectors
|
||||
foreach($anrechnung_arr as $anrechnung)
|
||||
{
|
||||
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
$result = $this->LehrveranstaltungModel->getLecturersByLv($anrechnung['studiensemester_kurzbz'], $anrechnung['lehrveranstaltung_id']);
|
||||
|
||||
if (!$result = getData($result))
|
||||
{
|
||||
show_error('Failed retrieving lectors of Lehrveranstaltung');
|
||||
}
|
||||
|
||||
// Check if lv has LV-Leitung
|
||||
$key = array_search(true, array_column($result, 'lvleiter'));
|
||||
|
||||
// If lv has LV-Leitung, keep only the one
|
||||
if ($key !== false)
|
||||
{
|
||||
$lector_arr[]= $result[$key];
|
||||
}
|
||||
// ...otherwise keep all lectors
|
||||
else
|
||||
{
|
||||
$lector_arr = array_merge($lector_arr, $result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTE: This step is only done to make the array unique by uid, vorname and nachname in the following step
|
||||
* (e.g. if same lector is ones LV-Leitung and another time not, then array_unique would leave both.
|
||||
* But we wish to send only one email by to that one person)
|
||||
* **/
|
||||
foreach ($lector_arr as $lector)
|
||||
{
|
||||
unset($lector->lvleiter);
|
||||
}
|
||||
|
||||
// Now make the lector array aka mail receivers unique
|
||||
$lector_arr = array_unique($lector_arr, SORT_REGULAR);
|
||||
|
||||
return $lector_arr;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,409 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class requestAnrechnung extends Auth_Controller
|
||||
{
|
||||
const REQUEST_ANRECHNUNG_URI = '/lehre/anrechnung/RequestAnrechnung';
|
||||
const APPROVE_ANRECHNUNG_URI = '/lehre/anrechnung/ApproveAnrechnungUebersicht';
|
||||
|
||||
const ANRECHNUNGSTATUS_PROGRESSED_BY_STGL = 'inProgressDP';
|
||||
const ANRECHNUNGSTATUS_PROGRESSED_BY_KF = 'inProgressKF';
|
||||
const ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR = 'inProgressLektor';
|
||||
const ANRECHNUNGSTATUS_APPROVED = 'approved';
|
||||
const ANRECHNUNGSTATUS_REJECTED = 'rejected';
|
||||
|
||||
const DEADLINE_INTERVAL_NACH_SEMESTERSTART = 'P1M'; // Deadline for application
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Set required permissions
|
||||
parent::__construct(
|
||||
array(
|
||||
'index' => 'student/anrechnung_beantragen:rw',
|
||||
'apply' => 'student/anrechnung_beantragen:rw',
|
||||
'download' => 'student/anrechnung_beantragen:rw',
|
||||
)
|
||||
);
|
||||
|
||||
// Load models
|
||||
$this->load->model('education/Anrechnung_model', 'AnrechnungModel');
|
||||
$this->load->model('content/DmsVersion_model', 'DmsVersionModel');
|
||||
|
||||
// Load libraries
|
||||
$this->load->library('WidgetLib');
|
||||
$this->load->library('PermissionLib');
|
||||
$this->load->library('AnrechnungLib');
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
// Load helpers
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->helper('hlp_sancho_helper');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'global',
|
||||
'ui',
|
||||
'anrechnung',
|
||||
'person',
|
||||
'lehre'
|
||||
)
|
||||
);
|
||||
|
||||
$this->_setAuthUID();
|
||||
|
||||
$this->setControllerId();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$studiensemester_kurzbz = $this->input->get('studiensemester');
|
||||
$lehrveranstaltung_id = $this->input->get('lv_id');
|
||||
|
||||
if (!is_numeric($lehrveranstaltung_id) || !is_string($studiensemester_kurzbz))
|
||||
{
|
||||
show_error('Missing correct parameter');
|
||||
}
|
||||
|
||||
// Check if application deadline is expired
|
||||
// $is_expired = $this->_checkAntragDeadline($studiensemester_kurzbz);
|
||||
$is_expired = false; // Set to false until Deadline is defined
|
||||
|
||||
$student = $this->StudentModel->load(array('student_uid' => $this->_uid));
|
||||
if (isSuccess($student) && hasData($student))
|
||||
{
|
||||
$prestudent_id = getData($student)[0]->prestudent_id;
|
||||
}
|
||||
else
|
||||
show_error('Cant load User');
|
||||
|
||||
// Get Anrechung data
|
||||
$result = $this->anrechnunglib->getAnrechnungDataByLv($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id);
|
||||
if (!$anrechnungData = getData($result))
|
||||
{
|
||||
show_error(getError($anrechnungData));
|
||||
}
|
||||
|
||||
// Dont show who is progressing the application to the student
|
||||
if ($anrechnungData->status_kurzbz == self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL ||
|
||||
$anrechnungData->status_kurzbz == self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR ||
|
||||
$anrechnungData->status_kurzbz == self::ANRECHNUNGSTATUS_PROGRESSED_BY_KF)
|
||||
{
|
||||
$anrechnungData->status = getUserLanguage() == 'German' ? 'in Bearbeitung' : 'in process';
|
||||
}
|
||||
|
||||
$antragData = $this->anrechnunglib->getAntragData($this->_uid, $studiensemester_kurzbz, $lehrveranstaltung_id);
|
||||
|
||||
$viewData = array(
|
||||
'antragData' => $antragData,
|
||||
'anrechnungData' => $anrechnungData,
|
||||
'is_expired' => $is_expired,
|
||||
'disabled' => $is_expired && empty($anrechnungData->anrechnung_id) || !empty($anrechnungData->anrechnung_id)
|
||||
? 'disabled'
|
||||
: ''
|
||||
);
|
||||
|
||||
$this->load->view('lehre/anrechnung/requestAnrechnung.php', $viewData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply Anrechnungsantrag and send to STGL
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$anmerkung = $this->input->post('anmerkung');
|
||||
$begruendung_id = $this->input->post('begruendung');
|
||||
$lehrveranstaltung_id = $this->input->post('lv_id');
|
||||
$studiensemester_kurzbz = $this->input->post('studiensemester');
|
||||
|
||||
if (empty($_FILES['uploadfile']['name']))
|
||||
{
|
||||
show_error('Missing upload file');
|
||||
}
|
||||
|
||||
if (!is_numeric($begruendung_id) || !is_numeric($lehrveranstaltung_id) || !is_string($studiensemester_kurzbz))
|
||||
{
|
||||
show_error('Missing correct parameter');
|
||||
}
|
||||
|
||||
$student = $this->StudentModel->load(array('student_uid' => $this->_uid));
|
||||
if (isSuccess($student) && hasData($student))
|
||||
{
|
||||
$prestudent_id = getData($student)[0]->prestudent_id;
|
||||
}
|
||||
else
|
||||
show_error('Cant load User');
|
||||
|
||||
$result = $this->_getAnrechnung($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id);
|
||||
if (hasData($result))
|
||||
{
|
||||
show_error('Der Antrag wurde bereits gestellt');
|
||||
}
|
||||
|
||||
// Start DB transaction
|
||||
$this->db->trans_start(false);
|
||||
|
||||
// Upload document
|
||||
$dms = array(
|
||||
'kategorie_kurzbz' => 'anrechnung',
|
||||
'version' => 0,
|
||||
'name' => $_FILES['uploadfile']['name'],
|
||||
'mimetype' => $_FILES['uploadfile']['type'],
|
||||
'insertamum' => (new DateTime())->format('Y-m-d H:i:s'),
|
||||
'insertvon' => $this->_uid
|
||||
);
|
||||
|
||||
if(isError($uploaddata = $this->dmslib->upload($dms, array('pdf'))))
|
||||
{
|
||||
show_error(getError($uploaddata));
|
||||
}
|
||||
|
||||
// Get PrestudentID
|
||||
$result = $this->_loadPrestudent($this->_uid, $studiensemester_kurzbz);
|
||||
|
||||
if (!$prestudent = getData($result)[0])
|
||||
{
|
||||
show_error('Failed retrieving prestudent');
|
||||
}
|
||||
|
||||
// Save Anrechnung
|
||||
$result = $this->AnrechnungModel->insert(array(
|
||||
'prestudent_id' => $prestudent->prestudent_id,
|
||||
'lehrveranstaltung_id' => $lehrveranstaltung_id,
|
||||
'begruendung_id' => $begruendung_id,
|
||||
'dms_id' => $uploaddata->retval['dms_id'],
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'anmerkung_student' => $anmerkung,
|
||||
'insertvon' => $this->_uid
|
||||
));
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
show_error('Failed inserting Anrechnung');
|
||||
}
|
||||
|
||||
// Save Anrechnungstatus 'inProgressSTGL'
|
||||
$result = $this->AnrechnungModel->saveAnrechnungstatus($result->retval, self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
show_error('Failed saving Anrechnungstatus');
|
||||
}
|
||||
|
||||
// Transaction complete!
|
||||
$this->db->trans_complete();
|
||||
|
||||
if ($this->db->trans_status() === false || isError($result))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
show_error($result->msg, EXIT_ERROR);
|
||||
}
|
||||
|
||||
// Send mail to STGL
|
||||
$mail_params = array(
|
||||
'studiengang_kz' => $prestudent->studiengang_kz,
|
||||
'lehrveranstaltung_id' => $lehrveranstaltung_id
|
||||
);
|
||||
|
||||
if(!$this->_sendSanchoMail($mail_params))
|
||||
{
|
||||
show_error('Failed sending mail');
|
||||
}
|
||||
else
|
||||
{
|
||||
redirect(site_url(). self::REQUEST_ANRECHNUNG_URI. '?studiensemester='. $studiensemester_kurzbz. '&lv_id='. $lehrveranstaltung_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download and open uploaded document (Nachweisdokument).
|
||||
*/
|
||||
public function download()
|
||||
{
|
||||
$dms_id = $this->input->get('dms_id');
|
||||
|
||||
if (!is_numeric($dms_id))
|
||||
{
|
||||
show_error('Wrong parameter');
|
||||
}
|
||||
|
||||
// Check if user is entitled to read dms doc
|
||||
self::_checkIfEntitledToReadDMSDoc($dms_id);
|
||||
|
||||
$this->dmslib->download($dms_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the UID of the logged user and checks if it is valid
|
||||
*/
|
||||
private function _setAuthUID()
|
||||
{
|
||||
$this->_uid = getAuthUID();
|
||||
|
||||
if (!$this->_uid) show_error('User authentification failed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Prestudent by uid and Studiensemester.
|
||||
* @param $uid
|
||||
* @param $studiensemester_kurzbz
|
||||
* @return mixed
|
||||
*/
|
||||
private function _loadPrestudent($uid, $studiensemester_kurzbz)
|
||||
{
|
||||
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
|
||||
$this->PrestudentstatusModel->addJoin('public.tbl_student', 'prestudent_id');
|
||||
return $this->PrestudentstatusModel->loadWhere(array(
|
||||
'student_uid' => $uid,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if application deadline is expired.
|
||||
* @param $studiensemester_kurzbz
|
||||
* @return bool True if semester start is more then 1 week ago
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _checkAntragDeadline($studiensemester_kurzbz)
|
||||
{
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
$this->StudiensemesterModel->addSelect('start');
|
||||
if (!$start = getData($this->StudiensemesterModel->load($studiensemester_kurzbz)))
|
||||
{
|
||||
show_error(getError($start));
|
||||
}
|
||||
|
||||
$start = new DateTime($start[0]->start);
|
||||
$today = new DateTime('today midnight');
|
||||
|
||||
// True if today > application deadline
|
||||
return ($today > $start->add((new DateInterval(self::DEADLINE_INTERVAL_NACH_SEMESTERSTART))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user is entitled to read dms doc
|
||||
* @param $dms_id
|
||||
*/
|
||||
private function _checkIfEntitledToReadDMSDoc($dms_id)
|
||||
{
|
||||
if (!$student = getData($this->StudentModel->load(array('student_uid' => $this->_uid)))[0])
|
||||
{
|
||||
show_error('Failed loading Student');
|
||||
}
|
||||
|
||||
$result = $this->AnrechnungModel->loadWhere(array('dms_id' => $dms_id));
|
||||
|
||||
if($result = getData($result)[0])
|
||||
{
|
||||
if ($result->prestudent_id == $student->prestudent_id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
show_error('You are not entitled to read this document');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Anrechnung by Lehrveranstaltung
|
||||
* @param $lehrveranstaltung_id
|
||||
* @return mixed
|
||||
*/
|
||||
private function _getAnrechnung($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id)
|
||||
{
|
||||
$result = $this->AnrechnungModel->loadWhere(array(
|
||||
'lehrveranstaltung_id' => $lehrveranstaltung_id,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'prestudent_id' => $prestudent_id
|
||||
));
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
show_error(getError($result));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send mail to STGL (if not available, send to STGL assistance)
|
||||
* @param $mail_params
|
||||
*/
|
||||
private function _sendSanchoMail($mail_params)
|
||||
{
|
||||
// Get STGL mail address, if available, otherwise get assistance mail address
|
||||
list ($to, $vorname) = $this->_getSTGLMailAddress($mail_params['studiengang_kz']);
|
||||
|
||||
// Get full name of student
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
if (!$student_name = getData($this->PersonModel->getFullName($this->_uid)))
|
||||
{
|
||||
show_error ('Failed retrieving person');
|
||||
}
|
||||
|
||||
// Get lehrveranstaltung bezeichnung
|
||||
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
if (!$lehrveranstaltung = getData($this->LehrveranstaltungModel->load($mail_params['lehrveranstaltung_id']))[0])
|
||||
{
|
||||
show_error ('Failed retrieving person');
|
||||
}
|
||||
|
||||
// Link to Antrag genehmigen
|
||||
$url =
|
||||
CIS_ROOT. 'cis/index.php?menu='.
|
||||
CIS_ROOT. 'cis/menu.php?content_id=&content='.
|
||||
CIS_ROOT. index_page(). self::APPROVE_ANRECHNUNG_URI;
|
||||
|
||||
// Prepare mail content
|
||||
$body_fields = array(
|
||||
'vorname' => $vorname,
|
||||
'student_name' => $student_name,
|
||||
'lehrveranstaltung_bezeichnung' => $lehrveranstaltung->bezeichnung,
|
||||
'link' => anchor($url, 'Anrechnungsanträge Übersicht')
|
||||
);
|
||||
|
||||
sendSanchoMail(
|
||||
'AnrechnungAntragStellen',
|
||||
$body_fields,
|
||||
$to,
|
||||
'Anerkennung nachgewiesener Kenntnisse: Neuer Antrag wurde gestellt'
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get STGL mail address, if available, otherwise get assistance mail address
|
||||
private function _getSTGLMailAddress($stg_kz)
|
||||
{
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
$result = $this->StudiengangModel->getLeitung($stg_kz);
|
||||
|
||||
// Get STGL mail address, if available
|
||||
if (hasData($result))
|
||||
{
|
||||
return array(
|
||||
$result->retval[0]->uid. '@'. DOMAIN,
|
||||
$result->retval[0]->vorname
|
||||
);
|
||||
}
|
||||
// ...otherwise get assistance mail address
|
||||
else
|
||||
{
|
||||
$result = $this->StudiengangModel->load($stg_kz);
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
return array(
|
||||
$result->retval[0]->email,
|
||||
''
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,397 @@
|
||||
<?php
|
||||
|
||||
//if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class reviewAnrechnungDetail extends Auth_Controller
|
||||
{
|
||||
const BERECHTIGUNG_ANRECHNUNG_EMPFEHLEN = 'lehre/anrechnung_empfehlen';
|
||||
|
||||
const APPROVE_ANRECHNUNG_URI = '/lehre/anrechnung/ApproveAnrechnungUebersicht';
|
||||
|
||||
const ANRECHNUNGSTATUS_PROGRESSED_BY_STGL = 'inProgressDP';
|
||||
const ANRECHNUNGSTATUS_PROGRESSED_BY_KF = 'inProgressKF';
|
||||
const ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR = 'inProgressLektor';
|
||||
const ANRECHNUNGSTATUS_APPROVED = 'approved';
|
||||
const ANRECHNUNGSTATUS_REJECTED = 'rejected';
|
||||
|
||||
const ANRECHNUNG_NOTIZTITEL_NOTIZ_BY_LEKTOR = 'AnrechnungNotizLektor';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Set required permissions
|
||||
parent::__construct(
|
||||
array(
|
||||
'index' => 'lehre/anrechnung_empfehlen:rw',
|
||||
'download' => 'lehre/anrechnung_empfehlen:rw',
|
||||
'recommend' => 'lehre/anrechnung_empfehlen:rw',
|
||||
'dontRecommend' => 'lehre/anrechnung_empfehlen:rw'
|
||||
)
|
||||
);
|
||||
|
||||
// Load models
|
||||
$this->load->model('education/Anrechnung_model', 'AnrechnungModel');
|
||||
$this->load->model('education/Anrechnungstatus_model', 'AnrechnungstatusModel');
|
||||
$this->load->model('content/DmsVersion_model', 'DmsVersionModel');
|
||||
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
|
||||
// Load libraries
|
||||
$this->load->library('WidgetLib');
|
||||
$this->load->library('PermissionLib');
|
||||
$this->load->library('AnrechnungLib');
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
// Load helpers
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->helper('hlp_sancho_helper');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'global',
|
||||
'ui',
|
||||
'anrechnung',
|
||||
'person',
|
||||
'lehre',
|
||||
'table'
|
||||
)
|
||||
);
|
||||
|
||||
$this->_setAuthUID();
|
||||
|
||||
$this->setControllerId();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$anrechnung_id = $this->input->get('anrechnung_id');
|
||||
|
||||
if (!is_numeric($anrechnung_id))
|
||||
{
|
||||
show_error('Missing correct parameter');
|
||||
}
|
||||
|
||||
// Check if user is entitled to read this Anrechnung
|
||||
self::_checkIfEntitledToReadAnrechnung($anrechnung_id);
|
||||
|
||||
// Get Anrechung data
|
||||
if (!$anrechnungData = getData($this->anrechnunglib->getAnrechnungData($anrechnung_id)))
|
||||
{
|
||||
show_error('Missing data for Anrechnung.');
|
||||
}
|
||||
|
||||
// Get Empfehlung data
|
||||
if(!$empfehlungData = getData($this->anrechnunglib->getEmpfehlungData($anrechnung_id)))
|
||||
{
|
||||
show_error('Missing data for recommendation');
|
||||
}
|
||||
|
||||
$viewData = array(
|
||||
'antragData' => $this->anrechnunglib->getAntragData(
|
||||
$student_uid = $this->StudentModel->getUID($anrechnungData->prestudent_id),
|
||||
$anrechnungData->studiensemester_kurzbz,
|
||||
$anrechnungData->lehrveranstaltung_id
|
||||
),
|
||||
'anrechnungData' => $anrechnungData,
|
||||
'empfehlungData' => $empfehlungData
|
||||
);
|
||||
|
||||
$this->load->view('lehre/anrechnung/reviewAnrechnungDetail.php', $viewData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recommend Anrechnungen.
|
||||
*/
|
||||
public function recommend()
|
||||
{
|
||||
$data = $this->input->post('data');
|
||||
|
||||
if(isEmptyArray($data))
|
||||
{
|
||||
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
|
||||
}
|
||||
|
||||
// Get statusbezeichnung for 'inProgressDP'
|
||||
$this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
|
||||
$inProgressDP = getData($this->AnrechnungstatusModel->load('inProgressDP'))[0];
|
||||
$inProgressDP = getUserLanguage() == 'German'
|
||||
? $inProgressDP->bezeichnung_mehrsprachig[0]
|
||||
: $inProgressDP->bezeichnung_mehrsprachig[1];
|
||||
|
||||
if (!$person = getData($this->PersonModel->getByUID($this->_uid))[0])
|
||||
{
|
||||
show_error('Failed retrieving person data');
|
||||
}
|
||||
|
||||
foreach ($data as $item)
|
||||
{
|
||||
// Approve Anrechnung
|
||||
if(getData($this->anrechnunglib->recommendAnrechnung($item['anrechnung_id'])))
|
||||
{
|
||||
$json[]= array(
|
||||
'anrechnung_id' => $item['anrechnung_id'],
|
||||
'empfehlung_anrechnung' => 'true',
|
||||
'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL,
|
||||
'status_bezeichnung' => $inProgressDP,
|
||||
'empfehlung_am' => (new DateTime())->format('d.m.Y'),
|
||||
'empfehlung_von' => $person->vorname. ' '. $person->nachname
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Output json to ajax
|
||||
if (isset($json) && !isEmptyArray($json))
|
||||
{
|
||||
/**
|
||||
* Send mails to STGL (if not present STGL, send to STGL assistance)
|
||||
* NOTE: mails are sent at the end to ensure sending only one mail to each STGL
|
||||
* */
|
||||
if (!$this->_sendSanchoMails($json, true))
|
||||
{
|
||||
show_error('Failed sending emails');
|
||||
}
|
||||
|
||||
return $this->outputJsonSuccess($json);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->outputJsonError('Empfehlungen wurden nicht durchgeführt');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dont recommend Anrechnungen.
|
||||
*/
|
||||
public function dontRecommend()
|
||||
{
|
||||
$data = $this->input->post('data');
|
||||
|
||||
if(isEmptyArray($data))
|
||||
{
|
||||
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
|
||||
}
|
||||
|
||||
// Get statusbezeichnung for 'inProgressDP'
|
||||
$this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
|
||||
$inProgressDP = getData($this->AnrechnungstatusModel->load('inProgressDP'))[0];
|
||||
$inProgressDP = getUserLanguage() == 'German'
|
||||
? $inProgressDP->bezeichnung_mehrsprachig[0]
|
||||
: $inProgressDP->bezeichnung_mehrsprachig[1];
|
||||
|
||||
if (!$person = getData($this->PersonModel->getByUID($this->_uid))[0])
|
||||
{
|
||||
show_error('Failed retrieving person data');
|
||||
}
|
||||
|
||||
foreach ($data as $item)
|
||||
{
|
||||
// Approve Anrechnung
|
||||
if(getData($this->anrechnunglib->dontRecommendAnrechnung($item['anrechnung_id'], $item['begruendung'])))
|
||||
{
|
||||
$json[]= array(
|
||||
'anrechnung_id' => $item['anrechnung_id'],
|
||||
'empfehlung_anrechnung' => 'false',
|
||||
'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL,
|
||||
'status_bezeichnung' => $inProgressDP,
|
||||
'empfehlumg_am' => (new DateTime())->format('d.m.Y'),
|
||||
'empfehlung_von' => $person->vorname. ' '. $person->nachname
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Output json to ajax
|
||||
if (isset($json) && !isEmptyArray($json))
|
||||
{
|
||||
// Send mails to STGL (if not present STGL, send to STGL assistance)
|
||||
if (!$this->_sendSanchoMails($json, false))
|
||||
{
|
||||
show_error('Failed sending emails');
|
||||
}
|
||||
|
||||
return $this->outputJsonSuccess($json);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->outputJsonError('Empfehlungen wurden nicht durchgeführt');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download and open uploaded document (Nachweisdokument).
|
||||
*/
|
||||
public function download()
|
||||
{
|
||||
$dms_id = $this->input->get('dms_id');
|
||||
|
||||
if (!is_numeric($dms_id))
|
||||
{
|
||||
show_error('Wrong parameter');
|
||||
}
|
||||
|
||||
// Check if user is entitled to read dms doc
|
||||
self::_checkIfEntitledToReadDMSDoc($dms_id);
|
||||
|
||||
$this->dmslib->download($dms_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the UID of the logged user and checks if it is valid
|
||||
*/
|
||||
private function _setAuthUID()
|
||||
{
|
||||
$this->_uid = getAuthUID();
|
||||
|
||||
if (!$this->_uid) show_error('User authentification failed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user is entitled to read dms doc
|
||||
* @param $dms_id
|
||||
*/
|
||||
private function _checkIfEntitledToReadAnrechnung($anrechnung_id)
|
||||
{
|
||||
$result = $this->AnrechnungModel->load($anrechnung_id);
|
||||
|
||||
if(!$result = getData($result)[0])
|
||||
{
|
||||
show_error('Failed retrieving Anrechnung');
|
||||
}
|
||||
|
||||
$result = $this->LehrveranstaltungModel
|
||||
->getLecturersByLv($result->studiensemester_kurzbz, $result->lehrveranstaltung_id);
|
||||
|
||||
if($result = getData($result))
|
||||
{
|
||||
$entitled_lector_arr = array_column($result, 'uid');
|
||||
|
||||
if (in_array($this->_uid, $entitled_lector_arr))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
show_error('You are not entitled to read this document');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user is entitled to read dms doc
|
||||
* @param $dms_id
|
||||
*/
|
||||
private function _checkIfEntitledToReadDMSDoc($dms_id)
|
||||
{
|
||||
$result = $this->AnrechnungModel->loadWhere(array('dms_id' => $dms_id));
|
||||
|
||||
if(!$result = getData($result)[0])
|
||||
{
|
||||
show_error('Failed retrieving Anrechnung');
|
||||
}
|
||||
|
||||
$result = $this->LehrveranstaltungModel
|
||||
->getLecturersByLv($result->studiensemester_kurzbz, $result->lehrveranstaltung_id);
|
||||
|
||||
if($result = getData($result))
|
||||
{
|
||||
$entitled_lector_arr = array_column($result, 'uid');
|
||||
|
||||
if (in_array($this->_uid, $entitled_lector_arr))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
show_error('You are not entitled to read this document');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send mails to STGL (if not present then to STGL assistance)
|
||||
* @param $mail_params
|
||||
* @param $empfehlung
|
||||
* @return bool
|
||||
*/
|
||||
private function _sendSanchoMails($mail_params, $empfehlung)
|
||||
{
|
||||
// Get studiengaenge
|
||||
$studiengang_kz_arr = array();
|
||||
|
||||
foreach ($mail_params as $item)
|
||||
{
|
||||
$this->AnrechnungModel->addSelect('studiengang_kz');
|
||||
$this->AnrechnungModel->addJoin('public.tbl_prestudent', 'prestudent_id');
|
||||
|
||||
$studiengang_kz_arr[]= $this->AnrechnungModel->load($item['anrechnung_id'])->retval[0]->studiengang_kz;
|
||||
}
|
||||
|
||||
$studiengang_kz_arr = array_unique($studiengang_kz_arr);
|
||||
|
||||
// Send mail to STGL of each studiengang
|
||||
foreach ($studiengang_kz_arr as $studiengang_kz)
|
||||
{
|
||||
// Get STGL mail address, if available, otherwise get assistance mail address
|
||||
list ($to, $vorname) = $this->_getSTGLMailAddress($studiengang_kz);
|
||||
|
||||
// Get full name of lector
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
if (!$lector_name = getData($this->PersonModel->getFullName($this->_uid)))
|
||||
{
|
||||
show_error ('Failed retrieving person');
|
||||
}
|
||||
|
||||
// Link to Antrag genehmigen
|
||||
$url =
|
||||
CIS_ROOT. 'cis/index.php?menu='.
|
||||
CIS_ROOT. 'cis/menu.php?content_id=&content='.
|
||||
CIS_ROOT. index_page(). self::APPROVE_ANRECHNUNG_URI;
|
||||
|
||||
// Prepare mail content
|
||||
$body_fields = array(
|
||||
'vorname' => $vorname,
|
||||
'lektor_name' => $lector_name,
|
||||
'empfehlung' => $empfehlung ? 'positive' : 'negative',
|
||||
'link' => anchor($url, 'Anrechnungsanträge Übersicht')
|
||||
);
|
||||
|
||||
sendSanchoMail(
|
||||
'AnrechnungEmpfehlungAbgeben',
|
||||
$body_fields,
|
||||
$to,
|
||||
'Anerkennung nachgewiesener Kenntnisse: Empfehlung wurde abgegeben'
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get STGL mail address, if available, otherwise get assistance mail address
|
||||
private function _getSTGLMailAddress($stg_kz)
|
||||
{
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
$result = $this->StudiengangModel->getLeitung($stg_kz);
|
||||
|
||||
// Get STGL mail address, if available
|
||||
if (hasData($result))
|
||||
{
|
||||
return array(
|
||||
$result->retval[0]->uid. '@'. DOMAIN,
|
||||
$result->retval[0]->vorname
|
||||
);
|
||||
}
|
||||
// ...otherwise get assistance mail address
|
||||
else
|
||||
{
|
||||
$result = $this->StudiengangModel->load($stg_kz);
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
return array(
|
||||
$result->retval[0]->email,
|
||||
''
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class reviewAnrechnungUebersicht extends Auth_Controller
|
||||
{
|
||||
const BERECHTIGUNG_ANRECHNUNG_EMPFEHLEN = 'lehre/anrechnung_empfehlen';
|
||||
|
||||
const APPROVE_ANRECHNUNG_URI = '/lehre/anrechnung/ApproveAnrechnungUebersicht';
|
||||
|
||||
const ANRECHNUNGSTATUS_PROGRESSED_BY_STGL = 'inProgressDP';
|
||||
const ANRECHNUNGSTATUS_PROGRESSED_BY_KF = 'inProgressKF';
|
||||
const ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR = 'inProgressLektor';
|
||||
const ANRECHNUNGSTATUS_APPROVED = 'approved';
|
||||
const ANRECHNUNGSTATUS_REJECTED = 'rejected';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Set required permissions
|
||||
parent::__construct(
|
||||
array(
|
||||
'index' => 'lehre/anrechnung_empfehlen:rw',
|
||||
'download' => 'lehre/anrechnung_empfehlen:rw',
|
||||
'recommend' => 'lehre/anrechnung_empfehlen:rw',
|
||||
'dontRecommend' => 'lehre/anrechnung_empfehlen:rw'
|
||||
)
|
||||
);
|
||||
|
||||
// Load models
|
||||
$this->load->model('education/Anrechnung_model', 'AnrechnungModel');
|
||||
$this->load->model('education/Anrechnungstatus_model', 'AnrechnungstatusModel');
|
||||
$this->load->model('content/DmsVersion_model', 'DmsVersionModel');
|
||||
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
|
||||
// Load libraries
|
||||
$this->load->library('WidgetLib');
|
||||
$this->load->library('PermissionLib');
|
||||
$this->load->library('AnrechnungLib');
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
// Load helpers
|
||||
$this->load->helper('form');
|
||||
$this->load->helper('url');
|
||||
$this->load->helper('hlp_sancho_helper');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'global',
|
||||
'ui',
|
||||
'anrechnung',
|
||||
'person',
|
||||
'lehre',
|
||||
'table'
|
||||
)
|
||||
);
|
||||
|
||||
$this->_setAuthUID();
|
||||
|
||||
$this->setControllerId();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$studiensemester_kurzbz = $this->input->get('studiensemester');
|
||||
|
||||
if (!is_string($studiensemester_kurzbz))
|
||||
{
|
||||
$studiensemester = $this->StudiensemesterModel->getNearest();
|
||||
if (hasData($studiensemester))
|
||||
{
|
||||
$studiensemester_kurzbz = $studiensemester->retval[0]->studiensemester_kurzbz;
|
||||
}
|
||||
elseif (isError($studiensemester))
|
||||
{
|
||||
show_error(getError($studiensemester));
|
||||
}
|
||||
}
|
||||
|
||||
$viewData = array(
|
||||
'studiensemester_selected' => $studiensemester_kurzbz
|
||||
);
|
||||
|
||||
$this->load->view('lehre/anrechnung/reviewAnrechnungUebersicht.php', $viewData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recommend Anrechnungen.
|
||||
*/
|
||||
public function recommend()
|
||||
{
|
||||
$data = $this->input->post('data');
|
||||
|
||||
if(isEmptyArray($data))
|
||||
{
|
||||
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
|
||||
}
|
||||
|
||||
// Get statusbezeichnung for 'inProgressDP'
|
||||
$this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
|
||||
$inProgressDP = getData($this->AnrechnungstatusModel->load('inProgressDP'))[0];
|
||||
$inProgressDP = getUserLanguage() == 'German'
|
||||
? $inProgressDP->bezeichnung_mehrsprachig[0]
|
||||
: $inProgressDP->bezeichnung_mehrsprachig[1];
|
||||
|
||||
foreach ($data as $item)
|
||||
{
|
||||
// Approve Anrechnung
|
||||
if(getData($this->anrechnunglib->recommendAnrechnung($item['anrechnung_id'])))
|
||||
{
|
||||
$json[]= array(
|
||||
'anrechnung_id' => $item['anrechnung_id'],
|
||||
'empfehlung_anrechnung' => 'true',
|
||||
'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL,
|
||||
'status_bezeichnung' => $inProgressDP
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Output json to ajax
|
||||
if (isset($json) && !isEmptyArray($json))
|
||||
{
|
||||
/**
|
||||
* Send mails to STGL (if not present STGL, send to STGL assistance)
|
||||
* NOTE: mails are sent at the end to ensure sending only one mail to each STGL
|
||||
* */
|
||||
if (!$this->_sendSanchoMails($json, true))
|
||||
{
|
||||
show_error('Failed sending emails');
|
||||
}
|
||||
|
||||
return $this->outputJsonSuccess($json);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->outputJsonError('Empfehlungen wurden nicht durchgeführt');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dont recommend Anrechnungen.
|
||||
*/
|
||||
public function dontRecommend()
|
||||
{
|
||||
$data = $this->input->post('data');
|
||||
|
||||
if(isEmptyArray($data))
|
||||
{
|
||||
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
|
||||
}
|
||||
|
||||
// Get statusbezeichnung for 'inProgressDP'
|
||||
$this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
|
||||
$inProgressDP = getData($this->AnrechnungstatusModel->load('inProgressDP'))[0];
|
||||
$inProgressDP = getUserLanguage() == 'German'
|
||||
? $inProgressDP->bezeichnung_mehrsprachig[0]
|
||||
: $inProgressDP->bezeichnung_mehrsprachig[1];
|
||||
|
||||
foreach ($data as $item)
|
||||
{
|
||||
// Approve Anrechnung
|
||||
if(getData($this->anrechnunglib
|
||||
->dontRecommendAnrechnung($item['anrechnung_id'], $item['begruendung'])))
|
||||
{
|
||||
$json[]= array(
|
||||
'anrechnung_id' => $item['anrechnung_id'],
|
||||
'empfehlung_anrechnung' => 'false',
|
||||
'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL,
|
||||
'status_bezeichnung' => $inProgressDP
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Output json to ajax
|
||||
if (isset($json) && !isEmptyArray($json))
|
||||
{
|
||||
// Send mails to STGL (if not present STGL, send to STGL assistance)
|
||||
if (!$this->_sendSanchoMails($json, false))
|
||||
{
|
||||
show_error('Failed sending emails');
|
||||
}
|
||||
|
||||
return $this->outputJsonSuccess($json);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->outputJsonError('Empfehlungen wurden nicht durchgeführt');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download and open uploaded document (Nachweisdokument).
|
||||
*/
|
||||
public function download()
|
||||
{
|
||||
$dms_id = $this->input->get('dms_id');
|
||||
|
||||
if (!is_numeric($dms_id))
|
||||
{
|
||||
show_error('Wrong parameter');
|
||||
}
|
||||
|
||||
// Check if user is entitled to read dms doc
|
||||
self::_checkIfEntitledToReadDMSDoc($dms_id);
|
||||
|
||||
$this->dmslib->download($dms_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the UID of the logged user and checks if it is valid
|
||||
*/
|
||||
private function _setAuthUID()
|
||||
{
|
||||
$this->_uid = getAuthUID();
|
||||
|
||||
if (!$this->_uid) show_error('User authentification failed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user is entitled to read dms doc
|
||||
* @param $dms_id
|
||||
*/
|
||||
private function _checkIfEntitledToReadDMSDoc($dms_id)
|
||||
{
|
||||
$result = $this->AnrechnungModel->loadWhere(array('dms_id' => $dms_id));
|
||||
|
||||
if(!$result = getData($result)[0])
|
||||
{
|
||||
show_error('Failed retrieving Anrechnung');
|
||||
}
|
||||
|
||||
$result = $this->LehrveranstaltungModel
|
||||
->getLecturersByLv($result->studiensemester_kurzbz, $result->lehrveranstaltung_id);
|
||||
|
||||
if($result = getData($result))
|
||||
{
|
||||
$entitled_lector_arr = array_column($result, 'uid');
|
||||
|
||||
if (in_array($this->_uid, $entitled_lector_arr))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
show_error('You are not entitled to read this document');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send mails to STGL (if not present then to STGL assistance)
|
||||
* @param $mail_params
|
||||
* @param $empfehlung
|
||||
* @return bool
|
||||
*/
|
||||
private function _sendSanchoMails($mail_params, $empfehlung)
|
||||
{
|
||||
// Get studiengaenge
|
||||
$studiengang_kz_arr = array();
|
||||
|
||||
foreach ($mail_params as $item)
|
||||
{
|
||||
$this->AnrechnungModel->addSelect('studiengang_kz');
|
||||
$this->AnrechnungModel->addJoin('public.tbl_prestudent', 'prestudent_id');
|
||||
|
||||
$studiengang_kz_arr[]= $this->AnrechnungModel->load($item['anrechnung_id'])->retval[0]->studiengang_kz;
|
||||
}
|
||||
|
||||
$studiengang_kz_arr = array_unique($studiengang_kz_arr);
|
||||
|
||||
// Send mail to STGL of each studiengang
|
||||
foreach ($studiengang_kz_arr as $studiengang_kz)
|
||||
{
|
||||
// Get STGL mail address, if available, otherwise get assistance mail address
|
||||
list ($to, $vorname) = $this->_getSTGLMailAddress($studiengang_kz);
|
||||
|
||||
// Get full name of lector
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
if (!$lector_name = getData($this->PersonModel->getFullName($this->_uid)))
|
||||
{
|
||||
show_error ('Failed retrieving person');
|
||||
}
|
||||
|
||||
// Link to Antrag genehmigen
|
||||
$url =
|
||||
CIS_ROOT. 'cis/index.php?menu='.
|
||||
CIS_ROOT. 'cis/menu.php?content_id=&content='.
|
||||
CIS_ROOT. index_page(). self::APPROVE_ANRECHNUNG_URI;
|
||||
|
||||
// Prepare mail content
|
||||
$body_fields = array(
|
||||
'vorname' => $vorname,
|
||||
'lektor_name' => $lector_name,
|
||||
'empfehlung' => $empfehlung ? 'positive' : 'negative',
|
||||
'link' => anchor($url, 'Anrechnungsanträge Übersicht')
|
||||
);
|
||||
|
||||
sendSanchoMail(
|
||||
'AnrechnungEmpfehlungAbgeben',
|
||||
$body_fields,
|
||||
$to,
|
||||
'Anerkennung nachgewiesener Kenntnisse: Empfehlung wurde abgegeben'
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get STGL mail address, if available, otherwise get assistance mail address
|
||||
private function _getSTGLMailAddress($stg_kz)
|
||||
{
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
$result = $this->StudiengangModel->getLeitung($stg_kz);
|
||||
|
||||
// Get STGL mail address, if available
|
||||
if (hasData($result))
|
||||
{
|
||||
return array(
|
||||
$result->retval[0]->uid. '@'. DOMAIN,
|
||||
$result->retval[0]->vorname
|
||||
);
|
||||
}
|
||||
// ...otherwise get assistance mail address
|
||||
else
|
||||
{
|
||||
$result = $this->StudiengangModel->load($stg_kz);
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
return array(
|
||||
$result->retval[0]->email,
|
||||
''
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user