Bug 20661: Shortcut circ scripts if a blocking error appeared
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 25 Apr 2018 20:08:42 +0000 (17:08 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 10 Aug 2018 12:23:03 +0000 (12:23 +0000)
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
No test plan found ;)
But tested bookcount and request-article.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

C4/Output.pm
circ/bookcount.pl
circ/request-article.pl
koha-tmpl/intranet-tmpl/prog/en/includes/blocking_errors.inc
koha-tmpl/intranet-tmpl/prog/en/modules/circ/bookcount.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt

index 39d9f9c..eef4506 100644 (file)
@@ -50,7 +50,7 @@ BEGIN {
     );
     push @EXPORT, qw(
         &output_html_with_http_headers &output_ajax_with_http_headers &output_with_http_headers
-        &output_and_exit_if_error
+        &output_and_exit_if_error &output_and_exit
     );
 
 }
@@ -338,14 +338,17 @@ sub output_and_exit_if_error {
         }
     }
 
-    if ( $error ) {
-        $template->param( blocking_error => $error );
-        output_html_with_http_headers ( $query, $cookie, $template->output );
-        exit;
-    }
+    output_and_exit( $query, $cookie, $template, $error ) if $error;
     return;
 }
 
+sub output_and_exit {
+    my ( $query, $cookie, $template, $error ) = @_;
+    $template->param( blocking_error => $error );
+    output_html_with_http_headers ( $query, $cookie, $template->output );
+    exit;
+}
+
 sub parametrized_url {
     my $url = shift || ''; # ie page.pl?ln={LANG}
     my $vars = shift || {}; # ie { LANG => en }
index 438d851..0d86946 100755 (executable)
@@ -39,22 +39,6 @@ my $biblionumber = $input->param('biblionumber');
 my $biblio = Koha::Biblios->find( $biblionumber );
 my $item   = Koha::Items->find( $itm );
 
-if ( !defined $biblio or !defined $item ) {
-    print $input->redirect("/cgi-bin/koha/errors/400.pl");
-}
-
-my $lastmove = lastmove($itm);
-
-my $lastdate;
-my $count;
-if ( not $lastmove ) {
-    $count = issuessince( $itm, 0 );
-} else {
-    $lastdate = $lastmove->{'datearrived'};
-    $count = issuessince( $itm, $lastdate );
-}
-
-# make the page ...
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
@@ -67,6 +51,21 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
+output_and_exit( $input, $cookie, $template, 'unknown_biblio')
+    unless $biblio;
+output_and_exit( $input, $cookie, $template, 'unknown_item')
+    unless $item;
+
+my $lastdate;
+my $count;
+my $lastmove = lastmove($itm);
+if ( not $lastmove ) {
+    $count = issuessince( $itm, 0 );
+} else {
+    $lastdate = $lastmove->{'datearrived'};
+    $count = issuessince( $itm, $lastdate );
+}
+
 my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;
 for my $library ( @$libraries ) {
     $library->{selected} = 1 if $library->{branchcode} eq C4::Context->userenv->{branch};
index ea33b3e..3d598ec 100755 (executable)
@@ -44,6 +44,9 @@ my $patron_cardnumber = $cgi->param('patron_cardnumber');
 my $patron_id         = $cgi->param('patron_id');
 
 my $biblio = Koha::Biblios->find($biblionumber);
+output_and_exit( $cgi, $cookie, $template, 'unknown_biblio')
+    unless $biblio;
+
 my $patron =
     $patron_id         ? Koha::Patrons->find($patron_id)
   : $patron_cardnumber ? Koha::Patrons->find( { cardnumber => $patron_cardnumber } )
index 4be8110..0ab6738 100644 (file)
@@ -3,6 +3,10 @@
     [% CASE 'unknown_patron' %]
         <div class="dialog message">This patron does not exist. <a href="/cgi-bin/koha/members/members-home.pl">Find another patron?</a></div>
     [% CASE 'cannot_see_patron_infos' %]You are not allowed to see the information of this patron.
+    [% CASE 'unknown_biblio' %]
+        <div class="dialog message">This bibliographic record does not exist.</div>
+    [% CASE 'unknown_item' %]
+        <div class="dialog message">This item does not exist.</div>
     [% CASE %][% blocking_error %]
     [% END %]
 
index 2211a98..9ed1a66 100644 (file)
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'circ-search.inc' %]
 
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a> &rsaquo; Circulation statistics for [% title |html %]</div>
+<div id="breadcrumbs">
+    <a href="/cgi-bin/koha/mainpage.pl">Home</a>
+    &rsaquo; <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a>
+    [% UNLESS blocking_error %]&rsaquo; Circulation statistics for [% title |html %][% END %]
+</div>
 
 <div id="doc3" class="yui-t2">
    
@@ -18,8 +22,8 @@
        <div id="yui-main">
        <div class="yui-b">
 
-<h2>
-[% title |html %] [% IF ( author ) %] by [% author |html %][% END %]</h2>
+[% INCLUDE 'blocking_errors.inc' %]
+<h2>[% title |html %] [% IF ( author ) %] by [% author |html %][% END %]</h2>
 <h3>Barcode [% barcode %]</h3>
 <table>
         <tr><th>Home library</th><th>Current library</th><th>Date arrived<br />at current library </th><th>Number of checkouts<br />since last transfer</th></tr>
index 94d9b33..375b653 100644 (file)
         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
         &rsaquo;
         <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
+        [% UNLESS blocking_error %]
         &rsaquo;
         <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]">[% biblio.title | html %]</a>
         &rsaquo;
         Request article
+        [% END %]
     </div>
 
+    [% INCLUDE 'blocking_errors.inc' %]
     <div id="doc3" class="yui-t2">
         <div id="bd">
             <div id="yui-main">