3 #script to delete items
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
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.
25 #use warnings; FIXME - Bug 2505
32 use C4::Branch; # GetBranches
33 use C4::VirtualShelves (); #no import
37 my ($template, $borrowernumber, $cookie)
38 = get_template_and_user({template_name => "members/deletemem.tmpl",
42 flagsrequired => {borrowers => 1},
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");
63 unless(C4::Auth::haspermission($userenv->{'id'},{'borrowers'=>1})) {
64 print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE");
69 if (C4::Context->preference("IndependantBranches")) {
70 my $userenv = C4::Context->userenv;
71 if (($userenv->{flags} % 2 != 1) && $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");
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->{'cardnumber'});
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 ''),
108 if ($countissues >0) {
109 $template->param(ItemsOnIssues => $countissues);
111 if ($flags->{'CHARGES'} ne '') {
112 $template->param(charges => $flags->{'CHARGES'}->{'amount'});
115 $template->param(guarantees => 1);
117 output_html_with_http_headers $input, $cookie, $template->output;
120 MoveMemberToDeleted($member);
121 C4::VirtualShelves::HandleDelBorrower($member);
123 print $input->redirect("/cgi-bin/koha/members/members-home.pl");