/[A3C]/lib/A3C/View.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/A3C/View.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 72 by dpavlin, Thu Apr 10 23:16:56 2008 UTC revision 142 by dpavlin, Fri May 30 23:47:29 2008 UTC
# Line 5  use warnings; Line 5  use warnings;
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    
# Line 12  template '/' => page { Line 13  template '/' => page {
13    
14          h1 { _('Statistics') }          h1 { _('Statistics') }
15    
16          my $orgs = A3C::Model::OrganizationCollection->new;          my $orgs = A3C::Model::hrEduOrgCollection->new;
17          $orgs->unlimit;          $orgs->unlimit;
18    
19          dt { _('Number of schools in system') }          dt { _('Number of schools in system') }
20          dd { $orgs->count }          dd { $orgs->count }
21    
22          my $people = A3C::Model::PersonCollection->new;          my $people = A3C::Model::hrEduPersonCollection->new;
23          $people->unlimit;          $people->unlimit;
24    
25          dt { _('Number of persons in system') }          dt { _('Number of persons in system') }
26          dd { $people->count }          dd { $people->count }
27    
28  =for later          my $by_towns = A3C::SQL->new({ query => qq{
29                    select count(uid),l
30                    from hr_edu_orgs
31                    inner join towns on towns.name = l
32                    group by l
33                    order by count desc
34                    limit 25
35            }});
36    
37          dt { _('Breakdown by towns') }          dt { _('Top %1 towns by schools', $by_towns->count) }
38          dd {          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;  
   
39                  ul {                  ul {
40                          for ( 1 .. 1 ) {                          while ( my $row = $by_towns->next ) {
41                                  my $o = $orgs->next;                                  li { outs_raw( $row->count, ' ', $row->l ) }
                                 warn "## ",dump( $o );  
                                 li { outs ( $o->l, '|', $o->__value('l'), $o->__value( $count ) ) }  
42                          }                          }
43                  }                  }
   
   
44          }          }
45    
46  =cut          my $by_county = A3C::SQL->new({ query => qq{
47                    select
48                            count(uid) as schools,
49                            county,
50                            count(distinct municipality) as municipalities
51                    from hr_edu_orgs
52                    inner join towns on towns.name = l
53                    group by county
54                    order by schools desc
55            }});
56    
57            dt { _('Schools by counties') }
58            dd {
59                    table {
60                            th { _('Schools') }
61                            th { _('County') }
62                            th { _('Municipalities') };
63                            while ( my $row = $by_county->next ) {
64                                    row {
65                                            cell { $row->schools }
66                                            cell { $row->county }
67                                            cell { $row->municipalities }
68                                    }
69                            }
70                    }
71            }
72  };  };
73    
74    
# Line 83  template 'people' => page { Line 100  template 'people' => page {
100          h1 { _('Find people') }          h1 { _('Find people') }
101    
102          my $action = new_action(          my $action = new_action(
103                  class   => 'SearchPerson',                  class   => 'SearchhrEduPerson',
104                  moniker => 'search-users',                  moniker => 'search-users',
105                  sticky_on_success => 1,                  sticky_on_success => 1,
106                  sticky_on_failure => 1,                  sticky_on_failure => 1,
# Line 121  template 'sync' => page { Line 138  template 'sync' => page {
138          );          );
139    
140          form {          form {
141                  render_action( $action => [ 'cn' ] );                  render_action( $action => [ 'org_uid' ] );
142                  form_submit( label => _('Sync Organization') );                  form_submit( label => _('Sync Organization') );
143          };          };
144    
# Line 137  template 'sync' => page { Line 154  template 'sync' => page {
154          }          }
155    
156  };  };
157    
158    # mount other views
159    use A3C::View::Organization;
160    
161    # we can't really use following form because Jifty would upper case first
162    # letter of model and try to find A3C::Model::HrEduOrg which doesn't exit!
163    #Jifty::View::Declare::CRUD->mount_view('hrEduOrg', 'A3C::View::Organization', '/organizations');
164    alias A3C::View::Organization under '/organizations', {
165            object_type => 'hrEduOrg',
166    };
167    
168    use A3C::View::Strix;
169    alias A3C::View::Strix under '/strix';
170    
171    1;

Legend:
Removed from v.72  
changed lines
  Added in v.142

  ViewVC Help
Powered by ViewVC 1.1.26