line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::bif::list::entities; |
2
|
1
|
|
|
1
|
|
1669
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
5
|
use Bif::Mo; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
6
|
|
5
|
1
|
|
|
1
|
|
943
|
use Term::ANSIColor 'color'; |
|
1
|
|
|
|
|
8460
|
|
|
1
|
|
|
|
|
735
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.1.5_6'; |
8
|
|
|
|
|
|
|
extends 'App::bif'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub run { |
11
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
12
|
1
|
|
|
|
|
5
|
my $opts = $self->opts; |
13
|
1
|
|
|
|
|
6
|
my $db = $self->db; |
14
|
0
|
|
|
|
|
|
my $dark = color('yellow'); |
15
|
0
|
|
|
|
|
|
my $reset = color('reset'); |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
DBIx::ThinSQL->import(qw/ concat case qv /); |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $data = $db->xarrayrefs( |
20
|
|
|
|
|
|
|
select => [ |
21
|
|
|
|
|
|
|
concat( qv($dark), 'n.kind', qv($reset) )->as('type'), |
22
|
|
|
|
|
|
|
'e.id', 'e.name', |
23
|
|
|
|
|
|
|
"ecm.mvalue || ' (' || ecm.method || ')' AS contact", |
24
|
|
|
|
|
|
|
case ( |
25
|
|
|
|
|
|
|
when => 'e.contact_id != e.id', |
26
|
|
|
|
|
|
|
then => 'c.name', |
27
|
|
|
|
|
|
|
else => qv('-'), |
28
|
|
|
|
|
|
|
)->as('via'), |
29
|
|
|
|
|
|
|
], |
30
|
|
|
|
|
|
|
from => 'entities e', |
31
|
|
|
|
|
|
|
inner_join => 'nodes n', |
32
|
|
|
|
|
|
|
on => 'n.id = e.id', |
33
|
|
|
|
|
|
|
inner_join => 'entities c', |
34
|
|
|
|
|
|
|
on => 'c.id = e.contact_id', |
35
|
|
|
|
|
|
|
inner_join => 'entity_contact_methods ecm', |
36
|
|
|
|
|
|
|
on => 'ecm.id = e.default_contact_method_id', |
37
|
|
|
|
|
|
|
order_by => [qw/e.name contact ecm.mvalue/], |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
return $self->ok('ListEntities') unless @$data; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$self->start_pager( scalar @$data ); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
print $self->render_table( ' l r l l l ', |
45
|
|
|
|
|
|
|
[ 'Type', 'ID', 'Entity', 'Contact (Method)', 'Via' ], $data ); |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return $self->ok('ListEntities'); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
__END__ |