Zoeken in deze blog

donderdag 23 juli 2009

Expiratiedatum bepalen o.b.v. Aanvraagtype en Prioriteit

var caseTypeCodeName=crmForm.all.casetypecode.SelectedText;
var priorityCodeName=crmForm.all.prioritycode.SelectedText;

switch(priorityCodeName.toLowerCase())
{
case 'hoog':
switch(caseTypeCodeName.toLowerCase())
{
case 'incident':
crmForm.all.followupby.DataValue=getFollowUpDate(1);
break;
case 'vraag':
crmForm.all.followupby.DataValue=getFollowUpDate(2);
break;
case 'wijziging':
case 'nieuw':
crmForm.all.followupby.DataValue=getFollowUpDate(5);
break;
}
break;
case 'normaal':
switch(caseTypeCodeName.toLowerCase())
{
case 'incident':
case 'vraag':
crmForm.all.followupby.DataValue=getFollowUpDate(3);
break;
case 'wijziging':
case 'nieuw':
crmForm.all.followupby.DataValue=getFollowUpDate(10);
break;
}
break;
case 'laag':
switch(caseTypeCodeName.toLowerCase())
{
case 'incident':
case 'vraag':
crmForm.all.followupby.DataValue=getFollowUpDate(10);
break;
case 'wijziging':
case 'nieuw':
crmForm.all.followupby.DataValue=getFollowUpDate(20);
break;
}
break;
}

function getFollowUpDate(nrOfDays)
{
var weekday=new Array(7);
weekday[0]='sunday';
weekday[1]='monday';
weekday[2]='tuesday';
weekday[3]='wednesday';
weekday[4]='thursday';
weekday[5]='friday';
weekday[6]='saturday';
var date
if(!IsNull(crmForm.all.createdon) && !IsNull(crmForm.all.createdon.DataValue))
date=crmForm.all.createdon.DataValue;
else
date=new Date();
// Calculate the new followup date
var followupDate=new Date();
followupDate.setFullYear(date.getFullYear(),date.getMonth(),date.getDate()+nrOfDays);
var followupDay=weekday[followupDate.getDay()];
// If followupday is on saterday or sunday, set the followupday to monday
if(followupDay=='saturday')
nrOfDays=2;
else if(followupDay=='sunday')
nrOfDays=1;
else
nrOfDays=0;
// Set the new followup date
date.setFullYear(followupDate.getFullYear(),followupDate.getMonth(),followupDate.getDate()+nrOfDays);
return date;
}

Geen opmerkingen:

Een reactie posten