Bugzilla – Attachment 31941 Details for
Bug 12627
SQLHelper replacement - C4::Suggestions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12627: Fix default values
Bug-12627-Fix-default-values.patch (text/plain), 2.88 KB, created by
Jonathan Druart
on 2014-09-30 10:57:21 UTC
(
hide
)
Description:
Bug 12627: Fix default values
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-09-30 10:57:21 UTC
Size:
2.88 KB
patch
obsolete
>From 1fac482d246316c6a20a96fffebd747b1576cf4b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Tue, 30 Sep 2014 12:19:21 +0200 >Subject: [PATCH] Bug 12627: Fix default values > >The default value for *by and *date fields is NULL. >But without this patch, the values are 0 or 0000-00-00. >It comes from the fact that the form set to an empty string the values >and DBIX::Class does not consider them as undefined. > >This patch is very ugly, not sure how we can fix that. >--- > C4/Suggestions.pm | 30 ++++++++++++++++++++++++++++++ > suggestion/suggestion.pl | 5 ++++- > 2 files changed, 34 insertions(+), 1 deletion(-) > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index eae80a0..bcf6806 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -28,6 +28,8 @@ use C4::Output; > use C4::Dates qw(format_date format_date_in_iso); > use C4::Debug; > use C4::Letters; >+use Koha::DateUtils qw( dt_from_string ); >+ > use List::MoreUtils qw(any); > use C4::Dates qw(format_date_in_iso); > use base qw(Exporter); >@@ -428,6 +430,21 @@ sub NewSuggestion { > > $suggestion->{STATUS} = "ASKED" unless $suggestion->{STATUS}; > >+ for my $field ( qw( >+ suggestedby >+ managedby >+ manageddate >+ acceptedby >+ accepteddate >+ rejectedby >+ rejecteddate >+ ) ) { >+ # Set the fields to NULL if not given. >+ $suggestion->{$field} ||= undef; >+ } >+ >+ $suggestion->{suggesteddate} = dt_from_string unless $suggestion->{suggesteddate}; >+ > my $rs = Koha::Database->new->schema->resultset('Suggestion'); > return $rs->create($suggestion)->id; > } >@@ -456,6 +473,19 @@ sub ModSuggestion { > }; > $status_update_table = 0 if( $@ ); > >+ for my $field ( qw( >+ suggestedby >+ managedby >+ manageddate >+ acceptedby >+ accepteddate >+ rejectedby >+ rejecteddate >+ ) ) { >+ # Set the fields to NULL if not given. >+ $suggestion->{$field} ||= undef; >+ } >+ > if ( $suggestion->{STATUS} ) { > > # fetch the entire updated suggestion so that we can populate the letter >diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl >index 14c90bd..f45d294 100755 >--- a/suggestion/suggestion.pl >+++ b/suggestion/suggestion.pl >@@ -124,7 +124,10 @@ $template->param('borrowernumber' => $borrowernumber); > ## Operations > ## > if ( $op =~ /save/i ) { >- if ( $suggestion_only->{"STATUS"} ) { >+ $suggestion_only->{suggesteddate} = dt_from_string( $suggestion_only->{suggesteddate} ) >+ if $suggestion_only->{suggesteddate}; >+ >+ if ( $suggestion_only->{"STATUS"} ) { > if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) { > $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string; > $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" } = C4::Context->userenv->{number}; >-- >2.1.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12627
:
29963
|
30095
|
30237
|
30269
|
30624
|
30635
|
30892
|
31916
|
31917
|
31937
|
31939
|
31940
|
31941
|
31942
|
31944
|
31948
|
31953
|
33244
|
33276
|
33277
|
33278
|
33279
|
33280
|
33281