use C4::Context;
use C4::Debug;
-use C4::Creators::Lib 1.000000 qw(get_unit_values);
+use C4::Creators::Lib qw(get_unit_values);
BEGIN {
- use version; our $VERSION = qv('1.0.0_1');
+ use version; our $VERSION = qv('3.07.00.049');
}
sub _check_params {
sub new {
my $invocant = shift;
- if (_check_params(@_) == 1) {
- return;
+ if (_check_params(@_) eq 1) {
+ return -1;
}
my $type = ref($invocant) || $invocant;
my $self = {
$sth->execute($opts{'profile_id'}, $opts{'creator'});
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
- return;
+ return -1;
}
my $self = $sth->fetchrow_hashref;
$self = _conv_points($self) if ($opts{convert} && $opts{convert} == 1);
warn sprintf('Database returned the following error on attempted DELETE: %s', $sth->errstr);
return -1;
}
- return;
+ return 0;
}
sub save {
$sth->execute(@params);
if ($sth->err) {
warn sprintf('Database returned the following error on attempted UPDATE: %s', $sth->errstr);
- return;
+ return -1;
}
return $self->{'profile_id'};
}
$sth->execute(@params);
if ($sth->err) {
warn sprintf('Database returned the following error on attempted INSERT: %s', $sth->errstr);
- return;
+ return -1;
}
my $sth1 = C4::Context->dbh->prepare("SELECT MAX(profile_id) FROM printers_profile;");
$sth1->execute();
sub get_attr {
my $self = shift;
if (_check_params(@_) eq 1) {
- return;
+ return -1;
}
my ($attr) = @_;
if (exists($self->{$attr})) {
}
else {
warn sprintf('%s is currently undefined.', $attr);
- return;
+ return -1;
}
}
=head2 save()
Invoking the I<save> method attempts to insert the profile into the database if the profile is new and update the existing profile record if the profile exists. The method returns
- the new record profile_id upon success and undef upon failure (This avoids conflicting with a record profile_id of 1). Errors are logged to the Apache log.
+ the new record profile_id upon success and -1 upon failure (This avoids conflicting with a record profile_id of 1). Errors are logged to the Apache log.
example:
C<my $exitstat = $profile->save(); # to save the record behind the $profile object>
=head2 get_attr($attribute)
- Invoking the I<get_attr> method will return the value of the requested attribute or undef on errors.
+ Invoking the I<get_attr> method will return the value of the requested attribute or -1 on errors.
example:
C<my $value = $profile->get_attr($attribute);>