diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index de0f13f6..0d2a7c2b 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -217,6 +217,11 @@ NOTE: Upgrading from 1.1.12-3 to 2.0.1 is at the bottom features to existing inbound report. Created IVR stats report to show stats on Asterisk IVRs +49. Updated Vtiger integration to version 5.0.4 and allow searching by + leads/accounts/vendors. Also added user synchronization with vicidial_users + +50. Added notification of time synchronization problems in the vicidial.php page + diff --git a/agc_2-X/trunk/agi/agi-IVR_recording_verification.agi b/agc_2-X/trunk/agi/agi-IVR_recording_verification.agi index bfc4aa26..2b378c5d 100644 --- a/agc_2-X/trunk/agi/agi-IVR_recording_verification.agi +++ b/agc_2-X/trunk/agi/agi-IVR_recording_verification.agi @@ -35,11 +35,11 @@ #exten => 1234,5,Hangup # # ;inbound IVR call from a VICIDIAL transfer: -#exten => _83002*,1,Ringing ; call ringing -#exten => _83002*,2,Wait(1) ; Wait 1 second for CID delivery -#exten => _83002*,3,Answer ; Answer the line -#exten => _83002*,4,AGI(agi-IVR_recording_verification.agi,7275551234---N---Y---N---N---Y-10-85100001---N---85100002-85100003---85100004---BOTH) -#exten => _83002*,5,Hangup +#exten => _83002*.,1,Ringing ; call ringing +#exten => _83002*.,2,Wait(1) ; Wait 1 second for CID delivery +#exten => _83002*.,3,Answer ; Answer the line +#exten => _83002*.,4,AGI(agi-IVR_recording_verification.agi,7275551234---N---Y---N---N---Y-10-85100001---N---85100002-85100003---85100004---BOTH) +#exten => _83002*.,5,Hangup # # # Copyright (C) 2007 Matt Florell LICENSE: AGPLv2 @@ -256,6 +256,26 @@ if ($extension =~ /^832\d\d\*|^833\d\d\*/) # prompt_response_9 TINYINT(1) UNSIGNED default '0', # prompt_audio_10 VARCHAR(20), # prompt_response_10 TINYINT(1) UNSIGNED default '0', +# prompt_audio_11 VARCHAR(20), +# prompt_response_11 TINYINT(1) UNSIGNED default '0', +# prompt_audio_12 VARCHAR(20), +# prompt_response_12 TINYINT(1) UNSIGNED default '0', +# prompt_audio_13 VARCHAR(20), +# prompt_response_13 TINYINT(1) UNSIGNED default '0', +# prompt_audio_14 VARCHAR(20), +# prompt_response_14 TINYINT(1) UNSIGNED default '0', +# prompt_audio_15 VARCHAR(20), +# prompt_response_15 TINYINT(1) UNSIGNED default '0', +# prompt_audio_16 VARCHAR(20), +# prompt_response_16 TINYINT(1) UNSIGNED default '0', +# prompt_audio_17 VARCHAR(20), +# prompt_response_17 TINYINT(1) UNSIGNED default '0', +# prompt_audio_18 VARCHAR(20), +# prompt_response_18 TINYINT(1) UNSIGNED default '0', +# prompt_audio_19 VARCHAR(20), +# prompt_response_19 TINYINT(1) UNSIGNED default '0', +# prompt_audio_20 VARCHAR(20), +# prompt_response_20 TINYINT(1) UNSIGNED default '0', # index (phone_number), # index (entry_time) # ); diff --git a/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt b/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt index 831dc424..dcd199bb 100644 --- a/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt +++ b/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt @@ -192,13 +192,13 @@ make install cd /usr/local -wget http://us2.php.net/distributions/php-5.2.6.tar.gz -gunzip php-5.2.6.tar.gz -tar xvf php-5.2.6.tar -wget http://mirror.candidhosting.com/pub/apache/httpd/httpd-2.2.10.tar.gz -gunzip httpd-2.2.10.tar.gz -tar xvf httpd-2.2.10.tar -cd httpd-2.2.10 +wget http://us2.php.net/distributions/php-5.2.8.tar.gz +gunzip php-5.2.8.tar.gz +tar xvf php-5.2.8.tar +wget http://mirror.nyi.net/apache/httpd/httpd-2.2.11.tar.gz +gunzip httpd-2.2.11.tar.gz +tar xvf httpd-2.2.11.tar +cd httpd-2.2.11 make clean ./configure --prefix=/usr/local/apache2 --enable-ssl --enable-setenvif --enable-so --with-apxs2 --enable-dav --enable-maintainer-mode make @@ -212,7 +212,7 @@ openssl req -new -x509 -days 1200 -keyout /usr/local/apache2/conf/ssl.key/server openssl rsa -in /usr/local/apache2/conf/ssl.key/server.key.cpy -out /usr/local/apache2/conf/ssl.key/server.key -cd ../php-5.2.6 +cd ../php-5.2.8 make clean ./configure --with-mysql=/usr/local/mysql --enable-inline-optimization --enable-memory-limit --enable-track-vars --enable-libgcc --enable-sysvsem --with-openssl --with-apxs2=/usr/local/apache2/bin/apxs --with-zlib make diff --git a/agc_2-X/trunk/docs/VTIGER.txt b/agc_2-X/trunk/docs/VTIGER.txt new file mode 100644 index 00000000..791da980 --- /dev/null +++ b/agc_2-X/trunk/docs/VTIGER.txt @@ -0,0 +1,227 @@ +VICIDIAL and Vtiger + +Current VICIDIAL integration with Vtiger is for the 5.0.4 release version of Vtiger only + +Current integration features: +- vicidial.php WEBFORM search for lead/account/vendor +- user synchronization of VICIDIAL users to Vtiger user database + +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. + +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. + 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 + 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. + +Here are the SQL queries used by the vtiger_search.php script to find records in the vtiger system: + +ACCTID: +$stmt="SELECT count(*) from vtiger_account where accountid='$vendor_id';"; + +ACCOUNT: +$stmt="SELECT count(*) from vtiger_account where phone='$phone' or otherphone='$phone' or fax='$phone';"; +$stmt="SELECT count(*) from vtiger_contactdetails where phone='$phone' or mobile='$phone' or fax='$phone';"; +$stmt="SELECT count(*) from vtiger_contactsubdetails where homephone='$phone' or otherphone='$phone' or assistantphone='$phone';"; + +VENDOR: +$stmt="SELECT count(*) from vtiger_vendor where phone='$phone';"; + +LEAD: +$stmt="SELECT count(*) from vtiger_leadaddress where phone='$phone' or mobile='$phone' or fax='$phone';"; + + + + + +Here is a short summary of the needed steps to install vtiger on your system: + +NOTE: vtiger requires PHP5, APACHE2.2 and MySQL5, + see the REQUIRED_APPS.txt doc for install instructions for those packages + + +mysql +GRANT ALL on vtigercrm504.* TO vtiger@'%' IDENTIFIED BY 'vtuser'; +GRANT ALL on vtigercrm504.* TO vtiger@localhost IDENTIFIED BY 'vtuser'; +create database vtigercrm504; +quit + +cd /usr/local/apache2/htdocs/ +wget http://voxel.dl.sourceforge.net/sourceforge/vtigercrm/vtigercrm-5.0.4.tar.gz +gunzip vtigercrm-5.0.4.tar.gz +tar xvf vtigercrm-5.0.4.tar +chmod -R 0777 vtigercrm +cd vtigercrm +ls -l +* in browser go to the following URL: http://ip-address/vtigetcrm/index.php +* enter contact info and click the START button at the bottom of the screen +* in system configuration set the database host to: +* database user/pass: vtiger/vtuser +* database name: vtigercrm504 +* change default admin(vtadmin) and standarduser(vtuser) passwords +* click to install vtiger, then follow the on-screen instructions +# patch vtiger to fix issue with user synchronization: +wget http://www.eflo.net/files/vtiger_user_file_504.patch +patch -p1 < ./vtiger_user_file_504.patch + + + + + +Now to explain the database side of things. +First, here is how users are stored in vtiger: + +THE USER TABLES: +vtiger_users +vtiger_user2role +vtiger_users2group +vtiger_users_last_import +vtiger_users_seq +vtiger_usertype + + +TABLE DETAIL: + +The vtiger_users table has the basic user information for users fo the vtiger system. An agent must have an entry in this table to be able to access the vtigers system. user_name is the field that is synchronized with the vicidial_users.user field in VICIDIAL. +mysql> describe vtiger_users; ++--------------------+--------------+------+-----+-----------------------------------------------------------------+----------------+ +| Field | Type | Null | Key | Default | Extra | ++--------------------+--------------+------+-----+-----------------------------------------------------------------+----------------+ +| id | int(11) | NO | PRI | NULL | auto_increment | +| user_name | varchar(255) | YES | MUL | NULL | | +| user_password | varchar(30) | YES | MUL | NULL | | +| user_hash | varchar(32) | YES | | NULL | | +| cal_color | varchar(25) | YES | | #E6FAD8 | | +| first_name | varchar(30) | YES | | NULL | | +| last_name | varchar(30) | YES | | NULL | | +| reports_to_id | varchar(36) | YES | | NULL | | +| is_admin | varchar(3) | YES | | 0 | | +| currency_id | int(19) | NO | | 1 | | +| description | text | YES | | NULL | | +| date_entered | timestamp | NO | | CURRENT_TIMESTAMP | | +| date_modified | timestamp | NO | | 0000-00-00 00:00:00 | | +| modified_user_id | varchar(36) | YES | | NULL | | +| title | varchar(50) | YES | | NULL | | +| department | varchar(50) | YES | | NULL | | +| phone_home | varchar(50) | YES | | NULL | | +| phone_mobile | varchar(50) | YES | | NULL | | +| phone_work | varchar(50) | YES | | NULL | | +| phone_other | varchar(50) | YES | | NULL | | +| phone_fax | varchar(50) | YES | | NULL | | +| email1 | varchar(100) | YES | | NULL | | +| email2 | varchar(100) | YES | | NULL | | +| yahoo_id | varchar(100) | YES | | NULL | | +| status | varchar(25) | YES | | NULL | | +| signature | varchar(250) | YES | | NULL | | +| address_street | varchar(150) | YES | | NULL | | +| address_city | varchar(100) | YES | | NULL | | +| address_state | varchar(100) | YES | | NULL | | +| address_country | varchar(25) | YES | | NULL | | +| address_postalcode | varchar(9) | YES | | NULL | | +| user_preferences | text | YES | | NULL | | +| tz | varchar(30) | YES | | NULL | | +| holidays | varchar(60) | YES | | NULL | | +| namedays | varchar(60) | YES | | NULL | | +| workdays | varchar(30) | YES | | NULL | | +| weekstart | int(11) | YES | | NULL | | +| date_format | varchar(200) | YES | | NULL | | +| hour_format | varchar(30) | YES | | am/pm | | +| start_hour | varchar(30) | YES | | 10:00 | | +| end_hour | varchar(30) | YES | | 23:00 | | +| homeorder | varchar(255) | YES | | HDB,ALVT,PLVT,QLTQ,CVLVT,HLT,OLV,GRT,OLTSO,ILTI,MNL,OLTPO,LTFAQ | | +| activity_view | varchar(200) | YES | | Today | | +| lead_view | varchar(200) | YES | | Today | | +| imagename | varchar(250) | YES | | NULL | | +| deleted | int(1) | NO | | 0 | | +| defhomeview | varchar(100) | YES | | NULL | | +| confirm_password | varchar(30) | YES | | NULL | | +| tagcloud_view | int(1) | YES | | 1 | | +| internal_mailer | varchar(3) | NO | | 1 | | +| crypt_type | varchar(20) | NO | | MD5 | | ++--------------------+--------------+------+-----+-----------------------------------------------------------------+----------------+ +mysql> select * from vtiger_users; ++----+--------------+------------------------------+----------------------------------+-----------+------------+---------------+---------------+----------+-------------+-------------+---------------------+---------------------+------------------+-------+------------+------------+--------------+------------+-------------+-----------+--------------------+--------+----------+--------+-----------+----------------+--------------+---------------+-----------------+--------------------+------------------+------+----------+----------+----------+-----------+-------------+-------------+------------+----------+-----------------------------------------------------------------+---------------+-----------+-----------+---------+-------------+------------------------------+---------------+-----------------+------------+ +| id | user_name | user_password | user_hash | cal_color | first_name | last_name | reports_to_id | is_admin | currency_id | description | date_entered | date_modified | modified_user_id | title | department | phone_home | phone_mobile | phone_work | phone_other | phone_fax | email1 | email2 | yahoo_id | status | signature | address_street | address_city | address_state | address_country | address_postalcode | user_preferences | tz | holidays | namedays | workdays | weekstart | date_format | hour_format | start_hour | end_hour | homeorder | activity_view | lead_view | imagename | deleted | defhomeview | confirm_password | tagcloud_view | internal_mailer | crypt_type | ++----+--------------+------------------------------+----------------------------------+-----------+------------+---------------+---------------+----------+-------------+-------------+---------------------+---------------------+------------------+-------+------------+------------+--------------+------------+-------------+-----------+--------------------+--------+----------+--------+-----------+----------------+--------------+---------------+-----------------+--------------------+------------------+------+----------+----------+----------+-----------+-------------+-------------+------------+----------+-----------------------------------------------------------------+---------------+-----------+-----------+---------+-------------+------------------------------+---------------+-----------------+------------+ +| 1 | admin | $1$ad$hsl2KFybNRnbXBa.b.WWv. | 21232f297a57a5a743894a0e4a801fc3 | #E6FAD8 | | Administrator | | on | 1 | | 2008-12-27 22:51:30 | 0000-00-00 00:00:00 | NULL | | | | | | | | mattf@vicidial.com | | | Active | | | | | | | NULL | NULL | NULL | NULL | NULL | NULL | yyyy-mm-dd | am/pm | 08:00 | 23:00 | HDB,ALVT,PLVT,QLTQ,CVLVT,HLT,OLV,GRT,OLTSO,ILTI,MNL,OLTPO,LTFAQ | This Week | Today | | 0 | NULL | $1$ad$peilFE10wX.4b0aIm7/.t/ | 1 | 1 | MD5 | +| 2 | standarduser | $1$st$k35HABw/iAKXXthyFMLPF/ | NULL | #E6FAD8 | | StandardUser | | off | 1 | | 2008-12-27 22:47:55 | 0000-00-00 00:00:00 | NULL | | | | | | | | mattf@vicidial.com | | | Active | | | | | | | NULL | NULL | NULL | NULL | NULL | NULL | yyyy-mm-dd | 24 | 08:00 | 23:00 | HDB,ALVT,PLVT,QLTQ,CVLVT,HLT,OLV,GRT,OLTSO,ILTI,MNL,OLTPO,LTFAQ | This Week | Today | | 0 | NULL | $1$st$1iX6Nfn6NbdWdlCljgg3u1 | 1 | 1 | MD5 | +| 4 | 6666 | $1$66$WpuoymV3Cudgm3vI8xWY.0 | 81dc9bdb52d04dc20036dbd8313ed055 | #E6FAD8 | NULL | Admin | NULL | on | 1 | NULL | 2008-12-31 13:32:23 | 0000-00-00 00:00:00 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Active | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | am/pm | 10:00 | 23:00 | HDB,ALVT,PLVT,QLTQ,CVLVT,HLT,OLV,GRT,OLTSO,ILTI,MNL,OLTPO,LTFAQ | Today | Today | NULL | 0 | NULL | NULL | 1 | 1 | MD5 | ++----+--------------+------------------------------+----------------------------------+-----------+------------+---------------+---------------+----------+-------------+-------------+---------------------+---------------------+------------------+-------+------------+------------+--------------+------------+-------------+-----------+--------------------+--------+----------+--------+-----------+----------------+--------------+---------------+-----------------+--------------------+------------------+------+----------+----------+----------+-----------+-------------+-------------+------------+----------+-----------------------------------------------------------------+---------------+-----------+-----------+---------+-------------+------------------------------+---------------+-----------------+------------+ + +This table stores the role of the vtiger users. VICIDIAL users will by default be set to H5(Sales Man), user_level 8 vicidial_users will be set to H4(Sales Manager) and user_level 9 vicidial_users will be set to H2(CEO). +mysql> describe vtiger_user2role; ++--------+--------------+------+-----+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++--------+--------------+------+-----+---------+-------+ +| userid | int(11) | NO | PRI | | | +| roleid | varchar(255) | NO | MUL | | | ++--------+--------------+------+-----+---------+-------+ +mysql> select * from vtiger_user2role; ++--------+--------+ +| userid | roleid | ++--------+--------+ +| 1 | H2 | +| 2 | H3 | ++--------+--------+ + +All VICIDIAL users will be entered into the Team Selling(groupid 1) +mysql> describe vtiger_users2group; ++---------+---------+------+-----+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++---------+---------+------+-----+---------+-------+ +| groupid | int(19) | NO | PRI | | | +| userid | int(19) | NO | PRI | | | ++---------+---------+------+-----+---------+-------+ +mysql> select * from vtiger_users2group; ++---------+--------+ +| groupid | userid | ++---------+--------+ +| 2 | 1 | +| 1 | 2 | +| 2 | 2 | +| 3 | 2 | ++---------+--------+ + +mysql> describe vtiger_users_last_import; ++------------------+-------------+------+-----+---------+----------------+ +| Field | Type | Null | Key | Default | Extra | ++------------------+-------------+------+-----+---------+----------------+ +| id | int(36) | NO | PRI | NULL | auto_increment | +| assigned_user_id | varchar(36) | YES | MUL | NULL | | +| bean_type | varchar(36) | YES | | NULL | | +| bean_id | varchar(36) | YES | | NULL | | +| deleted | int(1) | NO | | 0 | | ++------------------+-------------+------+-----+---------+----------------+ + +This table keeps the sequence number of the auto-incremented vtiger_users.id field +mysql> describe vtiger_users_seq; ++-------+---------+------+-----+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++-------+---------+------+-----+---------+-------+ +| id | int(11) | NO | | | | ++-------+---------+------+-----+---------+-------+ +mysql> select * from vtiger_users_seq; ++----+ +| id | ++----+ +| 2 | ++----+ + + +mysql> describe vtiger_usertype; ++-------------+--------------+------+-----+---------+----------------+ +| Field | Type | Null | Key | Default | Extra | ++-------------+--------------+------+-----+---------+----------------+ +| usertypeid | int(19) | NO | PRI | NULL | auto_increment | +| usertype | varchar(200) | NO | UNI | | | +| sortorderid | int(19) | NO | | 0 | | +| presence | int(1) | NO | | 1 | | ++-------------+--------------+------+-----+---------+----------------+ + + 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 9c9bae7b..dc80c7e4 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -179,7 +179,8 @@ department VARCHAR(30) CREATE TABLE server_updater ( server_ip VARCHAR(15) NOT NULL, -last_update DATETIME +last_update DATETIME, +db_time TIMESTAMP ); CREATE TABLE call_log ( @@ -473,7 +474,8 @@ delete_timeclock_log ENUM('1','0') default '0', alter_custphone_override ENUM('NOT_ACTIVE','ALLOW_ALTER') default 'NOT_ACTIVE', vdc_agent_api_access ENUM('0','1') default '0', modify_inbound_dids ENUM('1','0') default '0', -delete_inbound_dids ENUM('1','0') default '0' +delete_inbound_dids ENUM('1','0') default '0', +active ENUM('Y','N') default 'Y' ); @@ -599,7 +601,8 @@ agent_extended_alt_dial ENUM('Y','N') default 'N', 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' +web_form_target VARCHAR(100) NOT NULL default 'vdcwebform', +vtiger_search_category VARCHAR(100) default 'LEAD' ); CREATE TABLE vicidial_lists ( @@ -1018,7 +1021,7 @@ queuemetrics_pass VARCHAR(50), queuemetrics_url VARCHAR(255), queuemetrics_log_id VARCHAR(10) default 'VIC', queuemetrics_eq_prepend VARCHAR(255) default 'NONE', -vicidial_agent_disable ENUM('NOT_ACTIVE','LIVE_AGENT','EXTERNAL','ALL') default 'NOT_ACTIVE', +vicidial_agent_disable ENUM('NOT_ACTIVE','LIVE_AGENT','EXTERNAL','ALL') default 'ALL', allow_sipsak_messages ENUM('0','1') default '0', admin_home_url VARCHAR(255) default '../vicidial/welcome.php', enable_agc_xfer_log ENUM('0','1') default '0', @@ -1030,7 +1033,13 @@ vdc_header_date_format VARCHAR(50) default 'MS_DASH_24HR 2008-06-24 23:59:59', vdc_customer_date_format VARCHAR(50) default 'AL_TEXT_AMPM OCT 24, 2008 11:59:59 PM', vdc_header_phone_format VARCHAR(50) default 'US_PARN (000)000-0000', vdc_agent_api_active ENUM('0','1') default '0', -qc_last_pull_time DATETIME +qc_last_pull_time DATETIME, +enable_vtiger_integration ENUM('0','1') default '0', +vtiger_server_ip VARCHAR(15), +vtiger_dbname VARCHAR(50), +vtiger_login VARCHAR(50), +vtiger_pass VARCHAR(50), +vtiger_url VARCHAR(255) ); CREATE TABLE vicidial_campaigns_list_mix ( @@ -1085,6 +1094,26 @@ prompt_audio_9 VARCHAR(20), prompt_response_9 TINYINT(1) UNSIGNED default '0', prompt_audio_10 VARCHAR(20), prompt_response_10 TINYINT(1) UNSIGNED default '0', +prompt_audio_11 VARCHAR(20), +prompt_response_11 TINYINT(1) UNSIGNED default '0', +prompt_audio_12 VARCHAR(20), +prompt_response_12 TINYINT(1) UNSIGNED default '0', +prompt_audio_13 VARCHAR(20), +prompt_response_13 TINYINT(1) UNSIGNED default '0', +prompt_audio_14 VARCHAR(20), +prompt_response_14 TINYINT(1) UNSIGNED default '0', +prompt_audio_15 VARCHAR(20), +prompt_response_15 TINYINT(1) UNSIGNED default '0', +prompt_audio_16 VARCHAR(20), +prompt_response_16 TINYINT(1) UNSIGNED default '0', +prompt_audio_17 VARCHAR(20), +prompt_response_17 TINYINT(1) UNSIGNED default '0', +prompt_audio_18 VARCHAR(20), +prompt_response_18 TINYINT(1) UNSIGNED default '0', +prompt_audio_19 VARCHAR(20), +prompt_response_19 TINYINT(1) UNSIGNED default '0', +prompt_audio_20 VARCHAR(20), +prompt_response_20 TINYINT(1) UNSIGNED default '0', index (phone_number), index (entry_time) ); @@ -1359,7 +1388,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='1121'; +UPDATE system_settings SET db_schema_version='1122'; 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 a50bdecb..1b314f33 100644 --- a/agc_2-X/trunk/extras/upgrade_2.0.5.sql +++ b/agc_2-X/trunk/extras/upgrade_2.0.5.sql @@ -557,3 +557,41 @@ UPDATE system_settings SET db_schema_version='1120'; ALTER TABLE vicidial_campaigns MODIFY campaign_vdad_exten VARCHAR(20) default '8368'; UPDATE system_settings SET db_schema_version='1121'; + +ALTER TABLE system_settings ADD enable_vtiger_integration ENUM('0','1') default '0'; +ALTER TABLE system_settings ADD vtiger_server_ip VARCHAR(15); +ALTER TABLE system_settings ADD vtiger_dbname VARCHAR(50); +ALTER TABLE system_settings ADD vtiger_login VARCHAR(50); +ALTER TABLE system_settings ADD vtiger_pass VARCHAR(50); +ALTER TABLE system_settings ADD vtiger_url VARCHAR(255); + +ALTER TABLE vicidial_users ADD active ENUM('Y','N') default 'Y'; + +ALTER TABLE vicidial_campaigns ADD vtiger_search_category VARCHAR(100) default 'LEAD'; + +ALTER TABLE server_updater ADD db_time TIMESTAMP; + +ALTER TABLE vicidial_ivr ADD prompt_audio_11 VARCHAR(20); +ALTER TABLE vicidial_ivr ADD prompt_response_11 TINYINT(1) UNSIGNED default '0'; +ALTER TABLE vicidial_ivr ADD prompt_audio_12 VARCHAR(20); +ALTER TABLE vicidial_ivr ADD prompt_response_12 TINYINT(1) UNSIGNED default '0'; +ALTER TABLE vicidial_ivr ADD prompt_audio_13 VARCHAR(20); +ALTER TABLE vicidial_ivr ADD prompt_response_13 TINYINT(1) UNSIGNED default '0'; +ALTER TABLE vicidial_ivr ADD prompt_audio_14 VARCHAR(20); +ALTER TABLE vicidial_ivr ADD prompt_response_14 TINYINT(1) UNSIGNED default '0'; +ALTER TABLE vicidial_ivr ADD prompt_audio_15 VARCHAR(20); +ALTER TABLE vicidial_ivr ADD prompt_response_15 TINYINT(1) UNSIGNED default '0'; +ALTER TABLE vicidial_ivr ADD prompt_audio_16 VARCHAR(20); +ALTER TABLE vicidial_ivr ADD prompt_response_16 TINYINT(1) UNSIGNED default '0'; +ALTER TABLE vicidial_ivr ADD prompt_audio_17 VARCHAR(20); +ALTER TABLE vicidial_ivr ADD prompt_response_17 TINYINT(1) UNSIGNED default '0'; +ALTER TABLE vicidial_ivr ADD prompt_audio_18 VARCHAR(20); +ALTER TABLE vicidial_ivr ADD prompt_response_18 TINYINT(1) UNSIGNED default '0'; +ALTER TABLE vicidial_ivr ADD prompt_audio_19 VARCHAR(20); +ALTER TABLE vicidial_ivr ADD prompt_response_19 TINYINT(1) UNSIGNED default '0'; +ALTER TABLE vicidial_ivr ADD prompt_audio_20 VARCHAR(20); +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'; diff --git a/agc_2-X/trunk/extras/vtiger_user_file_504.patch b/agc_2-X/trunk/extras/vtiger_user_file_504.patch new file mode 100644 index 00000000..a5c08e39 --- /dev/null +++ b/agc_2-X/trunk/extras/vtiger_user_file_504.patch @@ -0,0 +1,21 @@ +--- ./include/utils/UserInfoUtil.php 2008-12-31 21:39:39.000000000 -0500 ++++ ./include/utils/UserInfoUtil.php 2009-01-01 01:20:17.000000000 -0500 +@@ -1175,6 +1175,18 @@ + global $adb; + global $current_user; + global $seclog; ++ if (!file_exists('user_privileges/user_privileges_'.$current_user->id.'.php')) ++ { ++ $up = fopen('user_privileges/user_privileges_'.$current_user->id.'.php',"a"); ++ fwrite($up, ''); ++ fclose($up); ++ } ++ if (!file_exists('user_privileges/sharing_privileges_'.$current_user->id.'.php')) ++ { ++ $sp = fopen('user_privileges/sharing_privileges_'.$current_user->id.'.php',"a"); ++ fwrite($sp, ''); ++ fclose($sp); ++ } + require('user_privileges/user_privileges_'.$current_user->id.'.php'); + require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); + $permission = "no"; 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 3400761c..e0c67f3e 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 @@ -346,6 +346,29 @@ To customize the query string after the web form, simply begin the web form with Recording Web Link -<\/B> This setting allows you to override the default of the display of the recording link in the admin web pages. Default is SERVER_IP|| Alternate Recording Server IP -<\/B> This setting is where you can put a server IP or other machine name that can be used in place of the server_ip in the links to recordings within the admin web pages. Default is empty|| Recording Web Link|| +Enable Vtiger Integration -<\/B> This setting allows you to enable Vtiger integration with VICIDIAL. Currently links to Vtiger admin and search as well as user replication are the only integration features available. Default is 0|| +Vtiger DB Server IP -<\/B> This is the IP address of the database for your Vtiger installation|| +Vtiger Database Name -<\/B> This is the database name for your Vtiger database|| +Vtiger Database Login -<\/B> This is the user name used to log in to your Vtiger database|| +Vtiger Database Password -<\/B> This is the password used to log in to your Vtiger database|| +Vtiger URL -<\/B> This is the URL or web site address used to get to your Vtiger installation|| +Enable Vtiger Integration:|| +Vtiger DB Server IP|| +Vtiger Database Name|| +Vtiger Database Login|| +Vtiger Database Password|| +Vtiger URL|| +VTIGER HOME|| +Active -<\/B> This field defines whether the user is active in the system and can use VICIDIAL resources. Default is Y|| +show only active users|| +show all users|| +Vtiger Search Category -<\/B> 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 Search Category:|| +ACTIVE LISTS CHANGED|| +SUBMIT ACTIVE LIST CHANGES|| +LAST CALL DATE|| +User Group Bulk Change|| +Bulk Group Change|| ############################################################ CLIENT @@ -383,11 +406,7 @@ Alt Count: || Change this phone number to INACTIVE|| Change this phone number to ACTIVE|| YOU MUST LOG IN TO THE TIMECLOCK FIRST|| -ACTIVE LISTS CHANGED|| -SUBMIT ACTIVE LIST CHANGES|| -LAST CALL DATE|| -User Group Bulk Change|| -Bulk Group Change|| +There is a time synchronization problem with your system, please tell your system administrator|| ############################################################ MANAGER Manual diff --git a/agc_2-X/trunk/www/agc/conf_exten_check.php b/agc_2-X/trunk/www/agc/conf_exten_check.php index 30372102..5fa4c438 100644 --- a/agc_2-X/trunk/www/agc/conf_exten_check.php +++ b/agc_2-X/trunk/www/agc/conf_exten_check.php @@ -40,10 +40,11 @@ # 80703-1106 - Added API functionality for Hangup and Dispo # 81104-0229 - Added mysql error logging capability # 81104-1409 - Added multi-retry for some vicidial_live_agents table MySQL queries +# 90102-1402 - Added check for system and database time synchronization # -$version = '2.0.4-15'; -$build = '81104-1409'; +$version = '2.0.4-16'; +$build = '90102-1402'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=14; $one_mysql_log=0; @@ -303,8 +304,23 @@ echo " $external_status = $row[1]; if (strlen($external_status)<1) {$external_status = '::::::::::';} - if ($Acount < 1) {$Alogin='DEAD_VLA';} - if ($AexternalDEAD > 0) {$Alogin='DEAD_EXTERNAL';} + $web_epoch = date("U"); + $stmt="select UNIX_TIMESTAMP(last_update),UNIX_TIMESTAMP(db_time) from server_updater where server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03014',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $server_epoch = $row[0]; + $db_epoch = $row[1]; + $time_diff = ($server_epoch - $db_epoch); + $web_diff = ($db_epoch - $web_epoch); + + if ( ( ($time_diff > 8) or ($time_diff < -8) or ($web_diff > 8) or ($web_diff < -8) ) and (eregi("0$",$StarTtime)) ) + {$Alogin='TIME_SYNC';} + if ($Acount < 1) + {$Alogin='DEAD_VLA';} + if ($AexternalDEAD > 0) + {$Alogin='DEAD_EXTERNAL';} echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Status: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . "|\n"; diff --git a/agc_2-X/trunk/www/agc/vicidial.php b/agc_2-X/trunk/www/agc/vicidial.php index c96ad8c0..78b8b838 100644 --- a/agc_2-X/trunk/www/agc/vicidial.php +++ b/agc_2-X/trunk/www/agc/vicidial.php @@ -211,10 +211,11 @@ # 81124-2213 - Fixes blind transfer bug # 81209-1617 - Added campaign web form target option and web form address variables # 81211-0422 - Fixed Manual dial agent_log bug +# 90102-1402 - Added time sync check notification # -$version = '2.0.5-190'; -$build = '81211-0422'; +$version = '2.0.5-191'; +$build = '90102-1402'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=53; $one_mysql_log=0; @@ -601,7 +602,7 @@ if ($user_login_first == 1) { if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) { - $stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + $stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0 and active='Y';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01005',$VD_login,$server_ip,$session_name,$one_mysql_log);} @@ -687,7 +688,7 @@ $VDloginDISPLAY=0; } else { - $stmt="SELECT count(*) from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + $stmt="SELECT count(*) from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0 and active='Y';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01006',$VD_login,$server_ip,$session_name,$one_mysql_log);} @@ -1489,8 +1490,7 @@ else if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01040',$VD_login,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); - $i=0; - while ($i < $qm_conf_ct) + if ($qm_conf_ct > 0) { $row=mysql_fetch_row($rslt); $enable_queuemetrics_logging = $row[0]; @@ -1501,7 +1501,6 @@ else $queuemetrics_log_id = $row[5]; $vicidial_agent_disable = $row[6]; $allow_sipsak_messages = $row[7]; - $i++; } ##### END QUEUEMETRICS LOGGING LOOKUP ##### ########################################### @@ -2651,6 +2650,10 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} { showDiv('AgenTDisablEBoX'); } + if ( (AGLogiN == 'TIME_SYNC') && (vicidial_agent_disable == 'ALL') ) + { + showDiv('SysteMDisablEBoX'); + } } var VLAStatuS_array = check_time_array[4].split("Status: "); var VLAStatuS = VLAStatuS_array[1]; @@ -6734,6 +6737,7 @@ else hideDiv('DispoSelectBox'); hideDiv('LogouTBox'); hideDiv('AgenTDisablEBoX'); + hideDiv('SysteMDisablEBoX'); hideDiv('CustomerGoneBox'); hideDiv('NoneInSessionBox'); hideDiv('WrapupBox'); @@ -7471,7 +7475,7 @@ echo "\n";
- + height=460>
CALLBACKS FOR AGENT :
Click on a callback below to call the customer back now. If you click on a record below to call it, it will be removed from the list.
@@ -7482,7 +7486,7 @@ echo "\n";
- + height=460>
NEW MANUAL DIAL LEAD FOR :

Enter information below for the new lead you wish to call.

Calls Dialing: + + height=500>
There is a time synchronization problem with your system, please tell your system administrator


Go Back +
+
+ + height=500>

LOGOUT
- +
- +
 
- + height=47>
Any changes made to the customer information below at this time will not be comitted, You must change customer information before you Hangup the call.
- + height=460>
DISPOSITION CALL :       Hangup Again       minimize
End-of-call Disposition Selection
@@ -7692,7 +7701,7 @@ Your Status:
Calls Dialing: + height=460>
SELECT A PAUSE CODE :
Pause Code Selection @@ -7700,10 +7709,10 @@ Your Status:
Calls Dialing: + - + height=460>
Select a CallBack Date :
@@ -7748,7 +7757,7 @@ Your Status:
Calls Dialing: MY CALLBACK ONLY
";} ?> - CB Comments:

+ CB Comments:

SUBMIT

@@ -7756,7 +7765,7 @@ Your Status:
Calls Dialing: + height=460>
CLOSER INBOUND GROUP SELECTION
Closer Inbound Group Selection
@@ -7767,7 +7776,7 @@ Your Status:
Calls Dialing: + Channel Channel diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index 1ec43c89..be8c8e52 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -861,7 +861,20 @@ if (isset($_GET["alt_server_ip"])) {$alt_server_ip=$_GET["alt_server_ip"];} elseif (isset($_POST["alt_server_ip"])) {$alt_server_ip=$_POST["alt_server_ip"];} if (isset($_GET["recording_web_link"])) {$recording_web_link=$_GET["recording_web_link"];} elseif (isset($_POST["recording_web_link"])) {$recording_web_link=$_POST["recording_web_link"];} - +if (isset($_GET["enable_vtiger_integration"])) {$enable_vtiger_integration=$_GET["enable_vtiger_integration"];} + elseif (isset($_POST["enable_vtiger_integration"])) {$enable_vtiger_integration=$_POST["enable_vtiger_integration"];} +if (isset($_GET["vtiger_server_ip"])) {$vtiger_server_ip=$_GET["vtiger_server_ip"];} + elseif (isset($_POST["vtiger_server_ip"])) {$vtiger_server_ip=$_POST["vtiger_server_ip"];} +if (isset($_GET["vtiger_dbname"])) {$vtiger_dbname=$_GET["vtiger_dbname"];} + elseif (isset($_POST["vtiger_dbname"])) {$vtiger_dbname=$_POST["vtiger_dbname"];} +if (isset($_GET["vtiger_login"])) {$vtiger_login=$_GET["vtiger_login"];} + elseif (isset($_POST["vtiger_login"])) {$vtiger_login=$_POST["vtiger_login"];} +if (isset($_GET["vtiger_pass"])) {$vtiger_pass=$_GET["vtiger_pass"];} + elseif (isset($_POST["vtiger_pass"])) {$vtiger_pass=$_POST["vtiger_pass"];} +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($script_id)) {$script_id= strtoupper($script_id);} if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} @@ -1033,6 +1046,7 @@ $modify_inbound_dids = ereg_replace("[^0-9]","",$modify_inbound_dids); $delete_inbound_dids = ereg_replace("[^0-9]","",$delete_inbound_dids); $answer_sec_pct_rt_stat_one = ereg_replace("[^0-9]","",$answer_sec_pct_rt_stat_one); $answer_sec_pct_rt_stat_two = ereg_replace("[^0-9]","",$answer_sec_pct_rt_stat_two); +$enable_vtiger_integration = ereg_replace("[^0-9]","",$enable_vtiger_integration); ### DIGITS and COLONS $shift_length = ereg_replace("[^\:0-9]","",$shift_length); @@ -1121,6 +1135,7 @@ $phone_ip = ereg_replace("[^\.0-9]","",$phone_ip); $old_server_ip = ereg_replace("[^\.0-9]","",$old_server_ip); $computer_ip = ereg_replace("[^\.0-9]","",$computer_ip); $queuemetrics_server_ip = ereg_replace("[^\.0-9]","",$queuemetrics_server_ip); +$vtiger_server_ip = ereg_replace("[^\.0-9]","",$vtiger_server_ip); ### ALPHA-NUMERIC and spaces and hash and star and comma $xferconf_a_dtmf = ereg_replace("[^ \,\*\#0-9a-zA-Z]","",$xferconf_a_dtmf); @@ -1226,6 +1241,7 @@ $exten_context = ereg_replace("[^-\_0-9a-zA-Z]","",$exten_context); $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); ### ALPHA-NUMERIC and underscore and dash and comma $logins_list = ereg_replace("[^-\,\_0-9a-zA-Z]","",$logins_list); @@ -1297,6 +1313,9 @@ $after_hours_message_filename = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$after $welcome_message_filename = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$welcome_message_filename); $onhold_prompt_filename = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$onhold_prompt_filename); $email = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$email); +$vtiger_dbname = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$vtiger_dbname); +$vtiger_login = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$vtiger_login); +$vtiger_pass = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$vtiger_pass); ### ALPHA-NUMERIC and underscore and dash and slash and at and space and colon $vdc_header_date_format = ereg_replace("[^- \:\/\_0-9a-zA-Z]","",$vdc_header_date_format); @@ -1316,6 +1335,7 @@ $survey_camp_record_dir = ereg_replace(";","",$survey_camp_record_dir); # $queuemetrics_url # $admin_home_url # $qc_web_form_address +# $vtiger_url ### VARIABLES not filtered at all ### # $script_text @@ -1491,11 +1511,13 @@ $survey_camp_record_dir = ereg_replace(";","",$survey_camp_record_dir); # 81209-1538 - Added web_form_target to campaign screen # 81210-1430 - Added http server IP and recording link options to servers # 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 # # 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-154'; -$build = '81222-0500'; +$admin_version = '2.0.5-156'; +$build = '90101-1216'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -1536,7 +1558,7 @@ while ($i < $qm_conf_ct) ##### END SETTINGS LOOKUP ##### ########################################### -$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and active='Y';"; if ($DB) {echo "|$stmt|\n";} if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} $rslt=mysql_query($stmt, $link); @@ -1567,7 +1589,7 @@ $browser = getenv("HTTP_USER_AGENT"); $stmt="SELECT * from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW';"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); - $LOGfullname =$row[3]; + $LOGfull_name =$row[3]; $LOGuser_level =$row[4]; $LOGuser_group =$row[5]; $LOGdelete_users =$row[8]; @@ -1605,7 +1627,7 @@ $browser = getenv("HTTP_USER_AGENT"); if ($WeBRooTWritablE > 0) { - fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfull_name|\n"); fclose($fp); } } @@ -2373,6 +2395,11 @@ echo "
Phone Pass - Here is where you can set a default phone pass value for when the user logs into vicidial.php. This value will populate the phone_pass automatically when the user logs in with their user-pass-campaign in the vicidial.php login screen. +
+ +
+Active - This field defines whether the user is active in the system and can use VICIDIAL resources. Default is Y +

@@ -3073,7 +3100,10 @@ echo "\n"; echo "\n"; echo "\n"; + echo "\n"; if ( ($LOGuser_level > 8) or ($LOGalter_agent_interface == "1") ) { @@ -11088,6 +11668,12 @@ if ($ADD==31) $rslt=mysql_query($stmt, $link); } + $stmt="SELECT enable_vtiger_integration,vtiger_url from system_settings;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration_LU = $row[0]; + $vtiger_url_LU = $row[1]; + $stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); @@ -11186,6 +11772,7 @@ if ($ADD==31) $three_way_call_cid = $row[96]; $three_way_dial_prefix = $row[97]; $web_form_target = $row[98]; + $vtiger_search_category = $row[99]; if (ereg("DISABLED",$list_order_mix)) {$DEFlistDISABLE = ''; $DEFstatusDISABLED=0;} @@ -11620,6 +12207,14 @@ if ($ADD==31) echo "\n"; + if ($enable_vtiger_integration_LU > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } if ($campaign_allow_inbound == 'Y') { @@ -14267,14 +14862,14 @@ if ($ADD==311111) ### list of users in this user group $active_confs = 0; - $stmt="SELECT user,full_name,user_level from vicidial_users where user_group='$user_group'"; + $stmt="SELECT user,full_name,user_level,active from vicidial_users where user_group='$user_group'"; $rsltx=mysql_query($stmt, $link); $users_to_print = mysql_num_rows($rsltx); echo "
\n"; echo "
USERS WITHIN THIS USER GROUP: $users_to_print
\n"; echo "
Survey Campaign Recording Directory - If the Survey Method of CAMPREC_60_WAV is selected then the customer response will be recorded and placed in a directory named after the campaign inside of this directory. - +
+ +
+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. @@ -4312,46 +4342,6 @@ The VICIDIAL basic web-based lead loader is designed simply to take a lead file
Webroot Writable - This setting allows you to define whether temp files and authentication files should be placed in the webroot on your web server. Default is 1. -
-
-
-Enable QueueMetrics Logging - This setting allows you to define whether VICIDIAL will insert log entries into the queue_log database table as Asterisk Queues activity does. QueueMetrics is a standalone, closed-source statistical analysis program. You must have QueueMetrics already installed and configured before enabling this feature. Default is 0. - -
-
-
-QueueMetrics Server IP - This is the IP address of the database for your QueueMetrics installation. - -
-
-
-QueueMetrics Database Name - This is the database name for your QueueMetrics database. - -
-
-
-QueueMetrics Database Login - This is the user name used to log in to your QueueMetrics database. - -
-
-
-QueueMetrics Database Password - This is the password used to log in to your QueueMetrics database. - -
-
-
-QueueMetrics URL - This is the URL or web site address used to get to your QueueMetrics installation. - -
-
-
-QueueMetrics Log ID - This is the server ID that all VICIDIAL logs going into the QueueMetrics database will use as an identifier for each record. - -
-
-
-QueueMetrics EnterQueue Prepend - This field is used to allow for prepending of one of the vicidial_list data fields in front of the phone number of the customer for customized QueueMetrics reports. Default is NONE to not populate anything. -

@@ -4429,6 +4419,78 @@ FR_SPAC 00 00 00 00 00 - France space separated phone number

Agent interface API Access Active - This option allows you to enable or disable the agent interface API. Default is 0. + +
+
+
+Enable QueueMetrics Logging - This setting allows you to define whether VICIDIAL will insert log entries into the queue_log database table as Asterisk Queues activity does. QueueMetrics is a standalone, closed-source statistical analysis program. You must have QueueMetrics already installed and configured before enabling this feature. Default is 0. + +
+
+
+QueueMetrics Server IP - This is the IP address of the database for your QueueMetrics installation. + +
+
+
+QueueMetrics Database Name - This is the database name for your QueueMetrics database. + +
+
+
+QueueMetrics Database Login - This is the user name used to log in to your QueueMetrics database. + +
+
+
+QueueMetrics Database Password - This is the password used to log in to your QueueMetrics database. + +
+
+
+QueueMetrics URL - This is the URL or web site address used to get to your QueueMetrics installation. + +
+
+
+QueueMetrics Log ID - This is the server ID that all VICIDIAL logs going into the QueueMetrics database will use as an identifier for each record. + +
+
+
+QueueMetrics EnterQueue Prepend - This field is used to allow for prepending of one of the vicidial_list data fields in front of the phone number of the customer for customized QueueMetrics reports. Default is NONE to not populate anything. + +
+
+
+Enable Vtiger Integration - This setting allows you to enable Vtiger integration with VICIDIAL. Currently links to Vtiger admin and search as well as user replication are the only integration features available. Default is 0. + +
+
+
+Vtiger DB Server IP - This is the IP address of the database for your Vtiger installation. + +
+
+
+Vtiger Database Name - This is the database name for your Vtiger database. + +
+
+
+Vtiger Database Login - This is the user name used to log in to your Vtiger database. + +
+
+
+Vtiger Database Password - This is the password used to log in to your Vtiger database. + +
+
+
+Vtiger URL - This is the URL or web site address used to get to your Vtiger installation. + +



VICIDIAL_STATUSES TABLE

@@ -6140,6 +6202,106 @@ if ($ADD=="2") $stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass) values('$user','$pass','$full_name','$user_level','$user_group','$phone_login','$phone_pass');"; $rslt=mysql_query($stmt, $link); + ############################################################### + ##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + $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 ($DB) {echo "$stmt\n";} + $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]; + } + ##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + ############################################################# + + if ($enable_vtiger_integration > 0) + { + ### 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());} + echo 'Connected successfully'; + mysql_select_db("$vtiger_dbname", $linkV); + + $user_name = $user; + $user_password = $pass; + $last_name = $full_name; + $is_admin = 'off'; + $roleid = 'H5'; + $status = 'Active'; + $groupid = '1'; + if ($user_level >= 8) {$roleid = 'H4';} + if ($user_level >= 9) {$roleid = 'H2';} + if ($user_level >= 9) {$is_admin = 'on';} + $salt = substr($user_name, 0, 2); + $salt = '$1$' . $salt . '$'; + $encrypted_password = crypt($user_password, $salt); + + $stmt="SELECT count(*) from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + ### user exists in vtiger, update it + if ($found_count > 0) + { + $stmt="SELECT id from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $userid = $row[0]; + + $stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW USER RECORD IN VTIGER + $stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $userid = mysql_insert_id($linkV); + + $stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "UPDATE vtiger_users_seq SET id='$userid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW USER RECORD IN VTIGER + } + + } + ### END vtiger integration + ### LOG CHANGES TO LOG FILE ### if ($WeBRooTWritablE > 0) { @@ -6176,7 +6338,7 @@ if ($ADD=="2A") } else { - if (ereg('AUTOGENERA',$user)) + if (ereg('AUTOGEN',$user)) { $new_user=0; $auto_user_add_value=0; @@ -6214,7 +6376,7 @@ if ($ADD=="2A") $rslt=mysql_query($stmt, $link); } - $stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids) SELECT \"$user\",\"$pass\",\"$full_name\",user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids from vicidial_users where user=\"$source_user_id\";"; + $stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active) SELECT \"$user\",\"$pass\",\"$full_name\",user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active from vicidial_users where user=\"$source_user_id\";"; $rslt=mysql_query($stmt, $link); $stmtA="INSERT INTO vicidial_inbound_group_agents (user,group_id,group_rank,group_weight,calls_today) SELECT \"$user\",group_id,group_rank,group_weight,\"0\" from vicidial_inbound_group_agents where user=\"$source_user_id\";"; @@ -6223,6 +6385,118 @@ if ($ADD=="2A") $stmtA="INSERT INTO vicidial_campaign_agents (user,campaign_id,campaign_rank,campaign_weight,calls_today) SELECT \"$user\",campaign_id,campaign_rank,campaign_weight,\"0\" from vicidial_campaign_agents where user=\"$source_user_id\";"; $rslt=mysql_query($stmtA, $link); + ############################################################### + ##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + $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 ($DB) {echo "$stmt\n";} + $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]; + } + ##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + ############################################################# + + if ($enable_vtiger_integration > 0) + { + $stmt = "SELECT user_level,active FROM vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $vuul_conf_ct = mysql_num_rows($rslt); + if ($vuul_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_level = $row[0]; + $active = $row[1]; + } + + ### 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());} + echo 'Connected successfully'; + mysql_select_db("$vtiger_dbname", $linkV); + + $user_name = $user; + $user_password = $pass; + $last_name = $full_name; + $is_admin = 'off'; + $roleid = 'H5'; + $status = 'Active'; + $groupid = '1'; + if ($user_level >= 8) {$roleid = 'H4';} + if ($user_level >= 9) {$roleid = 'H2';} + if ($user_level >= 9) {$is_admin = 'on';} + if (ereg('N',$active)) {$status = 'Inactive';} + $salt = substr($user_name, 0, 2); + $salt = '$1$' . $salt . '$'; + $encrypted_password = crypt($user_password, $salt); + + $stmt="SELECT count(*) from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + ### user exists in vtiger, update it + if ($found_count > 0) + { + $stmt="SELECT id from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $userid = $row[0]; + + $stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW USER RECORD IN VTIGER + $stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $userid = mysql_insert_id($linkV); + + $stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "UPDATE vtiger_users_seq SET id='$userid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW USER RECORD IN VTIGER + } + + } + ### END vtiger integration + echo "
USER COPIED: $user copied from $source_user_id\n"; echo "

\n"; echo "
Click here to go to the user record\n"; @@ -6318,7 +6592,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) 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 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) 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';"; $rslt=mysql_query($stmt, $link); $stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$campaign_id');"; @@ -7553,9 +7827,109 @@ if ($ADD=="4A") { echo "
USER MODIFIED - ADMIN: $user\n"; - $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',delete_users='$delete_users',delete_user_groups='$delete_user_groups',delete_lists='$delete_lists',delete_campaigns='$delete_campaigns',delete_ingroups='$delete_ingroups',delete_remote_agents='$delete_remote_agents',load_leads='$load_leads',campaign_detail='$campaign_detail',ast_admin_access='$ast_admin_access',ast_delete_phones='$ast_delete_phones',delete_scripts='$delete_scripts',modify_leads='$modify_leads',hotkeys_active='$hotkeys_active',change_agent_campaign='$change_agent_campaign',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',delete_filters='$delete_filters',alter_agent_interface_options='$alter_agent_interface_options',closer_default_blended='$closer_default_blended',delete_call_times='$delete_call_times',modify_call_times='$modify_call_times',modify_users='$modify_users',modify_campaigns='$modify_campaigns',modify_lists='$modify_lists',modify_scripts='$modify_scripts',modify_filters='$modify_filters',modify_ingroups='$modify_ingroups',modify_usergroups='$modify_usergroups',modify_remoteagents='$modify_remoteagents',modify_servers='$modify_servers',view_reports='$view_reports',vicidial_recording_override='$vicidial_recording_override',alter_custdata_override='$alter_custdata_override',qc_enabled='$qc_enabled',qc_user_level='$qc_user_level',qc_pass='$qc_pass',qc_finish='$qc_finish',qc_commit='$qc_commit',add_timeclock_log='$add_timeclock_log',modify_timeclock_log='$modify_timeclock_log',delete_timeclock_log='$delete_timeclock_log',alter_custphone_override='$alter_custphone_override',vdc_agent_api_access='$vdc_agent_api_access',modify_inbound_dids='$modify_inbound_dids',delete_inbound_dids='$delete_inbound_dids' where user='$user';"; + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',delete_users='$delete_users',delete_user_groups='$delete_user_groups',delete_lists='$delete_lists',delete_campaigns='$delete_campaigns',delete_ingroups='$delete_ingroups',delete_remote_agents='$delete_remote_agents',load_leads='$load_leads',campaign_detail='$campaign_detail',ast_admin_access='$ast_admin_access',ast_delete_phones='$ast_delete_phones',delete_scripts='$delete_scripts',modify_leads='$modify_leads',hotkeys_active='$hotkeys_active',change_agent_campaign='$change_agent_campaign',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',delete_filters='$delete_filters',alter_agent_interface_options='$alter_agent_interface_options',closer_default_blended='$closer_default_blended',delete_call_times='$delete_call_times',modify_call_times='$modify_call_times',modify_users='$modify_users',modify_campaigns='$modify_campaigns',modify_lists='$modify_lists',modify_scripts='$modify_scripts',modify_filters='$modify_filters',modify_ingroups='$modify_ingroups',modify_usergroups='$modify_usergroups',modify_remoteagents='$modify_remoteagents',modify_servers='$modify_servers',view_reports='$view_reports',vicidial_recording_override='$vicidial_recording_override',alter_custdata_override='$alter_custdata_override',qc_enabled='$qc_enabled',qc_user_level='$qc_user_level',qc_pass='$qc_pass',qc_finish='$qc_finish',qc_commit='$qc_commit',add_timeclock_log='$add_timeclock_log',modify_timeclock_log='$modify_timeclock_log',delete_timeclock_log='$delete_timeclock_log',alter_custphone_override='$alter_custphone_override',vdc_agent_api_access='$vdc_agent_api_access',modify_inbound_dids='$modify_inbound_dids',delete_inbound_dids='$delete_inbound_dids',active='$active' where user='$user';"; $rslt=mysql_query($stmt, $link); + ############################################################### + ##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + $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 ($DB) {echo "$stmt\n";} + $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]; + } + ##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + ############################################################# + + if ($enable_vtiger_integration > 0) + { + ### 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());} + echo 'Connected successfully'; + mysql_select_db("$vtiger_dbname", $linkV); + + $user_name = $user; + $user_password = $pass; + $last_name = $full_name; + $is_admin = 'off'; + $roleid = 'H5'; + $status = 'Active'; + $groupid = '1'; + if ($user_level >= 8) {$roleid = 'H4';} + if ($user_level >= 9) {$roleid = 'H2';} + if ($user_level >= 9) {$is_admin = 'on';} + if (ereg('N',$active)) {$status = 'Inactive';} + $salt = substr($user_name, 0, 2); + $salt = '$1$' . $salt . '$'; + $encrypted_password = crypt($user_password, $salt); + + $stmt="SELECT count(*) from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + ### user exists in vtiger, update it + if ($found_count > 0) + { + $stmt="SELECT id from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $userid = $row[0]; + + $stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW USER RECORD IN VTIGER + $stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $userid = mysql_insert_id($linkV); + + $stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "UPDATE vtiger_users_seq SET id='$userid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW USER RECORD IN VTIGER + } + + } + ### END vtiger integration ### LOG CHANGES TO LOG FILE ### if ($WeBRooTWritablE > 0) @@ -7594,9 +7968,111 @@ if ($ADD=="4B") { echo "
USER MODIFIED - ADMIN: $user\n"; - $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended',vicidial_recording_override='$vicidial_recording_override',alter_custdata_override='$alter_custdata_override',qc_enabled='$qc_enabled',qc_user_level='$qc_user_level',qc_pass='$qc_pass',qc_finish='$qc_finish',qc_commit='$qc_commit',alter_custphone_override='$alter_custphone_override' where user='$user';"; + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended',vicidial_recording_override='$vicidial_recording_override',alter_custdata_override='$alter_custdata_override',qc_enabled='$qc_enabled',qc_user_level='$qc_user_level',qc_pass='$qc_pass',qc_finish='$qc_finish',qc_commit='$qc_commit',alter_custphone_override='$alter_custphone_override',active='$active' where user='$user';"; $rslt=mysql_query($stmt, $link); + + ############################################################### + ##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + $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 ($DB) {echo "$stmt\n";} + $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]; + } + ##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + ############################################################# + + if ($enable_vtiger_integration > 0) + { + ### 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());} + echo 'Connected successfully'; + mysql_select_db("$vtiger_dbname", $linkV); + + $user_name = $user; + $user_password = $pass; + $last_name = $full_name; + $is_admin = 'off'; + $roleid = 'H5'; + $status = 'Active'; + $groupid = '1'; + if ($user_level >= 8) {$roleid = 'H4';} + if ($user_level >= 9) {$roleid = 'H2';} + if ($user_level >= 9) {$is_admin = 'on';} + if (ereg('N',$active)) {$status = 'Inactive';} + $salt = substr($user_name, 0, 2); + $salt = '$1$' . $salt . '$'; + $encrypted_password = crypt($user_password, $salt); + + $stmt="SELECT count(*) from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + ### user exists in vtiger, update it + if ($found_count > 0) + { + $stmt="SELECT id from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $userid = $row[0]; + + $stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW USER RECORD IN VTIGER + $stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $userid = mysql_insert_id($linkV); + + $stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "UPDATE vtiger_users_seq SET id='$userid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW USER RECORD IN VTIGER + } + + } + ### END vtiger integration + ### LOG CHANGES TO LOG FILE ### if ($WeBRooTWritablE > 0) { @@ -7635,9 +8111,111 @@ if ($ADD==4) { echo "
USER MODIFIED: $user\n"; - $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass' where user='$user';"; + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',active='$active' where user='$user';"; $rslt=mysql_query($stmt, $link); + + ############################################################### + ##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + $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 ($DB) {echo "$stmt\n";} + $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]; + } + ##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + ############################################################# + + if ($enable_vtiger_integration > 0) + { + ### 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());} + echo 'Connected successfully'; + mysql_select_db("$vtiger_dbname", $linkV); + + $user_name = $user; + $user_password = $pass; + $last_name = $full_name; + $is_admin = 'off'; + $roleid = 'H5'; + $status = 'Active'; + $groupid = '1'; + if ($user_level >= 8) {$roleid = 'H4';} + if ($user_level >= 9) {$roleid = 'H2';} + if ($user_level >= 9) {$is_admin = 'on';} + if (ereg('N',$active)) {$status = 'Inactive';} + $salt = substr($user_name, 0, 2); + $salt = '$1$' . $salt . '$'; + $encrypted_password = crypt($user_password, $salt); + + $stmt="SELECT count(*) from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + ### user exists in vtiger, update it + if ($found_count > 0) + { + $stmt="SELECT id from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $userid = $row[0]; + + $stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW USER RECORD IN VTIGER + $stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $userid = mysql_insert_id($linkV); + + $stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "UPDATE vtiger_users_seq SET id='$userid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW USER RECORD IN VTIGER + } + + } + ### END vtiger integration + ### LOG CHANGES TO LOG FILE ### if ($WeBRooTWritablE > 0) { @@ -7735,7 +8313,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' 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' where campaign_id='$campaign_id';"; $rslt=mysql_query($stmtA, $link); if ($reset_hopper == 'Y') @@ -9211,7 +9789,7 @@ if ($ADD==411111111111111) echo "
VICIDIAL SYSTEM SETTINGS MODIFIED\n"; - $stmt="UPDATE system_settings set use_non_latin='$use_non_latin',webroot_writable='$webroot_writable',enable_queuemetrics_logging='$enable_queuemetrics_logging',queuemetrics_server_ip='$queuemetrics_server_ip',queuemetrics_dbname='$queuemetrics_dbname',queuemetrics_login='$queuemetrics_login',queuemetrics_pass='$queuemetrics_pass',queuemetrics_url='$queuemetrics_url',queuemetrics_log_id='$queuemetrics_log_id',queuemetrics_eq_prepend='$queuemetrics_eq_prepend',vicidial_agent_disable='$vicidial_agent_disable',allow_sipsak_messages='$allow_sipsak_messages',admin_home_url='$admin_home_url',enable_agc_xfer_log='$enable_agc_xfer_log',timeclock_end_of_day='$timeclock_end_of_day',vdc_header_date_format='$vdc_header_date_format',vdc_customer_date_format='$vdc_customer_date_format',vdc_header_phone_format='$vdc_header_phone_format',vdc_agent_api_active='$vdc_agent_api_active';"; + $stmt="UPDATE system_settings set use_non_latin='$use_non_latin',webroot_writable='$webroot_writable',enable_queuemetrics_logging='$enable_queuemetrics_logging',queuemetrics_server_ip='$queuemetrics_server_ip',queuemetrics_dbname='$queuemetrics_dbname',queuemetrics_login='$queuemetrics_login',queuemetrics_pass='$queuemetrics_pass',queuemetrics_url='$queuemetrics_url',queuemetrics_log_id='$queuemetrics_log_id',queuemetrics_eq_prepend='$queuemetrics_eq_prepend',vicidial_agent_disable='$vicidial_agent_disable',allow_sipsak_messages='$allow_sipsak_messages',admin_home_url='$admin_home_url',enable_agc_xfer_log='$enable_agc_xfer_log',timeclock_end_of_day='$timeclock_end_of_day',vdc_header_date_format='$vdc_header_date_format',vdc_customer_date_format='$vdc_customer_date_format',vdc_header_phone_format='$vdc_header_phone_format',vdc_agent_api_active='$vdc_agent_api_active',enable_vtiger_integration='$enable_vtiger_integration',vtiger_server_ip='$vtiger_server_ip',vtiger_dbname='$vtiger_dbname',vtiger_login='$vtiger_login',vtiger_pass='$vtiger_pass',vtiger_url='$vtiger_url';"; $rslt=mysql_query($stmt, $link); ### LOG CHANGES TO LOG FILE ### @@ -10913,6 +11491,7 @@ if ($ADD==3) $vdc_agent_api_access = $row[55]; $modify_inbound_dids = $row[56]; $delete_inbound_dids = $row[57]; + $active = $row[58]; if ( ($user_level >= $LOGuser_level) and ($LOGuser_level < 9) ) @@ -10962,6 +11541,7 @@ if ($ADD==3) echo "$NWB#vicidial_users-user_group$NWE
Phone Login: $NWB#vicidial_users-phone_login$NWE
Phone Pass: $NWB#vicidial_users-phone_pass$NWE
Active: $NWB#vicidial_users-active$NWE
3-Way Call Dial Prefix: $NWB#vicidial_campaigns-three_way_dial_prefix$NWE
Vtiger Search Category: $NWB#vicidial_campaigns-vtiger_search_category$NWE
\n"; - echo "\n"; + echo "\n"; $o=0; while ($users_to_print > $o) @@ -14291,6 +14886,7 @@ if ($ADD==311111) echo "\n"; echo "\n"; echo "\n"; + echo "\n"; echo "\n"; } @@ -15347,7 +15943,7 @@ if ($ADD==311111111111111) echo "
USERFULL NAMELEVEL
USERFULL NAMELEVELACTIVE
$rowx[0]$rowx[1]$rowx[2]$rowx[3]
\n"; echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; echo "\n"; echo "$NWB#settings-vdc_header_phone_format$NWE\n"; + echo "\n"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "
\n"; echo ""; - $stmt="SELECT version,install_date,use_non_latin,webroot_writable,enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_url,queuemetrics_log_id,queuemetrics_eq_prepend,vicidial_agent_disable,allow_sipsak_messages,admin_home_url,enable_agc_xfer_log,db_schema_version,auto_user_add_value,timeclock_end_of_day,timeclock_last_reset_date,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,vdc_agent_api_active,qc_last_pull_time from system_settings;"; + $stmt="SELECT version,install_date,use_non_latin,webroot_writable,enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_url,queuemetrics_log_id,queuemetrics_eq_prepend,vicidial_agent_disable,allow_sipsak_messages,admin_home_url,enable_agc_xfer_log,db_schema_version,auto_user_add_value,timeclock_end_of_day,timeclock_last_reset_date,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,vdc_agent_api_active,qc_last_pull_time,enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url from system_settings;"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $version = $row[0]; @@ -15375,6 +15971,12 @@ if ($ADD==311111111111111) $vdc_header_phone_format = $row[22]; $vdc_agent_api_active = $row[23]; $qc_last_pull_time = $row[24]; + $enable_vtiger_integration = $row[25]; + $vtiger_server_ip = $row[26]; + $vtiger_dbname = $row[27]; + $vtiger_login = $row[28]; + $vtiger_pass = $row[29]; + $vtiger_url = $row[30]; echo "
MODIFY VICIDIAL SYSTEM SETTINGS
\n"; echo "\n"; @@ -15385,23 +15987,6 @@ if ($ADD==311111111111111) echo "
Install Date: $install_date
Use Non-Latin: $NWB#settings-use_non_latin$NWE
Webroot Writable: $NWB#settings-webroot_writable$NWE
Enable QueueMetrics Logging: $NWB#settings-enable_queuemetrics_logging$NWE
QueueMetrics Server IP: $NWB#settings-queuemetrics_server_ip$NWE
QueueMetrics DB Name: $NWB#settings-queuemetrics_dbname$NWE
QueueMetrics DB Login: $NWB#settings-queuemetrics_login$NWE
QueueMetrics DB Password: $NWB#settings-queuemetrics_pass$NWE
QueueMetrics URL: $NWB#settings-queuemetrics_url$NWE
QueueMetrics Log ID: $NWB#settings-queuemetrics_log_id$NWE
QueueMetrics EnterQueue Prepend: $NWB#settings-queuemetrics_eq_prepend$NWE
VICIDIAL Agent Disable Display:
Agent API Active: $NWB#settings-vdc_agent_api_active$NWE
Agent API Active: $NWB#settings-vdc_agent_api_active$NWE
Enable QueueMetrics Logging: $NWB#settings-enable_queuemetrics_logging$NWE
QueueMetrics Server IP: $NWB#settings-queuemetrics_server_ip$NWE
QueueMetrics DB Name: $NWB#settings-queuemetrics_dbname$NWE
QueueMetrics DB Login: $NWB#settings-queuemetrics_login$NWE
QueueMetrics DB Password: $NWB#settings-queuemetrics_pass$NWE
QueueMetrics URL: $NWB#settings-queuemetrics_url$NWE
QueueMetrics Log ID: $NWB#settings-queuemetrics_log_id$NWE
QueueMetrics EnterQueue Prepend: $NWB#settings-queuemetrics_eq_prepend$NWE
Enable Vtiger Integration: $NWB#settings-enable_vtiger_integration$NWE\n"; + echo "   Click here to Synchronize users with Vtiger\n"; + echo "
Vtiger DB Server IP: $NWB#settings-vtiger_server_ip$NWE
Vtiger DB Name: $NWB#settings-vtiger_dbname$NWE
Vtiger DB Login: $NWB#settings-vtiger_login$NWE
Vtiger DB Password: $NWB#settings-vtiger_pass$NWE
Vtiger URL: $NWB#settings-vtiger_url$NWE
\n"; echo "\n"; @@ -16030,6 +16645,17 @@ if ($ADD==0) { echo "
\n"; echo ""; + echo "
USER LISTINGS: "; + if (ereg('display_all',$status)) + { + $SQLstatus = ''; + echo "   show only active users\n"; + } + else + { + $SQLstatus = "where active='Y'"; + echo "   show all users\n"; + } $USERlink='stage=USERIDDOWN'; $NAMElink='stage=NAMEDOWN'; @@ -16044,17 +16670,17 @@ if ($ADD==0) if (eregi("LEVELDOWN",$stage)) {$SQLorder='order by user_level desc'; $LEVELlink='stage=LEVELUP';} if (eregi("GROUPUP",$stage)) {$SQLorder='order by user_group asc'; $GROUPlink='stage=GROUPDOWN';} if (eregi("GROUPDOWN",$stage)) {$SQLorder='order by user_group desc'; $GROUPlink='stage=GROUPUP';} - $stmt="SELECT user,full_name,user_level,user_group from vicidial_users $SQLorder"; + $stmt="SELECT user,full_name,user_level,user_group,active from vicidial_users $SQLstatus $SQLorder"; $rslt=mysql_query($stmt, $link); $people_to_print = mysql_num_rows($rslt); - echo "
USER LISTINGS:\n"; echo "
\n"; echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; echo "\n"; $o=0; @@ -16069,6 +16695,7 @@ if ($ADD==0) echo ""; echo ""; echo ""; + echo ""; echo "\n"; $o++; } @@ -16838,11 +17465,13 @@ if ($ADD==999999) $i++; } - $stmt="SELECT enable_queuemetrics_logging,queuemetrics_url from system_settings;"; + $stmt="SELECT enable_queuemetrics_logging,queuemetrics_url,enable_vtiger_integration,vtiger_url from system_settings;"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $enable_queuemetrics_logging_LU = $row[0]; $queuemetrics_url_LU = $row[1]; + $enable_vtiger_integration_LU = $row[2]; + $vtiger_url_LU = $row[3]; ?> @@ -16868,6 +17497,10 @@ if ($ADD==999999) { echo "
  • QUEUEMETRICS REPORTS\n"; } + if ($enable_vtiger_integration_LU > 0) + { + echo "
  • VTIGER HOME\n"; + } ?>
  • USER IDFULL NAMELEVELGROUPUSER IDFULL NAMELEVELGROUPACTIVELINKS
    $row[1]$row[2]$row[3]$row[4]
    MODIFY | STATS | STATUS | TIME
    diff --git a/agc_2-X/trunk/www/vicidial/vtiger_search.php b/agc_2-X/trunk/www/vicidial/vtiger_search.php index d8061866..05d1ef51 100644 --- a/agc_2-X/trunk/www/vicidial/vtiger_search.php +++ b/agc_2-X/trunk/www/vicidial/vtiger_search.php @@ -6,33 +6,24 @@ # 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. # -# This code is tested against vtiger 5.0.3 +# This code is tested against vtiger 5.0.4 # # CHANGES # 60719-1615 - First version # 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 # -#Asterisk/VICIDIAL Server (ASTERISK) -#Internal : 10.10.10.15 -#External : 55.55.55.55 - -#vtiger Server(TEST1) -#Internal : 10.10.10.16 -#External : 55.55.55.56 - -### Modified 20.Dec.2007 by I. Taushanov for VTiger 5.03- search/create lead - - -### alter to connect to your vtiger database, "IP", "username for DB", 'password for DB') -$link=mysql_connect("xxx.xxx.xxx.xxx", "dbuser",'dbpassword'); -if (!$link) {die('Could not connect: ' . mysql_error());} -echo 'Connected successfully'; -mysql_select_db("vtigercrm503"); +header ("Content-type: text/html; charset=utf-8"); +require("dbconnect.php"); +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; $PHP_SELF=$_SERVER['PHP_SELF']; if (isset($_GET["address1"])) {$address1=$_GET["address1"];} elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} @@ -43,53 +34,53 @@ if (isset($_GET["address3"])) {$address3=$_GET["address3"];} if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} - elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} -if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} - elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} if (isset($_GET["channel"])) {$channel=$_GET["channel"];} elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} -if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} - elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} -if (isset($_GET["city"])) {$city=$_GET["city"];} - elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} if (isset($_GET["comments"])) {$comments=$_GET["comments"];} elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} -if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} - elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} -if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];} - elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];} -if (isset($_GET["DB"])) {$DB=$_GET["DB"];} - elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} -if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} - elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} -if (isset($_GET["email"])) {$email=$_GET["email"];} - elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];} + elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} if (isset($_GET["extension"])) {$extension=$_GET["extension"];} elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} - elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} -if (isset($_GET["group"])) {$group=$_GET["group"];} - elseif (isset($_POST["group"])) {$group=$_POST["group"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} -if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} - elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} -if (isset($_GET["pass"])) {$pass=$_GET["pass"];} - elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} - elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} -if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} - elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} -if (isset($_GET["phone"])) {$phone=$_GET["phone"];} - elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} -if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} - elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} if (isset($_GET["province"])) {$province=$_GET["province"];} elseif (isset($_POST["province"])) {$province=$_POST["province"];} if (isset($_GET["security"])) {$security=$_GET["security"];} @@ -99,25 +90,22 @@ if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} - elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} -if (isset($_GET["state"])) {$state=$_GET["state"];} - elseif (isset($_POST["state"])) {$state=$_POST["state"];} -if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} elseif (isset($_POST["status"])) {$status=$_POST["status"];} -if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} - elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} -if (isset($_GET["user"])) {$user=$_GET["user"];} - elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} -if (isset($_GET["submit"])) {$submit=$_GET["submit"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} -if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} -#$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); -#$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); - #$DB = '1'; # DEBUG override $US = '_'; $STARTtime = date("U"); @@ -127,124 +115,397 @@ $REC_TIME = date("Ymd-His"); $FILE_datetime = $STARTtime; $parked_time = $STARTtime; +############################################################### +##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### +$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 ($DB) {echo "$stmt\n";} +$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]; + } +##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### +############################################################# + + echo "\n"; echo "\n"; echo "VICIDIAL Vtiger Lookup\n"; echo "\n"; -$stmt="SELECT count(*) from vtiger_leadaddress where phone='$phone' or mobile='$phone' or fax='$phone';"; +if ($enable_vtiger_integration < 1) + { + echo "ERROR! - Vtiger integration is disabled in the VICIDIAL system_settings"; + exit; + } + +$stmt = "SELECT vtiger_search_category FROM vicidial_campaigns where campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} -if (!$rslt) { - die('Could not execute: ' . mysql_error()); -} -$row=mysql_fetch_row($rslt); -$found_count = $row[0]; - -#echo "
    \n|$phone|$found_count|\n"; - -if ($found_count < 1) -{ - echo "\n"; - echo "\n"; - echo "
    \n"; - echo "$phone not found, creating account...\n"; -#Get logged in user ID - if ($DB) {echo "
    ";}
    -	$stmt="SELECT id from vtiger_users where user_name='$user';";
    -	if ($DB) {echo "$stmt\n";}
    -	$rslt=mysql_query($stmt, $link);
    +$vtc_conf_ct = mysql_num_rows($rslt);
    +if ($vtc_conf_ct > 0)
    +	{
     	$row=mysql_fetch_row($rslt);
    -	$user_id = $row[0];
    -	if (!$rslt) {die('Could not execute: ' . mysql_error());}
    -	
    -#Vtiger no longer use auto increment for vtiger_crmentity crmid, vtiger_crmentity_seq is used instead to list next aviable entity ID
    -# Get next aviable id to use as  crmid in vtiger_crmentity	
    -	$stmt="SELECT id from vtiger_crmentity_seq ;";
    +	$vtiger_search_category =	$row[0];
    +	}
    +if (strlen($vtiger_search_category)<1) 
    +	{$vtiger_search_category = 'LEAD';}
    +
    +### 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());}
    +echo 'Connected successfully';
    +mysql_select_db("$vtiger_dbname", $linkV);
    +
    +# Methods of searching for records:
    +#
    +# ACCTID:
    +# $stmt="SELECT count(*) from vtiger_account where accountid='$vendor_id';";
    +#
    +# ACCOUNT:
    +# $stmt="SELECT count(*) from vtiger_account where phone='$phone' or otherphone='$phone' or fax='$phone';";
    +# $stmt="SELECT count(*) from vtiger_contactdetails where phone='$phone' or mobile='$phone' or fax='$phone';";
    +# $stmt="SELECT count(*) from vtiger_contactsubdetails where homephone='$phone' or otherphone='$phone' or assistantphone='$phone';";
    +#
    +# VENDOR:
    +# $stmt="SELECT count(*) from vtiger_vendor where phone='$phone';";
    +#
    +# 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;}
    +if (ereg('ACCOUNT',$vtiger_search_category))	{$account_search=1;}
    +if (ereg('VENDOR',$vtiger_search_category))		{$vendor_search=1;}
    +if (ereg('LEAD',$vtiger_search_category))		{$lead_search=1;}
    +
    +
    +
    +
    +
    +##########################################################################
    +##### BEGIN - ACCTID -  Search in the account records for accountid number
    +##########################################################################
    +if ($acctid_search > 0)
    +	{
    +	$stmt="SELECT count(*) from vtiger_account where accountid='$vendor_id';";
    +	$rslt=mysql_query($stmt, $linkV);
     	if ($DB) {echo "$stmt\n";}
    -	$rslt=mysql_query($stmt, $link);
    +	if (!$rslt) {die('Could not execute: ' . mysql_error());}
     	$row=mysql_fetch_row($rslt);
    -	$leadid = $row[0];
    -	if (!$rslt) {die('Could not execute: ' . mysql_error());}
    +	$found_count = $row[0];
     
    -# Increase 	next aviable crmid with 1 so next record gets proper id
    -	$stmt="UPDATE vtiger_crmentity_seq SET `id` = `id` + 1;";
    +	if ($DB) {echo "
    \nACCTID|$vendor_id|$found_count|\n";} + + if ($found_count < 1) + { + 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"; + + echo "
    ";
    +		echo "account found! ACCTID\n";
    +		echo "accountid:   $vendor_id\n";
    +		echo "

    "; + exit; + } + } +########################################################################## +##### END - ACCTID - Search in the account records for accountid number +########################################################################## + + +########################################################################## +##### BEGIN - ACCOUNT - Search in the account records for phone number +########################################################################## +if ($account_search > 0) + { + $stmt="SELECT count(*) from vtiger_account where phone='$phone' or otherphone='$phone' or fax='$phone';"; + $rslt=mysql_query($stmt, $linkV); if ($DB) {echo "$stmt\n";} - $rslt=mysql_query($stmt, $link); if (!$rslt) {die('Could not execute: ' . mysql_error());} - - -#Insert values into tiger_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, $link); - if ($DB) {echo "|$leadid|\n";} - if (!$rslt) {die('Could not execute: ' . mysql_error());} - -#Insert values into vtiger_leaddetails - $stmt = "INSERT INTO vtiger_leaddetails (leadid,firstname,lastname,company) values('$leadid','$first_name','$last_name','$first_name $last_name');"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); - if (!$rslt) {die('Could not execute: ' . mysql_error());} - -#Insert values into vtiger_leaddetails - $stmt = "INSERT INTO vtiger_leadaddress (leadaddressid,city,code,state,country,phone,mobile,lane) values('$leadid','$city','$postal_code','$province','$country','$phone','$alt_phone','$address1 $address2');"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); - if (!$rslt) {die('Could not execute: ' . mysql_error());} - -#Insert values into vtiger_leadsubdetails - $stmt = "INSERT INTO vtiger_leadsubdetails (leadsubscriptionid) VALUES ('$leadid');"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); - if (!$rslt) {die('Could not execute: ' . mysql_error());} - -#Insert values into vtiger_leadscf, these are custom created fields example -# $stmt = "INSERT INTO vtiger_leadscf (leadid,cf_452,cf_454,cf_456) VALUES ('$leadid','$email','$address3','$security');"; -# if ($DB) {echo "|$stmt|\n";} -# $rslt=mysql_query($stmt, $link); -# if (!$rslt) {die('Could not execute: ' . mysql_error());} - - if ($DB) {echo "DONE\n";} - -#ammend with your Vtiger Address - $account_URL = "http://mysite.com/vtigercrm/index.php?module=Leads&action=DetailView&record=$leadid"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
    \n"; - - echo "
    ";
    -	echo "account created!\n";
    -	echo "accountid:   $leadid\n";
    -	echo "phone:       $phone\n";
    -	echo "

    "; - -} -else -{ - $stmt="SELECT leadaddressid from vtiger_leadaddress where phone='$phone' or mobile='$phone' or fax='$phone';"; - $rslt=mysql_query($stmt, $link); - if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); - $leadid = $row[0]; + $found_count = $row[0]; - -#ammend with your Vtiger Address - $account_URL = "http://mysite.com/vtigercrm/index.php?module=Leads&action=DetailView&record=$leadid"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
    \n"; + if ($DB) {echo "
    \nACCOUNT|$phone|$found_count|vtiger_account\n";} - echo "
    ";
    -	echo "account found!\n";
    -	echo "accountid:   $leadid\n";
    -	echo "phone:       $phone\n";
    -	echo "

    "; + if ($found_count < 1) + { + echo "\n"; + + $stmt="SELECT count(*) from vtiger_contactdetails where phone='$phone' or mobile='$phone' or fax='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + if ($DB) {echo "
    \nACCOUNT|$phone|$found_count|vtiger_contactdetails\n";} + + if ($found_count < 1) + { + echo "\n"; + + $stmt="SELECT count(*) from vtiger_contactsubdetails where homephone='$phone' or otherphone='$phone' or assistantphone='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + if ($DB) {echo "
    \nACCOUNT|$phone|$found_count|vtiger_contactsubdetails\n";} + + if ($found_count < 1) + { + echo "\n"; + } + else + { + # find vtiger_contact + $stmt="SELECT contactsubscriptionid from vtiger_contactsubdetails where homephone='$phone' or otherphone='$phone' or assistantphone='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $contactid = $row[0]; + + # find vtiger_account + $stmt="SELECT accountid from vtiger_contactdetails where contactid='$contactid';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $accountid = $row[0]; + } + } + else + { + # find vtiger_account + $stmt="SELECT accountid from vtiger_contactdetails where phone='$phone' or mobile='$phone' or fax='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $accountid = $row[0]; + } + } + else + { + # find vtiger_account + $stmt="SELECT accountid from vtiger_account where phone='$phone' or otherphone='$phone' or fax='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $accountid = $row[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"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
    \n"; + + echo "
    ";
    +		echo "account found! ACCOUNT\n";
    +		echo "accountid:   $accountid\n";
    +		echo "phone:       $phone\n";
    +		echo "

    "; + exit; + } + } +########################################################################## +##### END - ACCOUNT - Search in the account records for phone number +########################################################################## + + +########################################################################## +##### BEGIN - VENDOR - Search in the vendor records for phone number +########################################################################## +if ($vendor_search > 0) + { + $stmt="SELECT count(*) from vtiger_vendor where phone='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + if ($DB) {echo "
    \nVENDOR|$phone|$found_count|\n";} + + if ($found_count < 1) + { + echo "\n"; + } + else + { + # find vtiger_vendor + $stmt="SELECT vendorid from vtiger_vendor where phone='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $vendorid = $row[0]; + + # http://mysite.com/vtigercrm/index.php?module=Vendors&action=DetailView&record=2&parenttab=Inventory + $account_URL = "$vtiger_url/index.php?module=Vendors&action=DetailView&record=$vendorid&parenttab=Inventory"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
    \n"; + + echo "
    ";
    +		echo "account found! VENDOR\n";
    +		echo "vendorid:   $vendorid\n";
    +		echo "phone:       $phone\n";
    +		echo "

    "; + exit; + } + } +########################################################################## +##### END - VENDOR - Search in the vendor records for phone number +########################################################################## + + +########################################################################## +##### BEGIN - LEAD - Search in the leads records for phone number +########################################################################## +if ($lead_search > 0) + { + $stmt="SELECT count(*) from vtiger_leadaddress where phone='$phone' or mobile='$phone' or fax='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + if ($DB) {echo "
    \nLEAD|$phone|$found_count|\n";} + + if ($found_count < 1) + { + echo "\n"; + if ($create_lead_if_not_found > 0) + { + echo "\n"; + echo "\n"; + echo "
    \n"; + echo "$phone not found, creating account...\n"; + + $DB=1; + + #Get logged in user ID + if ($DB) {echo "
    ";}
    +			$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());}
    +			
    +			#Vtiger no longer use auto increment for vtiger_crmentity crmid, vtiger_crmentity_seq is used instead to list next aviable entity ID
    +			# Get next aviable id to use as  crmid 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);
    +			$leadid = ($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 = '$leadid';";
    +			if ($DB) {echo "$stmt\n";}
    +			$rslt=mysql_query($stmt, $linkV);
    +			if (!$rslt) {die('Could not execute: ' . mysql_error());}
    +			
    +			#Insert values into tiger_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);
    +			if ($DB) {echo "|$leadid|\n";}
    +			if (!$rslt) {die('Could not execute: ' . mysql_error());}
    +
    +			#Insert values into vtiger_leaddetails	
    +			$stmt = "INSERT INTO vtiger_leaddetails (leadid,firstname,lastname,company) values('$leadid','$first_name','$last_name','$first_name $last_name');";
    +			if ($DB) {echo "|$stmt|\n";}
    +			$rslt=mysql_query($stmt, $linkV);
    +			if (!$rslt) {die('Could not execute: ' . mysql_error());}
    +
    +			#Insert values into vtiger_leaddetails
    +			$stmt = "INSERT INTO vtiger_leadaddress (leadaddressid,city,code,state,country,phone,mobile,lane) values('$leadid','$city','$postal_code','$province','$country','$phone','$alt_phone','$address1 $address2');";
    +			if ($DB) {echo "|$stmt|\n";}
    +			$rslt=mysql_query($stmt, $linkV);
    +			if (!$rslt) {die('Could not execute: ' . mysql_error());}
    +
    +			#Insert values into vtiger_leadsubdetails	
    +			$stmt = "INSERT INTO vtiger_leadsubdetails (leadsubscriptionid) VALUES ('$leadid');";
    +			if ($DB) {echo "|$stmt|\n";}
    +			$rslt=mysql_query($stmt, $linkV);
    +			if (!$rslt) {die('Could not execute: ' . mysql_error());}
    +			
    +			#Insert values into vtiger_leadscf, these are custom created fields example	
    +			$stmt = "INSERT INTO vtiger_leadscf (leadid) VALUES ('$leadid');";
    +			if ($DB) {echo "|$stmt|\n";}
    +			$rslt=mysql_query($stmt, $linkV);
    +			if (!$rslt) {die('Could not execute: ' . mysql_error());}
    +
    +			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";
    +			echo "\n";
    +		#	echo "\n";
    +			echo "
    \n"; + + echo "
    ";
    +			echo "account created! LEAD\n";
    +			echo "leadid:   $leadid\n";
    +			echo "phone:       $phone\n";
    +			echo "

    "; + exit; + } + } + else + { + $stmt="SELECT leadaddressid from vtiger_leadaddress where phone='$phone' or mobile='$phone' or fax='$phone';"; + $rslt=mysql_query($stmt, $linkV); + 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"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
    \n"; + + echo "
    ";
    +		echo "lead found! LEAD\n";
    +		echo "leadid:   $leadid\n";
    +		echo "phone:       $phone\n";
    +		echo "

    "; + exit; + } + } +########################################################################## +##### END - LEAD - Search in the leads records for phone number +########################################################################## -} @@ -252,7 +513,7 @@ $ENDtime = date("U"); $RUNtime = ($ENDtime - $STARTtime); -echo "\n\n\n


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

    \n\n"; echo "\n\n\n


    \nscript runtime: $RUNtime seconds
    "; diff --git a/agc_2-X/trunk/www/vicidial/vtiger_user.php b/agc_2-X/trunk/www/vicidial/vtiger_user.php new file mode 100644 index 00000000..c0e15846 --- /dev/null +++ b/agc_2-X/trunk/www/vicidial/vtiger_user.php @@ -0,0 +1,264 @@ +column_fields["user_name"]; + global $mod_strings; + + $query = "SELECT user_name from vtiger_users where user_name=? AND id<>? AND deleted=0"; + $result =$this->db->pquery($query, array($usr_name, $this->id), true, "Error selecting possible duplicate users: "); + $dup_users = $this->db->fetchByAssoc($result); + + $query = "SELECT user_name from vtiger_users where is_admin = 'on' AND deleted=0"; + $result =$this->db->pquery($query, array(), true, "Error selecting possible duplicate vtiger_users: "); + $last_admin = $this->db->fetchByAssoc($result); + + $this->log->debug("last admin length: ".count($last_admin)); + $this->log->debug($last_admin['user_name']." == ".$usr_name); + + $verified = true; + if($dup_users != null) + { + $this->error_string .= $mod_strings['ERR_USER_NAME_EXISTS_1'].$usr_name.''.$mod_strings['ERR_USER_NAME_EXISTS_2']; + $verified = false; + } + if(!isset($_REQUEST['is_admin']) && + count($last_admin) == 1 && + $last_admin['user_name'] == $usr_name) { + $this->log->debug("last admin length: ".count($last_admin)); + + $this->error_string .= $mod_strings['ERR_LAST_ADMIN_1'].$usr_name.$mod_strings['ERR_LAST_ADMIN_2']; + $verified = false; + } + + return $verified; + } +*/ + + +# require("../vtigercrm/modules/Calendar/Activity.php"); + +# $verified = verify_data(); + + +/* + + * @return string encrypted password for storage in DB and comparison against DB password. + * @param string $user_name - Must be non null and at least 2 characters + * @param string $user_password - Must be non null and at least 1 character. + * @desc Take an unencrypted username and password and return the encrypted password + * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.. + * All Rights Reserved.. + * Contributor(s): ______________________________________.. + function encrypt_password($user_password, $crypt_type='') + { + // encrypt the password. + $salt = substr($this->column_fields["user_name"], 0, 2); + + // Fix for: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/4923 + if($crypt_type == '') { + // Try to get the crypt_type which is in database for the user + $crypt_type = $this->get_user_crypt_type(); + } + + // For more details on salt format look at: http://in.php.net/crypt + if($crypt_type == 'MD5') { + $salt = '$1$' . $salt . '$'; + } else if($crypt_type == 'BLOWFISH') { + $salt = '$2$' . $salt . '$'; + } + + $encrypted_password = crypt($user_password, $salt); + + return $encrypted_password; + + } +*/ + + + + + +##### vtiger_user.php - script used to synchronize the users from the VICIDIAL +##### vicidial_users table into the Vtiger system + +# CHANGES +# 81231-1307 - First build +# + + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; + + +#$DB = '1'; # DEBUG override +$US = '_'; +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$REC_TIME = date("Ymd-His"); +$FILE_datetime = $STARTtime; +$parked_time = $STARTtime; + +############################################################### +##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### +$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 ($DB) {echo "$stmt\n";} +$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]; + } +##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### +############################################################# + +echo "\n"; +echo "\n"; +echo "VICIDIAL Vtiger user synchronization utility\n"; +echo "\n"; + +if ($enable_vtiger_integration < 1) + { + echo "ERROR! - Vtiger integration is disabled in the VICIDIAL system_settings"; + exit; + } + +##### grab the existing users in the vicidial_users table +$stmt="SELECT user,pass,full_name,user_level,active FROM vicidial_users;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$VD_users_ct = mysql_num_rows($rslt); +$i=0; +while ($i < $VD_users_ct) + { + $row=mysql_fetch_row($rslt); + $user[$i] = $row[0]; + $pass[$i] = $row[1]; + $full_name[$i] = $row[2]; while (strlen($full_name[$i])>30) {$full_name[$i] = eregi_replace(".$",'',$full_name[$i]);} + $user_level[$i] = $row[3]; + $active[$i] = $row[4]; + $i++; + } + + +### 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());} +echo 'Connected successfully'; +mysql_select_db("$vtiger_dbname", $linkV); + + +$i=0; +while ($i < $VD_users_ct) + { + $user_name = $user[$i]; + $user_password = $pass[$i]; + $last_name = $full_name[$i]; + $is_admin = 'off'; + $roleid = 'H5'; + $status = 'Active'; + $groupid = '1'; + if ($user_level[$i] >= 8) {$roleid = 'H4';} + if ($user_level[$i] >= 9) {$roleid = 'H2';} + if ($user_level[$i] >= 9) {$is_admin = 'on';} + if (ereg('N',$active[$i])) {$status = 'Inactive';} + $salt = substr($user_name, 0, 2); + $salt = '$1$' . $salt . '$'; + $encrypted_password = crypt($user_password, $salt); + $i++; + + $stmt="SELECT count(*) from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + ### user exists in vtiger, update it + if ($found_count > 0) + { + $stmt="SELECT id from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $userid = $row[0]; + + $stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + echo "$user_name: $userid
    \n"; + echo "$stmtA
    \n"; + echo "$stmtB
    \n"; + echo "
    \n"; + + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW USER RECORD IN VTIGER + $stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $userid = mysql_insert_id($linkV); + + $stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "UPDATE vtiger_users_seq SET id='$userid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + echo "$user_name:
    \n"; + echo "$stmtA
    \n"; + echo "$stmtB
    \n"; + echo "$stmtC
    \n"; + echo "$stmtD
    \n"; + echo "
    \n"; + #### END CREATE NEW USER RECORD IN VTIGER + } + + + } + + + + + +echo "DONE\n"; + +exit; + +