--- lib/A3C/View.pm 2008/04/01 19:44:31 57 +++ lib/A3C/View.pm 2008/05/30 23:47:29 142 @@ -5,16 +5,75 @@ use Jifty::View::Declare -base; use A3C::LDAP; +use A3C::SQL; use Data::Dump qw/dump/; +template '/' => page { -template '/skole' => page { - h1 { _('Schools in system') }; - show 'skole_sve'; + h1 { _('Statistics') } + + my $orgs = A3C::Model::hrEduOrgCollection->new; + $orgs->unlimit; + + dt { _('Number of schools in system') } + dd { $orgs->count } + + my $people = A3C::Model::hrEduPersonCollection->new; + $people->unlimit; + + dt { _('Number of persons in system') } + dd { $people->count } + + my $by_towns = A3C::SQL->new({ query => qq{ + select count(uid),l + from hr_edu_orgs + inner join towns on towns.name = l + group by l + order by count desc + limit 25 + }}); + + dt { _('Top %1 towns by schools', $by_towns->count) } + dd { + ul { + while ( my $row = $by_towns->next ) { + li { outs_raw( $row->count, ' ', $row->l ) } + } + } + } + + my $by_county = A3C::SQL->new({ query => qq{ + select + count(uid) as schools, + county, + count(distinct municipality) as municipalities + from hr_edu_orgs + inner join towns on towns.name = l + group by county + order by schools desc + }}); + + dt { _('Schools by counties') } + dd { + table { + th { _('Schools') } + th { _('County') } + th { _('Municipalities') }; + while ( my $row = $by_county->next ) { + row { + cell { $row->schools } + cell { $row->county } + cell { $row->municipalities } + } + } + } + } }; -private template 'skole_sve' => sub { + +template 'ldap' => page { + h1 { _('LDAP data about Schools in system') }; my $ldap = A3C::LDAP->new; div { $ldap->search( @@ -36,13 +95,18 @@ } }; -template '/search-users' => page { +template 'people' => page { + + h1 { _('Find people') } my $action = new_action( - class => 'SearchUser', - moniker => 'search-users' + class => 'SearchhrEduPerson', + moniker => 'search-users', + sticky_on_success => 1, + sticky_on_failure => 1, ); + form { render_action( $action => [ 'uid_contains', 'cn_contains' ] ); form_submit( label => _('Find someone') ); @@ -64,7 +128,9 @@ }; -template '/sync' => page { +template 'sync' => page { + + h1 { _('Sync school from LDAP') } my $action = new_action( class => 'SyncOrganization', @@ -72,7 +138,7 @@ ); form { - render_action( $action => [ 'cn' ] ); + render_action( $action => [ 'org_uid' ] ); form_submit( label => _('Sync Organization') ); }; @@ -88,3 +154,18 @@ } }; + +# mount other views +use A3C::View::Organization; + +# we can't really use following form because Jifty would upper case first +# letter of model and try to find A3C::Model::HrEduOrg which doesn't exit! +#Jifty::View::Declare::CRUD->mount_view('hrEduOrg', 'A3C::View::Organization', '/organizations'); +alias A3C::View::Organization under '/organizations', { + object_type => 'hrEduOrg', +}; + +use A3C::View::Strix; +alias A3C::View::Strix under '/strix'; + +1;