diff --git a/UPGRADE b/UPGRADE index 94a8aeb3..7d7880d1 100644 --- a/UPGRADE +++ b/UPGRADE @@ -154,6 +154,11 @@ OTHER CHANGES: 20. Added system setting to view country code breakdown in list modify screen. +21. Added campaign option to allow agents to be able to place manual dial calls + by Lead ID. + +22. Added Advanced lead tools management, access from the Admin Utilities page + diff --git a/bin/AST_VDhopper.pl b/bin/AST_VDhopper.pl index ff6de703..335d595b 100644 --- a/bin/AST_VDhopper.pl +++ b/bin/AST_VDhopper.pl @@ -7,11 +7,9 @@ # approach of allocating leads to dialers. # # SUMMARY: -# For VICIDIAL auto-dial outbound dialing, this program must be in the crontab -# running every minute +# For VICIDIAL outbound dialing, this program must be in the crontab on only one +# server, running every minute during operating hours # -# It is recommended that you run this program on the local Asterisk machine -# # hopper sources: # - A = Auto-alt-dial # - C = Scheduled Callbacks @@ -76,19 +74,25 @@ # 121223-1540 - Fix for issue #627 preventing issues when filter is deleted, DomeDan # 130219-1501 - Fixed issue with other campaign dnc # 130510-0904 - Added state call time holidays functionality +# 131008-1518 - Changed campaign flag to allow multiple campaigns +# Changed and added several CLI flags, including -t to --test, added --version, --count-only +# Added code to restrict all functions if campaign flag is used # # constants -$DB=0; # Debug flag, set to 0 for no debug messages, On an active system this will generate lots of lines of output per minute +$build = '131008-1518'; +$DB=0; # Debug flag, set to 0 for no debug messages. Can be overriden with CLI --debug flag $US='__'; $MT[0]=''; -#$vicidial_hopper='TEST_vicidial_hopper'; # for testing +#$vicidial_hopper='TEST_vicidial_hopper'; # for testing only $vicidial_hopper='vicidial_hopper'; +$count_only=0; # options -$insert_auto_CB_to_hopper = 1; # set to 1 to automatically insert ANYONE callbacks into the hopper +$insert_auto_CB_to_hopper = 1; # set to 1 to automatically insert ANYONE callbacks into the hopper, default = 1 +### gather date and time $secT = time(); $secX = time(); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); @@ -150,7 +154,7 @@ if ($Vmon < 10) {$Vmon = "0$Vmon";} if ($Vmday < 10) {$Vmday = "0$Vmday";} $VDL_tensec = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; -### begin parsing run-time options ### +### begin parsing CLI run-time options ### if (length($ARGV[0])>1) { $i=0; @@ -164,26 +168,38 @@ if (length($ARGV[0])>1) if ($args =~ /--help/i) { print "allowed run time options(must stay in this order):\n"; + print " [--test] = test\n"; + print " [--help] = this screen\n"; + print " [--version] = print version of this script, then exit\n"; + print " [--count-only] = only display the number of leads in the hopper, then exit\n"; print " [--debug] = debug\n"; print " [--debugX] = super debug\n"; print " [--dbgmt] = show GMT offset of records as they are inserted into hopper\n"; print " [--dbdetail] = additional level of logging the leads that are inserted into the hopper\n"; print " [--allow-inactive-list-leads] = do not delete inactive list leads\n"; - print " [-t] = test\n"; print " [--level=XXX] = force a hopper_level of XXX\n"; - print " [--campaign=XXX] = run for campaign XXX only\n"; + print " [--campaign=XXX] = run for campaign XXX only(or more campaigns if separated by triple dash ---)\n"; print " [--wipe-hopper-clean] = deletes everything from the hopper USE WITH CAUTION!!!\n"; print "\n"; exit; } else { + if ($args =~ /--version/i) + { + print "version: $build\n"; + exit; + } if ($args =~ /--campaign=/i) { # print "\n|$ARGS|\n\n"; @data_in = split(/--campaign=/,$args); $CLIcampaign = $data_in[1]; $CLIcampaign =~ s/ .*$//gi; + if ($CLIcampaign =~ /---/) + { + $CLIcampaign =~ s/---/','/gi; + } } else {$CLIcampaign = '';} @@ -222,7 +238,7 @@ if (length($ARGV[0])>1) $allow_inactive_list_leads=1; # print "\n-----DEBUG DETAIL -----\n\n"; } - if ($args =~ /-t/i) + if ($args =~ /--test/i) { $T=1; $TEST=1; print "\n-----TESTING -----\n\n"; @@ -231,6 +247,10 @@ if (length($ARGV[0])>1) { $wipe_hopper_clean=1; } + if ($args =~ /--count-only/i) + { + $count_only=1; + } } } else @@ -323,11 +343,12 @@ if ($sec < 10) {$sec = "0$sec";} if ($DB) {print "TIME DEBUG: $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";} +### Wipe hopper clean process if ($wipe_hopper_clean) { if (length($CLIcampaign)>0) { - $stmtA = "DELETE from $vicidial_hopper where campaign_id = '$CLIcampaign';"; + $stmtA = "DELETE from $vicidial_hopper where campaign_id IN('$CLIcampaign');"; } else { @@ -340,8 +361,47 @@ if ($wipe_hopper_clean) exit; } + +### Count only process +if ($count_only) + { + if (length($CLIcampaign)>0) + { + $stmtA = "SELECT count(*) from $vicidial_hopper where campaign_id IN('$CLIcampaign');"; + } + else + { + $stmtA = "SELECT count(*) from $vicidial_hopper;"; + } + $hopper_count_only=0; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $hopper_count_only = $aryA[0]; + } + $sthA->finish(); + if ($DB) + {print "Hopper count: $hopper_count_only|$stmtA|\n";} + else + {print "Hopper count: $hopper_count_only\n";} + $event_string = "|HOPPER COUNT: $hopper_count_only|"; + &event_logger; + + exit; + } + ### Delete leads from inactive lists if there are any -$stmtA = "SELECT list_id FROM vicidial_lists where ( (active='N') or ( (active='Y') and (expiration_date < \"$file_date\") ) );"; +if (length($CLIcampaign)>0) + { + $stmtA = "SELECT list_id FROM vicidial_lists where ( ( (active='N') or ( (active='Y') and (expiration_date < \"$file_date\") ) ) and (campaign_id IN('$CLIcampaign') ) );"; + } +else + { + $stmtA = "SELECT list_id FROM vicidial_lists where ( (active='N') or ( (active='Y') and (expiration_date < \"$file_date\") ) );"; + } if ($DB) {print $stmtA;} $inactive_lists=''; $inactive_lists_count=0; @@ -373,7 +433,14 @@ if ($inactive_lists_count > 0) ##### BEGIN Change CBHOLD status leads to CALLBK if their vicidial_callbacks time has passed -$stmtA = "SELECT count(*) FROM vicidial_callbacks where callback_time <= '$now_date' and status='ACTIVE';"; +if (length($CLIcampaign)>0) + { + $stmtA = "SELECT count(*) FROM vicidial_callbacks where callback_time <= '$now_date' and status='ACTIVE' and campaign_id IN('$CLIcampaign');"; + } +else + { + $stmtA = "SELECT count(*) FROM vicidial_callbacks where callback_time <= '$now_date' and status='ACTIVE';"; + } $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @aryA = $sthA->fetchrow_array; @@ -386,7 +453,14 @@ if ($CBHOLD_count > 0) $update_leads=''; $cbc=0; $cba=0; - $stmtA = "SELECT vicidial_callbacks.lead_id,recipient,campaign_id,vicidial_callbacks.list_id,gmt_offset_now,state,vicidial_callbacks.lead_status,vendor_lead_code FROM vicidial_callbacks,vicidial_list where callback_time <= '$now_date' and vicidial_callbacks.status='ACTIVE' and vicidial_callbacks.lead_id=vicidial_list.lead_id;"; + if (length($CLIcampaign)>0) + { + $stmtA = "SELECT vicidial_callbacks.lead_id,recipient,campaign_id,vicidial_callbacks.list_id,gmt_offset_now,state,vicidial_callbacks.lead_status,vendor_lead_code FROM vicidial_callbacks,vicidial_list where callback_time <= '$now_date' and vicidial_callbacks.status='ACTIVE' and vicidial_callbacks.lead_id=vicidial_list.lead_id and vicidial_callbacks.campaign_id IN('$CLIcampaign');"; + } + else + { + $stmtA = "SELECT vicidial_callbacks.lead_id,recipient,campaign_id,vicidial_callbacks.list_id,gmt_offset_now,state,vicidial_callbacks.lead_status,vendor_lead_code FROM vicidial_callbacks,vicidial_list where callback_time <= '$now_date' and vicidial_callbacks.status='ACTIVE' and vicidial_callbacks.lead_id=vicidial_list.lead_id;"; + } $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -448,7 +522,14 @@ if ($CBHOLD_count > 0) ##### BEGIN Auto-Alt-Dial DNC check and update or delete ### Find out how many leads in the hopper are set to DNC status $hopper_dnc_count=0; -$stmtA = "SELECT count(*) from $vicidial_hopper where status='DNC';"; +if (length($CLIcampaign)>0) + { + $stmtA = "SELECT count(*) from $vicidial_hopper where status='DNC' and campaign_id IN('$CLIcampaign');"; + } +else + { + $stmtA = "SELECT count(*) from $vicidial_hopper where status='DNC';"; + } $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -466,7 +547,14 @@ if ($hopper_dnc_count > 0) &event_logger; ### Gather all DNC statused vicidial_hopper entries - $stmtA = "SELECT hopper_id,lead_id,alt_dial,campaign_id FROM $vicidial_hopper where status='DNC';"; + if (length($CLIcampaign)>0) + { + $stmtA = "SELECT hopper_id,lead_id,alt_dial,campaign_id FROM $vicidial_hopper where status='DNC' and campaign_id IN('$CLIcampaign');"; + } + else + { + $stmtA = "SELECT hopper_id,lead_id,alt_dial,campaign_id FROM $vicidial_hopper where status='DNC';"; + } $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArowsVHdnc=$sthA->rows; @@ -818,9 +906,9 @@ if ($hopper_dnc_count > 0) @campaign_id=@MT; $ANY_hopper_vlc_dup_check='N'; -if ($CLIcampaign) +if (length($CLIcampaign)>1) { - $stmtA = "SELECT campaign_id,lead_order,hopper_level,auto_dial_level,local_call_time,lead_filter_id,use_internal_dnc,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,dial_statuses,list_order_mix,use_campaign_dnc,drop_lockout_time,no_hopper_dialing,auto_alt_dial_statuses,dial_timeout,auto_hopper_multi,use_auto_hopper,auto_trim_hopper,lead_order_randomize,lead_order_secondary,call_count_limit,hopper_vlc_dup_check from vicidial_campaigns where campaign_id='$CLIcampaign';"; + $stmtA = "SELECT campaign_id,lead_order,hopper_level,auto_dial_level,local_call_time,lead_filter_id,use_internal_dnc,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,dial_statuses,list_order_mix,use_campaign_dnc,drop_lockout_time,no_hopper_dialing,auto_alt_dial_statuses,dial_timeout,auto_hopper_multi,use_auto_hopper,auto_trim_hopper,lead_order_randomize,lead_order_secondary,call_count_limit,hopper_vlc_dup_check from vicidial_campaigns where campaign_id IN('$CLIcampaign');"; } else { diff --git a/docs/CELLPHONE_USA_TCPA_FCC_COMPLIANCE.txt b/docs/CELLPHONE_USA_TCPA_FCC_COMPLIANCE.txt index 10655049..38e9bac8 100644 --- a/docs/CELLPHONE_USA_TCPA_FCC_COMPLIANCE.txt +++ b/docs/CELLPHONE_USA_TCPA_FCC_COMPLIANCE.txt @@ -5,20 +5,31 @@ We have received many inquiries from clients about the impending FCC deadline of First, here is a good summary of what the changes are, and what the definition of terms are: http://www.copilevitz-canter.com/resources/articles/upcoming-fcc-rule-changes-regarding-express-consent-to-call-cell-phones +Now time for a disclaimer. I am not a lawyer, and this document was not written by a lawyer. If you want legal advice on this topic, I strongly suggest discussing it with a telecommunications lawyer. + In summary, the new regulations ban any calls to cellphones in the USA by "automatic telephone dialing systems"(or ATDS) unless you have specifically received explicit written or audio recorded permission from the person(or spouse of the person) you are calling that you are allowed to call them on their cell phone through an auto-dialer. The vague definition of ATDS that the FCC uses is, "equipment which has the capacity (A) to store or produce telephone numbers to be called, using a random or sequential number generator; and (B) to dial such numbers". -This is such a broad definition that even a modern smartphone fits it's definition. But, the FCC also has said more recently that the basic function of an ATDS is “the capacity to dial numbers without human intervention”, which should pretty much exclude smartphones, as well as dialing systems where human intervention would be necessary for any calls to be placed, such as auto-dialers. -It is important to mention that this regulatory change has no effect on automated calls to land lines. +This is such a broad definition that even a modern smartphone fits it's definition. But, the FCC also has said more recently that the basic function of an ATDS is “the capacity to dial numbers without human intervention”, which should pretty much exclude smartphones, as well as dialing systems where human intervention would be necessary for any calls to be placed, such as auto-dialers. Unfortunately, some recent court rulings have ignored the "human intervention" exclusion, and ruled against companies that were purely click-to-dial calling people because their phone systems had "the capacity to store and dial phone numbers". Under this very strict interpretation of the law, there is virtually no way to call anyone on a cellphone unless you use only a basic analog wired phone. -For our clients that have the strictest interpretation of the regulation change, we have added a programmatic feature that is non-editable in System Settings called "Disable Auto Dial" which is disabled by default. This feature was added on July 11, 2013 and is available in svn/trunk versions 1999 and higher. To enable or disable this feature, you have to issue a MySQL command through the command line mysql interface: +It is important to mention that this regulatory change has no effect on automated calls to land line phones, except that it does disallow all pre-recorded robo-calls for marketing purposes unless you have express consent. - $ mysql asterisk - mysql> UPDATE system_settings SET disable_auto_dial='1'; - mysql> quit +For our clients that believe preview dialing, or click-to-dial list dialing, is acceptable, we have added a programmatic option that is non-editable in System Settings called "Disable Auto Dial" which is disabled by default. This feature was added on July 11, 2013 and is available in svn/trunk versions 1999 and higher. To enable or disable this feature, you have to issue a MySQL command through the command line mysql interface: + + mysql asterisk + UPDATE system_settings SET disable_auto_dial='1'; + UPDATE vicidial_campaigns SET dial_method='INBOUND_MAN' where dial_method NOT IN('MANUAL','RATIO','INBOUND_MAN'); + ALTER TABLE vicidial_campaigns MODIFY dial_method ENUM('MANUAL','RATIO','INBOUND_MAN') default 'MANUAL' NOT NULL; + UPDATE vicidial_campaigns SET auto_dial_level='1' where auto_dial_level NOT IN('0','1','1.0'); + ALTER TABLE vicidial_campaigns MODIFY auto_dial_level ENUM('0','1','1.0') default '0' NOT NULL; + quit + + find /srv/www/htdocs/vicidial/ -type f -exec sed -i 's/ADAPT_HARD_LIMIT/MANUAL/g' {} + + find /srv/www/htdocs/vicidial/ -type f -exec sed -i 's/ADAPT_AVERAGE/MANUAL/g' {} + + find /srv/www/htdocs/vicidial/ -type f -exec sed -i 's/ADAPT_TAPERED/MANUAL/g' {} + Once this is done, the system will be incapable of automatically placing outbound calls. This includes dial methods using ADAPT and RATIO in campaigns. If this feature is enabled and you are using those dial methods, you will see this warning on the campaign modification screen: "Auto-dialing has been disabled on this system". If your system has this feature enabled, you should only be using the MANUAL and INBOUND_MAN campaign dial methods. diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index 0112c586..a2fc3eea 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -877,7 +877,8 @@ use_other_campaign_dnc VARCHAR(8) default '', allow_emails ENUM('Y','N') default 'N', amd_inbound_group VARCHAR(20) default '', amd_callmenu VARCHAR(50) default '', -survey_wait_sec TINYINT(3) default '10' +survey_wait_sec TINYINT(3) default '10', +manual_dial_lead_id ENUM('Y','N') default 'N' ) ENGINE=MyISAM; CREATE TABLE vicidial_lists ( @@ -3214,4 +3215,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='1358',db_schema_update_date=NOW(); +UPDATE system_settings SET db_schema_version='1359',db_schema_update_date=NOW(); diff --git a/extras/upgrade_2.8.sql b/extras/upgrade_2.8.sql index c3e16e6f..8dd097b5 100644 --- a/extras/upgrade_2.8.sql +++ b/extras/upgrade_2.8.sql @@ -118,3 +118,7 @@ UPDATE system_settings SET db_schema_version='1357',db_schema_update_date=NOW() ALTER TABLE system_settings ADD country_code_list_stats ENUM('0','1') default '0'; UPDATE system_settings SET db_schema_version='1358',db_schema_update_date=NOW() where db_schema_version < 1358; + +ALTER TABLE vicidial_campaigns ADD manual_dial_lead_id ENUM('Y','N') default 'N'; + +UPDATE system_settings SET db_schema_version='1359',db_schema_update_date=NOW() where db_schema_version < 1359; diff --git a/translations/raw_translation_files/TO_BE_TRANSLATED_2.8.txt b/translations/raw_translation_files/TO_BE_TRANSLATED_2.8.txt index 21c28846..169fa0b7 100644 --- a/translations/raw_translation_files/TO_BE_TRANSLATED_2.8.txt +++ b/translations/raw_translation_files/TO_BE_TRANSLATED_2.8.txt @@ -235,6 +235,14 @@ This option, if enabled, will log when a customer is put on hold and taken off h Country Code List Stats|| This setting if enabled will show a country code breakdown summary on the list modify screen. Default is 0 for disabled|| COUNTRY CODES WITHIN THIS LIST|| +Manual Dial by Lead ID|| +This allows the agent in manual dial mode to place a call by lead_id instead of a phone number. Default is N for disabled|| +The ViciDial Contact Center Suite is maintained by the|| +The ViciDial Contact Center Suite is released under the|| +This is the dial plan context that this phone will use to dial out. If you are running a call center and you do not want your agents to be able to dial out outside of the Contact Center applicaiton for example, then you would set this field to a dialplan context that does not exist, something like agent-nodial. default is default|| +Update List Owner|| +Advanced Lead Management Tools|| +Basic Lead Management Tools|| ########################## CHANGES TO EXISTING PHRASES IN ADMIN TRANSLATION @@ -244,6 +252,9 @@ COUNTRY CODES WITHIN THIS LIST|| ############################################################ CLIENT This agent screen was not opened properly|| +Dial Lead ID|| +Agent Form Display Script|| +Agent Notes|| ########################## CHANGES TO EXISTING PHRASES IN AGENT TRANSLATION diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index 5786ae64..227a7037 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -1454,6 +1454,20 @@ if ($ACTION == 'manDiaLnextCaLL') if (strlen($phone_number) > 5) {$override_dial_number = $phone_number;} + else + { + ##### gather local call time setting from campaign + $stmt="SELECT phone_number FROM vicidial_list where lead_id='$lead_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $lid_chk_ct = mysqli_num_rows($rslt); + if ($lid_chk_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $phone_number = $row[0]; + } + } } else { diff --git a/www/agc/vdc_form_display.php b/www/agc/vdc_form_display.php index 6a154980..de9604a3 100644 --- a/www/agc/vdc_form_display.php +++ b/www/agc/vdc_form_display.php @@ -428,7 +428,7 @@ else echo "\n"; echo "\n"; echo "\n"; - echo "ViciDial Form Display Script"; + echo "<title>Agent Form Display Script"; echo "\n"; echo "\n"; diff --git a/www/agc/vdc_script_notes.php b/www/agc/vdc_script_notes.php index 67c2fddb..6c8ad70f 100644 --- a/www/agc/vdc_script_notes.php +++ b/www/agc/vdc_script_notes.php @@ -315,7 +315,7 @@ if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) echo "\n"; echo "\n"; echo "\n"; -echo "ViciDial Notes"; +echo "<title>Agent Notes"; echo "\n"; echo "\n"; echo "\n"; diff --git a/www/agc/vicidial.php b/www/agc/vicidial.php index 82cf88cd..abb3104d 100644 --- a/www/agc/vicidial.php +++ b/www/agc/vicidial.php @@ -412,10 +412,11 @@ # 130903-1920 - Added security check for browser window name, see launch.php for more information # 130925-2119 - Fixed span order issue # 131007-1348 - Added mrglock_ig_select_ct options.php setting +# 131010-2149 - Added option to allow manual dial by lead_id # -$version = '2.8-381c'; -$build = '131007-1348'; +$version = '2.8-382c'; +$build = '131010-2149'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=79; $one_mysql_log=0; @@ -1425,7 +1426,7 @@ else $HKstatusnames = substr("$HKstatusnames", 0, -1); ##### grab the campaign settings - $stmt="SELECT park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,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,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,agent_pause_codes_active,no_hopper_leads_logins,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,xfer_groups,disable_alter_custphone,display_queue_count,manual_dial_filter,agent_clipboard_copy,use_campaign_dnc,three_way_call_cid,dial_method,three_way_dial_prefix,web_form_target,vtiger_screen_login,agent_allow_group_alias,default_group_alias,quick_transfer_button,prepopulate_transfer_preset,view_calls_in_queue,view_calls_in_queue_launch,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,agent_select_territories,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,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,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,manual_preview_dial,api_manual_dial,manual_dial_call_time_check,my_callback_option,per_call_notes,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_pause_precall_code,auto_resume_precall,manual_dial_cid,custom_3way_button_transfer,callback_days_limit,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,pllb_grouping,pllb_grouping_limit,in_group_dial,in_group_dial_select,pause_after_next_call,owner_populate FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; + $stmt="SELECT park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,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,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,agent_pause_codes_active,no_hopper_leads_logins,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,xfer_groups,disable_alter_custphone,display_queue_count,manual_dial_filter,agent_clipboard_copy,use_campaign_dnc,three_way_call_cid,dial_method,three_way_dial_prefix,web_form_target,vtiger_screen_login,agent_allow_group_alias,default_group_alias,quick_transfer_button,prepopulate_transfer_preset,view_calls_in_queue,view_calls_in_queue_launch,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,agent_select_territories,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,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,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,manual_preview_dial,api_manual_dial,manual_dial_call_time_check,my_callback_option,per_call_notes,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_pause_precall_code,auto_resume_precall,manual_dial_cid,custom_3way_button_transfer,callback_days_limit,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,pllb_grouping,pllb_grouping_limit,in_group_dial,in_group_dial_select,pause_after_next_call,owner_populate,manual_dial_lead_id FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01013',$VD_login,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -1535,6 +1536,7 @@ else $in_group_dial_select = $row[102]; $pause_after_next_call = $row[103]; $owner_populate = $row[104]; + $manual_dial_lead_id = $row[105]; if ( ($queuemetrics_pe_phone_append > 0) and (strlen($qm_phone_environment)>0) ) {$qm_phone_environment .= "-$qm_extension";} @@ -6611,6 +6613,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) var MDDiaLCodEform = document.vicidial_form.MDDiaLCodE.value; var MDPhonENumbeRform = document.vicidial_form.MDPhonENumbeR.value; var MDLeadIDform = document.vicidial_form.MDLeadID.value; + var MDLeadIDEntryform = document.vicidial_form.MDLeadIDEntry.value; var MDTypeform = document.vicidial_form.MDType.value; var MDDiaLOverridEform = document.vicidial_form.MDDiaLOverridE.value; var MDVendorLeadCode = document.vicidial_form.vendor_lead_code.value; @@ -6624,6 +6627,9 @@ function set_length(SLnumber,SLlength_goal,SLdirection) if (MDDiaLCodEform.length < 1) {MDDiaLCodEform = document.vicidial_form.phone_code.value;} + if (MDLeadIDEntryform.length > 0) + {MDLeadIDform = document.vicidial_form.MDLeadIDEntry.value;} + if ( (MDDiaLOverridEform.length > 0) && (active_ingroup_dial.length < 1) ) { agent_dialed_number=1; @@ -6665,6 +6671,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) document.vicidial_form.MDPhonENumbeR.value = ''; document.vicidial_form.MDDiaLOverridE.value = ''; document.vicidial_form.MDLeadID.value = ''; + document.vicidial_form.MDLeadIDEntry.value=''; document.vicidial_form.MDType.value = ''; document.vicidial_form.MDPhonENumbeRHiddeN.value = ''; } @@ -10540,6 +10547,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) document.vicidial_form.MDPhonENumbeR.value = ''; document.vicidial_form.MDDiaLOverridE.value = ''; document.vicidial_form.MDLeadID.value = ''; + document.vicidial_form.MDLeadIDEntry.value=''; document.vicidial_form.MDType.value = ''; document.vicidial_form.MDPhonENumbeRHiddeN.value = ''; inbound_lead_search=0; @@ -12796,6 +12804,7 @@ function phone_number_format(formatphone) { document.vicidial_form.MDPhonENumbeR.value = ''; document.vicidial_form.MDDiaLOverridE.value = ''; document.vicidial_form.MDLeadID.value = ''; + document.vicidial_form.MDLeadIDEntry.value=''; document.vicidial_form.MDType.value = ''; document.vicidial_form.MDPhonENumbeRHiddeN.value = ''; } @@ -15217,6 +15226,20 @@ class="cust_form_text" value=""> + "; + echo " \n"; + echo " Dial Lead ID: \n"; + echo " \n"; + echo "   (digits only)\n"; + } + else + { + echo "\n"; + } + ?> Search Existing Leads: diff --git a/www/vicidial/AST_agent_performance_detail.php b/www/vicidial/AST_agent_performance_detail.php index 5f98636b..895f9f4a 100644 --- a/www/vicidial/AST_agent_performance_detail.php +++ b/www/vicidial/AST_agent_performance_detail.php @@ -37,6 +37,7 @@ # 130704-0935 - Fixed issue #675 # 130829-2012 - Changed to mysqli PHP functions # 131002-2015 - Added user group to report output +# 131010-1930 - Expanded user group column, added most recent user group # $startMS = microtime(); @@ -55,6 +56,8 @@ if (isset($_GET["group"])) {$group=$_GET["group"];} elseif (isset($_POST["group"])) {$group=$_POST["group"];} if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];} elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];} +if (isset($_GET["users"])) {$users=$_GET["users"];} + elseif (isset($_POST["users"])) {$users=$_POST["users"];} if (isset($_GET["shift"])) {$shift=$_GET["shift"];} elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} if (isset($_GET["stage"])) {$stage=$_GET["stage"];} @@ -257,6 +260,15 @@ while($i < $group_ct) $i++; } +$i=0; +$users_string='|'; +$users_ct = count($users); +while($i < $users_ct) + { + $users_string .= "$users[$i]|"; + $i++; + } + $stmt="select campaign_id from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$HTML_text.="$stmt\n";} @@ -288,6 +300,21 @@ while ($i < $user_groups_to_print) $i++; } +$stmt="select user, full_name from vicidial_users $whereLOGadmin_viewable_groupsSQL order by user"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$HTML_text.="$stmt\n";} +$users_to_print = mysqli_num_rows($rslt); +$i=0; +while ($i < $users_to_print) + { + $row=mysqli_fetch_row($rslt); + $users[$i]=$row[0]; + $user_names[$i]=$row[1]; + if ($all_users) {$user[$i]=$row[0];} + $i++; + } + + $i=0; $group_string='|'; $group_ct = count($group); @@ -324,9 +351,12 @@ if ( (preg_match('/\-\-ALL\-\-/',$user_group_string) ) or ($user_group_ct < 1) ) else { $user_group_SQL = preg_replace('/,$/i', '',$user_group_SQL); - $user_group_SQL = "and vicidial_agent_log.user_group IN($user_group_SQL)"; + $user_group_agent_log_SQL = "and vicidial_agent_log.user_group IN($user_group_SQL)"; + $user_group_SQL = "and vicidial_users.user_group IN($user_group_SQL)"; } + + if ($DB) {$HTML_text.="$user_group_string|$user_group_ct|$user_groupQS|$i
";} $LINKbase = "$PHP_SELF?query_date=$query_date&end_date=$end_date$groupQS$user_groupQS&shift=$shift&DB=$DB"; @@ -421,6 +451,21 @@ while ($user_groups_to_print > $o) $o++; } $HTML_text.="\n"; +$HTML_text.="Users:
"; +$HTML_text.="\n"; $HTML_text.="Shift:
"; $HTML_text.="\n"; +$HTML_text.=""; + +$HTML_text.="\n"; + +$HTML_text.="
to
"; + +$HTML_text.="\n"; + +$HTML_text.=" Campaigns:
"; +$HTML_text.="\n"; +$HTML_text.="User Groups:
"; +$HTML_text.="\n"; +$HTML_text.="Shift:
"; +$HTML_text.="

\n"; +$HTML_text.="Display as:
"; +$HTML_text.="\n

"; +$HTML_text.="$NWB#agent_performance_detail$NWE\n"; +$HTML_text.="         "; + +$HTML_text.="          \n"; +$HTML_text.=" REPORTS \n"; +$HTML_text.="\n"; +$HTML_text.=""; + +$HTML_text.="\n\n"; + + +$HTML_text.="
\n";
+
+
+if (!$group)
+{
+$HTML_text.="\n";
+$HTML_text.="PLEASE SELECT A CAMPAIGN AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+$HTML_text.=" NOTE: stats taken from shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$time_BEGIN=$AM_shift_BEGIN;
+	$time_END=$AM_shift_END;
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "03:45:00";}   
+	if (strlen($time_END) < 6) {$time_END = "15:14:59";}
+	}
+if ($shift == 'PM') 
+	{
+	$time_BEGIN=$PM_shift_BEGIN;
+	$time_END=$PM_shift_END;
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "15:15:00";}
+	if (strlen($time_END) < 6) {$time_END = "23:15:00";}
+	}
+if ($shift == 'ALL') 
+	{
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}
+	if (strlen($time_END) < 6) {$time_END = "23:59:59";}
+	}
+$query_date_BEGIN = "$query_date $time_BEGIN";   
+$query_date_END = "$end_date $time_END";
+
+$HTML_text.="Agent Performance Detail                        $NOW_TIME\n";
+
+$HTML_text.="Time range: $query_date_BEGIN to $query_date_END\n\n";
+$HTML_text.="---------- AGENTS Details -------------\n\n";
+
+
+### BEGIN gather all statuses that are in status flags  ###
+$sale_statuses='';
+$sale_pattern_match="|";
+$stmt="select status from vicidial_statuses where sale='Y' UNION select status from vicidial_campaign_statuses where sale='Y' and selectable IN('Y','N') $group_SQLand;";
+if ($DB) {$HTML_text.="$stmt\n";}
+$rslt=mysql_to_mysqli($stmt, $link);
+$statha_to_print = mysqli_num_rows($rslt);
+$i=0;
+while ($i < $statha_to_print)
+	{
+	$row=mysqli_fetch_row($rslt);
+	$temp_status=$row[0];
+	$sale_statuses .= "'$temp_status',";
+	$sale_pattern_match .= "$temp_status|";
+	$i++;
+	}
+if ($DB) {$HTML_text.="$sale_pattern_match\n";}
+
+
+$statuses='-';
+$statusesTXT='';
+$statusesHEAD='';
+
+$CSV_header="\"Agent Performance Detail                        $NOW_TIME\"\n";
+$CSV_header.="\"Time range: $query_date_BEGIN to $query_date_END\"\n\n";
+$CSV_header.="\"---------- AGENTS Details -------------\"\n";
+$CSV_header.='"USER NAME","ID","CURRENT USER GROUP","MOST RECENT USER GROUP","SALES/CALLS %","SALES PER HOUR","TOTAL SALES","CALLS","TIME","PAUSE","PAUSAVG","WAIT","WAITAVG","TALK","TALKAVG","DISPO","DISPAVG","DEAD","DEADAVG","CUSTOMER","CUSTAVG"';
+
+$statusesHTML='';
+$statusesARY[0]='';
+$j=0;
+$users='-';
+$usersARY[0]='';
+$user_namesARY[0]='';
+$k=0;
+
+$recent_UG_stmt="select max(event_time), user, user_group from vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000 $group_SQL $user_group_agent_log_SQL group by user";
+if ($DB) {$HTML_text.="$recent_UG_stmt\n";}
+$recent_UG_rslt=mysql_to_mysqli($recent_UG_stmt, $link);
+while ($UG_row=mysqli_fetch_row($recent_UG_rslt)) {
+	$recent_user_groups[$UG_row[1]]=$UG_row[2];
+}
+
+$stmt="select count(*) as calls,sum(talk_sec) as talk,full_name,vicidial_users.user,sum(pause_sec),sum(wait_sec),sum(dispo_sec),status,sum(dead_sec), vicidial_users.user_group from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000 $group_SQL $user_group_SQL group by user,full_name,user_group,status order by full_name,user,status desc limit 500000;";
+$rslt=mysql_to_mysqli($stmt, $link);
+if ($DB) {$HTML_text.="$stmt\n";}
+$rows_to_print = mysqli_num_rows($rslt);
+
+$graph_stats=array();
+$max_calls=1;
+$max_time=1;
+$max_pause=1;
+$max_pauseavg=1;
+$max_wait=1;
+$max_waitavg=1;
+$max_talk=1;
+$max_talkavg=1;
+$max_dispo=1;
+$max_dispoavg=1;
+$max_dead=1;
+$max_deadavg=1;
+$max_customer=1;
+$max_customeravg=1;
+$GRAPH="

"; +$GRAPH2=""; +$graph_header="
CALLSTIMEPAUSEPAUSE AVGWAITWAIT AVGTALKTALK AVGDISPODISPO AVGDEADDEAD AVGCUSTCUST AVG
"; +$CALLS_graph=$graph_header.""; +$TIME_graph=$graph_header.""; +$PAUSE_graph=$graph_header.""; +$PAUSEAVG_graph=$graph_header.""; +$WAIT_graph=$graph_header.""; +$WAITAVG_graph=$graph_header.""; +$TALK_graph=$graph_header.""; +$TALKAVG_graph=$graph_header.""; +$DISPO_graph=$graph_header.""; +$DISPOAVG_graph=$graph_header.""; +$DEAD_graph=$graph_header.""; +$DEADAVG_graph=$graph_header.""; +$CUST_graph=$graph_header.""; +$CUSTAVG_graph=$graph_header.""; + +$i=0; +while ($i < $rows_to_print) + { + $row=mysqli_fetch_row($rslt); +# $row[0] = ($row[0] - 1); # subtract 1 for login/logout event compensation + + $calls[$i] = $row[0]; + $talk_sec[$i] = $row[1]; + $full_name[$i] = $row[2]; + $user[$i] = $row[3]; + $pause_sec[$i] = $row[4]; + $wait_sec[$i] = $row[5]; + $dispo_sec[$i] = $row[6]; + $status[$i] = strtoupper($row[7]); + $dead_sec[$i] = $row[8]; + $user_group[$i] = $row[9]; + $customer_sec[$i] = ($talk_sec[$i] - $dead_sec[$i]); + + if (preg_match("/\|$row[7]\|/i", $sale_pattern_match)) { + $sale_counts[$row[3]]+=$row[0]; + } + + $max_varname="max_".$status[$i]; + $$max_varname=1; + + if ($customer_sec[$i] < 1) + {$customer_sec[$i]=0;} + if ( (!preg_match("/\-$status[$i]\-/i", $statuses)) and (strlen($status[$i])>0) ) + { + $statusesTXT = sprintf("%8s", $status[$i]); + $statusesHEAD .= "----------+"; + $statusesHTML .= " $statusesTXT |"; + + $CSV_header.=",\"$status[$i]\""; + + $statuses .= "$status[$i]-"; + $statusesARY[$j] = $status[$i]; + $j++; + } + if (!preg_match("/\-$user[$i]\-/i", $users)) + { + $users .= "$user[$i]-"; + $usersARY[$k] = $user[$i]; + $user_namesARY[$k] = $full_name[$i]; + $user_groupsARY[$k] = $user_group[$i]; + $k++; + } + + $i++; + } + +$CSV_header.="\n"; +$CSV_lines=''; + +$ASCII_text.="CALL STATS BREAKDOWN: (Statistics related to handling of calls only) [DOWNLOAD]\n"; +$ASCII_text.="+-----------------+----------+----------------------+----------------------+---------------+----------------+-------------+--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n"; +$ASCII_text.="| USER NAME | ID | CURRENT USER GROUP | MOST RECENT USER GRP | SALES/CALLS % | SALES PER HOUR | TOTAL SALES | CALLS | TIME | PAUSE |PAUSAVG | WAIT |WAITAVG | TALK |TALKAVG | DISPO |DISPAVG | DEAD |DEADAVG | CUSTOMER |CUSTAVG |$statusesHTML\n"; +$ASCII_text.="+-----------------+----------+----------------------+----------------------+---------------+----------------+-------------+--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n"; + + +### BEGIN loop through each user ### +$m=0; +while ($m < $k) + { + $Suser=$usersARY[$m]; + + $Slast_user_group=$recent_user_groups[$Suser]; + $recent_UG_stmt="select max(event_time) as most_recent_event, user_group from vicidial_agent_log where user='$Suser' and event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000 $group_SQL $user_group_agent_log_SQL group by user_group order by most_recent_event desc limit 1"; + if ($DB) {$HTML_text.="$recent_UG_stmt\n";} + $recent_UG_rslt=mysql_to_mysqli($recent_UG_stmt, $link); + while ($UG_row=mysqli_fetch_row($recent_UG_rslt)) { + $Slast_user_group=$UG_row[1]; + $recent_user_groups[$Suser]=$UG_row[1]; + } + + $Sfull_name=$user_namesARY[$m]; + $Suser_group=$user_groupsARY[$m]; + $Stotal_sales=$sale_counts[$Suser]+0; + $Sgrand_total_sales+=$Stotal_sales; + $Stime=0; + $Scalls=0; + $Stalk_sec=0; + $Spause_sec=0; + $Swait_sec=0; + $Sdispo_sec=0; + $Sdead_sec=0; + $Scustomer_sec=0; + $SstatusesHTML=''; + $CSVstatuses=''; + + ### BEGIN loop through each status ### + $n=0; + while ($n < $j) + { + $Sstatus=$statusesARY[$n]; + $SstatusTXT=''; + + $varname=$Sstatus."_graph"; + $$varname=$graph_header.""; + $max_varname="max_".$Sstatus; + ### BEGIN loop through each stat line ### + $i=0; $status_found=0; + while ($i < $rows_to_print) + { + if ( ($Suser=="$user[$i]") and ($Sstatus=="$status[$i]") ) + { + $Scalls = ($Scalls + $calls[$i]); + $Stalk_sec = ($Stalk_sec + $talk_sec[$i]); + $Spause_sec = ($Spause_sec + $pause_sec[$i]); + $Swait_sec = ($Swait_sec + $wait_sec[$i]); + $Sdispo_sec = ($Sdispo_sec + $dispo_sec[$i]); + $Sdead_sec = ($Sdead_sec + $dead_sec[$i]); + $Scustomer_sec = ($Scustomer_sec + $customer_sec[$i]); + $SstatusTXT = sprintf("%8s", $calls[$i]); + $SstatusesHTML .= " $SstatusTXT |"; + + if ($calls[$i]>$$max_varname) {$$max_varname=$calls[$i];} + $graph_stats[$m][(15+$n)]=($calls[$i]+0); + + $CSVstatuses.=",\"$calls[$i]\""; + + $status_found++; + } + $i++; + } + if ($status_found < 1) + { + $SstatusesHTML .= " 0 |"; + $CSVstatuses.=",\"0\""; + $graph_stats[$m][(15+$n)]=0; + } + ### END loop through each stat line ### + $n++; + } + ### END loop through each status ### + $Stime = ($Stalk_sec + $Spause_sec + $Swait_sec + $Sdispo_sec); + $TOTcalls=($TOTcalls + $Scalls); + $TOTtime=($TOTtime + $Stime); + $TOTtotTALK=($TOTtotTALK + $Stalk_sec); + $TOTtotWAIT=($TOTtotWAIT + $Swait_sec); + $TOTtotPAUSE=($TOTtotPAUSE + $Spause_sec); + $TOTtotDISPO=($TOTtotDISPO + $Sdispo_sec); + $TOTtotDEAD=($TOTtotDEAD + $Sdead_sec); + $TOTtotCUSTOMER=($TOTtotCUSTOMER + $Scustomer_sec); + $Stime = ($Stalk_sec + $Spause_sec + $Swait_sec + $Sdispo_sec); + if ( ($Scalls > 0) and ($Stalk_sec > 0) ) {$Stalk_avg = ($Stalk_sec/$Scalls);} + else {$Stalk_avg=0;} + if ( ($Scalls > 0) and ($Spause_sec > 0) ) {$Spause_avg = ($Spause_sec/$Scalls);} + else {$Spause_avg=0;} + if ( ($Scalls > 0) and ($Swait_sec > 0) ) {$Swait_avg = ($Swait_sec/$Scalls);} + else {$Swait_avg=0;} + if ( ($Scalls > 0) and ($Sdispo_sec > 0) ) {$Sdispo_avg = ($Sdispo_sec/$Scalls);} + else {$Sdispo_avg=0;} + if ( ($Scalls > 0) and ($Sdead_sec > 0) ) {$Sdead_avg = ($Sdead_sec/$Scalls);} + else {$Sdead_avg=0;} + if ( ($Scalls > 0) and ($Scustomer_sec > 0) ) {$Scustomer_avg = ($Scustomer_sec/$Scalls);} + else {$Scustomer_avg=0;} + + $RAWuser = $Suser; + $RAWcalls = $Scalls; + $Scalls = sprintf("%6s", $Scalls); + $Sfull_nameRAW = $Sfull_name; + $SuserRAW = $Suser; + + if ($non_latin < 1) + { + $Sfull_name= sprintf("%-15s", $Sfull_name); + while(strlen($Sfull_name)>15) {$Sfull_name = substr("$Sfull_name", 0, -1);} + $Suser_group= sprintf("%-20s", $Suser_group); + while(strlen($Suser_group)>20) {$Suser_group = substr("$Suser_group", 0, -1);} + $Slast_user_group= sprintf("%-20s", $Slast_user_group); + while(strlen($Slast_user_group)>20) {$Slast_user_group = substr("$Slast_user_group", 0, -1);} + $Suser = sprintf("%-8s", $Suser); + while(strlen($Suser)>8) {$Suser = substr("$Suser", 0, -1);} + } + else + { + $Sfull_name= sprintf("%-45s", $Sfull_name); + while(mb_strlen($Sfull_name,'utf-8')>15) {$Sfull_name = mb_substr("$Sfull_name", 0, -1,'utf-8');} + $Suser_group= sprintf("%-45s", $Suser_group); + while(mb_strlen($Suser_group,'utf-8')>15) {$Suser_group = mb_substr("$Suser_group", 0, -1,'utf-8');} + $Suser = sprintf("%-24s", $Suser); + while(mb_strlen($Suser,'utf-8')>8) {$Suser = mb_substr("$Suser", 0, -1,'utf-8');} + } + + if (trim($Scalls)>$max_calls) {$max_calls=trim($Scalls);} + if (trim($Stime)>$max_time) {$max_time=trim($Stime);} + if (trim($Spause_sec)>$max_pause) {$max_pause=trim($Spause_sec);} + if (trim($Spause_avg)>$max_pauseavg) {$max_pauseavg=trim($Spause_avg);} + if (trim($Swait_sec)>$max_wait) {$max_wait=trim($Swait_sec);} + if (trim($Swait_avg)>$max_waitavg) {$max_waitavg=trim($Swait_avg);} + if (trim($Stalk_sec)>$max_talk) {$max_talk=trim($Stalk_sec);} + if (trim($Stalk_avg)>$max_talkavg) {$max_talkavg=trim($Stalk_avg);} + if (trim($Sdispo_sec)>$max_dispo) {$max_dispo=trim($Sdispo_sec);} + if (trim($Sdispo_avg)>$max_dispoavg) {$max_dispoavg=trim($Sdispo_avg);} + if (trim($Sdead_sec)>$max_dead) {$max_dead=trim($Sdead_sec);} + if (trim($Sdead_avg)>$max_deadavg) {$max_deadavg=trim($Sdead_avg);} + if (trim($Scustomer_sec)>$max_customer) {$max_customer=trim($Scustomer_sec);} + if (trim($Scustomer_avg)>$max_customeravg) {$max_customeravg=trim($Scustomer_avg);} + $graph_stats[$m][0]=trim($Sfull_name)." - ".trim($Suser); + $graph_stats[$m][1]=trim($Scalls); + $graph_stats[$m][2]=trim($Stime); + $graph_stats[$m][3]=trim($Spause_sec); + $graph_stats[$m][4]=trim($Spause_avg); + $graph_stats[$m][5]=trim($Swait_sec); + $graph_stats[$m][6]=trim($Swait_avg); + $graph_stats[$m][7]=trim($Stalk_sec); + $graph_stats[$m][8]=trim($Stalk_avg); + $graph_stats[$m][9]=trim($Sdispo_sec); + $graph_stats[$m][10]=trim($Sdispo_avg); + $graph_stats[$m][11]=trim($Sdead_sec); + $graph_stats[$m][12]=trim($Sdead_avg); + $graph_stats[$m][13]=trim($Scustomer_sec); + $graph_stats[$m][14]=trim($Scustomer_avg); + + $pfUSERtime_MS = sec_convert($Stime,'H'); + $pfUSERtotTALK_MS = sec_convert($Stalk_sec,'H'); + $pfUSERavgTALK_MS = sec_convert($Stalk_avg,'M'); + $USERtotPAUSE_MS = sec_convert($Spause_sec,'H'); + $USERavgPAUSE_MS = sec_convert($Spause_avg,'M'); + $USERtotWAIT_MS = sec_convert($Swait_sec,'H'); + $USERavgWAIT_MS = sec_convert($Swait_avg,'M'); + $USERtotDISPO_MS = sec_convert($Sdispo_sec,'H'); + $USERavgDISPO_MS = sec_convert($Sdispo_avg,'M'); + $USERtotDEAD_MS = sec_convert($Sdead_sec,'H'); + $USERavgDEAD_MS = sec_convert($Sdead_avg,'M'); + $USERtotCUSTOMER_MS = sec_convert($Scustomer_sec,'H'); + $USERavgCUSTOMER_MS = sec_convert($Scustomer_avg,'M'); + + $pfUSERtime_MS = sprintf("%9s", $pfUSERtime_MS); + $pfUSERtotTALK_MS = sprintf("%8s", $pfUSERtotTALK_MS); + $pfUSERavgTALK_MS = sprintf("%6s", $pfUSERavgTALK_MS); + $pfUSERtotPAUSE_MS = sprintf("%8s", $USERtotPAUSE_MS); + $pfUSERavgPAUSE_MS = sprintf("%6s", $USERavgPAUSE_MS); + $pfUSERtotWAIT_MS = sprintf("%8s", $USERtotWAIT_MS); + $pfUSERavgWAIT_MS = sprintf("%6s", $USERavgWAIT_MS); + $pfUSERtotDISPO_MS = sprintf("%8s", $USERtotDISPO_MS); + $pfUSERavgDISPO_MS = sprintf("%6s", $USERavgDISPO_MS); + $pfUSERtotDEAD_MS = sprintf("%8s", $USERtotDEAD_MS); + $pfUSERavgDEAD_MS = sprintf("%6s", $USERavgDEAD_MS); + $pfUSERtotCUSTOMER_MS = sprintf("%8s", $USERtotCUSTOMER_MS); + $pfUSERavgCUSTOMER_MS = sprintf("%6s", $USERavgCUSTOMER_MS); + $PAUSEtotal[$m] = $pfUSERtotPAUSE_MS; + + $total_hours=($Stime/3600); + $Ssales_per_call=sprintf("%.2f", (100*($Stotal_sales/$Scalls)))." %"; + $Ssales_per_hour=sprintf("%.2f", ($Stotal_sales/$total_hours)); + + $Ssales_per_call=sprintf("%13s", $Ssales_per_call); + $Ssales_per_hour=sprintf("%14s", $Ssales_per_hour); + $Stotal_sales=sprintf("%11s", $Stotal_sales); + + $Toutput = "| $Sfull_name | $Suser | $Suser_group | $Slast_user_group | $Ssales_per_call | $Ssales_per_hour | $Stotal_sales | $Scalls | $pfUSERtime_MS | $pfUSERtotPAUSE_MS | $pfUSERavgPAUSE_MS | $pfUSERtotWAIT_MS | $pfUSERavgWAIT_MS | $pfUSERtotTALK_MS | $pfUSERavgTALK_MS | $pfUSERtotDISPO_MS | $pfUSERavgDISPO_MS | $pfUSERtotDEAD_MS | $pfUSERavgDEAD_MS | $pfUSERtotCUSTOMER_MS | $pfUSERavgCUSTOMER_MS |$SstatusesHTML\n"; + + $CSV_lines.="\"$Sfull_nameRAW\","; + $CSV_lines.=preg_replace('/\s/', '', "\"$SuserRAW\",\"$Suser_group\",\"$Slast_user_group\",\"$Ssales_per_call\",\"$Ssales_per_hour\",\"$Stotal_sales\",\"$Scalls\",\"$pfUSERtime_MS\",\"$pfUSERtotPAUSE_MS\",\"$pfUSERavgPAUSE_MS\",\"$pfUSERtotWAIT_MS\",\"$pfUSERavgWAIT_MS\",\"$pfUSERtotTALK_MS\",\"$pfUSERavgTALK_MS\",\"$pfUSERtotDISPO_MS\",\"$pfUSERavgDISPO_MS\",\"$pfUSERtotDEAD_MS\",\"$pfUSERavgDEAD_MS\",\"$pfUSERtotCUSTOMER_MS\",\"$pfUSERavgCUSTOMER_MS\"$CSVstatuses"); + $CSV_lines.="\n"; + + $TOPsorted_output[$m] = $Toutput; + + if ($stage == 'ID') + {$TOPsort[$m] = '' . sprintf("%08s", $RAWuser) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);} + if ($stage == 'LEADS') + {$TOPsort[$m] = '' . sprintf("%08s", $RAWcalls) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);} + if ($stage == 'TIME') + {$TOPsort[$m] = '' . sprintf("%08s", $Stime) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);} + if (!preg_match('/ID|TIME|LEADS/',$stage)) + {$ASCII_text.="$Toutput";} + + $m++; + } +### END loop through each user ### + + + +### BEGIN sort through output to display properly ### +if (preg_match('/ID|TIME|LEADS/',$stage)) + { + if (preg_match('/ID/',$stage)) + {sort($TOPsort, SORT_NUMERIC);} + if (preg_match('/TIME|LEADS/',$stage)) + {rsort($TOPsort, SORT_NUMERIC);} + + $m=0; + while ($m < $k) + { + $sort_split = explode("-----",$TOPsort[$m]); + $i = $sort_split[1]; + $sort_order[$m] = "$i"; + $ASCII_text.="$TOPsorted_output[$i]"; + $m++; + } + } +### END sort through output to display properly ### + + + +###### LAST LINE FORMATTING ########## +### BEGIN loop through each status ### +$SUMstatusesHTML=''; +$CSVSUMstatuses=''; +$n=0; +while ($n < $j) + { + $Scalls=0; + $Sstatus=$statusesARY[$n]; + $SUMstatusTXT=''; + $total_var=$Sstatus."_total"; + ### BEGIN loop through each stat line ### + $i=0; $status_found=0; + while ($i < $rows_to_print) + { + if ($Sstatus=="$status[$i]") + { + $Scalls = ($Scalls + $calls[$i]); + $status_found++; + } + $i++; + } + ### END loop through each stat line ### + if ($status_found < 1) + { + $SUMstatusesHTML .= " 0 |"; + $$total_var=0; + } + else + { + $SUMstatusTXT = sprintf("%8s", $Scalls); + $SUMstatusesHTML .= " $SUMstatusTXT |"; + $CSVSUMstatuses.=",\"$Scalls\""; + $$total_var=$Scalls; + } + $n++; + } +### END loop through each status ### + +$TOTcalls = sprintf("%7s", $TOTcalls); +$TOT_AGENTS = sprintf("%-4s", $m); + +if ($TOTtotTALK < 1) {$TOTavgTALK = '0';} +else {$TOTavgTALK = ($TOTtotTALK / $TOTcalls);} +if ($TOTtotDISPO < 1) {$TOTavgDISPO = '0';} +else {$TOTavgDISPO = ($TOTtotDISPO / $TOTcalls);} +if ($TOTtotDEAD < 1) {$TOTavgDEAD = '0';} +else {$TOTavgDEAD = ($TOTtotDEAD / $TOTcalls);} +if ($TOTtotPAUSE < 1) {$TOTavgPAUSE = '0';} +else {$TOTavgPAUSE = ($TOTtotPAUSE / $TOTcalls);} +if ($TOTtotWAIT < 1) {$TOTavgWAIT = '0';} +else {$TOTavgWAIT = ($TOTtotWAIT / $TOTcalls);} +if ($TOTtotCUSTOMER < 1) {$TOTavgCUSTOMER = '0';} +else {$TOTavgCUSTOMER = ($TOTtotCUSTOMER / $TOTcalls);} + +$TOTtime_MS = sec_convert($TOTtime,'H'); +$TOTtotTALK_MS = sec_convert($TOTtotTALK,'H'); +$TOTtotDISPO_MS = sec_convert($TOTtotDISPO,'H'); +$TOTtotDEAD_MS = sec_convert($TOTtotDEAD,'H'); +$TOTtotPAUSE_MS = sec_convert($TOTtotPAUSE,'H'); +$TOTtotWAIT_MS = sec_convert($TOTtotWAIT,'H'); +$TOTtotCUSTOMER_MS = sec_convert($TOTtotCUSTOMER,'H'); +$TOTavgTALK_MS = sec_convert($TOTavgTALK,'M'); +$TOTavgDISPO_MS = sec_convert($TOTavgDISPO,'H'); +$TOTavgDEAD_MS = sec_convert($TOTavgDEAD,'H'); +$TOTavgPAUSE_MS = sec_convert($TOTavgPAUSE,'H'); +$TOTavgWAIT_MS = sec_convert($TOTavgWAIT,'H'); +$TOTavgCUSTOMER_MS = sec_convert($TOTavgCUSTOMER,'H'); + +$TOTtime_MS = sprintf("%10s", $TOTtime_MS); +$TOTtotTALK_MS = sprintf("%10s", $TOTtotTALK_MS); +$TOTtotDISPO_MS = sprintf("%10s", $TOTtotDISPO_MS); +$TOTtotDEAD_MS = sprintf("%10s", $TOTtotDEAD_MS); +$TOTtotPAUSE_MS = sprintf("%10s", $TOTtotPAUSE_MS); +$TOTtotWAIT_MS = sprintf("%10s", $TOTtotWAIT_MS); +$TOTtotCUSTOMER_MS = sprintf("%10s", $TOTtotCUSTOMER_MS); +$TOTavgTALK_MS = sprintf("%6s", $TOTavgTALK_MS); +$TOTavgDISPO_MS = sprintf("%6s", $TOTavgDISPO_MS); +$TOTavgDEAD_MS = sprintf("%6s", $TOTavgDEAD_MS); +$TOTavgPAUSE_MS = sprintf("%6s", $TOTavgPAUSE_MS); +$TOTavgWAIT_MS = sprintf("%6s", $TOTavgWAIT_MS); +$TOTavgCUSTOMER_MS = sprintf("%6s", $TOTavgCUSTOMER_MS); + +while(strlen($TOTtime_MS)>10) {$TOTtime_MS = substr("$TOTtime_MS", 0, -1);} +while(strlen($TOTtotTALK_MS)>10) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);} +while(strlen($TOTtotDISPO_MS)>10) {$TOTtotDISPO_MS = substr("$TOTtotDISPO_MS", 0, -1);} +while(strlen($TOTtotDEAD_MS)>10) {$TOTtotDEAD_MS = substr("$TOTtotDEAD_MS", 0, -1);} +while(strlen($TOTtotPAUSE_MS)>10) {$TOTtotPAUSE_MS = substr("$TOTtotPAUSE_MS", 0, -1);} +while(strlen($TOTtotWAIT_MS)>10) {$TOTtotWAIT_MS = substr("$TOTtotWAIT_MS", 0, -1);} +while(strlen($TOTtotCUSTOMER_MS)>10) {$TOTtotCUSTOMER_MS = substr("$TOTtotCUSTOMER_MS", 0, -1);} +while(strlen($TOTavgTALK_MS)>6) {$TOTavgTALK_MS = substr("$TOTavgTALK_MS", 0, -1);} +while(strlen($TOTavgDISPO_MS)>6) {$TOTavgDISPO_MS = substr("$TOTavgDISPO_MS", 0, -1);} +while(strlen($TOTavgDEAD_MS)>6) {$TOTavgDEAD_MS = substr("$TOTavgDEAD_MS", 0, -1);} +while(strlen($TOTavgPAUSE_MS)>6) {$TOTavgPAUSE_MS = substr("$TOTavgPAUSE_MS", 0, -1);} +while(strlen($TOTavgWAIT_MS)>6) {$TOTavgWAIT_MS = substr("$TOTavgWAIT_MS", 0, -1);} +while(strlen($TOTavgCUSTOMER_MS)>6) {$TOTavgCUSTOMER_MS = substr("$TOTavgCUSTOMER_MS", 0, -1);} + +$grand_total_hours=($TOTtime/3600); +$STOTsales_per_call=sprintf("%.2f", (100*($Sgrand_total_sales/$TOTcalls)))." %"; +$STOTsales_per_hour=sprintf("%.2f", ($Sgrand_total_sales/$grand_total_hours)); + +$STOTsales_per_call=sprintf("%13s", $STOTsales_per_call); +$STOTsales_per_hour=sprintf("%14s", $STOTsales_per_hour); +$Sgrand_total_sales=sprintf("%11s", $Sgrand_total_sales); + +$ASCII_text.="+-----------------+----------+----------------------+----------------------+---------------+----------------+-------------+--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n"; +$ASCII_text.="| TOTALS AGENTS:$TOT_AGENTS | $STOTsales_per_call | $STOTsales_per_hour | $Sgrand_total_sales | $TOTcalls| $TOTtime_MS|$TOTtotPAUSE_MS| $TOTavgPAUSE_MS |$TOTtotWAIT_MS| $TOTavgWAIT_MS |$TOTtotTALK_MS| $TOTavgTALK_MS |$TOTtotDISPO_MS| $TOTavgDISPO_MS |$TOTtotDEAD_MS| $TOTavgDEAD_MS |$TOTtotCUSTOMER_MS| $TOTavgCUSTOMER_MS |$SUMstatusesHTML\n"; +$ASCII_text.="+-----------------+----------+----------------------+----------------------+---------------+----------------+-------------+--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n"; + + +for ($e=0; $e$SstatusTXT"; +} + +for ($d=0; $d"; + $TIME_graph.=" "; + $PAUSE_graph.=" "; + $PAUSEAVG_graph.=" "; + $WAIT_graph.=" "; + $WAITAVG_graph.=" "; + $TALK_graph.=" "; + $TALKAVG_graph.=" "; + $DISPO_graph.=" "; + $DISPOAVG_graph.=" "; + $DEAD_graph.=" "; + $DEADAVG_graph.=" "; + $CUST_graph.=" "; + $CUSTAVG_graph.=" "; + + for ($e=0; $e\n"; + + $$varname.=" "; + } +} + +$CALLS_graph.="
CALL STATS BREAKDOWN: (Statistics related to handling of calls only)
USERCALLS
TIME
PAUSE
PAUSE AVG
WAIT
WAIT AVG
TALK
TALK AVG
DISPO
DISPO AVG
DEAD
DEAD AVG
CUST
CUST AVG
$Sstatus
".$graph_stats[$d][1]."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][2], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][3], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][4], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][5], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][6], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][7], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][8], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][9], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][10], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][11], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][12], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][13], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][14], 'HF')."
".$graph_stats[$d][0]."".$graph_stats[$d][($e+15)]."
TOTAL:".trim($TOTcalls)."
"; +$TIME_graph.="TOTAL:".trim($TOTtime_MS).""; +$PAUSE_graph.="TOTAL:".trim($TOTtotPAUSE_MS).""; +$PAUSEAVG_graph.="TOTAL:".trim($TOTavgPAUSE_MS).""; +$WAIT_graph.="TOTAL:".trim($TOTtotWAIT_MS).""; +$WAITAVG_graph.="TOTAL:".trim($TOTavgWAIT_MS).""; +$TALK_graph.="TOTAL:".trim($TOTtotTALK_MS).""; +$TALKAVG_graph.="TOTAL:".trim($TOTavgTALK_MS).""; +$DISPO_graph.="TOTAL:".trim($TOTtotDISPO_MS).""; +$DISPOAVG_graph.="TOTAL:".trim($TOTavgDISPO_MS).""; +$DEAD_graph.="TOTAL:".trim($TOTtotDEAD_MS).""; +$DEADAVG_graph.="TOTAL:".trim($TOTavgDEAD_MS).""; +$CUST_graph.="TOTAL:".trim($TOTtotCUSTOMER_MS).""; +$CUSTAVG_graph.="TOTAL:".trim($TOTavgCUSTOMER_MS).""; + +for ($e=0; $e"; +} + +$JS_onload.="\tDrawGraph('CALLS', '1');\n"; +$JS_text.="function DrawGraph(graph, th_id) {\n"; +$JS_text.=" var graph_CALLS=\"$CALLS_graph\";\n"; +$JS_text.=" var graph_TIME=\"$TIME_graph\";\n"; +$JS_text.=" var graph_PAUSE=\"$PAUSE_graph\";\n"; +$JS_text.=" var graph_PAUSEAVG=\"$PAUSEAVG_graph\";\n"; +$JS_text.=" var graph_WAIT=\"$WAIT_graph\";\n"; +$JS_text.=" var graph_WAITAVG=\"$WAITAVG_graph\";\n"; +$JS_text.=" var graph_TALK=\"$TALK_graph\";\n"; +$JS_text.=" var graph_TALKAVG=\"$TALKAVG_graph\";\n"; +$JS_text.=" var graph_DISPO=\"$DISPO_graph\";\n"; +$JS_text.=" var graph_DISPOAVG=\"$DISPOAVG_graph\";\n"; +$JS_text.=" var graph_DEAD=\"$DEAD_graph\";\n"; +$JS_text.=" var graph_DEADAVG=\"$DEADAVG_graph\";\n"; +$JS_text.=" var graph_CUST=\"$CUST_graph\";\n"; +$JS_text.=" var graph_CUSTAVG=\"$CUSTAVG_graph\";\n"; + +for ($e=0; $e
 


"; + +$GRAPH_text.=$JS_text.$GRAPH.$GRAPH2.$GRAPH3; + + +$CSV_total=preg_replace('/\s/', '', "\"\",\"\",\"TOTALS\",\"AGENTS:$TOT_AGENTS\",\"$TOTcalls\",\"$TOTtime_MS\",\"$TOTtotPAUSE_MS\",\"$TOTavgPAUSE_MS\",\"$TOTtotWAIT_MS\",\"$TOTavgWAIT_MS\",\"$TOTtotTALK_MS\",\"$TOTavgTALK_MS\",\"$TOTtotDISPO_MS\",\"$TOTavgDISPO_MS\",\"$TOTtotDEAD_MS\",\"$TOTavgDEAD_MS\",\"$TOTtotCUSTOMER_MS\",\"$TOTavgCUSTOMER_MS\"$CSVSUMstatuses"); + +if ($file_download == 1) + { + $FILE_TIME = date("Ymd-His"); + $CSVfilename = "AGENT_PERFORMACE_DETAIL$US$FILE_TIME.csv"; + + // We'll be outputting a TXT file + header('Content-type: application/octet-stream'); + + // It will be called LIST_101_20090209-121212.txt + header("Content-Disposition: attachment; filename=\"$CSVfilename\""); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + ob_clean(); + flush(); + + echo "$CSV_header$CSV_lines$CSV_total"; + + if ($db_source == 'S') + { + mysqli_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect_mysqli.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $TOTALrun = ($runS + $runM); + + $stmt="UPDATE vicidial_report_log set run_time='$TOTALrun' where report_log_id='$report_log_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + + exit; + } + +$CSV_report=fopen("AST_agent_performance_detail.csv", "w"); +fwrite($CSV_report, $CSV_header); +fwrite($CSV_report, $CSV_lines); +fwrite($CSV_report, $CSV_total); + + +$ASCII_text.="\n\n"; + + + + +$sub_statuses='-'; +$sub_statusesTXT=''; +$sub_statusesHEAD=''; +$sub_statusesHTML=''; +$CSV_statuses=''; +$sub_statusesARY=$MT; +$j=0; +$PCusers='-'; +$PCusersARY=$MT; +$PCuser_namesARY=$MT; +$k=0; + +$graph_stats=array(); +$max_total=1; +$max_nonpause=1; +$max_pause=1; +$GRAPH="

"; +$GRAPH2=""; +$graph_header="
TOTALNONPAUSEPAUSE
"; +$TOTAL_graph=$graph_header.""; +$NONPAUSE_graph=$graph_header.""; +$PAUSE_graph=$graph_header.""; + +$stmt="select full_name,vicidial_users.user,sum(pause_sec),sub_status,sum(wait_sec + talk_sec + dispo_sec), vicidial_users.user_group from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and pause_sec<65000 $group_SQL $user_group_SQL group by user,full_name,sub_status order by user,full_name,sub_status desc limit 100000;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$ASCII_text.="$stmt\n";} +$subs_to_print = mysqli_num_rows($rslt); +$i=0; +while ($i < $subs_to_print) + { + $row=mysqli_fetch_row($rslt); + $PCfull_name[$i] = $row[0]; + $PCuser[$i] = $row[1]; + $PCpause_sec[$i] = $row[2]; + $sub_status[$i] = $row[3]; + $PCnon_pause_sec[$i] = $row[4]; + $PCuser_group[$i] = $row[5]; + $max_varname="max_".$sub_status[$i]; + $$max_varname=1; + + # echo "$sub_status[$i]|$PCpause_sec[$i]\n"; +# if ( (!preg_match("/\-$sub_status[$i]\-/i", $sub_statuses)) and (strlen($sub_status[$i])>0) ) + if (!preg_match("/\-$sub_status[$i]\-/i", $sub_statuses)) + { + $sub_statusesTXT = sprintf("%8s", $sub_status[$i]); + $sub_statusesHEAD .= "----------+"; + $sub_statusesHTML .= " $sub_statusesTXT |"; + $sub_statuses .= "$sub_status[$i]-"; + $sub_statusesARY[$j] = $sub_status[$i]; + $CSV_statuses.=",\"$sub_status[$i]\""; + $j++; + } + if (!preg_match("/\-$PCuser[$i]\-/i", $PCusers)) + { + $PCusers .= "$PCuser[$i]-"; + $PCusersARY[$k] = $PCuser[$i]; + $PCuser_namesARY[$k] = $PCfull_name[$i]; + $PCuser_groupsARY[$k] = $PCuser_group[$i]; + $k++; + } + + $i++; + } + +$ASCII_text.="PAUSE CODE BREAKDOWN: [DOWNLOAD]\n\n"; +$ASCII_text.="+-----------------+----------+----------------------+----------------------+----------+----------+----------+ +$sub_statusesHEAD\n"; +$ASCII_text.="| USER NAME | ID | CURRENT USER GROUP | MOST RECENT USER GRP | TOTAL | NONPAUSE | PAUSE | |$sub_statusesHTML\n"; +$ASCII_text.="+-----------------+----------+----------------------+----------------------+----------+----------+----------+ +$sub_statusesHEAD\n"; + +$CSV_header="\"Agent Performance Detail $NOW_TIME\"\n"; +$CSV_header.="\"Time range: $query_date_BEGIN to $query_date_END\"\n\n"; +$CSV_header.="\"PAUSE CODE BREAKDOWN:\"\n"; +$CSV_header.="\"USER NAME\",\"ID\",\"CURRENT USER GROUP\",\"MOST RECENT USER GROUP\",\"TOTAL\",\"NONPAUSE\",\"PAUSE\",$CSV_statuses\n"; + +### BEGIN loop through each user ### +$m=0; +$Suser_ct = count($usersARY); +$TOTtotNONPAUSE = 0; +$TOTtotTOTAL = 0; +$CSV_lines=""; + +while ($m < $k) + { + $d=0; + while ($d < $Suser_ct) + { + if ($usersARY[$d] === "$PCusersARY[$m]") + {$pcPAUSEtotal = $PAUSEtotal[$d];} + $d++; + } + $Suser=$PCusersARY[$m]; + $Sfull_name=$PCuser_namesARY[$m]; + $Suser_group=$PCuser_groupsARY[$m]; + $Slast_user_group=$recent_user_groups[$Suser]; + $Spause_sec=0; + $Snon_pause_sec=0; + $Stotal_sec=0; + $SstatusesHTML=''; + $CSV_statuses=""; + + ### BEGIN loop through each status ### + $n=0; + while ($n < $j) + { + $Sstatus=$sub_statusesARY[$n]; + $SstatusTXT=''; + $varname=$Sstatus."_graph"; + $$varname=$graph_header.""; + $max_varname="max_".$Sstatus; + ### BEGIN loop through each stat line ### + $i=0; $status_found=0; + while ($i < $subs_to_print) + { + if ( ($Suser=="$PCuser[$i]") and ($Sstatus=="$sub_status[$i]") ) + { + $Spause_sec = ($Spause_sec + $PCpause_sec[$i]); + $Snon_pause_sec = ($Snon_pause_sec + $PCnon_pause_sec[$i]); + $Stotal_sec = ($Stotal_sec + $PCnon_pause_sec[$i] + $PCpause_sec[$i]); + + $USERcodePAUSE_MS = sec_convert($PCpause_sec[$i],'H'); + $pfUSERcodePAUSE_MS = sprintf("%6s", $USERcodePAUSE_MS); + + $SstatusTXT = sprintf("%8s", $pfUSERcodePAUSE_MS); + $SstatusesHTML .= " $SstatusTXT |"; + + if ($PCpause_sec[$i]>$$max_varname) {$$max_varname=$PCpause_sec[$i];} + $graph_stats[$m][(4+$n)]=$PCpause_sec[$i]; + + $CSV_statuses.=",\"$USERcodePAUSE_MS\""; + $status_found++; + } + $i++; + } + if ($status_found < 1) + { + $SstatusesHTML .= " 0 |"; + $CSV_statuses.=",\"0\""; + $graph_stats[$m][(4+$n)]=0; + } + ### END loop through each stat line ### + $n++; + } + ### END loop through each status ### + $TOTtotPAUSE=($TOTtotPAUSE + $Spause_sec); + $Sfull_nameRAW = $Sfull_name; + $SuserRAW = $Suser; + $graph_stats[$m][0]="$Sfull_name - $SuserRAW"; + + if ($non_latin < 1) + { + $Sfull_name= sprintf("%-15s", $Sfull_name); + while(strlen($Sfull_name)>15) {$Sfull_name = substr("$Sfull_name", 0, -1);} + $Suser_group= sprintf("%-20s", $Suser_group); + while(strlen($Suser_group)>20) {$Suser_group = substr("$Suser_group", 0, -1);} + $Slast_user_group= sprintf("%-20s", $Slast_user_group); + while(strlen($Slast_user_group)>20) {$Slast_user_group = substr("$Slast_user_group", 0, -1);} + $Suser = sprintf("%-8s", $Suser); + while(strlen($Suser)>8) {$Suser = substr("$Suser", 0, -1);} + } + else + { + $Sfull_name= sprintf("%-45s", $Sfull_name); + while(mb_strlen($Sfull_name,'utf-8')>15) {$Sfull_name = mb_substr("$Sfull_name", 0, -1,'utf-8');} + $Suser_group= sprintf("%-45s", $Suser_group); + while(mb_strlen($Suser_group,'utf-8')>15) {$Suser_group = mb_substr("$Suser_group", 0, -1,'utf-8');} + $Suser = sprintf("%-24s", $Suser); + while(mb_strlen($Suser,'utf-8')>8) {$Suser = mb_substr("$Suser", 0, -1,'utf-8');} + } + + $TOTtotNONPAUSE = ($TOTtotNONPAUSE + $Snon_pause_sec); + $TOTtotTOTAL = ($TOTtotTOTAL + $Stotal_sec); + + if (trim($Stotal_sec)>$max_total) {$max_total=trim($Stotal_sec);} + if (trim($Snon_pause_sec)>$max_nonpause) {$max_nonpause=trim($Snon_pause_sec);} + if (trim($Spause_sec)>$max_pause) {$max_pause=trim($Spause_sec);} + $graph_stats[$m][1]="$Stotal_sec"; + $graph_stats[$m][2]="$Snon_pause_sec"; + $graph_stats[$m][3]="$Spause_sec"; + + $USERtotPAUSE_MS = sec_convert($Spause_sec,'H'); + $USERtotNONPAUSE_MS = sec_convert($Snon_pause_sec,'H'); + $USERtotTOTAL_MS = sec_convert($Stotal_sec,'H'); + + $pfUSERtotPAUSE_MS = sprintf("%8s", $USERtotPAUSE_MS); + $pfUSERtotNONPAUSE_MS = sprintf("%8s", $USERtotNONPAUSE_MS); + $pfUSERtotTOTAL_MS = sprintf("%8s", $USERtotTOTAL_MS); + + $BOTTOMoutput = "| $Sfull_name | $Suser | $Suser_group | $Slast_user_group | $pfUSERtotTOTAL_MS | $pfUSERtotNONPAUSE_MS | $pfUSERtotPAUSE_MS | |$SstatusesHTML\n"; + + $BOTTOMsorted_output[$m] = $BOTTOMoutput; + + $ASCII_text.="$BOTTOMoutput"; + $CSV_lines.="\"$Sfull_nameRAW\"".preg_replace('/\s/', '', ",\"$SuserRAW\",\"$Suser_group\",\"$Slast_user_group\",\"$pfUSERtotTOTAL_MS\",\"$pfUSERtotNONPAUSE_MS\",\"$pfUSERtotPAUSE_MS\",$CSV_statuses"); + $CSV_lines.="\n"; + $m++; + } +### END loop through each user ### + + + +### BEGIN sort through output to display properly ### +#if (preg_match('/ID|TIME|LEADS/',$stage)) +# { +# $n=0; +# while ($n <= $m) +# { +# $i = $sort_order[$m]; +# echo "$BOTTOMsorted_output[$i]"; +# $m--; +# } +# } +### END sort through output to display properly ### + + + +###### LAST LINE FORMATTING ########## +### BEGIN loop through each status ### +$SUMstatusesHTML=''; +$CSVSUMstatuses=''; +$TOTtotPAUSE=0; +$n=0; +while ($n < $j) + { + $Scalls=0; + $Sstatus=$sub_statusesARY[$n]; + $SUMstatusTXT=''; + $total_var=$Sstatus."_total"; + ### BEGIN loop through each stat line ### + $i=0; $status_found=0; + while ($i < $subs_to_print) + { + if ($Sstatus=="$sub_status[$i]") + { + $Scalls = ($Scalls + $PCpause_sec[$i]); + $status_found++; + } + $i++; + } + ### END loop through each stat line ### + if ($status_found < 1) + { + $SUMstatusesHTML .= " 0 |"; + $$total_var=0; + } + else + { + $TOTtotPAUSE = ($TOTtotPAUSE + $Scalls); + $$total_var=$Scalls; + + $USERsumstatPAUSE_MS = sec_convert($Scalls,'H'); + $pfUSERsumstatPAUSE_MS = sprintf("%8s", $USERsumstatPAUSE_MS); + + $SUMstatusTXT = sprintf("%8s", $pfUSERsumstatPAUSE_MS); + $SUMstatusesHTML .= " $SUMstatusTXT |"; + $CSVSUMstatuses.=",\"$USERsumstatPAUSE_MS\""; + } + $n++; + } +### END loop through each status ### + + $TOT_AGENTS = sprintf("%-4s", $m); + + $TOTtotPAUSE_MS = sec_convert($TOTtotPAUSE,'H'); + $TOTtotNONPAUSE_MS = sec_convert($TOTtotNONPAUSE,'H'); + $TOTtotTOTAL_MS = sec_convert($TOTtotTOTAL,'H'); + + $TOTtotPAUSE_MS = sprintf("%10s", $TOTtotPAUSE_MS); + $TOTtotNONPAUSE_MS = sprintf("%10s", $TOTtotNONPAUSE_MS); + $TOTtotTOTAL_MS = sprintf("%10s", $TOTtotTOTAL_MS); + + while(strlen($TOTtotPAUSE_MS)>10) {$TOTtotPAUSE_MS = substr("$TOTtotPAUSE_MS", 0, -1);} + while(strlen($TOTtotNONPAUSE_MS)>10) {$TOTtotNONPAUSE_MS = substr("$TOTtotNONPAUSE_MS", 0, -1);} + while(strlen($TOTtotTOTAL_MS)>10) {$TOTtotTOTAL_MS = substr("$TOTtotTOTAL_MS", 0, -1);} + + +$ASCII_text.="+-----------------+----------+----------------------+----------------------+----------+----------+----------+ +$sub_statusesHEAD\n"; +$ASCII_text.="| TOTALS AGENTS:$TOT_AGENTS |$TOTtotTOTAL_MS|$TOTtotNONPAUSE_MS|$TOTtotPAUSE_MS| |$SUMstatusesHTML\n"; +$ASCII_text.="+-----------------+----------+----------------------+----------------------+----------+----------+----------+ +$sub_statusesHEAD\n"; + +for ($e=0; $e$SstatusTXT"; +} + +for ($d=0; $d"; + $NONPAUSE_graph.=" "; + $PAUSE_graph.=" "; + + for ($e=0; $e"; + } +} + +$TOTAL_graph.="
PAUSE CODE BREAKDOWN
STATUSTOTAL
NONPAUSE
PAUSE
$Sstatus
".sec_convert($graph_stats[$d][1], 'H')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][2], 'H')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][3], 'H')."
".sec_convert($graph_stats[$d][($e+4)], 'H')."
TOTAL:".trim($TOTtotTOTAL_MS)."
"; +$NONPAUSE_graph.="TOTAL:".trim($TOTtotNONPAUSE_MS).""; +$PAUSE_graph.="TOTAL:".trim($TOTtotPAUSE_MS)."%"; +for ($e=0; $e"; +} +$JS_onload.="\tDrawPauseGraph('TOTAL', '1');\n"; +$JS_text="\n"; +$GRAPH3="
 


"; + +$GRAPH_text.=$JS_text.$GRAPH.$GRAPH2.$GRAPH3.$max; + + + +$CSV_total=preg_replace('/\s/', '', "\"\",\"\",\"TOTALS\",\"AGENTS:$TOT_AGENTS\",\"$TOTtotTOTAL_MS\",\"$TOTtotNONPAUSE_MS\",\"$TOTtotPAUSE_MS\",$CSVSUMstatuses"); + +if ($file_download == 2) + { + $FILE_TIME = date("Ymd-His"); + $CSVfilename = "AST_PAUSE_CODE_BREAKDOWN$US$FILE_TIME.csv"; + + // We'll be outputting a TXT file + header('Content-type: application/octet-stream'); + + // It will be called LIST_101_20090209-121212.txt + header("Content-Disposition: attachment; filename=\"$CSVfilename\""); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + ob_clean(); + flush(); + + echo "$CSV_header$CSV_lines$CSV_total"; + + if ($db_source == 'S') + { + mysqli_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect_mysqli.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $TOTALrun = ($runS + $runM); + + $stmt="UPDATE vicidial_report_log set run_time='$TOTALrun' where report_log_id='$report_log_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + + exit; + } +$CSV_report=fopen("AST_pause_code_breakdown.csv", "w"); +fwrite($CSV_report, $CSV_header); +fwrite($CSV_report, $CSV_lines); +fwrite($CSV_report, $CSV_total); + +if ($report_display_type=="HTML") + { + $HTML_text.=$GRAPH_text; + } +else + { + $HTML_text.=$ASCII_text; + } + +$HTML_text.="\n\n
$db_source"; +$HTML_text.=""; + +$HTML_text.=""; + + +} +if ($file_download == 0 || !$file_download) { + echo $HTML_head; + require("admin_header.php"); + echo $HTML_text; +} + + +if ($db_source == 'S') + { + mysqli_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect_mysqli.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$TOTALrun = ($runS + $runM); + +$stmt="UPDATE vicidial_report_log set run_time='$TOTALrun' where report_log_id='$report_log_id';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); + +exit; +?> + diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 570fd0a6..ebb0c9c8 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -1806,6 +1806,8 @@ if (isset($_GET["queuemetrics_record_hold"])) {$queuemetrics_record_hold=$_GET elseif (isset($_POST["queuemetrics_record_hold"])) {$queuemetrics_record_hold=$_POST["queuemetrics_record_hold"];} if (isset($_GET["country_code_list_stats"])) {$country_code_list_stats=$_GET["country_code_list_stats"];} elseif (isset($_POST["country_code_list_stats"])) {$country_code_list_stats=$_POST["country_code_list_stats"];} +if (isset($_GET["manual_dial_lead_id"])) {$manual_dial_lead_id=$_GET["manual_dial_lead_id"];} + elseif (isset($_POST["manual_dial_lead_id"])) {$manual_dial_lead_id=$_POST["manual_dial_lead_id"];} if (isset($script_id)) {$script_id= strtoupper($script_id);} @@ -2225,6 +2227,7 @@ if ($non_latin < 1) $report_option = preg_replace('/[^NY]/','',$report_option); $hopper_vlc_dup_check = preg_replace('/[^NY]/','',$hopper_vlc_dup_check); $inventory_report = preg_replace('/[^NY]/','',$inventory_report); + $manual_dial_lead_id = preg_replace('/[^NY]/','',$manual_dial_lead_id); $qc_enabled = preg_replace('/[^0-9NY]/','',$qc_enabled); $active = preg_replace('/[^0-9NY]/','',$active); @@ -3235,12 +3238,13 @@ else # 130928-1130 - Added country_code_list_stats system setting option # 131003-1749 - Small fix for voicemail box duplication with phone account # 131007-1234 - Fix for copy user on encrypted passwords systems +# 131016-2112 - Added manual_dial_lead_id campaign option, fixes some small issues # # 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.8-415a'; -$build = '131007-1234'; +$admin_version = '2.8-416a'; +$build = '131016-2112'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -5817,6 +5821,11 @@ if ($ADD==99999)
Manual Preview Dial - This allows the agent in manual dial mode to see the lead information when they click Dial Next Number before they actively dial the phone call. There is an optional link to SKIP the lead and move on to the next one if selected. Default is PREVIEW_AND_SKIP. +
+ +
+ Manual Dial by Lead ID - This allows the agent in manual dial mode to place a call by lead_id instead of a phone number. Default is N for disabled. +

@@ -12532,7 +12541,7 @@ if ($ADD==20) $rslt=mysql_to_mysqli($stmt, $link); } - $stmt="INSERT INTO vicidial_campaigns (campaign_name,campaign_id,active,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,list_order_mix,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_fourth_digit,survey_third_audio_file,survey_fourth_audio_file,survey_third_status,survey_fourth_status,survey_third_exten,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,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,safe_harbor_audio_field,pause_after_next_call,owner_populate,use_other_campaign_dnc,allow_emails,amd_inbound_group,amd_callmenu,survey_wait_sec) SELECT \"$campaign_name\",\"$campaign_id\",\"N\",dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,\"DISABLED\",campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_fourth_digit,survey_third_audio_file,survey_fourth_audio_file,survey_third_status,survey_fourth_status,survey_third_exten,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,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,safe_harbor_audio_field,pause_after_next_call,owner_populate,use_other_campaign_dnc,allow_emails,amd_inbound_group,amd_callmenu,survey_wait_sec from vicidial_campaigns where campaign_id='$source_campaign_id';"; + $stmt="INSERT INTO vicidial_campaigns (campaign_name,campaign_id,active,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,list_order_mix,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_fourth_digit,survey_third_audio_file,survey_fourth_audio_file,survey_third_status,survey_fourth_status,survey_third_exten,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,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,safe_harbor_audio_field,pause_after_next_call,owner_populate,use_other_campaign_dnc,allow_emails,amd_inbound_group,amd_callmenu,survey_wait_sec,manual_dial_lead_id) SELECT \"$campaign_name\",\"$campaign_id\",\"N\",dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,\"DISABLED\",campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_fourth_digit,survey_third_audio_file,survey_fourth_audio_file,survey_third_status,survey_fourth_status,survey_third_exten,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,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,safe_harbor_audio_field,pause_after_next_call,owner_populate,use_other_campaign_dnc,allow_emails,amd_inbound_group,amd_callmenu,survey_wait_sec,manual_dial_lead_id from vicidial_campaigns where campaign_id='$source_campaign_id';"; $rslt=mysql_to_mysqli($stmt, $link); $stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$campaign_id');"; @@ -16292,7 +16301,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='" . mysqli_real_escape_string($link, $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='" . mysqli_real_escape_string($link, $web_form_address_two) . "',waitforsilence_options='$waitforsilence_options',agent_select_territories='$agent_select_territories',crm_popup_login='$crm_popup_login',crm_login_address='" . mysqli_real_escape_string($link, $crm_login_address) . "',timer_action='$timer_action',timer_action_message='$timer_action_message',timer_action_seconds='$timer_action_seconds',start_call_url='" . mysqli_real_escape_string($link, $start_call_url) . "',dispo_call_url='" . mysqli_real_escape_string($link, $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='" . mysqli_real_escape_string($link, $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='" . mysqli_real_escape_string($link, $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',amd_inbound_group='$amd_inbound_group',amd_callmenu='$amd_callmenu' 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='" . mysqli_real_escape_string($link, $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='" . mysqli_real_escape_string($link, $web_form_address_two) . "',waitforsilence_options='$waitforsilence_options',agent_select_territories='$agent_select_territories',crm_popup_login='$crm_popup_login',crm_login_address='" . mysqli_real_escape_string($link, $crm_login_address) . "',timer_action='$timer_action',timer_action_message='$timer_action_message',timer_action_seconds='$timer_action_seconds',start_call_url='" . mysqli_real_escape_string($link, $start_call_url) . "',dispo_call_url='" . mysqli_real_escape_string($link, $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='" . mysqli_real_escape_string($link, $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='" . mysqli_real_escape_string($link, $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',amd_inbound_group='$amd_inbound_group',amd_callmenu='$amd_callmenu',manual_dial_lead_id='$manual_dial_lead_id' where campaign_id='$campaign_id';"; $rslt=mysql_to_mysqli($stmtA, $link); if ($reset_hopper == 'Y') @@ -18464,7 +18473,7 @@ if ($ADD==431111111111) {echo "
CONF TEMPLATE NOT MODIFIED - Please go back and look at the data you entered\n";} else { - $stmt="UPDATE vicidial_conf_templates set template_name='$template_name',template_contents='$template_contents' where template_id='$template_id';"; + $stmt="UPDATE vicidial_conf_templates set template_name='$template_name',template_contents='$template_contents',user_group='$user_group' where template_id='$template_id';"; $rslt=mysql_to_mysqli($stmt, $link); $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and user_group='$user_group';"; @@ -22072,7 +22081,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,allow_emails,amd_inbound_group,amd_callmenu,survey_wait_sec 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,amd_inbound_group,amd_callmenu,survey_wait_sec,manual_dial_lead_id from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $campaign_name = $row[1]; @@ -22289,6 +22298,7 @@ if ($ADD==31) $amd_inbound_group = $row[212]; $amd_callmenu = $row[213]; $survey_wait_sec = $row[214]; + $manual_dial_lead_id = $row[215]; if (preg_match('/DISABLED/', $list_order_mix)) {$DEFlistDISABLE = ''; $DEFstatusDISABLED=0;} @@ -23302,6 +23312,8 @@ if ($ADD==31) echo "Manual Preview Dial: $NWB#campaigns-manual_preview_dial$NWE\n"; + echo "Manual Dial by Lead ID: $NWB#campaigns-manual_dial_lead_id$NWE\n"; + echo "Manual Call Time Check: $NWB#campaigns-manual_dial_call_time_check$NWE\n"; echo "Manual Dial API: $NWB#campaigns-api_manual_dial$NWE\n"; @@ -36423,11 +36435,11 @@ if ($ADD==999995) echo "
Welcome to ViciDial: copyright, trademark and license page

\n"; echo "
\n"; - echo "\n"; + echo "\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; @@ -36468,7 +36480,7 @@ if ($ADD==999994) echo "
  • Admin Report Log Viewer\n"; echo "

    \n"; echo "
  • Bulk Phone Insert Page\n"; - echo "
  • Basic Lead Management Tools\n"; + echo "
  • Basic Lead Management Tools | Advanced Lead Management Tools\n"; echo "
  • Reset Campaign Lists\n"; echo "
  • Callbacks Transferral Page\n"; echo "
  • Send a Call With Custom CID Page\n"; diff --git a/www/vicidial/admin_phones_bulk_insert.php b/www/vicidial/admin_phones_bulk_insert.php index 3f480f35..920fb36a 100644 --- a/www/vicidial/admin_phones_bulk_insert.php +++ b/www/vicidial/admin_phones_bulk_insert.php @@ -221,7 +221,7 @@ if ($action == "HELP")
    - Phone Context - This is the dial plan context that this phone will use to dial out. If you are running a call center and you do not want your agents to be able to dial out outside of the ViciDial applicaiton for example, then you would set this field to a dialplan context that does not exist, something like agent-nodial. default is default. + Phone Context - This is the dial plan context that this phone will use to dial out. If you are running a call center and you do not want your agents to be able to dial out outside of the Contact Center applicaiton for example, then you would set this field to a dialplan context that does not exist, something like agent-nodial. default is default.


    diff --git a/www/vicidial/lead_tools.php b/www/vicidial/lead_tools.php index fbc07eaa..7382a446 100644 --- a/www/vicidial/lead_tools.php +++ b/www/vicidial/lead_tools.php @@ -10,10 +10,11 @@ # 130610-1045 - Finalized changing of all ereg instances to preg # 130619-2203 - Added filtering of input to prevent SQL injection attacks and new user auth # 130901-1927 - Changed to mysqli PHP functions +# 131016-2029 - Added links to advanced lead tools # -$version = '2.8-6'; -$build = '130901-1927'; +$version = '2.8-7'; +$build = '131016-2029'; # This limit is to prevent data inconsistancies. # If there are too many leads in a list this @@ -184,7 +185,7 @@ echo "
  • Copyright:   The ViciDial Call Center Suite is maintained by the ViciDial Group, © 2013
    Copyright:   The ViciDial Contact Center Suite is maintained by the ViciDial Group, © 2013
    Trademark:   \"VICIDIAL\" is a registered trademark of the ViciDial Group. Here is our trademark use policy
    License:   The ViciDial Call Center Suite is released under the AGPLv2 open source license
    License:   The ViciDial Contact Center Suite is released under the AGPLv2 open source license
    Source Code:   The ViciDial Call Center Suite software is available for download, and for use, free of cost. You can download the easy to install ViciBox CD ISO version, or only the source code
    \n"; echo "\n"; echo "\n"; echo "\n"; diff --git a/www/vicidial/lead_tools_advanced.php b/www/vicidial/lead_tools_advanced.php new file mode 100644 index 00000000..1ff7a4b4 --- /dev/null +++ b/www/vicidial/lead_tools_advanced.php @@ -0,0 +1,2486 @@ + LICENSE: AGPLv2 +# +# CHANGES +# 131016-1948 - Initial Build based upon lead_tools.php +# + +$version = '2.8-1'; +$build = '131016-1948'; + +# This limit is to prevent data inconsistancies. +# If there are too many leads in a list this +# script might not finish before the php execution limit. +$list_lead_limit = 100000; + +# maximum call count the script will work with +$max_count = 20; + +require("dbconnect_mysqli.php"); +require("functions.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$ip = getenv("REMOTE_ADDR"); +$SQLdate = date("Y-m-d H:i:s"); + +$DB=0; +$move_submit=""; +$update_submit=""; +$delete_submit=""; +$confirm_move=""; +$confirm_update=""; +$confirm_delete=""; + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["move_submit"])) {$move_submit=$_GET["move_submit"];} + elseif (isset($_POST["move_submit"])) {$move_submit=$_POST["move_submit"];} +if (isset($_GET["update_submit"])) {$update_submit=$_GET["update_submit"];} + elseif (isset($_POST["update_submit"])) {$update_submit=$_POST["update_submit"];} +if (isset($_GET["delete_submit"])) {$delete_submit=$_GET["delete_submit"];} + elseif (isset($_POST["delete_submit"])) {$delete_submit=$_POST["delete_submit"];} +if (isset($_GET["confirm_move"])) {$confirm_move=$_GET["confirm_move"];} + elseif (isset($_POST["confirm_move"])) {$confirm_move=$_POST["confirm_move"];} +if (isset($_GET["confirm_update"])) {$confirm_move=$_GET["confirm_update"];} + elseif (isset($_POST["confirm_update"])) {$confirm_update=$_POST["confirm_update"];} +if (isset($_GET["confirm_delete"])) {$confirm_delete=$_GET["confirm_delete"];} + elseif (isset($_POST["confirm_delete"])) {$confirm_delete=$_POST["confirm_delete"];} + +$DB = preg_replace('/[^0-9]/','',$DB); +$move_submit = preg_replace('/[^-_0-9a-zA-Z]/','',$move_submit); +$update_submit = preg_replace('/[^-_0-9a-zA-Z]/','',$update_submit); +$delete_submit = preg_replace('/[^-_0-9a-zA-Z]/','',$delete_submit); +$confirm_move = preg_replace('/[^-_0-9a-zA-Z]/','',$confirm_move); +$confirm_update = preg_replace('/[^-_0-9a-zA-Z]/','',$confirm_update); +$confirm_delete = preg_replace('/[^-_0-9a-zA-Z]/','',$confirm_delete); +$delete_status = preg_replace('/[^-_0-9a-zA-Z]/','',$delete_status); + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$sys_settings_stmt = "SELECT use_non_latin, outbound_autodial_active, sounds_central_control_active FROM system_settings;"; +$sys_settings_rslt=mysql_to_mysqli($sys_settings_stmt, $link); +if ($DB) {echo "$sys_settings_stmt\n";} +$num_rows = mysqli_num_rows($sys_settings_rslt); +if ($num_rows > 0) + { + $sys_settings_row=mysqli_fetch_row($sys_settings_rslt); + $non_latin = $sys_settings_row[0]; + $SSoutbound_autodial_active = $sys_settings_row[1]; + $sounds_central_control_active = $sys_settings_row[2]; + } +else + { + # there is something really weird if there are no system settings + exit; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ($non_latin < 1) + { + $PHP_AUTH_USER = preg_replace('/[^0-9a-zA-Z]/', '', $PHP_AUTH_USER); + $PHP_AUTH_PW = preg_replace('/[^0-9a-zA-Z]/', '', $PHP_AUTH_PW); + } +else + { + $PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW); + $PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER); + } +$list_id_override = preg_replace('/[^0-9]/','',$list_id_override); + +$auth=0; +$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'',1); +if ($auth_message == 'GOOD') + {$auth=1;} + +if ($auth < 1) + { + $VDdisplayMESSAGE = "Login incorrect, please try again"; + if ($auth_message == 'LOCK') + { + $VDdisplayMESSAGE = "Too many login attempts, try again in 15 minutes"; + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n"; + exit; + } + +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 + +# valid user +$rights_stmt = "SELECT load_leads,user_group, delete_lists, modify_leads, modify_lists from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {echo "|$stmt|\n";} +$rights_rslt=mysql_to_mysqli($rights_stmt, $link); +$rights_row=mysqli_fetch_row($rights_rslt); +$load_leads = $rights_row[0]; +$user_group = $rights_row[1]; +$delete_lists = $rights_row[2]; +$modify_leads = $rights_row[3]; +$modify_lists = $rights_row[4]; + +# check their permissions +if ( $load_leads < 1 ) + { + header ("Content-type: text/html; charset=utf-8"); + echo "You do not have permissions to load leads\n"; + exit; + } +if ( $modify_leads < 1 ) + { + header ("Content-type: text/html; charset=utf-8"); + echo "You do not have permissions to modify leads\n"; + exit; + } +if ( $modify_lists < 1 ) + { + header ("Content-type: text/html; charset=utf-8"); + echo "You do not have permissions to modify lists\n"; + exit; + } + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +?> + + +ADMINISTRATION: Lead Tools\n"; + +##### BEGIN Set variables to make header show properly ##### +$ADD = '999998'; +$hh = 'admin'; +$LOGast_admin_access = '1'; +$SSoutbound_autodial_active = '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=''; +$header_nonselected_bold=''; +$admin_color = '#FFFF99'; +$admin_font = 'BLACK'; +$admin_color = '#E6E6E6'; +$subcamp_color = '#C6C6C6'; +##### END Set variables to make header show properly ##### + +require("admin_header.php"); + +echo "
    \n"; echo "\n"; -echo "   Lead Tools\n"; +echo "   Basic Lead Tools   |   Advanced Lead Tools\n"; echo "\n"; echo "  
    \n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + + +echo "
    \n"; +echo "\n"; +echo "   Basic Lead Tools   |   Advanced Lead Tools\n"; +echo "\n"; +echo "  
      \n"; + +# move confirmation page +if ($move_submit == "move" ) + { + # get the variables + $enable_move_status=""; + $enable_move_country_code=""; + $enable_move_vendor_lead_code=""; + $enable_move_source_id=""; + $enable_move_owner=""; + $enable_move_entry_date=""; + $enable_move_modify_date=""; + $enable_move_security_phrase=""; + $enable_move_count=""; + $move_country_code=""; + $move_vendor_lead_code=""; + $move_source_id=""; + $move_owner=""; + $move_entry_date=""; + $move_modify_date=""; + $move_security_phrase=""; + $move_from_list=""; + $move_to_list=""; + $move_status=""; + $move_count_op=""; + $move_count_num=""; + + # check the get / post data for the variables + if (isset($_GET["enable_move_status"])) {$enable_move_status=$_GET["enable_move_status"];} + elseif (isset($_POST["enable_move_status"])) {$enable_move_status=$_POST["enable_move_status"];} + if (isset($_GET["enable_move_country_code"])) {$enable_move_country_code=$_GET["enable_move_country_code"];} + elseif (isset($_POST["enable_move_country_code"])) {$enable_move_country_code=$_POST["enable_move_country_code"];} + if (isset($_GET["enable_move_vendor_lead_code"])) {$enable_move_vendor_lead_code=$_GET["enable_move_vendor_lead_code"];} + elseif (isset($_POST["enable_move_vendor_lead_code"])) {$enable_move_vendor_lead_code=$_POST["enable_move_vendor_lead_code"];} + if (isset($_GET["enable_move_source_id"])) {$enable_move_source_id=$_GET["enable_move_source_id"];} + elseif (isset($_POST["enable_move_source_id"])) {$enable_move_source_id=$_POST["enable_move_source_id"];} + if (isset($_GET["enable_move_owner"])) {$enable_move_owner=$_GET["enable_move_owner"];} + elseif (isset($_POST["enable_move_owner"])) {$enable_move_owner=$_POST["enable_move_owner"];} + if (isset($_GET["enable_move_entry_date"])) {$enable_move_entry_date=$_GET["enable_move_entry_date"];} + elseif (isset($_POST["enable_move_entry_date"])) {$enable_move_entry_date=$_POST["enable_move_entry_date"];} + if (isset($_GET["enable_move_modify_date"])) {$enable_move_modify_date=$_GET["enable_move_modify_date"];} + elseif (isset($_POST["enable_move_modify_date"])) {$enable_move_modify_date=$_POST["enable_move_modify_date"];} + if (isset($_GET["enable_move_security_phrase"])) {$enable_move_security_phrase=$_GET["enable_move_security_phrase"];} + elseif (isset($_POST["enable_move_security_phrase"])) {$enable_move_security_phrase=$_POST["enable_move_security_phrase"];} + if (isset($_GET["enable_move_count"])) {$enable_move_count=$_GET["enable_move_count"];} + elseif (isset($_POST["enable_move_count"])) {$enable_move_count=$_POST["enable_move_count"];} + if (isset($_GET["move_country_code"])) {$move_country_code=$_GET["move_country_code"];} + elseif (isset($_POST["move_country_code"])) {$move_country_code=$_POST["move_country_code"];} + if (isset($_GET["move_vendor_lead_code"])) {$move_vendor_lead_code=$_GET["move_vendor_lead_code"];} + elseif (isset($_POST["move_vendor_lead_code"])) {$move_vendor_lead_code=$_POST["move_vendor_lead_code"];} + if (isset($_GET["move_source_id"])) {$move_source_id=$_GET["move_source_id"];} + elseif (isset($_POST["move_source_id"])) {$move_source_id=$_POST["move_source_id"];} + if (isset($_GET["move_owner"])) {$move_owner=$_GET["move_owner"];} + elseif (isset($_POST["move_owner"])) {$move_owner=$_POST["move_owner"];} + if (isset($_GET["move_entry_date"])) {$move_entry_date=$_GET["move_entry_date"];} + elseif (isset($_POST["move_entry_date"])) {$move_entry_date=$_POST["move_entry_date"];} + if (isset($_GET["move_modify_date"])) {$move_modify_date=$_GET["move_modify_date"];} + elseif (isset($_POST["move_modify_date"])) {$move_modify_date=$_POST["move_modify_date"];} + if (isset($_GET["move_security_phrase"])) {$move_security_phrase=$_GET["move_security_phrase"];} + elseif (isset($_POST["move_security_phrase"])) {$move_security_phrase=$_POST["move_security_phrase"];} + if (isset($_GET["move_from_list"])) {$move_from_list=$_GET["move_from_list"];} + elseif (isset($_POST["move_from_list"])) {$move_from_list=$_POST["move_from_list"];} + if (isset($_GET["move_to_list"])) {$move_to_list=$_GET["move_to_list"];} + elseif (isset($_POST["move_to_list"])) {$move_to_list=$_POST["move_to_list"];} + if (isset($_GET["move_status"])) {$move_status=$_GET["move_status"];} + elseif (isset($_POST["move_status"])) {$move_status=$_POST["move_status"];} + if (isset($_GET["move_count_op"])) {$move_count_op=$_GET["move_count_op"];} + elseif (isset($_POST["move_count_op"])) {$move_count_op=$_POST["move_count_op"];} + if (isset($_GET["move_count_num"])) {$move_count_num=$_GET["move_count_num"];} + elseif (isset($_POST["move_count_num"])) {$move_count_num=$_POST["move_count_num"];} + + if ($DB) + { + echo "

    enable_move_status = $enable_move_status | enable_move_country_code = $enable_move_country_code | enable_move_vendor_lead_code = $enable_move_vendor_lead_code | enable_move_source_id = $enable_move_source_id | enable_move_owner = $enable_move_owner | enable_move_entry_date = $enable_move_entry_date | enable_move_modify_date = $enable_move_modify_date | enable_move_security_phrase = $enable_move_security_phrase | enable_move_count = $enable_move_count | move_country_code = $move_country_code | move_vendor_lead_code = $move_vendor_lead_code | move_source_id = $move_source_id | move_owner = $move_owner | move_owner = $move_entry_date | move_modify_date = $move_modify_date | move_security_phrase = $move_security_phrase | move_from_list = $move_from_list | move_to_list = $move_to_list | move_status = $move_status | move_count_op = $move_count_op | move_count_num = $move_count_num

    "; + } + + # filter out anything bad + $enable_move_status = preg_replace('/[^a-zA-Z]/','',$enable_move_status); + $enable_move_country_code = preg_replace('/[^a-zA-Z]/','',$enable_move_country_code); + $enable_move_vendor_lead_code = preg_replace('/[^a-zA-Z]/','',$enable_move_vendor_lead_code); + $enable_move_source_id = preg_replace('/[^a-zA-Z]/','',$enable_move_source_id); + $enable_move_owner = preg_replace('/[^a-zA-Z]/','',$enable_move_owner); + $enable_move_entry_date = preg_replace('/[^a-zA-Z]/','',$enable_move_entry_date); + $enable_move_modify_date = preg_replace('/[^a-zA-Z]/','',$enable_move_modify_date); + $enable_move_security_phrase = preg_replace('/[^a-zA-Z]/','',$enable_move_security_phrase); + $enable_move_count = preg_replace('/[^a-zA-Z]/','',$enable_move_count); + $move_country_code = preg_replace('/[^-_%a-zA-Z0-9]/','',$move_country_code); + $move_vendor_lead_code = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_vendor_lead_code); + $move_source_id = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_source_id); + $move_owner = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_owner); + $move_entry_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_entry_date); + $move_modify_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_modify_date); + $move_security_phrase = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_security_phrase); + $move_status = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_status); + $move_from_list = preg_replace('/[^0-9]/','',$move_from_list); + $move_to_list = preg_replace('/[^0-9]/','',$move_to_list); + $move_count_num = preg_replace('/[^0-9]/','',$move_count_num); + $move_count_op = preg_replace('/[^<>=]/','',$move_count_op); + + if ($DB) + { + echo "

    enable_move_status = $enable_move_status | enable_move_country_code = $enable_move_country_code | enable_move_vendor_lead_code = $enable_move_vendor_lead_code | enable_move_source_id = $enable_move_source_id | enable_move_owner = $enable_move_owner | enable_move_entry_date = $enable_move_entry_date | enable_move_modify_date = $enable_move_modify_date | enable_move_security_phrase = $enable_move_security_phrase | enable_move_count = $enable_move_count | move_country_code = $move_country_code | move_vendor_lead_code = $move_vendor_lead_code | move_source_id = $move_source_id | move_owner = $move_owner | move_owner = $move_entry_date | move_modify_date = $move_modify_date | move_security_phrase = $move_security_phrase | move_from_list = $move_from_list | move_to_list = $move_to_list | move_status = $move_status | move_count_op = $move_count_op | move_count_num = $move_count_num

    "; + } + + # build the count operation phrase + $move_count_op_phrase=""; + if ( $move_count_op == "<" ) + { + $move_count_op_phrase= "less than "; + } + elseif ( $move_count_op == "<=" ) + { + $move_count_op_phrase= "less than or equal to "; + } + elseif ( $move_count_op == ">" ) + { + $move_count_op_phrase= "greater than "; + } + elseif ( $move_count_op == ">=" ) + { + $move_count_op_phrase= "greater than or equal to "; + } + + # make sure the required fields are set + if ($move_from_list == '') { missing_required_field('From List'); } + if ($move_to_list == '') { missing_required_field('To List'); } + + + # build the sql query's where phrase and the move phrase + $sql_where = ""; + $move_parm = ""; + if (($enable_move_status == "enabled") && ($move_status != '')) + { + if ($move_status == '---BLANK---') {$move_status = '';} + $sql_where = $sql_where . " and status like '$move_status' "; + $move_parm = $move_parm . "    status is like $move_status
    "; + if ($move_status == '') {$move_status = '---BLANK---';} + } + elseif ($enable_move_status == "enabled") + { + blank_field('Status'); + } + if (($enable_move_country_code == "enabled") && ($move_country_code != '')) + { + if ($move_country_code == '---BLANK---') {$move_country_code = '';} + $sql_where = $sql_where . " and country_code like '$move_country_code' "; + $move_parm = $move_parm . "    country code is like $move_country_code
    "; + if ($move_country_code == '') {$move_country_code = '---BLANK---';} + } + elseif ($enable_move_country_code == "enabled") + { + blank_field('Country Code'); + } + if (($enable_move_vendor_lead_code == "enabled") && ($move_vendor_lead_code != '')) + { + if ($move_vendor_lead_code == '---BLANK---') {$move_vendor_lead_code = '';} + $sql_where = $sql_where . " and vendor_lead_code like '$move_vendor_lead_code' "; + $move_parm = $move_parm . "    vendor lead code is like $move_vendor_lead_code
    "; + if ($move_vendor_lead_code == '') {$move_vendor_lead_code = '---BLANK---';} + } + elseif ($enable_move_vendor_lead_code == "enabled") + { + blank_field('Vendor Lead Code'); + } + if (($enable_move_source_id == "enabled") && ( $move_source_id != '')) + { + if ($move_source_id == '---BLANK---') {$move_source_id = '';} + $sql_where = $sql_where . " and source_id like '$move_source_id' "; + $move_parm = $move_parm . "    source id is like $move_source_id
    "; + if ($move_source_id == '') {$move_source_id = '---BLANK---';} + } + elseif ($enable_move_source_id == "enabled") + { + blank_field('Source ID'); + } + if (($enable_move_owner == "enabled") && ($move_owner != '')) + { + if ($move_owner == '---BLANK---') {$move_owner = '';} + $sql_where = $sql_where . " and owner like '$move_owner' "; + $move_parm = $move_parm . "    owner is like $move_owner
    "; + if ($move_owner == '') {$move_owner = '---BLANK---';} + } + elseif ($enable_move_owner == "enabled") + { + blank_field('Owner'); + } + if (($enable_move_security_phrase == "enabled") && ($move_security_phrase != '')) + { + if ($move_security_phrase == '---BLANK---') {$move_security_phrase = '';} + $sql_where = $sql_where . " and security_phrase like '$move_security_phrase' "; + $move_parm = $move_parm . "    secuirty_phrase is like $move_security_phrase
    "; + if ($move_security_phrase == '') {$move_security_phrase = '---BLANK---';} + } + elseif ($enable_move_security_phrase == "enabled") + { + blank_field('Security Phrase'); + } + if (($enable_move_entry_date == "enabled") && ($move_entry_date != '')) + { + if ($move_entry_date == '---BLANK---') + { + $sql_where = $sql_where . " and entry_date == '' "; + $move_parm = $move_parm . "    entry date is blank
    "; + } + else + { + $sql_where = $sql_where . " and entry_date >= '$move_entry_date 00:00:00' and entry_date <= '$move_entry_date 23:59:59' "; + $move_parm = $move_parm . "    entry date was on $move_entry_date
    "; + } + } + elseif ($enable_move_entry_date == "enabled") + { + blank_field('Entry Date'); + } + if (($enable_move_modify_date == "enabled") && ($move_modify_date != '')) + { + if ($move_modify_date == '---BLANK---') + { + $sql_where = $sql_where . " and modify_date == '' "; + $move_parm = $move_parm . "    modify date is blank
    "; + } + else + { + $sql_where = $sql_where . " and modify_date >= '$move_modify_date 00:00:00' and modify_date <= '$move_modify_date 23:59:59' "; + $move_parm = $move_parm . "    last modify date was on $move_modify_date
    "; + } + } + elseif ($enable_move_modify_date == "enabled") + { + blank_field('Modify Date'); + } + if (($enable_move_count == "enabled") && ($move_count_op != '') && ($move_count_num != '')) + { + if ($move_count_op == '---BLANK---') {$move_count_op = '';} + if ($move_count_num == '---BLANK---') {$move_count_num = '';} + $sql_where = $sql_where . " and called_count $move_count_op $move_count_num"; + $move_parm = $move_parm . "    called count is $move_count_op_phrase $move_count_num
    "; + if ($move_count_op == '') {$move_count_op = '---BLANK---';} + if ($move_count_num == '') {$move_count_num = '---BLANK---';} + } + elseif ($enable_move_count == "enabled") + { + blank_field('Move Count'); + } + + # get the number of leads this action will move + $move_lead_count=0; + $move_lead_count_stmt = "SELECT count(1) FROM vicidial_list WHERE list_id = '$move_from_list' $sql_where"; + if ($DB) { echo "|$move_lead_count_stmt|\n"; } + $move_lead_count_rslt = mysql_to_mysqli($move_lead_count_stmt, $link); + $move_lead_count_row = mysqli_fetch_row($move_lead_count_rslt); + $move_lead_count = $move_lead_count_row[0]; + + # get the number of leads in the list this action will move to + $to_list_lead_count=0; + $to_list_lead_stmt = "SELECT count(1) FROM vicidial_list WHERE list_id = '$move_to_list'"; + if ($DB) { echo "|$to_list_lead_stmt|\n"; } + $to_list_lead_rslt = mysql_to_mysqli($to_list_lead_stmt, $link); + $to_list_lead_row = mysqli_fetch_row($to_list_lead_rslt); + $to_list_lead_count = $to_list_lead_row[0]; + + # check to see if we will exceed list_lead_limit in the move to list + if ( $to_list_lead_count + $move_lead_count > $list_lead_limit ) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

    Sorry. This operation will cause list $move_to_list to exceed $list_lead_limit leads which is not allowed.

    \n"; + echo "

    Click here to start over.

    \n"; + echo "\n\n"; + } + else + { + echo "

    You are about to move $move_lead_count leads from list $move_from_list to $move_to_list with the following parameters:

    $move_parm
    Please press confirm to continue.

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

    Click here to start over.

    \n"; + echo "\n\n"; + } + } + +# actually do the move +if ($confirm_move == "confirm") + { + # get the variables + $enable_move_status=""; + $enable_move_country_code=""; + $enable_move_vendor_lead_code=""; + $enable_move_source_id=""; + $enable_move_owner=""; + $enable_move_entry_date=""; + $enable_move_modify_date=""; + $enable_move_security_phrase=""; + $enable_move_count=""; + $move_country_code=""; + $move_vendor_lead_code=""; + $move_source_id=""; + $move_owner=""; + $move_entry_date=""; + $move_modify_date=""; + $move_security_phrase=""; + $move_from_list=""; + $move_to_list=""; + $move_status=""; + $move_count_op=""; + $move_count_num=""; + + # check the get / post data for the variables + if (isset($_GET["enable_move_status"])) {$enable_move_status=$_GET["enable_move_status"];} + elseif (isset($_POST["enable_move_status"])) {$enable_move_status=$_POST["enable_move_status"];} + if (isset($_GET["enable_move_country_code"])) {$enable_move_country_code=$_GET["enable_move_country_code"];} + elseif (isset($_POST["enable_move_country_code"])) {$enable_move_country_code=$_POST["enable_move_country_code"];} + if (isset($_GET["enable_move_vendor_lead_code"])) {$enable_move_vendor_lead_code=$_GET["enable_move_vendor_lead_code"];} + elseif (isset($_POST["enable_move_vendor_lead_code"])) {$enable_move_vendor_lead_code=$_POST["enable_move_vendor_lead_code"];} + if (isset($_GET["enable_move_source_id"])) {$enable_move_source_id=$_GET["enable_move_source_id"];} + elseif (isset($_POST["enable_move_source_id"])) {$enable_move_source_id=$_POST["enable_move_source_id"];} + if (isset($_GET["enable_move_owner"])) {$enable_move_owner=$_GET["enable_move_owner"];} + elseif (isset($_POST["enable_move_owner"])) {$enable_move_owner=$_POST["enable_move_owner"];} + if (isset($_GET["enable_move_entry_date"])) {$enable_move_entry_date=$_GET["enable_move_entry_date"];} + elseif (isset($_POST["enable_move_entry_date"])) {$enable_move_entry_date=$_POST["enable_move_entry_date"];} + if (isset($_GET["enable_move_modify_date"])) {$enable_move_modify_date=$_GET["enable_move_modify_date"];} + elseif (isset($_POST["enable_move_modify_date"])) {$enable_move_modify_date=$_POST["enable_move_modify_date"];} + if (isset($_GET["enable_move_security_phrase"])) {$enable_move_security_phrase=$_GET["enable_move_security_phrase"];} + elseif (isset($_POST["enable_move_security_phrase"])) {$enable_move_security_phrase=$_POST["enable_move_security_phrase"];} + if (isset($_GET["enable_move_count"])) {$enable_move_count=$_GET["enable_move_count"];} + elseif (isset($_POST["enable_move_count"])) {$enable_move_count=$_POST["enable_move_count"];} + if (isset($_GET["move_country_code"])) {$move_country_code=$_GET["move_country_code"];} + elseif (isset($_POST["move_country_code"])) {$move_country_code=$_POST["move_country_code"];} + if (isset($_GET["move_vendor_lead_code"])) {$move_vendor_lead_code=$_GET["move_vendor_lead_code"];} + elseif (isset($_POST["move_vendor_lead_code"])) {$move_vendor_lead_code=$_POST["move_vendor_lead_code"];} + if (isset($_GET["move_source_id"])) {$move_source_id=$_GET["move_source_id"];} + elseif (isset($_POST["move_source_id"])) {$move_source_id=$_POST["move_source_id"];} + if (isset($_GET["move_owner"])) {$move_owner=$_GET["move_owner"];} + elseif (isset($_POST["move_owner"])) {$move_owner=$_POST["move_owner"];} + if (isset($_GET["move_entry_date"])) {$move_entry_date=$_GET["move_entry_date"];} + elseif (isset($_POST["move_entry_date"])) {$move_entry_date=$_POST["move_entry_date"];} + if (isset($_GET["move_modify_date"])) {$move_modify_date=$_GET["move_modify_date"];} + elseif (isset($_POST["move_modify_date"])) {$move_modify_date=$_POST["move_modify_date"];} + if (isset($_GET["move_security_phrase"])) {$move_security_phrase=$_GET["move_security_phrase"];} + elseif (isset($_POST["move_security_phrase"])) {$move_security_phrase=$_POST["move_security_phrase"];} + if (isset($_GET["move_from_list"])) {$move_from_list=$_GET["move_from_list"];} + elseif (isset($_POST["move_from_list"])) {$move_from_list=$_POST["move_from_list"];} + if (isset($_GET["move_to_list"])) {$move_to_list=$_GET["move_to_list"];} + elseif (isset($_POST["move_to_list"])) {$move_to_list=$_POST["move_to_list"];} + if (isset($_GET["move_status"])) {$move_status=$_GET["move_status"];} + elseif (isset($_POST["move_status"])) {$move_status=$_POST["move_status"];} + if (isset($_GET["move_count_op"])) {$move_count_op=$_GET["move_count_op"];} + elseif (isset($_POST["move_count_op"])) {$move_count_op=$_POST["move_count_op"];} + if (isset($_GET["move_count_num"])) {$move_count_num=$_GET["move_count_num"];} + elseif (isset($_POST["move_count_num"])) {$move_count_num=$_POST["move_count_num"];} + + if ($DB) + { + echo "

    enable_move_status = $enable_move_status | enable_move_country_code = $enable_move_country_code | enable_move_vendor_lead_code = $enable_move_vendor_lead_code | enable_move_source_id = $enable_move_source_id | enable_move_owner = $enable_move_owner | enable_move_entry_date = $enable_move_entry_date | enable_move_modify_date = $enable_move_modify_date | enable_move_security_phrase = $enable_move_security_phrase | enable_move_count = $enable_move_count | move_country_code = $move_country_code | move_vendor_lead_code = $move_vendor_lead_code | move_source_id = $move_source_id | move_owner = $move_owner | move_owner = $move_entry_date | move_modify_date = $move_modify_date | move_security_phrase = $move_security_phrase | move_from_list = $move_from_list | move_to_list = $move_to_list | move_status = $move_status | move_count_op = $move_count_op | move_count_num = $move_count_num

    "; + } + + # filter out anything bad + $enable_move_status = preg_replace('/[^a-zA-Z]/','',$enable_move_status); + $enable_move_country_code = preg_replace('/[^a-zA-Z]/','',$enable_move_country_code); + $enable_move_vendor_lead_code = preg_replace('/[^a-zA-Z]/','',$enable_move_vendor_lead_code); + $enable_move_source_id = preg_replace('/[^a-zA-Z]/','',$enable_move_source_id); + $enable_move_owner = preg_replace('/[^a-zA-Z]/','',$enable_move_owner); + $enable_move_entry_date = preg_replace('/[^a-zA-Z]/','',$enable_move_entry_date); + $enable_move_modify_date = preg_replace('/[^a-zA-Z]/','',$enable_move_modify_date); + $enable_move_security_phrase = preg_replace('/[^a-zA-Z]/','',$enable_move_security_phrase); + $enable_move_count = preg_replace('/[^a-zA-Z]/','',$enable_move_count); + $move_country_code = preg_replace('/[^-_%a-zA-Z0-9]/','',$move_country_code); + $move_vendor_lead_code = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_vendor_lead_code); + $move_source_id = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_source_id); + $move_owner = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_owner); + $move_entry_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_entry_date); + $move_modify_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_modify_date); + $move_security_phrase = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_security_phrase); + $move_status = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_status); + $move_from_list = preg_replace('/[^0-9]/','',$move_from_list); + $move_to_list = preg_replace('/[^0-9]/','',$move_to_list); + $move_count_num = preg_replace('/[^0-9]/','',$move_count_num); + $move_count_op = preg_replace('/[^<>=]/','',$move_count_op); + + if ($DB) + { + echo "

    enable_move_status = $enable_move_status | enable_move_country_code = $enable_move_country_code | enable_move_vendor_lead_code = $enable_move_vendor_lead_code | enable_move_source_id = $enable_move_source_id | enable_move_owner = $enable_move_owner | enable_move_entry_date = $enable_move_entry_date | enable_move_modify_date = $enable_move_modify_date | enable_move_security_phrase = $enable_move_security_phrase | enable_move_count = $enable_move_count | move_country_code = $move_country_code | move_vendor_lead_code = $move_vendor_lead_code | move_source_id = $move_source_id | move_owner = $move_owner | move_owner = $move_entry_date | move_modify_date = $move_modify_date | move_security_phrase = $move_security_phrase | move_from_list = $move_from_list | move_to_list = $move_to_list | move_status = $move_status | move_count_op = $move_count_op | move_count_num = $move_count_num

    "; + } + + $move_count_op_phrase=""; + if ( $move_count_op == "<" ) + { + $move_count_op_phrase= "less than "; + } + elseif ( $move_count_op == "<=" ) + { + $move_count_op_phrase= "less than or equal to "; + } + elseif ( $move_count_op == ">" ) + { + $move_count_op_phrase= "greater than "; + } + elseif ( $move_count_op == ">=" ) + { + $move_count_op_phrase= "greater than or equal to "; + } + + # make sure the required fields are set + if ($move_from_list == '') { missing_required_field('From List'); } + if ($move_to_list == '') { missing_required_field('To List'); } + + # build the sql query's where phrase and the move phrase + $sql_where = ""; + $move_parm = ""; + if (($enable_move_status == "enabled") && ($move_status != '')) + { + if ($move_status == '---BLANK---') {$move_status = '';} + $sql_where = $sql_where . " and status like '$move_status' "; + $move_parm = $move_parm . "    status is like $move_status
    "; + if ($move_status == '') {$move_status = '---BLANK---';} + } + elseif ($enable_move_status == "enabled") + { + blank_field('Status'); + } + if (($enable_move_country_code == "enabled") && ($move_country_code != '')) + { + if ($move_country_code == '---BLANK---') {$move_country_code = '';} + $sql_where = $sql_where . " and country_code like '$move_country_code' "; + $move_parm = $move_parm . "    country code is like $move_country_code
    "; + if ($move_country_code == '') {$move_country_code = '---BLANK---';} + } + elseif ($enable_move_country_code == "enabled") + { + blank_field('Country Code'); + } + if (($enable_move_vendor_lead_code == "enabled") && ($move_vendor_lead_code != '')) + { + if ($move_vendor_lead_code == '---BLANK---') {$move_vendor_lead_code = '';} + $sql_where = $sql_where . " and vendor_lead_code like '$move_vendor_lead_code' "; + $move_parm = $move_parm . "    vendor lead code is like $move_vendor_lead_code
    "; + if ($move_vendor_lead_code == '') {$move_vendor_lead_code = '---BLANK---';} + } + elseif ($enable_move_vendor_lead_code == "enabled") + { + blank_field('Vendor Lead Code'); + } + if (($enable_move_source_id == "enabled") && ( $move_source_id != '')) + { + if ($move_source_id == '---BLANK---') {$move_source_id = '';} + $sql_where = $sql_where . " and source_id like '$move_source_id' "; + $move_parm = $move_parm . "    source id is like $move_source_id
    "; + if ($move_source_id == '') {$move_source_id = '---BLANK---';} + } + elseif($enable_move_source_id == "enabled") + { + blank_field('Source ID'); + } + if (($enable_move_owner == "enabled") && ($move_owner != '')) + { + if ($move_owner == '---BLANK---') {$move_owner = '';} + $sql_where = $sql_where . " and owner like '$move_owner' "; + $move_parm = $move_parm . "    owner is like $move_owner
    "; + if ($move_owner == '') {$move_owner = '---BLANK---';} + } + elseif ($enable_move_owner == "enabled") + { + blank_field('Owner'); + } + if (($enable_move_security_phrase == "enabled") && ($move_security_phrase != '')) + { + if ($move_security_phrase == '---BLANK---') {$move_security_phrase = '';} + $sql_where = $sql_where . " and security_phrase like '$move_security_phrase' "; + $move_parm = $move_parm . "    secuirty_phrase is like $move_security_phrase
    "; + if ($move_security_phrase == '') {$move_security_phrase = '---BLANK---';} + } + elseif ($enable_move_security_phrase == "enabled") + { + blank_field('Security Phrase'); + } + if (($enable_move_entry_date == "enabled") && ($move_entry_date != '')) + { + if ($move_entry_date == '---BLANK---') + { + $sql_where = $sql_where . " and entry_date == '' "; + $move_parm = $move_parm . "    entry date is blank
    "; + } + else + { + $sql_where = $sql_where . " and entry_date >= '$move_entry_date 00:00:00' and entry_date <= '$move_entry_date 23:59:59' "; + $move_parm = $move_parm . "    entry date was on $move_entry_date
    "; + } + } + elseif ($enable_move_entry_date == "enabled") + { + blank_field('Entry Date'); + } + if (($enable_move_modify_date == "enabled") && ($move_modify_date != '')) + { + if ($move_modify_date == '---BLANK---') + { + $sql_where = $sql_where . " and modify_date == '' "; + $move_parm = $move_parm . "    modify date is blank
    "; + } + else + { + $sql_where = $sql_where . " and modify_date >= '$move_modify_date 00:00:00' and modify_date <= '$move_modify_date 23:59:59' "; + $move_parm = $move_parm . "    last modify date was on $move_modify_date
    "; + } + } + elseif ($enable_move_modify_date == "enabled") + { + blank_field('Modify Date'); + } + if (($enable_move_count == "enabled") && ($move_count_op != '') && ($move_count_num != '')) + { + if ($move_count_op == '---BLANK---') {$move_count_op = '';} + if ($move_count_num == '---BLANK---') {$move_count_num = '';} + $sql_where = $sql_where . " and called_count $move_count_op $move_count_num"; + $move_parm = $move_parm . "    called count is $move_count_op_phrase $move_count_num
    "; + if ($move_count_op == '') {$move_count_op = '---BLANK---';} + if ($move_count_num == '') {$move_count_num = '---BLANK---';} + } + elseif ($enable_move_count == "enabled") + { + blank_field('Move Count'); + } + + $move_lead_stmt = "UPDATE vicidial_list SET list_id = '$move_to_list' WHERE list_id = '$move_from_list' $sql_where"; + if ($DB) { echo "|$move_lead_stmt|\n"; } + $move_lead_rslt = mysql_to_mysqli($move_lead_stmt, $link); + $move_lead_count = mysqli_affected_rows($link); + + $move_sentence = "$move_lead_count leads have been moved from list $move_from_list to $move_to_list with the following parameters:

    $move_parm
    "; + + $SQL_log = "$move_lead_stmt|"; + $SQL_log = preg_replace('/;/', '', $SQL_log); + $SQL_log = addslashes($SQL_log); + $admin_log_stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='OTHER', record_id='$move_from_list', event_code='ADMIN MOVE LEADS', event_sql=\"$SQL_log\", event_notes='$move_sentence';"; + if ($DB) {echo "|$admin_log_stmt|\n";} + $admin_log_rslt=mysql_to_mysqli($admin_log_stmt, $link); + + echo "

    $move_sentence

    "; + echo "

    Click here to start over.

    \n"; + } + + +# update confirmation page +if ($update_submit == "update" ) + { + # get the variables + $enable_update_from_status=""; + $enable_update_country_code=""; + $enable_update_vendor_lead_code=""; + $enable_update_source_id=""; + $enable_update_owner=""; + $enable_update_entry_date=""; + $enable_update_modify_date=""; + $enable_update_security_phrase=""; + $enable_update_count=""; + $update_country_code=""; + $update_vendor_lead_code=""; + $update_source_id=""; + $update_owner=""; + $update_entry_date=""; + $update_modify_date=""; + $update_security_phrase=""; + $update_list=""; + $update_to_status=""; + $update_from_status=""; + $update_count_op=""; + $update_count_num=""; + + # check the get / post data for the variables + if (isset($_GET["enable_update_from_status"])) {$enable_update_from_status=$_GET["enable_update_from_status"];} + elseif (isset($_POST["enable_update_from_status"])) {$enable_update_from_status=$_POST["enable_update_from_status"];} + if (isset($_GET["enable_update_country_code"])) {$enable_update_country_code=$_GET["enable_update_country_code"];} + elseif (isset($_POST["enable_update_country_code"])) {$enable_update_country_code=$_POST["enable_update_country_code"];} + if (isset($_GET["enable_update_vendor_lead_code"])) {$enable_update_vendor_lead_code=$_GET["enable_update_vendor_lead_code"];} + elseif (isset($_POST["enable_update_vendor_lead_code"])) {$enable_update_vendor_lead_code=$_POST["enable_update_vendor_lead_code"];} + if (isset($_GET["enable_update_source_id"])) {$enable_update_source_id=$_GET["enable_update_source_id"];} + elseif (isset($_POST["enable_update_source_id"])) {$enable_update_source_id=$_POST["enable_update_source_id"];} + if (isset($_GET["enable_update_owner"])) {$enable_update_owner=$_GET["enable_update_owner"];} + elseif (isset($_POST["enable_update_owner"])) {$enable_update_owner=$_POST["enable_update_owner"];} + if (isset($_GET["enable_update_entry_date"])) {$enable_update_entry_date=$_GET["enable_update_entry_date"];} + elseif (isset($_POST["enable_update_entry_date"])) {$enable_update_entry_date=$_POST["enable_update_entry_date"];} + if (isset($_GET["enable_update_modify_date"])) {$enable_update_modify_date=$_GET["enable_update_modify_date"];} + elseif (isset($_POST["enable_update_modify_date"])) {$enable_update_modify_date=$_POST["enable_update_modify_date"];} + if (isset($_GET["enable_update_security_phrase"])) {$enable_update_security_phrase=$_GET["enable_update_security_phrase"];} + elseif (isset($_POST["enable_update_security_phrase"])) {$enable_update_security_phrase=$_POST["enable_update_security_phrase"];} + if (isset($_GET["enable_update_count"])) {$enable_update_count=$_GET["enable_update_count"];} + elseif (isset($_POST["enable_update_count"])) {$enable_update_count=$_POST["enable_update_count"];} + if (isset($_GET["update_country_code"])) {$update_country_code=$_GET["update_country_code"];} + elseif (isset($_POST["update_country_code"])) {$update_country_code=$_POST["update_country_code"];} + if (isset($_GET["update_vendor_lead_code"])) {$update_vendor_lead_code=$_GET["update_vendor_lead_code"];} + elseif (isset($_POST["update_vendor_lead_code"])) {$update_vendor_lead_code=$_POST["update_vendor_lead_code"];} + if (isset($_GET["update_source_id"])) {$update_source_id=$_GET["update_source_id"];} + elseif (isset($_POST["update_source_id"])) {$update_source_id=$_POST["update_source_id"];} + if (isset($_GET["update_owner"])) {$update_owner=$_GET["update_owner"];} + elseif (isset($_POST["update_owner"])) {$update_owner=$_POST["update_owner"];} + if (isset($_GET["update_entry_date"])) {$update_entry_date=$_GET["update_entry_date"];} + elseif (isset($_POST["update_entry_date"])) {$update_entry_date=$_POST["update_entry_date"];} + if (isset($_GET["update_modify_date"])) {$update_modify_date=$_GET["update_modify_date"];} + elseif (isset($_POST["update_modify_date"])) {$update_modify_date=$_POST["update_modify_date"];} + if (isset($_GET["update_security_phrase"])) {$update_security_phrase=$_GET["update_security_phrase"];} + elseif (isset($_POST["update_security_phrase"])) {$update_security_phrase=$_POST["update_security_phrase"];} + if (isset($_GET["update_list"])) {$update_list=$_GET["update_list"];} + elseif (isset($_POST["update_list"])) {$update_list=$_POST["update_list"];} + if (isset($_GET["update_from_status"])) {$update_from_status=$_GET["update_from_status"];} + elseif (isset($_POST["update_from_status"])) {$update_from_status=$_POST["update_from_status"];} + if (isset($_GET["update_to_status"])) {$update_to_status=$_GET["update_to_status"];} + elseif (isset($_POST["update_to_status"])) {$update_to_status=$_POST["update_to_status"];} + if (isset($_GET["update_count_op"])) {$update_count_op=$_GET["update_count_op"];} + elseif (isset($_POST["update_count_op"])) {$update_count_op=$_POST["update_count_op"];} + if (isset($_GET["update_count_num"])) {$update_count_num=$_GET["update_count_num"];} + elseif (isset($_POST["update_count_num"])) {$update_count_num=$_POST["update_count_num"];} + + if ($DB) + { + echo "

    enable_update_from_status = $enable_update_from_status | enable_update_country_code = $enable_update_country_code | enable_update_vendor_lead_code = $enable_update_vendor_lead_code | enable_update_source_id = $enable_update_source_id | enable_update_owner = $enable_update_owner | enable_update_entry_date = $enable_update_entry_date | enable_update_modify_date = $enable_update_modify_date | enable_update_security_phrase = $enable_update_security_phrase | enable_update_count = $enable_update_count | update_country_code = $update_country_code | update_vendor_lead_code = $update_vendor_lead_code | update_source_id = $update_source_id | update_owner = $update_owner | update_owner = $update_entry_date | update_modify_date = $update_modify_date | update_security_phrase = $update_security_phrase | update_list = $update_list | update_to_status = $ update_to_status | update_from_status = $update_from_status | update_count_op = $update_count_op | update_count_num = $update_count_num

    "; + } + + # filter out anything bad + $enable_update_from_status = preg_replace('/[^a-zA-Z]/','',$enable_update_from_status); + $enable_update_country_code = preg_replace('/[^a-zA-Z]/','',$enable_update_country_code); + $enable_update_vendor_lead_code = preg_replace('/[^a-zA-Z]/','',$enable_update_vendor_lead_code); + $enable_update_source_id = preg_replace('/[^a-zA-Z]/','',$enable_update_source_id); + $enable_update_owner = preg_replace('/[^a-zA-Z]/','',$enable_update_owner); + $enable_update_entry_date = preg_replace('/[^a-zA-Z]/','',$enable_update_entry_date); + $enable_update_modify_date = preg_replace('/[^a-zA-Z]/','',$enable_update_modify_date); + $enable_update_security_phrase = preg_replace('/[^a-zA-Z]/','',$enable_update_security_phrase); + $enable_update_count = preg_replace('/[^a-zA-Z]/','',$enable_update_count); + $update_country_code = preg_replace('/[^-_%a-zA-Z0-9]/','',$update_country_code); + $update_vendor_lead_code = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_vendor_lead_code); + $update_source_id = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_source_id); + $update_owner = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_owner); + $update_entry_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_entry_date); + $update_modify_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_modify_date); + $update_security_phrase = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_security_phrase); + $update_to_status = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_to_status); + $update_from_status = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_from_status); + $update_list = preg_replace('/[^0-9]/','',$update_list); + $update_count_num = preg_replace('/[^0-9]/','',$update_count_num); + $update_count_op = preg_replace('/[^<>=]/','',$update_count_op); + + if ($DB) + { + echo "

    enable_update_from_status = $enable_update_from_status | enable_update_country_code = $enable_update_country_code | enable_update_vendor_lead_code = $enable_update_vendor_lead_code | enable_update_source_id = $enable_update_source_id | enable_update_owner = $enable_update_owner | enable_update_entry_date = $enable_update_entry_date | enable_update_modify_date = $enable_update_modify_date | enable_update_security_phrase = $enable_update_security_phrase | enable_update_count = $enable_update_count | update_country_code = $update_country_code | update_vendor_lead_code = $update_vendor_lead_code | update_source_id = $update_source_id | update_owner = $update_owner | update_owner = $update_entry_date | update_modify_date = $update_modify_date | update_security_phrase = $update_security_phrase | update_list = $update_list | update_to_status = $ update_to_status | update_from_status = $update_from_status | update_count_op = $update_count_op | update_count_num = $update_count_num

    "; + } + + $update_count_op_phrase=""; + if ( $update_count_op == "<" ) + { + $update_count_op_phrase= "less than "; + } + elseif ( $update_count_op == "<=" ) + { + $update_count_op_phrase= "less than or equal to "; + } + elseif ( $update_count_op == ">" ) + { + $update_count_op_phrase= "greater than "; + } + elseif ( $update_count_op == ">=" ) + { + $update_count_op_phrase= "greater than or equal to "; + } + + # make sure the required fields are set + if ($update_to_status == '') { missing_required_field('To Status'); } + if ($update_list == '') { missing_required_field('List ID'); } + + # build the sql query's where phrase and the move phrase + $sql_where = ""; + $update_parm = ""; + if (($enable_update_from_status == "enabled") && ($update_from_status != '')) + { + if ($update_from_status == '---BLANK---') {$update_from_status = '';} + $sql_where = $sql_where . " and status like '$update_from_status' "; + $update_parm = $update_parm . "    status is like $update_from_status
    "; + if ($update_from_status == '') {$update_from_status = '---BLANK---';} + } + elseif ($enable_update_from_status == "enabled") + { + blank_field('Status'); + } + if (($enable_update_country_code == "enabled") && ($update_country_code != '')) + { + if ($update_country_code == '---BLANK---') {$update_country_code = '';} + $sql_where = $sql_where . " and country_code like '$update_country_code' "; + $update_parm = $update_parm . "    country code is like $update_country_code
    "; + if ($update_country_code == '') {$update_country_code = '---BLANK---';} + } + elseif ($enable_update_country_code == "enabled") + { + blank_field('Country Code'); + } + if (($enable_update_vendor_lead_code == "enabled") && ($update_vendor_lead_code != '')) + { + if ($update_vendor_lead_code == '---BLANK---') {$update_vendor_lead_code = '';} + $sql_where = $sql_where . " and vendor_lead_code like '$update_vendor_lead_code' "; + $update_parm = $update_parm . "    vendor lead code is like $update_vendor_lead_code
    "; + if ($update_vendor_lead_code == '') {$update_vendor_lead_code = '---BLANK---';} + } + elseif ($enable_update_vendor_lead_code == "enabled") + { + blank_field('Vendor Lead Code'); + } + if (($enable_update_source_id == "enabled") && ( $update_source_id != '')) + { + if ($update_source_id == '---BLANK---') {$update_source_id = '';} + $sql_where = $sql_where . " and source_id like '$update_source_id' "; + $update_parm = $update_parm . "    source id is like $update_source_id
    "; + if ($update_source_id == '') {$update_source_id = '---BLANK---';} + } + elseif ($enable_update_source_id == "enabled") + { + blank_field('Source ID'); + } + if (($enable_update_owner == "enabled") && ($update_owner != '')) + { + if ($update_owner == '---BLANK---') {$update_owner = '';} + $sql_where = $sql_where . " and owner like '$update_owner' "; + $update_parm = $update_parm . "    owner is like $update_owner
    "; + if ($update_owner == '') {$update_owner = '---BLANK---';} + } + elseif ($enable_update_owner == "enabled") + { + blank_field('Owner'); + } + if (($enable_update_security_phrase == "enabled") && ($update_security_phrase != '')) + { + if ($update_security_phrase == '---BLANK---') {$update_security_phrase = '';} + $sql_where = $sql_where . " and security_phrase like '$update_security_phrase' "; + $update_parm = $update_parm . "    secuirty_phrase is like $update_security_phrase
    "; + if ($update_security_phrase == '') {$update_security_phrase = '---BLANK---';} + } + elseif ($enable_update_security_phrase == "enabled") + { + blank_field('Security Phrase'); + } + if (($enable_update_entry_date == "enabled") && ($update_entry_date != '')) + { + if ($update_entry_date == '---BLANK---') + { + $sql_where = $sql_where . " and entry_date == '' "; + $update_parm = $update_parm . "    entry date is blank
    "; + } + else + { + $sql_where = $sql_where . " and entry_date >= '$update_entry_date 00:00:00' and entry_date <= '$update_entry_date 23:59:59' "; + $update_parm = $update_parm . "    entry date was on $update_entry_date
    "; + } + } + elseif ($enable_update_entry_date == "enabled") + { + blank_field('Entry Date'); + } + if (($enable_update_modify_date == "enabled") && ($update_modify_date != '')) + { + if ($update_modify_date == '---BLANK---') + { + $sql_where = $sql_where . " and modify_date == '' "; + $update_parm = $update_parm . "    modify date is blank
    "; + } + else + { + $sql_where = $sql_where . " and modify_date >= '$update_modify_date 00:00:00' and modify_date <= '$update_modify_date 23:59:59' "; + $update_parm = $update_parm . "    last modify date was on $update_modify_date
    "; + } + } + elseif ($enable_update_modify_date == "enabled") + { + blank_field('Modify Date'); + } + if (($enable_update_count == "enabled") && ($update_count_op != '') && ($update_count_num != '')) + { + if ($update_count_op == '---BLANK---') {$update_count_op = '';} + if ($update_count_num == '---BLANK---') {$update_count_num = '';} + $sql_where = $sql_where . " and called_count $update_count_op $update_count_num"; + $update_parm = $update_parm . "    called count is $update_count_op_phrase $update_count_num
    "; + if ($update_count_op == '') {$update_count_op = '---BLANK---';} + if ($update_count_num == '') {$update_count_num = '---BLANK---';} + } + elseif ($enable_update_count == "enabled") + { + blank_field('Move Count'); + } + + # get the number of leads this action will move + $update_lead_count=0; + $update_lead_count_stmt = "SELECT count(1) FROM vicidial_list WHERE list_id = '$update_list' $sql_where"; + if ($DB) { echo "|$update_lead_count_stmt|\n"; } + $update_lead_count_rslt = mysql_to_mysqli($update_lead_count_stmt, $link); + $update_lead_count_row = mysqli_fetch_row($update_lead_count_rslt); + $update_lead_count = $update_lead_count_row[0]; + + echo "

    You are about to update $update_lead_count leads in list $update_list to the status $update_to_status with the following parameters:

    $update_parm
    Please press confirm to continue.

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

    Click here to start over.

    \n"; + echo "\n\n"; + + } + +# actually do the update +if ($confirm_update == "confirm") + { + # get the variables + $enable_update_from_status=""; + $enable_update_country_code=""; + $enable_update_vendor_lead_code=""; + $enable_update_source_id=""; + $enable_update_owner=""; + $enable_update_entry_date=""; + $enable_update_modify_date=""; + $enable_update_security_phrase=""; + $enable_update_count=""; + $update_country_code=""; + $update_vendor_lead_code=""; + $update_source_id=""; + $update_owner=""; + $update_entry_date=""; + $update_modify_date=""; + $update_security_phrase=""; + $update_list=""; + $update_to_status=""; + $update_from_status=""; + $update_count_op=""; + $update_count_num=""; + + # check the get / post data for the variables + if (isset($_GET["enable_update_from_status"])) {$enable_update_from_status=$_GET["enable_update_from_status"];} + elseif (isset($_POST["enable_update_from_status"])) {$enable_update_from_status=$_POST["enable_update_from_status"];} + if (isset($_GET["enable_update_country_code"])) {$enable_update_country_code=$_GET["enable_update_country_code"];} + elseif (isset($_POST["enable_update_country_code"])) {$enable_update_country_code=$_POST["enable_update_country_code"];} + if (isset($_GET["enable_update_vendor_lead_code"])) {$enable_update_vendor_lead_code=$_GET["enable_update_vendor_lead_code"];} + elseif (isset($_POST["enable_update_vendor_lead_code"])) {$enable_update_vendor_lead_code=$_POST["enable_update_vendor_lead_code"];} + if (isset($_GET["enable_update_source_id"])) {$enable_update_source_id=$_GET["enable_update_source_id"];} + elseif (isset($_POST["enable_update_source_id"])) {$enable_update_source_id=$_POST["enable_update_source_id"];} + if (isset($_GET["enable_update_owner"])) {$enable_update_owner=$_GET["enable_update_owner"];} + elseif (isset($_POST["enable_update_owner"])) {$enable_update_owner=$_POST["enable_update_owner"];} + if (isset($_GET["enable_update_entry_date"])) {$enable_update_entry_date=$_GET["enable_update_entry_date"];} + elseif (isset($_POST["enable_update_entry_date"])) {$enable_update_entry_date=$_POST["enable_update_entry_date"];} + if (isset($_GET["enable_update_modify_date"])) {$enable_update_modify_date=$_GET["enable_update_modify_date"];} + elseif (isset($_POST["enable_update_modify_date"])) {$enable_update_modify_date=$_POST["enable_update_modify_date"];} + if (isset($_GET["enable_update_security_phrase"])) {$enable_update_security_phrase=$_GET["enable_update_security_phrase"];} + elseif (isset($_POST["enable_update_security_phrase"])) {$enable_update_security_phrase=$_POST["enable_update_security_phrase"];} + if (isset($_GET["enable_update_count"])) {$enable_update_count=$_GET["enable_update_count"];} + elseif (isset($_POST["enable_update_count"])) {$enable_update_count=$_POST["enable_update_count"];} + if (isset($_GET["update_country_code"])) {$update_country_code=$_GET["update_country_code"];} + elseif (isset($_POST["update_country_code"])) {$update_country_code=$_POST["update_country_code"];} + if (isset($_GET["update_vendor_lead_code"])) {$update_vendor_lead_code=$_GET["update_vendor_lead_code"];} + elseif (isset($_POST["update_vendor_lead_code"])) {$update_vendor_lead_code=$_POST["update_vendor_lead_code"];} + if (isset($_GET["update_source_id"])) {$update_source_id=$_GET["update_source_id"];} + elseif (isset($_POST["update_source_id"])) {$update_source_id=$_POST["update_source_id"];} + if (isset($_GET["update_owner"])) {$update_owner=$_GET["update_owner"];} + elseif (isset($_POST["update_owner"])) {$update_owner=$_POST["update_owner"];} + if (isset($_GET["update_entry_date"])) {$update_entry_date=$_GET["update_entry_date"];} + elseif (isset($_POST["update_entry_date"])) {$update_entry_date=$_POST["update_entry_date"];} + if (isset($_GET["update_modify_date"])) {$update_modify_date=$_GET["update_modify_date"];} + elseif (isset($_POST["update_modify_date"])) {$update_modify_date=$_POST["update_modify_date"];} + if (isset($_GET["update_security_phrase"])) {$update_security_phrase=$_GET["update_security_phrase"];} + elseif (isset($_POST["update_security_phrase"])) {$update_security_phrase=$_POST["update_security_phrase"];} + if (isset($_GET["update_list"])) {$update_list=$_GET["update_list"];} + elseif (isset($_POST["update_list"])) {$update_list=$_POST["update_list"];} + if (isset($_GET["update_from_status"])) {$update_from_status=$_GET["update_from_status"];} + elseif (isset($_POST["update_from_status"])) {$update_from_status=$_POST["update_from_status"];} + if (isset($_GET["update_to_status"])) {$update_to_status=$_GET["update_to_status"];} + elseif (isset($_POST["update_to_status"])) {$update_to_status=$_POST["update_to_status"];} + if (isset($_GET["update_count_op"])) {$update_count_op=$_GET["update_count_op"];} + elseif (isset($_POST["update_count_op"])) {$update_count_op=$_POST["update_count_op"];} + if (isset($_GET["update_count_num"])) {$update_count_num=$_GET["update_count_num"];} + elseif (isset($_POST["update_count_num"])) {$update_count_num=$_POST["update_count_num"];} + + if ($DB) + { + echo "

    enable_update_from_status = $enable_update_from_status | enable_update_country_code = $enable_update_country_code | enable_update_vendor_lead_code = $enable_update_vendor_lead_code | enable_update_source_id = $enable_update_source_id | enable_update_owner = $enable_update_owner | enable_update_entry_date = $enable_update_entry_date | enable_update_modify_date = $enable_update_modify_date | enable_update_security_phrase = $enable_update_security_phrase | enable_update_count = $enable_update_count | update_country_code = $update_country_code | update_vendor_lead_code = $update_vendor_lead_code | update_source_id = $update_source_id | update_owner = $update_owner | update_owner = $update_entry_date | update_modify_date = $update_modify_date | update_security_phrase = $update_security_phrase | update_list = $update_list | update_to_status = $ update_to_status | update_from_status = $update_from_status | update_count_op = $update_count_op | update_count_num = $update_count_num

    "; + } + + # filter out anything bad + $enable_update_from_status = preg_replace('/[^a-zA-Z]/','',$enable_update_from_status); + $enable_update_country_code = preg_replace('/[^a-zA-Z]/','',$enable_update_country_code); + $enable_update_vendor_lead_code = preg_replace('/[^a-zA-Z]/','',$enable_update_vendor_lead_code); + $enable_update_source_id = preg_replace('/[^a-zA-Z]/','',$enable_update_source_id); + $enable_update_owner = preg_replace('/[^a-zA-Z]/','',$enable_update_owner); + $enable_update_entry_date = preg_replace('/[^a-zA-Z]/','',$enable_update_entry_date); + $enable_update_modify_date = preg_replace('/[^a-zA-Z]/','',$enable_update_modify_date); + $enable_update_security_phrase = preg_replace('/[^a-zA-Z]/','',$enable_update_security_phrase); + $enable_update_count = preg_replace('/[^a-zA-Z]/','',$enable_update_count); + $update_country_code = preg_replace('/[^-_%a-zA-Z0-9]/','',$update_country_code); + $update_vendor_lead_code = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_vendor_lead_code); + $update_source_id = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_source_id); + $update_owner = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_owner); + $update_entry_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_entry_date); + $update_modify_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_modify_date); + $update_security_phrase = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_security_phrase); + $update_to_status = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_to_status); + $update_from_status = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_from_status); + $update_list = preg_replace('/[^0-9]/','',$update_list); + $update_count_num = preg_replace('/[^0-9]/','',$update_count_num); + $update_count_op = preg_replace('/[^<>=]/','',$update_count_op); + + if ($DB) + { + echo "

    enable_update_from_status = $enable_update_from_status | enable_update_country_code = $enable_update_country_code | enable_update_vendor_lead_code = $enable_update_vendor_lead_code | enable_update_source_id = $enable_update_source_id | enable_update_owner = $enable_update_owner | enable_update_entry_date = $enable_update_entry_date | enable_update_modify_date = $enable_update_modify_date | enable_update_security_phrase = $enable_update_security_phrase | enable_update_count = $enable_update_count | update_country_code = $update_country_code | update_vendor_lead_code = $update_vendor_lead_code | update_source_id = $update_source_id | update_owner = $update_owner | update_owner = $update_entry_date | update_modify_date = $update_modify_date | update_security_phrase = $update_security_phrase | update_list = $update_list | update_to_status = $ update_to_status | update_from_status = $update_from_status | update_count_op = $update_count_op | update_count_num = $update_count_num

    "; + } + + $update_count_op_phrase=""; + if ( $update_count_op == "<" ) + { + $update_count_op_phrase= "less than "; + } + elseif ( $update_count_op == "<=" ) + { + $update_count_op_phrase= "less than or equal to "; + } + elseif ( $update_count_op == ">" ) + { + $update_count_op_phrase= "greater than "; + } + elseif ( $update_count_op == ">=" ) + { + $update_count_op_phrase= "greater than or equal to "; + } + + # make sure the required fields are set + if ($update_to_status == '') { missing_required_field('To Status'); } + if ($update_list == '') { missing_required_field('List ID'); } + + # build the sql query's where phrase and the move phrase + $sql_where = ""; + $update_parm = ""; + if (($enable_update_from_status == "enabled") && ($update_from_status != '')) + { + if ($update_from_status == '---BLANK---') {$update_from_status = '';} + $sql_where = $sql_where . " and status like '$update_from_status' "; + $update_parm = $update_parm . "    status is like $update_from_status
    "; + if ($update_from_status == '') {$update_from_status = '---BLANK---';} + } + elseif ($enable_update_from_status == "enabled") + { + blank_field('Status'); + } + if (($enable_update_country_code == "enabled") && ($update_country_code != '')) + { + if ($update_country_code == '---BLANK---') {$update_country_code = '';} + $sql_where = $sql_where . " and country_code like '$update_country_code' "; + $update_parm = $update_parm . "    country code is like $update_country_code
    "; + if ($update_country_code == '') {$update_country_code = '---BLANK---';} + } + elseif ($enable_update_country_code == "enabled") + { + blank_field('Country Code'); + } + if (($enable_update_vendor_lead_code == "enabled") && ($update_vendor_lead_code != '')) + { + if ($update_vendor_lead_code == '---BLANK---') {$update_vendor_lead_code = '';} + $sql_where = $sql_where . " and vendor_lead_code like '$update_vendor_lead_code' "; + $update_parm = $update_parm . "    vendor lead code is like $update_vendor_lead_code
    "; + if ($update_vendor_lead_code == '') {$update_vendor_lead_code = '---BLANK---';} + } + elseif ($enable_update_vendor_lead_code == "enabled") + { + blank_field('Vendor Lead Code'); + } + if (($enable_update_source_id == "enabled") && ( $update_source_id != '')) + { + if ($update_source_id == '---BLANK---') {$update_source_id = '';} + $sql_where = $sql_where . " and source_id like '$update_source_id' "; + $update_parm = $update_parm . "    source id is like $update_source_id
    "; + if ($update_source_id == '') {$update_source_id = '---BLANK---';} + } + elseif ($enable_update_source_id == "enabled") + { + blank_field('Source ID'); + } + if (($enable_update_owner == "enabled") && ($update_owner != '')) + { + if ($update_owner == '---BLANK---') {$update_owner = '';} + $sql_where = $sql_where . " and owner like '$update_owner' "; + $update_parm = $update_parm . "    owner is like $update_owner
    "; + if ($update_owner == '') {$update_owner = '---BLANK---';} + } + elseif ($enable_update_owner == "enabled") + { + blank_field('Owner'); + } + if (($enable_update_security_phrase == "enabled") && ($update_security_phrase != '')) + { + if ($update_security_phrase == '---BLANK---') {$update_security_phrase = '';} + $sql_where = $sql_where . " and security_phrase like '$update_security_phrase' "; + $update_parm = $update_parm . "    secuirty_phrase is like $update_security_phrase
    "; + if ($update_security_phrase == '') {$update_security_phrase = '---BLANK---';} + } + elseif ($enable_update_security_phrase == "enabled") + { + blank_field('Security Phrase'); + } + if (($enable_update_entry_date == "enabled") && ($update_entry_date != '')) + { + if ($update_entry_date == '---BLANK---') + { + $sql_where = $sql_where . " and entry_date == '' "; + $update_parm = $update_parm . "    entry date is blank
    "; + } + else + { + $sql_where = $sql_where . " and entry_date >= '$update_entry_date 00:00:00' and entry_date <= '$update_entry_date 23:59:59' "; + $update_parm = $update_parm . "    entry date was on $update_entry_date
    "; + } + } + elseif ($enable_update_entry_date == "enabled") + { + blank_field('Entry Date'); + } + if (($enable_update_modify_date == "enabled") && ($update_modify_date != '')) + { + if ($update_modify_date == '---BLANK---') + { + $sql_where = $sql_where . " and modify_date == '' "; + $update_parm = $update_parm . "    modify date is blank
    "; + } + else + { + $sql_where = $sql_where . " and modify_date >= '$update_modify_date 00:00:00' and modify_date <= '$update_modify_date 23:59:59' "; + $update_parm = $update_parm . "    last modify date was on $update_modify_date
    "; + } + } + elseif ($enable_update_modify_date == "enabled") + { + blank_field('Modify Date'); + } + if (($enable_update_count == "enabled") && ($update_count_op != '') && ($update_count_num != '')) + { + if ($update_count_op == '---BLANK---') {$update_count_op = '';} + if ($update_count_num == '---BLANK---') {$update_count_num = '';} + $sql_where = $sql_where . " and called_count $update_count_op $update_count_num"; + $update_parm = $update_parm . "    called count is $update_count_op_phrase $update_count_num
    "; + if ($update_count_op == '') {$update_count_op = '---BLANK---';} + if ($update_count_num == '') {$update_count_num = '---BLANK---';} + } + elseif ($enable_update_count == "enabled") + { + blank_field('Move Count'); + } + + $update_lead_stmt = "UPDATE vicidial_list SET status = '$update_to_status' WHERE list_id = '$update_list' $sql_where"; + if ($DB) { echo "|$update_lead_stmt|\n"; } + $update_lead_rslt = mysql_to_mysqli($update_lead_stmt, $link); + $update_lead_count = mysqli_affected_rows($link); + + $update_sentence = "$update_lead_count leads in list $update_list had their status changed to $update_to_status with the following parameters:

    $update_parm"; + + $SQL_log = "$update_lead_stmt|"; + $SQL_log = preg_replace('/;/', '', $SQL_log); + $SQL_log = addslashes($SQL_log); + $admin_log_stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='MODIFY', record_id='$update_list', event_code='ADMIN UPDATE LEADS', event_sql=\"$SQL_log\", event_notes='$update_sentence';"; + if ($DB) {echo "|$admin_log_stmt|\n";} + $admin_log_rslt=mysql_to_mysqli($admin_log_stmt, $link); + + echo "

    $update_sentence

    "; + echo "

    Click here to start over.

    \n"; + } + + +# delete confirmation page +if ( ( $delete_submit == "delete" ) && ( $delete_lists > 0 ) ) + { + # get the variables + $enable_delete_lead_id=""; + $enable_delete_country_code=""; + $enable_delete_vendor_lead_code=""; + $enable_delete_source_id=""; + $enable_delete_owner=""; + $enable_delete_entry_date=""; + $enable_delete_modify_date=""; + $enable_delete_security_phrase=""; + $enable_delete_count=""; + $delete_country_code=""; + $delete_vendor_lead_code=""; + $delete_source_id=""; + $delete_owner=""; + $delete_entry_date=""; + $delete_modify_date=""; + $delete_security_phrase=""; + $delete_list=""; + $delete_status=""; + $delete_count_op=""; + $delete_count_num=""; + $delete_lead_id=""; + + # check the get / post data for the variables + if (isset($_GET["enable_delete_lead_id"])) {$enable_delete_lead_id=$_GET["enable_delete_lead_id"];} + elseif (isset($_POST["enable_delete_lead_id"])) {$enable_delete_lead_id=$_POST["enable_delete_lead_id"];} + if (isset($_GET["enable_delete_country_code"])) {$enable_delete_country_code=$_GET["enable_delete_country_code"];} + elseif (isset($_POST["enable_delete_country_code"])) {$enable_delete_country_code=$_POST["enable_delete_country_code"];} + if (isset($_GET["enable_delete_vendor_lead_code"])) {$enable_delete_vendor_lead_code=$_GET["enable_delete_vendor_lead_code"];} + elseif (isset($_POST["enable_delete_vendor_lead_code"])) {$enable_delete_vendor_lead_code=$_POST["enable_delete_vendor_lead_code"];} + if (isset($_GET["enable_delete_source_id"])) {$enable_delete_source_id=$_GET["enable_delete_source_id"];} + elseif (isset($_POST["enable_delete_source_id"])) {$enable_delete_source_id=$_POST["enable_delete_source_id"];} + if (isset($_GET["enable_delete_owner"])) {$enable_delete_owner=$_GET["enable_delete_owner"];} + elseif (isset($_POST["enable_delete_owner"])) {$enable_delete_owner=$_POST["enable_delete_owner"];} + if (isset($_GET["enable_delete_entry_date"])) {$enable_delete_entry_date=$_GET["enable_delete_entry_date"];} + elseif (isset($_POST["enable_delete_entry_date"])) {$enable_delete_entry_date=$_POST["enable_delete_entry_date"];} + if (isset($_GET["enable_delete_modify_date"])) {$enable_delete_modify_date=$_GET["enable_delete_modify_date"];} + elseif (isset($_POST["enable_delete_modify_date"])) {$enable_delete_modify_date=$_POST["enable_delete_modify_date"];} + if (isset($_GET["enable_delete_security_phrase"])) {$enable_delete_security_phrase=$_GET["enable_delete_security_phrase"];} + elseif (isset($_POST["enable_delete_security_phrase"])) {$enable_delete_security_phrase=$_POST["enable_delete_security_phrase"];} + if (isset($_GET["enable_delete_count"])) {$enable_delete_count=$_GET["enable_delete_count"];} + elseif (isset($_POST["enable_delete_count"])) {$enable_delete_count=$_POST["enable_delete_count"];} + if (isset($_GET["delete_country_code"])) {$delete_country_code=$_GET["delete_country_code"];} + elseif (isset($_POST["delete_country_code"])) {$delete_country_code=$_POST["delete_country_code"];} + if (isset($_GET["delete_vendor_lead_code"])) {$delete_vendor_lead_code=$_GET["delete_vendor_lead_code"];} + elseif (isset($_POST["delete_vendor_lead_code"])) {$delete_vendor_lead_code=$_POST["delete_vendor_lead_code"];} + if (isset($_GET["delete_source_id"])) {$delete_source_id=$_GET["delete_source_id"];} + elseif (isset($_POST["delete_source_id"])) {$delete_source_id=$_POST["delete_source_id"];} + if (isset($_GET["delete_owner"])) {$delete_owner=$_GET["delete_owner"];} + elseif (isset($_POST["delete_owner"])) {$delete_owner=$_POST["delete_owner"];} + if (isset($_GET["delete_entry_date"])) {$delete_entry_date=$_GET["delete_entry_date"];} + elseif (isset($_POST["delete_entry_date"])) {$delete_entry_date=$_POST["delete_entry_date"];} + if (isset($_GET["delete_modify_date"])) {$delete_modify_date=$_GET["delete_modify_date"];} + elseif (isset($_POST["delete_modify_date"])) {$delete_modify_date=$_POST["delete_modify_date"];} + if (isset($_GET["delete_security_phrase"])) {$delete_security_phrase=$_GET["delete_security_phrase"];} + elseif (isset($_POST["delete_security_phrase"])) {$delete_security_phrase=$_POST["delete_security_phrase"];} + if (isset($_GET["delete_list"])) {$delete_list=$_GET["delete_list"];} + elseif (isset($_POST["delete_list"])) {$delete_list=$_POST["delete_list"];} + if (isset($_GET["delete_status"])) {$delete_status=$_GET["delete_status"];} + elseif (isset($_POST["delete_status"])) {$delete_status=$_POST["delete_status"];} + if (isset($_GET["delete_lead_id"])) {$delete_lead_id=$_GET["delete_lead_id"];} + elseif (isset($_POST["delete_lead_id"])) {$delete_lead_id=$_POST["delete_lead_id"];} + if (isset($_GET["delete_count_op"])) {$delete_count_op=$_GET["delete_count_op"];} + elseif (isset($_POST["delete_count_op"])) {$delete_count_op=$_POST["delete_count_op"];} + if (isset($_GET["delete_count_num"])) {$delete_count_num=$_GET["delete_count_num"];} + elseif (isset($_POST["delete_count_num"])) {$delete_count_num=$_POST["delete_count_num"];} + + if ($DB) + { + echo "

    enable_delete_country_code = $enable_delete_country_code | enable_delete_vendor_lead_code = $enable_delete_vendor_lead_code | enable_delete_source_id = $enable_delete_source_id | enable_delete_owner = $enable_delete_owner | enable_delete_entry_date = $enable_delete_entry_date | enable_delete_modify_date = $enable_delete_modify_date | enable_delete_security_phrase = $enable_delete_security_phrase | enable_delete_count = $enable_delete_count | delete_country_code = $delete_country_code | delete_vendor_lead_code = $delete_vendor_lead_code | delete_source_id = $delete_source_id | delete_owner = $delete_owner | delete_owner = $delete_entry_date | delete_modify_date = $delete_modify_date | delete_security_phrase = $delete_security_phrase | delete_list = $delete_list | delete_status = $delete_status | delete_count_op = $delete_count_op | delete_count_num = $delete_count_num | delete_lead_id = $delete_lead_id

    "; + } + + # filter out anything bad + $enable_delete_status = preg_replace('/[^a-zA-Z]/','',$enable_delete_status); + $enable_delete_country_code = preg_replace('/[^a-zA-Z]/','',$enable_delete_country_code); + $enable_delete_vendor_lead_code = preg_replace('/[^a-zA-Z]/','',$enable_delete_vendor_lead_code); + $enable_delete_source_id = preg_replace('/[^a-zA-Z]/','',$enable_delete_source_id); + $enable_delete_owner = preg_replace('/[^a-zA-Z]/','',$enable_delete_owner); + $enable_delete_entry_date = preg_replace('/[^a-zA-Z]/','',$enable_delete_entry_date); + $enable_delete_modify_date = preg_replace('/[^a-zA-Z]/','',$enable_delete_modify_date); + $enable_delete_security_phrase = preg_replace('/[^a-zA-Z]/','',$enable_delete_security_phrase); + $enable_delete_count = preg_replace('/[^a-zA-Z]/','',$enable_delete_count); + $delete_country_code = preg_replace('/[^-_%a-zA-Z0-9]/','',$delete_country_code); + $delete_vendor_lead_code = preg_replace('/[^-_%0-9a-zA-Z]/','',$delete_vendor_lead_code); + $delete_source_id = preg_replace('/[^-_%0-9a-zA-Z]/','',$delete_source_id); + $delete_owner = preg_replace('/[^-_%0-9a-zA-Z]/','',$delete_owner); + $delete_entry_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$delete_entry_date); + $delete_modify_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$delete_modify_date); + $delete_security_phrase = preg_replace('/[^-_%0-9a-zA-Z]/','',$delete_security_phrase); + $delete_status = preg_replace('/[^-_%0-9a-zA-Z]/','',$delete_status); + $delete_lead_id = preg_replace('/[^0-9]/','',$delete_lead_id); + $delete_list = preg_replace('/[^0-9]/','',$delete_list); + $delete_count_num = preg_replace('/[^0-9]/','',$delete_count_num); + $delete_count_op = preg_replace('/[^<>=]/','',$delete_count_op); + + if ($DB) + { + echo "

    enable_delete_country_code = $enable_delete_country_code | enable_delete_vendor_lead_code = $enable_delete_vendor_lead_code | enable_delete_source_id = $enable_delete_source_id | enable_delete_owner = $enable_delete_owner | enable_delete_entry_date = $enable_delete_entry_date | enable_delete_modify_date = $enable_delete_modify_date | enable_delete_security_phrase = $enable_delete_security_phrase | enable_delete_count = $enable_delete_count | delete_country_code = $delete_country_code | delete_vendor_lead_code = $delete_vendor_lead_code | delete_source_id = $delete_source_id | delete_owner = $delete_owner | delete_owner = $delete_entry_date | delete_modify_date = $delete_modify_date | delete_security_phrase = $delete_security_phrase | delete_list = $delete_list | delete_status = $delete_status | delete_count_op = $delete_count_op | delete_count_num = $delete_count_num | delete_lead_id = $delete_lead_id

    "; + } + + $delete_count_op_phrase=""; + if ( $delete_count_op == "<" ) + { + $delete_count_op_phrase= "less than "; + } + elseif ( $delete_count_op == "<=" ) + { + $delete_count_op_phrase= "less than or equal to "; + } + elseif ( $delete_count_op == ">" ) + { + $delete_count_op_phrase= "greater than "; + } + elseif ( $delete_count_op == ">=" ) + { + $delete_count_op_phrase= "greater than or equal to "; + } + + # make sure the required fields are set + if ($delete_status == '') { missing_required_field('Status'); } + if ($delete_list == '') { missing_required_field('List ID'); } + + # build the sql query's where phrase and the delete phrase + $sql_where = ""; + $sql_where = $sql_where . " and status like '$delete_status' "; + $delete_parm = ""; + $delete_parm = $delete_parm . "    status is like $delete_status
    "; + if (($enable_delete_lead_id == "enabled") && ($delete_lead_id != '')) + { + if ($delete_lead_id == '---BLANK---') {$delete_lead_id = '';} + $sql_where = $sql_where . " and lead_id like '$delete_lead_id' "; + $delete_parm = $delete_parm . "    lead_id is like $delete_lead_id
    "; + if ($delete_lead_id == '') {$delete_lead_id = '---BLANK---';} + } + elseif ($enable_delete_lead_id == "enabled") + { + blank_field('Lead ID'); + } + if (($enable_delete_country_code == "enabled") && ($delete_country_code != '')) + { + if ($delete_country_code == '---BLANK---') {$delete_country_code = '';} + $sql_where = $sql_where . " and country_code like '$delete_country_code' "; + $delete_parm = $delete_parm . "    ;country code is like $delete_country_code
    "; + if ($delete_country_code == '') {$delete_country_code = '---BLANK---';} + } + elseif ($enable_delete_country_code == "enabled") + { + blank_field('Country Code'); + } + if (($enable_delete_vendor_lead_code == "enabled") && ($delete_vendor_lead_code != '')) + { + if ($delete_vendor_lead_code == '---BLANK---') {$delete_vendor_lead_code = '';} + $sql_where = $sql_where . " and vendor_lead_code like '$delete_vendor_lead_code' "; + $delete_parm = $delete_parm . "    ;vendor lead code is like $delete_vendor_lead_code
    "; + if ($delete_vendor_lead_code == '') {$delete_vendor_lead_code = '---BLANK---';} + } + elseif ($enable_delete_vendor_lead_code == "enabled") + { + blank_field('Vendor Lead Code'); + } + if (($enable_delete_source_id == "enabled") && ($delete_source_id != '')) + { + if ($delete_source_id == '---BLANK---') {$delete_source_id = '';} + $sql_where = $sql_where . " and source_id like '$delete_source_id' "; + $delete_parm = $delete_parm . "    ;source id code is like $delete_source_id
    "; + if ($delete_source_id == '') {$delete_source_id = '---BLANK---';} + } + elseif ($enable_delete_source_id == "enabled") + { + blank_field('Source ID'); + } + if (($enable_delete_security_phrase == "enabled") && ($delete_security_phrase != '')) + { + if ($delete_security_phrase == '---BLANK---') {$delete_security_phrase = '';} + $sql_where = $sql_where . " and security_phrase like '$delete_security_phrase' "; + $delete_parm = $delete_parm . "    ;secuirty phrase is like $delete_security_phrase
    "; + if ($delete_security_phrase == '') {$delete_security_phrase = '---BLANK---';} + } + elseif ($enable_delete_security_phrase == "enabled") + { + blank_field('Security Phrase'); + } + if (($enable_delete_owner == "enabled") && ($delete_owner != '')) + { + if ($delete_owner == '---BLANK---') {$delete_owner = '';} + $sql_where = $sql_where . " and owner like '$delete_owner' "; + $delete_parm = $delete_parm . "    ;owner is like $delete_owner
    "; + if ($delete_owner == '') {$delete_owner = '---BLANK---';} + } + elseif ($enable_delete_owner == "enabled") + { + blank_field('Owner'); + } + if (($enable_delete_entry_date == "enabled") && ($delete_entry_date != '')) + { + if ($delete_entry_date == '---BLANK---') + { + $sql_where = $sql_where . " and entry_date == '' "; + $delete_parm = $delete_parm . "    entry date is blank
    "; + } + else + { + $sql_where = $sql_where . " and entry_date >= '$delete_entry_date 00:00:00' and entry_date <= '$delete_entry_date 23:59:59' "; + $delete_parm = $delete_parm . "    entry date was on $delete_entry_date
    "; + } + } + elseif ($enable_delete_entry_date == "enabled") + { + blank_field('Entry Date'); + } + if (($enable_delete_modify_date == "enabled") && ($delete_modify_date != '')) + { + if ($delete_modify_date == '---BLANK---') + { + $sql_where = $sql_where . " and modify_date == '' "; + $delete_parm = $delete_parm . "    modify date is blank
    "; + } + else + { + $sql_where = $sql_where . " and modify_date >= '$delete_modify_date 00:00:00' and modify_date <= '$delete_modify_date 23:59:59' "; + $delete_parm = $delete_parm . "    last modify date was on $delete_modify_date
    "; + } + } + elseif ($enable_delete_modify_date == "enabled") + { + blank_field('Modify Date'); + } + if (($enable_delete_count == "enabled") && ($delete_count_op != '') && ($delete_count_num != '')) + { + if ($delete_count_op == '---BLANK---') {$delete_count_op = '';} + if ($delete_count_num == '---BLANK---') {$delete_count_num = '';} + $sql_where = $sql_where . " and called_count $delete_count_op $delete_count_num"; + $delete_parm = $delete_parm . "    called count is $update_count_op_phrase $delete_count_num
    "; + if ($delete_count_op == '') {$delete_count_op = '---BLANK---';} + if ($delete_count_num == '') {$delete_count_num = '---BLANK---';} + } + elseif ($enable_delete_count == "enabled") + { + blank_field('Move Count'); + } + + # get the number of leads this action will move + $delete_lead_count=0; + $delete_lead_count_stmt = "SELECT count(1) FROM vicidial_list WHERE list_id = '$delete_list' $sql_where"; + if ($DB) { echo "|$delete_lead_count_stmt|\n"; } + $delete_lead_count_rslt = mysql_to_mysqli($delete_lead_count_stmt, $link); + $delete_lead_count_row = mysqli_fetch_row($delete_lead_count_rslt); + $delete_lead_count = $delete_lead_count_row[0]; + + echo "

    You are about to delete $delete_lead_count leads in list $delete_list with the following parameters:

    $delete_parm
    Please press confirm to continue.

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

    Click here to start over.

    \n"; + echo "\n\n"; + + } + +# actually do the delete +if ( ( $confirm_delete == "confirm" ) && ( $delete_lists > 0 ) ) + { + # get the variables + $enable_delete_lead_id=""; + $enable_delete_country_code=""; + $enable_delete_vendor_lead_code=""; + $enable_delete_source_id=""; + $enable_delete_owner=""; + $enable_delete_entry_date=""; + $enable_delete_modify_date=""; + $enable_delete_security_phrase=""; + $enable_delete_count=""; + $delete_country_code=""; + $delete_vendor_lead_code=""; + $delete_source_id=""; + $delete_owner=""; + $delete_entry_date=""; + $delete_modify_date=""; + $delete_security_phrase=""; + $delete_list=""; + $delete_status=""; + $delete_count_op=""; + $delete_count_num=""; + $delete_lead_id=""; + + # check the get / post data for the variables + if (isset($_GET["enable_delete_lead_id"])) {$enable_delete_lead_id=$_GET["enable_delete_lead_id"];} + elseif (isset($_POST["enable_delete_lead_id"])) {$enable_delete_lead_id=$_POST["enable_delete_lead_id"];} + if (isset($_GET["enable_delete_country_code"])) {$enable_delete_country_code=$_GET["enable_delete_country_code"];} + elseif (isset($_POST["enable_delete_country_code"])) {$enable_delete_country_code=$_POST["enable_delete_country_code"];} + if (isset($_GET["enable_delete_vendor_lead_code"])) {$enable_delete_vendor_lead_code=$_GET["enable_delete_vendor_lead_code"];} + elseif (isset($_POST["enable_delete_vendor_lead_code"])) {$enable_delete_vendor_lead_code=$_POST["enable_delete_vendor_lead_code"];} + if (isset($_GET["enable_delete_source_id"])) {$enable_delete_source_id=$_GET["enable_delete_source_id"];} + elseif (isset($_POST["enable_delete_source_id"])) {$enable_delete_source_id=$_POST["enable_delete_source_id"];} + if (isset($_GET["enable_delete_owner"])) {$enable_delete_owner=$_GET["enable_delete_owner"];} + elseif (isset($_POST["enable_delete_owner"])) {$enable_delete_owner=$_POST["enable_delete_owner"];} + if (isset($_GET["enable_delete_entry_date"])) {$enable_delete_entry_date=$_GET["enable_delete_entry_date"];} + elseif (isset($_POST["enable_delete_entry_date"])) {$enable_delete_entry_date=$_POST["enable_delete_entry_date"];} + if (isset($_GET["enable_delete_modify_date"])) {$enable_delete_modify_date=$_GET["enable_delete_modify_date"];} + elseif (isset($_POST["enable_delete_modify_date"])) {$enable_delete_modify_date=$_POST["enable_delete_modify_date"];} + if (isset($_GET["enable_delete_security_phrase"])) {$enable_delete_security_phrase=$_GET["enable_delete_security_phrase"];} + elseif (isset($_POST["enable_delete_security_phrase"])) {$enable_delete_security_phrase=$_POST["enable_delete_security_phrase"];} + if (isset($_GET["enable_delete_count"])) {$enable_delete_count=$_GET["enable_delete_count"];} + elseif (isset($_POST["enable_delete_count"])) {$enable_delete_count=$_POST["enable_delete_count"];} + if (isset($_GET["delete_country_code"])) {$delete_country_code=$_GET["delete_country_code"];} + elseif (isset($_POST["delete_country_code"])) {$delete_country_code=$_POST["delete_country_code"];} + if (isset($_GET["delete_vendor_lead_code"])) {$delete_vendor_lead_code=$_GET["delete_vendor_lead_code"];} + elseif (isset($_POST["delete_vendor_lead_code"])) {$delete_vendor_lead_code=$_POST["delete_vendor_lead_code"];} + if (isset($_GET["delete_source_id"])) {$delete_source_id=$_GET["delete_source_id"];} + elseif (isset($_POST["delete_source_id"])) {$delete_source_id=$_POST["delete_source_id"];} + if (isset($_GET["delete_owner"])) {$delete_owner=$_GET["delete_owner"];} + elseif (isset($_POST["delete_owner"])) {$delete_owner=$_POST["delete_owner"];} + if (isset($_GET["delete_entry_date"])) {$delete_entry_date=$_GET["delete_entry_date"];} + elseif (isset($_POST["delete_entry_date"])) {$delete_entry_date=$_POST["delete_entry_date"];} + if (isset($_GET["delete_modify_date"])) {$delete_modify_date=$_GET["delete_modify_date"];} + elseif (isset($_POST["delete_modify_date"])) {$delete_modify_date=$_POST["delete_modify_date"];} + if (isset($_GET["delete_security_phrase"])) {$delete_security_phrase=$_GET["delete_security_phrase"];} + elseif (isset($_POST["delete_security_phrase"])) {$delete_security_phrase=$_POST["delete_security_phrase"];} + if (isset($_GET["delete_list"])) {$delete_list=$_GET["delete_list"];} + elseif (isset($_POST["delete_list"])) {$delete_list=$_POST["delete_list"];} + if (isset($_GET["delete_status"])) {$delete_status=$_GET["delete_status"];} + elseif (isset($_POST["delete_status"])) {$delete_status=$_POST["delete_status"];} + if (isset($_GET["delete_lead_id"])) {$delete_lead_id=$_GET["delete_lead_id"];} + elseif (isset($_POST["delete_lead_id"])) {$delete_lead_id=$_POST["delete_lead_id"];} + if (isset($_GET["delete_count_op"])) {$delete_count_op=$_GET["delete_count_op"];} + elseif (isset($_POST["delete_count_op"])) {$delete_count_op=$_POST["delete_count_op"];} + if (isset($_GET["delete_count_num"])) {$delete_count_num=$_GET["delete_count_num"];} + elseif (isset($_POST["delete_count_num"])) {$delete_count_num=$_POST["delete_count_num"];} + + if ($DB) + { + echo "

    enable_delete_country_code = $enable_delete_country_code | enable_delete_vendor_lead_code = $enable_delete_vendor_lead_code | enable_delete_source_id = $enable_delete_source_id | enable_delete_owner = $enable_delete_owner | enable_delete_entry_date = $enable_delete_entry_date | enable_delete_modify_date = $enable_delete_modify_date | enable_delete_security_phrase = $enable_delete_security_phrase | enable_delete_count = $enable_delete_count | delete_country_code = $delete_country_code | delete_vendor_lead_code = $delete_vendor_lead_code | delete_source_id = $delete_source_id | delete_owner = $delete_owner | delete_owner = $delete_entry_date | delete_modify_date = $delete_modify_date | delete_security_phrase = $delete_security_phrase | delete_list = $delete_list | delete_status = $delete_status | delete_count_op = $delete_count_op | delete_count_num = $delete_count_num | delete_lead_id = $delete_lead_id

    "; + } + + # filter out anything bad + $enable_delete_status = preg_replace('/[^a-zA-Z]/','',$enable_delete_status); + $enable_delete_country_code = preg_replace('/[^a-zA-Z]/','',$enable_delete_country_code); + $enable_delete_vendor_lead_code = preg_replace('/[^a-zA-Z]/','',$enable_delete_vendor_lead_code); + $enable_delete_source_id = preg_replace('/[^a-zA-Z]/','',$enable_delete_source_id); + $enable_delete_owner = preg_replace('/[^a-zA-Z]/','',$enable_delete_owner); + $enable_delete_entry_date = preg_replace('/[^a-zA-Z]/','',$enable_delete_entry_date); + $enable_delete_modify_date = preg_replace('/[^a-zA-Z]/','',$enable_delete_modify_date); + $enable_delete_security_phrase = preg_replace('/[^a-zA-Z]/','',$enable_delete_security_phrase); + $enable_delete_count = preg_replace('/[^a-zA-Z]/','',$enable_delete_count); + $delete_country_code = preg_replace('/[^-_%a-zA-Z0-9]/','',$delete_country_code); + $delete_vendor_lead_code = preg_replace('/[^-_%0-9a-zA-Z]/','',$delete_vendor_lead_code); + $delete_source_id = preg_replace('/[^-_%0-9a-zA-Z]/','',$delete_source_id); + $delete_owner = preg_replace('/[^-_%0-9a-zA-Z]/','',$delete_owner); + $delete_entry_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$delete_entry_date); + $delete_modify_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$delete_modify_date); + $delete_security_phrase = preg_replace('/[^-_%0-9a-zA-Z]/','',$delete_security_phrase); + $delete_status = preg_replace('/[^-_%0-9a-zA-Z]/','',$delete_status); + $delete_lead_id = preg_replace('/[^0-9]/','',$delete_lead_id); + $delete_list = preg_replace('/[^0-9]/','',$delete_list); + $delete_count_num = preg_replace('/[^0-9]/','',$delete_count_num); + $delete_count_op = preg_replace('/[^<>=]/','',$delete_count_op); + + if ($DB) + { + echo "

    enable_delete_country_code = $enable_delete_country_code | enable_delete_vendor_lead_code = $enable_delete_vendor_lead_code | enable_delete_source_id = $enable_delete_source_id | enable_delete_owner = $enable_delete_owner | enable_delete_entry_date = $enable_delete_entry_date | enable_delete_modify_date = $enable_delete_modify_date | enable_delete_security_phrase = $enable_delete_security_phrase | enable_delete_count = $enable_delete_count | delete_country_code = $delete_country_code | delete_vendor_lead_code = $delete_vendor_lead_code | delete_source_id = $delete_source_id | delete_owner = $delete_owner | delete_owner = $delete_entry_date | delete_modify_date = $delete_modify_date | delete_security_phrase = $delete_security_phrase | delete_list = $delete_list | delete_status = $delete_status | delete_count_op = $delete_count_op | delete_count_num = $delete_count_num | delete_lead_id = $delete_lead_id

    "; + } + + $delete_count_op_phrase=""; + if ( $delete_count_op == "<" ) + { + $delete_count_op_phrase= "less than "; + } + elseif ( $delete_count_op == "<=" ) + { + $delete_count_op_phrase= "less than or equal to "; + } + elseif ( $delete_count_op == ">" ) + { + $delete_count_op_phrase= "greater than "; + } + elseif ( $delete_count_op == ">=" ) + { + $delete_count_op_phrase= "greater than or equal to "; + } + + # make sure the required fields are set + if ($delete_status == '') { missing_required_field('Status'); } + if ($delete_list == '') { missing_required_field('List ID'); } + + # build the sql query's where phrase and the delete phrase + $sql_where = ""; + $sql_where = $sql_where . " and status like '$delete_status' "; + $delete_parm = ""; + $delete_parm = $delete_parm . "    status is like $delete_status
    "; + if (($enable_delete_lead_id == "enabled") && ($delete_lead_id != '')) + { + if ($delete_lead_id == '---BLANK---') {$delete_lead_id = '';} + $sql_where = $sql_where . " and lead_id like '$delete_lead_id' "; + $delete_parm = $delete_parm . "    lead_id is like $delete_lead_id
    "; + if ($delete_lead_id == '') {$delete_lead_id = '---BLANK---';} + } + elseif ($enable_delete_lead_id == "enabled") + { + blank_field('Lead ID'); + } + if (($enable_delete_country_code == "enabled") && ($delete_country_code != '')) + { + if ($delete_country_code == '---BLANK---') {$delete_country_code = '';} + $sql_where = $sql_where . " and country_code like '$delete_country_code' "; + $delete_parm = $delete_parm . "    ;country code is like $delete_country_code
    "; + if ($delete_country_code == '') {$delete_country_code = '---BLANK---';} + } + elseif ($enable_delete_country_code == "enabled") + { + blank_field('Country Code'); + } + if (($enable_delete_vendor_lead_code == "enabled") && ($delete_vendor_lead_code != '')) + { + if ($delete_vendor_lead_code == '---BLANK---') {$delete_vendor_lead_code = '';} + $sql_where = $sql_where . " and vendor_lead_code like '$delete_vendor_lead_code' "; + $delete_parm = $delete_parm . "    ;vendor lead code is like $delete_vendor_lead_code
    "; + if ($delete_vendor_lead_code == '') {$delete_vendor_lead_code = '---BLANK---';} + } + elseif ($enable_delete_vendor_lead_code == "enabled") + { + blank_field('Vendor Lead Code'); + } + if (($enable_delete_source_id == "enabled") && ($delete_source_id != '')) + { + if ($delete_source_id == '---BLANK---') {$delete_source_id = '';} + $sql_where = $sql_where . " and source_id like '$delete_source_id' "; + $delete_parm = $delete_parm . "    ;source id code is like $delete_source_id
    "; + if ($delete_source_id == '') {$delete_source_id = '---BLANK---';} + } + elseif ($enable_delete_source_id == "enabled") + { + blank_field('Source ID'); + } + if (($enable_delete_security_phrase == "enabled") && ($delete_security_phrase != '')) + { + if ($delete_security_phrase == '---BLANK---') {$delete_security_phrase = '';} + $sql_where = $sql_where . " and security_phrase like '$delete_security_phrase' "; + $delete_parm = $delete_parm . "    ;secuirty phrase is like $delete_security_phrase
    "; + if ($delete_security_phrase == '') {$delete_security_phrase = '---BLANK---';} + } + elseif ($enable_delete_security_phrase == "enabled") + { + blank_field('Security Phrase'); + } + if (($enable_delete_owner == "enabled") && ($delete_owner != '')) + { + if ($delete_owner == '---BLANK---') {$delete_owner = '';} + $sql_where = $sql_where . " and owner like '$delete_owner' "; + $delete_parm = $delete_parm . "    ;owner is like $delete_owner
    "; + if ($delete_owner == '') {$delete_owner = '---BLANK---';} + } + elseif ($enable_delete_owner == "enabled") + { + blank_field('Owner'); + } + if (($enable_delete_entry_date == "enabled") && ($delete_entry_date != '')) + { + if ($delete_entry_date == '---BLANK---') + { + $sql_where = $sql_where . " and entry_date == '' "; + $delete_parm = $delete_parm . "    entry date is blank
    "; + } + else + { + $sql_where = $sql_where . " and entry_date >= '$delete_entry_date 00:00:00' and entry_date <= '$delete_entry_date 23:59:59' "; + $delete_parm = $delete_parm . "    entry date was on $delete_entry_date
    "; + } + } + elseif ($enable_delete_entry_date == "enabled") + { + blank_field('Entry Date'); + } + if (($enable_delete_modify_date == "enabled") && ($delete_modify_date != '')) + { + if ($delete_modify_date == '---BLANK---') + { + $sql_where = $sql_where . " and modify_date == '' "; + $delete_parm = $delete_parm . "    modify date is blank
    "; + } + else + { + $sql_where = $sql_where . " and modify_date >= '$delete_modify_date 00:00:00' and modify_date <= '$delete_modify_date 23:59:59' "; + $delete_parm = $delete_parm . "    last modify date was on $delete_modify_date
    "; + } + } + elseif ($enable_delete_modify_date == "enabled") + { + blank_field('Modify Date'); + } + if (($enable_delete_count == "enabled") && ($delete_count_op != '') && ($delete_count_num != '')) + { + if ($delete_count_op == '---BLANK---') {$delete_count_op = '';} + if ($delete_count_num == '---BLANK---') {$delete_count_num = '';} + $sql_where = $sql_where . " and called_count $delete_count_op $delete_count_num"; + $delete_parm = $delete_parm . "    called count is $update_count_op_phrase $delete_count_num
    "; + if ($delete_count_op == '') {$delete_count_op = '---BLANK---';} + if ($delete_count_num == '') {$delete_count_num = '---BLANK---';} + } + elseif ($enable_delete_count == "enabled") + { + blank_field('Move Count'); + } + + $delete_lead_stmt = "DELETE FROM vicidial_list WHERE list_id = '$delete_list' $sql_where"; + if ($DB) { echo "|$delete_lead_stmt|\n"; } + $delete_lead_rslt = mysql_to_mysqli($delete_lead_stmt, $link); + $delete_lead_count = mysqli_affected_rows($link); + + $delete_sentence = "$delete_lead_count leads delete from list $delete_list with the following parameters:

    $delete_parm
    "; + + $SQL_log = "$delete_lead_stmt|"; + $SQL_log = preg_replace('/;/', '', $SQL_log); + $SQL_log = addslashes($SQL_log); + $admin_log_stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='DELETE', record_id='$delete_list', event_code='ADMIN DELETE LEADS', event_sql=\"$SQL_log\", event_notes='$delete_sentence';"; + if ($DB) {echo "|$admin_log_stmt|\n";} + $admin_log_rslt=mysql_to_mysqli($admin_log_stmt, $link); + + echo "

    $delete_sentence

    "; + echo "

    Click here to start over.

    \n"; + } + +# main page display +if ( + ($move_submit != "move" ) && ($update_submit != "update") && ($delete_submit != "delete") && + ($confirm_move != "confirm") && ($confirm_update != "confirm") && ($confirm_delete != "confirm") + ) + { + # figure out which campaigns this user is allowed to work on + $allowed_campaigns_stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$user_group';"; + if ($DB) { echo "|$allowed_campaigns_stmt|\n"; } + $rslt = mysql_to_mysqli($allowed_campaigns_stmt, $link); + $allowed_campaigns_row = mysqli_fetch_row($rslt); + $allowed_campaigns = $allowed_campaigns_row[0]; + if ($DB) { echo "|$allowed_campaigns|\n"; } + $allowed_campaigns_sql = ""; + if ( preg_match("/ALL\-CAMPAIGNS/i",$allowed_campaigns) ) + { + if ($DB) { echo "|Processing All Campaigns|\n"; } + $campaign_id_stmt = "SELECT campaign_id FROM vicidial_campaigns"; + $campaign_id_rslt = mysql_to_mysqli($campaign_id_stmt, $link); + $campaign_id_num_rows = mysqli_num_rows($campaign_id_rslt); + if ($DB) { echo "|campaign_id_num_rows = $campaign_id_num_rows|\n"; } + if ($campaign_id_num_rows > 0) + { + $i = 0; + while ( $i < $campaign_id_num_rows ) + { + $campaign_id_row = mysqli_fetch_row($campaign_id_rslt); + if ( $i == 0 ) + { + $allowed_campaigns_sql = "'$campaign_id_row[0]'"; + } + else + { + $allowed_campaigns_sql = "$allowed_campaigns_sql, '$campaign_id_row[0]'"; + } + $i++; + } + } + } + else + { + $allowed_campaigns_sql = preg_replace("/ -/",'',$allowed_campaigns); + $allowed_campaigns_sql = preg_replace("/^ /",'',$allowed_campaigns_sql); + $allowed_campaigns_sql = preg_replace("/ $/",'',$allowed_campaigns_sql); + $allowed_campaigns_sql = preg_replace("/ /","','",$allowed_campaigns_sql); + $allowed_campaigns_sql = "'$allowed_campaigns_sql'"; + } + + # figure out which lists they are allowed to see + $lists_stmt = "SELECT list_id, list_name FROM vicidial_lists WHERE campaign_id IN ($allowed_campaigns_sql) and active = 'N' ORDER BY list_id"; + if ($DB) { echo "|$lists_stmt|\n"; } + $lists_rslt = mysql_to_mysqli($lists_stmt, $link); + $num_rows = mysqli_num_rows($lists_rslt); + $i = 0; + $allowed_lists_count = 0; + while ( $i < $num_rows ) + { + $lists_row = mysqli_fetch_row($lists_rslt); + + # check how many leads are in the list + $lead_count_stmt = "SELECT count(1) FROM vicidial_list WHERE list_id = '$lists_row[0]'"; + if ($DB) { echo "|$lead_count_stmt|\n"; } + $lead_count_rslt = mysql_to_mysqli($lead_count_stmt, $link); + $lead_count_row = mysqli_fetch_row($lead_count_rslt); + $lead_count = $lead_count_row[0]; + + # only show lists that are under the list_lead_limit + if ( $lead_count <= $list_lead_limit ) + { + $list_ary[$allowed_lists_count] = $lists_row[0]; + $list_name_ary[$allowed_lists_count] = $lists_row[1]; + $list_lead_count_ary[$allowed_lists_count] = $lead_count_row[0]; + + if ($allowed_lists_count == 0) + { + $allowed_lists_sql = "'$lists_row[0]'"; + } + else + { + $allowed_lists_sql = "$allowed_lists_sql, '$lists_row[0]'"; + } + + $allowed_lists_count++; + } + $i++; + } + + # figure out which statuses are in the lists they are allowed to look at + $status_stmt = "SELECT DISTINCT status FROM vicidial_list WHERE list_id IN ( $allowed_lists_sql ) ORDER BY status"; + if ($DB) { echo "|$status_stmt|\n"; } + $status_rslt = mysql_to_mysqli($status_stmt, $link); + $status_count=mysqli_num_rows($status_rslt); + $i = 0; + while ( $i < $status_count ) + { + $status_row = mysqli_fetch_row($status_rslt); + $statuses[$i] = $status_row[0]; + $i++; + } + + # figure out which statuses are in the lists they are allowed to look at + $sys_status_stmt = "SELECT status FROM vicidial_statuses ORDER BY status"; + if ($DB) { echo "|$sys_status_stmt|\n"; } + $sys_status_rslt = mysql_to_mysqli($sys_status_stmt, $link); + $sys_status_count=mysqli_num_rows($sys_status_rslt); + $i = 0; + while ( $i < $sys_status_count ) + { + $sys_status_row = mysqli_fetch_row($sys_status_rslt); + $sys_statuses[$i] = $sys_status_row[0]; + $i++; + } + + + echo "

    The following are advanced lead management tools. They will only work on inactive lists with less than $list_lead_limit leads in them. This is to avoid data inconsistencies.

    "; + echo "
    \n"; + echo "
    \n"; + + # BEGIN lead move + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
    Move Leads
    From List\n"; + echo "
    To List\n"; + echo "
    Status\n"; + echo "\n"; + echo "
    Country Code\n"; + echo "\n"; + echo "\n"; + echo "
    Vendor Lead Code\n"; + echo "\n"; + echo "\n"; + echo "
    Source ID\n"; + echo "\n"; + echo "\n"; + echo "
    Owner\n"; + echo "\n"; + echo "\n"; + echo "
    Entry Date\n"; + echo "\n"; + echo "\n"; + echo "
    Modify Date\n"; + echo "\n"; + echo "\n"; + echo "
    Security Phrase\n"; + echo "\n"; + echo "\n"; + echo "
    Called Count\n"; + echo "\n"; + echo "\n"; + echo "
    \n"; + # END lead move + + # BEGIN Status Update + echo "
    \n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + # END Status Update + + if ( $delete_lists > 0 ) + { + # BEGIN Delete Leads + echo "
    Update Lead Statuses
    List\n"; + echo "
    To Status\n"; + echo "
    From Status\n"; + echo "\n"; + echo "
    Country Code\n"; + echo "\n"; + echo "\n"; + echo "
    Vendor Lead Code\n"; + echo "\n"; + echo "\n"; + echo "
    Source ID\n"; + echo "\n"; + echo "\n"; + echo "
    Owner\n"; + echo "\n"; + echo "\n"; + echo "
    Entry Date\n"; + echo "\n"; + echo "\n"; + echo "
    Modify Date\n"; + echo "\n"; + echo "\n"; + echo "
    Security Phrase\n"; + echo "\n"; + echo "\n"; + echo "
    Called Count\n"; + echo "\n"; + echo "\n"; + echo "
    \n"; + echo "
    \n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + # END Delete Leads + + } + + echo "
    Delete Leads
    List\n"; + echo "
    Status\n"; + echo "
    Country Code\n"; + echo "\n"; + echo "\n"; + echo "
    Vendor Lead Code\n"; + echo "\n"; + echo "\n"; + echo "
    Source ID\n"; + echo "\n"; + echo "\n"; + echo "
    Owner\n"; + echo "\n"; + echo "\n"; + echo "
    Entry Date\n"; + echo "\n"; + echo "\n"; + echo "
    Modify Date\n"; + echo "\n"; + echo "\n"; + echo "
    Security Phrase\n"; + echo "\n"; + echo "\n"; + echo "
    Lead ID\n"; + echo "\n"; + echo "\n"; + echo "
    Called Count\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
    \n"; + echo "
    \n"; + echo "\n"; + } + +echo "
    \n"; + +function blank_field($field_name) + { + echo "

    $field_name cannot be blank. If you wish to search for an empty field use ---BLANK--- instead.

    "; + echo "

    Click here to start over.

    \n"; + exit(); + } + +function missing_required_field($field_name) + { + echo "

    The field '$field_name' must have a value.

    "; + echo "

    Click here to start over.

    \n"; + exit(); + } + +?> diff --git a/www/vicidial/user_stats.php b/www/vicidial/user_stats.php index 5faf28a0..d7969ffc 100644 --- a/www/vicidial/user_stats.php +++ b/www/vicidial/user_stats.php @@ -41,6 +41,7 @@ # 130616-0059 - Added filtering of input to prevent SQL injection attacks and new user auth # 130625-1341 - Added phone login and phone_ip display to login/logout section # 130901-0836 - Changed to mysqli PHP functions +# 131016-2102 - Added checking for level 8 add-copy restriction # $startMS = microtime(); @@ -52,6 +53,7 @@ $report_name = 'User Stats'; $db_source = 'M'; $firstlastname_display_user_stats=0; +$add_copy_disabled=0; if (file_exists('options.php')) { require('options.php'); @@ -81,7 +83,7 @@ if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];} ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### -$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;"; +$stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db,user_territories_active,webroot_writable,allow_emails,level_8_disable_add FROM system_settings;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $qm_conf_ct = mysqli_num_rows($rslt); @@ -95,6 +97,7 @@ if ($qm_conf_ct > 0) $user_territories_active = $row[4]; $webroot_writable = $row[5]; $allow_emails = $row[6]; + $SSlevel_8_disable_add = $row[7]; } ##### END SETTINGS LOOKUP ##### ########################################### @@ -171,6 +174,16 @@ else exit; } + +$stmt="SELECT user_level from vicidial_users where user='$PHP_AUTH_USER';"; +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGuser_level =$row[0]; + +if (($LOGuser_level < 9) and ($SSlevel_8_disable_add > 0)) + {$add_copy_disabled++;} + + $date = date("r"); $ip = getenv("REMOTE_ADDR"); $browser = getenv("HTTP_USER_AGENT"); diff --git a/www/vicidial/user_status.php b/www/vicidial/user_status.php index 811d6ca2..7576ac85 100644 --- a/www/vicidial/user_status.php +++ b/www/vicidial/user_status.php @@ -24,6 +24,7 @@ # 130610-0937 - Finalized changing of all ereg instances to preg # 130616-0052 - Added filtering of input to prevent SQL injection attacks and new user auth # 130901-0835 - Changed to mysqli PHP functions +# 131016-2101 - Added checking for level 8 add-copy restriction # $startMS = microtime(); @@ -32,6 +33,8 @@ header ("Content-type: text/html; charset=utf-8"); $report_name='User Status'; +$add_copy_disabled=0; + require("dbconnect_mysqli.php"); require("functions.php"); @@ -57,7 +60,7 @@ if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### -$stmt = "SELECT use_non_latin,webroot_writable,outbound_autodial_active,user_territories_active FROM system_settings;"; +$stmt = "SELECT use_non_latin,webroot_writable,outbound_autodial_active,user_territories_active,level_8_disable_add FROM system_settings;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysqli_num_rows($rslt); @@ -68,6 +71,7 @@ if ($qm_conf_ct > 0) $webroot_writable = $row[1]; $SSoutbound_autodial_active = $row[2]; $user_territories_active = $row[3]; + $SSlevel_8_disable_add = $row[4]; } ##### END SETTINGS LOOKUP ##### ########################################### @@ -142,6 +146,16 @@ else exit; } + +$stmt="SELECT user_level from vicidial_users where user='$PHP_AUTH_USER';"; +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGuser_level =$row[0]; + +if (($LOGuser_level < 9) and ($SSlevel_8_disable_add > 0)) + {$add_copy_disabled++;} + + ##### BEGIN log visit to the vicidial_report_log table ##### $LOGip = getenv("REMOTE_ADDR"); $LOGbrowser = getenv("HTTP_USER_AGENT"); diff --git a/www/vicidial/user_territories.php b/www/vicidial/user_territories.php index 326fafb6..41fe8681 100644 --- a/www/vicidial/user_territories.php +++ b/www/vicidial/user_territories.php @@ -192,7 +192,7 @@ if ( ($action == "CHANGE_TERRITORY_OWNER_ACCOUNT") and ($enable_vtiger_integrati echo "$users_list"; echo "\n"; - echo "Update ViciDial List Owner: \n"; echo "\n"; echo "\n"; echo "\n"; @@ -404,7 +404,7 @@ if ( ($action == "CHANGE_TERRITORY_OWNER") and ($enable_vtiger_integration > 0) echo "$users_list"; echo "\n"; - echo "Update ViciDial List Owner: \n"; echo "\n"; echo "\n"; echo "\n"; diff --git a/www/vicidial/welcome.php b/www/vicidial/welcome.php index 7879e6e1..54a42f31 100644 --- a/www/vicidial/welcome.php +++ b/www/vicidial/welcome.php @@ -4,7 +4,7 @@ # Copyright (C) 2008 Matt Florell LICENSE: AGPLv2 # -echo "ViciDial Welcome\n"; +echo "Contact Center Welcome\n"; echo "\n"; echo "\n"; echo "




    "; diff --git a/www/vicidial/welcome_demo.php b/www/vicidial/welcome_demo.php index 48a594da..c2e73021 100644 --- a/www/vicidial/welcome_demo.php +++ b/www/vicidial/welcome_demo.php @@ -6,7 +6,7 @@ # header ("Content-type: text/html; charset=utf-8"); -echo "ViciDial Welcome\n"; +echo "Contact Center Welcome\n"; echo "\n"; echo "\n"; echo "



    ";