push (@{$self->{'items'}}, {$number_type => $record->{$number_type}, label_id => $record->{'label_id'}});
$record_flag = 1; # true if one or more rows were retrieved
}
- if ($record_flag == 0) {
- return; # no such record exists return undef
- }
+ return -2 if $record_flag == 0; # a hackish sort of way of indicating no such record exists
if ($sth->err) {
warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
- return;
+ return -1;
}
$self->{'batch_stat'} = 1;
bless ($self, $type);
=head2 C4::Labels::Batch->retrieve(batch_id => $batch_id)
- Invoking the I<retrieve> method constructs a new batch object containing the current values for batch_id. The method returns a new object upon success and undefined upon failure.
+ Invoking the I<retrieve> method constructs a new batch object containing the current values for batch_id. The method returns a new object upon success and 1 upon failure.
Errors are logged to the Apache log.
examples:
- my $batch = C4::Labels::Batch->(batch_id => 1); # Retrieves batch 1 and returns an object containing the record
+ my $batch = C4::Labels::Batch->retrieve(batch_id => 1); # Retrieves batch 1 and returns an object containing the record
=head2 delete()
my $invocant = shift;
my $self = '';
if (_check_params(@_) eq 1) {
- return;
+ return -1;
}
my $type = ref($invocant) || $invocant;
if (grep {$_ eq 'Labels'} @_) {
$sth->execute($opts{'layout_id'}, $opts{'creator'});
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
- return;
+ return -1;
}
my $self = $sth->fetchrow_hashref;
bless ($self, $type);
warn sprintf('Database returned the following error on attempted DELETE: %s', $sth->errstr);
return -1;
}
- return; # return no error code on success
}
sub save {
$sth->execute(@params);
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
- return;
+ return -1;
}
return $self->{'layout_id'};
}
$sth->execute(@params);
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
- return;
+ return -1;
}
my $sth1 = C4::Context->dbh->prepare("SELECT MAX(layout_id) FROM creator_layouts;");
$sth1->execute();
sub get_attr {
my $self = shift;
if (_check_params(@_) eq 1) {
- return;
+ return -1;
}
my ($attr) = @_;
if (exists($self->{$attr})) {
return $self->{$attr};
}
+ else {
+ return -1;
+ }
return;
}
sub set_attr {
my $self = shift;
if (_check_params(@_) eq 1) {
- return;
+ return -1;
}
my %attrs = @_;
foreach my $attrib (keys(%attrs)) {
=head2 get_attr($attribute)
- Invoking the I<get_attr> method will return the value of the requested attribute or undef on error.
+ Invoking the I<get_attr> method will return the value of the requested attribute or -1 on errors.
example:
C<my $value = $layout->get_attr($attribute);>
=head2 C4::Creators::Lib::get_all_templates()
- This function returns a reference to a hash containing all templates upon success and undefined upon failure. Errors are logged to the Apache log.
+ This function returns a reference to a hash containing all templates upon success and 1 upon failure. Errors are logged to the Apache log.
examples:
$sth->execute();
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
- return;
+ return -1;
}
ADD_TEMPLATES:
while (my $template = $sth->fetchrow_hashref) {
=head2 C4::Creators::Lib::get_all_layouts()
- This function returns a reference to a hash containing all layouts upon success and undefined upon failure. Errors are logged to the Apache log.
+ This function returns a reference to a hash containing all layouts upon success and 1 upon failure. Errors are logged to the Apache log.
examples:
$sth->execute();
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
- return;
+ return -1;
}
ADD_LAYOUTS:
while (my $layout = $sth->fetchrow_hashref) {
=head2 C4::Creators::Lib::get_all_profiles()
- This function returns an arrayref whose elements are hashes containing all profiles upon success and undefined upon failure. Errors are logged
+ This function returns an arrayref whose elements are hashes containing all profiles upon success and 1 upon failure. Errors are logged
to the Apache log. Two parameters are accepted. The first limits the field(s) returned. This parameter should be string of comma separted
fields. ie. "field_1, field_2, ...field_n" The second limits the records returned based on a string containing a valud SQL 'WHERE' filter.
$sth->execute();
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
- return;
+ return -1;
}
ADD_PROFILES:
while (my $profile = $sth->fetchrow_hashref) {
$sth->execute();
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
- return;
+ return -1;
}
grep {push @$image_names, {type => $$_[0], name => $$_[0], selected => 0}} @{$sth->fetchall_arrayref([0])};
return $image_names;
$sth->execute($params{'creator'});
if ($sth->err) {
warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
- return;
+ return -1;
}
ADD_BATCHES:
while (my $batch = $sth->fetchrow_hashref) {
$sth1->execute($batch->{'batch_id'}, $params{'creator'});
if ($sth1->err) {
warn sprintf('Database returned the following error on attempted SELECT count: %s', $sth1->errstr);
- return;
+ return -1;
}
my $count = $sth1->fetchrow_arrayref;
$batch->{'_item_count'} = @$count[0];
$sth->execute($item->{'item_number'}, $params{'batch_id'});
if ($sth->err) {
warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
- return;
+ return -1;
}
my $record = $sth->fetchrow_hashref;
my $label_summary;
$sth->execute($item->{'borrower_number'});
if ($sth->err) {
warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
- return;
+ return -1;
}
my $record = $sth->fetchrow_hashref;
my $card_summary->{'_card_number'} = $card_number;
sub html_table {
my $headers = shift;
my $data = shift;
- # no need to generate a table if there is not data to display
- unless ( @{$data} ) {
- return;
- }
+ return undef if scalar(@$data) == 0; # no need to generate a table if there is not data to display
my $table = [];
my $fields = [];
my @table_columns = ();
sub prAltJpeg
{ my ($iData, $iWidth, $iHeight, $iFormat,$aiData, $aiWidth, $aiHeight, $aiFormat) = @_;
my ($namnet, $utrad);
- if (! $PDF::Reuse::pos) { # If no output is active, it is no use to continue
- return;
+ if (! $PDF::Reuse::pos) # If no output is active, it is no use to continue
+ { return undef;
}
prJpegBlob($aiData, $aiWidth, $aiHeight, $aiFormat);
my $altObjNr = $PDF::Reuse::objNr;
sub prJpegBlob
{ my ($iData, $iWidth, $iHeight, $iFormat, $altArrayObjNr) = @_;
my ($iLangd, $namnet, $utrad);
- if (! $PDF::Reuse::pos) { # If no output is active, it is no use to continue
- return;
+ if (! $PDF::Reuse::pos) # If no output is active, it is no use to continue
+ { return undef;
}
my $checkidOld = $PDF::Reuse::checkId;
if (!$iFormat)
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;
}
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);>
my $invocant = shift;
my $type = ref($invocant) || $invocant;
if (_check_params(@_) eq 1) {
- return;
+ return -1;
}
my $self = {
profile_id => 0,
$sth->execute($opts{'template_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) || $opts{profile_id});
if (scalar(@query_params) < 2) { # If there is no template id or creator type then we cannot delete it
warn sprintf('%s : Cannot delete template as the template id is invalid or non-existant.', $call_type) if !$query_params[0];
warn sprintf('%s : Cannot delete template as the creator type is invalid or non-existant.', $call_type) if !$query_params[1];
- return;
+ return -1;
}
my $query = "DELETE FROM " . $opts{'table_name'} . " WHERE template_id = ? AND creator = ?";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute(@params);
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
- return;
+ return -1;
}
$self->{'template_stat'} = 1;
return $self->{'template_id'};
$sth->execute(@params);
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);
- return;
+ return -1;
}
my $sth1 = C4::Context->dbh->prepare("SELECT MAX(template_id) FROM " . $opts{'table_name'} . ";");
$sth1->execute();
sub get_attr {
my $self = shift;
if (_check_params(@_) eq 1) {
- return;
+ return -1;
}
my ($attr) = @_;
if (exists($self->{$attr})) {
return $self->{$attr};
}
- return;
+ else {
+ return -1;
+ }
}
sub set_attr {
my $self = shift;
if (_check_params(@_) eq 1) {
- return;
+ return -1;
}
my %attrs = @_;
foreach my $attrib (keys(%attrs)) {
=head2 save()
Invoking the I<save> method attempts to insert the template into the database if the template is new and update the existing template record if
- the template exists. The method returns the new record template_id upon success and undef upon failure (This avoids template_ids conflicting with a
+ the template exists. The method returns the new record template_id upon success and -1 upon failure (This avoids template_ids conflicting with a
record template_id of 1). Errors are logged to the Apache log.
example:
=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 = $template->get_attr($attribute);>