├── .gitignore ├── README.md └── sugarcrm ├── bootstrap └── bootstrap.php ├── design └── sugarcrmtheme │ ├── js │ └── sugarcrm.js │ └── tpl │ ├── lhchat │ └── chat_tabs │ │ ├── extension_chat_tab_content_multiinclude.tpl.php │ │ └── extension_chat_tab_multiinclude.tpl.php │ ├── lhsugarcrm │ ├── configuration.tpl.php │ ├── configuration_title.tpl.php │ ├── createorupdatelead.tpl.php │ ├── getleadfields.tpl.php │ ├── index.tpl.php │ ├── index_title.tpl.php │ ├── sugarcrm_chat_tab_title.tpl.php │ ├── sugarcrm_tab_enabled_pre.tpl.php │ └── sugarcrm_title.tpl.php │ └── pagelayouts │ └── parts │ ├── modules_menu │ └── extension_module_multiinclude.tpl.php │ ├── page_head_js_extension_multiinclude.tpl.php │ └── top_menu_extension_module_multiinclude.tpl.php ├── doc └── readme.txt ├── modules └── lhsugarcrm │ ├── configuration.php │ ├── createorupdatelead.php │ ├── getleadfields.php │ ├── index.php │ ├── module.php │ └── updateleadfields.php └── translations └── lt_LT └── translation.ts /.gitignore: -------------------------------------------------------------------------------- 1 | sugarcrm/modules/lhsugarcrm/soap.wsdl 2 | .idea -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Author: Remigijus Kiminas 2 | Version: 1.0 3 | 4 | This module brings tight integration SugarCRM with Live Helper Chat 5 | 6 | Requirements: 7 | a. PHP Soap module 8 | b. Live Helper Chat since 2.30v 9 | 10 | Install: 11 | * Put sugarcrm on your server extensions folder. 12 | * Enable extension in settings.ini.php file. 13 | 'extensions' => 14 | array ( 15 | 'sugarcrm', 16 | ), 17 | * Clean cache from back office. 18 | * From top menu go to Extra Modules => SugarCRM 19 | * Just configure and use 20 | 21 | In chat window will be new tab SugarCRM there wou can create/update existing Chat Lead -------------------------------------------------------------------------------- /sugarcrm/bootstrap/bootstrap.php: -------------------------------------------------------------------------------- 1 | listen('chat.chat_offline_request', array( 17 | $this, 18 | 'offlineRequest' 19 | )); 20 | } 21 | 22 | public function __get($var) 23 | { 24 | switch ($var) { 25 | 26 | case 'settings': 27 | $this->settings = erLhcoreClassModelChatConfig::fetch('sugarcrm_data')->data; 28 | return $this->settings; 29 | break; 30 | 31 | default: 32 | ; 33 | break; 34 | } 35 | } 36 | 37 | public function offlineRequest($params) 38 | { 39 | if (isset($this->settings['sugarcrm_offline_lead']) && $this->settings['sugarcrm_offline_lead'] == true && isset($this->settings['sugarcrm_enabled']) && $this->settings['sugarcrm_enabled'] == true) { 40 | $chat = $params['chat']; 41 | $inputData = $params['input_data']; 42 | 43 | $soapclient = new SoapClient($this->settings['wsdl_address']); 44 | 45 | $result_array = $soapclient->login(array( 46 | 'user_name' => $this->settings['wsdl_username'], 47 | 'password' => $this->settings['wsdl_password'], 48 | 'version' => '0.1' 49 | ), 'soaplhcsugarcrm'); 50 | $session_id = $result_array->id; 51 | $user_guid = $soapclient->get_user_id($session_id); 52 | 53 | $leadData = array( 54 | array( 55 | 'name' => 'last_name', 56 | 'value' => $chat->nick 57 | ), 58 | array( 59 | 'name' => 'department', 60 | 'value' => (string) $chat->department 61 | ), 62 | array( 63 | 'name' => 'status', 64 | 'value' => 'New' 65 | ), 66 | array( 67 | 'name' => 'phone_work', 68 | 'value' => (string) $chat->phone 69 | ), 70 | array( 71 | 'name' => 'email1', 72 | 'value' => (string) $chat->email 73 | ), 74 | array( 75 | 'name' => 'lead_source', 76 | 'value' => 'Web Site' 77 | ), 78 | array( 79 | 'name' => 'website', 80 | 'value' => (string) $chat->referrer 81 | ), 82 | array( 83 | 'name' => 'lead_source_description', 84 | 'value' => PHP_EOL.$inputData->question."\n\n".erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module', 'Offline form request') 85 | ), 86 | array( 87 | 'name' => 'assigned_user_id', 88 | 'value' => $user_guid 89 | ) 90 | ); 91 | 92 | $chatAdditionalData = $chat->additional_data_array; 93 | 94 | // Add custom fields if required 95 | if (isset($this->settings['lead_extra_fields']) && is_array($this->settings['lead_extra_fields']) && ! empty($this->settings['lead_extra_fields']) && is_array($chatAdditionalData) && ! empty($chatAdditionalData)) { 96 | 97 | $fieldsMappingSugar = array(); 98 | foreach ($this->settings['lead_extra_fields'] as $data) { 99 | if (isset($data['lhcfield']) && ! empty($data['lhcfield'])) { 100 | $fieldsMappingSugar[$data['lhcfield']] = $data['sugarcrm']; 101 | } 102 | } 103 | 104 | foreach ($chatAdditionalData as $addItem) { 105 | $fieldIdentifier = isset($addItem->identifier) ? $addItem->identifier : str_replace(' ', '_', $addItem->key); 106 | if (key_exists($fieldIdentifier, $fieldsMappingSugar)) { 107 | $leadData[] = array( 108 | 'name' => $fieldsMappingSugar[$fieldIdentifier], 109 | 'value' => $addItem->value 110 | ); 111 | } 112 | } 113 | } 114 | 115 | $result = $soapclient->set_entry($session_id, 'Leads', $leadData); 116 | } 117 | } 118 | 119 | /*** 120 | * Fetches single entry data 121 | * 122 | * @param string $leadId 123 | */ 124 | public function getLeadById($leadId) { 125 | 126 | $soapclient = new SoapClient($this->settings['wsdl_address']); 127 | 128 | $result_array = $soapclient->login(array( 129 | 'user_name' => $this->settings['wsdl_username'], 130 | 'password' => $this->settings['wsdl_password'], 131 | 'version' => '0.1' 132 | ), 'soaplhcsugarcrm'); 133 | 134 | $session_id = $result_array->id; 135 | 136 | $result = $soapclient->get_entry( $session_id, "Leads", $leadId); 137 | 138 | if (isset($result->entry_list[0])) { 139 | return $result->entry_list[0]; 140 | } 141 | 142 | return false; 143 | } 144 | 145 | public function getFieldsForUpdate() 146 | { 147 | return array( 148 | 'phone_work' => array( 149 | 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module', 'Phone work') 150 | ), 151 | 'phone_home' => array( 152 | 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module','Phone home') 153 | ), 154 | 'phone_mobile' => array( 155 | 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module','Phone mobile') 156 | ), 157 | 'date_entered' => array( 158 | 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module','Entered'), 159 | 'disabled' => true 160 | ), 161 | 'date_modified' => array( 162 | 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module','Modified'), 163 | 'disabled' => true 164 | ), 165 | 'description' => array( 166 | 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module','Description'), 167 | 'type' => 'textarea' 168 | ), 169 | 'first_name' => array( 170 | 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module','First name') 171 | ), 172 | 'last_name' => array( 173 | 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module','Last name') 174 | ), 175 | 'title' => array( 176 | 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module','Title') 177 | ), 178 | 'email1' => array( 179 | 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module','E-mail') 180 | ), 181 | 'website' => array( 182 | 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module','Website') 183 | ), 184 | 'lead_source_description' => array( 185 | 'title' => 'Lead source description','type' => 'textarea' 186 | ) 187 | ); 188 | } 189 | 190 | public function doUpdateLeadId($leadId) { 191 | 192 | $soapclient = new SoapClient($this->settings['wsdl_address']); 193 | 194 | $result_array = $soapclient->login(array( 195 | 'user_name' => $this->settings['wsdl_username'], 196 | 'password' => $this->settings['wsdl_password'], 197 | 'version' => '0.1' 198 | ), 'soaplhcsugarcrm'); 199 | 200 | $session_id = $result_array->id; 201 | 202 | $leadData = array(); 203 | $leadData[] = array( 204 | 'name' => 'id', 205 | 'value' => $leadId 206 | ); 207 | 208 | $leadFields = $this->getFieldsForUpdate(); 209 | 210 | foreach ($leadFields as $key => $field) { 211 | if (!isset($field['disabled']) || $field['disabled'] == false){ 212 | $leadData[] = array( 213 | 'name' => $key, 214 | 'value' => isset($_POST[$key]) ? $_POST[$key] : '' 215 | ); 216 | } 217 | } 218 | 219 | $result = $soapclient->set_entry($session_id, 'Leads', $leadData); 220 | 221 | if ($result->id != -1) { 222 | return $this->getLeadById($result->id); 223 | } 224 | 225 | return false; 226 | } 227 | 228 | /*** 229 | * $sugarcrm = erLhcoreClassModule::getExtensionInstance('erLhcoreClassExtensionSugarcrm'); 230 | * $sugarcrm->searchByModule(array('leads.phone_work' => '')); 231 | * */ 232 | public function searchByModule($searchParams = array(), $module = 'Leads') 233 | { 234 | 235 | $soapclient = new SoapClient($this->settings['wsdl_address']); 236 | 237 | $result_array = $soapclient->login(array( 238 | 'user_name' => $this->settings['wsdl_username'], 239 | 'password' => $this->settings['wsdl_password'], 240 | 'version' => '0.1' 241 | ), 'soaplhcsugarcrm'); 242 | 243 | $session_id = $result_array->id; 244 | 245 | $db = ezcDbInstance::get(); 246 | 247 | // format filter 248 | $filterSQLParams = array(); 249 | foreach ($searchParams as $field => $param) { 250 | $filterSQLParams[] = $field.' = '.$db->quote($param); 251 | } 252 | 253 | $results = $soapclient->get_entry_list( $session_id, $module, '('.implode(" OR ", $filterSQLParams).')', "", 0, array(), 1 ); 254 | 255 | if ($results->result_count == 1) 256 | { 257 | return $results->entry_list[0]; 258 | } 259 | 260 | return false; 261 | } 262 | 263 | /** 264 | * Creates a demo lead from SugarCRM extension configuration window 265 | * 266 | * @return unknown 267 | */ 268 | public function createDemoLead() 269 | { 270 | 271 | $soapclient = new SoapClient($this->settings['wsdl_address']); 272 | 273 | $result_array = $soapclient->login(array( 274 | 'user_name' => $this->settings['wsdl_username'], 275 | 'password' => $this->settings['wsdl_password'], 276 | 'version' => '0.1' 277 | ), 'soaplhcsugarcrm'); 278 | $session_id = $result_array->id; 279 | $user_guid = $soapclient->get_user_id($session_id); 280 | 281 | // $LeadFields = $soapclient->get_module_fields($session_id, 'Leads'); print_r($LeadFields); 282 | 283 | $result = $soapclient->set_entry($session_id, 'Leads', array( 284 | array( 285 | 'name' => 'last_name', 286 | 'value' => 'Live Helper Chat' 287 | ), 288 | array( 289 | 'name' => 'department', 290 | 'value' => 'Demo departament' 291 | ), 292 | array( 293 | 'name' => 'status', 294 | 'value' => 'New' 295 | ), 296 | array( 297 | 'name' => 'phone_work', 298 | 'value' => 'Demo Phone' 299 | ), 300 | array( 301 | 'name' => 'primary_address_city', 302 | 'value' => 'Demo City' 303 | ), 304 | array( 305 | 'name' => 'account_name', 306 | 'value' => 'Demo account name' 307 | ), 308 | array( 309 | 'name' => 'email1', 310 | 'value' => 'demo@example.com' 311 | ), 312 | array( 313 | 'name' => 'lead_source', 314 | 'value' => 'Web Site' 315 | ), 316 | array( 317 | 'name' => 'lead_source_description', 318 | 'value' => 'Your lead was successfully created' 319 | ), 320 | array( 321 | 'name' => 'assigned_user_id', 322 | 'value' => $user_guid 323 | ) 324 | )); 325 | 326 | return $result; 327 | } 328 | 329 | /** 330 | * Creates a general Lead by provided arguments 331 | * */ 332 | public function createLeadByArray($params, $leadId = false) { 333 | if ($this->settings['sugarcrm_enabled'] == true) { 334 | $soapclient = new SoapClient($this->settings['wsdl_address']); 335 | 336 | $result_array = $soapclient->login(array( 337 | 'user_name' => $this->settings['wsdl_username'], 338 | 'password' => $this->settings['wsdl_password'], 339 | 'version' => '0.1' 340 | ), 'soaplhcsugarcrm'); 341 | $session_id = $result_array->id; 342 | $user_guid = $soapclient->get_user_id($session_id); 343 | 344 | $leadData = array( 345 | array( 346 | 'name' => 'status', 347 | 'value' => 'New' 348 | ), 349 | array( 350 | 'name' => 'assigned_user_id', 351 | 'value' => $user_guid 352 | ) 353 | ); 354 | 355 | if ($leadId !== false) { 356 | $leadData[] = array( 357 | 'name' => 'id', 358 | 'value' => $leadId 359 | ); 360 | } 361 | 362 | foreach ($params as $additionalField) { 363 | $leadData[] = $additionalField; 364 | } 365 | 366 | $result = $soapclient->set_entry($session_id, 'Leads', $leadData); 367 | 368 | return $result; 369 | } else { 370 | throw new Exception('SugarCRM extension is not enabled'); 371 | } 372 | } 373 | 374 | /** 375 | * Creates a lead from chat object 376 | * 377 | * @param unknown $chat 378 | * @throws Exception 379 | * @return unknown 380 | */ 381 | public function createLeadByChat(& $chat) 382 | { 383 | if ($this->settings['sugarcrm_enabled'] == true) { 384 | 385 | // Search for existing leads only if lead does not exists and phone is not empty 386 | if ((!isset($chat->chat_variables_array['sugarcrm_lead_id']) || $chat->chat_variables_array['sugarcrm_lead_id'] == '') && $chat->phone != '') { 387 | $leadExisting = $this->searchByModule(array('leads.phone_work' => $chat->phone)); 388 | if ($leadExisting !== false) { 389 | 390 | // Store associated lead data 391 | $chat->chat_variables_array['sugarcrm_lead_id'] = $leadExisting->id; 392 | $chat->chat_variables = json_encode($chat->chat_variables_array); 393 | $chat->saveThis(); 394 | 395 | // Return founded lead 396 | return $leadExisting; 397 | } 398 | } 399 | 400 | // Proceed normal workflow if lead not found 401 | $soapclient = new SoapClient($this->settings['wsdl_address']); 402 | 403 | $result_array = $soapclient->login(array( 404 | 'user_name' => $this->settings['wsdl_username'], 405 | 'password' => $this->settings['wsdl_password'], 406 | 'version' => '0.1' 407 | ), 'soaplhcsugarcrm'); 408 | $session_id = $result_array->id; 409 | $user_guid = $soapclient->get_user_id($session_id); 410 | 411 | $leadData = array( 412 | array( 413 | 'name' => 'last_name', 414 | 'value' => $chat->nick 415 | ), 416 | array( 417 | 'name' => 'department', 418 | 'value' => (string) $chat->department 419 | ), 420 | array( 421 | 'name' => 'status', 422 | 'value' => 'New' 423 | ), 424 | array( 425 | 'name' => 'phone_work', 426 | 'value' => (string) $chat->phone 427 | ), 428 | array( 429 | 'name' => 'email1', 430 | 'value' => (string) $chat->email 431 | ), 432 | array( 433 | 'name' => 'lead_source', 434 | 'value' => 'Web Site' 435 | ), 436 | array( 437 | 'name' => 'website', 438 | 'value' => (string) $chat->referrer 439 | ), 440 | array( 441 | 'name' => 'lead_source_description', 442 | 'value' => (string) $chat->remarks."\n\n=====\n".erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module', 'Chat ID').' - '.$chat->id 443 | ), 444 | array( 445 | 'name' => 'assigned_user_id', 446 | 'value' => $user_guid 447 | ) 448 | ); 449 | 450 | $storeLead = true; 451 | 452 | if (isset($chat->chat_variables_array['sugarcrm_lead_id']) && $chat->chat_variables_array['sugarcrm_lead_id'] != '') { 453 | $leadData[] = array( 454 | 'name' => 'id', 455 | 'value' => $chat->chat_variables_array['sugarcrm_lead_id'] 456 | ); 457 | $storeLead = false; 458 | } 459 | 460 | $chatAdditionalData = $chat->additional_data_array; 461 | 462 | // Add custom fields if required 463 | if (isset($this->settings['lead_extra_fields']) && is_array($this->settings['lead_extra_fields']) && ! empty($this->settings['lead_extra_fields']) && is_array($chatAdditionalData) && ! empty($chatAdditionalData)) { 464 | 465 | $fieldsMappingSugar = array(); 466 | foreach ($this->settings['lead_extra_fields'] as $data) { 467 | if (isset($data['lhcfield']) && ! empty($data['lhcfield'])) { 468 | $fieldsMappingSugar[$data['lhcfield']] = $data['sugarcrm']; 469 | } 470 | } 471 | 472 | foreach ($chatAdditionalData as $addItem) { 473 | $fieldIdentifier = isset($addItem->identifier) ? $addItem->identifier : str_replace(' ', '_', $addItem->key); 474 | if (key_exists($fieldIdentifier, $fieldsMappingSugar)) { 475 | $leadData[] = array( 476 | 'name' => $fieldsMappingSugar[$fieldIdentifier], 477 | 'value' => $addItem->value 478 | ); 479 | } 480 | } 481 | } 482 | 483 | $result = $soapclient->set_entry($session_id, 'Leads', $leadData); 484 | 485 | if ($result->id != - 1 && $storeLead == true) { 486 | $chat->chat_variables_array['sugarcrm_lead_id'] = $result->id; 487 | $chat->chat_variables = json_encode($chat->chat_variables_array); 488 | $chat->saveThis(); 489 | } 490 | 491 | if ($result->id == -1) { 492 | throw new Exception('Lead could not be created'); 493 | } 494 | 495 | return $result; 496 | 497 | } else { 498 | throw new Exception('SugarCRM extension is not enabled'); 499 | } 500 | } 501 | 502 | /** 503 | * Validates lead settings 504 | * 505 | * @param unknown $settings 506 | * @return multitype:NULL 507 | */ 508 | public static function validateSettings(& $settings) 509 | { 510 | $definition = array( 511 | 'WSDLAddress' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 512 | 'WSDLUsername' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 513 | 'WSDLPassword' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 514 | 'SugarCRMEnabled' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 515 | 'SugarCRMCreateFromOffline' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 516 | 'SugarCRMLHCIdentifier' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 517 | 'SugarCRMLeadField' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY) 518 | ); 519 | 520 | $form = new ezcInputForm(INPUT_POST, $definition); 521 | 522 | $Errors = array(); 523 | 524 | if (! $form->hasValidData('WSDLAddress') || $form->WSDLAddress == '') { 525 | $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module', 'Please enter SugarCRM WSDL address'); 526 | } else { 527 | $settings['wsdl_address'] = $form->WSDLAddress; 528 | } 529 | 530 | if ($form->hasValidData('SugarCRMEnabled') && $form->SugarCRMEnabled == true) { 531 | $settings['sugarcrm_enabled'] = true; 532 | } else { 533 | $settings['sugarcrm_enabled'] = false; 534 | } 535 | 536 | if ($form->hasValidData('SugarCRMCreateFromOffline') && $form->SugarCRMCreateFromOffline == true) { 537 | $settings['sugarcrm_offline_lead'] = true; 538 | } else { 539 | $settings['sugarcrm_offline_lead'] = false; 540 | } 541 | 542 | if (! $form->hasValidData('WSDLUsername') || $form->WSDLUsername == '') { 543 | $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module', 'Please enter SugarCRM username'); 544 | } else { 545 | $settings['wsdl_username'] = $form->WSDLUsername; 546 | } 547 | 548 | if (! $form->hasValidData('WSDLPassword') || $form->WSDLPassword == '') { 549 | if ($settings['wsdl_password'] == '') { 550 | $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module', 'Please enter SugarCRM password'); 551 | } 552 | } else { 553 | if ($form->WSDLPassword != '') { 554 | $settings['wsdl_password'] = md5($form->WSDLPassword); 555 | } 556 | } 557 | 558 | if ($form->hasValidData('SugarCRMLHCIdentifier') && ! empty($form->SugarCRMLHCIdentifier)) { 559 | $fieldsData = array(); 560 | 561 | foreach ($form->SugarCRMLHCIdentifier as $key => $lhcFieldIdentifier) { 562 | $fieldsData[] = array( 563 | 'lhcfield' => $lhcFieldIdentifier, 564 | 'sugarcrm' => $form->SugarCRMLeadField[$key] 565 | ); 566 | } 567 | 568 | $settings['lead_extra_fields'] = $fieldsData; 569 | } else { 570 | $settings['lead_extra_fields'] = array(); 571 | } 572 | 573 | return $Errors; 574 | } 575 | } -------------------------------------------------------------------------------- /sugarcrm/design/sugarcrmtheme/js/sugarcrm.js: -------------------------------------------------------------------------------- 1 | var sugarcrm = { 2 | createOrUpdate : function(btn,chat_id) { 3 | var $btn = btn.button('loading'); 4 | 5 | $.postJSON(WWW_DIR_JAVASCRIPT + 'sugarcrm/createorupdatelead/' + chat_id, function(data){ 6 | $('#sugar-crm-lead-info-'+chat_id).html(data.result); 7 | $btn.button('reset'); 8 | 9 | if (data.error == false) { 10 | sugarcrm.loadLead(data.lead_id); 11 | } 12 | }); 13 | }, 14 | loadLead : function(lead_id) { 15 | if (lead_id != '') { 16 | if ($('#'+lead_id).html() == '') { 17 | $.getJSON(WWW_DIR_JAVASCRIPT + 'sugarcrm/getleadfields/' + lead_id, function(data){ 18 | $('#'+lead_id).html(data.result); 19 | }); 20 | } 21 | } 22 | }, 23 | updateLeadFields : function(lead_id,form) { 24 | if (lead_id != '') { 25 | var $btn = $('.btn-sugarcrm').button('loading'); 26 | $.postJSON(WWW_DIR_JAVASCRIPT + 'sugarcrm/updateleadfields/' + lead_id, form.serialize(), function(data){ 27 | $('#'+lead_id).html(data.result); 28 | $btn.button('reset'); 29 | }); 30 | } 31 | return false; 32 | } 33 | }; -------------------------------------------------------------------------------- /sugarcrm/design/sugarcrmtheme/tpl/lhchat/chat_tabs/extension_chat_tab_content_multiinclude.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | hasAccessTo('lhsugarcrm','use') && $sugarcrm_tab_enabled_pre == true) : ?> 4 | 5 | settings; ?> 6 | 7 |
8 | 9 | chat_variables_array['sugarcrm_lead_id']) || $chat->chat_variables_array['sugarcrm_lead_id'] == '') : ?> 10 | 13 | 14 | 15 |
16 | 17 |
18 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /sugarcrm/design/sugarcrmtheme/tpl/lhchat/chat_tabs/extension_chat_tab_multiinclude.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | hasAccessTo('lhsugarcrm','use') && $sugarcrm_tab_enabled_pre == true) : ?> 3 | settings; ?> 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /sugarcrm/design/sugarcrmtheme/tpl/lhsugarcrm/configuration.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | getTranslation('sugarcrm/module','Settings updated'); ?> 10 | 11 | 12 | 13 | getTranslation('sugarcrm/module','Lead was succesfully created')?> 14 | 15 | id != -1) : ?> 16 | 17 | getTranslation('sugarcrm/module', 'Failed to create a lead!'))?> 18 | 19 | 20 | 21 |
22 | 23 | 24 |
25 | 26 | 30 | 31 | 32 |
33 |
34 | 35 |
36 | 37 |
38 | 39 |
40 | 41 |
42 | 43 |
44 | 45 |
46 | 47 |
48 |
49 |
50 | 51 |
52 |
53 |
54 |
55 | 56 | 57 |
58 |
59 |
60 |
61 | 62 |
63 |

getTranslation('sugarcrm/module','Additional fields identifiers mapping to Lead field names')?>

64 |
65 | 66 |
67 |
68 |
69 |
70 | 71 | 72 |
73 |
74 | 75 | 76 |
77 |
78 |
79 |
80 | 81 |
82 |
83 | 84 |
85 |
86 | 87 |
88 | 89 |
90 | 91 |
-------------------------------------------------------------------------------- /sugarcrm/design/sugarcrmtheme/tpl/lhsugarcrm/configuration_title.tpl.php: -------------------------------------------------------------------------------- 1 |

getTranslation('sugarcrm/module', 'SugarCRM integration configuration'); ?>

-------------------------------------------------------------------------------- /sugarcrm/design/sugarcrmtheme/tpl/lhsugarcrm/createorupdatelead.tpl.php: -------------------------------------------------------------------------------- 1 | id == -1) : ?> 2 | 5 | id != -1) : ?> 6 | 12 | 13 | 14 | chat_variables_array['sugarcrm_lead_id'])) : ?> 15 | 21 |
22 | 23 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /sugarcrm/design/sugarcrmtheme/tpl/lhsugarcrm/getleadfields.tpl.php: -------------------------------------------------------------------------------- 1 | getFieldsForUpdate(); 4 | 5 | // Set values 6 | foreach ($lead->name_value_list as $nameValue){ 7 | if (key_exists($nameValue->name, $fieldsDisplay)) { 8 | $fieldsDisplay[$nameValue->name]['value'] = $nameValue->value; 9 | } 10 | } 11 | 12 | if ($lead !== false) : ?> 13 | 14 | 15 | 21 | 22 | 23 |
24 |
25 | $nameValue) : ?> 26 |
27 |
28 | 29 | 30 | 31 | 32 | disabled="disabled" type="text" name="" value="" /> 33 | 34 |
35 |
36 | 37 |
38 | 39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /sugarcrm/design/sugarcrmtheme/tpl/lhsugarcrm/index.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /sugarcrm/design/sugarcrmtheme/tpl/lhsugarcrm/index_title.tpl.php: -------------------------------------------------------------------------------- 1 |

SugarCRM

-------------------------------------------------------------------------------- /sugarcrm/design/sugarcrmtheme/tpl/lhsugarcrm/sugarcrm_chat_tab_title.tpl.php: -------------------------------------------------------------------------------- 1 |
  • SugarCRM
  • -------------------------------------------------------------------------------- /sugarcrm/design/sugarcrmtheme/tpl/lhsugarcrm/sugarcrm_tab_enabled_pre.tpl.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sugarcrm/design/sugarcrmtheme/tpl/lhsugarcrm/sugarcrm_title.tpl.php: -------------------------------------------------------------------------------- 1 | SugarCRM -------------------------------------------------------------------------------- /sugarcrm/design/sugarcrmtheme/tpl/pagelayouts/parts/modules_menu/extension_module_multiinclude.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | hasAccessTo('lhsugarcrm','configure') && $sugarcrm_tab_enabled_pre == true) : ?> 3 |
  • 4 | -------------------------------------------------------------------------------- /sugarcrm/design/sugarcrmtheme/tpl/pagelayouts/parts/page_head_js_extension_multiinclude.tpl.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sugarcrm/design/sugarcrmtheme/tpl/pagelayouts/parts/top_menu_extension_module_multiinclude.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | hasAccessTo('lhsugarcrm','configure') || (isset($hasExtensionModule) ? $hasExtensionModule : false);?> 4 | -------------------------------------------------------------------------------- /sugarcrm/doc/readme.txt: -------------------------------------------------------------------------------- 1 | Author: Remigijus Kiminas 2 | Version: 1.0 3 | 4 | This module brings tight integration SugarCRM with Live Helper Chat 5 | 6 | Requirements: 7 | a. PHP Soap module 8 | b. Live Helper Chat since 2.30v 9 | 10 | Install: 11 | 1. Put sugarcrm on your server extensions folder. 12 | 2. Enable extension in settings.ini.php file. 13 | 'extensions' => 14 | array ( 15 | 'sugarcrm', 16 | ), 17 | 4. Clean cache from back office. 18 | 5. From top menu go to Extra Modules => SugarCRM 19 | 6. Just configure and use 20 | 21 | In chat window will be new tab SugarCRM there wou can create/update existing Chat Lead -------------------------------------------------------------------------------- /sugarcrm/modules/lhsugarcrm/configuration.php: -------------------------------------------------------------------------------- 1 | data; 6 | 7 | if (ezcInputForm::hasPostData()) { 8 | $Errors = erLhcoreClassExtensionSugarcrm::validateSettings($data); 9 | 10 | if (count($Errors) == 0) { 11 | $dataObject->hidden = 1; 12 | $dataObject->identifier = 'sugarcrm_data'; 13 | $dataObject->type = 0; 14 | $dataObject->explain = 'SugarCRM extension configuration data'; 15 | $dataObject->value = serialize($data); 16 | $dataObject->saveThis(); 17 | 18 | if (isset($_POST['StoreAndTest'])){ 19 | $extension = erLhcoreClassModule::getExtensionInstance('erLhcoreClassExtensionSugarcrm'); 20 | try { 21 | $leadId = $extension->createDemoLead(); 22 | $tpl->set('lead_id',$leadId); 23 | } catch (Exception $e) { 24 | $tpl->set('errors',array($e->getMessage())); 25 | } 26 | } 27 | 28 | $tpl->set('updated',true); 29 | } else { 30 | $tpl->set('errors',$Errors); 31 | } 32 | } 33 | 34 | $tpl->set('data',$data); 35 | $Result['content'] = $tpl->fetch(); 36 | $Result['path'] = array( 37 | array( 38 | 'url' => erLhcoreClassDesign::baseurl('sugarcrm/index'), 39 | 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module', 'SugarCRM') 40 | ), 41 | array( 42 | 'url' => erLhcoreClassDesign::baseurl('sugarcrm/configuration'), 43 | 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module', 'Configuration') 44 | ) 45 | ); 46 | 47 | erLhcoreClassChatEventDispatcher::getInstance()->dispatch('sugarcrm.configuration_path',array('result' => & $Result)); 48 | 49 | ?> 50 | 51 | -------------------------------------------------------------------------------- /sugarcrm/modules/lhsugarcrm/createorupdatelead.php: -------------------------------------------------------------------------------- 1 | load( 'erLhcoreClassModelChat', $Params['user_parameters']['chat_id']); 5 | 6 | if ( erLhcoreClassChat::hasAccessToRead($chat) ) 7 | { 8 | erLhcoreClassChatEventDispatcher::getInstance()->dispatch('sugarcrm.createorupdatelead', array()); 9 | 10 | try { 11 | $sugarcrm = erLhcoreClassModule::getExtensionInstance('erLhcoreClassExtensionSugarcrm'); 12 | $leadId = $sugarcrm->createLeadByChat($chat); 13 | 14 | $tpl = erLhcoreClassTemplate::getInstance('lhsugarcrm/createorupdatelead.tpl.php'); 15 | $tpl->set('lead',$leadId); 16 | $tpl->set('chat',$chat); 17 | 18 | echo json_encode(array('error' => false, 'lead_id' => $leadId->id, 'result' => $tpl->fetch())); 19 | } catch (Exception $e) { 20 | $tpl = erLhcoreClassTemplate::getInstance('lhkernel/validation_error.tpl.php'); 21 | $tpl->set('errors',array($e->getMessage())); 22 | echo json_encode(array('error' => true, 'result' => $tpl->fetch())); 23 | } 24 | } 25 | 26 | exit; 27 | ?> -------------------------------------------------------------------------------- /sugarcrm/modules/lhsugarcrm/getleadfields.php: -------------------------------------------------------------------------------- 1 | getLeadById($Params['user_parameters']['lead_id']); 5 | 6 | $tpl = erLhcoreClassTemplate::getInstance('lhsugarcrm/getleadfields.tpl.php'); 7 | $tpl->set('lead',$lead); 8 | 9 | echo json_encode(array('result' => $tpl->fetch())); 10 | 11 | exit; 12 | ?> -------------------------------------------------------------------------------- /sugarcrm/modules/lhsugarcrm/index.php: -------------------------------------------------------------------------------- 1 | fetch(); 5 | $Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('sugarcrm/index'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('sugarcrm/module','SugarCRM'))); 6 | 7 | erLhcoreClassChatEventDispatcher::getInstance()->dispatch('sugarcrm.index_path',array('result' => & $Result)); 8 | 9 | ?> -------------------------------------------------------------------------------- /sugarcrm/modules/lhsugarcrm/module.php: -------------------------------------------------------------------------------- 1 | "SugarCRM", 4 | 'variable_params' => true ); 5 | 6 | $ViewList = array(); 7 | 8 | $ViewList['index'] = array( 9 | 'params' => array(), 10 | 'uparams' => array(), 11 | 'functions' => array('configure') 12 | ); 13 | 14 | $ViewList['createorupdatelead'] = array( 15 | 'params' => array('chat_id'), 16 | 'uparams' => array(), 17 | 'functions' => array('use') 18 | ); 19 | 20 | $ViewList['getleadfields'] = array( 21 | 'params' => array('lead_id'), 22 | 'uparams' => array(), 23 | 'functions' => array('use') 24 | ); 25 | 26 | $ViewList['updateleadfields'] = array( 27 | 'params' => array('lead_id'), 28 | 'uparams' => array(), 29 | 'functions' => array('use') 30 | ); 31 | 32 | $ViewList['configuration'] = array( 33 | 'params' => array(), 34 | 'uparams' => array(), 35 | 'functions' => array('configure') 36 | ); 37 | 38 | $FunctionList['use'] = array('explain' => 'Allow operator to use SugarCRM module'); 39 | $FunctionList['configure'] = array('explain' => 'Allow operator to configure SugarCRM module'); -------------------------------------------------------------------------------- /sugarcrm/modules/lhsugarcrm/updateleadfields.php: -------------------------------------------------------------------------------- 1 | load( 'erLhcoreClassModelChat', $Params['user_parameters']['chat_id']); 4 | 5 | if ( erLhcoreClassChat::hasAccessToRead($chat) ) 6 | { 7 | $errors = []; 8 | 9 | erLhcoreClassChatEventDispatcher::getInstance()->dispatch('sugarcrm.createorupdatelead', array('errors' => & $errors)); 10 | 11 | if (empty($errors)) { 12 | try { 13 | $sugarcrm = erLhcoreClassModule::getExtensionInstance('erLhcoreClassExtensionSugarcrm'); 14 | $leadId = $sugarcrm->createLeadByChat($chat); 15 | 16 | $tpl = erLhcoreClassTemplate::getInstance('lhsugarcrm/createorupdatelead.tpl.php'); 17 | $tpl->set('lead',$leadId); 18 | $tpl->set('chat',$chat); 19 | 20 | echo json_encode(array('result' => $tpl->fetch())); 21 | } catch (Exception $e) { 22 | $tpl = erLhcoreClassTemplate::getInstance('lhkernel/validation_error.tpl.php'); 23 | $tpl->set('errors',array($e->getMessage())); 24 | echo json_encode(array('result' => $tpl->fetch())); 25 | } 26 | } else { 27 | $tpl = erLhcoreClassTemplate::getInstance('lhkernel/validation_error.tpl.php'); 28 | $tpl->set('errors',$errors); 29 | echo json_encode(array('result' => $tpl->fetch())); 30 | } 31 | } 32 | 33 | exit; 34 | ?> -------------------------------------------------------------------------------- /sugarcrm/translations/lt_LT/translation.ts: -------------------------------------------------------------------------------- 1 | 2 | --------------------------------------------------------------------------------