subs renamed according to coding guidelines.
[koha.git] / circ / reserve.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 # Copyright 2000-2002 Katipo Communications
6 #
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
12 # version.
13 #
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA  02111-1307 USA
21
22 use strict;
23 use C4::Context;
24 use C4::Output;
25 use CGI;
26 use HTML::Template;
27 use C4::Auth;
28 use C4::Date;
29
30 my $input = new CGI;
31 my $type=$input->param('type');
32 my $order=$input->param('order');
33
34 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
35
36 my ($template, $loggedinuser, $cookie)
37       = get_template_and_user({template_name => "circ/reserve.tmpl",
38                                          query => $input,
39                                          type => "intranet",
40                                          authnotrequired => 0,
41                                          flagsrequired => {borrowers => 1},
42                                          debug => 1,
43                                          });
44 # borrowernumber        int(11) 
45 #        reservedate    date    
46 #        biblionumber   int(11) 
47 #        constrainttype         char(1)
48 #        branchcode     varchar(4) 
49 #        notificationdate       date    
50 #        reminderdate   date            
51 #        cancellationdate       date    
52 #        reservenotes   text    
53 #        priority       smallint(6) 
54 #        found          char(1)         
55 #        timestamp      timestamp               ON UPDATE CURRENT_TIMESTAMP     Oui     CURRENT_TIMESTAMP               Modifier        Supprimer       Primaire        Index   Unique  Texte entier
56 #        itemnumber     int(11)         
57 my $duedate;
58 my $bornum;
59 my $itemnum;
60 my $data1;
61 my $data2;
62 my $data3;
63 my $name;
64 my $phone;
65 my $email;
66 my $biblionumber;
67 my $title;
68 my $author;
69 my @datearr = localtime(time());
70 my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]);
71
72 my $dbh = C4::Context->dbh;
73 my $strsth="select reservedate,reserves.borrowernumber as bornum, concat(firstname,' ',surname) as borrower, borrowers.phone, borrowers.emailaddress,reserves.biblionumber, reserves.branchcode as branch, items.holdingbranch, items.itemcallnumber, items.itemnumber, notes, notificationdate, reminderdate, priority, reserves.found, biblio.title, biblio.author from reserves left join items on items.itemnumber=reserves.itemnumber, borrowers,biblio where isnull(cancellationdate) && reserves.borrowernumber=borrowers.borrowernumber && reserves.biblionumber=biblio.biblionumber order by reservedate, borrower ";
74 $strsth="select reservedate,reserves.borrowernumber as bornum,concat(firstname,' ',surname) as borrower, borrowers.phone, borrowers.emailaddress,reserves.biblionumber, reserves.branchcode as branch, items.holdingbranch, items.itemcallnumber, items.itemnumber, notes, notificationdate, reminderdate, priority, reserves.found, biblio.title, biblio.author from reserves left join items on  items.itemnumber=reserves.itemnumber , borrowers,biblio where isnull(cancellationdate) && reserves.borrowernumber=borrowers.borrowernumber && reserves.biblionumber=biblio.biblionumber order by borrower,reservedate " if ($order eq "borrower");
75 $strsth="select reservedate,reserves.borrowernumber as bornum,concat(firstname,' ',surname) as borrower, borrowers.phone, borrowers.emailaddress,reserves.biblionumber, reserves.branchcode as branch, items.holdingbranch, items.itemcallnumber, items.itemnumber, notes, notificationdate, reminderdate, priority, reserves.found, biblio.title, biblio.author from reserves left join items on items.itemnumber=reserves.itemnumber, borrowers,biblio where isnull(cancellationdate) && reserves.borrowernumber=borrowers.borrowernumber && reserves.biblionumber=biblio.biblionumber order by biblio.title, priority,reservedate " if ($order eq "biblio");
76 my $sth=$dbh->prepare($strsth);
77 warn "".$strsth;
78 $sth->execute();
79
80 my @reservedata;
81 while (my $data=$sth->fetchrow_hashref) {
82   push (@reservedata, 
83                         {
84                                 reservedate  => format_date($data->{reservedate}),
85                                 priority         => $data->{priority},
86                                 name         => $data->{borrower},
87                                 title        => $data->{title},
88                                 author       => $data->{author},
89                                 bornum       => $data->{bornum},
90                                 itemnum      => $data->{itemnumber},
91                                 phone        => $data->{phone},
92                                 email        => $data->{email},
93                                 biblionumber => $data->{biblionumber},
94                                 statusw          => ($data->{found} eq "w"),
95                                 statusf          => ($data->{found} eq "f"),
96                                 holdingbranch            => $data->{holdingbranch},
97                                 branch           => $data->{branch},
98                                 itemcallnumber => $data->{itemcallnumber},
99                                 notes            => $data->{notes},
100                                 notificationdate => $data->{notificationdate},
101                                 reminderdate => $data->{reminderdate}
102                         }
103         
104         );
105
106 }
107
108 $sth->finish;
109
110 $template->param(todaysdate        => format_date($todaysdate),
111                 reserveloop       => \@reservedata,
112                 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
113                 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
114                 IntranetNav => C4::Context->preference("IntranetNav"),
115                 );
116
117 print "Content-Type: text/html\n\n", $template->output;