|
Lines 95-100
my $tabcode = $input->param('tabcode');
Link Here
|
| 95 |
# filter informations which are not suggestion related. |
95 |
# filter informations which are not suggestion related. |
| 96 |
my $suggestion_ref = $input->Vars; |
96 |
my $suggestion_ref = $input->Vars; |
| 97 |
|
97 |
|
|
|
98 |
# get only the columns of Suggestion |
| 99 |
my $schema = Koha::Database->new()->schema; |
| 100 |
my $columns = ' '.join(' ', $schema->source('Suggestion')->columns).' '; |
| 101 |
my $suggestion_only = { map { $columns =~ / $_ / ? ($_ => $suggestion_ref->{$_}) : () } keys($suggestion_ref) }; |
| 102 |
$suggestion_only->{STATUS} = $suggestion_ref->{STATUS}; |
| 103 |
|
| 98 |
delete $$suggestion_ref{$_} foreach qw( suggestedbyme op displayby tabcode edit_field ); |
104 |
delete $$suggestion_ref{$_} foreach qw( suggestedbyme op displayby tabcode edit_field ); |
| 99 |
foreach (keys %$suggestion_ref){ |
105 |
foreach (keys %$suggestion_ref){ |
| 100 |
delete $$suggestion_ref{$_} if (!$$suggestion_ref{$_} && ($op eq 'else' || $op eq 'change')); |
106 |
delete $$suggestion_ref{$_} if (!$$suggestion_ref{$_} && ($op eq 'else' || $op eq 'change')); |
|
Lines 115-140
$template->param('borrowernumber' => $borrowernumber);
Link Here
|
| 115 |
## Operations |
121 |
## Operations |
| 116 |
## |
122 |
## |
| 117 |
if ( $op =~ /save/i ) { |
123 |
if ( $op =~ /save/i ) { |
| 118 |
if ( $$suggestion_ref{"STATUS"} ) { |
124 |
if ( $suggestion_only->{"STATUS"} ) { |
| 119 |
if ( my $tmpstatus = lc( $$suggestion_ref{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) { |
125 |
if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) { |
| 120 |
$$suggestion_ref{ lc( $$suggestion_ref{"STATUS"}) . "date" } = C4::Dates->today; |
126 |
$suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = C4::Dates->today; |
| 121 |
$$suggestion_ref{ lc( $$suggestion_ref{"STATUS"}) . "by" } = C4::Context->userenv->{number}; |
127 |
$suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" } = C4::Context->userenv->{number}; |
| 122 |
} |
128 |
} |
| 123 |
$$suggestion_ref{"manageddate"} = C4::Dates->today; |
129 |
$suggestion_only->{"manageddate"} = C4::Dates->today; |
| 124 |
$$suggestion_ref{"managedby"} = C4::Context->userenv->{number}; |
130 |
$suggestion_only->{"managedby"} = C4::Context->userenv->{number}; |
| 125 |
} |
131 |
} |
| 126 |
if ( $$suggestion_ref{'suggestionid'} > 0 ) { |
132 |
if ( $suggestion_only->{'suggestionid'} > 0 ) { |
| 127 |
&ModSuggestion($suggestion_ref); |
133 |
&ModSuggestion($suggestion_only); |
| 128 |
} else { |
134 |
} else { |
| 129 |
###FIXME:Search here if suggestion already exists. |
135 |
###FIXME:Search here if suggestion already exists. |
| 130 |
my $suggestions_loop = |
136 |
my $suggestions_loop = |
| 131 |
SearchSuggestion( $suggestion_ref ); |
137 |
SearchSuggestion( $suggestion_only ); |
| 132 |
if (@$suggestions_loop>=1){ |
138 |
if (@$suggestions_loop>=1){ |
| 133 |
#some suggestion are answering the request Donot Add |
139 |
#some suggestion are answering the request Donot Add |
| 134 |
} |
140 |
} |
| 135 |
else { |
141 |
else { |
| 136 |
## Adding some informations related to suggestion |
142 |
## Adding some informations related to suggestion |
| 137 |
&NewSuggestion($suggestion_ref); |
143 |
&NewSuggestion($suggestion_only); |
| 138 |
} |
144 |
} |
| 139 |
# empty fields, to avoid filter in "SearchSuggestion" |
145 |
# empty fields, to avoid filter in "SearchSuggestion" |
| 140 |
} |
146 |
} |
|
Lines 160-175
elsif ($op=~/edit/) {
Link Here
|
| 160 |
elsif ($op eq "change" ) { |
166 |
elsif ($op eq "change" ) { |
| 161 |
# set accepted/rejected/managed informations if applicable |
167 |
# set accepted/rejected/managed informations if applicable |
| 162 |
# ie= if the librarian has choosen some action on the suggestions |
168 |
# ie= if the librarian has choosen some action on the suggestions |
| 163 |
if ($$suggestion_ref{"STATUS"} eq "ACCEPTED"){ |
169 |
if ($suggestion_only->{"STATUS"} eq "ACCEPTED"){ |
| 164 |
$$suggestion_ref{"accepteddate"}=C4::Dates->today; |
170 |
$suggestion_only->{"accepteddate"}=C4::Dates->today; |
| 165 |
$$suggestion_ref{"acceptedby"}=C4::Context->userenv->{number}; |
171 |
$suggestion_only->{"acceptedby"}=C4::Context->userenv->{number}; |
| 166 |
} elsif ($$suggestion_ref{"STATUS"} eq "REJECTED"){ |
172 |
} elsif ($suggestion_only->{"STATUS"} eq "REJECTED"){ |
| 167 |
$$suggestion_ref{"rejecteddate"}=C4::Dates->today; |
173 |
$suggestion_only->{"rejecteddate"}=C4::Dates->today; |
| 168 |
$$suggestion_ref{"rejectedby"}=C4::Context->userenv->{number}; |
174 |
$suggestion_only->{"rejectedby"}=C4::Context->userenv->{number}; |
| 169 |
} |
175 |
} |
| 170 |
if ($$suggestion_ref{"STATUS"}){ |
176 |
if ($suggestion_only->{"STATUS"}){ |
| 171 |
$$suggestion_ref{"manageddate"}=C4::Dates->today; |
177 |
$suggestion_only->{"manageddate"}=C4::Dates->today; |
| 172 |
$$suggestion_ref{"managedby"}=C4::Context->userenv->{number}; |
178 |
$suggestion_only->{"managedby"}=C4::Context->userenv->{number}; |
| 173 |
} |
179 |
} |
| 174 |
if ( my $reason = $$suggestion_ref{"reason$tabcode"}){ |
180 |
if ( my $reason = $$suggestion_ref{"reason$tabcode"}){ |
| 175 |
if ( $reason eq "other" ) { |
181 |
if ( $reason eq "other" ) { |
|
Lines 183-190
elsif ($op eq "change" ) {
Link Here
|
| 183 |
} |
189 |
} |
| 184 |
foreach my $suggestionid (@editsuggestions) { |
190 |
foreach my $suggestionid (@editsuggestions) { |
| 185 |
next unless $suggestionid; |
191 |
next unless $suggestionid; |
| 186 |
$$suggestion_ref{'suggestionid'}=$suggestionid; |
192 |
$suggestion_only->{'suggestionid'}=$suggestionid; |
| 187 |
&ModSuggestion($suggestion_ref); |
193 |
&ModSuggestion($suggestion_only); |
| 188 |
} |
194 |
} |
| 189 |
my $params = ''; |
195 |
my $params = ''; |
| 190 |
foreach my $key ( |
196 |
foreach my $key ( |