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