Koha/opac/opac-suggestions.pl
Bernardo Gonzalez Kriegel 2d9f5fc69e Bug 9457: [ENH] Ordering branches should be case independent (2)
This patch replace use of CGI::scroll_list() to show list of branches.

In two files, marc21_linking_section.pl and unimarc_field_4XX.pl,
the scrolling list is created but not used in the template file,
so the code is removed.

Also minor renaming/normalizing of variables.

To test:
1) Install with some branches, records and patrons

2.1) Select a record, click 'Place hold', select user,
     there is a library pull-down next to 'Pickup at:',
     list is ordered case sensitive
2.2) Go to Reports > Average loan time,
     next to Library is a pull-down,
     list without order
2.3) Go to Reports > Catalog by item type,
     next to 'Select a library' is a pull-down,
     list is ordered case sensitive
2.4) This is tricky, go to Reports home,
     change last part of URL 'reports-home.pl' with
     'manager.pl?report_name=issues_by_borrower_category'
     (can't find a direct link), next to 'Select a library'
     is a library pull-down,
     list without order
2.5) Edit/Add a patron, on section 'Library management'
     there is a library pull-down, case sensitive
2.6) OPAC, as logged user, make a suggestion or hold,
     there is library pull-down, correct order

3) Apply the patch

4.1) Repeat 2.1), correctly ordered list
4.2) Repeat 2.2), correctly ordered list
4.3) Repeat 2.3), correctly ordered list
4.4) Repeat 2.4), correctly ordered list
4.5) This is a bit more work
     There are 3 possible situations to test:
     A) No branches, must show a message that are no
        libraries defined
     B) New patron, must show a correctly ordered
        list of branches, current branch selected
     C) Edit patron, must show a correctly ordered
        list of branches, patron branch selected
4.6) Small changes on variable names, so retest 2.6)

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
2013-03-20 15:35:58 -04:00

149 lines
4.7 KiB
Perl
Executable file

#!/usr/bin/perl
# 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 strict;
use warnings;
use CGI;
use C4::Auth; # get_template_and_user
use C4::Members;
use C4::Branch;
use C4::Koha;
use C4::Output;
use C4::Suggestions;
use C4::Koha;
use C4::Dates;
my $input = new CGI;
my $allsuggestions = $input->param('showall');
my $op = $input->param('op');
my $suggestion = $input->Vars;
delete $$suggestion{$_} foreach qw<op suggestedbyme>;
$op = 'else' unless $op;
my ( $template, $borrowernumber, $cookie );
my $deleted = $input->param('deleted');
my $submitted = $input->param('submitted');
if ( C4::Context->preference("AnonSuggestions") ) {
( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
template_name => "opac-suggestions.tmpl",
query => $input,
type => "opac",
authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
}
);
if ( !$$suggestion{suggestedby} ) {
$$suggestion{suggestedby} = C4::Context->preference("AnonymousPatron");
}
}
else {
( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
template_name => "opac-suggestions.tmpl",
query => $input,
type => "opac",
authnotrequired => 0,
}
);
}
if ($allsuggestions){
delete $$suggestion{suggestedby};
}
else {
$$suggestion{suggestedby} ||= $borrowernumber unless ($allsuggestions);
}
# warn "bornum:",$borrowernumber;
my $suggestions_loop =
&SearchSuggestion( $suggestion);
if ( $op eq "add_confirm" ) {
if (@$suggestions_loop>=1){
#some suggestion are answering the request Donot Add
}
else {
$$suggestion{'suggesteddate'}=C4::Dates->today;
$$suggestion{'branchcode'}= $input->param('branch') || C4::Context->userenv->{"branch"};
&NewSuggestion($suggestion);
# empty fields, to avoid filter in "SearchSuggestion"
$$suggestion{$_}='' foreach qw<title author publishercode copyrightdate place collectiontitle isbn STATUS>;
$suggestions_loop =
&SearchSuggestion( $suggestion );
}
$op = 'else';
print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else&submitted=1");
exit;
}
if ( $op eq "delete_confirm" ) {
my @delete_field = $input->param("delete_field");
foreach my $delete_field (@delete_field) {
&DelSuggestion( $borrowernumber, $delete_field );
}
$op = 'else';
print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else&deleted=1");
exit;
}
map{ $_->{'branchcodesuggestedby'}=GetBranchInfo($_->{'branchcodesuggestedby'})->[0]->{'branchname'}} @$suggestions_loop;
my $supportlist=GetSupportList();
foreach my $support(@$supportlist){
if ($$support{'imageurl'}){
$$support{'imageurl'}= getitemtypeimagelocation( 'opac', $$support{'imageurl'} );
}
else {
delete $$support{'imageurl'}
}
}
foreach my $suggestion(@$suggestions_loop) {
if($suggestion->{'suggestedby'} == $borrowernumber) {
$suggestion->{'showcheckbox'} = $borrowernumber;
} else {
$suggestion->{'showcheckbox'} = 0;
}
if($suggestion->{'patronreason'}){
$suggestion->{'patronreason'} = GetKohaAuthorisedValueLib("OPAC_SUG",$suggestion->{'patronreason'},1);
}
}
my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG");
# Is the person allowed to choose their branch
if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) {
my ( $borr ) = GetMemberDetails( $borrowernumber );
# pass the pickup branch along....
my $branch = $input->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ;
# make branch selection options...
my $branchloop = GetBranchesLoop($branch);
$template->param( branchloop => $branchloop );
}
$template->param(
%$suggestion,
itemtypeloop=> $supportlist,
suggestions_loop => $suggestions_loop,
patron_reason_loop => $patron_reason_loop,
showall => $allsuggestions,
"op_$op" => 1,
suggestionsview => 1,
);
output_html_with_http_headers $input, $cookie, $template->output;