Added Vtiger user synchronization
Added more options for the vtiger_search.php web form page Added notification of time sync problems to vicidial.php other bug fixes git-svn-id: svn://192.168.202.10@1026 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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 <vicidial@gmail.com> 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)
|
||||
# );
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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: <ip-address>
|
||||
* 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 | |
|
||||
+-------------+--------------+------+-----+---------+----------------+
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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, '<? $placeholder=0; ?>');
|
||||
+ 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, '<? $placeholder=0; ?>');
|
||||
+ fclose($sp);
|
||||
+ }
|
||||
require('user_privileges/user_privileges_'.$current_user->id.'.php');
|
||||
require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
|
||||
$permission = "no";
|
||||
@@ -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
|
||||
|
||||
@@ -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 "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
|
||||
$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";
|
||||
|
||||
|
||||
@@ -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 "</head>\n";
|
||||
<span id="AgentMuteSpan"></span> <BR>
|
||||
</font></span>
|
||||
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:38;" id="CallBacKsLisTBox">
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:39;" id="CallBacKsLisTBox">
|
||||
<table border=1 bgcolor="#CCFFCC" width=<?=$CAwidth ?> height=460><TR><TD align=center VALIGN=top> CALLBACKS FOR AGENT <? echo $VD_login ?>:<BR>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.
|
||||
<BR>
|
||||
<div class="scroll_callback" id="CallBacKsLisT"></div>
|
||||
@@ -7482,7 +7486,7 @@ echo "</head>\n";
|
||||
</TD></TR></TABLE>
|
||||
</span>
|
||||
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:39;" id="NeWManuaLDiaLBox">
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:40;" id="NeWManuaLDiaLBox">
|
||||
<table border=1 bgcolor="#CCFFCC" width=<?=$CAwidth ?> height=460><TR><TD align=center VALIGN=top> NEW MANUAL DIAL LEAD FOR <? echo "$VD_login in campaign $VD_campaign" ?>:<BR><BR>Enter information below for the new lead you wish to call.
|
||||
<BR>
|
||||
<?
|
||||
@@ -7663,23 +7667,28 @@ Your Status: <span id="AgentStatusStatus"></span> <BR>Calls Dialing: <span id="A
|
||||
</TD></TR></TABLE>
|
||||
</span>
|
||||
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:32;" id="LogouTBox">
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:32;" id="SysteMDisablEBoX">
|
||||
<table border=1 bgcolor="#FFFFFF" width=<?=$CAwidth ?> height=500><TR><TD align=center>There is a time synchronization problem with your system, please tell your system administrator<BR><BR><BR><a href="#" onclick="hideDiv('SysteMDisablEBoX');return false;">Go Back</a>
|
||||
</TD></TR></TABLE>
|
||||
</span>
|
||||
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:33;" id="LogouTBox">
|
||||
<table border=1 bgcolor="#FFFFFF" width=<?=$CAwidth ?> height=500><TR><TD align=center><BR><span id="LogouTBoxLink">LOGOUT</span></TD></TR></TABLE>
|
||||
</span>
|
||||
|
||||
<span style="position:absolute;left:0px;top:70px;z-index:33;" id="DispoButtonHideA">
|
||||
<span style="position:absolute;left:0px;top:70px;z-index:34;" id="DispoButtonHideA">
|
||||
<table border=0 bgcolor="#CCFFCC" width=165 height=22><TR><TD align=center VALIGN=top></TD></TR></TABLE>
|
||||
</span>
|
||||
|
||||
<span style="position:absolute;left:0px;top:138px;z-index:34;" id="DispoButtonHideB">
|
||||
<span style="position:absolute;left:0px;top:138px;z-index:35;" id="DispoButtonHideB">
|
||||
<table border=0 bgcolor="#CCFFCC" width=165 height=250><TR><TD align=center VALIGN=top> </TD></TR></TABLE>
|
||||
</span>
|
||||
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:35;" id="DispoButtonHideC">
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:36;" id="DispoButtonHideC">
|
||||
<table border=0 bgcolor="#CCFFCC" width=<?=$CAwidth ?> height=47><TR><TD align=center VALIGN=top>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. </TD></TR></TABLE>
|
||||
</span>
|
||||
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:36;" id="DispoSelectBox">
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:37;" id="DispoSelectBox">
|
||||
<table border=1 bgcolor="#CCFFCC" width=<?=$CAwidth ?> height=460><TR><TD align=center VALIGN=top> DISPOSITION CALL :<span id="DispoSelectPhonE"></span> <span id="DispoSelectHAspan"><a href="#" onclick="DispoHanguPAgaiN()">Hangup Again</a></span> <span id="DispoSelectMaxMin"><a href="#" onclick="DispoMinimize()"> minimize </a></span><BR>
|
||||
<span id="DispoSelectContent"> End-of-call Disposition Selection </span>
|
||||
<input type=hidden name=DispoSelection><BR>
|
||||
@@ -7692,7 +7701,7 @@ Your Status: <span id="AgentStatusStatus"></span> <BR>Calls Dialing: <span id="A
|
||||
</TD></TR></TABLE>
|
||||
</span>
|
||||
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:42;" id="PauseCodeSelectBox">
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:43;" id="PauseCodeSelectBox">
|
||||
<table border=1 bgcolor="#CCFFCC" width=<?=$CAwidth ?> height=460><TR><TD align=center VALIGN=top> SELECT A PAUSE CODE :<BR>
|
||||
<span id="PauseCodeSelectContent"> Pause Code Selection </span>
|
||||
<input type=hidden name=PauseCodeSelection>
|
||||
@@ -7700,10 +7709,10 @@ Your Status: <span id="AgentStatusStatus"></span> <BR>Calls Dialing: <span id="A
|
||||
</TD></TR></TABLE>
|
||||
</span>
|
||||
|
||||
<span style="position:absolute;left:0px;top:1000px;z-index:43;" id="GENDERhideFORieALT"></span>
|
||||
<span style="position:absolute;left:0px;top:1000px;z-index:44;" id="GENDERhideFORieALT"></span>
|
||||
|
||||
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:37;" id="CallBackSelectBox">
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:38;" id="CallBackSelectBox">
|
||||
<table border=1 bgcolor="#CCFFCC" width=<?=$CAwidth ?> height=460><TR><TD align=center VALIGN=top> Select a CallBack Date :<span id="CallBackDatE"></span><BR>
|
||||
<input type=hidden name=CallBackDatESelectioN ID="CallBackDatESelectioN">
|
||||
<input type=hidden name=CallBackTimESelectioN ID="CallBackTimESelectioN">
|
||||
@@ -7748,7 +7757,7 @@ Your Status: <span id="AgentStatusStatus"></span> <BR>Calls Dialing: <span id="A
|
||||
if ($agentonly_callbacks)
|
||||
{echo "<input type=checkbox name=CallBackOnlyMe id=CallBackOnlyMe size=1 value=\"0\"> MY CALLBACK ONLY <BR>";}
|
||||
?>
|
||||
CB Comments: <input type=text name="CallBackCommenTsField" id="CallBackCommenTsField" size=50><BR><BR>
|
||||
CB Comments: <input type=text name="CallBackCommenTsField" id="CallBackCommenTsField" size=50 maxlength=255><BR><BR>
|
||||
|
||||
<a href="#" onclick="CallBackDatE_submit();return false;">SUBMIT</a><BR><BR>
|
||||
<span id="CallBackDateContent"><?echo"$CCAL_OUT"?></span>
|
||||
@@ -7756,7 +7765,7 @@ Your Status: <span id="AgentStatusStatus"></span> <BR>Calls Dialing: <span id="A
|
||||
</TD></TR></TABLE>
|
||||
</span>
|
||||
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:40;" id="CloserSelectBox">
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:41;" id="CloserSelectBox">
|
||||
<table border=1 bgcolor="#CCFFCC" width=<?=$CAwidth ?> height=460><TR><TD align=center VALIGN=top> CLOSER INBOUND GROUP SELECTION <BR>
|
||||
<span id="CloserSelectContent"> Closer Inbound Group Selection </span>
|
||||
<input type=hidden name=CloserSelectList><BR>
|
||||
@@ -7767,7 +7776,7 @@ Your Status: <span id="AgentStatusStatus"></span> <BR>Calls Dialing: <span id="A
|
||||
</TD></TR></TABLE>
|
||||
</span>
|
||||
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:41;" id="NothingBox">
|
||||
<span style="position:absolute;left:0px;top:0px;z-index:42;" id="NothingBox">
|
||||
<BUTTON Type=button name="inert_button"><img src="./images/blank.gif"></BUTTON>
|
||||
<span id="DiaLLeaDPrevieWHide">Channel</span>
|
||||
<span id="DiaLDiaLAltPhonEHide">Channel</span>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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 "<html>\n";
|
||||
echo "<head>\n";
|
||||
echo "<title>VICIDIAL Vtiger Lookup</title>\n";
|
||||
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
|
||||
|
||||
|
||||
$stmt="SELECT count(*) from vtiger_leadaddress where phone='$phone' or mobile='$phone' or fax='$phone';";
|
||||
if ($enable_vtiger_integration < 1)
|
||||
{
|
||||
echo "<B>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 "<BR>\n|$phone|$found_count|\n";
|
||||
|
||||
if ($found_count < 1)
|
||||
{
|
||||
echo "</head>\n";
|
||||
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onLoad=\"document.forms[0].search_phone.focus(); setTimeout('document.forms[0].phone.focus()', 1000); self.focus()\">\n";
|
||||
echo "<CENTER><FONT FACE=\"Courier\" COLOR=BLACK SIZE=3>\n";
|
||||
echo "$phone not found, creating account...\n";
|
||||
#Get logged in user ID
|
||||
if ($DB) {echo "<PRE>";}
|
||||
$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 "<BR>\nACCTID|$vendor_id|$found_count|\n";}
|
||||
|
||||
if ($found_count < 1)
|
||||
{
|
||||
echo "<!-- ACCTID not found $vendor_id -->\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 "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$account_URL\">\n";
|
||||
echo "</head>\n";
|
||||
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onLoad=\"document.forms[0].search_phone.focus(); setTimeout('document.forms[0].phone.focus()', 1000); self.focus()\">\n";
|
||||
echo "<CENTER><FONT FACE=\"Courier\" COLOR=BLACK SIZE=3>\n";
|
||||
|
||||
echo "<PRE>";
|
||||
echo "account found! ACCTID\n";
|
||||
echo "accountid: <a href=\"$account_URL\">$vendor_id</a>\n";
|
||||
echo "</PRE><BR>";
|
||||
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 "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$account_URL\">\n";
|
||||
echo "</head>\n";
|
||||
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onLoad=\"document.forms[0].search_phone.focus(); setTimeout('document.forms[0].phone.focus()', 1000); self.focus()\">\n";
|
||||
echo "<CENTER><FONT FACE=\"Courier\" COLOR=BLACK SIZE=3>\n";
|
||||
|
||||
echo "<PRE>";
|
||||
echo "account created!\n";
|
||||
echo "accountid: <a href=\"$account_URL\">$leadid</a>\n";
|
||||
echo "phone: $phone\n";
|
||||
echo "</PRE><BR>";
|
||||
|
||||
}
|
||||
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 "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$account_URL\">\n";
|
||||
echo "</head>\n";
|
||||
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onLoad=\"document.forms[0].search_phone.focus(); setTimeout('document.forms[0].phone.focus()', 1000); self.focus()\">\n";
|
||||
echo "<CENTER><FONT FACE=\"Courier\" COLOR=BLACK SIZE=3>\n";
|
||||
if ($DB) {echo "<BR>\nACCOUNT|$phone|$found_count|vtiger_account\n";}
|
||||
|
||||
echo "<PRE>";
|
||||
echo "account found!\n";
|
||||
echo "accountid: <a href=\"$account_URL\">$leadid</a>\n";
|
||||
echo "phone: $phone\n";
|
||||
echo "</PRE><BR>";
|
||||
if ($found_count < 1)
|
||||
{
|
||||
echo "<!-- ACCOUNT vtiger_account not found $phone -->\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 "<BR>\nACCOUNT|$phone|$found_count|vtiger_contactdetails\n";}
|
||||
|
||||
if ($found_count < 1)
|
||||
{
|
||||
echo "<!-- ACCOUNT vtiger_contactdetails not found $phone -->\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 "<BR>\nACCOUNT|$phone|$found_count|vtiger_contactsubdetails\n";}
|
||||
|
||||
if ($found_count < 1)
|
||||
{
|
||||
echo "<!-- ACCOUNT vtiger_contactsubdetails not found $phone -->\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 "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$account_URL\">\n";
|
||||
echo "</head>\n";
|
||||
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onLoad=\"document.forms[0].search_phone.focus(); setTimeout('document.forms[0].phone.focus()', 1000); self.focus()\">\n";
|
||||
echo "<CENTER><FONT FACE=\"Courier\" COLOR=BLACK SIZE=3>\n";
|
||||
|
||||
echo "<PRE>";
|
||||
echo "account found! ACCOUNT\n";
|
||||
echo "accountid: <a href=\"$account_URL\">$accountid</a>\n";
|
||||
echo "phone: $phone\n";
|
||||
echo "</PRE><BR>";
|
||||
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 "<BR>\nVENDOR|$phone|$found_count|\n";}
|
||||
|
||||
if ($found_count < 1)
|
||||
{
|
||||
echo "<!-- VENDOR not found $phone -->\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 "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$account_URL\">\n";
|
||||
echo "</head>\n";
|
||||
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onLoad=\"document.forms[0].search_phone.focus(); setTimeout('document.forms[0].phone.focus()', 1000); self.focus()\">\n";
|
||||
echo "<CENTER><FONT FACE=\"Courier\" COLOR=BLACK SIZE=3>\n";
|
||||
|
||||
echo "<PRE>";
|
||||
echo "account found! VENDOR\n";
|
||||
echo "vendorid: <a href=\"$account_URL\">$vendorid</a>\n";
|
||||
echo "phone: $phone\n";
|
||||
echo "</PRE><BR>";
|
||||
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 "<BR>\nLEAD|$phone|$found_count|\n";}
|
||||
|
||||
if ($found_count < 1)
|
||||
{
|
||||
echo "<!-- LEAD not found $phone -->\n";
|
||||
if ($create_lead_if_not_found > 0)
|
||||
{
|
||||
echo "</head>\n";
|
||||
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onLoad=\"document.forms[0].search_phone.focus(); setTimeout('document.forms[0].phone.focus()', 1000); self.focus()\">\n";
|
||||
echo "<CENTER><FONT FACE=\"Courier\" COLOR=BLACK SIZE=3>\n";
|
||||
echo "$phone not found, creating account...\n";
|
||||
|
||||
$DB=1;
|
||||
|
||||
#Get logged in user ID
|
||||
if ($DB) {echo "<PRE>";}
|
||||
$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 "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$account_URL\">\n";
|
||||
echo "</head>\n";
|
||||
# echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onLoad=\"document.forms[0].search_phone.focus(); setTimeout('document.forms[0].phone.focus()', 1000); self.focus()\">\n";
|
||||
echo "<CENTER><FONT FACE=\"Courier\" COLOR=BLACK SIZE=3>\n";
|
||||
|
||||
echo "<PRE>";
|
||||
echo "account created! LEAD\n";
|
||||
echo "leadid: <a href=\"$account_URL\">$leadid</a>\n";
|
||||
echo "phone: $phone\n";
|
||||
echo "</PRE><BR>";
|
||||
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 "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$account_URL\">\n";
|
||||
echo "</head>\n";
|
||||
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onLoad=\"document.forms[0].search_phone.focus(); setTimeout('document.forms[0].phone.focus()', 1000); self.focus()\">\n";
|
||||
echo "<CENTER><FONT FACE=\"Courier\" COLOR=BLACK SIZE=3>\n";
|
||||
|
||||
echo "<PRE>";
|
||||
echo "lead found! LEAD\n";
|
||||
echo "leadid: <a href=\"$account_URL\">$leadid</a>\n";
|
||||
echo "phone: $phone\n";
|
||||
echo "</PRE><BR>";
|
||||
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<br><br><br>\n\n";
|
||||
echo "\n\n\n<br>NOT FOUND<br><br>\n\n";
|
||||
|
||||
|
||||
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
<?
|
||||
### vtiger web api for user administration
|
||||
|
||||
/**
|
||||
* @return -- returns a list of all users in the system.
|
||||
function verify_data()
|
||||
{
|
||||
$usr_name = $this->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 "<html>\n";
|
||||
echo "<head>\n";
|
||||
echo "<title>VICIDIAL Vtiger user synchronization utility</title>\n";
|
||||
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
|
||||
|
||||
if ($enable_vtiger_integration < 1)
|
||||
{
|
||||
echo "<B>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<BR>\n";
|
||||
echo "$stmtA<BR>\n";
|
||||
echo "$stmtB<BR>\n";
|
||||
echo "<BR>\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:<BR>\n";
|
||||
echo "$stmtA<BR>\n";
|
||||
echo "$stmtB<BR>\n";
|
||||
echo "$stmtC<BR>\n";
|
||||
echo "$stmtD<BR>\n";
|
||||
echo "<BR>\n";
|
||||
#### END CREATE NEW USER RECORD IN VTIGER
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo "DONE\n";
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user