New styles for bulk hold and bulk tag inputs on search results page.
[koha.git] / members / deletemem.pl
1 #!/usr/bin/perl
2
3 #script to delete items
4 #written 2/5/00
5 #by chris@katipo.co.nz
6
7 # Copyright 2000-2002 Katipo Communications
8 #
9 # This file is part of Koha.
10 #
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 #
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA  02111-1307 USA
23
24 use strict;
25
26 use CGI;
27 use C4::Context;
28 use C4::Output;
29 use C4::Auth;
30 use C4::Members;
31
32 my $input = new CGI;
33
34 my ($template, $borrowernumber, $cookie)
35                 = get_template_and_user({template_name => "members/deletemem.tmpl",
36                                         query => $input,
37                                         type => "intranet",
38                                         authnotrequired => 0,
39                                         flagsrequired => {borrowers => 1},
40                                         debug => 1,
41                                         });
42
43 #print $input->header;
44 my $member=$input->param('member');
45 my $issues = GetPendingIssues($member);     # FIXME: wasteful call when really, we only want the count
46 my $countissues = scalar(@$issues);
47
48 my ($bor)=GetMemberDetails($member,'');
49 my $flags=$bor->{flags};
50 my $userenv = C4::Context->userenv;
51 if ($bor->{category_type} eq "S") {
52     unless(C4::Auth::haspermission(undef,$userenv->{'id'},{'staffaccess'=>1})) {
53         print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_STAFF");
54         exit 1;
55     }
56 }
57
58 if (C4::Context->preference("IndependantBranches")) {
59     unless ($userenv->{flags} == 1){
60         unless ($userenv->{'branch'} eq $bor->{'branchcode'}){
61 #           warn "user ".$userenv->{'branch'} ."borrower :". $bor->{'branchcode'};
62             print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY");
63             exit 1;
64         }
65     }
66 }
67 my $dbh = C4::Context->dbh;
68 my $sth=$dbh->prepare("Select * from borrowers where guarantorid=?");
69 $sth->execute($member);
70 my $data=$sth->fetchrow_hashref;
71 if ($countissues > 0 or $flags->{'CHARGES'}  or $data->{'borrowernumber'}){
72     #   print $input->header;
73     $template->param(borrowernumber => $member);
74     if ($countissues >0) {
75         $template->param(ItemsOnIssues => $countissues);
76     }
77     if ($flags->{'CHARGES'} ne '') {
78         $template->param(charges => $flags->{'CHARGES'}->{'amount'});
79     }
80     if ($data) {
81         $template->param(guarantees => 1);
82     }
83 output_html_with_http_headers $input, $cookie, $template->output;
84
85 } else {
86     MoveMemberToDeleted($member);
87     DelMember($member);
88     print $input->redirect("/cgi-bin/koha/members/members-home.pl");
89 }
90
91