function checkform_back(obj)
{
var xc = 0;
for(x=0; x < obj.length; x++)
{
if(obj[x].value == '')
{
xc++;
obj[x].style.backgroundColor = '';
obj[x].style.borderColor = '';
if(xc==1)
obj[x].focus();
}
else
{
obj[x].style.backgroundColor = '';
obj[x].style.borderColor = '';
}
}
if(xc>0)
{
alert("El formulario esta incompleto.");
return false;
}
return true;
}
//----------------------------------------------------------------------------------
var hover_field_old_color = '';
var monitorWindow = false;
var monitorCardSuspend = false;
var alertsStack = Array();
var monitorDisabled = false;
var notifyid = 0;
function monitorDisable()
{
console.log('Disabling monitor');
monitorDisabled = true;
}
function prepareMonitorStatus()
{
if(monitorDisabled)
{
return;
}
setTimeout(function(){ monitorPriorityCalls(); }, 1000);
setInterval(function(){ monitorPriorityCalls(); }, 12000);
/*
if(notify.isSupported)
{
if(notify.permissionLevel() == notify.PERMISSION_DENIED)
{
monitorRequestPermission();
}
else
{
//notify.config({pageVisibility: false, autoClose: 500});
setInterval(function(){ monitorPriorityCalls(); }, 4000);
}
}
else
{
//alert('Debe cambiar un navegador que admita notificaciones de escritorio');
}
*/
}
function notificationAction(ot_id)
{
auxiliar = document.getElementById('triggerauxiliar') || document.getElementById('surveyContainer').contentWindow.auxiliar;
prm_goto_otid = document.getElementById('idx_goto_param_otid') || document.getElementById('surveyContainer').contentWindow.idx_goto_param_otid;
if(auxiliar)
{
auxiliar.value = 5;
prm_goto_otid.value = ot_id;
top.triggerWalkSurvey();
}
}
function goingToPriority()
{
auxiliar = document.getElementById('triggerauxiliar') || document.getElementById('surveyContainer').contentWindow.auxiliar;
if(auxiliar && auxiliar.value == 5)
return true;
return false;
}
function increaseAlertStack()
{
++alertsStack;
}
function decreaseAlertStack()
{
--alertsStack;
}
function monitorRequestPermission()
{
/*
if(confirm('Debe aceptar las notificaciones de escritorio'))
{
notify.requestPermission();
}
else
{
alert('Si no acepta no podrá ser notificada de eventos urgentes');
}
*/
}
function monitorPriorityCalls()
{
if(monitorDisabled || goingToPriority())
{
return;
}
var url = "mon/monitor.priorityCalls.php?monuid=" + monuid;
$.get(url, "", function(data)
{
$('#idx_priocalls').remove();
$("body").append(data);
});
/*
if(!monitorCardSuspend && alertsStack < 1)
{
switch(notify.permissionLevel())
{
case notify.PERMISSION_DEFAULT:
monitorRequestPermission();
case notify.PERMISSION_DENIED:
monitorRequestPermission();
break;
case notify.PERMISSION_GRANTED:
monuid = top.document.getElementById('monuid').value;
protocol = window.location.href.split("/");
protocol = protocol[0];
var url = protocol + "///mon/monitor.priorityCalls.php?monuid=" + monuid;
var url = "mon/monitor.priorityCalls.php?monuid=" + monuid;
$.ajax({
type: "POST",
cache: false,
url: url,
dataType: "json",
success: function(res)
{
var showMon = 0;
if(res)
if(res.status == "DISABLED")
{
//document.getElementById('status_monit').style["background-color"] = "#E93C11";
}
else
{
//document.getElementById('status_monit').style["background-color"] = "#33CC02";
var info = res;
if(typeof info != "undefined" && typeof info.otrm_phone != "undefined")
{
showMon++;
}
if(showMon)
{
increaseAlertStack();
notifyid = notify.createNotification("LLamada urgente", {body: info["otrm_description"] + "\n\nHaga clic aquí para que sea su próxima llamada", icon: "images/layout/logo.png"},
function()
{
notificationAction(info["survey_id"]);
},
function()
{
decreaseAlertStack();
}
);
}
}
}
});
break;
}
}
*/
}
//----------------------------------------------------------------------------------
function showFancyboxAuto2(xurl, xtype, width, height)
{
if(height == undefined || height == "")
height = 340;
if(width == undefined || width == "")
width = 560;
$.fancybox(xurl,
{
'width' : width,
'height' : height,
'autoScale' : false,
'transitionIn' : 'elastic',
'transitionOut': 'fade',
'type' : 'iframe',
'overlayShow' : true,
'scrolling' : 'auto',
'centerOnScroll': true
});
}
function disableGroup(selector, action){
var vm = $(selector);
if(action)
$(':input', vm).attr('disabled', true);
else
$(':input', vm).removeAttr('disabled');
}
//----------------------------------------------------------------------------------
function questionFromGlobal(action){
disableGroup('tr.disablegroup', action);
disableGroup('tr.globalgroup', !action);
var vm = $('tr.globalgroup');
if(action)
vm.css('display', '');
else
vm.css('display', 'none');
}
//----------------------------------------------------------------------------------
function getGlobalQuestionFromName(name)
{
var post = {}
post.data = $(name).val();
$.ajax({
type: "POST",
data: post,
url: "ajax/getGlobalQuestion.php",
success: function(response)
{
var vm = $('#global_question');
vm[0].options.length = 0;
var data = jQuery.parseJSON(response);
if(data !== null && data.response.length > 0)
{
r = data.response;
for(x in data.response)
{
vm.append('');
}
}
}
});
}
//----------------------------------------------------------------------------------
function resizeOperatorsFrame(val)
{
$(document).ready(function()
{
var xheight = $('#surveyContainer').contents().height() + 80;
document.getElementById('surveyContainer').style.height = xheight + 'px';
});
}
//----------------------------------------------------------------------------------
function syncAudios()
{
$.ajax({
type: "POST",
url: "sync.audios.php",
success: function(response)
{
var data = jQuery.parseJSON(response);
if(data.response != "ERROR")
{
alert('Sincronizado con éxito');
}
else
{
alert('No se han sincronizado audios');
}
}
});
}
//----------------------------------------------------------------------------------
var last_valid_selection = [];
function limitMultiSelect(selector, optLimit)
{
$(selector).change(function(event) {
if ($(this).val().length > optLimit) {
$(this).val(last_valid_selection[selector]);
} else {
last_valid_selection[selector] = $(this).val();
}
});
}
//----------------------------------------------------------------------------------
function maxOtMuiltiSelect(init)
{
/*
if(document.getElementById('ot_segment').selectedIndex == -1)
{
$('#ot_limit').removeAttr('disabled');
$('#ot_limit').removeAttr('readonly');
}
else
{
$('#ot_limit').attr('disabled');
$('#ot_limit').attr('readonly');
}
*/
if(init)
{
if (document.getElementById('ot_segment').selectedIndex == -1 || document.getElementById('ot_segment').selectedIndex == 0)
{
$('#ot_limit').removeAttr('readonly');
$('#ot_limit').removeAttr('disabled');
}
else if(document.getElementById('ot_segment').selectedIndex == 1 && $('#ot_segment').val()[0] == 0)
{
$('#ot_limit').removeAttr('readonly');
$('#ot_limit').removeAttr('disabled');
}
else
{
$('#ot_limit').attr('disabled','disabled');
$('#ot_limit').attr('readonly','readonly');
}
if (document.getElementById('ot_segment').selectedIndex > 3)
{
$('#ot_segment').val(last_valid_selection['#ot_segment']);
}
else
{
last_valid_selection['#ot_segment'] = $('#ot_segment').val();
}
maxOtMuiltiSelect();
}
else
{
$('#ot_segment').change(function(event)
{
if($(this).val() != null)
{
if ($(this).val().length == 0)
{
$('#ot_limit').removeAttr('readonly');
$('#ot_limit').removeAttr('disabled');
}
else if($(this).val().length == 1 && $(this).val()[0] == 0)
{
$('#ot_limit').removeAttr('readonly');
$('#ot_limit').removeAttr('disabled');
}
else
{
$('#ot_limit').attr('disabled','disabled');
$('#ot_limit').attr('readonly','readonly');
}
if ($(this).val().length > 3)
{
$(this).val(last_valid_selection['#ot_segment']);
}
else
{
last_valid_selection['#ot_segment'] = $(this).val();
}
}
else
{
$('#ot_limit').removeAttr('readonly');
$('#ot_limit').removeAttr('disabled');
}
});
}
}
function resizeIframe(obj)
{
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
obj.style.height = obj.contentWindow.document.body.scrollWidth + 'px';
}
function requestInput(txt, defaulttext)
{
var rlabel = prompt(txt, defaulttext);
if (rlabel != null)
{
if (rlabel.trim() != "")
{
$('input[name="request-label"]').val(rlabel);
return true;
}
else {
var rlabel = prompt(' ** El campo no puede estar vacio **', defaulttext);
if (rlabel != null && rlabel.trim() != "") {
$('input[name="request-label"]').val(rlabel);
return true;
}
}
}
return false;
}
function formCheckToggle(e)
{
var vm = $(e);
var form = vm.closest('form');
chkbxs = $('input[type=checkbox]', form).slice(1);
chkbxs.attr('checked', e.checked).change();
}
function formFn(form, fn)
{
vm = $(form);
vm.find('input[name=formfn]').val(fn);
}
function markRowEvent(form, fn)
{
formFn(form, fn);
}
function markRow(id)
{
// USES CHECKBOX AS CONTROLLER
id = id.toString();
var table = $('#tr-' + id);
var chkbx = $('#markrow-' + id);
if(chkbx.attr('checked'))
{
table.addClass('markrow');
}
else
{
table.removeClass('markrow');
}
}
function markToGlobal(id)
{
id = id.toString();
var table = $('#tr-' + id);
var input = $('#global-' + id);
if(input.val() === "0")
{
input.val(1);
table.addClass('marktoglobal');
}
else
{
input.val(0)
table.removeClass('marktoglobal');
}
}
function markToDelete(id)
{
id = id.toString();
var table = $('#tr-' + id);
var input = $('#delete-' + id);
if(input.val() === "0")
{
input.val(1);
table.addClass('marktodelete');
}
else
{
input.val(0)
table.removeClass('marktodelete');
}
}
function getQueryString()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
function showModal(module, xurl, xtype, wsize, hsize, xscrolling)
{
if(hsize == undefined)
{
hsize = 650;
}
if(wsize == undefined)
{
wsize = 750;
}
if(xscrolling == undefined)
{
xscrolling = false;
}
xurl = '/iframe.color.box.php?module=' + module + '&' + xurl;
var xurl = "