use C4::Stats;
use C4::Members;
use C4::Items;
+use C4::Circulation;
-#use C4::Circulation;
use vars qw($VERSION @ISA @EXPORT);
BEGIN {
# set the version for version checking
- $VERSION = 3.01;
+ $VERSION = 3.02;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(
&recordpayment &fixaccounts &makepayment &manualinvoice
- &getnextacctno &reconcileaccount
+ &getnextacctno &reconcileaccount &getcharges &getcredits
+ &getrefunds
);
}
);
$usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft );
$usth->finish;
- UpdateStats( $branch, 'payment', $data, '', '', '', $borrowernumber );
+ UpdateStats( $branch, 'payment', $data, '', '', '', $borrowernumber, $nextaccntno );
$sth->finish;
}
EOT
}
-# FIXME - Never used, but not exported, either.
sub returnlost {
my ( $borrowernumber, $itemnum ) = @_;
- my $dbh = C4::Context->dbh;
+ C4::Circulation::MarkIssueReturned( $borrowernumber, $itemnum );
my $borrower = C4::Members::GetMember( $borrowernumber, 'borrowernumber' );
- my $sth = $dbh->prepare(
- "UPDATE issues SET returndate=now() WHERE
- borrowernumber=? AND itemnumber=? AND returndate IS NULL"
- );
- $sth->execute( $borrowernumber, $itemnum );
- $sth->finish;
my @datearr = localtime(time);
- my $date =
- ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3];
- my $bor =
-"$borrower->{'firstname'} $borrower->{'surname'} $borrower->{'cardnumber'}";
+ my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3];
+ my $bor = "$borrower->{'firstname'} $borrower->{'surname'} $borrower->{'cardnumber'}";
ModItem({ paidfor => "Paid for by $bor $date" }, undef, $itemnum);
}
return ($amountleft);
}
+sub getcharges {
+ my ( $borrowerno, $timestamp, $accountno ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $timestamp2 = $timestamp - 1;
+ my $query = "";
+ my $sth = $dbh->prepare(
+ "SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?"
+ );
+ $sth->execute( $borrowerno, $accountno );
+
+ my @results;
+ while ( my $data = $sth->fetchrow_hashref ) {
+ push @results,$data;
+ }
+ return (@results);
+}
+
+
+sub getcredits {
+ my ( $date, $date2 ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare(
+ "SELECT * FROM accountlines,borrowers
+ WHERE amount < 0 AND accounttype <> 'Pay' AND accountlines.borrowernumber = borrowers.borrowernumber
+ AND timestamp >=TIMESTAMP(?) AND timestamp < TIMESTAMP(?)"
+ );
+
+ $sth->execute( $date, $date2 );
+ my @results;
+ while ( my $data = $sth->fetchrow_hashref ) {
+ $data->{'date'} = $data->{'timestamp'};
+ push @results,$data;
+ }
+ return (@results);
+}
+
+
+sub getrefunds {
+ my ( $date, $date2 ) = @_;
+ my $dbh = C4::Context->dbh;
+
+ my $sth = $dbh->prepare(
+ "SELECT *,timestamp AS datetime
+ FROM accountlines,borrowers
+ WHERE (accounttype = 'REF'
+ AND accountlines.borrowernumber = borrowers.borrowernumber
+ AND date >=? AND date <?)"
+ );
+
+ $sth->execute( $date, $date2 );
+
+ my @results;
+ while ( my $data = $sth->fetchrow_hashref ) {
+ push @results,$data;
+
+ }
+ return (@results);
+}
END { } # module clean-up code here (global destructor)
1;