Bug 27948: Add disclaimer to article request
authorAgustin Moyano <agustinmoyano@theke.io>
Wed, 26 May 2021 19:00:32 +0000 (16:00 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 12 Jul 2021 13:47:33 +0000 (15:47 +0200)
If ArticleRequestsDisclaimerText news is set, a disclaimer text will appear before an article request can be made

To test:
1. apply patches
2. enable ArticleRequest syspref
3. in OPAC place an article request for a patron
CHECK => No disclaimer text should appear before placing article request
4. add a text in ArticleRequestsDisclaimerText news
5. repeat step 3
SUCCESS => A disclaimer text is shown before you can place an article request

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt
opac/opac-request-article.pl

index ca7fa54..35d7177 100644 (file)
     [% END %]
     [% FOREACH lang_lis IN lang_list %]
         <optgroup label="[% lang_lis.language | html %]">
-            [% FOREACH location IN [ '', 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacSuggestionInstructions'] %]
+            [% FOREACH location IN [ '', 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText'] %]
                 [% IF ( location == '' ) %]
                     [% SET location_lang = lang_lis.language %]
                     [% location = BLOCK %]OPAC news[% END %]
index 69dd4f0..fe44076 100644 (file)
@@ -1,4 +1,5 @@
 [% USE Koha %]
+[% USE raw %]
 [% USE Branches %]
 [% USE ItemTypes %]
 [% INCLUDE 'doc-head-open.inc' %]
         <div class="row">
             <div class="col">
                 [% IF biblio.can_article_request( patron ) %]
-                    [% SET article_request_type = biblio.article_request_type( patron ) %]
+                    <h1>Place article request for [% biblio.title | html %]</h1>
+                    [% IF disclaimer %]
+                        <div class="alert alert-warning">
+                            [% FOREACH disc IN disclaimer %]
+                            <h3>[% disc.title | html %]</h3>
+                            <p>
+                                [% disc.content | $raw %]
+                            </p>
+                            [% END %]
+                            <a href="/cgi-bin/koha/opac-request-article.pl?biblionumber=[% biblio.biblionumber | uri %]&amp;action=accept"
+                            class="btn btn-sm btn-primary"><i class="fa fa-check" aria-hidden="true"></i> Accept</a>
+                        </div>
+                    [% ELSE %]
+                        [% SET article_request_type = biblio.article_request_type( patron ) %]
 
-                    [% IF article_request_type == 'yes' %]       [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFields') %]           [% END %]
-                    [% IF article_request_type == 'bib_only' %]  [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFieldsRecordOnly') %] [% END %]
-                    [% IF article_request_type == 'item_only' %] [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFieldsItemOnly') %]   [% END %]
+                        [% IF article_request_type == 'yes' %]       [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFields') %]           [% END %]
+                        [% IF article_request_type == 'bib_only' %]  [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFieldsRecordOnly') %] [% END %]
+                        [% IF article_request_type == 'item_only' %] [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFieldsItemOnly') %]   [% END %]
 
-                    <h1>Place article request for [% biblio.title | html %]</h1>
 
-                    <form id="place-article-request" method="post" action="/cgi-bin/koha/opac-request-article.pl">
+                        <form id="place-article-request" method="post" action="/cgi-bin/koha/opac-request-article.pl">
                         <legend class="sr-only">Place article request</legend>
-                        <input type="hidden" name="action" value="create" />
-                        <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblio.biblionumber | html %]" />
-
-                        <fieldset class="rows">
-                            <ul>
-                                <li>
-                                    [% IF mandatory_fields.search('title') %]
-                                        <label for="title" class="required">Title:</label>
-                                        <input type="text" required="required" name="title" id="title" size="50"/>
-                                    [% ELSE %]
-                                        <label for="title">Title:</label>
-                                        <input type="text" name="title" id="title" size="50"/>
-                                    [% END %]
-                                </li>
-
-                                <li>
-                                    [% IF mandatory_fields.search('author') %]
-                                        <label for="author" class="required">Author:</label>
-                                        <input type="text" required="required" name="author" id="author" size="50"/>
-                                    [% ELSE %]
-                                        <label for="author">Author:</label>
-                                        <input type="text" name="author" id="author" size="50"/>
-                                    [% END %]
-                                </li>
-
-                                <li>
-                                    [% IF mandatory_fields.search('volume') %]
-                                        <label for="volume" class="required">Volume:</label>
-                                        <input type="text" required="required" name="volume" id="volume" size="50"/>
-                                    [% ELSE %]
-                                        <label for="volume">Volume:</label>
-                                        <input type="text" name="volume" id="volume" size="50"/>
-                                    [% END %]
-                                </li>
-
-                                <li>
-                                    [% IF mandatory_fields.search('issue') %]
-                                        <label for="issue" class="required">Issue:</label>
-                                        <input type="text" required="required" name="issue" id="issue" size="50"/>
-                                    [% ELSE %]
-                                        <label for="issue">Issue:</label>
-                                        <input type="text" name="issue" id="issue" size="50"/>
-                                    [% END %]
-                                </li>
-
-                                <li>
-                                    [% IF mandatory_fields.search('date') %]
-                                        <label for="date" class="required">Date:</label>
-                                        <input type="text" required="required" name="date" id="date" size="50"/>
-                                    [% ELSE %]
-                                        <label for="date">Date:</label>
-                                        <input type="text" name="date" id="date" size="50"/>
-                                    [% END %]
-                                </li>
-
-                                <li>
-                                    [% IF mandatory_fields.search('pages') %]
-                                        <label for="pages" class="required">Pages:</label>
-                                        <input type="text" required="required" name="pages" id="pages" size="50"/>
-                                    [% ELSE %]
-                                        <label for="pages">Pages:</label>
-                                        <input type="text" name="pages" id="pages" size="50"/>
-                                    [% END %]
-                                </li>
-
-                                <li>
-                                    [% IF mandatory_fields.search('chapters') %]
-                                        <label for="chapters" class="required">Chapters:</label>
-                                        <input type="text" required="required" name="chapters" id="chapters" size="50"/>
-                                    [% ELSE %]
-                                        <label for="chapters">Chapters:</label>
-                                        <input type="text" name="chapters" id="chapters" size="50"/>
-                                    [% END %]
-                                </li>
-
-                                <li>
-                                    <label for="patron_notes">Notes:</label>
-                                    <input type="text" name="patron_notes" id="patron_notes" size="50"/>
-                                </li>
-
-                                <li>
-                                    <label for="branchcode">Pickup library:</label>
-                                    <select name="branchcode" id="branchcode" required="required">
-                                        [% FOREACH b IN Branches.all %]
-                                            [% IF b.branchcode == Branches.GetLoggedInBranchcode %]
-                                                <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
-                                            [% ELSE %]
-                                                <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
+                            <input type="hidden" name="action" value="create" />
+                            <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblio.biblionumber | html %]" />
+
+                            <fieldset class="rows">
+                                <ul>
+                                    <li>
+                                        [% IF mandatory_fields.search('title') %]
+                                            <label for="title" class="required">Title:</label>
+                                            <input type="text" required="required" name="title" id="title" size="50"/>
+                                        [% ELSE %]
+                                            <label for="title">Title:</label>
+                                            <input type="text" name="title" id="title" size="50"/>
+                                        [% END %]
+                                    </li>
+
+                                    <li>
+                                        [% IF mandatory_fields.search('author') %]
+                                            <label for="author" class="required">Author:</label>
+                                            <input type="text" required="required" name="author" id="author" size="50"/>
+                                        [% ELSE %]
+                                            <label for="author">Author:</label>
+                                            <input type="text" name="author" id="author" size="50"/>
+                                        [% END %]
+                                    </li>
+
+                                    <li>
+                                        [% IF mandatory_fields.search('volume') %]
+                                            <label for="volume" class="required">Volume:</label>
+                                            <input type="text" required="required" name="volume" id="volume" size="50"/>
+                                        [% ELSE %]
+                                            <label for="volume">Volume:</label>
+                                            <input type="text" name="volume" id="volume" size="50"/>
+                                        [% END %]
+                                    </li>
+
+                                    <li>
+                                        [% IF mandatory_fields.search('issue') %]
+                                            <label for="issue" class="required">Issue:</label>
+                                            <input type="text" required="required" name="issue" id="issue" size="50"/>
+                                        [% ELSE %]
+                                            <label for="issue">Issue:</label>
+                                            <input type="text" name="issue" id="issue" size="50"/>
+                                        [% END %]
+                                    </li>
+
+                                    <li>
+                                        [% IF mandatory_fields.search('date') %]
+                                            <label for="date" class="required">Date:</label>
+                                            <input type="text" required="required" name="date" id="date" size="50"/>
+                                        [% ELSE %]
+                                            <label for="date">Date:</label>
+                                            <input type="text" name="date" id="date" size="50"/>
+                                        [% END %]
+                                    </li>
+
+                                    <li>
+                                        [% IF mandatory_fields.search('pages') %]
+                                            <label for="pages" class="required">Pages:</label>
+                                            <input type="text" required="required" name="pages" id="pages" size="50"/>
+                                        [% ELSE %]
+                                            <label for="pages">Pages:</label>
+                                            <input type="text" name="pages" id="pages" size="50"/>
+                                        [% END %]
+                                    </li>
+
+                                    <li>
+                                        [% IF mandatory_fields.search('chapters') %]
+                                            <label for="chapters" class="required">Chapters:</label>
+                                            <input type="text" required="required" name="chapters" id="chapters" size="50"/>
+                                        [% ELSE %]
+                                            <label for="chapters">Chapters:</label>
+                                            <input type="text" name="chapters" id="chapters" size="50"/>
+                                        [% END %]
+                                    </li>
+
+                                    <li>
+                                        <label for="patron_notes">Notes:</label>
+                                        <input type="text" name="patron_notes" id="patron_notes" size="50"/>
+                                    </li>
+
+                                    <li>
+                                        <label for="branchcode">Pickup library:</label>
+                                        <select name="branchcode" id="branchcode" required="required">
+                                            [% FOREACH b IN Branches.all %]
+                                                [% IF b.branchcode == Branches.GetLoggedInBranchcode %]
+                                                    <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
+                                                [% ELSE %]
+                                                    <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
+                                                [% END %]
+                                            [% END %]
+                                        </select>
+                                    </li>
+                                </ul>
+                            </fieldset>
+
+                            [% IF article_request_type != 'bib_only' %]
+                                <table class="copiesrow table table-bordered table-striped">
+                                    <caption>Select a specific item:</caption>
+                                    <thead>
+                                        <tr>
+                                            <th>&nbsp;</th>
+                                            <th>Item type</th>
+                                            <th>Barcode</th>
+                                            <th>Home library</th>
+                                            <th>Call number</th>
+                                            <th>Enumeration</th>
+                                        </tr>
+                                    </thead>
+
+                                    <tbody>
+                                        [% FOREACH item IN biblio.items %]
+                                            [% IF item.can_article_request( patron ) %]
+                                                <tr>
+                                                    <td>
+                                                        [% IF article_request_type == 'item_only' && !checked %]
+                                                            [% SET checked = 1 %]
+                                                            <input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" checked="checked" />
+                                                        [% ELSE %]
+                                                            <input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" />
+                                                        [% END %]
+                                                    </td>
+                                                    <td>
+                                                        [% ItemTypes.GetDescription( item.itype ) | html %]
+                                                    </td>
+                                                    <td>
+                                                        [% item.barcode | html %]
+                                                    </td>
+                                                    <td>
+                                                        [% Branches.GetName( item.homebranch ) | html %]
+                                                    </td>
+                                                    <td>
+                                                        [% item.itemcallnumber | html %]
+                                                    </td>
+                                                    <td>
+                                                        [% item.enumchron | html %]
+                                                    </td>
+                                                </tr>
                                             [% END %]
                                         [% END %]
-                                    </select>
-                                </li>
-                            </ul>
-                        </fieldset>
-
-                        [% IF article_request_type != 'bib_only' %]
-                            <table class="copiesrow table table-bordered table-striped">
-                                <caption>Select a specific item:</caption>
-                                <thead>
-                                    <tr>
-                                        <th>&nbsp;</th>
-                                        <th>Item type</th>
-                                        <th>Barcode</th>
-                                        <th>Home library</th>
-                                        <th>Call number</th>
-                                        <th>Enumeration</th>
-                                    </tr>
-                                </thead>
-
-                                <tbody>
-                                    [% FOREACH item IN biblio.items %]
-                                        [% IF item.can_article_request( patron ) %]
+
+                                        [% IF article_request_type != 'item_only' %]
                                             <tr>
                                                 <td>
-                                                    [% IF article_request_type == 'item_only' && !checked %]
-                                                        [% SET checked = 1 %]
-                                                        <input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" checked="checked" />
-                                                    [% ELSE %]
-                                                        <input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" />
-                                                    [% END %]
-                                                </td>
-                                                <td>
-                                                    [% ItemTypes.GetDescription( item.itype ) | html %]
-                                                </td>
-                                                <td>
-                                                    [% item.barcode | html %]
+                                                    <input type="radio" name="itemnumber" value="" checked="checked"/>
                                                 </td>
-                                                <td>
-                                                    [% Branches.GetName( item.homebranch ) | html %]
-                                                </td>
-                                                <td>
-                                                    [% item.itemcallnumber | html %]
-                                                </td>
-                                                <td>
-                                                    [% item.enumchron | html %]
+                                                <td colspan="6">
+                                                    Any item
                                                 </td>
                                             </tr>
                                         [% END %]
-                                    [% END %]
-
-                                    [% IF article_request_type != 'item_only' %]
-                                        <tr>
-                                            <td>
-                                                <input type="radio" name="itemnumber" value="" checked="checked"/>
-                                            </td>
-                                            <td colspan="6">
-                                                Any item
-                                            </td>
-                                        </tr>
-                                    [% END %]
-                                </tbody>
-                            </table>
-                        [% END %]
+                                    </tbody>
+                                </table>
+                            [% END %]
 
-                        <input type="submit" class="btn btn-primary" value="Place request" />
-                    </form>
+                            <input type="submit" class="btn btn-primary" value="Place request" />
+                        </form>
+                    [% END %]
                 [% ELSE %]
                     <h1 class="title">[% biblio.title | html %]</h1>
                     <div class="alert alert-info">
index 6dc9189..18cc70e 100755 (executable)
@@ -23,6 +23,8 @@ use CGI qw ( -utf8 );
 
 use C4::Auth;
 use C4::Output;
+use C4::Context;
+use C4::NewsChannels;
 
 use Koha::Biblios;
 use Koha::Patrons;
@@ -39,6 +41,15 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
 
 my $action = $cgi->param('action') || q{};
 my $biblionumber = $cgi->param('biblionumber');
+my $homebranch = C4::Context->userenv->{'branch'} || "";
+my $location   = 'ArticleRequestsDisclaimerText_';
+my $disclaimer;
+if ( !$action ) {
+    $disclaimer = GetNewsToDisplay( $location . $template->lang, $homebranch );
+    $disclaimer = GetNewsToDisplay( $location . "en",            $homebranch )
+      if !scalar(@$disclaimer);
+}
+
 
 if ( $action eq 'create' ) {
     my $branchcode = $cgi->param('branchcode');
@@ -80,6 +91,7 @@ my $patron = Koha::Patrons->find($borrowernumber);
 $template->param(
     biblio => $biblio,
     patron => $patron,
+    disclaimer => $disclaimer
 );
 
 output_html_with_http_headers $cgi, $cookie, $template->output, undef, { force_no_caching => 1 };