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; |
my $ldap = A3C::LDAP->new; |
52 |
div { |
div { |
53 |
$ldap->search( |
$ldap->search( |
69 |
} |
} |
70 |
}; |
}; |
71 |
|
|
72 |
template '/search-users' => page { |
template 'people' => page { |
73 |
|
|
74 |
|
h1 { _('Find people') } |
75 |
|
|
76 |
my $action = new_action( |
my $action = new_action( |
77 |
class => 'SearchUser', |
class => 'SearchPerson', |
78 |
moniker => 'search-users' |
moniker => 'search-users', |
79 |
|
sticky_on_success => 1, |
80 |
|
sticky_on_failure => 1, |
81 |
); |
); |
82 |
|
|
83 |
|
|
84 |
form { |
form { |
85 |
render_action( $action => [ 'uid_contains', 'cn_contains' ] ); |
render_action( $action => [ 'uid_contains', 'cn_contains' ] ); |
86 |
form_submit( label => _('Find someone') ); |
form_submit( label => _('Find someone') ); |
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 |
|
}; |