functions that were in C4::Interface::CGI::Output are now in C4::Output.
[koha.git] / members / deletemem.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 #script to delete items
6 #written 2/5/00
7 #by chris@katipo.co.nz
8
9
10 # Copyright 2000-2002 Katipo Communications
11 #
12 # This file is part of Koha.
13 #
14 # Koha is free software; you can redistribute it and/or modify it under the
15 # terms of the GNU General Public License as published by the Free Software
16 # Foundation; either version 2 of the License, or (at your option) any later
17 # version.
18 #
19 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
20 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
21 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License along with
24 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
25 # Suite 330, Boston, MA  02111-1307 USA
26
27 use strict;
28
29 use CGI;
30 use C4::Context;
31 use C4::Output;
32 use C4::Circulation;
33 use C4::Auth;
34 use C4::Members;
35
36
37 my $input = new CGI;
38
39 my $flagsrequired;
40 $flagsrequired->{borrowers}=1;
41 my ($loggedinuser, $cookie, $sessionID) = checkauth($input, 0, $flagsrequired);
42
43
44
45 #print $input->header;
46 my $member=$input->param('member');
47 my %member2;
48 $member2{'borrowernumber'}=$member;
49 my $issues=GetBorrowerIssues(\%member2);
50 my $i=0;
51 foreach (sort keys %$issues) {
52         $i++;
53 }
54 my ($bor,$flags)=GetMemberDetails($member,'');
55 if (C4::Context->preference("IndependantBranches")) {
56         my $userenv = C4::Context->userenv;
57         unless ($userenv->{flags} == 1){
58                 unless ($userenv->{'branch'} eq $bor->{'branchcode'}){
59 #                       warn "user ".$userenv->{'branch'} ."borrower :". $bor->{'branchcode'};
60                         print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member");
61                         exit 1;
62                 }
63         }
64 }
65 my $dbh = C4::Context->dbh;
66 my $sth=$dbh->prepare("Select * from borrowers where guarantorid=?");
67 $sth->execute($member);
68 my $data=$sth->fetchrow_hashref;
69 $sth->finish;
70 if ($i > 0 or $flags->{'CHARGES'}  or $data->{'borrowernumber'}){
71 warn"je suis rentre dans la boucle";
72         my ($template, $borrowernumber, $cookie)
73                 = get_template_and_user({template_name => "members/deletemem.tmpl",
74                                         query => $input,
75                                         type => "intranet",
76                                         authnotrequired => 0,
77                                         flagsrequired => {borrowers => 1},
78                                         debug => 1,
79                                         });
80         #   print $input->header;
81         $template->param(borrowernumber => $member);
82         if ($i >0) {
83                 $template->param(ItemsOnIssues => $i);
84         }
85         if ($flags->{'CHARGES'} ne '') {
86                 $template->param(charges => $flags->{'CHARGES'}->{'message'});
87         }
88         if ($data ne '') {
89                 $template->param(guarantees => 1);
90         }
91 #       print "<table border=1>";
92 #       if ($i > 0){
93 #               print "<TR><TD>Items on Issue</td><td align=right>$i</td></tr>";
94 #       }
95 #       if ($flags->{'CHARGES'} ne ''){
96 #               print "<TR><TD>Charges</td><td>$flags->{'CHARGES'}->{'message'}</tr>";
97 #       }
98 #       if ($data ne ''){
99 #               print "<TR><TD>Guarantees</td></tr>";
100 #       }
101 #       print "</table>";
102 $template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
103                 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
104                 IntranetNav => C4::Context->preference("IntranetNav"),
105                 );
106 output_html_with_http_headers $input, $cookie, $template->output;
107
108 } else {
109         MoveMemberToDeleted($member);
110         DelMember($member);
111         print $input->redirect("/cgi-bin/koha/members/members-home.pl");
112 }
113
114