Esempio n. 1
0
        break;
    default:
        $result = '';
        $query = $db->prepare("CALL proc_smsInbound(:to, :from, :message)");
        $query->bindParam(":to", $to, PDO::PARAM_STR);
        $query->bindParam(":from", $from, PDO::PARAM_STR);
        $query->bindParam(":message", $message, PDO::PARAM_STR);
        $query->execute();
        break;
}
try {
    $call = $db->query($query);
    if ($message == 'status') {
        foreach ($call as $a) {
            switch ($a["allowSMS"]) {
                case '0':
                    $result = 'Text messages are currently turned OFF';
                    break;
                case '1':
                    $result = 'Text messages are currently turned ON';
                    break;
            }
        }
    }
    if ($result) {
        IfByPhone_Util::createSMS($from, $result);
    }
} catch (PDOException $e) {
    Database::logError('sms_inbound', $e);
    IfByPhone_Util::createSMS(ADMIN_PHONE_NUM, 'SMS INBOUND ERROR: ' . $from . ': ' . $message);
}
Esempio n. 2
0
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);
Esempio n. 3
0
require 'com/Database.php';
//require ('com/IfByPhone_Util.php');
$job_id = $_POST['job_id'];
$p_t = $_POST['p_t'];
// If the job_id was skipped the IVR sends 'NA' and that will generate an error in the database call.
// This is caused by a hangup without entering information.  Check for this first and exit without logging an error.
if ($job_id == 'NA') {
    Database::logMessage('Hangup without job number with passthrough (' . $p_t . ')');
    exit;
}
try {
    $conn = Database::getDB();
    $results = $conn->query("CALL verify_job('{$job_id}',@job_name,@job_pk_id,@isValid)");
    $results = $conn->query("SELECT @job_name,@job_pk_id,@isValid");
    foreach ($results as $result) {
        if (!$result["@isValid"]) {
            // for invalid combination
            // 1/29/13 UPDATE: must pass through data because employee information has already been verified
            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>362471</id>\n\t\t\t\t\t\t\t<p_t>" . $p_t . " </p_t>\n\t\t\t\t\t\t</parameters>\n\t\t\t\t\t</action>";
        } else {
            // for valid combination
            $name_clean = IfByPhone_Util::removeInvalidChar($result["@job_name"]);
            $job_pk_id = $result["@job_pk_id"];
            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>362481</id>\n\t\t\t\t\t\t\t<user_parameters>\n\t\t\t\t\t\t\t\t<job_name>" . $name_clean . "</job_name>\n\t\t\t\t\t\t\t</user_parameters>\n\t\t\t\t\t\t\t<p_t>" . $p_t . "||job_id|" . $job_id . "||company|" . $name_clean . "||job_pk_id|" . $job_pk_id . " </p_t>\n\t\t\t\t\t\t</parameters>\n\t\t\t\t\t</action>";
        }
    }
} catch (PDOException $e) {
    Database::logError('verify_job', $e);
    Database::sendToIvrError();
}
$conn = null;
Esempio n. 4
0
            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>362191</id>\n\t\t\t\t\t\t</parameters>\n\t\t\t\t\t</action>";
        } else {
            if (!$result["@ivrAccess"] || !$result["@isActive"]) {
                // for IVR access not authorized
                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>397881</id>\n\t\t\t\t\t\t</parameters>\n\t\t\t\t\t</action>";
            } else {
                $employee_id = $result["@employee_pkID"];
                $employee_name = $result["@employee_name"];
                // for valid combination, check to see if there is an open job
                $open_event_check = $conn->query("CALL proc_checkForOpenEvent('{$employee_id}', @event_pk_id, @serviceCategory,\n\t\t\t@name, @survo, @job_pk_id)");
                $open_event_check = $conn->query("SELECT @event_pk_id, @serviceCategory, @name, @survo, @job_pk_id");
                // Create instance of Utility to clean data
                foreach ($open_event_check as $checks) {
                    if ($checks["@event_pk_id"] != "0") {
                        // this branch reflects a valid employee, with an open job which needs to be closed
                        // Remove invalid characters from the @name field
                        $name_clean = IfByPhone_Util::removeInvalidChar($checks["@name"]);
                        echo "<action>\n\t\t\t\t\t\t<app>survo</app>\n\t\t\t\t\t\t\t<parameters>\n\t\t\t\t\t\t\t\t<id>" . $checks["@survo"] . "</id>\n\t\t\t\t\t\t\t\t<user_parameters>\n\t\t\t\t\t\t\t\t\t<name>" . $name_clean . "</name>\n\t\t\t\t\t\t\t\t</user_parameters>\n\t\t\t\t\t\t\t\t<p_t>employee_id|" . $employee_id . "||event_id|" . $checks["@event_pk_id"] . "||serviceCategory|" . $checks["@serviceCategory"] . "||company|" . $name_clean . "||employee_name|" . $employee_name . "||job_pk_id|" . $checks["@job_pk_id"] . "</p_t>\n\t\t\t\t\t\t\t</parameters>\n\t\t\t\t\t\t</action>";
                    } else {
                        // this branch reflects a valid employee, with no jobs open
                        echo "<action>\n\t\t\t\t\t\t\t<app>survo</app>\n\t\t\t\t\t\t\t\t<parameters>\n\t\t\t\t\t\t\t\t\t<id>359731</id>\n\t\t\t\t\t\t\t\t\t<p_t>employee_id|" . $employee_id . "||employee_name|" . $employee_name . "</p_t>\n\t\t\t\t\t\t\t\t</parameters>\n\t\t\t\t\t\t\t</action>";
                    }
                }
            }
        }
    }
} catch (PDOException $e) {
    Database::logError('verify_employee', $e);
    Database::sendToIvrError();
}
$conn = null;
Esempio n. 5
0
    exit;
}
$caller_id = $_POST['caller_id'];
$timestamp = $_POST['timestamp'];
$session_id = $_POST['session_id'];
$employee_id = '';
$job_id = '';
$job_pk_id = '';
$job_name = '';
$employee_name = '';
$p_t = $_POST['p_t'];
// passthrough data = employee_id|value||job_id|value
$passthrough_array = IfByPhone_Util::processPassThrough($p_t);
$employee_id = $passthrough_array['employee_id'];
$job_id = $passthrough_array['job_id'];
$job_pk_id = $passthrough_array['job_pk_id'];
$job_name = $passthrough_array['company'];
$employee_name = $passthrough_array['employee_name'];
try {
    // create connection to DB
    $conn = Database::getDB();
    $query = "CALL start_event('{$servicecategory}','{$caller_id}','{$timestamp}','{$session_id}','{$employee_id}','{$job_id}')";
    $conn->query($query);
    // update successful - play event started message
    echo "<action>\n\t\t\t<app>survo</app>\n\t\t\t\t<parameters>\n\t\t\t\t\t<id>368911</id>\n\t\t\t\t</parameters>\n\t\t  </action>";
} catch (PDOException $e) {
    Database::logError('start_event', $e);
    Database::sendToIvrError();
}
$sms = IfByPhone_Util::smsIvrEvent($conn, $servicecategory, 'STARTED', $job_pk_id, $timestamp, $employee_name, $job_name);
Esempio n. 6
0
    $results = $conn->query("SELECT @isValid, @employee_pkID, @remotePunch, @isActive, @employee_phone");
    foreach ($results as $result) {
        if (!$result["@isValid"]) {
            // for invalid combination
            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>394171</id>\n\t\t\t\t\t\t</parameters>\n\t\t\t\t\t</action>";
        } else {
            $employee_id = $result["@employee_pkID"];
            $remote = $result["@remotePunch"];
            $active = $result["@isActive"];
            $phone = $result["@employee_phone"];
            // if the employee does not have access to this feature  SURVO ID: 394181
            if (!$remote || !$active) {
                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>394181</id>\n\t\t\t\t\t\t</parameters>\n\t\t\t\t\t</action>";
            } else {
                // if the employee is valid, and has access, record the timeclock punch, send to survo confirming punch
                $query_timeclock = "INSERT into timeclock (employee_pk_id, punchDateTime) VALUES ('" . $employee_id . "','" . $timestamp . "')";
                $conn->query($query_timeclock);
                echo "<action>\n\t\t\t\t<app>survo</app>\n\t\t\t\t\t<parameters>\n\t\t\t\t\t\t<id>394191</id>\n\t\t\t\t\t\t<p_t>employee_id|" . $employee_id . "</p_t>\n\t\t\t\t\t</parameters>\n\t\t\t\t</action>";
                if ($employee_id == '2' || $employee_id == '355') {
                    $time = strToTime($timestamp);
                    $msg = "Time recorded: " . date('n-j-Y g:i:s A', $time);
                    IfByPhone_Util::createSMS($phone, $msg);
                }
            }
        }
    }
} catch (PDOException $e) {
    Database::logError('tc_verify_employee', $e);
    Database::sendToIvrError();
}
$conn = null;
Esempio n. 7
0
if ($lawn == 'No' && $herbicid == 'No' && $fertilize == 'No' && $prune == 'No') {
    echo "<action>\n\t\t\t<app>survo</app>\n\t\t\t\t<parameters>\n\t\t\t\t\t<id>412231</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_endLawnJob('{$event_id}', '{$timestamp}', '{$caller_id}', '{$session_id}', '{$message}',\n\t'{$lawn}', '{$herbicide}', '{$fertilize}', '{$prune}', @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<app>survo</app>\n\t\t\t\t<parameters>\n\t\t\t\t\t<id>362811</id>\n\t\t\t\t\t<user_parameters>\n\t\t\t\t\t\t<conf>" . $conf . "</conf>\n\t\t\t\t\t</user_parameters>\n\t\t\t\t</parameters>\n\t\t\t</action>";
} catch (PDOException $e) {
    // Error handling
    $conn->rollBack();
    Database::logError('lawn', $e);
    Database::sendToIvrError();
}
// Send SMS message notifying job completion
$sms = IfByPhone_Util::smsIvrEvent($conn, 'lawn service', 'FINISHED', $job_id, $timestamp, $employee_name, $job_name);