Added GUI for STGL Detail VIEW + logic (Antrag- and Empfehlungdata)

Signed-off-by: cris-technikum <hainberg@technikum-wien.at>
This commit is contained in:
Cris
2021-02-03 15:30:53 +01:00
committed by cris-technikum
parent 0affbf4e41
commit e780a3e505
7 changed files with 978 additions and 8 deletions
@@ -0,0 +1,421 @@
<?php
//if (! defined('BASEPATH')) exit('No direct script access allowed');
class approveAnrechnungDetail extends Auth_Controller
{
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_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/Prestudent_model', 'PrestudentModel');
$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');
}
// 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->PrestudentModel->getUID($anrechnungData->prestudent_id),
$anrechnungData->studiensemester_kurzbz,
$anrechnungData->lehrveranstaltung_id
),
'anrechnungData' => $anrechnungData,
'empfehlungData' => $empfehlungData
);
$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];
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');
}
$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');
}
/**
* 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 ';
// Prepare mail content
$body_fields = array(
'anrede_name' => $anrede. $result->vorname. ' '. $result->nachname,
'lehrveranstaltung_bezeichnung' => $result->lv_bezeichnung,
'stattgegeben_nichtstattgegeben' => $status_kurzbz == self::ANRECHNUNGSTATUS_APPROVED
? 'stattgegeben'
: 'nicht stattgegeben'
);
sendSanchoMail(
'AnrechnungGenehmigen',
$body_fields,
$to,
'Ihr Antrag auf Anerkennung nachgewiesener Kenntnisse wurde 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,
'Neue LV-Anrechnungsanträge benötigen Deine Empfehlung'
);
}
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;
}
}
+11
View File
@@ -201,6 +201,7 @@ class AnrechnungLib
$empfehlung_data->empfehlung = null;
$empfehlung_data->empfehlung_von = '-';
$empfehlung_data->empfehlung_am = '-';
$empfehlung_data->empfehlung_angefordert_am = '-';
$empfehlung_data->notiz = ''; // Begruendung, if not recommended
@@ -209,6 +210,16 @@ class AnrechnungLib
show_error('Failed loading Anrechnung');
}
// Get date, where recommendation was last requested
$result = $this->ci->AnrechnungModel->getLastAnrechnungstatus(
$anrechnung_id,
self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR // when STLG asks for recommendation, status is set to in progress lektor
);
if ($result = getData($result)[0])
{
$empfehlung_data->empfehlung_angefordert_am = (new DateTime($result->insertamum))->format('d.m.Y');
}
if (is_null($anrechnung->empfehlung_anrechnung))
{
return success($empfehlung_data);
@@ -0,0 +1,204 @@
<?php
$this->load->view(
'templates/FHC-Header',
array(
'title' => $this->p->t('anrechnung', 'anrechnungenGenehmigen'),
'jquery' => true,
'jqueryui' => true,
'bootstrap' => true,
'fontawesome' => true,
'ajaxlib' => true,
'dialoglib' => true,
'phrases' => array(
'global' => array(
'anerkennungNachgewiesenerKenntnisse',
'antragStellen'
),
'ui' => array(
'hilfeZuDieserSeite',
'hochladen'
),
'person' => array(
'student',
'personenkennzeichen'
),
'lehre' => array(
'studiensemester',
'studiengang',
'lehrveranstaltung',
'ects',
'lektor',
)
),
'customCSSs' => array(
'public/css/Tabulator.css'
),
'customJSs' => array(
'public/js/bootstrapper.js',
'public/js/lehre/anrechnung/approveAnrechnungDetail.js'
)
)
);
?>
<body>
<div id="page-wrapper">
<div class="container-fluid">
<!-- title -->
<div class="row">
<div class="col-lg-12 page-header">
<h3>
<?php echo $this->p->t('anrechnung', 'anrechnungenGenehmigen'); ?>
<small>| <?php echo $this->p->t('global', 'detailsicht'); ?></small>
</h3>
</div>
</div>
<div class="row">
<div class="col-xs-8">
<div class="panel panel-default">
<div class="panel-body">
<!-- Antragsdaten -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<span class="text-uppercase"><b><?php echo $this->p->t('anrechnung', 'antrag'); ?></b></span>
<span class="pull-right"><?php echo $this->p->t('anrechnung', 'antragdatum'); ?>: <span
id="approveAnrechnung-status"><?php echo !empty($anrechnungData->anrechnung_id) ? $anrechnungData->insertamum : '-' ?></span></span>
</div>
<table class="panel-body table table-bordered table-condensed">
<tbody>
<tr>
<td><?php echo $this->p->t('person', 'student'); ?></td>
<td><?php echo $antragData->vorname . ' ' . $antragData->nachname; ?></td>
</tr>
<tr>
<td><?php echo $this->p->t('person', 'personenkennzeichen'); ?></td>
<td><?php echo $antragData->matrikelnr ?></td>
</tr>
<tr>
<td><?php echo $this->p->t('lehre', 'studiensemester'); ?></td>
<td><?php echo $antragData->studiensemester_kurzbz ?></td>
</tr>
<tr>
<td><?php echo $this->p->t('lehre', 'studiengang'); ?></td>
<td><?php echo $antragData->stg_bezeichnung ?></td>
</tr>
<tr>
<td><?php echo $this->p->t('lehre', 'lehrveranstaltung'); ?></td>
<td><?php echo $antragData->lv_bezeichnung ?></td>
</tr>
<tr>
<td><?php echo $this->p->t('lehre', 'ects'); ?></td>
<td><?php echo $antragData->ects ?></td>
</tr>
<tr>
<td><?php echo $this->p->t('lehre', 'lektorInnen'); ?></td>
<td>
<?php $len = count($antragData->lektoren) - 1 ?>
<?php foreach ($antragData->lektoren as $key => $lektor): ?>
<?php echo $lektor->vorname . ' ' . $lektor->nachname;
echo $key === $len ? '' : ', ' ?>
<?php endforeach; ?>
</td>
</tr>
<tr>
<td><?php echo $this->p->t('anrechnung', 'herkunftDerKenntnisse'); ?></td>
<td><?php echo $anrechnungData->anmerkung ?></td>
</tr>
<tr>
<td><?php echo $this->p->t('anrechnung', 'nachweisdokumente'); ?></td>
<td>
<a href="<?php echo current_url() . '/download?dms_id=' . $anrechnungData->dms_id; ?>"
target="_blank"><?php echo $anrechnungData->dokumentname ?></a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- Empfehlungsdaten -->
<div class="row">
<div class="col-lg-12">
<form>
<input type="hidden" name="anrechnung_id" value="<?php echo $anrechnungData->anrechnung_id ?>">
<div class="panel panel-default" id="test">
<div class="panel-heading">
<span class="text-uppercase"><b><?php echo $this->p->t('anrechnung', 'empfehlung'); ?></b></span>
<div class="pull-right">
<?php echo $this->p->t('anrechnung', 'empfehlungVon'); ?>:
<span id="approveAnrechnungDetail-empfehlungVon"><?php echo $empfehlungData->empfehlung_von ?></span>
&emsp;|&emsp;
<?php echo $this->p->t('anrechnung', 'empfehlungdatum'); ?>:
<span id="approveAnrechnungDetail-empfehlungAm"><?php echo $empfehlungData->empfehlung_am ?></span>
</div>
</div>
<div class="panel-body" id="approveAnrechnungDetail-empfehlungDetail">
<div class="panel panel-default panel-body
<?php echo
is_null($empfehlungData->empfehlung) && $anrechnungData->status_kurzbz == 'inProgressDP'
? '' : 'hidden' ?>"
id="approveAnrechnungDetail-empfehlungDetail-empfehlungIsNull">
<?php echo $this->p->t('anrechnung', 'keineEmpfehlungAngefordert'); ?>
</div>
<div class="panel panel-default panel-body <?php echo
is_null($empfehlungData->empfehlung) && $anrechnungData->status_kurzbz == 'inProgressLektor'
? '' : 'hidden' ?>"
id="approveAnrechnungDetail-empfehlungDetail-empfehlungIsNull">
<?php echo $this->p->t('anrechnung', 'empfehlungAngefordertNochKeineEmpfehlung'); ?>
<?php echo $empfehlungData->empfehlung_angefordert_am ?>.
</div>
<div class="alert alert-success <?php echo $empfehlungData->empfehlung === true ? '' : 'hidden' ?>"
id="approveAnrechnungDetail-empfehlungDetail-empfehlungIsTrue">
<b><?php echo $this->p->t('anrechnung', 'empfehlungPositiv'); ?></b>
</div>
<div class="<?php echo $empfehlungData->empfehlung === false ? '' : 'hidden' ?>"
id="approveAnrechnungDetail-empfehlungDetail-empfehlungIsFalse">
<div class="alert alert-danger"><b><?php echo $this->p->t('anrechnung', 'empfehlungNegativ'); ?></b></div>
<div class="well"><b><?php echo $this->p->t('global', 'begruendung'); ?>: </b>
<span id="approveAnrechnungDetail-empfehlungDetail-begruendung"><?php echo $empfehlungData->notiz ?></span>
</div>
</div>
</div>
</div>
</form>
<div class="pull-right">
<button id="request-recommendation" class="btn btn-primary btn-w200"
<?php echo is_null($empfehlungData->empfehlung) && $anrechnungData->status_kurzbz == 'inProgressDP' ? '' : 'disabled' ?>>
<?php echo ucfirst($this->p->t('anrechnung', 'empfehlungAnfordern')); ?>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-4">
<div class="alert text-center">
Status:
<b><span class="text-uppercase" id="approveAnrechnung-status_kurzbz"
data-status_kurzbz="<?php echo $anrechnungData->status_kurzbz ?>">
<?php echo $anrechnungData->status; ?>
</span></b>
</div>
<br>
<?php $this->load->view('lehre/anrechnung/reviewAnrechnungInfo'); ?>
</div>
</div>
</div>
</div>
</body>
<?php $this->load->view('templates/FHC-Footer'); ?>
@@ -121,7 +121,7 @@ $this->load->view(
</div>
</div>
</div>
<!-- Antrag mit Checkboxen -->
<!-- Empfehlungsdaten -->
<div class="row">
<div class="col-lg-12">
<form>