Example #1
0
/**
 * 
 * Alert the dispatcher for events
 * 
 * @param type $type
 * @param type $data
 */
function _notifyDispatcher($type, $data)
{
    switch ($type) {
        case "POSITIVE_CONFIRMATION":
            # $data is a row from tripconfirmationtexts
            # we need : driver name , triptime simple
            // send driver special requests
            Schedulers::sendTripNotesToDriver($data['tripCode']);
            $driverName = $data['driverName'];
            $tripTime = date("H:i", strtotime($data['tripTime']));
            $tripDate = date("m/d", strtotime($data['tripTime']));
            $subject = "{$driverName} confirmed wakeup text for trip at {$tripTime}";
            $content = "Trip Info: {$tripDate} {$tripTime} - {$data['passengerFirstName']} {$data['passengerLastName']} - {$data['carName']} - {$data['vehicleType']}";
            $wakeup_notification = Config::GetEmailValue('wakeup_confirmation_email_notification');
            $wakeup_notification_emails = plainArray($wakeup_notification, 'value');
            _mail($wakeup_notification_emails, $subject, $content);
            break;
        case "PROACTIVE_HALT":
            # $data is a row from tripconfirmationtexts
            # we need : driver name , triptime simple
            // Send trip notes to driver upon confirmation
            Schedulers::sendTripNotesToDriver($data['tripCode']);
            $driverName = $data['driverName'];
            $tripTime = date("H:i", strtotime($data['tripTime']));
            $tripDate = date("m/d", strtotime($data['tripTime']));
            $haltTime = date("H:i");
            $subject = "{$driverName} checked in for {$tripTime} trip - {$data['passengerFirstName']} {$data['passengerLastName']}";
            $content = "Trip Info: {$tripDate} {$tripTime} - {$data['passengerFirstName']} {$data['passengerLastName']} - {$data['carName']} - {$data['vehicleType']}";
            $wakeup_notification = Config::GetEmailValue('wakeup_confirmation_email_notification');
            $wakeup_notification_emails = plainArray($wakeup_notification, 'value');
            _mail($wakeup_notification_emails, $subject, $content);
            break;
        case "DISPATCHER_HANDLED":
            # $data is a row from tripconfirmationtexts
            # we need : driver name , triptime simple
            $driverName = $data['driverName'];
            $dispatchName = $data['dispatcher_name'];
            $tripTime = date("H:i", strtotime($data['tripTime']));
            $tripDate = date("m/d", strtotime($data['tripTime']));
            $subject = "Trip at {$tripTime} was handled by dispatcher {$dispatchName} ";
            $content = "Driver {$driverName} failed to confirm wakeup text. <br /><br />Trip Info: {$tripDate} {$tripTime} - {$data['passengerFirstName']} {$data['passengerLastName']} - {$data['carName']} - {$data['vehicleType']} ";
            $wakeup_notification = Config::GetEmailValue('wakeup_red_alert');
            $wakeup_notification_emails = plainArray($wakeup_notification, 'value');
            _mail($wakeup_notification_emails, $subject, $content);
            break;
        case "NOBODY_HANDLED":
            # $data is a row from tripconfirmationtexts
            # we need : driver name , triptime simple
            $driverName = $data['driverName'];
            $driverNumber = $data['driverNumber'];
            $tripTime = date("H:i", strtotime($data['tripTime']));
            $tripDate = date("m/d", strtotime($data['tripTime']));
            $subject = "RED ALERT! Trip at {$tripTime} is orphan. Nobody is available to handle";
            $content = "Trip Info: {$tripDate} {$tripTime} - {$data['passengerFirstName']} {$data['passengerLastName']} - {$data['carName']} - {$data['vehicleType']}";
            $content .= "<br /><br />Driver Info: Name - {$driverName} | Cell #: {$driverNumber}";
            $wakeup_notification = Config::GetEmailValue('wakeup_red_alert');
            $wakeup_notification_emails = plainArray($wakeup_notification, 'value');
            _mail($wakeup_notification_emails, $subject, $content);
            break;
    }
}