fixed translatibility error in label-edit-layout.tmpl
[koha.git] / members / messaging.pl
blob14279738492d5c79aa3f8eccf3eb9f16592e8b74
1 #!/usr/bin/perl
3 # Copyright 2008 LibLime
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
21 use strict;
22 use CGI;
23 use C4::Context;
24 use C4::Auth;
25 use C4::Output;
26 use C4::Members;
27 use C4::Members::Messaging;
28 use C4::Dates;
29 use C4::Reserves;
30 use C4::Circulation;
31 use C4::Koha;
32 use C4::Letters;
33 use C4::Biblio;
34 use C4::Reserves;
35 use C4::Branch; # GetBranchName
37 use Data::Dumper;
39 use vars qw($debug);
41 BEGIN {
42 $debug = $ENV{DEBUG} || 0;
45 my $dbh = C4::Context->dbh;
47 my $query = CGI->new();
49 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
51 template_name => 'members/messaging.tmpl',
52 query => $query,
53 type => "intranet",
54 authnotrequired => 0,
55 flagsrequired => { borrowers => 1 },
56 debug => 1,
59 my $borrowernumber = $query->param('borrowernumber');
60 my $borrower = GetMember( $borrowernumber ,'borrowernumber');
61 my $branch = C4::Context->userenv->{'branch'};
63 $template->param( $borrower );
65 my $borrower = GetMemberDetails( $borrowernumber );
68 if ( $borrower->{'category_type'} eq 'C') {
69 my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
70 my $cnt = scalar(@$catcodes);
71 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
72 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
75 my ($picture, $dberror) = GetPatronImage($borrower->{'cardnumber'});
76 $template->param( picture => 1 ) if $picture;
78 # get some recent messages sent to this borrower for display:
79 my $message_queue = C4::Letters::GetQueuedMessages( { borrowernumber => $query->param('borrowernumber') } );
81 $template->param( messagingview => 1,
82 message_queue => $message_queue,
83 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
84 borrowernumber => $borrowernumber,
85 branchcode => $borrower->{'branchcode'},
86 branchname => GetBranchName($borrower->{'branchcode'}),
87 dateformat => C4::Context->preference("dateformat"),
88 categoryname => $borrower->{'description'},
89 $borrower->{'categorycode'} => 1,
92 #$messaging_preferences->{'SMSnumber'}{'value'} = defined $borrower->{'smsalertnumber'}
93 # ? $borrower->{'smsalertnumber'} : $borrower->{'mobile'};
95 $template->param( BORROWER_INFO => [ $borrower ],
96 messagingview => 1,
97 is_child => ($borrower->{'category_type'} eq 'C'),
100 output_html_with_http_headers $query, $cookie, $template->output;