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