use C4::Reserves;
use C4::Koha;
use C4::Biblio;
+use C4::Items;
use C4::Members;
use C4::Dates;
use Date::Calc qw(
use Data::Dumper;
-our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,%EXPORT_TAGS);
-
-# set the version for version checking
-$VERSION = 3.00;
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+
+BEGIN {
+ # set the version for version checking
+ $VERSION = 3.01;
+ @ISA = qw(Exporter);
+
+ # FIXME subs that should probably be elsewhere
+ push @EXPORT, qw(
+ &FixOverduesOnReturn
+ &cuecatbarcodedecode
+ );
+
+ # subs to deal with issuing a book
+ push @EXPORT, qw(
+ &CanBookBeIssued
+ &CanBookBeRenewed
+ &AddIssue
+ &AddRenewal
+ &GetRenewCount
+ &GetItemIssue
+ &GetItemIssues
+ &GetBorrowerIssues
+ &GetIssuingCharges
+ &GetBiblioIssues
+ &AnonymiseIssueHistory
+ );
+
+ # subs to deal with returns
+ push @EXPORT, qw(
+ &AddReturn
+ );
+
+ # subs to deal with transfers
+ push @EXPORT, qw(
+ &transferbook
+ &GetTransfers
+ &GetTransfersFromTo
+ &updateWrongTransfer
+ &DeleteTransfer
+ );
+}
=head1 NAME
=head1 FUNCTIONS
-=cut
-
-@ISA = qw(Exporter);
-
-# FIXME subs that should probably be elsewhere
-push @EXPORT, qw(
- &FixOverduesOnReturn
- &cuecatbarcodedecode
-);
-
-# subs to deal with issuing a book
-push @EXPORT, qw(
- &CanBookBeIssued
- &CanBookBeRenewed
- &AddIssue
- &AddRenewal
- &GetRenewCount
- &GetItemIssue
- &GetItemIssues
- &GetBorrowerIssues
- &GetIssuingCharges
- &GetBiblioIssues
- &AnonymiseIssueHistory
-);
-# subs to deal with returns
-push @EXPORT, qw(
- &AddReturn
-);
-
-# subs to deal with transfers
-push @EXPORT, qw(
- &transferbook
- &GetTransfers
- &GetTransfersFromTo
- &updateWrongTransfer
- &DeleteTransfer
-);
-
-# FIXME - At least, I'm pretty sure this is for decoding CueCat stuff.
-# FIXME From Paul : i don't understand what this sub does & why it has to be called on every circ. Speak of this with chris maybe ?
-
=head2 decode
=head3 $str = &decode($chunk);
=cut
+# FIXME - At least, I'm pretty sure this is for decoding CueCat stuff.
+# FIXME From Paul : i don't understand what this sub does & why it has to be called on every circ. Speak of this with chris maybe ?
+
sub cuecatbarcodedecode {
my ($barcode) = @_;
chomp($barcode);
# check the 2 parameters (branch / itemtype / default categorycode
$sth->execute( '*', $type, $branch );
- my $result = $sth->fetchrow_hashref;
+ $result = $sth->fetchrow_hashref;
# warn "*, $type, $branch = ".Data::Dumper::Dumper($result);
if ( $result->{maxissueqty} ne '' ) {
# check the 1 parameters (default branch / itemtype / categorycode
$sth->execute( $cat_borrower, $type, '*' );
- my $result = $sth->fetchrow_hashref;
+ $result = $sth->fetchrow_hashref;
# warn "$cat_borrower, $type, * = ".Data::Dumper::Dumper($result);
if ( $result->{maxissueqty} ne '' ) {
# check the 0 parameters (default branch / itemtype / default categorycode
$sth->execute( '*', $type, '*' );
- my $result = $sth->fetchrow_hashref;
+ $result = $sth->fetchrow_hashref;
# warn "*, $type, * = ".Data::Dumper::Dumper($result);
if ( $result->{maxissueqty} ne '' ) {
}
# now checking for total
$sth->execute( '*', '*', '*' );
- my $result = $sth->fetchrow_hashref;
+ $result = $sth->fetchrow_hashref;
if ( $result->{maxissueqty} ne '' ) {
warn "checking total";
$sth2->execute( $borrower->{'borrowernumber'}, $type );
);
$sth->finish;
$item->{'issues'}++;
- $sth =
- $dbh->prepare(
- "UPDATE items SET issues=?, holdingbranch=?, itemlost=0, datelastborrowed = now(), onloan = ? WHERE itemnumber=?");
- $sth->execute(
- $item->{'issues'},
- C4::Context->userenv->{'branch'},
- $dateduef->output('iso'),
- $item->{'itemnumber'}
- );
- $sth->finish;
- &ModDateLastSeen( $item->{'itemnumber'} );
- my $record = GetMarcItem( $item->{'biblionumber'}, $item->{'itemnumber'} );
- my $frameworkcode = GetFrameworkCode( $item->{'biblionumber'} );
- ModItemInMarc( $record, $item->{'biblionumber'}, $item->{'itemnumber'}, $frameworkcode );
+ ModItem({ issues => $item->{'issues'},
+ holdingbranch => C4::Context->userenv->{'branch'},
+ itemlost => 0,
+ datelastborrowed => C4::Dates->new()->output('iso'),
+ onloan => $dateduef->output('iso'),
+ }, $item->{'biblionumber'}, $item->{'itemnumber'});
+ ModDateLastSeen( $item->{'itemnumber'} );
+
# If it costs to borrow this book, charge it to the patron's account.
my ( $charge, $itemtype ) = GetIssuingCharges(
$item->{'itemnumber'},
$iteminformation->{'holdingbranch'} = C4::Context->userenv->{'branch'};
}
ModDateLastSeen( $iteminformation->{'itemnumber'} );
- my $sth = $dbh->prepare("UPDATE items SET onloan = NULL where itemnumber = ?");
- $sth->execute($iteminformation->{'itemnumber'});
- $sth->finish();
- my $record = GetMarcItem( $biblio->{'biblionumber'}, $iteminformation->{'itemnumber'} );
- my $frameworkcode = GetFrameworkCode( $biblio->{'biblionumber'} );
- ModItemInMarc( $record, $biblio->{'biblionumber'}, $iteminformation->{'itemnumber'}, $frameworkcode );
+ ModItem({ onloan => undef }, $biblio->{'biblionumber'}, $iteminformation->{'itemnumber'});
if ($iteminformation->{borrowernumber}){
($borrower) = C4::Members::GetMemberDetails( $iteminformation->{borrowernumber}, 0 );
VALUES (?,?,?,?)");
$usth->execute($borrower->{'borrowernumber'},$data->{'accountno'},$nextaccntno,$offset);
$usth->finish;
- $usth = $dbh->prepare("UPDATE items SET paidfor='' WHERE itemnumber=?");
- $usth->execute($itm);
- $usth->finish;
+ ModItem({ paidfor => '' }, undef, $itm);
}
$sth->finish;
return;
C<$itemnumber> is the itemnumber
Returns an array of hashes
+
=cut
sub GetItemIssue {
C<$history> is 0 if you want actuel "issuer" (if it exist) and 1 if you want issues history
Returns an array of hashes
+
=cut
sub GetItemIssues {
# Update the renewal count on the item, and tell zebra to reindex
$renews = $biblio->{'renewals'} + 1;
- $sth = $dbh->prepare("UPDATE items SET renewals = ? WHERE itemnumber = ?");
- $sth->execute($renews,$itemnumber);
- $sth->finish();
- my $record = GetMarcItem( $biblio->{'biblionumber'}, $itemnumber );
- my $frameworkcode = GetFrameworkCode( $biblio->{'biblionumber'} );
- ModItemInMarc( $record, $biblio->{'biblionumber'}, $itemnumber, $frameworkcode );
+ ModItem({ renewals => $renews }, $biblio->{'biblionumber'}, $itemnumber);
# Charge a new rental fee, if applicable?
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
$items = UpdateHoldingbranch($branch,$itmenumber);
Simple methode for updating hodlingbranch in items BDD line
+
=cut
sub UpdateHoldingbranch {
- my ( $branch,$itmenumber ) = @_;
- my $dbh = C4::Context->dbh;
-# first step validate the actual line of transfert .
- my $sth =
- $dbh->prepare(
- "update items set holdingbranch = ? where itemnumber= ?"
- );
- $sth->execute($branch,$itmenumber);
- $sth->finish;
-
-
+ my ( $branch,$itemnumber ) = @_;
+ ModItem({ holdingbranch => $branch }, undef, $itemnumber);
}
+
=head2 CheckValidDatedue
$newdatedue = CheckValidDatedue($date_due,$itemnumber,$branchcode);
C<$date_due> = returndate calculate with no day check
C<$itemnumber> = itemnumber
C<$branchcode> = localisation of issue
+
=cut
+
# Why not create calendar object? -
# TODO add 'duedate' option to useDaysMode .
sub CheckValidDatedue {
my $newdatedue=C4::Dates->new(sprintf("%04d-%02d-%02d",$years,$month,$day),'iso');
return $newdatedue;
}
+
=head2 CheckRepeatableHolidays
$countrepeatable = CheckRepeatableHoliday($itemnumber,$week_day,$branchcode);
C<$day> = the day of datedue
C<$itemnumber> = itemnumber
C<$branchcode> = localisation of issue
+
=cut
+
sub CheckSpecialHolidays{
my ($years,$month,$day,$itemnumber,$branchcode) = @_;
my $dbh = C4::Context->dbh;
C<$day> = the day of datedue
C<$itemnumber> = itemnumber
C<$branchcode> = localisation of issue
+
=cut
+
sub CheckRepeatableSpecialHolidays{
my ($month,$day,$itemnumber,$branchcode) = @_;
my $dbh = C4::Context->dbh;