Simple Hotel Style Wake-Up Calls – THE MODULE

Really all you would need to do is remove the error checking in the original wake up call scheduler.
OH! I meant that I did not have to change anything to get it to list more than one wakeup call. I changed it to support more than one.
 
Doesnt sound like its ready to be posted yet. Whats its current status? Have you successfully added the function?
 
Yes I have added the function. It works. You just schedule the firstncall and then call back and press 3 to schedule an additional call. By post the code I meant post it so you could see what I changed. I just have not figured out deleting individual calls. But other than that it works great.
 
Some questions

A few quick questions:
  1. Any possibility we could get a page that displays all pending wake up calls? It would help with debugging, among other things. EDIT: I note that they can be viewed by looking in /var/spool/asterisk/outgoing at the pending call files, but it would be nice if there was a way to see them from within the FreePBX interface.
  2. Under what circumstances might pending wake up calls be lost? Rebooting the system? Upgrading Asterisk to a new version? Upgrading FreePBX? Doing an "orange bar reload?" If any of these things could cause pending wake up calls to be lost, is there a way to fix that?
  3. Have you ever heard of any reason why wake up calls would be consistent late by approximately five minutes, when the system time (date command at Linux prompt) is right on the nose, and calling *60 gives the accurate time as well? Yet a 7:10 AM wake up call always seems to occur right around 7:15 (and this is not a heavily-used system).
Just trying to figure out what the issue is with wake up calls not working quite as expected. Thanks for any insights you may have.

EDIT: I also might have a way to fix the Daylight Savings Time issue, though I can't decipher your code well enough to tell how to modify it. EDIT: I'm now sure the change would go in /var/lib/asterisk/agi-bin/wakeupphp (after at first thinking the wrong file, see my edit below). But anyway, here's a little sample program you can run to illustrate how to apply a fix:

Code:
#!/usr/bin/php -q
<?php
$time = time( );
Echo "Current UNIX time: $time\n";
$date = date("F j, Y, g:i a I");
Echo "Current date/time: $date\n\n";

# Using times before and after change from Standard Time to DST 
$time_1 = 1299965601;
$time_2 = $time_1 + 86400;
$before_dt = date("F j, Y, g:i a I",$time_1);
Echo "A time on day before DST starts: $before_dt\n";
$after_dt = date("F j, Y, g:i a I",$time_2);
Echo "A time exactly 24 hours after the previous time: $after_dt\n";
$DST_correction = (date("I",$time_1) - date("I",$time_2)) * 3600;
Echo "DST correction that should be applied: $DST_correction\n";
$adjusted_time = date("F j, Y, g:i a I",$time_2 + $DST_correction);
Echo "Time adjusted with DST correction: $adjusted_time\n\n";

# Using times before and after change from DST back to Standard Time
$time_1 = 1320528801;
$time_2 = $time_1 + 86400;
$before_dt = date("F j, Y, g:i a I",$time_1);
Echo "A time on day before DST ends: $before_dt\n";
$after_dt = date("F j, Y, g:i a I",$time_2);
Echo "A time exactly 24 hours after the previous time: $after_dt\n";
$DST_correction = (date("I",$time_1) - date("I",$time_2)) * 3600;
Echo "DST correction that should be applied: $DST_correction\n";
$adjusted_time = date("F j, Y, g:i a I",$time_2 + $DST_correction);
Echo "Time adjusted with DST correction: $adjusted_time\n\n";

If you run it on a system in the USA where Daylight Savings Time is observed you will see the point (elsewhere you may have to change the $time_1 values to overlap a DST change in your area - this is just a demo program). The meat of the program is this line:

$DST_correction = (date("I",$time_1) - date("I",$time_2)) * 3600;

$time_1 would be the UNIX time at which the wake-up call is set, and $time_2 is the UNIX time of the desired wake up call. The date("I",$time_x) function returns 1 for DST and 0 for "not DST", therefore the $DST_correction value will be -3600 on the transition from standard time to daylight time (because you lose an hour) and +3600 on the transition from daylight time to standard time (because you gain an hour), and at all other times it will be zero. I'm assuming that because the wake up time is off by an hour, you're calculating the wakeup time as an offset from the current time (or something like that) so if you use the above and then add $DST_correction to the calculated wake up time it should be correct. As I say, I don't quite understand your code well enough to make this change myself. EDIT 2: However, my suspicion is that it could go after this line:

Code:
if ( $time_wakeup <= $time_now )
                                        $time_wakeup += 86400; // Add One Day on

After which I would GUESS you could insert:

Code:
$time_wakeup += ((date("I",$time_now) - date("I",$time_wakeup)) * 3600);
(Don't know if those outer parenthesis would be needed or not, but when in doubt...).

Haven't tested this because there's really only two times a year you can test something like this in actual use!

EDIT: I tested it on the March 13 time change - tried to set up a 3:10 AM wake up call and it called at 1:10 AM instead. Not exactly sure what I did wrong (maybe $time_now and $time_wakeup need to be reversed?) but I might have been able to figure it out had it not taken me most of an hour to realize I was editing the wrong file. The working copy of wakeupphp is in the /var/lib/asterisk/agi-bin directory, not in /var/www/html/admin/modules/hotelwakeup/agi-bin as I had originally thought.
 
This is my modified wakeupphp. It has the changed code that enabled multiple wake up calls. I am closer to figuring out how to read back multiple calls and choose which to delete.
 

Attachments

Take it. It's unlicensed and Tony Shiffer (maintainer of colsolgrp) no longer replies to PMs or Emails.

I say take it and apply a license to it. If Tony were here he'd say the license would be GPL 2.

Bump: Under what license is this module released?
 
Under FreePBX 2.9 version 1.2.4 of this module is throwing a warning message:

Code:
2011-Aug-08 02:20:00    /var/www/html/admin/modules/hotelwakeup/functions.inc.php:40
[NOTICE]: Use of undefined constant wakeupphp - assumed 'wakeupphp'

Not sure what that means or if it's important.
 

Members online

Forum statistics

Threads
26,695
Messages
174,440
Members
20,264
Latest member
TRENT310
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Back
Top