@@ -, +, @@
---
.../data/mysql/en/mandatory/suggest_status.sql | 6 +
.../data/mysql/en/mandatory/suggest_status.txt | 1 +
.../prog/en/modules/suggestion/suggestion.tt | 163 +++++++++++---------
.../opac-tmpl/prog/en/modules/opac-suggestions.tt | 7 +-
suggestion/suggestion.pl | 150 +++++++++---------
5 files changed, 177 insertions(+), 150 deletions(-)
create mode 100644 installer/data/mysql/en/mandatory/suggest_status.sql
create mode 100644 installer/data/mysql/en/mandatory/suggest_status.txt
--- a/installer/data/mysql/en/mandatory/suggest_status.sql
+++ a/installer/data/mysql/en/mandatory/suggest_status.sql
@@ -0,0 +1,6 @@
+INSERT INTO authorised_values ( category, authorised_value, lib, lib_opac) VALUES
+('SUGGEST_STATUS', 'ACCEPTED', 'Accepted', 'Accepted'),
+('SUGGEST_STATUS', 'CHECKED', 'Checked', 'Checked'),
+('SUGGEST_STATUS', 'REJECTED', 'Rejected', 'Rejected'),
+('SUGGEST_STATUS', 'ORDERED', 'Ordered', 'Ordered'),
+('SUGGEST_STATUS', 'ASKED', 'Pending', 'Requested');
--- a/installer/data/mysql/en/mandatory/suggest_status.txt
+++ a/installer/data/mysql/en/mandatory/suggest_status.txt
@@ -0,0 +1, @@
+Default Koha system suggestion statuses
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt
@@ -1,3 +1,5 @@
+[% USE KohaAuthorisedValues %]
+[% USE KohaBranchName %]
[% INCLUDE 'doc-head-open.inc' %]
Koha › Acquisitions ›
[% IF ( op_save ) %]
@@ -194,12 +196,14 @@ $(document).ready(function() { calcNewsuggTotal(); });
Status:
- [% IF ( STATUS == 'ASKED' ) %]Pending
- [% ELSIF ( STATUS == 'ACCEPTED' ) %]Accepted
- [% ELSIF ( STATUS == 'CHECKED' ) %]Checked
- [% ELSIF ( STATUS == 'REJECTED' ) %]Rejected
- [% ELSE %]No Status
+ [% SET status_found = 0 %]
+ [% FOREACH s IN SuggestionStatuses %]
+ [% IF STATUS == s.authorised_value %]
+ [% s.lib %]
+ [% SET status_found = 1 %]
+ [% END %]
[% END %]
+ [% UNLESS status_found %]No Status[% END %]
@@ -290,34 +294,39 @@ $(document).ready(function() { calcNewsuggTotal(); });
Suggestion management
- [% IF ( suggestionid ) %]Status: No Status
- [% IF (statusselected_ASKED ) %]Pending
- [% ELSE %]Pending [% END %]
- [% IF (statusselected_ACCEPTED ) %]Accepted
- [% ELSE %]Accepted [% END %]
- [% IF (statusselected_CHECKED ) %]Checked
- [% ELSE %]Checked [% END %]
- [% IF ( statusselected_REJECTED ) %]Rejected
- [% ELSE %]Rejected [% END %]
- [% END %]
+ [% IF ( suggestionid ) %]
+
+ Status:
+
+ No Status
+ [% FOREACH s IN SuggestionStatuses %]
+ [% IF s.authorised_value == selected_status %]
+ [% s.lib %]
+ [% ELSE %]
+ [% s.lib %]
+ [% END %]
+ [% END %]
+
+
+ [% END %]
@@ -364,21 +373,25 @@ $(document).ready(function() { calcNewsuggTotal(); });
Suggestions management
[% UNLESS ( notabs ) %]
-Sorting...
-Loading tab...
-
@@ -498,16 +518,19 @@ $(document).ready(function() { calcNewsuggTotal(); });
- Status: Any
- [% IF (statusselected_ASKED ) %]Pending
- [% ELSE %]Pending [% END %]
- [% IF (statusselected_ACCEPTED ) %]Accepted
- [% ELSE %]Accepted [% END %]
- [% IF (statusselected_CHECKED ) %]Checked
- [% ELSE %]Checked [% END %]
- [% IF ( statusselected_REJECTED ) %]Rejected
- [% ELSE %]Rejected [% END %]
-
+
+ Status:
+
+ Any
+ [% FOREACH s IN SuggestionStatuses %]
+ [% IF s.authorised_value == selected_status %]
+ [% s.lib %]
+ [% ELSE %]
+ [% s.lib %]
+ [% END %]
+ [% END %]
+
+
Suggested by: Any
[% FOREACH suggestedby_loo IN suggestedby_loop %][% IF ( suggestedby_loo.selected ) %][% suggestedby_loo.desc %] [% ELSE %][% suggestedby_loo.desc %] [% END %][% END %]
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt
+++ a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt
@@ -1,3 +1,4 @@
+[% USE KohaAuthorisedValues %]
[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog ›
[% IF ( op_add ) %]Enter a new purchase suggestion[% END %]
[% IF ( op_else ) %]Purchase Suggestions[% END %]
@@ -216,12 +217,8 @@ $.tablesorter.addParser({
[% IF ( suggestions_loo.surnamemanagedby ) %][% suggestions_loo.surnamemanagedby %][% IF ( suggestions_loo.firstnamemanagedby ) %],[% END %] [% suggestions_loo.firstnamemanagedby %][% ELSE %] [% END %]
- [% IF ( suggestions_loo.ASKED ) %]Requested[% END %]
- [% IF ( suggestions_loo.CHECKED ) %]Checked by the library[% END %]
- [% IF ( suggestions_loo.ACCEPTED ) %]Accepted by the library[% END %]
- [% IF ( suggestions_loo.ORDERED ) %]Ordered by the library[% END %]
- [% IF ( suggestions_loo.REJECTED ) %]Suggestion declined [% END %]
[% IF ( suggestions_loo.AVAILABLE ) %]Available in the library[% END %]
+ [% KohaAuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) %]
[% IF ( suggestions_loo.reason ) %]([% suggestions_loo.reason %])[% END %]
--- a/suggestion/suggestion.pl
+++ a/suggestion/suggestion.pl
@@ -51,6 +51,7 @@ sub Init {
# suggesteddate, when coming from the DB, needs to be formated
$suggestion->{'suggesteddate'} = format_date( $suggestion->{'suggesteddate'} );
}
+
foreach my $date (qw(rejecteddate accepteddate)) {
$suggestion->{$date} = (
( $suggestion->{$date} eq "0000-00-00" || $suggestion->{$date} eq "" )
@@ -58,13 +59,12 @@ sub Init {
: format_date( $suggestion->{$date} )
);
}
+
$suggestion->{'branchcode'} = C4::Context->userenv->{"branch"} unless ( $suggestion->{'branchcode'} );
}
sub GetCriteriumDesc {
my ( $criteriumvalue, $displayby ) = @_;
- return ( $criteriumvalue eq 'ASKED' ? "Pending" : ucfirst( lc($criteriumvalue) ) ) if ( $displayby =~ /status/i );
- return ( GetBranchName($criteriumvalue) ) if ( $displayby =~ /branchcode/ );
return ( GetSupportName($criteriumvalue) ) if ( $displayby =~ /itemtype/ );
if ( $displayby =~ /suggestedby/ || $displayby =~ /managedby/ || $displayby =~ /acceptedby/ ) {
my $borr = C4::Members::GetMember( borrowernumber => $criteriumvalue );
@@ -91,11 +91,11 @@ my $branchfilter = ( $displayby ne "branchcode" ) ? $input->param('branchco
my $tabcode = $input->param('tabcode');
# filter informations which are not suggestion related.
-my $suggestion_ref = $input->Vars;
+my $input_vars = $input->Vars;
-delete $$suggestion_ref{$_} foreach qw( suggestedbyme op displayby tabcode edit_field );
-foreach ( keys %$suggestion_ref ) {
- delete $$suggestion_ref{$_} if ( !$$suggestion_ref{$_} && ( $op eq 'else' || $op eq 'change' ) );
+delete $$input_vars{$_} foreach qw( suggestedbyme op displayby tabcode edit_field );
+foreach ( keys %$input_vars ) {
+ delete $$input_vars{$_} if ( !$$input_vars{$_} && ( $op eq 'else' || $op eq 'change' ) );
}
my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user(
{ template_name => "suggestion/suggestion.tmpl",
@@ -109,71 +109,71 @@ my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user(
## Operations
##
if ( $op =~ /save/i ) {
- if ( $$suggestion_ref{"STATUS"} ) {
- if ( my $tmpstatus = lc( $$suggestion_ref{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) {
- $$suggestion_ref{ lc( $$suggestion_ref{"STATUS"} ) . "date" } = C4::Dates->today;
- $$suggestion_ref{ lc( $$suggestion_ref{"STATUS"} ) . "by" } = C4::Context->userenv->{number};
+ if ( $$input_vars{"STATUS"} ) {
+ if ( my $tmpstatus = lc( $$input_vars{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) {
+ $$input_vars{ lc( $$input_vars{"STATUS"} ) . "date" } = C4::Dates->today;
+ $$input_vars{ lc( $$input_vars{"STATUS"} ) . "by" } = C4::Context->userenv->{number};
}
- $$suggestion_ref{"manageddate"} = C4::Dates->today;
- $$suggestion_ref{"managedby"} = C4::Context->userenv->{number};
+ $$input_vars{"manageddate"} = C4::Dates->today;
+ $$input_vars{"managedby"} = C4::Context->userenv->{number};
}
- if ( $$suggestion_ref{'suggestionid'} > 0 ) {
- &ModSuggestion($suggestion_ref);
+ if ( $$input_vars{'suggestionid'} > 0 ) {
+ &ModSuggestion($input_vars);
} else {
###FIXME:Search here if suggestion already exists.
- my $suggestions_loop = SearchSuggestion($suggestion_ref);
+ my $suggestions_loop = SearchSuggestion($input_vars);
if ( @$suggestions_loop >= 1 ) {
#some suggestion are answering the request Donot Add
} else {
## Adding some informations related to suggestion
- &NewSuggestion($suggestion_ref);
+ &NewSuggestion($input_vars);
}
# empty fields, to avoid filter in "SearchSuggestion"
}
- map { delete $$suggestion_ref{$_} } keys %$suggestion_ref;
+ map { delete $$input_vars{$_} } keys %$input_vars;
$op = 'else';
} elsif ( $op =~ /add/ ) {
#Adds suggestion
- Init($suggestion_ref);
+ Init($input_vars);
$op = 'save';
} elsif ( $op =~ /edit/ ) {
#Edit suggestion
- $suggestion_ref = &GetSuggestion( $$suggestion_ref{'suggestionid'} );
- Init($suggestion_ref);
+ $input_vars = &GetSuggestion( $$input_vars{'suggestionid'} );
+ Init($input_vars);
$op = 'save';
} elsif ( $op eq "change" ) {
# set accepted/rejected/managed informations if applicable
# ie= if the librarian has choosen some action on the suggestions
- if ( $$suggestion_ref{"STATUS"} eq "ACCEPTED" ) {
- $$suggestion_ref{"accepteddate"} = C4::Dates->today;
- $$suggestion_ref{"acceptedby"} = C4::Context->userenv->{number};
- } elsif ( $$suggestion_ref{"STATUS"} eq "REJECTED" ) {
- $$suggestion_ref{"rejecteddate"} = C4::Dates->today;
- $$suggestion_ref{"rejectedby"} = C4::Context->userenv->{number};
+ if ( $$input_vars{"STATUS"} eq "ACCEPTED" ) {
+ $$input_vars{"accepteddate"} = C4::Dates->today;
+ $$input_vars{"acceptedby"} = C4::Context->userenv->{number};
+ } elsif ( $$input_vars{"STATUS"} eq "REJECTED" ) {
+ $$input_vars{"rejecteddate"} = C4::Dates->today;
+ $$input_vars{"rejectedby"} = C4::Context->userenv->{number};
}
- if ( $$suggestion_ref{"STATUS"} ) {
- $$suggestion_ref{"manageddate"} = C4::Dates->today;
- $$suggestion_ref{"managedby"} = C4::Context->userenv->{number};
+ if ( $$input_vars{"STATUS"} ) {
+ $$input_vars{"manageddate"} = C4::Dates->today;
+ $$input_vars{"managedby"} = C4::Context->userenv->{number};
}
- if ( my $reason = $$suggestion_ref{"reason$tabcode"} ) {
+ if ( my $reason = $$input_vars{"reason$tabcode"} ) {
if ( $reason eq "other" ) {
- $reason = $$suggestion_ref{"other_reason$tabcode"};
+ $reason = $$input_vars{"other_reason$tabcode"};
}
- $$suggestion_ref{'reason'} = $reason;
+ $$input_vars{'reason'} = $reason;
}
- delete $$suggestion_ref{$_} foreach ( "reason$tabcode", "other_reason$tabcode" );
- foreach ( keys %$suggestion_ref ) {
- delete $$suggestion_ref{$_} unless ( $$suggestion_ref{$_} );
+ delete $$input_vars{$_} foreach ( "reason$tabcode", "other_reason$tabcode" );
+ foreach ( keys %$input_vars ) {
+ delete $$input_vars{$_} unless ( $$input_vars{$_} );
}
foreach my $suggestionid (@editsuggestions) {
next unless $suggestionid;
- $$suggestion_ref{'suggestionid'} = $suggestionid;
- &ModSuggestion($suggestion_ref);
+ $$input_vars{'suggestionid'} = $suggestionid;
+ &ModSuggestion($input_vars);
}
$op = 'else';
} elsif ( $op eq "delete" ) {
@@ -182,17 +182,17 @@ if ( $op =~ /save/i ) {
}
$op = 'else';
} elsif ( $op eq 'show' ) {
- $suggestion_ref = &GetSuggestion( $$suggestion_ref{'suggestionid'} );
- $$suggestion_ref{branchname} = GetBranchName $$suggestion_ref{branchcode};
- my $budget = GetBudget $$suggestion_ref{budgetid};
- $$suggestion_ref{budgetname} = $$budget{budget_name};
- Init($suggestion_ref);
+ $input_vars = &GetSuggestion( $$input_vars{'suggestionid'} );
+ $$input_vars{branchname} = GetBranchName $$input_vars{branchcode};
+ my $budget = GetBudget $$input_vars{budgetid};
+ $$input_vars{budgetname} = $$budget{budget_name};
+ Init($input_vars);
}
if ( $op =~ /else/ ) {
$op = 'else';
$displayby ||= "STATUS";
- delete $$suggestion_ref{'branchcode'} if ( $displayby eq "branchcode" );
+ delete $$input_vars{'branchcode'} if ( $displayby eq "branchcode" );
my $criteria_list = GetDistinctValues( "suggestions." . $displayby );
my @allsuggestions;
my $reasonsloop = GetAuthorisedValues("SUGGEST");
@@ -200,14 +200,14 @@ if ( $op =~ /else/ ) {
# By default, display suggestions from current working branch
if ( not defined $branchfilter ) {
- $$suggestion_ref{'branchcode'} = C4::Context->userenv->{'branch'};
+ $$input_vars{'branchcode'} = C4::Context->userenv->{'branch'};
}
- my $definedvalue = defined $$suggestion_ref{$displayby} && $$suggestion_ref{$displayby} ne "";
+ my $definedvalue = defined $$input_vars{$displayby} && $$input_vars{$displayby} ne "";
- next if ( $definedvalue && $$suggestion_ref{$displayby} ne $criteriumvalue );
- $$suggestion_ref{$displayby} = $criteriumvalue;
+ next if ( $definedvalue && $$input_vars{$displayby} ne $criteriumvalue );
+ $$input_vars{$displayby} = $criteriumvalue;
- my $suggestions = &SearchSuggestion($suggestion_ref);
+ my $suggestions = &SearchSuggestion($input_vars);
foreach my $suggestion (@$suggestions) {
if ( $suggestion->{budgetid} ) {
my $bud = GetBudget( $suggestion->{budgetid} );
@@ -223,13 +223,11 @@ if ( $op =~ /else/ ) {
}
push @allsuggestions,
{ "suggestiontype" => $criteriumvalue || "suggest",
- "suggestiontypelabel" => GetCriteriumDesc( $criteriumvalue, $displayby ) || "",
- "suggestionscount" => scalar(@$suggestions),
- 'suggestions_loop' => $suggestions,
- 'reasonsloop' => $reasonsloop,
+ 'suggestions_loop' => $suggestions,
+ 'reasonsloop' => $reasonsloop,
};
- delete $$suggestion_ref{$displayby} unless $definedvalue;
+ delete $$input_vars{$displayby} unless $definedvalue;
}
$template->param(
@@ -241,9 +239,9 @@ if ( $op =~ /else/ ) {
foreach my $element (qw(managedby suggestedby acceptedby)) {
- # $debug || warn $$suggestion_ref{$element};
- if ( $$suggestion_ref{$element} ) {
- my $member = GetMember( borrowernumber => $$suggestion_ref{$element} );
+ # $debug || warn $$input_vars{$element};
+ if ( $$input_vars{$element} ) {
+ my $member = GetMember( borrowernumber => $$input_vars{$element} );
$template->param(
$element . "_borrowernumber" => $$member{borrowernumber},
$element . "_firstname" => $$member{firstname},
@@ -255,7 +253,7 @@ foreach my $element (qw(managedby suggestedby acceptedby)) {
}
}
$template->param(
- %$suggestion_ref,
+ %$input_vars,
"op_$op" => 1,
dateformat => C4::Context->preference("dateformat"),
"op" => $op,
@@ -282,7 +280,7 @@ foreach my $thisbranch ( sort { $branches->{$a}->{'branchname'} cmp $branches->{
value => $thisbranch,
branchname => $branches->{$thisbranch}->{'branchname'},
selected => ( $branchfilter and $branches->{$thisbranch}->{'branchcode'} eq $branchfilter )
- || ( $$suggestion_ref{'branchcode'} and $branches->{$thisbranch}->{'branchcode'} eq $$suggestion_ref{'branchcode'} )
+ || ( $$input_vars{'branchcode'} and $branches->{$thisbranch}->{'branchcode'} eq $$input_vars{'branchcode'} )
);
push @branchloop, \%row;
}
@@ -298,8 +296,8 @@ my $supportlist = GetSupportList();
foreach my $support (@$supportlist) {
$$support{'selected'} =
- ( defined $$suggestion_ref{'itemtype'} )
- ? $$support{'itemtype'} eq $$suggestion_ref{'itemtype'}
+ ( defined $$input_vars{'itemtype'} )
+ ? $$support{'itemtype'} eq $$input_vars{'itemtype'}
: 0;
if ( $$support{'imageurl'} ) {
$$support{'imageurl'} = getitemtypeimagelocation( 'intranet', $$support{'imageurl'} );
@@ -310,7 +308,7 @@ foreach my $support (@$supportlist) {
$template->param( itemtypeloop => $supportlist );
$template->param( returnsuggestedby => $returnsuggestedby );
-my $patron_reason_loop = GetAuthorisedValues( "OPAC_SUG", $$suggestion_ref{'patronreason'} );
+my $patron_reason_loop = GetAuthorisedValues( "OPAC_SUG", $$input_vars{'patronreason'} );
$template->param( patron_reason_loop => $patron_reason_loop );
#Budgets management
@@ -328,22 +326,22 @@ foreach my $budget ( @{$budgets} ) {
## Please see file perltidy.ERR
$budget->{'selected'} = 1
- if ( $$suggestion_ref{'budgetid'}
- && $budget->{'budget_id'} eq $$suggestion_ref{'budgetid'} );
+ if ( $$input_vars{'budgetid'}
+ && $budget->{'budget_id'} eq $$input_vars{'budgetid'} );
push @budgets_loop, $budget;
}
$template->param( budgetsloop => \@budgets_loop );
-$template->param( "statusselected_$$suggestion_ref{'STATUS'}" => 1 ) if ( $$suggestion_ref{'STATUS'} );
+$template->param( "selected_status" => $$input_vars{'STATUS'} ) if ( $$input_vars{'STATUS'} );
# get currencies and rates
my @rates = GetCurrencies();
my $count = scalar @rates;
my $active_currency = GetCurrency();
my $selected_currency;
-if ( $$suggestion_ref{'currency'} ) {
- $selected_currency = $$suggestion_ref{'currency'};
+if ( $$input_vars{'currency'} ) {
+ $selected_currency = $$input_vars{'currency'};
} else {
$selected_currency = $active_currency->{currency};
}
@@ -360,22 +358,24 @@ for ( my $i = 0 ; $i < $count ; $i++ ) {
$template->param( loop_currency => \@loop_currency );
$template->param(
- price => sprintf( "%.2f", $$suggestion_ref{'price'} || 0 ),
- total => sprintf( "%.2f", $$suggestion_ref{'total'} || 0 ),
+ price => sprintf( "%.2f", $$input_vars{'price'} || 0 ),
+ total => sprintf( "%.2f", $$input_vars{'total'} || 0 ),
);
my %hashlists;
foreach my $field (qw(managedby acceptedby suggestedby budgetid)) {
my $values_list;
$values_list = GetDistinctValues( "suggestions." . $field );
- my @codes_list = map {
- { 'code' => $$_{'value'},
- 'desc' => GetCriteriumDesc( $$_{'value'}, $field ),
- 'selected' => ( $$suggestion_ref{$field} ) ? $$_{'value'} eq $$suggestion_ref{$field} : 0,
- }
- } @$values_list;
+ my @codes_list =
+ map { { 'code' => $$_{'value'}, 'desc' => GetCriteriumDesc( $$_{'value'}, $field ), 'selected' => ( $$input_vars{$field} ) ? $$_{'value'} eq $$input_vars{$field} : 0, } }
+ @$values_list;
$hashlists{ lc($field) . "_loop" } = \@codes_list;
}
$template->param(%hashlists);
-$template->param( DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), );
+
+$template->param(
+ DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
+ SuggestionStatuses => GetAuthorisedValues('SUGGEST_STATUS'),
+);
+
output_html_with_http_headers $input, $cookie, $template->output;
--