diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index e14a34d8f..7197b014c 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -101,9 +101,11 @@ class InfoCenter extends Auth_Controller 'reloadNotizen' => 'infocenter:r', 'reloadLogs' => 'infocenter:r', 'outputAkteContent' => 'infocenter:r', - 'getParkedDate' => 'infocenter:r', + 'getPostponeDate' => 'infocenter:r', 'park' => 'infocenter:rw', 'unpark' => 'infocenter:rw', + 'setOnHold' => 'infocenter:rw', + 'removeOnHold' => 'infocenter:rw', 'getStudienjahrEnd' => 'infocenter:r', 'setNavigationMenuArrayJson' => 'infocenter:r' ) @@ -712,11 +714,32 @@ class InfoCenter extends Auth_Controller * Gets the date until which a person is parked * @param $person_id */ - public function getParkedDate($person_id) + public function getPostponeDate($person_id) { + $result = array( + 'type' => null, + 'date' => null + ); + $parkedDate = $this->personloglib->getParkedDate($person_id); - $this->outputJsonSuccess(array($parkedDate)); + if (isset($parkedDate)) + { + $result['type'] = 'parked'; + $result['date'] = $parkedDate; + } + else + { + $onholdDate = $this->personloglib->getOnHoldDate($person_id); + + if (isset($onholdDate)) + { + $result['type'] = 'onhold'; + $result['date'] = $onholdDate; + } + } + + $this->outputJsonSuccess($result); } /** @@ -744,6 +767,31 @@ class InfoCenter extends Auth_Controller $this->outputJson($result); } + /** + * Sets a person on hold ("zurückstellen") + */ + public function setOnHold() + { + $person_id = $this->input->post('person_id'); + $date = $this->input->post('onholddate'); + + $result = $this->personloglib->setOnHold($person_id, date_format(date_create($date), 'Y-m-d'), self::TAETIGKEIT, self::APP, null, $this->_uid); + + $this->outputJson($result); + } + + /** + * Removed on hold status of a person + */ + public function removeOnHold() + { + $person_id = $this->input->post('person_id'); + + $result = $this->personloglib->removeOnHold($person_id); + + $this->outputJson($result); + } + /** * Gets the End date of the current Studienjahr */ diff --git a/application/libraries/PersonLogLib.php b/application/libraries/PersonLogLib.php index b56937dfe..ed530ef34 100644 --- a/application/libraries/PersonLogLib.php +++ b/application/libraries/PersonLogLib.php @@ -8,6 +8,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class PersonLogLib { const PARKED_LOGNAME = 'Parked'; + const ONHOLD_LOGNAME = 'Onhold'; /** * Constructor @@ -91,26 +92,20 @@ class PersonLogLib */ public function park($person_id, $date, $taetigkeit_kurzbz, $app = 'core', $oe_kurzbz = null, $user = null) { - $logdata = array( + $onhold = $this->getOnHoldDate($person_id); + + if (hasData($onhold)) + return error("Person already on hold"); + + $logjson = array( 'name' => self::PARKED_LOGNAME ); - $data = array( - 'person_id' => $person_id, - 'zeitpunkt' => $date, - 'taetigkeit_kurzbz' => $taetigkeit_kurzbz, - 'app' => $app, - 'oe_kurzbz' => $oe_kurzbz, - 'logtype_kurzbz' => 'Processstate', - 'logdata' => json_encode($logdata), - 'insertvon' => $user - ); - - return $this->ci->PersonLogModel->insert($data); + return $this->_saveLog($person_id, $date, $taetigkeit_kurzbz, $logjson, $app, $oe_kurzbz, $user); } /** - * Unparks a person, i.e. removes all log entries in the future + * Unparks a person, i.e. removes all log entries in the future with logname for parking * @param $person_id * @return array with deleted logids */ @@ -131,17 +126,9 @@ class PersonLogLib { $deleted[] = $log->log_id; } - else - { - return $delresult; - } } } } - else - { - return $result; - } return success($deleted); } @@ -172,4 +159,111 @@ class PersonLogLib return $parkeddate; } + + /** + * Sets person on hold, i.e. marks a person so no actions are expected for the person (e.g. as a prestudent). + * Done by adding a logentry with a special name. can be undone only manually by clicking button. + * @param $person_id + * @param $date + * @param $taetigkeit_kurzbz + * @param string $app + * @param null $oe_kurzbz + * @param null $user + * @return array + */ + public function setOnHold($person_id, $date, $taetigkeit_kurzbz, $app = 'core', $oe_kurzbz = null, $user = null) + { + $parked = $this->getParkedDate($person_id); + + if (hasData($parked)) + return error("Person already parked"); + + $logjson = array( + 'name' => self::ONHOLD_LOGNAME + ); + + return $this->_saveLog($person_id, $date, $taetigkeit_kurzbz, $logjson, $app, $oe_kurzbz, $user); + } + + /** + * Removes on hold status, i.e. removes all log entries with logname for on hold + * @param $person_id + * @return array + */ + public function removeOnHold($person_id) + { + $deleted = array(); + + $result = $this->ci->PersonLogModel->filterLog($person_id); + if (hasData($result)) + { + foreach ($result->retval as $log) + { + $logdata = json_decode($log->logdata); + if (isset($logdata->name) && $logdata->name === self::ONHOLD_LOGNAME) + { + $delresult = $this->ci->PersonLogModel->deleteLog($log->log_id); + if (isSuccess($delresult)) + { + $deleted[] = $log->log_id; + } + } + } + } + return success($deleted); + } + + /** + * Gets date until which a person is on hold + * @param $person_id + * @return the date if person is on hold, null otherwise + */ + public function getOnHoldDate($person_id) + { + $result = $this->ci->PersonLogModel->filterLog($person_id); + + $onholddate = null; + + if (hasData($result)) + { + foreach ($result->retval as $log) + { + $logdata = json_decode($log->logdata); + if (isset($logdata->name) && $logdata->name === self::ONHOLD_LOGNAME) + { + $onholddate = $log->zeitpunkt; + break; + } + } + } + + return $onholddate; + } + + /** + * Saves a log with specified parameters, including a specified log date. + * @param $person_id + * @param $date + * @param $taetigkeit_kurzbz + * @param $logjson + * @param string $app + * @param null $oe_kurzbz + * @param null $user + * @return mixed + */ + private function _saveLog($person_id, $date, $taetigkeit_kurzbz, $logjson, $app = 'core', $oe_kurzbz = null, $user = null) + { + $data = array( + 'person_id' => $person_id, + 'zeitpunkt' => $date, + 'taetigkeit_kurzbz' => $taetigkeit_kurzbz, + 'app' => $app, + 'oe_kurzbz' => $oe_kurzbz, + 'logtype_kurzbz' => 'Processstate', + 'logdata' => json_encode($logjson), + 'insertvon' => $user + ); + + return $this->ci->PersonLogModel->insert($data); + } } diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index 9e708d076..68b6c760e 100644 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -34,7 +34,12 @@ 'nichtsZumAusparken', 'fehlerBeimAusparken', 'fehlerBeimParken', - 'bewerberGeparktBis' + 'bewerberGeparktBis', + 'bewerberOnHold', + 'bewerberOnHoldEntfernen', + 'bewerberOnHoldBis', + 'nichtsZumEntfernen', + 'fehlerBeimEntfernen', ), 'ui' => array( 'gespeichert', @@ -176,7 +181,7 @@
-
+
load->view('system/infocenter/logs.php'); ?>
diff --git a/public/css/infocenter/infocenterDetails.css b/public/css/infocenter/infocenterDetails.css index b8bdc84bf..1586fd52d 100644 --- a/public/css/infocenter/infocenterDetails.css +++ b/public/css/infocenter/infocenterDetails.css @@ -65,4 +65,9 @@ #scrollToTop:hover{ background-color: lightgrey; +} + +#postponedate{ + height: 25px; + width: 99px } \ No newline at end of file diff --git a/public/js/infocenter/infocenterDetails.js b/public/js/infocenter/infocenterDetails.js index a43b36df8..09d2b3447 100644 --- a/public/js/infocenter/infocenterDetails.js +++ b/public/js/infocenter/infocenterDetails.js @@ -10,111 +10,113 @@ const STGFREIGABE_MESSAGE_VORLAGE = "InfocenterSTGfreigegeben"; //Statusgründe for which no Studiengang Freigabe Message should be sent const FIT_PROGRAMM_STUDIENGAENGE = [10021, 10027]; +const PARKEDNAME = 'parked'; +const ONHOLDNAME = 'onhold'; + /** * javascript file for infocenterDetails page */ $(document).ready(function () { - //initialise table sorter - Tablesort.addTablesorter("doctable", [[2, 1], [1, 0]], ["zebra"]); - Tablesort.addTablesorter("nachgdoctable", [[2, 0], [1, 1]], ["zebra"]); + //initialise table sorter + Tablesort.addTablesorter("doctable", [[2, 1], [1, 0]], ["zebra"]); + Tablesort.addTablesorter("nachgdoctable", [[2, 0], [1, 1]], ["zebra"]); - InfocenterDetails._formatMessageTable(); - InfocenterDetails._formatNotizTable(); - InfocenterDetails._formatLogTable(); + InfocenterDetails._formatMessageTable(); + InfocenterDetails._formatNotizTable(); + InfocenterDetails._formatLogTable(); - var personid = $("#hiddenpersonid").val(); - - //add submit event to message send link - $("#sendmsglink").click(function () - { - $("#sendmsgform").submit(); - }); - - //add click events to "formal geprüft" checkboxes - $(".prchbox").click(function () - { - var boxid = this.id; - var akteid = boxid.substr(boxid.indexOf("_") + 1); - var checked = this.checked; - InfocenterDetails.saveFormalGeprueft(personid, akteid, checked) - }); - - //add click events to zgv Prüfung section - InfocenterDetails._addZgvPruefungEvents(personid); - - MessageList.initMessageList(); - - //save notiz - $("#notizform").on("submit", function (e) - { - e.preventDefault(); - var notizid = $("#notizform :input[name='hiddenNotizId']").val(); - var formdata = $(this).serializeArray(); - var data = {}; - - data.person_id = personid; - - for (var i = 0; i < formdata.length; i++) - { - data[formdata[i].name] = formdata[i].value; - } - - $("#notizmsg").empty(); - - if (notizid !== '') - { - InfocenterDetails.updateNotiz(notizid, data); - } - else - { - InfocenterDetails.saveNotiz(personid, data); - } - } - ); - - //update notiz - autofill notizform - $(document).on("click", "#notiztable tbody tr", function () - { - $("#notizmsg").empty(); - - var notizid = $(this).find("td.hiddennotizid").html(); - - InfocenterDetails.getNotiz(notizid); - } - ); - - //update notiz - abbrechen-button: reset styles - $("#notizform :input[type='reset']").click(function () - { - InfocenterDetails._resetNotizFields(); - } - ); - - //check if person is parked and display it - InfocenterDetails.getParkedDate(personid); - - if ($(document).scrollTop() > 20) - $("#scrollToTop").show(); - - //scroll to top button - $(window).scroll(function() - { - if ($(document).scrollTop() > 20) - $("#scrollToTop").show(); - else - $("#scrollToTop").hide(); - } - ); - - $("#scrollToTop").click(function() - { - $('html,body').animate({scrollTop:0},250,'linear'); - } - ) + var personid = $("#hiddenpersonid").val(); + //add submit event to message send link + $("#sendmsglink").click(function () + { + $("#sendmsgform").submit(); }); + //add click events to "formal geprüft" checkboxes + $(".prchbox").click(function () + { + var boxid = this.id; + var akteid = boxid.substr(boxid.indexOf("_") + 1); + var checked = this.checked; + InfocenterDetails.saveFormalGeprueft(personid, akteid, checked) + }); + + //add click events to zgv Prüfung section + InfocenterDetails._addZgvPruefungEvents(personid); + + MessageList.initMessageList(); + + //save notiz + $("#notizform").on("submit", function (e) + { + e.preventDefault(); + var notizid = $("#notizform :input[name='hiddenNotizId']").val(); + var formdata = $(this).serializeArray(); + var data = {}; + + data.person_id = personid; + + for (var i = 0; i < formdata.length; i++) + { + data[formdata[i].name] = formdata[i].value; + } + + $("#notizmsg").empty(); + + if (notizid !== '') + { + InfocenterDetails.updateNotiz(notizid, data); + } + else + { + InfocenterDetails.saveNotiz(personid, data); + } + } + ); + + //update notiz - autofill notizform + $(document).on("click", "#notiztable tbody tr", function () + { + $("#notizmsg").empty(); + + var notizid = $(this).find("td.hiddennotizid").html(); + + InfocenterDetails.getNotiz(notizid); + } + ); + + //update notiz - abbrechen-button: reset styles + $("#notizform :input[type='reset']").click(function () + { + InfocenterDetails._resetNotizFields(); + } + ); + + //check if person is postponed (parked, on hold...) and display it + InfocenterDetails.getPostponeDate(personid); + + if ($(document).scrollTop() > 20) + $("#scrollToTop").show(); + + //scroll to top button + $(window).scroll(function() + { + if ($(document).scrollTop() > 20) + $("#scrollToTop").show(); + else + $("#scrollToTop").hide(); + } + ); + + $("#scrollToTop").click(function() + { + $('html,body').animate({scrollTop:0},250,'linear'); + } + ) +}); + var InfocenterDetails = { openZgvInfoForPrestudent: function(prestudent_id) @@ -397,7 +399,7 @@ var InfocenterDetails = { { var engdate = $.datepicker.parseDate("yy-mm-dd", FHC_AjaxClient.getData(data)[0]); var gerdate = $.datepicker.formatDate("dd.mm.yy", engdate); - $("#parkdate").val(gerdate); + $("#postponedate").val(gerdate); } }, errorCallback: function() @@ -408,19 +410,19 @@ var InfocenterDetails = { } ); }, - getParkedDate: function(personid) + getPostponeDate: function(personid) { FHC_AjaxClient.ajaxCallGet( - CALLED_PATH + "/getParkedDate/"+encodeURIComponent(personid), + CALLED_PATH + "/getPostponeDate/"+encodeURIComponent(personid), null, { successCallback: function(data, textStatus, jqXHR) { if (FHC_AjaxClient.hasData(data)) { - var parkedDate = FHC_AjaxClient.getData(data)[0]; - InfocenterDetails._refreshParking(parkedDate); + var postponeobj = FHC_AjaxClient.getData(data); + InfocenterDetails._refreshPostpone(postponeobj); InfocenterDetails._refreshLog(); - if (parkedDate === null) + if (postponeobj === null || postponeobj.type === null) InfocenterDetails.getStudienjahrEnd(); } }, @@ -435,7 +437,7 @@ var InfocenterDetails = { parkPerson: function(personid, date) { var parkError = function(){ - $("#parkmsg").text(" Fehler beim Parken!"); + $("#postponemsg").text(" Fehler beim Parken!"); }; FHC_AjaxClient.ajaxCallPost( @@ -447,7 +449,7 @@ var InfocenterDetails = { { successCallback: function(data, textStatus, jqXHR) { if (FHC_AjaxClient.hasData(data)) - InfocenterDetails.getParkedDate(personid); + InfocenterDetails.getPostponeDate(personid); else { parkError(); @@ -469,13 +471,62 @@ var InfocenterDetails = { successCallback: function(data, textStatus, jqXHR) { if (FHC_AjaxClient.hasData(data)) { - InfocenterDetails.getParkedDate(personid); + InfocenterDetails.getPostponeDate(personid); } else - $("#unparkmsg").removeClass().addClass("text-warning").text(FHC_PhrasesLib.t('infocenter', 'nichtsZumAusparken')); + $("#unpostponemsg").removeClass().addClass("text-warning").text(FHC_PhrasesLib.t('infocenter', 'nichtsZumAusparken')); }, errorCallback: function(){ - $("#unparkmsg").removeClass().addClass("text-danger").text(FHC_PhrasesLib.t('infocenter', 'fehlerBeimAusparken')); + $("#unpostponemsg").removeClass().addClass("text-danger").text(FHC_PhrasesLib.t('infocenter', 'fehlerBeimAusparken')); + }, + veilTimeout: 0 + } + ); + }, + setPersonOnHold: function(personid, date) + { + var onHoldError = function(){ + $("#postponemsg").text(" Fehler beim Setzen auf On Hold!"); + }; + + FHC_AjaxClient.ajaxCallPost( + CALLED_PATH + '/setOnHold', + { + "person_id": personid, + "onholddate": date + }, + { + successCallback: function(data, textStatus, jqXHR) { + if (FHC_AjaxClient.hasData(data)) + InfocenterDetails.getPostponeDate(personid); + else + { + onHoldError(); + } + }, + errorCallback: onHoldError, + veilTimeout: 0 + } + ); + }, + removePersonOnHold: function(personid) + { + FHC_AjaxClient.ajaxCallPost( + CALLED_PATH + '/removeOnHold', + { + "person_id": personid + }, + { + successCallback: function(data, textStatus, jqXHR) { + if (FHC_AjaxClient.hasData(data)) + { + InfocenterDetails.getPostponeDate(personid); + } + else + $("#unpostponemsg").removeClass().addClass("text-warning").text(FHC_PhrasesLib.t('infocenter', 'nichtsZumEntfernen')); + }, + errorCallback: function(){ + $("#unpostponemsg").removeClass().addClass("text-danger").text(FHC_PhrasesLib.t('infocenter', 'fehlerBeimEntfernen')); }, veilTimeout: 0 } @@ -864,50 +915,98 @@ var InfocenterDetails = { } ); }, - _refreshParking: function(date) + _refreshPostpone: function(postponeobj) { - if (date === null) + var personid = $("#hiddenpersonid").val(); + if (postponeobj === null || postponeobj.date === null || postponeobj.type === null) { - $("#parking").html( + //show both park and on hold buttons if not parked and not on hold + $("#postponing").html( '
'+ '     '+ + '     '+ FHC_PhrasesLib.t('global', 'bis') + '  '+ - ' '+ - ''+ + ' '+ + ' '+ + ''+ '
'); - $("#parkdate").datepicker({ + $("#postponedate").datepicker({ "dateFormat": "dd.mm.yy", "minDate": 0 }); + $("#parklink").click( function () { - var personid = $("#hiddenpersonid").val(); - var date = $("#parkdate").val(); - + //console.log(date); + var date = $("#postponedate").val(); InfocenterDetails.parkPerson(personid, date); } ); + + $("#onholdlink").click( + + function () + { + var date = $("#postponedate").val(); + InfocenterDetails.setPersonOnHold(personid, date); + } + ); } else { - var parkdate = $.datepicker.parseDate("yy-mm-dd", date); - var gerparkdate = $.datepicker.formatDate("dd.mm.yy", parkdate); - $("#parking").html( - FHC_PhrasesLib.t('infocenter', 'bewerberGeparktBis')+'  '+gerparkdate+'     '+ - ' '+ - '' + //info if parked/on hold and possibility to undo parking/on hold + var postponedate = $.datepicker.parseDate("yy-mm-dd", postponeobj.date); + var gerpostponedate = $.datepicker.formatDate("dd.mm.yy", postponedate); + + //var postponehtml = ""; + var callbackforundo = null; + var removePhrase = ""; + var postponedPhrase = ""; + var postponedtext = ""; + + if (postponeobj.type === PARKEDNAME) + { + removePhrase = 'bewerberAusparken'; + postponedtext = FHC_PhrasesLib.t('infocenter', 'bewerberGeparktBis')+'  '+gerpostponedate; + + callbackforundo = function () + { + InfocenterDetails.unparkPerson(personid); + } + } + else if (postponeobj.type === ONHOLDNAME) + { + removePhrase = 'bewerberOnHoldEntfernen'; + postponedtext = FHC_PhrasesLib.t('infocenter', 'bewerberOnHoldBis')+'  '+gerpostponedate; + + var currdate = new Date(); + + if (currdate > postponedate) + postponedtext = ""+postponedtext+""; + + callbackforundo = function () + { + InfocenterDetails.removePersonOnHold(personid); + } + } + + var postponehtml = postponedtext+'     '+ + ' '+ + ''; + + + $("#postponing").html( + postponehtml ); - $("#unparklink").click( - function () - { - var personid = $("#hiddenpersonid").val(); - InfocenterDetails.unparkPerson(personid, date); - } + $("#unpostponelink").click( + callbackforundo ); } }, diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 0ee2aeda5..b38aebb2c 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -3450,6 +3450,106 @@ $phrases = array( 'insertvon' => 'system' ) ) + ), + array( + 'app' => 'infocenter', + 'category' => 'infocenter', + 'phrase' => 'bewerberOnHold', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'BewerberIn zurückstellen', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Put applicant on hold', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'infocenter', + 'category' => 'infocenter', + 'phrase' => 'bewerberOnHoldEntfernen', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Zurückstellung entfernen', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Remove on hold state', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'infocenter', + 'category' => 'infocenter', + 'phrase' => 'bewerberOnHoldBis', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'BewerberIn zurückgestellt bis', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Applicant on hold until', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'infocenter', + 'category' => 'infocenter', + 'phrase' => 'nichtsZumEntfernen', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Nichts zum Entfernen', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Nothing to remove', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'infocenter', + 'category' => 'infocenter', + 'phrase' => 'fehlerBeimEntfernen', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Fehler beim Entfernen', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Error when removing', + 'description' => '', + 'insertvon' => 'system' + ) + ) ) );