Bug 3186 - invalid or uninstalled SMSSendDriver (or bad number format) causes process...
[koha.git] / members / deletemem.pl
blob32801e05dc369bbc95e4d1406e50486af3d95b04
1 #!/usr/bin/perl
3 #script to delete items
4 #written 2/5/00
5 #by chris@katipo.co.nz
7 # Copyright 2000-2002 Katipo Communications
9 # This file is part of Koha.
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.
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.
20 # You should have received a copy of the GNU General Public License along
21 # with Koha; if not, write to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 use strict;
25 #use warnings; FIXME - Bug 2505
27 use CGI;
28 use C4::Context;
29 use C4::Output;
30 use C4::Auth;
31 use C4::Members;
32 use C4::Branch; # GetBranches
33 use C4::VirtualShelves (); #no import
35 my $input = new CGI;
37 my ($template, $borrowernumber, $cookie)
38 = get_template_and_user({template_name => "members/deletemem.tt",
39 query => $input,
40 type => "intranet",
41 authnotrequired => 0,
42 flagsrequired => {borrowers => 1},
43 debug => 1,
44 });
46 #print $input->header;
47 my $member=$input->param('member');
48 my $issues = GetPendingIssues($member); # FIXME: wasteful call when really, we only want the count
49 my $countissues = scalar(@$issues);
51 my ($bor)=GetMemberDetails($member,'');
52 my $flags=$bor->{flags};
53 my $userenv = C4::Context->userenv;
57 if ($bor->{category_type} eq "S") {
58 unless(C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) {
59 print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_STAFF");
60 exit 1;
62 } else {
63 unless(C4::Auth::haspermission($userenv->{'id'},{'borrowers'=>1})) {
64 print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE");
65 exit 1;
69 if (C4::Context->preference("IndependentBranches")) {
70 my $userenv = C4::Context->userenv;
71 if ( !C4::Context->IsSuperLibrarian() && $bor->{'branchcode'}){
72 unless ($userenv->{branch} eq $bor->{'branchcode'}){
73 print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY");
74 exit;
79 my $dbh = C4::Context->dbh;
80 my $sth=$dbh->prepare("Select * from borrowers where guarantorid=?");
81 $sth->execute($member);
82 my $data=$sth->fetchrow_hashref;
83 if ($countissues > 0 or $flags->{'CHARGES'} or $data->{'borrowernumber'}){
84 # print $input->header;
86 my ($picture, $dberror) = GetPatronImage($bor->{'borrowernumber'});
87 $template->param( picture => 1 ) if $picture;
89 $template->param(borrowernumber => $member,
90 surname => $bor->{'surname'},
91 title => $bor->{'title'},
92 cardnumber => $bor->{'cardnumber'},
93 firstname => $bor->{'firstname'},
94 categorycode => $bor->{'categorycode'},
95 category_type => $bor->{'category_type'},
96 categoryname => $bor->{'description'},
97 address => $bor->{'address'},
98 address2 => $bor->{'address2'},
99 city => $bor->{'city'},
100 zipcode => $bor->{'zipcode'},
101 country => $bor->{'country'},
102 phone => $bor->{'phone'},
103 email => $bor->{'email'},
104 branchcode => $bor->{'branchcode'},
105 branchname => GetBranchName($bor->{'branchcode'}),
106 activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''),
107 RoutingSerials => C4::Context->preference('RoutingSerials'),
109 if ($countissues >0) {
110 $template->param(ItemsOnIssues => $countissues);
112 if ($flags->{'CHARGES'} ne '') {
113 $template->param(charges => $flags->{'CHARGES'}->{'amount'});
115 if ($data) {
116 $template->param(guarantees => 1);
118 output_html_with_http_headers $input, $cookie, $template->output;
120 } else {
121 MoveMemberToDeleted($member);
122 C4::VirtualShelves::HandleDelBorrower($member);
123 DelMember($member);
124 print $input->redirect("/cgi-bin/koha/members/members-home.pl");