%@page session="true" contentType="application/x-javascript"%>
<%@ page import="com.edeal.frontline.navigation.FlRequest" %>
<%@ page import="com.edeal.frontline.FlContext" %>
<%@ page import="com.edeal.frontline.DataDictionary" %>
<%@ page import="com.edeal.frontline.controller.actions.SelectAction" %>
<%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %><%
response.setContentType("application/x-javascript");
FlRequest flRequest = new FlRequest(request);
FlContext context = flRequest.getContext();
DataDictionary dico = context.getDataDictionary();
%>
function changeDay(y, m, d) {
var dateStr = d.toString() + "/" + m.toString() + "/" + y.toString();
var dateFormated = checkDate(dateStr, 'dd/mm/yyyy', dateFormatOut);
var url = window.location.href;
url = appendToURL(url, 'calyear', y);
url = appendToURL(url, 'calmonth', m);
window.location = appendToURL(url, 'date', dateFormated);
}
// sURL = URL to append to, sParam = parameter name, sParamVal = parameter value
function appendToURL(sURL,sParam,sParamVal) {
// remove existing parameters
sURL = removeFromURL(sURL,sParam);
// remove ? if it is the last character on the URL
sURL = sURL.replace(/\?$/,'');
// generate the querystring (add '?' if querystring is blank, '&' if there are other parameters)
sURL += ((sURL.indexOf("?") == -1)?"?":"&") + sParam + "=" + sParamVal;
return sURL;
}
// sURL = URL to remove from, sParam = parameter to remove from URL
function removeFromURL(sURL,sParam) {
// where the querystring starts (i.e. where ? appears)
var qStart = sURL.indexOf('?') + 1;
// if ? is not in sURL (i.e. qStart = 0) or ? is at the end of sURL, then there are no parameters to remove
if (qStart == 0 || qStart == sURL.length-1) {
return sURL;
}
/*
create regular expression, match sParam followed by '=', then any character (except '&') 1 or more times
and optionally ending with a single '&' (optional as there may be a parameter after this one, which will need to be preserved)
*/
var regexp = new RegExp("(" + sParam + "=[^&]+(&)?)");
/*
return the URL, first by getting the root url (which ends at qStart),
and then replacing any text that matches the regular expression, as well as making sure the url does not end with '&'
*/
return sURL.substring(0,qStart) + sURL.substring(qStart).replace(regexp,'').replace(/&$/,'');
}
intType = null;
intID = null;
function show (type, id) {
window.parent.intType = type;
window.parent.intID = id;
if (type.toLowerCase() == 'interaction') {
var doc = document;
var detailsNode = doc.getElementById("appt_details");
if (!detailsNode) {
doc = window.parent.document;
detailsNode = doc.getElementById("appt_details");
}
detailsNode.style.visibility = 'hidden';
doAjax('/interaction_details.fl?id=' + id);
}
}
function open_initial_win(url) {
// var win2open=window;
// do {win2open=win2open.top.opener} while (win2open.top.opener!=null);
// win2open.location=url;
// win2open.focus();
window.origin.location=url;
window.origin.focus();
}
function read_actor(id){
open_initial_win("/read_actor.fl?id="+id);
}
function read_person(id){
open_initial_win("/read_person.fl?id="+id);
}
function read_enterprise(id){
open_initial_win("/read_enterprise.fl?id="+id);
}
function edit() {
open_initial_win("/edit_" + intType.toLowerCase() + ".fl?id=" + intID);
}
function changeDate(date) {
var url = window.location.href;
window.location = appendToURL(url, 'date', date);
}
function createInteraction(actID, date, hour) {
window.open('&initIntAtvID=<%= dico.getRefIdByCode("IntAtvID", "NOTE") %>&initIntDate=' + date + '&initIntActID=' + actID + (hour ? '&initIntTimeBeg=' + hour : ''), 'CreateInteraction', 'menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,width=800,height=570');
}
function changeActor() {
var win = window.open('/select.fl?type=Actor&field=ActID&formIndex=0', 'SelectActor', 'menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,width=<%= SelectAction.SELECT_WINDOW_WIDTH %>,height=370')
}
function doActIDChange() {
var f = document.forms[0];
var loc = appendToURL(window.location.href, 'actor', f.ActID.value);
loc = appendToURL(loc, 'nbAgenda', f.nbAgenda.value);
window.open(loc, 'agenda' + f.ActID.value, 'width=1024,height=660,scrollbar=no,resizable=no,toolbar=no,location=no,menubar=no,status=no');
}
function calcAvailability() {
var f = document.forms[0];
var dt = '';
dt = f.date.value;
var act = '';
act = f.actor.value;
var length = 150;
window.open('/availability.fl?origin=agenda&actor='+act+'&date='+dt+'&length='+length, 'CompDisp', 'menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,width=700,height=470,screenX=50,screenY=10');
}