b6e62489d8
The display and editing of messaging preferences for a patron have been moved as follows: * the prefs for a patron are now displayed on the patron details tab, not the messaging tab. * the prefs are now modified by editing the patron record, not on the messaging tab. The messaging tab now contains only the list of messages that have been or will be sent to the patron. When creating a new patron record, changing the patron category via the category dropdown now also changes the default messaging preferences for that patron. If you start editing a new patron, change one of the messaging preferences, then change the patron category, the form will ask you if you want to keep the preferences or get the defaults belonging to the new patron category. Note that when you edit an existing patron record, changing the patron category will *not* cause the messaging preferences to be automatically changed. Programmer's note: this commit introduces a new web service, members/default_messagingprefs.pl, that uses Jesse Weaver's C4::Service module. Signed-off-by: Daniel Sweeney <daniel.sweeney@liblime.com> Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
100 lines
3.3 KiB
Perl
Executable file
100 lines
3.3 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# Copyright 2008 LibLime
|
|
#
|
|
# This file is part of Koha.
|
|
#
|
|
# Koha is free software; you can redistribute it and/or modify it under the
|
|
# terms of the GNU General Public License as published by the Free Software
|
|
# Foundation; either version 2 of the License, or (at your option) any later
|
|
# version.
|
|
#
|
|
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along with
|
|
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
|
|
# Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
use strict;
|
|
use CGI;
|
|
use C4::Context;
|
|
use C4::Auth;
|
|
use C4::Output;
|
|
use C4::Members;
|
|
use C4::Members::Messaging;
|
|
use C4::Dates;
|
|
use C4::Reserves;
|
|
use C4::Circulation;
|
|
use C4::Koha;
|
|
use C4::Letters;
|
|
use C4::Biblio;
|
|
use C4::Reserves;
|
|
use C4::Branch; # GetBranchName
|
|
|
|
use Data::Dumper;
|
|
|
|
use vars qw($debug);
|
|
|
|
BEGIN {
|
|
$debug = $ENV{DEBUG} || 0;
|
|
}
|
|
|
|
my $dbh = C4::Context->dbh;
|
|
|
|
my $query = CGI->new();
|
|
|
|
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
|
{
|
|
template_name => 'members/messaging.tmpl',
|
|
query => $query,
|
|
type => "intranet",
|
|
authnotrequired => 0,
|
|
flagsrequired => { borrowers => 1 },
|
|
debug => 1,
|
|
}
|
|
);
|
|
my $borrowernumber = $query->param('borrowernumber');
|
|
my $borrower = GetMember( $borrowernumber ,'borrowernumber');
|
|
my $branch = C4::Context->userenv->{'branch'};
|
|
|
|
$template->param( $borrower );
|
|
|
|
my $borrower = GetMemberDetails( $borrowernumber );
|
|
|
|
|
|
if ( $borrower->{'category_type'} eq 'C') {
|
|
my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
|
|
my $cnt = scalar(@$catcodes);
|
|
$template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
|
|
$template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
|
|
}
|
|
|
|
my ($picture, $dberror) = GetPatronImage($borrower->{'cardnumber'});
|
|
$template->param( picture => 1 ) if $picture;
|
|
|
|
# get some recent messages sent to this borrower for display:
|
|
my $message_queue = C4::Letters::GetQueuedMessages( { borrowernumber => $query->param('borrowernumber') } );
|
|
|
|
$template->param( messagingview => 1,
|
|
message_queue => $message_queue,
|
|
DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
|
|
borrowernumber => $borrowernumber,
|
|
branchcode => $borrower->{'branchcode'},
|
|
branchname => GetBranchName($borrower->{'branchcode'}),
|
|
dateformat => C4::Context->preference("dateformat"),
|
|
categoryname => $borrower->{'description'},
|
|
$borrower->{'categorycode'} => 1,
|
|
);
|
|
|
|
#$messaging_preferences->{'SMSnumber'}{'value'} = defined $borrower->{'smsalertnumber'}
|
|
# ? $borrower->{'smsalertnumber'} : $borrower->{'mobile'};
|
|
|
|
$template->param( BORROWER_INFO => [ $borrower ],
|
|
messagingview => 1,
|
|
is_child => ($borrower->{'category_type'} eq 'C'),
|
|
);
|
|
|
|
output_html_with_http_headers $query, $cookie, $template->output;
|