Bug 7677 - Remove atomic update
[koha.git] / members / update-child.pl
blob5d50d931b476f6640967846d0389af0fad15325c
1 #!/usr/bin/perl
3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 =head1 updatechild.pl
22 script to update a child member to (usually) an adult member category
24 - if called with op=multi, will return all available non child categories, for selection.
25 - if called with op=update, script will update member record via ModMember().
27 =cut
29 use strict;
30 #use warnings; FIXME - Bug 2505
31 use CGI qw ( -utf8 );
32 use C4::Context;
33 use C4::Auth;
34 use C4::Output;
35 use C4::Members;
36 use Koha::Patron::Categories;
38 # use Smart::Comments;
40 my $dbh = C4::Context->dbh;
41 my $input = new CGI;
43 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
45 template_name => "members/update-child.tt",
46 query => $input,
47 type => "intranet",
48 authnotrequired => 0,
49 flagsrequired => { borrowers => 1 },
50 debug => 1,
54 my $borrowernumber = $input->param('borrowernumber');
55 my $catcode = $input->param('catcode');
56 my $cattype = $input->param('cattype');
57 my $catcode_multi = $input->param('catcode_multi');
58 my $op = $input->param('op');
60 if ( $op eq 'multi' ) {
61 # FIXME - what are the possible upgrade paths? C -> A , C -> S ...
62 # currently just allowing C -> A
63 my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
64 $template->param(
65 MULTI => 1,
66 CATCODE_MULTI => 1,
67 borrowernumber => $borrowernumber,
68 patron_categories => $patron_categories,
70 output_html_with_http_headers $input, $cookie, $template->output;
73 elsif ( $op eq 'update' ) {
74 my $member = GetMember('borrowernumber'=>$borrowernumber);
75 $member->{'guarantorid'} = 0;
76 $member->{'categorycode'} = $catcode;
77 my $borcat = Koha::Patron::Categories->find($catcode);
78 $member->{'category_type'} = $borcat->category_type;
79 $member->{'description'} = $borcat->description;
80 delete $member->{password};
81 ModMember(%$member);
83 if ( $catcode_multi ) {
84 $template->param(
85 SUCCESS => 1,
86 borrowernumber => $borrowernumber,
88 output_html_with_http_headers $input, $cookie, $template->output;
89 } else {
90 print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber");