var participantsClone = null;
var chkOnlyVisibleAccountsClone = null;
var searchTimer = null;
var globalSearchEnter = true;
function callAjax(action, mode, handler, parameters)
{
var url = '$this.' + action + '.' + mode;
if (parameters)
cExecute(url, handler, $H(parameters).toQueryString());
else
cExecute(url, handler);
}
function getSectors()
{
function resultGetSectors(data)
{
setSelectValue($('sector'), data['sectors']);
$('sector').onchange = getParticipants;
resultGetParticipants(data['participants']);
}
var params = {
organization: $F('organization'),
onlyVisibleAccounts: $F('onlyVisibleAccounts'),
entities: $F('entities'),
id: $F('id'),
usePreffix: $F('usePreffix')
};
callAjax('bo_participants', 'getSectors', resultGetSectors, params);
}
function getParticipants()
{
var params = {
context: $F('sector'),
onlyVisibleAccounts: $F('onlyVisibleAccounts'),
entities: $F('entities'),
id: $F('id'),
usePreffix: $F('usePreffix')
};
callAjax('bo_participants', 'getEntities', resultGetParticipants, params);
}
function resultGetParticipants(data)
{
$('search').value = '';
setSelectValue($('participants'), data);
participantsClone = data;
if($('onlyVisibleAccounts'))
chkOnlyVisibleAccountsClone = $('onlyVisibleAccounts').checked;
}
function searchParticipantsTimer(e)
{
if (checkShortcuts((e) ? e : window.event))
return true;
if (searchTimer)
clearTimeout(searchTimer);
searchTimer = setTimeout(function(){searchParticipants($F('search'));}, 250);
}
function searchParticipants(searchString)
{
var reg = new RegExp("';
}
}
if (options.length > 0)
{
setSelectValue(target, target.innerHTML + options);
/* refaz o link que se perde quando modifica-se o innerHTML da select box */
target = window.opener.document.getElementById($F('target'));
}
current = target.innerHTML;
}
/* se o código do desenvolvedor está esperando o evento onchange, dispara o evento */
if (target.onchange)
if (current != previous)
target.onchange();
}
function setSelectValue(obj, value)
{
/* IE MAGIC */
if (obj.outerHTML)
{
obj.innerHTML = '';
obj.outerHTML = obj.outerHTML.match(/';
}
else
obj.innerHTML = value;
}
function participantsRemoveUser(obj)
{
if (obj.tagName == 'INPUT')
{
obj.value = '';
obj = document.getElementById(obj.id + '_desc');
if (obj)
obj.value = '';
}
else
{
for(var i = 0;i < obj.options.length; i++)
if(obj.options[i].selected)
obj.options[i--] = null;
}
}
function toggleFullSearch()
{
$('search').value = '';
if ($('useGlobalSearch').checked)
{
globalSearchEnter = true;
if ($('organizationSectors'))
$('organizationSectors').hide();
if ($('globalSearchTitle'))
$('globalSearchTitle').show();
setSelectValue($('participants'), '');
$('search').onkeydown = globalSearchKeyAnalyzer;
$('globalSearchWarnings').innerHTML = 'Para executar a busca, pressione ENTER.';
}
else
{
$('globalSearchWarnings').innerHTML = '';
if ($('globalSearchTitle'))
$('globalSearchTitle').hide();
if ($('organizationSectors'))
$('organizationSectors').show();
searchParticipants('');
$('search').onkeydown = searchParticipantsTimer;
}
$('search').focus();
}
function checkGlobalSearchShortcuts(e)
{
var whichCode = (e.which) ? e.which : e.keyCode;
var handled = false;
/* ENTER */
if ((whichCode == 13) && globalSearchEnter)
{
performGlobalSearch();
handled = true;
globalSearchEnter = false;
}
if (handled == false)
{
handled = checkShortcuts(e);
if (handled == true)
globalSearchEnter = false;
}
if (handled == false)
globalSearchEnter = true;
return handled;
}
function globalSearchKeyAnalyzer(e)
{
if (checkGlobalSearchShortcuts((e) ? e : window.event))
return true;
}
function performGlobalSearch()
{
function resultPerformGlobalSearch(data)
{
setSelectValue($('participants'), data['participants']);
if (data['warnings'])
if (data['warnings'].length > 0)
$('globalSearchWarnings').innerHTML = data['warnings'].join('
');
}
$('globalSearchWarnings').innerHTML = '';
var params = {
onlyVisibleAccounts: $F('onlyVisibleAccounts'),
searchTerm: $F('search'),
entities: $F('entities'),
id: $F('id'),
usePreffix: $F('usePreffix')
};
callAjax('bo_participants', 'globalSearch', resultPerformGlobalSearch, params);
}
function openParticipants(target, option)
{
newWidth = 500;
newHeight = 315;
newScreenX = screen.width - newWidth;
newScreenY = 0;
page = 'index.php?menuaction=workflow.ui_participants.form';
if (target)
page += "&target_element=" + target;
if (option)
page += "&" + option;
window.open(page,'','width='+newWidth+',height='+newHeight+',screenX='+newScreenX+',left='+newScreenX+',screenY='+newScreenY+',top='+newScreenY+',toolbar=no,scrollbars=no,resizable=no');
}