blak3r / yaai

SugarCRM Asterisk integration
http://www.sugarforge.org/projects/yaai
GNU General Public License v3.0
81 stars 85 forks source link

Only Outbound Calls Through SugarCRM Logged & No Pop-up #216

Open odiefrom opened 8 years ago

odiefrom commented 8 years ago

This seems to be a common issue so far, so I've done some digging into why these features seemingly no longer work in SugarCRM 6.5 (I'm using SugarCRM CE 6.5.20 Build 1001).

Following up on Issue 212 and Issue 214, they both refer to "Handlebars not defined" in the JS console of the browser. Loading up any page within Sugar does indeed reveal this error appearing. The error claims to be searching for "handlebars.runtime.js", and causing a secondary error when it's not found at $SUGAR_ROOT/custom/modules/Asterisk/javascript/handlebars.runtime.js

After exploring around the files, I noticed that in $SUGAR_ROOT/custom/modules/Asterisk/javascript/offlineMode/, there's two files, handlebars-1.0.rc.1.js and handlebars.runtime-1.0.rc.1.js.

WORKAROUND FIX Copying handlebars.runtime-1.0.rc.1.js to $SUGAR_ROOT/custom/modules/Asterisk/javascript and then renaming the file to "handlebars.runtime.js" resolves the errors in the console. It appears to be an issue with the install process, or the correct file simply isn't included.

This still doesn't solve inbound call logging, and still doesn't trigger the popup. :(

I then executed "/etc/init.d/asterisk_logger stop", and then navigated to $SUGAR_ROOT/custom/modules/Asterisk/, and executed "php asteriskLogger.php". I then dialed in from an external line to the Asterisk line, navigated to my extension, and browsed the log stream on screen.

After every hangup event Asterisk generated, asteriskLogger.php then spat the following out:

PHP Notice: Undefined index: asterisk_only_log_calls_matching_user_extension in /var/sugar/custom/modules/Asterisk/asteriskLogger.php on line 722 +++ findCallByAsteriskId(1442878860.105851) ! Warning, results set was empty! [1442878860.XXXXXX] FAILED TO FIND A CALL (note: there are two hangups per call, so this might not be an error)

{NOTE: The line number in asteriskLogger.php for the error will most likely differ for anyone reading this. I have inserted comments into my copy, changing line count.} The line in question, for asterisk_only_log_calls_matching_user_extension is the following:

if( $sugar_config['asterisk_only_log_calls_matching_user_extension'] && (empty($direction['user_extension'] ) || !findUserByAsteriskExtension($direction['user_extension'])))

"asterisk_only_log_calls_matching_user_extension" is never set in the config or anywhere (NEEDS TO BE CONFIRMED). I've since replaced this with "False" just to suppress the error, as the point currently is just to get call logging working.

Additionally, searching the code for "findCallByAsteriskId" reveals a function at line 1602 (once again, line number will vary as my file has comments). The line "! Warning, results set was empty!" only emits to the log when a soap connection to the SugarCRM MySQL database is successful, but there are no matches for the provided Asterisk Id within table "asterisk_log".

Logging into MySQL on the SugarCRM server, and executing the following commands to return all entries in the queried table, not just the filtered results in asteriskLogger.php:

USE sugarcrm; SELECT * FROM asterisk_log;

...the table is entirely empty. 0 results on a wildcard search. So, what is most likely happening, is that asteriskLogger.php is never writing out to sugarcrm.asterisk_log.

I'm done looking in the code for now. Please, please feel free to continue this research and help solve these issues for all of us struggling to get this amazing software working again. If I find anything more or fix anymore "bugs" or problems, I'll post a follow up in this thread.

Note: If user AlertusTechnologiesLLC sees this issue and would like to comment - publicly or privately to me, I would be happy to assist in fixing these issues, even if it's just stored in an unofficial form like a pull request for others to use.

lomelisan commented 8 years ago

Hi @odiefrom did you get pop up working?

odiefrom commented 8 years ago

Hello @lomelisan !

Unfortunately, I did not progress past that point. Shortly after I made that post, work got extremely busy, so I stopped having an opportunity to dig into our system more and hunt down this feature. While I can't promise anything, I'm hoping to be able to get back into it soon-ish (maybe within a month? Maybe a couple months?)

Hopefully my initial post is enough of a starting point to get you looking in the right place. I would honestly recommend killing any asteriskLogger.php processes on your system, and then in your connection to the system run "php asteriskLogger.php" so that you can watch the output. Make an inbound call, and see if you can start tracking the program flow through the file. Try to find the section that's going to call a javascript file...or sends out some kind of system/status message? I'm not sure.

Best of luck!

spoddig commented 8 years ago

Hello, i use suitecrm 7.1 and i have all the troubels no Popups no logged, and the the errors from above. :) :) I think the Problem is only into the template. I i make a call icomming or outgoing from the Contactsite the call is comming in or out, but without Popoup or logging. With Errors in the Logs.

Now i make the same call and durring the Call i go to edit the contact. Now i have the popup i can make Memo and all works fine. I click to save and the Popup is going down. When i terminate the call bevor i click on save i have logging in the crm. When i terminate the call after save nothing.

And i found this empty Url in AsteriskJS.php Is this corectly

$fop_user = $GLOBALS['current_user']->asterisk_fop_user_c; $fop_pass = $GLOBALS['current_user']->asterisk_fop_pass_c; $fop_url = "";

Sorry for my english

home

edit

lomelisan commented 8 years ago

Hi @odiefrom thanks for your quick response. I have been dealing with the logger and i manage to solve the problem with inbound calls, i use a custom rest call in function findsugarbeanbyphone. Rightnow im trying to solve a 3 multiple record in calls module when i make an outbound call. Its a empty array i think.

lomelisan commented 8 years ago

Hi @spoddig, looking good what you are doing, i will like to discuss the progress i made so far, so we can work together in a solution, will you able to do that?

spoddig commented 8 years ago

@lomelisan Goog morning from Germany. I think the Problem for no Popups is in call-template.tmpl

(function() {
  var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['call-template.html'] = template(function (Handlebars,depth0,helpers,partials,data) {
  this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;

`

lomelisan commented 8 years ago

@spoddig email me please, i have some advance i would like to discuss with you!

lomelisan@gmail.com