Bug 4254 - adding new patron advanced notice doesn't save
This was due to poorly constructed SQL which returned duplicate values for certain fields. This patch corrects that SQL. NOTE: There is also a formatting problem with the message prefs display table when it is displayed in moremember.pl. This is due to there being no logic to tell the table in that context to display checkboxes as appropriate. This patch does not fix that. Bug 5328 has been opened for this problem. Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
parent
b0e29e5595
commit
321eed9833
2 changed files with 16 additions and 16 deletions
|
@ -121,8 +121,7 @@ sub set_form_values {
|
|||
# walk through the options and update them with these borrower_preferences
|
||||
my $messaging_options = C4::Members::Messaging::GetMessagingOptions();
|
||||
PREF: foreach my $option ( @$messaging_options ) {
|
||||
my $pref = C4::Members::Messaging::GetMessagingPreferences( { %{ $target_params },
|
||||
message_name => $option->{'message_name'} } );
|
||||
my $pref = C4::Members::Messaging::GetMessagingPreferences( { %{ $target_params }, message_name => $option->{'message_name'} } );
|
||||
# make a hashref of the days, selecting one.
|
||||
if ( $option->{'takes_days'} ) {
|
||||
my $days_in_advance = $pref->{'days_in_advance'} ? $pref->{'days_in_advance'} : 0;
|
||||
|
|
|
@ -61,21 +61,23 @@ sub GetMessagingPreferences {
|
|||
|
||||
return unless exists $params->{message_name};
|
||||
return unless exists $params->{borrowernumber} xor exists $params->{categorycode}; # yes, xor
|
||||
|
||||
my $sql = <<'END_SQL';
|
||||
SELECT borrower_message_preferences.*,
|
||||
borrower_message_transport_preferences.message_transport_type,
|
||||
message_attributes.*,
|
||||
message_transports.*
|
||||
FROM borrower_message_preferences
|
||||
LEFT JOIN borrower_message_transport_preferences
|
||||
ON borrower_message_transport_preferences.borrower_message_preference_id = borrower_message_preferences.borrower_message_preference_id
|
||||
LEFT JOIN message_attributes
|
||||
ON message_attributes.message_attribute_id = borrower_message_preferences.message_attribute_id
|
||||
LEFT JOIN message_transports
|
||||
ON message_transports.message_attribute_id = message_attributes.message_attribute_id
|
||||
AND message_transports.message_transport_type = borrower_message_transport_preferences.message_transport_type
|
||||
WHERE message_attributes.message_name = ?
|
||||
message_attributes.message_name,
|
||||
message_attributes.takes_days,
|
||||
message_transports.is_digest,
|
||||
message_transports.letter_module,
|
||||
message_transports.letter_code
|
||||
FROM borrower_message_preferences
|
||||
LEFT JOIN borrower_message_transport_preferences
|
||||
ON borrower_message_transport_preferences.borrower_message_preference_id = borrower_message_preferences.borrower_message_preference_id
|
||||
LEFT JOIN message_attributes
|
||||
ON message_attributes.message_attribute_id = borrower_message_preferences.message_attribute_id
|
||||
LEFT JOIN message_transports
|
||||
ON message_transports.message_attribute_id = message_attributes.message_attribute_id
|
||||
AND message_transports.message_transport_type = borrower_message_transport_preferences.message_transport_type
|
||||
WHERE message_attributes.message_name = ?
|
||||
END_SQL
|
||||
|
||||
my @bind_params = ( $params->{'message_name'} );
|
||||
|
@ -93,10 +95,9 @@ END_SQL
|
|||
my %transports; # helps build a list of unique message_transport_types
|
||||
ROW: while ( my $row = $sth->fetchrow_hashref() ) {
|
||||
next ROW unless $row->{'message_attribute_id'};
|
||||
# warn( Data::Dumper->Dump( [ $row ], [ 'row' ] ) );
|
||||
$return->{'days_in_advance'} = $row->{'days_in_advance'} if defined $row->{'days_in_advance'};
|
||||
$return->{'wants_digest'} = $row->{'wants_digest'} if defined $row->{'wants_digest'};
|
||||
$return->{'letter_code'} = $row->{'letter_code'};
|
||||
$return->{'letter_code'} = $row->{'letter_code'};
|
||||
$transports{$row->{'message_transport_type'}} = 1;
|
||||
}
|
||||
@{$return->{'transports'}} = keys %transports;
|
||||
|
|
Loading…
Reference in a new issue