diff --git a/bin/ADMIN_keepalive_ALL.pl b/bin/ADMIN_keepalive_ALL.pl index ed46931e..2b7d80ca 100644 --- a/bin/ADMIN_keepalive_ALL.pl +++ b/bin/ADMIN_keepalive_ALL.pl @@ -15,6 +15,7 @@ # 80526-1350 - Added option 9 for timeclock auto-logout # 90211-1236 - Added auto-generation of conf files functions # 90213-0625 - Separated the reloading of Asterisk into 4 separate steps +# 90325-2239 - Rewrote sending of reload commands to Asterisk # $DB=0; # Debug flag @@ -506,11 +507,8 @@ if ( ($active_asterisk_server =~ /Y/) && ($generate_vicidial_conf =~ /Y/) && ($r { if ($DB) {print "generating new auto-gen conf files\n";} - if (-e "/root/asterisk_command_reload_iax2") - { - $stmtA="UPDATE servers SET rebuild_conf_files='N' where server_ip='$server_ip';"; - $affected_rows = $dbhA->do($stmtA); - } + $stmtA="UPDATE servers SET rebuild_conf_files='N' where server_ip='$server_ip';"; + $affected_rows = $dbhA->do($stmtA); ### format the new server_ip dialstring for example to use with extensions.conf $S='*'; @@ -883,34 +881,27 @@ if ( ($active_asterisk_server =~ /Y/) && ($generate_vicidial_conf =~ /Y/) && ($r if ($DB) {print "reloading asterisk\n";} if ($asterisk_version =~ /^1.2/) { - `echo iax2\ reload > /root/asterisk_command_reload_iax2`; - `echo sip\ reload > /root/asterisk_command_reload_sip`; - `echo extensions\ reload > /root/asterisk_command_reload_extensions`; - `echo reload\ app_voicemail.so > /root/asterisk_command_reload_voicemail`; + `screen -XS asterisk eval 'stuff "sip reload\015"'`; + sleep(1); + `screen -XS asterisk eval 'stuff "iax2 reload\015"'`; + sleep(1); + `screen -XS asterisk eval 'stuff "extensions reload\015"'`; + sleep(1); + `screen -XS asterisk eval 'stuff "reload app_voicemail.so\015"'`; + sleep(1); } else { - `echo iax2\ reload > /root/asterisk_command_reload_iax2`; - `echo sip\ reload > /root/asterisk_command_reload_sip`; - `echo dialplan\ reload > /root/asterisk_command_reload_extensions`; - `echo reload\ app_voicemail.so > /root/asterisk_command_reload_voicemail`; + `screen -XS asterisk eval 'stuff "sip reload\015"'`; + sleep(1); + `screen -XS asterisk eval 'stuff "iax2 reload\015"'`; + sleep(1); + `screen -XS asterisk eval 'stuff "dialplan reload\015"'`; + sleep(1); + `screen -XS asterisk eval 'stuff "module reload app_voicemail.so\015"'`; + sleep(1); } - `screen -XS asterisk readbuf /root/asterisk_command_reload_iax2`; - sleep(1); - `screen -XS asterisk paste .`; - sleep(3); - `screen -XS asterisk readbuf /root/asterisk_command_reload_sip`; - sleep(1); - `screen -XS asterisk paste .`; - sleep(3); - `screen -XS asterisk readbuf /root/asterisk_command_reload_extensions`; - sleep(1); - `screen -XS asterisk paste .`; - sleep(3); - `screen -XS asterisk readbuf /root/asterisk_command_reload_voicemail`; - sleep(1); - `screen -XS asterisk paste .`; - sleep(10); + } diff --git a/bin/VICIDIAL_IN_new_leads_file.pl b/bin/VICIDIAL_IN_new_leads_file.pl index 8d76bac6..f0a97ddf 100644 --- a/bin/VICIDIAL_IN_new_leads_file.pl +++ b/bin/VICIDIAL_IN_new_leads_file.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# VICIDIAL_IN_new_leads_file.pl version 2.0.5 *DBI-version* +# VICIDIAL_IN_new_leads_file.pl version 2.2.0 *DBI-version* # # DESCRIPTION: # script lets you insert leads into the vicidial_list table from a TAB-delimited @@ -8,7 +8,7 @@ # # It is recommended that you run this program on the local Asterisk machine # -# Copyright (C) 2008 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 # # # CHANGES @@ -31,6 +31,7 @@ # 80730-1607 - Added minicsv format # 80812-1204 - Added FTP grab options and summary email options # 80829-2301 - Added multi-alt-phone entry insertion capability +# 90324-1038 - Added minicsv02 format # $secX = time(); @@ -140,6 +141,9 @@ if (length($ARGV[0])>1) print "minicsv:\n"; print "address1,city,name,phone_number,state,postal_code\n"; print "\"105 Fifth St\",\"Steinhatchee\",\"Frank Smith\",\"3525556601\",\"FL\",\"32359\"\n\n"; + print "minicsv02:\n"; + print "name,address1,city,state,postal_code,phone_number\n"; + print "\"Adam Smith\",\"123 Fourth St\",\"Englishtown\",\"NS\",\"B0C1H0\",\"902-555-1212\"\n\n"; exit; } @@ -440,10 +444,47 @@ foreach(@FILES) $number =~ s/\"//gi; @m = split(/\|/, $number); + $format_set=0; + # This is the format for the minicsv02 lead files + # name,address1,city,state,postal_code,phone_number + # "Adam Smith","123 Fourth St","Englishtown","NS","B0C1H0","902-555-1212" + if ( ($format =~ /minicsv02/) && ($format_set < 1) ) + { + @name=@MT; + $vendor_lead_code = ''; + $source_code = ''; + $list_id = '995'; + $phone_code = '1'; + $phone_number = $m[5]; chomp($phone_number); $phone_number =~ s/\D//gi; + $USarea = substr($phone_number, 0, 3); + $title = ''; + $full_name = $m[0]; @name = split(/ /, $full_name); + $first_name = $name[0]; chomp($first_name); + $last_name = "$name[1] $name[2]"; chomp($first_name); + $middle_initial = ''; + $address1 = $m[1]; chomp($address1); + $address2 = ''; + $address3 = ''; + $city = $m[2]; chomp($city); + $state = $m[3]; chomp($state); + $province = ''; + $postal_code = $m[4]; chomp($postal_code); + $country = 'USA'; + $gender = 'U'; + $date_of_birth = '0000-00-00'; + $alt_phone = ''; + $email = ''; + $security_phrase = ''; + $comments = ''; + $called_count = 0; + $status = 'NEW'; + + $format_set++; + } # This is the format for the minicsv lead files #"105 Fifth St","Steinhatchee","Frank Smith","3525556601","FL","32359" - if ($format =~ /minicsv/) + if ( ($format =~ /minicsv/) && ($format_set < 1) ) { @name=@MT; $vendor_lead_code = ''; @@ -473,10 +514,12 @@ foreach(@FILES) $comments = ''; $called_count = 0; $status = 'NEW'; + + $format_set++; } # This is the format for the standard lead files #3857822|31022|105|01144|1625551212|MRS|B||BURTON|249 MUNDON ROAD|MALDON|ESSEX||||CM9 6PW|UK||||||COMMENTS - else + if ($format_set < 1) { $vendor_lead_code = $m[0]; chomp($vendor_lead_code); $source_code = $m[1]; chomp($source_code); $source_id = $source_code; diff --git a/bin/Vtiger_IN_new_accounts_file.pl b/bin/Vtiger_IN_new_accounts_file.pl index 6741b06a..88200f0a 100644 --- a/bin/Vtiger_IN_new_accounts_file.pl +++ b/bin/Vtiger_IN_new_accounts_file.pl @@ -391,11 +391,12 @@ foreach(@FILES) $number =~ s/,/\|/gi; @m = split(/\|/, $number); + $format_set=0; # This is the format for the minicsv lead files # business,contact,phone_number,address1,city,state,postal_code # "CHURCH","Bob Smith","3525556601","105 Fifth St","Steinhatchee","FL","32359" - if ($format =~ /minicsv/) + if ( ($format =~ /minicsv/) && ($format_set < 1) ) { $employees = '1'; $ticker_symbol = ''; @@ -418,13 +419,15 @@ foreach(@FILES) $emailoptout = '0'; $notify_owner = '0'; $country = 'USA'; + + $format_set++; } # This is the format for the vicidialalt(VICIDIAL alternate) lead files # employees,ticker_symbol,web1,revenue,account_name,address,po_box,city,state,post_code,phone_number,ownership,fax,email,other_phone,other_email,website,emailoptout,notify_owner # 4,C03IMM001,12345,2,ST MARK CHURCH,1710 W COLLEGE AVE,,CHICAGO,IL,61555,3095551111,PAUL SMITH,3095551212,TEST@VERIZON.NET,7775553333,test@1034.com,bigsite.com,1,0 # sic_code is left blank because it will be used by vicidial to put the last call dispo status in - if ($format =~ /vicidialalt/) + if ( ($format =~ /vicidialalt/) && ($format_set < 1) ) { $employees = $m[0]; chomp($employees); $employees =~ s/\D//gi; $ticker_symbol = $m[1]; chomp($ticker_symbol); @@ -451,12 +454,14 @@ foreach(@FILES) $notify_owner = $m[18]; chomp($notify_owner); $notify_owner =~ s/\D//gi; if (length($notify_owner)<1) {$notify_owner="0";} $country = 'USA'; + + $format_set++; } # This is the format for the standard lead files # employees,ticker_symbol,sic_code,revenue,account_name,address,po_box,city,state,post_code,phone_number,ownership,fax,email,other_phone,other_email,website # 4,C03IMM001,39207955,2,ST MARK CHURCH,1710 W COLLEGE AVE,,CHICAGO,IL,61555,3095551111,PAUL SMITH,3095551212,TEST@VERIZON.NET,7775553333,test@1034.com,bigsite.com - if ($format =~ /standard/) + if ( ($format =~ /standard/) || ($format_set < 1) ) { $employees = $m[0]; chomp($employees); $employees =~ s/\D//gi; $ticker_symbol = $m[1]; chomp($ticker_symbol); @@ -480,6 +485,8 @@ foreach(@FILES) $emailoptout = '0'; $notify_owner = '0'; $country = 'USA'; + + $format_set++; } if ($DBX) {print "$a|$phone_number|$account_name|$website\n";} diff --git a/bin/start_asterisk_boot.pl b/bin/start_asterisk_boot.pl index 349ff578..7704dc42 100644 --- a/bin/start_asterisk_boot.pl +++ b/bin/start_asterisk_boot.pl @@ -6,8 +6,9 @@ # # CHANGES # -# 60814-1658 - added option to start without logging through servers table setting +# 60814-1658 - Added option to start without logging through servers table setting # 90309-0905 - Added deleting of asterisk command files +# 90325-2238 - Rewrote launching of Asterisk, removed command files # # default path to astguiclient configuration file: @@ -61,46 +62,48 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA } $sthA->finish(); -if (-e "/root/asterisk_command_reload_iax2") - { - ### find the find binary - $findbin = ''; - if ( -e ('/bin/find')) {$findbin = '/bin/find';} - else - { - if ( -e ('/sbin/find')) {$findbin = '/sbin/find';} - else - { - if ( -e ('/usr/bin/find')) {$findbin = '/usr/bin/find';} - else - { - if ( -e ('/usr/local/bin/find')) {$findbin = '/usr/local/bin/find';} - else - { - print "Can't find find binary! Exiting...\n"; - } - } - } - } - - `$findbin /root/ -maxdepth 1 -name "asterisk_command*" -print | xargs rm -f`; - - `ulimit -n 65536`; - - } +`ulimit -n 65536`; if ($SYSLOG) { - print "\nStarting Asterisk... screen logging on\n"; - `/usr/bin/screen -L -d -m -S asterisk /usr/sbin/asterisk -vvvvvvvvvvvvvvvvvvvvvgc`; + `/usr/bin/screen -d -m -S astershell /usr/bin/screen -S astshell`; + print "started screen\n"; + + sleep(1); + `screen -XS astshell eval 'stuff "cd /var/log/astguiclient\015"'`; + print "changed directory\n"; + + sleep(1); + `screen -XS astshell eval 'stuff "screen -L -S asterisk\015"'`; + print "started new screen session\n"; + + sleep(1); + `screen -d astshell`; + `screen -d asterisk`; + print "detached screens\n"; + + sleep(1); + `screen -XS asterisk eval 'stuff "ulimit -n 65536\015"'`; + print "raised ulimit open files\n"; + + sleep(1); + `screen -XS asterisk eval 'stuff "/usr/sbin/asterisk -vvvvvvvvvvvvvvvvvvvvvgc\015"'`; + print "Asterisk started... screen logging on\n"; } else { - print "\nStarting Asterisk... screen logging off\n"; - `/usr/bin/screen -d -m -S asterisk /usr/sbin/asterisk -vvvvgc`; + `/usr/bin/screen -d -m -S astershell /usr/bin/screen -S asterisk`; + print "started screen\n"; + + sleep(1); + `screen -d asterisk`; + print "detached screen\n"; + + sleep(1); + `screen -XS asterisk eval 'stuff "ulimit -n 65536\015"'`; + print "raised ulimit open files\n"; + + sleep(1); + `screen -XS asterisk eval 'stuff "/usr/sbin/asterisk -vvvvgc\015"'`; + print "Asterisk started... screen logging off\n"; } - -print "Asterisk started\n"; - -sleep(10); - diff --git a/docs/VTIGER.txt b/docs/VTIGER.txt index a71a936b..24d5b667 100644 --- a/docs/VTIGER.txt +++ b/docs/VTIGER.txt @@ -7,6 +7,9 @@ Current integration features: - User synchronization of VICIDIAL users to Vtiger user database - User Group synchronization of VICIDIAL user groups to Vtiger Groups - Added activity event option(call logging in Vtiger) when going from VICIDIAL to Vtiger + (Or this can be done in the background without having to use the web form) +- Added ViciDial status synchronization after each call to set the siccode field in Vtiger to the last selected VICIDIAL status +- Ability to un-delete or resurrect deleted Accounts within Vtiger from the web form(this is a VICIDIAL campaign option) - Ability to click-to-dial a phone number from a record in Vtiger screen to the vicidial.php screen - Optional script to bulk load leads into Vtiger from a CSV file since Vtiger only seems to want to load 500 at a time: Vtiger_IN_new_accounts_file.pl @@ -16,7 +19,7 @@ Current integration features: 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 lead. -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 with about 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(Vtiger504_vicidial.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 one thing 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. Another purpose of this patch is to allow for click-to-dial phone numbers in Vtiger, so that the numbers will be dialed as manual dial calls in a VICIDIAL agent screen. For this to work you must have applied the patch, you need to have user 1000 set up in VICIDIAL with a password of 1234 and Agent API set to '1', and the agent needs to be logged into vicidial.php(there is also a VICIDIAL Campaign Detail option to automatically login to Vtiger when an agent logs into vicidial.php) then when the agent clicks on any phone number with a "VCcall:" lable bext to it, a call will be placed in their vicidial.php agent screen and the Vtiger window will be closed so that they can open it up again with the vicidial.php WEB FORM button in VICIDIAL. +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 with about 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(Vtiger504_vicidial.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 one thing 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. Another purpose of this patch is to allow for click-to-dial phone numbers in Vtiger, so that the numbers will be dialed as manual dial calls in a VICIDIAL agent screen. For this to work you must have applied the patch, you need to have user 1000 set up in VICIDIAL with a password of 1234 and Agent API set to '1', and the agent needs to be logged into vicidial.php(there is also a VICIDIAL Campaign Detail option to automatically login to Vtiger when an agent logs into vicidial.php, this can log the agent into Vtiger within the SCRIPT tab or by opening a new browser window) then when the agent clicks on any phone number with a "VCcall:" label next to it, a call will be placed in their vicidial.php agent screen and the Vtiger window will be closed(or left open if using alternate patch) so that they can open it up again with the vicidial.php WEB FORM button in VICIDIAL. 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. @@ -318,3 +321,23 @@ Click-to-dial: uitype = '11' for phone fields + +Use of custom fields for dates within Vtiger, these date fields will be updated by VICIDIAL if the status(siccode) update option is set to Y: + +mysql> select * from vtiger_field where fieldlabel LIKE "%Date%" and fieldname LIKE "cf%"; ++-------+---------+------------+-------------------+---------------+--------+-----------+--------------------------+----------+----------+----------+---------------+----------+-------+-------------+------------+-------------+---------------------+-----------+ +| tabid | fieldid | columnname | tablename | generatedtype | uitype | fieldname | fieldlabel | readonly | presence | selected | maximumlength | sequence | block | displaytype | typeofdata | quickcreate | quickcreatesequence | info_type | ++-------+---------+------------+-------------------+---------------+--------+-----------+--------------------------+----------+----------+----------+---------------+----------+-------+-------------+------------+-------------+---------------------+-----------+ +| 6 | 475 | cf_474 | vtiger_accountscf | 2 | 5 | cf_474 | Date of Last Attempt | 0 | 0 | 0 | 100 | 15 | 10 | 1 | D~O | 1 | 0 | BAS | +| 6 | 533 | cf_532 | vtiger_accountscf | 2 | 5 | cf_532 | Date of Last Non-Contact | 0 | 0 | 0 | 100 | 50 | 10 | 1 | D~O | 1 | 0 | BAS | +| 6 | 535 | cf_534 | vtiger_accountscf | 2 | 5 | cf_534 | Date of Last Contact | 0 | 0 | 0 | 100 | 51 | 10 | 1 | D~O | 1 | 0 | BAS | +| 6 | 537 | cf_536 | vtiger_accountscf | 2 | 5 | cf_536 | Date of Last Sale | 0 | 0 | 0 | 100 | 52 | 10 | 1 | D~O | 1 | 0 | BAS | ++-------+---------+------------+-------------------+---------------+--------+-----------+--------------------------+----------+----------+----------+---------------+----------+-------+-------------+------------+-------------+---------------------+-----------+ + +mysql> select * from vtiger_accountscf where accountid='6762'; ++-----------+------------+----------+------------+--------+------------+------------+------------+---------+----------+-----------------------------------+--------+---------------------+--------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ +| accountid | cf_456 | cf_464 | cf_474 | cf_530 | cf_532 | cf_534 | cf_536 | cf_538 | cf_540 | cf_542 | cf_544 | cf_546 | cf_548 | cf_550 | cf_552 | cf_554 | cf_556 | cf_558 | cf_560 | cf_562 | cf_564 | cf_566 | cf_568 | ++-----------+------------+----------+------------+--------+------------+------------+------------+---------+----------+-----------------------------------+--------+---------------------+--------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ +| 6762 | 2009-03-25 | 12:30 pm | 2009-03-09 | Sale | 2009-03-01 | 2009-03-09 | 2009-03-09 | 1500.75 | 30000.00 | Breakroom |##| Jan/San |##| Paper | Hot | Test Decision Maker | 610-701-9661 | | | | | | 1 | 1 | 1 | 1 | 0 | ++-----------+------------+----------+------------+--------+------------+------------+------------+---------+----------+-----------------------------------+--------+---------------------+--------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ + diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index c169df3f..452adf74 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -192,12 +192,14 @@ # 90305-1041 - Added agent_dialed_number and type for user_call_log feature # 90307-1735 - Added Shift enforcement and manager override features # 90320-0306 - Fixed agent log bug when using wrapup time +# 90323-2013 - Added function to put phone numbers in the DNC lists if they were set to status type dnc=Y +# 90324-1316 - Added functions to log calls to Vtiger accounts and update status to siccode # -$version = '2.0.5-104'; -$build = '90320-0306'; +$version = '2.2.0-106'; +$build = '90324-1316'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=194; +$mysql_log_count=210; $one_mysql_log=0; require("dbconnect.php"); @@ -3336,7 +3338,41 @@ if ($ACTION == 'updateDISPO') if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00145',$user,$server_ip,$session_name,$one_mysql_log);} } - if ( ($use_internal_dnc=='Y') and ($dispo_choice=='DNC') ) + ### find all DNC-type statuses in the system + if ( ($use_internal_dnc=='Y') or ($use_campaign_dnc=='Y') ) + { + $DNC_string_check = '|'; + $stmt = "SELECT status FROM vicidial_statuses where dnc='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00195',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $dncvs_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $dncvs_ct) + { + $row=mysql_fetch_row($rslt); + $DNC_string_check .= "$row[0]|"; + $i++; + } + + $stmt = "SELECT status FROM vicidial_campaign_statuses where dnc='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00196',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $dncvcs_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $dncvcs_ct) + { + $row=mysql_fetch_row($rslt); + $DNC_string_check .= "$row[0]"; + $i++; + } + + # echo "$DNC_string_check"; + } + + $insert_into_dnc=0; + if ( ($use_internal_dnc=='Y') and (eregi("\|$dispo_choice\|", $DNC_string_check) ) ) { $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; if ($DB) {echo "$stmt\n";} @@ -3347,8 +3383,9 @@ if ($ACTION == 'updateDISPO') $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00147',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} + $insert_into_dnc++; } - if ( ($use_campaign_dnc=='Y') and ($dispo_choice=='DNC') ) + if ( ($use_campaign_dnc=='Y') and (eregi("\|$dispo_choice\|", $DNC_string_check) ) ) { $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; if ($DB) {echo "$stmt\n";} @@ -3359,6 +3396,7 @@ if ($ACTION == 'updateDISPO') $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00149',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} + $insert_into_dnc++; } } @@ -3449,6 +3487,315 @@ if ($ACTION == 'updateDISPO') if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00158',$user,$server_ip,$session_name,$one_mysql_log);} } + ####### START Vtiger Call Logging ####### + $stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00197',$user,$server_ip,$session_name,$one_mysql_log);} + $ss_conf_ct = mysql_num_rows($rslt); + if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration = $row[0]; + $vtiger_server_ip = $row[1]; + $vtiger_dbname = $row[2]; + $vtiger_login = $row[3]; + $vtiger_pass = $row[4]; + $vtiger_url = $row[5]; + } + + if ($enable_vtiger_integration > 0) + { + $stmt = "SELECT vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_search_dead,vtiger_status_call FROM vicidial_campaigns where campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00198',$user,$server_ip,$session_name,$one_mysql_log);} + $vtc_conf_ct = mysql_num_rows($rslt); + if ($vtc_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $vtiger_search_category = $row[0]; + $vtiger_create_call_record = $row[1]; + $vtiger_create_lead_record = $row[2]; + $vtiger_search_dead = $row[3]; + $vtiger_status_call = $row[4]; + } + if ( (ereg('ACCTID',$vtiger_search_category)) or (ereg('ACCOUNT',$vtiger_search_category)) ) + { + ### connect to your vtiger database + $linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass"); + if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysql_error());} + mysql_select_db("$vtiger_dbname", $linkV); + + $stmt = "SELECT vendor_lead_code FROM vicidial_list where lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00210',$user,$server_ip,$session_name,$one_mysql_log);} + $vlc_ct = mysql_num_rows($rslt); + if ($vlc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $vendor_id = $row[0]; + } + + # make sure the ID is present in Vtiger database as an account + $stmt="SELECT count(*) from vtiger_account where accountid='$vendor_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00199',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VIDcount = $row[0]; + if ($VIDcount > 0) + { + ### create a call record in vtiger linked to the account + if (ereg('DISPO',$vtiger_create_call_record)) + { + $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); + + #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); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00200',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $user_id = $row[0]; + + # 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); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00201',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $activityid = ($row[0] + 1); + + # 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 ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00202',$user,$server_ip,$session_name,$one_mysql_log);} + + #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 ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00203',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "|$leadid|\n";} + + #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 ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00204',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "|$leadid|\n";} + + #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 ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00205',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "|$leadid|\n";} + + #Insert values into vtiger_activity + $stmt = "INSERT INTO vtiger_activity SET activityid='$activityid',subject='VICIDIAL Account call $vendor_id status $dispo_choice',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 ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00206',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "|$leadid|\n";} + } + ### update the status of the record in vtiger + if (ereg('Y',$vtiger_status_call)) + { + #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); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00207',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $user_id = $row[0]; + + #Update vtiger_crmentity + $stmt = "UPDATE vtiger_crmentity SET modifiedby='$user_id', modifiedtime='$NOW_TIME' where crmid='$vendor_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00208',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "|$leadid|\n";} + + if ($insert_into_dnc > 0) {$emailoptoutSQL = ", emailoptout='1'";} + #Update vtiger_account dnc=emailoptout + $stmt = "UPDATE vtiger_account SET siccode='$dispo_choice' $emailoptoutSQL where accountid='$vendor_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00209',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "|$leadid|\n";} + + + ### check and see if the custom date fields exist, if they do then update them if necessary + # Date of Last Attempt, Date of Last Non-Contact, Date of Last Contact, Date of Last Sale + + # first find the sale statuses that are in the system + $SALE_string_check = '|'; + $stmt = "SELECT status FROM vicidial_statuses where sale='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00211',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $salevs_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $salevs_ct) + { + $row=mysql_fetch_row($rslt); + $SALE_string_check .= "$row[0]|"; + $i++; + } + $stmt = "SELECT status FROM vicidial_campaign_statuses where sale='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00212',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $salevcs_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $salevcs_ct) + { + $row=mysql_fetch_row($rslt); + $SALE_string_check .= "$row[0]"; + $i++; + } + + # second find the customer contact statuses that are in the system + $CC_string_check = '|'; + $stmt = "SELECT status FROM vicidial_statuses where customer_contact='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00213',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cc_vs_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $cc_vs_ct) + { + $row=mysql_fetch_row($rslt); + $CC_string_check .= "$row[0]|"; + $i++; + } + $stmt = "SELECT status FROM vicidial_campaign_statuses where customer_contact='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00214',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cc_vcs_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $cc_vcs_ct) + { + $row=mysql_fetch_row($rslt); + $CC_string_check .= "$row[0]"; + $i++; + } + + # third calculate what custom date fields need their date updated + $VT_last_noncontact_update=0; $VT_last_noncontact_ct=0; + $VT_last_contact_update=0; $VT_last_contact_ct=0; + $VT_last_sale_update=0; $VT_last_sale_ct=0; + if (eregi("\|$dispo_choice\|", $SALE_string_check) ) + {$VT_last_sale_update++;} + if (eregi("\|$dispo_choice\|", $CC_string_check) ) + {$VT_last_contact_update++;} + else + {$VT_last_noncontact_update++;} + + # fourth see if the vtiger database has the custom date fields in it + $stmt="SELECT count(*) from vtiger_field where fieldlabel='Date of Last Attempt';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00215',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_attempt_ct = $row[0]; + + if ($VT_last_noncontact_update > 0) + { + $stmt="SELECT count(*) from vtiger_field where fieldlabel='Date of Last Non-Contact';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00216',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_noncontact_ct = $row[0]; + } + if ($VT_last_contact_update > 0) + { + $stmt="SELECT count(*) from vtiger_field where fieldlabel='Date of Last Contact';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00217',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_contact_ct = $row[0]; + } + if ($VT_last_sale_update > 0) + { + $stmt="SELECT count(*) from vtiger_field where fieldlabel='Date of Last Sale';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00218',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_sale_ct = $row[0]; + } + + # fifth find the fieldnames if they exist and update the dates + if ($VT_last_attempt_ct > 0) + { + $stmt="SELECT fieldname from vtiger_field where fieldlabel='Date of Last Attempt';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00219',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_attempt_field = $row[0]; + + $stmt = "UPDATE vtiger_accountscf SET $VT_last_attempt_field='$TODAY' where accountid='$vendor_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00223',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($VT_last_noncontact_ct > 0) + { + $stmt="SELECT fieldname from vtiger_field where fieldlabel='Date of Last Non-Contact';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00220',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_noncontact_field = $row[0]; + + $stmt = "UPDATE vtiger_accountscf SET $VT_last_noncontact_field='$TODAY' where accountid='$vendor_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00224',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($VT_last_contact_ct > 0) + { + $stmt="SELECT fieldname from vtiger_field where fieldlabel='Date of Last Contact';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00221',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_contact_field = $row[0]; + + $stmt = "UPDATE vtiger_accountscf SET $VT_last_contact_field='$TODAY' where accountid='$vendor_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00225',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($VT_last_sale_ct > 0) + { + $stmt="SELECT fieldname from vtiger_field where fieldlabel='Date of Last Sale';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00222',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_sale_field = $row[0]; + + $stmt = "UPDATE vtiger_accountscf SET $VT_last_sale_field='$TODAY' where accountid='$vendor_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00226',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + } + } + } + ####### END Vtiger Call Logging ####### + ############################################# ##### START QUEUEMETRICS LOGGING LOOKUP ##### $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; diff --git a/www/agc/vicidial.php b/www/agc/vicidial.php index cc54d8cd..aa92bc36 100644 --- a/www/agc/vicidial.php +++ b/www/agc/vicidial.php @@ -6162,6 +6162,8 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} xmlhttp.send(DSupdate_query); xmlhttp.onreadystatechange = function() { + // alert(xmlhttp.responseText); + if ( (xmlhttp.readyState == 4 && xmlhttp.status == 200) && (auto_dial_level < 1) ) { var check_dispo = null; @@ -7369,8 +7371,16 @@ else if ( (VtigeRLogiNScripT == 'Y') && (VtigeREnableD > 0) ) { document.getElementById("ScriptContents").innerHTML = " "; - } + if ( (VtigeRLogiNScripT == 'NEW_WINDOW') && (VtigeREnableD > 0) ) + { + var VtigeRall = VtigeRurl + "/index.php?module=Users&action=Authenticate&return_module=Users&return_action=Login&user_name=" + user + "&user_password=" + pass + "&login_theme=softed&login_language=en_us"; + + VtigeRwin =window.open(VtigeRall, web_form_target,'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width=700,height=480'); + + VtigeRwin.blur(); + } + VICIDiaL_closer_login_checked = 1; } else diff --git a/www/vicidial/vtiger_search.php b/www/vicidial/vtiger_search.php index 5e9c9761..fa38bfed 100644 --- a/www/vicidial/vtiger_search.php +++ b/www/vicidial/vtiger_search.php @@ -18,6 +18,7 @@ # 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 +# 90323-2104 - Added deleted account/lead check and reactivation from campaign option # header ("Content-type: text/html; charset=utf-8"); @@ -152,7 +153,7 @@ if ($enable_vtiger_integration < 1) exit; } -$stmt = "SELECT vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record FROM vicidial_campaigns where campaign_id='$campaign';"; +$stmt = "SELECT vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_search_dead FROM vicidial_campaigns where campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $vtc_conf_ct = mysql_num_rows($rslt); @@ -162,6 +163,7 @@ if ($vtc_conf_ct > 0) $vtiger_search_category = $row[0]; $vtiger_create_call_record = $row[1]; $vtiger_create_lead_record = $row[2]; + $vtiger_search_dead = $row[3]; } if (strlen($vtiger_search_category)<1) {$vtiger_search_category = 'LEAD';} @@ -219,78 +221,102 @@ if ($acctid_search > 0) } else { - if (ereg('Y',$vtiger_create_call_record)) + $stmt="SELECT count(*) from vtiger_crmentity where crmid='$vendor_id' and deleted='1';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $deleted_count = $row[0]; + if ( ($deleted_count > 0) and (ereg('DISABLED',$vtiger_search_dead)) ) { - ### 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"; + echo "\n"; } 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"; - echo "
\n"; + if ( ($deleted_count > 0) and ( (ereg('RESURRECT',$vtiger_search_dead)) or (ereg('ASK',$vtiger_search_dead)) ) ) + { + # un-delete the record + $stmt="UPDATE vtiger_crmentity SET deleted='0' where crmid='$vendor_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + echo "\n"; + } - echo "
";
-		echo "account found! ACCTID\n";
-		echo "accountid:   $vendor_id\n";
-		echo "

"; - exit; + 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"; + echo "
\n"; + + echo "
";
+			echo "account found! ACCTID\n";
+			echo "accountid:   $vendor_id\n";
+			echo "

"; + exit; + } } } ########################################################################## @@ -380,79 +406,102 @@ if ($account_search > 0) } if (strlen($accountid) > 0) { - if (ereg('Y',$vtiger_create_call_record)) + $stmt="SELECT count(*) from vtiger_crmentity where crmid='$accountid' and deleted='1';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $deleted_count = $row[0]; + if ( ($deleted_count > 0) and (ereg('DISABLED',$vtiger_search_dead)) ) { - ### 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"; + echo "\n"; } 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"; - echo "
\n"; + if ( ($deleted_count > 0) and ( (ereg('RESURRECT',$vtiger_search_dead)) or (ereg('ASK',$vtiger_search_dead)) ) ) + { + # un-delete the record + $stmt="UPDATE vtiger_crmentity SET deleted='0' where crmid='$accountid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + echo "\n"; + } + if (ereg('Y',$vtiger_create_call_record)) + { + ### Log the call in Vtiger - echo "
";
-		echo "account found! ACCOUNT\n";
-		echo "accountid:   $accountid\n";
-		echo "phone:       $phone\n";
-		echo "

"; - exit; + #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"; + echo "
\n"; + + echo "
";
+			echo "account found! ACCOUNT\n";
+			echo "accountid:   $accountid\n";
+			echo "phone:       $phone\n";
+			echo "

"; + exit; + } } } ########################################################################## @@ -675,80 +724,104 @@ if ($lead_search > 0) $row=mysql_fetch_row($rslt); $leadid = $row[0]; - if (ereg('Y',$vtiger_create_call_record)) + $stmt="SELECT count(*) from vtiger_crmentity where crmid='$leadid' and deleted='1';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $deleted_count = $row[0]; + if ( ($deleted_count > 0) and (ereg('DISABLED',$vtiger_search_dead)) ) { - ### 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"; + echo "\n"; } 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"; - echo "
\n"; + if ( ($deleted_count > 0) and ( (ereg('RESURRECT',$vtiger_search_dead)) or (ereg('ASK',$vtiger_search_dead)) ) ) + { + # un-delete the record + $stmt="UPDATE vtiger_crmentity SET deleted='0' where crmid='$leadid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + echo "\n"; + } - echo "
";
-		echo "lead found! LEAD\n";
-		echo "leadid:   $leadid\n";
-		echo "phone:       $phone\n";
-		echo "

"; - exit; + 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"; + echo "
\n"; + + echo "
";
+			echo "lead found! LEAD\n";
+			echo "leadid:   $leadid\n";
+			echo "phone:       $phone\n";
+			echo "

"; + exit; + } } } ##########################################################################