[1520] | 1 | package LATMOS::Accounts::Bases::Sql::Userstatus; |
---|
| 2 | |
---|
| 3 | use strict; |
---|
| 4 | use warnings; |
---|
| 5 | |
---|
| 6 | use base qw(LATMOS::Accounts::Bases::Sql::Employment); |
---|
| 7 | |
---|
| 8 | our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0]; |
---|
| 9 | |
---|
| 10 | =head1 NAME |
---|
| 11 | |
---|
| 12 | LATMOS::Accounts::Bases::Sql::Userstatus - Virtual object about only futur employment |
---|
| 13 | |
---|
| 14 | =head1 DESCRIPTION |
---|
| 15 | |
---|
| 16 | This module handle object for office address, allowing to support multiple |
---|
| 17 | address per people. |
---|
| 18 | |
---|
| 19 | =cut |
---|
| 20 | |
---|
| 21 | sub list { |
---|
| 22 | my ($class, $base) = @_; |
---|
| 23 | |
---|
| 24 | my $sth = $base->db->prepare_cached( |
---|
| 25 | sprintf( |
---|
| 26 | q{select %s.%s as k from %s |
---|
| 27 | join "user" on %s."user" = "user".name |
---|
| 28 | where (%s.lastday is null or %s.lastday >= now() - '1 days'::interval) |
---|
| 29 | %s %s |
---|
| 30 | order by %s.%s |
---|
| 31 | }, |
---|
| 32 | $base->db->quote_identifier($class->_object_table), |
---|
| 33 | $base->db->quote_identifier($class->_key_field), |
---|
| 34 | $base->db->quote_identifier($class->_object_table), |
---|
| 35 | $base->db->quote_identifier($class->_object_table), |
---|
| 36 | $base->db->quote_identifier($class->_object_table), |
---|
| 37 | $base->db->quote_identifier($class->_object_table), |
---|
| 38 | ($base->{wexported} ? '' : 'and "user".exported = true'), |
---|
| 39 | ($base->{wexported} ? '' : 'and ' . |
---|
| 40 | $base->db->quote_identifier($class->_object_table) . '.exported = true'), |
---|
| 41 | $base->db->quote_identifier($class->_object_table), |
---|
| 42 | $base->db->quote_identifier($class->_key_field), |
---|
| 43 | ) |
---|
| 44 | ); |
---|
| 45 | $sth->execute; |
---|
| 46 | my @keys; |
---|
| 47 | while(my $res = $sth->fetchrow_hashref) { |
---|
| 48 | push(@keys, $res->{k}); |
---|
| 49 | } |
---|
| 50 | @keys |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | sub list_from_rev { |
---|
| 54 | my ($class, $base, $rev) = @_; |
---|
| 55 | |
---|
| 56 | my $sth = $base->db->prepare_cached( |
---|
| 57 | sprintf( |
---|
| 58 | q{select %s.%s as k from %s |
---|
| 59 | join "user" on %s."user" = "user".name |
---|
| 60 | where (%s.lastday is null or %s.lastday >= now() - '1 days'::interval) |
---|
| 61 | and rev > ? |
---|
| 62 | %s %s |
---|
| 63 | order by %s.%s |
---|
| 64 | }, |
---|
| 65 | $base->db->quote_identifier($class->_object_table), |
---|
| 66 | $base->db->quote_identifier($class->_key_field), |
---|
| 67 | $base->db->quote_identifier($class->_object_table), |
---|
| 68 | $base->db->quote_identifier($class->_object_table), |
---|
| 69 | $base->db->quote_identifier($class->_object_table), |
---|
| 70 | $base->db->quote_identifier($class->_object_table), |
---|
| 71 | ($base->{wexported} ? '' : 'and "user".exported = true'), |
---|
| 72 | ($base->{wexported} ? '' : 'and ' . |
---|
| 73 | $base->db->quote_identifier($class->_object_table) . '.exported = true'), |
---|
| 74 | $base->db->quote_identifier($class->_object_table), |
---|
| 75 | $base->db->quote_identifier($class->_key_field), |
---|
| 76 | ) |
---|
| 77 | ); |
---|
| 78 | $sth->execute($rev); |
---|
| 79 | my @keys; |
---|
| 80 | while(my $res = $sth->fetchrow_hashref) { |
---|
| 81 | push(@keys, $res->{k}); |
---|
| 82 | } |
---|
| 83 | @keys |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | 1; |
---|
| 87 | |
---|
| 88 | __END__ |
---|
| 89 | |
---|
| 90 | =head1 SEE ALSO |
---|
| 91 | |
---|
| 92 | L<LATMOS::Accounts::Bases::Sql> |
---|
| 93 | |
---|
| 94 | L<LATMOS::Accounts::Bases::Sql::Address> |
---|
| 95 | |
---|
| 96 | =head1 AUTHOR |
---|
| 97 | |
---|
| 98 | Thauvin Olivier, E<lt>olivier.thauvin@latmos.ipsl.frE<gt> |
---|
| 99 | |
---|
| 100 | =head1 COPYRIGHT AND LICENSE |
---|
| 101 | |
---|
| 102 | Copyright (C) 2009, 2010, 2011, 2012 by Thauvin Olivier |
---|
| 103 | |
---|
| 104 | This library is free software; you can redistribute it and/or modify |
---|
| 105 | it under the same terms as Perl itself, either Perl version 5.10.0 or, |
---|
| 106 | at your option, any later version of Perl 5 you may have available. |
---|
| 107 | |
---|
| 108 | =cut |
---|