Bug 14610 - Add and update scripts
authorKyle M Hall <kyle@bywatersolutions.com>
Wed, 7 Oct 2015 16:26:14 +0000 (12:26 -0400)
committerKyle M Hall <kyle@bywatersolutions.com>
Wed, 26 Oct 2016 12:15:14 +0000 (12:15 +0000)
Signed-off-by: Jennifer Schmidt <jschmidt@switchinc.org>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

27 files changed:
Koha/Item.pm
admin/smart-rules.pl
circ/article-request-slip.pl [new file with mode: 0755]
circ/article-requests.pl [new file with mode: 0755]
circ/request-article.pl [new file with mode: 0755]
koha-tmpl/intranet-tmpl/prog/css/staff-global.css
koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc
koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt
koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt [new file with mode: 0644]
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
koha-tmpl/opac-tmpl/bootstrap/less/opac.less
mainpage.pl
opac/opac-article-request-cancel.pl [new file with mode: 0755]
opac/opac-request-article.pl [new file with mode: 0755]
opac/opac-user.pl
svc/article_request [new file with mode: 0755]
tools/letter.pl

index 758d19c..51a5ac0 100644 (file)
@@ -164,7 +164,7 @@ sub article_request_type {
       :                                      undef;
     my $borrowertype = $borrower->categorycode;
     my $itemtype = $self->effective_itemtype();
-    my $rules = GetIssuingRule( $borrowertype, $itemtype, $branchcode );
+    my $rules = C4::Circulation::GetIssuingRule( $borrowertype, $itemtype, $branchcode );
 
     return $rules->{article_requests} || q{};
 }
index 1aa6b89..2ceda62 100755 (executable)
@@ -152,6 +152,7 @@ elsif ($op eq 'add') {
     my $hardduedatecompare = $input->param('hardduedatecompare');
     my $rentaldiscount = $input->param('rentaldiscount');
     my $opacitemholds = $input->param('opacitemholds') || 0;
+    my $article_requests = $input->param('article_requests') || 'no';
     my $overduefinescap = $input->param('overduefinescap') || undef;
     my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on';
     $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
@@ -183,6 +184,7 @@ elsif ($op eq 'add') {
         opacitemholds                 => $opacitemholds,
         overduefinescap               => $overduefinescap,
         cap_fine_to_replacement_price => $cap_fine_to_replacement_price,
+        article_requests              => $article_requests,
     };
 
     my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype, branchcode => $br});
diff --git a/circ/article-request-slip.pl b/circ/article-request-slip.pl
new file mode 100755 (executable)
index 0000000..6a7087d
--- /dev/null
@@ -0,0 +1,67 @@
+#!/usr/bin/perl
+
+# Copyright 2015 ByWater Solutions
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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 <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+
+use CGI qw( -utf8 );
+
+use C4::Context;
+use C4::Output;
+use C4::Auth;
+use Koha::ArticleRequests;
+
+my $cgi = new CGI;
+
+my $id = $cgi->param('id');
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "circ/printslip.tt",
+        query           => $cgi,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { circulate => "circulate_remaining_permissions" },
+    }
+);
+
+my $ar = Koha::ArticleRequests->find($id);
+
+$template->param( article_request => $ar );
+
+my $slip = C4::Letters::GetPreparedLetter(
+    module                 => 'circulation',
+    letter_code            => 'AR_SLIP',
+    message_transport_type => 'print',
+    tables                 => {
+        article_requests => $ar->id,
+        borrowers        => $ar->borrowernumber,
+        biblio           => $ar->biblionumber,
+        biblioitems      => $ar->biblionumber,
+        items            => $ar->itemnumber,
+        branches         => $ar->branchcode,
+    },
+);
+
+$template->param(
+    slip   => $slip->{content},
+    caller => 'article-request',
+    plain  => !$slip->{is_html},
+);
+
+output_html_with_http_headers $cgi, $cookie, $template->output;
diff --git a/circ/article-requests.pl b/circ/article-requests.pl
new file mode 100755 (executable)
index 0000000..d0c2805
--- /dev/null
@@ -0,0 +1,47 @@
+#!/usr/bin/perl
+
+# Copyright 2015 ByWater Solutions
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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 <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+
+use CGI qw ( -utf8 );
+
+use C4::Auth;
+use C4::Output;
+use Koha::ArticleRequests;
+
+my $query = new CGI;
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "circ/article-requests.tt",
+        query           => $query,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { circulate => "circulate_remaining_permissions" },
+    }
+);
+
+my $branchcode = defined( $query->param('branchcode') ) ? $query->param('branchcode') : C4::Context->userenv->{'branch'};
+
+$template->param(
+    branchcode                  => $branchcode,
+    article_requests_pending    => scalar Koha::ArticleRequests->pending($branchcode),
+    article_requests_processing => scalar Koha::ArticleRequests->processing($branchcode),
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/circ/request-article.pl b/circ/request-article.pl
new file mode 100755 (executable)
index 0000000..ea33b3e
--- /dev/null
@@ -0,0 +1,111 @@
+#!/usr/bin/perl
+
+# Copyright 2015 ByWater Solutions
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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 <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+
+use C4::Output;
+use C4::Auth;
+use C4::Utils::DataTables::Members;
+use Koha::Biblios;
+use Koha::Patrons;
+use Koha::ArticleRequests;
+
+my $cgi = new CGI;
+
+my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user(
+    {
+        template_name   => "circ/request-article.tt",
+        query           => $cgi,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { circulate => 'circulate_remaining_permissions' },
+    }
+);
+
+my $action            = $cgi->param('action') || q{};
+my $biblionumber      = $cgi->param('biblionumber');
+my $patron_cardnumber = $cgi->param('patron_cardnumber');
+my $patron_id         = $cgi->param('patron_id');
+
+my $biblio = Koha::Biblios->find($biblionumber);
+my $patron =
+    $patron_id         ? Koha::Patrons->find($patron_id)
+  : $patron_cardnumber ? Koha::Patrons->find( { cardnumber => $patron_cardnumber } )
+  : undef;
+
+if ( $action eq 'create' ) {
+    my $borrowernumber = $cgi->param('borrowernumber');
+    my $branchcode     = $cgi->param('branchcode');
+
+    my $itemnumber   = $cgi->param('itemnumber')   || undef;
+    my $title        = $cgi->param('title')        || undef;
+    my $author       = $cgi->param('author')       || undef;
+    my $volume       = $cgi->param('volume')       || undef;
+    my $issue        = $cgi->param('issue')        || undef;
+    my $date         = $cgi->param('date')         || undef;
+    my $pages        = $cgi->param('pages')        || undef;
+    my $chapters     = $cgi->param('chapters')     || undef;
+    my $patron_notes = $cgi->param('patron_notes') || undef;
+
+    my $ar = Koha::ArticleRequest->new(
+        {
+            borrowernumber => $borrowernumber,
+            biblionumber   => $biblionumber,
+            branchcode     => $branchcode,
+            itemnumber     => $itemnumber,
+            title          => $title,
+            author         => $author,
+            volume         => $volume,
+            issue          => $issue,
+            date           => $date,
+            pages          => $pages,
+            chapters       => $chapters,
+            patron_notes   => $patron_notes,
+        }
+    )->store();
+
+}
+
+if ( !$patron && $patron_cardnumber ) {
+    my $results = C4::Utils::DataTables::Members::search(
+        {
+            searchmember => $patron_cardnumber,
+            dt_params    => { iDisplayLength => -1 },
+        }
+    );
+
+    my $patrons = $results->{patrons};
+
+    if ( scalar @$patrons == 1 ) {
+        $patron = Koha::Patrons->find( $patrons->[0]->{borrowernumber} );
+    }
+    elsif (@$patrons) {
+        $template->param( patrons => $patrons );
+    }
+    else {
+        $template->param( no_patrons_found => $patron_cardnumber );
+    }
+}
+
+$template->param(
+    biblio => $biblio,
+    patron => $patron,
+);
+
+output_html_with_http_headers $cgi, $cookie, $template->output;
index 52ee8d4..c8921f9 100644 (file)
@@ -1725,8 +1725,8 @@ ul.budget_hierarchy li:first-child:after {
 .child_fund_amount {
     font-style: italic;
 }
-.holdcount { font-size : 105%; line-height : 200%; }
-.holdcount a {
+.number_box { font-size : 105%; line-height : 200%; }
+.number_box a {
        border : 1px solid #a4bedd;
        background-color : #e4ecf5;
        font-weight : bold;
@@ -1735,7 +1735,7 @@ ul.budget_hierarchy li:first-child:after {
        padding : .1em .4em;
        text-decoration : none;
 }
-.holdcount a:hover { background-color : #ebeff7; }
+.number_box a:hover { background-color : #ebeff7; }
 .container {
        border : 1px solid #EEE;
        padding : 1em;
index 76c52f8..95c0ee4 100644 (file)
@@ -1,5 +1,7 @@
+[% USE Koha %]
 [% USE Biblio %]
 [% SET biblio_object_id = object || biblionumber %]
+
 <div id="menu">
 <ul>
     [% IF ( detailview ) %]<li class="active">[% ELSE %]<li>[% END %]
     [% END %]
     [% IF ( EasyAnalyticalRecords ) %][% IF ( analyze ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio_object_id | url  %]&amp;analyze=1">Analytics</a></li>[% END %]
 
+    [% IF Koha.Preference('ArticleRequests') %]
+        [% IF ( article_requests_view ) %]<li class="active">[% ELSE %]<li>[% END %]
+        <a href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% IF ( object ) %][% object %][% ELSE %][% biblionumber %][% END %]">Article requests ([% Biblio.ArticleRequestsActiveCount( biblio_object_id ) %])</a></li>
+    [% END %]
+
     [% IF ( subscriptionsnumber ) %]<li><a href="/cgi-bin/koha/serials/serials-search.pl?searched=1&amp;biblionumber=[% biblio_object_id | url  %]">Subscription(s)</a></li>[% END %]
 </ul>
 <ul>
index 0c10e63..a8868ab 100644 (file)
@@ -261,6 +261,10 @@ CAN_user_serials_create_subscription ) %]
     [% END %]
 [% END %]
 
+[% IF Koha.Preference('ArticleRequests') %]
+    <div class="btn-group"><a id="placehold" class="btn btn-small" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% biblionumber %]"><i class="fa fa-file-text-o"></i> Request article</a></div>
+[% END %]
+
 </div>
 
     <!--Modal for Dublin Core-->
index 81c0876..22ea57a 100644 (file)
@@ -782,3 +782,46 @@ Circulation:
                   yes: Enable
                   no: Disable
             - "housebound module"
+    Article Requests:
+        -
+            - pref: ArticleRequests
+              choices:
+                  yes: Enable
+                  no: "Don't enable"
+            - patrons to place article requests.
+        -
+            - For records that are record level or item level requestable, make the following fields mandatory
+            - pref: ArticleRequestsMandatoryFields
+              multiple:
+                title: Title
+                author: Author
+                volume: Volume
+                issue: Issue
+                date: Date
+                pages: Pages
+                chapters: Chapters
+            -
+        -
+            - For records that are only record level requestable, make the following fields mandatory
+            - pref: ArticleRequestsMandatoryFieldsRecordOnly
+              multiple:
+                title: Title
+                author: Author
+                volume: Volume
+                issue: Issue
+                date: Date
+                pages: Pages
+                chapters: Chapters
+            -
+        -
+            - For records that are only item level requestable, make the following fields mandatory
+            - pref: ArticleRequestsMandatoryFieldsItemOnly
+              multiple:
+                title: Title
+                author: Author
+                volume: Volume
+                issue: Issue
+                date: Date
+                pages: Pages
+                chapters: Chapters
+            -
index 9e87404..e0b92eb 100644 (file)
@@ -189,6 +189,7 @@ $(document).ready(function() {
                 <th>Holds per record (count)</th>
                 <th>On shelf holds allowed</th>
                 <th>Item level holds</th>
+                <th>Article requests</th>
                 <th>Rental discount (%)</th>
                 <th>Actions</th>
             </tr>
@@ -275,6 +276,17 @@ $(document).ready(function() {
                                                                 If any unavailable
                                                             [% END %]</td>
                                                         <td>[% IF rule.opacitemholds == 'F'%]Force[% ELSIF rule.opacitemholds == 'Y'%]Allow[% ELSE %]Don't allow[% END %]</td>
+                                                        <td>
+                                                            [% IF rule.article_requests == 'no' %]
+                                                                No
+                                                            [% ELSIF rule.article_requests == 'yes' %]
+                                                                Yes
+                                                            [% ELSIF rule.article_requests == 'bib_only' %]
+                                                                Record only
+                                                            [% ELSIF rule.article_requests == 'item_only' %]
+                                                                Item only
+                                                            [% END %]
+                                                        </td>
                                                        <td>[% rule.rentaldiscount %]</td>
                                                         <td class="actions">
                                                           <a href="#" class="editrule btn btn-mini"><i class="fa fa-pencil"></i> Edit</a>
@@ -355,6 +367,14 @@ $(document).ready(function() {
                             <option value="F">Force</option>
                         </select>
                     </td>
+                    <td>
+                        <select id="article_requests" name="article_requests">
+                            <option value="no">No</option>
+                            <option value="yes">Yes</option>
+                            <option value="bib_only">Record only</option>
+                            <option value="item_only">Item only</option>
+                        </select>
+                    </td>
                     <td><input type="text" name="rentaldiscount" id="rentaldiscount" size="2" /></td>
                     <td class="actions">
                         <input type="hidden" name="branch" value="[% current_branch %]"/>
@@ -387,6 +407,7 @@ $(document).ready(function() {
                       <th>Holds per record (count)</th>
                       <th>On shelf holds allowed</th>
                       <th>Item level holds</th>
+                      <th>Article requests</th>
                       <th>Rental discount (%)</th>
                       <th colspan="2">&nbsp;</th>
                     </tr>
index c33463d..2b6583b 100644 (file)
@@ -2,6 +2,7 @@
 [% USE KohaDates %]
 [% USE AuthorisedValues %]
 [% USE Branches %]
+[% USE Biblio %]
 
 [% ShowCourseReserves = 0 %]
 [% IF UseCourseReserves %]
@@ -408,6 +409,24 @@ function verify_images() {
         [% END %]
         <span id="catalogue_detail_marc_preview" class="results_summary"><span class="label">MARC Preview:</span> <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% biblionumber %]&amp;viewas=html" title="MARC" class="previewMARC">Show</a></span>
 
+        [% IF ( holdcount ) %]
+            <span class="results_summary">
+                <span class="label">Holds:</span>
+                <span class="number_box">
+                    <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblionumber %]">[% holdcount %]</a>
+                </span>
+            </span>
+        [% END %]
+
+        [% IF ( article_requests_count = Biblio.ArticleRequestsActiveCount( biblionumber ) ) %]
+            <span class="results_summary">
+                <span class="label">Article requests:</span>
+                <span class="number_box">
+                    <a href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% biblionumber %]">[% article_requests_count %]</a>
+                </span>
+            </span>
+        [% END %]
+
         [% IF ( AmazonCoverImages  || LocalCoverImages ) %]
         </div><div class="yui-u" id="bookcoverimg">
         [% IF ( LocalCoverImages ) %]
index 3cecf8a..031c1f8 100644 (file)
@@ -599,6 +599,10 @@ var holdForPatron = function () {
                                     [% END %]
                                 [% END # / IF intranetbookbag %]
 
+                          [% IF Koha.Preference('ArticleRequests') %]
+                              | <a id="requst_article_[% SEARCH_RESULT.biblionumber %]" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Request article</a>
+                          [% END %]
+
                           [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
                           | <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Edit record</a>
                           [% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt
new file mode 100644 (file)
index 0000000..7a93511
--- /dev/null
@@ -0,0 +1,409 @@
+[% USE KohaDates %]
+[% USE ItemTypes %]
+[% USE Branches %]
+[% USE AuthorisedValues %]
+
+[% INCLUDE 'doc-head-open.inc' %]
+<title>Koha &rsaquo; Circulation &rsaquo; Article requests</title>
+[% INCLUDE 'doc-head-close.inc' %]
+<style type="text/css"> p { margin-top: 0; }</style>
+</head>
+
+<body id="circ_view_holdsqueue" class="circ">
+    [% INCLUDE 'header.inc' %]
+    [% INCLUDE 'cat-search.inc' %]
+
+    <script type="text/javascript">//<![CDATA[
+        $(document).ready(function() {
+            $('#article-request-tabs').tabs();
+
+            [% IF article_requests_pending.count %]
+                $(".ar-pending-none").hide();
+            [% END %]
+
+            [% IF article_requests_processing.count %]
+                $(".ar-processing-none").hide();
+            [% END %]
+        });
+
+        function PrintSlip(link) {
+            window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
+        }
+
+        function Cancel( id, a ) {
+            notes = prompt(_("Reason for cancelation:"));
+            if ( notes == null ) {
+                return;
+            }
+
+            a.closest('td').prepend('<img src="[% interface %]/[% theme %]/img/loading-small.gif"/>');
+            a.closest('div').hide();
+            $.ajax({
+                type: "POST",
+                url: '/cgi-bin/koha/svc/article_request',
+                data: {
+                    action: 'cancel',
+                    id: id,
+                    notes: notes
+                },
+                success: function( data ) {
+                    a.closest('tr').remove();
+                    UpdateTabCounts()
+                },
+                dataType: 'json'
+            });
+        }
+
+        function Process( id, a ) {
+            var table_row = a.closest('tr').clone();
+            table_row.find('.ar-process-request').remove();
+
+            a.closest('td').prepend('<img src="[% interface %]/[% theme %]/img/loading-small.gif"/>');
+            a.closest('div').hide();
+            $.ajax({
+                type: "POST",
+                url: '/cgi-bin/koha/svc/article_request',
+                data: {
+                    action: 'process',
+                    id: id,
+                },
+                success: function( data ) {
+                    a.closest('tr').remove();
+                    $("#article-requests-processing-table").append( table_row );
+                    $("#article-requests-processing-table .ar-processing-none").hide();
+                    UpdateTabCounts()
+                },
+                dataType: 'json'
+            });
+        }
+
+        function Complete( id, a ) {
+            a.closest('td').prepend('<img src="[% interface %]/[% theme %]/img/loading-small.gif"/>');
+            a.closest('div').hide();
+            $.ajax({
+                type: "POST",
+                url: '/cgi-bin/koha/svc/article_request',
+                data: {
+                    action: 'complete',
+                    id: id,
+                },
+                success: function( data ) {
+                    a.closest('tr').remove();
+                    UpdateTabCounts()
+                },
+                dataType: 'json'
+            });
+        }
+
+        function UpdateTabCounts() {
+            var pending_count = $('#article-requests-pending-table tbody tr.ar-row').length;
+            $("#ar_pending_count").html( pending_count );
+            if ( pending_count == 0 ) $(".ar-pending-none").show();
+
+            var processing_count = $('#article-requests-processing-table tbody tr.ar-row').length;
+            $("#ar_processing_count").html( processing_count );
+            if ( processing_count == 0 ) $(".ar-processing-none").show();
+        }
+    //]]></script>
+
+    <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;
+        <a href="/cgi-bin/koha/circ/article-requests.pl">Article requests</a>
+    </div>
+
+<div id="doc" class="yui-t7">
+    <div id="bd">
+        <div id="yui-main">
+            <div class="yui-g">
+
+                <h1>Article requests</h1>
+
+                <form id="ar-branchcode-form" method="post">
+                    <select name="branchcode" id="branchcode">
+                        <option value="">All libraries</option>
+                        [% FOREACH b IN Branches.all %]
+                            [% IF b.branchcode == branchcode %]
+                                <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
+                            [% ELSE %]
+                                <option value="[% b.branchcode %]">[% b.branchname %]</option>
+                            [% END %]
+                        [% END %]
+                    </select>
+                    <button type="submit" class="btn btn-small" type="submit">
+                        <i class="fa fa-refresh"></i> Update
+                    </button>
+                </form>
+
+                <div id="article-request-tabs" class="toptabs">
+                    <ul>
+                        <li>
+                            <a href="#article-requests-pending">
+                                Pending (<span id="ar_pending_count">[% article_requests_pending.count %]</span>)
+                            </a>
+                        </li>
+
+                        <li>
+                            <a href="#article-requests-processing">
+                                Processing (<span id="ar_processing_count">[% article_requests_processing.count %]</span>)
+                            </a>
+                        </li>
+                    </ul>
+
+                    <div id="article-requests-pending">
+                        <table id="article-requests-pending-table">
+                            <thead>
+                                <tr>
+                                    <th class="ar-title">Title</th>
+                                    <th class="ar-request">Requested article</th>
+                                    <th class="ar-collection">Collection</th>
+                                    <th class="ar-itemtype">Item type</th>
+                                    <th class="ar-callnumber">Call number</th>
+                                    <th class="ar-copynumber">Copy number</th>
+                                    <th class="ar-enumchron">Enumeration</th>
+                                    <th class="ar-barcode">Barcode</th>
+                                    <th class="ar-patron">Patron</th>
+                                    <th class="ar-date">Date</th>
+                                    <th class="ar-actions">Actions</th>
+                                </tr>
+                            </thead>
+
+                             <tbody>
+                                <tr class="ar-pending-none">
+                                    <td colspan="11">
+                                        There are no pending article requests at this time.
+                                    </td>
+                                </tr>
+
+                                [% FOREACH ar IN article_requests_pending %]
+                                    <tr class="ar-row ar-pending">
+                                        <td class="ar-title">
+                                            <p>
+                                                <a href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber %]">
+                                                    <strong>[% ar.biblio.title | html %]</strong>
+                                                    [% FOREACH s IN itemsloo.subtitle %] [% s %][% END %]
+                                                </a>
+                                            </p>
+
+                                            <p>
+                                                <div class="ar-biblionumber content_hidden">[% ar.biblionumber %]</div>
+                                                <div class="ar-author">[% ar.biblio.author %]</div>
+                                                <div class="ar-pubdata">
+                                                    [% ar.biblio.biblioitem.publishercode %]
+
+                                                    [% IF ar.biblio.biblioitem.publicationyear %]
+                                                        , [% ar.biblio.biblioitem.publicationyear %]
+                                                    [% ELSIF ar.biblio.copyrightdate %]
+                                                        , [% ar.biblio.copyrightdate %]
+                                                    [% END %]
+
+                                                    [% IF ar.biblio.biblioitem.pages %]
+                                                        : [% ar.biblio.biblioitem.pages %]
+                                                    [% END %]
+
+                                                    [%  r.biblio.biblioitem.size %]
+
+                                                    [% IF ar.biblio.biblioitem.isbn %]
+                                                        ISBN: [% ar.biblio.biblioitem.isbn %]
+                                                    [% END %]
+                                                </div>
+                                            </p>
+                                        </td>
+                                        <td class="ar-request">
+                                            [% IF ar.title %]        <p><strong>Title:</strong>        [% ar.title %]        </p> [% END %]
+                                            [% IF ar.author %]       <p><strong>Author:</strong>       [% ar.author %]       </p> [% END %]
+                                            [% IF ar.volume %]       <p><strong>Volume:</strong>       [% ar.volume %]       </p> [% END %]
+                                            [% IF ar.issue %]        <p><strong>Issue:</strong>        [% ar.issue %]        </p> [% END %]
+                                            [% IF ar.date %]         <p><strong>Date:</strong>         [% ar.date %]         </p> [% END %]
+                                            [% IF ar.pages %]        <p><strong>Pages:</strong>        [% ar.pages %]        </p> [% END %]
+                                            [% IF ar.chapters %]     <p><strong>Chapters:</strong>     [% ar.chapters %]     </p> [% END %]
+                                            [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes %] </p> [% END %]
+                                        </td>
+                                        <td class="ar-collection">[% AuthorisedValues.GetByCode( 'CCODE', ar.item.ccode ) %]</td>
+                                        <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) %]</td>
+                                        <td class="ar-callnumber">
+                                            [% IF ar.item.location %]
+                                                <em>[% AuthorisedValues.GetByCode( 'LOC', ar.item.location ) %]</em>
+                                            [% END %]
+
+                                            [% ar.item.itemcallnumber %]
+                                        </td>
+                                        <td class="ar-copynumber">[% ar.item.copynumber %]</td>
+                                        <td class="ar-enumchron">[% ar.item.enumchron %]</td>
+                                        <td class="ar-barcode">[% ar.item.barcode %]</td>
+                                        <td class="ar-patron">
+                                            <p>
+                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber %]">
+                                                    [% ar.borrower.surname %][% IF ar.borrower.firstname %], [% ar.borrower.firstname %][% END %] ([% ar.borrower.cardnumber %])
+                                                </a>
+                                            </p>
+
+                                            <p>[% ar.borrower.phone %]</p>
+                                        </td>
+                                        <td class="ar-date"><span title="[% ar.created_on %]">[% ar.created_on | $KohaDates %]</span></td>
+                                        <td class="ar-actions">
+                                            <div class="dropdown">
+                                                <a class="btn btn-mini dropdown-toggle" id="ar-actions" role="button" data-toggle="dropdown" href="#">
+                                                    Actions <b class="caret"></b>
+                                                </a>
+
+                                                <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="ar-actions">
+                                                    <li>
+                                                        <a class="ar-process-request" href="#" onclick="Process( [% ar.id %], $(this) ); return false;">
+                                                            <i class="icon-ok-circle"></i>
+                                                            Process request
+                                                        </a>
+
+                                                        <a class="ar-complete-request" href="#" onclick="Complete( [% ar.id %], $(this) ); return false;">
+                                                            <i class="icon-ok-circle"></i>
+                                                            Complete request
+                                                        </a>
+
+                                                        <a class="ar-cancel-request" href="#" onclick="Cancel( [% ar.id %], $(this) ); return false;">
+                                                            <i class="icon-remove-circle"></i>
+                                                            Cancel request
+                                                        </a>
+
+                                                        <a class="ar-print-request" href="#" onclick="PrintSlip('article-request-slip.pl?id=[% ar.id %]'); return false;">
+                                                            <i class="icon-print"></i>
+                                                            Print slip
+                                                        </a>
+                                                    </li>
+                                                </ul>
+                                            </div>
+                                        </td>
+                                    </tr>
+                                [% END %]
+                            </tbody>
+                        </table>
+                    </div>
+
+                    <div id="article-requests-processing">
+                        <table id="article-requests-processing-table">
+                            <thead>
+                                <tr>
+                                    <th class="ar-title">Title</th>
+                                    <th class="ar-request">Requested article</th>
+                                    <th class="ar-collection">Collection</th>
+                                    <th class="ar-itemtype">Item type</th>
+                                    <th class="ar-callnumber">Call number</th>
+                                    <th class="ar-copynumber">Copy number</th>
+                                    <th class="ar-enumchron">Enumeration</th>
+                                    <th class="ar-barcode">Barcode</th>
+                                    <th class="ar-patron">Patron</th>
+                                    <th class="ar-date">Date</th>
+                                    <th class="ar-actions">Actions</th>
+                                </tr>
+                            </thead>
+
+                             <tbody>
+                                <tr class="ar-processing-none">
+                                    <td colspan="11">
+                                        There are no article requests in processing at this time.
+                                    </td>
+                                </tr>
+
+                                [% FOREACH ar IN article_requests_processing %]
+                                    <tr class="ar-row ar-processing">
+                                        <td class="ar-title">
+                                            <p>
+                                                <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% ar.biblionumber %]">
+                                                    <strong>[% ar.biblio.title | html %]</strong>
+                                                    [% FOREACH s IN itemsloo.subtitle %] [% s %][% END %]
+                                                </a>
+                                            </p>
+
+                                            <p>
+                                                <div class="ar-biblionumber content_hidden">[% ar.biblionumber %]</div>
+                                                <div class="ar-author">[% ar.biblio.author %]</div>
+                                                <div class="ar-pubdata">
+                                                    [% ar.biblio.biblioitem.publishercode %]
+
+                                                    [% IF ar.biblio.biblioitem.publicationyear %]
+                                                        , [% ar.biblio.biblioitem.publicationyear %]
+                                                    [% ELSIF ar.biblio.copyrightdate %]
+                                                        , [% ar.biblio.copyrightdate %]
+                                                    [% END %]
+
+                                                    [% IF ar.biblio.biblioitem.pages %]
+                                                        : [% ar.biblio.biblioitem.pages %]
+                                                    [% END %]
+
+                                                    [%  r.biblio.biblioitem.size %]
+
+                                                    [% IF ar.biblio.biblioitem.isbn %]
+                                                        ISBN: [% ar.biblio.biblioitem.isbn %]
+                                                    [% END %]
+                                                </div>
+                                            </p>
+                                        </td>
+                                        <td class="ar-request">
+                                            [% IF ar.title %]        <p><strong>Title:</strong>        [% ar.title %]        </p> [% END %]
+                                            [% IF ar.author %]       <p><strong>Author:</strong>       [% ar.author %]       </p> [% END %]
+                                            [% IF ar.volume %]       <p><strong>Volume:</strong>       [% ar.volume %]       </p> [% END %]
+                                            [% IF ar.issue %]        <p><strong>Issue:</strong>        [% ar.issue %]        </p> [% END %]
+                                            [% IF ar.date %]         <p><strong>Date:</strong>         [% ar.date %]         </p> [% END %]
+                                            [% IF ar.pages %]        <p><strong>Pages:</strong>        [% ar.pages %]        </p> [% END %]
+                                            [% IF ar.chapters %]     <p><strong>Chapters:</strong>     [% ar.chapters %]     </p> [% END %]
+                                            [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes %] </p> [% END %]
+                                        </td>
+                                        <td class="ar-collection">[% AuthorisedValues.GetByCode( 'CCODE', ar.item.ccode ) %]</td>
+                                        <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) %]</td>
+                                        <td class="ar-callnumber">
+                                            [% IF ar.item.location %]
+                                                <em>[% AuthorisedValues.GetByCode( 'LOC', ar.item.location ) %]</em>
+                                            [% END %]
+
+                                            [% ar.item.itemcallnumber %]
+                                        </td>
+                                        <td class="ar-copynumber">[% ar.item.copynumber %]</td>
+                                        <td class="ar-enumchron">[% ar.item.enumchron %]</td>
+                                        <td class="ar-barcode">[% ar.item.barcode %]</td>
+                                        <td class="ar-patron">
+                                            <p>
+                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber %]">
+                                                    [% ar.borrower.surname %][% IF ar.borrower.firstname %], [% ar.borrower.firstname %][% END %] ([% ar.borrower.cardnumber %])
+                                                </a>
+                                            </p>
+
+                                            <p>[% ar.borrower.phone %]</p>
+                                        </td>
+                                        <td class="ar-date"><span title="[% ar.created_on %]">[% ar.created_on | $KohaDates %]</span></td>
+                                        <td class="ar-actions">
+                                            <div class="dropdown">
+                                                <a class="btn btn-mini dropdown-toggle" id="ar-actions" role="button" data-toggle="dropdown" href="#">
+                                                    Actions <b class="caret"></b>
+                                                </a>
+
+                                                <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="ar-actions">
+                                                    <li>
+                                                        <a href="#" onclick="Complete( [% ar.id %], $(this) ); return false;">
+                                                            <i class="icon-ok-circle"></i>
+                                                            Complete request
+                                                        </a>
+
+                                                        <a href="#" onclick="Cancel( [% ar.id %], $(this) ); return false;">
+                                                            <i class="icon-remove-circle"></i>
+                                                            Cancel request
+                                                        </a>
+
+                                                        <a href="#" onclick="PrintSlip('article-request-slip.pl?id=[% ar.id %]'); return false;">
+                                                            <i class="icon-print"></i>
+                                                            Print slip
+                                                        </a>
+                                                    </li>
+                                                </ul>
+                                            </div>
+                                        </td>
+                                    </tr>
+                                [% END %]
+                            </tbody>
+                        </table>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+[% INCLUDE 'intranet-bottom.inc' %]
index fdd361f..48f4f8d 100644 (file)
     <li>    <a href="/cgi-bin/koha/circ/waitingreserves.pl">Holds awaiting pickup</a></li>
        <li>    <a href="/cgi-bin/koha/circ/reserveratios.pl">Hold ratios</a></li>
        <li>    <a href="/cgi-bin/koha/circ/transferstoreceive.pl">Transfers to receive</a></li>
+    [% IF Koha.Preference('ArticleRequests') %]
+        <li>
+            <a href="/cgi-bin/koha/circ/article-requests.pl" title="Article requests">Article requests</a>
+        </li>
+    [% END %]
      [% IF ( CAN_user_circulate_overdues_report ) %]<li>    <a href="/cgi-bin/koha/circ/overdue.pl">Overdues</a>
        - <b>Warning:</b> This report is very resource intensive on
        systems with large numbers of overdue items.</li>[% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt
new file mode 100644 (file)
index 0000000..9aa40d0
--- /dev/null
@@ -0,0 +1,380 @@
+[% USE KohaDates %]
+[% USE Branches %]
+[% USE ItemTypes %]
+[% SET article_requests_view = 1 %]
+[% SET biblionumber = biblio.biblionumber %]
+[% INCLUDE 'doc-head-open.inc' %]
+<title>Koha &rsaquo; Circulation &rsaquo; Request article</title>
+[% INCLUDE 'doc-head-close.inc' %]
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+[% INCLUDE 'datatables.inc' %]
+
+<script type="text/javascript">
+// <![CDATA[
+$('#current-article-requests').ready(function() {
+    $(".hide").hide();
+});
+
+$(document).ready(function() {
+    $( "#patron" ).autocomplete({
+        source: "/cgi-bin/koha/circ/ysearch.pl",
+        minLength: 3,
+        select: function( event, ui ) {
+            $( "#patron" ).val( ui.item.cardnumber );
+            $( "#holds_patronsearch" ).submit();
+            return false;
+        }
+    })
+    .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
+        return $( "<li></li>" )
+        .data( "ui-autocomplete-item", item )
+        .append( "<a>" + item.surname + ", " + item.firstname +
+                 " (" + item.cardnumber + ") <small>" + item.address +
+                 " " + item.city + " " + item.zipcode + " " +
+                 item.country + "</small></a>" )
+        .appendTo( ul );
+    };
+
+    $( ".ar-update-branchcode" ).on('focus', function(){
+        previous_branchcode = this.value;
+    }).on('change', function(){
+        var branchcode = this.value;
+        var c = confirm(_("Are you sure you want to change the pickup library from %s to %s for this request?").format( previous_branchcode, branchcode ));
+
+        if ( c ) {
+            var id = this.id.split("branchcode-")[1];
+            $("#update-processing-" + id ).css({opacity: 0, visibility: "visible"}).animate({opacity: 1.0}, 200);
+
+            $.ajax({
+                type: "POST",
+                url: '/cgi-bin/koha/svc/article_request',
+                data: {
+                    action: 'update_branchcode',
+                    id: id,
+                    branchcode: branchcode,
+                },
+                success: function( data ) {
+                    $("#update-processing-" + id ).css({opacity: 1.0, visibility: "visible"}).animate({opacity: 0}, 200);
+                },
+                dataType: 'json'
+            });
+
+        } else {
+            this.value = previous_branchcode;
+        }
+    });
+
+    $(".ar-cancel-request").on("click", function(){
+        var a = $(this);
+        var notes = prompt(_("Reason for cancellation:"));
+
+        if ( notes != null ) {
+            var id = this.id.split("cancel-")[1];
+            $("#cancel-processing-" + id ).hide('slow');
+            $("#cancel-processing-spinner-" + id ).show('slow');
+
+            $.ajax({
+                type: "POST",
+                url: '/cgi-bin/koha/svc/article_request',
+                data: {
+                    action: 'cancel',
+                    id: id,
+                    notes: notes
+                },
+                success: function( data ) {
+                    a.parents('tr').hide('slow');
+                },
+                dataType: 'json'
+            });
+        }
+    });
+});
+// ]]>
+</script>
+</head>
+
+<body id="circ_article_request" class="catalog">
+    [% 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/catalogue/search.pl">Catalog</a>
+        &rsaquo;
+        <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]">[% biblio.title | html %]</a>
+        &rsaquo;
+        Request article
+    </div>
+
+    <div id="doc3" class="yui-t2">
+        <div id="bd">
+            <div id="yui-main">
+                <div class="yui-b">
+
+                    <h1>Request article from <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.id %]">[% biblio.title | html %]</a></h1>
+                    [% IF no_patrons_found %]
+                        <div class="dialog alert">
+                            <h3>Patron not found</h3>
+                            <p>No patron with this name, please, try another</p>
+                        </div>
+                    [% ELSIF patrons %]
+                        <form id="article_request_patron_results" method="post">
+                            <fieldset>
+                                <table id="table_borrowers">
+                                    <thead>
+                                        <tr>
+                                            <th></th>
+                                            <th>Name</th>
+                                            <th>Cardnumber</th>
+                                            <th>Category</th>
+                                            <th>Library</th>
+                                            <th>Address</th>
+                                        </tr>
+                                    </thead>
+                                    <tbody>
+                                        [% FOREACH patron IN patrons %]
+                                            <tr>
+                                                <td><input type="radio" name="patron_id" value="[% patron.borrowernumber %]"/></td>
+                                                <td>[% patron.surname %], [% patron.firstname %]</td>
+                                                <td>[% patron.cardnumber %]</td>
+                                                <td>[% patron.categorycode %]</td>
+                                                <td>[% patron.branchcode %]</td>
+                                                <td>[% patron.address %]</td>
+                                            </tr>
+                                        [% END %]
+                                    </tbody>
+                                </table>
+                                <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
+                                <fieldset class="action"><input type="submit" value="Select" /></fieldset>
+                            </fieldset>
+                        </form>
+                    [% ELSIF !patron %]
+                        <form id="article_requests_patronsearch" action="request-article.pl" method="post">
+                            <fieldset class="brief">
+                                <label for="patron">Patron: </label>
+                                <div class="hint">Enter patron card number or partial name:</div>
+                                <input type="text" size="40" id="patron" class="focus" name="patron_cardnumber" />
+                                <input type="submit" value="Search" />
+                                <input type="hidden" name="biblionumber" value="[% biblio.id %]" />
+                            </fieldset>
+                        </form>
+                    [% ELSE %]
+                        [% IF biblio.can_article_request( patron ) %]
+
+                            <form id="place-article-request" method="post" action="/cgi-bin/koha/circ/request-article.pl">
+                                <input type="hidden" name="action" value="create" />
+                                <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblio.biblionumber %]" />
+                                <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.id %]" />
+
+                                <fieldset class="rows">
+                                    <legend>Place article request from [% biblio.title %] for [% patron.firstname %] [% patron.surname %] ( [% patron.cardnumber %] )</legend>
+                                    <p/>
+                                    <ul>
+                                        <li>
+                                            <label for="title">Title:</label>
+                                            <input type="text" name="title" id="title" size="50"/>
+                                        </li>
+
+                                        <li>
+                                            <label for="author">Author:</label>
+                                            <input type="text" name="author" id="author" size="50"/>
+                                        </li>
+
+                                        <li>
+                                            <label for="volume">Volume:</label>
+                                            <input type="text" name="volume" id="volume" size="50"/>
+                                        </li>
+
+                                        <li>
+                                            <label for="issue">Issue:</label>
+                                            <input type="text" name="issue" id="issue" size="50"/>
+                                        </li>
+
+                                        <li>
+                                            <label for="date">Date:</label>
+                                            <input type="text" name="date" id="date" size="50"/>
+                                        </li>
+
+                                        <li>
+                                            <label for="pages">Pages:</label>
+                                            <input type="text" name="pages" id="pages" size="50"/>
+                                        </li>
+
+                                        <li>
+                                            <label for="chapters">Chapters:</label>
+                                            <input type="text" name="chapters" id="chapters" size="50"/>
+                                        </li>
+
+                                        <li>
+                                            <label for="patron_notes">Patron 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">
+                                                [% FOREACH b IN Branches.all %]
+                                                    [% IF b.branchcode == Branches.GetLoggedInBranchcode %]
+                                                        <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
+                                                    [% ELSE %]
+                                                        <option value="[% b.branchcode %]">[% b.branchname %]</option>
+                                                    [% END %]
+                                                [% END %]
+                                            </select>
+                                        </li>
+                                    </ul>
+                                </fieldset>
+
+                                [% SET article_request_type = biblio.article_request_type( patron ) %]
+                                [% IF article_request_type != 'bib_only' %]
+                                    <table id="current-requests-table" class="ar-table table table-bordered table-striped">
+                                        <caption>Select 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 %]" checked="checked" />
+                                                            [% ELSE %]
+                                                                <input type="radio" name="itemnumber" value="[% item.itemnumber %]" />
+                                                            [% END %]
+                                                        </td>
+                                                        <td>
+                                                            [% ItemTypes.GetDescription( item.itype ) %]
+                                                        </td>
+                                                        <td>
+                                                            [% item.barcode %]
+                                                        </td>
+                                                        <td>
+                                                            [% Branches.GetName( item.homebranch ) %]
+                                                        </td>
+                                                        <td>
+                                                            [% item.itemcallnumber %]
+                                                        </td>
+                                                        <td>
+                                                            [% item.enumchron %]
+                                                        </td>
+                                                    </tr>
+                                                [% END %]
+                                            [% END %]
+
+                                            [% IF article_request_type != 'item_only' %]
+                                                <tr>
+                                                    <td>
+                                                        <input type="radio" name="itemnumber" value="" checked="checked"/>
+                                                    </td>
+                                                    <td colspan="5">
+                                                        Any item
+                                                    </td>
+                                                </tr>
+                                            [% END %]
+                                        </tbody>
+                                    </table>
+                                [% END %]
+
+                                <p>
+                                    <input type="submit" class="btn" value="Place request" />
+                                </p>
+                            </form>
+                        [% ELSE %]
+                            No article requests can be made for this record.
+                        [% END %]
+
+                    [% END %]
+
+                    [% IF biblio.article_requests_current && !patron %]
+                        <fieldset class="rows left" id="current-article-requests-fieldset">
+                            <legend>Current article requests</legend>
+
+                            <table id="current-article-requests-table">
+                                <tr>
+                                    <th>Placed on</th>
+                                    <th>Patron</th>
+                                    <th>Title</th>
+                                    <th>Author</th>
+                                    <th>Volume</th>
+                                    <th>Issue</th>
+                                    <th>Date</th>
+                                    <th>Pages</th>
+                                    <th>Chapters</th>
+                                    <th>Patron notes</th>
+                                    <th>Item</th>
+                                    <th>Status</th>
+                                    <th>Pickup library</th>
+                                    <th>&nbsp;</th>
+                                </tr>
+
+                                [% FOREACH ar IN biblio.article_requests_current %]
+                                    <tr>
+                                        <td>[% ar.created_on | $KohaDates %]</td>
+                                        <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% ar.borrowernumber %]">[% ar.borrower.firstname %] [% ar.borrower.surname %]</a></td>
+                                        <td>[% ar.title %]</td>
+                                        <td>[% ar.author %]</td>
+                                        <td>[% ar.volume %]</td>
+                                        <td>[% ar.issue %]</td>
+                                        <td>[% ar.date %]</td>
+                                        <td>[% ar.pages %]</td>
+                                        <td>[% ar.chapters %]</td>
+                                        <td>[% ar.patron_notes %]</td>
+                                        <td>
+                                            [% IF ar.item %]
+                                                <a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% ar.itemnumber %]&biblionumber=[% ar.biblionumber %]">[% ar.item.barcode %]</a>
+                                            [% END %]
+                                        </td>
+                                        <td>
+                                            [% IF ar.status == 'PENDING' %]
+                                                Pending
+                                            [% ELSIF ar.status == 'PROCESSING' %]
+                                                Processing
+                                            [% ELSIF ar.status == 'COMPLETED' %]
+                                                Completed
+                                            [% ELSIF ar.status == 'CANCELED' %]
+                                                Canceled
+                                            [% END %]
+                                        </td>
+                                        <td>
+                                            <i id="update-processing-[% ar.id %]" class="fa fa-cog fa-spin hidden"></i>
+                                            <select name="branchcode" id="branchcode-[% ar.id %]" class="ar-update-branchcode">
+                                                [% FOREACH b IN Branches.all %]
+                                                    [% IF b.branchcode == ar.branchcode %]
+                                                        <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
+                                                    [% ELSE %]
+                                                        <option value="[% b.branchcode %]">[% b.branchname %]</option>
+                                                    [% END %]
+                                                [% END %]
+                                            </select>
+                                        </td>
+                                        <td>
+                                            <a title="Cancel article request" href="#" id="cancel-[% ar.id %]" class="ar-cancel-request">
+                                                <i id="cancel-processing-spinner-[% ar.id %]" class="fa fa-cog fa-spin hide"></i>
+                                                <i id="cancel-processing-[% ar.id %]" class="fa fa-times fa-lg" style="color:red"></i>
+                                            </a>
+                                        </td>
+                                    </tr>
+                                [% END %]
+                            </table>
+                        </fieldset>
+                    [% END %]
+                </div>
+            </div>
+
+            <div class="yui-b">
+                [% INCLUDE 'biblio-view-menu.inc' %]
+            </div>
+        </div>
+    </div>
+[% INCLUDE 'intranet-bottom.inc' %]
index b251d9b..33e6259 100644 (file)
@@ -124,8 +124,17 @@ var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this news item? This
                     || ( CAN_user_borrowers && pending_borrower_modifications )
                     || ( CAN_user_acquisition && pendingsuggestions )
                     || ( CAN_user_borrowers && pending_discharge_requests )
+                    || pending_article_requests
             ) %]
                 <div id="area-pending">
+                    [% IF pending_article_requests %]
+                    <div class="pending-info" id="article_requests_pending">
+
+                        <a href="/cgi-bin/koha/circ/article-requests.pl">Article requests</a>:
+                        <span class="pending-number-link">[% pending_article_requests %]</span>
+                    </div>
+                    [% END %]
+
                     [% IF ( CAN_user_acquisition && pendingsuggestions ) %]
                     <div class="pending-info" id="suggestions_pending">
 
index 3c14bea..17fd0e8 100644 (file)
@@ -1,3 +1,4 @@
+[% USE Biblio %]
 <ul id="action">
     [% UNLESS ( norequests ) %]
         [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
@@ -8,12 +9,21 @@
             [% END %]
         [% END %]
     [% END %]
+
     <li><a class="print-large" href="#">Print</a></li>
+
+    [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
+        [% IF Koha.Preference('ArticleRequests') %]
+            <li><a class="article_request" href="/cgi-bin/koha/opac-request-article.pl?biblionumber=[% biblionumber %]">Request article</a></li>
+        [% END %]
+    [% END %]
+
     [% IF Koha.Preference( 'virtualshelves' ) == 1 %]
         [% IF ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && loggedinusername ) %]
             <li><a class="addtoshelf" href="/cgi-bin/koha/opac-addbybiblionumber.pl?biblionumber=[% biblionumber %]">Save to your lists</a></li>
         [% END %]
     [% END %]
+
     [% IF Koha.Preference( 'opacbookbag' ) == 1 %]
         [% IF ( incart ) %]
             <li><a class="incart cart[% biblionumber %] addrecord" href="#">In your cart</a> <a class="cartRemove cartR[% biblionumber %]" href="#">(remove)</a></li>
@@ -21,6 +31,7 @@
             <li><a class="addtocart cart[% biblionumber %] addrecord" href="#">Add to your cart</a>  <a style="display:none;" class="cartRemove cartR[% biblionumber %]" href="#">(remove)</a></li>
         [% END %]
     [% END %]
+
     [% IF ( OpacHighlightedWords && query_desc ) %]
     <li>
         <a href="#" class="highlight_toggle" id="highlight_toggle_off">Unhighlight</a>
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt
new file mode 100644 (file)
index 0000000..18036a8
--- /dev/null
@@ -0,0 +1,225 @@
+[% USE Koha %]
+[% USE Branches %]
+[% USE ItemTypes %]
+[% INCLUDE 'doc-head-open.inc' %]
+<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Request article</title>
+[% INCLUDE 'doc-head-close.inc' %]
+[% BLOCK cssinclude %][% END %]
+</head>
+
+[% INCLUDE 'bodytag.inc' bodyid='opac-holds' %]
+[% INCLUDE 'masthead.inc' %]
+
+<div class="main">
+    <ul class="breadcrumb">
+        <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
+        <li><a href="#">Request article</a></li>
+    </ul>
+
+    <div class="container">
+        [% IF biblio.can_article_request( patron ) %]
+            [% 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 %]
+
+            <h3>Place article request for [% biblio.title %]</h3>
+
+            <form id="place-article-request" method="post" action="/cgi-bin/koha/opac-request-article.pl">
+                <input type="hidden" name="action" value="create" />
+                <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblio.biblionumber %]" />
+
+                <fieldset class="rows">
+                    <ul>
+                        <li>
+                            [% IF mandatory_fields.search('title') %]
+                                <label for="title" class="required">Title:</label>
+                            [% ELSE %]
+                                <label for="title">Title:</label>
+                            [% END %]
+                            <input type="text" name="title" id="title" size="50"/>
+                        </li>
+
+                        <li>
+                            [% IF mandatory_fields.search('author') %]
+                                <label for="author" class="required">Author:</label>
+                            [% ELSE %]
+                                <label for="author">Author:</label>
+                            [% END %]
+                            <input type="text" name="author" id="author" size="50"/>
+                        </li>
+
+                        <li>
+                            [% IF mandatory_fields.search('volume') %]
+                                <label for="volume" class="required">Volume:</label>
+                            [% ELSE %]
+                                <label for="volume">Volume:</label>
+                            [% END %]
+                            <input type="text" name="volume" id="volume" size="50"/>
+                        </li>
+
+                        <li>
+                            [% IF mandatory_fields.search('issue') %]
+                                <label for="issue" class="required">Issue:</label>
+                            [% ELSE %]
+                                <label for="issue">Issue:</label>
+                            [% END %]
+                            <input type="text" name="issue" id="issue" size="50"/>
+                        </li>
+
+                        <li>
+                            [% IF mandatory_fields.search('date') %]
+                                <label for="date" class="required">Date:</label>
+                            [% ELSE %]
+                                <label for="date">Date:</label>
+                            [% END %]
+                            <input type="text" name="date" id="date" size="50"/>
+                        </li>
+
+                        <li>
+                            [% IF mandatory_fields.search('pages') %]
+                                <label for="pages" class="required">Pages:</label>
+                            [% ELSE %]
+                                <label for="pages">Pages:</label>
+                            [% END %]
+                            <input type="text" name="pages" id="pages" size="50"/>
+                        </li>
+
+                        <li>
+                            [% IF mandatory_fields.search('chapters') %]
+                                <label for="chapters" class="required">Chapters:</label>
+                            [% ELSE %]
+                                <label for="chapters">Chapters:</label>
+                            [% END %]
+                            <input type="text" name="chapters" id="chapters" size="50"/>
+                        </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">
+                                [% FOREACH b IN Branches.all %]
+                                    [% IF b.branchcode == Branches.GetLoggedInBranchcode %]
+                                        <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
+                                    [% ELSE %]
+                                        <option value="[% b.branchcode %]">[% b.branchname %]</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 %]" checked="checked" />
+                                            [% ELSE %]
+                                                <input type="radio" name="itemnumber" value="[% item.itemnumber %]" />
+                                            [% END %]
+                                        </td>
+                                        <td>
+                                            [% ItemTypes.GetDescription( item.itype ) %]
+                                        </td>
+                                        <td>
+                                            [% item.barcode %]
+                                        </td>
+                                        <td>
+                                            [% Branches.GetName( item.homebranch ) %]
+                                        </td>
+                                        <td>
+                                            [% item.itemcallnumber %]
+                                        </td>
+                                        <td>
+                                            [% item.enumchron %]
+                                        </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 %]
+
+                <input type="submit" class="btn" value="Place request" />
+            </form>
+        [% ELSE %]
+            No article requests can be made for this record.
+        [% END %]
+
+    </div> <!-- / .container -->
+</div> <!-- / .main -->
+
+[% INCLUDE 'opac-bottom.inc' %]
+
+[% BLOCK jsinclude %]
+<script type="text/javascript">
+// <![CDATA[
+    allow_submit = false;
+    $('#place-article-request').on('submit', function( event ){
+        if ( ! allow_submit ) {
+            event.preventDefault();
+
+            [% IF article_request_type == 'item_only' %]
+                if ( ! $("input:radio[name='itemnumber']").is(":checked") ) {
+                    alert( _("Please select a specific item for this article request.") );
+                    return 0;
+                }
+            [% END %]
+
+            var mandatory_fields = "[% mandatory_fields %]";
+            var m = new Array();
+            if ( mandatory_fields ) m = mandatory_fields.split(",");
+            var f = new Array();
+
+            for (i = 0; i < m.length; i++) {
+                if ( ! $("#" + m[i]).val() ) {
+                    f.push( m[i] );
+                }
+            }
+
+            if ( f.length ) {
+                alert( _("The following fields are required and not filled in: ") + f.join(", ") );
+                return 0;
+            }
+
+            allow_submit = true;
+            $('#place-article-request').submit();
+        }
+    });
+// ]]>
+</script>
+[% END %]
index 7cd6b7a..2d85671 100644 (file)
                                                             [% END # UNLESS SEARCH_RESULT.norequests %]
                                                         [% END # IF RequestOnOpac %]
 
+                                                        [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) %]
+                                                            [% IF Koha.Preference('ArticleRequests') %]
+                                                                <span class="actions"><a class="article_request" href="/cgi-bin/koha/opac-request-article.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Request article</a></span>
+                                                            [% END %]
+                                                        [% END %]
+
                                                         [% IF ( TagsInputEnabled ) %]
                                                             [% IF ( loggedinusername ) %]
                                                                 <span class="actions"><a class="tag_add" id="tag_add[% SEARCH_RESULT.biblionumber %]" href="#">Add tag</a></span>
index b7ac6f9..a242d44 100644 (file)
@@ -134,6 +134,7 @@ Using this account is not recommended because some parts of Koha will not functi
                                 [% IF ( BORROWER_INFO.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% BORROWER_INFO.amountoutstanding | $Price %])</a></li>[% END %]
                             [% END %]
                             [% IF ( RESERVES.count ) %]<li><a href="#opac-user-holds">Holds ([% RESERVES.count %])</a></li>[% END %]
+                            [% IF Koha.Preference('ArticleRequests') && borrower.article_requests_current %]<li><a href="#opac-user-article-requests">Article requests ([% borrower.article_requests_current.count %])</a></li>[% END %]
                         </ul>
 
                         <div id="opac-user-checkouts">
@@ -716,6 +717,105 @@ Using this account is not recommended because some parts of Koha will not functi
                             [% END %]
                         </div> <!-- / #opac-user-holds -->
                         [% END # / #RESERVES.count %]
+
+                        [% IF Koha.Preference('ArticleRequests') && borrower.article_requests_current.count %]
+                            <div id="opac-user-article-requests">
+                                <table id="article-requests-table" class="table table-bordered table-striped">
+                                    <caption>Article requests <span class="count">([% borrower.article_requests_current.count %] total)</span></caption>
+                                    <!-- RESERVES TABLE ROWS -->
+                                    <thead>
+                                        <tr>
+                                            <th class="anti-the">Record title</th>
+                                            <th class="psort">Placed on</th>
+                                            <th class="anti-the">Title</th>
+                                            <th>Author</th>
+                                            <th>Volume</th>
+                                            <th>Issue</th>
+                                            <th>Date</th>
+                                            <th>Pages</th>
+                                            <th>Chapters</th>
+                                            <th>Notes</th>
+                                            <th>Status</th>
+                                            <th>Pickup library</th>
+                                            <th class="nosort">&nbsp;</th>
+                                        </tr>
+                                    </thead>
+
+                                    <tbody>
+                                    [% FOREACH ar IN borrower.article_requests_current %]
+                                            <td class="article-request-title">
+                                                <a class="article-request-title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% ar.biblionumber %]">
+                                                    [% ar.biblio.title %]
+                                                    [% ar.item.enumchron %]
+                                                </a>
+                                                [% ar.biblio.author %]
+                                                [% IF ar.itemnumber %] <i>(only [% ar.item.barcode %])</i>[% END %]
+                                            </td>
+
+                                            <td class="article-request-created_on">
+                                                [% ar.created_on | $KohaDates %]
+                                            </td>
+
+                                            <td class="article-request-title">
+                                                [% ar.title %]
+                                            </td>
+
+                                            <td class="article-request-author">
+                                                [% ar.author %]
+                                            </td>
+
+                                            <td class="article-request-volume">
+                                                [% ar.volume %]
+                                            </td>
+
+                                            <td class="article-request-issue">
+                                                [% ar.issue %]
+                                            </td>
+
+                                            <td class="article-request-date">
+                                                [% ar.date %]
+                                            </td>
+
+                                            <td class="article-request-pages">
+                                                [% ar.pages %]
+                                            </td>
+
+                                            <td class="article-request-chapters">
+                                                [% ar.chapters %]
+                                            </td>
+
+                                            <td class="article-request-patron-notes">
+                                                [% ar.patron_notes %]
+                                            </td>
+
+                                            <td class="article-request-status">
+                                                [% IF ar.status == 'PENDING' %]
+                                                    Pending
+                                                [% ELSIF ar.status == 'PROCESSING' %]
+                                                    Processing
+                                                [% ELSIF ar.status == 'COMPLETED' %]
+                                                    Completed
+                                                [% ELSIF ar.status == 'CANCELED' %]
+                                                    Canceled
+                                                [% END %]
+                                            </td>
+
+                                            <td class="article-request-branchcode">
+                                                [% ar.branch.branchname %]
+                                            </td>
+
+                                            <td class="article-request-cancel">
+                                                <span class="tdlabel">Cancel:</span>
+                                                <a class="btn btn-mini btn-danger" href="opac-article-request-cancel.pl?id=[% ar.id %]" onclick="return confirmDelete(MSG_CONFIRM_DELETE_HOLD);"><i class="icon-remove icon-white"></i> Cancel</a>
+                                                <!-- TODO: replace MSG_CONFIRM_DELETE_HOLD with correct message -->
+                                            </td>
+                                        </tr>
+                                    [% END %]
+                                </tbody>
+                            </table>
+                        </div> <!-- / #opac-user-article-requests -->
+                    [% END %]
+
                     </div> <!-- /#opac-user-views -->
                 </div> <!-- /#userdetails -->
             </div> <!-- /.span10 -->
index 0bd32b4..8fc5da4 100644 (file)
@@ -266,6 +266,14 @@ td {
             padding-left : 21px;
             text-decoration : none;
         }
+        &.article_request {
+            background-image : url("../images/sprite.png"); /* Place hold small */
+            background-position : -2px -26px;
+            background-repeat: no-repeat;
+            margin-right : 1em;
+            padding-left : 21px;
+            text-decoration : none;
+        }
         &.addtocart {
             background-image : url("../images/sprite.png"); /* Cart small */
             background-position : -5px -572px;
@@ -1338,6 +1346,7 @@ a.print-large,
 a.removeitems,
 a.removeitems.disabled,
 a.reserve,
+a.article_request,
 a.send,
 a.tag_add,
 a.removefromlist,
@@ -1466,6 +1475,11 @@ a.reserve {
     padding-left : 35px;
 }
 
+a.article_request {
+    background-position: 0px -24px; /* Place article request */
+    padding-left : 35px;
+}
+
 a.send {
     background-position : 2px -386px; /* Email */
     text-decoration : none;
@@ -2503,4 +2517,8 @@ a.reviewlink:visited {
     cursor: pointer;
 }
 
+.btn-danger {
+    color: white !important;
+}
+
 @import "responsive.less";
index 258a9d5..7410247 100755 (executable)
@@ -30,6 +30,7 @@ use C4::Tags qw/get_count_by_tag_status/;
 use Koha::Patron::Modifications;
 use Koha::Patron::Discharge;
 use Koha::Reviews;
+use Koha::ArticleRequests;
 
 my $query = new CGI;
 
@@ -67,6 +68,12 @@ my $pendingtags        = get_count_by_tag_status(0);
 my $pendingsuggestions = CountSuggestion("ASKED");
 my $pending_borrower_modifications = Koha::Patron::Modifications->pending_count( $branch );
 my $pending_discharge_requests = Koha::Patron::Discharge::count({ pending => 1 });
+my $pending_article_requests = Koha::ArticleRequests->count(
+    {
+        status => Koha::ArticleRequest::Status::Pending,
+        $branch ? ( branchcode => $branch ) : (),
+    }
+);
 
 $template->param(
     pendingcomments                => $pendingcomments,
@@ -74,6 +81,7 @@ $template->param(
     pendingsuggestions             => $pendingsuggestions,
     pending_borrower_modifications => $pending_borrower_modifications,
     pending_discharge_requests     => $pending_discharge_requests,
+    pending_article_requests       => $pending_article_requests,
 );
 
 #
diff --git a/opac/opac-article-request-cancel.pl b/opac/opac-article-request-cancel.pl
new file mode 100755 (executable)
index 0000000..baaa0ae
--- /dev/null
@@ -0,0 +1,47 @@
+#!/usr/bin/perl
+
+# Copyright 2015
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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 <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+
+use CGI qw ( -utf8 );
+
+use C4::Output;
+use C4::Auth;
+use Koha::ArticleRequests;
+
+my $query = new CGI;
+
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-account.tt",
+        query           => $query,
+        type            => "opac",
+        authnotrequired => 0,
+        debug           => 1,
+    }
+);
+
+my $id = $query->param('id');
+
+if ( $id && $borrowernumber ) {
+    my $ar = Koha::ArticleRequests->find( $id );
+    $ar->cancel() if $ar;
+}
+
+print $query->redirect("/cgi-bin/koha/opac-user.pl#opac-user-article-requests");
diff --git a/opac/opac-request-article.pl b/opac/opac-request-article.pl
new file mode 100755 (executable)
index 0000000..b7621dc
--- /dev/null
@@ -0,0 +1,87 @@
+#!/usr/bin/perl
+
+# Copyright ByWater Solutions 2015
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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 <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+
+use CGI qw ( -utf8 );
+
+use C4::Auth;
+use C4::Output;
+
+use Koha::Biblios;
+use Koha::Patrons;
+
+my $cgi = new CGI;
+
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-request-article.tt",
+        query           => $cgi,
+        type            => "opac",
+        authnotrequired => 0,
+        debug           => 1,
+    }
+);
+
+my $action = $cgi->param('action') || q{};
+my $biblionumber = $cgi->param('biblionumber');
+
+if ( $action eq 'create' ) {
+    my $branchcode = $cgi->param('branchcode');
+
+    my $itemnumber   = $cgi->param('itemnumber')   || undef;
+    my $title        = $cgi->param('title')        || undef;
+    my $author       = $cgi->param('author')       || undef;
+    my $volume       = $cgi->param('volume')       || undef;
+    my $issue        = $cgi->param('issue')        || undef;
+    my $date         = $cgi->param('date')         || undef;
+    my $pages        = $cgi->param('pages')        || undef;
+    my $chapters     = $cgi->param('chapters')     || undef;
+    my $patron_notes = $cgi->param('patron_notes') || undef;
+
+    my $ar = Koha::ArticleRequest->new(
+        {
+            borrowernumber => $borrowernumber,
+            biblionumber   => $biblionumber,
+            branchcode     => $branchcode,
+            itemnumber     => $itemnumber,
+            title          => $title,
+            author         => $author,
+            volume         => $volume,
+            issue          => $issue,
+            date           => $date,
+            pages          => $pages,
+            chapters       => $chapters,
+            patron_notes   => $patron_notes,
+        }
+    )->store();
+
+    print $cgi->redirect("/cgi-bin/koha/opac-user.pl#opac-user-article-requests");
+    exit;
+}
+
+my $biblio = Koha::Biblios->find($biblionumber);
+my $patron = Koha::Patrons->find($borrowernumber);
+
+$template->param(
+    biblio => $biblio,
+    patron => $patron,
+);
+
+output_html_with_http_headers $cgi, $cookie, $template->output;
index 0ac78de..838a573 100755 (executable)
@@ -38,6 +38,7 @@ use Koha::Holds;
 use Koha::Database;
 use Koha::Patron::Messages;
 use Koha::Patron::Discharge;
+use Koha::Patrons;
 
 use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
 
@@ -324,7 +325,7 @@ if (   C4::Context->preference('AllowPatronToSetCheckoutsVisibilityForGuarantor'
 }
 
 $template->param(
-    borrower                 => $borr,
+    borrower                 => Koha::Patrons->find($borrowernumber),
     patron_messages          => $patron_messages,
     opacnote                 => $borr->{opacnote},
     patronupdate             => $patronupdate,
diff --git a/svc/article_request b/svc/article_request
new file mode 100755 (executable)
index 0000000..8db68ff
--- /dev/null
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+
+# Copyright 2015 ByWater Solutions
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+use Modern::Perl;
+
+use CGI;
+use JSON qw(to_json);
+
+use C4::Auth qw(check_cookie_auth);
+use Koha::ArticleRequests;
+
+my $cgi = new CGI;
+
+my ( $auth_status, $sessionID ) =
+  check_cookie_auth( $cgi->cookie('CGISESSID'), { circulate => 'circulate_remaining_permissions' } );
+if ( $auth_status ne "ok" ) {
+    exit 0;
+}
+
+binmode STDOUT, ':encoding(UTF-8)';
+print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
+
+my $id = $cgi->param('id');
+my $action = $cgi->param('action') || q{};
+my $notes = $cgi->param('notes');
+
+my $ar = Koha::ArticleRequests->find($id);
+
+if ($ar) {
+    if ( $action eq 'cancel' ) {
+        $ar = $ar->cancel( $notes );
+    }
+    elsif ( $action eq 'process' ) {
+        $ar = $ar->process();
+    }
+    elsif ( $action eq 'complete' ) {
+        $ar = $ar->complete();
+    }
+    elsif ( $action eq 'update_branchcode' ) {
+        my $branchcode = $cgi->param('branchcode');
+        $ar->branchcode( $branchcode ) if $branchcode;
+        $ar = $ar->store();
+    }
+}
+
+print to_json( { success => $ar ? 1 : 0 } );
index 2e5c037..441a05f 100755 (executable)
@@ -234,6 +234,10 @@ sub add_form {
         } else {
             push @{$field_selection}, add_fields('issues');
         }
+
+        if ( $module eq 'circulation' and $code =~ /^AR_/  ) {
+            push @{$field_selection}, add_fields('article_requests');
+        }
     }
 
     $template->param(