From 53ecca780dc32f29520e32cb97056b182cba4ca2 Mon Sep 17 00:00:00 2001 From: mattf Date: Mon, 12 Jan 2009 09:01:32 +0000 Subject: [PATCH] Added options for call logging in vtiger_search.php git-svn-id: svn://192.168.202.10@1031 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/docs/LOAD_BALANCING.txt | 36 ++- agc_2-X/trunk/docs/VTIGER.txt | 57 +++- .../docs/conf_examples/extensions.conf.sample | 69 ++-- .../conf_examples/extensions.conf.sample-1.4 | 69 ++-- .../trunk/extras/MySQL_AST_CREATE_tables.sql | 6 +- agc_2-X/trunk/extras/upgrade_2.0.5.sql | 6 + .../TO_BE_TRANSLATED_2.0.5.txt | 4 + agc_2-X/trunk/www/vicidial/admin.php | 37 ++- agc_2-X/trunk/www/vicidial/vtiger_search.php | 299 ++++++++++++++++-- 9 files changed, 479 insertions(+), 104 deletions(-) diff --git a/agc_2-X/trunk/docs/LOAD_BALANCING.txt b/agc_2-X/trunk/docs/LOAD_BALANCING.txt index 8c0f4086..a3581fd9 100644 --- a/agc_2-X/trunk/docs/LOAD_BALANCING.txt +++ b/agc_2-X/trunk/docs/LOAD_BALANCING.txt @@ -167,10 +167,16 @@ If you have any questions or problems please post to the astguiclient-users list 8. On all servers but one you should DELETE the following line from your extensions.conf: ; prompt recording AGI script, ID is 4321 + exten => 8167,1,Answer + exten => 8167,2,AGI(agi-record_prompts.agi,wav-----720000) + exten => 8167,3,Hangup exten => 8168,1,Answer - exten => 8168,2,AGI(agi-record_prompts.agi) + exten => 8168,2,AGI(agi-record_prompts.agi,gsm-----720000) exten => 8168,3,Hangup -This should help to prevent overwriting of prompts that are copied over from the one server that is used to do prompt creation. + This should help to prevent overwriting of prompts that are copied over from the one server that is used to do prompt creation. + Or you can simply redirect to the server that does have the recordings on it: + exten => 8167,1,Dial(${TRUNKIAX2}/${EXTEN},55,o) + exten => 8168,1,Dial(${TRUNKIAX2}/${EXTEN},55,o) 9. On all servers but one you should consider redirecting voicemail direct calls to a single server: Change this: @@ -180,9 +186,17 @@ This should help to prevent overwriting of prompts that are copied over from the To something like this: exten => _85026666666666.,1,Dial(${TRUNKIAX2}/${EXTEN},55,o) + Change this: + exten => 8500,1,VoicemailMain + exten => 8500,2,Goto(s,6) + To something like this: + exten => 8500,1,Dial(${TRUNKIAX2}/${EXTEN},55,o) - - + Change this: + exten => 8501,1,VoicemailMain(s${CALLERIDNUM}) + exten => 8501,2,Hangup + To something like this: + exten => 8501,1,Dial(${TRUNKIAX2}/${EXTEN},55,o) THREE VICIDIAL SERVER LOAD BALANCING SETUP: @@ -294,6 +308,12 @@ The only steps that are different as you add more load-balanced servers are step exten => _8600XXX*.,1,AGI(agi-VDADfixCXFER.agi) exten => _78600XXX*.,1,AGI(agi-VDADfixCXFER.agi) + exten => 8167,1,Dial(${TRUNKIAX1}/${EXTEN},55,o) + exten => 8168,1,Dial(${TRUNKIAX1}/${EXTEN},55,o) + exten => _85026666666666.,1,Dial(${TRUNKIAX1}/${EXTEN},55,o) + exten => 8500,1,Dial(${TRUNKIAX1}/${EXTEN},55,o) + exten => 8501,1,Dial(${TRUNKIAX1}/${EXTEN},55,o) + SERVER THREE(ASTtest3-10.10.10.17) extensions.conf: [globals] @@ -308,9 +328,15 @@ The only steps that are different as you add more load-balanced servers are step exten => _8600XXX*.,1,AGI(agi-VDADfixCXFER.agi) exten => _78600XXX*.,1,AGI(agi-VDADfixCXFER.agi) + exten => 8167,1,Dial(${TRUNKIAX1}/${EXTEN},55,o) + exten => 8168,1,Dial(${TRUNKIAX1}/${EXTEN},55,o) + exten => _85026666666666.,1,Dial(${TRUNKIAX1}/${EXTEN},55,o) + exten => 8500,1,Dial(${TRUNKIAX1}/${EXTEN},55,o) + exten => 8501,1,Dial(${TRUNKIAX1}/${EXTEN},55,o) -Example Monitoring of Load Balancing agents on other servers: + +Example Audio Monitoring of Load Balancing agents on other servers: exten => _589XXX,1,Goto(default,8600${EXTEN:3},1) exten => _689XXX,1,Dial(${TRUNKIAX1}/08600${EXTEN:3},55,o) diff --git a/agc_2-X/trunk/docs/VTIGER.txt b/agc_2-X/trunk/docs/VTIGER.txt index 791da980..5f527f12 100644 --- a/agc_2-X/trunk/docs/VTIGER.txt +++ b/agc_2-X/trunk/docs/VTIGER.txt @@ -5,12 +5,13 @@ Current VICIDIAL integration with Vtiger is for the 5.0.4 release version of Vti Current integration features: - vicidial.php WEBFORM search for lead/account/vendor - user synchronization of VICIDIAL users to Vtiger user database +- added activity event option(call logging in Vtiger) when going from VICIDIAL to Vtiger There has been a basic vtiger integration option available in VICIDIAL since the 1.X release versions through the vtiger_search.php web script(when used as a web form in the campaign) that will search through the leads for the dialed phone number in vicidial.php and if it is not in the vtiger system as a lead then it will be put in as a new contact. More in-depth integration with Vtiger is a bit complicated due to the fact that it has 312 database tables(and you though VICIDIAL had a lot at 70). Attempts at using the built-in 5.0.4 API structure were unsuccessful because of inaccurate documentation and the inability to use the modules easily outside of the vtiger directory tree without major reworking of the vtiger code, so we decided to have VICIDIAL work directly with the database instead. Unfortunately, working only with the database doesn't get you the whole way with Vtiger. For user synchronization you need to make sure that the patch(vtiger_user_file_504.patch) is applied to Vtiger(see instructions below). This patch is used to create blank user profile files so Vtiger will load properly with synchronized users from VICIDIAL. Vtiger doesn't check to see if these user profile files exist before trying to use them, so all this patch does is check if the files exist for each user, and if they do not, it will create them with a simple placeholder. -as of 2008-12-31, several user synchronization features have been added to allow for the creation of vtiger users from the vicidial_users user database. The vtiger_search.php script has also been updated to work with the current vtiger release 5.0.4. To enable the Vtiger integration features you will need to go to the Admin -> System Settings section of the admin.php Administartion web page to set Vtiger Integration to enabled and configure the connection details for the Vtiger database. +as of 2008-12-31, several user synchronization features have been added to allow for the creation of vtiger users from the vicidial_users user database. The vtiger_search.php script has also been updated to work with the current vtiger release 5.0.4. To enable the Vtiger integration features you will need to go to the Admin -> System Settings section of the admin.php Administration web page to set Vtiger Integration to enabled and configure the connection details for the Vtiger database. There are options in the VICIDIAL Modify Campaign Detail screen that you can choose how you want the vtiger_search.php to search for a Vtiger record in the Vtiger system. If Vtiger integration is enabled in the system_settings then this setting will define where the vtiger_search.php page will search for the phone number that was entered. There are 4 options that can be used in this field: ACCTID- This option works only for accounts and it will take the vicidial vendor_lead_code field and try to search for the Vtiger accountid. If unsuccessful it will try any other methods listed that you have selected. @@ -18,7 +19,7 @@ There are options in the VICIDIAL Modify Campaign Detail screen that you can cho VENDOR- This option will only search through the Vtiger vendors LEAD- This option will search through the Vtiger leads only -Multiple search options can be used for each campaign, but on large databases this is not recommended. Default is LEAD. The order that you see the searching options above is the order in which they will be searched if you have selected multiple searching methods. If an account does not exist and you have LEAD selected as a search method, then it will insert the lead with that phone number and you will be taken to the edit screen for that lead when you go to the vtiger_search web page. Vtiger recommends on standard equipment a limit of 50,000 account records, but many users report no issues with 100,000 or more account records in their Vtiger systems. +Multiple search options can be used for each campaign, but on large databases this is not recommended. Default is LEAD. The order that you see the searching options above is the order in which they will be searched if you have selected multiple searching methods. If an account does not exist and you have LEAD selected as a search method, then(if the create lead option is enabled) it will insert the lead with that phone number and you will be taken to the edit screen for that lead when you go to the vtiger_search web page. There is also an option to log the call as an event in Vtiger that will associate with the Lead or Account that the agent screen is sent to. Vtiger recommends on standard equipment a limit of 50,000 account records, but many users report no issues with 100,000 or more account records in their Vtiger systems. Here are the SQL queries used by the vtiger_search.php script to find records in the vtiger system: @@ -225,3 +226,55 @@ mysql> describe vtiger_usertype; +-------------+--------------+------+-----+---------+----------------+ +## Logging calls in Vtiger: +vtiger_crmentity_seq - increment once to account for call log and use for activity ID +vtiger_activity - Where calls are logged +vtiger_cntactivityrel - links a contact to an activity(call) +vtiger_salesmanactivityrel - links a user to an activity(call) +vtiger_seactivityrel - links crmid(account) to an activity(call) +vtiger_seactivityrel_seq - does not appear to be used + +mysql> describe vtiger_activity; ++------------------+--------------+------+-----+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++------------------+--------------+------+-----+---------+-------+ +| activityid | int(19) | NO | PRI | 0 | | +| subject | varchar(100) | NO | | | | +| semodule | varchar(20) | YES | | NULL | | +| activitytype | varchar(200) | NO | MUL | | | +| date_start | date | NO | MUL | | | +| due_date | date | YES | | NULL | | +| time_start | varchar(50) | YES | | NULL | | +| time_end | varchar(50) | YES | | NULL | | +| sendnotification | varchar(3) | NO | | 0 | | +| duration_hours | varchar(2) | YES | | NULL | | +| duration_minutes | varchar(200) | YES | | NULL | | +| status | varchar(200) | YES | MUL | NULL | | +| eventstatus | varchar(200) | YES | MUL | NULL | | +| priority | varchar(200) | YES | | NULL | | +| location | varchar(150) | YES | | NULL | | +| notime | varchar(3) | NO | | 0 | | +| visibility | varchar(50) | NO | | all | | +| recurringtype | varchar(200) | YES | | NULL | | ++------------------+--------------+------+-----+---------+-------+ + + activityid: 12 + subject: VICIDIAL call + semodule: NULL + activitytype: Call + date_start: 2009-01-11 + due_date: 2009-01-11 + time_start: 07:00 + time_end: 07:05 +sendnotification: 0 + duration_hours: 0 +duration_minutes: 5 + status: + eventstatus: Held + priority: Medium + location: Dialer + notime: 0 + visibility: Public + recurringtype: --None-- + + diff --git a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample index ded2ac6c..630fccd0 100644 --- a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample +++ b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample @@ -42,6 +42,43 @@ exten => _08600XXX,1,Dial(${TRUNKblind}/6${EXTEN:1},55,To) ; exten => _010*010*010*016*.,1,Dial(${TRUNKIAX1}/${EXTEN:16},55,o) +;;;;;;;;;; BEGIN Voicemail and Prompts Section ;;;;;;;;;;;;;;;;;;;;;;; +; Give voicemail at extension 8500 +exten => 8500,1,VoicemailMain +exten => 8500,2,Goto(s,6) + +; this is used to allow the GUI to send you directly into voicemail +; don't forget to set GUI variable $voicemail_exten to this extension +exten => 8501,1,VoicemailMain(s${CALLERIDNUM}) +exten => 8501,2,Hangup + +; this is used to allow the GUI to send live calls directly into voicemail +; don't forget to set GUI variable $voicemail_dump_exten to this extension +exten => _85026666666666.,1,Wait(1) +exten => _85026666666666.,2,Voicemail(${EXTEN:14}|u) +exten => _85026666666666.,3,Hangup + +; prompts for recording AGI script, ID is 4321 +; first variable is format (gsm/wav) +; second variable is timeout in milliseconds (default is 720000 [12 minutes]) +exten => 8167,1,Answer +exten => 8167,2,AGI(agi-record_prompts.agi,wav-----720000) +exten => 8167,3,Hangup +exten => 8168,1,Answer +exten => 8168,2,AGI(agi-record_prompts.agi,gsm-----720000) +exten => 8168,3,Hangup + +; playback of recorded prompts +exten => _851XXXXX,1,Answer +exten => _851XXXXX,2,Playback(${EXTEN}) +exten => _851XXXXX,3,Hangup +;;;;;;;;;; END Voicemail and Prompts Section ;;;;;;;;;;;;;;;;;;;;;;;;; + + +; FastAGI for VICIDIAL/astGUIclient call logging +exten => h,1,DeadAGI(agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----${HANGUPCAUSE}-----${DIALSTATUS}-----${DIALEDTIME}-----${ANSWEREDTIME}) + + ; Example phone extensions ; Extension 2000 Sipura/Linksys ATA line 1 @@ -78,12 +115,6 @@ exten => #,2,Hangup ; Hang them up. exten => t,1,Goto(#,1) ; If they take too long, give up exten => i,1,Playback(invalid) ; "That's not valid, try again" -; Give voicemail at extension 8500 -exten => 8500,1,VoicemailMain -exten => 8500,2,Goto(s,6) - -; FastAGI for VICIDIAL/astGUIclient call logging -exten => h,1,DeadAGI(agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----${HANGUPCAUSE}-----${DIALSTATUS}-----${DIALEDTIME}-----${ANSWEREDTIME}) ; Inbound call from BINFONE ; exten => 1112223333,1,AGI(agi://127.0.0.1:4577/call_log) @@ -353,32 +384,6 @@ exten => 8352,1,AGI(agi-VDADselective_CID_hangup.agi,${EXTEN}) exten => 8352,2,Playback(safe_harbor) exten => 8352,3,Hangup -; prompts for recording AGI script, ID is 4321 -; first variable is format (gsm/wav) -; second variable is timeout in milliseconds (default is 720000 [12 minutes]) -exten => 8167,1,Answer -exten => 8167,2,AGI(agi-record_prompts.agi,wav-----720000) -exten => 8167,3,Hangup -exten => 8168,1,Answer -exten => 8168,2,AGI(agi-record_prompts.agi,gsm-----720000) -exten => 8168,3,Hangup - -; playback of recorded prompts -exten => _851XXXXX,1,Answer -exten => _851XXXXX,2,Playback(${EXTEN}) -exten => _851XXXXX,3,Hangup - -; this is used to allow the GUI to send you directly into voicemail -; don't forget to set GUI variable $voicemail_exten to this extension -exten => 8501,1,VoicemailMain(s${CALLERIDNUM}) -exten => 8501,2,Hangup - -; this is used to allow the GUI to send live calls directly into voicemail -; don't forget to set GUI variable $voicemail_dump_exten to this extension -exten => _85026666666666.,1,Wait(1) -exten => _85026666666666.,2,Voicemail(${EXTEN:14}|u) -exten => _85026666666666.,3,Hangup - ; this is used for sending DTMF signals within conference calls, the client app ; sends the digits to be played in the callerID field ; sound files must be placed in /var/lib/asterisk/sounds diff --git a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 index b16a2734..78c44b9b 100644 --- a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 +++ b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 @@ -42,6 +42,43 @@ exten => _08600XXX,1,Dial(${TRUNKblind}/6${EXTEN:1},55,To) ; exten => _010*010*010*016*.,1,Dial(${TRUNKIAX1}/${EXTEN:16},55,o) +;;;;;;;;;; BEGIN Voicemail and Prompts Section ;;;;;;;;;;;;;;;;;;;;;;; +; Give voicemail at extension 8500 +exten => 8500,1,VoicemailMain +exten => 8500,2,Goto(s,6) + +; this is used to allow the GUI to send you directly into voicemail +; don't forget to set GUI variable $voicemail_exten to this extension +exten => 8501,1,VoicemailMain(s${{CALLERID(num)}(num)}) +exten => 8501,2,Hangup + +; this is used to allow the GUI to send live calls directly into voicemail +; don't forget to set GUI variable $voicemail_dump_exten to this extension +exten => _85026666666666.,1,Wait(1) +exten => _85026666666666.,2,Voicemail(${EXTEN:14}|u) +exten => _85026666666666.,3,Hangup + +; prompts for recording AGI script, ID is 4321 +; first variable is format (gsm/wav) +; second variable is timeout in milliseconds (default is 720000 [12 minutes]) +exten => 8167,1,Answer +exten => 8167,2,AGI(agi-record_prompts.agi,wav-----720000) +exten => 8167,3,Hangup +exten => 8168,1,Answer +exten => 8168,2,AGI(agi-record_prompts.agi,gsm-----720000) +exten => 8168,3,Hangup + +; playback of recorded prompts +exten => _851XXXXX,1,Answer +exten => _851XXXXX,2,Playback(${EXTEN}) +exten => _851XXXXX,3,Hangup +;;;;;;;;;; END Voicemail and Prompts Section ;;;;;;;;;;;;;;;;;;;;;;;;; + + +; FastAGI for VICIDIAL/astGUIclient call logging +exten => h,1,DeadAGI(agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----${HANGUPCAUSE}-----${DIALSTATUS}-----${DIALEDTIME}-----${ANSWEREDTIME}) + + ; Example phone extensions ; Extension 2000 Sipura/Linksys ATA line 1 @@ -78,12 +115,6 @@ exten => #,2,Hangup ; Hang them up. exten => t,1,Goto(#,1) ; If they take too long, give up exten => i,1,Playback(invalid) ; "That's not valid, try again" -; Give voicemail at extension 8500 -exten => 8500,1,VoicemailMain -exten => 8500,2,Goto(s,6) - -; FastAGI for VICIDIAL/astGUIclient call logging -exten => h,1,DeadAGI(agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----${HANGUPCAUSE}-----${DIALSTATUS}-----${DIALEDTIME}-----${ANSWEREDTIME}) ; Inbound call from BINFONE ; exten => 1112223333,1,AGI(agi://127.0.0.1:4577/call_log) @@ -353,32 +384,6 @@ exten => 8352,1,AGI(agi-VDADselective_CID_hangup.agi,${EXTEN}) exten => 8352,2,Playback(safe_harbor) exten => 8352,3,Hangup -; prompts for recording AGI script, ID is 4321 -; first variable is format (gsm/wav) -; second variable is timeout in milliseconds (default is 720000 [12 minutes]) -exten => 8167,1,Answer -exten => 8167,2,AGI(agi-record_prompts.agi,wav-----720000) -exten => 8167,3,Hangup -exten => 8168,1,Answer -exten => 8168,2,AGI(agi-record_prompts.agi,gsm-----720000) -exten => 8168,3,Hangup - -; playback of recorded prompts -exten => _851XXXXX,1,Answer -exten => _851XXXXX,2,Playback(${EXTEN}) -exten => _851XXXXX,3,Hangup - -; this is used to allow the GUI to send you directly into voicemail -; don't forget to set GUI variable $voicemail_exten to this extension -exten => 8501,1,VoicemailMain(s${{CALLERID(num)}(num)}) -exten => 8501,2,Hangup - -; this is used to allow the GUI to send live calls directly into voicemail -; don't forget to set GUI variable $voicemail_dump_exten to this extension -exten => _85026666666666.,1,Wait(1) -exten => _85026666666666.,2,Voicemail(${EXTEN:14}|u) -exten => _85026666666666.,3,Hangup - ; this is used for sending DTMF signals within conference calls, the client app ; sends the digits to be played in the callerID field ; sound files must be placed in /var/lib/asterisk/sounds diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql index dc80c7e4..86b5d191 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -602,7 +602,9 @@ use_campaign_dnc ENUM('Y','N') default 'N', three_way_call_cid ENUM('CAMPAIGN','CUSTOMER','AGENT_PHONE') default 'CAMPAIGN', three_way_dial_prefix VARCHAR(20) default '', web_form_target VARCHAR(100) NOT NULL default 'vdcwebform', -vtiger_search_category VARCHAR(100) default 'LEAD' +vtiger_search_category VARCHAR(100) default 'LEAD', +vtiger_create_call_record ENUM('Y','N') default 'Y', +vtiger_create_lead_record ENUM('Y','N') default 'Y' ); CREATE TABLE vicidial_lists ( @@ -1388,7 +1390,7 @@ CREATE INDEX phone_number on vicidial_closer_log (phone_number); CREATE INDEX date_user on vicidial_closer_log (call_date,user); CREATE INDEX comment_a on live_inbound_log (comment_a); -UPDATE system_settings SET db_schema_version='1122'; +UPDATE system_settings SET db_schema_version='1123'; GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@localhost; diff --git a/agc_2-X/trunk/extras/upgrade_2.0.5.sql b/agc_2-X/trunk/extras/upgrade_2.0.5.sql index 1b314f33..9675121a 100644 --- a/agc_2-X/trunk/extras/upgrade_2.0.5.sql +++ b/agc_2-X/trunk/extras/upgrade_2.0.5.sql @@ -595,3 +595,9 @@ ALTER TABLE vicidial_ivr ADD prompt_response_20 TINYINT(1) UNSIGNED default '0'; ALTER TABLE system_settings MODIFY vicidial_agent_disable ENUM('NOT_ACTIVE','LIVE_AGENT','EXTERNAL','ALL') default 'ALL'; UPDATE system_settings SET db_schema_version='1122'; + +ALTER TABLE vicidial_campaigns ADD vtiger_create_call_record ENUM('Y','N') default 'Y'; +ALTER TABLE vicidial_campaigns ADD vtiger_create_lead_record ENUM('Y','N') default 'Y'; + +UPDATE system_settings SET db_schema_version='1123'; + diff --git a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt index e0c67f3e..c3b7ba29 100644 --- a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt +++ b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt @@ -369,6 +369,10 @@ SUBMIT ACTIVE LIST CHANGES|| LAST CALL DATE|| User Group Bulk Change|| Bulk Group Change|| +Vtiger Create Call Record -<\/B> If Vtiger integration is enabled in the system settings then this setting will define whether a new Vtiger activity record is created for the call when the agent goes to the vtiger_search page. Default is Y|| +Vtiger Create Call Record:|| +Vtiger Create Lead Record -<\/B> If Vtiger integration is enabled in the system settings and Vtiger Search Category includes LEAD then this setting will define whether a new Vtiger lead record is created when the agent goes to the vtiger_search page and no record is found to have the call phone number. Default is Y|| +Vtiger Create Lead Record:|| ############################################################ CLIENT diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index be8c8e52..51170976 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -875,6 +875,10 @@ if (isset($_GET["vtiger_url"])) {$vtiger_url=$_GET["vtiger_url"];} elseif (isset($_POST["vtiger_url"])) {$vtiger_url=$_POST["vtiger_url"];} if (isset($_GET["vtiger_search_category"])) {$vtiger_search_category=$_GET["vtiger_search_category"];} elseif (isset($_POST["vtiger_search_category"])) {$vtiger_search_category=$_POST["vtiger_search_category"];} +if (isset($_GET["vtiger_create_call_record"])) {$vtiger_create_call_record=$_GET["vtiger_create_call_record"];} + elseif (isset($_POST["vtiger_create_call_record"])) {$vtiger_create_call_record=$_POST["vtiger_create_call_record"];} +if (isset($_GET["vtiger_create_lead_record"])) {$vtiger_create_lead_record=$_GET["vtiger_create_lead_record"];} + elseif (isset($_POST["vtiger_create_lead_record"])) {$vtiger_create_lead_record=$_POST["vtiger_create_lead_record"];} if (isset($script_id)) {$script_id= strtoupper($script_id);} if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} @@ -1183,8 +1187,8 @@ $park_file_name = ereg_replace("[^-\_0-9a-zA-Z]","",$park_file_name); $pass = ereg_replace("[^-\_0-9a-zA-Z]","",$pass); $phone_login = ereg_replace("[^-\_0-9a-zA-Z]","",$phone_login); $phone_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$phone_pass); -$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); -$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^-\_0-9a-zA-Z]","",$PHP_AUTH_PW); +$PHP_AUTH_USER = ereg_replace("[^-\_0-9a-zA-Z]","",$PHP_AUTH_USER); $protocol = ereg_replace("[^-\_0-9a-zA-Z]","",$protocol); $server_id = ereg_replace("[^-\_0-9a-zA-Z]","",$server_id); $stage = ereg_replace("[^-\_0-9a-zA-Z]","",$stage); @@ -1242,6 +1246,8 @@ $three_way_call_cid = ereg_replace("[^-\_0-9a-zA-Z]","",$three_way_call_cid); $web_form_target = ereg_replace("[^-\_0-9a-zA-Z]","",$web_form_target); $recording_web_link = ereg_replace("[^-\_0-9a-zA-Z]","",$recording_web_link); $vtiger_search_category = ereg_replace("[^-\_0-9a-zA-Z]","",$vtiger_search_category); +$vtiger_create_call_record = ereg_replace("[^-\_0-9a-zA-Z]","",$vtiger_create_call_record); +$vtiger_create_lead_record = ereg_replace("[^-\_0-9a-zA-Z]","",$vtiger_create_lead_record); ### ALPHA-NUMERIC and underscore and dash and comma $logins_list = ereg_replace("[^-\,\_0-9a-zA-Z]","",$logins_list); @@ -1513,11 +1519,12 @@ $survey_camp_record_dir = ereg_replace(";","",$survey_camp_record_dir); # 81222-0500 - Reformatted all listings to same format changed to field selects instead of * # 81228-2300 - Added fields for vtiger integration and active vicidial_user display # 90101-1216 - Added options for user synchronization with vtiger +# 90112-0335 - Added vtiger_create_lead_record and vtiger_create_lead_record options # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$admin_version = '2.0.5-156'; -$build = '90101-1216'; +$admin_version = '2.0.5-157'; +$build = '90112-0335'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -3105,6 +3112,16 @@ echo "\n"; + + echo "\n"; + + echo "\n"; } else { echo "\n"; + echo "\n"; + echo "\n"; } if ($campaign_allow_inbound == 'Y') diff --git a/agc_2-X/trunk/www/vicidial/vtiger_search.php b/agc_2-X/trunk/www/vicidial/vtiger_search.php index 05d1ef51..ff23a5ca 100644 --- a/agc_2-X/trunk/www/vicidial/vtiger_search.php +++ b/agc_2-X/trunk/www/vicidial/vtiger_search.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 # # This page does a search against a standard vtiger CRM system. If the record # is not present, it will create a new one and send the agent's screen to that new page. @@ -10,12 +10,14 @@ # # CHANGES # 60719-1615 - First version -# 60801-2304 - added mysql debug and auto-forward -# 60802-1111 - added insertion of not-found record into vtiger system +# 60801-2304 - Added mysql debug and auto-forward +# 60802-1111 - Added insertion of not-found record into vtiger system # 71220-0000 - Modified by I. Taushanov for VTiger 5.03- search/create lead -# 80120-1934 - added changes for compatibility with vtiger 5.0.3 -# 81229-1017 - added usage of system_settings connection settings for vtiger database -# 81229-1441 - added options for searching by ACCTID, ACCOUNT, VENDOR and LEAD +# 80120-1934 - Added changes for compatibility with vtiger 5.0.3 +# 81229-1017 - Added usage of system_settings connection settings for vtiger database +# 81229-1441 - Added options for searching by ACCTID, ACCOUNT, VENDOR and LEAD +# 90111-1451 - Added logging of call as activity for account/lead +# 90112-0336 - Added create call and create lead options # header ("Content-type: text/html; charset=utf-8"); @@ -110,6 +112,9 @@ if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} $US = '_'; $STARTtime = date("U"); $TODAY = date("Y-m-d"); +$HHMMnow = date("H:i"); +$minute_old = mktime(date("H"), date("i")+5, date("s"), date("m"), date("d"), date("Y")); +$HHMMend = date("H:i",$minute_old); $NOW_TIME = date("Y-m-d H:i:s"); $REC_TIME = date("Ymd-His"); $FILE_datetime = $STARTtime; @@ -147,14 +152,16 @@ if ($enable_vtiger_integration < 1) exit; } -$stmt = "SELECT vtiger_search_category FROM vicidial_campaigns where campaign_id='$campaign';"; +$stmt = "SELECT vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record FROM vicidial_campaigns where campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $vtc_conf_ct = mysql_num_rows($rslt); if ($vtc_conf_ct > 0) { $row=mysql_fetch_row($rslt); - $vtiger_search_category = $row[0]; + $vtiger_search_category = $row[0]; + $vtiger_create_call_record = $row[1]; + $vtiger_create_lead_record = $row[2]; } if (strlen($vtiger_search_category)<1) {$vtiger_search_category = 'LEAD';} @@ -181,7 +188,6 @@ mysql_select_db("$vtiger_dbname", $linkV); # LEAD: # $stmt="SELECT count(*) from vtiger_leadaddress where phone='$phone' or mobile='$phone' or fax='$phone';"; -$create_lead_if_not_found=1; $lead_search=0; $account_search=0; $vendor_search=0; $acctid_search=0; if (ereg('ACCTID',$vtiger_search_category)) {$acctid_search=1;} @@ -213,8 +219,68 @@ if ($acctid_search > 0) } else { - # http://mysite.com/vtigercrm/index.php?module=Accounts&action=DetailView&record=2&parenttab=Sales - $account_URL = "$vtiger_url/index.php?module=Accounts&action=DetailView&record=$vendor_id&parenttab=Sales"; + if (ereg('Y',$vtiger_create_call_record)) + { + ### Log the call in Vtiger + + #Get logged in user ID + $stmt="SELECT id from vtiger_users where user_name='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $user_id = $row[0]; + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Get next aviable id from vtiger_crmentity_seq to use as activityid in vtiger_crmentity + $stmt="SELECT id from vtiger_crmentity_seq ;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $activityid = ($row[0] + 1); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Increase next aviable crmid with 1 so next record gets proper id + $stmt="UPDATE vtiger_crmentity_seq SET id = '$activityid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_salesmanactivityrel + $stmt = "INSERT INTO vtiger_salesmanactivityrel SET smid='$user_id',activityid='$activityid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_seactivityrel + $stmt = "INSERT INTO vtiger_seactivityrel SET crmid='$vendor_id',activityid='$activityid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_crmentity + $stmt = "INSERT INTO vtiger_crmentity (crmid, smcreatorid, smownerid, modifiedby, setype, description, createdtime, modifiedtime, viewedtime, status, version, presence, deleted) VALUES ('$activityid', '$user_id', '$user_id','$user_id', 'Calendar', 'VICIDIAL Call user $user', '$NOW_TIME', '$NOW_TIME', '$NOW_TIME', NULL, '0', '1', '0');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_activity + $stmt = "INSERT INTO vtiger_activity SET activityid='$activityid',subject='VICIDIAL Account call $vendor_id',activitytype='Call',date_start='$TODAY',due_date='$TODAY',time_start='$HHMMnow',time_end='$HHMMend',sendnotification='0',duration_hours='0',duration_minutes='1',status='',eventstatus='Held',priority='Medium',location='VICIDIAL User $user',notime='0',visibility='Public',recurringtype='--None--';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # http://mysite.com/vtigercrm/index.php?module=Calendar&action=EditView&return_module=Accounts&return_action=DetailView&record=16&activity_mode=Events&return_id=9&parenttab=Sales + $account_URL = "$vtiger_url/index.php?module=Calendar&action=EditView&return_module=Accounts&return_action=DetailView&record=$activityid&activity_mode=Events&return_id=$vendor_id&parenttab=Sales"; + } + else + { + # http://mysite.com/vtigercrm/index.php?module=Accounts&action=DetailView&record=2&parenttab=Sales + $account_URL = "$vtiger_url/index.php?module=Accounts&action=DetailView&record=$vendor_id&parenttab=Sales"; + } echo "\n"; echo "\n"; echo "\n"; @@ -314,8 +380,68 @@ if ($account_search > 0) } if (strlen($accountid) > 0) { - # http://mysite.com/vtigercrm/index.php?module=Accounts&action=DetailView&record=2&parenttab=Sales - $account_URL = "$vtiger_url/index.php?module=Accounts&action=DetailView&record=$accountid&parenttab=Sales"; + if (ereg('Y',$vtiger_create_call_record)) + { + ### Log the call in Vtiger + + #Get logged in user ID + $stmt="SELECT id from vtiger_users where user_name='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $user_id = $row[0]; + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Get next aviable id from vtiger_crmentity_seq to use as activityid in vtiger_crmentity + $stmt="SELECT id from vtiger_crmentity_seq ;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $activityid = ($row[0] + 1); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Increase next aviable crmid with 1 so next record gets proper id + $stmt="UPDATE vtiger_crmentity_seq SET id = '$activityid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_salesmanactivityrel + $stmt = "INSERT INTO vtiger_salesmanactivityrel SET smid='$user_id',activityid='$activityid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_seactivityrel + $stmt = "INSERT INTO vtiger_seactivityrel SET crmid='$accountid',activityid='$activityid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_crmentity + $stmt = "INSERT INTO vtiger_crmentity (crmid, smcreatorid, smownerid, modifiedby, setype, description, createdtime, modifiedtime, viewedtime, status, version, presence, deleted) VALUES ('$activityid', '$user_id', '$user_id','$user_id', 'Calendar', 'VICIDIAL Call user $user', '$NOW_TIME', '$NOW_TIME', '$NOW_TIME', NULL, '0', '1', '0');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_activity + $stmt = "INSERT INTO vtiger_activity SET activityid='$activityid',subject='VICIDIAL Account call $phone',activitytype='Call',date_start='$TODAY',due_date='$TODAY',time_start='$HHMMnow',time_end='$HHMMend',sendnotification='0',duration_hours='0',duration_minutes='1',status='',eventstatus='Held',priority='Medium',location='VICIDIAL User $user',notime='0',visibility='Public',recurringtype='--None--';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # http://mysite.com/vtigercrm/index.php?module=Calendar&action=EditView&return_module=Accounts&return_action=DetailView&record=16&activity_mode=Events&return_id=9&parenttab=Sales + $account_URL = "$vtiger_url/index.php?module=Calendar&action=EditView&return_module=Accounts&return_action=DetailView&record=$activityid&activity_mode=Events&return_id=$accountid&parenttab=Sales"; + } + else + { + # http://mysite.com/vtigercrm/index.php?module=Accounts&action=DetailView&record=2&parenttab=Sales + $account_URL = "$vtiger_url/index.php?module=Accounts&action=DetailView&record=$accountid&parenttab=Sales"; + } echo "\n"; echo "\n"; echo "\n"; @@ -398,7 +524,7 @@ if ($lead_search > 0) if ($found_count < 1) { echo "\n"; - if ($create_lead_if_not_found > 0) + if (ereg('Y',$vtiger_create_lead_record)) { echo "\n"; echo "\n"; @@ -431,7 +557,7 @@ if ($lead_search > 0) $rslt=mysql_query($stmt, $linkV); if (!$rslt) {die('Could not execute: ' . mysql_error());} - #Insert values into tiger_crmentity + #Insert values into vtiger_crmentity $stmt = "INSERT INTO vtiger_crmentity (crmid, smcreatorid, smownerid, modifiedby, setype, description, createdtime, modifiedtime, viewedtime, status, version, presence, deleted) VALUES ('$leadid', '$user_id', '$user_id','$user_id', 'Leads', '(Memo)', '$NOW_TIME', '$NOW_TIME', '$NOW_TIME', NULL, '0', '1', '0');"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $linkV); @@ -464,11 +590,73 @@ if ($lead_search > 0) if ($DB) {echo "DONE creating lead records\n";} - # http://mysite.com/vtigercrm/index.php?module=Accounts&action=EditView&record=2&parenttab=Sales - $account_URL = "$vtiger_url/index.php?module=Leads&action=EditView&record=$leadid&parenttab=Sales"; - # echo "\n"; + if (ereg('Y',$vtiger_create_call_record)) + { + ### Log the call in Vtiger + + #Get logged in user ID + $stmt="SELECT id from vtiger_users where user_name='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $user_id = $row[0]; + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Get next aviable id from vtiger_crmentity_seq to use as activityid in vtiger_crmentity + $stmt="SELECT id from vtiger_crmentity_seq ;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $activityid = ($row[0] + 1); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Increase next aviable crmid with 1 so next record gets proper id + $stmt="UPDATE vtiger_crmentity_seq SET id = '$activityid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_salesmanactivityrel + $stmt = "INSERT INTO vtiger_salesmanactivityrel SET smid='$user_id',activityid='$activityid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_seactivityrel + $stmt = "INSERT INTO vtiger_seactivityrel SET crmid='$leadid',activityid='$activityid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_crmentity + $stmt = "INSERT INTO vtiger_crmentity (crmid, smcreatorid, smownerid, modifiedby, setype, description, createdtime, modifiedtime, viewedtime, status, version, presence, deleted) VALUES ('$activityid', '$user_id', '$user_id','$user_id', 'Calendar', 'VICIDIAL Call user $user', '$NOW_TIME', '$NOW_TIME', '$NOW_TIME', NULL, '0', '1', '0');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_activity + $stmt = "INSERT INTO vtiger_activity SET activityid='$activityid',subject='VICIDIAL Lead call $phone',activitytype='Call',date_start='$TODAY',due_date='$TODAY',time_start='$HHMMnow',time_end='$HHMMend',sendnotification='0',duration_hours='0',duration_minutes='1',status='',eventstatus='Held',priority='Medium',location='VICIDIAL user $user',notime='0',visibility='Public',recurringtype='--None--';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + + # http://mysite.com/vtigercrm/index.php?module=Calendar&action=EditView&return_module=Accounts&return_action=DetailView&record=16&activity_mode=Events&return_id=9&parenttab=Sales + $account_URL = "$vtiger_url/index.php?module=Calendar&action=EditView&return_module=Leads&return_action=DetailView&record=$activityid&activity_mode=Events&return_id=$leadid&parenttab=Sales"; + } + else + { + # http://mysite.com/vtigercrm/index.php?module=Accounts&action=EditView&record=2&parenttab=Sales + $account_URL = "$vtiger_url/index.php?module=Leads&action=EditView&record=$leadid&parenttab=Sales"; + } + + echo "\n"; echo "\n"; - # echo "\n"; + echo "\n"; echo "
\n"; echo "
";
@@ -486,9 +674,70 @@ if ($lead_search > 0)
 		if ($DB) {echo "$stmt\n";}
 		$row=mysql_fetch_row($rslt);
 		$leadid = $row[0];
-		
-		# http://mysite.com/vtigercrm/index.php?module=Accounts&action=DetailView&record=2&parenttab=Sales
-		$account_URL = "$vtiger_url/index.php?module=Leads&action=DetailView&record=$leadid&parenttab=Sales";
+
+		if (ereg('Y',$vtiger_create_call_record))
+			{
+			### Log the call in Vtiger
+
+			#Get logged in user ID
+			$stmt="SELECT id from vtiger_users where user_name='$user';";
+			if ($DB) {echo "$stmt\n";}
+			$rslt=mysql_query($stmt, $linkV);
+			$row=mysql_fetch_row($rslt);
+			$user_id = $row[0];
+			if (!$rslt) {die('Could not execute: ' . mysql_error());}
+			
+			# Get next aviable id from vtiger_crmentity_seq to use as activityid in vtiger_crmentity	
+			$stmt="SELECT id from vtiger_crmentity_seq ;";
+			if ($DB) {echo "$stmt\n";}
+			$rslt=mysql_query($stmt, $linkV);
+			$row=mysql_fetch_row($rslt);
+			$activityid = ($row[0] + 1);
+			if (!$rslt) {die('Could not execute: ' . mysql_error());}
+
+			# Increase next aviable crmid with 1 so next record gets proper id
+			$stmt="UPDATE vtiger_crmentity_seq SET id = '$activityid';";
+			if ($DB) {echo "$stmt\n";}
+			$rslt=mysql_query($stmt, $linkV);
+			if (!$rslt) {die('Could not execute: ' . mysql_error());}
+			
+			#Insert values into vtiger_salesmanactivityrel
+			$stmt = "INSERT INTO vtiger_salesmanactivityrel SET smid='$user_id',activityid='$activityid';";
+			if ($DB) {echo "|$stmt|\n";}
+			$rslt=mysql_query($stmt, $linkV);
+			if ($DB) {echo "|$leadid|\n";}
+			if (!$rslt) {die('Could not execute: ' . mysql_error());}
+			
+			#Insert values into vtiger_seactivityrel
+			$stmt = "INSERT INTO vtiger_seactivityrel SET crmid='$leadid',activityid='$activityid';";
+			if ($DB) {echo "|$stmt|\n";}
+			$rslt=mysql_query($stmt, $linkV);
+			if ($DB) {echo "|$leadid|\n";}
+			if (!$rslt) {die('Could not execute: ' . mysql_error());}
+			
+			#Insert values into vtiger_crmentity
+			$stmt = "INSERT INTO vtiger_crmentity (crmid, smcreatorid, smownerid, modifiedby, setype, description, createdtime, modifiedtime, viewedtime, status, version, presence, deleted) VALUES ('$activityid', '$user_id', '$user_id','$user_id', 'Calendar', 'VICIDIAL Call user $user', '$NOW_TIME', '$NOW_TIME', '$NOW_TIME', NULL, '0', '1', '0');";
+			if ($DB) {echo "|$stmt|\n";}
+			$rslt=mysql_query($stmt, $linkV);
+			if ($DB) {echo "|$leadid|\n";}
+			if (!$rslt) {die('Could not execute: ' . mysql_error());}
+
+			#Insert values into vtiger_activity
+			$stmt = "INSERT INTO vtiger_activity SET activityid='$activityid',subject='VICIDIAL Lead call $phone',activitytype='Call',date_start='$TODAY',due_date='$TODAY',time_start='$HHMMnow',time_end='$HHMMend',sendnotification='0',duration_hours='0',duration_minutes='1',status='',eventstatus='Held',priority='Medium',location='VICIDIAL user $user',notime='0',visibility='Public',recurringtype='--None--';";
+			if ($DB) {echo "|$stmt|\n";}
+			$rslt=mysql_query($stmt, $linkV);
+			if ($DB) {echo "|$leadid|\n";}
+			if (!$rslt) {die('Could not execute: ' . mysql_error());}
+
+
+			# http://mysite.com/vtigercrm/index.php?module=Calendar&action=EditView&return_module=Accounts&return_action=DetailView&record=16&activity_mode=Events&return_id=9&parenttab=Sales
+			$account_URL = "$vtiger_url/index.php?module=Calendar&action=EditView&return_module=Leads&return_action=DetailView&record=$activityid&activity_mode=Events&return_id=$leadid&parenttab=Sales";
+			}
+		else
+			{
+			# http://mysite.com/vtigercrm/index.php?module=Accounts&action=DetailView&record=2&parenttab=Sales
+			$account_URL = "$vtiger_url/index.php?module=Leads&action=DetailView&record=$leadid&parenttab=Sales";
+			}
 		echo "\n";
 		echo "\n";
 		echo "\n";
@@ -513,10 +762,10 @@ $ENDtime = date("U");
 
 $RUNtime = ($ENDtime - $STARTtime);
 
-echo "\n\n\n
NOT FOUND

\n\n"; +echo "\n\n\n
$phone NOT FOUND

\n\n"; +echo "Click here to go to the Vtiger home page\n"; - -echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; +# echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; ?>
Vtiger Search Category - If Vtiger integration is enabled in the system settings then this setting will define where the vtiger_search.php page will search for the phone number that was entered. There are 4 options that can be used in this field: LEAD- This option will search through the Vtiger leads only, ACCOUNT- This option will search through the Vtiger accounts and all contacts and sub-contacts for the phone number, VENDOR- This option will only search through the Vtiger vendors, ACCTID- This option works only for accounts and it will take the vicidial vendor_lead_code field and try to search for the Vtiger account ID. If unsuccessful it will try any other methods listed that you have selected. Multiple options can be used for each search, but on large databases this is not recommended. Default is LEAD. +
+ +
+Vtiger Create Call Record - If Vtiger integration is enabled in the system settings then this setting will define whether a new Vtiger activity record is created for the call when the agent goes to the vtiger_search page. Default is Y. + +
+
+
+Vtiger Create Lead Record - If Vtiger integration is enabled in the system settings and Vtiger Search Category includes LEAD then this setting will define whether a new Vtiger lead record is created when the agent goes to the vtiger_search page and no record is found to have the call phone number. Default is Y. + @@ -6592,7 +6609,7 @@ if ($ADD==20) { echo "
CAMPAIGN COPIED: $campaign_id copied from $source_campaign_id\n"; - $stmt="INSERT INTO vicidial_campaigns (campaign_name,campaign_id,active,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,list_order_mix,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category) SELECT \"$campaign_name\",\"$campaign_id\",\"N\",dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,\"DISABLED\",campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category from vicidial_campaigns where campaign_id='$source_campaign_id';"; + $stmt="INSERT INTO vicidial_campaigns (campaign_name,campaign_id,active,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,list_order_mix,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record) SELECT \"$campaign_name\",\"$campaign_id\",\"N\",dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,\"DISABLED\",campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record from vicidial_campaigns where campaign_id='$source_campaign_id';"; $rslt=mysql_query($stmt, $link); $stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$campaign_id');"; @@ -8313,7 +8330,7 @@ if ($ADD==41) if ( (!ereg("DISABLED",$list_order_mix)) and ($hopper_level < 100) ) {$hopper_level='100';} - $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', $adlSQL next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysql_real_escape_string($web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number',xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',drop_action='$drop_action',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns='$groups_value',use_internal_dnc='$use_internal_dnc',allcalls_delay='$allcalls_delay',omit_phone_code='$omit_phone_code',dial_method='$dial_method',available_only_ratio_tally='$available_only_ratio_tally',adaptive_dropped_percentage='$adaptive_dropped_percentage',adaptive_maximum_level='$adaptive_maximum_level',adaptive_latest_server_time='$adaptive_latest_server_time',adaptive_intensity='$adaptive_intensity',adaptive_dl_diff_target='$adaptive_dl_diff_target',concurrent_transfers='$concurrent_transfers',auto_alt_dial='$auto_alt_dial',agent_pause_codes_active='$agent_pause_codes_active',campaign_description='$campaign_description',campaign_changedate='$SQLdate',campaign_stats_refresh='$campaign_stats_refresh',disable_alter_custdata='$disable_alter_custdata',no_hopper_leads_logins='$no_hopper_leads_logins',list_order_mix='$list_order_mix',campaign_allow_inbound='$campaign_allow_inbound',manual_dial_list_id='$manual_dial_list_id',default_xfer_group='$default_xfer_group',xfer_groups='$XFERgroups_value',queue_priority='$queue_priority',drop_inbound_group='$drop_inbound_group',disable_alter_custphone='$disable_alter_custphone',display_queue_count='$display_queue_count',manual_dial_filter='$manual_dial_filter',agent_clipboard_copy='$agent_clipboard_copy',agent_extended_alt_dial='$agent_extended_alt_dial',use_campaign_dnc='$use_campaign_dnc',three_way_call_cid='$three_way_call_cid',three_way_dial_prefix='$three_way_dial_prefix',web_form_target='$web_form_target',vtiger_search_category='$vtiger_search_category' where campaign_id='$campaign_id';"; + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', $adlSQL next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysql_real_escape_string($web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number',xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',drop_action='$drop_action',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns='$groups_value',use_internal_dnc='$use_internal_dnc',allcalls_delay='$allcalls_delay',omit_phone_code='$omit_phone_code',dial_method='$dial_method',available_only_ratio_tally='$available_only_ratio_tally',adaptive_dropped_percentage='$adaptive_dropped_percentage',adaptive_maximum_level='$adaptive_maximum_level',adaptive_latest_server_time='$adaptive_latest_server_time',adaptive_intensity='$adaptive_intensity',adaptive_dl_diff_target='$adaptive_dl_diff_target',concurrent_transfers='$concurrent_transfers',auto_alt_dial='$auto_alt_dial',agent_pause_codes_active='$agent_pause_codes_active',campaign_description='$campaign_description',campaign_changedate='$SQLdate',campaign_stats_refresh='$campaign_stats_refresh',disable_alter_custdata='$disable_alter_custdata',no_hopper_leads_logins='$no_hopper_leads_logins',list_order_mix='$list_order_mix',campaign_allow_inbound='$campaign_allow_inbound',manual_dial_list_id='$manual_dial_list_id',default_xfer_group='$default_xfer_group',xfer_groups='$XFERgroups_value',queue_priority='$queue_priority',drop_inbound_group='$drop_inbound_group',disable_alter_custphone='$disable_alter_custphone',display_queue_count='$display_queue_count',manual_dial_filter='$manual_dial_filter',agent_clipboard_copy='$agent_clipboard_copy',agent_extended_alt_dial='$agent_extended_alt_dial',use_campaign_dnc='$use_campaign_dnc',three_way_call_cid='$three_way_call_cid',three_way_dial_prefix='$three_way_dial_prefix',web_form_target='$web_form_target',vtiger_search_category='$vtiger_search_category',vtiger_create_call_record='$vtiger_create_call_record',vtiger_create_lead_record='$vtiger_create_lead_record' where campaign_id='$campaign_id';"; $rslt=mysql_query($stmtA, $link); if ($reset_hopper == 'Y') @@ -11773,6 +11790,8 @@ if ($ADD==31) $three_way_dial_prefix = $row[97]; $web_form_target = $row[98]; $vtiger_search_category = $row[99]; + $vtiger_create_call_record = $row[100]; + $vtiger_create_lead_record = $row[101]; if (ereg("DISABLED",$list_order_mix)) {$DEFlistDISABLE = ''; $DEFstatusDISABLED=0;} @@ -12210,10 +12229,16 @@ if ($ADD==31) if ($enable_vtiger_integration_LU > 0) { echo "
Vtiger Search Category: $NWB#vicidial_campaigns-vtiger_search_category$NWE
Vtiger Create Call Record: $NWB#vicidial_campaigns-vtiger_create_call_record$NWE
Vtiger Create Lead Record: $NWB#vicidial_campaigns-vtiger_create_lead_record$NWE