2018-09-19 12:29:53 +00:00
|
|
|
/**
|
|
|
|
* @package Joomla.Members.Manager
|
|
|
|
*
|
2018-12-27 10:38:37 +00:00
|
|
|
* @created 6th July, 2018
|
2018-09-19 12:29:53 +00:00
|
|
|
* @author Llewellyn van der Merwe <https://www.joomlacomponentbuilder.com/>
|
|
|
|
* @github Joomla Members Manager <https://github.com/vdm-io/Joomla-Members-Manager>
|
|
|
|
* @copyright Copyright (C) 2015. All Rights Reserved
|
|
|
|
* @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* JS Document */
|
|
|
|
// Get report based on id & element from Server
|
|
|
|
function getReport_server(report_key){
|
2019-04-04 11:58:49 +00:00
|
|
|
var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.getReport&raw=true&format=json&vdm="+vastDevMod);
|
2018-09-19 12:29:53 +00:00
|
|
|
if(token.length > 0 && report_key.length > 0){
|
|
|
|
var request = 'token='+token+'&key='+report_key;
|
|
|
|
}
|
|
|
|
return jQuery.ajax({
|
|
|
|
type: 'GET',
|
|
|
|
url: getUrl,
|
2019-04-04 11:58:49 +00:00
|
|
|
dataType: 'json',
|
2018-09-19 12:29:53 +00:00
|
|
|
data: request,
|
2019-04-04 11:58:49 +00:00
|
|
|
jsonp: false
|
2018-09-19 12:29:53 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
// get report to display
|
|
|
|
function getReport(id, element, report_key){
|
|
|
|
// remove old data and add spinner
|
2018-09-26 14:54:10 +00:00
|
|
|
jQuery('.setreport').html('');
|
|
|
|
jQuery('.report-spinner').show();
|
2018-09-19 12:29:53 +00:00
|
|
|
// get key
|
|
|
|
var key = id+element;
|
|
|
|
// first we see if we have local storage of this data
|
|
|
|
var data = null; // jQuery.jStorage.get(key);
|
|
|
|
if (!data) {
|
|
|
|
getReport_server(report_key).done(function(result) {
|
|
|
|
if(result.html){
|
|
|
|
setReport(result.html);
|
|
|
|
// store the data for next time
|
|
|
|
jQuery.jStorage.set(key,result.html,{TTL: expire});
|
|
|
|
} else if(result.error){
|
|
|
|
// set an error if item date could not return
|
|
|
|
setReport(result.error);
|
|
|
|
} else {
|
|
|
|
// set an error if item date could not return
|
|
|
|
setReport(Joomla.JText._('COM_MEMBERSMANAGER_THERE_WAS_NO_REPORT_FOUND'));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
setReport(data, key);
|
|
|
|
// make sure to keep the Time To Live updated
|
|
|
|
jQuery.jStorage.setTTL(key,expire);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// set the Report
|
|
|
|
function setReport(data) {
|
|
|
|
// show data
|
2018-09-26 14:54:10 +00:00
|
|
|
jQuery('.setreport').html(data);
|
2018-09-19 12:29:53 +00:00
|
|
|
// hide spinner
|
2018-09-26 14:54:10 +00:00
|
|
|
jQuery('.report-spinner').hide();
|
2018-12-27 10:38:37 +00:00
|
|
|
}
|
|
|
|
// load chart in modal
|
|
|
|
function loadTheChartInModal(callback, targetDivID){
|
|
|
|
// remove old data and add spinner
|
|
|
|
jQuery('.setreport').html('');
|
|
|
|
jQuery('.report-spinner').show();
|
|
|
|
// add new div
|
|
|
|
jQuery('.setreport').html('<a href="javascript:void(0)" onclick="printMe(\'Report\', \'' + targetDivID + '_print\')" >Print</a><br /><div class="chartDiv" id="' + targetDivID + '_print"><div id="' + targetDivID + '" class="chart"></div></div>');
|
|
|
|
// allow modal to open
|
|
|
|
setTimeout(function() {
|
|
|
|
// hide spinner
|
|
|
|
jQuery('.report-spinner').hide();
|
|
|
|
// run call back
|
|
|
|
callback();
|
|
|
|
}, 800);
|
2019-04-04 11:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get messages based on id & element from Server
|
|
|
|
function getListMessages_server(messages_key){
|
|
|
|
var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.getListMessages&raw=true&format=json&vdm="+vastDevMod);
|
|
|
|
if(token.length > 0 && messages_key.length > 0){
|
|
|
|
var request = 'token='+token+'&key='+messages_key;
|
|
|
|
}
|
|
|
|
return jQuery.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: getUrl,
|
|
|
|
dataType: 'json',
|
|
|
|
data: request,
|
|
|
|
jsonp: false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// get messages to display
|
|
|
|
function getListMessages(messages_key){
|
|
|
|
// remove old data and add spinner
|
|
|
|
jQuery('.setlistmessages').html('');
|
|
|
|
jQuery('.listmessages-spinner').show();
|
|
|
|
// first we see if we have local storage of this data
|
|
|
|
getListMessages_server(messages_key).done(function(result) {
|
|
|
|
if(result.html){
|
|
|
|
setListMessages(result.html);
|
|
|
|
} else if(result.error){
|
|
|
|
// set an error if item date could not return
|
|
|
|
setListMessages(result.error);
|
|
|
|
} else {
|
|
|
|
// set an error if item date could not return
|
|
|
|
setListMessages('<li>'+Joomla.JText._('COM_MEMBERSMANAGER_THERE_WAS_NO_MESSAGES_FOUND')+'</li>');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// set the Messages
|
|
|
|
function setListMessages(data) {
|
|
|
|
// show data
|
|
|
|
jQuery('.setlistmessages').html(data);
|
|
|
|
// hide spinner
|
|
|
|
jQuery('.listmessages-spinner').hide();
|
|
|
|
}
|