/
RelatedLists.js
153 lines (144 loc) · 6.73 KB
/
RelatedLists.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*************************************************************************************************
* Copyright 2016 JPL TSolucio, S.L. -- This file is a part of TSOLUCIO coreBOS Customizations.
* Licensed under the vtiger CRM Public License Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You can redistribute it and/or modify it
* under the terms of the License. JPL TSolucio, S.L. reserves all rights not expressly
* granted by the License. coreBOS distributed by JPL TSolucio S.L. 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. Unless required by
* applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT ANY WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing
* permissions and limitations under the License. You may obtain a copy of the License
* at <http://corebos.org/documentation/doku.php?id=en:devel:vpl11>
*************************************************************************************************/
if (window.cbRelatedListsLoaded == undefined) {
window.cbRelatedListsLoaded = 'loaded';
function OpenWindow(url) {
openPopUp('xAttachFile', this, url, 'attachfileWin', 380, 375, 'menubar=no,toolbar=no,location=no,status=no,resizable=no');
}
function isRelatedListBlockLoaded(id, urldata) {
var elem = document.getElementById(id);
if (elem == null || typeof elem == 'undefined' || urldata.indexOf('order_by') != -1 || urldata.indexOf('start') != -1 ||
urldata.indexOf('withCount') != -1 || urldata.indexOf('email_filter') != -1 || urldata.indexOf('cbcalendar_filter') != -1) {
return false;
}
var tables = elem.getElementsByTagName('table');
return tables.length > 0;
}
function loadRelatedListBlock(urldata, target, imagesuffix) {
if ( document.getElementById('return_module').value == 'Campaigns') {
var selectallActivation = document.getElementById(imagesuffix+'_selectallActivate').value;
var excludedRecords = document.getElementById(imagesuffix+'_excludedRecords').value = document.getElementById(imagesuffix+'_excludedRecords').value;
var numofRows = document.getElementById(imagesuffix+'_numOfRows').value;
}
var showdata = 'show_'+imagesuffix;
var showdata_element = document.getElementById(showdata);
var hidedata = 'hide_'+imagesuffix;
var hidedata_element = document.getElementById(hidedata);
if (isRelatedListBlockLoaded(target, urldata)) {
jQuery('#'+target).show();
jQuery(showdata_element).hide();
showdata_element.parentElement.style.display = 'none';
jQuery(hidedata_element).show();
hidedata_element.parentElement.style.display = 'inline-block';
jQuery('#delete_'+imagesuffix).show();
return;
}
var indicator = 'indicator_'+imagesuffix;
var indicator_element = document.getElementById(indicator);
jQuery(indicator_element).show();
document.getElementById('delete_'+imagesuffix).style.display='block';
var target_element = document.getElementById(target);
jQuery.ajax({
method: 'POST',
url: 'index.php?'+urldata,
}).done(function (response) {
var responseData = trim(response);
target_element.innerHTML=responseData;
jQuery(target_element).show();
jQuery(showdata_element).hide();
showdata_element.parentElement.style.display = 'none';
jQuery(hidedata_element).show();
hidedata_element.parentElement.style.display = 'inline-block';
jQuery(indicator_element).hide();
if (document.getElementById('return_module').value == 'Campaigns') {
var obj = document.getElementsByName(imagesuffix+'_selected_id');
var relatedModule = imagesuffix.replace('Campaigns_', '');
if (document.getElementById(relatedModule+'_count')) {
document.getElementById(relatedModule+'_count').innerHTML = numofRows;
}
if (selectallActivation == 'true') {
document.getElementById(imagesuffix+'_selectallActivate').value='true';
jQuery('#'+imagesuffix+'_linkForSelectAll').show();
document.getElementById(imagesuffix+'_selectAllRec').style.display='none';
document.getElementById(imagesuffix+'_deSelectAllRec').style.display='inline';
var exculdedArray=excludedRecords.split(';');
if (obj) {
var viewForSelectLink = showSelectAllLink(obj, exculdedArray);
document.getElementById(imagesuffix+'_selectCurrentPageRec').checked = viewForSelectLink;
document.getElementById(imagesuffix+'_excludedRecords').value = document.getElementById(imagesuffix+'_excludedRecords').value+excludedRecords;
}
} else {
jQuery('#'+imagesuffix+'_linkForSelectAll').hide();
}
updateParentCheckbox(obj, imagesuffix);
}
if (typeof RLColorizerList === 'function') {
var relation = getQueryVariable(urldata, 'relation_id');
if (relation != '') {
jQuery.ajax({
method: 'POST',
url: 'index.php?module=Utilities&action=UtilitiesAjax&file=ExecuteFunctions&functiontocall=getRelatedListInfo&relation_id='+relation,
}).done(function (response) {
var resp = JSON.parse(response);
var rlModule = resp.modulerel;
RLColorizerList(rlModule);
});
} else {
rlModule = imagesuffix.replace(document.getElementById('return_module').value + '_', '');
RLColorizerList(rlModule);
}
}
});
}
function getQueryVariable(urldata, variable) {
var query =urldata;
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == variable) {
return decodeURIComponent(pair[1]);
}
}
return '';
}
function hideRelatedListBlock(target, imagesuffix) {
var showdata = 'show_'+imagesuffix;
var showdata_element = document.getElementById(showdata);
var hidedata = 'hide_'+imagesuffix;
var hidedata_element = document.getElementById(hidedata);
jQuery('#'+target).hide();
jQuery('#hide_'+imagesuffix).hide();
hidedata_element.parentElement.style.display = 'none';
jQuery('#show_'+imagesuffix).show();
showdata_element.parentElement.style.display = 'inline-block';
jQuery('#delete_'+imagesuffix).hide();
}
function disableRelatedListBlock(urldata, target, imagesuffix) {
jQuery('#indicator_'+imagesuffix).show();
jQuery.ajax({
method: 'POST',
url: 'index.php?'+urldata,
}).done(function (response) {
var responseData = trim(response);
jQuery('#'+target).hide();
jQuery('#delete_'+imagesuffix).hide();
jQuery('#hide_'+imagesuffix).hide();
jQuery('#show_'+imagesuffix).show();
var showdata_element = document.getElementById('show_'+imagesuffix);
showdata_element.parentElement.style.display = 'inline-block';
jQuery('#indicator_'+imagesuffix).hide();
});
}
} // cbRelatedListsLoaded