Lines 91-96
my $returnsuggested = $input->param('returnsuggested');
Link Here
|
91 |
my $managedby = $input->param('managedby'); |
91 |
my $managedby = $input->param('managedby'); |
92 |
my $displayby = $input->param('displayby') || ''; |
92 |
my $displayby = $input->param('displayby') || ''; |
93 |
my $tabcode = $input->param('tabcode'); |
93 |
my $tabcode = $input->param('tabcode'); |
|
|
94 |
my $save_confirmed = $input->param('save_confirmed') || 0; |
95 |
|
94 |
my $reasonsloop = GetAuthorisedValues("SUGGEST"); |
96 |
my $reasonsloop = GetAuthorisedValues("SUGGEST"); |
95 |
|
97 |
|
96 |
# filter informations which are not suggestion related. |
98 |
# filter informations which are not suggestion related. |
Lines 122-178
my $branchfilter = $input->param('branchcode') || C4::Context->userenv->{'branch
Link Here
|
122 |
######################################### |
124 |
######################################### |
123 |
## Operations |
125 |
## Operations |
124 |
## |
126 |
## |
|
|
127 |
|
125 |
if ( $op =~ /save/i ) { |
128 |
if ( $op =~ /save/i ) { |
126 |
$suggestion_only->{suggesteddate} = dt_from_string( $suggestion_only->{suggesteddate} ) |
129 |
my @messages; |
127 |
if $suggestion_only->{suggesteddate}; |
130 |
my $biblio = MarcRecordFromNewSuggestion({ |
|
|
131 |
title => $suggestion_only->{title}, |
132 |
author => $suggestion_only->{author}, |
133 |
itemtype => $suggestion_only->{itemtype}, |
134 |
}); |
135 |
|
136 |
if ( ( my ($duplicatebiblionumber, $duplicatetitle) = FindDuplicate($biblio) ) && !$save_confirmed ) { |
137 |
push @messages, { type => 'error', code => 'biblio_exists', id => $duplicatebiblionumber, title => $duplicatetitle }; |
138 |
$template->param( |
139 |
messages => \@messages, |
140 |
need_confirm => 1 |
141 |
); |
142 |
delete $suggestion_ref->{suggesteddate}; |
143 |
Init($suggestion_ref); |
144 |
} |
145 |
else { |
146 |
$suggestion_only->{suggesteddate} = dt_from_string( $suggestion_only->{suggesteddate} ) |
147 |
if $suggestion_only->{suggesteddate}; |
128 |
|
148 |
|
129 |
if ( $suggestion_only->{"STATUS"} ) { |
149 |
if ( $suggestion_only->{"STATUS"} ) { |
130 |
if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) { |
150 |
if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) { |
131 |
$suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string; |
151 |
$suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string; |
132 |
$suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" } = C4::Context->userenv->{number}; |
152 |
$suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" } = C4::Context->userenv->{number}; |
|
|
153 |
} |
154 |
$suggestion_only->{manageddate} = dt_from_string; |
155 |
$suggestion_only->{"managedby"} = C4::Context->userenv->{number}; |
133 |
} |
156 |
} |
134 |
$suggestion_only->{manageddate} = dt_from_string; |
|
|
135 |
$suggestion_only->{"managedby"} = C4::Context->userenv->{number}; |
136 |
} |
137 |
|
157 |
|
138 |
my $otherreason = $input->param('other_reason'); |
158 |
my $otherreason = $input->param('other_reason'); |
139 |
if ($suggestion_only->{reason} eq 'other' && $otherreason) { |
159 |
if ($suggestion_only->{reason} eq 'other' && $otherreason) { |
140 |
$suggestion_only->{reason} = $otherreason; |
160 |
$suggestion_only->{reason} = $otherreason; |
141 |
} |
161 |
} |
142 |
|
162 |
|
143 |
if ( $suggestion_only->{'suggestionid'} > 0 ) { |
163 |
if ( $suggestion_only->{'suggestionid'} > 0 ) { |
144 |
&ModSuggestion($suggestion_only); |
164 |
&ModSuggestion($suggestion_only); |
145 |
} else { |
165 |
} else { |
146 |
###FIXME:Search here if suggestion already exists. |
166 |
###FIXME:Search here if suggestion already exists. |
147 |
my $suggestions_loop = |
167 |
my $suggestions_loop = |
148 |
SearchSuggestion( $suggestion_only ); |
168 |
SearchSuggestion( $suggestion_only ); |
149 |
if (@$suggestions_loop>=1){ |
169 |
if (@$suggestions_loop>=1){ |
150 |
#some suggestion are answering the request Donot Add |
170 |
#some suggestion are answering the request Donot Add |
151 |
my @messages; |
171 |
my @messages; |
152 |
for my $suggestion ( @$suggestions_loop ) { |
172 |
for my $suggestion ( @$suggestions_loop ) { |
153 |
push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} }; |
173 |
push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} }; |
|
|
174 |
} |
175 |
$template->param( messages => \@messages ); |
176 |
} |
177 |
else { |
178 |
## Adding some informations related to suggestion |
179 |
&NewSuggestion($suggestion_only); |
154 |
} |
180 |
} |
155 |
$template->param( messages => \@messages ); |
181 |
# empty fields, to avoid filter in "SearchSuggestion" |
156 |
} |
|
|
157 |
else { |
158 |
## Adding some informations related to suggestion |
159 |
&NewSuggestion($suggestion_only); |
160 |
} |
182 |
} |
161 |
# empty fields, to avoid filter in "SearchSuggestion" |
183 |
map{delete $$suggestion_ref{$_}} keys %$suggestion_ref; |
162 |
} |
184 |
$op = 'else'; |
163 |
map{delete $$suggestion_ref{$_}} keys %$suggestion_ref; |
|
|
164 |
$op = 'else'; |
165 |
|
185 |
|
166 |
if( $redirect eq 'purchase_suggestions' ) { |
186 |
if( $redirect eq 'purchase_suggestions' ) { |
167 |
print $input->redirect("/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=$borrowernumber"); |
187 |
print $input->redirect("/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=$borrowernumber"); |
|
|
188 |
} |
168 |
} |
189 |
} |
169 |
|
|
|
170 |
} |
190 |
} |
171 |
elsif ($op=~/add/) { |
191 |
elsif ($op=~/add/) { |
172 |
#Adds suggestion |
192 |
#Adds suggestion |
173 |
Init($suggestion_ref); |
193 |
Init($suggestion_ref); |
174 |
$op ='save'; |
194 |
$op ='save'; |
175 |
} |
195 |
} |
176 |
elsif ($op=~/edit/) { |
196 |
elsif ($op=~/edit/) { |
177 |
#Edit suggestion |
197 |
#Edit suggestion |
178 |
$suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'}); |
198 |
$suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'}); |
179 |
- |
|
|