5 |
|
|
6 |
use Jifty::View::Declare -base; |
use Jifty::View::Declare -base; |
7 |
use A3C::LDAP; |
use A3C::LDAP; |
8 |
|
use A3C::SQL; |
9 |
|
|
10 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
11 |
|
|
12 |
|
template '/' => page { |
13 |
|
|
14 |
|
h1 { _('Statistics') } |
15 |
|
|
16 |
|
my $orgs = A3C::Model::OrganizationCollection->new; |
17 |
|
$orgs->unlimit; |
18 |
|
|
19 |
|
dt { _('Number of schools in system') } |
20 |
|
dd { $orgs->count } |
21 |
|
|
22 |
|
my $people = A3C::Model::PersonCollection->new; |
23 |
|
$people->unlimit; |
24 |
|
|
25 |
|
dt { _('Number of persons in system') } |
26 |
|
dd { $people->count } |
27 |
|
|
28 |
|
my $sql = A3C::SQL->new({ query => qq{ |
29 |
|
select count(uid),l |
30 |
|
from organizations |
31 |
|
inner join towns on towns.name = l |
32 |
|
group by l |
33 |
|
order by count desc |
34 |
|
limit 25 |
35 |
|
}}); |
36 |
|
|
37 |
|
dt { _('Top %1 towns by schools', $sql->count) } |
38 |
|
dd { |
39 |
|
ul { |
40 |
|
while ( my $row = $sql->next ) { |
41 |
|
li { outs_raw( $row->count, ' ', $row->l ) } |
42 |
|
} |
43 |
|
} |
44 |
|
} |
45 |
|
|
|
template '/skole' => page { |
|
|
h1 { _('Schools in system') }; |
|
|
show 'skole_sve'; |
|
46 |
}; |
}; |
47 |
|
|
48 |
private template 'skole_sve' => sub { |
|
49 |
|
template 'ldap' => page { |
50 |
|
h1 { _('LDAP data about Schools in system') }; |
51 |
|
my $ldap = A3C::LDAP->new; |
52 |
div { |
div { |
53 |
my $search = A3C::LDAP->search( |
$ldap->search( |
54 |
base => 'dc=skole,dc=hr', |
base => 'dc=skole,dc=hr', |
55 |
filter => '(objectClass=hrEduOrg)', |
filter => '(objectClass=hrEduOrg)', |
56 |
sizelimit => 10, |
sizelimit => 10, |
57 |
); |
); |
58 |
while ( my $entry = $search->shift_entry ) { |
while ( my $entry = $ldap->current_search->shift_entry ) { |
59 |
#warn $entry->dump; |
#warn $entry->dump; |
60 |
ul { |
ul { |
61 |
foreach my $attr ( $entry->attributes ) { |
foreach my $attr ( $entry->attributes ) { |
69 |
} |
} |
70 |
}; |
}; |
71 |
|
|
72 |
|
template 'people' => page { |
73 |
|
|
74 |
|
h1 { _('Find people') } |
75 |
|
|
76 |
|
my $action = new_action( |
77 |
|
class => 'SearchPerson', |
78 |
|
moniker => 'search-users', |
79 |
|
sticky_on_success => 1, |
80 |
|
sticky_on_failure => 1, |
81 |
|
); |
82 |
|
|
83 |
|
|
84 |
|
form { |
85 |
|
render_action( $action => [ 'uid_contains', 'cn_contains' ] ); |
86 |
|
form_submit( label => _('Find someone') ); |
87 |
|
}; |
88 |
|
|
89 |
|
# warn dump( $action->result->content ); |
90 |
|
|
91 |
|
if ( my $search = $action->result->content('search') ) { |
92 |
|
div { sprintf(_('Found %d results'), $search->count ) } |
93 |
|
ol { |
94 |
|
while (my $user = $search->next) { |
95 |
|
li { |
96 |
|
span { $user->cn } |
97 |
|
tt { $user->uid } |
98 |
|
} |
99 |
|
} |
100 |
|
} |
101 |
|
} |
102 |
|
|
103 |
|
}; |
104 |
|
|
105 |
|
template 'sync' => page { |
106 |
|
|
107 |
|
h1 { _('Sync school from LDAP') } |
108 |
|
|
109 |
|
my $action = new_action( |
110 |
|
class => 'SyncOrganization', |
111 |
|
moniker => 'sync-organization' |
112 |
|
); |
113 |
|
|
114 |
|
form { |
115 |
|
render_action( $action => [ 'cn' ] ); |
116 |
|
form_submit( label => _('Sync Organization') ); |
117 |
|
}; |
118 |
|
|
119 |
|
if ( my $users = $action->result->content('synced-users') ) { |
120 |
|
ol { |
121 |
|
while (my $user = $users->next) { |
122 |
|
li { |
123 |
|
span { $user->cn } |
124 |
|
tt { { class is 'email' } '<' . $user->mail . '>' } |
125 |
|
} |
126 |
|
} |
127 |
|
} |
128 |
|
} |
129 |
|
|
130 |
|
}; |