Bugzilla – Attachment 181340 Details for
Bug 9762
Log circulation overrides
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9762: Log circulation overrides
Bug-9762-Log-circulation-overrides.patch (text/plain), 41.00 KB, created by
Martin Renvoize (ashimema)
on 2025-04-23 08:28:39 UTC
(
hide
)
Description:
Bug 9762: Log circulation overrides
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-04-23 08:28:39 UTC
Size:
41.00 KB
patch
obsolete
>From fe52f2f744b9acada8cecefd20e80f462227b375 Mon Sep 17 00:00:00 2001 >From: emilyrose <emily-rose.francoeur@inLibro.com> >Date: Tue, 26 Sep 2023 08:44:24 -0400 >Subject: [PATCH] Bug 9762: Log circulation overrides >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch allows you to save commands that have been overridden by someone. > >The patch has been updated but is not yet completed. Tests 10, 13, 14, and 17 are still not functional. Tests 15 and 16 need to be fixed as they do not display the barcode. All other tests should be functional. > >To test: > >--After each step, a message will be displayed in the action_logs table and in Tools > Log viewer -- > >Circulation -- Checking out > >1) Check out an item that is age-restricted (AgeRestrictionOverride syspref) >2) Check out an item that has a ânot for loanâ status (AllowNotForLoanOverride syspref) >3) Check out an item that has a âlostâ status (IssueLostItem syspref) >4) Check out an item to a patron who has reached the checkout limit (AllowTooManyOverride syspref) >5) Check out an item to a patron who is not allowed to borrow this item type >6) Check out an item to a patron who has unpaid fines (AllFinesNeedOverride and/or AllowFineOverride + noissuescharge sysprefs) >7) Check out an item on hold for someone else >8) Check out an item on hold ready for pickup by someone else >9) Check out an item already checked out to someone else (AutoReturnCheckedOutItems syspref) >10) Check out to a patron who has restrictions > >Circulation -- Checking in > >11) Ignore a hold upon check in >12) Ignore a hold and transfer upon check in > >Circulation â Renewing > >13) Renew an item on hold for someone else (AllowRenewalOnHoldOverride syspref) >14) Renew an item that has reached the maximum number of renewals (AllowRenewalLimitOverride syspref) > >Holds > >15) Place a hold for a patron who is not allowed to place this item type on hold (AllowHoldPolicyOverride syspref) >16) Place a hold for a patron who has reached the maximum number of holds >17) Place an item-level hold when rules dictate that this is not allowed (In circulation rules put "On shelf holds allowed" to "If any unavailable") >--- > C4/Circulation.pm | 161 +++++++++++++++++++++++++++++++++++++++++++- > circ/circulation.pl | 97 +++++++++++++++----------- > circ/renew.pl | 55 ++++++++++++++- > circ/returns.pl | 86 ++++++++++++++--------- > reserve/request.pl | 80 +++++++++++++--------- > svc/renew | 54 +++++++++++++++ > 6 files changed, 425 insertions(+), 108 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 31794b7c02f..97f492614f5 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -22,11 +22,12 @@ use Modern::Perl; > use DateTime; > use POSIX qw( floor ); > use Encode; >+use JSON; > > use C4::Context; > use C4::Stats qw( UpdateStats ); > use C4::Reserves >- qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority RevertWaitingStatus IsAvailableForItemLevelRequest ); >+ qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority RevertWaitingStatus IsItemOnHoldAndFound IsAvailableForItemLevelRequest ); > use C4::Biblio qw( UpdateTotalIssues ); > use C4::Items qw( ModItemTransfer ModDateLastSeen CartToShelf ); > use C4::Accounts; >@@ -319,6 +320,21 @@ A recall for this item was found, and the item needs to be transferred to the re > > =cut > >+my $query = CGI->new; >+ >+my $stickyduedate = $query->param('stickyduedate'); >+my $duedatespec = $query->param('duedatespec'); >+my $restoreduedatespec = $query->param('restoreduedatespec') || $duedatespec; >+if ( $restoreduedatespec && $restoreduedatespec eq "highholds_empty" ) { >+ undef $restoreduedatespec; >+} >+my $issueconfirmed = $query->param('issueconfirmed'); >+my $cancelreserve = $query->param('cancelreserve'); >+my $cancel_recall = $query->param('cancel_recall'); >+my $recall_id = $query->param('recall_id'); >+my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice >+my $charges = $query->param('charges') || q{}; >+ > sub transferbook { > my $params = shift; > my $tbr = $params->{to_branch}; >@@ -816,9 +832,22 @@ sub CanBookBeIssued { > my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); > > my $now = dt_from_string(); >+ my $message; >+ my @message; >+ > $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); >+ > if ( DateTime->compare( $duedate, $now ) == -1 ) { # duedate cannot be before now > $needsconfirmation{INVALID_DATE} = $duedate; >+ if ($issueconfirmed) { >+ if ($message) { >+ $message = "$message + sticky due date is invalid or due date in the past"; >+ } else { >+ $message = "sticky due date is invalid or due date in the past"; >+ } >+ push( @message, "sticky due date is invalid or due date in the past" ); >+ } >+ > } > > my $fees = Koha::Charges::Fees->new( >@@ -864,6 +893,14 @@ sub CanBookBeIssued { > } > if ( $patron->is_debarred ) { > $issuingimpossible{DEBARRED} = 1; >+ if ($issueconfirmed) { >+ if ($message) { >+ $message = "$message + borrower is restricted"; >+ } else { >+ $message = "borrower is restricted"; >+ } >+ push( @message, "borrower is restricted" ); >+ } > } > > if ( $patron->is_expired ) { >@@ -936,10 +973,26 @@ sub CanBookBeIssued { > } else { > if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) { > $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; >+ if ($issueconfirmed) { >+ if ($message) { >+ $message = "$message + borrower had amend"; >+ } else { >+ $message = "borrower had amend"; >+ } >+ push( @message, "borrower had amend" ); >+ } > } elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) { > $issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; > } elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) { > $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; >+ if ($issueconfirmed) { >+ if ($message) { >+ $message = "$message + borrower had amend"; >+ } else { >+ $message = "borrower had amend"; >+ } >+ push( @message, "borrower had amend" ); >+ } > } > } > >@@ -1020,6 +1073,14 @@ sub CanBookBeIssued { > $needsconfirmation{issued_surname} = $patron->surname; > $needsconfirmation{issued_cardnumber} = $patron->cardnumber; > $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; >+ if ($issueconfirmed) { >+ if ($message) { >+ $message = "$message + item is checked out for someone else "; >+ } else { >+ $message = "item is checked out for someone else"; >+ } >+ push( @message, "item is checked out for someone else" ); >+ } > } > } > } >@@ -1047,6 +1108,14 @@ sub CanBookBeIssued { > $needsconfirmation{current_loan_count} = $toomany->{count}; > $needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; > $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule}; >+ if ($issueconfirmed) { >+ if ($message) { >+ $message = "$message + too many checkout"; >+ } else { >+ $message = "too many checkout"; >+ } >+ push( @message, "too many checkout" ); >+ } > } else { > $issuingimpossible{TOO_MANY} = $toomany->{reason}; > $issuingimpossible{current_loan_count} = $toomany->{count}; >@@ -1074,6 +1143,14 @@ sub CanBookBeIssued { > } else { > $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; > $needsconfirmation{item_notforloan} = $item_object->notforloan; >+ if ($issueconfirmed) { >+ if ($message) { >+ $message = "$message + item not for loan"; >+ } else { >+ $message = "item not for loan"; >+ } >+ push( @message, "item not for loan" ); >+ } > } > } else { > >@@ -1119,6 +1196,14 @@ sub CanBookBeIssued { > my $code = $av->count ? $av->next->lib : ''; > $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); > $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); >+ if ($issueconfirmed) { >+ if ($message) { >+ $message = "$message + item lost"; >+ } else { >+ $message = "item lost"; >+ } >+ push( @message, "item lost" ); >+ } > } > if ( C4::Context->preference("IndependentBranches") ) { > my $userenv = C4::Context->userenv; >@@ -1219,6 +1304,16 @@ sub CanBookBeIssued { > $needsconfirmation{'resbranchcode'} = $res->{branchcode}; > $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; > $needsconfirmation{'reserve_id'} = $res->{reserve_id}; >+ >+ if ($issueconfirmed) { >+ if ($message) { >+ $message = >+ "$message + item is on reserve and waiting, but has been reserved by some other patron."; >+ } else { >+ $message = "item is on reserve and waiting, but has been reserved by some other patron."; >+ } >+ push( @message, "item is on reserve and waiting, but has been reserved by some other patron" ); >+ } > } elsif ( $restype eq "Reserved" ) { > > # The item is on reserve for someone else. >@@ -1230,6 +1325,15 @@ sub CanBookBeIssued { > $needsconfirmation{'resbranchcode'} = $res->{branchcode}; > $needsconfirmation{'resreservedate'} = $res->{reservedate}; > $needsconfirmation{'reserve_id'} = $res->{reserve_id}; >+ >+ if ($issueconfirmed) { >+ if ($message) { >+ $message = "$message + item is on reserve for someone else"; >+ } else { >+ $message = "item is on reserve for someone else"; >+ } >+ push( @message, "item is on reserve for someone else" ); >+ } > } elsif ( $restype eq "Transferred" ) { > > # The item is determined hold being transferred for someone else. >@@ -1241,6 +1345,15 @@ sub CanBookBeIssued { > $needsconfirmation{'resbranchcode'} = $res->{branchcode}; > $needsconfirmation{'resreservedate'} = $res->{reservedate}; > $needsconfirmation{'reserve_id'} = $res->{reserve_id}; >+ >+ if ($issueconfirmed) { >+ if ($message) { >+ $message = "$message + item is determined hold being transferred for someone else"; >+ } else { >+ $message = "item is determined hold being transferred for someone else"; >+ } >+ push( @message, "item is determined hold being transferred for someone else" ); >+ } > } elsif ( $restype eq "Processing" ) { > > # The item is determined hold being processed for someone else. >@@ -1252,6 +1365,15 @@ sub CanBookBeIssued { > $needsconfirmation{'resbranchcode'} = $res->{branchcode}; > $needsconfirmation{'resreservedate'} = $res->{reservedate}; > $needsconfirmation{'reserve_id'} = $res->{reserve_id}; >+ >+ if ($issueconfirmed) { >+ if ($message) { >+ $message = "$message + item is determined hold being processed for someone else"; >+ } else { >+ $message = "item is determined hold being processed for someone else"; >+ } >+ push( @message, "item is determined hold being processed for someone else" ); >+ } > } > } > } >@@ -1295,6 +1417,12 @@ sub CanBookBeIssued { > if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) { > if ( C4::Context->preference('AgeRestrictionOverride') ) { > $needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; >+ if ($message) { >+ $message = "$message + age restriction"; >+ } else { >+ $message = "age restriction"; >+ } >+ push( @message, "age restriction" ); > } else { > $issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; > } >@@ -1353,6 +1481,35 @@ sub CanBookBeIssued { > } > } > >+ my $borrower = $patron; >+ my $user = C4::Context->userenv->{number}; >+ my $branchcode = C4::Context->userenv->{branch}; >+ my $item = Koha::Items->find( { barcode => $barcode } ); >+ my $itemnumber = $item->itemnumber; >+ >+ # action, cardnumber, barcode, date, heure, user, branche >+ if ($issueconfirmed) { >+ >+ my $infos = ( >+ { >+ message => \@message, >+ borrowernumber => $borrower->borrowernumber, >+ barcode => $barcode, >+ manager_id => $user, >+ branchcode => $branchcode, >+ } >+ ); >+ >+ my $json_infos = JSON->new->utf8->pretty->encode($infos); >+ $json_infos =~ s/"/'/g; >+ >+ logaction( >+ "CIRCULATION", "ISSUE", >+ $borrower->{'borrowernumber'}, >+ $json_infos, >+ ) if C4::Context->preference("IssueLog"); >+ } >+ > return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); > } > >@@ -3200,7 +3357,7 @@ sub CanBookBeRenewed { > > foreach my $other_item (@other_items) { > next if defined $matched_items{ $other_item->itemnumber }; >- next if $other_item->holds->filter_by_found->count; >+ next if IsItemOnHoldAndFound( $other_item->itemnumber ); > next unless IsAvailableForItemLevelRequest( $other_item, $patron_with_reserve, undef ); > next > unless CanItemBeReserved( >diff --git a/circ/circulation.pl b/circ/circulation.pl >index e7732bfdc7b..3ac158f0026 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -36,9 +36,10 @@ use C4::Auth qw( get_session get_template_and_user ); > use C4::Koha; > use C4::Circulation qw( barcodedecode CanBookBeIssued AddIssue AddReturn ); > use C4::Members; >-use C4::Biblio qw( TransformMarcToKoha ); >-use C4::Search qw( new_record_from_zebra ); >-use C4::Reserves qw( ModReserveAffect ); >+use C4::Biblio qw( TransformMarcToKoha ); >+use C4::Search qw( new_record_from_zebra ); >+use C4::Reserves; >+use C4::Log qw( logaction ); > use Koha::Holds; > use C4::Context; > use CGI::Session; >@@ -52,7 +53,6 @@ use Koha::Plugins; > use Koha::Database; > use Koha::BiblioFrameworks; > use Koha::Items; >-use Koha::CirculationRules; > use Koha::SearchEngine; > use Koha::SearchEngine::Search; > use Koha::Patron::Modifications; >@@ -112,7 +112,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >-my $op = $query->param('op') // ''; >+my $op = $query->param('op'); > my $override_high_holds = $query->param('override_high_holds'); > my $override_high_holds_tmp = $query->param('override_high_holds_tmp'); > >@@ -239,7 +239,7 @@ if ( @$barcodes == 0 && $charges eq 'yes' ) { > # STEP 2 : FIND BORROWER > # if there is a list of find borrowers.... > # >-my $message; >+ > if ($findborrower) { > Koha::Plugins->call( 'patron_barcode_transform', \$findborrower ); > my $patron = Koha::Patrons->find( { cardnumber => $findborrower } ); >@@ -325,6 +325,9 @@ if ($patron) { > # STEP 3 : ISSUING > # > # >+my $message; >+my @message; >+ > if ( @$barcodes && $op eq 'cud-checkout' ) { > my $checkout_infos; > for my $barcode (@$barcodes) { >@@ -370,16 +373,19 @@ if ( @$barcodes && $op eq 'cud-checkout' ) { > } > > if ( $issuingimpossible->{'STATS'} ) { >- my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) = >- AddReturn( $item->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 ); >+ $template->param( STATS => 1 ); > >- $template->param( >- STATS => 1, >- CHECKEDIN => $stats_return, >- MESSAGES => $stats_messages, >- ITEM => $stats_iteminformation, >- BORROWER => $stats_borrower, >- ); >+ if ( $item->onloan ) { >+ my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) = >+ AddReturn( $item->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 ); >+ >+ $template->param( >+ CHECKEDIN => $stats_return, >+ MESSAGES => $stats_messages, >+ ITEM => $stats_iteminformation, >+ BORROWER => $stats_borrower, >+ ); >+ } > > #increment items.localuse > my $localuse_count = $item->localuse; >@@ -483,39 +489,19 @@ if ( @$barcodes && $op eq 'cud-checkout' ) { > $template_params->{ADDITIONAL_MATERIALS} = $materials; > $template_params->{itemhomebranch} = $item->homebranch; > >- my $patron_session_confirmation = $query->cookie('patronSessionConfirmation') || undef; >- my ( $patron_for_session, $session_confirmations ) = split( /:/, $patron_session_confirmation, 2 ); >- my $patron_match = $borrowernumber == $patron_for_session; >- my @conf_keys = split( /\|/, $session_confirmations ); >- $template_params->{sessionConfirmationKeys} = (); >- > # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed. > foreach my $needsconfirmation_key ( keys %$needsconfirmation ) { >- if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) { >- my $rule = Koha::CirculationRules->get_effective_rule( >- { >- rule_name => 'bookings_lead_period', >- itemtype => $item->effective_itemtype, >- branchcode => "*" >- } >- ); >- my $preparation_period = $rule ? $rule->rule_value : 1; >- my $reduceddue = dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date ) >- >- ->subtract( days => $preparation_period ); >- $template_params->{reduceddue} = $reduceddue; >- } >- next >- if $patron_match >- && scalar(@conf_keys) > 0 >- && grep( { $needsconfirmation_key eq $_ } @conf_keys ); >- > $template_params->{$needsconfirmation_key} = $needsconfirmation->{$needsconfirmation_key}; > $template_params->{getTitleMessageIteminfo} = $biblio->title; > $template_params->{getBarcodeMessageIteminfo} = $item->barcode; > $template_params->{NEEDSCONFIRMATION} = 1; > $confirm_required = 1; >- push( @{ $template_params->{sessionConfirmationKeys} }, $needsconfirmation_key ); >+ if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) { >+ my $reduceddue = >+ dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date ) >+ ->subtract( days => 1 ); >+ $template_params->{reduceddue} = $reduceddue; >+ } > } > } > unless ($confirm_required) { >@@ -531,6 +517,7 @@ if ( @$barcodes && $op eq 'cud-checkout' ) { > } > ); > $recall_id = ( $recall and $recall->id ) ? $recall->id : undef; >+ > } > > # If booked (alerts or confirmation) update datedue to end of booking >@@ -548,6 +535,34 @@ if ( @$barcodes && $op eq 'cud-checkout' ) { > } > ); > $template_params->{issue} = $issue; >+ >+ my $borrower = $patron; >+ my $borrowernumber = $patron->borrowernumber; >+ my $user = C4::Context->userenv->{number}; >+ my $branchcode = C4::Context->userenv->{branch}; >+ $message = "Restriction overridden temporarily"; >+ @message = ("Restriction overridden temporarily"); >+ >+ if ($issueconfirmed) { >+ my $infos = ( >+ { >+ message => \@message, >+ borrowernumber => $borrowernumber, >+ barcode => $barcode, >+ manager_id => $user, >+ branchcode => $branchcode, >+ } >+ ); >+ >+ my $json_infos = JSON->new->utf8->pretty->encode($infos); >+ $json_infos =~ s/"/'/g; >+ >+ logaction( >+ "CIRCULATION", "ISSUE", >+ $borrower->{'borrowernumber'}, >+ $json_infos, >+ ) if C4::Context->preference("IssueLog"); >+ } > $session->clear('auto_renew'); > $inprocess = 1; > } >diff --git a/circ/renew.pl b/circ/renew.pl >index c27881a494c..2260f458c23 100755 >--- a/circ/renew.pl >+++ b/circ/renew.pl >@@ -24,6 +24,7 @@ use C4::Context; > use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); > use C4::Circulation qw( barcodedecode CanBookBeRenewed GetLatestAutoRenewDate AddRenewal ); >+use C4::Log qw( logaction ); > use Koha::DateUtils qw( dt_from_string ); > use Koha::Database; > use Koha::BiblioFrameworks; >@@ -64,8 +65,14 @@ if ( $op eq 'cud-renew' && $barcode ) { > if ($checkout) { > > $patron = $checkout->patron; >- >- if ( ( $patron->is_debarred || q{} ) lt dt_from_string()->ymd() ) { >+ my $borrower = $patron; >+ my $borrowernumber = $borrower->borrowernumber; >+ my $user = C4::Context->userenv->{number}; >+ my $branchcode = C4::Context->userenv->{branch}; >+ my $message; >+ my @message; >+ >+ if ( ( $borrower->debarred() || q{} ) lt dt_from_string()->ymd() ) { > my $can_renew; > my $info; > ( $can_renew, $error, $info ) = CanBookBeRenewed( $patron, $checkout, $override_limit ); >@@ -74,6 +81,28 @@ if ( $op eq 'cud-renew' && $barcode ) { > if ($override_holds) { > $can_renew = 1; > $error = undef; >+ >+ $message = "Override Renew hold for another"; >+ @message = ("Override Renew hold for another"); >+ >+ my $infos = ( >+ { >+ message => \@message, >+ borrowernumber => $borrowernumber, >+ barcode => $barcode, >+ manager_id => $user, >+ branchcode => $branchcode, >+ } >+ ); >+ >+ my $json_infos = JSON->new->utf8->pretty->encode($infos); >+ $json_infos =~ s/"/'/g; >+ >+ logaction( >+ "CIRCULATION", "RENEWAL", >+ $borrower->{'borrowernumber'}, >+ $json_infos, >+ ) if C4::Context->preference("RenewalLog"); > } else { > $can_renew = 0; > } >@@ -104,6 +133,28 @@ if ( $op eq 'cud-renew' && $barcode ) { > } > ); > $template->param( date_due => $date_due ); >+ >+ $message = "Override limit Renew"; >+ @message = ("Override limit Renew"); >+ >+ my $infos = ( >+ { >+ message => \@message, >+ borrowernumber => $borrowernumber, >+ barcode => $barcode, >+ manager_id => $user, >+ branchcode => $branchcode, >+ } >+ ); >+ >+ my $json_infos = JSON->new->utf8->pretty->encode($infos); >+ $json_infos =~ s/"/'/g; >+ >+ logaction( >+ "CIRCULATION", "RENEWAL", >+ $borrower->{'borrowernumber'}, >+ $json_infos, >+ ) if C4::Context->preference("RenewalLog"); > } > } else { > $error = "patron_restricted"; >diff --git a/circ/returns.pl b/circ/returns.pl >index c9c89593a82..f100ac6a21c 100755 >--- a/circ/returns.pl >+++ b/circ/returns.pl >@@ -35,13 +35,15 @@ use CGI qw ( -utf8 ); > use DateTime; > > use C4::Auth qw( get_template_and_user get_session haspermission ); >-use C4::Circulation qw( barcodedecode GetBranchItemRule AddReturn LostItem ); >+use C4::Circulation qw( barcodedecode GetBranchItemRule AddReturn updateWrongTransfer LostItem ); > use C4::Context; >+use C4::Items qw( ModItemTransfer ); > use C4::Members::Messaging; > use C4::Members; > use C4::Output qw( output_html_with_http_headers ); > use C4::Reserves qw( ModReserve ModReserveAffect CheckReserves ); > use C4::RotatingCollections; >+use C4::Log qw( logaction ); > use Koha::AuthorisedValues; > use Koha::BiblioFrameworks; > use Koha::Calendar; >@@ -111,7 +113,7 @@ for my $counter ( $query->multi_param("checkin_counter") ) { > last if ++$i >= $returned_counter; > } > >-my $op = $query->param('op') // ''; >+my $op = $query->param('op'); > > ############ > # Deal with the requests.... >@@ -151,13 +153,50 @@ if ( $query->param('reserve_id') && $op eq 'cud-affect_reserve' ) { > ModReserveAffect( $itemnumber, $borrowernumber, $diffBranchSend, $reserve_id, $desk_id ); > > if ($diffBranchSend) { >- my $tobranch = $hold->pickup_library(); >- >- # Add transfer, enqueue if one is already in the queue, and immediately set to in transit >- my $transfer = $item->request_transfer( { to => $tobranch, reason => 'Reserve', enqueue => 1 } ); >- $transfer->transit; >+ ModItemTransfer( $itemnumber, $userenv_branch, $diffBranchSend, 'Reserve' ); > } > } >+ >+ # check if we have other reserves for this document, if we have a result send the message of transfer >+ # FIXME do we need to do this if we didn't take the cancel_reserve branch above? >+ my ( undef, $nextreservinfo, undef ) = CheckReserves($item); >+ >+ if ( $userenv_branch ne $nextreservinfo->{'branchcode'} ) { >+ my $patron = Koha::Patrons->find( $nextreservinfo->{'borrowernumber'} ); >+ $template->param( >+ itemtitle => $biblio->title, >+ itembiblionumber => $biblio->biblionumber, >+ iteminfo => $biblio->author, >+ patron => $patron, >+ diffbranch => 1, >+ ); >+ } >+} else { >+ my $message = "return an element that is reserved"; >+ my @message = ("return an element that is reserved"); >+ my $user = C4::Context->userenv->{number}; >+ my $branchcode = C4::Context->userenv->{branch}; >+ my $barcode = $query->param('barcode'); >+ >+ my $infos = ( >+ { >+ message => \@message, >+ >+ #'card number' => $cardnumber, >+ barcode => $barcode, >+ manager_id => $user, >+ branchcode => $branchcode, >+ } >+ ); >+ >+ my $json_infos = JSON->new->utf8->pretty->encode($infos); >+ $json_infos =~ s/"/'/g; >+ >+ logaction( >+ "CIRCULATION", "RETURN", >+ $session, >+ $json_infos, >+ ) if C4::Context->preference("ReturnLog"); > } > > if ( $query->param('recall_id') && $op eq 'cud-affect_recall' ) { >@@ -218,15 +257,13 @@ if ($return_date_override) { > } > } > >-# If 'needstransfer' was set and the librarian has chosen to initiate the transfer > if ( $op eq 'cud-dotransfer' ) { >+ >+ # An item has been returned to a branch other than the homebranch, and the librarian has chosen to initiate a transfer > my $transferitem = $query->param('transferitem'); >- my $item = Koha::Items->find($transferitem); >- my $tobranchcode = $query->param('tobranch'); >- my $tobranch = Koha::Libraries->find($tobranchcode); >+ my $tobranch = $query->param('tobranch'); > my $trigger = $query->param('trigger'); >- my $transfer = $item->request_transfer( { to => $tobranch, reason => $trigger } ); >- $transfer->transit; >+ ModItemTransfer( $transferitem, $userenv_branch, $tobranch, $trigger ); > } > > if ( $transit && $op eq 'cud-transfer' ) { >@@ -414,11 +451,7 @@ if ( $barcode && ( $op eq 'cud-checkin' || $op eq 'cud-affect_reserve' ) ) { > } > > # Mark missing bundle items as lost and report unexpected items >- if ( $item >- && $item->is_bundle >- && $query->param('confirm_items_bundle_return') >- && !$query->param('do_not_verify_items_bundle_contents') ) >- { >+ if ( $item && $item->is_bundle && $query->param('confirm_items_bundle_return') ) { > my $BundleLostValue = C4::Context->preference('BundleLostValue'); > my $barcodes = $query->param('verify-items-bundle-contents-barcodes'); > my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes ); >@@ -513,7 +546,6 @@ if ( $messages->{'WasTransfered'} ) { > $template->param( > found => 1, > transfer => $messages->{'WasTransfered'}, >- transferto => $messages->{'TransferTo'}, > trigger => $messages->{'TransferTrigger'}, > itemnumber => $itemnumber, > ); >@@ -547,10 +579,8 @@ if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'} ) { > ); > > # Update the transfer to reflect the new item holdingbranch >- my $item = Koha::Items->find( $messages->{'WrongTransferItem'} ); >- my $old_transfer = $item->get_transfer; >- my $new_transfer = $item->request_transfer( >- { to => $old_transfer->to_library, reason => $old_transfer->reason, replace => 'WrongTransfer' } ); >+ my $new_transfer = >+ updateWrongTransfer( $messages->{'WrongTransferItem'}, $messages->{'WrongTransfer'}, $userenv_branch ); > $template->param( NewTransfer => $new_transfer->id ); > > my $reserve = $messages->{'ResFound'}; >@@ -583,11 +613,7 @@ if ( $messages->{'ResFound'} ) { > ModReserveAffect( $itemnumber, $reserve->{borrowernumber}, $diffBranchSend, $reserve->{reserve_id}, $desk_id ); > > if ($diffBranchSend) { >- my $tobranch = Koha::Libraries->find( $reserve->{branchcode} ); >- >- # Add transfer, enqueue if one is already in the queue, and immediately set to in transit >- my $transfer = $item->request_transfer( { to => $tobranch, reason => 'Reserve', enqueue => 1 } ); >- $transfer->transit; >+ ModItemTransfer( $itemnumber, $item->holdingbranch, $reserve->{branchcode}, 'Reserve' ); > } > > $template->param( >@@ -679,8 +705,6 @@ foreach my $code ( keys %$messages ) { > $err{waslost} = 1; > } elsif ( $code eq 'LostItemFeeRefunded' ) { > $template->param( LostItemFeeRefunded => 1 ); >- } elsif ( $code eq 'LostItemPaymentNotRefunded' ) { >- $template->param( LostItemPaymentNotRefunded => 1 ); > } elsif ( $code eq 'LostItemFeeCharged' ) { > $template->param( LostItemFeeCharged => 1 ); > } elsif ( $code eq 'LostItemFeeRestored' ) { >@@ -693,8 +717,6 @@ foreach my $code ( keys %$messages ) { > ; # FIXME... anything to do here? > } elsif ( $code eq 'WasTransfered' ) { > ; # FIXME... anything to do here? >- } elsif ( $code eq 'TransferTo' ) { >- ; # Handled above, along with WasTransfered > } elsif ( $code eq 'withdrawn' ) { > $err{withdrawn} = 1; > } elsif ( $code eq 'WrongTransfer' ) { >diff --git a/reserve/request.pl b/reserve/request.pl >index c5e354aa7d2..3ec07c9cc97 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -26,6 +26,7 @@ script to place reserves/requests > =cut > > use Modern::Perl; >+use Data::Dumper; > > use CGI qw ( -utf8 ); > use List::MoreUtils qw( uniq ); >@@ -33,13 +34,14 @@ use Date::Calc qw( Date_to_Days ); > use C4::Output qw( output_html_with_http_headers ); > use C4::Auth qw( get_template_and_user ); > use C4::Reserves >- qw( RevertWaitingStatus AlterPriority ToggleLowestPriority CanBookBeReserved GetMaxPatronHoldsForRecord CanItemBeReserved IsAvailableForItemLevelRequest ); >+ qw( RevertWaitingStatus AlterPriority ToggleLowestPriority ToggleSuspend CanBookBeReserved GetMaxPatronHoldsForRecord CanItemBeReserved IsAvailableForItemLevelRequest ); > use C4::Items qw( get_hostitemnumbers_of ); > use C4::Koha qw( getitemtypeimagelocation ); > use C4::Serials qw( CountSubscriptionFromBiblionumber ); > use C4::Circulation qw( _GetCircControlBranch GetBranchItemRule ); > use Koha::DateUtils qw( dt_from_string ); > use C4::Search qw( enabled_staff_search_views ); >+use C4::Log qw( logaction ); > > use Koha::Biblios; > use Koha::Checkouts; >@@ -88,8 +90,7 @@ my $warnings; > my $messages; > my $exceeded_maxreserves; > my $exceeded_holds_per_record; >-my @failed_holds = $input->multi_param('failed_holds'); >-my $form_submitted = $input->param('form_submitted'); >+my @failed_holds = $input->multi_param('failed_holds'); > > my $op = $input->param('op') || q{}; > >@@ -117,15 +118,10 @@ if ( $op eq 'cud-move' ) { > } elsif ( $op eq 'cud-setLowestPriority' ) { > my $reserve_id = $input->param('reserve_id'); > ToggleLowestPriority($reserve_id); >-} elsif ( $op eq 'cud-suspend' ) { >+} elsif ( $op eq 'cud-toggleSuspend' ) { > my $reserve_id = $input->param('reserve_id'); > my $suspend_until = $input->param('suspend_until'); >- my $hold = Koha::Holds->find($reserve_id); >- $hold->suspend_hold($suspend_until) if $hold; >-} elsif ( $op eq 'cud-unsuspend' ) { >- my $reserve_id = $input->param('reserve_id'); >- my $hold = Koha::Holds->find($reserve_id); >- $hold->resume() if $hold; >+ ToggleSuspend( $reserve_id, $suspend_until ); > } elsif ( $op eq 'cud-cancel_bulk' ) { > my $cancellation_reason = $input->param("cancellation-reason"); > my @hold_ids = split( ',', scalar $input->param("ids") ); >@@ -146,29 +142,24 @@ if ($findborrower) { > $borrowernumber_hold = $patron->borrowernumber if $patron; > } > >-if ($form_submitted) { >- if ($findclub) { >- my $club = Koha::Clubs->find( { name => $findclub } ); >- if ($club) { >- $club_hold = $club->id; >+if ($findclub) { >+ my $club = Koha::Clubs->find( { name => $findclub } ); >+ if ($club) { >+ $club_hold = $club->id; >+ } else { >+ my @clubs = Koha::Clubs->search( >+ [ >+ { name => { like => '%' . $findclub . '%' } }, >+ { description => { like => '%' . $findclub . '%' } } >+ ] >+ )->as_list; >+ if ( scalar @clubs == 1 ) { >+ $club_hold = $clubs[0]->id; >+ } elsif (@clubs) { >+ $template->param( clubs => \@clubs ); > } else { >- my @clubs = Koha::Clubs->search( >- [ >- { name => { like => '%' . $findclub . '%' } }, >- { description => { like => '%' . $findclub . '%' } } >- ] >- )->as_list; >- if ( scalar @clubs == 1 ) { >- $club_hold = $clubs[0]->id; >- } elsif (@clubs) { >- $template->param( clubs => \@clubs ); >- } else { >- $messageclub = "'$findclub'"; >- } >+ $messageclub = "'$findclub'"; > } >- } else { >- my @clubs = Koha::Clubs->search()->as_list; >- $template->param( clubs => \@clubs ); > } > } > >@@ -561,6 +552,33 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) > $num_alreadyheld++; > } > >+ my $borrower = $patron; >+ my $borrowernumber = $patron->borrowernumber; >+ my $user = C4::Context->userenv->{number}; >+ my $branchcode = C4::Context->userenv->{branch}; >+ my $message = "Override limitation of hold"; >+ my @message = ("Override limitation of hold"); >+ my $barcode = $item->{barcode}; >+ >+ my $infos = ( >+ { >+ message => \@message, >+ borrowernumber => $borrowernumber, >+ barcode => $barcode, >+ manager_id => $user, >+ branchcode => $branchcode, >+ } >+ ); >+ >+ my $json_infos = JSON->new->utf8->pretty->encode($infos); >+ $json_infos =~ s/"/'/g; >+ >+ logaction( >+ "HOLD", "ISSUE", >+ $borrower->{'borrowernumber'}, >+ $json_infos, >+ ) if C4::Context->preference("IssueLog"); >+ > push( @available_itemtypes, $item->{itype} ); > } else { > >diff --git a/svc/renew b/svc/renew >index b995a6ef344..9f0543268dd 100755 >--- a/svc/renew >+++ b/svc/renew >@@ -26,6 +26,7 @@ use Try::Tiny; > use C4::Circulation qw( AddRenewal CanBookBeRenewed ); > use C4::Context; > use C4::Auth qw(check_cookie_auth); >+use C4::Log qw( logaction ); > > use Koha::DateUtils qw(output_pref dt_from_string); > >@@ -53,6 +54,10 @@ my $date_due; > if ( $input->param('date_due') ) { > $date_due = dt_from_string( scalar $input->param('date_due') ); > } >+my $borrower = Koha::Patrons->find($borrowernumber); >+my $user = C4::Context->userenv->{'number'}; >+my $message; >+my @message; > > my $data; > $data->{itemnumber} = $itemnumber; >@@ -69,6 +74,55 @@ my $item = Koha::Items->find($itemnumber); > if ( $data->{error} && $data->{error} eq 'on_reserve' && C4::Context->preference('AllowRenewalOnHoldOverride') ) { > $data->{renew_okay} = 1; > $data->{error} = undef; >+ >+ $message = "Override Renew hold for another"; >+ @message = ("Override Renew hold for another"); >+ >+ my $infos = ( >+ { >+ message => \@message, >+ borrowernumber => $borrowernumber, >+ barcode => $item->barcode, >+ manager_id => $user, >+ branchcode => $branchcode, >+ } >+ ); >+ >+ my $json_infos = JSON->new->utf8->pretty->encode($infos); >+ $json_infos =~ s/"/'/g; >+ >+ logaction( >+ "CIRCULATION", "RENEWAL", >+ $borrower->{'borrowernumber'}, >+ $json_infos, >+ ) if C4::Context->preference("IssueLog"); >+} >+ >+if ( $data->{error} && $data->{error} eq 'too_many' && C4::Context->preference('AllowRenewalLimitOverride') ) { >+ $data->{renew_okay} = 1; >+ $data->{error} = undef; >+ >+ $message = "Override limit Renew"; >+ @message = ("Override limit Renew"); >+ >+ my $infos = ( >+ { >+ message => \@message, >+ borrowernumber => $borrowernumber, >+ barcode => $item->barcode, >+ manager_id => $user, >+ branchcode => $branchcode, >+ } >+ ); >+ >+ my $json_infos = JSON->new->utf8->pretty->encode($infos); >+ $json_infos =~ s/"/'/g; >+ >+ logaction( >+ "CIRCULATION", "RENEWAL", >+ $borrower->{'borrowernumber'}, >+ $json_infos, >+ ) if C4::Context->preference("IssueLog"); > } > > if ( $data->{renew_okay} || ( $seen && $data->{error} eq 'too_unseen' ) ) { >-- >2.49.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9762
:
149554
|
156222
|
163847
|
164022
|
164067
|
164068
|
164302
|
164387
|
164426
|
164479
|
164508
|
164509
|
164510
|
164519
|
170271
|
170272
|
170273
|
176742
|
177294
|
177295
|
177296
|
178029
|
178030
|
178031
|
178036
|
181303
|
181304
|
181305
|
181306
|
181307
|
181308
|
181340
|
181341
|
181342
|
181343
|
181344
|
181345
|
181346
|
181357
|
181358
|
181359
|
181360
|
181361
|
181362
|
181363
|
181371
|
181381
|
181390
|
181393
|
181545
|
181546