X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=7ac8c6214cc40029e10006c48db1f126758d16ab;hb=093fbb43eb8cfa3f94c8416ac9d2b7b078d8ee18;hp=9627f9ffdbd1399b47d01c0c5b2a9bba89350301;hpb=e3dd31c479fb51c2a543ef3c0d7aff59bc44d6f4;p=freeside.git diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 9627f9ffd..7ac8c6214 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -2731,6 +2731,13 @@ sub retry_realtime { my $join = FS::part_event_condition->join_conditions_sql; my $order = FS::part_event_condition->order_conditions_sql; + my $mine = + '( ' + . join ( ' OR ' , map { + "( part_event.eventtable = " . dbh->quote($_) + . " AND tablenum IN( SELECT " . dbdef->table($_)->primary_key . " from $_ where custnum = " . dbh->quote( $self->custnum ) . "))" ; + } FS::part_event->eventtables) + . ') '; #here is the agent virtualization my $agent_virt = " ( part_event.agentnum IS NULL @@ -2754,7 +2761,7 @@ sub retry_realtime { 'addl_from' => "LEFT JOIN part_event USING ( eventpart ) $join", 'hashref' => { 'status' => 'done' }, 'extra_sql' => " AND statustext IS NOT NULL AND statustext != '' ". - " AND $is_realtime_event AND $agent_virt $order" # LIMIT 1" + " AND $mine AND $is_realtime_event AND $agent_virt $order" # LIMIT 1" }); my %seen_invnum = (); @@ -5786,7 +5793,7 @@ sub _agent_plandata { LEFT JOIN part_event_option AS peo_agentnum ON ( part_event.eventpart = peo_agentnum.eventpart AND peo_agentnum.optionname = 'agentnum' - AND peo_agentnum.optionvalue ~ '(^|,)agentnum(,|$)' + AND peo_agentnum.optionvalue ~ '(^|,)}. $agentnum. q{agentnum(,|$)' ) LEFT JOIN part_event_option AS peo_cust_bill_age ON ( part_event.eventpart = peo_cust_bill_age.eventpart @@ -5796,6 +5803,7 @@ sub _agent_plandata { #'hashref' => { 'optionname' => $option }, 'hashref' => { 'part_event_option.optionname' => $option }, 'extra_sql' => " AND event = 'cust_bill_send_agent' ". + " AND disabled != 'Y' ". " AND peo_agentnum.optionname = 'agentnum' ". " AND agentnum IS NULL OR agentnum = $agentnum ". " ORDER BY