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