diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index e186ae8c..d8b4a2da 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -1902,6 +1902,20 @@ OTHER CHANGES: 15. Tested new asterisk-perl module (0.09) and found that it is NOT compatible. Please make sure you use asterisk-perl-0.08 ONLY. +16. Added email support, it needs to be enabled in your System Settings. Also, + the following perl modules need to be installed on your voicemail server + install LWP::UserAgent + install HTML::Entities + install HTML::Strip + install HTML::FormatText + install HTML::TreeBuilder + install Switch + install Time::Local + install MIME::Decoder + install Mail::POP3Client + install Mail::IMAPClient + install Mail::Message + diff --git a/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl b/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl index d6c3c4cf..e3d2561e 100644 --- a/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl +++ b/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl @@ -76,6 +76,7 @@ # 120820-1026 - Added clearing of vicidial_session_data table at end of day # 121019-1021 - Added voicemail greeting option # 121124-1440 - Added holiday expiration function +# 121215-2036 - Added email inbound script keepalive, option E # $DB=0; # Debug flag @@ -197,6 +198,7 @@ foreach(@conf) # 7 - AST_VDauto_dial_FILL\n"; # 8 - ip_relay for blind monitoring\n"; # 9 - Timeclock auto logout\n"; +# E - Email parser script # - Other setting are set by configuring them in the database if ($VARactive_keepalives =~ /X/) @@ -211,6 +213,7 @@ $AST_VDauto_dial=0; $AST_VDremote_agents=0; $AST_VDadapt=0; $FastAGI_log=0; +$email_inbound=0; $AST_VDauto_dial_FILL=0; $ip_relay=0; $timeclock_auto_logout=0; @@ -224,6 +227,7 @@ $runningFastAGI_log=0; $runningAST_VDauto_dial_FILL=0; $runningip_relay=0; $runningAST_conf_3way=0; +$runningemail_inbound=0; $AST_conf_3way=0; if ($VARactive_keepalives =~ /1/) @@ -271,6 +275,11 @@ if ($VARactive_keepalives =~ /9/) $timeclock_auto_logout=1; if ($DB) {print "Check to see if Timeclock auto logout should run\n";} } +if ($VARactive_keepalives =~ /E/) + { + $email_inbound=1; + if ($DB) {print "Check to see if email parser should run\n";} + } if ($cu3way > 0) { $AST_conf_3way=1; @@ -344,6 +353,11 @@ foreach (@psoutput) $runningAST_VDauto_dial_FILL++; if ($DB) {print "AST_VDauto_dial_FILL RUNNING: |$psline[1]|\n";} } + if ($psline[1] =~ /$REGhome\/VD_email_inbound\.pl/) + { + $runningemail_inbound++; + if ($DB) {print "VD_email_inbound RUNNING:|$psline[1]|\n";} + } if ($psoutput[$i] =~ / ip_relay /) { $runningip_relay++; @@ -425,7 +439,8 @@ if ( ( ($FastAGI_log > 0) && ($runningFastAGI_log < 1) ) || ( ($AST_VDauto_dial_FILL > 0) && ($runningAST_VDauto_dial_FILL < 1) ) || ( ($ip_relay > 0) && ($runningip_relay < 1) ) || - ( ($AST_conf_3way > 0) && ($runningAST_conf_3way < 1) ) + ( ($AST_conf_3way > 0) && ($runningAST_conf_3way < 1) ) || + ( ($email_inbound > 0) && ($runningemail_inbound < 1) ) ) { @@ -444,7 +459,7 @@ if ( $i=0; foreach (@psoutput2) { - chomp($psoutput2[$i]); + chomp($psoutput2[$i]); if ($DBX) {print "$i|$psoutput2[$i]| \n";} @psline = split(/\/usr\/bin\/perl /,$psoutput2[$i]); @@ -488,6 +503,11 @@ if ( $runningAST_VDauto_dial_FILL++; if ($DB) {print "AST_VDauto_dial_FILL RUNNING: |$psline[1]|\n";} } + if ($psline[1] =~ /$REGhome\/VD_email_inbound\.pl/) + { + $runningemail_inbound++; + if ($DB) {print "VD_email_inbound RUNNING:|$psline[1]|\n";} + } if ($psoutput2[$i] =~ / ip_relay /) { $runningip_relay++; @@ -550,6 +570,12 @@ if ( # add a '-L' to the command below to activate logging `/usr/bin/screen -d -m -S ASTVDautoFILL $PATHhome/AST_VDauto_dial_FILL.pl`; } + if ( ($email_inbound > 0) && ($runningemail_inbound < 1) ) + { + if ($DB) {print "starting VD_email_inbound...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTemail $PATHhome/VD_email_inbound.pl`; + } if ( ($ip_relay > 0) && ($runningip_relay < 1) ) { if ($DB) {print "starting ip_relay through relay_control...\n";} diff --git a/agc_2-X/trunk/bin/AST_inbound_email_parser.pl b/agc_2-X/trunk/bin/AST_inbound_email_parser.pl new file mode 100644 index 00000000..e9b8a59a --- /dev/null +++ b/agc_2-X/trunk/bin/AST_inbound_email_parser.pl @@ -0,0 +1,801 @@ +#!/usr/bin/perl +#use strict; +# use warnings; +use HTML::Entities; +use HTML::Strip; +use Switch; +use Time::Local; +use MIME::Decoder; + +# Copyright (C) 2012 Joe Johnson LICENSE: AGPLv2 +# +# AST_inbound_email_parser.pl - This script is essential for periodically checking any active POP3 or IMAP +# email accounts set up through the Vicidial admin. +# +# You cannot check an email account more often than 5 minutes at a time. This is in place because several +# email providers will lock an email account if it is being checked too often; currently the most restrictive +# email provider encountered allows no more than three logins every 15 minutes, hence 5 minutes being the +# most frequent time allowed. +# +# Upon execution, this script will query the vicidial_email_accounts table in the asterisk database and +# gather the information for all email accounts set up through the dialer that are currently active. It +# will then check the time setting on each of those accounts to see if it is time to check that particular +# account. If so, the program then will attempt to access the account using the appropriate Perl module +# depending on the account protocol (POP3 or IMAP). If the program successfully connects to the email +# account, then it will download any unread email messages, and grab any important information in the +# email headers, along with any attachments and the message itself. Each bit of information will be +# stored in the vicidial_email_list table, and any attachments will be stored in the +# inbound_email_attachments table as BLOB data. +# +# Additionally, depending on the email account settings, prior to putting the email record into the +# vicidial_email_list table, the accounts can be set up to check if the "from" address is already part +# of a lead in the vicidial_list table. The accounts can be set up to not check at all (EMAIL), in +# which all email messages go in as new leads, first in the vicidial_list table and then in the +# vicidial_email_list table with the lead_id gleaned from the vicidial_list insert. They can also be +# set up to check if the email address is already on a lead in a particular list (EMAILLOOKUPRL), or +# if the email address is in a lead belonging to any list in a given campaign (EMAILLOOKUPRC), or if +# the email address is on any lead currently in the vicidial_list table (EMAILLOOKUP). In these +# cases, the script will grab the lead_id of the most recently loaded lead (i.e. highest lead_id value), +# and use that as the lead_id in the vicidial_email_list table without creating a new lead. +# +# After checking and downloading any unread messages, the script will then log off the email account, +# and when all active email accounts have been checked in this manner, the script will exit. +# +# This script should be set up in the cron to run once per minute, not continuously. +# * * * * * /usr/share/astguiclient/AST_inbound_email_parser.pl +# +# Use the --debug variable when executing the script to have it print out what it is attempting to do on a +# step-by-step basis. Use the --debugX variable to include outputting of mail information and SQL queries the script +# attempts to execute. +# +# changes: +# 121213-2200 - First Build +# + +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; +$|=1; + +if ($ARGV[0]=~/--help/) { + print "AST_inbound_email_parser.pl - This script is essential for periodically checking any active POP3 or IMAP \n"; + print "email accounts set up through the Vicidial admin.\n"; + print "\n"; + print "You cannot check an email account more often than 5 minutes at a time. This is in place because several \n"; + print "email providers will lock an email account if it is being checked too often; currently the most restrictive\n"; + print "email provider encountered allows no more than three logins every 15 minutes, hence 5 minutes being the\n"; + print "most frequent time allowed.\n"; + print "\n"; + print "Upon execution, this script will query the vicidial_email_accounts table in the asterisk database and \n"; + print "gather the information for all email accounts set up through the dialer that are currently active. It\n"; + print "will then check the time setting on each of those accounts to see if it is time to check that particular \n"; + print "account. If so, the program then will attempt to access the account using the appropriate Perl module\n"; + print "depending on the account protocol (POP3 or IMAP). If the program successfully connects to the email \n"; + print "account, then it will download any unread email messages, and grab any important information in the \n"; + print "email headers, along with any attachments and the message itself. Each bit of information will be \n"; + print "stored in the vicidial_email_list table, and any attachments will be stored in the \n"; + print "inbound_email_attachments table as BLOB data.\n"; + print "\n"; + print "Additionally, depending on the email account settings, prior to putting the email record into the \n"; + print "vicidial_email_list table, the accounts can be set up to check if the 'from' address is already part \n"; + print "of a lead in the vicidial_list table. The accounts can be set up to not check at all (EMAIL), in \n"; + print "which all email messages go in as new leads, first in the vicidial_list table and then in the \n"; + print "vicidial_email_list table with the lead_id gleaned from the vicidial_list insert. They can also be\n"; + print "set up to check if the email address is already on a lead in a particular list (EMAILLOOKUPRL), or\n"; + print "if the email address is in a lead belonging to any list in a given campaign (EMAILLOOKUPRC), or if \n"; + print "the email address is on any lead currently in the vicidial_list table (EMAILLOOKUP). In these \n"; + print "cases, the script will grab the lead_id of the most recently loaded lead (i.e. highest lead_id value), \n"; + print "and use that as the lead_id in the vicidial_email_list table without creating a new lead.\n"; + print "\n"; + print "After checking and downloading any unread messages, the script will then log off the email account, \n"; + print "and when all active email accounts have been checked in this manner, the script will exit.\n"; + print "\n"; + print "This script should be set up in the cron to run once per minute, not continuously.\n"; + print "* * * * * /usr/share/astguiclient/AST_inbound_email_parser.pl\n"; + print "\n"; + print "Use the --debug variable when executing the script to have it print out what it is attempting to do on a\n"; + print "step-by-step basis. Use the --debugX variable to include outputting of mail information and SQL queries the script \n"; + print "attempts to execute.\n"; + exit; +} + +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) + {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} + if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) + {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} + if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) + {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} + if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) + {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} + if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) + {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} + if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; + } + +if (!$VARDB_port) {$VARDB_port='3306';} + +use DBI; + +$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; +$dbhA2 = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; +$dbhA3 = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +if($min==0) {$min=60;} +$minutes=($hour*60)+$min; +$minutes=0; + +$stmt="select * from vicidial_email_accounts where active='Y'"; +$rslt=$dbhA->prepare($stmt); +$rslt->execute(); + +while (@row=$rslt->fetchrow_array) { + + $VARemail_ID=$row[0]; + $VARemail_protocol=$row[4]; + $VARemail_server=$row[6]; + $VARemail_user=$row[7]; + $VARemail_pwd=$row[8]; + $VARemail_frequency=$row[10]; + $VARemail_groupid=$row[11]; + $default_list_id=$row[12]; + $call_handle_method=$row[13]; + $agent_search_method=$row[14]; + $campaign_id=$row[15]; + $list_id=$row[16]; + + if ($minutes%$VARemail_frequency==0) { + if ($ARGV[0]=~/debug/i) {print "Attempting to connect to $VARemail_protocol server ($VARemail_server)\n\n";} + if ($VARemail_protocol eq "IMAP") { + # if (!$sleep_time || $sleep_time<10) {$sleep_time=10;} # Ten second minimum wait time for IMAP. + + # Connect to IMAP server + use Mail::IMAPClient; + use Mail::Message; + + my $client = Mail::IMAPClient->new( + Server => "$VARemail_server", + User => "$VARemail_user", + Password => "$VARemail_pwd", + Port => 993, + Ssl => 1, + ) + or die "Cannot connect through IMAPClient: $!"; + + # Include options for folders in IMAP? POP3 doesn't support this. + + # List folders on remote server (see if all is ok) + if ( $client->IsAuthenticated() ) { + #print "Folders:\n"; + $new_messages=0; + my @folder_array=$client->folders("INBOX"); + for (my $i=0; $imessage_count($folder_array[$i]); + #print "+---+ Messages: ".$msgcount."\n"; + if ($msgcount>0) { + $client->select($folder_array[$i]); + my @msgs = $client->messages or die "Could not messages: $@\n"; + my @unseenMsgs = $client->unseen; + for(my $j=0; $jparse_headers($msgs[$j], 'ALL'); + my %email_values=%{$hashref}; + my $email_to=$email_values{"To"}->[0]; + my $email_from=$email_values{"From"}->[0]; + my $email_date=$email_values{"Date"}->[0]; + my $subject=$email_values{"Subject"}->[0]; + my $mime_type=$email_values{"MIME-Version"}->[0]; + my $content_type=$email_values{"Content-Type"}->[0]; + my $x_mailer=$email_values{"X-Mailer"}->[0]; + my $auth_results=$email_values{"Authentication-Results"}->[0]; + my $spf=$email_values{"Received-SPF"}->[0]; + $message = $client->body_string($msgs[$j]); + $text_written=0; ## Keeps track of whether or not text of email was grabbed + $attach_ct=0; ## Keeps number + @ins_values=(); + @output_ins_values=(); + + if ($email_date=~/[0-9]{1,2}\s+(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+[0-9]{4}\s+[0-9]{1,2}\:[0-9]{1,2}(\:[0-9]{1,2})?/) { + $email_date=$&; + $email_date=~s/\s+/ /gi; + @date_array=split(/\s/, $email_date); + $day=substr("0".$date_array[0], -2); + $month=$date_array[1]; + $year=$date_array[2]; + @time_array=split(/\:/, $date_array[3]); + $hour=substr("00".$time_array[0], -2); + $min=substr("00".$time_array[1], -2); + $sec=substr("00".$time_array[2], -2); + $email_date="$day $month $year $hour:$min:$sec"; + if ($ARGV[0]=~/debug/) {print "Time stamp on email is $email_date\n";} + } elsif ($ARGV[0]=~/debug/) {print "WARNING: Time stamp on email is $email_date\n";} + + + ############# MESSAGE ACTIONS + if ($content_type=~/^text\/plain/i) { + ## Do nothing - it's plain text and needs no further work on it. + if ($ARGV[0]=~/debug/i) {print "Email message is text/plain. Nothing needs to be done.\n\n";} + } elsif ($content_type=~/^text\/html/i) { + ## Message is HTML, so it needs to be stripped. + if ($ARGV[0]=~/debug/i) {print "Email message is text/html. Needs to have tags stripped via HTML::Strip.\n\n";} + StripHTML(); + } elsif ($content_type=~/^multipart\/(alternative|mixed)/i) { + ## Message is multipart/alternative, so it needs to be read and partitioned. The multipart/alternative subtype indicates that each part is an "alternative" + ## version of the same (or similar) content, each in a different format denoted by its "Content-Type" header. The formats are ordered by how faithful they are to + ## the original, with the least faithful first and the most faithful last. Systems can then choose the "best" representation they are capable of processing; in + ## general, this will be the last part that the system can understand, although other factors may affect this. + if ($ARGV[0]=~/debug/i) {print "Email message is multipart. Need to select the best format type and parse it.\n";} + + ## First, get the boundary from the content-type and use it to break the email into it's multiple parts + if ($content_type=~/boundary\=\"?[^\"]+\"?/i) { + $boundary=$&; + + $boundary=~s/(^boundary=\"?|\"?$)//gi; + $boundary="--".$boundary; + @alternatives_array=split(/$boundary/, $message); + + for ($k=1; $k<(scalar(@alternatives_array)-1); $k++) { # Ignore the first and last entry in the array; it's just a blank entry and the two dashes after the last boundary. + ## Grab the message by using Mail::Message to strip header information + $alt_email_text=$alternatives_array[$k]; + $alt_email_text=~s/(^(\s|\r|\n)+|(\s|\r|\n)+$)//; # This needs to be trimmed so the Mail::Message->read command will strip out the headers - leading carriage returns ruin it + + # Reset certain variables; + $sub_content_disposition=""; + $sub_content_type=""; + $attachment_fulltype=""; + $attachment_filename=""; + $attachment_type=""; + + if ($alt_email_text=~/Content\-Type\:\s+(.*?)\n/i) {$sub_content_type=$&;} + if ($alt_email_text=~/Content\-Disposition\:\s+(.*?)\n/i) {$sub_content_disposition=$&;} + if ($alt_email_text=~/Content\-Transfer\-Encoding\:\s+(.*?)\n/i) { + $encoding_type=$&; + $encoding_type=~s/(^Content-Transfer-Encoding\:\s+|\;$)//gi; + $encoding_type=~s/[\r\n]//g; + } + $sub_content_type=~s/[\r\n]//g; + $sub_content_disposition=~s/[\r\n]//g; + + my $msg = Mail::Message->read($alt_email_text); + $body_contents=$msg->body; + $attachment_filesize=$msg->size(); + $head=$msg->head; + if ($ARGV[0]=~/debugX/i) {print "Part content disposition is $sub_content_disposition\n Part content type is $sub_content_type.\n";} + if ($ARGV[0]=~/debugX/i) {print "Part content size is $attachment_filesize\n";} + + + ## Check if the content-type is plain or html + if ($alt_email_text=~/Content\-Type\:\s+text\/html/i && $text_written==0) { + $message=$body_contents; + if ($ARGV[0]=~/debug/i) {print "First acceptable content-type match is text/html. Stripping headers and stripping tags from the body/message...\n";} + if ($ARGV[0]=~/debugX/i) {print "$k)\n***Pre-HTML strip:\n$message\n***\n";} + StripHTML(); + if ($ARGV[0]=~/debugX/i) {print "$k)\n***Post-HTML strip:\n$message\n***\n";} + $text_written=1; + } elsif ($alt_email_text=~/Content\-Type\:\s+text\/plain/i && $text_written==0) { + if ($ARGV[0]=~/debug/i) {print "First acceptable content-type match is text/plain. Stripping headers to get text...\n";} + $text_written=1; + $message=$body_contents; + } + + ## Check for attachments + if ($sub_content_disposition=~/attachment/) { + $attachment_fulltype=""; + $attachment_filename=""; + ## Check to see if attachment is an accepted filetype + $sub_content_type=~/Content-Type\:\s+[^\;]+\;/i; $attachment_type=$&; + $attachment_type=~s/(^Content-Type\:\s+|\;$)//gi; + $attachment_type=~s/[\r\n]//g; + + switch ($attachment_type) { + case "application/pdf" {$attachment_fulltype="PDF";} + case "image/jpeg" {$attachment_fulltype="JPG";} + case "image/jpg" {$attachment_fulltype="JPG";} + case "image/gif" {$attachment_fulltype="GIF";} + case "image/x-png" {$attachment_fulltype="PNG";} + case "image/png" {$attachment_fulltype="PNG";} + case "image/bmp" {$attachment_fulltype="BMP";} + case "image/x-ms-bmp" {$attachment_fulltype="BMP";} + case "application/msword" {$attachment_fulltype="DOC";} + case "application/rtf" {$attachment_fulltype="RTF";} + case "application/vnd.ms-powerpoint" {$attachment_fulltype="PPT";} + case "application/vnd.ms-excel" {$attachment_fulltype="XLS";} + case "application/x-msexcel" {$attachment_fulltype="XLS";} + case "application/ms-excel" {$attachment_fulltype="XLS";} + case "application/zip" {$attachment_fulltype="ZIP";} + case "text/csv" {$attachment_fulltype="CSV";} + case "text/plain" {$attachment_fulltype="TXT";} + case "application/vnd.oasis.opendocument.text" {$attachment_fulltype="ODT";} + case "application/vnd.oasis.opendocument.spreadsheet" {$attachment_fulltype="ODS";} + } + if ($sub_content_disposition=~/filename\=\"?(.*?)\"?$/i) {$attachment_filename=$&;} + if (length($attachment_filename)==0) { + if ($ARGV[0]=~/debug/i) {print "Couldn't find file name with content-disposition. Searching full header for 'filename' value...\n";} + if ($alt_email_text=~/filename\=\"?(.*?)\"?$/i) {$attachment_filename=$&;} + if (length($attachment_filename)==0) { + if ($ARGV[0]=~/debug/i) {print "Couldn't find file name anywhere in header. Searching Content-Type for 'name' value...\n";} + if ($sub_content_type=~/name\=\"?(.*?)\"?$/i) {$attachment_filename=$&;} + } + } + $attachment_filename=~s/(file)?name\=\"?|\"?$//gi; + + + # If the attachment check is good, then proceed with storing the attachment. Otherwise continue. + if ($attachment_fulltype && $attachment_fulltype ne "") { + if ($attachment_filename && $attachment_filename ne "") { + if ($ARGV[0]=~/debug/i) {print "Found valid attachment, type $attachment_type \n Attachment filename is $attachment_filename ($attachment_fulltype)\nFile can be stored in database....\n";} + $ins_values[$attach_ct]="'$attachment_filename','$attachment_type','$encoding_type','$attachment_filesize','$attachment_fulltype','$body_contents'"; + $output_ins_values[$attach_ct]="'$attachment_filename','$attachment_type','$encoding_type','$attachment_filesize','$attachment_fulltype',''"; + $attach_ct++; + } else { + if ($ARGV[0]=~/debug/i) {print "!!!!WARNING - Found valid attachment, type $attachment_type \n Attachment does not have file name. Skipping...\n";} + } + } else { + if ($ARGV[0]=~/debug/i) {print "!!!!WARNING - Found attachment $attachment_filename, but is NOT a valid file type \n Attachment type is $attachment_type. Skipping...\n";} + } + } + # print "\n"; + } + } else { + if ($ARGV[0]=~/debug/i) {print "!!!!WARNING - Mail is multi-part, but no boundary value was found. Email will be ignored.\n";} + } + } + #print "\n"; + + $message=~s/(\"|\||\'|\;)/\\$&/g; + $email_to=~s/(\"|\||\'|\;)/\\$&/g; + $email_from=~s/(\"|\||\'|\;)/\\$&/g; + $subject=~s/(\"|\||\'|\;)/\\$&/g; + $mime_type=~s/(\"|\||\'|\;)/\\$&/g; + $content_type=~s/(\"|\||\'|\;)/\\$&/g; + $x_mailer=~s/(\"|\||\'|\;)/\\$&/g; + $sender_ip=~s/(\"|\||\'|\;)/\\$&/g; + $message=~s/\s{2,}/ /gi; + my $status="NEW"; + + ### Parses the actual email address from the "Email From:" value in order to run it against vicidial_list + ### Not sure how accurate this is + $email_from_name=$email_from; + $email_from_name=~s/\?//gi; + $email_from_name=~s/^\s*(.*?)\s*$/$1/; + + $email_from=~/\?/i; + $email_from=$&; + $email_from=~s/(^\<)|(\>$)//gi; + + $auth_results=~/([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}/i; + my $sender_ip=$&; + $spf=~/([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}/i; + my $sender_ip2=$&; + if (length($sender_ip)==0) {$sender_ip=$sender_ip2;} + + $limit=1; + $call_handle_clause=""; + if ($call_handle_method eq "EMAILLOOKUP") { + $call_handle_clause="where email='$email_from' order by lead_id desc"; + } elsif ($call_handle_method eq "EMAILLOOKUPRL") { + $call_handle_clause="where email='$email_from' and list_id='$list_id' order by lead_id desc"; + } elsif ($call_handle_method eq "EMAILLOOKUPRC") { + my $list_id_stmt="select list_id from vicidial_lists where campaign_id='$campaign_id'"; + my $list_id_rslt=$dbhA->prepare($list_id_stmt); + $list_id_rslt->execute(); + $list_id_str=""; + while (@list_id_row=$list_id_rslt->fetchrow_array) { + $list_id_str.="$list_id_row[0],"; + } + $list_id_str=substr($list_id_str, 0, -1); + $call_handle_clause="where email='$email_from' and list_id in ($list_id_str) order by lead_id desc"; + } else { + $limit=0; + } + + ### CHECK if lead exists in vicidial_list table via a search by email based on the email account settings + my $vicidial_lead_check_stmt="select lead_id, list_id from vicidial_list $call_handle_clause limit $limit"; + if ($ARGV[0]=~/debugX/i) {print $vicidial_lead_check_stmt;} + my $vicidial_lead_check_rslt=$dbhA->prepare($vicidial_lead_check_stmt); + $vicidial_lead_check_rslt->execute(); + if ($vicidial_lead_check_rslt->rows>0) { + my @lead_id_row=$vicidial_lead_check_rslt->fetchrow_array; + $lead_id=$lead_id_row[0]; + } else { + my $vicidial_list_stmt="insert into vicidial_list(list_id, email, comments, status) values('$default_list_id', '$email_from', '".substr($message,0,255)."', '$status')"; + if ($ARGV[0]=~/debugX/i) {print $vicidial_list_stmt;} + my $vicidial_list_rslt=$dbhA->prepare($vicidial_list_stmt); + if ($vicidial_list_rslt->execute()) { + $lead_id=$dbhA->last_insert_id(undef, undef, 'vicidial_list', 'lead_id'); + } else { + die "Vicidial list insert failed. Check SQL in:\n $vicidial_list_stmt\n"; + } + } + + ## Insert a new record into vicidial_email_list. This is ALWAYS done for new email messages. + $ins_stmt="insert into vicidial_email_list(lead_id, protocol, email_date, email_to, email_from, email_from_name, subject, mime_type, content_type, x_mailer, sender_ip, message, email_account_id, group_id, status, direction) values('$lead_id', 'IMAP', STR_TO_DATE('$email_date', '%d %b %Y %T'), '$email_to', '$email_from', '$email_from_name', '$subject', '$mime_type', '$content_type', '$x_mailer', '$sender_ip', trim('$message'), '$VARemail_ID', '$VARemail_groupid', '$status', 'INBOUND')"; + + if ($ARGV[0]=~/debugX/i) {print $ins_stmt."\n";} + my $ins_rslt=$dbhA->prepare($ins_stmt); + if ($ins_rslt->execute()) { + if ($attach_ct>0) { + $email_id=$dbhA->last_insert_id(undef, undef, 'vicidial_email_list', 'email_row_id'); + $multistmt=""; + for ($k=0; $k<$attach_ct; $k++) { + $ins_values[$k]="('$email_id',$ins_values[$k])"; + $multistmt.="$ins_values[$k],"; + $output_ins_values[$k]="('$email_id',$output_ins_values[$k])"; + $output_multistmt.="$output_ins_values[$k],"; + } + + $attachment_ins_stmt="insert into inbound_email_attachments(email_row_id, filename, file_type, file_encoding, file_size, file_extension, file_contents) VALUES ".substr($multistmt,0,-1); + $attachment_ins_rslt=$dbhA->prepare($attachment_ins_stmt); + $attachment_ins_rslt->execute(); + + $output_ins_stmt="insert into inbound_email_attachments(email_row_id, filename, file_type, file_encoding, file_size, file_extension, file_contents) VALUES ".substr($output_multistmt,0,-1); + if ($ARGV[0]=~/debugX/i) {print $output_ins_stmt."\n";} + } + if ($ARGV[0]=~/debug/i) {print "\n Found $attach_ct attachments in email\n";} + } else { + die "Email insert failed. Check SQL in:\n $ins_stmt\n"; + } + + } + } + } + } + if ($ARGV[0]=~/debug/i) { + if ($ARGV[0]=~/debugX/i) { + print "Iteration #$q - found ".($new_messages+0)." new messages\n"; + } else { + # print "."; + } + } + # sleep($sleep_time); + } + $client->logout(); + } elsif ($VARemail_protocol eq "POP3") { + # if (!$sleep_time || $sleep_time<300) {$sleep_time=300;} # Some servers don't allow multiple connections within a certain time frame. + # if ($ARGV[0]=~/debug/) {$mail_check_iterations=5;} else {$mail_check_iterations=1000000;} + use Mail::POP3Client; + $pop = new Mail::POP3Client( USER => "$VARemail_user", + PASSWORD => "$VARemail_pwd", + HOST => "$VARemail_server", + PORT => 995, + USESSL => true, + DEBUG => true, + ) + or die "Cannot connect through POP3Client: $!"; + + if ($pop->Count()<0) {die "Error connecting to server. Please try again later.\n";} + for( $i = 1; $i <= $pop->Count(); $i++ ) { + foreach( $pop->Head( $i ) ) { + if ($_=~/^(To|From|Date|Subject|MIME-Version|Content-Type|X-Mailer|Authentication-Results|Received-SPF|Message|Body):\s+/i) { + $value=$_; + $ptn=$&; + $value=~s/$ptn//i; + $ptn=~s/^\s*(.*?)\s*$/$1/; + $ptn=~s/:$//; + $ptn=~s/\-/_/i; + $varname=lc($ptn); + $$varname=$value; + } + if ($_=~/boundary\=\"?[^\"]+\"?/i) { + $bkup_boundary=$&; + } + } + $message=$pop->Body( $i ); + $text_written=0; ## Keeps track of whether or not text of email was grabbed + $attach_ct=0; ## Keeps number + @ins_values=(); + @output_ins_values=(); + + if ($content_type=~/^text\/plain/i) { + ## Do nothing - it's plain text and needs no further work on it. + if ($ARGV[0]=~/debug/i) {print "Email message is text/plain. Nothing needs to be done.\n\n";} + } elsif ($content_type=~/^text\/html/i) { + ## Message is HTML, so it needs to be stripped. + if ($ARGV[0]=~/debug/i) {print "Email message is text/html. Needs to have tags stripped via HTML::Strip.\n\n";} + StripHTML(); + } elsif ($content_type=~/^multipart\/(alternative|mixed)/i) { + ## Message is multipart/alternative, so it needs to be read and partitioned. The multipart/alternative subtype indicates that each part is an "alternative" + ## version of the same (or similar) content, each in a different format denoted by its "Content-Type" header. The formats are ordered by how faithful they are to + ## the original, with the least faithful first and the most faithful last. Systems can then choose the "best" representation they are capable of processing; in + ## general, this will be the last part that the system can understand, although other factors may affect this. + if ($ARGV[0]=~/debug/i) {print "Email message is multipart. Need to select the best format type and parse it.\n";} + + ## First, get the boundary from the content-type and use it to break the email into it's multiple parts + if ($content_type=~/boundary\=\"?[^\"]+\"?/i) { + $boundary=$&; + } else { + $boundary=$bkup_boundary; + } + + if (length($boundary)>0) { + $boundary=~s/(^boundary=\"?|\"?$)//gi; + $boundary="--".$boundary; + @alternatives_array=split(/$boundary/, $message); + + for ($k=1; $k<(scalar(@alternatives_array)-1); $k++) { # Ignore the first and last entry in the array; it's just a blank entry and the two dashes after the last boundary. + ## Grab the message by using Mail::Message to strip header information + $alt_email_text=$alternatives_array[$k]; + $alt_email_text=~s/(^(\s|\r|\n)+|(\s|\r|\n)+$)//; # This needs to be trimmed so the Mail::Message->read command will strip out the headers - leading carriage returns ruin it + + # Reset certain variables; + $sub_content_disposition=""; + $sub_content_type=""; + $attachment_fulltype=""; + $attachment_filename=""; + $attachment_type=""; + + if ($alt_email_text=~/Content\-Type\:\s+(.*?)\n/i) {$sub_content_type=$&;} + if ($alt_email_text=~/Content\-Disposition\:\s+(.*?)\n/i) {$sub_content_disposition=$&;} + if ($alt_email_text=~/Content\-Transfer\-Encoding\:\s+(.*?)\n/i) { + $encoding_type=$&; + $encoding_type=~s/(^Content-Transfer-Encoding\:\s+|\;$)//gi; + $encoding_type=~s/[\r\n]//g; + } + $sub_content_type=~s/[\r\n]//g; + $sub_content_disposition=~s/[\r\n]//g; + + my $msg = Mail::Message->read($alt_email_text); + $body_contents=$msg->body; + $attachment_filesize=$msg->size(); + $head=$msg->head; + if ($ARGV[0]=~/debugX/i) {print "Part content disposition is $sub_content_disposition\n Part content type is $sub_content_type.\n";} + if ($ARGV[0]=~/debugX/i) {print "Part content size is $attachment_filesize\n";} + + + ## Check if the content-type is plain or html + if ($alt_email_text=~/Content\-Type\:\s+text\/html/i && $text_written==0) { + $message=$body_contents; + if ($ARGV[0]=~/debug/i) {print "First acceptable content-type match is text/html. Stripping headers and stripping tags from the body/message...\n";} + if ($ARGV[0]=~/debugX/i) {print "$k)\n***Pre-HTML strip:\n$message\n***\n";} + StripHTML(); + if ($ARGV[0]=~/debugX/i) {print "$k)\n***Post-HTML strip:\n$message\n***\n";} + $text_written=1; + } elsif ($alt_email_text=~/Content\-Type\:\s+text\/plain/i && $text_written==0) { + if ($ARGV[0]=~/debug/i) {print "First acceptable content-type match is text/plain. Stripping headers to get text...\n";} + $text_written=1; + $message=$body_contents; + } + + ## Check for attachments + if ($sub_content_disposition=~/attachment/) { + $attachment_fulltype=""; + $attachment_filename=""; + ## Check to see if attachment is an accepted filetype + $sub_content_type=~/Content-Type\:\s+[^\;]+\;/i; $attachment_type=$&; + $attachment_type=~s/(^Content-Type\:\s+|\;$)//gi; + $attachment_type=~s/[\r\n]//g; + + switch ($attachment_type) { + case "application/pdf" {$attachment_fulltype="PDF";} + case "image/jpeg" {$attachment_fulltype="JPG";} + case "image/jpg" {$attachment_fulltype="JPG";} + case "image/gif" {$attachment_fulltype="GIF";} + case "image/x-png" {$attachment_fulltype="PNG";} + case "image/png" {$attachment_fulltype="PNG";} + case "image/bmp" {$attachment_fulltype="BMP";} + case "image/x-ms-bmp" {$attachment_fulltype="BMP";} + case "application/msword" {$attachment_fulltype="DOC";} + case "application/rtf" {$attachment_fulltype="RTF";} + case "application/vnd.ms-powerpoint" {$attachment_fulltype="PPT";} + case "application/vnd.ms-excel" {$attachment_fulltype="XLS";} + case "application/x-msexcel" {$attachment_fulltype="XLS";} + case "application/ms-excel" {$attachment_fulltype="XLS";} + case "application/zip" {$attachment_fulltype="ZIP";} + case "text/csv" {$attachment_fulltype="CSV";} + case "text/plain" {$attachment_fulltype="TXT";} + case "application/vnd.oasis.opendocument.text" {$attachment_fulltype="ODT";} + case "application/vnd.oasis.opendocument.spreadsheet" {$attachment_fulltype="ODS";} + } + if ($sub_content_disposition=~/filename\=\"?(.*?)\"?$/i) {$attachment_filename=$&;} + if (length($attachment_filename)==0) { + if ($ARGV[0]=~/debug/i) {print "Couldn't find file name with content-disposition. Searching full header for 'filename' value...\n";} + if ($alt_email_text=~/filename\=\"?(.*?)\"?$/i) {$attachment_filename=$&;} + if (length($attachment_filename)==0) { + if ($ARGV[0]=~/debug/i) {print "Couldn't find file name anywhere in header. Searching Content-Type for 'name' value...\n";} + if ($sub_content_type=~/name\=\"?(.*?)\"?$/i) {$attachment_filename=$&;} + } + } + $attachment_filename=~s/(file)?name\=\"?|\"?$//gi; + + + # If the attachment check is good, then proceed with storing the attachment. Otherwise continue. + if ($attachment_fulltype && $attachment_fulltype ne "") { + if ($attachment_filename && $attachment_filename ne "") { + $body_contents=~s/(\"|\||\'|\;)/\\$&/g; # This is a problem for POP3 (of course) in the attachment contents. + if ($ARGV[0]=~/debug/i) {print "Found valid attachment, type $attachment_type \n Attachment filename is $attachment_filename ($attachment_fulltype)\nFile can be stored in database....\n";} + $ins_values[$attach_ct]="'$attachment_filename','$attachment_type','$encoding_type','$attachment_filesize','$attachment_fulltype','$body_contents'"; + $output_ins_values[$attach_ct]="'$attachment_filename','$attachment_type','$encoding_type','$attachment_filesize','$attachment_fulltype',''"; + $attach_ct++; + } else { + if ($ARGV[0]=~/debug/i) {print "!!!!WARNING - Found valid attachment, type $attachment_type \n Attachment does not have file name. Skipping...\n";} + } + } else { + if ($ARGV[0]=~/debug/i) {print "!!!!WARNING - Found attachment $attachment_filename, but is NOT a valid file type \n Attachment type is $attachment_type. Skipping...\n";} + } + } + # print "\n"; + } + } else { + if ($ARGV[0]=~/debug/i) {print "!!!!WARNING - Mail is multi-part, but no boundary value was found. Email will be ignored.\n";} + } + } + # print "\n"; + + if ($date=~/[0-9]{1,2}\s+(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+[0-9]{4}\s+[0-9]{1,2}\:[0-9]{1,2}(\:[0-9]{1,2})?/) { + $date=$&; + $date=~s/\s+/ /gi; + @date_array=split(/\s/, $date); + $day=substr("0".$date_array[0], -2); + $month=$date_array[1]; + $year=$date_array[2]; + @time_array=split(/\:/, $date_array[3]); + $hour=substr("00".$time_array[0], -2); + $min=substr("00".$time_array[1], -2); + $sec=substr("00".$time_array[2], -2); + $date="$day $month $year $hour:$min:$sec"; + if ($ARGV[0]=~/debug/) {print "Time stamp on email is $date\n";} + } elsif ($ARGV[0]=~/debug/) {print "WARNING: Time stamp on email is $date\n";} + + $message=~s/(\"|\||\'|\;)/\\$&/g; + $email_to=~s/(\"|\||\'|\;)/\\$&/g; + $email_from=~s/(\"|\||\'|\;)/\\$&/g; + $subject=~s/(\"|\||\'|\;)/\\$&/g; + $mime_type=~s/(\"|\||\'|\;)/\\$&/g; + $content_type=~s/(\"|\||\'|\;)/\\$&/g; + $x_mailer=~s/(\"|\||\'|\;)/\\$&/g; + $sender_ip=~s/(\"|\||\'|\;)/\\$&/g; + $message=~s/\s{2,}/ /gi; + my $status="NEW"; + $message=~s/\s{2,}/ /gi; + + ### Parses the actual email address from the "Email From:" value in order to run it against vicidial_list + ### Not sure how accurate this is + $email_from_name=$email_from; + $email_from_name=~s/\?//gi; + $email_from_name=~s/^\s*(.*?)\s*$/$1/; + + $email_from=~/\?/i; + $email_from=$&; + $email_from=~s/(^\<)|(\>$)//gi; + + $status="NEW"; + $authentication_results=~/([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}/i; + $sender_ip=$&; + $received_spf=~/([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}/i; + $sender_ip2=$&; + if (length($sender_ip)==0) {$sender_ip=$sender_ip2;} + + $limit=1; + $call_handle_clause=""; + if ($call_handle_method eq "EMAILLOOKUP") { + $call_handle_clause="where email='$email_from' order by lead_id desc"; + } elsif ($call_handle_method eq "EMAILLOOKUPRL") { + $call_handle_clause="where email='$email_from' and list_id='$list_id' order by lead_id desc"; + } elsif ($call_handle_method eq "EMAILLOOKUPRC") { + my $list_id_stmt="select list_id from vicidial_lists where campaign_id='$campaign_id'"; + my $list_id_rslt=$dbhA->prepare($list_id_stmt); + $list_id_rslt->execute(); + $list_id_str=""; + while (@list_id_row=$list_id_rslt->fetchrow_array) { + $list_id_str.="$list_id_row[0],"; + } + $list_id_str=substr($list_id_str, 0, -1); + $call_handle_clause="where email='$email_from' and list_id in ($list_id_str) order by lead_id desc"; + } else { + $limit=0; + } + + ### CHECK if lead exists in vicidial_list table via a search by email based on the email account settings + my $vicidial_lead_check_stmt="select lead_id from vicidial_list $call_handle_clause limit $limit"; + my $vicidial_lead_check_rslt=$dbhA->prepare($vicidial_lead_check_stmt); + $vicidial_lead_check_rslt->execute(); + if ($vicidial_lead_check_rslt->rows>0) { + my @lead_id_row=$vicidial_lead_check_rslt->fetchrow_array; + $lead_id=$lead_id_row[0]; + } else { + my $vicidial_list_stmt="insert into vicidial_list(list_id, email, comments, status) values('$default_list_id', '$email_from', '".substr($message,0,255)."', '$status')"; + if ($ARGV[0]=~/debugX/i) {print $vicidial_list_stmt;} + my $vicidial_list_rslt=$dbhA->prepare($vicidial_list_stmt); + if ($vicidial_list_rslt->execute()) { + $lead_id=$dbhA->last_insert_id(undef, undef, 'vicidial_list', 'lead_id'); + } else { + die "Vicidial list insert failed. Check SQL in:\n $vicidial_list_stmt\n"; + } + } + + ## Insert a new record into vicidial_email_list. This is ALWAYS done for new email messages. + my $ins_stmt="insert into vicidial_email_list(lead_id, protocol, email_date, email_to, email_from, email_from_name, subject, mime_type, content_type, x_mailer, sender_ip, message, email_account_id, group_id, status, direction) values('$lead_id', 'IMAP', STR_TO_DATE('$email_date', '%d %b %Y %T'), '$email_to', '$email_from', '$email_from_name', '$subject', '$mime_type', '$content_type', '$x_mailer', '$sender_ip', trim('$message'), '$VARemail_ID', '$VARemail_groupid', '$status', 'INBOUND')"; + + if ($ARGV[0]=~/debugX/i) {print $ins_stmt;} + my $ins_rslt=$dbhA->prepare($ins_stmt); + if ($ins_rslt->execute()) { + $pop->Delete($i); + if ($attach_ct>0) { + $email_id=$dbhA->last_insert_id(undef, undef, 'vicidial_email_list', 'email_row_id'); + $multistmt=""; + for ($k=0; $k<$attach_ct; $k++) { + $ins_values[$k]="('$email_id',$ins_values[$k])"; + $multistmt.="$ins_values[$k],"; + $output_ins_values[$k]="('$email_id',$output_ins_values[$k])"; + $output_multistmt.="$output_ins_values[$k],"; + } + + $attachment_ins_stmt="insert into inbound_email_attachments(email_row_id, filename, file_type, file_encoding, file_size, file_extension, file_contents) VALUES ".substr($multistmt,0,-1); + $attachment_ins_rslt=$dbhA->prepare($attachment_ins_stmt); + $attachment_ins_rslt->execute(); + $output_ins_stmt="insert into inbound_email_attachments(email_row_id, filename, file_type, file_encoding, file_size, file_extension, file_contents) VALUES ".substr($output_multistmt,0,-1); + if ($ARGV[0]=~/debugX/i) {print $output_ins_stmt."\n";} + } + if ($ARGV[0]=~/debug/i) {print "\n $attach_ct attachments in email\n";} + } else { + die "Email insert failed. Check SQL in:\n $ins_stmt\n"; + } + } + + #### END CYCLING THROUGH EMAILS + if ($ARGV[0]=~/debug/i) { + if ($ARGV[0]=~/debugX/i) { + print "Iteration #$q - found ".($pop->Count()+0)." new messages\n"; + } + } + + if ($ARGV[0]=~/debugX/i) { + print "Closing connection to finalize deletion of emails\n"; + } + $pop->Close(); + # sleep($sleep_time); + if ($ARGV[0]=~/debugX/i) { + print "Reconnecting to email account...\n"; + } + $pop = new Mail::POP3Client( USER => "$VARemail_user", + PASSWORD => "$VARemail_pwd", + HOST => "$VARemail_server", + PORT => 995, + USESSL => true, + #DEBUG => true, + ) + or die "Cannot connect through POP3Client: $!"; + $pop->Close(); + } else { + die "No valid protocol specified for this program: ($VARemail_protocol) is the current protocol - needs to be IMAP or POP3.\n"; + } + } +} + +sub StripHTML() +{ + $message=~s/^\s*(.*?)\s*$/$1/; + $message=~s/[\r\n]/ /g; + if ($message=~//i) { + $message=$&; + my $hs = HTML::Strip->new(); + $message = $hs->parse( $message ); + $hs->eof; + } +} diff --git a/agc_2-X/trunk/bin/VD_email_inbound.pl b/agc_2-X/trunk/bin/VD_email_inbound.pl new file mode 100644 index 00000000..ea90fb68 --- /dev/null +++ b/agc_2-X/trunk/bin/VD_email_inbound.pl @@ -0,0 +1,385 @@ +#!/usr/bin/perl +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; + +# Copyright (C) 2012 Joe Johnson, Matt Florell LICENSE: AGPLv2 +# +# VD_email_inbound.pl +# This script is responsible for assigning transferred and new emails to +# available agents. This is done by repeatedly checking for transferred emails +# waiting to be assigned sorted by email group rank, then all new emails +# waiting to be assigned, also sorted by email group rank. Then it checks +# the vicidial_live_agents table for agents with READY or CLOSER status. +# +# As it cycles through the prioritized emails to assign, it takes the inbound group +# each email belongs to, selects the agent it should be assigned to based on the +# next_agent_call setting, and puts that lead in QUEUE, as well as putting the +# chosen agent in a special MQUEUE status. Programming in other parts of Vicidial +# will cause these emails to be displayed in the agent's interface. +# +# This script should be set up on ONLY ONE SERVER. You set it up using the "E" +# keepalive option in the /etc/astguiclient.conf file on one of the servers in +# your cluster. +# +# changes: +# 121214-2303 - First Build +# + +if ($ARGV[0]=~/--help/) + { + print "VD_email_inbound.pl\n"; + print "\n"; + print "This script is responsible for assigning transferred and new emails to\n"; + print "available agents. This is done by repeatedly checking for transferred emails\n"; + print "waiting to be assigned sorted by email group rank, then all new emails\n"; + print "waiting to be assigned, also sorted by email group rank. Then it checks\n"; + print "the vicidial_live_agents table for agents with READY or CLOSER status.\n"; + print "\n"; + print "As it cycles through the prioritized emails to assign, it takes the inbound\n"; + print "group each email belongs to, selects the agent it should be assigned to based\n"; + print "on the next_agent_call setting, and puts that lead in QUEUE, as well as putting\n"; + print "the chosen agent in a special MQUEUE status. Programming in other parts of \n"; + print "Vicidial will cause these emails to be displayed in the agent's interface.\n"; + print "\n"; + print "This script should be set up on ONLY ONE SERVER. You set it up using the \"E\"\n"; + print "keepalive option in the /etc/astguiclient.conf file on one of the servers in\n"; + print "your cluster.\n"; + print "\n"; + print "Use the --debug variable when executing the script to have it print out the SQL\n"; + print "statements it is attempting to execute.\n"; + exit; + } + +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) + {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} + if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) + {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} + if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) + {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} + if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) + {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} + if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) + {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} + if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; + } + +$|=1; + +if (!$VARDB_port) {$VARDB_port='3306';} +if (!$AGILOGfile) {$AGILOGfile = "$PATHlogs/agiout.$year-$mon-$mday";} +if (!$PRSLOGfile) {$PRSLOGfile = "$PATHlogs/prsout.$year-$mon-$mday";} +if (!$PRSTESTfile) {$PRSTESTfile = "$PATHlogs/prstest.$year-$mon-$mday";} +if (!$ERRLOGfile) {$ERRLOGfile = "$PATHlogs/MySQLerror.$year-$mon-$mday";} + +use DBI; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + +$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; +$dbhB = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$mon++; +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +if ($hour < 10) {$hour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} + +$hm = "$hour$min"; +$hm = ($hm + 0); + +$now_date_epoch = time(); +$start_epoch = $now_date_epoch; +$now_date = "$year-$mon-$mday $hour:$min:$sec"; +$CLInow_date = "$year-$mon-$mday\\ $hour:$min:$sec"; +$YMD = "$year-$mon-$mday"; +$start_time=$now_date; +$CIDdate = "$mon$mday$hour$min$sec"; +$tsSQLdate = "$year$mon$mday$hour$min$sec"; +$SQLdate = "$year-$mon-$mday $hour:$min:$sec"; +$SQLdateBEGIN = $SQLdate; +$ORIGINAL_call_time = $SQLdate; + while (length($CIDdate) > 9) {$CIDdate =~ s/^.//gi;} # 0902235959 changed to 902235959 + + +$BDtarget = ($now_date_epoch - 5); +($Bsec,$Bmin,$Bhour,$Bmday,$Bmon,$Byear,$Bwday,$Byday,$Bisdst) = localtime($BDtarget); +$Byear = ($Byear + 1900); +$Bmon++; +if ($Bmon < 10) {$Bmon = "0$Bmon";} +if ($Bmday < 10) {$Bmday = "0$Bmday";} +if ($Bhour < 10) {$Bhour = "0$Bhour";} +if ($Bmin < 10) {$Bmin = "0$Bmin";} +if ($Bsec < 10) {$Bsec = "0$Bsec";} +$BDtsSQLdate = "$Byear$Bmon$Bmday$Bhour$Bmin$Bsec"; + +#$ADUfindSQL - for AGENTDIRECT, not necessary +#$INBOUNDcampsSQL* +#$BDtsSQLdate* +#$ring_no_answer_agents - not necessary? +#$vlia_users - queue_priority, already handled? +#$qp_groupWAIT_camp_SQL - queue_priority, already handled? +#$qp_groupWAIT_SQL - queue_priority, already handled? +#$vig_stmt="select campaign_id, queue_priority, next_agent_call from vicidial_inbound_groups where group_handling='EMAIL' and active='Y' order by queue_priority desc"; +#$vig_rslt=$dbhA->prepare($vig_stmt); +#$vig_rslt->execute(); + + +for ($i=0; $i<=1000000; $i++) + { + $vci=0; + $INBOUNDcampsSQL=''; + $stmtA = "SELECT campaign_id FROM vicidial_campaigns where active='Y' and campaign_allow_inbound='Y';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $dbhP=$dbhA; $mysql_count='02033'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + while ($sthArows > $vci) + { + @aryA = $sthA->fetchrow_array; + if ($vci < 1) {$INBOUNDcampsSQL = "'$aryA[0]'";} + else {$INBOUNDcampsSQL .= ",'$aryA[0]'";} + $vci++; + } + $sthA->finish(); + + # CHECK IF THERE ARE ANY EMAIL GROUPS ACTIVE TO SCAN + $order_stmt="select group_id, next_agent_call from vicidial_inbound_groups where group_handling='EMAIL' and active='Y'"; + $order_rslt=$dbhA->prepare($order_stmt); + $order_rslt->execute or die "executing: $order_stmt ", $dbhA->errstr; + + if ($order_rslt->rows>0) + { + %group_orders=(); + while (@order_row=$order_rslt->fetchrow_array) + { + $group_orders{"$order_row[0]"}=$order_row[1]; + } + + $email_ct=0; + ## CHECK IF THERE ARE ANY TRANSFERS TO ASSIGN + $xfer_stmt="select email_row_id, vicidial_xfer_log.lead_id, vicidial_xfer_log.campaign_id, vicidial_inbound_groups.next_agent_call from vicidial_email_list, vicidial_inbound_groups, vicidial_xfer_log where vicidial_inbound_groups.group_handling='EMAIL' and vicidial_inbound_groups.active='Y' and vicidial_inbound_groups.group_id=vicidial_xfer_log.campaign_id and vicidial_xfer_log.closer='EMAIL_XFER' and vicidial_xfer_log.lead_id=vicidial_email_list.lead_id and vicidial_xfer_log.xfercallid=vicidial_email_list.xfercallid order by queue_priority desc, email_date asc"; + if ($ARGV[0]=~/debug/i) {print $xfer_stmt."\n";} + $xfer_rslt=$dbhB->prepare($xfer_stmt); + $xfer_rslt->execute or die "executing: $xfer_stmt ", $dbhB->errstr; + $xfers_to_assign=$xfer_rslt->rows; + + if ($xfers_to_assign>0) + { + while (@xfer_row=$xfer_rslt->fetchrow_array) + { + $row_id_ary[$email_ct]=$xfer_row[0]; + $lead_id_ary[$email_ct]=$xfer_row[1]; + $group_id_ary[$email_ct]=$xfer_row[2]; + $email_type_ary[$email_ct]="XFER"; + + $email_ct++; + } + } + $xfer_rslt->finish(); + + ## CHECK IF THERE ARE ANY REGULAR EMAILS TO ASSIGN + $inb_stmt="select email_row_id, lead_id, vicidial_email_list.group_id, vicidial_inbound_groups.next_agent_call from vicidial_email_list, vicidial_inbound_groups where group_handling='EMAIL' and active='Y' and vicidial_inbound_groups.group_id=vicidial_email_list.group_id and vicidial_email_list.status='NEW' order by queue_priority desc, email_date asc"; + if ($ARGV[0]=~/debug/i) {print $inb_stmt."\n";} + $inb_rslt=$dbhB->prepare($inb_stmt); + $inb_rslt->execute or die "executing: $inb_stmt ", $dbhB->errstr; + $emails_to_assign=$inb_rslt->rows; + if ($emails_to_assign>0) + { + while (@inb_row=$inb_rslt->fetchrow_array) + { + $row_id_ary[$email_ct]=$inb_row[0]; + $lead_id_ary[$email_ct]=$inb_row[1]; + $group_id_ary[$email_ct]=$inb_row[2]; + $email_type_ary[$email_ct]="INCOMING"; + + $email_ct++; + } + } + $inb_rslt->finish(); + + if ($email_ct>0) {AssignAgents();} else {if ($ARGV[0]=~/debug/i) {print "**** NO EMAILS TO QUEUE ****\n";}} + } + usleep(100000); + } + + +sub AssignAgents() + { + if ($ARGV[0]=~/debug/i) {print $xfers_to_assign." transfers to assign\n".$emails_to_assign." incoming emails to assign...\n";} + + for ($q=0; $q<$email_ct; $q++) + { + $CAMP_callorder=$group_orders{"$group_id_ary[$q]"}; + $email_row_id=$row_id_ary[$q]; + $lead_id=$lead_id_ary[$q]; + $email_type=$email_type_ary[$q]; + $group_id=$group_id_ary[$q]; + + $ADUfindSQL=''; + $user=''; + $ring_no_answer_agents = "''"; + $aco_sub=0; + $agent_call_order='order by last_call_finish'; + if ($CAMP_callorder =~ /longest_wait_time/i) {$agent_call_order = 'order by vicidial_live_agents.last_state_change';} + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by vicidial_live_agents.last_call_time';} # + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by vicidial_live_agents.last_call_finish';} + if ($CAMP_callorder =~ /oldest_inbound_call_start/i) {$agent_call_order = 'order by vicidial_live_agents.last_inbound_call_time';} # + if ($CAMP_callorder =~ /oldest_inbound_call_finish/i) {$agent_call_order = 'order by vicidial_live_agents.last_inbound_call_finish';} # + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + if ($CAMP_callorder =~ /campaign_rank/i) {$agent_call_order = 'order by campaign_weight desc,last_call_finish';} + if ($CAMP_callorder =~ /fewest_calls_campaign/i) {$agent_call_order = 'order by vicidial_live_agents.calls_today,vicidial_live_agents.last_call_finish';} + if ($CAMP_callorder =~ /ingroup_grade_random/i) {$aco_sub=1; $agent_call_order = 'order by random_id';} + if ($CAMP_callorder =~ /campaign_grade_random/i) {$aco_sub=1; $agent_call_order = 'order by random_id';} + if ($CAMP_callorder =~ /inbound_group_rank/i) {$aco_sub=1; $agent_call_order = 'order by group_weight desc,vicidial_live_inbound_agents.last_call_finish';} + if ($CAMP_callorder =~ /fewest_calls$/i) {$aco_sub=1; $agent_call_order = 'order by vicidial_live_inbound_agents.calls_today,vicidial_live_inbound_agents.last_call_finish';} + + if ($aco_sub > 0) + { + $stmtA = "LOCK TABLES vicidial_live_agents WRITE, vicidial_live_inbound_agents WRITE;"; + my $LOCKaffected_rows = $dbhA->do($stmtA); + + $stmtA = "SELECT vicidial_live_agents.user from vicidial_live_agents, vicidial_live_inbound_agents WHERE vicidial_live_agents.user=vicidial_live_inbound_agents.user and status IN('CLOSER','READY') and lead_id<1 $ADUfindSQL and vicidial_live_inbound_agents.group_id='$group_id' and last_update_time > '$BDtsSQLdate' and vicidial_live_agents.user NOT IN($ring_no_answer_agents$vlia_users) and ring_callerid='' $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($ARGV[0]=~/debug/i) {print $stmtA."\n";} + +# if ($CAMP_callorder =~ /grade/) +# { +# $stmtA = "SELECT vicidial_live_agents.user,vicidial_live_inbound_agents.group_grade,vicidial_live_agents.campaign_grade from vicidial_live_agents, vicidial_live_inbound_agents WHERE vicidial_live_agents.user=vicidial_live_inbound_agents.user and status IN('CLOSER','READY') and lead_id<1 $ADUfindSQL and vicidial_live_inbound_agents.group_id='$group_id' and last_update_time > '$BDtsSQLdate' and vicidial_live_agents.user NOT IN($ring_no_answer_agents$vlia_users) and ring_callerid='' $qp_groupWAIT_camp_SQL limit 1000;"; +# $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +# $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +# $sthArows=$sthA->rows; +# } +# else +# { +# $stmtA = "SELECT vicidial_live_agents.conf_exten,vicidial_live_agents.user,vicidial_live_agents.extension,vicidial_live_agents.server_ip,vicidial_live_inbound_agents.group_weight,ra_user,vicidial_live_agents.campaign_id,on_hook_agent,on_hook_ring_time,vicidial_live_inbound_agents.group_grade,vicidial_live_agents.campaign_grade from vicidial_live_agents, vicidial_live_inbound_agents WHERE vicidial_live_agents.user=vicidial_live_inbound_agents.user and status IN('CLOSER','READY') and lead_id<1 $ADUfindSQL and vicidial_live_inbound_agents.group_id='$group_id' and last_update_time > '$BDtsSQLdate' and vicidial_live_agents.user NOT IN($ring_no_answer_agents$vlia_users) and ring_callerid='' $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; +# $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +# $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +# $sthArows=$sthA->rows; +# } + + if ($sthArows>0) + { + while (@user_row=$sthA->fetchrow_array) + { + $user=$user_row[0]; + } + $sthA->finish(); + } + + if ($user ne "") + { + $upd_stmt="update vicidial_email_list set status='QUEUE', user='$user' where email_row_id='$email_row_id'"; + $upd_rslt=$dbhB->prepare($upd_stmt); + $upd_rslt->execute or die "executing: $upd_stmt ", $dbhB->errstr; + $upd_rslt->finish(); + if ($ARGV[0]=~/debug/i) {print $upd_stmt."\n";} + $upd_stmt="update vicidial_live_agents set status='MQUEUE' where user='$user'"; + $upd_rslt=$dbhA->prepare($upd_stmt); + $upd_rslt->execute or die "executing: $upd_stmt ", $dbhB->errstr; + $upd_rslt->finish(); + if ($ARGV[0]=~/debug/i) {print $upd_stmt."\n";} + } + + $stmtA = "UNLOCK TABLES;"; + my $LOCKaffected_rows = $dbhA->do($stmtA); + } + else + { + $stmtA = "LOCK TABLES vicidial_live_agents WRITE;"; + my $LOCKaffected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='02158'; $MEL_aff_rows=$LOCKaffected_rows; &mysql_error_logging; + + $stmtA = "SELECT user FROM vicidial_live_agents where status IN('CLOSER','READY') and lead_id<1 $ADUfindSQL and campaign_id IN($INBOUNDcampsSQL) and closer_campaigns LIKE \"% $group_id %\" and last_update_time > '$BDtsSQLdate' and vicidial_live_agents.user NOT IN($ring_no_answer_agents) $qp_groupWAIT_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + if ($ARGV[0]=~/debug/i) {print $stmtA."\n";} + $sthArows=$sthA->rows; + + if ($sthArows>0) + { + while (@user_row=$sthA->fetchrow_array) + { + $user=$user_row[0]; + } + $sthA->finish(); + } + + if ($user ne "") + { + $upd_stmt="update vicidial_email_list set status='QUEUE', user='$user' where email_row_id='$email_row_id'"; + $upd_rslt=$dbhB->prepare($upd_stmt); + $upd_rslt->execute or die "executing: $upd_stmt ", $dbhB->errstr; + $upd_rslt->finish(); + if ($ARGV[0]=~/debug/i) {print $upd_stmt."\n";} + $upd_stmt="update vicidial_live_agents set status='MQUEUE' where user='$user'"; + $upd_rslt=$dbhA->prepare($upd_stmt); + $upd_rslt->execute or die "executing: $upd_stmt ", $dbhB->errstr; + $upd_rslt->finish(); + if ($ARGV[0]=~/debug/i) {print $upd_stmt."\n";} + } + + $stmtA = "UNLOCK TABLES;"; + my $LOCKaffected_rows = $dbhA->do($stmtA); + } + + } + if ($ARGV[0]=~/debug/i) {print "\n\n";} + + } + +sub mysql_error_logging + { + ($Lsec,$Lmin,$Lhour,$Lmday,$Lmon,$Lyear,$Lwday,$Lyday,$Lisdst) = localtime(time); + if ($Lhour < 10) {$Lhour = "0$Lhour";} + if ($Lmin < 10) {$Lmin = "0$Lmin";} + if ($Lsec < 10) {$Lsec = "0$Lsec";} + $LOGtime = "$Lhour:$Lmin:$Lsec"; + + $errno=''; + $error=''; + if ( ($mel > 0) || ($one_mysql_log > 0) ) + { + $errno = $dbhP->err(); + if ( ($errno > 0) || ($mel > 1) || ($one_mysql_log > 0) ) + { + $error = $dbhP->errstr(); + ### open the log file for writing ### + open(Eout, ">>$ERRLOGfile") + || die "Can't open $ERRLOGfile: $!\n"; + print Eout "$now_date|$LOGtime|$script|$mysql_count|$MEL_aff_rows|$errno|$error|$stmtA|$callerid|$insert_lead_id|\n"; + close(Eout); + } + } + $one_mysql_log=0; + } diff --git a/agc_2-X/trunk/docs/BASE_INSTALL.txt b/agc_2-X/trunk/docs/BASE_INSTALL.txt index e702a686..e5da40fc 100644 --- a/agc_2-X/trunk/docs/BASE_INSTALL.txt +++ b/agc_2-X/trunk/docs/BASE_INSTALL.txt @@ -475,6 +475,9 @@ PHASE 6: ADDING CRONTAB ENTRIES FOR ASTGUICLIENT/VICIDIAL SCRIPTS ### VICIDIAL agent time log weekly summary report generation 2 0 * * 0 /usr/share/astguiclient/AST_agent_week.pl +### inbound email parser +#* * * * * /usr/share/astguiclient/AST_inbound_email_parser.pl + ### remove old recordings more than 7 days old #24 0 * * * /usr/bin/find /var/spool/asterisk/monitorDONE -maxdepth 2 -type f -mtime +7 -print | xargs rm -f diff --git a/agc_2-X/trunk/docs/Email_user_manual.txt b/agc_2-X/trunk/docs/Email_user_manual.txt new file mode 100644 index 00000000..7bdd0beb --- /dev/null +++ b/agc_2-X/trunk/docs/Email_user_manual.txt @@ -0,0 +1,25 @@ +In order to use this feature, the very first thing you need is an email account to handle your incoming emails. This account must operate under either the IMAP or POP3 mail protocols, as these are currenty the only two that Vicidial supports. You can sign up for a free Gmail account, which uses the IMAP protocol, or a Yahoo! account, which uses POP3. People using this feature may find it more feasible to use an email that operates under the IMAP protocol. The reason for this is that if you use a POP3 account, messages sent to it will be erased upon discovery by your Vicidial installation. This is because the programming involved does not allow POP3 accounts to have their email messages marked to prevent repeat pullings from the mailbox, and therefore the email message must be erased once imported, whereas IMAP accounts are supported such that they can be marked as read. + +Once you have created your new email account, you must set it up in the dialer so that the dialer will be able to connect to it and collect any emails in it and import those into the dialer. First, the dialer must have the "Emails Enabled" setting turned on under the "System Settings" page in the "Admin" section. Ensure that this value is set to "1" and if not, switch it to that and submit the changed system settings. Now, you must also turn on the modification privileges for the users who will be able to modify email accounts. This can be found under the "Admin Interface Options" section on the user's account page and is called "Modify Email Accounts". + +With the email settings enabled and having users who can update email account-related information, you must now create an email group that Vicidial will "file" incoming emails under so that they can be routed to the appropriate agents in the appropriate campaigns. This is done by clicking on the "Inbound" link at left. From the list of links that appear beneath the "Inbound" link, click on the "Add New Email Group". This will take you to a form that you must fill out. All new email groups must be given a group ID and a group name. Click the "SUBMIT" button and if the form was filled out correctly, you will have created an inbound group that will handle email messages, as opposed to the "regular" in-groups which handle phone calls. Remember to set the "Active" setting to "Y" once you're ready to have email messages collected and stored. + +When the email setting is enabled and the email in-group is created, you can create the email account settings that will tell the dialer where and how to connect to your email account and the in-group to file them under. Under the "Admin" section, click on the "Email Accounts" setting. Click on the "Add a New Account" link at the top of the page and you will be taken to the form you must fill out with all the necessary information for Vicidial to connect to your email account. You must set an email account ID and an email account description, both of which are relatively arbitrary. More importantly, make sure the proper protocol (IMAP or POP3) is selected, and that the email reply-to address (which is just the actual email address on the account) and the email account server is entered properly (ex: gmail is imap.gmail.com). You also need to enter the username and password that is used to access the account, and also the frequency that Vicidial should check your account for new emails. Some email accounts do not allow more than a few logins over a set amount of time, so at the moment the highest rate of frequency that Vicidial will allow is one login attempt every five minutes. Fill out the remaining fields (click the "?" button by any field that needs explaining - if you are familiar with inbound groups, most of these fields work in the same way) and submit the new email account. When you are ready to have Vicidial start checking it for emails, be sure the "Active" setting is set to "Y". + +The checking of email accounts is handled by a cron job that should only be active on ONE server on your Vicidial installation: + +* * * * * /usr/share/astguiclient/AST_inbound_email_parser.pl + +This script will check to see if any active email account is due to be checked for new messages, per the "Email Frequency Check Rate" setting on the active accounts. If new emails are found in an active account, one of two things will happen, depending on the account protocol. As stated earlier, IMAP accounts will have the message marked as read, so it will not be pulled into your Vicidial database again, but in POP3 accounts the message will be erased. When this script finds an email to insert into the Vicidial dialer, it will parse out the pertininent information from the header and body of the email, and then based on the "In-Group Call Handle Method" setting for the associated email account, it will insert the data as a new lead in the vicidial_list table or check the vicidial_list table for the email address and use the lead_id from the found record to create a new lead in the vicidial_email_list table. Both tables can be tied together by the lead_id column. Also, if the email message has any attachments, those will be inserted into the inbound_email_attachments table, with the email_row_id column in that table tying back to the column of the same name in vicidial_email_list. + +With the email messages being imported into your Vicidial system, you can now set up campaigns to distribute the messages out to agents who log in to the appropriate campaigns. This is identical to the procedure for setting up inbound calls. All you do is view the "Detail View" for the campaign(s) that is/are to receive these emails, and under the "Allowed Inbound Groups" section, check the box next to each email in-group that the campaign will take. Campaigns must be set as RATIO, INBOUND_MAN, or any of the ADAPT dial methods(?). Emails can even be transferred to other agents, similar to transferring phone calls. This is done in the same way; set up an email in-group, and then under the "Detail View" setting for a campaign, check the box for that group under the "Allowed Transfer Group" to allow emails to be transferred to that ingroup, and in turn another campaign can be set up to accept these transfers by making that in-group an "Allowed Inbound Group". + +Once this is all set up, emails will start to come in to your system. In the agent interface, there is now a new tab called "EMAIL" at the top of the screen. This is the default call launch for email messages, and is the screen that will automatically be displayed for the agents. From here, agents can see the sent message and the address of the person who sent it (and sometimes the sender name), and can even view any attachments the sender included. Agents can type a plain text response to the incoming message, and can also send back attachments of their own. The system will notify the agent if an email attempt is successful, and these message "calls" can be terminated in the same way as a regular phone call, by clicking the "HANGUP CUSTOMER" button or using HotKeys. + +The order in which incoming emails will be distributed to the agents is determined by the queue_priority setting on each in-group, and then by the date in which the email was sent. In other words, unless one email-group has a higher priority over another, agents will always receive the oldest emails first. In addition, email in-groups will also prioritize agents based on the "Next agent call" setting for each ingroup. Agents can be prioritized based on the number of calls/emails they have received, or by rank or by one of the time values stored in the vicidial_live_agent table. + +The determination of the order in which emails are distributed out to agents and the determination of the order of which agents are to receive emails are both handled by a single script, VD_email_inbound.pl, which is implemented thusly in ONE server's crontab: + +* * * * * /usr/share/astguiclient/VD_email_inbound.pl + +This is a perpetually-running script that is constantly checking the vicidial_email_list and vicidial_xfer_log tables for any email messages that need to be queued and handled by an agent. Emails from transfer in-groups always take precedence over regular incoming emails, regardless of the queue priority setting. However, the queue priority is taken into consideration if multiple transfer in-groups have emails that need handling. This script first checks the vicidial_xfer_log table for email messages that have been transferred by an agent, and then checks the vicidial_email_list table for any new email messages that have not yet been handled by any agent. Once a list of emails to queue has been generated, this script go through each email one at a time, and will take the in-group the email belongs to and check the system for any agents in a READY or CLOSER status who are currently taking emails that in-group. If more than one agent is available, the agents selected to receive the messages is determined by the "Next agent call" setting for the group the message belongs to. The script will proceed in this fashion until all email messages have been assigned or all active agents have been given a message. The script will then sleep for a brief period and then repeat the process. \ No newline at end of file diff --git a/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt b/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt index 717d6008..c6dfdee5 100644 --- a/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt +++ b/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt @@ -74,6 +74,17 @@ install Text::CSV_PP install File::Temp install Text::CSV_XS install Spreadsheet::Read +install LWP::UserAgent +install HTML::Entities +install HTML::Strip +install HTML::FormatText +install HTML::TreeBuilder +install Switch +install Time::Local +install MIME::Decoder +install Mail::POP3Client +install Mail::IMAPClient +install Mail::Message quit diff --git a/agc_2-X/trunk/docs/SCRATCH_INSTALL.txt b/agc_2-X/trunk/docs/SCRATCH_INSTALL.txt index bb014e5b..2d5fcd8a 100644 --- a/agc_2-X/trunk/docs/SCRATCH_INSTALL.txt +++ b/agc_2-X/trunk/docs/SCRATCH_INSTALL.txt @@ -448,6 +448,17 @@ following modules first: (say YES if asked to install prerequisites) - install File::Temp - install Text::CSV_XS - install Spreadsheet::Read + - install LWP::UserAgent + - install HTML::Entities + - install HTML::Strip + - install HTML::FormatText + - install HTML::TreeBuilder + - install Switch + - install Time::Local + - install MIME::Decoder + - install Mail::POP3Client + - install Mail::IMAPClient + - install Mail::Message - then quit cpan, you are done 5. Go to http://asterisk.gnuinter.net/ and download the asterisk-perl module (backup link: http://download.vicidial.com/packages/asterisk-perl-0.08.tar.gz) @@ -2462,6 +2473,9 @@ SUBPHASE 6.5: setting up astguiclient scripts for continuous running #32 0 * * * /usr/share/astguiclient/AST_VDsales_export.pl #42 0 * * * /usr/share/astguiclient/AST_sourceID_summary_export.pl +### inbound email parser +#* * * * * /usr/share/astguiclient/AST_inbound_email_parser.pl + ### inventory report optional #1 7 * * * /usr/share/astguiclient/AST_dialer_inventory_snapshot.pl -q --override-24hours 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 01d35b63..dd5b7dfe 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -357,7 +357,7 @@ user VARCHAR(20), server_ip VARCHAR(15) NOT NULL, conf_exten VARCHAR(20), extension VARCHAR(100), -status ENUM('READY','QUEUE','INCALL','PAUSED','CLOSER') default 'PAUSED', +status ENUM('READY','QUEUE','INCALL','PAUSED','CLOSER','MQUEUE') default 'PAUSED', lead_id INT(9) UNSIGNED NOT NULL, campaign_id VARCHAR(8), uniqueid VARCHAR(20), @@ -599,7 +599,9 @@ preset_contact_search ENUM('NOT_ACTIVE','ENABLED','DISABLED') default 'NOT_ACTIV modify_contacts ENUM('1','0') default '0', modify_same_user_level ENUM('0','1') default '1', admin_hide_lead_data ENUM('0','1') default '0', -admin_hide_phone_data ENUM('0','1','2_DIGITS','3_DIGITS','4_DIGITS') default '0' +admin_hide_phone_data ENUM('0','1','2_DIGITS','3_DIGITS','4_DIGITS') default '0', +agentcall_email ENUM('0','1') default '0', +modify_email_accounts ENUM('0','1') default '0' ); CREATE UNIQUE INDEX user ON vicidial_users (user); @@ -860,7 +862,8 @@ in_group_dial_select ENUM('AGENT_SELECTED','CAMPAIGN_SELECTED','ALL_USER_GROUP') safe_harbor_audio_field VARCHAR(30) default 'DISABLED', pause_after_next_call ENUM('ENABLED','DISABLED') default 'DISABLED', owner_populate ENUM('ENABLED','DISABLED') default 'DISABLED', -use_other_campaign_dnc VARCHAR(8) default '' +use_other_campaign_dnc VARCHAR(8) default '', +allow_emails ENUM('Y','N') default 'N' ); CREATE TABLE vicidial_lists ( @@ -961,7 +964,7 @@ voicemail_ext VARCHAR(10), next_agent_call VARCHAR(30) default 'longest_wait_time', fronter_display ENUM('Y','N') default 'Y', ingroup_script VARCHAR(10), -get_call_launch ENUM('NONE','SCRIPT','WEBFORM','WEBFORMTWO','FORM') default 'NONE', +get_call_launch ENUM('NONE','SCRIPT','WEBFORM','WEBFORMTWO','FORM','EMAIL') default 'NONE', xferconf_a_dtmf VARCHAR(50), xferconf_a_number VARCHAR(50), xferconf_b_dtmf VARCHAR(50), @@ -1064,7 +1067,8 @@ user_group VARCHAR(20) default '---ALL---', max_calls_method ENUM('TOTAL','IN_QUEUE','DISABLED') default 'DISABLED', max_calls_count SMALLINT(5) default '0', max_calls_action ENUM('DROP','AFTERHOURS','NO_AGENT_NO_QUEUE') default 'NO_AGENT_NO_QUEUE', -dial_ingroup_cid VARCHAR(20) default '' +dial_ingroup_cid VARCHAR(20) default '', +group_handling ENUM('PHONE','EMAIL') default 'PHONE' ); CREATE TABLE vicidial_stations ( @@ -1499,7 +1503,8 @@ audio_store_purge TEXT, svn_revision INT(9) default '0', queuemetrics_socket VARCHAR(20) default 'NONE', queuemetrics_socket_url TEXT, -enhanced_disconnect_logging ENUM('0','1') default '0' +enhanced_disconnect_logging ENUM('0','1') default '0', +allow_emails ENUM('0','1') default '0' ); CREATE TABLE vicidial_campaigns_list_mix ( @@ -2770,6 +2775,84 @@ default_afterhours_filename_override VARCHAR(255) default '', user_group VARCHAR(20) default '---ALL---' ); +CREATE TABLE vicidial_email_list ( +email_row_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +lead_id INT(9) UNSIGNED DEFAULT NULL, +email_date DATETIME DEFAULT NULL, +protocol ENUM('POP3','IMAP','NONE') DEFAULT 'IMAP', +email_to VARCHAR(255) DEFAULT NULL, +email_from VARCHAR(255) DEFAULT NULL, +email_from_name VARCHAR(255) DEFAULT NULL, +subject TEXT, +mime_type TEXT, +content_type TEXT, +x_mailer TEXT, +sender_ip VARCHAR(25) DEFAULT NULL, +message TEXT, +email_account_id VARCHAR(20) DEFAULT NULL, +group_id VARCHAR(20) DEFAULT NULL, +user VARCHAR(20) DEFAULT NULL, +status VARCHAR(10) DEFAULT NULL, +direction ENUM('INBOUND','OUTBOUND') DEFAULT 'INBOUND', +uniqueid VARCHAR(20) DEFAULT NULL, +xfercallid INT(9) UNSIGNED DEFAULT NULL, +PRIMARY KEY (email_row_id), +KEY email_list_account_key (email_account_id), +KEY email_list_user_key (user), +KEY vicidial_email_lead_id_key (lead_id) +); + +CREATE TABLE vicidial_email_accounts ( +email_account_id VARCHAR(20) NOT NULL, +email_account_name VARCHAR(100) DEFAULT NULL, +email_account_description VARCHAR(255) DEFAULT NULL, +user_group VARCHAR(20) DEFAULT '---ALL---', +protocol ENUM('POP3','IMAP','SMTP') DEFAULT 'IMAP', +email_replyto_address VARCHAR(255) DEFAULT NULL, +email_account_server VARCHAR(255) DEFAULT NULL, +email_account_user VARCHAR(255) DEFAULT NULL, +email_account_pass VARCHAR(100) DEFAULT NULL, +active ENUM('Y','N') DEFAULT 'N', +email_frequency_check_mins TINYINT(3) UNSIGNED DEFAULT '5', +group_id VARCHAR(20) DEFAULT NULL, +default_list_id BIGINT(14) UNSIGNED DEFAULT NULL, +call_handle_method VARCHAR(20) DEFAULT 'CID', +agent_search_method ENUM('LO','LB','SO') DEFAULT 'LB', +campaign_id VARCHAR(8) DEFAULT NULL, +list_id BIGINT(14) UNSIGNED DEFAULT NULL, +email_account_type ENUM('INBOUND','OUTBOUND') DEFAULT 'INBOUND', +PRIMARY KEY (email_account_id), +KEY email_accounts_group_key (group_id) +); + +CREATE TABLE inbound_email_attachments ( +attachment_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +email_row_id INT(10) UNSIGNED DEFAULT NULL, +filename VARCHAR(250) NOT NULL DEFAULT '', +file_type VARCHAR(100) DEFAULT NULL, +file_encoding VARCHAR(20) DEFAULT NULL, +file_size VARCHAR(45) DEFAULT NULL, +file_extension VARCHAR(5) NOT NULL DEFAULT '', +file_contents LONGBLOB NOT NULL, +PRIMARY KEY (attachment_id), +KEY attachments_email_id_key (email_row_id) +); + +CREATE TABLE vicidial_email_log ( +email_log_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +email_row_id INT(10) UNSIGNED DEFAULT NULL, +lead_id INT(9) UNSIGNED DEFAULT NULL, +email_date DATETIME DEFAULT NULL, +user VARCHAR(20) DEFAULT NULL, +email_to VARCHAR(255) DEFAULT NULL, +message TEXT, +campaign_id VARCHAR(10) DEFAULT NULL, +attachments TEXT, +PRIMARY KEY (email_log_id), +KEY vicidial_email_log_lead_id_key (lead_id), +KEY vicidial_email_log_email_row_id_key (email_row_id) +); + ALTER TABLE vicidial_qc_codes ADD qc_result_type ENUM( 'PASS', 'FAIL', 'CANCEL', 'COMMIT' ) NOT NULL; @@ -3005,4 +3088,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version'; UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1336',db_schema_update_date=NOW(); +UPDATE system_settings SET db_schema_version='1337',db_schema_update_date=NOW(); diff --git a/agc_2-X/trunk/extras/upgrade_2.6.sql b/agc_2-X/trunk/extras/upgrade_2.6.sql index 97986b12..0726b6e1 100644 --- a/agc_2-X/trunk/extras/upgrade_2.6.sql +++ b/agc_2-X/trunk/extras/upgrade_2.6.sql @@ -199,3 +199,95 @@ ALTER TABLE vicidial_campaigns MODIFY agent_lead_search ENUM('ENABLED','LIVE_CAL ALTER TABLE vicidial_users MODIFY agent_lead_search_override ENUM('NOT_ACTIVE','ENABLED','LIVE_CALL_INBOUND','LIVE_CALL_INBOUND_AND_MANUAL','DISABLED') default 'NOT_ACTIVE'; UPDATE system_settings SET db_schema_version='1336',db_schema_update_date=NOW() where db_schema_version < 1336; + +CREATE TABLE vicidial_email_list ( +email_row_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +lead_id INT(9) UNSIGNED DEFAULT NULL, +email_date DATETIME DEFAULT NULL, +protocol ENUM('POP3','IMAP','NONE') DEFAULT 'IMAP', +email_to VARCHAR(255) DEFAULT NULL, +email_from VARCHAR(255) DEFAULT NULL, +email_from_name VARCHAR(255) DEFAULT NULL, +subject TEXT, +mime_type TEXT, +content_type TEXT, +x_mailer TEXT, +sender_ip VARCHAR(25) DEFAULT NULL, +message TEXT, +email_account_id VARCHAR(20) DEFAULT NULL, +group_id VARCHAR(20) DEFAULT NULL, +user VARCHAR(20) DEFAULT NULL, +status VARCHAR(10) DEFAULT NULL, +direction ENUM('INBOUND','OUTBOUND') DEFAULT 'INBOUND', +uniqueid VARCHAR(20) DEFAULT NULL, +xfercallid INT(9) UNSIGNED DEFAULT NULL, +PRIMARY KEY (email_row_id), +KEY email_list_account_key (email_account_id), +KEY email_list_user_key (user), +KEY vicidial_email_lead_id_key (lead_id) +); + +CREATE TABLE vicidial_email_accounts ( +email_account_id VARCHAR(20) NOT NULL, +email_account_name VARCHAR(100) DEFAULT NULL, +email_account_description VARCHAR(255) DEFAULT NULL, +user_group VARCHAR(20) DEFAULT '---ALL---', +protocol ENUM('POP3','IMAP','SMTP') DEFAULT 'IMAP', +email_replyto_address VARCHAR(255) DEFAULT NULL, +email_account_server VARCHAR(255) DEFAULT NULL, +email_account_user VARCHAR(255) DEFAULT NULL, +email_account_pass VARCHAR(100) DEFAULT NULL, +active ENUM('Y','N') DEFAULT 'N', +email_frequency_check_mins TINYINT(3) UNSIGNED DEFAULT '5', +group_id VARCHAR(20) DEFAULT NULL, +default_list_id BIGINT(14) UNSIGNED DEFAULT NULL, +call_handle_method VARCHAR(20) DEFAULT 'CID', +agent_search_method ENUM('LO','LB','SO') DEFAULT 'LB', +campaign_id VARCHAR(8) DEFAULT NULL, +list_id BIGINT(14) UNSIGNED DEFAULT NULL, +email_account_type ENUM('INBOUND','OUTBOUND') DEFAULT 'INBOUND', +PRIMARY KEY (email_account_id), +KEY email_accounts_group_key (group_id) +); + +CREATE TABLE inbound_email_attachments ( +attachment_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +email_row_id INT(10) UNSIGNED DEFAULT NULL, +filename VARCHAR(250) NOT NULL DEFAULT '', +file_type VARCHAR(100) DEFAULT NULL, +file_encoding VARCHAR(20) DEFAULT NULL, +file_size VARCHAR(45) DEFAULT NULL, +file_extension VARCHAR(5) NOT NULL DEFAULT '', +file_contents LONGBLOB NOT NULL, +PRIMARY KEY (attachment_id), +KEY attachments_email_id_key (email_row_id) +); + +CREATE TABLE vicidial_email_log ( +email_log_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +email_row_id INT(10) UNSIGNED DEFAULT NULL, +lead_id INT(9) UNSIGNED DEFAULT NULL, +email_date DATETIME DEFAULT NULL, +user VARCHAR(20) DEFAULT NULL, +email_to VARCHAR(255) DEFAULT NULL, +message TEXT, +campaign_id VARCHAR(10) DEFAULT NULL, +attachments TEXT, +PRIMARY KEY (email_log_id), +KEY vicidial_email_log_lead_id_key (lead_id), +KEY vicidial_email_log_email_row_id_key (email_row_id) +); + +ALTER TABLE system_settings ADD allow_emails ENUM('0','1') default '0'; + +ALTER TABLE vicidial_campaigns ADD allow_emails ENUM('Y','N') default 'N'; + +ALTER TABLE vicidial_inbound_groups ADD group_handling ENUM('PHONE','EMAIL') default 'PHONE'; +ALTER TABLE vicidial_inbound_groups MODIFY get_call_launch get_call_launch ENUM('NONE','SCRIPT','WEBFORM','WEBFORMTWO','FORM','EMAIL') default 'NONE'; + +ALTER TABLE vicidial_users ADD agentcall_email ENUM('0','1') default '0'; +ALTER TABLE vicidial_users ADD modify_email_accounts ENUM('0','1') default '0'; + +ALTER TABLE vicidial_live_agents MODIFY status ENUM('READY','QUEUE','INCALL','PAUSED','CLOSER','MQUEUE') default 'PAUSED'; + +UPDATE system_settings SET db_schema_version='1337',db_schema_update_date=NOW() where db_schema_version < 1337; diff --git a/agc_2-X/trunk/install.pl b/agc_2-X/trunk/install.pl index 400ba166..081b0b29 100644 --- a/agc_2-X/trunk/install.pl +++ b/agc_2-X/trunk/install.pl @@ -27,6 +27,7 @@ # 110812-1510 - Added tts sound directories creation # 120224-1614 - Added function to clear out web auth log files # 121027-1750 - Added svn logging information +# 121215-2059 - Added keepalive option E for email process # ############################################ @@ -189,6 +190,7 @@ if (length($ARGV[0])>1) print " 7 - AST_VDauto_dial_FILL (only for multi-server, this must only be on one server)\n"; print " 8 - ip_relay (used for blind agent monitoring)\n"; print " 9 - Timeclock auto-logout\n"; + print " E - Email processor, (If multi-server system, this must only be on one server)\n"; print " [--asterisk_version] = set the asterisk version you want to install for\n"; print " [--copy_sample_conf_files] = copies the sample conf files to /etc/asterisk/\n"; print " [--web-languages] = copy language translations (WARNING! may not work on trunk installs)\n"; @@ -1800,6 +1802,7 @@ else print " 7 - AST_VDauto_dial_FILL (only for multi-server, this must only be on one server)\n"; print " 8 - ip_relay (used for blind agent monitoring)\n"; print " 9 - Timeclock auto logout\n"; + print " E - Email processor, (If multi-server system, this must only be on one server)\n"; print "Enter active keepalives or press enter for default: [$VARactive_keepalives] "; $PROMPTactive_keepalives = ; chomp($PROMPTactive_keepalives); @@ -2378,6 +2381,7 @@ print conf "# 6 - FastAGI_log\n"; print conf "# 7 - AST_VDauto_dial_FILL (only for multi-server, this must only be on one server)\n"; print conf "# 8 - ip_relay (used for blind agent monitoring)\n"; print conf "# 9 - Timeclock auto logout\n"; +print conf "# E - Email processor, (If multi-server system, this must only be on one server)\n"; print conf "VARactive_keepalives => $VARactive_keepalives\n"; print conf "\n"; print conf "# Asterisk version VICIDIAL is installed for\n"; diff --git a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.6.txt b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.6.txt index 122b9bde..6057db96 100644 --- a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.6.txt +++ b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.6.txt @@ -81,6 +81,98 @@ Enhanced Disconnect Logging|| This setting enables logging of calls that get a CONGESTION signal with a cause code of 1, 19, 21, 34 or 38. We usually do not recommend enabling this in the USA. Default is 0 for disabled|| LIVE_CALL_INBOUND will allow search for a lead while on an inbound call only. LIVE_CALL_INBOUND_AND_MANUAL will allow search for a lead while on an inbound call or while paused. When Lead Search is used on a live inbound call, the lead of the call when it went to the agent will be changed to a status of LSMERG, and the logs for the call will be modified to link to the agent selected lead instead|| If this is a call that will go to a Call Menu and then back to an in-group, we suggest you use CUSTOMERCLOSER in this field, and also you need to set the In-Group Search Method in the Call Menu to CLOSER|| +Add New EMAIL In-Group|| +Copy EMAIL In-Group|| +New Email Group Addition|| +New Copied Email Group Addition|| +Modify EMAIL In-Group|| +Email In-Groups|| +Modify Email Accounts|| +This option if set to 1 allows the user to modify email accounts in the email account management page|| +Allow Emails|| +This is where you can set whether the users of this campaign will be able to receive inbound emails in addition to phone calls|| +This is where you can set whether this system will be able to receive inbound emails in addition to phone calls|| +VICIDIAL EMAIL ACCOUNTS|| +The Vicidial Email Accounts management section allows you to create, copy, and delete email account settings that will allow you to have email messages come into your Vicidial system and be treated as regular calls. EMAIL ACCOUNTS MUST BE SET UP BY YOU AND AN EMAIL SERVICE PROVIDER - THAT IS NOT COVERED BY THIS MODULE|| +Email Account ID|| +This is the short name of the email account, it is not editable after initial submission, must not contain any spaces and must be between 2 and 20 characters in length|| +Email Account Name|| +This is the full name of the email account, it must be between 2 and 30 characters in length|| +This determines whether this account will be checked for new email messages to be loaded into the dialer|| +Email Account Description|| +This allows for a lengthy description, if needed, of the email account. 255 characters max|| +Email Account Type|| +Specifies whether the account is used for inbound or outbound email messages. Should be set to INBOUND|| +Admin User Group|| +This is the administrative user group for this inbound group, this allows admin viewing of this in-group restricted by user group. Default is --ALL-- which allows any admin user to view this in-group|| +Email Account Protocol|| +This is the email protocol used by the account you are setting up access to. Currently only IMAP and POP3 accounts are supported|| +Email Reply-to Address|| +The email address of the account you are setting up access to. Replies to email messages from the agent interface will read as coming from this address|| +Email Account Server|| +The email server that the account is housed on|| +Email Account User|| +The login used to access this account. Usually it's the portion of the reply-to address before the -at- symbol|| +Email Account Password|| +The password used to access this account. This is usually set at the time the email account is created|| +Email Frequency Check Rate (mins)|| +How often this email account should be checked. The highest rate of frequency at the moment is five minutes; some email providers will not allow more than three login attempts in fifteen minutes before locking the account for an indeterminate amount of time|| +In-Group ID|| +The In-Group that email messages will be sent to|| +Default List ID|| +The List ID that leads will be inserted into if necessary|| +In-Group Call Handle Method|| +This is the action that will be taken when a new email is found in the account. EMAIL means all email messages will be inserted into vicidial_list as a new lead. EMAILLOOKUP will search the entire vicidial_list table for the email address in the email column - if the lead is found, that lead's list ID will be used in the record that goes into the vicidial_email_list table. EMAILLOOKUPRC does the same, but it will only search lists belonging to the campaign selected in the "In-Group Campaign ID" box below. EMAILLOOKUPRL will only search one particular list, which is the one entered into the "In-Group List ID" box below|| +In-Group Agent Search Method|| +The agent search method to be used by the inbound group, LO is Load-Balanced-Overflow and will try to send the call to an agent on the local server before trying to send it to an agent on another server, LB is Load-Balanced and will try to send the call to the next agent no matter what server they are on, SO is Server-Only and will only try to send the calls to agents on the server that the call came in on. Default is LB.|| +In-Group List ID|| +This is the List ID that will be used to search for a match within|| +In-Group Campaign ID|| +This is the Campaign ID that will be used to search for a match within|| +Group Handling|| +COPY EMAIL GROUP|| +Email Group ID|| +Email Group Name|| +Source Email Group ID|| +Email Accounts|| +Next Agent Email|| +Start Email URL|| +Dispo Email URL|| +No Agent Email URL|| +EMAIL ACCOUNTS USING THIS IN-GROUP|| +EMAIL GROUP NOT ADDED|| +Email group ID must be between 2 and 20 characters in length and contain no|| +Email group name and group color must be at least 2 characters in length|| +EMAIL GROUP ADDED|| +Show Email Accounts|| +Add A New Account|| +Copy An Account|| +Dialer Email Account fields|| +NEW ACCOUNT|| +SUCCESSFULLY CREATED|| +All Admin User Groups|| +ERROR: Inbound emails are not active on this system|| +invalid or null|| +SUCCESSFULLY MODIFIED|| +There was an unknown error when attempting to copy the new account|| +SUCCESSFULLY COPIED FROM|| +source email does not exist|| +ACCOUNT NOT COPIED|| +Copy New Account from Existing Account|| +Account ID to Copy From|| +New Account ID|| +New Account Name|| +There are no existing accounts to copy from|| +The data you submitted has the following errors|| +ACCOUNT NOT INSERTED|| +ADD NEW INBOUND EMAIL ACCOUNT|| +CONFIRM DELETION OF INBOUND EMAIL ACCOUNT|| +Click to delete account|| +ACCOUNT NOT UPDATED|| +UPDATE AN EXISTING INBOUND EMAIL ACCOUNT|| +INBOUND EMAIL ACCOUNT LISTINGS|| +UNREAD EMAILS|| +Un-handled Emails|| ############################################################ CLIENT @@ -103,6 +195,7 @@ View Comment History|| reset form|| SELECT THIS LEAD|| YOU MUST BE ON AN ACTIVE INBOUND CALL TO SEARCH FOR A LEAD|| +Attachments|| ############################################################ MANAGER Manual diff --git a/agc_2-X/trunk/www/agc/vdc_db_query.php b/agc_2-X/trunk/www/agc/vdc_db_query.php index 0d5c773d..4b3b6d12 100644 --- a/agc_2-X/trunk/www/agc/vdc_db_query.php +++ b/agc_2-X/trunk/www/agc/vdc_db_query.php @@ -321,12 +321,12 @@ # 121130-0740 - Added call notes option to dispo call url # 121205-1620 - Added parentheses around filter SQL when in SQL queries # 121206-0635 - Added inbound lead search feature -# +# 121214-2208 - Added inbound email features -$version = '2.6-219'; -$build = '121206-0635'; +$version = '2.6-220'; +$build = '121214-2208'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=484; +$mysql_log_count=528; $one_mysql_log=0; require("dbconnect.php"); @@ -547,6 +547,12 @@ if (isset($_GET["nocall_dial_flag"])) {$nocall_dial_flag=$_GET["nocall_dial_fl elseif (isset($_POST["nocall_dial_flag"])) {$nocall_dial_flag=$_POST["nocall_dial_flag"];} if (isset($_GET["inbound_lead_search"])) {$inbound_lead_search=$_GET["inbound_lead_search"];} elseif (isset($_POST["inbound_lead_search"])) {$inbound_lead_search=$_POST["inbound_lead_search"];} +if (isset($_GET["email_enabled"])) {$email_enabled=$_GET["email_enabled"];} + elseif (isset($_POST["email_enabled"])) {$email_enabled=$_POST["email_enabled"];} +if (isset($_GET["email_row_id"])) {$email_row_id=$_GET["email_row_id"];} + elseif (isset($_POST["email_row_id"])) {$email_row_id=$_POST["email_row_id"];} +if (isset($_GET["inbound_email_groups"])) {$inbound_email_groups=$_GET["inbound_email_groups"];} + elseif (isset($_POST["inbound_email_groups"])) {$inbound_email_groups=$_POST["inbound_email_groups"];} header ("Content-type: text/html; charset=utf-8"); @@ -6013,7 +6019,943 @@ if ($ACTION == 'VDADcheckINCOMING') } } } +####################################################################################### +### XFERemail - for auto-dial VICIDiaL dialing this will check for emails +### in the vicidial_email_list table in NEW status, then +### lookup the lead info and pass it back to vicidial.php +### Also looks up transferred emails in vicidial_xfer_log +###################################################################################### +if ($ACTION == 'XFERemail') + { + # xferemail_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=XFERemail&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&exten=" + redirectdestination + "&ext_context=" + ext_context + "&ext_priority=1&extrachannel=" + redirectXTRAvalue + "&lead_id=" + document.vicidial_form.lead_id.value + "&phone_code=" + document.vicidial_form.phone_code.value + "&phone_number=" + document.vicidial_form.phone_number.value + "&filename=" + taskdebugnote + "&campaign=" + XfeR_GrouP + "&session_id=" + session_id + "&agentchannel=" + agentchannel + "&protocol=" + protocol + "&extension=" + extension + "&auto_dial_level=" + auto_dial_level; + $ins_stmt="INSERT INTO vicidial_xfer_log (lead_id,list_id,campaign_id,call_date,phone_code,phone_number,user,closer) values('$lead_id','$list_id','$campaign','$NOW_TIME','$phone_code','$phone_number','$user','EMAIL_XFER')"; + $ins_rslt=mysql_query($ins_stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00485',$user,$server_ip,$session_name,$one_mysql_log);} + $xfercallid = mysql_insert_id($link); + echo mysql_affected_rows()."|$ins_stmt"; + + $upd_stmt="update vicidial_email_list set xfercallid='$xfercallid' where email_row_id='$email_row_id'"; + $upd_rslt=mysql_query($upd_stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00486',$user,$server_ip,$session_name,$one_mysql_log);} + } + +####################################################################################### +### VDADcheckINCOMINGemail - for auto-dial VICIDiaL dialing this will check for emails +### in the vicidial_email_list table in NEW status, then +### lookup the lead info and pass it back to vicidial.php +### Also looks up transferred emails in vicidial_xfer_log +###################################################################################### +if ($ACTION == 'VDADcheckINCOMINGemail') + { + $VDCL_ingroup_recording_override = ''; + $VDCL_ingroup_rec_filename = ''; + $Ctype = 'A'; + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + $alt_phone_code=''; + $alt_phone_number=''; + $alt_phone_note=''; + $alt_phone_active=''; + $alt_phone_count=''; + $INclosecallid=''; + $INxfercallid=''; + $email_group_str=''; + + $email_group_ct=count($inbound_email_groups); # This should always be greater than zero for the script to reach this point, but just in case... + for ($i=0; $i<$email_group_ct; $i++) { + $email_group_str.="'$inbound_email_groups[$i]',"; + } + $email_group_str=substr($email_group_str, 0, -1); + # $DB=1; + + if ( (strlen($campaign)<1) || (strlen($server_ip)<1) ) + { + $channel_live=0; + echo "0\n"; + echo "Campaign $campaign is not valid\n"; + exit; + } + else + { + ### Check for transfers + #$upd_stmt="update vicidial_email_list inner join(select email_row_id from vicidial_email_list inner join vicidial_inbound_groups on vicidial_inbound_groups.group_id=vicidial_email_list.group_id order by queue_priority desc, email_date asc limit 1) as selected_row on selected_row.email_row_id=vicidial_email_list.email_row_id set status='QUEUE', user='$user'"; + $stmt="select vicidial_email_list.lead_id, vicidial_email_list.email_date, vicidial_email_list.email_to, vicidial_email_list.email_from, vicidial_email_list.subject, vicidial_xfer_log.campaign_id, vicidial_email_list.email_row_id, vicidial_xfer_log.xfercallid from vicidial_email_list, vicidial_xfer_log where vicidial_email_list.status='QUEUE' and vicidial_email_list.user='$user' and vicidial_xfer_log.xfercallid=vicidial_email_list.xfercallid and direction='INBOUND' and vicidial_xfer_log.campaign_id in ($email_group_str) and closer='EMAIL_XFER' order by vicidial_xfer_log.call_date asc limit 1"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00487',$user,$server_ip,$session_name,$one_mysql_log);} + $email_ct = mysql_num_rows($rslt); + $xferred_email=$email_ct; + + if ($email_ct==0) + { + # Check if there are any QUEUE calls + $stmt = "select lead_id, email_date, email_to, email_from, subject, group_id, email_row_id from vicidial_email_list where status='QUEUE' and direction='INBOUND' and user='$user' and group_id in ($email_group_str) order by email_date asc"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00488',$user,$server_ip,$session_name,$one_mysql_log);} + $email_ct = mysql_num_rows($rslt); + +# if ($email_ct==0) +# { +# $upd_stmt="update vicidial_email_list inner join(select email_row_id from vicidial_email_list inner join vicidial_inbound_groups on vicidial_inbound_groups.group_id=vicidial_email_list.group_id order by queue_priority desc, email_date asc limit 1) as selected_row on selected_row.email_row_id=vicidial_email_list.email_row_id set status='QUEUE', user='$user'"; +# if ($DB) {echo "$upd_stmt\n";} +# $rslt=mysql_query($stmt, $link); +# if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00104',$user,$server_ip,$session_name,$one_mysql_log);} + +# if (mysql_affected_rows()>0) +# { +# $stmt = "select lead_id, email_date, email_to, email_from, subject, group_id, email_row_id from vicidial_email_list where status='QUEUE' and direction='INBOUND' and user='$user' and group_id in ($email_group_str) order by email_date asc limit 1"; +# if ($DB) {echo "$stmt\n";} +# $rslt=mysql_query($stmt, $link); +# if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00104',$user,$server_ip,$session_name,$one_mysql_log);} +# $email_ct = mysql_num_rows($rslt); +# } +# } + } + + if ($email_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + $email_date =$row[1]; + $email_to =$row[2]; + $email_from =$row[3]; + $subject =$row[4]; + $VDADchannel_group=$row[5]; + $email_row_id=$row[6]; + $xfercallid=$row[7]; + $uniqueid=date("U").".".rand(1, 9999); + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + # echo "1\n" . $lead_id . '|'.$uniqueid.'|' . $email_date . '|' . $email_from . '|' . $subject . '|' . $email_row_id . "|\n"; # VDIC_data_VDAC + # Change to better suit the output processed by the agent interface + echo "1\n" . $lead_id . '|'.$uniqueid.'|' . $email_from . '|EMAIL|' . $email_row_id . '|' . $email_row_id . "|\n"; # VDIC_data_VDAC + + ##### grab number of calls today in this campaign and increment + $stmt="SELECT calls_today FROM vicidial_live_agents WHERE user='$user' and campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00489',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vla_cc_ct = mysql_num_rows($rslt); + if ($vla_cc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $calls_today =$row[0]; + } + else + {$calls_today ='0';} + $calls_today++; + + ### update the agent status to INCALL in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',comments='EMAIL',last_call_time='$NOW_TIME',lead_id='$lead_id',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00490',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9106$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + $stmt = "UPDATE vicidial_campaign_agents set calls_today='$calls_today' where user='$user' and campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00491',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmtA = "UPDATE vicidial_live_inbound_agents set calls_today='$calls_today',last_call_time=NOW() WHERE user='$user' and group_id='$VDADchannel_group';"; + $rsltA=mysql_query($stmtA, $link); + $stmtA = "UPDATE vicidial_inbound_group_agents set calls_today='$calls_today' WHERE user='$user' and group_id='$VDADchannel_group';"; + $rsltA=mysql_query($stmtA, $link); + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,entry_list_id FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00492',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $source_id = trim("$row[6]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = stripslashes(trim("$row[29]")); + $called_count = trim("$row[30]"); + $rank = trim("$row[32]"); + $owner = trim("$row[33]"); + $entry_list_id = trim("$row[34]"); + if ($entry_list_id < 100) {$entry_list_id = $list_id;} + } + + ### update the lead status to INCALL + $stmt = "UPDATE vicidial_list set status='INCALL', user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00493',$user,$server_ip,$session_name,$one_mysql_log);} + + ### update the email lead status to INCALL + # I moved user='$user' clause here because it is now getting added to the lead when the status becomes QUEUE + $stmt = "UPDATE vicidial_email_list set status='INCALL', uniqueid='$uniqueid' where lead_id='$lead_id' and email_row_id='$email_row_id' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00494',$user,$server_ip,$session_name,$one_mysql_log);} + + ### if a transfer, update the transfer record with the user + if ($xferred_email==1) + { + $stmt = "UPDATE vicidial_xfer_log set closer='$user' where xfercallid='$xfercallid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00495',$user,$server_ip,$session_name,$one_mysql_log);} + } + + ### gather custom_call_id from vicidial_log_extended table + $custom_call_id=''; + /* Can't use this - $unique_id is gotten from querying the vicidial_live_agents from an inbound call. These are not calls. + $stmt="SELECT custom_call_id FROM vicidial_log_extended where uniqueid='$uniqueid';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00333',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vle_record_ct = mysql_num_rows($rslt); + if ($vle_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $custom_call_id = $row[0]; + } + */ + + ### update the log status to INCALL + $user_group=''; + $stmt="SELECT user_group,full_name FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00496',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + $fullname = $row[1]; + } + + ### update the vicidial_closer_log user to INCALL + #$stmt = "UPDATE vicidial_closer_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL', user_group='$user_group' where lead_id='$lead_id' order by closecallid desc limit 1;"; + $stmt="INSERT INTO vicidial_closer_log(call_date, start_epoch, user, comments, list_id, status, user_group, lead_id, campaign_id, processed, phone_code, phone_number, xfercallid, queue_position, uniqueid) values('".date("Y-m-d H:i:s")."', '".date("U")."', '$user', 'AUTO', '$list_id', 'INCALL', '$user_group', '$lead_id', '$VDADchannel_group', 'N', '$phone_code', '$phone_number', '0', '1', '$uniqueid');"; + + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00497',$user,$server_ip,$session_name,$one_mysql_log);} + + if (strlen($closecallid)<1) + { + $stmt = "SELECT closecallid,xfercallid from vicidial_closer_log where lead_id='$lead_id' and user='$user' and list_id='$list_id' order by call_date desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00498',$user,$server_ip,$session_name,$one_mysql_log);} + $VDCL_mvac_ct = mysql_num_rows($rslt); + if ($VDCL_mvac_ct > 0) + { + $row=mysql_fetch_row($rslt); + $INclosecallid = $row[0]; + $INxfercallid = $row[1]; + } + } + + $stmt = "SELECT count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00499',$user,$server_ip,$session_name,$one_mysql_log);} + $VDL_cid_ct = mysql_num_rows($rslt); + if ($VDL_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_front_VDlog =$row[0]; + } + $stmt = "SELECT group_name,group_color,web_form_address,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,default_xfer_group,ingroup_recording_override,ingroup_rec_filename,default_group_alias,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,uniqueid_status_display,uniqueid_status_prefix,timer_action_destination from vicidial_inbound_groups where group_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00500',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_name = $row[0]; + $VDCL_group_color = $row[1]; + $VDCL_group_web = stripslashes($row[2]); + $VDCL_fronter_display = $row[3]; + $VDCL_ingroup_script = $row[4]; + $VDCL_get_call_launch = $row[5]; + $VDCL_xferconf_a_dtmf = $row[6]; + $VDCL_xferconf_a_number = $row[7]; + $VDCL_xferconf_b_dtmf = $row[8]; + $VDCL_xferconf_b_number = $row[9]; + $VDCL_default_xfer_group = $row[10]; + $VDCL_ingroup_recording_override = $row[11]; + $VDCL_ingroup_rec_filename = $row[12]; + $VDCL_default_group_alias = $row[13]; + $VDCL_group_web_two = stripslashes($row[14]); + $VDCL_timer_action = $row[15]; + $VDCL_timer_action_message = $row[16]; + $VDCL_timer_action_seconds = $row[17]; + $VDCL_start_call_url = $row[18]; + $VDCL_dispo_call_url = $row[19]; + $VDCL_xferconf_c_number = $row[20]; + $VDCL_xferconf_d_number = $row[21]; + $VDCL_xferconf_e_number = $row[22]; + $VDCL_uniqueid_status_display = $row[23]; + $VDCL_uniqueid_status_prefix = $row[24]; + $VDCL_timer_action_destination = $row[25]; + + $stmt = "SELECT campaign_script,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,default_group_alias,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,timer_action_destination from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00501',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidOR_ct = mysql_num_rows($rslt); + if ($VDIG_cidOR_ct > 0) + { + $row=mysql_fetch_row($rslt); + if (strlen($VDCL_xferconf_a_dtmf) < 1) + {$VDCL_xferconf_a_dtmf = $row[1];} + if (strlen($VDCL_xferconf_a_number) < 1) + {$VDCL_xferconf_a_number = $row[2];} + if (strlen($VDCL_xferconf_b_dtmf) < 1) + {$VDCL_xferconf_b_dtmf = $row[3];} + if (strlen($VDCL_xferconf_b_number) < 1) + {$VDCL_xferconf_b_number = $row[4];} + if (strlen($VDCL_default_group_alias) < 1) + {$VDCL_default_group_alias = $row[5];} + if (strlen($VDCL_timer_action) < 1) + {$VDCL_timer_action = $row[6];} + if (strlen($VDCL_timer_action_message) < 1) + {$VDCL_timer_action_message = $row[7];} + if (strlen($VDCL_timer_action_seconds) < 1) + {$VDCL_timer_action_seconds = $row[8];} + if (strlen($VDCL_start_call_url) < 1) + {$VDCL_start_call_url = $row[9];} + if (strlen($VDCL_dispo_call_url) < 1) + {$VDCL_dispo_call_url = $row[10];} + if (strlen($VDCL_xferconf_c_number) < 1) + {$VDCL_xferconf_c_number = $row[11];} + if (strlen($VDCL_xferconf_d_number) < 1) + {$VDCL_xferconf_d_number = $row[12];} + if (strlen($VDCL_xferconf_e_number) < 1) + {$VDCL_xferconf_e_number = $row[13];} + if (strlen($VDCL_timer_action_destination) < 1) + {$VDCL_timer_action_destination = $row[14];} + } + $stmt = "SELECT group_web_vars from vicidial_inbound_group_agents where group_id='$VDADchannel_group' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00502',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidgwv_ct = mysql_num_rows($rslt); + if ($VDIG_cidgwv_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_web_vars = $row[0]; + } + + if (strlen($VDCL_group_web_vars) < 1) + { + $stmt = "SELECT group_web_vars from vicidial_campaign_agents where campaign_id='$campaign' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00503',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidogwv = mysql_num_rows($rslt); + if ($VDIG_cidogwv > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_web_vars = $row[0]; + } + } + + ### update the comments in vicidial_live_agents record + $stmt = "UPDATE vicidial_live_agents set last_inbound_call_time='$NOW_TIME' where user='$user' and 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,'00504',$user,$server_ip,$session_name,$one_mysql_log);} + + $Ctype = 'I'; + } + else + { + $stmt = "SELECT campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,default_group_alias,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,timer_action_destination from vicidial_campaigns where campaign_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00505',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_ingroup_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + $VDCL_default_group_alias = $row[6]; + $VDCL_timer_action = $row[7]; + $VDCL_timer_action_message = $row[8]; + $VDCL_timer_action_seconds = $row[9]; + $VDCL_start_call_url = $row[10]; + $VDCL_dispo_call_url = $row[11]; + $VDCL_xferconf_c_number = $row[12]; + $VDCL_xferconf_d_number = $row[13]; + $VDCL_xferconf_e_number = $row[14]; + $VDCL_timer_action_destination = $row[15]; + } + + $stmt = "SELECT group_web_vars from vicidial_campaign_agents where campaign_id='$VDADchannel_group' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00506',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidogwv = mysql_num_rows($rslt); + if ($VDIG_cidogwv > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_web_vars = $row[0]; + } + } + + $VDCL_caller_id_number=''; + if (strlen($VDCL_default_group_alias)>1) + { + $stmt = "SELECT caller_id_number from groups_alias where group_alias_id='$VDCL_default_group_alias';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00507',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidnum_ct = mysql_num_rows($rslt); + if ($VDIG_cidnum_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_caller_id_number = $row[0]; + } + } + + ### Check for List ID override settings + if (strlen($list_id)>0) + { + $stmt = "SELECT xferconf_a_number,xferconf_b_number,xferconf_c_number,xferconf_d_number,xferconf_e_number,web_form_address,web_form_address_two from vicidial_lists where list_id='$list_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00508',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidOR_ct = mysql_num_rows($rslt); + if ($VDIG_cidOR_ct > 0) + { + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 0) + {$VDCL_xferconf_a_number = $row[0];} + if (strlen($row[1]) > 0) + {$VDCL_xferconf_b_number = $row[1];} + if (strlen($row[2]) > 0) + {$VDCL_xferconf_c_number = $row[2];} + if (strlen($row[3]) > 0) + {$VDCL_xferconf_d_number = $row[3];} + if (strlen($row[4]) > 0) + {$VDCL_xferconf_e_number = $row[4];} + if (strlen($row[5]) > 5) + {$VDCL_group_web = $row[5];} + if (strlen($row[6]) > 5) + {$VDCL_group_web_two = $row[6];} + } + } + + $DID_id=''; + $DID_extension=''; + $DID_pattern=''; + $DID_description=''; + + $stmt = "SELECT did_id,extension from vicidial_did_log where uniqueid='$uniqueid' order by call_date desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00509',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIDL_ct = mysql_num_rows($rslt); + if ($VDIDL_ct > 0) + { + $row=mysql_fetch_row($rslt); + $DID_id = $row[0]; + $DID_extension = $row[1]; + + $stmt = "SELECT did_pattern,did_description from vicidial_inbound_dids where did_id='$DID_id' limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00510',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIDL_ct = mysql_num_rows($rslt); + if ($VDIDL_ct > 0) + { + $row=mysql_fetch_row($rslt); + $DID_pattern = $row[0]; + $DID_description = $row[1]; + } + } + + ### if web form is set then send on to vicidial.php for override of WEB_FORM address + if ( (strlen($VDCL_group_web)>5) or (strlen($VDCL_group_name)>0) ) {echo "$VDCL_group_web|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|$VDCL_default_xfer_group|$VDCL_ingroup_recording_override|$VDCL_ingroup_rec_filename|$VDCL_default_group_alias|$VDCL_caller_id_number|$VDCL_group_web_vars|$VDCL_group_web_two|$VDCL_timer_action|$VDCL_timer_action_message|$VDCL_timer_action_seconds|$VDCL_xferconf_c_number|$VDCL_xferconf_d_number|$VDCL_xferconf_e_number|$VDCL_uniqueid_status_display|$custom_call_id|$VDCL_uniqueid_status_prefix|$VDCL_timer_action_destination|$DID_id|$DID_extension|$DID_pattern|$DID_description|$INclosecallid|$INxfercallid|\n";} + else {echo "X|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|$VDCL_default_xfer_group|$VDCL_ingroup_recording_override|$VDCL_ingroup_rec_filename|$VDCL_default_group_alias|$VDCL_caller_id_number|$VDCL_group_web_vars|$VDCL_group_web_two|$VDCL_timer_action|$VDCL_timer_action_message|$VDCL_timer_action_seconds|$VDCL_xferconf_c_number|$VDCL_xferconf_d_number|$VDCL_xferconf_e_number|$VDCL_uniqueid_status_display|$custom_call_id|$VDCL_uniqueid_status_prefix|$VDCL_timer_action_destination|$DID_id|$DID_extension|$DID_pattern|$DID_description|$INclosecallid|$INxfercallid|\n";} + + $stmt = "SELECT full_name from vicidial_users where user='$tsr';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00511',$user,$server_ip,$session_name,$one_mysql_log);} + $VDU_cid_ct = mysql_num_rows($rslt); + if ($VDU_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $fronter_full_name = $row[0]; + echo $fronter_full_name . '|' . $tsr . "\n"; + } + else {echo '|' . $tsr . "\n";} + + $custom_field_names='|'; + $custom_field_names_SQL=''; + $custom_field_values='----------'; + $custom_field_types='|'; + ### find the names of all custom fields, if any + $stmt = "SELECT field_label,field_type FROM vicidial_lists_fields where list_id='$entry_list_id' and field_type NOT IN('SCRIPT','DISPLAY') and field_label NOT IN('vendor_lead_code','source_id','list_id','gmt_offset_now','called_since_last_reset','phone_code','phone_number','title','first_name','middle_initial','last_name','address1','address2','address3','city','state','province','postal_code','country_code','gender','date_of_birth','alt_phone','email','security_phrase','comments','called_count','last_local_call_time','rank','owner');"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00512',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cffn_ct = mysql_num_rows($rslt); + $d=0; + while ($cffn_ct > $d) + { + $row=mysql_fetch_row($rslt); + $custom_field_names .= "$row[0]|"; + $custom_field_names_SQL .= "$row[0],"; + $custom_field_types .= "$row[1]|"; + $custom_field_values .= "----------"; + $d++; + } + if ($cffn_ct > 0) + { + $custom_field_names_SQL = eregi_replace(".$","",$custom_field_names_SQL); + ### find the values of the named custom fields + $stmt = "SELECT $custom_field_names_SQL FROM custom_$entry_list_id where lead_id='$lead_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00513',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cffv_ct = mysql_num_rows($rslt); + if ($cffv_ct > 0) + { + $custom_field_values='----------'; + $row=mysql_fetch_row($rslt); + $d=0; + while ($cffn_ct > $d) + { + $custom_field_values .= "$row[$d]----------"; + $d++; + } + $custom_field_values = preg_replace("/\n/"," ",$custom_field_values); + $custom_field_values = preg_replace("/\r/","",$custom_field_values); + } + } + + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $callerid . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + $LeaD_InfO .= $CBentry_time . "\n"; + $LeaD_InfO .= $CBcallback_time . "\n"; + $LeaD_InfO .= $CBuser . "\n"; + $LeaD_InfO .= $CBcomments . "\n"; + $LeaD_InfO .= $dialed_number . "\n"; + $LeaD_InfO .= $dialed_label . "\n"; + $LeaD_InfO .= $source_id . "\n"; + $LeaD_InfO .= $alt_phone_code . "\n"; + $LeaD_InfO .= $alt_phone_number . "\n"; + $LeaD_InfO .= $alt_phone_note . "\n"; + $LeaD_InfO .= $alt_phone_active . "\n"; + $LeaD_InfO .= $alt_phone_count . "\n"; + $LeaD_InfO .= $rank . "\n"; + $LeaD_InfO .= $owner . "\n"; + $LeaD_InfO .= $script_recording_delay . "\n"; + $LeaD_InfO .= $entry_list_id . "\n"; + $LeaD_InfO .= $custom_field_names . "\n"; + $LeaD_InfO .= $custom_field_values . "\n"; + $LeaD_InfO .= $custom_field_types . "\n"; + + echo $LeaD_InfO; + + + + $wait_sec=0; + $StarTtime = date("U"); + $stmt = "SELECT wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00514',$user,$server_ip,$session_name,$one_mysql_log);} + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00515',$user,$server_ip,$session_name,$one_mysql_log);} + + ### If a scheduled callback, change vicidial_callback record to INACTIVE + $CBstatus = 0; + + $stmt="SELECT count(*) FROM vicidial_statuses where status='$dispo' and scheduled_callback='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00516',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBstatus = $row[0]; + } + if ($CBstatus < 1) + { + $stmt="SELECT count(*) FROM vicidial_campaign_statuses where status='$dispo' and scheduled_callback='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00517',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBstatus = $row[0]; + } + } + if ( ($CBstatus > 0) or (eregi("CALLBK|CBHOLD", $dispo)) ) + { + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' and status NOT IN('INACTIVE','DEAD','ARCHIVE');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00518',$user,$server_ip,$session_name,$one_mysql_log);} + } + + ##### check if system is set to generate logfile for transfers + $stmt="SELECT enable_agc_xfer_log FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00519',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $enable_agc_xfer_log_ct = mysql_num_rows($rslt); + if ($enable_agc_xfer_log_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_agc_xfer_log =$row[0]; + } + + if ( ($WeBRooTWritablE > 0) and ($enable_agc_xfer_log > 0) ) + { + # DATETIME|campaign|lead_id|phone_number|user|type + # 2007-08-22 11:11:11|TESTCAMP|65432|3125551212|1234|A + $fp = fopen ("./xfer_log.txt", "a"); + fwrite ($fp, "$NOW_TIME|$campaign|$lead_id|$phone_number|$user|$Ctype|$callerid|$uniqueid|$province\n"); + fclose($fp); + } + + ### Issue Start Call URL if defined + if (strlen($VDCL_start_call_url) > 7) + { + if (eregi('--A--user_custom_',$VDCL_start_call_url)) + { + $stmt = "SELECT custom_one,custom_two,custom_three,custom_four,custom_five from vicidial_users where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00520',$user,$server_ip,$session_name,$one_mysql_log);} + $VUC_ct = mysql_num_rows($rslt); + if ($VUC_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_custom_one = urlencode(trim($row[0])); + $user_custom_two = urlencode(trim($row[1])); + $user_custom_three = urlencode(trim($row[2])); + $user_custom_four = urlencode(trim($row[3])); + $user_custom_five = urlencode(trim($row[4])); + } + } + $VDCL_start_call_url = preg_replace('/^VAR/','',$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--lead_id--B--',urlencode(trim($lead_id)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--vendor_id--B--',urlencode(trim($vendor_id)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--vendor_lead_code--B--',urlencode(trim($vendor_id)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--list_id--B--',urlencode(trim($list_id)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--gmt_offset_now--B--',urlencode(trim($gmt_offset_now)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--phone_code--B--',urlencode(trim($phone_code)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--phone_number--B--',urlencode(trim($phone_number)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--title--B--',urlencode(trim($title)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--first_name--B--',urlencode(trim($first_name)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--middle_initial--B--',urlencode(trim($middle_initial)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--last_name--B--',urlencode(trim($last_name)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--address1--B--',urlencode(trim($address1)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--address2--B--',urlencode(trim($address2)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--address3--B--',urlencode(trim($address3)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--city--B--',urlencode(trim($city)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--state--B--',urlencode(trim($state)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--province--B--',urlencode(trim($province)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--postal_code--B--',urlencode(trim($postal_code)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--country_code--B--',urlencode(trim($country_code)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--gender--B--',urlencode(trim($gender)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--date_of_birth--B--',urlencode(trim($date_of_birth)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--alt_phone--B--',urlencode(trim($alt_phone)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--email--B--',urlencode(trim($email)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--security_phrase--B--',urlencode(trim($security_phrase)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--comments--B--',urlencode(trim($comments)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--user--B--',urlencode(trim($user)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--pass--B--',urlencode(trim($pass)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--campaign--B--',urlencode(trim($campaign)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--phone_login--B--',urlencode(trim($phone_login)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--original_phone_login--B--',urlencode(trim($original_phone_login)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--phone_pass--B--',urlencode(trim($phone_pass)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--fronter--B--',urlencode(trim($fronter)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--closer--B--',urlencode(trim($closer)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--group--B--',urlencode(trim($VDADchannel_group)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--channel_group--B--',urlencode(trim($VDADchannel_group)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--SQLdate--B--',urlencode(trim($SQLdate)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--epoch--B--',urlencode(trim($epoch)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--uniqueid--B--',urlencode(trim($uniqueid)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--customer_zap_channel--B--',urlencode(trim($customer_zap_channel)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--customer_server_ip--B--',urlencode(trim($customer_server_ip)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--server_ip--B--',urlencode(trim($server_ip)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--SIPexten--B--',urlencode(trim($SIPexten)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--session_id--B--',urlencode(trim($session_id)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--phone--B--',urlencode(trim($phone)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--parked_by--B--',urlencode(trim($parked_by)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--dispo--B--',urlencode(trim($dispo)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--dialed_number--B--',urlencode(trim($dialed_number)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--dialed_label--B--',urlencode(trim($dialed_label)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--source_id--B--',urlencode(trim($source_id)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--rank--B--',urlencode(trim($rank)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--owner--B--',urlencode(trim($owner)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--camp_script--B--',urlencode(trim($camp_script)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--in_script--B--',urlencode(trim($in_script)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--fullname--B--',urlencode(trim($fullname)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--user_custom_one--B--',urlencode(trim($user_custom_one)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--user_custom_two--B--',urlencode(trim($user_custom_two)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--user_custom_three--B--',urlencode(trim($user_custom_three)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--user_custom_four--B--',urlencode(trim($user_custom_four)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--user_custom_five--B--',urlencode(trim($user_custom_five)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--talk_time--B--',"0",$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--talk_time_min--B--',"0",$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--entry_list_id--B--',urlencode(trim($entry_list_id)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--did_id--B--',urlencode(trim($DID_id)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--did_extension--B--',urlencode(trim($DID_extension)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--did_pattern--B--',urlencode(trim($DID_pattern)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--did_description--B--',urlencode(trim($DID_description)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--closecallid--B--',urlencode(trim($INclosecallid)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--xfercallid--B--',urlencode(trim($INxfercallid)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--agent_log_id--B--',urlencode(trim($agent_log_id)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--call_id--B--',urlencode(trim($callerid)),$VDCL_start_call_url); + + if (strlen($custom_field_names)>2) + { + $custom_field_names = preg_replace("/^\||\|$/",'',$custom_field_names); + $custom_field_names = preg_replace("/\|/",",",$custom_field_names); + $custom_field_names_ARY = explode(',',$custom_field_names); + $custom_field_names_ct = count($custom_field_names_ARY); + $custom_field_names_SQL = $custom_field_names; + + ##### BEGIN grab the data from custom table for the lead_id + $stmt="SELECT $custom_field_names_SQL FROM custom_$entry_list_id where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00521',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + $o=0; + while ($custom_field_names_ct > $o) + { + $form_field_value = urlencode(trim("$row[$o]")); + $field_name_id = $custom_field_names_ARY[$o]; + $field_name_tag = "--A--" . $field_name_id . "--B--"; + $VDCL_start_call_url = eregi_replace("$field_name_tag","$form_field_value",$VDCL_start_call_url); + $o++; + } + } + } + + $stmt="UPDATE vicidial_log_extended set start_url_processed='Y' where uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00522',$user,$server_ip,$session_name,$one_mysql_log);} + $vle_update = mysql_affected_rows($link); + + ### insert a new url log entry + $SQL_log = "$VDCL_start_call_url"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + # $upd_stmt="update vicidial_email_list set message='URL: $SQL_log' where lead_id='$lead_id'"; + # $upd_rslt=mysql_query($upd_stmt, $link); + + $stmt = "INSERT INTO vicidial_url_log SET uniqueid='$uniqueid',url_date='$NOW_TIME',url_type='start',url='$SQL_log',url_response='';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00523',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + $url_id = mysql_insert_id($link); + + $URLstart_sec = date("U"); + + ### grab the call_start_url ### + if ($DB > 0) {echo "$VDCL_start_call_url
\n";} + $SCUfile = file("$VDCL_start_call_url"); + if ($DB > 0) {echo "$SCUfile[0]
\n";} + + ### update url log entry + $URLend_sec = date("U"); + $URLdiff_sec = ($URLend_sec - $URLstart_sec); + $SCUfile_contents = implode("", $SCUfile); + $SCUfile_contents = ereg_replace(';','',$SCUfile_contents); + $SCUfile_contents = addslashes($SCUfile_contents); + $stmt = "UPDATE vicidial_url_log SET response_sec='$URLdiff_sec',url_response='$SCUfile_contents' where url_log_id='$url_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00524',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + + ##### BEGIN special filtering and response for Vtiger account balance function ##### + # http://vtiger/vicidial/api.php?mode=callxfer&contactwsid=--A--vendor_lead_code--B--&minuteswarning=3 + $stmt = "SELECT enable_vtiger_integration FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00525',$user,$server_ip,$session_name,$one_mysql_log);} + $ss_conf_ct = mysql_num_rows($rslt); + if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration = $row[0]; + } + if ( ( ($enable_vtiger_integration > 0) and (ereg('callxfer',$VDCL_start_call_url)) and (ereg('contactwsid',$VDCL_start_call_url)) ) or (preg_match("/minuteswarning/",$VDCL_start_call_url)) ) + { + $SCUoutput=''; + foreach ($SCUfile as $SCUline) + {$SCUoutput .= "$SCUline";} + # {"result":true,"durationLimit":3071} + if ( (strlen($SCUoutput) > 4) or (preg_match("/minuteswarning/",$VDCL_start_call_url)) ) + { + $minuteswarning=3; # default to 3 + if (preg_match("/minuteswarning/",$VDCL_start_call_url)) + { + $minuteswarningARY = explode('minuteswarning=',$VDCL_start_call_url); + $minuteswarning = preg_replace('/&.*/','',$minuteswarningARY[1]); + } + ### add this to the Start Call URL for callcard calls to be logged "&minuteswarning=1&callcard=1" + if (preg_match("/callcard=/",$VDCL_start_call_url)) + { + $stmt="SELECT balance_minutes_start FROM callcard_log where uniqueid='$uniqueid' order by call_time desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00526',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $bms_ct = mysql_num_rows($rslt); + if ($bms_ct > 0) + { + $row=mysql_fetch_row($rslt); + $durationLimit = $row[0]; + + $stmt="UPDATE callcard_log set agent_time='$NOW_TIME',agent='$user' where uniqueid='$uniqueid' order by call_time desc LIMIT 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00527',$user,$server_ip,$session_name,$one_mysql_log);} + $ccl_update = mysql_affected_rows($link); + } + } + else + { + $SCUresponse = explode('durationLimit',$SCUoutput); + $durationLimit = preg_replace('/\D/','',$SCUresponse[1]); + } + if (strlen($durationLimit) < 1) {$durationLimit = 0;} + $durationLimitSECnext = ( ($minuteswarning + 0) * 60); + $durationLimitSEC = ( ( ($durationLimit + 0) - $minuteswarning) * 60); # minutes - 3 for 3-minute-warning + if ($durationLimitSEC < 5) {$durationLimitSEC = 5;} + if ( ($durationLimitSECnext < 30) or (strlen($durationLimitSECnext)<1) ) {$durationLimitSECnext = 30;} + + $timer_action_destination=''; + if (preg_match("/nextstep=/",$VDCL_start_call_url)) + { + $nextstepARY = explode('nextstep=',$VDCL_start_call_url); + $nextstep = preg_replace("/&.*/",'',$nextstepARY[1]); + $nextmessageARY = explode('nextmessage=',$VDCL_start_call_url); + $nextmessage = preg_replace("/&.*/",'',$nextmessageARY[1]); + $destinationARY = explode('destination=',$VDCL_start_call_url); + $destination = preg_replace("/&.*/",'',$destinationARY[1]); + $timer_action_destination = "nextstep---$nextstep--$durationLimitSECnext--$destination--$nextmessage--"; + } + + $stmt="UPDATE vicidial_live_agents set external_timer_action='D1_DIAL',external_timer_action_message='$minuteswarning minute warning for customer',external_timer_action_seconds='$durationLimitSEC',external_timer_action_destination='$timer_action_destination' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00528',$user,$server_ip,$session_name,$one_mysql_log);} + $vla_update_timer = mysql_affected_rows($link); + + $fp = fopen ("./call_url_log.txt", "a"); + fwrite ($fp, "$VDCL_start_call_url\n$SCUoutput\n$durationLimit|$durationLimitSEC|$vla_update_timer|$minuteswarning|$uniqueid|\n"); + fclose($fp); + } + } + ##### END special filtering and response for Vtiger account balance function ##### + } + } + else + { + echo "0\n"; + # echo "No calls in QUEUE for $user on $server_ip\n"; + exit; + } + } + } ################################################################################ ### LeaDSearcHSelecTUpdatE - for inbound lead search update select calls @@ -7047,6 +7989,15 @@ if ($ACTION == 'updateDISPO') //Added by Poundteam Incorporated for Audit Comments Package require_once('audit_comments.php'); audit_comments($lead_id,$list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log,$campaign); + + // JOEJ - Email feature - may not be necessary if vicidial_email_list doesn't need a status column. + if ($email_enabled>0) { + $stmt="UPDATE vicidial_email_list set status='$dispo_choice', user='$user' where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142',$user,$server_ip,$session_name,$one_mysql_log);} + } + # $fp = fopen ("./vicidial_debug.txt", "a"); # fwrite ($fp, "$NOW_TIME|DISPO_CALL |$MDnextCID|$stage|$campaign|$lead_id|$dispo_choice|$user|$uniqueid|$auto_dial_level|$agent_log_id|\n"); # fclose($fp); @@ -10731,6 +11682,54 @@ if ($ACTION == 'LEADINFOview') ### END Gather Call Log and notes ### + ### BEGIN Email log + $NOTESout .= "
EMAIL LOG FOR THIS LEAD:
\n"; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= "\n"; + + + $stmt="select email_log_id,email_row_id,lead_id,email_date,user,email_to,message,campaign_id,attachments from vicidial_email_log where lead_id='$lead_id' order by email_date desc limit 500;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + if (strlen($row[6])>400) {$row[6]=substr($row[6],0,400)."...";} + $row[8]=preg_replace('/\|/', ', ', $row[8]); + $row[8]=preg_replace('/,\s+$/', '', $row[8]); + $u++; + + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= ""; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= ""; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + $NOTESout .= "\n"; + } + + $NOTESout .= "
#   DATE/TIME   USER   CAMPAIGN   EMAIL TO   ATTACHMENTS
$u   $row[3]   $row[4]   $row[7]   $row[5]   $row[8]
  MESSAGE: $row[6]
"; + + ### END Email Log ## + if ($search == 'logfirst') {echo "$NOTESout\n$INFOout\n";} else diff --git a/agc_2-X/trunk/www/agc/vdc_email_display.php b/agc_2-X/trunk/www/agc/vdc_email_display.php new file mode 100644 index 00000000..9ba03a9d --- /dev/null +++ b/agc_2-X/trunk/www/agc/vdc_email_display.php @@ -0,0 +1,362 @@ + LICENSE: AGPLv2 +# +# This page displays any incoming emails in the Vicidial user interface. It +# also allows the user to download and view any attachments sent in the email, +# and also gives the user the ability to respond to the email and even +# attach files to it. The page also logs all email messages that are sent +# through it to the vicidial_email_log table +# +# changes: +# 121214-2300 - First Build +# + +require("dbconnect.php"); +require("functions.php"); + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["attachment_id"])) {$attachment_id=$_GET["attachment_id"];} + elseif (isset($_POST["attachment_id"])) {$attachment_id=$_POST["attachment_id"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["email_row_id"])) {$email_row_id=$_GET["email_row_id"];} + elseif (isset($_POST["email_row_id"])) {$email_row_id=$_POST["email_row_id"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["sender_email"])) {$sender_email=$_GET["sender_email"];} + elseif (isset($_POST["sender_email"])) {$sender_email=$_POST["sender_email"];} +if (isset($_GET["reply_subject"])) {$reply_subject=$_GET["reply_subject"];} + elseif (isset($_POST["reply_subject"])) {$reply_subject=$_POST["reply_subject"];} +if (isset($_GET["reply_to_address"])) {$reply_to_address=$_GET["reply_to_address"];} + elseif (isset($_POST["reply_to_address"])) {$reply_to_address=$_POST["reply_to_address"];} +if (isset($_GET["reply_from_address"])) {$reply_from_address=$_GET["reply_from_address"];} + elseif (isset($_POST["reply_from_address"])) {$reply_from_address=$_POST["reply_from_address"];} +if (isset($_GET["reply_message"])) {$reply_message=$_GET["reply_message"];} + elseif (isset($_POST["reply_message"])) {$reply_message=$_POST["reply_message"];} +if (isset($_GET["REPLY"])) {$REPLY=$_GET["REPLY"];} + elseif (isset($_POST["REPLY"])) {$REPLY=$_POST["REPLY"];} + +$attachment1=$_FILES["attachment1"]; + $A1_orig = $_FILES['attachment1']['name']; + $A1_path = $_FILES['attachment1']['tmp_name']; + $A1_type = $_FILES['attachment1']['type']; +$attachment2=$_FILES["attachment2"]; + $A2_orig = $_FILES['attachment2']['name']; + $A2_path = $_FILES['attachment2']['tmp_name']; + $A2_type = $_FILES['attachment2']['type']; +$attachment3=$_FILES["attachment3"]; + $A3_orig = $_FILES['attachment3']['name']; + $A3_path = $_FILES['attachment3']['tmp_name']; + $A3_type = $_FILES['attachment3']['type']; +$attachment4=$_FILES["attachment4"]; + $A4_orig = $_FILES['attachment4']['name']; + $A4_path = $_FILES['attachment4']['tmp_name']; + $A4_type = $_FILES['attachment4']['type']; +$attachment5=$_FILES["attachment5"]; + $A5_orig = $_FILES['attachment5']['name']; + $A5_path = $_FILES['attachment5']['tmp_name']; + $A5_type = $_FILES['attachment5']['type']; + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 + +if ($stage=='WELCOME') + {echo "EMAIL"; exit;} + +$txt = '.txt'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +$MT[0]=''; +$agents='@agents'; +$script_height = ($script_height - 20); +if (strlen($bgcolor) < 6) {$bgcolor='FFFFFF';} + +$IFRAME=0; + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock,custom_fields_enabled,allow_emails FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $timeclock_end_of_day = $row[1]; + $agentonly_callback_campaign_lock = $row[2]; + $custom_fields_enabled = $row[3]; + $allow_emails = $row[4]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ($allow_emails<1) + { + echo "Your system does not have the email setting enabled\n"; + exit; + } + +if ($non_latin < 1) + { + $user=ereg_replace("[^-_0-9a-zA-Z]","",$user); + $pass=ereg_replace("[^-_0-9a-zA-Z]","",$pass); + } +else + { + $user = ereg_replace("'|\"|\\\\|;","",$user); + $pass = ereg_replace("'|\"|\\\\|;","",$pass); + } + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + if ($format == 'debug') {$DB=1;} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +if ($DB) {echo "|$stmt|\n";} +if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and modify_leads='1';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$VUmodify=$row[0]; + +$stmt="SELECT count(*) from vicidial_live_agents where user='$user';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$LVAactive=$row[0]; +$LVAactive=9; +if ( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) or ( ($LVAactive < 1) ) ) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + exit; + } +else + { + # do nothing for now + } + +if ($REPLY) + { + $to = "$reply_to_address"; + $from = "$reply_from_address"; + $subject ="$reply_subject"; + $message = "$reply_message"; + $headers = "From: $from"; + $attachment_str=""; + + $semi_rand = md5(time()); + $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; + $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; + $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; + $message .= "--{$mime_boundary}\n"; + + for ($i=1; $i<=5; $i++) + { + $attachment_orig_name="A".$i."_orig"; + $attachment_path="A".$i."_path"; + $LF_orig=$$attachment_orig_name; + $LF_path=$$attachment_path; + #echo "

".$$attachment_name."
".$$attachment_orig_name."
".$$attachment_path."

"; + if ($LF_orig) + { + if (preg_match("/;|:|\/|\^|\[|\]|\"|\'|\*/",$LF_orig)) + { + echo "ERROR: Invalid File Name: $LF_orig\n"; + exit; + } + else + { + copy($LF_path, "/tmp/$LF_orig"); + $file = fopen("/tmp/$LF_orig","rb"); + $data = fread($file,filesize("/tmp/$LF_orig")); + fclose($file); + $data = chunk_split(base64_encode($data)); + $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$LF_orig\"\n" . + "Content-Disposition: attachment;\n" . " filename=\"$LF_orig\"\n" . + "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; + $message .= "--{$mime_boundary}\n"; + $attachment_str.="$LF_orig|"; + } + } + } + + $sendmail = @mail($to, $subject, $message, $headers); + if ($sendmail) + { + $reply_message=preg_replace('/(\"|\||\'|\;)/', '\\\$1', $reply_message); + $log_stmt="insert into vicidial_email_log(email_row_id, lead_id, email_date, user, email_to, message, campaign_id, attachments) VALUES('$email_row_id', '$lead_id', now(), '$user', '$reply_to_address', '$reply_message', '$campaign', '$attachment_str')"; + $log_rslt=mysql_query($log_stmt, $link); + echo "

mail sent to $to!

"; + } + else + { + echo "

mail could not be sent!

"; + } + exit; + } + + +if ($lead_id) { + $stmt="select * from vicidial_email_list where lead_id='$lead_id' and direction='INBOUND' and status IN('NEW','INCALL') order by email_date asc"; + $rslt=mysql_query($stmt, $link); + if (mysql_num_rows($rslt)>0) { + $row=mysql_fetch_array($rslt); + $email_row_id=$row["email_row_id"]; + preg_match('/\<[^\>\@]+\@[^\>\@]+\>/', $row["email_from"], $matches); + if (strlen($matches[0])>0) { + $email_from = substr($matches[0],1,-1); + } else { + $email_from = $row["email_from"]; + } + preg_match('/\<[^\>\@]+\@[^\>\@]+\>/', $row["email_to"], $matches); + if (strlen($matches[0])>0) { + $row["email_from"]=preg_replace('/\>/', '>', $row["email_from"]); + $row["email_from"]=preg_replace('/\/', '\>', $row["email_to"]); + $email_to = $row["email_to"]; + } + $EMAIL_form="
\n"; + $EMAIL_form.="\n"; + $EMAIL_form.="\n"; + $EMAIL_form.="\n"; + $EMAIL_form.="\n"; + + $att_stmt="select * from inbound_email_attachments where email_row_id='$email_row_id'"; + $att_rslt=mysql_query($att_stmt, $link); + if (mysql_num_rows($att_rslt)>0) { + $EMAIL_form.=""; + } + $EMAIL_form.=""; + $EMAIL_form.="\n"; + $EMAIL_form.="\n"; + $EMAIL_form.="\n"; + $EMAIL_form.=""; + $EMAIL_form.="
Date received:$row[email_date]
From:$row[email_from]
Subject:$row[subject]
Message:
$row[message]
Attachments:
";
+			while($att_row=mysql_fetch_array($att_rslt)) {
+				$EMAIL_form.="
  • $att_row[filename]\n"; + } + $EMAIL_form.="

  • Response:RE: $row[subject]
    Reply:

    Attachments:"; + $EMAIL_form.="
    "; + $EMAIL_form.="
    "; + $EMAIL_form.="
    "; + $EMAIL_form.="
    "; + $EMAIL_form.=""; + $EMAIL_form.="
    \n"; + $EMAIL_form.="\n"; + $EMAIL_form.="\n"; + $EMAIL_form.="\n"; + $EMAIL_form.="\n"; + $EMAIL_form.="\n"; + $EMAIL_form.="\n"; + $EMAIL_form.="\n"; + } + + if ($attachment_id) { + $stmt="select * from inbound_email_attachments where attachment_id='$attachment_id'"; + $rslt=mysql_query($stmt, $link); + if (mysql_num_rows($rslt)>0) { + $row=mysql_fetch_array($rslt); + $filename=$row["filename"]; + $encoding=$row["file_encoding"]; + $file_size=$row["file_size"]; + $file_type=$row["file_type"]; + $file_contents=$row["file_contents"]; + if ($encoding=="base64") { + $file_contents=base64_decode($file_contents); + $file_size=strlen($file_contents); + } + header("Content-length: ".$file_size.""); + header("Content-type: ".$file_type.""); + header('Content-Disposition: attachment; filename="'.$filename.'"'); + echo $file_contents; + } + } else { +?> + + + VICIDIAL email frame + + + + +
    ' method='get' name="email_display_form" id="email_display_form" onSubmit="if (this.submitted) return false; this.submitted=true" enctype="multipart/form-data"> + +
    + + + diff --git a/agc_2-X/trunk/www/agc/vicidial.php b/agc_2-X/trunk/www/agc/vicidial.php index e481862c..3746aa40 100644 --- a/agc_2-X/trunk/www/agc/vicidial.php +++ b/agc_2-X/trunk/www/agc/vicidial.php @@ -392,10 +392,10 @@ # 121129-2149 - Corrected hotkeys activation conditions # 121130-0734 - Fixed call notes amphersand issue #612 # 121206-0634 - Added inbound lead search feature -# +# 121222-2315 - Added inbound email features -$version = '2.6-360c'; -$build = '121206-0634'; +$version = '2.6-361c'; +$build = '121222-2315'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=79; $one_mysql_log=0; @@ -480,7 +480,7 @@ $random = (rand(1000000, 9999999) + 10000000); ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### -$stmt = "SELECT use_non_latin,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,webroot_writable,timeclock_end_of_day,vtiger_url,enable_vtiger_integration,outbound_autodial_active,enable_second_webform,user_territories_active,static_agent_url,custom_fields_enabled,pllb_grouping_limit,qc_features_active FROM system_settings;"; +$stmt = "SELECT use_non_latin,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,webroot_writable,timeclock_end_of_day,vtiger_url,enable_vtiger_integration,outbound_autodial_active,enable_second_webform,user_territories_active,static_agent_url,custom_fields_enabled,pllb_grouping_limit,qc_features_active,email_enabled FROM system_settings;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01001',$VD_login,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -503,6 +503,7 @@ if ($qm_conf_ct > 0) $custom_fields_enabled = $row[12]; $SSpllb_grouping_limit = $row[13]; $qc_enabled = $row[14]; + $email_enabled = $row[15]; } ##### END SETTINGS LOOKUP ##### ########################################### @@ -1765,23 +1766,46 @@ else ##### grab the inbound groups to choose from if campaign contains CLOSER $VARingroups="''"; + $VARingroup_handlers="''"; + $VARphonegroups="''"; + $VARemailgroups="''"; if ( ($campaign_allow_inbound == 'Y') and ($dial_method != 'MANUAL') ) { $VARingroups=''; - $stmt="select group_id from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 800;"; + $VARingroup_handlers=''; + $VARphonegroups=''; + $VARemailgroups=''; + $stmt="select group_id,group_handling from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 800;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01015',$VD_login,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $closer_ct = mysql_num_rows($rslt); $INgrpCT=0; + $EMAILgrpCT=0; + $PHONEgrpCT=0; while ($INgrpCT < $closer_ct) { $row=mysql_fetch_row($rslt); $closer_groups[$INgrpCT] =$row[0]; + $closer_group_handling[$INgrpCT] =$row[1]; // PHONE OR EMAIL - this is important $VARingroups = "$VARingroups'$closer_groups[$INgrpCT]',"; + $VARingroup_handlers = "$VARingroup_handlers'$closer_group_handling[$INgrpCT]',"; + if ($row[1]=="EMAIL") // Make a list of ingroups for email handling groups and one for phones, so there is no overlap + { + $VARemailgroups = "$VARemailgroups'$closer_groups[$INgrpCT]',"; + $EMAILgrpCT++; + } + else + { + $VARphonegroups = "$VARphonegroups'$closer_groups[$INgrpCT]',"; + $PHONEgrpCT++; + } $INgrpCT++; } $VARingroups = substr("$VARingroups", 0, -1); + $VARingroup_handlers = substr("$VARingroup_handlers", 0, -1); + $VARphonegroups = substr("$VARphonegroups", 0, -1); + $VARemailgroups = substr("$VARemailgroups", 0, -1); } else {$closer_campaigns = "''";} @@ -3199,6 +3223,19 @@ $CCAL_OUT .= ""; var VARSELstatuses_ct = ''; VARingroups = new Array(); var INgroupCOUNT = ''; + + VARemailgroups = new Array(); + // var EMAILgroupCOUNT = ''; + var EMAILgroupCOUNT = 0; + var incomingEMAILgroups= new Array(); + + VARphonegroups = new Array(); + // var PHONEgroupCOUNT = ''; + var PHONEgroupCOUNT = 0; + + var VARingroup_handlers = new Array(); + var QUEUEpadding=0; + VARdialingroups = new Array(); var dialINgroupCOUNT = ''; VARterritories = new Array(); @@ -3471,6 +3508,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var APIDiaL_ID = '99999'; var CheckDEADcall = 0; var CheckDEADcallON = 0; + var currently_in_email = 0; var VtigeRLogiNScripT = ''; var VtigeRurl = ''; var VtigeREnableD = ''; @@ -3570,6 +3608,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var API_selected_callmenu=''; var custom_fields_enabled=''; var form_contents_loaded=0; + var email_enabled=''; var enable_xfer_presets=''; var hide_xfer_number_to_dial=''; var Presets_HTML=''; @@ -5114,358 +5153,450 @@ function set_length(SLnumber,SLlength_goal,SLdirection) if (taskvar == 'XfeRLOCAL') {consultativexfer_checked = 0;} - // conf_dialed=1; - if (auto_dial_level == 0) {RedirecTxFEr = 1;} - var xmlhttpXF=false; - /*@cc_on @*/ - /*@if (@_jscript_version >= 5) - // JScript gives us Conditional compilation, we can cope with old IE versions. - // and security blocked creation of the objects. - try { - xmlhttpXF = new ActiveXObject("Msxml2.XMLHTTP"); - } catch (e) { - try { - xmlhttpXF = new ActiveXObject("Microsoft.XMLHTTP"); - } catch (E) { - xmlhttpXF = false; - } - } - @end @*/ - if (!xmlhttpXF && typeof XMLHttpRequest!='undefined') - { - xmlhttpXF = new XMLHttpRequest(); - } - if (xmlhttpXF) + if (taskxferconf=='EMAIL') // If it's an EMAIL you're transferring, it will work differently from a call, BIG TIME. So a new function was made. { - var redirectvalue = MDchannel; - var redirectserverip = lastcustserverip; - if (redirectvalue.length < 2) - {redirectvalue = lastcustchannel} - if ( (taskvar == 'XfeRBLIND') || (taskvar == 'XfeRVMAIL') ) + var email_row_id=taskserverip; // Change variable name to what it actually is; too confusing otherwise + transfer_email(taskvar, document.vicidial_form.lead_id.value, document.vicidial_form.uniqueid.value, email_row_id); + } + else + { + // conf_dialed=1; + if (auto_dial_level == 0) {RedirecTxFEr = 1;} + var xmlhttpXF=false; + /*@cc_on @*/ + /*@if (@_jscript_version >= 5) + // JScript gives us Conditional compilation, we can cope with old IE versions. + // and security blocked creation of the objects. + try { + xmlhttpXF = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + xmlhttpXF = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (E) { + xmlhttpXF = false; + } + } + @end @*/ + if (!xmlhttpXF && typeof XMLHttpRequest!='undefined') { - if (tasklockedquick > 0) - {document.vicidial_form.xfernumber.value = quick_transfer_button_orig;} - var queryCID = "XBvdcW" + epoch_sec + user_abb; - var blindxferdialstring = document.vicidial_form.xfernumber.value; - var blindxferhiddendialstring = document.vicidial_form.xfernumhidden.value; - if ( (blindxferdialstring.length < 1) && (blindxferhiddendialstring.length > 0) ) - {blindxferdialstring=blindxferhiddendialstring;} - var regXFvars = new RegExp("XFER","g"); - if (blindxferdialstring.match(regXFvars)) + xmlhttpXF = new XMLHttpRequest(); + } + if (xmlhttpXF) + { + var redirectvalue = MDchannel; + var redirectserverip = lastcustserverip; + if (redirectvalue.length < 2) + {redirectvalue = lastcustchannel} + if ( (taskvar == 'XfeRBLIND') || (taskvar == 'XfeRVMAIL') ) { - var regAXFvars = new RegExp("AXFER","g"); - if (blindxferdialstring.match(regAXFvars)) + if (tasklockedquick > 0) + {document.vicidial_form.xfernumber.value = quick_transfer_button_orig;} + var queryCID = "XBvdcW" + epoch_sec + user_abb; + var blindxferdialstring = document.vicidial_form.xfernumber.value; + var blindxferhiddendialstring = document.vicidial_form.xfernumhidden.value; + if ( (blindxferdialstring.length < 1) && (blindxferhiddendialstring.length > 0) ) + {blindxferdialstring=blindxferhiddendialstring;} + var regXFvars = new RegExp("XFER","g"); + if (blindxferdialstring.match(regXFvars)) { - var Ctasknum = blindxferdialstring.replace(regAXFvars, ''); - if (Ctasknum.length < 2) - {Ctasknum = '83009';} - var closerxfercamptail = '_L'; - if (closerxfercamptail.length < 3) - {closerxfercamptail = 'IVR';} - blindxferdialstring = Ctasknum + '*' + document.vicidial_form.phone_number.value + '*' + document.vicidial_form.lead_id.value + '*' + campaign + '*' + closerxfercamptail + '*' + user + '**' + VD_live_call_secondS + '*'; + var regAXFvars = new RegExp("AXFER","g"); + if (blindxferdialstring.match(regAXFvars)) + { + var Ctasknum = blindxferdialstring.replace(regAXFvars, ''); + if (Ctasknum.length < 2) + {Ctasknum = '83009';} + var closerxfercamptail = '_L'; + if (closerxfercamptail.length < 3) + {closerxfercamptail = 'IVR';} + blindxferdialstring = Ctasknum + '*' + document.vicidial_form.phone_number.value + '*' + document.vicidial_form.lead_id.value + '*' + campaign + '*' + closerxfercamptail + '*' + user + '**' + VD_live_call_secondS + '*'; + } } - } - else - { - if (document.vicidial_form.xferoverride.checked==false) + else { - if (three_way_dial_prefix == 'X') {var temp_dial_prefix = '';} - else {var temp_dial_prefix = three_way_dial_prefix;} - if (omit_phone_code == 'Y') {var temp_phone_code = '';} - else {var temp_phone_code = document.vicidial_form.phone_code.value;} + if (document.vicidial_form.xferoverride.checked==false) + { + if (three_way_dial_prefix == 'X') {var temp_dial_prefix = '';} + else {var temp_dial_prefix = three_way_dial_prefix;} + if (omit_phone_code == 'Y') {var temp_phone_code = '';} + else {var temp_phone_code = document.vicidial_form.phone_code.value;} - if (blindxferdialstring.length > 7) - {blindxferdialstring = temp_dial_prefix + "" + temp_phone_code + "" + blindxferdialstring;} + if (blindxferdialstring.length > 7) + {blindxferdialstring = temp_dial_prefix + "" + temp_phone_code + "" + blindxferdialstring;} + } + } + if (API_selected_callmenu.length > 0) + { + var blindxferdialstring = 's'; + var blindxfercontext = document.vicidial_form.xfernumber.value; + } + else + {var blindxfercontext = ext_context;} + no_delete_VDAC=0; + if (taskvar == 'XfeRVMAIL') + { + var blindxferdialstring = campaign_am_message_exten + '*' + campaign + '*' + document.vicidial_form.phone_code.value + '*' + document.vicidial_form.phone_number.value + '*' + document.vicidial_form.lead_id.value; + no_delete_VDAC=1; + } + if (blindxferdialstring.length<'1') + { + xferredirect_query=''; + taskvar = 'NOTHING'; + alert_box("Transfer number must have at least 1 digit:" + blindxferdialstring); + } + else + { + xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectVD&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&exten=" + blindxferdialstring + "&ext_context=" + blindxfercontext + "&ext_priority=1&auto_dial_level=" + auto_dial_level + "&campaign=" + campaign + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&lead_id=" + document.vicidial_form.lead_id.value + "&secondS=" + VD_live_call_secondS + "&session_id=" + session_id + "&nodeletevdac=" + no_delete_VDAC + "&preset_name=" + document.vicidial_form.xfername.value; } } - if (API_selected_callmenu.length > 0) + if (taskvar == 'XfeRINTERNAL') { - var blindxferdialstring = 's'; - var blindxfercontext = document.vicidial_form.xfernumber.value; + var closerxferinternal = ''; + taskvar = 'XfeRLOCAL'; } - else - {var blindxfercontext = ext_context;} - no_delete_VDAC=0; - if (taskvar == 'XfeRVMAIL') + else { - var blindxferdialstring = campaign_am_message_exten + '*' + campaign + '*' + document.vicidial_form.phone_code.value + '*' + document.vicidial_form.phone_number.value + '*' + document.vicidial_form.lead_id.value; - no_delete_VDAC=1; + var closerxferinternal = '9'; } - if (blindxferdialstring.length<'1') + if (taskvar == 'XfeRLOCAL') + { + if (consult_custom_sent < 1) + {CustomerData_update();} + + document.vicidial_form.xfername.value=''; + var XfeRSelecT = document.getElementById("XfeRGrouP"); + var XfeR_GrouP = XfeRSelecT.value; + if (API_selected_xfergroup.length > 1) + {var XfeR_GrouP = API_selected_xfergroup;} + if (tasklockedquick > 0) + {XfeR_GrouP = quick_transfer_button_orig;} + var queryCID = "XLvdcW" + epoch_sec + user_abb; + // "90009*$group**$lead_id**$phone_number*$user*$agent_only*"; + var redirectdestination = closerxferinternal + '90009*' + XfeR_GrouP + '**' + document.vicidial_form.lead_id.value + '**' + dialed_number + '*' + user + '*' + document.vicidial_form.xfernumber.value + '*'; + + + xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectVD&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&exten=" + redirectdestination + "&ext_context=" + ext_context + "&ext_priority=1&auto_dial_level=" + auto_dial_level + "&campaign=" + campaign + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&lead_id=" + document.vicidial_form.lead_id.value + "&secondS=" + VD_live_call_secondS + "&session_id=" + session_id; + } + if (taskvar == 'XfeR') + { + var queryCID = "LRvdcW" + epoch_sec + user_abb; + var redirectdestination = document.vicidial_form.extension_xfer.value; + xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectName&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&extenName=" + redirectdestination + "&ext_context=" + ext_context + "&ext_priority=1" + "&session_id=" + session_id; + } + if (taskvar == 'VMAIL') + { + var queryCID = "LVvdcW" + epoch_sec + user_abb; + var redirectdestination = document.vicidial_form.extension_xfer.value; + xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectNameVmail&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&exten=" + voicemail_dump_exten + "&extenName=" + redirectdestination + "&ext_context=" + ext_context + "&ext_priority=1" + "&session_id=" + session_id; + } + if (taskvar == 'ENTRY') + { + var queryCID = "LEvdcW" + epoch_sec + user_abb; + var redirectdestination = document.vicidial_form.extension_xfer_entry.value; + xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=Redirect&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&exten=" + redirectdestination + "&ext_context=" + ext_context + "&ext_priority=1" + "&session_id=" + session_id; + } + if (taskvar == '3WAY') { xferredirect_query=''; - taskvar = 'NOTHING'; - alert_box("Transfer number must have at least 1 digit:" + blindxferdialstring); - } - else - { - xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectVD&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&exten=" + blindxferdialstring + "&ext_context=" + blindxfercontext + "&ext_priority=1&auto_dial_level=" + auto_dial_level + "&campaign=" + campaign + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&lead_id=" + document.vicidial_form.lead_id.value + "&secondS=" + VD_live_call_secondS + "&session_id=" + session_id + "&nodeletevdac=" + no_delete_VDAC + "&preset_name=" + document.vicidial_form.xfername.value; - } - } - if (taskvar == 'XfeRINTERNAL') - { - var closerxferinternal = ''; - taskvar = 'XfeRLOCAL'; - } - else - { - var closerxferinternal = '9'; - } - if (taskvar == 'XfeRLOCAL') - { - if (consult_custom_sent < 1) - {CustomerData_update();} - document.vicidial_form.xfername.value=''; - var XfeRSelecT = document.getElementById("XfeRGrouP"); - var XfeR_GrouP = XfeRSelecT.value; - if (API_selected_xfergroup.length > 1) - {var XfeR_GrouP = API_selected_xfergroup;} - if (tasklockedquick > 0) - {XfeR_GrouP = quick_transfer_button_orig;} - var queryCID = "XLvdcW" + epoch_sec + user_abb; - // "90009*$group**$lead_id**$phone_number*$user*$agent_only*"; - var redirectdestination = closerxferinternal + '90009*' + XfeR_GrouP + '**' + document.vicidial_form.lead_id.value + '**' + dialed_number + '*' + user + '*' + document.vicidial_form.xfernumber.value + '*'; - - - xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectVD&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&exten=" + redirectdestination + "&ext_context=" + ext_context + "&ext_priority=1&auto_dial_level=" + auto_dial_level + "&campaign=" + campaign + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&lead_id=" + document.vicidial_form.lead_id.value + "&secondS=" + VD_live_call_secondS + "&session_id=" + session_id; - } - if (taskvar == 'XfeR') - { - var queryCID = "LRvdcW" + epoch_sec + user_abb; - var redirectdestination = document.vicidial_form.extension_xfer.value; - xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectName&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&extenName=" + redirectdestination + "&ext_context=" + ext_context + "&ext_priority=1" + "&session_id=" + session_id; - } - if (taskvar == 'VMAIL') - { - var queryCID = "LVvdcW" + epoch_sec + user_abb; - var redirectdestination = document.vicidial_form.extension_xfer.value; - xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectNameVmail&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&exten=" + voicemail_dump_exten + "&extenName=" + redirectdestination + "&ext_context=" + ext_context + "&ext_priority=1" + "&session_id=" + session_id; - } - if (taskvar == 'ENTRY') - { - var queryCID = "LEvdcW" + epoch_sec + user_abb; - var redirectdestination = document.vicidial_form.extension_xfer_entry.value; - xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=Redirect&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&exten=" + redirectdestination + "&ext_context=" + ext_context + "&ext_priority=1" + "&session_id=" + session_id; - } - if (taskvar == '3WAY') - { - xferredirect_query=''; - - var queryCID = "VXvdcW" + epoch_sec + user_abb; - var redirectdestination = "NEXTAVAILABLE"; - var redirectXTRAvalue = XDchannel; - var redirecttype_test = document.vicidial_form.xfernumber.value; - var XfeRSelecT = document.getElementById("XfeRGrouP"); - var XfeR_GrouP = XfeRSelecT.value; - if (API_selected_xfergroup.length > 1) - {var XfeR_GrouP = API_selected_xfergroup;} - var regRXFvars = new RegExp("CXFER","g"); - if ( ( (redirecttype_test.match(regRXFvars)) || (consultativexfer_checked > 0) ) && (local_consult_xfers > 0) ) - {var redirecttype = 'RedirectXtraCXNeW';} - else - {var redirecttype = 'RedirectXtraNeW';} - DispO3waychannel = redirectvalue; - DispO3wayXtrAchannel = redirectXTRAvalue; - DispO3wayCalLserverip = redirectserverip; - DispO3wayCalLxfernumber = document.vicidial_form.xfernumber.value; - DispO3wayCalLcamptail = ''; - - xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=" + redirecttype + "&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&exten=" + redirectdestination + "&ext_context=" + ext_context + "&ext_priority=1&extrachannel=" + redirectXTRAvalue + "&lead_id=" + document.vicidial_form.lead_id.value + "&phone_code=" + document.vicidial_form.phone_code.value + "&phone_number=" + document.vicidial_form.phone_number.value + "&filename=" + taskdebugnote + "&campaign=" + XfeR_GrouP + "&session_id=" + session_id + "&agentchannel=" + agentchannel + "&protocol=" + protocol + "&extension=" + extension + "&auto_dial_level=" + auto_dial_level; - - if (taskdebugnote == 'FIRST') - { - document.getElementById("DispoSelectHAspan").innerHTML = "Leave 3Way Call Again"; - } - } - if (taskvar == 'ParK') - { - if (CalLCID.length < 1) - { - CalLCID = MDnextCID; - } - blind_transfer=0; - var queryCID = "LPvdcW" + epoch_sec + user_abb; - var redirectdestination = taskxferconf; - var redirectdestserverip = taskserverip; - var parkedby = protocol + "/" + extension; - xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectToPark&format=text&channel=" + redirectdestination + "&call_server_ip=" + redirectdestserverip + "&queryCID=" + queryCID + "&exten=" + park_on_extension + "&ext_context=" + ext_context + "&ext_priority=1&extenName=park&parkedby=" + parkedby + "&session_id=" + session_id + "&CalLCID=" + CalLCID + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign; - - document.getElementById("ParkControl").innerHTML ="\"Grab"; - if ( (ivr_park_call=='ENABLED') || (ivr_park_call=='ENABLED_PARK_ONLY') ) - { - document.getElementById("ivrParkControl").innerHTML ="\"Grab"; - } - customerparked=1; - customerparkedcounter=0; - } - if (taskvar == 'FROMParK') - { - blind_transfer=0; - var queryCID = "FPvdcW" + epoch_sec + user_abb; - var redirectdestination = taskxferconf; - var redirectdestserverip = taskserverip; - - if( (server_ip == taskserverip) && (taskserverip.length > 6) ) - {var dest_dialstring = session_id;} - else - { - if(taskserverip.length > 6) - {var dest_dialstring = server_ip_dialstring + "" + session_id;} + var queryCID = "VXvdcW" + epoch_sec + user_abb; + var redirectdestination = "NEXTAVAILABLE"; + var redirectXTRAvalue = XDchannel; + var redirecttype_test = document.vicidial_form.xfernumber.value; + var XfeRSelecT = document.getElementById("XfeRGrouP"); + var XfeR_GrouP = XfeRSelecT.value; + if (API_selected_xfergroup.length > 1) + {var XfeR_GrouP = API_selected_xfergroup;} + var regRXFvars = new RegExp("CXFER","g"); + if ( ( (redirecttype_test.match(regRXFvars)) || (consultativexfer_checked > 0) ) && (local_consult_xfers > 0) ) + {var redirecttype = 'RedirectXtraCXNeW';} else - {var dest_dialstring = session_id;} - } + {var redirecttype = 'RedirectXtraNeW';} + DispO3waychannel = redirectvalue; + DispO3wayXtrAchannel = redirectXTRAvalue; + DispO3wayCalLserverip = redirectserverip; + DispO3wayCalLxfernumber = document.vicidial_form.xfernumber.value; + DispO3wayCalLcamptail = ''; - xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectFromPark&format=text&channel=" + redirectdestination + "&call_server_ip=" + redirectdestserverip + "&queryCID=" + queryCID + "&exten=" + dest_dialstring + "&ext_context=" + ext_context + "&ext_priority=1" + "&session_id=" + session_id + "&CalLCID=" + CalLCID + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign; + xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=" + redirecttype + "&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&exten=" + redirectdestination + "&ext_context=" + ext_context + "&ext_priority=1&extrachannel=" + redirectXTRAvalue + "&lead_id=" + document.vicidial_form.lead_id.value + "&phone_code=" + document.vicidial_form.phone_code.value + "&phone_number=" + document.vicidial_form.phone_number.value + "&filename=" + taskdebugnote + "&campaign=" + XfeR_GrouP + "&session_id=" + session_id + "&agentchannel=" + agentchannel + "&protocol=" + protocol + "&extension=" + extension + "&auto_dial_level=" + auto_dial_level; - document.getElementById("ParkControl").innerHTML ="\"Park"; - if ( (ivr_park_call=='ENABLED') || (ivr_park_call=='ENABLED_PARK_ONLY') ) - { - document.getElementById("ivrParkControl").innerHTML ="\"IVR"; - } - customerparked=0; - customerparkedcounter=0; - } - if (taskvar == 'ParKivr') - { - if (CalLCID.length < 1) - { - CalLCID = MDnextCID; - } - blind_transfer=0; - var queryCID = "LPvdcW" + epoch_sec + user_abb; - var redirectdestination = taskxferconf; - var redirectdestserverip = taskserverip; - var parkedby = protocol + "/" + extension; - xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectToParkIVR&format=text&channel=" + redirectdestination + "&call_server_ip=" + redirectdestserverip + "&queryCID=" + queryCID + "&exten=" + park_on_extension + "&ext_context=" + ext_context + "&ext_priority=1&extenName=park&parkedby=" + parkedby + "&session_id=" + session_id + "&CalLCID=" + CalLCID + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign; - - document.getElementById("ParkControl").innerHTML ="\"Grab"; - if (ivr_park_call=='ENABLED_PARK_ONLY') - { - document.getElementById("ivrParkControl").innerHTML ="\"Grab"; - } - if (ivr_park_call=='ENABLED') - { - document.getElementById("ivrParkControl").innerHTML ="\"Grab"; - } - customerparked=1; - customerparkedcounter=0; - } - if (taskvar == 'FROMParKivr') - { - blind_transfer=0; - var queryCID = "FPvdcW" + epoch_sec + user_abb; - var redirectdestination = taskxferconf; - var redirectdestserverip = taskserverip; - - if( (server_ip == taskserverip) && (taskserverip.length > 6) ) - {var dest_dialstring = session_id;} - else - { - if(taskserverip.length > 6) - {var dest_dialstring = server_ip_dialstring + "" + session_id;} - else - {var dest_dialstring = session_id;} - } - - xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectFromParkIVR&format=text&channel=" + redirectdestination + "&call_server_ip=" + redirectdestserverip + "&queryCID=" + queryCID + "&exten=" + dest_dialstring + "&ext_context=" + ext_context + "&ext_priority=1" + "&session_id=" + session_id + "&CalLCID=" + CalLCID + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign; - - document.getElementById("ParkControl").innerHTML ="\"Park"; - if ( (ivr_park_call=='ENABLED') || (ivr_park_call=='ENABLED_PARK_ONLY') ) - { - document.getElementById("ivrParkControl").innerHTML ="\"IVR"; - } - customerparked=0; - customerparkedcounter=0; - } - - var XFRDop = ''; - xmlhttpXF.open('POST', 'manager_send.php'); - xmlhttpXF.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); - xmlhttpXF.send(xferredirect_query); - xmlhttpXF.onreadystatechange = function() - { - if (xmlhttpXF.readyState == 4 && xmlhttpXF.status == 200) - { - var XfeRRedirecToutput = null; - XfeRRedirecToutput = xmlhttpXF.responseText; - var XfeRRedirecToutput_array=XfeRRedirecToutput.split("|"); - var XFRDop = XfeRRedirecToutput_array[0]; - if (XFRDop == "NeWSessioN") + if (taskdebugnote == 'FIRST') { - threeway_end=1; - document.getElementById("callchannel").innerHTML = ''; - document.vicidial_form.callserverip.value = ''; - dialedcall_send_hangup(); - - document.vicidial_form.xferchannel.value = ''; - xfercall_send_hangup(); - - session_id = XfeRRedirecToutput_array[1]; - document.getElementById("sessionIDspan").innerHTML = session_id; - - // alert("session_id changed to: " + session_id); + document.getElementById("DispoSelectHAspan").innerHTML = "Leave 3Way Call Again"; } - // alert(xferredirect_query + "\n" + xmlhttpXF.responseText); - // document.getElementById("debugbottomspan").innerHTML = xferredirect_query + "\n" + xmlhttpXF.responseText; + } + if (taskvar == 'ParK') + { + if (CalLCID.length < 1) + { + CalLCID = MDnextCID; + } + blind_transfer=0; + var queryCID = "LPvdcW" + epoch_sec + user_abb; + var redirectdestination = taskxferconf; + var redirectdestserverip = taskserverip; + var parkedby = protocol + "/" + extension; + xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectToPark&format=text&channel=" + redirectdestination + "&call_server_ip=" + redirectdestserverip + "&queryCID=" + queryCID + "&exten=" + park_on_extension + "&ext_context=" + ext_context + "&ext_priority=1&extenName=park&parkedby=" + parkedby + "&session_id=" + session_id + "&CalLCID=" + CalLCID + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign; + + document.getElementById("ParkControl").innerHTML ="\"Grab"; + if ( (ivr_park_call=='ENABLED') || (ivr_park_call=='ENABLED_PARK_ONLY') ) + { + document.getElementById("ivrParkControl").innerHTML ="\"Grab"; + } + customerparked=1; + customerparkedcounter=0; + } + if (taskvar == 'FROMParK') + { + blind_transfer=0; + var queryCID = "FPvdcW" + epoch_sec + user_abb; + var redirectdestination = taskxferconf; + var redirectdestserverip = taskserverip; + + if( (server_ip == taskserverip) && (taskserverip.length > 6) ) + {var dest_dialstring = session_id;} + else + { + if(taskserverip.length > 6) + {var dest_dialstring = server_ip_dialstring + "" + session_id;} + else + {var dest_dialstring = session_id;} + } + + xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectFromPark&format=text&channel=" + redirectdestination + "&call_server_ip=" + redirectdestserverip + "&queryCID=" + queryCID + "&exten=" + dest_dialstring + "&ext_context=" + ext_context + "&ext_priority=1" + "&session_id=" + session_id + "&CalLCID=" + CalLCID + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign; + + document.getElementById("ParkControl").innerHTML ="\"Park"; + if ( (ivr_park_call=='ENABLED') || (ivr_park_call=='ENABLED_PARK_ONLY') ) + { + document.getElementById("ivrParkControl").innerHTML ="\"IVR"; + } + customerparked=0; + customerparkedcounter=0; + } + if (taskvar == 'ParKivr') + { + if (CalLCID.length < 1) + { + CalLCID = MDnextCID; + } + blind_transfer=0; + var queryCID = "LPvdcW" + epoch_sec + user_abb; + var redirectdestination = taskxferconf; + var redirectdestserverip = taskserverip; + var parkedby = protocol + "/" + extension; + xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectToParkIVR&format=text&channel=" + redirectdestination + "&call_server_ip=" + redirectdestserverip + "&queryCID=" + queryCID + "&exten=" + park_on_extension + "&ext_context=" + ext_context + "&ext_priority=1&extenName=park&parkedby=" + parkedby + "&session_id=" + session_id + "&CalLCID=" + CalLCID + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign; + + document.getElementById("ParkControl").innerHTML ="\"Grab"; + if (ivr_park_call=='ENABLED_PARK_ONLY') + { + document.getElementById("ivrParkControl").innerHTML ="\"Grab"; + } + if (ivr_park_call=='ENABLED') + { + document.getElementById("ivrParkControl").innerHTML ="\"Grab"; + } + customerparked=1; + customerparkedcounter=0; + } + if (taskvar == 'FROMParKivr') + { + blind_transfer=0; + var queryCID = "FPvdcW" + epoch_sec + user_abb; + var redirectdestination = taskxferconf; + var redirectdestserverip = taskserverip; + + if( (server_ip == taskserverip) && (taskserverip.length > 6) ) + {var dest_dialstring = session_id;} + else + { + if(taskserverip.length > 6) + {var dest_dialstring = server_ip_dialstring + "" + session_id;} + else + {var dest_dialstring = session_id;} + } + + xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=RedirectFromParkIVR&format=text&channel=" + redirectdestination + "&call_server_ip=" + redirectdestserverip + "&queryCID=" + queryCID + "&exten=" + dest_dialstring + "&ext_context=" + ext_context + "&ext_priority=1" + "&session_id=" + session_id + "&CalLCID=" + CalLCID + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign; + + document.getElementById("ParkControl").innerHTML ="\"Park"; + if ( (ivr_park_call=='ENABLED') || (ivr_park_call=='ENABLED_PARK_ONLY') ) + { + document.getElementById("ivrParkControl").innerHTML ="\"IVR"; + } + customerparked=0; + customerparkedcounter=0; + } + + var XFRDop = ''; + xmlhttpXF.open('POST', 'manager_send.php'); + xmlhttpXF.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); + xmlhttpXF.send(xferredirect_query); + xmlhttpXF.onreadystatechange = function() + { + if (xmlhttpXF.readyState == 4 && xmlhttpXF.status == 200) + { + var XfeRRedirecToutput = null; + XfeRRedirecToutput = xmlhttpXF.responseText; + var XfeRRedirecToutput_array=XfeRRedirecToutput.split("|"); + var XFRDop = XfeRRedirecToutput_array[0]; + if (XFRDop == "NeWSessioN") + { + threeway_end=1; + document.getElementById("callchannel").innerHTML = ''; + document.vicidial_form.callserverip.value = ''; + dialedcall_send_hangup(); + + document.vicidial_form.xferchannel.value = ''; + xfercall_send_hangup(); + + session_id = XfeRRedirecToutput_array[1]; + document.getElementById("sessionIDspan").innerHTML = session_id; + + // alert("session_id changed to: " + session_id); + } + // alert(xferredirect_query + "\n" + xmlhttpXF.responseText); + // document.getElementById("debugbottomspan").innerHTML = xferredirect_query + "\n" + xmlhttpXF.responseText; + } + } + delete xmlhttpXF; + } + + // used to send second Redirect for manual dial calls + if ( (auto_dial_level == 0) && (taskvar != '3WAY') ) + { + RedirecTxFEr = 1; + var xmlhttpXF2=false; + /*@cc_on @*/ + /*@if (@_jscript_version >= 5) + // JScript gives us Conditional compilation, we can cope with old IE versions. + // and security blocked creation of the objects. + try { + xmlhttpXF2 = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + xmlhttpXF2 = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (E) { + xmlhttpXF2 = false; + } + } + @end @*/ + if (!xmlhttpXF2 && typeof XMLHttpRequest!='undefined') + { + xmlhttpXF2 = new XMLHttpRequest(); + } + if (xmlhttpXF2) + { + xmlhttpXF2.open('POST', 'manager_send.php'); + xmlhttpXF2.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); + xmlhttpXF2.send(xferredirect_query + "&stage=2NDXfeR"); + xmlhttpXF2.onreadystatechange = function() + { + if (xmlhttpXF2.readyState == 4 && xmlhttpXF2.status == 200) + { + Nactiveext = null; + Nactiveext = xmlhttpXF2.responseText; + // alert(RedirecTxFEr + "|" + xmlhttpXF2.responseText); + } + } + delete xmlhttpXF2; } } - delete xmlhttpXF; - } - // used to send second Redirect for manual dial calls - if ( (auto_dial_level == 0) && (taskvar != '3WAY') ) - { - RedirecTxFEr = 1; - var xmlhttpXF2=false; - /*@cc_on @*/ - /*@if (@_jscript_version >= 5) - // JScript gives us Conditional compilation, we can cope with old IE versions. - // and security blocked creation of the objects. - try { - xmlhttpXF2 = new ActiveXObject("Msxml2.XMLHTTP"); - } catch (e) { - try { - xmlhttpXF2 = new ActiveXObject("Microsoft.XMLHTTP"); - } catch (E) { - xmlhttpXF2 = false; - } - } - @end @*/ - if (!xmlhttpXF2 && typeof XMLHttpRequest!='undefined') + if ( (taskvar == 'XfeRLOCAL') || (taskvar == 'XfeRBLIND') || (taskvar == 'XfeRVMAIL') ) { - xmlhttpXF2 = new XMLHttpRequest(); + if (auto_dial_level == 0) {RedirecTxFEr = 1;} + document.getElementById("callchannel").innerHTML = ''; + document.vicidial_form.callserverip.value = ''; + if( document.images ) { document.images['livecall'].src = image_livecall_OFF.src;} + // alert(RedirecTxFEr + "|" + auto_dial_level); + dialedcall_send_hangup(taskdispowindow,'','',no_delete_VDAC); } - if (xmlhttpXF2) - { - xmlhttpXF2.open('POST', 'manager_send.php'); - xmlhttpXF2.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); - xmlhttpXF2.send(xferredirect_query + "&stage=2NDXfeR"); - xmlhttpXF2.onreadystatechange = function() - { - if (xmlhttpXF2.readyState == 4 && xmlhttpXF2.status == 200) - { - Nactiveext = null; - Nactiveext = xmlhttpXF2.responseText; - // alert(RedirecTxFEr + "|" + xmlhttpXF2.responseText); - } - } - delete xmlhttpXF2; - } - } - - if ( (taskvar == 'XfeRLOCAL') || (taskvar == 'XfeRBLIND') || (taskvar == 'XfeRVMAIL') ) - { - if (auto_dial_level == 0) {RedirecTxFEr = 1;} - document.getElementById("callchannel").innerHTML = ''; - document.vicidial_form.callserverip.value = ''; - if( document.images ) { document.images['livecall'].src = image_livecall_OFF.src;} - // alert(RedirecTxFEr + "|" + auto_dial_level); - dialedcall_send_hangup(taskdispowindow,'','',no_delete_VDAC); - } + } // END ELSE FOR EMAIL CHECK } } +// ################################################################################ +// Transfer an email to an in-group for another rep. +// Currently this behaves as a blind transfer no matter which button you press, but saving the taskvar variable just in case + function transfer_email(EMAILtaskvar, EMAILlead_id, EMAILuniqueid, email_row_id) { + + var xmlhttpXF=false; + /*@cc_on @*/ + /*@if (@_jscript_version >= 5) + // JScript gives us Conditional compilation, we can cope with old IE versions. + // and security blocked creation of the objects. + try { + xmlhttpXF = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + xmlhttpXF = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (E) { + xmlhttpXF = false; + } + } + @end @*/ + if (!xmlhttpXF && typeof XMLHttpRequest!='undefined') + { + xmlhttpXF = new XMLHttpRequest(); + } + if (xmlhttpXF) + { + var redirectvalue = MDchannel; + var redirectserverip = lastcustserverip; + var queryCID=''; + var exten=''; + var ext_context=''; + var redirectXTRAvalue=''; + var redirectdestination=''; + var taskdebugnote=''; + if (redirectvalue.length < 2) + {redirectvalue = lastcustchannel} + var XFRDop = ''; + var XfeRSelecT = document.getElementById("XfeRGrouP"); + var XfeR_GrouP = XfeRSelecT.value; + if (API_selected_xfergroup.length > 1) + {var XfeR_GrouP = API_selected_xfergroup;} + // + "&queryCID=" + queryCID + "&exten=" + redirectdestination + "&ext_context=" + ext_context + xferemail_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=XFERemail&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&exten=" + redirectdestination + "&ext_context=" + ext_context + "&ext_priority=1&extrachannel=" + redirectXTRAvalue + "&lead_id=" + document.vicidial_form.lead_id.value + "&phone_code=" + document.vicidial_form.phone_code.value + "&phone_number=" + document.vicidial_form.phone_number.value + "&filename=" + taskdebugnote + "&campaign=" + XfeR_GrouP + "&session_id=" + session_id + "&agentchannel=" + agentchannel + "&protocol=" + protocol + "&extension=" + extension + "&auto_dial_level=" + auto_dial_level + "&list_id=" + document.vicidial_form.list_id.value + "&email_row_id=" + email_row_id; + //alert(xferemail_query); + + xmlhttpXF.open('POST', 'vdc_db_query.php'); + xmlhttpXF.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); + xmlhttpXF.send(xferemail_query); + xmlhttpXF.onreadystatechange = function() + { + if (xmlhttpXF.readyState == 4 && xmlhttpXF.status == 200) + { + var XfeRRedirecToutput = null; + XfeRRedirecToutput = xmlhttpXF.responseText; + // alert(XfeRRedirecToutput); + var XfeRRedirecToutput_array=XfeRRedirecToutput.split("|"); + var XFRDop = XfeRRedirecToutput_array[0]; + if (XFRDop == 1) + { + threeway_end=1; + document.getElementById("callchannel").innerHTML = ''; + document.vicidial_form.callserverip.value = ''; + dialedcall_send_hangup(); // Put this in the transfer_email function + + //* document.vicidial_form.xferchannel.value = ''; + //* xfercall_send_hangup(); + + //* session_id = XfeRRedirecToutput_array[1]; + //* document.getElementById("sessionIDspan").innerHTML = session_id; + + // alert("session_id changed to: " + session_id); + } + else + { + // + } + // alert(xferredirect_query + "\n" + xmlhttpXF.responseText); + // document.getElementById("debugbottomspan").innerHTML = xferredirect_query + "\n" + xmlhttpXF.responseText; + } + } + delete xmlhttpXF; + } + } + // ################################################################################ // Finish the alternate dialing and move on to disposition the call function ManualDialAltDonE() @@ -6958,6 +7089,11 @@ function set_length(SLnumber,SLlength_goal,SLdirection) if (fields_list.match(regUDformreload)) {FormContentsLoad();} + // JOEJ 082812 - new for email feature + var regUDemailreload = new RegExp("emailreload,","ig"); + if (fields_list.match(regUDemailreload)) + {EmailContentsLoad();} + var regWFAcustom = new RegExp("^VAR","ig"); if (VDIC_web_form_address.match(regWFAcustom)) { @@ -7350,6 +7486,12 @@ function set_length(SLnumber,SLlength_goal,SLdirection) { FormContentsLoad(); } + // JOEJ 082812 - new for email feature + // Will populate email tab in case this is a customer with an email record AND that the user selected a campaign that handles emails instead of phones + if (email_enabled > 0 && EMAILgroupCOUNT > 0) + { + EmailContentsLoad(); + } if (get_call_launch == 'SCRIPT') { if (delayed_script_load == 'YES') @@ -7364,6 +7506,10 @@ function set_length(SLnumber,SLlength_goal,SLdirection) FormPanelToFront(); } + if (get_call_launch == 'EMAIL') + { + EmailPanelToFront(); + } if (get_call_launch == 'WEBFORM') { @@ -7711,6 +7857,12 @@ function set_length(SLnumber,SLlength_goal,SLdirection) { FormContentsLoad(); } + // JOEJ 082812 - new for email feature + // Will populate email tab in case this is a customer with an email record + if (email_enabled > 0) + { + EmailContentsLoad(); + } if (get_call_launch == 'SCRIPT') { if (delayed_script_load == 'YES') @@ -7723,6 +7875,10 @@ function set_length(SLnumber,SLlength_goal,SLdirection) { FormPanelToFront(); } + if (get_call_launch == 'EMAIL') + { + EmailPanelToFront(); + } if (get_call_launch == 'WEBFORM') { window.open(TEMP_VDIC_web_form_address, web_form_target, 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=640,height=450'); @@ -8046,6 +8202,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) { // alert(xmlhttprequestcheckauto.responseText); AutoDialWaiting = 0; + QUEUEpadding = 0; var VDIC_data_VDAC=check_VDIC_array[1].split("|"); VDIC_web_form_address = VICIDiaL_web_form_address @@ -8478,6 +8635,11 @@ function set_length(SLnumber,SLlength_goal,SLdirection) { FormContentsLoad(); } + // JOEJ 082812 - new for email feature + if (email_enabled > 0) + { + EmailContentsLoad(); + } if (CalL_AutO_LauncH == 'SCRIPT') { if (delayed_script_load == 'YES') @@ -8490,6 +8652,10 @@ function set_length(SLnumber,SLlength_goal,SLdirection) { FormPanelToFront(); } + if (CalL_AutO_LauncH == 'EMAIL') + { + EmailPanelToFront(); + } if (CalL_AutO_LauncH == 'WEBFORM') { @@ -8521,9 +8687,16 @@ function set_length(SLnumber,SLlength_goal,SLdirection) alert(" Incoming: " + dial_display_number + "\n Group- " + VDIC_data_VDIG[1] + "   " + VDIC_fronter); } } - else + else if (email_enabled>0 && EMAILgroupCOUNT>0 && AutoDialWaiting==1) { - // do nothing + // JOEJ check for EMAIL + // QUEUEpadding is needed to allow inbound calls to get through QUEUE status + QUEUEpadding++; + if (QUEUEpadding==5) + { + QUEUEpadding=0; + check_for_incoming_email(); + } } xmlhttprequestcheckauto = undefined; delete xmlhttprequestcheckauto; @@ -8534,6 +8707,532 @@ function set_length(SLnumber,SLlength_goal,SLdirection) } +// ################################################################################ +// Check to see if there is an email unanswered in queue +// This should not happen if the agent is INCALL + function check_for_incoming_email() + { + if (typeof(xmlhttprequestcheckemail) == "undefined") + { + all_record = 'NO'; + all_record_count=0; + var xmlhttprequestcheckemail=false; + if (!xmlhttprequestcheckemail && typeof XMLHttpRequest!='undefined') + { + xmlhttprequestcheckemail = new XMLHttpRequest(); + } + if (xmlhttprequestcheckemail) + { + + checkVDAI_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&campaign=" + campaign + "&ACTION=VDADcheckINCOMINGemail" + "&agent_log_id=" + agent_log_id; + + // Add on all the email groups the user selected in order to pass them to the vdc_db_query script + for (var i = 0; i < incomingEMAILgroups.length; i++) { + checkVDAI_query+="&inbound_email_groups[]="+incomingEMAILgroups[i]; + } + + xmlhttprequestcheckemail.open('POST', 'vdc_db_query.php'); + xmlhttprequestcheckemail.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); + xmlhttprequestcheckemail.send(checkVDAI_query); + + xmlhttprequestcheckemail.onreadystatechange = function() + { + if (xmlhttprequestcheckemail.readyState == 4 && xmlhttprequestcheckemail.status == 200) + { + var check_incoming = null; + check_incoming = xmlhttprequestcheckemail.responseText; + // alert(checkVDAI_query); + //alert(xmlhttprequestcheckemail.responseText); + var check_VDIC_array=check_incoming.split("\n"); + if (check_VDIC_array[0] == '1') + { + // alert(xmlhttprequestcheckemail.responseText); + AutoDialWaiting = 0; + + var VDIC_data_VDAC=check_VDIC_array[1].split("|"); + VDIC_web_form_address = VICIDiaL_web_form_address + VDIC_web_form_address_two = VICIDiaL_web_form_address_two + var VDIC_fronter=''; + + var VDIC_data_VDIG=check_VDIC_array[2].split("|"); + if (VDIC_data_VDIG[0].length > 5) + {VDIC_web_form_address = VDIC_data_VDIG[0];} + var VDCL_group_name = VDIC_data_VDIG[1]; + var VDCL_group_color = VDIC_data_VDIG[2]; + var VDCL_fronter_display = VDIC_data_VDIG[3]; + VDCL_group_id = VDIC_data_VDIG[4]; + CalL_ScripT_id = VDIC_data_VDIG[5]; + CalL_AutO_LauncH = 'EMAIL'; // FORCE EMAIL tab + CalL_XC_a_Dtmf = VDIC_data_VDIG[7]; + CalL_XC_a_NuMber = VDIC_data_VDIG[8]; + CalL_XC_b_Dtmf = VDIC_data_VDIG[9]; + CalL_XC_b_NuMber = VDIC_data_VDIG[10]; + if ( (VDIC_data_VDIG[11].length > 1) && (VDIC_data_VDIG[11] != '---NONE---') ) + {LIVE_default_xfer_group = VDIC_data_VDIG[11];} + else + {LIVE_default_xfer_group = default_xfer_group;} + + if ( (VDIC_data_VDIG[12].length > 1) && (VDIC_data_VDIG[12]!='DISABLED') ) + {LIVE_campaign_recording = VDIC_data_VDIG[12];} + else + {LIVE_campaign_recording = campaign_recording;} + + if ( (VDIC_data_VDIG[13].length > 1) && (VDIC_data_VDIG[13]!='NONE') ) + {LIVE_campaign_rec_filename = VDIC_data_VDIG[13];} + else + {LIVE_campaign_rec_filename = campaign_rec_filename;} + + if ( (VDIC_data_VDIG[14].length > 1) && (VDIC_data_VDIG[14]!='NONE') ) + {LIVE_default_group_alias = VDIC_data_VDIG[14];} + else + {LIVE_default_group_alias = default_group_alias;} + + if ( (VDIC_data_VDIG[15].length > 1) && (VDIC_data_VDIG[15]!='NONE') ) + {LIVE_caller_id_number = VDIC_data_VDIG[15];} + else + {LIVE_caller_id_number = default_group_alias_cid;} + + if (VDIC_data_VDIG[16].length > 0) + {LIVE_web_vars = VDIC_data_VDIG[16];} + else + {LIVE_web_vars = default_web_vars;} + + if (VDIC_data_VDIG[17].length > 5) + {VDIC_web_form_address_two = VDIC_data_VDIG[17];} + + var call_timer_action = VDIC_data_VDIG[18]; + + if ( (call_timer_action == 'NONE') || (call_timer_action.length < 2) ) + { + timer_action = campaign_timer_action; + timer_action_message = campaign_timer_action_message; + timer_action_seconds = campaign_timer_action_seconds; + timer_action_destination = campaign_timer_action_destination; + } + else + { + var call_timer_action_message = VDIC_data_VDIG[19]; + var call_timer_action_seconds = VDIC_data_VDIG[20]; + var call_timer_action_destination = VDIC_data_VDIG[27]; + timer_action = call_timer_action; + timer_action_message = call_timer_action_message; + timer_action_seconds = call_timer_action_seconds; + timer_action_destination = call_timer_action_destination; + } + + CalL_XC_c_NuMber = VDIC_data_VDIG[21]; + CalL_XC_d_NuMber = VDIC_data_VDIG[22]; + CalL_XC_e_NuMber = VDIC_data_VDIG[23]; + CalL_XC_e_NuMber = VDIC_data_VDIG[23]; + uniqueid_status_display = VDIC_data_VDIG[24]; + uniqueid_status_prefix = VDIC_data_VDIG[26]; + did_id = VDIC_data_VDIG[28]; + did_extension = VDIC_data_VDIG[29]; + did_pattern = VDIC_data_VDIG[30]; + did_description = VDIC_data_VDIG[31]; + closecallid = VDIC_data_VDIG[32]; + xfercallid = VDIC_data_VDIG[33]; + + var VDIC_data_VDFR=check_VDIC_array[3].split("|"); + if ( (VDIC_data_VDFR[1].length > 1) && (VDCL_fronter_display == 'Y') ) + {VDIC_fronter = " Fronter: " + VDIC_data_VDFR[0] + " - " + VDIC_data_VDFR[1];} + + document.vicidial_form.lead_id.value = VDIC_data_VDAC[0]; + document.vicidial_form.uniqueid.value = VDIC_data_VDAC[1]; + CIDcheck = VDIC_data_VDAC[2]; + CalLCID = VDIC_data_VDAC[2]; + LastCallCID = VDIC_data_VDAC[2]; + document.getElementById("callchannel").innerHTML = VDIC_data_VDAC[3]; + lastcustchannel = VDIC_data_VDAC[3]; + document.vicidial_form.callserverip.value = VDIC_data_VDAC[4]; + lastcustserverip = VDIC_data_VDAC[4]; + if( document.images ) { document.images['livecall'].src = image_livecall_ON.src;} + document.vicidial_form.SecondS.value = 0; + document.getElementById("SecondSDISP").innerHTML = '0'; + + if (uniqueid_status_display=='ENABLED') + {custom_call_id = " Call ID " + VDIC_data_VDAC[1];} + if (uniqueid_status_display=='ENABLED_PREFIX') + {custom_call_id = " Call ID " + uniqueid_status_prefix + "" + VDIC_data_VDAC[1];} + if (uniqueid_status_display=='ENABLED_PRESERVE') + {custom_call_id = " Call ID " + VDIC_data_VDIG[25];} + + VD_live_customer_call = 1; + VD_live_call_secondS = 0; + CheckDEADcallON = 1; // Do this to keep the interface from instantly reading an email as a hangup + currently_in_email = 1; // Do this to block channel checks (or anything else) that would indicate a completed call + + // INSERT VICIDIAL_LOG ENTRY FOR THIS CALL PROCESS + // DialLog("start"); + + custchannellive=1; + + LasTCID = check_VDIC_array[4]; + LeaDPreVDispO = check_VDIC_array[6]; + fronter = check_VDIC_array[7]; + document.vicidial_form.vendor_lead_code.value = check_VDIC_array[8]; + document.vicidial_form.list_id.value = check_VDIC_array[9]; + document.vicidial_form.gmt_offset_now.value = check_VDIC_array[10]; + document.vicidial_form.phone_code.value = check_VDIC_array[11]; + if ( (disable_alter_custphone=='Y') || (disable_alter_custphone=='HIDE') ) + { + var tmp_pn = document.getElementById("phone_numberDISP"); + if (disable_alter_custphone=='Y') + { + tmp_pn.innerHTML = check_VDIC_array[12]; + } + } + document.vicidial_form.phone_number.value = check_VDIC_array[12]; + document.vicidial_form.title.value = check_VDIC_array[13]; + document.vicidial_form.first_name.value = check_VDIC_array[14]; + document.vicidial_form.middle_initial.value = check_VDIC_array[15]; + document.vicidial_form.last_name.value = check_VDIC_array[16]; + document.vicidial_form.address1.value = check_VDIC_array[17]; + document.vicidial_form.address2.value = check_VDIC_array[18]; + document.vicidial_form.address3.value = check_VDIC_array[19]; + document.vicidial_form.city.value = check_VDIC_array[20]; + document.vicidial_form.state.value = check_VDIC_array[21]; + document.vicidial_form.province.value = check_VDIC_array[22]; + document.vicidial_form.postal_code.value = check_VDIC_array[23]; + document.vicidial_form.country_code.value = check_VDIC_array[24]; + document.vicidial_form.gender.value = check_VDIC_array[25]; + document.vicidial_form.date_of_birth.value = check_VDIC_array[26]; + document.vicidial_form.alt_phone.value = check_VDIC_array[27]; + document.vicidial_form.email.value = check_VDIC_array[28]; + document.vicidial_form.security_phrase.value = check_VDIC_array[29]; + var REGcommentsNL = new RegExp("!N","g"); + check_VDIC_array[30] = check_VDIC_array[30].replace(REGcommentsNL, "\n"); + document.vicidial_form.comments.value = check_VDIC_array[30]; + document.vicidial_form.called_count.value = check_VDIC_array[31]; + CBentry_time = check_VDIC_array[32]; + CBcallback_time = check_VDIC_array[33]; + CBuser = check_VDIC_array[34]; + CBcomments = check_VDIC_array[35]; + dialed_number = check_VDIC_array[36]; + dialed_label = check_VDIC_array[37]; + source_id = check_VDIC_array[38]; + EAphone_code = check_VDIC_array[39]; + EAphone_number = check_VDIC_array[40]; + EAalt_phone_notes = check_VDIC_array[41]; + EAalt_phone_active = check_VDIC_array[42]; + EAalt_phone_count = check_VDIC_array[43]; + document.vicidial_form.rank.value = check_VDIC_array[44]; + document.vicidial_form.owner.value = check_VDIC_array[45]; + script_recording_delay = check_VDIC_array[46]; + document.vicidial_form.entry_list_id.value = check_VDIC_array[47]; + custom_field_names = check_VDIC_array[48]; + custom_field_values = check_VDIC_array[49]; + custom_field_types = check_VDIC_array[50]; + + + if (hide_gender > 0) + { + document.vicidial_form.gender_list.value = check_VDIC_array[25]; + } + else + { + var gIndex = 0; + if (document.vicidial_form.gender.value == 'M') {var gIndex = 1;} + if (document.vicidial_form.gender.value == 'F') {var gIndex = 2;} + document.getElementById("gender_list").selectedIndex = gIndex; + } + + lead_dial_number = document.vicidial_form.phone_number.value; + var dispnum = document.vicidial_form.phone_number.value; + var status_display_number = phone_number_format(dispnum); + var callnum = dialed_number; + var dial_display_number = phone_number_format(callnum); + + var status_display_content=''; + if (status_display_CALLID > 0) {status_display_content = status_display_content + " UID: " + LasTCID;} + if (status_display_LEADID > 0) {status_display_content = status_display_content + " Lead: " + document.vicidial_form.lead_id.value;} + if (status_display_LISTID > 0) {status_display_content = status_display_content + " List: " + document.vicidial_form.list_id.value;} + + document.getElementById("MainStatuSSpan").innerHTML = " Incoming: " + dial_display_number + " " + custom_call_id + " " + status_display_content + "   " + VDIC_fronter; + + if (CBentry_time.length > 2) + { + document.getElementById("CusTInfOSpaN").innerHTML = " PREVIOUS CALLBACK "; + document.getElementById("CusTInfOSpaN").style.background = CusTCB_bgcolor; + document.getElementById("CBcommentsBoxA").innerHTML = "Last Call: " + CBentry_time; + document.getElementById("CBcommentsBoxB").innerHTML = "CallBack: " + CBcallback_time; + document.getElementById("CBcommentsBoxC").innerHTML = "Agent: " + CBuser; + document.getElementById("CBcommentsBoxD").innerHTML = "Comments:
    " + CBcomments; + showDiv('CBcommentsBox'); + } + if (dialed_label == 'ALT') + {document.getElementById("CusTInfOSpaN").innerHTML = " ALT DIAL NUMBER: ALT ";} + if (dialed_label == 'ADDR3') + {document.getElementById("CusTInfOSpaN").innerHTML = " ALT DIAL NUMBER: ADDRESS3 ";} + var REGalt_dial = new RegExp("X","g"); + if (dialed_label.match(REGalt_dial)) + { + document.getElementById("CusTInfOSpaN").innerHTML = " ALT DIAL NUMBER: " + dialed_label + ""; + document.getElementById("EAcommentsBoxA").innerHTML = "Phone Code and Number: " + EAphone_code + " " + EAphone_number; + + var EAactive_link = ''; + if (EAalt_phone_active == 'Y') + {EAactive_link = "Change this phone number to INACTIVE";} + else + {EAactive_link = "Change this phone number to ACTIVE";} + + document.getElementById("EAcommentsBoxB").innerHTML = "Active: " + EAalt_phone_active + "
    " + EAactive_link; + document.getElementById("EAcommentsBoxC").innerHTML = "Alt Count: " + EAalt_phone_count; + document.getElementById("EAcommentsBoxD").innerHTML = "Notes: " + EAalt_phone_notes; + showDiv('EAcommentsBox'); + } + + if (VDIC_data_VDIG[1].length > 0) + { + inOUT = 'IN'; + if (VDIC_data_VDIG[2].length > 2) + { + document.getElementById("MainStatuSSpan").style.background = VDIC_data_VDIG[2]; + } + var dispnum = document.vicidial_form.phone_number.value; + var status_display_number = phone_number_format(dispnum); + var callnum = dialed_number; + var dial_display_number = phone_number_format(callnum); + + var status_display_content=''; + if (status_display_CALLID > 0) {status_display_content = status_display_content + " UID: " + CIDcheck;} + if (status_display_LEADID > 0) {status_display_content = status_display_content + " Lead: " + document.vicidial_form.lead_id.value;} + if (status_display_LISTID > 0) {status_display_content = status_display_content + " List: " + document.vicidial_form.list_id.value;} + + document.getElementById("MainStatuSSpan").innerHTML = " Incoming: " + dial_display_number + " " + custom_call_id + " Group- " + VDIC_data_VDIG[1] + "   " + VDIC_fronter + " " + status_display_content; + } + + document.getElementById("ParkControl").innerHTML ="\"Park"; + if ( (ivr_park_call=='ENABLED') || (ivr_park_call=='ENABLED_PARK_ONLY') ) + { + document.getElementById("ivrParkControl").innerHTML ="\"IVR"; + } + + document.getElementById("HangupControl").innerHTML = "\"Hangup"; + + document.getElementById("XferControl").innerHTML = "\"Transfer"; + + document.getElementById("LocalCloser").innerHTML = "\"LOCAL"; + + document.getElementById("DialBlindTransfer").innerHTML = "\"Dial"; + + document.getElementById("DialBlindVMail").innerHTML = "\"Blind"; + + if ( (quick_transfer_button == 'IN_GROUP') || (quick_transfer_button == 'LOCKED_IN_GROUP') ) + { + if (quick_transfer_button_locked > 0) + {quick_transfer_button_orig = default_xfer_group;} + + document.getElementById("QuickXfer").innerHTML = "\"QUICK"; + } + if (prepopulate_transfer_preset_enabled > 0) + { + if ( (prepopulate_transfer_preset == 'PRESET_1') || (prepopulate_transfer_preset == 'LOCKED_PRESET_1') ) + {document.vicidial_form.xfernumber.value = CalL_XC_a_NuMber; document.vicidial_form.xfername.value='D1';} + if ( (prepopulate_transfer_preset == 'PRESET_2') || (prepopulate_transfer_preset == 'LOCKED_PRESET_2') ) + {document.vicidial_form.xfernumber.value = CalL_XC_b_NuMber; document.vicidial_form.xfername.value='D2';} + if ( (prepopulate_transfer_preset == 'PRESET_3') || (prepopulate_transfer_preset == 'LOCKED_PRESET_3') ) + {document.vicidial_form.xfernumber.value = CalL_XC_c_NuMber; document.vicidial_form.xfername.value='D3';} + if ( (prepopulate_transfer_preset == 'PRESET_4') || (prepopulate_transfer_preset == 'LOCKED_PRESET_4') ) + {document.vicidial_form.xfernumber.value = CalL_XC_d_NuMber; document.vicidial_form.xfername.value='D4';} + if ( (prepopulate_transfer_preset == 'PRESET_5') || (prepopulate_transfer_preset == 'LOCKED_PRESET_5') ) + {document.vicidial_form.xfernumber.value = CalL_XC_e_NuMber; document.vicidial_form.xfername.value='D5';} + } + if ( (quick_transfer_button == 'PRESET_1') || (quick_transfer_button == 'PRESET_2') || (quick_transfer_button == 'PRESET_3') || (quick_transfer_button == 'PRESET_4') || (quick_transfer_button == 'PRESET_5') || (quick_transfer_button == 'LOCKED_PRESET_1') || (quick_transfer_button == 'LOCKED_PRESET_2') || (quick_transfer_button == 'LOCKED_PRESET_3') || (quick_transfer_button == 'LOCKED_PRESET_4') || (quick_transfer_button == 'LOCKED_PRESET_5') ) + { + if ( (quick_transfer_button == 'PRESET_1') || (quick_transfer_button == 'LOCKED_PRESET_1') ) + {document.vicidial_form.xfernumber.value = CalL_XC_a_NuMber; document.vicidial_form.xfername.value='D1';} + if ( (quick_transfer_button == 'PRESET_2') || (quick_transfer_button == 'LOCKED_PRESET_2') ) + {document.vicidial_form.xfernumber.value = CalL_XC_b_NuMber; document.vicidial_form.xfername.value='D2';} + if ( (quick_transfer_button == 'PRESET_3') || (quick_transfer_button == 'LOCKED_PRESET_3') ) + {document.vicidial_form.xfernumber.value = CalL_XC_c_NuMber; document.vicidial_form.xfername.value='D3';} + if ( (quick_transfer_button == 'PRESET_4') || (quick_transfer_button == 'LOCKED_PRESET_4') ) + {document.vicidial_form.xfernumber.value = CalL_XC_d_NuMber; document.vicidial_form.xfername.value='D4';} + if ( (quick_transfer_button == 'PRESET_5') || (quick_transfer_button == 'LOCKED_PRESET_5') ) + {document.vicidial_form.xfernumber.value = CalL_XC_e_NuMber; document.vicidial_form.xfername.value='D5';} + if (quick_transfer_button_locked > 0) + {quick_transfer_button_orig = document.vicidial_form.xfernumber.value;} + + document.getElementById("QuickXfer").innerHTML = "\"QUICK"; + } + + if (custom_3way_button_transfer_enabled > 0) + { + document.getElementById("CustomXfer").innerHTML = "\"Custom"; + } + + + if (call_requeue_button > 0) + { + var CloserSelectChoices = document.vicidial_form.CloserSelectList.value; + var regCRB = new RegExp("AGENTDIRECT","ig"); + if ( (CloserSelectChoices.match(regCRB)) || (VU_closer_campaigns.match(regCRB)) ) + { + document.getElementById("ReQueueCall").innerHTML = "\"Re-Queue"; + } + else + { + document.getElementById("ReQueueCall").innerHTML = "\"Re-Queue"; + } + } + + // Build transfer pull-down list + var loop_ct = 0; + var live_XfeR_HTML = ''; + var XfeR_SelecT = ''; + while (loop_ct < XFgroupCOUNT) + { + if (VARxfergroups[loop_ct] == LIVE_default_xfer_group) + {XfeR_SelecT = 'selected ';} + else {XfeR_SelecT = '';} + live_XfeR_HTML = live_XfeR_HTML + "\n"; + loop_ct++; + } + document.getElementById("XfeRGrouPLisT").innerHTML = ""; + + if (lastcustserverip == server_ip) + { + document.getElementById("VolumeUpSpan").innerHTML = ""; + document.getElementById("VolumeDownSpan").innerHTML = ""; + } + + if (dial_method == "INBOUND_MAN") + { + document.getElementById("DiaLControl").innerHTML = "\"\"Resume\"
    \"Dial"; + } + else + { + document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_OFF; + } + + if (VDCL_group_id.length > 1) + {var group = VDCL_group_id;} + else + {var group = campaign;} + if ( (dialed_label.length < 2) || (dialed_label=='NONE') ) {dialed_label='MAIN';} + + if (hide_gender < 1) + { + var genderIndex = document.getElementById("gender_list").selectedIndex; + var genderValue = document.getElementById('gender_list').options[genderIndex].value; + document.vicidial_form.gender.value = genderValue; + } + + LeaDDispO=''; + + var regWFAcustom = new RegExp("^VAR","ig"); + if (VDIC_web_form_address.match(regWFAcustom)) + { + TEMP_VDIC_web_form_address = URLDecode(VDIC_web_form_address,'YES','CUSTOM'); + TEMP_VDIC_web_form_address = TEMP_VDIC_web_form_address.replace(regWFAcustom, ''); + } + else + { + TEMP_VDIC_web_form_address = URLDecode(VDIC_web_form_address,'YES','DEFAULT','1'); + } + + if (VDIC_web_form_address_two.match(regWFAcustom)) + { + TEMP_VDIC_web_form_address_two = URLDecode(VDIC_web_form_address_two,'YES','CUSTOM'); + TEMP_VDIC_web_form_address_two = TEMP_VDIC_web_form_address_two.replace(regWFAcustom, ''); + } + else + { + TEMP_VDIC_web_form_address_two = URLDecode(VDIC_web_form_address_two,'YES','DEFAULT','2'); + } + + + document.getElementById("WebFormSpan").innerHTML = "\"Web\n"; + + if (enable_second_webform > 0) + { + document.getElementById("WebFormSpanTwo").innerHTML = "\"Web\n"; + } + + if ( (LIVE_campaign_recording == 'ALLCALLS') || (LIVE_campaign_recording == 'ALLFORCE') ) + {all_record = 'YES';} + + if ( (view_scripts == 1) && (CalL_ScripT_id.length > 0) ) + { + var SCRIPT_web_form = 'http://127.0.0.1/testing.php'; + var TEMP_SCRIPT_web_form = URLDecode(SCRIPT_web_form,'YES','DEFAULT','1'); + + if ( (script_recording_delay > 0) && ( (LIVE_campaign_recording == 'ALLCALLS') || (LIVE_campaign_recording == 'ALLFORCE') ) ) + { + delayed_script_load = 'YES'; + RefresHScript('CLEAR'); + } + else + { + load_script_contents(); + } + } + + if (custom_fields_enabled > 0) + { + FormContentsLoad(); + } + // JOEJ 082812 - new for email feature + if (email_enabled > 0) + { + EmailContentsLoad(); + } + if (CalL_AutO_LauncH == 'SCRIPT') + { + if (delayed_script_load == 'YES') + { + load_script_contents(); + } + ScriptPanelToFront(); + } + if (CalL_AutO_LauncH == 'FORM') + { + FormPanelToFront(); + } + if (CalL_AutO_LauncH == 'EMAIL') + { + EmailPanelToFront(); + } + + if (CalL_AutO_LauncH == 'WEBFORM') + { + window.open(TEMP_VDIC_web_form_address, web_form_target, 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=640,height=450'); + } + if (CalL_AutO_LauncH == 'WEBFORMTWO') + { + window.open(TEMP_VDIC_web_form_address_two, web_form_target, 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=640,height=450'); + } + + if (useIE > 0) + { + var regCTC = new RegExp("^NONE","ig"); + if (CopY_tO_ClipboarD.match(regCTC)) + {var nothing=1;} + else + { + var tmp_clip = document.getElementById(CopY_tO_ClipboarD); + // alert_box("Copy to clipboard SETTING: |" + useIE + "|" + CopY_tO_ClipboarD + "|" + tmp_clip.value + "|"); + window.clipboardData.setData('Text', tmp_clip.value) + // alert_box("Copy to clipboard: |" + tmp_clip.value + "|" + CopY_tO_ClipboarD + "|"); + } + } + + if (alert_enabled=='ON') + { + var callnum = dialed_number; + var dial_display_number = phone_number_format(callnum); + alert(" Incoming: " + dial_display_number + "\n Group- " + VDIC_data_VDIG[1] + "   " + VDIC_fronter); + } + } + xmlhttprequestcheckemail = undefined; + delete xmlhttprequestcheckemail; + } + } + } + } + } + + // ################################################################################ // refresh or clear the SCRIPT frame contents function RefresHScript(temp_wipe) @@ -9571,6 +10270,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) leaving_threeway=0; blind_transfer=0; CheckDEADcallON=0; + currently_in_email=0; customer_3way_hangup_counter=0; customer_3way_hangup_counter_trigger=0; waiting_on_dispo=1; @@ -9619,7 +10319,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) } if (xmlhttp) { - DSupdate_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=updateDISPO&format=text&user=" + user + "&pass=" + pass + "&dispo_choice=" + DispoChoice + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign + "&auto_dial_level=" + auto_dial_level + "&agent_log_id=" + agent_log_id + "&CallBackDatETimE=" + CallBackDatETimE + "&list_id=" + document.vicidial_form.list_id.value + "&recipient=" + CallBackrecipient + "&use_internal_dnc=" + use_internal_dnc + "&use_campaign_dnc=" + use_campaign_dnc + "&MDnextCID=" + LasTCID + "&stage=" + group + "&vtiger_callback_id=" + vtiger_callback_id + "&phone_number=" + document.vicidial_form.phone_number.value + "&phone_code=" + document.vicidial_form.phone_code.value + "&dial_method" + dial_method + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&CallBackLeadStatus=" + CallBackLeadStatus + "&comments=" + encodeURIComponent(CallBackCommenTs) + "&custom_field_names=" + custom_field_names + "&call_notes=" + encodeURIComponent(document.vicidial_form.call_notes_dispo.value) + "&qm_dispo_code=" + DispoQMcsCODE; + DSupdate_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=updateDISPO&format=text&user=" + user + "&pass=" + pass + "&dispo_choice=" + DispoChoice + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign + "&auto_dial_level=" + auto_dial_level + "&agent_log_id=" + agent_log_id + "&CallBackDatETimE=" + CallBackDatETimE + "&list_id=" + document.vicidial_form.list_id.value + "&recipient=" + CallBackrecipient + "&use_internal_dnc=" + use_internal_dnc + "&use_campaign_dnc=" + use_campaign_dnc + "&MDnextCID=" + LasTCID + "&stage=" + group + "&vtiger_callback_id=" + vtiger_callback_id + "&phone_number=" + document.vicidial_form.phone_number.value + "&phone_code=" + document.vicidial_form.phone_code.value + "&dial_method" + dial_method + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&CallBackLeadStatus=" + CallBackLeadStatus + "&comments=" + encodeURIComponent(CallBackCommenTs) + "&custom_field_names=" + custom_field_names + "&call_notes=" + encodeURIComponent(document.vicidial_form.call_notes_dispo.value) + "&qm_dispo_code=" + DispoQMcsCODE + "&email_enabled=" + email_enabled; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp.send(DSupdate_query); @@ -9808,6 +10508,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) if (auto_dial_level != '0') { AutoDialWaiting = 0; + QUEUEpadding = 0; AutoDial_ReSume_PauSe("VDADpause"); } VICIDiaL_pause_calling = 1; @@ -10204,10 +10905,13 @@ function set_length(SLnumber,SLlength_goal,SLdirection) if (CSCchange==1) { var loop_ct = 0; + EMAILgroupCOUNT = 0; + PHONEgroupCOUNT = 0; var CSCcolumn = ''; var live_CSC_HTML_ADD = ''; var live_CSC_HTML_DELETE = ''; var live_CSC_LIST_value = " "; + incomingEMAILS = 0; while (loop_ct < INgroupCOUNT) { var regCSL = new RegExp(" " + VARingroups[loop_ct] + " ","ig"); @@ -10221,6 +10925,16 @@ function set_length(SLnumber,SLlength_goal,SLdirection) { live_CSC_HTML_DELETE = live_CSC_HTML_DELETE + "" + VARingroups[loop_ct] + "
    "; live_CSC_LIST_value = live_CSC_LIST_value + VARingroups[loop_ct] + " "; + if (VARingroup_handlers[loop_ct]=="EMAIL") + { + incomingEMAILgroups[incomingEMAILS]=VARingroups[loop_ct]; + EMAILgroupCOUNT++; + incomingEMAILS++; + } + else + { + PHONEgroupCOUNT++; + } } else { @@ -12083,6 +12797,20 @@ function phone_number_format(formatphone) { form_entry_list_id = ''; } +// ################################################################################ +// Refresh the EMAIL content + function EmailContentsLoad() + { + var form_list_id = document.vicidial_form.list_id.value; + var form_entry_list_id = document.vicidial_form.entry_list_id.value; + if (form_entry_list_id.length > 2) + {form_list_id = form_entry_list_id} + document.getElementById('vcEmailIFrame').src='./vdc_email_display.php?lead_id=' + document.vicidial_form.lead_id.value + '&list_id=' + form_list_id + '&user=' + user + '&pass=' + pass + '&campaign=' + campaign + '&server_ip=' + server_ip + '&session_id=' + '&uniqueid=' + document.vicidial_form.uniqueid.value + '&stage=DISPLAY' + "&campaign=" + campaign + "&phone_login=" + phone_login + "&original_phone_login=" + original_phone_login +"&phone_pass=" + phone_pass + "&fronter=" + fronter + "&closer=" + user + "&group=" + group + "&channel_group=" + group + "&SQLdate=" + SQLdate + "&epoch=" + UnixTime + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&customer_zap_channel=" + lastcustchannel + "&customer_server_ip=" + lastcustserverip +"&server_ip=" + server_ip + "&SIPexten=" + extension + "&session_id=" + session_id + "&phone=" + document.vicidial_form.phone_number.value + "&parked_by=" + document.vicidial_form.lead_id.value +"&dispo=" + LeaDDispO + '' +"&dialed_number=" + dialed_number + '' +"&dialed_label=" + dialed_label + '' +"&camp_script=" + campaign_script + '' +"&in_script=" + CalL_ScripT_id + '' +"&script_width=" + script_width + '' +"&script_height=" + script_height + '' +"&fullname=" + LOGfullname + '' +"&recording_filename=" + recording_filename + '' +"&recording_id=" + recording_id + '' +"&user_custom_one=" + VU_custom_one + '' +"&user_custom_two=" + VU_custom_two + '' +"&user_custom_three=" + VU_custom_three + '' +"&user_custom_four=" + VU_custom_four + '' +"&user_custom_five=" + VU_custom_five + '' +"&preset_number_a=" + CalL_XC_a_NuMber + '' +"&preset_number_b=" + CalL_XC_b_NuMber + '' +"&preset_number_c=" + CalL_XC_c_NuMber + '' +"&preset_number_d=" + CalL_XC_d_NuMber + '' +"&preset_number_e=" + CalL_XC_e_NuMber + '' +"&preset_dtmf_a=" + CalL_XC_a_Dtmf + '' +"&preset_dtmf_b=" + CalL_XC_b_Dtmf + '' +"&did_id=" + did_id + '' +"&did_extension=" + did_extension + '' +"&did_pattern=" + did_pattern + '' +"&did_description=" + did_description + '' +"&closecallid=" + closecallid + '' +"&xfercallid=" + xfercallid + '' + "&agent_log_id=" + agent_log_id + "&call_id=" + LasTCID + '' +"&web_vars=" + LIVE_web_vars + ''; + form_list_id = ''; + form_entry_list_id = ''; + } + + // ################################################################################ // Move the Dispo frame out of the way and change the link to maximize function DispoMinimize() @@ -12454,6 +13182,8 @@ function phone_number_format(formatphone) { hideDiv('MainPanel'); hideDiv('ScriptPanel'); hideDiv('ScriptRefresH'); + hideDiv('EmailPanel'); + hideDiv('EmailRefresH'); hideDiv('FormPanel'); hideDiv('FormRefresH'); hideDiv('DispoSelectBox'); @@ -13334,6 +14064,8 @@ function phone_number_format(formatphone) { hideDiv('ScriptRefresH'); hideDiv('FormPanel'); hideDiv('FormRefresH'); + hideDiv('EmailPanel'); + hideDiv('EmailRefresH'); showDiv('MainPanel'); ShoWGenDerPulldown(); @@ -13387,6 +14119,8 @@ function phone_number_format(formatphone) { showDiv('ScriptRefresH'); hideDiv('FormPanel'); hideDiv('FormRefresH'); + hideDiv('EmailPanel'); + hideDiv('EmailRefresH'); document.getElementById("MainTable").style.backgroundColor=""; document.getElementById("MaiNfooter").style.backgroundColor=""; panel_bgcolor=''; @@ -13402,6 +14136,22 @@ function phone_number_format(formatphone) { document.getElementById("CallbacksButtons").style.left = '360px'; showDiv('FormPanel'); showDiv('FormRefresH'); + hideDiv('EmailPanel'); + hideDiv('EmailRefresH'); + document.getElementById("MainTable").style.backgroundColor=""; + document.getElementById("MaiNfooter").style.backgroundColor=""; + panel_bgcolor=''; + // document.getElementById("MainStatuSSpan").style.background = panel_bgcolor; + + HidEGenDerPulldown(); + } + function EmailPanelToFront() + { + var CBFPheight = 'px'; + document.getElementById("CallbacksButtons").style.top = CBFPheight; + document.getElementById("CallbacksButtons").style.left = '360px'; + showDiv('EmailPanel'); + showDiv('EmailRefresH'); document.getElementById("MainTable").style.backgroundColor=""; document.getElementById("MaiNfooter").style.backgroundColor=""; panel_bgcolor=''; @@ -13507,6 +14257,9 @@ $zi=2; 0) {echo "
    \"FORM\"\n";} ?> + 0) + {echo "\"EMAIL\"\n";} + ?>   LIVE   session ID:     Live Call @@ -13950,10 +14703,22 @@ if ($agent_display_dialable_leads > 0)
    + +
    \n";} + ?> +
    +
    + reset form + +refresh + + diff --git a/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php b/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php index 298eb50b..11d38a70 100644 --- a/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php +++ b/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php @@ -77,10 +77,11 @@ # 111103-1220 - Added admin_hide_phone_data and admin_hide_lead_data options # 120223-1934 - Added user group options # 120612-2150 - Added percentages to counts for carrier stats and TOTAL line to carrier display stats as well +# 121222-2151 - Added email status # -$version = '2.4-67'; -$build = '120223-1934'; +$version = '2.6-68'; +$build = '121222-2151'; header ("Content-type: text/html; charset=utf-8"); @@ -2600,7 +2601,7 @@ $talking_to_print = mysql_num_rows($rslt); } else { - if (!ereg("$Acallerid[$i]\|",$callerids)) + if (!ereg("$Acallerid[$i]\|",$callerids) && !eregi("EMAIL",$comments)) { $Acall_time[$i]=$Astate_change[$i]; @@ -2616,6 +2617,8 @@ $talking_to_print = mysql_num_rows($rslt); { if (eregi("INBOUND",$comments)) {$CM='I';} + else if (eregi("EMAIL",$comments)) + {$CM='E';} else {$CM='M';} } diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index 575d2d06..30682615 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -1742,6 +1742,14 @@ if (isset($_GET["in_group_dial_select"])) {$in_group_dial_select=$_GET["in_gro elseif (isset($_POST["in_group_dial_select"])) {$in_group_dial_select=$_POST["in_group_dial_select"];} if (isset($_GET["dial_ingroup_cid"])) {$dial_ingroup_cid=$_GET["dial_ingroup_cid"];} elseif (isset($_POST["dial_ingroup_cid"])) {$dial_ingroup_cid=$_POST["dial_ingroup_cid"];} +if (isset($_GET["allow_emails"])) {$allow_emails=$_GET["allow_emails"];} + elseif (isset($_POST["allow_emails"])) {$allow_emails=$_POST["allow_emails"];} +if (isset($_GET["group_handling"])) {$group_handling=$_GET["group_handling"];} + elseif (isset($_POST["group_handling"])) {$group_handling=$_POST["group_handling"];} +if (isset($_GET["agentcall_email"])) {$agentcall_email=$_GET["agentcall_email"];} + elseif (isset($_POST["agentcall_email"])) {$agentcall_email=$_POST["agentcall_email"];} +if (isset($_GET["modify_email_accounts"])) {$modify_email_accounts=$_GET["modify_email_accounts"];} + elseif (isset($_POST["modify_email_accounts"])) {$modify_email_accounts=$_POST["modify_email_accounts"];} if (isset($_GET["safe_harbor_audio_field"])) {$safe_harbor_audio_field=$_GET["safe_harbor_audio_field"];} elseif (isset($_POST["safe_harbor_audio_field"])) {$safe_harbor_audio_field=$_POST["safe_harbor_audio_field"];} if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} @@ -1849,7 +1857,7 @@ if ($download_max_system_stats_metric_name) { ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### -$stmt = "SELECT use_non_latin,enable_queuemetrics_logging,enable_vtiger_integration,qc_features_active,outbound_autodial_active,sounds_central_control_active,enable_second_webform,user_territories_active,custom_fields_enabled,admin_web_directory,webphone_url,first_login_trigger,hosted_settings,default_phone_registration_password,default_phone_login_password,default_server_password,test_campaign_calls,active_voicemail_server,voicemail_timezones,default_voicemail_timezone,default_local_gmt,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,call_menu_qualify_enabled,admin_list_counts,allow_voicemail_greeting,svn_revision FROM system_settings;"; +$stmt = "SELECT use_non_latin,enable_queuemetrics_logging,enable_vtiger_integration,qc_features_active,outbound_autodial_active,sounds_central_control_active,enable_second_webform,user_territories_active,custom_fields_enabled,admin_web_directory,webphone_url,first_login_trigger,hosted_settings,default_phone_registration_password,default_phone_login_password,default_server_password,test_campaign_calls,active_voicemail_server,voicemail_timezones,default_voicemail_timezone,default_local_gmt,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,call_menu_qualify_enabled,admin_list_counts,allow_voicemail_greeting,svn_revision,allow_emails FROM system_settings;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); @@ -1891,6 +1899,7 @@ if ($qm_conf_ct > 0) $SSadmin_list_counts = $row[32]; $SSallow_voicemail_greeting = $row[33]; $SSsvn_revision = $row[34]; + $SSallow_emails = $row[35]; } ##### END SETTINGS LOOKUP ##### ########################################### @@ -3208,12 +3217,13 @@ else # 121205-1619 - Added parentheses around filter SQL when in SQL queries # 121206-0630 - Added inbound lead search feature # 121212-1529 - Standardization of list_id fields at 19 digits in forms +# 121222-2146 - Added new email features # # 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.6-390a'; -$build = '121212-1529'; +$admin_version = '2.6-391a'; +$build = '121222-2146'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -3270,7 +3280,7 @@ if ($force_logout) } ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### -$stmt = "SELECT use_non_latin,auto_dial_limit,user_territories_active,allow_custom_dialplan,callcard_enabled,admin_modify_refresh,nocache_admin,webroot_writable FROM system_settings;"; +$stmt = "SELECT use_non_latin,auto_dial_limit,user_territories_active,allow_custom_dialplan,callcard_enabled,admin_modify_refresh,nocache_admin,webroot_writable,allow_emails FROM system_settings;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); @@ -3285,6 +3295,7 @@ if ($qm_conf_ct > 0) $SSadmin_modify_refresh = $row[5]; $SSnocache_admin = $row[6]; $SSwebroot_writable = $row[7]; + $SSemail_enabled = $row[8]; } ##### END SETTINGS LOOKUP ##### ########################################### @@ -3534,6 +3545,8 @@ if ($ADD==1411) {$hh='ingroups'; echo "Copy DID";} if ($ADD==1511) {$hh='ingroups'; echo "Add Call Menu";} if ($ADD==1611) {$hh='ingroups'; echo "Copy Call Menu";} if ($ADD==1711) {$hh='ingroups'; echo "Add Filter Phone Group";} +if ($ADD==1811) {$hh='ingroups'; echo "Add New EMAIL In-Group";} +if ($ADD==1911) {$hh='ingroups'; echo "Copy EMAIL In-Group";} if ($ADD==11111) {$hh='remoteagent'; echo "Add New Remote Agents";} if ($ADD==12111) {$hh='remoteagent'; echo "Add Extension Group";} if ($ADD==111111) {$hh='usergroups'; echo "Add New Users Group";} @@ -3578,6 +3591,8 @@ if ($ADD==2411) {$hh='ingroups'; echo "New Copied DID Addition";} if ($ADD==2511) {$hh='ingroups'; echo "New Call Menu";} if ($ADD==2611) {$hh='ingroups'; echo "New Call Menu";} if ($ADD==2711) {$hh='ingroups'; echo "New Filter Phone Group";} +if ($ADD==2811) {$hh='ingroups'; echo "New Email Group Addition";} +if ($ADD==2911) {$hh='ingroups'; echo "New Copied Email Group Addition";} if ($ADD==21111) {$hh='remoteagent'; echo "New Remote Agents Addition";} if ($ADD==22111) {$hh='remoteagent'; echo "New Group Extension Addition";} if ($ADD==211111) {$hh='usergroups'; echo "New Users Group Addition";} @@ -3650,6 +3665,7 @@ if ($ADD==3311) {$hh='ingroups'; echo "Modify DID";} if ($ADD==3321) {$hh='ingroups'; echo "Modify DID RA Extension Overrides";} if ($ADD==3511) {$hh='ingroups'; echo "Modify Call Menu";} if ($ADD==3711) {$hh='ingroups'; echo "Modify Filter Phone Group";} +if ($ADD==3811) {$hh='ingroups'; echo "Modify EMAIL In-Group";} if ($ADD==31111) {$hh='remoteagent'; echo "Modify Remote Agents";} if ($ADD==32111) {$hh='remoteagent'; echo "Modify Extension Group";} if ($ADD==311111) {$hh='usergroups'; echo "Modify Users Groups";} @@ -3695,6 +3711,7 @@ if ($ADD==4111) {$hh='ingroups'; echo "Modify In-Group";} if ($ADD==4311) {$hh='ingroups'; echo "Modify DID";} if ($ADD==4511) {$hh='ingroups'; echo "Modify Call Menu";} if ($ADD==4711) {$hh='ingroups'; echo "Modify Filter Phone Group";} +if ($ADD==4811) {$hh='ingroups'; echo "Modify Email In-Group";} if ($ADD==41111) {$hh='remoteagent'; echo "Modify Remote Agents";} if ($ADD==42111) {$hh='remoteagent'; echo "Modify Extension Group";} if ($ADD==411111) {$hh='usergroups'; echo "Modify Users Groups";} @@ -3809,6 +3826,7 @@ if ($ADD==1300) {$hh='ingroups'; echo "DIDs";} if ($ADD==1320) {$hh='ingroups'; echo "Modify DID RA Extension Overrides";} if ($ADD==1500) {$hh='ingroups'; echo "Call Menus";} if ($ADD==1700) {$hh='ingroups'; echo "Filter Phone Groups";} +if ($ADD==1800) {$hh='ingroups'; echo "Email In-Groups";} if ($ADD==10000) {$hh='remoteagent'; echo "Remote Agents";} if ($ADD==12000) {$hh='remoteagent'; echo "Extension Groups";} if ($ADD==100000) {$hh='usergroups'; echo "User Groups";} @@ -4524,7 +4542,7 @@ if ($ADD==99999)

    - VICIDIAL Recording Override - This option will override whatever the option is in the campaign for recording. DISABLED will not override the campaign recording setting. NEVER will disable recording on the client. ONDEMAND is the default and allows the agent to start and stop recording as needed. ALLCALLS will start recording on the client whenever a call is sent to an agent. ALLFORCE will start recording on the client whenever a call is sent to an agent giving the agent no option to stop recording. For ALLCALLS and ALLFORCE there is an option to use the Recording Delay to cut down on very short recordings and recude system load. + VICIDIAL Recording Override - This option will override whatever the option is in the campaign for recording. DISABLED will not override the campaign recording setting. NEVER will disable recording on the client. ONDEMAND is the default and allows the agent to start and stop recording as needed. ALLCALLS will start recording on the client whenever a call is sent to an agent. ALLFORCE will start recording on the client whenever a call is sent to an agent giving the agent no option to stop recording. For ALLCALLS and ALLFORCE there is an option to use the Recording Delay to cut down on very short recordings and reduce system load.
    @@ -4662,6 +4680,18 @@ if ($ADD==99999)
    Modify Leads - This option if set to 1 allows the user to modify leads in the admin section lead search results page. + 0) + { + ?> +
    +
    +
    + Modify Email Accounts - This option if set to 1 allows the user to modify email accounts in the email account management page. + +

    @@ -4885,6 +4915,17 @@ if ($ADD==99999)
    Allow Closers - This is where you can set whether the users of this campaign will have the option to send the call to a closer. + 0) + { + ?> +
    +
    +
    + Allow Emails - This is where you can set whether the users of this campaign will be able to receive inbound emails in addition to phone calls. +

    @@ -5370,7 +5411,7 @@ if ($ADD==99999)

    - Campaign Recording - This menu allows you to choose what level of recording is allowed on this campaign. NEVER will disable recording on the client. ONDEMAND is the default and allows the agent to start and stop recording as needed. ALLCALLS will start recording on the client whenever a call is sent to an agent. ALLFORCE will start recording on the client whenever a call is sent to an agent giving the agent no option to stop recording. For ALLCALLS and ALLFORCE there is an option to use the Recording Delay to cut down on very short recordings and recude system load. + Campaign Recording - This menu allows you to choose what level of recording is allowed on this campaign. NEVER will disable recording on the client. ONDEMAND is the default and allows the agent to start and stop recording as needed. ALLCALLS will start recording on the client whenever a call is sent to an agent. ALLFORCE will start recording on the client whenever a call is sent to an agent giving the agent no option to stop recording. For ALLCALLS and ALLFORCE there is an option to use the Recording Delay to cut down on very short recordings and reduce system load.
    @@ -8480,6 +8521,11 @@ if ($ADD==99999)
    Admin List Counts - This setting allows you to disable the list counts that appear on the Lists listing and the Campaign modify screens. Default is 1 for enabled. +
    +
    +
    + Allow Emails - This is where you can set whether this system will be able to receive inbound emails in addition to phone calls. +

    @@ -8738,7 +8784,110 @@ if ($ADD==99999)



    + 0) + { + ?> + VICIDIAL EMAIL ACCOUNTS

    +
    +
    + The Vicidial Email Accounts management section allows you to create, copy, and delete email account settings that will allow you to have email messages come into your Vicidial system and be treated as regular calls. EMAIL ACCOUNTS MUST BE SET UP BY YOU AND AN EMAIL SERVICE PROVIDER - THAT IS NOT COVERED BY THIS MODULE. +
    +
    +
    + Email Account ID - This is the short name of the email account, it is not editable after initial submission, must not contain any spaces and must be between 2 and 20 characters in length. + +
    +
    +
    + Email Account Name - This is the full name of the email account, it must be between 2 and 30 characters in length. + +
    +
    +
    + Active - This determines whether this account will be checked for new email messages to be loaded into the dialer. + +
    +
    +
    + Email Account Description - This allows for a lengthy description, if needed, of the email account. 255 characters max. + +
    +
    +
    + Email Account Type - Specifies whether the account is used for inbound or outbound email messages. Should be set to INBOUND. + +
    +
    +
    + Admin User Group - This is the administrative user group for this inbound group, this allows admin viewing of this in-group restricted by user group. Default is --ALL-- which allows any admin user to view this in-group. + +
    +
    +
    + Email Account Protocol - This is the email protocol used by the account you are setting up access to. Currently only IMAP and POP3 accounts are supported. + +
    +
    +
    + Email Reply-to Address - The email address of the account you are setting up access to. Replies to email messages from the agent interface will read as coming from this address. + +
    +
    +
    + Email Account Server - The email server that the account is housed on. + +
    +
    +
    + Email Account User - The login used to access this account. Usually it's the portion of the reply-to address before the -at- symbol. + +
    +
    +
    + Email Account Password - The password used to access this account. This is usually set at the time the email account is created. + +
    +
    +
    + Email Frequency Check Rate (mins) - How often this email account should be checked. The highest rate of frequency at the moment is five minutes; some email providers will not allow more than three login attempts in fifteen minutes before locking the account for an indeterminate amount of time. + +
    +
    +
    + In-Group ID - The In-Group that email messages will be sent to. + +
    +
    +
    + Default List ID - The List ID that leads will be inserted into if necessary. + +
    +
    +
    + In-Group Call Handle Method - This is the action that will be taken when a new email is found in the account. EMAIL means all email messages will be inserted into vicidial_list as a new lead. EMAILLOOKUP will search the entire vicidial_list table for the email address in the email column - if the lead is found, that lead's list ID will be used in the record that goes into the vicidial_email_list table. EMAILLOOKUPRC does the same, but it will only search lists belonging to the campaign selected in the "In-Group Campaign ID" box below. EMAILLOOKUPRL will only search one particular list, which is the one entered into the "In-Group List ID" box below. + +
    +
    +
    + In-Group Agent Search Method - The agent search method to be used by the inbound group, LO is Load-Balanced-Overflow and will try to send the call to an agent on the local server before trying to send it to an agent on another server, LB is Load-Balanced and will try to send the call to the next agent no matter what server they are on, SO is Server-Only and will only try to send the calls to agents on the server that the call came in on. Default is LB. IS THIS NECESSARY? + +
    +
    +
    + In-Group List ID - This is the List ID that will be used to search for a match within. + +
    +
    +
    + In-Group Campaign ID - This is the Campaign ID that will be used to search for a match within. + + + + +



    + VICIDIAL CUSTOM TEMPLATE MAKER


    @@ -9897,6 +10046,75 @@ if ($ADD==1111) if ($SScustom_fields_enabled > 0) {$cfwHTML = '';} echo "
    \n"; + if ($SSallow_emails>0) + { + echo "\n"; + } + else + {echo "\n";} + echo "\n"; + echo "
    Get Call Launch: $NWB#vicidial_inbound_groups-get_call_launch$NWE
    Group Handling: $NWB#vicidial_inbound_groups-group_handling$NWE
    \n"; + } + else + { + echo "You do not have permission to view this page\n"; + exit; + } + } + +###################### +# ADD=1811 display the ADD NEW EMAIL GROUP SCREEN +###################### + +if ($ADD==1811) + { + if ( ($LOGmodify_ingroups==1) and ($SSallow_emails>0) ) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $voi_count = "$row[0]"; + } + ##### END ID override optional section ##### + + echo "
    \n"; + echo ""; + + echo "
    ADD A NEW EMAIL GROUP
    \n"; + echo "\n"; + echo "
    \n"; + if ($voi_count > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + # echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $eswHTML=''; $cfwHTML=''; + if ($SSenable_second_webform > 0) + {$eswHTML = '';} + if ($SScustom_fields_enabled > 0) + {$cfwHTML = '';} + echo "\n"; echo "\n"; echo "
    Group ID: Auto-Generated $NWB#vicidial_inbound_groups-group_id$NWE
    Group ID: (no spaces)$NWB#vicidial_inbound_groups-group_id$NWE
    Group Name: $NWB#vicidial_inbound_groups-group_name$NWE
    Group Color: $NWB#vicidial_inbound_groups-group_color$NWE
    Active: $NWB#vicidial_inbound_groups-active$NWE
    Admin User Group: $NWB#vicidial_inbound_groups-user_group$NWE
    Web Form: $NWB#vicidial_inbound_groups-web_form_address$NWE
    Voicemail: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
    Next Agent Email: $NWB#vicidial_inbound_groups-next_agent_call$NWE
    Fronter Display: $NWB#vicidial_inbound_groups-fronter_display$NWE
    Script: $NWB#vicidial_inbound_groups-ingroup_script$NWE
    Get Call Launch: $NWB#vicidial_inbound_groups-get_call_launch$NWE
    \n"; } @@ -9970,6 +10188,67 @@ if ($ADD==1211) } } +###################### +# ADD=1911 display the COPY EMAIL INBOUND GROUP SCREEN +###################### + +if ($ADD==1911) + { + if ( ($LOGmodify_ingroups==1) and ($SSallow_emails>0) ) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $voi_count = "$row[0]"; + } + ##### END ID override optional section ##### + + echo "
    \n"; + echo ""; + + echo "
    COPY EMAIL GROUP\n"; + echo "\n"; + echo "
    \n"; + if ($voi_count > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "
    Email Group ID: Auto-Generated $NWB#vicidial_inbound_groups-group_id$NWE
    Email Group ID: (no spaces)$NWB#vicidial_inbound_groups-group_id$NWE
    Email Group Name: $NWB#vicidial_inbound_groups-group_name$NWE
    Source Email Group ID: $NWB#vicidial_inbound_groups-group_id$NWE
    \n"; + } + else + { + echo "You do not have permission to view this page\n"; + exit; + } + } ###################### # ADD=1311 display the ADD NEW DID SCREEN @@ -12530,7 +12809,7 @@ if ($ADD==2111) } else { - $stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,web_form_address_two,start_call_url,dispo_call_url,add_lead_url,na_call_url,user_group) values('$group_id','$group_name','$group_color','$active','" . mysql_real_escape_string($web_form_address) . "','$voicemail_ext','$next_agent_call','$fronter_display','$script_id','$get_call_launch','','','','','','$user_group');"; + $stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,web_form_address_two,start_call_url,dispo_call_url,add_lead_url,na_call_url,user_group,group_handling) values('$group_id','$group_name','$group_color','$active','" . mysql_real_escape_string($web_form_address) . "','$voicemail_ext','$next_agent_call','$fronter_display','$script_id','$get_call_launch','','','','','','$user_group','$group_handling');"; $rslt=mysql_query($stmt, $link); $stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$group_id');"; @@ -12554,6 +12833,73 @@ if ($ADD==2111) $ADD=3111; } +###################### +# ADD=2811 adds the new EMAIL inbound group to the system +###################### + +if ( ($ADD==2811) and ($SSallow_emails>0) ) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $group_id = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$group_id' where id_table='vicidial_inbound_groups' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
    EMAIL GROUP NOT ADDED - there is already a group in the system with this ID\n";} + else + { + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
    EMAIL GROUP NOT ADDED - there is already a campaign in the system with this ID\n";} + else + { + if ( (strlen($group_id) < 2) or (strlen($group_name) < 2) or (strlen($group_color) < 2) or (strlen($group_id) > 20) or (eregi(' ',$group_id)) or (eregi("\-",$group_id)) or (eregi("\+",$group_id)) ) + { + echo "
    GROUP NOT ADDED - Please go back and look at the data you entered\n"; + echo "
    Group ID must be between 2 and 20 characters in length and contain no ' -+'.\n"; + echo "
    Group name and group color must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,web_form_address_two,start_call_url,dispo_call_url,add_lead_url,na_call_url,user_group,group_handling) values('$group_id','$group_name','$group_color','$active','" . mysql_real_escape_string($web_form_address) . "','$voicemail_ext','$next_agent_call','$fronter_display','$script_id','EMAIL','','','','','','$user_group','EMAIL');"; + $rslt=mysql_query($stmt, $link); + + $stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$group_id');"; + $rslt=mysql_query($stmtA, $link); + + $stmtA="INSERT INTO vicidial_campaign_stats_debug (campaign_id) values('$group_id');"; + $rslt=mysql_query($stmtA, $link); + + echo "
    EMAIL GROUP ADDED: $group_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='INGROUPS', event_type='ADD', record_id='$group_id', event_code='ADMIN ADD INBOUND GROUP', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + $ADD=3811; + } + ###################### # ADD=2011 adds copied inbound group to the system @@ -12598,7 +12944,7 @@ if ($ADD==2011) } else { - $stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid) SELECT \"$group_id\",\"$group_name\",group_color,\"N\",web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid from vicidial_inbound_groups where group_id=\"$source_group_id\";"; + $stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid,group_handling) SELECT \"$group_id\",\"$group_name\",group_color,\"N\",web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid,group_handling from vicidial_inbound_groups where group_id=\"$source_group_id\";"; $rslt=mysql_query($stmt, $link); $stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$group_id');"; @@ -12622,6 +12968,73 @@ if ($ADD==2011) $ADD=3111; } +###################### +# ADD=2911 adds copied inbound group to the system +###################### + +if ( ($ADD==2911) and ($SSallow_emails>0) ) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $group_id = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$group_id' where id_table='vicidial_inbound_groups' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
    EMAIL GROUP NOT ADDED - there is already a group in the system with this ID\n";} + else + { + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
    EMAIL GROUP NOT ADDED - there is already a campaign in the system with this ID\n";} + else + { + if ( (strlen($group_id) < 2) or (strlen($group_name) < 2) or (strlen($group_id) > 20) or (eregi(' ',$group_id)) or (eregi("\-",$group_id)) or (eregi("\+",$group_id)) ) + { + echo "
    EMAIL GROUP NOT ADDED - Please go back and look at the data you entered\n"; + echo "
    Email group ID must be between 2 and 20 characters in length and contain no ' -+'.\n"; + echo "
    Email group name and group color must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid,group_handling) SELECT \"$group_id\",\"$group_name\",group_color,\"N\",web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid,group_handling from vicidial_inbound_groups where group_id=\"$source_group_id\";"; + $rslt=mysql_query($stmt, $link); + + $stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$group_id');"; + $rslt=mysql_query($stmtA, $link); + + $stmtA="INSERT INTO vicidial_campaign_stats_debug (campaign_id) values('$group_id');"; + $rslt=mysql_query($stmtA, $link); + + echo "
    EMAIL GROUP ADDED: $group_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='INGROUPS', event_type='COPY', record_id='$group_id', event_code='ADMIN COPY INBOUND GROUP', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + $ADD=3811; + } + ###################### # ADD=2311 adds the new did to the system @@ -14215,7 +14628,7 @@ 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',active='$active',download_lists='$download_lists',agent_shift_enforcement_override='$agent_shift_enforcement_override',manager_shift_enforcement_override='$manager_shift_enforcement_override',export_reports='$export_reports',delete_from_dnc='$delete_from_dnc',email='$email',user_code='$user_code',territory='$territory',allow_alerts='$allow_alerts',agent_choose_territories='$agent_choose_territories',custom_one='$custom_one',custom_two='$custom_two',custom_three='$custom_three',custom_four='$custom_four',custom_five='$custom_five',voicemail_id='$voicemail_id',agent_call_log_view_override='$agent_call_log_view_override',callcard_admin='$callcard_admin',agent_choose_blended='$agent_choose_blended',realtime_block_user_info='$realtime_block_user_info',custom_fields_modify='$custom_fields_modify',force_change_password='$force_change_password',agent_lead_search_override='$agent_lead_search',modify_shifts='$modify_shifts',modify_phones='$modify_phones',modify_carriers='$modify_carriers',modify_labels='$modify_labels',modify_statuses='$modify_statuses',modify_voicemail='$modify_voicemail',modify_audiostore='$modify_audiostore',modify_moh='$modify_moh',modify_tts='$modify_tts',preset_contact_search='$preset_contact_search',modify_contacts='$modify_contacts',modify_same_user_level='$modify_same_user_level',admin_hide_lead_data='$admin_hide_lead_data',admin_hide_phone_data='$admin_hide_phone_data' where user='$user' $LOGadmin_viewable_groupsSQL;"; + $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',download_lists='$download_lists',agent_shift_enforcement_override='$agent_shift_enforcement_override',manager_shift_enforcement_override='$manager_shift_enforcement_override',export_reports='$export_reports',delete_from_dnc='$delete_from_dnc',email='$email',user_code='$user_code',territory='$territory',allow_alerts='$allow_alerts',agent_choose_territories='$agent_choose_territories',custom_one='$custom_one',custom_two='$custom_two',custom_three='$custom_three',custom_four='$custom_four',custom_five='$custom_five',voicemail_id='$voicemail_id',agent_call_log_view_override='$agent_call_log_view_override',callcard_admin='$callcard_admin',agent_choose_blended='$agent_choose_blended',realtime_block_user_info='$realtime_block_user_info',custom_fields_modify='$custom_fields_modify',force_change_password='$force_change_password',agent_lead_search_override='$agent_lead_search',modify_shifts='$modify_shifts',modify_phones='$modify_phones',modify_carriers='$modify_carriers',modify_labels='$modify_labels',modify_statuses='$modify_statuses',modify_voicemail='$modify_voicemail',modify_audiostore='$modify_audiostore',modify_moh='$modify_moh',modify_tts='$modify_tts',preset_contact_search='$preset_contact_search',modify_contacts='$modify_contacts',modify_same_user_level='$modify_same_user_level',admin_hide_lead_data='$admin_hide_lead_data',admin_hide_phone_data='$admin_hide_phone_data',agentcall_email='$agentcall_email',modify_email_accounts='$modify_email_accounts' where user='$user' $LOGadmin_viewable_groupsSQL;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -15192,7 +15605,7 @@ if ($ADD==41) if (strlen($groups_value)>2) {$groups_value .= " -";} } - $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', auto_trim_hopper='$auto_trim_hopper', use_auto_hopper='$use_auto_hopper', auto_hopper_multi='$auto_hopper_multi', $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=$closer_campaignsSQL,use_internal_dnc='$use_internal_dnc',allcalls_delay='$allcalls_delay',omit_phone_code='$omit_phone_code',dial_method='$dial_method',available_only_ratio_tally='$available_only_ratio_tally',adaptive_dropped_percentage='$adaptive_dropped_percentage',adaptive_maximum_level='$adaptive_maximum_level',adaptive_latest_server_time='$adaptive_latest_server_time',adaptive_intensity='$adaptive_intensity',adaptive_dl_diff_target='$adaptive_dl_diff_target',concurrent_transfers='$concurrent_transfers',auto_alt_dial='$auto_alt_dial',agent_pause_codes_active='$agent_pause_codes_active',campaign_description='$campaign_description',campaign_changedate='$SQLdate',campaign_stats_refresh='$campaign_stats_refresh',disable_alter_custdata='$disable_alter_custdata',no_hopper_leads_logins='$no_hopper_leads_logins',list_order_mix='$list_order_mix',campaign_allow_inbound='$campaign_allow_inbound',manual_dial_list_id='$manual_dial_list_id',default_xfer_group='$default_xfer_group',xfer_groups='$XFERgroups_value',queue_priority='$queue_priority',drop_inbound_group='$drop_inbound_group',disable_alter_custphone='$disable_alter_custphone',display_queue_count='$display_queue_count',manual_dial_filter='$manual_dial_filter',agent_clipboard_copy='$agent_clipboard_copy',agent_extended_alt_dial='$agent_extended_alt_dial',use_campaign_dnc='$use_campaign_dnc',three_way_call_cid='$three_way_call_cid',three_way_dial_prefix='$three_way_dial_prefix',web_form_target='$web_form_target',vtiger_search_category='$vtiger_search_category',vtiger_create_call_record='$vtiger_create_call_record',vtiger_create_lead_record='$vtiger_create_lead_record',vtiger_screen_login='$vtiger_screen_login',cpd_amd_action='$cpd_amd_action',agent_allow_group_alias='$agent_allow_group_alias',default_group_alias='$default_group_alias',vtiger_search_dead='$vtiger_search_dead',vtiger_status_call='$vtiger_status_call',drop_lockout_time='$drop_lockout_time',quick_transfer_button='$quick_transfer_button',prepopulate_transfer_preset='$prepopulate_transfer_preset',drop_rate_group='$drop_rate_group',view_calls_in_queue='$view_calls_in_queue',view_calls_in_queue_launch='$view_calls_in_queue_launch',grab_calls_in_queue='$grab_calls_in_queue',call_requeue_button='$call_requeue_button',pause_after_each_call='$pause_after_each_call',no_hopper_dialing='$no_hopper_dialing',agent_dial_owner_only='$agent_dial_owner_only',agent_display_dialable_leads='$agent_display_dialable_leads',web_form_address_two='" . mysql_real_escape_string($web_form_address_two) . "',waitforsilence_options='$waitforsilence_options',agent_select_territories='$agent_select_territories',crm_popup_login='$crm_popup_login',crm_login_address='" . mysql_real_escape_string($crm_login_address) . "',timer_action='$timer_action',timer_action_message='$timer_action_message',timer_action_seconds='$timer_action_seconds',start_call_url='" . mysql_real_escape_string($start_call_url) . "',dispo_call_url='" . mysql_real_escape_string($dispo_call_url) . "',xferconf_c_number='$xferconf_c_number',xferconf_d_number='$xferconf_d_number',xferconf_e_number='$xferconf_e_number',use_custom_cid='$use_custom_cid',scheduled_callbacks_alert='$scheduled_callbacks_alert',queuemetrics_callstatus_override='$queuemetrics_callstatus',extension_appended_cidname='$extension_appended_cidname',scheduled_callbacks_count='$scheduled_callbacks_count',manual_dial_override='$manual_dial_override',blind_monitor_warning='$blind_monitor_warning',blind_monitor_message='" . mysql_real_escape_string($blind_monitor_message) . "',blind_monitor_filename='$blind_monitor_filename',inbound_queue_no_dial='$inbound_queue_no_dial',timer_action_destination='$timer_action_destination',enable_xfer_presets='$enable_xfer_presets',hide_xfer_number_to_dial='$hide_xfer_number_to_dial',manual_dial_prefix='$manual_dial_prefix',customer_3way_hangup_logging='$customer_3way_hangup_logging',customer_3way_hangup_seconds='$customer_3way_hangup_seconds',customer_3way_hangup_action='$customer_3way_hangup_action',ivr_park_call='$ivr_park_call',ivr_park_call_agi='$ivr_park_call_agi',manual_preview_dial='$manual_preview_dial',realtime_agent_time_stats='$realtime_agent_time_stats',api_manual_dial='$api_manual_dial',manual_dial_call_time_check='$manual_dial_call_time_check',lead_order_randomize='$lead_order_randomize',lead_order_secondary='$lead_order_secondary',per_call_notes='$per_call_notes',my_callback_option='$my_callback_option',agent_lead_search='$agent_lead_search',agent_lead_search_method='$agent_lead_search_method',queuemetrics_phone_environment='$queuemetrics_phone_environment',auto_pause_precall='$auto_pause_precall',auto_resume_precall='$auto_resume_precall',auto_pause_precall_code='$auto_pause_precall_code',manual_dial_cid='$manual_dial_cid',post_phone_time_diff_alert='$post_phone_time_diff_alert',custom_3way_button_transfer='$custom_3way_button_transfer',available_only_tally_threshold='$available_only_tally_threshold',available_only_tally_threshold_agents='$available_only_tally_threshold_agents',dial_level_threshold='$dial_level_threshold',dial_level_threshold_agents='$dial_level_threshold_agents',safe_harbor_audio='$safe_harbor_audio',safe_harbor_menu_id='$safe_harbor_menu_id',callback_days_limit='$callback_days_limit',dl_diff_target_method='$dl_diff_target_method',disable_dispo_screen='$disable_dispo_screen',disable_dispo_status='$disable_dispo_status',screen_labels='$screen_labels',status_display_fields='$status_display_fields',na_call_url='" . mysql_real_escape_string($na_call_url) . "',pllb_grouping='$pllb_grouping',pllb_grouping_limit='$pllb_grouping_limit',call_count_limit='$call_count_limit',call_count_target='$call_count_target',callback_hours_block='$callback_hours_block',callback_list_calltime='$callback_list_calltime',user_group='$user_group',hopper_vlc_dup_check='$hopper_vlc_dup_check',in_group_dial='$in_group_dial',in_group_dial_select='$in_group_dial_select',safe_harbor_audio_field='$safe_harbor_audio_field',pause_after_next_call='$pause_after_next_call',owner_populate='$owner_populate',use_other_campaign_dnc='$use_other_campaign_dnc' 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', auto_trim_hopper='$auto_trim_hopper', use_auto_hopper='$use_auto_hopper', auto_hopper_multi='$auto_hopper_multi', $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=$closer_campaignsSQL,use_internal_dnc='$use_internal_dnc',allcalls_delay='$allcalls_delay',omit_phone_code='$omit_phone_code',dial_method='$dial_method',available_only_ratio_tally='$available_only_ratio_tally',adaptive_dropped_percentage='$adaptive_dropped_percentage',adaptive_maximum_level='$adaptive_maximum_level',adaptive_latest_server_time='$adaptive_latest_server_time',adaptive_intensity='$adaptive_intensity',adaptive_dl_diff_target='$adaptive_dl_diff_target',concurrent_transfers='$concurrent_transfers',auto_alt_dial='$auto_alt_dial',agent_pause_codes_active='$agent_pause_codes_active',campaign_description='$campaign_description',campaign_changedate='$SQLdate',campaign_stats_refresh='$campaign_stats_refresh',disable_alter_custdata='$disable_alter_custdata',no_hopper_leads_logins='$no_hopper_leads_logins',list_order_mix='$list_order_mix',campaign_allow_inbound='$campaign_allow_inbound',manual_dial_list_id='$manual_dial_list_id',default_xfer_group='$default_xfer_group',xfer_groups='$XFERgroups_value',queue_priority='$queue_priority',drop_inbound_group='$drop_inbound_group',disable_alter_custphone='$disable_alter_custphone',display_queue_count='$display_queue_count',manual_dial_filter='$manual_dial_filter',agent_clipboard_copy='$agent_clipboard_copy',agent_extended_alt_dial='$agent_extended_alt_dial',use_campaign_dnc='$use_campaign_dnc',three_way_call_cid='$three_way_call_cid',three_way_dial_prefix='$three_way_dial_prefix',web_form_target='$web_form_target',vtiger_search_category='$vtiger_search_category',vtiger_create_call_record='$vtiger_create_call_record',vtiger_create_lead_record='$vtiger_create_lead_record',vtiger_screen_login='$vtiger_screen_login',cpd_amd_action='$cpd_amd_action',agent_allow_group_alias='$agent_allow_group_alias',default_group_alias='$default_group_alias',vtiger_search_dead='$vtiger_search_dead',vtiger_status_call='$vtiger_status_call',drop_lockout_time='$drop_lockout_time',quick_transfer_button='$quick_transfer_button',prepopulate_transfer_preset='$prepopulate_transfer_preset',drop_rate_group='$drop_rate_group',view_calls_in_queue='$view_calls_in_queue',view_calls_in_queue_launch='$view_calls_in_queue_launch',grab_calls_in_queue='$grab_calls_in_queue',call_requeue_button='$call_requeue_button',pause_after_each_call='$pause_after_each_call',no_hopper_dialing='$no_hopper_dialing',agent_dial_owner_only='$agent_dial_owner_only',agent_display_dialable_leads='$agent_display_dialable_leads',web_form_address_two='" . mysql_real_escape_string($web_form_address_two) . "',waitforsilence_options='$waitforsilence_options',agent_select_territories='$agent_select_territories',crm_popup_login='$crm_popup_login',crm_login_address='" . mysql_real_escape_string($crm_login_address) . "',timer_action='$timer_action',timer_action_message='$timer_action_message',timer_action_seconds='$timer_action_seconds',start_call_url='" . mysql_real_escape_string($start_call_url) . "',dispo_call_url='" . mysql_real_escape_string($dispo_call_url) . "',xferconf_c_number='$xferconf_c_number',xferconf_d_number='$xferconf_d_number',xferconf_e_number='$xferconf_e_number',use_custom_cid='$use_custom_cid',scheduled_callbacks_alert='$scheduled_callbacks_alert',queuemetrics_callstatus_override='$queuemetrics_callstatus',extension_appended_cidname='$extension_appended_cidname',scheduled_callbacks_count='$scheduled_callbacks_count',manual_dial_override='$manual_dial_override',blind_monitor_warning='$blind_monitor_warning',blind_monitor_message='" . mysql_real_escape_string($blind_monitor_message) . "',blind_monitor_filename='$blind_monitor_filename',inbound_queue_no_dial='$inbound_queue_no_dial',timer_action_destination='$timer_action_destination',enable_xfer_presets='$enable_xfer_presets',hide_xfer_number_to_dial='$hide_xfer_number_to_dial',manual_dial_prefix='$manual_dial_prefix',customer_3way_hangup_logging='$customer_3way_hangup_logging',customer_3way_hangup_seconds='$customer_3way_hangup_seconds',customer_3way_hangup_action='$customer_3way_hangup_action',ivr_park_call='$ivr_park_call',ivr_park_call_agi='$ivr_park_call_agi',manual_preview_dial='$manual_preview_dial',realtime_agent_time_stats='$realtime_agent_time_stats',api_manual_dial='$api_manual_dial',manual_dial_call_time_check='$manual_dial_call_time_check',lead_order_randomize='$lead_order_randomize',lead_order_secondary='$lead_order_secondary',per_call_notes='$per_call_notes',my_callback_option='$my_callback_option',agent_lead_search='$agent_lead_search',agent_lead_search_method='$agent_lead_search_method',queuemetrics_phone_environment='$queuemetrics_phone_environment',auto_pause_precall='$auto_pause_precall',auto_resume_precall='$auto_resume_precall',auto_pause_precall_code='$auto_pause_precall_code',manual_dial_cid='$manual_dial_cid',post_phone_time_diff_alert='$post_phone_time_diff_alert',custom_3way_button_transfer='$custom_3way_button_transfer',available_only_tally_threshold='$available_only_tally_threshold',available_only_tally_threshold_agents='$available_only_tally_threshold_agents',dial_level_threshold='$dial_level_threshold',dial_level_threshold_agents='$dial_level_threshold_agents',safe_harbor_audio='$safe_harbor_audio',safe_harbor_menu_id='$safe_harbor_menu_id',callback_days_limit='$callback_days_limit',dl_diff_target_method='$dl_diff_target_method',disable_dispo_screen='$disable_dispo_screen',disable_dispo_status='$disable_dispo_status',screen_labels='$screen_labels',status_display_fields='$status_display_fields',na_call_url='" . mysql_real_escape_string($na_call_url) . "',pllb_grouping='$pllb_grouping',pllb_grouping_limit='$pllb_grouping_limit',call_count_limit='$call_count_limit',call_count_target='$call_count_target',callback_hours_block='$callback_hours_block',callback_list_calltime='$callback_list_calltime',user_group='$user_group',hopper_vlc_dup_check='$hopper_vlc_dup_check',in_group_dial='$in_group_dial',in_group_dial_select='$in_group_dial_select',safe_harbor_audio_field='$safe_harbor_audio_field',pause_after_next_call='$pause_after_next_call',owner_populate='$owner_populate',use_other_campaign_dnc='$use_other_campaign_dnc',allow_emails='$allow_emails' where campaign_id='$campaign_id';"; $rslt=mysql_query($stmtA, $link); if ($reset_hopper == 'Y') @@ -16074,7 +16487,7 @@ if ($ADD==411) # ADD=4111 modify in-group info in the system ###################### -if ($ADD==4111) +if ($ADD==4111 || $ADD==4811) { if ($SUB=='agents_select') { @@ -16255,7 +16668,7 @@ if ($ADD==4111) exit; } } - $ADD=3111; # go to in-group modification form below + $ADD-=1000; #$ADD=3111; # go to in-group modification form below } @@ -17781,7 +18194,7 @@ if ($ADD==411111111111111) } $tables_use_alt_log_db = preg_replace("/,$/","",$new_altlog_value); - $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',qc_features_active='$qc_features_active',outbound_autodial_active='$outbound_autodial_active',outbound_calls_per_second='$outbound_calls_per_second',enable_tts_integration='$enable_tts_integration',agentonly_callback_campaign_lock='$agentonly_callback_campaign_lock',sounds_central_control_active='$sounds_central_control_active',sounds_web_server='$sounds_web_server',sounds_web_directory='$sounds_web_directory',active_voicemail_server='$active_voicemail_server',auto_dial_limit='$auto_dial_limit',user_territories_active='$user_territories_active',allow_custom_dialplan='$allow_custom_dialplan',enable_second_webform='$enable_second_webform',default_webphone='$default_webphone',default_external_server_ip='$default_external_server_ip',webphone_url='" . mysql_real_escape_string($webphone_url) . "',enable_agc_dispo_log='$enable_agc_dispo_log',custom_dialplan_entry='$custom_dialplan_entry',queuemetrics_loginout='$queuemetrics_loginout',callcard_enabled='$callcard_enabled',queuemetrics_callstatus='$queuemetrics_callstatus',default_codecs='$default_codecs',admin_web_directory='$admin_web_directory',label_title='$label_title',label_first_name='$label_first_name',label_middle_initial='$label_middle_initial',label_last_name='$label_last_name',label_address1='$label_address1',label_address2='$label_address2',label_address3='$label_address3',label_city='$label_city',label_state='$label_state',label_province='$label_province',label_postal_code='$label_postal_code',label_vendor_lead_code='$label_vendor_lead_code',label_gender='$label_gender',label_phone_number='$label_phone_number',label_phone_code='$label_phone_code',label_alt_phone='$label_alt_phone',label_security_phrase='$label_security_phrase',label_email='$label_email',label_comments='$label_comments',custom_fields_enabled='$custom_fields_enabled',slave_db_server='$slave_db_server',reports_use_slave_db='$reports_use_slave_db',webphone_systemkey='$webphone_systemkey',first_login_trigger='$first_login_trigger',default_phone_registration_password='$default_phone_registration_password',default_phone_login_password='$default_phone_login_password',default_server_password='$default_server_password',admin_modify_refresh='$admin_modify_refresh',nocache_admin='$nocache_admin',generate_cross_server_exten='$generate_cross_server_exten',queuemetrics_addmember_enabled='$queuemetrics_addmember_enabled',queuemetrics_dispo_pause='$queuemetrics_dispo_pause',label_hide_field_logs='$label_hide_field_logs',queuemetrics_pe_phone_append='$queuemetrics_pe_phone_append',test_campaign_calls='$test_campaign_calls',agents_calls_reset='$agents_calls_reset',default_voicemail_timezone='$default_voicemail_timezone',default_local_gmt='$default_local_gmt',noanswer_log='$noanswer_log',alt_log_server_ip='$alt_log_server_ip',alt_log_dbname='$alt_log_dbname',alt_log_login='$alt_log_login',alt_log_pass='$alt_log_pass',tables_use_alt_log_db='$tables_use_alt_log_db',did_agent_log='$did_agent_log',campaign_cid_areacodes_enabled='$campaign_cid_areacodes_enabled',pllb_grouping_limit='$pllb_grouping_limit',did_ra_extensions_enabled='$did_ra_extensions_enabled',expanded_list_stats='$expanded_list_stats',contacts_enabled='$contacts_enabled',call_menu_qualify_enabled='$call_menu_qualify_enabled',admin_list_counts='$admin_list_counts',allow_voicemail_greeting='$allow_voicemail_greeting',queuemetrics_socket='$queuemetrics_socket',queuemetrics_socket_url='$queuemetrics_socket_url',enhanced_disconnect_logging='$enhanced_disconnect_logging';"; + $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',qc_features_active='$qc_features_active',outbound_autodial_active='$outbound_autodial_active',outbound_calls_per_second='$outbound_calls_per_second',enable_tts_integration='$enable_tts_integration',agentonly_callback_campaign_lock='$agentonly_callback_campaign_lock',sounds_central_control_active='$sounds_central_control_active',sounds_web_server='$sounds_web_server',sounds_web_directory='$sounds_web_directory',active_voicemail_server='$active_voicemail_server',auto_dial_limit='$auto_dial_limit',user_territories_active='$user_territories_active',allow_custom_dialplan='$allow_custom_dialplan',enable_second_webform='$enable_second_webform',default_webphone='$default_webphone',default_external_server_ip='$default_external_server_ip',webphone_url='" . mysql_real_escape_string($webphone_url) . "',enable_agc_dispo_log='$enable_agc_dispo_log',custom_dialplan_entry='$custom_dialplan_entry',queuemetrics_loginout='$queuemetrics_loginout',callcard_enabled='$callcard_enabled',queuemetrics_callstatus='$queuemetrics_callstatus',default_codecs='$default_codecs',admin_web_directory='$admin_web_directory',label_title='$label_title',label_first_name='$label_first_name',label_middle_initial='$label_middle_initial',label_last_name='$label_last_name',label_address1='$label_address1',label_address2='$label_address2',label_address3='$label_address3',label_city='$label_city',label_state='$label_state',label_province='$label_province',label_postal_code='$label_postal_code',label_vendor_lead_code='$label_vendor_lead_code',label_gender='$label_gender',label_phone_number='$label_phone_number',label_phone_code='$label_phone_code',label_alt_phone='$label_alt_phone',label_security_phrase='$label_security_phrase',label_email='$label_email',label_comments='$label_comments',custom_fields_enabled='$custom_fields_enabled',slave_db_server='$slave_db_server',reports_use_slave_db='$reports_use_slave_db',webphone_systemkey='$webphone_systemkey',first_login_trigger='$first_login_trigger',default_phone_registration_password='$default_phone_registration_password',default_phone_login_password='$default_phone_login_password',default_server_password='$default_server_password',admin_modify_refresh='$admin_modify_refresh',nocache_admin='$nocache_admin',generate_cross_server_exten='$generate_cross_server_exten',queuemetrics_addmember_enabled='$queuemetrics_addmember_enabled',queuemetrics_dispo_pause='$queuemetrics_dispo_pause',label_hide_field_logs='$label_hide_field_logs',queuemetrics_pe_phone_append='$queuemetrics_pe_phone_append',test_campaign_calls='$test_campaign_calls',agents_calls_reset='$agents_calls_reset',default_voicemail_timezone='$default_voicemail_timezone',default_local_gmt='$default_local_gmt',noanswer_log='$noanswer_log',alt_log_server_ip='$alt_log_server_ip',alt_log_dbname='$alt_log_dbname',alt_log_login='$alt_log_login',alt_log_pass='$alt_log_pass',tables_use_alt_log_db='$tables_use_alt_log_db',did_agent_log='$did_agent_log',campaign_cid_areacodes_enabled='$campaign_cid_areacodes_enabled',pllb_grouping_limit='$pllb_grouping_limit',did_ra_extensions_enabled='$did_ra_extensions_enabled',expanded_list_stats='$expanded_list_stats',contacts_enabled='$contacts_enabled',call_menu_qualify_enabled='$call_menu_qualify_enabled',admin_list_counts='$admin_list_counts',allow_voicemail_greeting='$allow_voicemail_greeting',queuemetrics_socket='$queuemetrics_socket',queuemetrics_socket_url='$queuemetrics_socket_url',enhanced_disconnect_logging='$enhanced_disconnect_logging',allow_emails='$allow_emails';"; $rslt=mysql_query($stmt, $link); if ($reload_dialplan_on_servers > 0) @@ -20517,7 +20930,7 @@ if ($ADD==3) echo "\n"; echo "\n"; echo "\n"; + if ($SSallow_emails > 0) { + echo "\n"; + } + else + { + echo "\n"; + } echo "\n"; echo "\n"; if ($SSoutbound_autodial_active > 0) @@ -20820,6 +21242,13 @@ if ($ADD==3) echo "\n"; echo "\n"; echo "\n"; + if ($SSallow_emails > 0) { + echo "\n"; + } + else + { + echo "\n"; + } echo "\n"; echo "\n"; echo "\n"; @@ -20917,7 +21346,7 @@ if ($ADD==31) $enable_vtiger_integration_LU = $row[0]; $vtiger_url_LU = $row[1]; - $stmt="SELECT campaign_id,campaign_name,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,xfer_groups,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_shift_id,qc_get_record_launch,qc_show_recording,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,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_third_audio_file,survey_third_status,survey_third_exten,survey_fourth_digit,survey_fourth_audio_file,survey_fourth_status,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,campaign_calldate,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,use_custom_cid,scheduled_callbacks_alert,queuemetrics_callstatus_override,extension_appended_cidname,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,inbound_queue_no_dial,timer_action_destination,enable_xfer_presets,hide_xfer_number_to_dial,manual_dial_prefix,customer_3way_hangup_logging,customer_3way_hangup_seconds,customer_3way_hangup_action,ivr_park_call,ivr_park_call_agi,manual_preview_dial,realtime_agent_time_stats,use_auto_hopper,auto_hopper_multi,auto_trim_hopper,api_manual_dial,manual_dial_call_time_check,display_leads_count,lead_order_randomize,lead_order_secondary,per_call_notes,my_callback_option,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_resume_precall,auto_pause_precall_code,manual_dial_cid,post_phone_time_diff_alert,custom_3way_button_transfer,available_only_tally_threshold,available_only_tally_threshold_agents,dial_level_threshold,dial_level_threshold_agents,safe_harbor_audio,safe_harbor_menu_id,survey_menu_id,callback_days_limit,dl_diff_target_method,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,na_call_url,survey_recording,pllb_grouping,pllb_grouping_limit,call_count_limit,call_count_target,callback_hours_block,callback_list_calltime,user_group,hopper_vlc_dup_check,in_group_dial,in_group_dial_select,safe_harbor_audio_field,pause_after_next_call,owner_populate,use_other_campaign_dnc from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; + $stmt="SELECT campaign_id,campaign_name,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,xfer_groups,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_shift_id,qc_get_record_launch,qc_show_recording,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,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_third_audio_file,survey_third_status,survey_third_exten,survey_fourth_digit,survey_fourth_audio_file,survey_fourth_status,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,campaign_calldate,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,use_custom_cid,scheduled_callbacks_alert,queuemetrics_callstatus_override,extension_appended_cidname,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,inbound_queue_no_dial,timer_action_destination,enable_xfer_presets,hide_xfer_number_to_dial,manual_dial_prefix,customer_3way_hangup_logging,customer_3way_hangup_seconds,customer_3way_hangup_action,ivr_park_call,ivr_park_call_agi,manual_preview_dial,realtime_agent_time_stats,use_auto_hopper,auto_hopper_multi,auto_trim_hopper,api_manual_dial,manual_dial_call_time_check,display_leads_count,lead_order_randomize,lead_order_secondary,per_call_notes,my_callback_option,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_resume_precall,auto_pause_precall_code,manual_dial_cid,post_phone_time_diff_alert,custom_3way_button_transfer,available_only_tally_threshold,available_only_tally_threshold_agents,dial_level_threshold,dial_level_threshold_agents,safe_harbor_audio,safe_harbor_menu_id,survey_menu_id,callback_days_limit,dl_diff_target_method,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,na_call_url,survey_recording,pllb_grouping,pllb_grouping_limit,call_count_limit,call_count_target,callback_hours_block,callback_list_calltime,user_group,hopper_vlc_dup_check,in_group_dial,in_group_dial_select,safe_harbor_audio_field,pause_after_next_call,owner_populate,use_other_campaign_dnc,allow_emails from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $campaign_name = $row[1]; @@ -21130,6 +21559,7 @@ if ($ADD==31) $pause_after_next_call = $row[208]; $owner_populate = $row[209]; $use_other_campaign_dnc = $row[210]; + $allow_emails = $row[211]; if (ereg("DISABLED",$list_order_mix)) {$DEFlistDISABLE = ''; $DEFstatusDISABLED=0;} @@ -21427,7 +21857,14 @@ if ($ADD==31) } echo "\n"; echo "\n"; - + if ($SSallow_emails > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } if ($SSoutbound_autodial_active > 0) { echo "\n"; @@ -23258,7 +23695,7 @@ if ($ADD==34) $rslt=mysql_query($stmt, $link); } - $stmt="SELECT campaign_id,campaign_name,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,xfer_groups,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_shift_id,qc_get_record_launch,qc_show_recording,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,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_third_audio_file,survey_third_status,survey_third_exten,survey_fourth_digit,survey_fourth_audio_file,survey_fourth_status,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,display_leads_count,user_group from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; + $stmt="SELECT campaign_id,campaign_name,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,xfer_groups,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_shift_id,qc_get_record_launch,qc_show_recording,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,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_third_audio_file,survey_third_status,survey_third_exten,survey_fourth_digit,survey_fourth_audio_file,survey_fourth_status,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,display_leads_count,user_group,allow_emails from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $dial_status_a = $row[3]; @@ -23296,6 +23733,7 @@ if ($ADD==34) $drop_lockout_time = $row[116]; $display_leads_count = $row[130]; $user_group = $row[131]; + $allow_emails = $row[132]; if (ereg("DISABLED",$list_order_mix)) {$DEFlistDISABLE = ''; $DEFstatusDISABLED=0;} @@ -23424,6 +23862,11 @@ if ($ADD==34) echo "\n"; echo "\n"; echo "\n"; + if ($SSallow_emails > 0) + { + echo "\n"; + } + if ($SSoutbound_autodial_active > 0) { echo "\n"; @@ -25528,7 +25971,7 @@ if ($ADD==3111) echo "
    \n"; echo ""; - $stmt="SELECT user_id,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,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override,shift_override_flag,export_reports,delete_from_dnc,email,user_code,territory,allow_alerts,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five,voicemail_id,agent_call_log_view_override,callcard_admin,agent_choose_blended,realtime_block_user_info,custom_fields_modify,force_change_password,agent_lead_search_override,modify_shifts,modify_phones,modify_carriers,modify_labels,modify_statuses,modify_voicemail,modify_audiostore,modify_moh,modify_tts,preset_contact_search,modify_contacts,modify_same_user_level,admin_hide_lead_data,admin_hide_phone_data from vicidial_users where user='$user' $LOGadmin_viewable_groupsSQL;"; + $stmt="SELECT user_id,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,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override,shift_override_flag,export_reports,delete_from_dnc,email,user_code,territory,allow_alerts,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five,voicemail_id,agent_call_log_view_override,callcard_admin,agent_choose_blended,realtime_block_user_info,custom_fields_modify,force_change_password,agent_lead_search_override,modify_shifts,modify_phones,modify_carriers,modify_labels,modify_statuses,modify_voicemail,modify_audiostore,modify_moh,modify_tts,preset_contact_search,modify_contacts,modify_same_user_level,admin_hide_lead_data,admin_hide_phone_data,agentcall_email,modify_email_accounts from vicidial_users where user='$user' $LOGadmin_viewable_groupsSQL;"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $user_id = $row[0]; @@ -20616,6 +21029,8 @@ if ($ADD==3) $modify_same_user_level = $row[95]; $admin_hide_lead_data = $row[96]; $admin_hide_phone_data = $row[97]; + $agentcall_email = $row[98]; + $modify_email_accounts = $row[99]; if ( ( ($user_level >= $LOGuser_level) and ($LOGuser_level < 9) ) or ( ($LOGmodify_same_user_level < 1) and ($LOGuser_level > 8) and ($user_level > 8) ) ) { @@ -20710,6 +21125,13 @@ if ($ADD==3) echo "
    Scheduled Callbacks: $NWB#vicidial_users-scheduled_callbacks$NWE
    Agent-Only Callbacks: $NWB#vicidial_users-agentonly_callbacks$NWE
    Agent Call Manual: $NWB#vicidial_users-agentcall_manual$NWE
    Agent Call Email: $NWB#vicidial_users-agentcall_email$NWE
    Vicidial Recording: $NWB#vicidial_users-vicidial_recording$NWE
    Vicidial Transfers: $NWB#vicidial_users-vicidial_transfers$NWE
    Modify Shifts: $NWB#vicidial_users-modify_sections$NWE
    Modify Phones: $NWB#vicidial_users-modify_sections$NWE
    Modify Carriers: $NWB#vicidial_users-modify_sections$NWE
    Modify Email Accounts: $NWB#vicidial_users-modify_email_accounts$NWE
    Modify Labels: $NWB#vicidial_users-modify_sections$NWE
    Modify Statuses: $NWB#vicidial_users-modify_sections$NWE
    Modify Voicemail: $NWB#vicidial_users-modify_sections$NWE
    Web Form Target: $NWB#vicidial_campaigns-web_form_target$NWE
    Allow Closers: $NWB#vicidial_campaigns-allow_closers$NWE
    Allow Emails: $NWB#vicidial_campaigns-allow_emails$NWE
    Allow Inbound and Blended: $NWB#vicidial_campaigns-campaign_allow_inbound$NWE
    Web Form: $row[11]$NWB#vicidial_campaigns-web_form_address$NWE
    Allow Closers: $row[12] $NWB#vicidial_campaigns-allow_closers$NWE
    Default Transfer Group: $default_xfer_group $NWB#vicidial_campaigns-default_xfer_group$NWE
    Allow Emails: $allow_emails $NWB#vicidial_campaigns-allow_emails$NWE
    Allow Inbound and Blended: $campaign_allow_inbound $NWB#vicidial_campaigns-campaign_allow_inbound$NWE
    \n"; echo ""; - $stmt="SELECT group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename, eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,group_calldate,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid from vicidial_inbound_groups where group_id='$group_id' $LOGadmin_viewable_groupsSQL;"; + $stmt="SELECT group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename, eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,group_calldate,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid,group_handling from vicidial_inbound_groups where group_id='$group_id' $LOGadmin_viewable_groupsSQL;"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); @@ -25644,6 +26087,7 @@ if ($ADD==3111) $max_calls_count = $row[110]; $max_calls_action = $row[111]; $dial_ingroup_cid = $row[112]; + $group_handling = $row[113]; ##### get callmenu listings for dynamic pulldown $stmt="SELECT menu_id,menu_name from vicidial_call_menu $whereLOGadmin_viewable_groupsSQL order by menu_id;"; @@ -26537,6 +26981,708 @@ if ($ADD==3111) +###################### +# ADD=3811 modify in-group info in the system +###################### + +if ($ADD==3811) + { + if ( ($LOGmodify_ingroups==1) and ($SSallow_emails>0) ) + { + if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) ) + { + $modify_url = "$PHP_SELF?ADD=3811&group_id=$group_id"; + $modify_footer_refresh=1; + } + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; @@ -31825,6 +32974,61 @@ if ($ADD==1000) echo "
    \n"; + echo ""; + + $stmt="SELECT group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,ignore_list_script_override,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,timer_action_destination,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename, eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,na_call_url,on_hook_cid,group_calldate,action_xfer_cid,drop_callmenu,after_hours_callmenu,user_group,max_calls_method,max_calls_count,max_calls_action,dial_ingroup_cid,group_handling from vicidial_inbound_groups where group_id='$group_id' $LOGadmin_viewable_groupsSQL;"; + + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $group_name = $row[1]; + $group_color = $row[2]; + $active = $row[3]; + $web_form_address = stripslashes($row[4]); + $voicemail_ext = $row[5]; + $next_agent_call = $row[6]; + $fronter_display = $row[7]; + $script_id = $row[8]; + $get_call_launch = $row[9]; + $drop_call_seconds = $row[14]; + $drop_action = $row[15]; + $drop_exten = $row[16]; + $call_time_id = $row[17]; + $after_hours_action = $row[18]; + $after_hours_message_filename = $row[19]; + $after_hours_exten = $row[20]; + $after_hours_voicemail = $row[21]; + $welcome_message_filename = $row[22]; + $moh_context = $row[23]; + $onhold_prompt_filename = $row[24]; + $prompt_interval = $row[25]; + $agent_alert_exten = $row[26]; + $agent_alert_delay = $row[27]; + $default_xfer_group = $row[28]; + $queue_priority = $row[29]; + $drop_inbound_group = $row[30]; + $ingroup_recording_override = $row[31]; + $ingroup_rec_filename = $row[32]; + $afterhours_xfer_group = $row[33]; + $qc_enabled = $row[34]; + $qc_statuses = $row[35]; + $qc_shift_id = $row[36]; + $qc_get_record_launch = $row[37]; + $qc_show_recording = $row[38]; + $qc_web_form_address = stripslashes($row[39]); + $qc_script = $row[40]; + $play_place_in_line = $row[41]; + $play_estimate_hold_time = $row[42]; + $hold_time_option = $row[43]; + $hold_time_option_seconds = $row[44]; + $hold_time_option_exten = $row[45]; + $hold_time_option_voicemail = $row[46]; + $hold_time_option_xfer_group = $row[47]; + $hold_time_option_callback_filename = $row[48]; + $hold_time_option_callback_list_id = $row[49]; + $hold_recall_xfer_group = $row[50]; + $no_delay_call_route = $row[51]; + $play_welcome_message = $row[52]; + $answer_sec_pct_rt_stat_one = $row[53]; + $answer_sec_pct_rt_stat_two = $row[54]; + $default_group_alias = $row[55]; + $no_agent_no_queue = $row[56]; + $no_agent_action = $row[57]; + $no_agent_action_value = $row[58]; + $web_form_address_two = stripslashes($row[59]); + $timer_action = $row[60]; + $timer_action_message = $row[61]; + $timer_action_seconds = $row[62]; + $start_call_url = $row[63]; + $dispo_call_url = $row[64]; + $ignore_list_script_override = $row[68]; + $extension_appended_cidname = $row[69]; + $uniqueid_status_display = $row[70]; + $uniqueid_status_prefix = $row[71]; + $hold_time_option_minimum = $row[72]; + $hold_time_option_press_filename = $row[73]; + $hold_time_option_callmenu = $row[74]; + $onhold_prompt_no_block = $row[75]; + $onhold_prompt_seconds = $row[76]; + $hold_time_option_no_block = $row[77]; + $hold_time_option_prompt_seconds = $row[78]; + $hold_time_second_option = $row[79]; + $hold_time_third_option = $row[80]; + $wait_hold_option_priority = $row[81]; + $wait_time_option = $row[82]; + $wait_time_second_option = $row[83]; + $wait_time_third_option = $row[84]; + $wait_time_option_seconds = $row[85]; + $wait_time_option_exten = $row[86]; + $wait_time_option_voicemail = $row[87]; + $wait_time_option_xfer_group = $row[88]; + $wait_time_option_callmenu = $row[89]; + $wait_time_option_callback_filename = $row[90]; + $wait_time_option_callback_list_id = $row[91]; + $wait_time_option_press_filename = $row[92]; + $wait_time_option_no_block = $row[93]; + $wait_time_option_prompt_seconds = $row[94]; + $timer_action_destination = $row[95]; + $calculate_estimated_hold_seconds = $row[96]; + $add_lead_url = $row[97]; + $eht_minimum_prompt_filename = $row[98]; + $eht_minimum_prompt_no_block = $row[99]; + $eht_minimum_prompt_seconds = $row[100]; + $na_call_url = $row[102]; + $group_calldate = $row[104]; + $action_xfer_cid = $row[105]; + $drop_callmenu = $row[106]; + $after_hours_callmenu = $row[107]; + $user_group = $row[108]; + $max_calls_method = $row[109]; + $max_calls_count = $row[110]; + $max_calls_action = $row[111]; + $dial_ingroup_cid = $row[112]; + $group_handling = $row[113]; + + ##### get callmenu listings for dynamic pulldown + $stmt="SELECT menu_id,menu_name from vicidial_call_menu $whereLOGadmin_viewable_groupsSQL order by menu_id;"; + $rslt=mysql_query($stmt, $link); + $Xmenus_to_print = mysql_num_rows($rslt); + $o=0; + $Xmenuslist=''; + $Wmenuslist=''; + while ($Xmenus_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Xmenuslist .= "\n"; + $Wmenuslist .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]\n"; + $o++; + } + if ($Xmenus_selected < 1) + {$Xmenuslist .= "\n";} + if ($Wmenus_selected < 1) + {$Wmenuslist .= "\n";} + + + ##### get in-groups listings for dynamic pulldown + $stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') $LOGadmin_viewable_groupsSQL order by group_id;"; + $rslt=mysql_query($stmt, $link); + $Xgroups_to_print = mysql_num_rows($rslt); + $Xgroups_menu=''; + $Xgroups_selected=0; + $Dgroups_menu=''; + $Dgroups_selected=0; + $Agroups_menu=''; + $Agroups_selected=0; + $Hgroups_menu=''; + $Hgroups_selected=0; + $Wgroups_menu=''; + $Wgroups_selected=0; + $Tgroups_menu=''; + $Tgroups_selected=0; + $o=0; + while ($Xgroups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Xgroups_menu .= "\n"; + $Dgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]\n"; + if ($group_id!=$rowx[0]) + { + $Agroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]\n"; + $Tgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]\n"; + $Wgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]\n"; + $Hgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]\n"; + } + $o++; + } + if ($Xgroups_selected < 1) + {$Xgroups_menu .= "\n";} + else + {$Xgroups_menu .= "\n";} + if ($Dgroups_selected < 1) + {$Dgroups_menu .= "\n";} + else + {$Dgroups_menu .= "\n";} + if ($Agroups_selected < 1) + {$Agroups_menu .= "\n";} + else + {$Agroups_menu .= "\n";} + if ($Tgroups_selected < 1) + {$Tgroups_menu .= "\n";} + else + {$Tgroups_menu .= "\n";} + if ($Wgroups_selected < 1) + {$Wgroups_menu .= "\n";} + else + {$Wgroups_menu .= "\n";} + if ($Hgroups_selected < 1) + {$Hgroups_menu .= "\n";} + else + {$Hgroups_menu .= "\n";} + + + echo "
    MODIFY AN EMAIL GROUPS RECORD: $row[0]\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"; + if ($SSenable_second_webform > 0) + { + echo "\n"; + } + echo "\n"; + + echo "\n"; + + echo "\n"; + +/* Commenting this out because it is handled by the Email Account section and is redundant here + 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"; + + if ($SSqc_features_active > 0) + { + echo "\n"; + echo "\n"; + + ##### get status listings for dynamic pulldown + $qc_statuses = preg_replace("/^ | -$/","",$qc_statuses); + $QCstatuses = explode(" ", $qc_statuses); + $QCs_to_print = (count($QCstatuses) -0); + $stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback from vicidial_statuses where status NOT IN('QUEUE','INCALL') order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $qc_statuses_list=''; + + $o=0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $qc_statuses_list .= " $o) + { + $rowx=mysql_fetch_row($rslt); + if (!ereg("\"$rowx[0]\"",$qc_statuses_list)) + { + $qc_statuses_list .= " $o) + { + $rowx=mysql_fetch_row($rslt); + $QCscripts_list .= "\n"; + $scriptname_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + ##### get shifts listings for pulldown + $stmt="SELECT shift_id,shift_name from vicidial_shifts $whereLOGadmin_viewable_groupsSQL order by shift_id;"; + $rslt=mysql_query($stmt, $link); + $shifts_to_print = mysql_num_rows($rslt); + $QCshifts_list=""; + $o=0; + while ($shifts_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $QCshifts_list .= "\n"; + $shiftname_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "
    Group ID: $row[0]$NWB#vicidial_inbound_groups-group_id$NWE
    Group Name: $NWB#vicidial_inbound_groups-group_name$NWE
    Group Color: $NWB#vicidial_inbound_groups-group_color$NWE
    Active: $NWB#vicidial_inbound_groups-active$NWE
    In-Group Email Date: $group_calldate$NWB#vicidial_inbound_groups-group_emaildate$NWE
    \n"; + horizontal_bar_chart($group_id,'8','in-group',$link,'total_calls','call count',1); + echo "
    Admin User Group: $NWB#vicidial_inbound_groups-user_group$NWE
    Web Form: $NWB#vicidial_inbound_groups-web_form_address$NWE
    Web Form Two: $NWB#vicidial_inbound_groups-web_form_address$NWE
    Next Agent Email: $NWB#vicidial_inbound_groups-next_agent_email$NWE
    Queue Priority: $NWB#vicidial_inbound_groups-queue_priority$NWE
    Fronter Display: $NWB#vicidial_inbound_groups-fronter_display$NWE
    In-Group Call Handle Method: $NWB#vicidial_inbound_dids-call_handle_method$NWE
    In-Group Agent Search Method: $NWB#vicidial_inbound_dids-agent_search_method$NWE
    In-Group List ID: $NWB#vicidial_inbound_dids-list_id$NWE
    In-Group Campaign ID: $NWB#vicidial_inbound_dids-campaign_id$NWE
    Start Email URL: $NWB#vicidial_inbound_groups-start_email_url$NWE
    Dispo Email URL: $NWB#vicidial_inbound_groups-dispo_email_url$NWE
    Add Lead URL: $NWB#vicidial_inbound_groups-add_lead_url$NWE
    No Agent Email URL: $NWB#vicidial_inbound_groups-na_email_url$NWE
    Extension Append CID: $NWB#vicidial_inbound_groups-extension_appended_cidname$NWE
    Uniqueid Status Display: $NWB#vicidial_inbound_groups-uniqueid_status_display$NWE
    Uniqueid Status Prefix: $NWB#vicidial_inbound_groups-uniqueid_status_prefix$NWE
     
    Inbound Group QC Settings:
    QC Enabled: $NWB#vicidial_inbound_groups-qc_enabled$NWE
    QC Statuses:
    $NWB#vicidial_inbound_groups-qc_statuses$NWE
    $qc_statuses_list
    QC WebForm: $NWB#vicidial_inbound_groups-qc_web_form_address$NWE
    QC Script: $NWB#vicidial_inbound_groups-qc_script$NWE
    QC Shift: $NWB#vicidial_inbound_groups-qc_shift_id$NWE
    QC Get Record Launch: $NWB#vicidial_inbound_groups-qc_get_record_launch$NWE
    QC Show Recording: $NWB#vicidial_inbound_groups-qc_show_recording$NWE
    \n"; + echo "


    \n"; + + + ### list of agent rank or skill-level for this inbound group + echo "
    \n"; + echo "
    AGENT RANKS FOR THIS INBOUND GROUP:
    \n"; + echo "\n"; + echo "\n"; + + $stmt="SELECT user,full_name,closer_campaigns,user_group from vicidial_users where active='Y' $LOGadmin_viewable_groupsSQL order by user;"; + $rsltx=mysql_query($stmt, $link); + $users_to_print = mysql_num_rows($rsltx); + + $o=0; + while ($users_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $o++; + + $ARIG_user[$o] = $rowx[0]; + $ARIG_name[$o] = $rowx[1]; + $ARIG_close[$o] = $rowx[2]; + $ARIG_group[$o] = $rowx[3]; + $ARIG_check[$o] = ''; + if (preg_match("/ $group_id /",$ARIG_close[$o])) + {$ARIG_check[$o] = ' CHECKED';} + } + + $o=0; + $ARIG_changenotes=''; + $stmtDlog=''; + while ($users_to_print > $o) + { + $o++; + $stmt="SELECT group_rank,calls_today,group_grade from vicidial_inbound_group_agents where group_id='$group_id' and user='$ARIG_user[$o]';"; + $rsltx=mysql_query($stmt, $link); + $viga_to_print = mysql_num_rows($rsltx); + if ($viga_to_print > 0) + { + $rowx=mysql_fetch_row($rsltx); + $ARIG_rank[$o] = $rowx[0]; + $ARIG_calls[$o] = $rowx[1]; + $ARIG_grade[$o] = $rowx[2]; + } + else + { + $stmtD="INSERT INTO vicidial_inbound_group_agents set calls_today='0',group_rank='0',group_weight='0',user='$ARIG_user[$o]',group_id='$group_id',group_grade='1';"; + $rslt=mysql_query($stmtD, $link); + if ($DB > 0) {echo "|$stmtD|";} + $stmtDlog .= "$stmtD|"; + $ARIG_changenotes .= "added missing user to viga table $ARIG_user[$o]|"; + $ARIG_rank[$o] = '0'; + $ARIG_calls[$o] = '0'; + $ARIG_grade[$o] = '1'; + } + } + if (strlen($ARIG_changenotes) > 10) + { + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmtDlog|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='INGROUPS', event_type='MODIFY', record_id='$group_id', event_code='USER INGROUP VIGA ADD', event_sql=\"$SQL_log\", event_notes='$ARIG_changenotes';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + + + if ($stage=='SUBMIT') + { + $o=0; + while ($users_to_print > $o) + { + $o++; + + $ARIG_checked=''; + $ARIG_ranked=''; + $ARIG_graded=''; + + $checkbox_field="CHECK_$ARIG_user[$o]$US$group_id"; + $rank_field="RANK_$ARIG_user[$o]$US$group_id"; + $grade_field="GRADE_$ARIG_user[$o]$US$group_id"; + + if (isset($_GET["$checkbox_field"])) {$ARIG_checked=$_GET["$checkbox_field"];} + elseif (isset($_POST["$checkbox_field"])) {$ARIG_checked=$_POST["$checkbox_field"];} + if (isset($_GET["$rank_field"])) {$ARIG_ranked=$_GET["$rank_field"];} + elseif (isset($_POST["$rank_field"])) {$ARIG_ranked=$_POST["$rank_field"];} + if (isset($_GET["$grade_field"])) {$ARIG_graded=$_GET["$grade_field"];} + elseif (isset($_POST["$grade_field"])) {$ARIG_graded=$_POST["$grade_field"];} + $ARIG_checked = ereg_replace("[^A-Z]","",$ARIG_checked); + $ARIG_ranked = ereg_replace("[^-0-9]","",$ARIG_ranked); + $ARIG_graded = ereg_replace("[^-0-9]","",$ARIG_graded); + + $stmtA=''; + $stmtB=''; + $stmtC=''; + $ARIG_updated=0; + $ARIG_changenotes=''; + if ( ($ARIG_check[$o]=='') and ($ARIG_checked=='YES') ) + { + if (strlen($ARIG_close[$o]) < 4) {$ARIG_close[$o]=' - ';} + $stmtA="UPDATE vicidial_users set closer_campaigns=' $group_id$ARIG_close[$o]' where user='$ARIG_user[$o]';"; + $rslt=mysql_query($stmtA, $link); + if ($DB > 0) {echo "|$stmtA|";} + $ARIG_updated++; + $ARIG_changenotes .= "added $group_id to selected in-groups|"; + } + if ( ($ARIG_check[$o]==' CHECKED') and ($ARIG_checked=='') ) + { + $ARIG_close[$o] = preg_replace("/ $group_id /",' ',$ARIG_close[$o]); + $stmtB="UPDATE vicidial_users set closer_campaigns='$ARIG_close[$o]' where user='$ARIG_user[$o]';"; + $rslt=mysql_query($stmtB, $link); + if ($DB > 0) {echo "|$stmtB|";} + $ARIG_updated++; + $ARIG_changenotes .= "removed $group_id from selected in-groups|"; + } + if ( ($ARIG_ranked < $ARIG_rank[$o]) or ($ARIG_ranked > $ARIG_rank[$o]) ) + { + $stmtC="UPDATE vicidial_inbound_group_agents set group_rank='$ARIG_ranked',group_weight='$ARIG_ranked' where user='$ARIG_user[$o]' and group_id='$group_id';"; + $rslt=mysql_query($stmtC, $link); + if ($DB > 0) {echo "|$stmtC|";} + $ARIG_updated++; + $ARIG_changenotes .= "changed rank from $ARIG_rank[$o] to $ARIG_ranked|"; + } + if ( ($ARIG_graded < $ARIG_grade[$o]) or ($ARIG_graded > $ARIG_grade[$o]) ) + { + $stmtC="UPDATE vicidial_inbound_group_agents set group_grade='$ARIG_graded' where user='$ARIG_user[$o]' and group_id='$group_id';"; + $rslt=mysql_query($stmtC, $link); + if ($DB > 0) {echo "|$stmtC|";} + $ARIG_updated++; + $ARIG_changenotes .= "changed grade from $ARIG_grade[$o] to $ARIG_graded|"; + } + if ($ARIG_updated > 0) + { + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmtA|$stmtB|$stmtC|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='USERS', event_type='MODIFY', record_id='$ARIG_user[$o]', event_code='USER INGROUP SETTINGS', event_sql=\"$SQL_log\", event_notes='$ARIG_changenotes';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + + $stmt="SELECT vu.user,viga.group_rank,calls_today,full_name,closer_campaigns,viga.group_grade from vicidial_inbound_group_agents viga, vicidial_users vu where group_id='$group_id' and active='Y' and vu.user=viga.user $LOGadmin_viewable_groupsSQL order by vu.user;"; + $rsltx=mysql_query($stmt, $link); + $users_to_print = mysql_num_rows($rsltx); + + $o=0; + while ($users_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $o++; + + $ARIG_user[$o] = $rowx[0]; + $ARIG_rank[$o] = $rowx[1]; + $ARIG_calls[$o] = $rowx[2]; + $ARIG_name[$o] = $rowx[3]; + $ARIG_close[$o] = $rowx[4]; + $ARIG_grade[$o] = $rowx[5]; + $ARIG_check[$o] = ''; + if (preg_match("/ $group_id /",$ARIG_close[$o])) + {$ARIG_check[$o] = ' CHECKED';} + } + } + + $checkbox_count=0; + $o=0; + while ($users_to_print > $o) + { + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $checkbox_field="CHECK_$ARIG_user[$o]$US$group_id"; + $rank_field="RANK_$ARIG_user[$o]$US$group_id"; + $grade_field="GRADE_$ARIG_user[$o]$US$group_id"; + $checkbox_list .= "|$checkbox_field"; + $checkbox_count++; + + $users_output .= "\n"; + $users_output .= "\n"; + $users_output .= "\n"; + $users_output .= "\n"; + + echo "$users_output"; + + echo "\n"; + + echo "
    USERGROUPSELECTED     RANK     GRADE     CALLS TODAY
    $ARIG_user[$o] - $ARIG_name[$o]$ARIG_group[$o]     select all  

    \n"; + + echo "
    Click here to see a report for this inbound group

    \n"; + + echo "Click here to see agents logged in to this inbound group

    \n"; + + echo "
    \n"; + + echo "EMAIL ACCOUNTS USING THIS IN-GROUP:
    \n"; + echo "\n"; + + $stmt="SELECT email_account_id, email_account_name from vicidial_email_accounts where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $emails_to_print = mysql_num_rows($rslt); + $o=0; + while ($emails_to_print > $o) + { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + + echo "
    $row[0] $row[1]

    \n"; + echo "CAMPAIGNS ALLOWING THIS IN-GROUP:
    \n"; + echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where closer_campaigns LIKE \"% $group_id %\" $LOGallowed_campaignsSQL;"; + $rslt=mysql_query($stmt, $link); + $campin_to_print = mysql_num_rows($rslt); + $o=0; + while ($campin_to_print > $o) + { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + + echo "
    $row[0] $row[1]
    \n"; + + if ($LOGdelete_ingroups > 0) + { + # echo "

    EMERGENCY VDAC CLEAR FOR THIS IN-GROUP

    \n"; + echo "

    DELETE THIS IN-GROUP\n"; + } + if ($LOGuser_level >= 9) + { + echo "

    Click here to see Admin changes to this In-Group
    \n"; + } + } + else + { + echo "You do not have permission to view this page\n"; + exit; + } + + } + + + ###################### # ADD=3311 modify did info in the system ###################### @@ -30553,7 +31699,7 @@ if ($ADD==311111111111111) $ALLagent_count = $rowx[2]; } - $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,qc_features_active,outbound_autodial_active,outbound_calls_per_second,enable_tts_integration,agentonly_callback_campaign_lock,sounds_central_control_active,sounds_web_server,sounds_web_directory,active_voicemail_server,auto_dial_limit,user_territories_active,allow_custom_dialplan,db_schema_update_date,enable_second_webform,default_webphone,default_external_server_ip,webphone_url,enable_agc_dispo_log,custom_dialplan_entry,queuemetrics_loginout,callcard_enabled,queuemetrics_callstatus,default_codecs,admin_web_directory,label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments,custom_fields_enabled,slave_db_server,reports_use_slave_db,webphone_systemkey,first_login_trigger,default_phone_registration_password,default_phone_login_password,default_server_password,admin_modify_refresh,nocache_admin,generate_cross_server_exten,queuemetrics_addmember_enabled,queuemetrics_dispo_pause,label_hide_field_logs,queuemetrics_pe_phone_append,test_campaign_calls,agents_calls_reset,default_voicemail_timezone,default_local_gmt,noanswer_log,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,did_agent_log,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,call_menu_qualify_enabled,admin_list_counts,allow_voicemail_greeting,svn_revision,queuemetrics_socket,queuemetrics_socket_url,enhanced_disconnect_logging 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,qc_features_active,outbound_autodial_active,outbound_calls_per_second,enable_tts_integration,agentonly_callback_campaign_lock,sounds_central_control_active,sounds_web_server,sounds_web_directory,active_voicemail_server,auto_dial_limit,user_territories_active,allow_custom_dialplan,db_schema_update_date,enable_second_webform,default_webphone,default_external_server_ip,webphone_url,enable_agc_dispo_log,custom_dialplan_entry,queuemetrics_loginout,callcard_enabled,queuemetrics_callstatus,default_codecs,admin_web_directory,label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments,custom_fields_enabled,slave_db_server,reports_use_slave_db,webphone_systemkey,first_login_trigger,default_phone_registration_password,default_phone_login_password,default_server_password,admin_modify_refresh,nocache_admin,generate_cross_server_exten,queuemetrics_addmember_enabled,queuemetrics_dispo_pause,label_hide_field_logs,queuemetrics_pe_phone_append,test_campaign_calls,agents_calls_reset,default_voicemail_timezone,default_local_gmt,noanswer_log,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,did_agent_log,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,call_menu_qualify_enabled,admin_list_counts,allow_voicemail_greeting,svn_revision,queuemetrics_socket,queuemetrics_socket_url,enhanced_disconnect_logging,allow_emails from system_settings;"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $version = $row[0]; @@ -30668,6 +31814,7 @@ if ($ADD==311111111111111) $queuemetrics_socket = $row[109]; $queuemetrics_socket_url = $row[110]; $enhanced_disconnect_logging = $row[111]; + $allow_emails = $row[112]; echo "
    MODIFY VICIDIAL SYSTEM SETTINGS
    \n"; echo "\n"; @@ -30862,6 +32009,8 @@ if ($ADD==311111111111111) echo "
    Admin List Counts: $NWB#settings-admin_list_counts$NWE
    Allow Emails: $NWB#settings-allow_emails$NWE
    First Login Trigger: $first_login_trigger   $NWB#settings-first_login_trigger$NWE
    Default Phone Registration Password: $NWB#settings-default_phone_registration_password$NWE     Strength:
    \n"; } +###################### +# ADD=1800 display all email groups +###################### +if ( ($ADD==1800) and ($SSallow_emails>0) ) + { + echo "
    \n"; + echo ""; + + $stmt="SELECT group_id,group_name,queue_priority,active,call_time_id,group_color,user_group from vicidial_inbound_groups where group_handling='EMAIL' $LOGadmin_viewable_groupsSQL order by group_id;"; + $rslt=mysql_query($stmt, $link); + $ingroups_to_print = mysql_num_rows($rslt); + + echo "
    EMAIL GROUP LISTINGS:\n"; + echo "
    \n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + + $o=0; + while ($ingroups_to_print > $o) + { + $row=mysql_fetch_row($rslt); + + ## Get unhandled count + $ct_stmt="select count(*) From vicidial_email_list where status='NEW' and group_id='$row[0]'"; + $ct_rslt=mysql_query($ct_stmt, $link); + $ct_row=mysql_fetch_row($ct_rslt); + $unhandled_emails=$ct_row[0]; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
    IN-GROUPNAMEPRIORITYACTIVEUNREAD EMAILSADMIN GROUPTIMECOLORMODIFY
    $row[0] $row[1] $row[2] $row[3] $unhandled_emails $row[6] $row[4]  MODIFY
    \n"; + } ###################### # ADD=1300 display all inbound dids @@ -33691,6 +34895,10 @@ if ($ADD==999998) echo "
  • System Statuses \n"; echo "
  • Voicemail \n"; + if ($SSemail_enabled > 0) + { + echo "
  • Email Accounts \n"; + } if ( ($sounds_central_control_active > 0) or ($SSsounds_central_control_active > 0) ) { echo "
  • Audio Store \n"; diff --git a/agc_2-X/trunk/www/vicidial/admin_email_accounts.php b/agc_2-X/trunk/www/vicidial/admin_email_accounts.php new file mode 100644 index 00000000..488c2c3c --- /dev/null +++ b/agc_2-X/trunk/www/vicidial/admin_email_accounts.php @@ -0,0 +1,864 @@ + LICENSE: AGPLv2 +# +# This page manages the inbound email accounts in ViciDial +# +# changes: +# 121214-2245 - First Build +# + +$admin_version = '2.6-1'; +$build = '121214-2245'; + +$sh="emails"; + +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["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["action"])) {$action=$_GET["action"];} + elseif (isset($_POST["action"])) {$action=$_POST["action"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["eact"])) {$eact=$_GET["eact"];} + elseif (isset($_POST["eact"])) {$eact=$_POST["eact"];} +if (isset($_GET["email_account_id"])) {$email_account_id=$_GET["email_account_id"];} + elseif (isset($_POST["email_account_id"])) {$email_account_id=$_POST["email_account_id"];} +if (isset($_GET["email_account_name"])) {$email_account_name=$_GET["email_account_name"];} + elseif (isset($_POST["email_account_name"])) {$email_account_name=$_POST["email_account_name"];} +if (isset($_GET["email_account_description"])) {$email_account_description=$_GET["email_account_description"];} + elseif (isset($_POST["email_account_description"])) {$email_account_description=$_POST["email_account_description"];} +if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];} + elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["email_account_server"])) {$email_account_server=$_GET["email_account_server"];} + elseif (isset($_POST["email_account_server"])) {$email_account_server=$_POST["email_account_server"];} +if (isset($_GET["email_account_user"])) {$email_account_user=$_GET["email_account_user"];} + elseif (isset($_POST["email_account_user"])) {$email_account_user=$_POST["email_account_user"];} +if (isset($_GET["email_account_pass"])) {$email_account_pass=$_GET["email_account_pass"];} + elseif (isset($_POST["email_account_pass"])) {$email_account_pass=$_POST["email_account_pass"];} +if (isset($_GET["active"])) {$active=$_GET["active"];} + elseif (isset($_POST["active"])) {$active=$_POST["active"];} +if (isset($_GET["email_frequency_check_mins"])) {$email_frequency_check_mins=$_GET["email_frequency_check_mins"];} + elseif (isset($_POST["email_frequency_check_mins"])) {$email_frequency_check_mins=$_POST["email_frequency_check_mins"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["default_list_id"])) {$default_list_id=$_GET["default_list_id"];} + elseif (isset($_POST["default_list_id"])) {$default_list_id=$_POST["default_list_id"];} +if (isset($_GET["group_id"])) {$group_id=$_GET["group_id"];} + elseif (isset($_POST["group_id"])) {$group_id=$_POST["group_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["new_account_id"])) {$new_account_id=$_GET["new_account_id"];} + elseif (isset($_POST["new_account_id"])) {$new_account_id=$_POST["new_account_id"];} +if (isset($_GET["source_email_account"])) {$source_email_account=$_GET["source_email_account"];} + elseif (isset($_POST["source_email_account"])) {$source_email_account=$_POST["source_email_account"];} +if (isset($_GET["confirm_deletion"])) {$confirm_deletion=$_GET["confirm_deletion"];} + elseif (isset($_POST["confirm_deletion"])) {$confirm_deletion=$_POST["confirm_deletion"];} +if (isset($_GET["email_replyto_address"])) {$email_replyto_address=$_GET["email_replyto_address"];} + elseif (isset($_POST["email_replyto_address"])) {$email_replyto_address=$_POST["email_replyto_address"];} +if (isset($_GET["email_replyto_address"])) {$email_replyto_address=$_GET["email_replyto_address"];} + elseif (isset($_POST["email_replyto_address"])) {$email_replyto_address=$_POST["email_replyto_address"];} +if (isset($_GET["email_account_type"])) {$email_account_type=$_GET["email_account_type"];} + elseif (isset($_POST["email_account_type"])) {$email_account_type=$_POST["email_account_type"];} +if (isset($_GET["call_handle_method"])) {$call_handle_method=$_GET["call_handle_method"];} + elseif (isset($_POST["call_handle_method"])) {$call_handle_method=$_POST["call_handle_method"];} +if (isset($_GET["agent_search_method"])) {$agent_search_method=$_GET["agent_search_method"];} + elseif (isset($_POST["agent_search_method"])) {$agent_search_method=$_POST["agent_search_method"];} + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,enable_queuemetrics_logging,enable_vtiger_integration,qc_features_active,outbound_autodial_active,sounds_central_control_active,enable_second_webform,user_territories_active,custom_fields_enabled,admin_web_directory,webphone_url,first_login_trigger,hosted_settings,default_phone_registration_password,default_phone_login_password,default_server_password,test_campaign_calls,active_voicemail_server,voicemail_timezones,default_voicemail_timezone,default_local_gmt,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,allow_emails,email_enabled FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $SSenable_queuemetrics_logging = $row[1]; + $SSenable_vtiger_integration = $row[2]; + $SSqc_features_active = $row[3]; + $SSoutbound_autodial_active = $row[4]; + $SSsounds_central_control_active = $row[5]; + $SSenable_second_webform = $row[6]; + $SSuser_territories_active = $row[7]; + $SScustom_fields_enabled = $row[8]; + $SSadmin_web_directory = $row[9]; + $SSwebphone_url = $row[10]; + $SSfirst_login_trigger = $row[11]; + $SShosted_settings = $row[12]; + $SSdefault_phone_registration_password =$row[13]; + $SSdefault_phone_login_password = $row[14]; + $SSdefault_server_password = $row[15]; + $SStest_campaign_calls = $row[16]; + $SSactive_voicemail_server = $row[17]; + $SSvoicemail_timezones = $row[18]; + $SSdefault_voicemail_timezone = $row[19]; + $SSdefault_local_gmt = $row[20]; + $SScampaign_cid_areacodes_enabled = $row[21]; + $SSpllb_grouping_limit = $row[22]; + $SSdid_ra_extensions_enabled = $row[23]; + $SSexpanded_list_stats = $row[24]; + $SScontacts_enabled = $row[25]; + $SSalt_log_server_ip = $row[26]; + $SSalt_log_dbname = $row[27]; + $SSalt_log_login = $row[28]; + $SSalt_log_pass = $row[29]; + $SStables_use_alt_log_db = $row[30]; + $SSallow_emails = $row[31]; + $SSemail_enabled = $row[32]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ($non_latin < 1) + { + $PHP_AUTH_USER = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_USER); + $PHP_AUTH_PW = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_PW); + + $email_account_id = ereg_replace("[^_0-9a-zA-Z]","",$email_account_id); + $email_account_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$email_account_name); + $email_account_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$email_account_description); + $user_group = ereg_replace("[^_0-9a-zA-Z]","",$user_group); + $protocol = preg_replace("/^(IMAP|POP3|SMTP)/","",$protocol); + $email_account_server = ereg_replace("[^\.\-\_0-9a-zA-Z]","",$email_account_server); + $active = preg_replace("/^(Y|N)/","",$active); + $email_frequency_check_mins = preg_replace("/^0-9/","",$email_frequency_check_mins); + $list_id = ereg_replace("[^0-9]","",$list_id); + + } # end of non_latin +else + { + $PHP_AUTH_USER = ereg_replace("'|\"|\\\\|;","",$PHP_AUTH_USER); + $PHP_AUTH_PW = ereg_replace("'|\"|\\\\|;","",$PHP_AUTH_PW); + } + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and modify_email_accounts='1';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +if ($webroot_writable > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$user = $PHP_AUTH_USER; + +if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } +else + { + if ($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name,user_level,user_group,modify_email_accounts 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[0]; + $LOGuser_level = $row[1]; + $LOGuser_group = $row[2]; + $LOGemails_modify = $row[3]; + + $stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGallowed_campaigns = $row[0]; + $LOGallowed_reports = $row[1]; + $LOGadmin_viewable_groups = $row[2]; + $LOGadmin_viewable_call_times = $row[3]; + $admin_viewable_groupsALL=0; + $LOGadmin_viewable_groupsSQL=''; + $whereLOGadmin_viewable_groupsSQL=''; + $valLOGadmin_viewable_groupsSQL=''; + $vmLOGadmin_viewable_groupsSQL=''; + if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $valLOGadmin_viewable_groupsSQL = "and val.user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $vmLOGadmin_viewable_groupsSQL = "and vm.user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + else + {$admin_viewable_groupsALL=1;} + $regexLOGadmin_viewable_groups = " $LOGadmin_viewable_groups "; + + $UUgroups_list=''; + if ($admin_viewable_groupsALL > 0) + {$UUgroups_list .= "\n";} + $stmt="SELECT user_group,group_name from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;"; + $rslt=mysql_query($stmt, $link); + $UUgroups_to_print = mysql_num_rows($rslt); + $o=0; + while ($UUgroups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $UUgroups_list .= "\n"; + $o++; + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_handling='EMAIL' $LOGadmin_viewable_groupsSQL order by group_id;"; + # $stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') order by group_id"; + $rslt=mysql_query($stmt, $link); + $Dgroups_to_print = mysql_num_rows($rslt); + $Dgroups_menu=''; + $Dgroups_selected=0; + $o=0; + while ($Dgroups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Dgroups_menu .= "\n"; + $o++; + } + if ($Dgroups_selected < 1) + {$Dgroups_menu .= "\n";} + else + {$Dgroups_menu .= "\n";} + + + if ($webroot_writable > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|XXXX|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($webroot_writable > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|XXXX|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + +ADMINISTRATION: Dialer Email Account fields +<?php + +##### BEGIN Set variables to make header show properly ##### +$ADD = '0'; +$hh = 'admin'; +$sh = 'emails'; +$LOGast_admin_access = '1'; +$ADMIN = 'admin.php'; +$page_width='770'; +$section_width='750'; +$header_font_size='3'; +$subheader_font_size='2'; +$subcamp_font_size='2'; +$header_selected_bold='<b>'; +$header_nonselected_bold=''; +$admin_color = '#FFFF99'; +$admin_font = 'BLACK'; +$admin_color = '#E6E6E6'; +$emails_color = '#FFFF99'; +$emails_font = 'BLACK'; +$emails_color = '#C6C6C6'; +$subcamp_color = '#C6C6C6'; +##### END Set variables to make header show properly ##### + +require("admin_header.php"); + +if ( ($LOGemails_modify < 1) or ($LOGuser_level < 8) ) + { + echo "You are not authorized to view this section\n"; + exit; + } + +if ($SSemail_enabled < 1) + { + echo "ERROR: Inbound emails are not active on this system\n"; + exit; + } + + +$NWB = "   <a href=\"javascript:openNewWindow('admin.php?ADD=99999"; +$NWE = "')\"><IMG SRC=\"help.gif\" WIDTH=20 HEIGHT=20 BORDER=0 ALT=\"HELP\" ALIGN=TOP></A>"; + + +if ($DB > 0) +{ +echo "$DB,$action,$ip,$user,$copy_option,$field_id,$list_id,$source_email_account,$field_label,$field_name,$field_description,$field_rank,$field_help,$field_type,$field_options,$field_size,$field_max,$field_default,$field_required,$field_cost,$multi_position,$name_position,$field_order"; +} + +if ($eact=="DELETE" && $confirm_deletion=="yes" && $email_account_id) + { + $del_stmt="delete from vicidial_email_accounts where email_account_id='$email_account_id'"; + $del_rslt=mysql_query($del_stmt, $link); + $message="ACCOUNT $email_account_id DELETED<BR/>"; + $eact=""; + } + + + +if (($SUBMIT=="SUBMIT" || $SUBMIT=="UPDATE") && $email_account_id) + { + $error_msg=""; + if (!$list_id) {$error_msg.="- Default list ID is invalid or null<BR/>";} + if (!$email_account_id) {$error_msg.="- Email account ID is invalid or null<BR/>";} + if (!$email_account_name) {$error_msg.="- Email account name is invalid or null<BR/>";} + if (!$email_account_server) {$error_msg.="- Email account server is invalid or null<BR/>";} + if (!$email_account_user) {$error_msg.="- Email account user is invalid or null<BR/>";} + if (!$email_account_pass) {$error_msg.="- Email account password is invalid or null<BR/>";} + if (!filter_var($email_replyto_address, FILTER_VALIDATE_EMAIL)) {$error_msg.="- Email reply-to address is invalid or null<BR/>";} + + if (!$error_msg) + { + if ($SUBMIT=="SUBMIT") + { + $ins_stmt="INSERT INTO vicidial_email_accounts(email_account_id, email_account_name, email_account_description, user_group, email_replyto_address, protocol, email_account_server, email_account_user, email_account_pass, active, email_frequency_check_mins, group_id, default_list_id, email_account_type, call_handle_method, agent_search_method, list_id, campaign_id) VALUES('$email_account_id', '$email_account_name', '$email_account_description', '$user_group', '$email_replyto_address', '$protocol', '$email_account_server', '$email_account_user', '$email_account_pass', '$active', '$email_frequency_check_mins', '$group_id', '$default_list_id', '$email_account_type', '$call_handle_method', '$agent_search_method', '$list_id', '$campaign_id')"; + $ins_rslt=mysql_query($ins_stmt, $link); + if (mysql_affected_rows($link)==0) + { + $error_msg.="- There was an unknown error when attempting to create the new account<BR/>"; + if($DB>0) {$error_msg.="<B>$ins_stmt</B><BR>";} + } + else + { + $message="NEW ACCOUNT $email_account_id SUCCESSFULLY CREATED"; + $eact=""; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$ins_stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date=now(), user='$PHP_AUTH_USER', ip_address='$ip', event_section='EMAIL', event_type='ADD', record_id='$user', event_code='NEW EMAIL ACCOUNT ADDED', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + $upd_stmt="update vicidial_email_accounts set email_account_name='$email_account_name', email_account_description='$email_account_description', user_group='$user_group', protocol='$protocol', email_replyto_address='$email_replyto_address', email_account_server='$email_account_server', email_account_user='$email_account_user', email_account_pass='$email_account_pass', active='$active', email_frequency_check_mins='$email_frequency_check_mins', group_id='$group_id', default_list_id='$default_list_id', email_account_type='$email_account_type', call_handle_method='$call_handle_method', agent_search_method='$agent_search_method', campaign_id='$campaign_id', list_id='$list_id' WHERE email_account_id='$email_account_id'"; + $upd_rslt=mysql_query($upd_stmt, $link); + if (mysql_affected_rows($link)==0) + { + $error_msg.="- There was an unknown error when attempting to update account $email_account_id<BR/>"; + if($DB>0) {$error_msg.="<B>$upd_stmt</B><BR>";} + } + else + { + $message="ACCOUNT $email_account_id SUCCESSFULLY MODIFIED"; + # $eact=""; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$upd_stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date=now(), user='$PHP_AUTH_USER', ip_address='$ip', event_section='EMAIL', event_type='MODIFY', record_id='$user', event_code='EMAIL ACCOUNT MODIFIED', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + } +else if ($SUBMIT=="COPY") + { + $stmt="select * from vicidial_email_accounts where email_account_id='$source_email_account'"; + $rslt=mysql_query($stmt, $link); + if (mysql_num_rows($rslt)>0) + { + $row=mysql_fetch_array($rslt); + $ins_stmt="insert into vicidial_email_accounts(email_account_id, email_account_name, email_account_description, user_group, protocol, email_replyto_address, email_account_server, email_account_user, email_account_pass, active, email_frequency_check_mins, group_id, default_list_id, email_account_type, call_handle_method, agent_search_method, list_id, campaign_id) VALUES('$new_account_id', '$email_account_name', '$row[email_account_description]', '$row[user_group]', '$row[protocol]', '$row[email_replyto_address]', '$row[email_account_server]', '$row[email_account_user]', '$row[email_account_pass]', '$row[active]', '$row[email_frequency_check_mins]', '$row[group_id]','$row[default_list_id]', '$row[email_account_type]', '$row[call_handle_method]','$row[agent_search_method]', '$row[list_id]', '$row[campaign_id]')"; + $ins_rslt=mysql_query($ins_stmt, $link); + if (mysql_affected_rows($link)==0) + { + $error_msg.="- There was an unknown error when attempting to copy the new account<BR/>"; + if($DB>0) {$error_msg.="<B>$ins_stmt</B><BR>";} + } + else + { + $message="NEW ACCOUNT $new_account_id SUCCESSFULLY COPIED FROM $source_email_account<BR/>"; + $eact=""; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$ins_stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date=now(), user='$PHP_AUTH_USER', ip_address='$ip', event_section='EMAIL', event_type='ADD', record_id='$user', event_code='NEW EMAIL ACCOUNT ADDED', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + $error_msg="- Error - source email does not exist<BR/>"; + if($DB>0) {$error_msg.="<B>$stmt</B><BR>";} + } + } + + +################################################################################ +##### BEGIN copy fields to a list form +if ($eact == "COPY") + { + ##### get lists listing for dynamic pulldown + $stmt="SELECT email_account_id, email_account_name from vicidial_email_accounts order by email_account_id"; + $rsltx=mysql_query($stmt, $link); + $accounts_to_print = mysql_num_rows($rsltx); + $accounts_list=''; + $o=0; + if ($accounts_to_print>0) + { + while ($accounts_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $accounts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + echo "<TABLE><TR><TD>\n"; + echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"; + if ($error_msg) {echo "ACCOUNT NOT COPIED<BR/>The data you submitted has the following errors:<BR/>$error_msg";} + echo "<br>Copy New Account from Existing Account<form action='$PHP_SELF' method='GET'>\n"; + echo "<input type=hidden name=DB value=\"$DB\">\n"; + echo "<input type=hidden name=action value=COPY_EMAIL_SUBMIT>\n"; + echo "<center><TABLE width=$section_width cellspacing=3>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Account ID to Copy From: </td><td align=left><select size=1 name=source_email_account>\n"; + echo "$accounts_list"; + echo "</select></td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>New Account ID: </td><td align=left><input type=text name=new_account_id value='$new_account_id' size=10 maxlength=20></td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>New Account Name: </td><td align=left><input type=text name=email_account_name size=40 maxlength=100>$NWB#vicidial_email_accounts-carrier_name$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=center colspan=2><input type=submit name=SUBMIT value='COPY'></td></tr>\n"; + echo "</TABLE></center>\n"; + echo "</TD></TR></TABLE>\n"; + } + else + { + echo "<TABLE><TR><TD>\n"; + echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"; + echo "<br><br>*** There are no existing accounts to copy from ***\n"; + echo "</TD></TR></TABLE>\n"; + } + } +### END copy fields to a list form +else if ($eact == "ADD") + { + if ( ($LOGemails_modify==1) ) + { + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get in-groups listings for dynamic pulldown + $stmt="SELECT group_id,group_name from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;"; + $rslt=mysql_query($stmt, $link); + $Xgroups_to_print = mysql_num_rows($rslt); + $Xgroups_menu=''; + $Xgroups_selected=0; + $FXgroups_menu=''; + $FXgroups_selected=0; + $o=0; + while ($Xgroups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Xgroups_menu .= "<option "; + $FXgroups_menu .= "<option "; + if ($user_route_settings_ingroup == "$rowx[0]") + { + $Xgroups_menu .= "SELECTED "; + $Xgroups_selected++; + } + if ($filter_user_route_settings_ingroup == "$rowx[0]") + { + $FXgroups_menu .= "SELECTED "; + $FXgroups_selected++; + } + $Xgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $FXgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + if ($Xgroups_selected < 1) + {$Xgroups_menu .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";} + else + {$Xgroups_menu .= "<option value=\"---NONE---\">---NONE---</option>\n";} + if ($FXgroups_selected < 1) + {$FXgroups_menu .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";} + else + {$FXgroups_menu .= "<option value=\"---NONE---\">---NONE---</option>\n";} + + + ##### get in-groups listings for dynamic pulldown + $stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') $LOGadmin_viewable_groupsSQL order by group_id;"; + $rslt=mysql_query($stmt, $link); + $Dgroups_to_print = mysql_num_rows($rslt); + $Dgroups_menu=''; + $Dgroups_selected=0; + $FDgroups_menu=''; + $FDgroups_selected=0; + $o=0; + while ($Dgroups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Dgroups_menu .= "<option "; + $FDgroups_menu .= "<option "; + if ($group_id == "$rowx[0]") + { + $Dgroups_menu .= "SELECTED "; + $Dgroups_selected++; + } + if ($filter_group_id == "$rowx[0]") + { + $FDgroups_menu .= "SELECTED "; + $FDgroups_selected++; + } + $Dgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $FDgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + if ($Dgroups_selected < 1) + {$Dgroups_menu .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";} + else + {$Dgroups_menu .= "<option value=\"---NONE---\">---NONE---</option>\n";} + if ($FDgroups_selected < 1) + {$FDgroups_menu .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";} + else + {$FDgroups_menu .= "<option value=\"---NONE---\">---NONE---</option>\n";} + + + echo "<TABLE>\n"; + echo "<TR><TD>\n"; + echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"; + if ($error_msg) {echo "ACCOUNT NOT INSERTED<BR/>The data you submitted has the following errors:<BR/>$error_msg";} + echo "<br>ADD NEW INBOUND EMAIL ACCOUNT<form action='$PHP_SELF' method='GET'>\n"; + echo "<center><TABLE width=$section_width cellspacing=3>\n"; + + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account ID: </td><td align=left><input type=text name=email_account_id size=15 maxlength=20 value='$email_account_id'>$NWB#vicidial_email_accounts-email_account_id$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account Name: </td><td align=left><input type=text name=email_account_name size=40 maxlength=100 value='$email_account_name'>$NWB#vicidial_email_accounts-email_account_name$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Active: </td><td align=left><select size=1 name=active><option>Y</option><option SELECTED>N</option></select>$NWB#vicidial_email_accounts-email_account_active$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account Description: </td><td align=left><input type=text name=email_account_description size=70 maxlength=255 value='$email_account_description'>$NWB#vicidial_email_accounts-email_account_description$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account Type: </td><td align=left><select size=1 name=email_account_type><option>INBOUND</option></select>$NWB#vicidial_email_accounts-email_account_type$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Admin User Group: </td><td align=left><select size=1 name=user_group>\n"; + echo "$UUgroups_list"; + echo "<option SELECTED value=\"---ALL---\">All Admin User Groups</option>\n"; + echo "</select>$NWB#vicidial_email_accounts-admin_user_group$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account Protocol: </td><td align=left><select size=1 name=protocol><option SELECTED>IMAP</option><option>POP3</option></select>$NWB#vicidial_email_accounts-protocol$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Reply-to Address: </td><td align=left><input type=text name=email_replyto_address size=70 maxlength=255 value='$email_replyto_address'>$NWB#vicidial_email_accounts-email_replyto_address$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account Server: </td><td align=left><input type=text name=email_account_server size=70 maxlength=255 value='$email_account_server'>$NWB#vicidial_email_accounts-email_account_server$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account User: </td><td align=left><input type=text name=email_account_user size=30 maxlength=255 value='$email_account_user'>$NWB#vicidial_email_accounts-email_account_user$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account Password: </td><td align=left><input type=text name=email_account_pass size=30 maxlength=100 value='$email_account_pass'>$NWB#vicidial_email_accounts-email_account_pass$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Frequency Check Rate (mins): </td><td align=left><select name='email_frequency_check_mins'>"; + $i=5; + while ($i<=60) + { + echo "<option value='$i'>$i</option>"; + $i+=5; + } + echo "</select>$NWB#vicidial_email_accounts-email_frequency_check_mins$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right><a href=\"admin.php?ADD=1000\">In-Group ID</a>: </td><td align=left><select size=1 name=group_id>"; + echo "$Dgroups_menu"; + echo "</select>$NWB#vicidial_email_accounts-in_group$NWE</td></tr>\n"; + + echo "<tr bgcolor=#B6D3FC><td align=right><a href=\"admin.php?ADD=1000\">Default List ID</a>: </td><td align=left><input type=text name=default_list_id size=20 maxlength=255 value='$default_list_id'>$NWB#vicidial_email_accounts-default_list_id$NWE</td></tr>\n"; + + echo "<tr bgcolor=#B6D3FC><td align=right>In-Group Call Handle Method: </td><td align=left><select size=1 name=call_handle_method><option>CID</option><option>CIDLOOKUP</option><option>CIDLOOKUPRL</option><option>CIDLOOKUPRC</option><option SELECTED>$call_handle_method</option></select>$NWB#vicidial_email_accounts-call_handle_method$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>In-Group Agent Search Method: </td><td align=left><select size=1 name=agent_search_method><option value=\"LB\">LB - Load Balanced</option><option value=\"LO\">LO - Load Balanced Overflow</option><option value=\"SO\">SO - Server Only</option><option SELECTED>$agent_search_method</option></select>$NWB#vicidial_email_accounts-agent_search_method$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>In-Group List ID: </td><td align=left><input type=text name=list_id size=14 maxlength=14 value=\"$list_id\">$NWB#vicidial_email_accounts-ingroup_list_id$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>In-Group Campaign ID: </td><td align=left><select size=1 name=campaign_id>\n"; + echo "$campaigns_list"; + echo "<option SELECTED>$campaign_id</option>\n"; + echo "</select>$NWB#vicidial_email_accounts-ingroup_campaign_id$NWE</td></tr>\n"; + + echo "<tr bgcolor=#B6D3FC><td align=center colspan=2><input type=submit name=SUBMIT VALUE=SUBMIT><input type=hidden name='eact' value='ADD'></td></tr>\n"; + echo "</TABLE></center></form>\n"; + } + else + { + echo "You do not have permission to view this page\n"; + exit; + } + } +else if (($eact=="DELETE" || $eact=="UPDATE") && $email_account_id) + { + if ( ($LOGemails_modify==1) ) + { + $stmt="SELECT * from vicidial_email_accounts where email_account_id='$email_account_id'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_array($rslt); + + $email_account_id=$row["email_account_id"]; + $email_account_name=$row["email_account_name"]; + $email_account_description=$row["email_account_description"]; + $user_group=$row["user_group"]; + $protocol=$row["protocol"]; + $email_replyto_address=$row["email_replyto_address"]; + $email_account_server=$row["email_account_server"]; + $email_account_user=$row["email_account_user"]; + $email_account_pass=$row["email_account_pass"]; + $active=$row["active"]; + $email_frequency_check_mins=$row["email_frequency_check_mins"]; + $group_id=$row["group_id"]; + $call_handle_method=$row["call_handle_method"]; + $agent_search_method=$row["agent_search_method"]; + $campaign_id=$row["campaign_id"]; + $list_id=$row["list_id"]; + $default_list_id=$row["default_list_id"]; + $email_account_type=$row["email_account_type"]; + + if ($eact=="DELETE" && $email_account_id) + { + echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"; + echo "<br><B>CONFIRM DELETION OF INBOUND EMAIL ACCOUNT $email_account_id</B><BR>\n"; + echo "<a href='$PHP_SELF?eact=DELETE&email_account_id=$email_account_id&confirm_deletion=yes'>Click to delete account $email_account_id</a>\n"; + echo "</font>"; + } + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get in-groups listings for dynamic pulldown + $stmt="SELECT group_id,group_name from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;"; + $rslt=mysql_query($stmt, $link); + $Xgroups_to_print = mysql_num_rows($rslt); + $Xgroups_menu=''; + $Xgroups_selected=0; + $FXgroups_menu=''; + $FXgroups_selected=0; + $o=0; + while ($Xgroups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Xgroups_menu .= "<option "; + $FXgroups_menu .= "<option "; + if ($user_route_settings_ingroup == "$rowx[0]") + { + $Xgroups_menu .= "SELECTED "; + $Xgroups_selected++; + } + if ($filter_user_route_settings_ingroup == "$rowx[0]") + { + $FXgroups_menu .= "SELECTED "; + $FXgroups_selected++; + } + $Xgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $FXgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + if ($Xgroups_selected < 1) + {$Xgroups_menu .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";} + else + {$Xgroups_menu .= "<option value=\"---NONE---\">---NONE---</option>\n";} + if ($FXgroups_selected < 1) + {$FXgroups_menu .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";} + else + {$FXgroups_menu .= "<option value=\"---NONE---\">---NONE---</option>\n";} + + + ##### get in-groups listings for dynamic pulldown + $stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') $LOGadmin_viewable_groupsSQL order by group_id;"; + $rslt=mysql_query($stmt, $link); + $Dgroups_to_print = mysql_num_rows($rslt); + $Dgroups_menu=''; + $Dgroups_selected=0; + $FDgroups_menu=''; + $FDgroups_selected=0; + $o=0; + while ($Dgroups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Dgroups_menu .= "<option "; + $FDgroups_menu .= "<option "; + if ($group_id == "$rowx[0]") + { + $Dgroups_menu .= "SELECTED "; + $Dgroups_selected++; + } + if ($filter_group_id == "$rowx[0]") + { + $FDgroups_menu .= "SELECTED "; + $FDgroups_selected++; + } + $Dgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $FDgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + if ($Dgroups_selected < 1) + {$Dgroups_menu .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";} + else + {$Dgroups_menu .= "<option value=\"---NONE---\">---NONE---</option>\n";} + if ($FDgroups_selected < 1) + {$FDgroups_menu .= "<option SELECTED value=\"---NONE---\">---NONE---</option>\n";} + else + {$FDgroups_menu .= "<option value=\"---NONE---\">---NONE---</option>\n";} + + ## Get unhandled count + $stmt="select count(*) From vicidial_email_list where status='NEW' and email_account_id='$email_account_id'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $unhandled_emails=$row[0]; + + echo "<TABLE>\n"; + echo "<TR><TD>\n"; + echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"; + if ($message) {echo "<B>$message</B><BR>";} + if ($error_msg) {echo "ACCOUNT NOT UPDATED<BR/>The data you submitted has the following errors:<BR/>$error_msg";} + echo "<br>UPDATE AN EXISTING INBOUND EMAIL ACCOUNT<form action='$PHP_SELF' method='GET'>\n"; + echo "<center><TABLE width=$section_width cellspacing=3>\n"; + + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account ID: </td><td align=left><input type=hidden name=email_account_id value='$email_account_id'><B>$email_account_id$NWB#vicidial_email_accounts-email_account_id$NWE</B></td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account Name: </td><td align=left><input type=text name=email_account_name size=40 maxlength=100 value='$email_account_name'>$NWB#vicidial_email_accounts-email_account_name$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Active: </td><td align=left><select size=1 name=active>"; + echo "<option value='$active' selected>$active</option>"; + echo "<option>Y</option><option>N</option></select>$NWB#vicidial_email_accounts-email_account_active$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account Description: </td><td align=left><input type=text name=email_account_description size=70 maxlength=255 value='$email_account_description'>$NWB#vicidial_email_accounts-email_account_description$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account Type: </td><td align=left><select size=1 name=email_account_type><option value='$email_account_type' selected>$email_account_type</option><option>INBOUND</option></select>$NWB#vicidial_email_accounts-email_account_type$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Admin User Group: </td><td align=left><select size=1 name=user_group>\n"; + echo "<option value='$user_group' selected>$user_group</option>"; + echo "$UUgroups_list"; + echo "<option SELECTED value=\"---ALL---\">All Admin User Groups</option>\n"; + echo "</select>$NWB#vicidial_email_accounts-admin_user_group$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account Protocol: </td><td align=left><select size=1 name=protocol><option>IMAP</option><option>POP3</option><option SELECTED>$protocol</option></select>$NWB#vicidial_email_accounts-protocol$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Reply-to Address: </td><td align=left><input type=text name=email_replyto_address size=70 maxlength=255 value='$email_replyto_address'>$NWB#vicidial_email_accounts-email_replyto_address$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account Server: </td><td align=left><input type=text name=email_account_server size=70 maxlength=255 value='$email_account_server'>$NWB#vicidial_email_accounts-email_account_server$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account User: </td><td align=left><input type=text name=email_account_user size=30 maxlength=255 value='$email_account_user'>$NWB#vicidial_email_accounts-email_account_user$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Account Password: </td><td align=left><input type=text name=email_account_pass size=30 maxlength=100 value='$email_account_pass'>$NWB#vicidial_email_accounts-email_account_pass$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>Email Frequency Check Rate (mins): </td><td align=left><select name='email_frequency_check_mins'>"; + echo "<option value='$email_frequency_check_mins' selected>$email_frequency_check_mins</option>"; + $i=5; + while ($i<=60) + { + echo "<option value='$i'>$i</option>"; + $i+=5; + } + echo "</select>$NWB#vicidial_email_accounts-email_frequency_check_mins$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right><a href=\"admin.php?ADD=3811&group_id=$group_id\">In-Group ID</a>: </td><td align=left><select size=1 name=group_id>"; + echo "$Dgroups_menu"; + echo "<option value='$group_id' selected>$group_id</option></select>$NWB#vicidial_email_accounts-in_group$NWE</td></tr>\n"; + + echo "<tr bgcolor=#B6D3FC><td align=right><a href=\"admin.php?ADD=1000\">Default List ID</a>: </td><td align=left><input type=text name=default_list_id size=20 maxlength=255 value='$default_list_id'>$NWB#vicidial_email_accounts-default_list_id$NWE</td></tr>\n"; + +############### + echo "<tr bgcolor=#B6D3FC><td align=right>In-Group Call Handle Method: </td><td align=left><select size=1 name=call_handle_method><option>EMAIL</option><option>EMAILLOOKUP</option><option>EMAILLOOKUPRL</option><option>EMAILLOOKUPRC</option><option SELECTED>$call_handle_method</option></select>$NWB#vicidial_email_accounts-call_handle_method$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>In-Group Agent Search Method: </td><td align=left><select size=1 name=agent_search_method><option value=\"LB\">LB - Load Balanced</option><option value=\"LO\">LO - Load Balanced Overflow</option><option value=\"SO\">SO - Server Only</option><option SELECTED>$agent_search_method</option></select>$NWB#vicidial_email_accounts-agent_search_method$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>In-Group List ID: </td><td align=left><input type=text name=list_id size=14 maxlength=14 value=\"$list_id\">$NWB#vicidial_email_accounts-ingroup_list_id$NWE</td></tr>\n"; + echo "<tr bgcolor=#B6D3FC><td align=right>In-Group Campaign ID: </td><td align=left><select size=1 name=campaign_id>\n"; + echo "$campaigns_list"; + echo "<option SELECTED>$campaign_id</option>\n"; + echo "</select>$NWB#vicidial_email_accounts-ingroup_campaign_id$NWE</td></tr>\n"; + + echo "<tr bgcolor=#B6D3FC><td align=right>Un-handled Emails: </td><td align=left><B>$unhandled_emails</B></td></tr>\n"; +################ + + echo "<tr bgcolor=#B6D3FC><td align=center colspan=2><input type=submit name=SUBMIT VALUE=UPDATE><input type=hidden name='eact' value='UPDATE'></td></tr>\n"; + echo "</TABLE><BR><BR>"; + if ($LOGuser_level >= 9) + { + echo "<br><br><a href=\"admin.php?ADD=720000000000000&category=EMAIL&stage=$user\">Click here to see Admin changes to this record</FONT>\n"; + } + echo "<BR><BR><a href='$PHP_SELF?eact=DELETE&email_account_id=$email_account_id'>DELETE EMAIL ACCOUNT</a></center></form>\n"; + } + else + { + echo "You do not have permission to view this page\n"; + exit; + } + } +else + { + echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"; + if ($message) {echo "<B>$message</B><BR>";} + echo "<br>INBOUND EMAIL ACCOUNT LISTINGS:\n"; + echo "<center><TABLE width=750 cellspacing=0 cellpadding=1>\n"; + echo "<TR BGCOLOR=BLACK>\n"; + echo "<TD><font size=1 color=white>ACCOUNT ID</TD>\n"; + echo "<TD><font size=1 color=white>ACCOUNT NAME</TD>\n"; + echo "<TD><font size=1 color=white>DESCRIPTION</TD>\n"; + echo "<TD><font size=1 color=white>REPLY-TO ADDRESS</TD>\n"; + echo "<TD><font size=1 color=white>PROTOCOL</TD>\n"; + echo "<TD><font size=1 color=white>SERVER</TD>\n"; + echo "<TD><font size=1 color=white>FREQUENCY</TD>\n"; + echo "<TD><font size=1 color=white>ACTIVE</TD>\n"; + echo "<TD><font size=1 color=white>UNREAD EMAILS</TD>\n"; + echo "<TD><font size=1 color=white>MODIFY</TD></tr>\n"; + + $stmt="SELECT email_account_id, email_account_name, email_account_description, email_replyto_address, protocol, email_account_server, email_frequency_check_mins, active from vicidial_email_accounts $whereLOGadmin_viewable_groupsSQL order by email_account_id;"; + $rslt=mysql_query($stmt, $link); + $accounts_to_print = mysql_num_rows($rslt); + $o=0; + while ($accounts_to_print > $o) + { + $row=mysql_fetch_array($rslt); + + ## Get unhandled count + $ct_stmt="select count(*) From vicidial_email_list where status='NEW' and email_account_id='$row[email_account_id]'"; + $ct_rslt=mysql_query($ct_stmt, $link); + $ct_row=mysql_fetch_row($ct_rslt); + $unhandled_emails=$ct_row[0]; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo "<tr $bgcolor><td><font size=1><a href=\"$PHP_SELF?eact=UPDATE&email_account_id=$row[email_account_id]\">$row[email_account_id]</a></font></td>"; + echo "<td><font size=1> $row[email_account_name]</font></td>"; + echo "<td><font size=1> $row[email_account_description]</font></td>"; + echo "<td><font size=1> $row[email_replyto_address]</font></td>"; + echo "<td><font size=1> $row[protocol]</font></td>"; + echo "<td><font size=1> $row[email_account_server]</font></td>"; + echo "<td><font size=1> $row[email_frequency_check_mins] mins</font></td>"; + echo "<td><font size=1> $row[active]</font></td>"; + echo "<td><font size=1> $unhandled_emails</font></td>"; + echo "<td><font size=1><a href=\"$PHP_SELF?eact=UPDATE&email_account_id=$row[email_account_id]\">MODIFY</a></font></td></tr>\n"; + $o++; + } + + echo "</table></font>"; + } + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $STARTtime); +echo "\n\n\n<br><br><br>\n<font size=1> runtime: $RUNtime seconds         Version: $admin_version     Build: $build</font>"; + +?> + +</body> +</html> diff --git a/agc_2-X/trunk/www/vicidial/admin_header.php b/agc_2-X/trunk/www/vicidial/admin_header.php index 75266186..c3845343 100644 --- a/agc_2-X/trunk/www/vicidial/admin_header.php +++ b/agc_2-X/trunk/www/vicidial/admin_header.php @@ -39,6 +39,7 @@ # 120402-2134 - Changed lead loader link to fourth gen # 121116-1412 - Added QC functionality # 121123-0911 - Added Call Times Holidays Inbound functionality +# 121214-2238 - Added email menus # @@ -872,7 +873,7 @@ if ( ($ADD==3511) or ($ADD==2511) or ($ADD==2611) or ($ADD==4511) or ($ADD==5511 } ### Javascript for dynamic in-group option value entries -if ( ($ADD==3111) or ($ADD==2111) or ($ADD==2011) or ($ADD==4111) or ($ADD==5111) ) +if ( ($ADD==2811) or ($ADD==3811) or ($ADD==3111) or ($ADD==2111) or ($ADD==2011) or ($ADD==4111) or ($ADD==5111) ) { ?> @@ -1057,14 +1058,14 @@ else echo "<!-- INTERNATIONALIZATION-LINKS-PLACEHOLDER-VICIDIAL -->\n"; -$stmt="SELECT admin_home_url,enable_tts_integration,callcard_enabled,custom_fields_enabled from system_settings;"; +$stmt="SELECT admin_home_url,enable_tts_integration,callcard_enabled,custom_fields_enabled,allow_emails from system_settings;"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $admin_home_url_LU = $row[0]; $SSenable_tts_integration = $row[1]; $SScallcard_enabled = $row[2]; $SScustom_fields_enabled = $row[3]; - +$SSemail_enabled = $row[4]; ?> <CENTER> @@ -1261,6 +1262,20 @@ $SScustom_fields_enabled = $row[3]; </TD></TR><TR BGCOLOR=<?php echo $ingroups_color ?>><TD ALIGN=LEFT>   <a href="<?php echo $ADMIN ?>?ADD=1211"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=<?php echo $subheader_font_size ?>> Copy In-Group </a> <HR> + <?php + if ($SSemail_enabled>0) + { + ?> + <TR BGCOLOR=<?php echo $ingroups_color ?>><TD ALIGN=LEFT>   + <a href="<?php echo $ADMIN ?>?ADD=1800"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=<?php echo $subheader_font_size ?>> Show Email Groups </a> + </TD></TR><TR BGCOLOR=<?php echo $ingroups_color ?>><TD ALIGN=LEFT>   + <a href="<?php echo $ADMIN ?>?ADD=1811"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=<?php echo $subheader_font_size ?>> Add New Email Group </a> + </TD></TR><TR BGCOLOR=<?php echo $ingroups_color ?>><TD ALIGN=LEFT>   + <a href="<?php echo $ADMIN ?>?ADD=1911"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=<?php echo $subheader_font_size ?>> Copy Email Group </a> + <HR> + <?php + } + ?> </TD></TR><TR BGCOLOR=<?php echo $ingroups_color ?>><TD ALIGN=LEFT>   <a href="<?php echo $ADMIN ?>?ADD=1300"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=<?php echo $subheader_font_size ?>> Show DIDs </a> </TD></TR><TR BGCOLOR=<?php echo $ingroups_color ?>><TD ALIGN=LEFT>   @@ -1370,6 +1385,9 @@ $SScustom_fields_enabled = $row[3]; else {$cc_sh=''; $cc_fc='BLACK';} if ($sh=='cts') {$cts_sh="bgcolor=\"$cts_color\""; $cts_fc="$cc_font";} else {$cts_sh=''; $cts_fc='BLACK';} + if ($sh=='emails') {$emails_sh="bgcolor=\"$subcamp_color\""; $emails_fc="$subcamp_font";} + else {$emails_sh=''; $emails_fc='BLACK';} + ?> <TR BGCOLOR=<?php echo $admin_color ?>> @@ -1396,7 +1414,14 @@ $SScustom_fields_enabled = $row[3]; </TR><TR BGCOLOR=<?php echo $admin_color ?>><TD ALIGN=LEFT <?php echo $vm_sh ?>>   <a href="<?php echo $ADMIN ?>?ADD=170000000000"><FONT FACE="ARIAL,HELVETICA" COLOR=<?php echo $vm_fc ?> SIZE=<?php echo $header_font_size ?>> Voicemail </a></TD> </TR> - <?php if ( ($sounds_central_control_active > 0) or ($SSsounds_central_control_active > 0) ) + <?php + if ($SSemail_enabled > 0) + { ?> + <TR BGCOLOR=<?php echo $admin_color ?>><TD ALIGN=LEFT <?php echo $emails_sh ?>>   + <a href="admin_email_accounts.php"><FONT FACE="ARIAL,HELVETICA" COLOR=<?php echo $emails_fc ?> SIZE=<?php echo $header_font_size ?>> Email Accounts </a></TD> + </TR> + <?php } + if ( ($sounds_central_control_active > 0) or ($SSsounds_central_control_active > 0) ) { ?> <TR BGCOLOR=<?php echo $admin_color ?>><TD ALIGN=LEFT <?php echo $audio_sh ?>>   <a href="audio_store.php"><FONT FACE="ARIAL,HELVETICA" COLOR=<?php echo $audio_fc ?> SIZE=<?php echo $header_font_size ?>> Audio Store </a></TD> @@ -1490,6 +1515,10 @@ $SScustom_fields_enabled = $row[3]; ?> <TR BGCOLOR=<?php echo $carriers_color ?>><TD ALIGN=LEFT COLSPAN=2>   <a href="<?php echo $ADMIN ?>?ADD=140000000000"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=<?php echo $subheader_font_size ?>> Show Carriers </a>   |   <a href="<?php echo $ADMIN ?>?ADD=141111111111"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=<?php echo $subheader_font_size ?>> Add A New Carrier </a>   |   <a href="<?php echo $ADMIN ?>?ADD=140111111111"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=<?php echo $subheader_font_size ?>> Copy A Carrier </a></TD></TR> <?php } + if ( (strlen($emails_sh) > 1) and (strlen($admin_hh) > 1) ) { + ?> + <TR BGCOLOR=<?php echo $emails_color ?>><TD ALIGN=LEFT COLSPAN=2>   <a href="admin_email_accounts.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=<?php echo $subheader_font_size ?>> Show Email Accounts </a>   |   <a href="admin_email_accounts.php?eact=ADD"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=2> Add A New Account </a>   |   <a href="admin_email_accounts.php?eact=COPY"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=<?php echo $subheader_font_size ?>> Copy An Account </a></TD></TR> + <?php } if ( (strlen($tts_sh) > 1) and (strlen($admin_hh) > 1) ) { ?> <TR BGCOLOR=<?php echo $tts_color ?>><TD ALIGN=LEFT COLSPAN=2>   <a href="<?php echo $ADMIN ?>?ADD=150000000000"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=<?php echo $subheader_font_size ?>> Show TTS Entries </a>   |   <a href="<?php echo $ADMIN ?>?ADD=151111111111"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=<?php echo $subheader_font_size ?>> Add A New TTS Entry </a></TD></TR> diff --git a/agc_2-X/trunk/www/vicidial/admin_modify_lead.php b/agc_2-X/trunk/www/vicidial/admin_modify_lead.php index d1dc8e58..b1aefe94 100644 --- a/agc_2-X/trunk/www/vicidial/admin_modify_lead.php +++ b/agc_2-X/trunk/www/vicidial/admin_modify_lead.php @@ -50,6 +50,7 @@ # 120529-1635 - Added User Group Campaign-Lists validation # 121116-1411 - Added QC functionality # 121130-1033 - Changed scheduled callback user ID field to be 20 characters, issue #467 +# 121222-2145 - Added email log # require("dbconnect.php"); @@ -169,7 +170,7 @@ $NOW_TIME = date("Y-m-d H:i:s"); ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### -$stmt = "SELECT use_non_latin,custom_fields_enabled,webroot_writable FROM system_settings;"; +$stmt = "SELECT use_non_latin,custom_fields_enabled,webroot_writable,allow_emails FROM system_settings;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); @@ -179,6 +180,7 @@ if ($qm_conf_ct > 0) $non_latin = $row[0]; $custom_fields_enabled = $row[1]; $webroot_writable = $row[2]; + $allow_emails = $row[3]; } ##### END SETTINGS LOOKUP ##### ########################################### @@ -1330,6 +1332,46 @@ else echo "</TABLE><BR><BR>\n"; + ##### vicidial agent outbound calls for this time period ##### + + if ($allow_emails>0) + { + echo "<B>OUTBOUND EMAILS FOR THIS LEAD:</B>\n"; + echo "<TABLE width=750 cellspacing=1 cellpadding=1>\n"; + echo "<tr><td><font size=1># </td><td><font size=2>DATE/TIME </td><td align=right><font size=2> USER</td><td align=right><font size=2> CAMPAIGN</td><td align=left><font size=2>EMAIL TO</td><td align=left><font size=2> MESSAGE</td><td align=right><font size=2> ATTACHMENTS</td></tr>\n"; + + $stmt="select * from vicidial_email_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by email_date desc limit 500;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + if (strlen($row[6])>100) {$row[6]=substr($row[6],0,100)."...";} + $row[8]=preg_replace('/\|/', ', ', $row[8]); + $row[8]=preg_replace('/,\s+$/', '', $row[8]); + $u++; + + echo "<tr $bgcolor>"; + echo "<td><font size=1>$u</td>"; + echo "<td><font size=1>$row[3]</td>"; + echo "<td align=right><font size=2> <A HREF=\"user_stats.php?lead_id=$row[4]\" target=\"_blank\">$row[4]</A> </td>\n"; + echo "<td align=left><font size=2> $row[7]</td>\n"; + echo "<td align=left><font size=1> $row[5]</td>\n"; + echo "<td align=left><font size=1> $row[6] </td>\n"; + echo "<td align=right><font size=1> $row[8] </td></tr>\n"; + } + + + echo "</TABLE><BR><BR>\n"; + } + + echo "<B>RECORDINGS FOR THIS LEAD:</B>\n"; echo "<TABLE width=750 cellspacing=1 cellpadding=1>\n"; diff --git a/agc_2-X/trunk/www/vicidial/user_stats.php b/agc_2-X/trunk/www/vicidial/user_stats.php index 78ae20cb..d755f87f 100644 --- a/agc_2-X/trunk/www/vicidial/user_stats.php +++ b/agc_2-X/trunk/www/vicidial/user_stats.php @@ -34,6 +34,7 @@ # 111103-1050 - Added admin_hide_phone_data and admin_hide_lead_data options # 111106-1105 - Added user_group restrictions # 120223-2135 - Removed logging of good login passwords if webroot writable is enabled +# 121222-2152 - Added email log display # @@ -46,7 +47,7 @@ $db_source = 'M'; ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### -$stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db,user_territories_active,webroot_writable FROM system_settings;"; +$stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db,user_territories_active,webroot_writable,allow_emails FROM system_settings;"; $rslt=mysql_query($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); @@ -59,6 +60,7 @@ if ($qm_conf_ct > 0) $reports_use_slave_db = $row[3]; $user_territories_active = $row[4]; $webroot_writable = $row[5]; + $allow_emails = $row[6]; } ##### END SETTINGS LOOKUP ##### ########################################### @@ -695,6 +697,54 @@ if ($did < 1) $MAIN.="</TABLE><BR><BR>\n"; } + ##### vicidial agent outbound emails for this time period ##### + + if ($allow_emails>0) + { + $MAIN.="<B>OUTBOUND EMAILS FOR THIS TIME PERIOD: (10000 record limit)     <a href='$download_link&file_download=5'>[DOWNLOAD]</a></B>\n"; + $MAIN.="<TABLE width=670 cellspacing=0 cellpadding=3>\n"; + $MAIN.="<tr><td><font size=1># </td><td><font size=2>DATE/TIME </td><td align=left><font size=2>USER</td><td align=left><font size=2> CAMPAIGN</td><td align=left><font size=2> EMAIL TO</td><td align=right><font size=2> ATTACHMENTS</td><td align=right><font size=2> LEAD</td></tr>\n"; + $CSV_text5.="\"OUTBOUND EMAILS FOR THIS TIME PERIOD: (10000 record limit)\"\n"; + $CSV_text5.="\"\",\"#\",\"DATE/TIME\",\"USER\",\"CAMPAIGN\",\"EMAIL TO\",\"ATTACHMENT\",\"LEAD\",\"MESSAGE\"\n"; + + $stmt="select * from vicidial_email_log where user='" . mysql_real_escape_string($user) . "' and email_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and email_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' order by email_date desc limit 10000;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + if (strlen($row[6])>400) {$row[6]=substr($row[6],0,400)."...";} + $row[8]=preg_replace('/\|/', ', ', $row[8]); + $row[8]=preg_replace('/,\s+$/', '', $row[8]); + $u++; + + $MAIN .= "<tr $bgcolor>"; + $MAIN .= "<td><font size=1>$u</td>"; + $MAIN .= "<td align=left><font size=1>   $row[3]</td>"; + $MAIN .= "<td align=left><font size=2>   $row[4] </td>\n"; + $MAIN .= "<td align=left><font size=2>   $row[7]</td>\n"; + $MAIN .= "<td align=left><font size=1>   $row[5]</td>\n"; + $MAIN .= "<td align=left><font size=1>   $row[8] </td>\n"; + $MAIN .= "<td align=left><font size=1>   <A HREF=\"admin_modify_lead.php?lead_id=$row[2]\" target=\"_blank\">$row[2]</A> </td>\n"; + $MAIN .= "</tr>\n"; + $MAIN .= "<tr>"; + $MAIN .= "<td><font size=1>   </td>\n"; + $MAIN .= "<td align=left colspan=6 $bgcolor><font size=1> MESSAGE: $row[6] </td>\n"; + $MAIN .= "</tr>\n"; + + $CSV_text5.="\"\",\"$u\",\"$row[3]\",\"$row[4]\",\"$row[7]\",\"$row[5]\",\"$row[8]\",\"$row[2]\",\"$row[6]\"\n"; + } + + + $MAIN.="</TABLE><BR><BR>\n"; + } + ##### vicidial agent inbound calls for this time period ##### $MAIN.="<B>INBOUND/CLOSER CALLS FOR THIS TIME PERIOD: (10000 record limit)     <a href='$download_link&file_download=6'>[DOWNLOAD]</a></B>\n";