|
Lines 437-456
Insert a new suggestion on database with value given on input arg.
Link Here
|
| 437 |
sub NewSuggestion { |
437 |
sub NewSuggestion { |
| 438 |
my ($suggestion) = @_; |
438 |
my ($suggestion) = @_; |
| 439 |
|
439 |
|
| 440 |
for my $field ( qw( |
|
|
| 441 |
suggestedby |
| 442 |
managedby |
| 443 |
manageddate |
| 444 |
acceptedby |
| 445 |
accepteddate |
| 446 |
rejectedby |
| 447 |
rejecteddate |
| 448 |
budgetid |
| 449 |
) ) { |
| 450 |
# Set the fields to NULL if not given. |
| 451 |
$suggestion->{$field} ||= undef; |
| 452 |
} |
| 453 |
|
| 454 |
$suggestion->{STATUS} = "ASKED" unless $suggestion->{STATUS}; |
440 |
$suggestion->{STATUS} = "ASKED" unless $suggestion->{STATUS}; |
| 455 |
|
441 |
|
| 456 |
$suggestion->{suggesteddate} = dt_from_string unless $suggestion->{suggesteddate}; |
442 |
$suggestion->{suggesteddate} = dt_from_string unless $suggestion->{suggesteddate}; |
|
Lines 526-548
sub ModSuggestion {
Link Here
|
| 526 |
my ($suggestion) = @_; |
512 |
my ($suggestion) = @_; |
| 527 |
return unless( $suggestion and defined($suggestion->{suggestionid}) ); |
513 |
return unless( $suggestion and defined($suggestion->{suggestionid}) ); |
| 528 |
|
514 |
|
| 529 |
for my $field ( qw( |
|
|
| 530 |
suggestedby |
| 531 |
managedby |
| 532 |
manageddate |
| 533 |
acceptedby |
| 534 |
accepteddate |
| 535 |
rejectedby |
| 536 |
rejecteddate |
| 537 |
budgetid |
| 538 |
) ) { |
| 539 |
# Set the fields to NULL if not given. |
| 540 |
$suggestion->{$field} = undef |
| 541 |
if exists $suggestion->{$field} |
| 542 |
and ($suggestion->{$field} eq '0' |
| 543 |
or $suggestion->{$field} eq '' ); |
| 544 |
} |
| 545 |
|
| 546 |
my $suggestion_object = Koha::Suggestions->find( $suggestion->{suggestionid} ); |
515 |
my $suggestion_object = Koha::Suggestions->find( $suggestion->{suggestionid} ); |
| 547 |
eval { # FIXME Must raise an exception instead |
516 |
eval { # FIXME Must raise an exception instead |
| 548 |
$suggestion_object->set($suggestion)->store; |
517 |
$suggestion_object->set($suggestion)->store; |
| 549 |
- |
|
|