-
-=head2 GetNotifyId
-
- ($notify_id) = &GetNotifyId($borrowernumber,$itemnumber);
-
-Returns the file number per borrower and itemnumber
-
-C<$borrowernumber> is a reference-to-hash whose keys are all of the fields
-from the items tables of the Koha database. Thus,
-
-C<$itemnumber> contains the borrower categorycode
-
-C<$notify_id> contains the file number for the borrower number nad item number
-
-=cut
-
-sub GetNotifyId {
- my ( $borrowernumber, $itemnumber ) = @_;
- my $query = qq|SELECT notify_id
- FROM accountlines
- WHERE borrowernumber=?
- AND itemnumber=?
- AND (accounttype='FU' or accounttype='O')|;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare($query);
- $sth->execute( $borrowernumber, $itemnumber );
- my ($notify_id) = $sth->fetchrow;
- $sth->finish;
- return ($notify_id);
-}
-
-=head2 CreateItemAccountLine
-
- () = &CreateItemAccountLine($borrowernumber, $itemnumber, $date, $amount,
- $description, $accounttype, $amountoutstanding,
- $timestamp, $notify_id, $level);
-
-update the account lines with file number or with file level
-
-C<$items> is a reference-to-hash whose keys are all of the fields
-from the items tables of the Koha database. Thus,
-
-C<$itemnumber> contains the item number
-
-C<$borrowernumber> contains the borrower number
-
-C<$date> contains the date of the day
-
-C<$amount> contains item price
-
-C<$description> contains the descritpion of accounttype
-
-C<$accounttype> contains the account type
-
-C<$amountoutstanding> contains the $amountoutstanding
-
-C<$timestamp> contains the timestamp with time and the date of the day
-
-C<$notify_id> contains the file number
-
-C<$level> contains the file level
-
-=cut
-
-sub CreateItemAccountLine {
- my (
- $borrowernumber, $itemnumber, $date, $amount,
- $description, $accounttype, $amountoutstanding, $timestamp,
- $notify_id, $level
- ) = @_;
- my $dbh = C4::Context->dbh;
- my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
- my $query = "INSERT into accountlines
- (borrowernumber,accountno,itemnumber,date,amount,description,accounttype,amountoutstanding,timestamp,notify_id,notify_level)
- VALUES
- (?,?,?,?,?,?,?,?,?,?,?)";
-
- my $sth = $dbh->prepare($query);
- $sth->execute(
- $borrowernumber, $nextaccntno, $itemnumber,
- $date, $amount, $description,
- $accounttype, $amountoutstanding, $timestamp,
- $notify_id, $level
- );
-}
-
-=head2 UpdateAccountLines
-
- () = &UpdateAccountLines($notify_id,$notify_level,$borrowernumber,$itemnumber);
-
-update the account lines with file number or with file level
-
-C<$items> is a reference-to-hash whose keys are all of the fields
-from the items tables of the Koha database. Thus,
-
-C<$itemnumber> contains the item number
-
-C<$notify_id> contains the file number
-
-C<$notify_level> contains the file level
-
-C<$borrowernumber> contains the borrowernumber
-
-=cut
-
-sub UpdateAccountLines {
- my ( $notify_id, $notify_level, $borrowernumber, $itemnumber ) = @_;
- my $query;
- if ( $notify_id eq '' ) {
- $query = qq|UPDATE accountlines
- SET notify_level=?
- WHERE borrowernumber=? AND itemnumber=?
- AND (accounttype='FU' or accounttype='O')|;
- } else {
- $query = qq|UPDATE accountlines
- SET notify_id=?, notify_level=?
- WHERE borrowernumber=?
- AND itemnumber=?
- AND (accounttype='FU' or accounttype='O')|;
- }
-
- my $sth = C4::Context->dbh->prepare($query);
- if ( $notify_id eq '' ) {
- $sth->execute( $notify_level, $borrowernumber, $itemnumber );
- } else {
- $sth->execute( $notify_id, $notify_level, $borrowernumber, $itemnumber );
- }
-}
-