From c68bacc5c2928b98062fe3a69ae1445816d632f8 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 8 Jul 2026 14:40:45 -0300 Subject: [PATCH] Bug 40206: Fix wrong layout in curbside pickups when 'CircSidebar' enabled This patch solves the following issues: * Template flow issue: the template called STOP which prevented the WRAPPER to complete and affected how things were rendered. * Redirect to 404 if feature disabled. This is common practice in other modules. The fact things can be executed even with the feature disabled is not ok (syspref). * Shortcircuit earlier. Similar to the above, if the feature is disabled for the current branch, no DB queries and stuff should take place. Notice the lack of checks actually makes the controller perform the actions. It is just that it is not displayed afterwards! To test: 1. Enable the `CurbsidePickup` syspref. 2. 'Activate' the `CircSidebar` syspref. 3. Be on a branch that doesn't have them enabled 4. Go to Circulation > Check in => SUCCESS: A nice left-hand sidebar is displayed with access to Circulation actions 5. Click on 'Curbside pickups' => FAIL: The sidebar doesn't display. boo! 6. Apply this patch 7. Restart plack $ ktd --shell $ koha-plack --restart kohadev 8. Repeat 4 => SUCCESS: It renders much better! 9. Sign off :-D Signed-off-by: Owen Leonard Signed-off-by: Martin Renvoize Signed-off-by: Pedro Amorim --- circ/curbside_pickups.pl | 16 ++++++++++-- .../prog/en/modules/circ/curbside_pickups.tt | 25 ++++++++++++------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/circ/curbside_pickups.pl b/circ/curbside_pickups.pl index 305d3cf595..63ba9aa9cb 100755 --- a/circ/curbside_pickups.pl +++ b/circ/curbside_pickups.pl @@ -45,7 +45,19 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( ); my $branchcode = C4::Context->userenv()->{'branch'}; -my $libraries = Koha::Libraries->search( {}, { order_by => ['branchname'] } ); + +my $policy; +if ( C4::Context->preference('CurbsidePickup') ) { + $policy = Koha::CurbsidePickupPolicies->find( { branchcode => $branchcode } ); +} + +unless ( $policy && $policy->enabled ) { + $template->param( disabled_for_branch => 1 ); + output_html_with_http_headers $input, $cookie, $template->output; + exit; +} + +my $libraries = Koha::Libraries->search( {}, { order_by => ['branchname'] } ); if ( $op eq 'find-patron' ) { my $borrowernumber = $input->param('borrowernumber'); @@ -150,7 +162,7 @@ $template->param( tab => $tab, auto_refresh => $auto_refresh, refresh_delay => $refresh_delay, - policy => Koha::CurbsidePickupPolicies->find( { branchcode => $branchcode } ), + policy => $policy, curbside_pickups => Koha::CurbsidePickups->search( { branchcode => $branchcode, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt index 2faa7170d4..f1355f2c5c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt @@ -84,16 +84,9 @@ [% END %] [% END %] -[% SET aside = Koha.Preference('CircSidebar') ? 'circ-nav' : '' %] -[% WRAPPER 'main-container.inc' aside=aside %] +[% BLOCK curbside_pickups_enabled %]

Curbside pickups

- [% UNLESS policy.enabled %] -
Curbside pickups are not enabled for your library.
- [% INCLUDE 'intranet-bottom.inc' %] - [% STOP %] - [% END %] - [% FOR m IN messages %]
[% SWITCH m.code %] @@ -457,7 +450,7 @@ [% END # /tab_panel %] [% END # /WRAPPER tab_panels %] [% END # /WRAPPER tabs %] -[% END %] +[% END # /BLOCK enabled %] [% MACRO jsinclude BLOCK %] [% Asset.js("lib/dayjs/plugin/isSameOrAfter.js") | $raw %] @@ -695,4 +688,18 @@ [% END %] +[% BLOCK curbside_pickups_disabled %] +

Curbside pickups

+
Curbside pickups are not enabled. Enable the CurbsidePickup system preference to use this feature.
+[% END # /BLOCK disabled %] + +[% SET aside = Koha.Preference('CircSidebar') ? 'circ-nav' : '' %] +[% WRAPPER 'main-container.inc' aside=aside %] + [% IF !disabled_for_branch %] + [% PROCESS curbside_pickups_enabled %] + [% ELSE %] + [% PROCESS curbside_pickups_disabled %] + [% END %] +[% END # /WRAPPER %] + [% INCLUDE 'intranet-bottom.inc' %]