public function testGetsAllReservationsWithReminderDateOfThisMinute()
 {
     $seriesId = 123;
     $instanceId = 456;
     $referenceNumber = 'refnum1';
     $startDate = Date::Now()->AddDays(1)->ToDatabase();
     $endDate = Date::Now()->AddDays(2)->ToDatabase();
     $title = 'reservation title';
     $description = 'reservation description';
     $resourceName = 'resource name';
     $emailAddress = '*****@*****.**';
     $fname = 'first';
     $lname = 'last';
     $timezone = 'America/Chicago';
     $reminder_minutes = 100;
     $now = Date::Now();
     $language = 'en_us';
     $row1 = new ReminderNoticeRow($seriesId, $instanceId, $referenceNumber, $startDate, $endDate, $title, $description, $resourceName, $emailAddress, $fname, $lname, $timezone, $reminder_minutes, $language);
     $row2 = new ReminderNoticeRow();
     $rows = array_merge($row1->Rows(), $row2->Rows());
     $this->db->SetRows($rows);
     $reminderNotices = $this->repository->GetReminderNotices($now, ReservationReminderType::Start);
     $expectedCommand = new GetReminderNoticesCommand($now->ToTheMinute(), ReservationReminderType::Start);
     $this->assertEquals(2, count($reminderNotices));
     $this->assertEquals($expectedCommand, $this->db->_LastCommand);
     $expectedReminderNotice = ReminderNotice::FromRow($rows[0]);
     $this->assertEquals($expectedReminderNotice, $reminderNotices[0]);
 }
Example #2
0
This script must be executed every minute for to enable Reservation Reminders functionality

* * * * * php -f /home/mydomain/public_html/booked/Jobs/sendreminders.php
* * * * * /path/to/php -f /home/mydomain/public_html/booked/Jobs/sendreminders.php

*/
define('ROOT_DIR', dirname(__FILE__) . '/../');
//define('ROOT_DIR', __DIR__ . '/../');
require_once ROOT_DIR . 'Domain/Access/namespace.php';
require_once ROOT_DIR . 'Domain/Reminder.php';
require_once ROOT_DIR . 'lib/Email/Messages/ReminderEmail.php';
require_once ROOT_DIR . 'Jobs/JobCop.php';
Log::Debug('Running sendreminders.php');
JobCop::EnsureCommandLine();
try {
    $repository = new ReminderRepository();
    $now = Date::Now();
    $startNotices = $repository->GetReminderNotices($now, ReservationReminderType::Start);
    Log::Debug('Found %s start reminders', count($startNotices));
    foreach ($startNotices as $notice) {
        ServiceLocator::GetEmailService()->Send(new ReminderStartEmail($notice));
    }
    $endNotices = $repository->GetReminderNotices(Date::Now(), ReservationReminderType::End);
    Log::Debug('Found %s end reminders', count($endNotices));
    foreach ($endNotices as $notice) {
        ServiceLocator::GetEmailService()->Send(new ReminderEndEmail($notice));
    }
} catch (Exception $ex) {
    Log::Error('Error running sendreminders.php: %s', $ex);
}
Log::Debug('Finished running sendreminders.php');