Changeset 1438 for trunk


Ignore:
Timestamp:
10/30/15 15:24:33 (9 years ago)
Author:
nanardon
Message:

Replace current statistics by user's statistics

Location:
trunk
Files:
2 added
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts-Web/MANIFEST

    r1410 r1438  
    3434lib/LATMOS/Accounts/Web/Controller/Services.pm 
    3535lib/LATMOS/Accounts/Web/Controller/Sites.pm 
     36lib/LATMOS/Accounts/Web/Controller/Stat.pm 
    3637lib/LATMOS/Accounts/Web/Controller/Summary/Departments.pm 
    3738lib/LATMOS/Accounts/Web/Controller/Summary/Offices.pm 
    38 lib/LATMOS/Accounts/Web/Controller/Summary/Rh.pm 
    3939lib/LATMOS/Accounts/Web/Controller/Users.pm 
    4040lib/LATMOS/Accounts/Web/Model/Accounts.pm 
     
    113113root/html/sites/menu.tt 
    114114root/html/sites/object_header.tt 
     115root/html/stat/index.tt 
    115116root/html/summary/departments/index.tt 
    116117root/html/summary/offices/index.tt 
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Json/Stat.pm

    r1412 r1438  
    2222=cut 
    2323 
    24 sub employment :Local :Args(0) { 
    25     my ( $self, $c ) = @_; 
     24sub index :Path :Args(1) { 
     25    my ( $self, $c, $statname ) = @_; 
    2626 
    2727    my $base = $c->model('Accounts')->db; 
    2828 
    29     my @results = (); 
     29    my $ostat = $base->get_object('stat', $statname) or return; 
    3030 
    31     foreach my $contrat ($base->search_objects('group', 'sutype=contrattype')) { 
    32         my $ocontrat = $base->get_object('group', $contrat); 
    33         my $count = scalar( $base->search_objects('user', "memberOf=$contrat", 'active=1') ); 
     31    my $res = $ostat->getStat or return; 
    3432 
    35         push(@results, [ ($ocontrat->get_attributes('label') || $contrat), $count ]); 
    36     } 
    37  
    38     $c->stash->{data} = [ sort { $b->[1] <=> $a->[1] } @results ]; 
     33    $c->stash->{data} = [ map { [ $_, $res->{$_} +0 ] } sort { $res->{$b} <=> $res->{$a} } keys %$res ]; 
    3934} 
    4035 
    41 sub dpmt :Local :Args(0) { 
    42     my ( $self, $c ) = @_; 
     36sub history :Local :Args(1) { 
     37    my ( $self, $c, $statname ) = @_; 
    4338 
    4439    my $base = $c->model('Accounts')->db; 
    4540 
    46     my @results = (); 
     41    my $ostat = $base->get_object('stat', $statname) or return; 
    4742 
    48     foreach my $dpmt ($base->search_objects('group', 'sutype=dpmt')) { 
    49         my $odpmt = $base->get_object('group', $dpmt); 
    50         my $count = scalar( $base->search_objects('user', "department=$dpmt", 'active=1') ); 
     43    my $data = $ostat->getAllStat or return; 
    5144 
    52         push(@results, [ $dpmt, $count ]); 
    53     } 
     45    my $graph = { 
     46        series => [], 
     47        data => [], 
     48    }; 
    5449 
    55     $c->stash->{data} = [ sort { $b->[1] <=> $a->[1] } @results ]; 
    56 } 
     50    my %lines; 
    5751 
    58 sub manager :Local :Args(0) { 
    59     my ( $self, $c ) = @_; 
    60  
    61     my $base = $c->model('Accounts')->db; 
    62  
    63     my @results = (); 
    64  
    65     my %active = map { $_ => 1 } $base->search_objects('user', 'active=1', 'givenName=*'); 
    66  
    67     my %managed = $base->attributes_summary_by_object('user', 'managerContact'); 
    68  
    69     my %managers = (); 
    70  
    71     my $total = 0; 
    72  
    73     foreach my $user (sort keys %managed) { 
    74         $active{$user} or next; 
    75         foreach (@{ $managed{ $user } }) { 
    76             $active{$_} or next; 
    77             $managers{$_} ||= 0; 
    78             $managers{$_} ++; 
    79             $total++; 
     52    foreach my $date (sort keys %$data) { 
     53        foreach my $val (sort keys %{ $data->{$date} }) { 
     54            push(@{ $lines{$val} }, [ $date, $data->{$date}{$val} + 0 ]); 
    8055        } 
    8156    } 
    8257 
    83     my $minreport = $c->req->param('min'); 
    84     my $others = 0; 
    85  
    86     foreach my $user (sort { $managers{$b} <=> $managers{$a} } keys %managers) { 
    87         if ($minreport && $managers{$user} / $total * 100 < $minreport) { 
    88             $others++; 
    89             next; 
    90         } 
    91         push(@results, [ $user, $managers{$user} ]); 
     58    foreach (sort keys %lines) { 
     59        push(@{ $graph->{data} }, $lines{$_}); 
     60        push(@{ $graph->{series} }, { label => $_ }); 
    9261    } 
    9362 
    94     push(@results, [ 'Others', $others ]) if ($others);  
    95  
    96     $c->stash->{data} = \@results; 
     63    $c->stash->{data} = $graph; 
    9764} 
    98  
    99  
    10065 
    10166 
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Stat.pm

    r1437 r1438  
    1 package LATMOS::Accounts::Web::Controller::Summary::Rh; 
     1package LATMOS::Accounts::Web::Controller::Stat; 
    22use Moose; 
    33use namespace::autoclean; 
     
    2222=cut 
    2323 
    24 sub index :Path :Args(0) { 
    25     my ( $self, $c ) = @_; 
     24sub index :Path :Args(1) { 
     25    my ( $self, $c, $statname ) = @_; 
    2626 
     27    $c->stash->{statname} = $statname; 
    2728} 
    2829 
  • trunk/LATMOS-Accounts-Web/root/html/includes/sidebar.tt

    r1363 r1438  
    2929    <li><a href="[% c.uri_for('/summary', 'departments') %]">Liste des départements</a></li> 
    3030 
    31     <li><a href="[% c.uri_for('/summary', 'rh') %]">Statistiques</a></li> 
     31    [% FOREACH stat = c.model('Accounts').db.list_objects('stat') %] 
     32    [% ostat = c.model('Accounts').db.get_object('stat', stat) %] 
     33    <li><a href="[% c.uri_for('/stat', stat) %]">[% ostat.get_attributes('description') || stat | html %]</a></li> 
     34    [% END %] 
     35 
    3236    </ul> 
    3337</li> 
  • trunk/LATMOS-Accounts-Web/root/html/includes/wrapper.tt

    r1362 r1438  
    1515<script src="[% c.uri_for('/static', 'js', 'jqplot', 'plugins', 'jqplot.json2.js') %]"></script> 
    1616<script src="[% c.uri_for('/static', 'js', 'jqplot', 'plugins', 'jqplot.pieRenderer.js') %]"></script> 
     17<script src="[% c.uri_for('/static', 'js', 'jqplot', 'plugins', 'jqplot.dateAxisRenderer.js') %]"></script> 
    1718<link rel="stylesheet" href="[% c.uri_for('/static/js/jqplot/jquery.jqplot.css') %]" type="text/css"> 
    1819 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Stat.pm

    r1434 r1438  
    168168    my ($self, $id) = @_; 
    169169 
    170     ($id) ||= $self->_attributes('lastStatId'); 
     170    ($id) ||= $self->_get_attributes('lastStatId'); 
    171171 
    172172    if (!$id) { 
Note: See TracChangeset for help on using the changeset viewer.