From c631aaf5562496cab0002141cf89f4a15460676f Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 4 Mar 2011 15:36:10 +0000 Subject: [PATCH] Added on-hook phone agent features for inbound calls Added ring_all Next-Agent-Call feature for inbound calls see UPGRADE doc for more details git-svn-id: svn://192.168.202.10@1611 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/UPGRADE | 20 + agc_2-X/trunk/agi/agi-VDAD_ALL_inbound.agi | 954 +++++++----------- agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi | 9 +- agc_2-X/trunk/agi/agi-VDAD_RINGALL.agi | 438 ++++++++ .../trunk/bin/AST_DB_territory_populate.pl | 116 +++ agc_2-X/trunk/bin/AST_VDauto_dial.pl | 20 +- agc_2-X/trunk/bin/AST_VDremote_agents.pl | 20 +- agc_2-X/trunk/bin/FastAGI_log.pl | 80 +- .../docs/conf_examples/extensions.conf.sample | 9 +- .../conf_examples/extensions.conf.sample-1.4 | 9 +- .../trunk/extras/MySQL_AST_CREATE_tables.sql | 18 +- agc_2-X/trunk/extras/upgrade_2.4.sql | 15 + .../TO_BE_TRANSLATED_2.4.txt | 11 + agc_2-X/trunk/www/agc/api.php | 4 + agc_2-X/trunk/www/agc/vdc_db_query.php | 42 +- agc_2-X/trunk/www/agc/vicidial.php | 40 +- .../trunk/www/vicidial/AST_timeonVDADall.php | 72 +- agc_2-X/trunk/www/vicidial/admin.php | 59 +- agc_2-X/trunk/www/vicidial/non_agent_api.php | 13 +- .../trunk/www/vicidial/realtime_report.php | 10 +- 20 files changed, 1247 insertions(+), 712 deletions(-) create mode 100644 agc_2-X/trunk/agi/agi-VDAD_RINGALL.agi create mode 100644 agc_2-X/trunk/bin/AST_DB_territory_populate.pl diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index c88cb3d9..d03f40fc 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -479,6 +479,26 @@ OTHER CHANGES: callback and lead information, including call history and call notes, without having to dial the lead. +114. Added on-hook agent phone feature. This feature allows inbound calls from + customers to ring on an on-hook agent phone, but not be transferred to + that agent until the agent's phone is answered. If the call times out + then the call will go on to the next agent. This is defined in the + Phones record and allows the agent using the vicidial.php agent screen + to not have to stay on the phone at all times when they are logged in. + You will need to add the following lines to the default context in your + extensions.conf file: + ; these are used for the ring_all function in VICIDIAL + exten => _8331*.,1,Playback(sip-silence) + exten => _8331*.,n,AGI(agi-VDAD_RINGALL.agi,${EXTEN}) + exten => _8331*.,n,AGI(agi-VDAD_RINGALL.agi,${EXTEN}) + exten => _8331*.,n,Hangup + +115. Added ring_all Next Agent Call option for in-groups. This works with on- + hook agent phones to allow all available agents to have their phones + ring at the same time, with the first agent to pick up their phone + receiving the call. It is not recommended to use this on high-volume + systems or systems with many agents available. + diff --git a/agc_2-X/trunk/agi/agi-VDAD_ALL_inbound.agi b/agc_2-X/trunk/agi/agi-VDAD_ALL_inbound.agi index 6bb2d9d8..116b2a21 100644 --- a/agc_2-X/trunk/agi/agi-VDAD_ALL_inbound.agi +++ b/agc_2-X/trunk/agi/agi-VDAD_ALL_inbound.agi @@ -145,6 +145,7 @@ # 101008-0410 - Added option for alternate Minimum Hold Time Message # 101219-2110 - Added call time overflow # 110224-1735 - Added compatibility with QM phone environment logging +# 110303-2338 - Added on-hook agent compatibility and rewrote a few sections # $script = 'agi-VDAD_ALL_inbound.agi'; @@ -156,7 +157,7 @@ $wait_prompt_runs=0; $at='@'; $S='*'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=157; +$mysql_log_count=169; $one_mysql_log=0; @@ -586,7 +587,7 @@ $sthA->finish(); ### Grab inbound groups values from the database $cbc=0; -$stmtA = "SELECT call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,drop_call_seconds,drop_action,drop_exten,next_agent_call,voicemail_ext,queue_priority,drop_inbound_group,afterhours_xfer_group,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,no_agent_no_queue,no_agent_action,no_agent_action_value,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,active,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds FROM vicidial_inbound_groups where group_id = '$channel_group';"; +$stmtA = "SELECT call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,drop_call_seconds,drop_action,drop_exten,next_agent_call,voicemail_ext,queue_priority,drop_inbound_group,afterhours_xfer_group,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,no_agent_no_queue,no_agent_action,no_agent_action_value,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,active,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time FROM vicidial_inbound_groups where group_id = '$channel_group';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -667,6 +668,7 @@ if ($sthArows > 0) $eht_minimum_prompt_filename = $aryA[63]; $eht_minimum_prompt_no_block = $aryA[64]; $eht_minimum_prompt_seconds = $aryA[65]; + $on_hook_ring_time = $aryA[66]; $custom_call_id=''; if ($uniqueid_status_display =~ /ENABLED/) @@ -833,7 +835,6 @@ if ($call_handle_method =~ /LOOKUP/) $dbhP=$dbhA; $mysql_count='02010'; $MEL_aff_rows=$sthArows; &mysql_error_logging; if ($sthArows > 0) { - $rec_countCUSTDATA=0; while ($sthArows > $cbc) { @aryA = $sthA->fetchrow_array; @@ -1597,11 +1598,14 @@ if ($VLEcount < 1) $wait_in_queue=1; $drop_timer=0; $drop_seconds=0; +$ring_all_timer=0; $hold_message_counter=($prompt_interval - 10); $hold_tone_counter=0; $skipLOSO=0; +$RING_agent=0; $ADfindSQL=''; $ADUfindSQL=''; +$ring_no_answer_agents = "'',"; ########################################################## ### For AGENTDIRECT calls try to send call to an agent ### @@ -1719,23 +1723,29 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) ) } } - $rec_countCUSTDATA=0; - $rec_countWAIT=0; - $gsp_countWAIT=0; - $qp_countWAIT=0; - $cbc=0; - $aco_sub=0; - $agent_call_order='order by last_call_finish'; - if ($CAMP_callorder =~ /longest_wait_time/i) {$agent_call_order = 'order by vicidial_live_agents.last_state_change';} - if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} - if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by vicidial_live_agents.last_call_time';} - if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by vicidial_live_agents.last_call_finish';} - if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} - if ($CAMP_callorder =~ /campaign_rank/i) {$agent_call_order = 'order by campaign_weight desc,last_call_finish';} - if ($CAMP_callorder =~ /fewest_calls_campaign/i) {$agent_call_order = 'order by vicidial_live_agents.calls_today,vicidial_live_agents.last_call_finish';} - if ($CAMP_callorder =~ /inbound_group_rank/i) {$aco_sub=1; $agent_call_order = 'order by group_weight desc,vicidial_live_inbound_agents.last_call_finish';} - if ($CAMP_callorder =~ /fewest_calls$/i) {$aco_sub=1; $agent_call_order = 'order by vicidial_live_inbound_agents.calls_today,vicidial_live_inbound_agents.last_call_finish';} - + $rec_countWAIT=0; + $gsp_countWAIT=0; + $qp_countWAIT=0; + $cbc=0; + $aco_sub=0; + $VDADconf_exten=''; + $VDADuser=''; + $VDADextension=''; + $VDADserver_ip=''; + $ra_user=''; + $VDADon_hook_ring_time=''; + $ring_agent_loop=0; + $agent_call_order='order by last_call_finish'; + if ($CAMP_callorder =~ /longest_wait_time/i) {$agent_call_order = 'order by vicidial_live_agents.last_state_change';} + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by vicidial_live_agents.last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by vicidial_live_agents.last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + if ($CAMP_callorder =~ /campaign_rank/i) {$agent_call_order = 'order by campaign_weight desc,last_call_finish';} + if ($CAMP_callorder =~ /fewest_calls_campaign/i) {$agent_call_order = 'order by vicidial_live_agents.calls_today,vicidial_live_agents.last_call_finish';} + if ($CAMP_callorder =~ /inbound_group_rank/i) {$aco_sub=1; $agent_call_order = 'order by group_weight desc,vicidial_live_inbound_agents.last_call_finish';} + if ($CAMP_callorder =~ /fewest_calls$/i) {$aco_sub=1; $agent_call_order = 'order by vicidial_live_inbound_agents.calls_today,vicidial_live_inbound_agents.last_call_finish';} + if ($CAMP_callorder =~ /ring_all$/i) {$aco_sub=0; $agent_call_order = 'order by vicidial_live_agents.last_state_change';} $vci=0; $INBOUNDcampsSQL="''"; @@ -1743,8 +1753,8 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) ) $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02033'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - while ($sthArows > $vci) + $dbhP=$dbhA; $mysql_count='02033'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + while ($sthArows > $vci) { @aryA = $sthA->fetchrow_array; if ($vci < 1) {$INBOUNDcampsSQL = "'$aryA[0]'";} @@ -1758,7 +1768,7 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) ) ##### BEGIN Check for Agent Grab of this call $AGENTgrab=0; $AGENTuser=''; - $stmtA = "SELECT agent_grab FROM vicidial_auto_calls where auto_call_id='$auto_call_id' and agent_grab NOT IN('');"; + $stmtA = "SELECT agent_grab,agent_grab_extension FROM vicidial_auto_calls where auto_call_id='$auto_call_id' and agent_grab NOT IN('');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1767,519 +1777,20 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) ) { @aryA = $sthA->fetchrow_array; $AGENTuser = $aryA[0]; + $AGENTextension = $aryA[1]; $AGENTgrab++; + $RING_agent=0; + $VDADon_hook_agent = 'N'; + if ($AGILOG) {$agi_string = "AGENT GRAB TRIGGERED: |$AGENTuser|$AGENTextension|$AGENTgrab|"; &agi_output;} } $sthA->finish(); ##### END Check for Agent Grab of this call ################################################################ - - ################################################################ ##### Attempt to send call to an agent on this server only ##### if ($agent_search_method =~ /^SO/) {$agent_search_method = 'LO';} - if ( ($agent_search_method =~ /^SO|^LO/) && ($skipLOSO < 1) ) - { - ### Get count of number of calls in this group that are ahead of this call - $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$VARserver_ip' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$insert_lead_id' and queue_priority >= '$queue_priority';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02034'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $rec_countWAIT = $aryA[0]; - $cbc++; - } - $sthA->finish(); - if ($AGILOG) {$agi_string = "$rec_countWAIT|$AGENTgrab|$stmtA|"; &agi_output;} - - if ( ($rec_countWAIT < 1) || ($AGENTgrab > 0) ) - { - $qp_countWAIT=0; - ### Get count of number of waiting calls in higher priority groups than this call or the same priority with longer wait time - $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$VARserver_ip' and lead_id != '$insert_lead_id' and ( (queue_priority > '$queue_priority') or (queue_priority = '$queue_priority' and call_time < \"$SQLdateBEGIN\"));"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02035'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $qp_countWAIT = $aryA[0]; - } - $sthA->finish(); - - $qp_groupWAIT=''; - $qp_groupWAIT_SQL=''; - $qp_groupWAIT_aco=''; - $qp_groupWAIT_aco_SQL=''; - $qp_groupWAIT_camp_SQL=''; - if ( ($qp_countWAIT > 0) && ($AGENTgrab < 1) ) - { - ### Get group/campaign ids of calls in higher priority groups than this call or the same priority with longer wait time - $stmtA = "SELECT distinct campaign_id FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$VARserver_ip' and lead_id != '$insert_lead_id' and ( (queue_priority > '$queue_priority') or (queue_priority = '$queue_priority' and call_time < \"$SQLdateBEGIN\") );"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02036'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - $dbc=0; - $qp_groupWAIT=''; - while ($sthArows > $dbc) - { - @aryA = $sthA->fetchrow_array; - $qp_groupWAIT_aco .= "'$aryA[0]',"; - if ($dbc > 0) - { - $qp_groupWAIT .= "and "; - } - $qp_groupWAIT .= "closer_campaigns NOT LIKE \"% $aryA[0] %\" "; - $dbc++; - } - if (length($qp_groupWAIT_aco)>2) - {chop($qp_groupWAIT_aco);} - else - { - $qp_groupWAIT_aco="''"; - $qp_groupWAIT = "closer_campaigns != ''"; - } - - $qp_groupWAIT_SQL = "and ($qp_groupWAIT)"; - $qp_groupWAIT_aco_SQL = "and vicidial_live_inbound_agents.group_id NOT IN($qp_groupWAIT_aco)"; - $qp_groupWAIT_camp_SQL = "and campaign_id NOT IN($qp_groupWAIT_aco)"; - - $sthA->finish(); - } - - if ( ($aco_sub>0) || ($AGENTgrab > 0) ) - { - $stmtA = "LOCK TABLES vicidial_live_agents WRITE, vicidial_live_inbound_agents WRITE;"; - my $LOCKaffected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02037'; $MEL_aff_rows=$LOCKaffected_rows; &mysql_error_logging; - - if (length($qp_groupWAIT_aco)<2) - {$qp_groupWAIT_aco="''";} - ### Get list of users that should take higher priority inbound calls first - $stmtA = "SELECT distinct user from vicidial_live_inbound_agents where group_id IN($qp_groupWAIT_aco);"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02122'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - $dbc=0; - $vlia_users=''; - while ($sthArows > $dbc) - { - @aryA = $sthA->fetchrow_array; - $vlia_users .= "'$aryA[0]',"; - $dbc++; - } - if (length($vlia_users)>2) - {chop($vlia_users);} - else - {$vlia_users="''";} - - $stmtA = "SELECT vicidial_live_agents.conf_exten,vicidial_live_agents.user,vicidial_live_agents.extension,vicidial_live_agents.server_ip,vicidial_live_inbound_agents.group_weight,ra_user,vicidial_live_agents.campaign_id from vicidial_live_agents, vicidial_live_inbound_agents WHERE vicidial_live_agents.user=vicidial_live_inbound_agents.user and status IN('CLOSER','READY') and lead_id<1 and server_ip='$VARserver_ip' $ADUfindSQL and vicidial_live_inbound_agents.group_id='$channel_group' and last_update_time > '$BDtsSQLdate' and vicidial_live_agents.user NOT IN($vlia_users) $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02038'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $VDADconf_exten = $aryA[0]; - $VDADuser = $aryA[1]; - $VDADextension = $aryA[2]; - $VDADserver_ip = $aryA[3]; - $VDADgroup_weight = $aryA[4]; - $ra_user = $aryA[5]; - $log_campaign = $aryA[6]; - } - $sthA->finish(); - if ($AGILOG) {$agi_string = "$VDADuser|$VDADgroup_weight|$stmtA|"; &agi_output;} - - if ($AGENTgrab > 0) - { - $stmtA = "SELECT conf_exten,extension,server_ip,ra_user,campaign_id from vicidial_live_agents WHERE user='$AGENTuser';"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02111'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $VDADconf_exten = $aryA[0]; - $VDADextension = $aryA[1]; - $VDADuser = $AGENTuser; - $VDADserver_ip = $aryA[2]; - $ra_user = $aryA[3]; - $log_campaign = $aryA[4]; - } - $sthA->finish(); - } - if ($sthArows > 0) - { - $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$insert_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid',comments='INBOUND' where user='$VDADuser';"; - $Faffected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02039'; $MEL_aff_rows=$Faffected_rows; &mysql_error_logging; - } - else - { - $Faffected_rows=0; - } - $found_agents=$Faffected_rows; - - $stmtA = "UNLOCK TABLES;"; - $LOCKaffected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02040'; $MEL_aff_rows=$LOCKaffected_rows; &mysql_error_logging; - } - else - { - $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$insert_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid',comments='INBOUND' where status IN('CLOSER','READY') and lead_id<1 and server_ip='$VARserver_ip' and campaign_id IN($INBOUNDcampsSQL) and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $qp_groupWAIT_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; - $Faffected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02041'; $MEL_aff_rows=$Faffected_rows; &mysql_error_logging; - $found_agents=$Faffected_rows; - } - if ($AGILOG) {$agi_string = "-- VDAD get agent: |$DROP_TIME|$drop_timer|$hold_message_counter|$prompt_interval|$Faffected_rows|$channel_group|$found_agents|$moh_delay|$wait_prompt_runs|$stmtA|"; &agi_output;} - if ($found_agents > 0) - { - if ($aco_sub<1) - { - $cbc=0; - $stmtA = "SELECT conf_exten,user,extension,ra_user,campaign_id FROM vicidial_live_agents where status IN('QUEUE','INCALL') and server_ip='$VARserver_ip' and campaign_id IN($INBOUNDcampsSQL) and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02042'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - $rec_countCUSTDATA=0; - while ($sthArows > $cbc) - { - @aryA = $sthA->fetchrow_array; - $VDADconf_exten = $aryA[0]; - $VDADuser = $aryA[1]; - $VDADextension = $aryA[2]; - $ra_user = $aryA[3]; - $log_campaign = $aryA[4]; - - $cbc++; - } - $sthA->finish(); - } - - $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER', stage='CLOSER-$drop_timer' where callerid='$callerid';"; - $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02043'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) {$agi_string = "-- VDCL XFER : |$affected_rows|$callerid\n|$stmtA|"; &agi_output;} - if ($affected_rows < 1) - { - $stmtA = "INSERT INTO vicidial_auto_calls SET server_ip='$VARserver_ip',campaign_id='$channel_group',status='CLOSER',lead_id='$insert_lead_id',uniqueid='$uniqueid',callerid='$callerid',channel='$channel',phone_code='$phone_code',phone_number='$phone_number',call_time='$SQLdate',call_type='IN',stage='CLOSER-$drop_timer',queue_priority='$queue_priority' $adSQL;"; - $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02044'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - $stmtB = "select LAST_INSERT_ID() LIMIT 1;"; - $sthA = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtB ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $stmtA=$stmtB; $mysql_count='02126'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $auto_call_id = $aryA[0]; - } - $sthA->finish(); - if ($AGILOG) {$agi_string = "$affected_rows|VDAC-reinsert|$mysql_count|$auto_call_id|$stmtA|"; &agi_output;} - } - - if ($enable_queuemetrics_logging > 0) - { - $dataSQL=''; - $stmtA = "SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$log_campaign' and queuemetrics_phone_environment!='';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArowsCQPE=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02154'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - if ($sthArowsCQPE > 0) - { - @aryA = $sthA->fetchrow_array; - $dataSQL = ",data4='$aryA[0]'"; - } - $sthA->finish(); - if ($AGILOG) {$agi_string = "$sthArowsCQPE|$dataSQL|$stmtA|"; &agi_output;} - - $dbhB = DBI->connect("DBI:mysql:$queuemetrics_dbname:$queuemetrics_server_ip:3306", "$queuemetrics_login", "$queuemetrics_pass") - or die "Couldn't connect to database: " . DBI->errstr; - - if ($DBX) {print "CONNECTED TO DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} - $now_date_epoch = time(); - - $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='Agent/$VDADuser',verb='CONNECT',data1='$drop_timer',serverid='$queuemetrics_log_id' $data4SQL;"; - $Baffected_rows = $dbhB->do($stmtB); - $dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02045'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging; - - $QLabandon=0; - $stmtB="SELECT count(*) from queue_log where call_id='$YqueryCID' and verb='ABANDON';"; - if ($AGILOG) {$agi_string = "|$stmtB|"; &agi_output;} - $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; - $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; - $sthBrowsQLA=$sthB->rows; - if ($sthBrowsQLA > 0) - { - @aryB = $sthB->fetchrow_array; - $QLabandon = $aryB[0]; - } - $sthB->finish(); - if ( ($QLabandon > 0) && (length($callerid) > 15) ) - { - $stmtB = "DELETE FROM queue_log where call_id='$YqueryCID' and verb='ABANDON';"; - if ($AGILOG) {$agi_string = "Removing ABANDON queue_log entries for call $QLabandon|$YqueryCID"; &agi_output;} - $Baffected_rows = $dbhB->do($stmtB); - $dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02116'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging; - } - - $dbhB->disconnect(); - } - - if ($call_handle_method =~ /CLOSER|DIGITID$/) - { - $stmtA = "UPDATE vicidial_xfer_log set closer='$VDADuser' where lead_id = '$insert_lead_id' order by call_date desc limit 1;"; - $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02046'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) {$agi_string = "-- VDXL XFER vicidial_xfer_log update: |$affected_rows|$insert_lead_id|$VDADuser\n|$stmtA|"; &agi_output;} - } - - $stmtA = "UPDATE vicidial_closer_log set user='$VDADuser' where lead_id='$insert_lead_id' order by call_date desc limit 1;"; - $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02047'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) {$agi_string = "-- closer log : |$affected_rows|$insert_lead_id|$insert_close_id|\n|$stmtA|"; &agi_output;} - - ### if agent alert exten is not disabled, then trigger the alert and wait - if ( ($agent_alert_exten !~ /^X$/i) && (length($agent_alert_exten)>0) && ($no_delay_call_route !~ /Y/i) && ($VDADextension !~ /^R\//) ) - { - if ($agent_alert_exten =~ /^8304$/) - {$agent_alert_exten = 'ding';} - $VHqueryCID = "VH$CIDdate$VDADconf_exten"; - - ### insert a NEW record to the vicidial_manager table to play the alert message to the agent - $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$VARserver_ip','','Originate','$VHqueryCID','Exten: 83047777777777','Context: vicidial-auto','Channel: Local/$dtmf_silent_prefix$VDADconf_exten$at$ext_context','Priority: 1','Callerid: $agent_alert_exten','Timeout: 10','','','','')"; - $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02048'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) {$agi_string = "-- VDCL agent alert: |$VHqueryCID|7$VDADconf_exten|$channel|$agent_alert_exten|insert to vicidial_manager"; &agi_output;} - - usleep(1 * $agent_alert_delay * 1000); - } - - if ($AGILOG) {$agi_string = "exiting VDAD app, transferring call to $VDADconf_exten"; &agi_output;} - - if ($no_delay_call_route =~ /N/) - { - $AGI->stream_file('sip-silence'); # stop music-on-hold process - $AGI->stream_file('sip-silence'); - } - - ### update calls_today for vicidial_live_inbound_agents ### - $stmtA = "SELECT calls_today from vicidial_inbound_group_agents WHERE user='$VDADuser' and group_id='$channel_group';"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02049'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $calls_today = $aryA[0]; - $calls_today++; - } - $sthA->finish(); - - if ($sthArows > 0) - { - $stmtA = "UPDATE vicidial_live_inbound_agents set calls_today='$calls_today',last_call_time=NOW() WHERE user='$VDADuser' and group_id='$channel_group';"; - $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02050'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - $stmtA = "UPDATE vicidial_inbound_group_agents set calls_today='$calls_today' WHERE user='$VDADuser' and group_id='$channel_group';"; - $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02051'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) {$agi_string = "-- VDLIA agent calls: |$calls_today|$VDADuser|$channel_group|"; &agi_output;} - } - - &trigger_transfer_process; - - if ($no_delay_call_route !~ /Y/i) - {usleep(1*500*1000);} - - ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); - $year = ($year + 1900); - $mon++; - if ($mon < 10) {$mon = "0$mon";} - if ($mday < 10) {$mday = "0$mday";} - if ($hour < 10) {$hour = "0$hour";} - if ($min < 10) {$min = "0$min";} - if ($sec < 10) {$sec = "0$sec";} - - ### BEGIN REMOTE AGENT SECTION - if ($VDADextension =~ /^R\//) - { - ### set the callerid to the ACQS value(calleridname) - ## use these two lines for Asterisk 1.2 tree - $newcallerid = "\"$callerid <$phone_number>\""; - $AGI->set_callerid($newcallerid); - ## use these two lines for Asterisk 1.0 tree - # print "SET CALLERID \"$calleridname\" <0000000000>\n"; - # print "SET CALLERIDNAME \"$calleridname\"\n"; - ### custom change to allow exten to be sent as phone*vendor_id - if ($VDADconf_exten =~ /888888888888/) - { - $VDADconf_exten = "$phone_number$S$vendor_id"; - } - - if (length($ra_user) > 0) - { - $extension_group=''; - $stmtA = "SELECT extension_group,extension_group_order FROM vicidial_remote_agents where user_start='$ra_user';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='01131'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $extension_group = $aryA[0]; - $extension_group_order = $aryA[1]; - } - $sthA->finish(); - if ( (length($extension_group) > 0) and ($extension_group !~ /^NONE/) ) - { - $extension_group_orderSQL = 'order by last_call_time'; - if ($extension_group_order =~ /RANK/) - {$extension_group_orderSQL = 'order by rank desc, last_call_time';} - if ($extension_group_order =~ /CALL_COUNT/) - {$extension_group_orderSQL = 'order by call_count_today, last_call_time';} - $stmtA = "UPDATE vicidial_extension_groups set last_callerid='$callerid',last_call_time=NOW(),call_count_today=(call_count_today + 1) where extension_group_id='$extension_group' and ( (campaign_groups='') or (campaign_groups LIKE \"%|$channel_group|%\") ) $extension_group_orderSQL limit 1;"; - $VEGaffected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='01132'; $MEL_aff_rows=$VEGaffected_rows; &mysql_error_logging; - if ($AGILOG) {$agi_string = "-- REMOTE EXTEN GROUP : |$VEGaffected_rows|update of veg table: $callerid\n|$stmtA|"; &agi_output;} - if ($VEGaffected_rows > 0) - { - $stmtA = "SELECT extension,extension_id,call_count_today FROM vicidial_extension_groups where last_callerid='$callerid' order by last_call_time desc limit 1;"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='01133'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $VDADconf_exten = $aryA[0]; - - if ($AGILOG) {$agi_string = "-- REMOTE EXTEN SET : |$VDADconf_exten|$aryA[1]|$aryA[2]|"; &agi_output;} - } - $sthA->finish(); - } - } - } - print STDERR "Setting CID \"$newcallerid\"\n"; - checkresult($result); - - $stmtA = "UPDATE vicidial_live_agents set ra_extension='$VDADconf_exten' where extension='$VDADextension' and ra_user='$ra_user';"; - $rVLAaffected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='01140'; $MEL_aff_rows=$rVLAaffected_rows; &mysql_error_logging; - - $stmtA = "UPDATE vicidial_auto_calls set extension='$VDADconf_exten' where callerid='$callerid';"; - $rVACaffected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='01141'; $MEL_aff_rows=$rVACaffected_rows; &mysql_error_logging; - - $stmtA = "INSERT INTO vicidial_remote_agent_log set callerid='$callerid',uniqueid='$uniqueid',ra_user='$ra_user',user='$VDADuser',call_time=NOW(),extension='$VDADconf_exten',lead_id='$insert_lead_id',phone_number='$phone_number',campaign_id='$channel_group',processed='N';"; - $RALaffected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='01137'; $MEL_aff_rows=$RALaffected_rows; &mysql_error_logging; - if ($AGILOG) {$agi_string = "-- REMOTE EXTEN LOG : |$RALaffected_rows|CID changed: \"$callerid\" \<$phone_number\>\n|$stmtA|"; &agi_output;} - } - ### END REMOTE AGENT SECTION - else - { - if ($extension_appended_cidname =~ /Y/) - { - $eac_cbc=0; - $stmtA = "SELECT extension FROM vicidial_live_agents where user='$VDADuser' order by last_call_time limit 1;"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02148'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - while ($sthArows > $eac_cbc) - { - @aryA = $sthA->fetchrow_array; - $eac_extension = $aryA[0]; - $eac_extension =~ s/SIP\/|IAX2\/|Zap\/|DAHDI\/|Local\///gi; - $eac_cbc++; - } - $sthA->finish(); - - $newcallerid = "\"$callerid $eac_extension <$phone_number>\""; - $AGI->set_callerid($newcallerid); - } - } - - $stmtA = "UPDATE vicidial_closer_log set queue_seconds='$drop_timer' where lead_id = '$insert_lead_id' and call_date='$SQLdate';"; - $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02052'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) {$agi_string = "-- VDCL vcl update: |$affected_rows|$insert_lead_id|$insert_close_id|\n|$stmtA|"; &agi_output;} - - $AGI->stream_file('sip-silence'); - $AGI->stream_file('sip-silence'); - $AGI->stream_file('sip-silence'); - $AGI->stream_file('sip-silence'); - - print "SET CONTEXT $ext_context\n"; - checkresult($result); - print "SET EXTENSION $VDADconf_exten\n"; - checkresult($result); - print "SET PRIORITY 1\n"; - checkresult($result); - - $dbhA->disconnect(); - - $now_date_epoch = time(); - $now_date = "$year-$mon-$mday $hour:$min:$sec"; - if ($AGILOG) {$agi_string = "XXXXX VDAD transferred: start|stop $start_time|$now_date|$VDADconf_exten"; &agi_output;} - - exit; - } - else - { - if ($AGILOG) {$agi_string = "NNNNN No available local agent found"; &agi_output;} - } - } - else - { - ### For Debugging purposes display the call ahead of this call - if ( ($rec_countWAIT == '1') && ($drop_timer > 2) && ($AGILOG) ) - { - $stmtA = "SELECT call_time,campaign_id,last_update_time,callerid,status,channel FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$VARserver_ip' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$insert_lead_id';"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02053'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - $r=0; - $agi_string="\n"; - while ($sthArows > $r) - { - @aryA = $sthA->fetchrow_array; - $agi_string .= "|$aryA[0]|$aryA[1]|$aryA[2]|$aryA[3]|$aryA[4]|$aryA[5]|\n"; - $r++; - } - $sthA->finish(); - &agi_output; - } - if ($AGILOG) {$agi_string = "WWWWW VDAD XFER LOCAL WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|$drop_timer|"; &agi_output;} - } - } - - if ($agent_search_method =~ /^LO|^LB/) { ################################################################################################### @@ -2360,53 +1871,99 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) ) $sthA->finish(); } - if ( ($aco_sub>0) || ($AGENTgrab > 0) ) + if ( ($CAMP_callorder !~ /ring_all$/i) || ($AGENTgrab > 0) ) { - $stmtA = "LOCK TABLES vicidial_live_agents WRITE, vicidial_live_inbound_agents WRITE;"; - my $LOCKaffected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02057'; $MEL_aff_rows=$LOCKaffected_rows; &mysql_error_logging; - - if (length($qp_groupWAIT_aco)<2) - {$qp_groupWAIT_aco="''";} - ### Get list of users that should take higher priority inbound calls first - $stmtA = "SELECT distinct user from vicidial_live_inbound_agents where group_id IN($qp_groupWAIT_aco);"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02123'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - $dbc=0; - $vlia_users=''; - while ($sthArows > $dbc) + if ($aco_sub > 0) { - @aryA = $sthA->fetchrow_array; - $vlia_users .= "'$aryA[0]',"; - $dbc++; + ### BEGIN in-group-rank-based next-agent-call processing ### + $stmtA = "LOCK TABLES vicidial_live_agents WRITE, vicidial_live_inbound_agents WRITE;"; + my $LOCKaffected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='02057'; $MEL_aff_rows=$LOCKaffected_rows; &mysql_error_logging; + + if (length($qp_groupWAIT_aco)<2) + {$qp_groupWAIT_aco="''";} + ### Get list of users that should take higher priority inbound calls first + $stmtA = "SELECT distinct user from vicidial_live_inbound_agents where group_id IN($qp_groupWAIT_aco);"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $dbhP=$dbhA; $mysql_count='02123'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + $dbc=0; + $vlia_users=''; + while ($sthArows > $dbc) + { + @aryA = $sthA->fetchrow_array; + $vlia_users .= "'$aryA[0]',"; + $dbc++; + } + if (length($vlia_users)>2) + {chop($vlia_users);} + else + {$vlia_users="''";} + + ### if ringing an agent, do not look for one, else, look for one + if ($RING_agent > 0) + {$sthArows=0;} + else + { + $stmtA = "SELECT vicidial_live_agents.conf_exten,vicidial_live_agents.user,vicidial_live_agents.extension,vicidial_live_agents.server_ip,vicidial_live_inbound_agents.group_weight,ra_user,vicidial_live_agents.campaign_id,on_hook_agent,on_hook_ring_time from vicidial_live_agents vicidial_live_inbound_agents WHERE vicidial_live_agents.user=vicidial_live_inbound_agents.user and status IN('CLOSER','READY') and lead_id<1 $ADUfindSQL and vicidial_live_inbound_agents.group_id='$channel_group' and last_update_time > '$BDtsSQLdate' and vicidial_live_agents.user NOT IN($ring_no_answer_agents$vlia_users) and ring_callerid='' $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $dbhP=$dbhA; $mysql_count='02058'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $VDADconf_exten = $aryA[0]; + $VDADuser = $aryA[1]; + $VDADextension = $aryA[2]; + $VDADserver_ip = $aryA[3]; + $VDADgroup_weight = $aryA[4]; + $ra_user = $aryA[5]; + $log_campaign = $aryA[6]; + $VDADon_hook_agent = $aryA[7]; + $VDADon_hook_ring_time = $aryA[8]; + } + $sthA->finish(); + if ($AGILOG) {$agi_string = "$VDADuser|$VDADgroup_weight|$stmtA|"; &agi_output;} + } + ### END in-group-rank-based next-agent-call processing ### } - if (length($vlia_users)>2) - {chop($vlia_users);} else - {$vlia_users="''";} - - $stmtA = "SELECT vicidial_live_agents.conf_exten,vicidial_live_agents.user,vicidial_live_agents.extension,vicidial_live_agents.server_ip,vicidial_live_inbound_agents.group_weight,ra_user,vicidial_live_agents.campaign_id from vicidial_live_agents, vicidial_live_inbound_agents WHERE vicidial_live_agents.user=vicidial_live_inbound_agents.user and status IN('CLOSER','READY') and lead_id<1 $ADUfindSQL and vicidial_live_inbound_agents.group_id='$channel_group' and last_update_time > '$BDtsSQLdate' and vicidial_live_agents.user NOT IN($vlia_users) $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $rec_countCUSTDATA=0; - $dbhP=$dbhA; $mysql_count='02058'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - - if ($sthArows > 0) { - @aryA = $sthA->fetchrow_array; - $VDADconf_exten = $aryA[0]; - $VDADuser = $aryA[1]; - $VDADextension = $aryA[2]; - $VDADserver_ip = $aryA[3]; - $VDADgroup_weight = $aryA[4]; - $ra_user = $aryA[5]; - $log_campaign = $aryA[6]; + ### BEGIN standard next-agent-call processing ### + $stmtA = "LOCK TABLES vicidial_live_agents WRITE;"; + my $LOCKaffected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='02158'; $MEL_aff_rows=$LOCKaffected_rows; &mysql_error_logging; + + ### if ringing an agent, do not look for one, else, look for one + if ($RING_agent > 0) + {$sthArows=0;} + else + { + $stmtA = "SELECT conf_exten,user,extension,server_ip,last_call_time,ra_user,campaign_id,on_hook_agent,on_hook_ring_time FROM vicidial_live_agents where status IN('CLOSER','READY') and lead_id<1 $ADUfindSQL and campaign_id IN($INBOUNDcampsSQL) and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' and vicidial_live_agents.user NOT IN($ring_no_answer_agents'') $qp_groupWAIT_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $dbhP=$dbhA; $mysql_count='02159'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $VDADconf_exten = $aryA[0]; + $VDADuser = $aryA[1]; + $VDADextension = $aryA[2]; + $VDADserver_ip = $aryA[3]; + $VDADlast_call_time = $aryA[4]; + $ra_user = $aryA[5]; + $log_campaign = $aryA[6]; + $VDADon_hook_agent = $aryA[7]; + $VDADon_hook_ring_time = $aryA[8]; + } + $sthA->finish(); + if ($AGILOG) {$agi_string = "$VDADuser|$VDADlast_call_time|$stmtA|"; &agi_output;} + } + ### END standard next-agent-call processing ### } - $sthA->finish(); - if ($AGILOG) {$agi_string = "$VDADuser|$VDADgroup_weight|$stmtA|"; &agi_output;} if ($AGENTgrab > 0) { @@ -2425,14 +1982,43 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) ) $VDADserver_ip = $aryA[2]; $ra_user = $aryA[3]; $log_campaign = $aryA[4]; + $VDADon_hook_agent = 'N'; + $VDADon_hook_ring_time=0; + $RING_agent=0; + $ring_all_timer=1; + if (length($AGENTextension) > 1) + { + if ($AGILOG) {$agi_string = "AGENT GRAB EXTENSION OVERRIDE: |$VDADconf_exten|$AGENTextension|"; &agi_output;} + $VDADconf_exten = $AGENTextension; + } } $sthA->finish(); } if ($sthArows > 0) { - $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$insert_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid', call_server_ip='$VARserver_ip',comments='INBOUND' where user='$VDADuser';"; - $Faffected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02059'; $MEL_aff_rows=$Faffected_rows; &mysql_error_logging; + if ( ($VDADon_hook_agent == 'Y') && ($AGENTgrab < 1) ) + { + $Faffected_rows = 0; + $RING_agent++; + $stmtA = "UPDATE vicidial_live_agents set ring_callerid='$callerid' where user='$VDADuser';"; + $RAFaffected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='02160'; $MEL_aff_rows=$RAFaffected_rows; &mysql_error_logging; + + if ($AGILOG) {$agi_string = "ON-HOOK-AGENT UPDATE: |$stmtA|$RING_agent|"; &agi_output;} + + $ring_no_answer_agents .= "'$VDADuser',"; # do not send calls to this agent again, unless no others available + } + else + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$insert_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid', call_server_ip='$VARserver_ip',comments='INBOUND',ring_callerid='' where user='$VDADuser';"; + $Faffected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='02059'; $MEL_aff_rows=$Faffected_rows; &mysql_error_logging; + + ### clear the ringing hold on the ring agents + $stmtA = "UPDATE vicidial_live_agents SET ring_callerid='' where ring_callerid='$callerid';"; + $CRHaffected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='02161'; $MEL_aff_rows=$CRHaffected_rows; &mysql_error_logging; + } } else { @@ -2444,41 +2030,205 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) ) my $LOCKaffected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02060'; $MEL_aff_rows=$LOCKaffected_rows; &mysql_error_logging; } - else + + + if ( ( ($RING_agent > 0) || ($CAMP_callorder =~ /ring_all$/i) ) && ($AGENTgrab < 1) ) { - $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$insert_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid', call_server_ip='$VARserver_ip',comments='INBOUND' where status IN('CLOSER','READY') and lead_id<1 $ADUfindSQL and campaign_id IN($INBOUNDcampsSQL) and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $qp_groupWAIT_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; - $Faffected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02061'; $MEL_aff_rows=$Faffected_rows; &mysql_error_logging; - $found_agents=$Faffected_rows; - if ($AGILOG) {$agi_string = "$Faffected_rows|$stmtA|"; &agi_output;} + ### BEGIN ring-agent and ring-all processing ### + $TEMPon_hook_ring_time = $on_hook_ring_time; + $ring_agent_loop++; + + if ($ring_all_timer < 1) + { + $Faffected_rows=0; + ### BEGIN trigger call to all available agents back to agi-VDAD_RINGALL.agi script ### + if ($CAMP_callorder =~ /ring_all$/i) + { + ### gather all available agents phones information (don't call more than 50 phones at once) + $stmtA = "SELECT conf_exten,user,extension,server_ip,ra_user,on_hook_ring_time from vicidial_live_agents where status IN('CLOSER','READY') and on_hook_agent='Y' and lead_id<1 $ADUfindSQL and campaign_id IN($INBOUNDcampsSQL) and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $qp_groupWAIT_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 50;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArowsAR=$sthA->rows; + $dbhP=$dbhA; $mysql_count='02162'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + $ragp=0; + while ($sthArowsAR > $ragp) + { + @aryA = $sthA->fetchrow_array; + $ARconf_exten[$ragp] = $aryA[0]; + $ARuser[$ragp] = $aryA[1]; + $ARextension[$ragp] = $aryA[2]; + $ARserver_ip[$ragp] = $aryA[3]; + $ARra_user[$ragp] = $aryA[4]; + $ARon_hook_ring_time[$ragp] = $aryA[5]; + $AR_DIALstr[$ragp] = ''; + $ring_all_DIALstr[$ragp] = ''; + $ARdialplan_number[$ragp] = ''; + $ragp++; + } + $sthA->finish(); + } + if ($RING_agent > 0) + { + $sthArowsAR=1; + $ragp=1; + $ARconf_exten[0] = $VDADconf_exten; + $ARuser[0] = $VDADuser; + $ARextension[0] = $VDADextension; + $ARserver_ip[0] = $VDADserver_ip; + $ARra_user[0] = $ra_user; + $ARon_hook_ring_time[0] = $VDADon_hook_ring_time; + $AR_DIALstr[0] = ''; + $ring_all_DIALstr[0] = ''; + $ARdialplan_number[0] = ''; + } + + $ragp=0; + while ($sthArowsAR > $ragp) + { + ### format the remote server dialstring to get the call to the agent + if($ARserver_ip[$ragp] =~ m/(\S+)\.(\S+)\.(\S+)\.(\S+)/ ) + { + $a = leading_zero($1); + $b = leading_zero($2); + $c = leading_zero($3); + $d = leading_zero($4); + $AR_DIALstr[$ragp] = "$a$S$b$S$c$S$d$S"; + } + + ### if a remote agent, find out where to ring + if ($ARextension[$ragp] =~ /^R\//) + { + if (length($ARra_user[$ragp]) > 0) + { + $extension_group=''; + $stmtA = "SELECT extension_group,extension_group_order FROM vicidial_remote_agents where user_start='$ARra_user[$ragp]';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $dbhP=$dbhA; $mysql_count='02163'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $extension_group = $aryA[0]; + $extension_group_order = $aryA[1]; + } + $sthA->finish(); + if ( (length($extension_group) > 0) and ($extension_group !~ /^NONE/) ) + { + $extension_group_orderSQL = 'order by last_call_time'; + if ($extension_group_order =~ /RANK/) + {$extension_group_orderSQL = 'order by rank desc, last_call_time';} + if ($extension_group_order =~ /CALL_COUNT/) + {$extension_group_orderSQL = 'order by call_count_today, last_call_time';} + $stmtA = "UPDATE vicidial_extension_groups set last_callerid='$callerid',last_call_time=NOW(),call_count_today=(call_count_today + 1) where extension_group_id='$extension_group' and ( (campaign_groups='') or (campaign_groups LIKE \"%|$channel_group|%\") ) $extension_group_orderSQL limit 1;"; + $VEGaffected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='02164'; $MEL_aff_rows=$VEGaffected_rows; &mysql_error_logging; + # if ($AGILOG) {$agi_string = "-- REMOTE EXTEN GROUP : |$VEGaffected_rows|update of veg table: $callerid\n|$stmtA|"; &agi_output;} + if ($VEGaffected_rows > 0) + { + $stmtA = "SELECT extension,extension_id,call_count_today FROM vicidial_extension_groups where last_callerid='$callerid' order by last_call_time desc limit 1;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $dbhP=$dbhA; $mysql_count='02165'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $ARconf_exten[$ragp] = $aryA[0]; + $ARdialplan_number[$ragp] = $aryA[0]; + # if ($AGILOG) {$agi_string = "-- REMOTE EXTEN SET : |$VDADconf_exten|$aryA[1]|$aryA[2]|"; &agi_output;} + } + $sthA->finish(); + } + } + } + if (length($ARconf_exten[$ragp]) > 0) + {$ring_all_DIALstr[$ragp] = "Local/$AR_DIALstr[$ragp]$ARconf_exten[$ragp]" . '@default';} + } + else + { + $ARon_hook_ring_time[$ragp] = ($ARon_hook_ring_time[$ragp] - 2); # set ring timeout lower so it doesn't go to vmail + $phone_extension = $ARextension[$ragp]; + $phone_protocol = $ARextension[$ragp]; + $phone_extension =~ s/.*\///gi; + $phone_protocol =~ s/\/.*//gi; + $dialplan_number=''; + $stmtA = "SELECT dialplan_number FROM phones where extension='$phone_extension' and protocol='$phone_protocol' and server_ip='$ARserver_ip[$ragp]';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $dbhP=$dbhA; $mysql_count='02166'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $dialplan_number = $aryA[0]; + $ARdialplan_number[$ragp] = $aryA[0]; + } + if (length($dialplan_number) > 0) + {$ring_all_DIALstr[$ragp] = "Local/$AR_DIALstr[$ragp]$dialplan_number" . '@default';} + } + + ### set the ring time lower if the phones ring time is lower + if ( ($TEMPon_hook_ring_time > $ARon_hook_ring_time[$ragp]) && ($ARon_hook_ring_time[$ragp] > 0) ) + {$TEMPon_hook_ring_time = $ARon_hook_ring_time[$ragp];} + + $ragp++; + } + + $ring_all_timer = $TEMPon_hook_ring_time; + $commandTEMPon_hook_ring_time = ($TEMPon_hook_ring_time - 1); + $commandTEMPon_hook_ring_time .= "000"; + $ragp=0; + while ($sthArowsAR > $ragp) + { + ### if there are phones to call, and the dial string exists, send the commands + if (length($ring_all_DIALstr[$ragp]) > 7) + { + $RING_agent++; + $stmtA = "UPDATE vicidial_live_agents set ring_callerid='$callerid' where user='$ARuser[$ragp]';"; + $RAFaffected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='02167'; $MEL_aff_rows=$RAFaffected_rows; &mysql_error_logging; + + $RINGALLexten = "8331*$auto_call_id*$callerid*$ARuser[$ragp]*$ARdialplan_number[$ragp]"; + + $PADauto_call_id = sprintf("%011s", $auto_call_id); while (length($PADauto_call_id) > 11) {chop($PADauto_call_id);} + $RINGALLqueryCID = "RINGAGENT$PADauto_call_id"; + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$VARserver_ip','','Originate','$RINGALLqueryCID','Exten: $RINGALLexten','Context: default','Channel: $ring_all_DIALstr[$ragp]','Priority: 1','Callerid: $RINGALLqueryCID','Timeout: $commandTEMPon_hook_ring_time','','','','')"; + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='02168'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) {$agi_string = "RING-AGENT CALL SENT: |$RINGALLqueryCID|$RINGALLexten|$ragp|$TEMPon_hook_ring_time $channel|$callerid"; &agi_output;} + } + $ragp++; + } + ### END trigger call to all available agents back to agi-VDAD_RINGALL.agi script ### + } + else + { + if ($drop_timer < 2) + {$ring_all_timer = ($ring_all_timer - 0.25);} + else + {$ring_all_timer = ($ring_all_timer - 1);} + if ($ring_all_timer < 1) + { + $RING_agent=0; + ### clear the ringing hold on the ring agents + $stmtA = "UPDATE vicidial_live_agents SET ring_callerid='' where ring_callerid='$callerid';"; + $CRHaffected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='02169'; $MEL_aff_rows=$CRHaffected_rows; &mysql_error_logging; + } + if ($AGILOG) {$agi_string = "RING-AGENT TIMER: $ring_all_timer|$TEMPon_hook_ring_time|$on_hook_ring_time $channel|$callerid"; &agi_output;} + } + + ### END ring-agent and ring-all processing ### } + $found_agents=$Faffected_rows; + if ($AGILOG) {$agi_string = "-- VDAD get agent: |$DROP_TIME|$drop_timer|$hold_message_counter|$prompt_interval|$Faffected_rows|$found_agents|$moh_delay|$wait_prompt_runs|update of vla table: $channel_group|\n|$stmtA|"; &agi_output;} + + + ### if agent is found, prepare and send call to agent ### if ($found_agents > 0) { - if ($aco_sub<1) - { - $cbc=0; - $stmtA = "SELECT conf_exten,user,extension,server_ip,last_call_time,ra_user,campaign_id FROM vicidial_live_agents where status IN('QUEUE','INCALL') and campaign_id IN($INBOUNDcampsSQL) and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02062'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - $rec_countCUSTDATA=0; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $VDADconf_exten = $aryA[0]; - $VDADuser = $aryA[1]; - $VDADextension = $aryA[2]; - $VDADserver_ip = $aryA[3]; - $VDADlast_call_time = $aryA[4]; - $ra_user = $aryA[5]; - $log_campaign = $aryA[6]; - $cbc++; - } - $sthA->finish(); - if ($AGILOG) {$agi_string = "$VDADuser|$VDADlast_call_time|$stmtA|"; &agi_output;} - } $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER', stage='CLOSER-$drop_timer' where callerid='$callerid';"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02063'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; @@ -2640,7 +2390,7 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) ) if ($sec < 10) {$sec = "0$sec";} ### BEGIN REMOTE AGENT SECTION - if ($VDADextension =~ /^R\//) + if ( ($VDADextension =~ /^R\//) && (length($AGENTextension) < 2) ) { ### set the callerid to the ACQS value(calleridname) ## use these two lines for Asterisk 1.2 tree @@ -2771,6 +2521,8 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) ) else { if ($AGILOG) {$agi_string = "NNNNN No available balance agent found"; &agi_output;} + if ( ($ring_all_timer < 1) && ($ring_agent_loop < 1) ) + {$ring_no_answer_agents = "'',"; if ($AGILOG) {$agi_string = "ring_no_answer_agents reset"; &agi_output;}} } } else diff --git a/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi b/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi index 0b44d49b..3b7e1551 100644 --- a/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi +++ b/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi @@ -81,6 +81,7 @@ # 101207-0713 - Added fix for rare VDAC-entry-missing issue # 110213-0008 - Added scheduled callbacks custom statuses compatibility # 110224-1733 - Added compatibility with QM phone environment logging +# 110303-2316 - Added condition that would not allow calls to be sent to agent with ringing inbound call # $script = 'agi-VDAD_ALL_outbound.agi'; @@ -1536,7 +1537,7 @@ while ($drop_timer <= $DROP_TIME) if ($rec_countWAITIN > 0) { ### get a list of the in-groups that the READY agents are able to take calls from - $stmtA = "SELECT closer_campaigns,user FROM vicidial_live_agents where status = 'READY' and server_ip='$VARserver_ip' and lead_id<1 and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate';"; + $stmtA = "SELECT closer_campaigns,user FROM vicidial_live_agents where status = 'READY' and ring_callerid='' and server_ip='$VARserver_ip' and lead_id<1 and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate';"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1608,7 +1609,7 @@ while ($drop_timer <= $DROP_TIME) $rec_countWAIT = ($rec_countWAITOUT + $rec_countWAITIN); if ($rec_countWAIT < $concurrent_transfers) { - $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', call_server_ip='$VARserver_ip', callerid='$callerid',comments='AUTO' where status = 'READY' and lead_id<1 and server_ip='$VARserver_ip' and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', call_server_ip='$VARserver_ip', callerid='$callerid',comments='AUTO' where status = 'READY' and lead_id<1 and server_ip='$VARserver_ip' and ring_callerid='' and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='01035'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; @@ -1911,7 +1912,7 @@ while ($drop_timer <= $DROP_TIME) if ($rec_countWAITremIN > 0) { ### get a list of the in-groups that the READY agents are able to take calls from - $stmtA = "SELECT closer_campaigns,user FROM vicidial_live_agents where status = 'READY' and lead_id<1 and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate';"; + $stmtA = "SELECT closer_campaigns,user FROM vicidial_live_agents where status = 'READY' and lead_id<1 and ring_callerid='' and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate';"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1983,7 +1984,7 @@ while ($drop_timer <= $DROP_TIME) $rec_countWAITrem = ($rec_countWAITremOUT + $rec_countWAITremIN); if ($rec_countWAITrem < $concurrent_transfers) { - $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', call_server_ip='$VARserver_ip', callerid='$callerid',comments='AUTO' where status = 'READY' and lead_id<1 and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', call_server_ip='$VARserver_ip', callerid='$callerid',comments='AUTO' where status = 'READY' and lead_id<1 and ring_callerid='' and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='01042'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; diff --git a/agc_2-X/trunk/agi/agi-VDAD_RINGALL.agi b/agc_2-X/trunk/agi/agi-VDAD_RINGALL.agi new file mode 100644 index 00000000..82055959 --- /dev/null +++ b/agc_2-X/trunk/agi/agi-VDAD_RINGALL.agi @@ -0,0 +1,438 @@ +#!/usr/bin/perl +# +# agi-VDAD_RINGALL.agi version 2.4 +# +# NOTE: this script is used for on-hook agents to be connected to customer calls +# when they answer their ringing phones +# +# In the default dialplan context, this is set to the following: +# ; these are used for the ring_all function in VICIDIAL +# exten => _8331*.,1,Playback(sip-silence) +# exten => _8331*.,n,AGI(agi-VDAD_RINGALL.agi,${EXTEN}) +# exten => _8331*.,n,AGI(agi-VDAD_RINGALL.agi,${EXTEN}) +# exten => _8331*.,n,Hangup +# +# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 +# +# changes: +# 110303-2325 - First build +# + +$script = 'agi-VDAD_RINGALL.agi'; + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$mon++; +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +if ($hour < 10) {$hour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +$now_date_epoch = time(); +$now_date = "$year-$mon-$mday $hour:$min:$sec"; +$now_num = "$year$mon$mday$hour$min$sec"; +$S='*'; + +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; + +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) + {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} + if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) + {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} + if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) + {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} + if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) + {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} + if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) + {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} + if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; + } + + +if (!$VARDB_port) {$VARDB_port='3306';} +if (!$AGILOGfile) {$AGILOGfile = "$PATHlogs/agiout.$year-$mon-$mday";} + +use DBI; +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + +$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + +### Grab Server values from the database +$stmtA = "SELECT agi_output,ext_context FROM servers where server_ip = '$VARserver_ip';"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; +$rec_count=0; +while ($sthArows > $rec_count) + { + $AGILOG = '0'; + @aryA = $sthA->fetchrow_array; + $DBagi_output = $aryA[0]; + $ext_context = $aryA[1]; + if ($DBagi_output =~ /STDERR/) {$AGILOG = '1';} + if ($DBagi_output =~ /FILE/) {$AGILOG = '2';} + if ($DBagi_output =~ /BOTH/) {$AGILOG = '3';} + $rec_count++; + } +$sthA->finish(); + + +### begin parsing run-time options ### +$|=1; +while() + { + chomp; + last unless length($_); + if ($AGILOG) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( $calleridname =~ /\"/) {$calleridname =~ s/\"//gi;} + if ( (!$callerid) or ($callerid =~ /unknown/) or ( ($calleridname =~ /\d\d\d\d\d\d\d\d\d/) && (length($calleridname) > 16) ) ) + {$callerid = $calleridname;} + if ( ($callerid =~ / /) && (length($callerid) > 20) ) + {$callerid =~ s/ .*//gi;} + $calleridname = $callerid; + + if ($extension =~ /^8331\*\d/) + { + @EXTEN_vars = split(/\*/, $extension); + $auto_call_id = $EXTEN_vars[1]; + $call_callerid = $EXTEN_vars[2]; + $dial_user = $EXTEN_vars[3]; + $phone_exten = $EXTEN_vars[4]; + $channel_root = $channel; + $channel_root =~ s/\,.*//gi; + } + } + + +if ($AGILOG) {$agi_string = "AGI Environment Dump:"; &agi_output;} + +foreach $i (sort keys %AGI) + { + if ($AGILOG) {$agi_string = " -- $i = $AGI{$i}"; &agi_output;} + } + + +if ($AGILOG) {$agi_string = "AGI Variables: |$unique_id|$channel|$extension|$type|$callerid|$auto_call_id|"; &agi_output;} + +if ($AGILOG) {$agi_string = "RING-AGENT AGI STARTED"; &agi_output;} + + +### Hangup if Local/ channel, since these are usually invalid or voicemail +if ($channel =~ /^Local/) + { + $AGI->stream_file('sip-silence'); + $AGI->stream_file('sip-silence'); + $AGI->stream_file('sip-silence'); + if ($AGILOG) {$agi_string = "RING-ALL AGI Local Channel, exiting..."; &agi_output;} + exit; + } + + +### Check that the call exists, if not then buzz and hangup ### +$stmtA = "SELECT campaign_id,call_type,extension,phone_number,lead_id FROM vicidial_auto_calls where auto_call_id='$auto_call_id';"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$VACcount=$sthA->rows; +if ($VACcount > 0) + { + @aryA = $sthA->fetchrow_array; + $VAC_campaign_id = $aryA[0]; + $VAC_call_type = $aryA[1]; + $VAC_extension = $aryA[2]; + $VAC_phone_number = $aryA[3]; + $VAC_lead_id = $aryA[4]; + if ($AGILOG) {$agi_string = "-- VAC Call Found: |$callerid|$VAC_campaign_id|$VAC_call_type|$VAC_extension|$VAC_phone_number|$VAC_lead_id|$auto_call_id|"; &agi_output;} + $sthA->finish(); + } +else + { + if ($AGILOG) {$agi_string = "-- VAC Call Not Found, exiting: |$callerid|$auto_call_id|"; &agi_output;} + $AGI->stream_file('buzz'); + $AGI->hangup(); + exit; + } + + +### Check that the user exists in vicidial_live_agents, if not then buzz and hangup ### +$stmtA = "SELECT conf_exten,extension,server_ip,ra_user,campaign_id from vicidial_live_agents WHERE user='$dial_user' and status IN('READY','CLOSER');"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$VLAcount=$sthA->rows; +if ($VLAcount > 0) + { + @aryA = $sthA->fetchrow_array; + $VLAconf_exten = $aryA[0]; + $VLAextension = $aryA[1]; + $VLAserver_ip = $aryA[2]; + $VLAra_user = $aryA[3]; + $VLAcampaign_id = $aryA[4]; + if ($AGILOG) {$agi_string = "-- VLA Agent Found: |$callerid|$VLAconf_exten|$VLAextension|$VLAserver_ip|$VLAra_user|$VLAcampaign_id|$auto_call_id|"; &agi_output;} + $sthA->finish(); + } +else + { + if ($AGILOG) {$agi_string = "-- VLA Agent Not Found, exiting: |$callerid|$auto_call_id|$dial_user|"; &agi_output;} + $AGI->stream_file('buzz'); + $AGI->hangup(); + exit; + } + + +### Check that the call has not been grabbed already, if it has then buzz and hangup ### +$stmtA = "SELECT count(*) FROM vicidial_auto_calls where auto_call_id='$auto_call_id' and agent_grab='';"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$NAGcount=$sthA->rows; +if ($NAGcount > 0) + { + @aryA = $sthA->fetchrow_array; + $not_grabbed_count = $aryA[0]; + $sthA->finish(); + + if ($not_grabbed_count > 0) + { + if ($VLAextension =~ /^R\//) + { + ### BEGIN If remote agent, then reserve a vicidial_conferences session on their server to send the calls to ### + $stmtA="SELECT count(*) FROM vicidial_conferences where server_ip='$VLAserver_ip' and ((extension='') or (extension is null)) and conf_exten != '$VLAconf_exten';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $AVCcount=$sthA->rows; + if ($AVCcount > 0) + { + @aryA = $sthA->fetchrow_array; + $available_sessions = $aryA[0]; + $sthA->finish(); + if ($available_sessions > 0) + { + $stmtA="UPDATE vicidial_conferences set extension='3WAY_$dial_user', leave_3way='1', leave_3way_datetime='$now_date' where server_ip='$VLAserver_ip' and ((extension='') or (extension is null)) and conf_exten != '$VLAconf_exten' limit 1;"; + $AVCaffected_rows = $dbhA->do($stmtA); + if ($AVCaffected_rows) + { + + $stmtA="SELECT conf_exten from vicidial_conferences where server_ip='$VLAserver_ip' and extension='3WAY_$dial_user' and leave_3way_datetime='$now_date' and conf_exten != '$VLAconf_exten';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $SVCcount=$sthA->rows; + if ($SVCcount > 0) + { + @aryA = $sthA->fetchrow_array; + $VLAconf_exten = $aryA[0]; + $sthA->finish(); + if ($AGILOG) {$agi_string = "-- AVC Session Reserved: |$callerid|$auto_call_id|$dial_user|3WAY_$dial_user|$now_date|$VLAconf_exten|"; &agi_output;} + } + else + { + if ($AGILOG) {$agi_string = "-- AVC No Available Sessions(SELECT3), exiting: |$VLAserver_ip|$auto_call_id|$dial_user|$VLAextension$now_num|"; &agi_output;} + $AGI->stream_file('buzz'); + $AGI->hangup(); + exit; + } + } + else + { + if ($AGILOG) {$agi_string = "-- AVC No Available Sessions(UPDATE), exiting: |$VLAserver_ip|$auto_call_id|$dial_user|"; &agi_output;} + $AGI->stream_file('buzz'); + $AGI->hangup(); + exit; + } + } + else + { + if ($AGILOG) {$agi_string = "-- AVC No Available Sessions(SELECT2), exiting: |$VLAserver_ip|$auto_call_id|$dial_user|"; &agi_output;} + $AGI->stream_file('buzz'); + $AGI->hangup(); + exit; + } + } + else + { + if ($AGILOG) {$agi_string = "-- AVC No Available Sessions(SELECT), exiting: |$VLAserver_ip|$auto_call_id|$dial_user|"; &agi_output;} + $AGI->stream_file('buzz'); + $AGI->hangup(); + exit; + } + ### END If remote agent, then reserve a vicidial_conferences session on their server to send the calls to ### + } + + ### Try to grab the call for this agent, if already grabbed then buzz and hangup ### + $stmtA = "UPDATE vicidial_auto_calls SET agent_grab='$dial_user',agent_grab_extension='$VLAconf_exten' where auto_call_id='$auto_call_id' and agent_grab='';"; + $AGaffected_rows = $dbhA->do($stmtA); + if ($AGaffected_rows) + { + if ($AGILOG) {$agi_string = "-- VAC Call Grabbed: |$callerid|$auto_call_id|$dial_user|$AGaffected_rows|"; &agi_output;} + + ### send agent to their session ### + if($VLAserver_ip =~ m/(\S+)\.(\S+)\.(\S+)\.(\S+)/ ) + { + $a = leading_zero($1); + $b = leading_zero($2); + $c = leading_zero($3); + $d = leading_zero($4); + $VLA_DIALstr = "$a$S$b$S$c$S$d$S"; + } + $VLA_DIALstr .= "7$VLAconf_exten"; + + $AGI->stream_file('sip-silence'); + $AGI->stream_file('sip-silence'); + $AGI->stream_file('sip-silence'); + $AGI->stream_file('sip-silence'); + + if ($AGILOG) {$agi_string = "-- Ring-Agent Sending Call: |$callerid|$auto_call_id|$dial_user|$VLA_DIALstr|"; &agi_output;} + + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VLA_DIALstr\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + $dbhA->disconnect(); + + exit; + } + else + { + if ($AGILOG) {$agi_string = "-- VAC Call Already Grabbed(UPDATE2), exiting: |$callerid|$auto_call_id|$dial_user|$AGaffected_rows|"; &agi_output;} + $AGI->stream_file('buzz'); + $AGI->hangup(); + exit; + } + } + else + { + if ($AGILOG) {$agi_string = "-- VAC Call Already Grabbed(UPDATE), exiting: |$callerid|$auto_call_id|$dial_user|$AGaffected_rows|"; &agi_output;} + $AGI->stream_file('buzz'); + $AGI->hangup(); + exit; + } + } +else + { + if ($AGILOG) {$agi_string = "-- VAC Call Already Grabbed(SELECT), exiting: |$callerid|$auto_call_id|$dial_user|$AGaffected_rows|"; &agi_output;} + $AGI->stream_file('buzz'); + $AGI->hangup(); + exit; + } + + + + + + + + + + + + +if ($AGILOG) {$agi_string = "-- sleeping: |$callerid|$auto_call_id|"; &agi_output;} + +sleep(10); + +exit; + + +$dbhA->disconnect(); + + +$AGI->stream_file('sip-silence'); + +if ($AGILOG) {$agi_string = "-- Exiting Ring-Agent AGI: |$callerid|"; &agi_output;} + +exit; + + + + + +sub agi_output + { + if ($AGILOG >=2) + { + ### open the log file for writing ### + open(Lout, ">>$AGILOGfile") + || die "Can't open $AGILOGfile: $!\n"; + print Lout "$now_date|$script|$agi_string\n"; + close(Lout); + } + ### send to STDERR writing ### + if ( ($AGILOG == '1') || ($AGILOG == '3') ) + {print STDERR "$now_date|$script|$agi_string\n";} + $agi_string=''; + } + + +sub checkresult + { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) + { + $res =~ /result=(-?\d+)/; + if (!length($1)) + { + # print STDERR "FAIL ($res)\n"; + $fail++; + } + else + { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } + else + { + # print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } + } + + +sub leading_zero($) + { + $_ = $_[0]; + s/^(\d)$/0$1/; + s/^(\d\d)$/0$1/; + return $_; + } # End of the leading_zero() routine. diff --git a/agc_2-X/trunk/bin/AST_DB_territory_populate.pl b/agc_2-X/trunk/bin/AST_DB_territory_populate.pl new file mode 100644 index 00000000..42d8fb50 --- /dev/null +++ b/agc_2-X/trunk/bin/AST_DB_territory_populate.pl @@ -0,0 +1,116 @@ +#!/usr/bin/perl +# +# AST_DB_territory_populate.pl version 2.4 +# +# DESCRIPTION: +# OPTIONAL!!! CUSTOMIZE THIS SCRIPT FIRST!!! +# - populates the owner field with a territory based upon the state +# +# It is recommended that you run this program on the local Asterisk machine +# +# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 +# +# CHANGES +# 110305-0959 - first build +# + +### begin parsing run-time options ### +if (length($ARGV[0])>1) + { + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-debug/i) + { + $DB=1; # Debug flag, set to 0 for no debug messages, On an active system this will generate hundreds of lines of output per minute + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } + } +else + { + print "no command line options set\n"; + } +### end parsing run-time options ### + + +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; + +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) + {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} + if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) + {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} + if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) + {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} + if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) + {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} + if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) + {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} + if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; + } + +# Customized Variables +$server_ip = $VARserver_ip; # Asterisk server IP + +if (!$VARDB_port) {$VARDB_port='3306';} + +use DBI; + +$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + + +##### Populate the owner field with a new territory based upon the state + +$stmtA = "UPDATE vicidial_list SET owner=CONCAT('MUTO2822',state) where owner='' and list_id IN('1295','1298') and state!='' and state is NOT NULL;"; +if($DB){print STDERR "\n|$stmtA|\n";} +if (!$T) + { + $affected_rows = $dbhA->do($stmtA); + if($DB){print STDERR "\n|$affected_rows records changed|\n";} + } + + +$dbhA->disconnect(); + +exit; + diff --git a/agc_2-X/trunk/bin/AST_VDauto_dial.pl b/agc_2-X/trunk/bin/AST_VDauto_dial.pl index 209be28c..e2ccf548 100644 --- a/agc_2-X/trunk/bin/AST_VDauto_dial.pl +++ b/agc_2-X/trunk/bin/AST_VDauto_dial.pl @@ -98,6 +98,7 @@ # 110124-1134 - Small query fix for large queue_log tables # 110224-1408 - Fixed trunk reservation bug # 110224-1859 - Added compatibility with QM phone environment logging +# 110303-1710 - Added clearing of ring_callerid when vicidial_auto_calls deleted # @@ -1215,7 +1216,7 @@ while($one_day_interval > 0) $CLlead_id=''; $auto_call_id=''; $CLstatus=''; $CLcampaign_id=''; $CLphone_number=''; $CLphone_code=''; - $stmtA = "SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,call_type,UNIX_TIMESTAMP(last_update_time) FROM vicidial_auto_calls where callerid='$KLcallerid[$kill_vac]'"; + $stmtA = "SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,call_type,UNIX_TIMESTAMP(last_update_time) FROM vicidial_auto_calls where callerid='$KLcallerid[$kill_vac]';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1291,7 +1292,10 @@ while($one_day_interval > 0) $stmtA = "DELETE from vicidial_auto_calls where auto_call_id='$auto_call_id'"; $affected_rows = $dbhA->do($stmtA); - $event_string = "| dead call vac deleted|$auto_call_id|$CLlead_id|$KLcallerid[$kill_vac]|$end_epoch|$affected_rows|$KLchannel[$kill_vac]|$CLcall_type|$CLdial_timeout|$CLdrop_call_seconds|$call_timeout|$dialtime_log|$dialtime_catch|"; + $stmtA = "UPDATE vicidial_live_agents set ring_callerid='' where ring_callerid='$KLcallerid[$kill_vac]';"; + $affected_rowsX = $dbhA->do($stmtA); + + $event_string = "| dead call vac deleted|$auto_call_id|$CLlead_id|$KLcallerid[$kill_vac]|$end_epoch|$affected_rows|$KLchannel[$kill_vac]|$CLcall_type|$CLdial_timeout|$CLdrop_call_seconds|$call_timeout|$dialtime_log|$dialtime_catch|$affected_rowsX|"; &event_logger; $CLstage =~ s/LIVE|-//gi; @@ -1817,7 +1821,10 @@ while($one_day_interval > 0) $stmtA = "DELETE from vicidial_auto_calls where auto_call_id='$auto_call_id'"; $affected_rows = $dbhA->do($stmtA); - $event_string = "| M dead call vac deleted|$auto_call_id|$CLlead_id|$KLcallerid[$kill_vac]|$end_epoch|$affected_rows|$KLchannel[$kill_vac]|$CLcall_type|$CLlast_update_time < $XDtarget|"; + $stmtA = "UPDATE vicidial_live_agents set ring_callerid='' where ring_callerid='$KLcallerid[$kill_vac]';"; + $affected_rowsX = $dbhA->do($stmtA); + + $event_string = "| M dead call vac deleted|$auto_call_id|$CLlead_id|$KLcallerid[$kill_vac]|$end_epoch|$affected_rows|$KLchannel[$kill_vac]|$CLcall_type|$CLlast_update_time < $XDtarget|$affected_rowsX|"; &event_logger; } @@ -2116,10 +2123,13 @@ while($one_day_interval > 0) $rec_count=0; while ($sthArows > $rec_count) { - $stmtA = "DELETE from vicidial_auto_calls where auto_call_id='$auto_call_id'"; + $stmtA = "DELETE from vicidial_auto_calls where auto_call_id='$auto_call_id';"; $affected_rows = $dbhA->do($stmtA); - $event_string = "| lagged call vdac call DELETED $affected_rows|$BDtsSQLdate|$auto_call_id|$CLcallerid|$CLuniqueid|$CLphone_number|$CLstatus|"; + $stmtA = "UPDATE vicidial_live_agents set ring_callerid='' where ring_callerid='$CLcallerid';"; + $affected_rowsX = $dbhA->do($stmtA); + + $event_string = "| lagged call vdac call DELETED $affected_rows|$affected_rowsX|$BDtsSQLdate|$auto_call_id|$CLcallerid|$CLuniqueid|$CLphone_number|$CLstatus|"; &event_logger; if ( ($affected_rows > 0) && ($CLlead_id > 0) ) diff --git a/agc_2-X/trunk/bin/AST_VDremote_agents.pl b/agc_2-X/trunk/bin/AST_VDremote_agents.pl index ab108667..fc0872ae 100644 --- a/agc_2-X/trunk/bin/AST_VDremote_agents.pl +++ b/agc_2-X/trunk/bin/AST_VDremote_agents.pl @@ -39,6 +39,7 @@ # 110103-1230 - Added queuemetrics_loginout NONE option # 110124-1134 - Small query fix for large queue_log tables # 110224-1903 - Added compatibility with QM phone environment logging +# 110304-0007 - Added agent on-hook compatibility # ### begin parsing run-time options ### @@ -410,6 +411,8 @@ while($one_day_interval > 0) @DBremote_conf_exten=@MT; @DBremote_closer=@MT; @DBremote_random=@MT; + @DBon_hook_agent=@MT; + @DBon_hook_ring_time=@MT; @loginexistsRANDOM=@MT; @loginexistsALL=@MT; @VD_user=@MT; @@ -424,7 +427,7 @@ while($one_day_interval > 0) ############################################################################### ###### first, grab all of the ACTIVE remote agents information from the database ############################################################################### - $stmtA = "SELECT remote_agent_id,user_start,number_of_lines,server_ip,conf_exten,status,campaign_id,closer_campaigns FROM vicidial_remote_agents where status IN('ACTIVE') and server_ip='$server_ip' order by user_start;"; + $stmtA = "SELECT remote_agent_id,user_start,number_of_lines,server_ip,conf_exten,status,campaign_id,closer_campaigns,on_hook_agent,on_hook_ring_time FROM vicidial_remote_agents where status IN('ACTIVE') and server_ip='$server_ip' order by user_start;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -438,6 +441,8 @@ while($one_day_interval > 0) $conf_exten = $aryA[4]; $campaign_id = $aryA[6]; $closer_campaigns = $aryA[7]; + $on_hook_agent = $aryA[8]; + $on_hook_ring_time = $aryA[9]; $y=0; while ($y < $number_of_lines) @@ -456,6 +461,8 @@ while($one_day_interval > 0) } $DBremote_closer[$user_counter] = $closer_campaigns; $DBremote_random[$user_counter] = $random; + $DBon_hook_agent[$user_counter] = $on_hook_agent; + $DBon_hook_ring_time[$user_counter] = $on_hook_ring_time; $y++; $user_counter++; @@ -520,9 +527,12 @@ while($one_day_interval > 0) {$CAMPAIGN_autodial[$h] = 'N';} } $sthA->finish(); - + + $DBon_hook_agent[$user_counter] = $on_hook_agent; + $DBon_hook_ring_time[$user_counter] = $on_hook_ring_time; + ### check to see if the record exists and only needs random number update - $stmtA = "SELECT count(*) FROM vicidial_live_agents where user='$DBremote_user[$h]' and server_ip='$server_ip' and campaign_id='$DBremote_campaign[$h]' and conf_exten='$DBremote_conf_exten[$h]' and closer_campaigns='$DBremote_closer[$h]' and outbound_autodial='$CAMPAIGN_autodial[$h]';"; + $stmtA = "SELECT count(*) FROM vicidial_live_agents where user='$DBremote_user[$h]' and server_ip='$server_ip' and campaign_id='$DBremote_campaign[$h]' and conf_exten='$DBremote_conf_exten[$h]' and closer_campaigns='$DBremote_closer[$h]' and outbound_autodial='$CAMPAIGN_autodial[$h]' and on_hook_agent='$DBon_hook_agent[$h]' and on_hook_ring_time='$DBon_hook_ring_time[$h]';"; if ($DBX) {print STDERR "|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -557,7 +567,7 @@ while($one_day_interval > 0) if ($loginexistsALL[$h] > 0) { - $stmtA = "UPDATE vicidial_live_agents set random_id='$DBremote_random[$h]',campaign_id='$DBremote_campaign[$h]',conf_exten='$DBremote_conf_exten[$h]',closer_campaigns='$DBremote_closer[$h]',status='READY',last_state_change='$SQLdate',outbound_autodial='$CAMPAIGN_autodial[$h]' where user='$DBremote_user[$h]' and server_ip='$server_ip';"; + $stmtA = "UPDATE vicidial_live_agents set random_id='$DBremote_random[$h]',campaign_id='$DBremote_campaign[$h]',conf_exten='$DBremote_conf_exten[$h]',closer_campaigns='$DBremote_closer[$h]',status='READY',last_state_change='$SQLdate',outbound_autodial='$CAMPAIGN_autodial[$h]',on_hook_agent='$DBon_hook_agent[$h]',on_hook_ring_time='$DBon_hook_ring_time[$h]' where user='$DBremote_user[$h]' and server_ip='$server_ip';"; $affected_rows = $dbhA->do($stmtA); if ($DBX) {print STDERR "$DBremote_user[$h] ALL UPDATE: $affected_rows\n";} # if ($affected_rows>0) @@ -596,7 +606,7 @@ while($one_day_interval > 0) } $sthA->finish(); - $stmtA = "INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,campaign_id,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,channel,uniqueid,callerid,user_level,comments,last_state_change,outbound_autodial,ra_user) values('$DBremote_user[$h]','$server_ip','$DBremote_conf_exten[$h]','R/$DBremote_user[$h]','READY','$DBremote_campaign[$h]','$DBremote_random[$h]','$SQLdate','$FDtsSQLdate','$SQLdate','$DBremote_closer[$h]','','','','$DBuser_level[$h]','REMOTE','$SQLdate','$CAMPAIGN_autodial[$h]','$DBuser_start[$h]');"; + $stmtA = "INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,campaign_id,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,channel,uniqueid,callerid,user_level,comments,last_state_change,outbound_autodial,ra_user,on_hook_agent,on_hook_ring_time) values('$DBremote_user[$h]','$server_ip','$DBremote_conf_exten[$h]','R/$DBremote_user[$h]','READY','$DBremote_campaign[$h]','$DBremote_random[$h]','$SQLdate','$FDtsSQLdate','$SQLdate','$DBremote_closer[$h]','','','','$DBuser_level[$h]','REMOTE','$SQLdate','$CAMPAIGN_autodial[$h]','$DBuser_start[$h]','$DBon_hook_agent[$h]','$DBon_hook_ring_time[$h]');"; $affected_rows = $dbhA->do($stmtA); if ($DBX) {print STDERR "$DBremote_user[$h] NEW INSERT\n";} if ($TESTrun > 0) diff --git a/agc_2-X/trunk/bin/FastAGI_log.pl b/agc_2-X/trunk/bin/FastAGI_log.pl index 4cd59941..6199574a 100644 --- a/agc_2-X/trunk/bin/FastAGI_log.pl +++ b/agc_2-X/trunk/bin/FastAGI_log.pl @@ -59,6 +59,7 @@ # 101111-1556 - Added source to vicidial_hopper inserts # 101123-0443 - Fixed minor parked call manual dial bug # 110224-1854 - Added compatibility with QM phone environment logging +# 110304-0005 - Small changes for CPD and on-hook agent features # # defaults for PreFork @@ -771,40 +772,46 @@ sub process_request if ($channel =~ /^Local/) { $CPDfound=0; - ############################################################## - ### BEGIN - CPD Look for result for B/DC calls - ############################################################## - $stmtA = "SELECT result FROM vicidial_cpd_log where callerid='$callerid' and result NOT IN('Voice','Unknown','???','') order by cpd_id desc limit 1;"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $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; - $cpd_result = $aryA[0]; - $sthA->finish(); - if ($cpd_result =~ /Busy/i) {$VDL_status='CPDB'; $VDAC_status='BUSY'; $CPDfound++;} - if ($cpd_result =~ /Unknown/i) {$VDL_status='CPDUK'; $VDAC_status='NA'; $CPDfound++;} - if ($cpd_result =~ /All-Trunks-Busy/i) {$VDL_status='CPDATB'; $VDAC_status='CONGESTION'; $CPDfound++;} - if ($cpd_result =~ /No-Answer/i) {$VDL_status='CPDNA'; $VDAC_status='NA'; $CPDfound++;} - if ($cpd_result =~ /Reject/i) {$VDL_status='CPDREJ'; $VDAC_status='DISCONNECT'; $CPDfound++;} - if ($cpd_result =~ /Invalid-Number/i) {$VDL_status='CPDINV'; $VDAC_status='DISCONNECT'; $CPDfound++;} - if ($cpd_result =~ /Service-Unavailable/i) {$VDL_status='CPDSUA'; $VDAC_status='CONGESTION'; $CPDfound++;} - if ($cpd_result =~ /Sit-Intercept/i) {$VDL_status='CPDSI'; $VDAC_status='DISCONNECT'; $CPDfound++;} - if ($cpd_result =~ /Sit-No-Circuit/i) {$VDL_status='CPDSNC'; $VDAC_status='CONGESTION'; $CPDfound++;} - if ($cpd_result =~ /Sit-Reorder/i) {$VDL_status='CPDSR'; $VDAC_status='CONGESTION'; $CPDfound++;} - if ($cpd_result =~ /Sit-Unknown/i) {$VDL_status='CPDSUK'; $VDAC_status='CONGESTION'; $CPDfound++;} - if ($cpd_result =~ /Sit-Vacant/i) {$VDL_status='CPDSV'; $VDAC_status='CONGESTION'; $CPDfound++;} - if ($cpd_result =~ /\?\?\?/i) {$VDL_status='CPDERR'; $VDAC_status='NA'; $CPDfound++;} - if ($cpd_result =~ /Fax|Modem/i) {$VDL_status='AFAX'; $VDAC_status='FAX'; $CPDfound++;} - if ($cpd_result =~ /Answering-Machine/i) {$VDL_status='AA'; $VDAC_status='AMD'; $CPDfound++;} - } - $sthA->finish(); - ############################################################## - ### END - CPD Look for result for B/DC calls - ############################################################## + # V2251502010052435563 + if ($callerid =~ /^V\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) + { + ############################################################## + ### BEGIN - CPD Look for result for B/DC calls + ############################################################## + sleep(1); + + $stmtA = "SELECT result FROM vicidial_cpd_log where callerid='$callerid' and result NOT IN('Voice','Unknown','???','') order by cpd_id desc limit 1;"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $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; + $cpd_result = $aryA[0]; + $sthA->finish(); + if ($cpd_result =~ /Busy/i) {$VDL_status='CPDB'; $VDAC_status='BUSY'; $CPDfound++;} + if ($cpd_result =~ /Unknown/i) {$VDL_status='CPDUK'; $VDAC_status='NA'; $CPDfound++;} + if ($cpd_result =~ /All-Trunks-Busy/i) {$VDL_status='CPDATB'; $VDAC_status='CONGESTION'; $CPDfound++;} + if ($cpd_result =~ /No-Answer/i) {$VDL_status='CPDNA'; $VDAC_status='NA'; $CPDfound++;} + if ($cpd_result =~ /Reject/i) {$VDL_status='CPDREJ'; $VDAC_status='DISCONNECT'; $CPDfound++;} + if ($cpd_result =~ /Invalid-Number/i) {$VDL_status='CPDINV'; $VDAC_status='DISCONNECT'; $CPDfound++;} + if ($cpd_result =~ /Service-Unavailable/i) {$VDL_status='CPDSUA'; $VDAC_status='CONGESTION'; $CPDfound++;} + if ($cpd_result =~ /Sit-Intercept/i) {$VDL_status='CPDSI'; $VDAC_status='DISCONNECT'; $CPDfound++;} + if ($cpd_result =~ /Sit-No-Circuit/i) {$VDL_status='CPDSNC'; $VDAC_status='CONGESTION'; $CPDfound++;} + if ($cpd_result =~ /Sit-Reorder/i) {$VDL_status='CPDSR'; $VDAC_status='CONGESTION'; $CPDfound++;} + if ($cpd_result =~ /Sit-Unknown/i) {$VDL_status='CPDSUK'; $VDAC_status='CONGESTION'; $CPDfound++;} + if ($cpd_result =~ /Sit-Vacant/i) {$VDL_status='CPDSV'; $VDAC_status='CONGESTION'; $CPDfound++;} + if ($cpd_result =~ /\?\?\?/i) {$VDL_status='CPDERR'; $VDAC_status='NA'; $CPDfound++;} + if ($cpd_result =~ /Fax|Modem/i) {$VDL_status='AFAX'; $VDAC_status='FAX'; $CPDfound++;} + if ($cpd_result =~ /Answering-Machine/i) {$VDL_status='AA'; $VDAC_status='AMD'; $CPDfound++;} + } + $sthA->finish(); + ############################################################## + ### END - CPD Look for result for B/DC calls + ############################################################## + } if ( ($PRI =~ /^PRI$/) && ($callerid =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) && ( ( ($dialstatus =~ /BUSY/) || ( ($dialstatus =~ /CHANUNAVAIL/) && ($hangup_cause =~ /^1$|^28$/) ) ) || ($CPDfound > 0) )) { if ($CPDfound < 1) @@ -829,12 +836,10 @@ sub process_request if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $VDLaffected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- VDAD vicidial_log update: |$VDLaffected_rows|$uniqueid|$VDACuniqueid|"; &agi_output;} - - sleep(1); } else { - if ($AGILOG) {$agi_string = "-- VD_hangup Local DEBUG: |$PRI|$callerid|$dialstatus|$hangup_cause|"; &agi_output;} + if ($AGILOG) {$agi_string = "-- VD_hangup Local DEBUG: |$PRI|$callerid|$dialstatus|$hangup_cause|$CPDfound|$VDL_status|"; &agi_output;} } if ($AGILOG) {$agi_string = "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority"; &agi_output;} @@ -915,6 +920,9 @@ sub process_request $VACaffected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- VDAC record deleted: |$VACaffected_rows| |$VD_lead_id|$uniqueid|$VD_uniqueid|$VD_callerid|$VARserver_ip|$VD_status|"; &agi_output;} + $stmtA = "UPDATE vicidial_live_agents SET ring_callerid='' where ring_callerid='$callerid';"; + $VLACaffected_rows = $dbhA->do($stmtA); + ############################################# ##### START QUEUEMETRICS LOGGING LOOKUP ##### $stmtA = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; diff --git a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample index 3c7f39e5..c2fc82e1 100644 --- a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample +++ b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample @@ -325,7 +325,7 @@ exten => _86000[5-9]X,1,Meetme,${EXTEN}|F exten => _86000[5-9]X,n,Hangup exten => _8600[1-2]XX,1,Meetme,${EXTEN}|F exten => _8600[1-2]XX,n,Hangup -; quiet entry and leaving conferences for VICIDIAL (inbound announce and SendDTMF) +; quiet entry and leaving conferences for VICIDIAL (inbound announce, SendDTMF and ring-agent) exten => _78600XXX,1,Meetme,${EXTEN:1}|Fq exten => _78600XXX,n,Hangup ; quiet monitor-only extensions for meetme rooms (for room managers) @@ -378,6 +378,13 @@ exten => 8320,2,Hangup exten => _8320*.,1,AGI(VD_amd.agi,${EXTEN}-----YES) exten => _8320*.,2,Hangup +; these are used for the ring_all function in VICIDIAL +exten => _8331*.,1,Playback(sip-silence) +exten => _8331*.,n,AGI(agi-VDAD_RINGALL.agi,${EXTEN}) +exten => _8331*.,n,AGI(agi-VDAD_RINGALL.agi,${EXTEN}) +exten => _8331*.,n,Hangup + + ; use for selective CallerID hangup by area code(hard-coded) exten => 8352,1,AGI(agi-VDADselective_CID_hangup.agi,${EXTEN}) exten => 8352,2,Playback(safe_harbor) diff --git a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 index 205fd99f..47ce4213 100644 --- a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 +++ b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 @@ -329,7 +329,7 @@ exten => _86000[5-9]X,1,Meetme,${EXTEN}|F exten => _86000[5-9]X,n,Hangup exten => _8600[1-2]XX,1,Meetme,${EXTEN}|F exten => _8600[1-2]XX,n,Hangup -; quiet entry and leaving conferences for VICIDIAL (inbound announce and SendDTMF) +; quiet entry and leaving conferences for VICIDIAL (inbound announce, SendDTMF and ring-agent) exten => _78600XXX,1,Meetme,${EXTEN:1}|Fq exten => _78600XXX,n,Hangup ; quiet monitor-only extensions for meetme rooms (for room managers) @@ -382,6 +382,13 @@ exten => 8320,2,Hangup exten => _8320*.,1,AGI(VD_amd.agi,${EXTEN}-----YES) exten => _8320*.,2,Hangup +; these are used for the ring_all function in VICIDIAL +exten => _8331*.,1,Playback(sip-silence) +exten => _8331*.,n,AGI(agi-VDAD_RINGALL.agi,${EXTEN}) +exten => _8331*.,n,AGI(agi-VDAD_RINGALL.agi,${EXTEN}) +exten => _8331*.,n,Hangup + + ; use for selective CallerID hangup by area code(hard-coded) exten => 8352,1,AGI(agi-VDADselective_CID_hangup.agi,${EXTEN}) exten => 8352,2,Playback(safe_harbor) diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql index 6d794755..567da420 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -78,6 +78,7 @@ use_external_server_ip ENUM('Y','N') default 'N', codecs_list VARCHAR(100) default '', codecs_with_template ENUM('0','1') default '0', webphone_dialpad ENUM('Y','N','TOGGLE','TOGGLE_OFF') default 'Y', +on_hook_agent ENUM('Y','N') default 'N', index (server_ip), unique index extenserver (extension, server_ip) ); @@ -388,7 +389,10 @@ external_timer_action_destination VARCHAR(100) default '', index (random_id), index (last_call_time), index (last_update_time), -index (last_call_finish) +index (last_call_finish), +on_hook_agent ENUM('Y','N') default 'N', +on_hook_ring_time SMALLINT(5) default '15', +ring_callerid VARCHAR(20) default '' ); CREATE TABLE vicidial_auto_calls ( @@ -412,6 +416,7 @@ agent_only VARCHAR(20) default '', agent_grab VARCHAR(20) default '', queue_position SMALLINT(4) UNSIGNED default '1', extension VARCHAR(100) default '', +agent_grab_extension VARCHAR(100) default '', index (uniqueid), index (callerid), index (call_time), @@ -882,7 +887,7 @@ group_color VARCHAR(7), active ENUM('Y','N'), web_form_address TEXT, voicemail_ext VARCHAR(10), -next_agent_call ENUM('random','oldest_call_start','oldest_call_finish','overall_user_level','inbound_group_rank','campaign_rank','fewest_calls','fewest_calls_campaign','longest_wait_time') default 'longest_wait_time', +next_agent_call ENUM('random','oldest_call_start','oldest_call_finish','overall_user_level','inbound_group_rank','campaign_rank','fewest_calls','fewest_calls_campaign','longest_wait_time','ring_all') default 'longest_wait_time', fronter_display ENUM('Y','N') default 'Y', ingroup_script VARCHAR(10), get_call_launch ENUM('NONE','SCRIPT','WEBFORM','WEBFORMTWO','FORM') default 'NONE', @@ -976,7 +981,8 @@ calculate_estimated_hold_seconds SMALLINT(5) UNSIGNED default '0', add_lead_url TEXT, eht_minimum_prompt_filename VARCHAR(255) default '', eht_minimum_prompt_no_block ENUM('N','Y') default 'N', -eht_minimum_prompt_seconds SMALLINT(5) default '10' +eht_minimum_prompt_seconds SMALLINT(5) default '10', +on_hook_ring_time SMALLINT(5) default '15' ); CREATE TABLE vicidial_stations ( @@ -1000,7 +1006,9 @@ status ENUM('ACTIVE','INACTIVE') default 'INACTIVE', campaign_id VARCHAR(8), closer_campaigns TEXT, extension_group VARCHAR(20) default 'NONE', -extension_group_order VARCHAR(20) default 'NONE' +extension_group_order VARCHAR(20) default 'NONE', +on_hook_agent ENUM('Y','N') default 'N', +on_hook_ring_time SMALLINT(5) default '15' ); CREATE TABLE live_inbound_log ( @@ -2442,7 +2450,7 @@ ALTER TABLE vicidial_call_notes_archive MODIFY notesid INT(9) UNSIGNED NOT NULL; CREATE TABLE vicidial_lead_search_log_archive LIKE vicidial_lead_search_log; ALTER TABLE vicidial_lead_search_log_archive MODIFY search_log_id INT(9) UNSIGNED NOT NULL; -UPDATE system_settings SET db_schema_version='1263',db_schema_update_date=NOW(); +UPDATE system_settings SET db_schema_version='1264',db_schema_update_date=NOW(); GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@localhost; diff --git a/agc_2-X/trunk/extras/upgrade_2.4.sql b/agc_2-X/trunk/extras/upgrade_2.4.sql index f450ceca..078a3ba0 100644 --- a/agc_2-X/trunk/extras/upgrade_2.4.sql +++ b/agc_2-X/trunk/extras/upgrade_2.4.sql @@ -696,3 +696,18 @@ ALTER TABLE servers ADD active_twin_server_ip VARCHAR(15) default ''; UPDATE system_settings SET db_schema_version='1263',db_schema_update_date=NOW(); +ALTER TABLE vicidial_inbound_groups ADD on_hook_ring_time SMALLINT(5) default '15'; +ALTER TABLE vicidial_inbound_groups MODIFY next_agent_call ENUM('random','oldest_call_start','oldest_call_finish','overall_user_level','inbound_group_rank','campaign_rank','fewest_calls','fewest_calls_campaign','longest_wait_time','ring_all') default 'longest_wait_time'; + +ALTER TABLE vicidial_live_agents ADD on_hook_agent ENUM('Y','N') default 'N'; +ALTER TABLE vicidial_live_agents ADD on_hook_ring_time SMALLINT(5) default '15'; +ALTER TABLE vicidial_live_agents ADD ring_callerid VARCHAR(20) default ''; + +ALTER TABLE phones ADD on_hook_agent ENUM('Y','N') default 'N'; + +ALTER TABLE vicidial_remote_agents ADD on_hook_agent ENUM('Y','N') default 'N'; +ALTER TABLE vicidial_remote_agents ADD on_hook_ring_time SMALLINT(5) default '15'; + +ALTER TABLE vicidial_auto_calls ADD agent_grab_extension VARCHAR(100) default ''; + +UPDATE system_settings SET db_schema_version='1264',db_schema_update_date=NOW(); diff --git a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt index ba41c732..a33890a9 100644 --- a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt +++ b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt @@ -585,6 +585,17 @@ Callback Entry Time|| Callback Trigger Time|| Callback Comments|| To see information on one of the callbacks below, click on the INFO link. To call the customer back now, click on the DIAL link. If you click on a record below to dial it, it will be removed from the list|| +rings all available agents until one picks up the phone|| +NOTES: For ring_all, the agents that are using phones that have On Hook Agent enabled will have their phones ring and the first one to answer will receive the call and the information on the agent screen. Since ring_all ignores agent wait time and ranking and will call every agent that is available for the queue, we do not recommend using this method for large queues. When using ring_all, agents logged with phones that have the On Hook Agent disabled will have to use the Calls In Queue panel and click on the TAKE CALL link to take calls in queue. The amount of time the agents phone will ring for ring_all is set to the On-Hook Ring Time setting or the shortest ring time of the phones that will be called. We do not recommend using ring_all on high call volume queues, or queues with many agents. The ring_all method is intended to be used with only a few agents and on low call volume in-groups|| +This option is only used for agents that are logged in with phones that have the agent-on-hook feature enabled. This is the number of seconds that each call attempt to the agent will ring for until the system will wait one second and start ringing the available agent phones again. This field can be overridden if the agent phones are set to a lower ring time which may be necessary to prevent calls from being sent one phones voicemail. Default is 15|| +On-Hook Agent|| +On-Hook Ring Time|| +This option is only used for inbound calls going to this remote agent. This feature will call the remote agent and will not send the customer to the remote agent until the line is answered. Default is N for disabled|| +This option is only used when the On-Hook Agent field above is set to Y and then only for inbound calls coming to this remote agent. This is the number of seconds that each call attempt will ring to try to get an answer. It is recommended that you set this to a few seconds less than it takes for a call to be sent to voicemail. Default is 15|| +On-Hook Agent Login|| +This option is only used for inbound calls going to an agent logged in with this phone. This feature will call the agent and will not send the customer to the agents session until the line is answered. Default is N for disabled|| +This is a Phone On-Hook Agent|| +Maximum Ring Time|| ############################################################ MANAGER Manual diff --git a/agc_2-X/trunk/www/agc/api.php b/agc_2-X/trunk/www/agc/api.php index 8d55e43d..930465f5 100644 --- a/agc_2-X/trunk/www/agc/api.php +++ b/agc_2-X/trunk/www/agc/api.php @@ -2035,6 +2035,10 @@ if ($function == 'ra_call_control') $stmt = "DELETE from vicidial_auto_calls where callerid='$value';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); + + $stmt = "UPDATE vicidial_live_agents set ring_callerid='' where ring_callerid='$value';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); } } else diff --git a/agc_2-X/trunk/www/agc/vdc_db_query.php b/agc_2-X/trunk/www/agc/vdc_db_query.php index 7bc346a5..dbef4341 100644 --- a/agc_2-X/trunk/www/agc/vdc_db_query.php +++ b/agc_2-X/trunk/www/agc/vdc_db_query.php @@ -276,12 +276,13 @@ # 110222-2228 - Added owner restriction to agent lead search # 110224-1712 - Added compatibility with QM phone environment logging and QM pause code last call logging # 110225-1237 - Added scheduled callback lead info display to the lead info view function +# 110303-1616 - Added vicidial_log_extended logging for manual dial calls # -$version = '2.4-181'; -$build = '110225-1237'; +$version = '2.4-182'; +$build = '110303-1616'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=398; +$mysql_log_count=403; $one_mysql_log=0; require("dbconnect.php"); @@ -3054,6 +3055,11 @@ if ($ACTION == 'manDiaLlookCaLL') if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00293',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_live_agents set ring_callerid='' where ring_callerid='$MDnextCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00399',$user,$server_ip,$session_name,$one_mysql_log);} } } } @@ -3140,6 +3146,13 @@ if ($stage == "start") $user_group = trim("$row[0]"); } + ##### insert log into vicidial_log_extended for manual VICIDiaL call + $stmt="INSERT IGNORE INTO vicidial_log_extended SET uniqueid='$uniqueid',server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID',custom_call_id='' ON DUPLICATE KEY UPDATE server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00400',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsX = mysql_affected_rows($link); + $manualVLexists=0; $beginUNIQUEID = preg_replace("/\..*/","",$uniqueid); $stmt="SELECT count(*) from vicidial_log where lead_id='$lead_id' and user='$user' and phone_number='$phone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; @@ -3877,6 +3890,13 @@ if ($stage == "end") } } + ##### insert log into vicidial_log_extended for manual VICIDiaL call + $stmt="INSERT IGNORE INTO vicidial_log_extended SET uniqueid='$uniqueid',server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID',custom_call_id='' ON DUPLICATE KEY UPDATE server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00401',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsX = mysql_affected_rows($link); + ### check to see if the vicidial_log record exists, if not, insert it $manualVLexists=0; $beginUNIQUEID = preg_replace("/\..*/","",$uniqueid); @@ -5908,6 +5928,13 @@ if ($ACTION == 'updateDISPO') $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00215',$user,$server_ip,$session_name,$one_mysql_log);} + ##### insert log into vicidial_log_extended for manual VICIDiaL call + $stmt="INSERT IGNORE INTO vicidial_log_extended SET uniqueid='$FAKEcall_id',server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID',custom_call_id='' ON DUPLICATE KEY UPDATE server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00402',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsX = mysql_affected_rows($link); + $MAN_vl_insert++; } @@ -5915,6 +5942,11 @@ if ($ACTION == 'updateDISPO') if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00219',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_live_agents set ring_callerid='' where ring_callerid='$MDnextCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00403',$user,$server_ip,$session_name,$one_mysql_log);} } else { @@ -7193,7 +7225,9 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $vla_lead_wipeSQL=''; if ($ACTION == 'VDADready') {$vla_lead_wipeSQL = ",lead_id=0";} - $stmt="UPDATE vicidial_live_agents set status='$stage' $vla_lead_wipeSQL where user='$user' and server_ip='$server_ip';"; + if ($ACTION == 'VDADpause') + {$vla_ring_resetSQL = ",ring_callerid=''";} + $stmt="UPDATE vicidial_live_agents set status='$stage' $vla_lead_wipeSQL $vla_ring_resetSQL where user='$user' and server_ip='$server_ip';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00166',$user,$server_ip,$session_name,$one_mysql_log);} diff --git a/agc_2-X/trunk/www/agc/vicidial.php b/agc_2-X/trunk/www/agc/vicidial.php index 932bb749..c8af0fa2 100644 --- a/agc_2-X/trunk/www/agc/vicidial.php +++ b/agc_2-X/trunk/www/agc/vicidial.php @@ -338,12 +338,13 @@ # 110221-1251 - Changed statuses display to keep track of non-selectable statuses # 110224-1713 - Added compatibility with QM phone environment logging, QM pause code last call logging and active server twin check # 110225-1231 - Changed scheduled callbacks list to allow clicking to see lead info without dialing, and separate dial link +# 110303-2321 - Added notice of on-hook phone use, and ability to click 'ring' to call into session, minor queue_log fix # -$version = '2.4-315c'; -$build = '110225-1231'; +$version = '2.4-316c'; +$build = '110303-2321'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=71; +$mysql_log_count=72; $one_mysql_log=0; require("dbconnect.php"); @@ -1937,7 +1938,7 @@ else echo "\n"; } echo "Agent web client\n"; - $stmt="SELECT extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,messages,old_messages,protocol,local_gmt,ASTmgrUSERNAME,ASTmgrSECRET,login_user,login_pass,login_campaign,park_on_extension,conf_on_extension,VICIDIAL_park_on_extension,VICIDIAL_park_on_filename,monitor_prefix,recording_exten,voicemail_exten,voicemail_dump_exten,ext_context,dtmf_send_extension,call_out_number_group,client_browser,install_directory,local_web_callerID_URL,VICIDIAL_web_URL,AGI_call_logging_enabled,user_switching_enabled,conferencing_enabled,admin_hangup_enabled,admin_hijack_enabled,admin_monitor_enabled,call_parking_enabled,updater_check_enabled,AFLogging_enabled,QUEUE_ACTION_enabled,CallerID_popup_enabled,voicemail_button_enabled,enable_fast_refresh,fast_refresh_rate,enable_persistant_mysql,auto_dial_next_number,VDstop_rec_after_each_call,DBX_server,DBX_database,DBX_user,DBX_pass,DBX_port,DBY_server,DBY_database,DBY_user,DBY_pass,DBY_port,outbound_cid,enable_sipsak_messages,email,template_id,conf_override,phone_context,phone_ring_timeout,conf_secret,is_webphone,use_external_server_ip,codecs_list,webphone_dialpad from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + $stmt="SELECT extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,messages,old_messages,protocol,local_gmt,ASTmgrUSERNAME,ASTmgrSECRET,login_user,login_pass,login_campaign,park_on_extension,conf_on_extension,VICIDIAL_park_on_extension,VICIDIAL_park_on_filename,monitor_prefix,recording_exten,voicemail_exten,voicemail_dump_exten,ext_context,dtmf_send_extension,call_out_number_group,client_browser,install_directory,local_web_callerID_URL,VICIDIAL_web_URL,AGI_call_logging_enabled,user_switching_enabled,conferencing_enabled,admin_hangup_enabled,admin_hijack_enabled,admin_monitor_enabled,call_parking_enabled,updater_check_enabled,AFLogging_enabled,QUEUE_ACTION_enabled,CallerID_popup_enabled,voicemail_button_enabled,enable_fast_refresh,fast_refresh_rate,enable_persistant_mysql,auto_dial_next_number,VDstop_rec_after_each_call,DBX_server,DBX_database,DBX_user,DBX_pass,DBX_port,DBY_server,DBY_database,DBY_user,DBY_pass,DBY_port,outbound_cid,enable_sipsak_messages,email,template_id,conf_override,phone_context,phone_ring_timeout,conf_secret,is_webphone,use_external_server_ip,codecs_list,webphone_dialpad,phone_ring_timeout,on_hook_agent from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01025',$VD_login,$server_ip,$session_name,$one_mysql_log);} @@ -2009,9 +2010,11 @@ else $use_external_server_ip=$row[74]; $codecs_list=$row[75]; $webphone_dialpad=$row[76]; + $phone_ring_timeout=$row[77]; + $on_hook_agent=$row[78]; $no_empty_session_warnings=0; - if ($phone_login == 'nophone') + if ( ($phone_login == 'nophone') or ($on_hook_agent == 'Y') ) { $no_empty_session_warnings=1; } @@ -2244,8 +2247,11 @@ else $webphone_content=''; if ($is_webphone != 'Y') { + $TEMP_SIP_user_DiaL = $SIP_user_DiaL; + if ($on_hook_agent == 'Y') + {$TEMP_SIP_user_DiaL = 'Local/8300@default';} ### insert a NEW record to the vicidial_manager table to be processed - $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $SIP_user_DiaL','Context: $ext_context','Exten: $session_id','Priority: 1','Callerid: \"$SIqueryCID\" <$campaign_cid>','','','','','');"; + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $TEMP_SIP_user_DiaL','Context: $ext_context','Exten: $session_id','Priority: 1','Callerid: \"$SIqueryCID\" <$campaign_cid>','','','','','');"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01041',$VD_login,$server_ip,$session_name,$one_mysql_log);} @@ -2358,9 +2364,8 @@ else { echo "\n"; - $closer_chooser_string=''; - $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level,campaign_weight,calls_today,last_state_change,outbound_autodial,manager_ingroup_set) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level','$campaign_weight','$calls_today','$NOW_TIME','Y','N');"; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level,campaign_weight,calls_today,last_state_change,outbound_autodial,manager_ingroup_set,on_hook_ring_time,on_hook_agent) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level','$campaign_weight','$calls_today','$NOW_TIME','Y','N','$phone_ring_timeout','$on_hook_agent');"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01044',$VD_login,$server_ip,$session_name,$one_mysql_log);} @@ -2420,7 +2425,7 @@ else { print "\n"; - $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,user_level,campaign_weight,calls_today,last_state_change,outbound_autodial,manager_ingroup_set) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$user_level', '$campaign_weight', '$calls_today','$NOW_TIME','N','N');"; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,user_level,campaign_weight,calls_today,last_state_change,outbound_autodial,manager_ingroup_set,on_hook_ring_time,on_hook_agent) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$user_level', '$campaign_weight', '$calls_today','$NOW_TIME','N','N','$phone_ring_timeout','$on_hook_agent');"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01047',$VD_login,$server_ip,$session_name,$one_mysql_log);} @@ -2456,6 +2461,16 @@ else $affected_rows = mysql_affected_rows($linkB); echo "\n"; + if ($queuemetrics_addmember_enabled > 0) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtimE',call_id='NONE',queue='$VD_campaign',agent='Agent/$VD_login',verb='ADDMEMBER2',data1='$QM_PHONE',serverid='$queuemetrics_log_id',data4='$qm_phone_environment';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'01072',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + echo "\n"; + } + mysql_close($linkB); mysql_select_db("$VARDB_database", $link); } @@ -11776,7 +11791,12 @@ $zi=2; Logged in as User - + ring)";} + echo "  to campaign: $VD_campaign  \n"; + ?>     0) {echo "TERRITORIES     \n";} ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php b/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php index ec775908..4d2d369d 100644 --- a/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php +++ b/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 # # live real-time stats for the VICIDIAL Auto-Dialer all servers # @@ -72,10 +72,11 @@ # 101109-1448 - Added Auto Hopper Level display (MikeC) # 101216-1358 - Added functions to work with new realtime_report.php script # 110218-1037 - Fixed query that was causing load spikes on systems with millions of log entries +# 110303-2125 - Added agent on-hook phone indication and RING status and color # -$version = '2.4-63'; -$build = '110218-1037'; +$version = '2.4-64'; +$build = '110303-2125'; header ("Content-type: text/html; charset=utf-8"); @@ -824,6 +825,7 @@ else .khaki {color: black; background-color: #F0E68C} .orange {color: black; background-color: orange} .black {color: white; background-color: black} + .salmon {color: white; background-color: #FA8072} .r1 {color: black; background-color: #FFCCCC} .r2 {color: black; background-color: #FF9999} @@ -2167,7 +2169,8 @@ else {$UgroupSQL = " and vicidial_live_agents.campaign_id IN($group_SQL)";} if (strlen($usergroup)<1) {$usergroupSQL = '';} else {$usergroupSQL = " and user_group='" . mysql_real_escape_string($usergroup) . "'";} -$stmt="select extension,vicidial_live_agents.user,conf_exten,vicidial_live_agents.status,vicidial_live_agents.server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,vicidial_live_agents.campaign_id,vicidial_users.user_group,vicidial_users.full_name,vicidial_live_agents.comments,vicidial_live_agents.calls_today,vicidial_live_agents.callerid,lead_id,UNIX_TIMESTAMP(last_state_change) from vicidial_live_agents,vicidial_users where vicidial_live_agents.user=vicidial_users.user $UgroupSQL $usergroupSQL order by $orderSQL;"; +$ring_agents=0; +$stmt="select extension,vicidial_live_agents.user,conf_exten,vicidial_live_agents.status,vicidial_live_agents.server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,vicidial_live_agents.campaign_id,vicidial_users.user_group,vicidial_users.full_name,vicidial_live_agents.comments,vicidial_live_agents.calls_today,vicidial_live_agents.callerid,lead_id,UNIX_TIMESTAMP(last_state_change),on_hook_agent,ring_callerid from vicidial_live_agents,vicidial_users where vicidial_live_agents.user=vicidial_users.user $UgroupSQL $usergroupSQL order by $orderSQL;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $talking_to_print = mysql_num_rows($rslt); @@ -2194,6 +2197,18 @@ $talking_to_print = mysql_num_rows($rslt); $Acallerid[$i] = $row[13]; $Alead_id[$i] = $row[14]; $Astate_change[$i] = $row[15]; + $Aon_hook_agent[$i] = $row[16]; + $Aring_callerid[$i] = $row[17]; + $Aring_note[$i] = ' '; + + if ($Aon_hook_agent[$i] == 'Y') + { + $Aring_note[$i] = '*'; + $ring_agents++; + if (strlen($Aring_callerid[$i]) > 18) + {$Astatus[$i]="RING";} + } + ### 3-WAY Check ### if ($Alead_id[$i]!=0) @@ -2212,26 +2227,26 @@ $talking_to_print = mysql_num_rows($rslt); $i++; } -$callerids=''; -$pausecode=''; -$stmt="select callerid,lead_id,phone_number from vicidial_auto_calls;"; -$rslt=mysql_query($stmt, $link); -if ($DB) {echo "$stmt\n";} -$calls_to_list = mysql_num_rows($rslt); + $callerids=''; + $pausecode=''; + $stmt="select callerid,lead_id,phone_number from vicidial_auto_calls;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $calls_to_list = mysql_num_rows($rslt); if ($calls_to_list > 0) - { - $i=0; - while ($i < $calls_to_list) { - $row=mysql_fetch_row($rslt); - $callerids .= "$row[0]|"; - $VAClead_ids[$i] = $row[1]; - $VACphones[$i] = $row[2]; - $i++; + $i=0; + while ($i < $calls_to_list) + { + $row=mysql_fetch_row($rslt); + $callerids .= "$row[0]|"; + $VAClead_ids[$i] = $row[1]; + $VACphones[$i] = $row[2]; + $i++; + } } - } -### Lookup phone logins + ### Lookup phone logins $i=0; while ($i < $talking_to_print) { @@ -2509,6 +2524,13 @@ $calls_to_list = mysql_num_rows($rslt); if ($call_time_S >= 300) {$G=''; $EG='';} } + if ($Astatus[$i] == 'RING') + { + $agent_total++; + $G=''; $EG=''; + if ($call_time_S >= 0) {$G=''; $EG='';} + } + $L=''; $R=''; if ($SIPmonitorLINK>0) {$L=" LISTEN"; $R='';} @@ -2556,11 +2578,11 @@ $calls_to_list = mysql_num_rows($rslt); if ($realtime_block_user_info > 0) { - $Aecho .= "|$UGD $G$sessionid$EG$L$R | $G$status$EG $CM $pausecode|$CP$SVD$G$call_time_MS$EG | $G$campaign_id$EG | $G$calls_today$EG |$INGRP\n"; + $Aecho .= "|$UGD $G$sessionid$EG$L$R$Aring_note[$i]| $G$status$EG $CM $pausecode|$CP$SVD$G$call_time_MS$EG | $G$campaign_id$EG | $G$calls_today$EG |$INGRP\n"; } if ($realtime_block_user_info < 1) { - $Aecho .= "| $G$extension$EG |$phoneD$G$user$EG + |$UGD $G$sessionid$EG$L$R | $G$status$EG $CM $pausecode|$CP$SVD$G$call_time_MS$EG | $G$campaign_id$EG | $G$calls_today$EG |$INGRP\n"; + $Aecho .= "| $G$extension$EG$Aring_note[$i]|$phoneD$G$user$EG + |$UGD $G$sessionid$EG$L$R | $G$status$EG $CM $pausecode|$CP$SVD$G$call_time_MS$EG | $G$campaign_id$EG | $G$calls_today$EG |$INGRP\n"; } $j++; } @@ -2582,6 +2604,12 @@ $calls_to_list = mysql_num_rows($rslt); $Aecho .= " - Agent in 3-WAY > 10 seconds\n"; $Aecho .= " - Agent on a dead call\n"; + if ($ring_agents > 0) + { + $Aecho .= " - Agent phone ringing\n"; + $Aecho .= " * Denotes on-hook agent\n"; + } + if ($agent_ready > 0) {$B=''; $BG='';} if ($agent_ready > 4) {$B=''; $BG='';} if ($agent_ready > 9) {$B=''; $BG='';} diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index 4633f16c..31cb4daf 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -1516,6 +1516,10 @@ if (isset($_GET["queuemetrics_phone_environment"])) {$queuemetrics_phone_envi elseif (isset($_POST["queuemetrics_phone_environment"])) {$queuemetrics_phone_environment=$_POST["queuemetrics_phone_environment"];} if (isset($_GET["active_twin_server_ip"])) {$active_twin_server_ip=$_GET["active_twin_server_ip"];} elseif (isset($_POST["active_twin_server_ip"])) {$active_twin_server_ip=$_POST["active_twin_server_ip"];} +if (isset($_GET["on_hook_agent"])) {$on_hook_agent=$_GET["on_hook_agent"];} + elseif (isset($_POST["on_hook_agent"])) {$on_hook_agent=$_POST["on_hook_agent"];} +if (isset($_GET["on_hook_ring_time"])) {$on_hook_ring_time=$_GET["on_hook_ring_time"];} + elseif (isset($_POST["on_hook_ring_time"])) {$on_hook_ring_time=$_POST["on_hook_ring_time"];} if (isset($script_id)) {$script_id= strtoupper($script_id);} @@ -1751,6 +1755,7 @@ if ($non_latin < 1) $generate_cross_server_exten = ereg_replace("[^0-9]","",$generate_cross_server_exten); $queuemetrics_addmember_enabled = ereg_replace("[^0-9]","",$queuemetrics_addmember_enabled); $modify_page = ereg_replace("[^0-9]","",$modify_page); + $on_hook_ring_time = ereg_replace("[^0-9]","",$on_hook_ring_time); $drop_call_seconds = ereg_replace("[^-0-9]","",$drop_call_seconds); @@ -1840,6 +1845,7 @@ if ($non_latin < 1) $first_login_trigger = ereg_replace("[^NY]","",$first_login_trigger); $eht_minimum_prompt_no_block = ereg_replace("[^NY]","",$eht_minimum_prompt_no_block); $lead_order_randomize = ereg_replace("[^NY]","",$lead_order_randomize); + $on_hook_agent = ereg_replace("[^NY]","",$on_hook_agent); $qc_enabled = ereg_replace("[^0-9NY]","",$qc_enabled); $active = ereg_replace("[^0-9NY]","",$active); @@ -2659,12 +2665,13 @@ else # 110215-2135 - Added agent_lead_search options to user and campaign # 110222-2039 - Added USER, GROUP and TERRITORY restrictions to agent lead search # 110224-1427 - Added queuemetrics_phone_environment and active_twin_server_ip options +# 110301-1206 - Added options for ring-all in-group next-agent-call # # 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.4-303a'; -$build = '110224-1427'; +$admin_version = '2.4-304a'; +$build = '110301-1206'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -5082,8 +5089,15 @@ if ($ADD==99999)
  - campaign_rank: orders by the rank given to the agent for the campaign. Highest to Lowest.
  - fewest_calls_campaign: orders by the number of calls received by an agent for the campaign. Least calls first.
  - longest_wait_time: orders by the amount of time agent has been actively waiting for a call. +
  - ring_all: rings all available agents until one picks up the phone. +
NOTES: For ring_all, the agents that are using phones that have On Hook Agent enabled will have their phones ring and the first one to answer will receive the call and the information on the agent screen. Since ring_all ignores agent wait time and ranking and will call every agent that is available for the queue, we do not recommend using this method for large queues. When using ring_all, agents logged with phones that have the On Hook Agent disabled will have to use the Calls In Queue panel and click on the TAKE CALL link to take calls in queue. The amount of time the agents phone will ring for ring_all is set to the On-Hook Ring Time setting or the shortest ring time of the phones that will be called. We do not recommend using ring_all on high call volume queues, or queues with many agents. The ring_all method is intended to be used with only a few agents and on low call volume in-groups.
+
+ +
+ On-Hook Ring Time - This option is only used for agents that are logged in with phones that have the agent-on-hook feature enabled. This is the number of seconds that each call attempt to the agent will ring for until the system will wait one second and start ringing the available agent phones again. This field can be overridden if the agent phones are set to a lower ring time which may be necessary to prevent calls from being sent one phones voicemail. Default is 15. +

@@ -5813,6 +5827,16 @@ if ($ADD==99999)
Campaign - Here is where you select the campaign that these remote agents will be logged into. Inbound needs to use the CLOSER campaign and select the inbound campaigns below that you want to receive calls from. +
+
+
+ On-Hook Agent - This option is only used for inbound calls going to this remote agent. This feature will call the remote agent and will not send the customer to the remote agent until the line is answered. Default is N for disabled. + +
+
+
+ On-Hook Ring Time - This option is only used when the On-Hook Agent field above is set to Y and then only for inbound calls coming to this remote agent. This is the number of seconds that each call attempt will ring to try to get an answer. It is recommended that you set this to a few seconds less than it takes for a call to be sent to voicemail. Default is 15. +

@@ -6418,6 +6442,11 @@ if ($ADD==99999)
Phone Ring Timeout - This is the amount of time, in seconds, that the phone will ring in the dialplan before sending the call to voicemail. Default is 60 seconds. +
+
+
+ On-Hook Agent Login - This option is only used for inbound calls going to an agent logged in with this phone. This feature will call the agent and will not send the customer to the agents session until the line is answered. Default is N for disabled. +

@@ -8491,7 +8520,7 @@ if ($ADD==1111) echo "Active: $NWB#vicidial_inbound_groups-active$NWE\n"; echo "Web Form: $NWB#vicidial_inbound_groups-web_form_address$NWE\n"; echo "Voicemail: $NWB#vicidial_inbound_groups-voicemail_ext$NWE\n"; - echo "Next Agent Call: $NWB#vicidial_inbound_groups-next_agent_call$NWE\n"; + echo "Next Agent Call: $NWB#vicidial_inbound_groups-next_agent_call$NWE\n"; echo "Fronter Display: $NWB#vicidial_inbound_groups-fronter_display$NWE\n"; echo "Script: $NWB#vicidial_inbound_groups-web_form_address$NWE\n"; } - echo "Next Agent Call: $NWB#vicidial_inbound_groups-next_agent_call$NWE\n"; + echo "Next Agent Call: $NWB#vicidial_inbound_groups-next_agent_call$NWE\n"; echo "Queue Priority: $NWB#vicidial_inbound_groups-queue_priority$NWE\n"; + echo "On-Hook Ring Time: $NWB#vicidial_inbound_groups-on_hook_ring_time$NWE\n"; + echo "Fronter Display: $NWB#vicidial_inbound_groups-fronter_display$NWE\n"; echo "
Script: \n"; echo "$campaigns_list"; echo "\n"; + echo "On-Hook Agent: $NWB#vicidial_remote_agents-on_hook_agent$NWE\n"; + echo "On-Hook Ring Time: $NWB#vicidial_remote_agents-on_hook_ring_time$NWE\n"; echo "$NWB#vicidial_remote_agents-campaign_id$NWE\n"; echo "Inbound Groups: \n"; echo "$groups_list"; @@ -24872,7 +24908,7 @@ if ($ADD==31111111111) echo "\n"; echo "\n"; echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; diff --git a/agc_2-X/trunk/www/vicidial/non_agent_api.php b/agc_2-X/trunk/www/vicidial/non_agent_api.php index 6e0b1d63..0651283f 100644 --- a/agc_2-X/trunk/www/vicidial/non_agent_api.php +++ b/agc_2-X/trunk/www/vicidial/non_agent_api.php @@ -41,10 +41,11 @@ # 101117-1104 - Added callback and custom field entry delete to delete_lead option # 101206-2126 - Added recording_lookup and did_log_export functions # 110127-2245 - Added add_user and add_phone functions +# 110303-2122 - Added information on agent-on-hook phone to real-time report popup # -$version = '2.4-27'; -$build = '110127-2245'; +$version = '2.4-28'; +$build = '110303-2122'; require("dbconnect.php"); @@ -884,7 +885,7 @@ if ($function == 'agent_ingroup_info') } else { - $stmt="SELECT campaign_id,closer_campaigns,outbound_autodial,manager_ingroup_set,external_igb_set_user from vicidial_live_agents where user='$agent_user';"; + $stmt="SELECT campaign_id,closer_campaigns,outbound_autodial,manager_ingroup_set,external_igb_set_user,on_hook_agent,on_hook_ring_time from vicidial_live_agents where user='$agent_user';"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $campaign_id = $row[0]; @@ -892,6 +893,8 @@ if ($function == 'agent_ingroup_info') $blended = $row[2]; $manager_ingroup_set = $row[3]; $external_igb_set_user = $row[4]; + $on_hook_agent = $row[5]; + $on_hook_ring_time = $row[6]; $stmt="SELECT full_name from vicidial_users where user='$agent_user';"; $rslt=mysql_query($stmt, $link); @@ -974,6 +977,10 @@ if ($function == 'agent_ingroup_info') if ( ($allowed_user_change_ingroups > 0) and ($stage == 'change') ) { $output .= "
\n"; echo ""; - $stmt="SELECT extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,messages,old_messages,protocol,local_gmt,ASTmgrUSERNAME,ASTmgrSECRET,login_user,login_pass,login_campaign,park_on_extension,conf_on_extension,VICIDIAL_park_on_extension,VICIDIAL_park_on_filename,monitor_prefix,recording_exten,voicemail_exten,voicemail_dump_exten,ext_context,dtmf_send_extension,call_out_number_group,client_browser,install_directory,local_web_callerID_URL,VICIDIAL_web_URL,AGI_call_logging_enabled,user_switching_enabled,conferencing_enabled,admin_hangup_enabled,admin_hijack_enabled,admin_monitor_enabled,call_parking_enabled,updater_check_enabled,AFLogging_enabled,QUEUE_ACTION_enabled,CallerID_popup_enabled,voicemail_button_enabled,enable_fast_refresh,fast_refresh_rate,enable_persistant_mysql,auto_dial_next_number,VDstop_rec_after_each_call,DBX_server,DBX_database,DBX_user,DBX_pass,DBX_port,DBY_server,DBY_database,DBY_user,DBY_pass,DBY_port,outbound_cid,enable_sipsak_messages,email,template_id,conf_override,phone_context,phone_ring_timeout,conf_secret,delete_vm_after_email,is_webphone,use_external_server_ip,codecs_list,codecs_with_template,webphone_dialpad from phones where extension='$extension' and server_ip='$server_ip';"; + $stmt="SELECT extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,messages,old_messages,protocol,local_gmt,ASTmgrUSERNAME,ASTmgrSECRET,login_user,login_pass,login_campaign,park_on_extension,conf_on_extension,VICIDIAL_park_on_extension,VICIDIAL_park_on_filename,monitor_prefix,recording_exten,voicemail_exten,voicemail_dump_exten,ext_context,dtmf_send_extension,call_out_number_group,client_browser,install_directory,local_web_callerID_URL,VICIDIAL_web_URL,AGI_call_logging_enabled,user_switching_enabled,conferencing_enabled,admin_hangup_enabled,admin_hijack_enabled,admin_monitor_enabled,call_parking_enabled,updater_check_enabled,AFLogging_enabled,QUEUE_ACTION_enabled,CallerID_popup_enabled,voicemail_button_enabled,enable_fast_refresh,fast_refresh_rate,enable_persistant_mysql,auto_dial_next_number,VDstop_rec_after_each_call,DBX_server,DBX_database,DBX_user,DBX_pass,DBX_port,DBY_server,DBY_database,DBY_user,DBY_pass,DBY_port,outbound_cid,enable_sipsak_messages,email,template_id,conf_override,phone_context,phone_ring_timeout,conf_secret,delete_vm_after_email,is_webphone,use_external_server_ip,codecs_list,codecs_with_template,webphone_dialpad,on_hook_agent from phones where extension='$extension' and server_ip='$server_ip';"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); @@ -24914,6 +24950,7 @@ if ($ADD==31111111111) echo "
Client Protocol: $NWB#phones-protocol$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#phones-local_gmt$NWE
Phone Ring Timeout: $NWB#phones-phone_ring_timeout$NWE
On-Hook Agent: $NWB#phones-on_hook_agent$NWE
Manager Login: $NWB#phones-ASTmgrUSERNAME$NWE
Manager Secret: $NWB#phones-ASTmgrSECRET$NWE
VICIDIAL Default User: $NWB#phones-login_user$NWE
\n"; + if ($on_hook_agent == 'Y') + { + $output .= "\n"; + } $output .= "
This is a Phone On-Hook Agent   Maximum Ring Time: $on_hook_ring_time
Selected In-Groups: \n"; $output .= "\n"; $output .= "