use Koha::CirculationRules;
use Koha::Database;
use Koha::DateUtils qw( dt_from_string output_pref );
-use Koha::Hold;
use Koha::Holds;
use Koha::ItemTypes;
use Koha::Items;
use Koha::Libraries;
-use Koha::Old::Hold;
+use Koha::Old::Holds;
use Koha::Patrons;
use Koha::Plugins;
my $itemtype = $params->{itemtype};
my $non_priority = $params->{non_priority};
- $resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' })
- or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
-
- $patron_expiration_date = output_pref({ str => $patron_expiration_date, dateonly => 1, dateformat => 'iso' });
+ $resdate ||= dt_from_string;
# if we have an item selectionned, and the pickup branch is the same as the holdingbranch
# of the document, we force the value $priority and $found .
my ( $notissued, $reserved );
( $notissued ) = $dbh->selectrow_array( $issue_qry, undef,
( $biblionumber ) );
- if( $notissued ) {
+ if( $notissued == 0 ) {
+ # all items are issued
( $reserved ) = $dbh->selectrow_array( $holds_qry, undef,
( $biblionumber, $borrowernumber ) );
$fee = 0 if $reserved == 0;
+ } else {
+ $fee = 0;
}
}
return $fee;
if C4::Context->preference('HoldsLog');
# The only column that can be updated for a found hold is the expiration date
- $hold->expirationdate(dt_from_string($date))->store();
+ $hold->expirationdate($date)->store();
}
elsif ($rank =~ /^\d+/ and $rank > 0) {
logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold )
if ( defined( $suspend_until ) ) {
if ( $suspend_until ) {
- $suspend_until = eval { dt_from_string( $suspend_until ) };
$hold->suspend_hold( $suspend_until );
} else {
# If the hold is suspended leave the hold suspended, but convert it to an indefinite hold.
sub ToggleSuspend {
my ( $reserve_id, $suspend_until ) = @_;
- $suspend_until = dt_from_string($suspend_until) if ($suspend_until);
-
my $hold = Koha::Holds->find( $reserve_id );
if ( $hold->is_suspended ) {
my $suspend_until = $params{'suspend_until'} || undef;
my $suspend = defined( $params{'suspend'} ) ? $params{'suspend'} : 1;
- $suspend_until = eval { dt_from_string($suspend_until) }
- if ( defined($suspend_until) );
-
return unless ( $borrowernumber || $biblionumber );
my $params;
sub _koha_notify_reserve {
my $reserve_id = shift;
- my $notify_library = shift;
my $hold = Koha::Holds->find($reserve_id);
my $borrowernumber = $hold->borrowernumber;
} );
my $library = Koha::Libraries->find( $hold->branchcode );
- my $admin_email_address = $library->from_email_address;
- $library = $library->unblessed;
+ my $inbound_email_address = $library->inbound_email_address;
my %letter_params = (
module => 'reserves',
branchcode => $hold->branchcode,
lang => $patron->lang,
tables => {
- 'branches' => $library,
+ 'branches' => $library->unblessed,
'borrowers' => $patron->unblessed,
'biblio' => $hold->biblionumber,
'biblioitems' => $hold->biblionumber,
C4::Letters::EnqueueLetter( {
letter => $letter,
borrowernumber => $borrowernumber,
- from_address => $admin_email_address,
+ from_address => $inbound_email_address,
message_transport_type => $mtt,
} );
};
&$send_notification('print', 'HOLD');
}
- if ($notify_library) {
- my $letter = C4::Letters::GetPreparedLetter(
- module => 'reserves',
- letter_code => 'HOLD_CHANGED',
- branchcode => $hold->branchcode,
- substitute => { today => output_pref( dt_from_string ) },
- tables => {
- 'branches' => $library,
- 'borrowers' => $patron->unblessed,
- 'biblio' => $hold->biblionumber,
- 'biblioitems' => $hold->biblionumber,
- 'reserves' => $hold->unblessed,
- 'items' => $hold->itemnumber,
- },
- );
-
- my $email =
- C4::Context->preference('ExpireReservesAutoFillEmail')
- || $library->{branchemail}
- || C4::Context->preference('KohaAdminEmailAddress');
-
- C4::Letters::EnqueueLetter(
- {
- letter => $letter,
- borrowernumber => $borrowernumber,
- message_transport_type => 'email',
- from_address => $email,
- to_address => $email,
- }
- );
- }
}
=head2 _koha_notify_hold_changed
my $email =
C4::Context->preference('ExpireReservesAutoFillEmail')
- || $library->branchemail
- || C4::Context->preference('KohaAdminEmailAddress');
+ || $library->inbound_email_address;
C4::Letters::EnqueueLetter(
{