Lines 18-30
Link Here
|
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
|
19 |
|
20 |
use strict; |
20 |
use strict; |
|
|
21 |
|
21 |
#use warnings; FIXME - Bug 2505 |
22 |
#use warnings; FIXME - Bug 2505 |
22 |
require Exporter; |
23 |
require Exporter; |
23 |
use CGI; |
24 |
use CGI; |
24 |
use C4::Auth; # get_template_and_user |
25 |
use C4::Auth; # get_template_and_user |
25 |
use C4::Output; |
26 |
use C4::Output; |
26 |
use C4::Suggestions; |
27 |
use C4::Suggestions; |
27 |
use C4::Koha; #GetItemTypes |
28 |
use C4::Koha; #GetItemTypes |
28 |
use C4::Branch; |
29 |
use C4::Branch; |
29 |
use C4::Budgets; |
30 |
use C4::Budgets; |
30 |
use C4::Search; |
31 |
use C4::Search; |
Lines 32-114
use C4::Dates qw(format_date);
Link Here
|
32 |
use C4::Members; |
33 |
use C4::Members; |
33 |
use C4::Debug; |
34 |
use C4::Debug; |
34 |
|
35 |
|
35 |
sub Init{ |
36 |
sub Init { |
36 |
my $suggestion= shift @_; |
37 |
my $suggestion = shift @_; |
|
|
38 |
|
37 |
# "Managed by" is used only when a suggestion is being edited (not when created) |
39 |
# "Managed by" is used only when a suggestion is being edited (not when created) |
38 |
if ($suggestion->{'suggesteddate'} eq "0000-00-00" ||$suggestion->{'suggesteddate'} eq "") { |
40 |
if ( $suggestion->{'suggesteddate'} eq "0000-00-00" || $suggestion->{'suggesteddate'} eq "" ) { |
|
|
41 |
|
39 |
# new suggestion |
42 |
# new suggestion |
40 |
$suggestion->{'suggesteddate'} = C4::Dates->today; |
43 |
$suggestion->{'suggesteddate'} = C4::Dates->today; |
41 |
$suggestion->{'suggestedby'} = C4::Context->userenv->{"number"} unless ($suggestion->{'suggestedby'}); |
44 |
$suggestion->{'suggestedby'} = C4::Context->userenv->{"number"} unless ( $suggestion->{'suggestedby'} ); |
42 |
} |
45 |
} else { |
43 |
else { |
46 |
|
44 |
# editing of an existing suggestion |
47 |
# editing of an existing suggestion |
45 |
$suggestion->{'manageddate'} = C4::Dates->today; |
48 |
$suggestion->{'manageddate'} = C4::Dates->today; |
46 |
$suggestion->{'managedby'} = C4::Context->userenv->{"number"} unless ($suggestion->{'managedby'}); |
49 |
$suggestion->{'managedby'} = C4::Context->userenv->{"number"} unless ( $suggestion->{'managedby'} ); |
|
|
50 |
|
47 |
# suggesteddate, when coming from the DB, needs to be formated |
51 |
# suggesteddate, when coming from the DB, needs to be formated |
48 |
$suggestion->{'suggesteddate'} = format_date($suggestion->{'suggesteddate'}); |
52 |
$suggestion->{'suggesteddate'} = format_date( $suggestion->{'suggesteddate'} ); |
49 |
} |
53 |
} |
50 |
foreach my $date ( qw(rejecteddate accepteddate) ){ |
54 |
foreach my $date (qw(rejecteddate accepteddate)) { |
51 |
$suggestion->{$date}=(($suggestion->{$date} eq "0000-00-00" ||$suggestion->{$date} eq "")? |
55 |
$suggestion->{$date} = ( |
52 |
"": |
56 |
( $suggestion->{$date} eq "0000-00-00" || $suggestion->{$date} eq "" ) |
53 |
format_date($suggestion->{$date}) |
57 |
? "" |
54 |
); |
58 |
: format_date( $suggestion->{$date} ) |
|
|
59 |
); |
55 |
} |
60 |
} |
56 |
$suggestion->{'branchcode'}=C4::Context->userenv->{"branch"} unless ($suggestion->{'branchcode'}); |
61 |
$suggestion->{'branchcode'} = C4::Context->userenv->{"branch"} unless ( $suggestion->{'branchcode'} ); |
57 |
} |
62 |
} |
58 |
|
63 |
|
59 |
sub GetCriteriumDesc{ |
64 |
sub GetCriteriumDesc { |
60 |
my ($criteriumvalue,$displayby)=@_; |
65 |
my ( $criteriumvalue, $displayby ) = @_; |
61 |
return ($criteriumvalue eq 'ASKED'?"Pending":ucfirst(lc( $criteriumvalue))) if ($displayby =~/status/i); |
66 |
return ( $criteriumvalue eq 'ASKED' ? "Pending" : ucfirst( lc($criteriumvalue) ) ) if ( $displayby =~ /status/i ); |
62 |
return (GetBranchName($criteriumvalue)) if ($displayby =~/branchcode/); |
67 |
return ( GetBranchName($criteriumvalue) ) if ( $displayby =~ /branchcode/ ); |
63 |
return (GetSupportName($criteriumvalue)) if ($displayby =~/itemtype/); |
68 |
return ( GetSupportName($criteriumvalue) ) if ( $displayby =~ /itemtype/ ); |
64 |
if ($displayby =~/suggestedby/||$displayby =~/managedby/||$displayby =~/acceptedby/){ |
69 |
if ( $displayby =~ /suggestedby/ || $displayby =~ /managedby/ || $displayby =~ /acceptedby/ ) { |
65 |
my $borr=C4::Members::GetMember(borrowernumber=>$criteriumvalue); |
70 |
my $borr = C4::Members::GetMember( borrowernumber => $criteriumvalue ); |
66 |
return "" unless $borr; |
71 |
return "" unless $borr; |
67 |
return $$borr{surname} . ", " . $$borr{firstname}; |
72 |
return $$borr{surname} . ", " . $$borr{firstname}; |
68 |
} |
73 |
} |
69 |
if ( $displayby =~ /budgetid/) { |
74 |
if ( $displayby =~ /budgetid/ ) { |
70 |
my $budget = GetBudget($criteriumvalue); |
75 |
my $budget = GetBudget($criteriumvalue); |
71 |
return "" unless $budget; |
76 |
return "" unless $budget; |
72 |
return $$budget{budget_name}; |
77 |
return $$budget{budget_name}; |
73 |
} |
78 |
} |
74 |
} |
79 |
} |
75 |
|
80 |
|
76 |
my $input = CGI->new; |
81 |
my $input = CGI->new; |
77 |
my $suggestedbyme = (defined $input->param('suggestedbyme')? $input->param('suggestedbyme'):1); |
82 |
my $suggestedbyme = ( defined $input->param('suggestedbyme') ? $input->param('suggestedbyme') : 1 ); |
78 |
my $op = $input->param('op')||'else'; |
83 |
my $op = $input->param('op') || 'else'; |
79 |
my @editsuggestions = $input->param('edit_field'); |
84 |
my @editsuggestions = $input->param('edit_field'); |
80 |
my $suggestedby = $input->param('suggestedby'); |
85 |
my $suggestedby = $input->param('suggestedby'); |
81 |
my $returnsuggestedby = $input->param('returnsuggestedby'); |
86 |
my $returnsuggestedby = $input->param('returnsuggestedby'); |
82 |
my $returnsuggested = $input->param('returnsuggested'); |
87 |
my $returnsuggested = $input->param('returnsuggested'); |
83 |
my $managedby = $input->param('managedby'); |
88 |
my $managedby = $input->param('managedby'); |
84 |
my $displayby = $input->param('displayby') || ''; |
89 |
my $displayby = $input->param('displayby') || ''; |
85 |
my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : ''; |
90 |
my $branchfilter = ( $displayby ne "branchcode" ) ? $input->param('branchcode') : ''; |
86 |
my $tabcode = $input->param('tabcode'); |
91 |
my $tabcode = $input->param('tabcode'); |
87 |
|
92 |
|
88 |
# filter informations which are not suggestion related. |
93 |
# filter informations which are not suggestion related. |
89 |
my $suggestion_ref = $input->Vars; |
94 |
my $suggestion_ref = $input->Vars; |
90 |
|
95 |
|
91 |
delete $$suggestion_ref{$_} foreach qw( suggestedbyme op displayby tabcode edit_field ); |
96 |
delete $$suggestion_ref{$_} foreach qw( suggestedbyme op displayby tabcode edit_field ); |
92 |
foreach (keys %$suggestion_ref){ |
97 |
foreach ( keys %$suggestion_ref ) { |
93 |
delete $$suggestion_ref{$_} if (!$$suggestion_ref{$_} && ($op eq 'else' || $op eq 'change')); |
98 |
delete $$suggestion_ref{$_} if ( !$$suggestion_ref{$_} && ( $op eq 'else' || $op eq 'change' ) ); |
94 |
} |
99 |
} |
95 |
my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user( |
100 |
my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user( |
96 |
{ |
101 |
{ template_name => "suggestion/suggestion.tmpl", |
97 |
template_name => "suggestion/suggestion.tmpl", |
102 |
query => $input, |
98 |
query => $input, |
103 |
type => "intranet", |
99 |
type => "intranet", |
104 |
flagsrequired => { catalogue => 1 }, |
100 |
flagsrequired => { catalogue => 1 }, |
105 |
} |
101 |
} |
106 |
); |
102 |
); |
|
|
103 |
|
107 |
|
104 |
######################################### |
108 |
######################################### |
105 |
## Operations |
109 |
## Operations |
106 |
## |
110 |
## |
107 |
if ( $op =~ /save/i ) { |
111 |
if ( $op =~ /save/i ) { |
108 |
if ( $$suggestion_ref{"STATUS"} ) { |
112 |
if ( $$suggestion_ref{"STATUS"} ) { |
109 |
if ( my $tmpstatus = lc( $$suggestion_ref{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) { |
113 |
if ( my $tmpstatus = lc( $$suggestion_ref{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) { |
110 |
$$suggestion_ref{ lc( $$suggestion_ref{"STATUS"}) . "date" } = C4::Dates->today; |
114 |
$$suggestion_ref{ lc( $$suggestion_ref{"STATUS"} ) . "date" } = C4::Dates->today; |
111 |
$$suggestion_ref{ lc( $$suggestion_ref{"STATUS"}) . "by" } = C4::Context->userenv->{number}; |
115 |
$$suggestion_ref{ lc( $$suggestion_ref{"STATUS"} ) . "by" } = C4::Context->userenv->{number}; |
112 |
} |
116 |
} |
113 |
$$suggestion_ref{"manageddate"} = C4::Dates->today; |
117 |
$$suggestion_ref{"manageddate"} = C4::Dates->today; |
114 |
$$suggestion_ref{"managedby"} = C4::Context->userenv->{number}; |
118 |
$$suggestion_ref{"managedby"} = C4::Context->userenv->{number}; |
Lines 117-201
if ( $op =~ /save/i ) {
Link Here
|
117 |
&ModSuggestion($suggestion_ref); |
121 |
&ModSuggestion($suggestion_ref); |
118 |
} else { |
122 |
} else { |
119 |
###FIXME:Search here if suggestion already exists. |
123 |
###FIXME:Search here if suggestion already exists. |
120 |
my $suggestions_loop = |
124 |
my $suggestions_loop = SearchSuggestion($suggestion_ref); |
121 |
SearchSuggestion( $suggestion_ref ); |
125 |
if ( @$suggestions_loop >= 1 ) { |
122 |
if (@$suggestions_loop>=1){ |
126 |
|
123 |
#some suggestion are answering the request Donot Add |
127 |
#some suggestion are answering the request Donot Add |
124 |
} |
128 |
} else { |
125 |
else { |
|
|
126 |
## Adding some informations related to suggestion |
129 |
## Adding some informations related to suggestion |
127 |
&NewSuggestion($suggestion_ref); |
130 |
&NewSuggestion($suggestion_ref); |
128 |
} |
131 |
} |
|
|
132 |
|
129 |
# empty fields, to avoid filter in "SearchSuggestion" |
133 |
# empty fields, to avoid filter in "SearchSuggestion" |
130 |
} |
134 |
} |
131 |
map{delete $$suggestion_ref{$_}} keys %$suggestion_ref; |
135 |
map { delete $$suggestion_ref{$_} } keys %$suggestion_ref; |
132 |
$op = 'else'; |
136 |
$op = 'else'; |
133 |
} |
137 |
} elsif ( $op =~ /add/ ) { |
134 |
elsif ($op=~/add/) { |
138 |
|
135 |
#Adds suggestion |
139 |
#Adds suggestion |
136 |
Init($suggestion_ref); |
140 |
Init($suggestion_ref); |
137 |
$op ='save'; |
141 |
$op = 'save'; |
138 |
} |
142 |
} elsif ( $op =~ /edit/ ) { |
139 |
elsif ($op=~/edit/) { |
143 |
|
140 |
#Edit suggestion |
144 |
#Edit suggestion |
141 |
$suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'}); |
145 |
$suggestion_ref = &GetSuggestion( $$suggestion_ref{'suggestionid'} ); |
142 |
Init($suggestion_ref); |
146 |
Init($suggestion_ref); |
143 |
$op ='save'; |
147 |
$op = 'save'; |
144 |
} |
148 |
} elsif ( $op eq "change" ) { |
145 |
elsif ($op eq "change" ) { |
149 |
|
146 |
# set accepted/rejected/managed informations if applicable |
150 |
# set accepted/rejected/managed informations if applicable |
147 |
# ie= if the librarian has choosen some action on the suggestions |
151 |
# ie= if the librarian has choosen some action on the suggestions |
148 |
if ($$suggestion_ref{"STATUS"} eq "ACCEPTED"){ |
152 |
if ( $$suggestion_ref{"STATUS"} eq "ACCEPTED" ) { |
149 |
$$suggestion_ref{"accepteddate"}=C4::Dates->today; |
153 |
$$suggestion_ref{"accepteddate"} = C4::Dates->today; |
150 |
$$suggestion_ref{"acceptedby"}=C4::Context->userenv->{number}; |
154 |
$$suggestion_ref{"acceptedby"} = C4::Context->userenv->{number}; |
151 |
} elsif ($$suggestion_ref{"STATUS"} eq "REJECTED"){ |
155 |
} elsif ( $$suggestion_ref{"STATUS"} eq "REJECTED" ) { |
152 |
$$suggestion_ref{"rejecteddate"}=C4::Dates->today; |
156 |
$$suggestion_ref{"rejecteddate"} = C4::Dates->today; |
153 |
$$suggestion_ref{"rejectedby"}=C4::Context->userenv->{number}; |
157 |
$$suggestion_ref{"rejectedby"} = C4::Context->userenv->{number}; |
|
|
158 |
} |
159 |
if ( $$suggestion_ref{"STATUS"} ) { |
160 |
$$suggestion_ref{"manageddate"} = C4::Dates->today; |
161 |
$$suggestion_ref{"managedby"} = C4::Context->userenv->{number}; |
162 |
} |
163 |
if ( my $reason = $$suggestion_ref{"reason$tabcode"} ) { |
164 |
if ( $reason eq "other" ) { |
165 |
$reason = $$suggestion_ref{"other_reason$tabcode"}; |
166 |
} |
167 |
$$suggestion_ref{'reason'} = $reason; |
168 |
} |
169 |
delete $$suggestion_ref{$_} foreach ( "reason$tabcode", "other_reason$tabcode" ); |
170 |
foreach ( keys %$suggestion_ref ) { |
171 |
delete $$suggestion_ref{$_} unless ( $$suggestion_ref{$_} ); |
154 |
} |
172 |
} |
155 |
if ($$suggestion_ref{"STATUS"}){ |
|
|
156 |
$$suggestion_ref{"manageddate"}=C4::Dates->today; |
157 |
$$suggestion_ref{"managedby"}=C4::Context->userenv->{number}; |
158 |
} |
159 |
if ( my $reason = $$suggestion_ref{"reason$tabcode"}){ |
160 |
if ( $reason eq "other" ) { |
161 |
$reason = $$suggestion_ref{"other_reason$tabcode"}; |
162 |
} |
163 |
$$suggestion_ref{'reason'}=$reason; |
164 |
} |
165 |
delete $$suggestion_ref{$_} foreach ("reason$tabcode", "other_reason$tabcode"); |
166 |
foreach (keys %$suggestion_ref){ |
167 |
delete $$suggestion_ref{$_} unless ($$suggestion_ref{$_}); |
168 |
} |
169 |
foreach my $suggestionid (@editsuggestions) { |
173 |
foreach my $suggestionid (@editsuggestions) { |
170 |
next unless $suggestionid; |
174 |
next unless $suggestionid; |
171 |
$$suggestion_ref{'suggestionid'}=$suggestionid; |
175 |
$$suggestion_ref{'suggestionid'} = $suggestionid; |
172 |
&ModSuggestion($suggestion_ref); |
176 |
&ModSuggestion($suggestion_ref); |
173 |
} |
177 |
} |
174 |
$op = 'else'; |
178 |
$op = 'else'; |
175 |
}elsif ($op eq "delete" ) { |
179 |
} elsif ( $op eq "delete" ) { |
176 |
foreach my $delete_field (@editsuggestions) { |
180 |
foreach my $delete_field (@editsuggestions) { |
177 |
&DelSuggestion( $borrowernumber, $delete_field,'intranet' ); |
181 |
&DelSuggestion( $borrowernumber, $delete_field, 'intranet' ); |
178 |
} |
182 |
} |
179 |
$op = 'else'; |
183 |
$op = 'else'; |
180 |
} |
184 |
} elsif ( $op eq 'show' ) { |
181 |
elsif ( $op eq 'show' ) { |
185 |
$suggestion_ref = &GetSuggestion( $$suggestion_ref{'suggestionid'} ); |
182 |
$suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'}); |
|
|
183 |
$$suggestion_ref{branchname} = GetBranchName $$suggestion_ref{branchcode}; |
186 |
$$suggestion_ref{branchname} = GetBranchName $$suggestion_ref{branchcode}; |
184 |
my $budget = GetBudget $$suggestion_ref{budgetid}; |
187 |
my $budget = GetBudget $$suggestion_ref{budgetid}; |
185 |
$$suggestion_ref{budgetname} = $$budget{budget_name}; |
188 |
$$suggestion_ref{budgetname} = $$budget{budget_name}; |
186 |
Init($suggestion_ref); |
189 |
Init($suggestion_ref); |
187 |
} |
190 |
} |
188 |
if ($op=~/else/) { |
191 |
if ( $op =~ /else/ ) { |
189 |
$op='else'; |
192 |
$op = 'else'; |
190 |
|
193 |
|
191 |
$displayby||="STATUS"; |
194 |
$displayby ||= "STATUS"; |
192 |
delete $$suggestion_ref{'branchcode'} if($displayby eq "branchcode"); |
195 |
delete $$suggestion_ref{'branchcode'} if ( $displayby eq "branchcode" ); |
193 |
my $criteria_list=GetDistinctValues("suggestions.".$displayby); |
196 |
my $criteria_list = GetDistinctValues( "suggestions." . $displayby ); |
194 |
my @allsuggestions; |
197 |
my @allsuggestions; |
195 |
my $reasonsloop = GetAuthorisedValues("SUGGEST"); |
198 |
my $reasonsloop = GetAuthorisedValues("SUGGEST"); |
196 |
foreach my $criteriumvalue ( map { $$_{'value'} } @$criteria_list ) { |
199 |
foreach my $criteriumvalue ( map { $$_{'value'} } @$criteria_list ) { |
|
|
200 |
|
197 |
# By default, display suggestions from current working branch |
201 |
# By default, display suggestions from current working branch |
198 |
if(not defined $branchfilter) { |
202 |
if ( not defined $branchfilter ) { |
199 |
$$suggestion_ref{'branchcode'} = C4::Context->userenv->{'branch'}; |
203 |
$$suggestion_ref{'branchcode'} = C4::Context->userenv->{'branch'}; |
200 |
} |
204 |
} |
201 |
my $definedvalue = defined $$suggestion_ref{$displayby} && $$suggestion_ref{$displayby} ne ""; |
205 |
my $definedvalue = defined $$suggestion_ref{$displayby} && $$suggestion_ref{$displayby} ne ""; |
Lines 205-308
if ($op=~/else/) {
Link Here
|
205 |
|
209 |
|
206 |
my $suggestions = &SearchSuggestion($suggestion_ref); |
210 |
my $suggestions = &SearchSuggestion($suggestion_ref); |
207 |
foreach my $suggestion (@$suggestions) { |
211 |
foreach my $suggestion (@$suggestions) { |
208 |
if ($suggestion->{budgetid}){ |
212 |
if ( $suggestion->{budgetid} ) { |
209 |
my $bud = GetBudget( $suggestion->{budgetid} ); |
213 |
my $bud = GetBudget( $suggestion->{budgetid} ); |
210 |
$suggestion->{budget_name} = $bud->{budget_name} if $bud; |
214 |
$suggestion->{budget_name} = $bud->{budget_name} if $bud; |
211 |
} |
215 |
} |
212 |
foreach my $date (qw(suggesteddate manageddate accepteddate)) { |
216 |
foreach my $date (qw(suggesteddate manageddate accepteddate)) { |
213 |
if ($suggestion->{$date} and $suggestion->{$date} ne "0000-00-00") { |
217 |
if ( $suggestion->{$date} and $suggestion->{$date} ne "0000-00-00" ) { |
214 |
$suggestion->{$date} = format_date( $suggestion->{$date} ); |
218 |
$suggestion->{$date} = format_date( $suggestion->{$date} ); |
215 |
} else { |
219 |
} else { |
216 |
$suggestion->{$date} = ""; |
220 |
$suggestion->{$date} = ""; |
217 |
} |
221 |
} |
218 |
} |
222 |
} |
219 |
} |
223 |
} |
220 |
push @allsuggestions,{ |
224 |
push @allsuggestions, |
221 |
"suggestiontype"=>$criteriumvalue||"suggest", |
225 |
{ "suggestiontype" => $criteriumvalue || "suggest", |
222 |
"suggestiontypelabel"=>GetCriteriumDesc($criteriumvalue,$displayby)||"", |
226 |
"suggestiontypelabel" => GetCriteriumDesc( $criteriumvalue, $displayby ) || "", |
223 |
"suggestionscount"=>scalar(@$suggestions), |
227 |
"suggestionscount" => scalar(@$suggestions), |
224 |
'suggestions_loop'=>$suggestions, |
228 |
'suggestions_loop' => $suggestions, |
225 |
'reasonsloop' => $reasonsloop, |
229 |
'reasonsloop' => $reasonsloop, |
226 |
}; |
230 |
}; |
227 |
|
231 |
|
228 |
delete $$suggestion_ref{$displayby} unless $definedvalue; |
232 |
delete $$suggestion_ref{$displayby} unless $definedvalue; |
229 |
} |
233 |
} |
230 |
|
234 |
|
231 |
$template->param( |
235 |
$template->param( |
232 |
"displayby"=> $displayby, |
236 |
"displayby" => $displayby, |
233 |
"notabs"=> $displayby eq "", |
237 |
"notabs" => $displayby eq "", |
234 |
suggestions => \@allsuggestions, |
238 |
suggestions => \@allsuggestions, |
235 |
); |
239 |
); |
236 |
} |
240 |
} |
237 |
|
241 |
|
238 |
foreach my $element ( qw(managedby suggestedby acceptedby) ) { |
242 |
foreach my $element (qw(managedby suggestedby acceptedby)) { |
239 |
# $debug || warn $$suggestion_ref{$element}; |
243 |
|
240 |
if ($$suggestion_ref{$element}){ |
244 |
# $debug || warn $$suggestion_ref{$element}; |
241 |
my $member=GetMember(borrowernumber=>$$suggestion_ref{$element}); |
245 |
if ( $$suggestion_ref{$element} ) { |
|
|
246 |
my $member = GetMember( borrowernumber => $$suggestion_ref{$element} ); |
242 |
$template->param( |
247 |
$template->param( |
243 |
$element."_borrowernumber"=>$$member{borrowernumber}, |
248 |
$element . "_borrowernumber" => $$member{borrowernumber}, |
244 |
$element."_firstname"=>$$member{firstname}, |
249 |
$element . "_firstname" => $$member{firstname}, |
245 |
$element."_surname"=>$$member{surname}, |
250 |
$element . "_surname" => $$member{surname}, |
246 |
$element."_branchcode"=>$$member{branchcode}, |
251 |
$element . "_branchcode" => $$member{branchcode}, |
247 |
$element."_description"=>$$member{description}, |
252 |
$element . "_description" => $$member{description}, |
248 |
$element."_category_type"=>$$member{category_type} |
253 |
$element . "_category_type" => $$member{category_type} |
249 |
); |
254 |
); |
250 |
} |
255 |
} |
251 |
} |
256 |
} |
252 |
$template->param( |
257 |
$template->param( |
253 |
%$suggestion_ref, |
258 |
%$suggestion_ref, |
254 |
"op_$op" => 1, |
259 |
"op_$op" => 1, |
255 |
dateformat => C4::Context->preference("dateformat"), |
260 |
dateformat => C4::Context->preference("dateformat"), |
256 |
"op" =>$op, |
261 |
"op" => $op, |
257 |
); |
262 |
); |
258 |
|
263 |
|
259 |
if(defined($returnsuggested) and $returnsuggested ne "noone") |
264 |
if ( defined($returnsuggested) and $returnsuggested ne "noone" ) { |
260 |
{ |
265 |
print $input->redirect( "/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $returnsuggested . "#suggestions" ); |
261 |
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=".$returnsuggested."#suggestions"); |
|
|
262 |
} |
266 |
} |
263 |
|
267 |
|
264 |
#################### |
268 |
#################### |
265 |
## Initializing selection lists |
269 |
## Initializing selection lists |
266 |
|
270 |
|
267 |
#branch display management |
271 |
#branch display management |
268 |
my $onlymine=C4::Context->preference('IndependantBranches') && |
272 |
my $onlymine = |
269 |
C4::Context->userenv && |
273 |
C4::Context->preference('IndependantBranches') |
270 |
C4::Context->userenv->{flags}!=1 && |
274 |
&& C4::Context->userenv |
271 |
C4::Context->userenv->{branch}; |
275 |
&& C4::Context->userenv->{flags} != 1 |
|
|
276 |
&& C4::Context->userenv->{branch}; |
272 |
my $branches = GetBranches($onlymine); |
277 |
my $branches = GetBranches($onlymine); |
273 |
my @branchloop; |
278 |
my @branchloop; |
274 |
|
279 |
|
275 |
foreach my $thisbranch ( sort {$branches->{$a}->{'branchname'} cmp $branches->{$b}->{'branchname'}} keys %$branches ) { |
280 |
foreach my $thisbranch ( sort { $branches->{$a}->{'branchname'} cmp $branches->{$b}->{'branchname'} } keys %$branches ) { |
276 |
my %row = ( |
281 |
my %row = ( |
277 |
value => $thisbranch, |
282 |
value => $thisbranch, |
278 |
branchname => $branches->{$thisbranch}->{'branchname'}, |
283 |
branchname => $branches->{$thisbranch}->{'branchname'}, |
279 |
selected => ($branchfilter and $branches->{$thisbranch}->{'branchcode'} eq $branchfilter ) || ( $$suggestion_ref{'branchcode'} and $branches->{$thisbranch}->{'branchcode'} eq $$suggestion_ref{'branchcode'} ) |
284 |
selected => ( $branchfilter and $branches->{$thisbranch}->{'branchcode'} eq $branchfilter ) |
|
|
285 |
|| ( $$suggestion_ref{'branchcode'} and $branches->{$thisbranch}->{'branchcode'} eq $$suggestion_ref{'branchcode'} ) |
280 |
); |
286 |
); |
281 |
push @branchloop, \%row; |
287 |
push @branchloop, \%row; |
282 |
} |
288 |
} |
283 |
$branchfilter=C4::Context->userenv->{'branch'} if ($onlymine && !$branchfilter); |
289 |
$branchfilter = C4::Context->userenv->{'branch'} if ( $onlymine && !$branchfilter ); |
284 |
|
290 |
|
285 |
$template->param( branchloop => \@branchloop, |
291 |
$template->param( |
286 |
branchfilter => $branchfilter); |
292 |
branchloop => \@branchloop, |
|
|
293 |
branchfilter => $branchfilter |
294 |
); |
287 |
|
295 |
|
288 |
# the index parameter is different for item-level itemtypes |
296 |
# the index parameter is different for item-level itemtypes |
289 |
my $supportlist = GetSupportList(); |
297 |
my $supportlist = GetSupportList(); |
290 |
|
298 |
|
291 |
foreach my $support (@$supportlist) { |
299 |
foreach my $support (@$supportlist) { |
292 |
$$support{'selected'} = (defined $$suggestion_ref{'itemtype'}) |
300 |
$$support{'selected'} = |
293 |
? $$support{'itemtype'} eq $$suggestion_ref{'itemtype'} |
301 |
( defined $$suggestion_ref{'itemtype'} ) |
294 |
: 0; |
302 |
? $$support{'itemtype'} eq $$suggestion_ref{'itemtype'} |
|
|
303 |
: 0; |
295 |
if ( $$support{'imageurl'} ) { |
304 |
if ( $$support{'imageurl'} ) { |
296 |
$$support{'imageurl'} = getitemtypeimagelocation( 'intranet', $$support{'imageurl'} ); |
305 |
$$support{'imageurl'} = getitemtypeimagelocation( 'intranet', $$support{'imageurl'} ); |
297 |
} else { |
306 |
} else { |
298 |
delete $$support{'imageurl'}; |
307 |
delete $$support{'imageurl'}; |
299 |
} |
308 |
} |
300 |
} |
309 |
} |
301 |
$template->param(itemtypeloop=>$supportlist); |
310 |
$template->param( itemtypeloop => $supportlist ); |
302 |
$template->param( returnsuggestedby => $returnsuggestedby ); |
311 |
$template->param( returnsuggestedby => $returnsuggestedby ); |
303 |
|
312 |
|
304 |
my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG",$$suggestion_ref{'patronreason'}); |
313 |
my $patron_reason_loop = GetAuthorisedValues( "OPAC_SUG", $$suggestion_ref{'patronreason'} ); |
305 |
$template->param(patron_reason_loop=>$patron_reason_loop); |
314 |
$template->param( patron_reason_loop => $patron_reason_loop ); |
306 |
|
315 |
|
307 |
#Budgets management |
316 |
#Budgets management |
308 |
my $budgets = []; |
317 |
my $budgets = []; |
Lines 315-342
if ($branchfilter) {
Link Here
|
315 |
|
324 |
|
316 |
my @budgets_loop; |
325 |
my @budgets_loop; |
317 |
foreach my $budget ( @{$budgets} ) { |
326 |
foreach my $budget ( @{$budgets} ) { |
318 |
next unless (CanUserUseBudget($borrowernumber, $budget, $userflags)); |
327 |
next unless ( CanUserUseBudget( $borrowernumber, $budget, $userflags ) ); |
319 |
|
328 |
|
320 |
## Please see file perltidy.ERR |
329 |
## Please see file perltidy.ERR |
321 |
$budget->{'selected'} = 1 |
330 |
$budget->{'selected'} = 1 |
322 |
if ($$suggestion_ref{'budgetid'} |
331 |
if ( $$suggestion_ref{'budgetid'} |
323 |
&& $budget->{'budget_id'} eq $$suggestion_ref{'budgetid'}); |
332 |
&& $budget->{'budget_id'} eq $$suggestion_ref{'budgetid'} ); |
324 |
|
333 |
|
325 |
push @budgets_loop, $budget; |
334 |
push @budgets_loop, $budget; |
326 |
} |
335 |
} |
327 |
|
336 |
|
328 |
$template->param( budgetsloop => \@budgets_loop); |
337 |
$template->param( budgetsloop => \@budgets_loop ); |
329 |
$template->param( "statusselected_$$suggestion_ref{'STATUS'}" =>1) if ($$suggestion_ref{'STATUS'}); |
338 |
$template->param( "statusselected_$$suggestion_ref{'STATUS'}" => 1 ) if ( $$suggestion_ref{'STATUS'} ); |
330 |
|
339 |
|
331 |
# get currencies and rates |
340 |
# get currencies and rates |
332 |
my @rates = GetCurrencies(); |
341 |
my @rates = GetCurrencies(); |
333 |
my $count = scalar @rates; |
342 |
my $count = scalar @rates; |
334 |
my $active_currency = GetCurrency(); |
343 |
my $active_currency = GetCurrency(); |
335 |
my $selected_currency; |
344 |
my $selected_currency; |
336 |
if ($$suggestion_ref{'currency'}) { |
345 |
if ( $$suggestion_ref{'currency'} ) { |
337 |
$selected_currency = $$suggestion_ref{'currency'}; |
346 |
$selected_currency = $$suggestion_ref{'currency'}; |
338 |
} |
347 |
} else { |
339 |
else { |
|
|
340 |
$selected_currency = $active_currency->{currency}; |
348 |
$selected_currency = $active_currency->{currency}; |
341 |
} |
349 |
} |
342 |
|
350 |
|
Lines 345-373
for ( my $i = 0 ; $i < $count ; $i++ ) {
Link Here
|
345 |
my %line; |
353 |
my %line; |
346 |
$line{currcode} = $rates[$i]->{'currency'}; |
354 |
$line{currcode} = $rates[$i]->{'currency'}; |
347 |
$line{rate} = $rates[$i]->{'rate'}; |
355 |
$line{rate} = $rates[$i]->{'rate'}; |
348 |
$line{selected} = 1 if ($line{'currcode'} eq $selected_currency); |
356 |
$line{selected} = 1 if ( $line{'currcode'} eq $selected_currency ); |
349 |
push @loop_currency, \%line; |
357 |
push @loop_currency, \%line; |
350 |
} |
358 |
} |
351 |
|
359 |
|
352 |
$template->param(loop_currency => \@loop_currency); |
360 |
$template->param( loop_currency => \@loop_currency ); |
353 |
|
361 |
|
354 |
$template->param( |
362 |
$template->param( |
355 |
price => sprintf("%.2f", $$suggestion_ref{'price'}||0), |
363 |
price => sprintf( "%.2f", $$suggestion_ref{'price'} || 0 ), |
356 |
total => sprintf("%.2f", $$suggestion_ref{'total'}||0), |
364 |
total => sprintf( "%.2f", $$suggestion_ref{'total'} || 0 ), |
357 |
); |
365 |
); |
358 |
|
366 |
|
359 |
my %hashlists; |
367 |
my %hashlists; |
360 |
foreach my $field ( qw(managedby acceptedby suggestedby budgetid) ) { |
368 |
foreach my $field (qw(managedby acceptedby suggestedby budgetid)) { |
361 |
my $values_list; |
369 |
my $values_list; |
362 |
$values_list = GetDistinctValues( "suggestions." . $field ); |
370 |
$values_list = GetDistinctValues( "suggestions." . $field ); |
363 |
my @codes_list = map { |
371 |
my @codes_list = map { |
364 |
{ 'code' => $$_{'value'}, |
372 |
{ 'code' => $$_{'value'}, |
365 |
'desc' => GetCriteriumDesc( $$_{'value'}, $field ), |
373 |
'desc' => GetCriteriumDesc( $$_{'value'}, $field ), |
366 |
'selected' => ($$suggestion_ref{$field}) ? $$_{'value'} eq $$suggestion_ref{$field} : 0, |
374 |
'selected' => ( $$suggestion_ref{$field} ) ? $$_{'value'} eq $$suggestion_ref{$field} : 0, |
367 |
} |
375 |
} |
368 |
} @$values_list; |
376 |
} @$values_list; |
369 |
$hashlists{ lc($field) . "_loop" } = \@codes_list; |
377 |
$hashlists{ lc($field) . "_loop" } = \@codes_list; |
370 |
} |
378 |
} |
371 |
$template->param(%hashlists); |
379 |
$template->param(%hashlists); |
372 |
$template->param(DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),); |
380 |
$template->param( DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), ); |
373 |
output_html_with_http_headers $input, $cookie, $template->output; |
381 |
output_html_with_http_headers $input, $cookie, $template->output; |
374 |
- |
|
|