//
 $callStatus = NULL;
 $callName = NULL;
 $callDescription = "";
 if ($callDurationRaw > 10) {
     $callStatus = "Held";
     $callName = "Successfull call";
 } else {
     $callStatus = "Missed";
     $callName = sprintf("Failed call (%s) ", $e['Cause-txt']);
     $callDescription = "Missed/failed call\n";
     $callDescription .= "------------------\n";
     $callDescription .= sprintf(" %-20s : %-40s\n", "Caller ID", $rawData['callerID']);
 }
 // ** EXPERIMENTAL **
 $assoSugarObject = findSugarObjectByPhoneNumber($rawData['callerID']);
 $parentID = NULL;
 $parentType = NULL;
 if ($assoSugarObject && $assoSugarObject['type'] == 'Contacts') {
     $assocAccount = findAccountForContact($assoSugarObject['values']['id']);
     if ($assocAccount) {
         $parentType = 'Accounts';
         $parentID = $assocAccount;
     }
 }
 echo "! Call start was " . gmdate('Y-m-d H:i:s', $callStart) . "\n";
 //
 // ... on success also update entry in Calls module
 //
 print "# SQL update successfull, now updating record in /Calls/...\n";
 $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' => '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))));
示例#2
0
 print "Entered test mode!";
 mt_start();
 $obj = findSugarObjectByPhoneNumber("4102152497");
 $dur_oldMethod = mt_end();
 mt_start();
 $obj = findSugarBeanByPhoneNumber("4102152497");
 $dur_newMethod = mt_end();
 logLine("Old / New: {$dur_oldMethod}  {$dur_newMethod}");
 print_r(findSugarBeanByPhoneNumber("7607058888"));
 $obj = findSugarObjectByPhoneNumber("4108464565");
 print "findUserByAsteriskExtension(51) returned: " . findUserByAsteriskExtension("51") . "\n";
 print "findUserByAsteriskExtension(207) returned: " . findUserByAsteriskExtension("207") . "\n";
 print "findUserByAsteriskExtension(710) returned: " . findUserByAsteriskExtension('710') . "\n";
 findUserByAsteriskExtension('206');
 foreach ($phones as $currPhone) {
     $obj = findSugarObjectByPhoneNumber($currPhone);
     if ($obj === FALSE) {
         print "!!! DIDN'T FIND OBJ for {$currPhone}\n";
     } else {
         print " For {$currPhone} I found: " . $obj['values']['id'] . ' ' . $obj['values']['first_name'] . ' ' . $obj['values']['last_name'] . "\n";
     }
 }
 // Test for memory leaks...
 $cnt = 0;
 gc_enable();
 $GLOBALS['_transient']['static']['nusoap_base']->globalDebugLevel = 0;
 $lastMem = 0;
 while ($cnt++ < 1000) {
     $set_entry_params = array('session' => $soapSessionId, 'module_name' => 'Calls', 'name_value_list' => array(array('name' => 'name', 'value' => $mod_strings['YAAI']['CALL_AUTOMATIC_RECORD']), array('name' => 'status', 'value' => $mod_strings['YAAI']['CALL_IN_LIMBO']), array('name' => 'assigned_user_id', 'value' => '1')));
     $soapResult = $soapClient->call('set_entry', $set_entry_params);
     unset($set_entry_params);