mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-23 09:52:22 +00:00
Merge branch 'feature-15391/Positive_Zeitsperre'
This commit is contained in:
@@ -71,6 +71,16 @@ $config['navigation_header'] = array(
|
||||
'lehre/lehrauftrag_erteilen:r'
|
||||
)
|
||||
),
|
||||
'zverfueg' => array(
|
||||
'link' => site_url('lehre/lvplanung/AdminZeitverfuegbarkeit'),
|
||||
'description' => 'Zeitverfügbarkeit',
|
||||
'expand' => true,
|
||||
'sort' => 45,
|
||||
'requiredPermissions' => array(
|
||||
'lehre/zeitverfuegbarkeit:rw',
|
||||
'lehre/zeitverfuegbarkeit:rw'
|
||||
)
|
||||
),
|
||||
'zgvueberpruefung' => array(
|
||||
'link' => site_url('system/infocenter/ZGVUeberpruefung'),
|
||||
'description' => 'ZGV Überprüfung',
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class LVPlanJob extends CLI_Controller
|
||||
class LVPlanJob extends JOB_Controller
|
||||
{
|
||||
/**
|
||||
* Initialize LVPlanJob Class
|
||||
@@ -149,4 +149,313 @@ class LVPlanJob extends CLI_Controller
|
||||
echo "Failed ".$fail."\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Mail to STGL, Kompetenzfeld and LV Planung about todays updated Zeitwuensche.
|
||||
* STGL gets list only of lectors who updated future assigend courses concerning their STG.
|
||||
* Kompetenzleitung gets list only of lectors who updated future assigend courses concerning their KF.
|
||||
* LVPlanung gets list of lectors who updated future assigend courses.
|
||||
*/
|
||||
public function mailUpdatedZeitwuensche()
|
||||
{
|
||||
// Load models
|
||||
$this->load->model('ressource/Stundenplandev_model', 'StundenplandevModel');
|
||||
$this->load->model('organisation/Studiensemester_model', 'StundiensemesterModel');
|
||||
$this->load->model('education/Lehreinheit_model', 'LehreinheitModel');
|
||||
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
|
||||
// Load libs
|
||||
$this->load->library('MailLib');
|
||||
|
||||
// Load helpers
|
||||
$this->load->helper('hlp_sancho_helper');
|
||||
|
||||
// Start Log Message
|
||||
$this->logInfo('Mail updated Zeitwuensche started.');
|
||||
|
||||
// Get all lectors, who updated their Zeitwunsch today
|
||||
$db = new DB_Model();
|
||||
$result = $db->execReadOnlyQuery('
|
||||
SELECT
|
||||
zwg.mitarbeiter_uid, tbl_lehrveranstaltung.studiengang_kz, tbl_lehrveranstaltung.oe_kurzbz
|
||||
FROM
|
||||
campus.tbl_zeitwunsch_gueltigkeit zwg
|
||||
JOIN lehre.tbl_stundenplandev stpl
|
||||
ON(
|
||||
stpl.mitarbeiter_uid=zwg.mitarbeiter_uid
|
||||
AND stpl.datum BETWEEN zwg.von AND COALESCE(zwg.bis, \'2999-12-31\')
|
||||
AND (zwg.insertamum::date = (NOW()-\'1 days\'::interval)::date
|
||||
OR
|
||||
zwg.updateamum::date = (NOW()-\'1 days\'::interval)::date)
|
||||
AND stpl.datum > now()
|
||||
)
|
||||
JOIN lehre.tbl_lehreinheit USING(lehreinheit_id)
|
||||
JOIN lehre.tbl_lehrveranstaltung USING(lehrveranstaltung_id)
|
||||
GROUP BY
|
||||
zwg.mitarbeiter_uid, tbl_lehrveranstaltung.studiengang_kz, tbl_lehrveranstaltung.oe_kurzbz
|
||||
');
|
||||
|
||||
if (!hasData($result))
|
||||
{
|
||||
return; // No updated Zeitwuensche today
|
||||
}
|
||||
|
||||
$uidByStg_arr = array(); // Mail data for Studiengang
|
||||
$uidByOe_arr = array(); // Mail data for Kompetenzfeld
|
||||
$uid_arr = array(); // Mail data for Kompetenzfeld
|
||||
|
||||
// Loop through lectors, who updated their Zeitwunsch today
|
||||
$changed_arr = getData($result);
|
||||
foreach ($changed_arr as $row)
|
||||
{
|
||||
|
||||
// Add unique lector array
|
||||
if (!in_array($row->mitarbeiter_uid, $uid_arr))
|
||||
{
|
||||
$uid_arr[]= $row->mitarbeiter_uid;
|
||||
}
|
||||
|
||||
// Build unique Studiengang array
|
||||
if (!array_key_exists($row->studiengang_kz, $uidByStg_arr))
|
||||
{
|
||||
$uidByStg_arr[$row->studiengang_kz] = array($row->mitarbeiter_uid);
|
||||
|
||||
}
|
||||
elseif (!in_array($row->mitarbeiter_uid, $uidByStg_arr[$row->studiengang_kz]))
|
||||
{
|
||||
$uidByStg_arr[$row->studiengang_kz][]= $row->mitarbeiter_uid;
|
||||
}
|
||||
|
||||
// Build unique Kompetenzfeld array
|
||||
if (!array_key_exists($row->oe_kurzbz, $uidByOe_arr))
|
||||
{
|
||||
$uidByOe_arr[$row->oe_kurzbz] = array($row->mitarbeiter_uid);
|
||||
|
||||
}
|
||||
elseif (!in_array($row->mitarbeiter_uid, $uidByOe_arr[$row->oe_kurzbz]))
|
||||
{
|
||||
$uidByOe_arr[$row->oe_kurzbz][]= $row->mitarbeiter_uid;
|
||||
}
|
||||
}
|
||||
|
||||
// Send mail to STG Assistenz
|
||||
$result = $this->_sendMailToStg($uidByStg_arr);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->logError(getError($result));
|
||||
}
|
||||
|
||||
// Send mail to Kompetenzfeld Leitung
|
||||
$result = $this->_sendMailToKF($uidByOe_arr);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->logError(getError($result));
|
||||
}
|
||||
|
||||
// Send mail to LV Planung
|
||||
$result = $this->_sendMailToLvPlanung($uid_arr);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->logError(getError($result));
|
||||
}
|
||||
|
||||
// End Log Message
|
||||
$this->logInfo('Mail updated Zeitwuensche ended.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Mail to STGL Assistance about lectors, who teach LV assigend to the STG, and who updated Zeitwuensche.
|
||||
*
|
||||
* @param $data_arr
|
||||
* @param $stg_bezeichnung
|
||||
*/
|
||||
private function _sendMailToStg($data_arr)
|
||||
{
|
||||
foreach ($data_arr as $stg_kurzbz => $uid_arr)
|
||||
{
|
||||
// Get STG eMail
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
$result = $this->StudiengangModel->load($stg_kurzbz);
|
||||
$stgMail = $result->retval[0]->email;
|
||||
|
||||
$lektorenTabelle = '
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th style="text-align:left">Name</th>
|
||||
<th style="text-align:left">UID</th>
|
||||
</tr>
|
||||
</thead><tbody>
|
||||
';
|
||||
|
||||
foreach($uid_arr as $uid)
|
||||
{
|
||||
$person = $this->PersonModel->getByUid($uid);
|
||||
$lektorenTabelle.= '
|
||||
<tr>
|
||||
<td style="text-align:left">'. getData($person)[0]->vorname. ' '. getData($person)[0]->nachname. '</td>
|
||||
<td style="text-align:left">['. $uid. ']</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
|
||||
$lektorenTabelle.= '</tbody></table>';
|
||||
|
||||
$contentData_arr = array(
|
||||
'datentabelle' => $lektorenTabelle
|
||||
);
|
||||
|
||||
// Send mail
|
||||
if (!sendSanchoMail(
|
||||
'ZeitwunschUpdateMail',
|
||||
$contentData_arr,
|
||||
$stgMail,
|
||||
'Änderung von Zeitwünschen',
|
||||
'sancho_header_min_bw.jpg',
|
||||
'sancho_footer_min_bw.jpg'
|
||||
))
|
||||
{
|
||||
$errorReceiverUid_arr[]= $stgMail;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($errorReceiverUid_arr))
|
||||
{
|
||||
return error('Mail updated Zeitwuensche could not be sent to :'. implode($errorReceiverUid_arr, ','));
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Mail to Kompetenzfeld about lectors, who teach LV assigend to the Kompetenzfeld, and who updated Zeitwuensche.
|
||||
*
|
||||
* @param $data_arr
|
||||
* @param $stg_bezeichnung
|
||||
*/
|
||||
private function _sendMailToKF($data_arr)
|
||||
{
|
||||
// Send mail to Komepetenzfeld Leitung
|
||||
foreach ($data_arr as $oe_kurzbz => $uid_arr)
|
||||
{
|
||||
// Get KF Leitung eMail
|
||||
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
|
||||
$result = $this->BenutzerfunktionModel->getBenutzerFunktionen(
|
||||
'Leitung',
|
||||
$oe_kurzbz,
|
||||
$activeoeonly = true,
|
||||
$activebenonly = true
|
||||
);
|
||||
|
||||
if(isSuccess($result) && hasData($result))
|
||||
{
|
||||
$empfaenger = array();
|
||||
|
||||
foreach(getData($result) as $row)
|
||||
$empfaenger[] = $row->uid. '@'. DOMAIN;
|
||||
$kfMail = implode(',',$empfaenger);
|
||||
|
||||
$lektorenTabelle = '
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th style="text-align:left">Name</th>
|
||||
<th style="text-align:left">UID</th>
|
||||
</tr>
|
||||
</thead><tbody>
|
||||
';
|
||||
|
||||
foreach($uid_arr as $uid)
|
||||
{
|
||||
$person = $this->PersonModel->getByUid($uid);
|
||||
$lektorenTabelle.= '
|
||||
<tr>
|
||||
<td style="text-align:left">'. getData($person)[0]->vorname. ' '. getData($person)[0]->nachname. '</td>
|
||||
<td style="text-align:left">['. $uid. ']</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
|
||||
$lektorenTabelle.= '</tbody></table>';
|
||||
|
||||
$contentData_arr = array(
|
||||
'datentabelle' => $lektorenTabelle
|
||||
);
|
||||
|
||||
// Send mail
|
||||
if (!sendSanchoMail(
|
||||
'ZeitwunschUpdateMail',
|
||||
$contentData_arr,
|
||||
$kfMail,
|
||||
'Änderung von Zeitwünschen',
|
||||
'sancho_header_min_bw.jpg',
|
||||
'sancho_footer_min_bw.jpg'
|
||||
))
|
||||
{
|
||||
$errorReceiverUid_arr[]= $kfMail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($errorReceiverUid_arr))
|
||||
{
|
||||
return error('Mail updated Zeitwuensche could not be sent to :'. implode($errorReceiverUid_arr, ','));
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Mail to LV Planung about all lectors who updated Zeitwuensche.
|
||||
*
|
||||
* @param $data_arr
|
||||
* @param $stg_bezeichnung
|
||||
*/
|
||||
private function _sendMailToLvPlanung($data_arr)
|
||||
{
|
||||
$lektorenTabelle = '
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th style="text-align:left">Name</th>
|
||||
<th style="text-align:left">UID</th>
|
||||
</tr>
|
||||
</thead><tbody>
|
||||
';
|
||||
|
||||
foreach($data_arr as $lector)
|
||||
{
|
||||
$person = $this->PersonModel->getByUid($lector);
|
||||
$lektorenTabelle.= '
|
||||
<tr>
|
||||
<td style="text-align:left">'. getData($person)[0]->vorname. ' '. getData($person)[0]->nachname. '</td>
|
||||
<td style="text-align:left">['. $lector. ']</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
|
||||
$lektorenTabelle.= '</tbody></table>';
|
||||
|
||||
$contentData_arr = array(
|
||||
'datentabelle' => $lektorenTabelle
|
||||
);
|
||||
|
||||
// Send mail
|
||||
if (!sendSanchoMail(
|
||||
'ZeitwunschUpdateMail',
|
||||
$contentData_arr,
|
||||
MAIL_LVPLAN,
|
||||
'Änderung von Zeitwünschen',
|
||||
'sancho_header_min_bw.jpg',
|
||||
'sancho_footer_min_bw.jpg'
|
||||
))
|
||||
{
|
||||
$errorReceiver = MAIL_LVPLAN;
|
||||
}
|
||||
|
||||
if (isset($errorReceiver))
|
||||
{
|
||||
return error('Mail updated Zeitwuensche could not be sent to :'. $errorReceiver);
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class AdminZeitverfuegbarkeit extends Auth_Controller
|
||||
{
|
||||
const BERECHTIGUNG_ZEITVERFUEGBARKEIT = 'lehre/zeitverfuegbarkeit';
|
||||
private $_uid; // uid of the logged user
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Set required permissions
|
||||
parent::__construct(
|
||||
array(
|
||||
'index' => 'lehre/zeitverfuegbarkeit:rw',
|
||||
'saveZeitverfuegbarkeit' => 'lehre/zeitverfuegbarkeit:rw',
|
||||
'deleteZeitverfuegbarkeit' => 'lehre/zeitverfuegbarkeit:rw'
|
||||
)
|
||||
);
|
||||
|
||||
// Load models
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
$this->load->model('ressource/Zeitsperre_model', 'ZeitsperreModel');
|
||||
|
||||
// Load libraries
|
||||
$this->load->library('PermissionLib');
|
||||
$this->load->library('AuthLib');
|
||||
$this->load->library('WidgetLib');
|
||||
|
||||
// Load helpers
|
||||
$this->load->helper('array');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'global',
|
||||
'ui',
|
||||
'lehre'
|
||||
)
|
||||
);
|
||||
|
||||
$this->_setAuthUID(); // sets property uid
|
||||
|
||||
$this->setControllerId(); // sets the controller id
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
public function index()
|
||||
{
|
||||
// Get Studiengaenge the user is entitled for
|
||||
$result = $this->permissionlib->getSTG_isEntitledFor(self::BERECHTIGUNG_ZEITVERFUEGBARKEIT);
|
||||
$studiengang_kz_arr = !isEmptyArray($result) ? $result : array();
|
||||
|
||||
// Get lectors of that Studiengaenge
|
||||
$result = $this->_getLehreinheitmitarbeiterByStg($studiengang_kz_arr);
|
||||
$lektor_arr = hasData($result) ? getData($result) : array();
|
||||
|
||||
// Get available Stundenplan Stunden
|
||||
$result = $this->_getStunden();
|
||||
$stunde_arr = hasData($result) ? getData($result) : array();
|
||||
|
||||
// Get actual Studiensemester to set min-limit Datepicker
|
||||
$result = $this->StudiensemesterModel->getAkt();
|
||||
$studsemStart = hasData($result) ? getData($result)[0]->start : '';
|
||||
|
||||
$view_data = array(
|
||||
'studiengang_kz_arr' => $studiengang_kz_arr,
|
||||
'lektor_arr' => $lektor_arr,
|
||||
'stunde_arr' => $stunde_arr,
|
||||
'studsemStart' => $studsemStart
|
||||
);
|
||||
|
||||
$this->load->view('lehre/lvplanung/adminZeitverfuegbarkeit.php', $view_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save or update Zeitverfuegbarkeit.
|
||||
*/
|
||||
public function saveZeitverfuegbarkeit()
|
||||
{
|
||||
$zeitsperre_id = $this->input->post('zeitsperre_id');
|
||||
$mitarbeiter_uid = $this->input->post('mitarbeiter_uid');
|
||||
$zeitsperretyp_kurzbz = $this->input->post('zeitsperretyp_kurzbz');
|
||||
$bezeichnung = $this->input->post('bezeichnung');
|
||||
$vonDatum = $this->input->post('vondatum');
|
||||
$vonStunde = isEmptyString($this->input->post('vonstunde')) ? null : $this->input->post('vonstunde');
|
||||
$bisDatum = $this->input->post('bisdatum');
|
||||
$bisStunde = isEmptyString($this->input->post('bisstunde')) ? null : $this->input->post('bisstunde');
|
||||
|
||||
$result = $this->_validate($this->input->post());
|
||||
if (isSuccess($result))
|
||||
{
|
||||
if (is_numeric($zeitsperre_id))
|
||||
{
|
||||
$result = $this->ZeitsperreModel->update(
|
||||
$zeitsperre_id,
|
||||
array(
|
||||
'vondatum' => $vonDatum,
|
||||
'vonstunde' => $vonStunde,
|
||||
'bisdatum' => $bisDatum,
|
||||
'bisstunde' => $bisStunde,
|
||||
'bezeichnung' => $bezeichnung
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->ZeitsperreModel->save(
|
||||
$zeitsperretyp_kurzbz,
|
||||
$mitarbeiter_uid,
|
||||
$vonDatum,
|
||||
$bisDatum,
|
||||
$vonStunde,
|
||||
$bisStunde,
|
||||
$bezeichnung
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithJsonError(getError($result));
|
||||
}
|
||||
|
||||
$zeitsperre_id = getData($result);
|
||||
|
||||
// Success response to AJAX
|
||||
$this->outputJsonSuccess(array(
|
||||
'zeitsperre_id' => $zeitsperre_id,
|
||||
'msg' => $this->p->t('ui', 'gespeichert')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Zeitverfuegbarkeit.
|
||||
*/
|
||||
public function deleteZeitverfuegbarkeit()
|
||||
{
|
||||
$zeitsperre_id = $this->input->post('zeitsperre_id');
|
||||
|
||||
if (!is_numeric($zeitsperre_id))
|
||||
{
|
||||
$this->terminateWithJsonError('Wählen Sie einen Lehrenden aus der Zeitverfügbarkeit-Tabelle aus.');
|
||||
}
|
||||
|
||||
// Load Zeitsperre
|
||||
$result = $this->ZeitsperreModel->load($zeitsperre_id);
|
||||
$delZsp = getData($result)[0];
|
||||
|
||||
// Delete
|
||||
$result = $this->ZeitsperreModel->delete($zeitsperre_id);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithJsonError(getError($result));
|
||||
}
|
||||
|
||||
// Store Deletion query
|
||||
$delQry = $this->db->last_query();
|
||||
|
||||
// Log deletion
|
||||
$this->_logDeletion($delZsp, $delQry);
|
||||
|
||||
$this->outputJsonSuccess(array('msg' => $this->p->t('ui', 'geloescht')));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all lectors that are assigend to Lehreinheiten in actual or future semester.
|
||||
*
|
||||
* @param $studiengang_kz_arr Restrict only to given stg-
|
||||
* @return mixed
|
||||
*/
|
||||
private function _getLehreinheitmitarbeiterByStg($studiengang_kz_arr)
|
||||
{
|
||||
$this->MitarbeiterModel->addSelect('lema.mitarbeiter_uid, nachname, vorname');
|
||||
$this->MitarbeiterModel->addDistinct('lema.mitarbeiter_uid');
|
||||
$this->MitarbeiterModel->addJoin('lehre.tbl_lehreinheitmitarbeiter lema', 'tbl_mitarbeiter.mitarbeiter_uid = lema.mitarbeiter_uid');
|
||||
$this->MitarbeiterModel->addJoin('public.tbl_benutzer b', 'lema.mitarbeiter_uid = b.uid');
|
||||
$this->MitarbeiterModel->addJoin('public.tbl_person p', 'person_id');
|
||||
$this->MitarbeiterModel->addJoin('lehre.tbl_lehreinheit le', 'lehreinheit_id');
|
||||
$this->MitarbeiterModel->addJoin('lehre.tbl_lehrveranstaltung lv', 'lehrveranstaltung_id');
|
||||
$this->MitarbeiterModel->addJoin('public.tbl_studiensemester ss', 'studiensemester_kurzbz');
|
||||
$this->MitarbeiterModel->addOrder('lema.mitarbeiter_uid');
|
||||
|
||||
// Return lektoren assigned to actual or future lehreinheiten
|
||||
return $this->MitarbeiterModel->loadWhere('
|
||||
lv.studiengang_kz IN (' . implode(', ', $studiengang_kz_arr) . ')
|
||||
AND b.aktiv
|
||||
AND personalnummer > 0
|
||||
AND NOW() <= ss.ende'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all available Stunden of Stundentabelle.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function _getStunden()
|
||||
{
|
||||
$this->load->model('ressource/Stunde_model', 'StundeModel');
|
||||
$this->StundeModel->addOrder('stunde');
|
||||
|
||||
return $this->StundeModel->load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validaton checks performed on post data.
|
||||
*
|
||||
* @param $post
|
||||
* @return array|stdClass
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _validate($post)
|
||||
{
|
||||
if (isEmptyString($post['mitarbeiter_uid']))
|
||||
{
|
||||
return (error('LektorIn fehlt'));
|
||||
}
|
||||
|
||||
if (isEmptyString($post['bezeichnung']))
|
||||
{
|
||||
return (error('Notiz fehlt'));
|
||||
}
|
||||
|
||||
if (isEmptyString($post['vondatum']))
|
||||
{
|
||||
return error('Startdatum fehlt');
|
||||
}
|
||||
|
||||
if (isEmptyString($post['bisdatum']))
|
||||
{
|
||||
return error('Endedatum fehlt');
|
||||
}
|
||||
|
||||
if (new DateTime($post['bisdatum']) < new DateTime($post['vondatum']))
|
||||
{
|
||||
return error('Endedatum darf nicht VOR dem Startdatum liegen');
|
||||
}
|
||||
|
||||
// Check bisstunde not after vonstunde within same day
|
||||
if (new DateTime($post['bisdatum']) == new DateTime($post['vondatum']))
|
||||
{
|
||||
if (is_numeric($post['vonstunde']) && is_numeric($post['bisstunde'])
|
||||
&& $post['bisstunde'] < $post['vonstunde'])
|
||||
{
|
||||
return error('Am gleichen Tag darf Endstunde nicht VOR der Startstunde liegen');
|
||||
}
|
||||
}
|
||||
|
||||
// Check dates are > then start of actual Studiensemester
|
||||
$result = $this->StudiensemesterModel->getAkt();
|
||||
$studsemStart = hasData($result) ? getData($result)[0]->start : '';
|
||||
|
||||
if (new DateTime($post['vondatum']) < new DateTime($studsemStart) ||
|
||||
new DateTime($post['bisdatum']) < new DateTime($studsemStart))
|
||||
{
|
||||
return error('Start- und Endedatum können nur für das aktuelle oder künftige Studiensemester geplant werden');
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Log information of deleted Zeitsperre into log table.
|
||||
*
|
||||
* @param $delZsp object of deleted Zeitsperre
|
||||
* @param $delQry string of performed delete query
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _logDeletion($delZsp, $delQry)
|
||||
{
|
||||
$beschreibung = 'Zeitverfügbarkeitlöschung '
|
||||
. $delZsp->mitarbeiter_uid. ' '
|
||||
. (new DateTime($delZsp->vondatum))->format('d.m.Y')
|
||||
. (is_null($delZsp->vonstunde) ? '(*)' : '('. $delZsp->vonstunde. ')')
|
||||
. '-'
|
||||
. (new DateTime($delZsp->bisdatum))->format('d.m.Y')
|
||||
. (is_null($delZsp->bisstunde) ? '(*)' : '('. $delZsp->bisstunde. ')')
|
||||
. '';
|
||||
|
||||
$this->load->model('system/Log_model', 'LogModel');
|
||||
return $this->LogModel->insert(array(
|
||||
'mitarbeiter_uid' => $this->_uid,
|
||||
'beschreibung' => substr($beschreibung, 0, 64),
|
||||
'sql' => $delQry
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerIm
|
||||
$body = _parseMailContent('Sancho_Mail_Template', $layout);
|
||||
|
||||
// Send mail
|
||||
$ci->maillib->send($from, $to, $subject, $body, $alias = '', $cc, $bcc, $altMessage = '', $bulk = true, $autogenerated = true);
|
||||
return $ci->maillib->send($from, $to, $subject, $body, $alias = '', $cc, $bcc, $altMessage = '', $bulk = true, $autogenerated = true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,20 @@ class Studiensemester_model extends DB_Model
|
||||
$this->hasSequence = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get actual Studiensemester.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAkt()
|
||||
{
|
||||
return $this->loadWhere(array(
|
||||
'start <= ' => 'NOW()',
|
||||
'ende >= ' => 'NOW()'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Get next study semester
|
||||
public function getNext()
|
||||
{
|
||||
@@ -167,15 +181,13 @@ class Studiensemester_model extends DB_Model
|
||||
if (date_format(date_create($from), 'Y-m-d') > (date_format(date_create($to), 'Y-m-d')))
|
||||
return success(array());
|
||||
|
||||
$query = "SELECT *
|
||||
FROM public.tbl_studiensemester
|
||||
WHERE
|
||||
(ende > ?::date AND start < ?::date)
|
||||
OR start = ?::date
|
||||
OR ende = ?::date
|
||||
ORDER BY start DESC";
|
||||
$query = "
|
||||
SELECT *
|
||||
FROM public.tbl_studiensemester
|
||||
WHERE ( ?::date < ende AND ?::date > start )
|
||||
ORDER BY start DESC";
|
||||
|
||||
return $this->execQuery($query, array($from, $to, $from, $to));
|
||||
return $this->execQuery($query, array($from, $to));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,4 +61,98 @@ class Stundenplandev_model extends DB_Model
|
||||
|
||||
return $this->execQuery($qry, $parametersArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Stundenplan data.
|
||||
*
|
||||
* @param null $lehrveranstaltung_id
|
||||
* @param null $studiensemester_kurzbz
|
||||
* @param null $lehreinheit_id
|
||||
* @param null $mitarbeiter_uid
|
||||
* @param null $student_uid
|
||||
* @param false $nurBevorstehende If true, only future data is retrieved.
|
||||
* @return array|false|stdClass|null
|
||||
*/
|
||||
public function getStundenplanData($lehrveranstaltung_id=null, $studiensemester_kurzbz=null, $lehreinheit_id=null, $mitarbeiter_uid=null, $student_uid=null, $nurBevorstehende = false)
|
||||
{
|
||||
$params = array();
|
||||
|
||||
$qry = "SELECT
|
||||
stpl.datum, min(stpl.stunde) as stundevon, max(stpl.stunde) as stundebis,
|
||||
stpl.lehreinheit_id, lehrfach.bezeichnung as lehrfach_bezeichnung,
|
||||
array_agg(
|
||||
CASE WHEN gruppe_kurzbz is not null THEN gruppe_kurzbz
|
||||
ELSE (SELECT UPPER(typ || kurzbz) FROM public.tbl_studiengang WHERE studiengang_kz=stpl.studiengang_kz) || COALESCE(stpl.semester,'0') || COALESCE(stpl.verband,'') || COALESCE(stpl.gruppe,'')
|
||||
END) as gruppen, array_agg(mitarbeiter_uid) as lektoren,
|
||||
array_agg(ort_kurzbz) as orte,
|
||||
array_agg(titel) as titel
|
||||
FROM
|
||||
lehre.tbl_stundenplandev as stpl
|
||||
JOIN lehre.tbl_lehreinheit USING(lehreinheit_id)
|
||||
JOIN lehre.tbl_lehrveranstaltung as lehrfach ON(tbl_lehreinheit.lehrfach_id=lehrfach.lehrveranstaltung_id)
|
||||
WHERE ";
|
||||
|
||||
if ($lehrveranstaltung_id != '')
|
||||
{
|
||||
$qry.="
|
||||
lehreinheit_id IN (
|
||||
SELECT lehreinheit_id FROM lehre.tbl_lehreinheit
|
||||
WHERE lehrveranstaltung_id = ?
|
||||
AND studiensemester_kurzbz = ?
|
||||
)";
|
||||
|
||||
$params[]= $lehrveranstaltung_id;
|
||||
$params[]= $studiensemester_kurzbz;
|
||||
|
||||
}
|
||||
elseif ($lehreinheit_id!='')
|
||||
{
|
||||
$qry.=" lehreinheit_id = ?";
|
||||
|
||||
$params[]= $lehreinheit_id;
|
||||
}
|
||||
elseif ($mitarbeiter_uid != '')
|
||||
{
|
||||
$qry.= "
|
||||
mitarbeiter_uid = ?
|
||||
AND lehreinheit_id IN (
|
||||
SELECT lehreinheit_id
|
||||
FROM lehre.tbl_lehreinheitmitarbeiter
|
||||
JOIN lehre.tbl_lehreinheit USING (lehreinheit_id)
|
||||
WHERE mitarbeiter_uid = ?
|
||||
AND studiensemester_kurzbz IN ( ? )
|
||||
)";
|
||||
$params[] = $mitarbeiter_uid;
|
||||
$params[] = $mitarbeiter_uid;
|
||||
$params[] = $studiensemester_kurzbz;
|
||||
}
|
||||
elseif ($student_uid != '')
|
||||
{
|
||||
$qry.="
|
||||
lehreinheit_id IN (
|
||||
SELECT lehreinheit_id
|
||||
FROM campus.vw_student_lehrveranstaltung
|
||||
WHERE uid = ?
|
||||
AND studiensemester_kurzbz = ?
|
||||
)";
|
||||
|
||||
$params[] = $student_uid;
|
||||
$params[] = $studiensemester_kurzbz;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
if($nurBevorstehende)
|
||||
{
|
||||
$qry.= " AND stpl.datum >= NOW()::date ";
|
||||
}
|
||||
|
||||
$qry.= "
|
||||
GROUP BY stpl.datum, stpl.unr, stpl.lehreinheit_id, lehrfach.bezeichnung
|
||||
ORDER BY stpl.datum, min(stpl.stunde), stpl.unr, stpl.lehreinheit_id
|
||||
";
|
||||
|
||||
return $this->execQuery($qry, $params);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,47 @@ class Zeitsperre_model extends DB_Model
|
||||
$this->pk = 'zeitsperre_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* Save or update Zeitsperre.
|
||||
*
|
||||
* @param $zeitsperretyp_kurzbz
|
||||
* @param $mitarbeiter_uid
|
||||
* @param $vonDatum
|
||||
* @param $bisDatum
|
||||
* @param null $vonStunde
|
||||
* @param null $bisStunde
|
||||
* @param null $bezeichnung
|
||||
* @param null $vertretung_uid
|
||||
* @param null $erreichbarkeit_kurzbz
|
||||
* @param null $freigabeamum
|
||||
* @param null $freigabevon
|
||||
* @return array
|
||||
*/
|
||||
public function save($zeitsperretyp_kurzbz, $mitarbeiter_uid, $vonDatum, $bisDatum,
|
||||
$vonStunde = null, $bisStunde = null, $bezeichnung = null, $vertretung_uid = null,
|
||||
$erreichbarkeit_kurzbz = null, $freigabeamum = null, $freigabevon = null)
|
||||
{
|
||||
return $this->insert(array(
|
||||
'zeitsperretyp_kurzbz' => $zeitsperretyp_kurzbz,
|
||||
'mitarbeiter_uid' => $mitarbeiter_uid,
|
||||
'vondatum' => $vonDatum,
|
||||
'bisdatum' => $bisDatum,
|
||||
'vonstunde' => $vonStunde,
|
||||
'bisstunde' => $bisStunde,
|
||||
'bezeichnung' => $bezeichnung,
|
||||
'vertretung_uid' => $vertretung_uid,
|
||||
'insertvon' => getAuthUID(),
|
||||
'insertamum' => (new DateTime())->format('Y-m-d H:i:s'),
|
||||
'erreichbarkeit_kurzbz' => $erreichbarkeit_kurzbz,
|
||||
'freigabeamum' => $freigabeamum,
|
||||
'freigabevon' => $freigabevon
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Zeitsperre.
|
||||
* @return array|stdClass|null
|
||||
*/
|
||||
public function deleteEntriesForCurrentDay()
|
||||
{
|
||||
$today = date('Y-m-d');
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Zeitwunsch_gueltigkeit_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'campus.tbl_zeitwunsch_gueltigkeit';
|
||||
$this->pk = 'zeitwunsch_gueltigkeit_id';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
$this->load->view(
|
||||
'templates/FHC-Header',
|
||||
array(
|
||||
'title' => 'Zeitverfuegbarkeit verwalten',
|
||||
'jquery' => true,
|
||||
'jqueryui' => true,
|
||||
'bootstrap' => true,
|
||||
'fontawesome' => true,
|
||||
'momentjs' => true,
|
||||
'ajaxlib' => true,
|
||||
'tabulator' => true,
|
||||
'tablewidget' => true,
|
||||
'navigationwidget' => true,
|
||||
'sbadmintemplate' => true,
|
||||
'phrases' => array(
|
||||
'global' => array(
|
||||
'bis',
|
||||
'notiz'
|
||||
),
|
||||
'ui' => array(
|
||||
'systemfehler',
|
||||
'keineDatenVorhanden',
|
||||
'von',
|
||||
'bitteWaehlen',
|
||||
'speichern',
|
||||
'loeschen',
|
||||
'abbrechen'
|
||||
),
|
||||
'lehre' => array(
|
||||
'lektor'
|
||||
)
|
||||
),
|
||||
'widgets' => true,
|
||||
'dialoglib' => true,
|
||||
'customJSs' => array(
|
||||
'public/js/bootstrapper.js',
|
||||
'public/js/lehre/lvplanung/zverfueg.js'
|
||||
)
|
||||
)
|
||||
);
|
||||
?>
|
||||
|
||||
<body>
|
||||
<?php echo $this->widgetlib->widget('NavigationWidget'); ?>
|
||||
<div id="page-wrapper">
|
||||
<div class="container-fluid">
|
||||
|
||||
<!-- title -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12 page-header">
|
||||
<h3>Zeitverfügbarkeiten verwalten<small> | Punktuelle Zeitverfügbarkeiten von Lehrenden für die LV-Planung verwalten</small></h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- form -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<form id="form-zeitverfuegbarkeit" class="form-horizontal">
|
||||
<input type="hidden" id="studsemStart" value="<?php echo $studsemStart ?>">
|
||||
<input type="hidden" id="zeitsperre_id" name="zeitsperre_id" value="">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="mitarbeiter_uid" class="col-sm-1 control-label">LektorIn: </label>
|
||||
<div class="col-sm-3">
|
||||
<select id="mitarbeiter_uid" name="mitarbeiter_uid" class="form-control select-w500" required>
|
||||
<option value="" >
|
||||
<?php echo $this->p->t('ui', 'bitteWaehlen'); ?>
|
||||
</option>
|
||||
<?php foreach ($lektor_arr as $lektor) : ?>
|
||||
<option value="<?php echo $lektor->mitarbeiter_uid ?>">
|
||||
<?php echo $lektor->nachname. ' '. $lektor->vorname ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="zverfueg" class="col-sm-1 control-label">Grund: </label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" id="zeitsperretyp_kurzbz" value="Zeitverfügbarkeit" name="zeitsperretyp_kurzbz" readonly />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="bezeichnung" class="col-sm-1 control-label">Notiz: </label>
|
||||
<div class="col-sm-3">
|
||||
<textarea type="" id="bezeichnung" name="bezeichnung" value="" required></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="vondatum" class="col-sm-1 control-label">Von: </label>
|
||||
<div class="col-sm-3">
|
||||
<input type="date" id="vondatum" name="vondatum" class="form-control zverfueg-datepicker" required>
|
||||
</div>
|
||||
<label for="vonstunde" class="col-sm-1 control-label">Stunde (inkl.): </label>
|
||||
<div class="col-sm-3">
|
||||
<select id="vonstunde" name="vonstunde" class="form-control select-w500">
|
||||
<option value="" >*</option>
|
||||
<?php foreach ($stunde_arr as $stunde) : ?>
|
||||
<option value="<?php echo $stunde->stunde ?>">
|
||||
<?php echo $stunde->stunde.
|
||||
' ['.
|
||||
(new DateTime($stunde->beginn))->format('H:i'). ' - '.
|
||||
(new DateTime($stunde->ende))->format('H:i').
|
||||
']' ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="bisdatum" class="col-sm-1 control-label">Bis: </label>
|
||||
<div class="col-sm-3">
|
||||
<input type="date" id="bisdatum" name="bisdatum" class="form-control zverfueg-datepicker" required>
|
||||
</div>
|
||||
<label for="bisstunde" class="col-sm-1 control-label">Stunde (inkl.): </label>
|
||||
<div class="col-sm-3">
|
||||
<select id="bisstunde" name="bisstunde" class="form-control select-w500">
|
||||
<option value="" >*</option>
|
||||
<?php foreach ($stunde_arr as $stunde) : ?>
|
||||
<option value="<?php echo $stunde->stunde ?>">
|
||||
<?php echo $stunde->stunde.
|
||||
' ['.
|
||||
(new DateTime($stunde->beginn))->format('H:i'). ' - '.
|
||||
(new DateTime($stunde->ende))->format('H:i').
|
||||
']' ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-8">
|
||||
<button type="submit" id="btn-save" class="btn btn-primary btn-w200 pull-right">
|
||||
<?php echo ucfirst($this->p->t('ui', 'speichern')); ?>
|
||||
</button>
|
||||
<button type="button" id="btn-delete" class="btn btn-danger btn-w200 btn-mr5 pull-right" disabled
|
||||
data-toggle="tooltip" data-placement="right"
|
||||
title="Zum Löschen LektorIn aus Tabelle wählen">
|
||||
<?php echo ucfirst($this->p->t('ui', 'loeschen')); ?>
|
||||
</button>
|
||||
<button type="reset" id="btn-break" class="btn btn-default btn-w200 btn-mr5 pull-right">
|
||||
<?php echo ucfirst($this->p->t('ui', 'abbrechen')); ?>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- data table -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<?php $this->load->view('lehre/lvplanung/adminZeitverfuegbarkeitData.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><!-- end container -->
|
||||
</div><!-- end page-wrapper -->
|
||||
<br>
|
||||
</body>
|
||||
|
||||
<?php $this->load->view('templates/FHC-Footer'); ?>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
$STUDIENGANG_KZ_ARR = $studiengang_kz_arr; // stg the user is entitled to administrate
|
||||
|
||||
$qry = '
|
||||
SELECT * FROM (
|
||||
SELECT DISTINCT ON (zeitsperre_id, zsp.mitarbeiter_uid) zeitsperre_id, zsp.mitarbeiter_uid,
|
||||
concat_ws(\' \', nachname, vorname) AS "lektor",
|
||||
vondatum, vonstunde, bisdatum, bisstunde, zsp.bezeichnung
|
||||
FROM public.tbl_person
|
||||
JOIN public.tbl_benutzer b USING (person_id)
|
||||
JOIN public.tbl_mitarbeiter ma ON (ma.mitarbeiter_uid = b.uid)
|
||||
JOIN lehre.tbl_lehreinheitmitarbeiter lema ON (lema.mitarbeiter_uid = b.uid)
|
||||
JOIN lehre.tbl_lehreinheit le USING (lehreinheit_id)
|
||||
JOIN lehre.tbl_lehrveranstaltung lv USING (lehrveranstaltung_id)
|
||||
JOIN public.tbl_studiensemester ss USING (studiensemester_kurzbz)
|
||||
JOIN campus.tbl_zeitsperre zsp ON zsp.mitarbeiter_uid = lema.mitarbeiter_uid
|
||||
WHERE lv.studiengang_kz IN ('. implode (',', $STUDIENGANG_KZ_ARR). ')
|
||||
AND b.aktiv
|
||||
AND zsp.vondatum >= ss.start
|
||||
AND zeitsperretyp_kurzbz = \'ZVerfueg\'
|
||||
ORDER BY zeitsperre_id, zsp.mitarbeiter_uid
|
||||
) as tmp
|
||||
ORDER BY vondatum DESC
|
||||
';
|
||||
|
||||
$filterWidgetArray = array(
|
||||
'query' => $qry,
|
||||
'tableUniqueId' => 'adminZeitverfuegbarkeit',
|
||||
'requiredPermissions' => 'lehre/zeitverfuegbarkeit',
|
||||
'datasetRepresentation' => 'tabulator',
|
||||
'columnsAliases' => array(
|
||||
'ZeitsperreID',
|
||||
'UID',
|
||||
ucfirst($this->p->t('lehre', 'lektor')),
|
||||
ucfirst($this->p->t('ui', 'von')),
|
||||
'VonStunde',
|
||||
ucfirst($this->p->t('global', 'bis')),
|
||||
'BisStunde',
|
||||
ucfirst($this->p->t('global', 'notiz'))
|
||||
),
|
||||
'datasetRepOptions' => '{
|
||||
layout: "fitColumns", // fit columns to width of table
|
||||
autoResize: false, // prevent auto resizing of table (false to allow adapting table size when cols are (de-)activated
|
||||
headerFilterPlaceholder: " ",
|
||||
index: "zeitsperre_id", // assign specific column as unique id (important for row indexing)
|
||||
selectable: 1, // allow row selection
|
||||
tableWidgetHeader: false,
|
||||
rowSelected: function(row) {
|
||||
func_rowSelected(row);
|
||||
},
|
||||
rowDeselected: function(row) {
|
||||
func_rowDeselected(row);
|
||||
}
|
||||
}', // tabulator properties
|
||||
'datasetRepFieldsDefs' => '{
|
||||
zeitsperre_id: {visible:false},
|
||||
mitarbeiter_uid: {visible: true, headerFilter:"input"},
|
||||
lektor: {visible: true, headerFilter:"input"},
|
||||
vondatum: {visible: true, headerFilter:"input"},
|
||||
vonstunde: {visible: true, headerFilter:"input"},
|
||||
bisdatum: {visible: true, headerFilter:"input"},
|
||||
bisstunde: {visible: true, headerFilter:"input"},
|
||||
bezeichnung: {visible: true, headerFilter:"input"}
|
||||
}', // col properties
|
||||
);
|
||||
|
||||
echo $this->widgetlib->widget('TableWidget', $filterWidgetArray);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user