by TroyD » Tue May 20, 2014 4:02 pm
This is what Im playing with to update Sugarcrm. Although I have a seperate table for phones, you can easily get the idea and modify. Also you should put some if ispost statements in there to handle things better. I am assuming here that I will always have a vaild post.. There is a better way to do this Im sure of it, but at least it will get you going down the path to updating CRM upon dispositions.. (Currently I am not getting a value posted for the security_phrase field but hope to resolve this soon)
This is for writing to MSSQL with php 5.3 You will have to use other methods for writing to db if you use mysql.. Google is your friend.. Basically change sqlsrv to mysql or mssql for pdo extensions..
(Hosting this on IIS by the way, you can host on apache if you like)
*******************Begin PHP Code **************
<?php
//Set Debug options overriding the PHP settings temporarily
ini_set('display_errors', 1);
error_reporting(E_ALL);
//Define SQL server connection
$serverName = "192.111.000.123";
$connectionInfo = array( "Database"=>"NEWCRM", "UID"=>"admin", "PWD"=>"yourpasswd" );
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
//Get status from dialer and store in variable
$phoneid = $_GET["security_phrase"];
$dial_status = $_GET["dispo"];
// Deal with the time and date and set into variable
date_default_timezone_set("UTC");
$timestamp = date("Y-m-d H:i:s", time());
// echo "$timestamp";
//Query to update CRM with posted data from dialer
$sql = "UPDATE phone_phones SET dial_status = '".$dial_status."', last_called_time = '".$timestamp."', dialer_call_attempts = dialer_call_attempts +1 Where id = '".$phoneid."'";
// If we have addl paramaters use this
//$params = array(1, "some data");
// Run the query if any errors then die.
$stmt = sqlsrv_query( $conn, $sql);
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
// Close the SQL connection.
sqlsrv_close( $conn);
// Log posted variables for debugging
file_put_contents( "dialogger.txt", print_r($_REQUEST, true));
?>
*********************** END PHP Code *******************
|3 Server - Cluster - WEB/DB/DIALER - ViciBox Install
|ASTERISK VER - Asterisk 11.25.1-vici
|AstGuiClient VERSION: 2.14-678a
|BUILD: 180613-0943