From 3ee016b41a319ecbddd1240ebf2ce1384675697e Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 5 Mar 2026 11:48:33 -0500 Subject: [PATCH] Bug 41993: (follow-up) Tidy and other QA fixes Fixing issues raised by the QA tool --- Koha/Items.pm | 33 +- Koha/REST/V1/Items.pm | 12 +- .../paths/items_available_for_booking.yaml | 2 +- circ/available-bookings.pl | 12 +- .../prog/en/includes/circ-nav.inc | 126 +++---- .../en/modules/circ/available-bookings.tt | 337 +++++++++--------- 6 files changed, 263 insertions(+), 259 deletions(-) mode change 100644 => 100755 circ/available-bookings.pl diff --git a/Koha/Items.pm b/Koha/Items.pm index 4eec60514e5..36f9aae3190 100644 --- a/Koha/Items.pm +++ b/Koha/Items.pm @@ -205,7 +205,7 @@ during the specified period (not booked and not checked out). =cut sub filter_by_bookable { - my ($self, $params) = @_; + my ( $self, $params ) = @_; my $bookable_items; if ( !C4::Context->preference('item-level_itypes') ) { @@ -232,7 +232,7 @@ sub filter_by_bookable { ); } - return $self->_filter_by_availability($bookable_items, $params); + return $self->_filter_by_availability( $bookable_items, $params ); } =head3 _filter_by_availability @@ -242,7 +242,7 @@ Internal helper method to filter items by availability during a date range. =cut sub _filter_by_availability { - my ($self, $bookable_items, $params) = @_; + my ( $self, $bookable_items, $params ) = @_; return $bookable_items unless $params && $params->{start_date} && $params->{end_date}; @@ -267,17 +267,20 @@ sub _filter_by_availability { ); my $item_start_date = $start_date->clone; - my $item_end_date = $end_date->clone; + my $item_end_date = $end_date->clone; - if (defined $processing_rules->{'bookings_lead_period'} && $processing_rules->{'bookings_lead_period'} ne '') { + if ( defined $processing_rules->{'bookings_lead_period'} && $processing_rules->{'bookings_lead_period'} ne '' ) + { my $lead_days = $processing_rules->{'bookings_lead_period'}; - $item_start_date->subtract(days => $lead_days); + $item_start_date->subtract( days => $lead_days ); $item_start_date->set_hour(0)->set_minute(0)->set_second(0); } - if (defined $processing_rules->{'bookings_trail_period'} && $processing_rules->{'bookings_trail_period'} ne '') { + if ( defined $processing_rules->{'bookings_trail_period'} + && $processing_rules->{'bookings_trail_period'} ne '' ) + { my $trail_days = $processing_rules->{'bookings_trail_period'}; - $item_end_date->add(days => $trail_days); + $item_end_date->add( days => $trail_days ); $item_end_date->set_hour(23)->set_minute(59)->set_second(59); } @@ -313,18 +316,20 @@ sub _filter_by_availability { } ); - my $checkout = $item->checkout; + my $checkout = $item->checkout; my $checkout_conflicts = 0; if ($checkout) { - my $due_date = dt_from_string($checkout->date_due); + my $due_date = dt_from_string( $checkout->date_due ); $checkout_conflicts = 1 if $due_date >= $item_start_date; } - if ($existing_bookings->count > 0 || $checkout_conflicts) { + if ( $existing_bookings->count > 0 || $checkout_conflicts ) { push @excluded_items, $item->itemnumber; + # Debug - uncomment to see why items are excluded: # warn "EXCLUDED Item #" . $item->itemnumber . " - Bookings: " . $existing_bookings->count . ", Checkout conflicts: $checkout_conflicts, Lead: " . ($processing_rules->{'bookings_lead_period'} // 'none') . ", Trail: " . ($processing_rules->{'bookings_trail_period'} // 'none'); } else { + # Debug - uncomment to see items that pass: # warn "PASSED Item #" . $item->itemnumber . " - Lead: " . ($processing_rules->{'bookings_lead_period'} // 'none') . ", Trail: " . ($processing_rules->{'bookings_trail_period'} // 'none'); } @@ -333,9 +338,7 @@ sub _filter_by_availability { $bookable_items->reset; if (@excluded_items) { - return $bookable_items->search({ - 'me.itemnumber' => { '-not_in' => \@excluded_items } - }); + return $bookable_items->search( { 'me.itemnumber' => { '-not_in' => \@excluded_items } } ); } return $bookable_items; @@ -889,4 +892,4 @@ Martin Renvoize =cut -1; \ No newline at end of file +1; diff --git a/Koha/REST/V1/Items.pm b/Koha/REST/V1/Items.pm index 9ddcb46d787..cd4ba22eb63 100644 --- a/Koha/REST/V1/Items.pm +++ b/Koha/REST/V1/Items.pm @@ -437,18 +437,20 @@ sub available_for_booking { return try { my $start_date = $c->param('start_date'); - my $end_date = $c->param('end_date'); + my $end_date = $c->param('end_date'); $c->req->params->remove('start_date'); $c->req->params->remove('end_date'); my $items_set = Koha::Items->new->filter_by_bookable( - ($start_date && $end_date) ? { + ( $start_date && $end_date ) + ? { start_date => $start_date, - end_date => $end_date, - } : undef + end_date => $end_date, + } + : undef ); - my $items = $c->objects->search( $items_set ); + my $items = $c->objects->search($items_set); return $c->render( status => 200, openapi => $items ); } catch { diff --git a/api/v1/swagger/paths/items_available_for_booking.yaml b/api/v1/swagger/paths/items_available_for_booking.yaml index 8ac5142c928..187499cb337 100644 --- a/api/v1/swagger/paths/items_available_for_booking.yaml +++ b/api/v1/swagger/paths/items_available_for_booking.yaml @@ -78,4 +78,4 @@ $ref: "../swagger.yaml#/definitions/error" x-koha-authorization: permissions: - circulate: manage_bookings \ No newline at end of file + circulate: manage_bookings diff --git a/circ/available-bookings.pl b/circ/available-bookings.pl old mode 100644 new mode 100755 index d22014175c6..fba05b9b6c5 --- a/circ/available-bookings.pl +++ b/circ/available-bookings.pl @@ -15,7 +15,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with Koha; if not, see . +# along with Koha; if not, see . use Modern::Perl; @@ -39,14 +39,14 @@ my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( my $branchcode = defined( $input->param('library') ) ? $input->param('library') : C4::Context->userenv->{'branch'}; -my $today = dt_from_string(); +my $today = dt_from_string(); my $startdate = $today->clone->truncate( to => 'day' ); -my $enddate = $startdate->clone->add( days => 7 ); +my $enddate = $startdate->clone->add( days => 7 ); $template->param( - branchcode => $branchcode, + branchcode => $branchcode, start_date_default => $startdate, - end_date_default => $enddate, + end_date_default => $enddate, ); -output_html_with_http_headers $input, $cookie, $template->output; \ No newline at end of file +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc index 9d8832e5638..97cff2f81f7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc @@ -64,77 +64,77 @@ - -
+
[% IF ( CAN_user_circulate_manage_bookings ) %] -
Bookings
- +
Bookings
+ [% END %] [% IF Koha.Preference('UseRecalls') and CAN_user_recalls %] -
Recalls
- - [% END %] - - [% IF Koha.Preference('ArticleRequests') %] -
Patron request
- - [% END %] - -
Transfers
- - [% IF ( CAN_user_circulate_overdues_report ) %] -
Overdues
+
Transfers
- [% END %] + + [% IF ( CAN_user_circulate_overdues_report ) %] +
Overdues
+ + [% END %] +
+
- diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/available-bookings.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/available-bookings.tt index d41ad3d2d04..0b86347704c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/available-bookings.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/available-bookings.tt @@ -9,11 +9,12 @@ [% PROCESS 'i18n.inc' %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] -[% FILTER collapse %] - [% t("Items available for booking") | html %] › - [% t("Circulation") | html %] › - [% t("Koha") | html %] -[% END %] +[% FILTER collapse %] + [% t("Items available for booking") | html %] + › [% t("Circulation") | html %] › [% t("Koha") | html %] + [% END %] [% INCLUDE 'doc-head-close.inc' %] @@ -35,7 +36,6 @@
-
@@ -57,11 +57,11 @@
  1. - +
  2. - +
  3. @@ -98,179 +98,178 @@
[% MACRO jsinclude BLOCK %] -[% INCLUDE 'calendar.inc' %] -[% INCLUDE 'datatables.inc' %] -[% INCLUDE 'js-biblio-format.inc' %] -[% INCLUDE 'js-date-format.inc' %] - - + }); + [% END %] -[% INCLUDE 'intranet-bottom.inc' %] \ No newline at end of file +[% INCLUDE 'intranet-bottom.inc' %] -- 2.39.5