blob: b5da292498e58061adcd00d2bcbc08ef5af9c907 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch);
use FS::part_event;
use FS::part_event_condition;
my $fs_user = shift or die "usage: event-search username";
adminsuidsetup( $fs_user );
my $eventtable = 'cust_bill';
my $pkey = 'invnum';
#my $pkey_value = 33623;
my $pkey_value = 34333;
my $cross = "CROSS JOIN $eventtable";
$cross .= ' LEFT JOIN cust_main USING ( custnum )'
unless $eventtable eq 'cust_main';
my $cross_where = "$eventtable.$pkey = $pkey_value";
my $join = FS::part_event_condition->join_conditions_sql( $eventtable );
@FS::part_event_condition::SKIP_CONDITION_SQL = ( 'once' );
my $extra_sql =
FS::part_event_condition->where_conditions_sql( $eventtable,
#'time'=>$opt{'time'}
'time'=>time,
);
my $order = FS::part_event_condition->order_conditions_sql( $eventtable );
$extra_sql = "AND $extra_sql" if $extra_sql;
#here is the agent virtualization
$extra_sql .= " AND ( part_event.agentnum IS NULL
OR part_event.agentnum = 5 )";
$extra_sql .= " $order";
my @part_event = qsearch( {
#'debug' => ( $opt{'debug'} > 3 ? 1 : 0 ),
'select' => 'part_event.*',
'table' => 'part_event',
'addl_from' => "$cross $join",
'hashref' => { 'check_freq' => '1d', #( $opt{'check_freq'} || '1d' ),
'eventtable' => $eventtable,
'disabled' => '',
},
'extra_sql' => "AND $cross_where $extra_sql",
} );
warn scalar(@part_event). " found\n";
warn Dumper(@part_event);
|