use strict;
use warnings;
-use Sys::Syslog qw(syslog);
-
use C4::Context;
use C4::Debug;
$given_params = {@_};
foreach my $key (keys %{$given_params}) {
if (!(grep m/$key/, @valid_template_params)) {
- syslog("LOG_ERR", "C4::Labels::Batch : Unrecognized parameter type of \"%s\".", $key);
+ warn sprintf('Unrecognized parameter type of "%s".', $key);
$exit_code = 1;
}
}
}
else {
if (!(grep m/$_/, @valid_template_params)) {
- syslog("LOG_ERR", "C4::Labels::Batch : Unrecognized parameter type of \"%s\".", $_);
+ warn sprintf('Unrecognized parameter type of %s', $_);
$exit_code = 1;
}
}
# $sth->{'TraceLevel'} = 3;
$sth->execute($self->{'batch_id'}, $item_number, $self->{'branch_code'});
if ($sth->err) {
- syslog("LOG_ERR", "C4::Labels::Batch->add_item : Database returned the following error on attempted INSERT: %s", $sth->errstr);
+ warn sprintf('Database returned the following error on attempted INSERT: %s', $sth->errstr);
return -1;
}
$query = "SELECT max(label_id) FROM labels_batches WHERE batch_id=? AND item_number=? AND branch_code=?;";
# $sth->{'TraceLevel'} = 3;
$sth->execute($label_id, $self->{'batch_id'});
if ($sth->err) {
- syslog("LOG_ERR", "C4::Labels::Batch->remove_item : Database returned the following error on attempted DELETE: %s", $sth->errstr);
+ warn sprintf('Database returned the following error on attempted DELETE: %s', $sth->errstr);
return -1;
}
@{$self->{'items'}} = grep{$_->{'label_id'} != $label_id} @{$self->{'items'}};
#
# Invoking the I<save> method attempts to insert the batch into the database. The method returns
# the new record batch_id upon success and -1 upon failure (This avoids conflicting with a record
-# batch_id of 1). Errors are logged to the syslog.
+# batch_id of 1). Errors are logged to the Apache log.
#
# example:
# my $exitstat = $batch->save(); # to save the record behind the $batch object
# my $sth1 = C4::Context->dbh->prepare($query);
# $sth1->execute($self->{'batch_id'}, $item_number->{'item_number'}, $self->{'branch_code'});
# if ($sth1->err) {
-# syslog("LOG_ERR", "C4::Labels::Batch->save : Database returned the following error on attempted INSERT: %s", $sth1->errstr);
+# warn sprintf('Database returned the following error on attempted INSERT: %s', $sth1->errstr);
# return -1;
# }
# $self->{'batch_stat'} = 1;
}
return -2 if $record_flag == 0; # a hackish sort of way of indicating no such record exists
if ($sth->err) {
- syslog("LOG_ERR", "C4::Labels::Batch->retrieve : Database returned the following error on attempted SELECT: %s", $sth->errstr);
+ warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
return -1;
}
$self->{'batch_stat'} = 1;
@query_params = ($opts{'batch_id'}, $opts{'branch_code'});
}
if ($query_params[0] eq '') { # If there is no template id then we cannot delete it
- syslog("LOG_ERR", "%s : Cannot delete batch as the batch id is invalid or non-existant.", $call_type);
+ warn sprtinf('%s : Cannot delete batch as the batch id is invalid or non-existent.', $call_type);
return -1;
}
my $query = "DELETE FROM labels_batches WHERE batch_id = ? AND branch_code =?";
# $sth->{'TraceLevel'} = 3;
$sth->execute(@query_params);
if ($sth->err) {
- syslog("LOG_ERR", "%s : Database returned the following error on attempted INSERT: %s", $call_type, $sth->errstr);
+ warn sprintf('%s : Database returned the following error on attempted INSERT: %s', $call_type, $sth->errstr);
return -1;
}
return 0;
foreach my $item (@duplicate_items) {
$sth->execute($item->{'label_id'});
if ($sth->err) {
- syslog("LOG_ERR", "C4::Labels::Batch->remove_duplicates() : Database returned the following error on attempted DELETE for label_id %s: %s", $item->{'label_id'}, $sth->errstr);
+ warn sprintf('Database returned the following error on attempted DELETE for label_id %s: %s', $item->{'label_id'}, $sth->errstr);
return -1;
}
$sth->finish(); # Per DBI.pm docs: "If execute() is called on a statement handle that's still active ($sth->{Active} is true) then it should effectively call finish() to tidy up the previous execution results before starting this new execution."
=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 1 upon failure.
- Errors are logged to the syslog.
+ Errors are logged to the Apache log.
examples:
=head2 delete()
- Invoking the delete method attempts to delete the template from the database. The method returns -1 upon failure. Errors are logged to the syslog.
+ Invoking the delete method attempts to delete the template from the database. The method returns -1 upon failure. Errors are logged to the Apache log.
NOTE: This method may also be called as a function and passed a key/value pair simply deleteing that batch from the database. See the example below.
examples:
=head2 remove_duplicates()
Invoking the remove_duplicates method attempts to remove duplicate items in the batch from the database. The method returns the count of duplicate records removed upon
- success and -1 upon failure. Errors are logged to the syslog.
+ success and -1 upon failure. Errors are logged to the Apache log.
NOTE: This method may also be called as a function and passed a key/value pair removing duplicates in the batch passed in. See the example below.
examples:
use strict;
use warnings;
-use Sys::Syslog qw(syslog);
use Text::Wrap;
use Algorithm::CheckDigits;
use Text::CSV_XS;
$given_params = {@_};
foreach my $key (keys %{$given_params}) {
if (!(grep m/$key/, @valid_label_params)) {
- syslog("LOG_ERR", "C4::Labels::Label : Unrecognized parameter type of \"%s\".", $key);
+ warn sprintf('Unrecognized parameter type of "%s".', $key);
$exit_code = 1;
}
}
}
else {
if (!(grep m/$_/, @valid_label_params)) {
- syslog("LOG_ERR", "C4::Labels::Label : Unrecognized parameter type of \"%s\".", $_);
+ warn sprintf('Unrecognized parameter type of "%s".', $_);
$exit_code = 1;
}
}
my $sth = $dbh->prepare("SELECT bi.*, i.*, b.* FROM items AS i, biblioitems AS bi ,biblio AS b WHERE itemnumber=? AND i.biblioitemnumber=bi.biblioitemnumber AND bi.biblionumber=b.biblionumber;");
$sth->execute($item_number);
if ($sth->err) {
- syslog("LOG_ERR", "C4::Labels::Label::_get_label_item : Database returned the following error: %s", $sth->errstr);
+ warn sprintf('Database returned the following error: %s', $sth->errstr);
}
my $data = $sth->fetchrow_hashref;
# Replaced item's itemtype with the more user-friendly description...
my $sth1 = $dbh->prepare("SELECT itemtype,description FROM itemtypes WHERE itemtype = ?");
$sth1->execute($data->{'itemtype'});
if ($sth1->err) {
- syslog("LOG_ERR", "C4::Labels::Label::_get_label_item : Database returned the following error: %s", $sth1->errstr);
+ warn sprintf('Database returned the following error: %s', $sth1->errstr);
}
my $data1 = $sth->fetchrow_hashref;
$data->{'itemtype'} = $data1->{'description'};
my $status = $csv->parse($format_string);
my @sorted_fields = map {{ 'code' => $_, desc => $_ }} $csv->fields();
my $error = $csv->error_input();
- syslog("LOG_ERR", "C4::Labels::Label::_get_text_fields : Text field sort failed with this error: %s", $error) if $error;
+ warn sprintf('Text field sort failed with this error: %s', $error) if $error;
return \@sorted_fields;
}
\s*
/x;
unless (scalar @parts) {
- syslog("LOG_ERR", "C4::Labels::Label::_split_lccn : regexp failed to match string: %s", $_);
+ warn sprintf('regexp failed to match string: %s', $_);
push @parts, $_; # if no match, just push the whole string.
}
push @parts, split /\s+/, pop @parts; # split the last piece into an arbitrary number of pieces at spaces
- $debug and print STDERR "split_lccn array: ", join(" | ", @parts), "\n";
+ $debug and warn "split_lccn array: ", join(" | ", @parts), "\n";
return @parts;
}
\s*
/x;
unless (scalar @parts) {
- syslog("LOG_ERR", "C4::Labels::Label::_split_ddcn : regexp failed to match string: %s", $_);
+ warn sprintf('regexp failed to match string: %s', $_);
push @parts, $_; # if no match, just push the whole string.
}
}
}
unless (scalar @fcn_split) {
- syslog("LOG_ERR", "C4::Labels::Label::_split_fcn : regexp failed to match string: %s", $_);
+ warn sprintf('regexp failed to match string: %s', $_);
push (@fcn_split, $_);
}
return @fcn_split;
$datastring .= $item->{$f};
}
else {
- syslog("LOG_ERR", "C4::Labels::Label::_get_barcode_data : The '%s' field contains no data.", $f);
+ warn sprintf("The '%s' field contains no data.", $f);
}
$f = $';
next FIELD_LIST;
$datastring .= $itemfield->subfield($subf) . $ws;
}
else {
- syslog("LOG_ERR", "C4::Labels::Label::_get_barcode_data : The '%s' field contains no data.", $f);
+ warn sprintf("The '%s' field contains no data.", $f);
}
last ITEM_FIELDS;
}
$datastring .= $marcfield[0]->subfield($subf) . $ws;
}
else {
- syslog("LOG_ERR", "C4::Labels::Label::_get_barcode_data : The '%s' field contains no data.", $f);
+ warn sprintf("The '%s' field contains no data.", $f);
}
}
}
next FIELD_LIST;
}
else {
- syslog("LOG_ERR", "C4::Labels::Label::_get_barcode_data : Failed to parse label format string: %s", $f);
+ warn sprintf('Failed to parse label format string: %s', $f);
last FIELD_LIST; # Failed to match
}
}
@label_lines = _split_fcn($field_data) if !@label_lines;
push (@label_lines, $field_data) if !@label_lines;
} else {
- syslog("LOG_ERR", "C4::Labels::Label->draw_label_text : Call number splitting failed for: %s. Please add this call number to bug #2500 at bugs.koha.org", $field_data);
+ warn sprintf('Call number splitting failed for: %s. Please add this call number to bug #2500 at bugs.koha.org', $field_data);
push @label_lines, $field_data;
}
}
);
};
if ($@) {
- syslog("LOG_ERR", "Barcode generation failed for item %s with this error: %s", $self->{'item_number'}, $@);
+ warn sprintf('Barcode generation failed for item %s with this error: %s', $self->{'item_number'}, $@);
}
}
elsif ($params{'barcode_type'} eq 'COOP2OF5') {
);
};
if ($@) {
- syslog("LOG_ERR", "Barcode generation failed for item %s with this error: %s", $self->{'item_number'}, $@);
+ warn sprintf('Barcode generation failed for item %s with this error: %s', $self->{'item_number'}, $@);
}
}
elsif ( $params{'barcode_type'} eq 'INDUSTRIAL2OF5' ) {
);
};
if ($@) {
- syslog("LOG_ERR", "Barcode generation failed for item %s with this error: %s", $self->{'item_number'}, $@);
+ warn sprintf('Barcode generation failed for item %s with this error: %s', $self->{'item_number'}, $@);
}
}
}
use strict;
use warnings;
-use Sys::Syslog qw(syslog);
use DBI qw(neat);
use C4::Context;
my %given_params = @_;
foreach my $key (keys %given_params) {
if (!(grep m/$key/, @valtmpl_id_params)) {
- syslog("LOG_ERR", "C4::Labels::Layout : (Multiple parameters) Unrecognized parameter type of \"%s\".", $key);
+ warn sprintf('(Multiple parameters) Unrecognized parameter type of "%s".', $key);
$exit_code = 1;
}
}
}
else {
if (!(grep m/$_/, @valtmpl_id_params)) {
- syslog("LOG_ERR", "C4::Labels::Layout : (Single parameter) Unrecognized parameter type of \"%s\".", $_);
+ warn sprintf('(Single parameter) Unrecognized parameter type of "%s".', $_);
$exit_code = 1;
}
}
my $sth = C4::Context->dbh->prepare($query);
$sth->execute($opts{'layout_id'});
if ($sth->err) {
- syslog("LOG_ERR", "Database returned the following error: %s", $sth->errstr);
+ warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
my $self = $sth->fetchrow_hashref;
$query_param = $opts{'layout_id'};
}
if ($query_param eq '') { # If there is no layout id then we cannot delete it
- syslog("LOG_ERR", "%s : Cannot delete layout as the layout id is invalid or non-existant.", $call_type);
+ warn sprintf('%s : Cannot delete layout as the layout id is invalid or non-existant.', $call_type);
return -1;
}
my $query = "DELETE FROM labels_layouts WHERE layout_id = ?";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute($query_param);
if ($sth->err) {
- syslog("LOG_ERR", "%s : Database returned the following error: %s", $call_type, $sth->errstr);
+ warn sprintf('%s : Database returned the following error: %s', $call_type, $sth->errstr);
return -1;
}
return 0;
#local $sth->{TraceLevel} = "3"; # enable DBI trace and set level; outputs to STDERR
$sth->execute(@params);
if ($sth->err) {
- syslog("LOG_ERR", "C4::Labels::Layout : Database returned the following error: %s", $sth->errstr);
+ warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
return $self->{'layout_id'};
my $sth = C4::Context->dbh->prepare($query);
$sth->execute(@params);
if ($sth->err) {
- syslog("LOG_ERR", "C4::Labels::Layout : Database returned the following error: %s", $sth->errstr);
+ warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
my $sth1 = C4::Context->dbh->prepare("SELECT MAX(layout_id) FROM labels_layouts;");
=head2 retrieve(layout_id => layout_id)
Invoking the I<retrieve> method constructs a new layout object containing the current values for layout_id. The method returns a new object upon success and 1 upon failure.
- Errors are logged to the syslog.
+ Errors are logged to the Apache log.
example:
C<my $layout = Layout->retrieve(layout_id => 1); # Retrieves layout record 1 and returns an object containing the record>
=head2 delete()
- Invoking the delete method attempts to delete the layout from the database. The method returns 0 upon success and -1 upon failure. Errors are logged to the syslog.
+ Invoking the delete method attempts to delete the layout from the database. The method returns 0 upon success and -1 upon failure. Errors are logged to the Apache log.
NOTE: This method may also be called as a function and passed a key/value pair simply deleteing that template from the database. See the example below.
examples:
=head2 save()
Invoking the I<save> method attempts to insert the layout into the database if the layout is new and update the existing layout record if the layout exists.
- The method returns the new record id upon success and -1 upon failure (This avoids conflicting with a record id of 1). Errors are logged to the syslog.
+ The method returns the new record id upon success and -1 upon failure (This avoids conflicting with a record id of 1). Errors are logged to the Apache log.
example:
C<my $exitstat = $layout->save(); # to save the record behind the $layout object>
use strict;
use warnings;
-use Sys::Syslog qw(syslog);
use Data::Dumper;
use C4::Context;
#=head2 C4::Labels::Lib::_SELECT()
#
-# This function returns a recordset upon success and 1 upon failure. Errors are logged to the syslog.
+# This function returns a recordset upon success and 1 upon failure. Errors are logged to the Apache log.
#
# examples:
#
# $sth->{'TraceLevel'} = 3;
$sth->execute();
if ($sth->err) {
- syslog("LOG_ERR", "C4::Labels::Lib::get_single_field_value : Database returned the following error: %s", $sth->errstr);
+ warn sprintf('Database returned the following error: %s', $sth->errstr);
return 1;
}
my $record_set = [];
=head2 C4::Labels::Lib::get_all_templates()
- This function returns a reference to a hash containing all templates upon success and 1 upon failure. Errors are logged to the syslog.
+ 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:
my $sth = C4::Context->dbh->prepare($query);
$sth->execute();
if ($sth->err) {
- syslog("LOG_ERR", "C4::Labels::Lib::get_all_templates : Database returned the following error: %s", $sth->errstr);
+ warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
ADD_TEMPLATES:
=head2 C4::Labels::Lib::get_all_layouts()
- This function returns a reference to a hash containing all layouts upon success and 1 upon failure. Errors are logged to the syslog.
+ 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:
my $sth = C4::Context->dbh->prepare($query);
$sth->execute();
if ($sth->err) {
- syslog("LOG_ERR", "C4::Labels::Lib::get_all_layouts : Database returned the following error: %s", $sth->errstr);
+ warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
ADD_LAYOUTS:
=head2 C4::Labels::Lib::get_all_profiles()
This function returns an arrayref whose elements are hashes containing all profiles upon success and 1 upon failure. Errors are logged
- to the syslog. Two parameters are accepted. The first limits the field(s) returned. This parameter should be string of comma separted
+ 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.
NOTE: Do not pass in the keyword 'WHERE.'
# $sth->{'TraceLevel'} = 3 if $debug;
$sth->execute();
if ($sth->err) {
- syslog("LOG_ERR", "C4::Labels::Lib::get_all_profiles : Database returned the following error: %s", $sth->errstr);
+ warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
ADD_PROFILES:
=head2 C4::Labels::Lib::get_batch_summary()
This function returns an arrayref whose elements are hashes containing the batch_ids of current batches along with the item count
- for each batch upon success and 1 upon failure. Item counts are stored under the key '_item_count' Errors are logged to the syslog.
+ for each batch upon success and 1 upon failure. Item counts are stored under the key '_item_count' Errors are logged to the Apache log.
One parameter is accepted which limits the records returned based on a string containing a valud SQL 'WHERE' filter.
NOTE: Do not pass in the keyword 'WHERE.'
# $sth->{'TraceLevel'} = 3;
$sth->execute();
if ($sth->err) {
- syslog("LOG_ERR", "C4::Labels::Lib::get_batch_summary : Database returned the following error on attempted SELECT: %s", $sth->errstr);
+ warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
return -1;
}
ADD_BATCHES:
my $sth1 = C4::Context->dbh->prepare($query);
$sth1->execute($batch->{'batch_id'});
if ($sth1->err) {
- syslog("LOG_ERR", "C4::Labels::Lib::get_batch_summary : Database returned the following error on attempted SELECT count: %s", $sth1->errstr);
+ warn sprintf('Database returned the following error on attempted SELECT count: %s', $sth1->errstr);
return -1;
}
my $count = $sth1->fetchrow_arrayref;
=head2 C4::Labels::Lib::get_label_summary()
This function returns an arrayref whose elements are hashes containing the label_ids of current labels along with the item count
- for each label upon success and 1 upon failure. Item counts are stored under the key '_item_count' Errors are logged to the syslog.
+ for each label upon success and 1 upon failure. Item counts are stored under the key '_item_count' Errors are logged to the Apache log.
One parameter is accepted which limits the records returned based on a string containing a valud SQL 'WHERE' filter.
NOTE: Do not pass in the keyword 'WHERE.'
$label_number++;
$sth->execute($item->{'item_number'}, $params{'batch_id'});
if ($sth->err) {
- syslog("LOG_ERR", "C4::Labels::Lib::get_label_summary : Database returned the following error on attempted SELECT: %s", $sth->errstr);
+ warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
return -1;
}
my $record = $sth->fetchrow_hashref;
my $label_summary->{'_label_number'} = $label_number;
$record->{'author'} =~ s/[^\.|\w]$// if $record->{'author'}; # strip off ugly trailing chars... but not periods or word chars
$record->{'title'} =~ s/\W*$//; # strip off ugly trailing chars
+ # FIXME contructing staff interface URLs should be done *much* higher up the stack - for the most part, C4 module code
+ # should not know that it's part of a web app
$record->{'title'} = '<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' . $record->{'biblionumber'} . '"> ' . $record->{'title'} . '</a>';
$label_summary->{'_summary'} = $record->{'title'} . " | " . ($record->{'author'} ? $record->{'author'} : 'N/A');
$label_summary->{'_item_type'} = $record->{'itemtype'};
use strict;
use warnings;
-use Sys::Syslog qw(syslog);
use C4::Context;
use C4::Debug;
$given_params = {@_};
foreach my $key (keys %{$given_params}) {
if (!(grep m/$key/, @valid_profile_params)) {
- syslog("LOG_ERR", "C4::Labels::Profile : Unrecognized parameter type of \"%s\".", $key);
+ warn sprintf('Unrecognized parameter type of "%s".', $key);
$exit_code = 1;
}
}
}
else {
if (!(grep m/$_/, @valid_profile_params)) {
- syslog("LOG_ERR", "C4::Labels::Profile : Unrecognized parameter type of \"%s\".", $_);
+ warn sprintf('Unrecognized parameter type of "%s".', $_);
$exit_code = 1;
}
}
my $sth = C4::Context->dbh->prepare($query);
$sth->execute($opts{profile_id});
if ($sth->err) {
- syslog("LOG_ERR", "Database returned the following error: %s", $sth->errstr);
+ warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
my $self = $sth->fetchrow_hashref;
$query_param = $opts{'profile_id'};
}
if ($query_param eq '') { # If there is no profile id then we cannot delete it
- syslog("LOG_ERR", "%s : Cannot delete layout as the profile id is invalid or non-existant.", $call_type);
+ warn sprintf('%s : Cannot delete layout as the profile id is invalid or non-existant.', $call_type);
return -1;
}
my $query = "DELETE FROM printers_profile WHERE profile_id = ?";
# $sth->{'TraceLevel'} = 3;
$sth->execute(@params);
if ($sth->err) {
- syslog("LOG_ERR", "C4::Labels::Profile : Database returned the following error on attempted UPDATE: %s", $sth->errstr);
+ warn sprintf('Database returned the following error on attempted UPDATE: %s', $sth->errstr);
return -1;
}
return $self->{'profile_id'};
my $sth = C4::Context->dbh->prepare($query);
$sth->execute(@params);
if ($sth->err) {
- syslog("LOG_ERR", "C4::Labels::Profile : Database returned the following error on attempted INSERT: %s", $sth->errstr);
+ warn sprintf('Database returned the following error on attempted INSERT: %s', $sth->errstr);
return -1;
}
my $sth1 = C4::Context->dbh->prepare("SELECT MAX(profile_id) FROM printers_profile;");
return $self->{$attr};
}
else {
- syslog("LOG_ERR", "C4::Labels::Profile : %s is currently undefined.", $attr);
+ warn sprintf('%s is currently undefined.', $attr);
return -1;
}
}
=head2 retrieve(profile_id => $profile_id, convert => 1)
Invoking the I<retrieve> method constructs a new profile object containing the current values for profile_id. The method returns a new object upon success and 1 upon failure.
- Errors are logged to the syslog. One further option maybe accessed. See the examples below for further description.
+ Errors are logged to the Apache log. One further option maybe accessed. See the examples below for further description.
examples:
=head2 delete()
- Invoking the delete method attempts to delete the profile from the database. The method returns -1 upon failure. Errors are logged to the syslog.
+ Invoking the delete method attempts to delete the profile from the database. The method returns -1 upon failure. Errors are logged to the Apache log.
NOTE: This method may also be called as a function and passed a key/value pair simply deleteing that profile from the database. See the example below.
examples:
=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 -1 upon failure (This avoids conflicting with a record profile_id of 1). Errors are logged to the syslog.
+ 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>
use strict;
use warnings;
-use Sys::Syslog qw(syslog);
use PDF::Reuse;
use POSIX qw(ceil);
$given_params = {@_};
foreach my $key (keys %{$given_params}) {
if (!(grep m/$key/, @valid_template_params)) {
- syslog("LOG_ERR", "C4::Labels::Template : Unrecognized parameter type of \"%s\".", $key);
+ warn sprintf('Unrecognized parameter type of "%s".', $key);
$exit_code = 1;
}
}
}
else {
if (!(grep m/$_/, @valid_template_params)) {
- syslog("LOG_ERR", "C4::Labels::Template : Unrecognized parameter type of \"%s\".", $_);
+ warn sprintf('Unrecognized parameter type of "%s".', $_);
$exit_code = 1;
}
}
my $sth = C4::Context->dbh->prepare($query);
$sth->execute($opts{template_id});
if ($sth->err) {
- syslog("LOG_ERR", "Database returned the following error: %s", $sth->errstr);
+ warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
my $self = $sth->fetchrow_hashref;
$query_param = $opts{'template_id'};
}
if ($query_param eq '') { # If there is no template id then we cannot delete it
- syslog("LOG_ERR", "%s : Cannot delete layout as the template id is invalid or non-existant.", $call_type);
+ warn sprintf('%s : Cannot delete layout as the template id is invalid or non-existant.', $call_type);
return -1;
}
my $query = "DELETE FROM labels_templates WHERE template_id = ?";
my $sth = C4::Context->dbh->prepare($query);
$sth->execute(@params);
if ($sth->err) {
- syslog("LOG_ERR", "Database returned the following error: %s", $sth->errstr);
+ warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
$self->{'template_stat'} = 1;
my $sth = C4::Context->dbh->prepare($query);
$sth->execute(@params);
if ($sth->err) {
- syslog("LOG_ERR", "Database returned the following error: %s", $sth->errstr);
+ warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
my $sth1 = C4::Context->dbh->prepare("SELECT MAX(template_id) FROM labels_templates;");
=head2 retrieve(template_id => $template_id)
Invoking the I<retrieve> method constructs a new template object containing the current values for template_id. The method returns
- a new object upon success and -1 upon failure. Errors are logged to the syslog. Two further options may be accessed. See the example
+ a new object upon success and -1 upon failure. Errors are logged to the Apache log. Two further options may be accessed. See the example
below for further description.
examples:
=head2 delete()
- Invoking the delete method attempts to delete the template from the database. The method returns -1 upon failure. Errors are logged to the syslog.
+ Invoking the delete method attempts to delete the template from the database. The method returns -1 upon failure. Errors are logged to the Apache log.
NOTE: This method may also be called as a function and passed a key/value pair simply deleteing that template from the database. See the example below.
examples:
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 -1 upon failure (This avoids template_ids conflicting with a
- record template_id of 1). Errors are logged to the syslog.
+ record template_id of 1). Errors are logged to the Apache log.
example:
C<my $template_id = $template->save(); # to save the record behind the $template object>
use strict;
use warnings;
-use Sys::Syslog qw(syslog);
-
use C4::Context;
use C4::Debug;
use C4::Biblio;
$given_params = {@_};
foreach my $key (keys %{$given_params}) {
if (!(grep m/$key/, @valid_template_params)) {
- syslog("LOG_ERR", "C4::Labels::Batch : Unrecognized parameter type of \"%s\".", $key);
+ warn sprintf('Unrecognized parameter type of "%s".', $key);
$exit_code = 1;
}
}
}
else {
if (!(grep m/$_/, @valid_template_params)) {
- syslog("LOG_ERR", "C4::Labels::Batch : Unrecognized parameter type of \"%s\".", $_);
+ warn sprintf('Unrecognized parameter type of "%s".', $_);
$exit_code = 1;
}
}
Invoking the I<save> method attempts to insert the batch into the database if the batch is new and
update the existing batch record if the batch exists. The method returns the new record batch_id upon
success and -1 upon failure (This avoids conflicting with a record batch_id of 1). Errors are
- logged to the syslog.
+ logged to the Apache log.
example:
my $exitstat = $batch->save(); # to save the record behind the $batch object
my $sth->C4::Context->dbh->prepare($query);
$sth->execute($item_number, $self->{layout_id}, $self->{tmpl_id}, $self->{prof_id}, $self->{batch_id});
if ($sth->err) {
- syslog("LOG_ERR", "Database returned the following error: %s", $sth->errstr);
+ warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
}
my $sth->C4::Context->dbh->prepare($query);
$sth->execute($item_number, $self->{layout_id}, $self->{tmpl_id}, $self->{prof_id});
if ($sth->err) {
- syslog("LOG_ERR", "Database returned the following error: %s", $sth->errstr);
+ warn sprintf('Database returned the following error: %s', $sth->errstr);
return -1;
}
my $sth1 = C4::Context->dbh->prepare("SELECT MAX(batch_id) FROM labels_batches;");
=head2 C4::Labels::Template->retrieve(template_id)
Invoking the I<retrieve> method constructs a new template object containing the current values for template_id. The method returns
- a new object upon success and 1 upon failure. Errors are logged to the syslog. Two further options may be accessed. See the example
+ a new object upon success and 1 upon failure. Errors are logged to the Apache log. Two further options may be accessed. See the example
below for further description.
examples:
my $sth = C4::Context->dbh->prepare($query);
$sth->execute($opts{batch_id});
if ($sth->err) {
- syslog("LOG_ERR", "Database returned the following error: %s", $sth->errstr);
+ warn sprintf('Database returned the following error: %s', $sth->errstr);
return 1;
}
my $self = {
=head2 C4::Labels::Batch->delete(batch_id => batch_id) | $batch->delete()
Invoking the delete method attempts to delete the batch from the database. The method returns 0 upon success
- and 1 upon failure. Errors are logged to the syslog.
+ and 1 upon failure. Errors are logged to the Apache log.
examples:
my $exitstat = $batch->delete(); # to delete the record behind the $batch object
my $self = shift;
my %opts = @_;
if ((ref $self) && !$self->{'batch_id'}) { # If there is no batch batch_id then we cannot delete it from the db
- syslog("LOG_ERR", "Cannot delete batch: Batch has not been saved.");
+ warn 'Cannot delete batch: Batch has not been saved.';
return 1;
}
elsif (!$opts{batch_id}) {
- syslog("LOG_ERR", "Cannot delete batch: Missing batch_id.");
+ warn 'Cannot delete batch: Missing batch_id.';
return 1;
}
my $query = "DELETE FROM labels_batches WHERE batch_id = ?";
<!-- TMPL_IF NAME="err" -->
<div class="yui-u">
<div class="alert">
- <strong>WARNING: An error was encountered and <!-- TMPL_VAR NAME="errstr" --> Please have your system administrator check the syslog for details.</strong>
+ <strong>WARNING: An error was encountered and <!-- TMPL_VAR NAME="errstr" --> Please have your system administrator check the error log for details.</strong>
</div>
</div>
<!-- TMPL_ELSIF NAME="duplicate_message" -->
<!-- TMPL_IF NAME="error" -->
<div class="yui-u">
<div class="alert">
- <strong>WARNING: An error was encountered and <!-- TMPL_VAR NAME="label_element" --> <!-- TMPL_VAR NAME="element_id" --> was not deleted. Please have your system administrator check the syslog for details.</strong>
+ <strong>WARNING: An error was encountered and <!-- TMPL_VAR NAME="label_element" --> <!-- TMPL_VAR NAME="element_id" --> was not deleted. Please have your system administrator check the error log for details.</strong>
</div>
</div>
<!-- /TMPL_IF -->
use warnings;
use CGI;
-use Sys::Syslog qw(syslog);
use Text::CSV_XS;
use Data::Dumper;
print $csv->string() . "\n";
}
else {
- syslog("LOG_ERR", "labels/label-create-csv.pl : Text::CSV_XS->combine() returned the following error: %s", $csv->error_input);
+ warn sprintf('Text::CSV_XS->combine() returned the following error: %s', $csv->error_input);
next CSV_ITEMS;
}
}
use warnings;
use CGI;
-use Sys::Syslog qw(syslog);
use C4::Debug;
use C4::Labels::Batch 1.000000;
use warnings;
use CGI;
-use Sys::Syslog qw(syslog);
use XML::Simple;
use Data::Dumper;
push(@{$xml_data->{'label'}[$item_count]->{$data_fields[$i]}}, $$csv_data[$i]);
}
$item_count++;
-# else {
-# syslog("LOG_ERR", "labels/label-create-csv.pl : Text::CSV_XS->combine() returned the following error: %s", $csv->error_input);
-# next CSV_ITEMS;
-# }
}
#die "XML DATA:\n" . Dumper($xml_data);
use warnings;
use vars qw($debug);
-use Sys::Syslog qw(syslog);
use CGI;
use HTML::Template::Pro;
use strict;
use warnings;
-use Sys::Syslog qw(syslog);
use CGI;
use HTML::Template::Pro;
use POSIX;
my $csv = Text::CSV_XS->new({ allow_whitespace => 1 });
my $status = $csv->parse($format_string);
my @text_fields = $csv->fields();
- syslog("LOG_ERR", "labels/label-edit-layout.pl : Error parsing format_string. Parser returned: %s",$csv->error_input()) if $csv->error_input();
+ warn sprintf('Error parsing format_string. Parser returned: %s', $csv->error_input()) if $csv->error_input();
my $field_count = $#text_fields + 1;
POPULATE_TABLE:
foreach my $text_field (@text_fields) {
}
if ($op eq 'edit') {
- syslog("LOG_ERR", "labels/label-edit-layout.pl : Error performing '%s': No 'layout_id' passed in.", $op) unless ($layout_id);
+ warn sprintf("Error performing '%s': No 'layout_id' passed in.", $op) unless ($layout_id);
$layout = C4::Labels::Layout->retrieve(layout_id => $layout_id);
}
use strict;
use warnings;
-use Sys::Syslog qw(syslog);
use CGI;
use HTML::Template::Pro;
use strict;
use warnings;
-use Sys::Syslog qw(syslog);
use CGI;
use HTML::Template::Pro;
use CGI;
use HTML::Template::Pro;
use List::Util qw( max min );
-use Sys::Syslog qw(syslog);
use POSIX qw(ceil);
use C4::Auth qw(get_template_and_user);
}
else {
# FIXME: Some error trapping code needed
- syslog("LOG_ERR", "labels/label-item-search.pl : No item numbers retrieved for biblio number: %s", $biblionumber);
+ warn sprintf('No item numbers retrieved for biblio number: %s', $biblionumber);
}
}
use warnings;
use vars qw($debug);
-use Sys::Syslog qw(syslog);
use CGI;
use HTML::Template::Pro;
use Data::Dumper;
my $sth = C4::Context->dbh->prepare('SELECT branchcode FROM branches b LIMIT 0,1');
$sth->execute();
my $branch_code = $sth->fetchrow_hashref()->{'branchcode'};
-syslog("LOG_ERR", "t/db_dependent/Labels/t_Batch.t : Database returned the following error: %s", $sth->errstr) if $sth->errstr;
+diag sprintf('Database returned the following error: %s', $sth->errstr) if $sth->errstr;
my $expected_batch = {
items => [],
branch_code => $branch_code,
my $item_number = 0;
diag "Testing Batch->new() method.";
-ok($batch = C4::Labels::Batch->new(branch_code => $branch_code)) || diag "Batch->new() FAILED. Check syslog for details.";
+ok($batch = C4::Labels::Batch->new(branch_code => $branch_code)) || diag "Batch->new() FAILED.";
my $batch_id = $batch->get_attr('batch_id');
$expected_batch->{'batch_id'} = $batch_id;
is_deeply($batch, $expected_batch) || diag "New batch object FAILED to verify.";
my $sth1 = C4::Context->dbh->prepare('SELECT itemnumber FROM items LIMIT 0,10');
$sth1->execute();
while (my $row = $sth1->fetchrow_hashref()) {
- syslog("LOG_ERR", "t/db_dependent/Labels/t_Batch.t : Database returned the following error: %s", $sth1->errstr) if $sth1->errstr;
- ok($batch->add_item($row->{'itemnumber'}) eq 0 ) || diag "Batch->add_item() FAILED. Check syslog for details.";
+ diag sprintf('Database returned the following error: %s', $sth1->errstr) if $sth1->errstr;
+ ok($batch->add_item($row->{'itemnumber'}) eq 0 ) || diag "Batch->add_item() FAILED.";
$item_number = $row->{'itemnumber'};
}
diag "Testing Batch->retrieve() method.";
-ok(my $saved_batch = C4::Labels::Batch->retrieve(batch_id => $batch_id)) || diag "Batch->retrieve() FAILED. Check syslog for details.";
+ok(my $saved_batch = C4::Labels::Batch->retrieve(batch_id => $batch_id)) || diag "Batch->retrieve() FAILED.";
is_deeply($saved_batch, $batch) || diag "Retrieved batch object FAILED to verify.";
diag "Testing Batch->remove_item() method.";
-ok($batch->remove_item($item_number) eq 0) || diag "Batch->remove_item() FAILED. See syslog for details.";
+ok($batch->remove_item($item_number) eq 0) || diag "Batch->remove_item() FAILED.";
my $updated_batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
is_deeply($updated_batch, $batch) || diag "Updated batch object FAILED to verify.";
diag "Testing Batch->delete() method.";
my $del_results = $batch->delete();
-ok($del_results eq 0) || diag "Batch->delete() FAILED. See syslog for details.";
+ok($del_results eq 0) || diag "Batch->delete() FAILED.";
my $layout;
diag "Testing Layout->new() method.";
-ok($layout = C4::Labels::Layout->new(layout_name => 'TEST')) || diag "Layout->new() FAILED. Check syslog for details.";
+ok($layout = C4::Labels::Layout->new(layout_name => 'TEST')) || diag "Layout->new() FAILED";
is_deeply($layout, $default_layout) || diag "New layout object FAILED to verify.";
diag "Testing Layout->get_attr() method.";
diag "Testing Layout->save() method with a new object.";
my $sav_results = $layout->save();
-ok($sav_results ne -1) || diag "Layout->save() FAILED. See syslog for details.";
+ok($sav_results ne -1) || diag "Layout->save() FAILED";
my $saved_layout;
if ($sav_results ne -1) {
diag "Testing Layout->retrieve() method.";
$new_attr->{'layout_id'} = $sav_results;
- ok($saved_layout = C4::Labels::Layout->retrieve(layout_id => $sav_results)) || diag "Layout->retrieve() FAILED. Check syslog for details.";
+ ok($saved_layout = C4::Labels::Layout->retrieve(layout_id => $sav_results)) || diag "Layout->retrieve() FAILED";
is_deeply($saved_layout, $new_attr) || diag "Retrieved layout object FAILED to verify.";
}
$saved_layout->set_attr(font => 'C');
my $upd_results = $saved_layout->save();
-ok($upd_results ne -1) || diag "Layout->save() FAILED. See syslog for details.";
+ok($upd_results ne -1) || diag "Layout->save() FAILED";
my $updated_layout = C4::Labels::Layout->retrieve(layout_id => $sav_results);
is_deeply($updated_layout, $saved_layout) || diag "Updated layout object FAILED to verify.";
diag "Testing Layout->delete() method.";
my $del_results = $updated_layout->delete();
-ok($del_results eq 0) || diag "Layout->delete() FAILED. See syslog for details.";
+ok($del_results eq 0) || diag "Layout->delete() FAILED";
my $err = 0;
diag "Testing Profile->new() method.";
-ok(my $profile = C4::Labels::Profile->new(printer_name => 'Circulation Desk',paper_bin => 'bypass')) || diag"Profile->new() FAILED. Check syslog for details.";
+ok(my $profile = C4::Labels::Profile->new(printer_name => 'Circulation Desk',paper_bin => 'bypass')) || diag"Profile->new() FAILED.";
is_deeply($profile, $expected_profile) || diag "New profile object FAILED to verify.";
diag "Testing Profile->get_attr() method.";
foreach my $key (keys %{$expected_profile}) {
- ok($expected_profile->{$key} eq $profile->get_attr($key)) || diag "Profile->get_attr() FAILED on attribute $key. Check syslog for details.";
+ ok($expected_profile->{$key} eq $profile->get_attr($key)) || diag "Profile->get_attr() FAILED on attribute $key.";
}
diag "Testing Profile->set_attr() method.";
diag "Testing Profile->save() method with a new object.";
my $sav_results = $profile->save();
-ok($sav_results ne -1) || diag "Profile->save() FAILED. See syslog for details.";
+ok($sav_results ne -1) || diag "Profile->save() FAILED.";
my $saved_profile;
if ($sav_results ne -1) {
diag "Testing Profile->retrieve() method.";
$new_attr->{'profile_id'} = $sav_results;
- ok($saved_profile = C4::Labels::Profile->retrieve(profile_id => $sav_results)) || diag "Profile->retrieve() FAILED. Check syslog for details.";
+ ok($saved_profile = C4::Labels::Profile->retrieve(profile_id => $sav_results)) || diag "Profile->retrieve() FAILED.";
is_deeply($saved_profile, $new_attr) || diag "Retrieved profile object FAILED to verify.";
}
$err = 0; # Reset error code
$err = $saved_profile->set_attr(units => 'CM');
my $upd_results = $saved_profile->save();
-ok(($upd_results ne -1) && ($err lt 1)) || diag "Profile->save() FAILED. See syslog for details.";
+ok(($upd_results ne -1) && ($err lt 1)) || diag "Profile->save() FAILED.";
my $updated_profile = C4::Labels::Profile->retrieve(profile_id => $sav_results);
is_deeply($updated_profile, $saved_profile) || diag "Updated layout object FAILED to verify.";
diag "Testing Profile->delete() method.";
my $del_results = $updated_profile->delete();
-ok($del_results ne -1) || diag "Profile->delete() FAILED. See syslog for details.";
+ok($del_results ne -1) || diag "Profile->delete() FAILED.";
my $template;
diag "Testing Template->new() method.";
-ok($template = C4::Labels::Template->new(page_width => 8.5,cols => 3)) || diag "Template->new() FAILED. Check syslog for details.";
+ok($template = C4::Labels::Template->new(page_width => 8.5,cols => 3)) || diag "Template->new() FAILED.";
is_deeply($template, $expect_template) || diag "New template object FAILED to verify.";
diag "Testing Template->get_attr() method.";
diag "Testing Template->save() method with a new object.";
my $sav_results = $template->save();
-ok($sav_results ne -1) || diag "Template->save() FAILED. See syslog for details.";
+ok($sav_results ne -1) || diag "Template->save() FAILED.";
my $saved_template;
if ($sav_results ne -1) {
diag "Testing Template->retrieve() method.";
$new_attr->{'template_id'} = $sav_results;
- ok($saved_template = C4::Labels::Template->retrieve(template_id => $sav_results)) || diag "Template->retrieve() FAILED. Check syslog for details.";
+ ok($saved_template = C4::Labels::Template->retrieve(template_id => $sav_results)) || diag "Template->retrieve() FAILED.";
is_deeply($saved_template, $new_attr) || diag "Retrieved template object FAILED to verify.";
}
$saved_template->set_attr(template_desc => 'A test template');
my $upd_results = $saved_template->save();
-ok($upd_results ne -1) || diag "Template->save() FAILED. See syslog for details.";
+ok($upd_results ne -1) || diag "Template->save() FAILED.";
my $updated_template = C4::Labels::Template->retrieve(template_id => $sav_results);
is_deeply($updated_template, $saved_template) || diag "Updated template object FAILED to verify.";
diag "Testing Template->delete() method.";
my $del_results = $updated_template->delete();
-ok($del_results ne -1) || diag "Template->delete() FAILED. See syslog for details.";
+ok($del_results ne -1) || diag "Template->delete() FAILED.";
use CGI;
use CGI::Cookie;
use MARC::File::USMARC;
-use Sys::Syslog qw(syslog);
# Koha modules used
use C4::Context;
my $batch = C4::Labels::Batch->new(branch_code => $branch_code);
my @items = GetItemNumbersFromImportBatch($batch_id);
if (grep{$_ == 0} @items) {
- syslog("LOG_ERR", "tools/manage-marc-import.pl : create_labelbatch_from_importbatch() : Call to C4::ImportBatch::GetItemNumbersFromImportBatch returned no item number(s) from import batch #%s.", $batch_id);
+ warn sprintf('create_labelbatch_from_importbatch() : Call to C4::ImportBatch::GetItemNumbersFromImportBatch returned no item number(s) from import batch #%s.', $batch_id);
return -1;
}
foreach my $item_number (@items) {
$err = $batch->add_item($item_number);
if ($err == -1) {
- syslog("LOG_ERR", "tools/manage-marc-import.pl : create_labelbatch_from_importbatch() : Error attempting to add item #%s of import batch #%s to label batch.", $item_number, $batch_id);
+ warn sprintf('create_labelbatch_from_importbatch() : Error attempting to add item #%s of import batch #%s to label batch.', $item_number, $batch_id);
return -1;
}
}