diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index 4dac2663f..44081da16 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -15,6 +15,7 @@ class Messages extends Auth_Controller array( 'write' => array('basis/message:rw', 'infocenter:rw'), 'send' => array('basis/message:rw', 'infocenter:rw'), + 'sendJson' => array('basis/message:rw', 'infocenter:rw'), 'getVorlage' => array('basis/message:r', 'infocenter:r'), 'parseMessageText' => array('basis/message:r', 'infocenter:r'), 'getMessageFromIds' => array('basis/message:r', 'infocenter:r') @@ -190,6 +191,38 @@ class Messages extends Auth_Controller * send */ public function send($sender_id = null) + { + $result = $this->_execSend($sender_id); + + if (isSuccess($result)) + { + echo "Messages sent successfully"; + } + else + { + echo "Error when sending message"; + } + } + + /** + * Send message, response is in JSON format + * @param $sender_id + */ + public function sendJson($sender_id = null) + { + $result = $this->_execSend($sender_id); + + $this->output + ->set_content_type('application/json') + ->set_output(json_encode($result)); + } + + /** + * Executes message sending + * @param $sender_id + * @return array wether execution was successfull - error or success + */ + private function _execSend($sender_id) { if ($sender_id === null) { @@ -197,18 +230,19 @@ class Messages extends Auth_Controller if (!hasData($user_person)) { - show_error('no sender'); + return error('no sender'); } $sender_id = $user_person->retval[0]->person_id; } - $error = false; - $subject = $this->input->post('subject'); $body = $this->input->post('body'); $prestudents = $this->input->post('prestudents'); $persons = $this->input->post('persons'); $relationmessage_id = $this->input->post('relationmessage_id'); + $vorlage_kurzbz = $this->input->post('vorlage_kurzbz'); + $oe_kurzbz = $this->input->post('oe_kurzbz'); + $msgvars = $this->input->post('msgvars'); if (!isset($relationmessage_id) || $relationmessage_id == '') { @@ -240,10 +274,8 @@ class Messages extends Auth_Controller $dataArray[$newKey] = $dataArray[$key]; } - $parsedText = $this->messagelib->parseMessageText($body, $dataArray); - - $oe_kurzbz = null; - if (hasData($prestudentsData)) + // if oe not given, get from prestudent + if (isEmptyString($oe_kurzbz) && hasData($prestudentsData)) { for ($p = 0; $p < count($prestudentsData->retval); $p++) { @@ -254,12 +286,29 @@ class Messages extends Auth_Controller } } - $msg = $this->messagelib->sendMessage($sender_id, $dataArray['person_id'], $subject, $parsedText, PRIORITY_NORMAL, $relationmessage_id, $oe_kurzbz); + // send without vorlage + if (isEmptyString($vorlage_kurzbz)) + { + $parsedText = $this->messagelib->parseMessageText($body, $dataArray); + $msg = $this->messagelib->sendMessage($sender_id, $dataArray['person_id'], $subject, $parsedText, PRIORITY_NORMAL, $relationmessage_id, $oe_kurzbz); + } + // send with vorlage + else + { + if (isset($msgvars) && is_array($msgvars)) + { + //additional message variables + foreach ($msgvars as $key => $msgvar) + { + $dataArray[$key] = $msgvar; + } + } + $msg = $this->messagelib->sendMessageVorlage($sender_id, $dataArray['person_id'], $vorlage_kurzbz, $oe_kurzbz, $dataArray); + } + if ($msg->error) { - show_error($msg->retval); - $error = true; - break; + return error($msg->msg); } // Loads the person log library @@ -279,12 +328,9 @@ class Messages extends Auth_Controller null, $this->uid ); - } - } - if (!$error) - { - echo "Messages sent successfully"; + return success($msg->retval); + } } } @@ -383,8 +429,10 @@ class Messages extends Auth_Controller * @param $msg_id * @param $receiver_id */ - public function getMessageFromIds($msg_id, $receiver_id) + public function getMessageFromIds() { + $msg_id = $this->input->get('msg_id'); + $receiver_id = $this->input->get('receiver_id'); $msg = $this->messagelib->getMessage($msg_id, $receiver_id); $this->output diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index fdc0db7d0..e669a105a 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -11,6 +11,7 @@ class InfoCenter extends Auth_Controller // App and Verarbeitungstaetigkeit name for logging const APP = 'infocenter'; const TAETIGKEIT = 'bewerbung'; + const FREIGABE_MAIL_VORLAGE = 'InfocenterMailFreigabeAssistenz'; const INFOCENTER_URI = 'system/infocenter/InfoCenter'; // URL prefix for this controller const INDEX_PAGE = 'index'; @@ -83,9 +84,10 @@ class InfoCenter extends Auth_Controller 'saveFreigabe' => 'infocenter:rw', 'saveNotiz' => 'infocenter:rw', 'updateNotiz' => 'infocenter:rw', + 'reloadZgvPruefungen' => 'infocenter:r', + 'reloadMessages' => 'infocenter:r', 'reloadNotizen' => 'infocenter:r', 'reloadLogs' => 'infocenter:r', - 'reloadZgvPruefungen' => 'infocenter:r', 'outputAkteContent' => 'infocenter:r', 'getParkedDate' => 'infocenter:r', 'park' => 'infocenter:rw', @@ -307,12 +309,16 @@ class InfoCenter extends Auth_Controller */ public function saveZgvPruefung() { + $json = null; + $prestudent_id = $this->input->post('prestudentid'); if (isEmptyString($prestudent_id)) - $result = error('Prestudentid missing'); + $json = error('Prestudentid missing'); else { + $ausbildungssemester = $this->input->post('ausbildungssemester'); + // zgvdata // Check for string null, in case dropdown changed to default value $zgv_code = $this->input->post('zgv') === 'null' ? null : $this->input->post('zgv'); @@ -321,14 +327,28 @@ class InfoCenter extends Auth_Controller $zgvdatum = isEmptyString($zgvdatum) ? null : date_format(date_create($zgvdatum), 'Y-m-d'); $zgvnation_code = $this->input->post('zgvnation') === 'null' ? null : $this->input->post('zgvnation'); - //zgvmasterdata + // zgvmasterdata $zgvmas_code = $this->input->post('zgvmas') === 'null' ? null : $this->input->post('zgvmas'); $zgvmaort = $this->input->post('zgvmaort'); $zgvmadatum = $this->input->post('zgvmadatum'); $zgvmadatum = isEmptyString($zgvmadatum) ? null : date_format(date_create($zgvmadatum), 'Y-m-d'); $zgvmanation_code = $this->input->post('zgvmanation') === 'null' ? null : $this->input->post('zgvmanation'); - $result = $this->PrestudentModel->update( + $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id, '', 'Interessent'); + + $semresult = null; + + if (hasData($lastStatus)) + { + $semresult = $this->PrestudentstatusModel->update( + array('prestudent_id' => $lastStatus->retval[0]->prestudent_id, + 'status_kurzbz' => $lastStatus->retval[0]->status_kurzbz, + 'studiensemester_kurzbz' => $lastStatus->retval[0]->studiensemester_kurzbz), + array('ausbildungssemester' => $ausbildungssemester) + ); + } + + $prestresult = $this->PrestudentModel->update( $prestudent_id, array( 'zgv_code' => $zgv_code, @@ -343,7 +363,14 @@ class InfoCenter extends Auth_Controller ) ); - if (isSuccess($result)) + if (isError($prestresult)) + $json = error('Error when updating Prestudent!'); + elseif (isError($semresult)) + $json = error('Error when updating Ausbildungssemester!'); + else + $json = success('Zgv saved successfully!'); + + if (isSuccess($semresult) || isSuccess($prestresult)) { //get extended Prestudent data for logging $logdata = $this->_getPersonAndStudiengangFromPrestudent($prestudent_id); @@ -351,7 +378,7 @@ class InfoCenter extends Auth_Controller $this->_log($logdata['person_id'], 'savezgv', array($logdata['studiengang_kurzbz'], $prestudent_id)); } } - $this->output->set_content_type('application/json')->set_output(json_encode($result)); + $this->output->set_content_type('application/json')->set_output(json_encode($json)); } /** @@ -414,6 +441,7 @@ class InfoCenter extends Auth_Controller { $json = null; $prestudent_id = $this->input->post('prestudent_id'); + $statusgrund_id = $this->input->post('statusgrund_id'); $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id); @@ -428,6 +456,18 @@ class InfoCenter extends Auth_Controller //check if still Interessent and not freigegeben yet if ($lastStatus->status_kurzbz === 'Interessent' && !isset($lastStatus->bestaetigtam)) { + $statusdata = array( + 'bestaetigtvon' => $this->_uid, + 'bestaetigtam' => date('Y-m-d'), + 'updatevon' => $this->_uid, + 'updateamum' => date('Y-m-d H:i:s') + ); + + if (isset($statusgrund_id) && is_numeric($statusgrund_id)) + { + $statusdata['statusgrund_id'] = $statusgrund_id; + } + $result = $this->PrestudentstatusModel->update( array( 'prestudent_id' => $prestudent_id, @@ -435,12 +475,7 @@ class InfoCenter extends Auth_Controller 'studiensemester_kurzbz' => $lastStatus->studiensemester_kurzbz, 'ausbildungssemester' => $lastStatus->ausbildungssemester ), - array( - 'bestaetigtvon' => $this->_uid, - 'bestaetigtam' => date('Y-m-d'), - 'updatevon' => $this->_uid, - 'updateamum' => date('Y-m-d H:i:s') - ) + $statusdata ); $json = $result; @@ -459,7 +494,7 @@ class InfoCenter extends Auth_Controller $acceptresult = $this->DokumentprestudentModel->setAcceptedDocuments($prestudent_id, $dokument_kurzbzs); - //returns null if no documents to accept + // acceptresult returns null if no documents to accept if ($acceptresult !== null && isError($acceptresult)) { $json->error = 2; @@ -526,6 +561,29 @@ class InfoCenter extends Auth_Controller $this->output->set_content_type('application/json')->set_output(json_encode($result)); } + /** + * Loads Zgv Prüfung view for a person, helper for reloading after ajax request + * @param $person_id + */ + public function reloadZgvPruefungen($person_id) + { + $prestudentdata = $this->_loadPrestudentData($person_id); + + $prestudentdata[self::FHC_CONTROLLER_ID] = $this->getControllerId(); + + $this->load->view('system/infocenter/zgvpruefungen.php', $prestudentdata); + } + + /** + * Loads Messages view for a person, helper for reloading after ajax request + * @param $person_id + */ + public function reloadMessages($person_id) + { + $messages = $this->MessageModel->getMessagesOfPerson($person_id, 1); + $this->load->view('system/messageList.php', array('messages' => $messages->retval)); + } + /** * Loads Notizen view for a person, helper for reloading after ajax request * @param $person_id @@ -552,19 +610,6 @@ class InfoCenter extends Auth_Controller $this->load->view('system/infocenter/logs.php', array('logs' => $logs)); } - /** - * Loads Zgv Prüfung view for a person, helper for reloading after ajax request - * @param $person_id - */ - public function reloadZgvPruefungen($person_id) - { - $prestudentdata = $this->_loadPrestudentData($person_id); - - $prestudentdata[self::FHC_CONTROLLER_ID] = $this->getControllerId(); - - $this->load->view('system/infocenter/zgvpruefungen.php', $prestudentdata); - } - /** * Outputs content of an Akte, sends appropriate headers (so the document can be downloaded) * @param $akte_id @@ -1087,7 +1132,7 @@ class InfoCenter extends Auth_Controller //if prestudent is not interessent or is already bestaetigt, then show only as information, non-editable $zgvpruefung->infoonly = !isset($zgvpruefung->prestudentstatus) || isset($zgvpruefung->prestudentstatus->bestaetigtam) || $zgvpruefung->prestudentstatus->status_kurzbz != 'Interessent'; - //numeric application priority and arrows for changing + //numeric application priority $zgvpruefung->changeup = false; $zgvpruefung->changedown = false; @@ -1108,16 +1153,16 @@ class InfoCenter extends Auth_Controller $zgvpruefungen[] = $zgvpruefung; } - $this->load->model('organisation/studiensemester_model', 'StudiensemesterModel'); - $this->_sortPrestudents($zgvpruefungen); - $statusgruende = $this->StatusgrundModel->loadWhere(array('status_kurzbz' => 'Abgewiesener'))->retval; + $abwstatusgruende = $this->StatusgrundModel->loadWhere(array('status_kurzbz' => 'Abgewiesener'))->retval; + $intstatusgruende = $this->StatusgrundModel->loadWhere(array('status_kurzbz' => 'Interessent'))->retval; $data = array ( 'zgvpruefungen' => $zgvpruefungen, 'numberinteressenten' => $interessentenCount, - 'statusgruende' => $statusgruende + 'abwstatusgruende' => $abwstatusgruende, + 'intstatusgruende' => $intstatusgruende ); return $data; @@ -1129,6 +1174,8 @@ class InfoCenter extends Auth_Controller */ private function _sortPrestudents(&$zgvpruefungen) { + $this->load->model('organisation/studiensemester_model', 'StudiensemesterModel'); + @usort($zgvpruefungen, function ($a, $b) { //sort: // 1: Studiensemester @@ -1209,30 +1256,6 @@ class InfoCenter extends Auth_Controller }); } - /** - * Helper function for redirecting to initial page for person from a prestudent-specific page - * @param $prestudent_id - * @param $section optional section of the page to go to - */ - private function _redirectToStart($prestudent_id, $section = '') - { - $this->PrestudentModel->addSelect('person_id'); - $person_id = $this->PrestudentModel->load($prestudent_id)->retval[0]->person_id; - - redirect( - sprintf( - '/%s/%s?%s=%s&%s=%s#%s', - self::INFOCENTER_URI, - self::SHOW_DETAILS_PAGE, - 'person_id', - $person_id, - self::FHC_CONTROLLER_ID, - $this->getControllerId(), - $section - ) - ); - } - /** * Helper function retrieves personid and studiengang kurzbz from a prestudent id * @param $prestudent_id @@ -1371,12 +1394,8 @@ class InfoCenter extends Auth_Controller 'dokumente_nachgereicht' => $dokumenteNachzureichenMail ); - $this->load->library('parser'); - $this->load->library('MailLib'); $this->load->library('LogLib'); - - //parse freigabe html email template, wordwrap wraps text so no display errors - $email = wordwrap($this->parser->parse('templates/mailtemplates/interessentFreigabe', $data, true), 70); + $this->load->helper('hlp_sancho'); $subject = ($person->geschlecht == 'm' ? 'Interessent ' : 'Interessentin ').$person->vorname.' '.$person->nachname.' für '.$prestudent->studiengangbezeichnung.$orgform.' freigegeben'; @@ -1385,10 +1404,12 @@ class InfoCenter extends Auth_Controller if (!isEmptyString($receiver)) { //Freigabeinformationmail sent from default system mail to studiengang mail(s) - $sent = $this->maillib->send('', $receiver, $subject, $email, '', null, null, 'Bitte sehen Sie sich die Nachricht in HTML Sicht an, um den Inhalt vollständig darzustellen.'); - - if (!$sent) - $this->loglib->logError('Error when sending Freigabe mail'); + sendSanchoMail( + self::FREIGABE_MAIL_VORLAGE, + $data, + $receiver, + $subject + ); } else { diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index ce03fe6dc..45ccce876 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -315,7 +315,8 @@ class MessageLib { // Parses template text $parsedText = $this->ci->vorlagelib->parseVorlagetext($result->retval[0]->text, $data); - $subject = $result->retval[0]->subject; + // Parses subject + $subject = $this->ci->vorlagelib->parseVorlagetext($result->retval[0]->subject, $data); // Save message $result = $this->_saveMessage($sender_id, $receiver_id, $subject, $parsedText, $relationmessage_id, $oe_kurzbz); diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index b7e54185e..89ab2623d 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -228,8 +228,10 @@ class Prestudent_model extends DB_Model $lastStatus->retval[0]->studiengangkurzbzlang = $studienordnung->retval[0]->studiengangkurzbzlang; $lastStatus->retval[0]->studiengangbezeichnung = $studienordnung->retval[0]->studiengangbezeichnung; $lastStatus->retval[0]->studiengangbezeichnung_englisch = $studienordnung->retval[0]->studiengangbezeichnung_englisch; + $lastStatus->retval[0]->regelstudiendauer = $studienordnung->retval[0]->regelstudiendauer; } + //get Sprache $this->load->model('system/sprache_model', 'SpracheModel'); $language = $this->SpracheModel->load($lastStatus->retval[0]->sprache); diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index 0492719a4..7a42532e1 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -173,6 +173,8 @@ class Person_model extends DB_Model if($kontakte->error) return error($kontakte->retval); $where = $zustellung_only === true ? array('person_id' => $person_id, 'zustelladresse' => true) : array('person_id' => $person_id); + $this->AdresseModel->addSelect('public.tbl_adresse.*, bis.tbl_nation.kurztext AS nationkurztext'); + $this->AdresseModel->addJoin('bis.tbl_nation', 'tbl_adresse.nation = tbl_nation.nation_code', 'LEFT'); $adressen = $this->AdresseModel->loadWhere($where); if($adressen->error) return error($adressen->retval); diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index 9a8a0a35e..2a64f2478 100755 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -21,6 +21,7 @@ 'customJSs' => array( 'public/js/bootstrapper.js', 'public/js/tablesort/tablesort.js', + 'public/js/messaging/messageList.js', 'public/js/infocenter/infocenterDetails.js' ), 'phrases' => array( @@ -139,7 +140,7 @@
-
+
load->view('system/messageList.php', $messages); ?> @@ -184,6 +185,7 @@
+ load->view('templates/FHC-Footer'); ?> diff --git a/application/views/system/infocenter/stammdaten.php b/application/views/system/infocenter/stammdaten.php index 6681e29d3..d8e71f44d 100755 --- a/application/views/system/infocenter/stammdaten.php +++ b/application/views/system/infocenter/stammdaten.php @@ -98,6 +98,7 @@ strasse.', '.$adresse->plz.' '.$adresse->ort : '' ?> + nationkurztext) ? '
'.$adresse->nationkurztext : '' ?> heimatadresse === true ? 'Heimatadresse' : ''). diff --git a/application/views/system/infocenter/zgvpruefungen.php b/application/views/system/infocenter/zgvpruefungen.php index 8640b70db..4c2958d62 100644 --- a/application/views/system/infocenter/zgvpruefungen.php +++ b/application/views/system/infocenter/zgvpruefungen.php @@ -9,7 +9,8 @@ $studiengangbezeichnung = empty($zgvpruefung->prestudentstatus->studiengangbezeichnung) ? $zgvpruefung->studiengangbezeichnung : $zgvpruefung->prestudentstatus->studiengangbezeichnung; //set bootstrap columns for zgv form - $columns = array(4, 3, 2, 3); + $columns = array(3, 3, 3, 3); + $headercolumns = array(7, 5); if (!$infoonly && isset($zgvpruefung->prestudentstatus->bewerbungsnachfrist) && isset($zgvpruefung->prestudentstatus->bewerbungstermin)) { @@ -54,7 +55,11 @@ prestudentstatus->bestaetigtam)): ?> - p->t('global', 'anStudiengangFreigegeben') ?> + prestudentstatus->statusgrund_id)) + echo $this->p->t('global', 'anStudiengangFreigegeben').(isset($zgvpruefung->prestudentstatus->bezeichnung_statusgrund[0]) ? ' ('.$zgvpruefung->prestudentstatus->bezeichnung_statusgrund[0].')' : ''); + else + echo $this->p->t('global', 'zumReihungstestFreigegeben'); + ?> p->t('infocenter', 'bewerbung')) . ' ' . $this->p->t('global', 'abgeschickt') . ': '.(isset($zgvpruefung->prestudentstatus->bewerbung_abgeschicktamum) ? '' : ''); ?> @@ -112,10 +117,22 @@
-
- - prestudentstatus->ausbildungssemester) ? $zgvpruefung->prestudentstatus->ausbildungssemester : '' ?> +
+ + prestudentstatus->ausbildungssemester)): ?> + + + prestudentstatus->ausbildungssemester?> + + + +
@@ -286,24 +303,22 @@ ?> @@ -407,7 +447,13 @@
prestudentstatus->bestaetigtam) ? '' : '' ?> - +
diff --git a/application/views/system/messageList.php b/application/views/system/messageList.php index 76c77612a..d666e32fe 100644 --- a/application/views/system/messageList.php +++ b/application/views/system/messageList.php @@ -35,67 +35,3 @@ $widthColumn = $msgExists === true ? 8 : 12;
- diff --git a/public/css/infocenter/infocenterDetails.css b/public/css/infocenter/infocenterDetails.css index 25e5d1820..3e64bbcd7 100644 --- a/public/css/infocenter/infocenterDetails.css +++ b/public/css/infocenter/infocenterDetails.css @@ -35,4 +35,34 @@ top: -4px; right: 2px; left: 2px; +} + +.ausbildungssemselect{ + width: 40px !important; + margin-top: -5px; + padding: 4px; +} + +.frgstatusgrselect{ + margin-top: 2px; +} + +#scrollToTop{ + display: none; + position: fixed; + bottom: 1%; + right: 0.3%; + z-index: 99; + border: none; + outline: none; + background-color: #dfdfdf; + color: black; + cursor: pointer; + padding: 10px; + border-radius: 10px; + font-size: 14px; +} + +#scrollToTop:hover{ + background-color: lightgrey; } \ No newline at end of file diff --git a/public/js/infocenter/infocenterDetails.js b/public/js/infocenter/infocenterDetails.js index 92ebbe1c3..1e38575ab 100644 --- a/public/js/infocenter/infocenterDetails.js +++ b/public/js/infocenter/infocenterDetails.js @@ -1,6 +1,9 @@ -const CONTROLLER_URL = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/"+FHC_JS_DATA_STORAGE_OBJECT.called_path; +const BASE_URL = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router; const CALLED_PATH = FHC_JS_DATA_STORAGE_OBJECT.called_path; +const CONTROLLER_URL = BASE_URL + "/"+CALLED_PATH; +const FREIGABE_MESSAGE_VORLAGE = "InfocenterRTfreigegeben"; +const FREIGABE_MESSAGE_VORLAGE_QUER = "InfocenterRTfreigegQuer"; /** * javascript file for infocenterDetails page @@ -10,9 +13,8 @@ $(document).ready(function () //initialise table sorter Tablesort.addTablesorter("doctable", [[2, 1], [1, 0]], ["zebra"]); Tablesort.addTablesorter("nachgdoctable", [[2, 0], [1, 1]], ["zebra"]); - Tablesort.addTablesorter("msgtable", [[0, 1], [2, 0]], ["zebra", "filter"], 2); - Tablesort.tablesortAddPager("msgtable", "msgpager", 14); + InfocenterDetails._formatMessageTable(); InfocenterDetails._formatNotizTable(); InfocenterDetails._formatLogTable(); @@ -36,6 +38,8 @@ $(document).ready(function () //add click events to zgv Prüfung section InfocenterDetails._addZgvPruefungEvents(personid); + MessageList.initMessageList(); + //save notiz $("#notizform").on("submit", function (e) { @@ -90,6 +94,25 @@ $(document).ready(function () //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 InfocenterDetails = { @@ -213,16 +236,15 @@ var InfocenterDetails = { if (FHC_AjaxClient.hasData(data)) { - InfocenterDetails._refreshLog(); $("#zgvSpeichern_" + prestudentid).before("" + FHC_PhrasesLib.t('ui', 'gespeichert') + "  "); + InfocenterDetails._refreshLog(); } else { zgvError(); } }, - errorCallback: zgvError, - veilTimeout: 0 + errorCallback: zgvError } ); }, @@ -247,19 +269,40 @@ var InfocenterDetails = { } ); }, - saveFreigabe: function(data) + saveFreigabe: function(data, rtfreigabe) { + var callback = null; + FHC_AjaxClient.ajaxCallPost( CALLED_PATH + '/saveFreigabe', data, { successCallback: function(data, textStatus, jqXHR) { - console.log(data.error); if (FHC_AjaxClient.hasData(data)) { - InfocenterDetails._refreshZgv(); - InfocenterDetails._refreshLog(); + if (rtfreigabe) + { + FHC_AjaxClient.showVeil(); + callback = function () + { + InfocenterDetails.sendFreigabeMessage(data.retval.prestudent_id); + }; + } + else + { + callback = function () + { + InfocenterDetails._refreshLog(); + }; + } + + + InfocenterDetails._refreshZgv( + false, + //send message only after refresh to have current Ausbildungssemester + callback + ); } else if (data.error === 2 && parseInt(data.retval.prestudent_id, 10)) { @@ -404,6 +447,30 @@ var InfocenterDetails = { } ); }, + sendFreigabeMessage: function(prestudentid) + { + var ausbildungssem = $("#ausbildungssem_"+prestudentid).val(); + var vorlage_kurzbz = isNaN(ausbildungssem) || parseInt(ausbildungssem) === 1 ? FREIGABE_MESSAGE_VORLAGE : FREIGABE_MESSAGE_VORLAGE_QUER; + + FHC_AjaxClient.ajaxCallPost( + 'system/Messages/sendJson', + { + "prestudents": prestudentid, + "vorlage_kurzbz": vorlage_kurzbz, + "oe_kurzbz": 'infocenter', + "msgvars": { + 'rtlink': FHC_JS_DATA_STORAGE_OBJECT.app_root + 'addons/bewerbung/cis/registration.php?active=aufnahme', + 'ausbildungssemester': ausbildungssem + } + }, + { + successCallback: function(data, textStatus, jqXHR) { + InfocenterDetails._refreshMessages(); + InfocenterDetails._refreshLog(); + } + } + ); + }, // ----------------------------------------------------------------------------------------------------------------- // (private) methods executed after ajax (refreshers) @@ -424,12 +491,20 @@ var InfocenterDetails = { $(".prioup").click(function () { var prestudentid = this.id.substr(this.id.indexOf("_") + 1); - InfocenterDetails._savePrio(prestudentid, -1); + var data = { + "prestudentid": prestudentid, + "change": -1 + }; + InfocenterDetails.saveBewPriorisierung(data); }); $(".priodown").click(function () { var prestudentid = this.id.substr(this.id.indexOf("_") + 1); - InfocenterDetails._savePrio(prestudentid, 1); + var data = { + "prestudentid": prestudentid, + "change": 1 + }; + InfocenterDetails.saveBewPriorisierung(data); }); //zgv übernehmen @@ -466,21 +541,45 @@ var InfocenterDetails = { } ); - //prevent opening modal when Statusgrund not chosen - $(".absageModal").on('show.bs.modal', function (e) + $(".freigabebtn").click(function() { - var id = this.id.substr(this.id.indexOf("_") + 1); - var statusgrvalue = $("#statusgrselect_" + id + " select[name=statusgrund]").val(); - if (statusgrvalue === "null") + var prestudentid = this.id.substr(this.id.indexOf("_") + 1); + InfocenterDetails._toggleFreigabeDialog(prestudentid, true);//true - Reihungstestfreigabe + } + ); + + $(".freigabebtnstg").click(function() + { + var prestudentid = this.id.substr(this.id.indexOf("_") + 1); + var statusgrel = $("#frgstatusgrselect_"+prestudentid+" select[name=frgstatusgrund]"); + var statusgrund_id = statusgrel.val(); + var statusgrund = statusgrel.find("option:selected").text(); + + if (statusgrund_id === 'null') { - $("#statusgrselect_" + id).addClass("has-error"); - return e.preventDefault(); + $("#frgstatusgrselect_" + prestudentid).addClass("has-error"); + } + else + { + var rtfreigabe = false;//no Reihungstestfreigabe + InfocenterDetails._toggleFreigabeDialog(prestudentid, rtfreigabe, statusgrund); } } ); + $(".absageBtn").click(function() + { + var prestudentid = this.id.substr(this.id.indexOf("_") + 1); + var statusgrund = $("#absgstatusgrselect_" + prestudentid + " select[name=absgstatusgrund]").val(); + if (statusgrund === "null") + $("#absgstatusgrselect_" + prestudentid).addClass("has-error"); + else + $("#absageModal_"+prestudentid).modal("show"); + } + ); + //remove red mark when statusgrund is selected again - $("select[name=statusgrund]").change( + $("select[name=absgstatusgrund],select[name=frgstatusgrund]").change( function () { $(this).parent().removeClass("has-error"); @@ -491,7 +590,7 @@ var InfocenterDetails = { { $(".absageModal").modal("hide"); var prestudent_id = this.id.substr(this.id.indexOf("_") + 1); - var statusgrund_id = $("#statusgrselect_" + prestudent_id + " select[name=statusgrund]").val(); + var statusgrund_id = $("#absgstatusgrselect_" + prestudent_id + " select[name=absgstatusgrund]").val(); var data = {"prestudent_id": prestudent_id , "statusgrund": statusgrund_id}; InfocenterDetails.saveAbsage(data); } @@ -502,12 +601,21 @@ var InfocenterDetails = { $(".freigabeModal").modal("hide"); var prestudent_id = this.id.substr(this.id.indexOf("_") + 1); var data = {"prestudent_id": prestudent_id}; + InfocenterDetails.saveFreigabe(data, true); + } + ); + + $(".saveStgFreigabe").click(function() + { + $(".freigabeModal").modal("hide"); + var prestudent_id = this.id.substr(this.id.indexOf("_") + 1); + var statusgrund_id = $("#frgstatusgrselect_" + prestudent_id + " select[name=frgstatusgrund]").val(); + var data = {"prestudent_id": prestudent_id, "statusgrund_id": statusgrund_id}; InfocenterDetails.saveFreigabe(data); } ) - }, - _refreshZgv: function(preserveCollapseState) + _refreshZgv: function(preserveCollapseState, callback) { var personid = $("#hiddenpersonid").val(); @@ -525,8 +633,6 @@ var InfocenterDetails = { ); } - //show veil until refresh finished? - //FHC_AjaxClient.showVeil(); $("#zgvpruefungen").load( CONTROLLER_URL + '/reloadZgvPruefungen/' + personid + '?fhc_controller_id=' + FHC_AjaxClient.getUrlParameter('fhc_controller_id'), function() @@ -542,7 +648,21 @@ var InfocenterDetails = { $("#"+i).addClass("in"); } } - //FHC_AjaxClient.hideVeil(); + + // variable callback executed after refresh + if (callback) + callback(); + } + ); + }, + _refreshMessages: function() + { + var personid = $("#hiddenpersonid").val(); + $("#messagelist").load( + CONTROLLER_URL + '/reloadMessages/' + personid + '?fhc_controller_id=' + FHC_AjaxClient.getUrlParameter('fhc_controller_id'), + function () { + MessageList.initMessageList(); + InfocenterDetails._formatMessageTable(); } ); }, @@ -557,12 +677,6 @@ var InfocenterDetails = { } ); }, - _formatLogTable: function() - { - Tablesort.addTablesorter("logtable", [[0, 1]], ["filter"], 2); - Tablesort.tablesortAddPager("logtable", "logpager", 22); - $("#logtable").addClass("table-condensed"); - }, _refreshNotizen: function() { $("#notizform").find("input[type=text], textarea").val(""); @@ -622,12 +736,45 @@ var InfocenterDetails = { ); } }, + _formatMessageTable: function() + { + Tablesort.addTablesorter("msgtable", [[0, 1], [2, 0]], ["zebra", "filter"], 2); + Tablesort.tablesortAddPager("msgtable", "msgpager", 14); + }, _formatNotizTable: function() { Tablesort.addTablesorter("notiztable", [[0, 1]], ["filter"], 2); Tablesort.tablesortAddPager("notiztable", "notizpager", 11); $("#notiztable").addClass("table-condensed"); }, + _formatLogTable: function() + { + Tablesort.addTablesorter("logtable", [[0, 1]], ["filter"], 2); + Tablesort.tablesortAddPager("logtable", "logpager", 22); + $("#logtable").addClass("table-condensed"); + }, + _toggleFreigabeDialog: function(prestudentid, rtfreigabe, statusgrund) + { + var statusgrundspan = $("#freigabeModalStgr_"+prestudentid); + var freigabebtn = $("#saveFreigabe_"+prestudentid); + var stgfreigabebtn = $("#saveStgFreigabe_"+prestudentid); + + if (rtfreigabe) + { + statusgrundspan.text(" - Reihungstest"); + freigabebtn.show(); + stgfreigabebtn.hide(); + } + else + { + if (statusgrund !== "undefined" && statusgrund !== null) + statusgrundspan.text(" - "+statusgrund); + freigabebtn.hide(); + stgfreigabebtn.show(); + } + + $("#freigabeModal_"+prestudentid).modal("show"); + }, _resetNotizFields: function() { $("#notizmsg").empty(); @@ -638,13 +785,5 @@ var InfocenterDetails = { _errorSaveNotiz: function() { $("#notizmsg").text(FHC_PhrasesLib.t('ui', 'fehlerBeimSpeichern')); - }, - _savePrio: function(prestudentid, change) - { - var data = { - "prestudentid": prestudentid, - "change": change - }; - InfocenterDetails.saveBewPriorisierung(data); } }; diff --git a/public/js/messaging/messageList.js b/public/js/messaging/messageList.js new file mode 100644 index 000000000..85d5ad603 --- /dev/null +++ b/public/js/messaging/messageList.js @@ -0,0 +1,72 @@ +/** + * javascript file for displaying MessageList + */ + +var MessageList = { + + initMessageList: function() + { + tinymce.remove(); + tinymce.init({ + menubar: false, + toolbar: false, + readonly: 1, + selector: "#msgbody", + statusbar: false, + plugins: "autoresize", + autoresize_bottom_margin: 10, + autoresize_min_height: 140, + autoresize_max_height: 495, + //callback to avoid conflict with ajax (for getting body of first message) + init_instance_callback: "MessageList._initMsgBody", + responsive: true + + }); + }, + _initMsgBody: function() + { + var tblrows = $("#msgtable tbody tr"); + + if (tblrows.length > 0) + { + //in the begging last sent message is shown + var firstelement = tblrows.first(); + var id = firstelement.attr('id'); + + MessageList._getMsgBody(id); + firstelement.find("td").addClass("tablesort-active"); + + //add click event on message table for message preview + tblrows.click( + function () + { + $("#msgtable").find("td").removeClass("tablesort-active"); + $(this).find("td").addClass("tablesort-active"); + MessageList._getMsgBody(this.id); + } + ); + } + }, + //retrieve message data from message and receiver id via AJAX + _getMsgBody: function(id) + { + var msgid = id.substr(0, id.indexOf('_')); + var recid = id.substr(id.indexOf('_') + 1); + + FHC_AjaxClient.ajaxCallGet( + 'system/Messages/getMessageFromIds', + { + "msg_id": msgid, + "receiver_id": recid + }, + { + successCallback: function(data, textStatus, jqXHR) { + $("#msgsubject").text(data[0].subject); + tinyMCE.get("msgbody").setContent(data[0].body); + }, + veilTimeout: 0 + } + ); + } + +}; diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 959768932..5bbef50b2 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -848,6 +848,26 @@ $phrases = array( ) ) ), + array( + 'app' => 'core', + 'category' => 'global', + 'phrase' => 'zumReihungstestFreigegeben', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'zum Reihungstest freigegeben', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'approved for placement test', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), array( 'app' => 'core', 'category' => 'global', @@ -1114,6 +1134,26 @@ $phrases = array( ) ) ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'freigabeart', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Freigabeart', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Approval type', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), array( 'app' => 'core', 'category' => 'ui', @@ -1128,7 +1168,27 @@ $phrases = array( ), array( 'sprache' => 'English', - 'text' => '', + 'text' => 'Approve for study program', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'freigabeZumReihungstest', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Freigabe zum Reihungstest', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Approve for placement test', 'description' => '', 'insertvon' => 'system' ) @@ -2727,7 +2787,7 @@ $phrases = array( ), array( 'sprache' => 'English', - 'text' => '', + 'text' => 'reject applicant', 'description' => '', 'insertvon' => 'system' )