<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Myles Wakeham wrote:
<blockquote cite="mid:4B3CC750.5050301@techsol.org" type="cite">
<pre wrap="">
I suspect others have done this sort of thing with Asterisk before, but
I've not found any resources so far.
</pre>
</blockquote>
<br>
<font face="Courier New, Courier, monospace">exten =>
317xxxxxxx,1,Gosub(holiday_check,s,1)<br>
<br>
<br>
[holiday_check]<br>
<br>
;********************************<br>
;* Break out current 2 digit month<br>
;********************************<br>
<br>
exten => s,1,Gosub(todays_date,s,1)<br>
<br>
;*****************************************<br>
;* Look for database entry for match against<br>
;* month and day. Store sound file name<br>
;* to GREETING variable<br>
;*****************************************<br>
<br>
exten => s,n,MYSQL(Connect connid localhost anonymous '' holidays)<br>
exten => s,n,GosubIf($["${MYSQL_STATUS}" = "-1"]?mysql_failed,s,6)<br>
exten => s,n,MYSQL(Query resultid ${connid} SELECT greeting FROM
schedule WHERE month = ${MONTH} AND day = ${DAY})<br>
exten => s,n,MYSQL(Fetch fetchid ${resultid} GREETING)<br>
exten => s,n,MYSQL(Disconnect ${connid})<br>
exten => s,n,MYSQL(Clear ${resultid})<br>
<br>
;*******************************************<br>
;* If GREETING <> *BLANK, must be a holiday<br>
;* jump to s,10. Else return from subroutine<br>
;*******************************************<br>
<br>
exten => s,n,GotoIf($["${GREETING}" != ""]?9:13)<br>
<br>
;********************************<br>
;* Play Holiday message and return<br>
;* from subroutine<br>
;********************************<br>
<br>
exten => s,n,Wait(2)<br>
exten => s,n,Playback(local/holidays/greet_begin)<br>
exten => s,n,Playback(local/holidays/${GREETING})<br>
exten => s,n,Set(_Holiday=YES)<br>
exten => s,n,Return<br>
<br>
<br>
[todays_date]<br>
<br>
;********************************<br>
;* Break out current 2 digit hour<br>
;********************************<br>
<br>
exten => s,1,Set(HOUR=${STRFTIME(${EPOCH},,%H)})<br>
<br>
;********************************<br>
;* Break out current 2 digit day<br>
;********************************<br>
<br>
exten => s,n,Set(DAY=${STRFTIME(${EPOCH},,%d)})<br>
<br>
;********************************<br>
;* Break out current 2 digit month<br>
;********************************<br>
<br>
exten => s,n,Set(MONTH=${STRFTIME(${EPOCH},,%m)})<br>
<br>
;********************************<br>
;* Break out current 4 digit year<br>
;********************************<br>
<br>
exten => s,n,Set(YEAR=${STRFTIME(${EPOCH},,%Y)})<br>
<br>
;********************************<br>
;* Set TODAY to DAY/MONTH/YEAR<br>
;********************************<br>
<br>
exten => s,n,Set(TODAY=${MONTH}/${DAY}/${YEAR})<br>
<br>
exten => s,n,Return()<br>
<br>
</font><br>
</body>
</html>