Changeset 2028


Ignore:
Timestamp:
05/09/17 15:13:29 (7 years ago)
Author:
nanardon
Message:

Trying to fix local time in employment managment

Location:
trunk/LATMOS-Accounts/lib/LATMOS/Accounts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm

    r1992 r2028  
    13001300                    my $self = $attr->object; 
    13011301 
     1302                    my $now = DateTime->now()->iso8610 . 'Z'; 
     1303 
    13021304                    my $sth = $self->base->db->prepare_cached( 
    13031305                        q{ 
    1304                         select name from employment where firstday <= now() and 
    1305                         (lastday is null or lastday >= now() - '1 days'::interval) and "user" = ? 
     1306                        select name from employment where firstday <= ?::timestamp and 
     1307                        (lastday is null or lastday >= ?::timestamp - '1 days'::interval) and "user" = ? 
    13061308                        limit 1 
    13071309                        } 
    13081310                    ); 
    1309                     $sth->execute($self->id); 
     1311                    $sth->execute($now, $now, $self->id); 
    13101312                    my $res = $sth->fetchrow_hashref; 
    13111313                    $sth->finish; 
     
    13251327                    my $self = $attr->object; 
    13261328 
     1329                    my $now = DateTime->now()->iso8610 . 'Z'; 
     1330 
    13271331                    my $sth = $self->base->db->prepare_cached( 
    13281332                        q{ 
    1329                         select name from employment where firstday > now() and "user" = ? 
     1333                        select name from employment where firstday > ? and "user" = ? 
    13301334                        order by firstday asc 
    13311335                        limit 1 
    13321336                        } 
    13331337                    ); 
    1334                     $sth->execute($self->id); 
     1338                    $sth->execute($now, $self->id); 
    13351339                    my $res = $sth->fetchrow_hashref; 
    13361340                    $sth->finish; 
     
    13501354                    my $self = $attr->object; 
    13511355 
     1356                    my $now = DateTime->now()->iso8610 . 'Z'; 
     1357 
    13521358                    my $sth = $self->base->db->prepare_cached( 
    13531359                        q{ 
    13541360                        select name from employment where 
    1355                         (lastday is not null and lastday <= now() - '1 days'::interval) and "user" = ? 
     1361                        (lastday is not null and lastday <= ? - '1 days'::interval) and "user" = ? 
    13561362                        order by firstday desc 
    13571363                        limit 1 
    13581364                        } 
    13591365                    ); 
    1360                     $sth->execute($self->id); 
     1366                    $sth->execute($now, $self->id); 
    13611367                    my $res = $sth->fetchrow_hashref; 
    13621368                    $sth->finish; 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Employment.pm

    r1964 r2028  
    88use LATMOS::Accounts::Utils; 
    99use LATMOS::Accounts::Bases::Sql::Employment; 
     10use DateTime; 
     11use DateTime::TimeZone; 
    1012 
    1113=head1 NAME 
     
    4446    } 
    4547 
     48    my $now = DateTime->now()->iso8601 . 'Z'; 
     49 
    4650    my $listempl = $self->{_base}->db->prepare_cached(q{ 
    47         SELECT * FROM employment where firstday <= now() and (lastday is null or lastday >= now() - '1 days'::interval) 
     51        SELECT * FROM employment where firstday <= ?::timestamp and (lastday is null or lastday >= ?::timestamp - '1 days'::interval) 
    4852            and exported = true 
    4953            order by lastday, firstday 
    5054    }); 
    51     $listempl->execute(); 
     55    $listempl->execute($now, $now); 
    5256    my %new  = (); 
    5357    while (my $res = $listempl->fetchrow_hashref) { 
Note: See TracChangeset for help on using the changeset viewer.