Files
crm.e5.pl/modules/EcmCalls/SubPanel.js
2024-04-27 09:23:34 +02:00

104 lines
3.2 KiB
JavaScript
Executable File

//my standard functions - begin
function doRequest(where,post,success,fail) {
this.Display = function(result) { success(result.responseText); }
this.Fail = function(result){ if(typeof(fail) != "undefined") { if(typeof(fail) == "string") alert(fail); else fail(result.responseText); } }
YAHOO.util.Connect.asyncRequest('POST',where,{success:this.Display,failure:this.Fail},post);
}
function addEvent(object,eventName,do_function) {
if(typeof(object) == "string") object = document.getElementById(object);
if(!object) { alert('No object in function addEvent!'); return; }
if(object.addEventListener) {
object.addEventListener(eventName, do_function, false);
} else {
object.attachEvent('on'+eventName, do_function);
}
}
//my standard functions - end
var EcmCallsPage = 0;
var EcmCallsRowLook = new Object()
var EcmCallsColors = new Object();
function loadEcmCalls(page) {
var b = findSubpanel('subpanel_ecmcalls');
if(b) {
doRequest(
'index.php',
'module=EcmCalls&action=SubPanel&to_pdf=1&page='+page+'&searchModule='+document.forms.DetailView.module.value+'&searchRecord='+document.forms.DetailView.record.value,
function(result) {
b.slotCount = 0;
var arr = eval(result);
if(arr[0]) {
arr = arr[0];
EcmCallsColors = arr['colors'];
for(x in arr['positions']) addEcmCall(b,arr['positions'][x]);
}
b.slotCount = 0;
}
);
}
}
function addEcmCall(body_,ecmcall) {
var tr = document.createElement('tr');
tr.height = "20";
tr.scope = "row";
tr.onmouseover = function() { setPointer(this, '', 'over', EcmCallsColors['even_bg'], EcmCallsColors['hilite_bg'] , ''); }
tr.onmouseout = function() { setPointer(this, '', 'out', EcmCallsColors['even_bg'], EcmCallsColors['hilite_bg'] , ''); }
for(x in EcmCallsRowLook) {
var td = document.createElement('td');
td.className = ((body_.slotCount%2) ? 'oddListRowS1' : 'evenListRowS1');
td.bgcolor = EcmCallsColors['odd_bg'];
td.valign = "top";
td.noWrap = "noWrap";
var span = document.createElement('span');
span.sugar = "slot"+(body_.slotCount++)+"b";
span.innerHTML = ecmcall[x];
td.appendChild(span);
tr.appendChild(td);
}
body_.appendChild(tr);
var tr = document.createElement('tr');
var td = document.createElement('td');
td.colSpan = 20;
td.className = 'listViewHRS1';
tr.appendChild(td);
body_.appendChild(tr);
}
function findSubpanel(name) {
var div = document.getElementById(name);
if(div) {
var table = div.getElementsByTagName('table');
if(table && table[0]) {
var body_ = table[0].getElementsByTagName('tbody');
if(body_) {
return body_[0];
}
}
}
return null;
}
addEvent(
window,
'load',
function(result) {
/*
var tmp = document.getElementById('EcmCallsSubPanelDefs');
var spd = eval(tmp.value);
if(spd && spd[0]) spd = spd[0];
EcmCallsRowLook = spd;
*/
showSubPanel('ecmcalls','/index.php?module=EcmCalls&spModule='+document.forms.DetailView.module.value+'&record='+document.forms.DetailView.record.value+'&'+document.forms.DetailView.module.value+'_CELL_offset=0&to_pdf=true&action=SubPanelViewerMy&subpanel=ecmcalls&EcmCalls_CELL_offset=0&EcmCalls_CELL_ORDER_BY=&sort_order=desc&to_pdf=true',true);
//loadEcmCalls();
}
);