Example #1
0
// Not all answers can be "No".
if ($sweep == 'No' && $trashcans == 'No' && $handpick == 'No') {
    echo "<action>\n\t\t\t<app>survo</app>\n\t\t\t\t<parameters>\n\t\t\t\t\t<id>412191</id>\n\t\t\t\t\t<p_t>" . $p_t . "</p_t>\n\t\t\t\t</parameters>\n\t\t\t</action>";
    // Stop the PHP script before it hits the database;
    exit;
}
// Query statement
$query = "CALL proc_endSweepJob('{$event_id}', '{$timestamp}', '{$caller_id}', '{$session_id}',\n\t\t\t\t'{$message}', '{$mileage}', '{$sweep}', '{$trashcans}', '{$can_qty}', '{$handpick}', @confirmation)";
// Connect to the database
$conn = Database::getDB();
try {
    $conn->beginTransaction();
    $results = $conn->query($query);
    // Return value is the confirmation code
    $results = $conn->query("SELECT @confirmation");
    $conn->commit();
    foreach ($results as $result) {
        // Process confirmation code to create a digit by digit message.
        // (e.g., 1 2 3 instead of 123)
        $conf = IfByPhone_Util::processConfirmationCode($result["@confirmation"]);
    }
    // Select the confirmation code survo on the IVR system
    echo "<action>\n\t\t\t\t\t<app>survo</app>\n\t\t\t\t\t\t<parameters>\n\t\t\t\t\t\t\t<id>362811</id>\n\t\t\t\t\t\t\t<user_parameters>\n\t\t\t\t\t\t\t\t<conf>" . $conf . "</conf>\n\t\t\t\t\t\t\t</user_parameters>\n\t\t\t\t\t\t</parameters>\n\t\t\t\t\t</action>";
} catch (PDOException $e) {
    // Error handling
    $conn->rollBack();
    Database::logError('sweep', $e);
    Database::sendToIvrError();
}
// Send SMS message notifying job completion
$sms = IfByPhone_Util::smsIvrEvent($conn, 'sweeping', 'FINISHED', $job_id, $timestamp, $employee_name, $job_name);