0
0
mirror of https://github.com/salesagility/SuiteCRM.git synced 2024-11-22 07:52:36 +00:00
salesagility_SuiteCRM/modules/Project/js/main_lib_chart.js
Ashley Nicolson 29a3b668a3 Merge branch feature/projectsmodule. Resolve many Project Module issues and Gantt Chart issues.
Commits included are:
commit 3ea2c1f49d26ef6918a69f4c2069824e0ff487f1
commit 4949b32cf655bbc597bcc19820c81ebbd7559b57
commit 92545172da
commit a48e6f4572
commit ab6e8322d37b4b8a5c3bb78312445358c97406b2
commit 5911d92e9483309220d7f1b5350edd51fcd6bad5
commit 14bcaa3d77
commit 3a414f6186
commit 2db4441ab4
commit ec2fc67231
commit f502666b64
commit 9d45b94425
commit 7d926ac4ac
commit 7d1b17828a
commit fe004be24e
commit c02617039f
commit c8a8fe7cff
commit 5a5a11e467
commit 4502f66472
commit f4681c81f9
commit 9c571f0276
commit 929bc56df3
commit ee37e5734e5f3c35b5f432aed83c24205fd40de7
commit bf7012889149154579d0b0b879423919e329583f
commit 4fe4ae32fc5d67e05f6af326ccab533e32a0d35a
commit 818b342a9f
commit e58b6cf690
commit b180713c0a
commit 723f5cc09c1b5087e3b83b22ca8f35fc94a82f90
commit 890a6daf50a4c80d3a0080617c1f2cf8c834a5b0
commit 5ce07bfff6c6af032af3cc678e5c4c0bd607010f
commit 9f18f07f8e
commit 39bfaf92ea
commit 7abe50ec4f
commit d8b1498a35
commit 8b0b56fa63
commit 58e82c9ec4
commit 6f8b135376
commit fe201f8aa4
commit 542e9f4ea5
commit f09e2a1805
commit 872e2b73f8
commit f8979a1610
commit e8a34d9ad5
commit 632080e861
commit f42acc9efa
commit be4d11f94e
commit 61f65a7f70
commit 903af549ce
Author: Haris Raheem <haris_raheem@hotmail.com>
2017-05-16 15:36:18 +01:00

247 lines
7.5 KiB
JavaScript

/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
* @Package Gantt chart
* @copyright Andrew Mclaughlan 2014
* @author Andrew Mclaughlan <andrew@mclaughlan.info>
*/
// unblock when ajax activity stops
$(document).ajaxStop($.unblockUI);
//Get the default sugar page loading message
var loading = SUGAR.language.languages.app_strings['LBL_LOADING_PAGE'];
$(function() {
//generate the chart on page load
gen_chart('0');
//message for ajax loading screen
var msg = '<div><br />' +
'<h1><img align="absmiddle" src="themes/default/images/img_loading.gif"> ' + loading + '</h1>' + '</div>';
//on button click re-generate the chart
$(document.body).on('click','#create_link', function(e) {
$(".qtip").remove(); //Clear all tooltips before re-generating the chart
$.blockUI({//ajax loading screen
message:msg,
css: {
height: '50px',
width: '240px',
// top: ($(window).height() - 50) /2 + 'px',
left: ($(window).width() - 240) /2 + 'px'//centre box
}
});
setTimeout(gen_chart(0,true),800); //call the ajax generate chart function with delay
});
//Gets the previous month
$(document.body).on('click','#prev_month', function(e) {
e.preventDefault();
$(".qtip").remove(); //Clear all tooltips before re-generating the chart
$.blockUI({//ajax loading screen
message:msg,
css: {
height: '50px',
width: '240px',
// top: ($(window).height() - 50) /2 + 'px',
left: ($(window).width() - 240) /2 + 'px'//centre box
}
});
setTimeout(gen_chart('-1'),800); //call the ajax generate chart function with delay
});
//Gets the next month
$(document.body).on('click','#next_month', function(e) {
e.preventDefault();
$(".qtip").remove(); //Clear all tooltips before re-generating the chart
$.blockUI({//ajax loading screen
message:msg,
css: {
height: '50px',
width: '240px',
// top: ($(window).height() - 50) /2 + 'px',
left: ($(window).width() - 240) /2 + 'px'//centre box
}
});
setTimeout(gen_chart('+1'),800); //call the ajax generate chart function with delay
});
});
/*
* This function generates the html chart grid by calling the update_chart function in the controller using ajax.
* The jquery block UI plugin is used for the loading screen
* */
function gen_chart(month, flag){
//Get the chart properties
var start = $('#date_start').val();
var end = $('#date_end').val();
var projects = $('#projects').val();
var users = $('#users').val();
var contacts = $('#contacts').val();
var chart_type = $('#chart_type').val();
//var type = 'all';
if(!start){
start = '';
}
if(!end){
end = '';
}
if(!projects){
projects = '';
}
if(!users){
users = '';
}
if(!contacts){
contacts = '';
}
if(!chart_type){
chart_type = '';
}
if(flag){
flag = '1';
}
else {
flag = '0';
}
//Put the properties into a string
var dataString = '&start=' + start + '&end=' + end + '&projects=' + projects + '&users=' + users + '&contacts=' + contacts + '&month=' + month + '&flag=' + flag + '&chart_type=' + chart_type ;
//Pass the properties to the controller function via ajax
$.ajax({
type: "POST",
url: "index.php?module=Project&action=update_chart",
data: dataString,
success: function(data) { // On success generate the tasks for the chart
// data is ur summary
$('#gantt_chart').html(data);
add_tooltips();
}
});
}
/*
* This function generates the tooltips on the resource chart by calling the tooltip function in the controller using ajax.
* qTips tooltip jquery plugin is used for the tooltips
* */
function add_tooltips(){
//loop through each task and add tooltips
$('.h,.d').each(function(event) {
//set tooltip title
var title = SUGAR.language.get('Project', 'LBL_TOOLTIP_TITLE');
//get start and end date of the task to pass via ajax to the tooltip controller function
var rel = $(this).attr('rel');
var dates = rel.split("|");
var projects = $("#projects").val();
if(projects != null)
projects = projects.join();
else
projects = '';
var dataString = 'start_date=' + dates[0] + '&end_date=' + dates[1] +'&resource_id=' + dates[2] + '&type=' + dates[3] + '&projects=' + projects;
var url = 'index.php?module=Project&action=Tooltips';
$(this).qtip({
content: {
text: function(event, api) {
$.ajax({
type: "POST",
url: url,
data: dataString
}).then(function(content) {
// Set the tooltip content upon successful retrieval
api.set('content.text', content);
},
function(xhr, status, error) {
// Upon failure... set the tooltip content to the status and error value
api.set('content.text', status + ': ' + error);
});
return 'Loading...'; // Set some initial text
},
title: {
//button: true,
text: title
}
},
position: {
my: 'bottom center',
at: 'top center',
target: 'mouse',
adjust: {
mouse: false,
scroll: false,
y: -10
}
},
show: {
event: 'mouseover'
},
hide: {
event: 'mouseout'
},
style: {
classes : 'qtip-green qtip-shadow qtip_box', //qtip-rounded'
tip: {
offset: 10
}
}
});
});
}
$(document.body).on('change','#users', function(e) {
$('#users option:selected').each(function(i, selected){
if($(selected).val() == '' || $(selected).val() == 'none' ){
$('#users option:selected').removeAttr("selected");
$("#users").val(new Array($(selected).val()));
return 0;
}
});
});
$(document.body).on('change','#contacts', function(e) {
$('#contacts option:selected').each(function(i, selected){
if($(selected).val() == '' || $(selected).val() == 'none' ){
$('#contacts option:selected').removeAttr("selected");
$("#contacts").val(new Array($(selected).val()));
return 0;
}
});
});