--- lib/A3C/View.pm 2008/03/30 15:23:35 41 +++ lib/A3C/View.pm 2008/04/10 23:16:56 72 @@ -8,13 +8,55 @@ use Data::Dump qw/dump/; +template '/' => page { + + h1 { _('Statistics') } + + my $orgs = A3C::Model::OrganizationCollection->new; + $orgs->unlimit; + + dt { _('Number of schools in system') } + dd { $orgs->count } + + my $people = A3C::Model::PersonCollection->new; + $people->unlimit; + + dt { _('Number of persons in system') } + dd { $people->count } + +=for later + + dt { _('Breakdown by towns') } + dd { + $orgs->redo_search; + # select count(l),l from organizations group by l order by count desc limit 25 + $orgs->group_by( column => 'l' ); + $orgs->order_by( column => 'l', order => 'desc' ); + + warn "## SQL: ", $orgs->build_select_query; + my $count = $orgs->column( column => 'l', function => 'count(l)' ); + warn "## count: $count\n"; +# $orgs->column( column => 'l' ); + warn "## SQL: ", $orgs->build_select_query; + + ul { + for ( 1 .. 1 ) { + my $o = $orgs->next; + warn "## ",dump( $o ); + li { outs ( $o->l, '|', $o->__value('l'), $o->__value( $count ) ) } + } + } + + + } + +=cut -template '/skole' => page { - h1 { _('Schools in system') }; - show 'skole_sve'; }; -private template 'skole_sve' => sub { + +template 'ldap' => page { + h1 { _('LDAP data about Schools in system') }; my $ldap = A3C::LDAP->new; div { $ldap->search( @@ -36,3 +78,62 @@ } }; +template 'people' => page { + + h1 { _('Find people') } + + my $action = new_action( + class => 'SearchPerson', + moniker => 'search-users', + sticky_on_success => 1, + sticky_on_failure => 1, + ); + + + form { + render_action( $action => [ 'uid_contains', 'cn_contains' ] ); + form_submit( label => _('Find someone') ); + }; + +# warn dump( $action->result->content ); + + if ( my $search = $action->result->content('search') ) { + div { sprintf(_('Found %d results'), $search->count ) } + ol { + while (my $user = $search->next) { + li { + span { $user->cn } + tt { $user->uid } + } + } + } + } + +}; + +template 'sync' => page { + + h1 { _('Sync school from LDAP') } + + my $action = new_action( + class => 'SyncOrganization', + moniker => 'sync-organization' + ); + + form { + render_action( $action => [ 'cn' ] ); + form_submit( label => _('Sync Organization') ); + }; + + if ( my $users = $action->result->content('synced-users') ) { + ol { + while (my $user = $users->next) { + li { + span { $user->cn } + tt { { class is 'email' } '<' . $user->mail . '>' } + } + } + } + } + +};