App-Dochazka-REST
view release on metacpan or search on metacpan
lib/App/Dochazka/REST/Model/Schedhistory.pm view on Meta::CPAN
my ( $conn, $shid ) = validate_pos( @_,
{ isa => 'DBIx::Connector' },
{ type => SCALAR }
);
return load(
conn => $conn,
class => __PACKAGE__,
sql => $site->SQL_SCHEDHISTORY_SELECT_BY_SHID,
keys => [ $shid ],
);
}
=head2 load_by_shid
Wrapper for load_by_id
=cut
sub load_by_shid {
my $self = shift;
my ( $conn, $shid ) = validate_pos( @_,
{ isa => 'DBIx::Connector' },
{ type => SCALAR }
);
return $self->load_by_id( $conn, $shid );
}
=head2 insert
Instance method. Attempts to INSERT a record into the 'Schedhistory' table.
Field values are taken from the object. Returns a status object.
=cut
sub insert {
my $self = shift;
my ( $context ) = validate_pos( @_, { type => HASHREF } );
my $status = cud(
conn => $context->{'dbix_conn'},
eid => $context->{'current'}->{'eid'},
object => $self,
sql => $site->SQL_SCHEDHISTORY_INSERT,
attrs => [ 'eid', 'sid', 'effective', 'remark' ],
);
return $status;
}
=head2 update
Instance method. Updates the record. Returns status object.
=cut
sub update {
my $self = shift;
my ( $context ) = validate_pos( @_, { type => HASHREF } );
my $status = cud(
conn => $context->{'dbix_conn'},
eid => $context->{'current'}->{'eid'},
object => $self,
sql => $site->SQL_SCHEDHISTORY_UPDATE,
attrs => [ 'sid', 'effective', 'remark', 'shid' ],
);
return $status;
}
=head2 delete
Instance method. Deletes the record. Returns status object.
=cut
sub delete {
my $self = shift;
my ( $context ) = validate_pos( @_, { type => HASHREF } );
my $status = cud(
conn => $context->{'dbix_conn'},
eid => $context->{'current'}->{'eid'},
object => $self,
sql => $site->SQL_SCHEDHISTORY_DELETE,
attrs => [ 'shid' ],
);
$self->reset( 'shid' => $self->{shid} ) if $status->ok;
return $status;
}
=head2 get_schedhistory
Takes a PARAMHASH which can have one or more of the properties 'eid', 'nick',
and 'tsrange'.
At least one of { 'eid', 'nick' } must be specified. If both are specified,
the employee is determined according to 'eid'.
The function returns the history of schedule changes for that employee
over the given tsrange, or the entire history if no tsrange is supplied.
The return value will always be an L<App::CELL::Status|status> object.
Upon success, the payload will be a reference to an array of C<schedhistory>
objects. If nothing is found, the array will be empty. If there is a DBI error,
the payload will be undefined.
=cut
sub get_schedhistory {
my $context = shift;
return get_history( 'sched', $context->{'dbix_conn'}, @_ );
( run in 0.952 second using v1.01-cache-2.11-cpan-39bf76dae61 )