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