mirror of
https://github.com/salesagility/SuiteCRM.git
synced 2024-11-22 07:52:36 +00:00
29a3b668a3
Commits included are: commit 3ea2c1f49d26ef6918a69f4c2069824e0ff487f1 commit 4949b32cf655bbc597bcc19820c81ebbd7559b57 commit92545172da
commita48e6f4572
commit ab6e8322d37b4b8a5c3bb78312445358c97406b2 commit 5911d92e9483309220d7f1b5350edd51fcd6bad5 commit14bcaa3d77
commit3a414f6186
commit2db4441ab4
commitec2fc67231
commitf502666b64
commit9d45b94425
commit7d926ac4ac
commit7d1b17828a
commitfe004be24e
commitc02617039f
commitc8a8fe7cff
commit5a5a11e467
commit4502f66472
commitf4681c81f9
commit9c571f0276
commit929bc56df3
commit ee37e5734e5f3c35b5f432aed83c24205fd40de7 commit bf7012889149154579d0b0b879423919e329583f commit 4fe4ae32fc5d67e05f6af326ccab533e32a0d35a commit818b342a9f
commite58b6cf690
commitb180713c0a
commit 723f5cc09c1b5087e3b83b22ca8f35fc94a82f90 commit 890a6daf50a4c80d3a0080617c1f2cf8c834a5b0 commit 5ce07bfff6c6af032af3cc678e5c4c0bd607010f commit9f18f07f8e
commit39bfaf92ea
commit7abe50ec4f
commitd8b1498a35
commit8b0b56fa63
commit58e82c9ec4
commit6f8b135376
commitfe201f8aa4
commit542e9f4ea5
commitf09e2a1805
commit872e2b73f8
commitf8979a1610
commite8a34d9ad5
commit632080e861
commitf42acc9efa
commitbe4d11f94e
commit61f65a7f70
commit903af549ce
Author: Haris Raheem <haris_raheem@hotmail.com>
247 lines
7.5 KiB
JavaScript
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;
|
|
}
|
|
|
|
});
|
|
|
|
});
|