mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-23 09:52:22 +00:00
- Renamed public/js/messaging/messageClient.js to public/js/messaging/read.js
- Added new JS public/js/messaging/write.js used in view application/views/system/messages/ajaxWrite.php - Added new public method write, listReceivedMessages, listSentMessages and sendMessageToOU to controller system/messages/MessageClient.php - Removed private method _getReceiversByOekurzbz from MessageLib - Fixed method sendMessageOU of MessageLib - Added new public method prepareAjaxWrite to model CL/Messages_model - Fixed method prepareAjaxReadReceived of model CL/Messages_model - Added new public method prepareAjaxReadSent to model CL/Messages_model - Changed method CL/Messages_model->_personLog interface - Added new public method getOrganisationunitsByPersonId to crm/Prestudent_model - Added new public method getReceivedMessages to model system/Recipient_model - Changed getReceivedMessages method of model system/Recipient_model - Changed view system/messages/ajaxRead.php - Added new view system/messages/ajaxWrite.php
This commit is contained in:
@@ -8,8 +8,11 @@ class MessageClient extends Auth_Controller
|
||||
{
|
||||
parent::__construct(
|
||||
array(
|
||||
'read' => array('basis/message:r'),
|
||||
'listMessages' => array('basis/message:r')
|
||||
'read' => array('basis/person:r'),
|
||||
'write' => array('basis/person:r'),
|
||||
'listReceivedMessages' => array('basis/person:r'),
|
||||
'listSentMessages' => array('basis/person:r'),
|
||||
'sendMessageToOU' => array('basis/person:r')
|
||||
)
|
||||
);
|
||||
|
||||
@@ -27,13 +30,39 @@ class MessageClient extends Auth_Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns JSON that that contains all the received messages by the currently logged user
|
||||
* This JSON structure is nested data used by tabulator
|
||||
* Starts the GUI used to write a personal message to an organisation unit
|
||||
*/
|
||||
public function listMessages()
|
||||
public function write()
|
||||
{
|
||||
$jsonNestedData = $this->CLMessagesModel->prepareAjaxRead();
|
||||
// Loads the view to write a message
|
||||
$this->load->view('system/messages/ajaxWrite', $this->CLMessagesModel->prepareAjaxWrite());
|
||||
}
|
||||
|
||||
$this->outputJson($jsonNestedData);
|
||||
/**
|
||||
* Returns JSON that that contains all the received messages by the currently logged user
|
||||
*/
|
||||
public function listReceivedMessages()
|
||||
{
|
||||
$this->outputJson($this->CLMessagesModel->prepareAjaxReadReceived());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns JSON that that contains all the sent messages by the currently logged user
|
||||
*/
|
||||
public function listSentMessages()
|
||||
{
|
||||
$this->outputJson($this->CLMessagesModel->prepareAjaxReadSent());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function sendMessageToOU()
|
||||
{
|
||||
$receiverOU = $this->input->post('receiverOU');
|
||||
$subject = $this->input->post('subject');
|
||||
$body = $this->input->post('body');
|
||||
|
||||
$this->outputJson($this->CLMessagesModel->sendToOrganisationUnit($receiverOU, $subject, $body));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,9 @@ class MessageLib
|
||||
// If the recipient is an organisation unit that would be possible to send the same message (same message id)
|
||||
// to the entire organisation unit (one to many functionality)
|
||||
// In this case the receiver id is a the one present in message configuration
|
||||
$receivers = success(array($this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID)));
|
||||
$receiver = new stdClass();
|
||||
$receiver->person_id = $this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID);
|
||||
$receivers = success(array($receiver));
|
||||
|
||||
// Send the message and return the result
|
||||
return $this->_sendMessage($receivers, $receiversOU, $subject, $body, $sender_id, $senderOU, $relationmessage_id, $priority, $multiPartMime);
|
||||
@@ -373,24 +375,6 @@ class MessageLib
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the receivers id that are enabled to read messages for that oe_kurzbz
|
||||
*/
|
||||
private function _getReceiversByOekurzbz($oe_kurzbz)
|
||||
{
|
||||
// Load Benutzerfunktion_model
|
||||
$this->_ci->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
|
||||
// Join with table public.tbl_benutzer on field uid
|
||||
$this->_ci->BenutzerfunktionModel->addJoin('public.tbl_benutzer', 'uid');
|
||||
// Get all the valid receivers id using the oe_kurzbz
|
||||
$receivers = $this->_ci->BenutzerfunktionModel->loadWhere(
|
||||
'oe_kurzbz = '.$this->_ci->db->escape($oe_kurzbz).
|
||||
' AND funktion_kurzbz = '.$this->_ci->db->escape($this->_ci->config->item(self::CFG_OU_RECEIVERS)).
|
||||
' AND (NOW() BETWEEN COALESCE(datum_von, NOW()) AND COALESCE(datum_bis, NOW()))'
|
||||
);
|
||||
return $receivers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a new message in DB
|
||||
*/
|
||||
|
||||
@@ -28,9 +28,10 @@ class Messages_model extends CI_Model
|
||||
|
||||
// Loads model MessageToken_model
|
||||
$this->load->model('system/MessageToken_model', 'MessageTokenModel');
|
||||
|
||||
// Loads model Benutzerrolle_model
|
||||
$this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel');
|
||||
// Loads model Prestudent_model
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
@@ -39,20 +40,42 @@ class Messages_model extends CI_Model
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function prepareAjaxRead()
|
||||
public function prepareAjaxWrite()
|
||||
{
|
||||
$jsonNestedData = error('Something did not go as it should');
|
||||
$ouResult = $this->PrestudentModel->getOrganisationunitsByPersonId(getAuthPersonId());
|
||||
|
||||
if (isError($ouResult)) show_error('An error occurred while loading this page, please contact the site administrator');
|
||||
|
||||
$ouOptions = '<option value="0">Select...</option>';
|
||||
|
||||
if (hasData($ouResult))
|
||||
{
|
||||
foreach (getData($ouResult) as $ou)
|
||||
{
|
||||
$ouOptions .= sprintf("\n".'<option value="%s">%s</option>', $ou->oe_kurzbz, $ou->bezeichnung);
|
||||
}
|
||||
}
|
||||
|
||||
return array('organisationUnitOptions' => $ouOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function prepareAjaxReadReceived()
|
||||
{
|
||||
$jsonResult = error('Something did not go as it should');
|
||||
|
||||
$loggedUserName = getAuthFirstname().' '.getAuthSurname();
|
||||
|
||||
if (isEmptyString($loggedUserName)) $loggedUserName = 'Me';
|
||||
|
||||
$receivedMessagesResult = $this->RecipientModel->getReceivedMessages(getAuthPersonId());
|
||||
$receivedMessagesResult = $this->RecipientModel->getReceivedMessages(
|
||||
getAuthPersonId(),
|
||||
$this->config->item(MessageLib::CFG_OU_RECEIVERS)
|
||||
);
|
||||
if (isError($receivedMessagesResult)) return $receivedMessagesResult;
|
||||
|
||||
$sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId());
|
||||
if (isError($sentMessagesResult)) return $sentMessagesResult;
|
||||
|
||||
if (hasData($receivedMessagesResult))
|
||||
{
|
||||
$jsonArray = array();
|
||||
@@ -60,41 +83,59 @@ class Messages_model extends CI_Model
|
||||
foreach (getData($receivedMessagesResult) as $receivedMessage)
|
||||
{
|
||||
$jsonRecord = new stdClass();
|
||||
$jsonRecord->message_id = $receivedMessage->message_id;
|
||||
$jsonRecord->subject = $receivedMessage->subject;
|
||||
$jsonRecord->body = $receivedMessage->body;
|
||||
$jsonRecord->from = $receivedMessage->vorname.' '.$receivedMessage->nachname;
|
||||
$sentDate = new DateTime($receivedMessage->sent);
|
||||
$jsonRecord->sent = $sentDate->format('d/m/Y H:i:s');
|
||||
$jsonRecord->status = $receivedMessage->status;
|
||||
|
||||
if (hasData($sentMessagesResult))
|
||||
{
|
||||
$jsonChildrenArray = array();
|
||||
$jsonArray[] = $jsonRecord;
|
||||
}
|
||||
|
||||
foreach (getData($sentMessagesResult) as $sentMessage)
|
||||
{
|
||||
if ($receivedMessage->relationmessage_id == $sentMessage->message_id)
|
||||
{
|
||||
$jsonChildrenRecord = new stdClass();
|
||||
$jsonChildrenRecord->subject = $sentMessage->subject;
|
||||
$jsonChildrenRecord->from = $loggedUserName;
|
||||
$sentDate = new DateTime($sentMessage->sent);
|
||||
$jsonChildrenRecord->sent = $sentDate->format('d/m/Y H:i:s');
|
||||
$jsonChildrenRecord->status = $sentMessage->status;
|
||||
$jsonResult = success(json_encode($jsonArray));
|
||||
}
|
||||
|
||||
$jsonChildrenArray[] = $jsonChildrenRecord;
|
||||
}
|
||||
}
|
||||
return $jsonResult;
|
||||
}
|
||||
|
||||
if (!isEmptyArray($jsonChildrenArray)) $jsonRecord->_children = $jsonChildrenArray;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function prepareAjaxReadSent()
|
||||
{
|
||||
$jsonResult = error('Something did not go as it should');
|
||||
|
||||
$loggedUserName = getAuthFirstname().' '.getAuthSurname();
|
||||
|
||||
if (isEmptyString($loggedUserName)) $loggedUserName = 'Me';
|
||||
|
||||
$sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId());
|
||||
if (isError($sentMessagesResult)) return $sentMessagesResult;
|
||||
|
||||
if (hasData($sentMessagesResult))
|
||||
{
|
||||
$jsonArray = array();
|
||||
|
||||
foreach (getData($sentMessagesResult) as $sentMessage)
|
||||
{
|
||||
$jsonRecord = new stdClass();
|
||||
$jsonRecord->message_id = $sentMessage->message_id;
|
||||
$jsonRecord->subject = $sentMessage->subject;
|
||||
$jsonRecord->body = $sentMessage->body;
|
||||
$jsonRecord->from = $sentMessage->vorname.' '.$sentMessage->nachname;
|
||||
$sentDate = new DateTime($sentMessage->sent);
|
||||
$jsonRecord->sent = $sentDate->format('d/m/Y H:i:s');
|
||||
$jsonRecord->status = $sentMessage->status;
|
||||
|
||||
$jsonArray[] = $jsonRecord;
|
||||
}
|
||||
|
||||
$jsonNestedData = success(json_encode($jsonArray));
|
||||
$jsonResult = success(json_encode($jsonArray));
|
||||
}
|
||||
|
||||
return $jsonNestedData;
|
||||
return $jsonResult;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,7 +301,6 @@ class Messages_model extends CI_Model
|
||||
if (isError($msgVarsData)) show_error(getData($msgVarsData));
|
||||
if (!hasData($msgVarsData)) show_error('No recipients were given');
|
||||
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents);
|
||||
|
||||
// Adds the organisation unit to each prestudent
|
||||
@@ -337,6 +377,34 @@ class Messages_model extends CI_Model
|
||||
return success('Messages sent successfully');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to an organisation unit
|
||||
*/
|
||||
public function sendToOrganisationUnit($receiverOU, $subject, $body)
|
||||
{
|
||||
if (isEmptyString($receiverOU)) return error('Not a valid organisation unit');
|
||||
if (isEmptyString($subject)) return error('Subject is an empty string');
|
||||
if (isEmptyString($body)) return error('Body is an empty string');
|
||||
|
||||
$sender_id = getAuthPersonId();
|
||||
|
||||
$message = $this->messagelib->sendMessageOU(
|
||||
$receiverOU, // receiverPersonId
|
||||
$subject, // subject
|
||||
$body, // body
|
||||
$sender_id // sender_id
|
||||
);
|
||||
|
||||
if (isError($message)) return $message;
|
||||
if (!hasData($message)) return error('No messages were saved in database');
|
||||
|
||||
// Write log entry
|
||||
$personLog = $this->_personLog($sender_id, $this->config->item(MessageLib::CFG_SYSTEM_PERSON_ID), getData($message)[0], $receiverOU);
|
||||
if (isError($personLog)) return $personLog;
|
||||
|
||||
return success('Messages sent successfully');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods called by controller system/messages/Messages
|
||||
|
||||
@@ -447,18 +515,21 @@ class Messages_model extends CI_Model
|
||||
/**
|
||||
* Perform a person log after a message is sent
|
||||
*/
|
||||
private function _personLog($sender_id, $receiver_id, $message_id)
|
||||
private function _personLog($sender_id, $receiver_id, $message_id, $receiverOU = null)
|
||||
{
|
||||
// In case the message is accessed via ViewMessage controller -> no authentication
|
||||
// If no authentication is performed then use a hard coded uid
|
||||
$loggedUserUID = isLogged() ? getAuthUID() : self::NO_AUTH_UID;
|
||||
|
||||
$message = 'Message sent from person '.$sender_id.' to '.$receiver_id.', message id: '.$message_id;
|
||||
if (!isEmptyString($receiverOU)) $message .= ', receiverOU: '.$receiverOU;
|
||||
|
||||
return $this->personloglib->log(
|
||||
$receiver_id,
|
||||
'Action',
|
||||
array(
|
||||
'name' => 'Message sent',
|
||||
'message' => 'Message sent from person '.$sender_id.' to '.$receiver_id.', message id: '.$message_id,
|
||||
'message' => $message,
|
||||
'success' => 'true'
|
||||
),
|
||||
'kommunikation',
|
||||
|
||||
@@ -523,4 +523,20 @@ class Prestudent_model extends DB_Model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get organisation units for all the prestudents of a person
|
||||
*/
|
||||
public function getOrganisationunitsByPersonId($person_id)
|
||||
{
|
||||
$query = 'SELECT o.oe_kurzbz, o.bezeichnung
|
||||
FROM public.tbl_prestudent p
|
||||
JOIN public.tbl_studiengang s USING(studiengang_kz)
|
||||
JOIN public.tbl_organisationseinheit o USING(oe_kurzbz)
|
||||
WHERE p.person_id = ?
|
||||
GROUP BY o.oe_kurzbz, o.bezeichnung
|
||||
ORDER BY o.bezeichnung';
|
||||
|
||||
return $this->execQuery($query, array($person_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,13 +303,13 @@ class Recipient_model extends DB_Model
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getReceivedMessages($person_id)
|
||||
public function getReceivedMessages($person_id, $functions)
|
||||
{
|
||||
$sql = 'SELECT mr.message_id,
|
||||
mm.relationmessage_id,
|
||||
mm.subject,
|
||||
mm.body,
|
||||
mr.sent,
|
||||
mr.sent AS sent,
|
||||
p.vorname,
|
||||
p.nachname,
|
||||
MAX(ms.status) AS status
|
||||
@@ -327,9 +327,34 @@ class Recipient_model extends DB_Model
|
||||
mr.sent,
|
||||
p.vorname,
|
||||
p.nachname
|
||||
ORDER BY mr.sent DESC';
|
||||
UNION
|
||||
SELECT mrou.message_id,
|
||||
mm.relationmessage_id,
|
||||
mm.subject,
|
||||
mm.body,
|
||||
mrou.sent AS sent,
|
||||
p.vorname,
|
||||
p.nachname,
|
||||
MAX(ms.status) AS status
|
||||
FROM public.tbl_person p
|
||||
JOIN public.tbl_benutzer b ON (b.person_id = p.person_id)
|
||||
JOIN (SELECT uid, oe_kurzbz FROM public.tbl_benutzerfunktion WHERE funktion_kurzbz IN ?) bf ON (bf.uid = b.uid)
|
||||
JOIN public.tbl_msg_recipient mrou ON (mrou.oe_kurzbz = bf.oe_kurzbz)
|
||||
JOIN public.tbl_msg_message mm ON (mm.message_id = mrou.message_id)
|
||||
JOIN public.tbl_msg_status ms ON (ms.message_id = mrou.message_id AND ms.person_id = mrou.person_id)
|
||||
WHERE p.person_id = ?
|
||||
AND mrou.sent IS NOT NULL
|
||||
AND mrou.sentinfo IS NULL
|
||||
GROUP BY mrou.message_id,
|
||||
mm.relationmessage_id,
|
||||
mm.subject,
|
||||
mm.body,
|
||||
mrou.sent,
|
||||
p.vorname,
|
||||
p.nachname
|
||||
ORDER BY sent DESC';
|
||||
|
||||
return $this->execQuery($sql, array($person_id));
|
||||
return $this->execQuery($sql, array($person_id, $functions, $person_id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -342,10 +367,13 @@ class Recipient_model extends DB_Model
|
||||
mm.subject,
|
||||
mm.body,
|
||||
mr.sent,
|
||||
p.vorname,
|
||||
p.nachname,
|
||||
MAX(ms.status) AS status
|
||||
FROM public.tbl_msg_message mm
|
||||
JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id)
|
||||
JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id)
|
||||
JOIN public.tbl_person p ON (p.person_id = mr.person_id)
|
||||
WHERE mm.person_id = ?
|
||||
AND mr.sent IS NOT NULL
|
||||
AND mr.sentinfo IS NULL
|
||||
@@ -353,7 +381,9 @@ class Recipient_model extends DB_Model
|
||||
mm.relationmessage_id,
|
||||
mm.subject,
|
||||
mm.body,
|
||||
mr.sent
|
||||
mr.sent,
|
||||
p.vorname,
|
||||
p.nachname
|
||||
ORDER BY mr.sent DESC';
|
||||
|
||||
return $this->execQuery($sql, array($person_id));
|
||||
|
||||
@@ -6,15 +6,28 @@
|
||||
'jquery' => true,
|
||||
'jqueryui' => true,
|
||||
'bootstrap' => true,
|
||||
'fontawesome' => true,
|
||||
'sbadmintemplate' => true,
|
||||
'momentjs' => true,
|
||||
'tabulator' => true,
|
||||
'ajaxlib' => true,
|
||||
'dialoglib' => true,
|
||||
'customJSs' => array('public/js/messaging/messageClient.js')
|
||||
'tinymce' => true,
|
||||
'customJSs' => array('public/js/messaging/read.js')
|
||||
)
|
||||
);
|
||||
?>
|
||||
<body>
|
||||
<div class="toggleMessages">
|
||||
<div class="btn-group btn-group-toggle" data-toggle="buttons">
|
||||
<label class="btn btn-secondary active" id="r">
|
||||
<input type="radio" autocomplete="off" checked> Received
|
||||
</label>
|
||||
<label class="btn btn-secondary" id="s">
|
||||
<input type="radio" autocomplete="off"> Sent
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div id="lstMessagesPanel"></div>
|
||||
<div id="readMessagePanel"></div>
|
||||
</body>
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
$this->load->view(
|
||||
'templates/FHC-Header',
|
||||
array(
|
||||
'title' => 'Write a new message',
|
||||
'jquery' => true,
|
||||
'jqueryui' => true,
|
||||
'bootstrap' => true,
|
||||
'fontawesome' => true,
|
||||
'sbadmintemplate' => true,
|
||||
'ajaxlib' => true,
|
||||
'dialoglib' => true,
|
||||
'tinymce' => true,
|
||||
'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'),
|
||||
'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/write.js')
|
||||
)
|
||||
);
|
||||
?>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<div id="page-wrapper">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h3 class="page-header">Send message</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<div class="col-lg-1 msgfieldcol-left">
|
||||
<label>Receiver:</label>
|
||||
</div>
|
||||
<div class="col-lg-11 msgfieldcol-right">
|
||||
<select id="organisationUnit">
|
||||
|
||||
<?php echo $organisationUnitOptions; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<div class="col-lg-1 msgfield msgfieldcol-left">
|
||||
<label>Subject:</label>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-7">
|
||||
<input id="subject" class="form-control" type="text" value="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<label>Message:</label>
|
||||
<textarea id="body"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 text-right">
|
||||
<button id="sendButton" class="btn btn-default" type="button">Send</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<?php $this->load->view("templates/FHC-Footer"); ?>
|
||||
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
|
||||
FHC_AjaxClient.ajaxCallGet(
|
||||
FHC_JS_DATA_STORAGE_OBJECT.called_path + '/listMessages',
|
||||
null,
|
||||
{
|
||||
successCallback: function(data, textStatus, jqXHR) {
|
||||
|
||||
if (FHC_AjaxClient.hasData(data))
|
||||
{
|
||||
try
|
||||
{
|
||||
var jsonMessageLst = JSON.parse(FHC_AjaxClient.getData(data));
|
||||
|
||||
console.log(jsonMessageLst);
|
||||
|
||||
var tableMessageLst = new Tabulator("#lstMessagesPanel", {
|
||||
height: "400px",
|
||||
data: jsonMessageLst,
|
||||
dataTree: true,
|
||||
dataTreeStartExpanded: true,
|
||||
dataTreeElementColumn: "subject",
|
||||
columns: [
|
||||
{title: "Subject", field: "subject", width: 700, responsive: 0},
|
||||
{title: "From", field: "from", width: 400},
|
||||
{title: "Date", field: "sent", sorter: "datetime", width: 150}
|
||||
],
|
||||
rowClick: function(e, row) {
|
||||
// TODO
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (syntaxError)
|
||||
{
|
||||
FHC_DialogLib.alertError("An error occurred while retrieving message, contact the website administrator");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FHC_DialogLib.alertWarning("No message currently available");
|
||||
}
|
||||
},
|
||||
errorCallback: function() {
|
||||
|
||||
},
|
||||
veilTimeout: 300
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* JS used by view system/messages/htmlWriteTemplate
|
||||
*/
|
||||
// ********************************************************
|
||||
// JS used by view system/messages/htmlWriteTemplate
|
||||
// ********************************************************
|
||||
|
||||
function tinymcePreviewSetContent()
|
||||
{
|
||||
@@ -52,12 +52,12 @@ $(document).ready(function ()
|
||||
});
|
||||
|
||||
tinymce.init({
|
||||
selector: "#tinymcePreview",
|
||||
plugins: "autoresize",
|
||||
menubar: false,
|
||||
toolbar: false,
|
||||
statusbar: false,
|
||||
readonly: 1,
|
||||
selector: "#tinymcePreview",
|
||||
plugins: "autoresize",
|
||||
autoresize_min_height: 150,
|
||||
autoresize_bottom_margin: 10
|
||||
});
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
// ***********************************************************************
|
||||
// List all personal messages, used by view system/messages/ajaxRead
|
||||
// ***********************************************************************
|
||||
|
||||
//
|
||||
var tableMessageLst;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function genericError()
|
||||
{
|
||||
FHC_DialogLib.alertError("An error occurred while retrieving message, contact the website administrator");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function getReceivedMessages()
|
||||
{
|
||||
_getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + '/listReceivedMessages');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function getSentMessages()
|
||||
{
|
||||
_getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + '/listSentMessages');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function _getMessages(getMessagesURL)
|
||||
{
|
||||
FHC_AjaxClient.ajaxCallGet(
|
||||
getMessagesURL,
|
||||
null,
|
||||
{
|
||||
successCallback: function(data, textStatus, jqXHR) {
|
||||
|
||||
if (FHC_AjaxClient.hasData(data))
|
||||
{
|
||||
try
|
||||
{
|
||||
tableMessageLst.replaceData(JSON.parse(FHC_AjaxClient.getData(data)));
|
||||
}
|
||||
catch (syntaxError)
|
||||
{
|
||||
genericError();
|
||||
}
|
||||
}
|
||||
},
|
||||
errorCallback: genericError,
|
||||
veilTimeout: 300
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function changeTinyMCE(e, row)
|
||||
{
|
||||
tinyMCE.get("readMessagePanel").setContent(row._row.data.body);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function toggleMessages()
|
||||
{
|
||||
//
|
||||
if ($(this)[0].className.search('active') == -1)
|
||||
{
|
||||
$(this)[0].id == 'r' ? getReceivedMessages() : getSentMessages();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
|
||||
//
|
||||
tinymce.init({
|
||||
selector: "#readMessagePanel",
|
||||
plugins: "autoresize",
|
||||
menubar: false,
|
||||
toolbar: false,
|
||||
statusbar: false,
|
||||
readonly: 1,
|
||||
autoresize_min_height: 200,
|
||||
autoresize_bottom_margin: 0
|
||||
});
|
||||
|
||||
//
|
||||
tableMessageLst = new Tabulator("#lstMessagesPanel", {
|
||||
height: "400px",
|
||||
pagination: "local",
|
||||
columns: [
|
||||
{title: "Subject", field: "subject", width: 700, responsive: 0},
|
||||
{title: "From", field: "from", width: 400},
|
||||
{title: "Date", field: "sent", sorter: "datetime", width: 150}
|
||||
],
|
||||
rowClick: changeTinyMCE
|
||||
});
|
||||
|
||||
//
|
||||
$('.toggleMessages .btn').click(toggleMessages);
|
||||
|
||||
//
|
||||
getReceivedMessages();
|
||||
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
// ****************************************************************************************
|
||||
// Write a message to an organisation unit, used by view system/messages/ajaxWrite
|
||||
// ****************************************************************************************
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function sendMessageToOU()
|
||||
{
|
||||
if ($('#organisationUnit').val() == 0)
|
||||
{
|
||||
FHC_DialogLib.alertWarning("Not valid organisation unit");
|
||||
}
|
||||
else
|
||||
{
|
||||
FHC_AjaxClient.ajaxCallPost(
|
||||
FHC_JS_DATA_STORAGE_OBJECT.called_path + '/sendMessageToOU',
|
||||
{
|
||||
receiverOU: $('#organisationUnit').val(),
|
||||
subject: $('#subject').val(),
|
||||
body: tinyMCE.get("body").getContent()
|
||||
},
|
||||
{
|
||||
successCallback: function(data, textStatus, jqXHR) {
|
||||
FHC_DialogLib.alertSuccess("Message sent succesfully");
|
||||
},
|
||||
errorCallback: function() {
|
||||
FHC_DialogLib.alertError("Error");
|
||||
},
|
||||
veilTimeout: 300
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
|
||||
//
|
||||
tinymce.init({
|
||||
selector: "#body",
|
||||
plugins: "autoresize",
|
||||
autoresize_min_height: 150,
|
||||
autoresize_max_height: 600,
|
||||
autoresize_bottom_margin: 10
|
||||
});
|
||||
|
||||
$('#sendButton').click(sendMessageToOU);
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user