From f99e27708cd87387a70a131bde3c8a786978997a Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 16 Feb 2016 13:41:43 +0000 Subject: [PATCH] Bug 14610 [QA Followup] - Get rid of separate scripts just for creating new requests --- circ/request-article-do.pl | 62 ---------------------- circ/request-article.pl | 49 ++++++++++++++--- .../prog/en/modules/circ/request-article.tt | 3 +- .../bootstrap/en/modules/opac-request-article.tt | 3 +- opac/opac-request-article-do.pl | 62 ---------------------- opac/opac-request-article.pl | 33 ++++++++++++ 6 files changed, 78 insertions(+), 134 deletions(-) delete mode 100755 circ/request-article-do.pl delete mode 100755 opac/opac-request-article-do.pl diff --git a/circ/request-article-do.pl b/circ/request-article-do.pl deleted file mode 100755 index 66fd3c5..0000000 --- a/circ/request-article-do.pl +++ /dev/null @@ -1,62 +0,0 @@ -#!/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 . - -use Modern::Perl; - -use CGI qw ( -utf8 ); - -use C4::Auth; -use C4::Output; - -use Koha::ArticleRequest; - -my $cgi = new CGI; - -checkauth( $cgi, 0, { circulate => 'circulate_remaining_permissions' }, 'intranet' ); - -my $biblionumber = $cgi->param('biblionumber'); -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 $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, - } -)->store(); - -print $cgi->redirect("/cgi-bin/koha/circ/request-article.pl?biblionumber=$biblionumber"); diff --git a/circ/request-article.pl b/circ/request-article.pl index 448cac8..6c083d5 100755 --- a/circ/request-article.pl +++ b/circ/request-article.pl @@ -26,26 +26,59 @@ use Koha::Biblios; use Koha::Borrowers; use Koha::ArticleRequests; -my $input = new CGI; +my $cgi = new CGI; my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( { template_name => "circ/request-article.tt", - query => $input, + query => $cgi, type => "intranet", authnotrequired => 0, flagsrequired => { circulate => 'circulate_remaining_permissions' }, } ); -my $biblionumber = $input->param('biblionumber'); -my $patron_cardnumber = $input->param('patron_cardnumber'); -my $patron_id = $input->param('patron_id'); +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 = Koha::Borrowers->find( $patron_id ? $patron_id : { cardnumber => $patron_cardnumber } ); +my $patron = Koha::Borrowers->find( + $patron_id ? $patron_id : { cardnumber => $patron_cardnumber } ); -if (!$patron && $patron_cardnumber) { +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 $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, + } + )->store(); + +} + +if ( !$patron && $patron_cardnumber ) { my $results = C4::Utils::DataTables::Members::search( { searchmember => $patron_cardnumber, @@ -71,4 +104,4 @@ $template->param( patron => $patron, ); -output_html_with_http_headers $input, $cookie, $template->output; +output_html_with_http_headers $cgi, $cookie, $template->output; 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 index 0ce2cc7..e74e289 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt @@ -161,7 +161,8 @@ $(document).ready(function() { [% ELSE %] [% IF biblio.can_article_request( patron ) %] -
+ + 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 index 7937292..bb5042f 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt @@ -25,7 +25,8 @@

Place article request for [% biblio.title %]

- + +
diff --git a/opac/opac-request-article-do.pl b/opac/opac-request-article-do.pl deleted file mode 100755 index 921b8fd..0000000 --- a/opac/opac-request-article-do.pl +++ /dev/null @@ -1,62 +0,0 @@ -#!/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 . - -use Modern::Perl; - -use CGI qw ( -utf8 ); - -use C4::Auth; -use C4::Output; - -use Koha::ArticleRequest; - -my $cgi = new CGI; - -my ( $userid, $cookie, $sessionID ) = checkauth( $cgi, 0, {}, 'opac' ); -my $borrowernumber = C4::Context->userenv->{'number'}; - -my $biblionumber = $cgi->param('biblionumber'); -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 $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, - } -)->store(); - -print $cgi->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 index a5b1b83..5920366 100755 --- a/opac/opac-request-article.pl +++ b/opac/opac-request-article.pl @@ -39,8 +39,41 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); +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 $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, + } + )->store(); + + print $cgi->redirect("/cgi-bin/koha/opac-user.pl#opac-user-article-requests"); + exit; +} + my $biblio = Koha::Biblios->find($biblionumber); my $patron = Koha::Borrowers->find($borrowernumber); -- 2.1.4