Ejemplo n.º 1
0
function memoSave($call_record_id, $sugar_user_id, $phone_number, $description, $direction)
{
    $GLOBALS['log']->debug('memoSave' . $phone_number);
    if ($call_record_id) {
        $call = new Call();
        /*
        if (!empty($contact_id)) {
            $call->parent_id = $contact_id;
            $call->parent_type = 'Contacts';
        }
        */
        $call->retrieve($call_record_id);
        $call->description = $description;
        //!$name ? $call->name = getMemoName($call, $direction) : $call->name = $_REQUEST["name"];
        //$GLOBALS['log']->fatal('memoSave' . $phone_number);
        $call->name = getMemoName($call, $direction, $phone_number);
        $call->assigned_user_id = $sugar_user_id;
        $call->save();
        gitimg_log("notes-saved");
        // $GLOBALS['log']->fatal('callid_' . $call->id);
    }
}
Ejemplo n.º 2
0
     }
     setRelationshipBetweenCallAndBean($callRecord['sweet']['id'], $beanType, $beanID);
     // This might not be needed... forget if service does this already.
     if ($beanType == "Accounts") {
         $parentType = "Accounts";
         $parentID = $beanID;
     }
     echo "! Call start was " . gmdate('Y-m-d H:i:s', $callStart) . "\n";
     //
     // ... on success also update entry in Calls module
     //
     logLine(" Updating record in /Calls/ id=" . $callRecord['sweet']['id'] . "...\n");
     //print_r($callRecord);
     logLine(" NAME: " . $callRecord['sweet']['name'] . "\n");
     logLine(" DESCRIPTION: " . $callRecord['sweet']['description'] . "\n");
     gitimg_log("call-in");
     if ($sugar_config['asterisk_logger_sql_mode']) {
         $query = "UPDATE calls, calls_cstm\n                                              SET name='{$callName}',\n                                              duration_hours='{$callDurationHours}',\n                                              duration_minutes='{$callDurationMinutes}',\n                                              status='{$callStatus}',\n                                              description='{$callDescription}',\n                                              asterisk_caller_id_c='{$rawData['callerID']}',\n                                              asterisk_call_id_c='{$rawData['asterisk_id']}',\n                                              asterisk_user_ext_c='{$direction['user_extension']}',\n                                              asterisk_inbound_ext_c='{$direction['inbound_extension']}',\n                                              parent_type='{$parentType}',\n                                              parent_id='{$parentID}',\n                                              assigned_user_id='{$assignedUser}'\n                                              WHERE calls.id = '{$callRecord['sweet']['id']}'\n                                              AND calls_cstm.id_c = '{$callRecord['sweet']['id']}'";
         db_checked_query($query);
     } else {
         $soapResult = $soapClient->call('set_entry', array('session' => $soapSessionId, 'module_name' => 'Calls', 'name_value_list' => array(array('name' => 'id', 'value' => $callRecord['sweet']['id']), array('name' => 'name', 'value' => $callName), array('name' => 'duration_hours', 'value' => $callDurationHours), array('name' => 'duration_minutes', 'value' => $callDurationMinutes), array('name' => 'status', 'value' => $callStatus), array('name' => 'description', 'value' => $callDescription), array('name' => 'asterisk_caller_id_c', 'value' => $rawData['callerID']), array('name' => 'asterisk_call_id_c', 'value' => $rawData['asterisk_id']), array('name' => 'asterisk_user_ext_c', 'value' => $direction['user_extension']), array('name' => 'asterisk_inbound_ext_c', 'value' => $direction['inbound_extension']), array('name' => 'date_start', 'value' => gmdate('Y-m-d H:i:s', $callStart)), array('name' => 'parent_type', 'value' => $parentType), array('name' => 'parent_id', 'value' => $parentID), array('name' => 'assigned_user_id', 'value' => $assignedUser))));
     }
 }
 // End Inbound Case
 // In case of multiple extensions when a call is not answered, every extensions produces a failed call record,
 // this will keep the first of those records but delete the rest. (LIMIT 1,999999999999 in query returns all but first match.)
 $query = "SELECT asterisk_id FROM asterisk_log WHERE asterisk_id='{$id}'";
 $result = db_checked_query($query);
 $result_id = db_fetchAssoc($result);
 logLine("Cleaning up Failed Calls part1, asterisk_id = " . $result_id['asterisk_id'] . "\n");
 $query = "SELECT call_record_id FROM asterisk_log WHERE asterisk_id='" . $result_id['asterisk_id'] . "' ORDER BY id ASC";
Ejemplo n.º 3
0
    fputs($socket, "Channel: " . $channel . "\r\n");
    fputs($socket, "Context: " . $context . "\r\n");
    fputs($socket, "Exten: " . $number . "\r\n");
    fputs($socket, "Priority: 1\r\n");
    fputs($socket, "Callerid:" . $_REQUEST['phoneNr'] . "\r\n");
    fputs($socket, "Account: CLICKTODIAL-" . formatPhoneNumberToE164($_REQUEST['phoneNr']) . "-" . $_REQUEST['module'] . "-" . $_REQUEST['contactId'] . "\r\n");
    fputs($socket, "Variable: CALLERID(number)=" . $extension . "\r\n\r\n");
    // You will not get an originate response unless you wait for the phone to be answered... so it's impractical to wait.
    // but, if there is a permission issue it will fail almost immediately with permission denied.
    $result = ReadResponse($socket, 10000000);
    echo "Originate Response: " . $result . "\n";
    fputs($socket, "Action: Logoff\r\n\r\n");
    fputs($socket, "\r\n");
    $result = ReadResponse($socket);
    echo "Logout Response: " . $result;
    gitimg_log("click-to-dial");
    //var_dump($result);
    //var_dump($channel);
    //var_dump($context);
    //var_dump($number);
    //sleep(1);
    // close socket
    fclose($socket);
}
/**
 * Read the socket response
 *
 * @param object $socket Socket
 * @param int $timeout in uS, default is 500000 (1/2 a second)
 *
 * @return array Array of socket responses