On login, when we know who the user is, we call the checkBirthday() function.
The line where the form frm_person_happy_birthday_dlg is called has to be changed. That form displays a nice photo, the user's name and a green button to play the song.
That will then be played with the function
application.playSound("media:///sounds/happyBirthdayFrankSinatra.wav");
Such wav-files can be found in the internet.
The lbl_header will show "Happy birthday, dear Mr.User" in big letters, with i18n of course.
In case someone would like to implement:
- Code: Select all
function checkBirthday() {
var dBirthday = (_to_person$currentpersonid.ps_birthday) ? scopes.utils.date_clearTime(_to_person$currentpersonid.ps_birthday) : null,
dLastMsg = (_to_person$currentpersonid.ps_last_birthday_notice) ? scopes.utils.date_clearTime(_to_person$currentpersonid.ps_last_birthday_notice) : null,
nAge = null,
dToday = scopes.utils.date_clearTime(new Date()),
dCurrentBirthday = null;
if (dBirthday) {
nAge = scopes.utils.date_getAge(dBirthday);
dCurrentBirthday = scopes.svyDateUtils.addYears(dBirthday,nAge);
if ( (dLastMsg == null || dLastMsg != dCurrentBirthday)
&& dToday >= dCurrentBirthday
&& scopes.svyDateUtils.getDateDifference(dCurrentBirthday, dToday).days <= 7) {
forms["frm_person_happy_birthday_dlg"].elements.lbl_header.text = _to_person$currentpersonid.clcs_ps_full_name;
if (dToday === dCurrentBirthday) {
forms["frm_person_happy_birthday_dlg"].elements.lblBirthdayGreeting.text = i18n.getI18NMessage("bob.ps_birthday_greeting");
} else {
forms["frm_person_happy_birthday_dlg"].elements.lblBirthdayGreeting.text = i18n.getI18NMessage("bob.ps_birthday_greeting_late");
}
_to_person$currentpersonid.ps_last_birthday_notice = dCurrentBirthday;
scopes.ui.DIALOGS.showFormInModalDialog(forms["frm_person_happy_birthday_dlg"], -1, -1, -1, -1, " ", true, false, "dlgHappyBirthday", true);
}
}
}
function date_clearTime(dDate){
if (!dDate) {
scopes.utils.log("Error: No dDate was passed to scopes.utils.date_clearTime(dDate)", LOGGINGLEVEL.ERROR);
return null;
}
try
{
dDate.setHours(0, 0, 0, 0);
}
catch (error)
{
scopes.utils.log("Error: No valid date in dDate was passed to scopes.utils.date_clearTime(dDate)", LOGGINGLEVEL.ERROR);
return null;
}
return dDate;
}
function date_getAge(birth) {
var today = new Date();
var nowyear = today.getFullYear();
var nowmonth = today.getMonth();
var nowday = today.getDate();
var birthyear = birth.getFullYear();
var birthmonth = birth.getMonth();
var birthday = birth.getDate();
var age = nowyear - birthyear;
var age_month = nowmonth - birthmonth;
var age_day = nowday - birthday;
if(age_month < 0 || (age_month == 0 && age_day <0)) {
age = age -1;
}
return age;
}