# July 26, 2002 (my birthday!)
use strict;
+use warnings;
use CGI;
use C4::Output;
use C4::Auth qw(:DEFAULT :EditPermissions);
use C4::Context;
use C4::Members;
+use C4::Branch;
+use C4::Members::Attributes qw(GetBorrowerAttributes);
#use C4::Acquisitions;
use C4::Output;
$sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?");
$sth->execute($module_flags, $member);
- if (C4::Context->preference('CheckSpecificUserPermissions')) {
- # deal with subpermissions
- $sth = $dbh->prepare("DELETE FROM user_permissions WHERE borrowernumber = ?");
- $sth->execute($member);
- $sth = $dbh->prepare("INSERT INTO user_permissions (borrowernumber, module_bit, code)
- SELECT ?, bit, ?
- FROM userflags
- WHERE flag = ?");
- foreach my $module (keys %sub_perms) {
- next if exists $all_module_perms{$module};
- foreach my $sub_perm (@{ $sub_perms{$module} }) {
- $sth->execute($member, $sub_perm, $module);
- }
+ # deal with subpermissions
+ $sth = $dbh->prepare("DELETE FROM user_permissions WHERE borrowernumber = ?");
+ $sth->execute($member);
+ $sth = $dbh->prepare("INSERT INTO user_permissions (borrowernumber, module_bit, code)
+ SELECT ?, bit, ?
+ FROM userflags
+ WHERE flag = ?");
+ foreach my $module (keys %sub_perms) {
+ next if exists $all_module_perms{$module};
+ foreach my $sub_perm (@{ $sub_perms{$module} }) {
+ $sth->execute($member, $sub_perm, $module);
}
}
checked => $checked,
flagdesc => $flagdesc );
- if (C4::Context->preference('CheckSpecificUserPermissions')) {
- my @sub_perm_loop = ();
- my $expand_parent = 0;
- if ($checked) {
- if (exists $all_perms->{$flag}) {
- $expand_parent = 1;
- foreach my $sub_perm (sort keys %{ $all_perms->{$flag} }) {
- push @sub_perm_loop, {
- id => "${flag}_$sub_perm",
- perm => "$flag:$sub_perm",
- code => $sub_perm,
- description => $all_perms->{$flag}->{$sub_perm},
- checked => 1
- };
- }
+ my @sub_perm_loop = ();
+ my $expand_parent = 0;
+ if ($checked) {
+ if (exists $all_perms->{$flag}) {
+ $expand_parent = 1;
+ foreach my $sub_perm (sort keys %{ $all_perms->{$flag} }) {
+ push @sub_perm_loop, {
+ id => "${flag}_$sub_perm",
+ perm => "$flag:$sub_perm",
+ code => $sub_perm,
+ description => $all_perms->{$flag}->{$sub_perm},
+ checked => 1
+ };
}
- } else {
- if (exists $user_perms->{$flag}) {
- $expand_parent = 1;
- # put selected ones first
- foreach my $sub_perm (sort keys %{ $user_perms->{$flag} }) {
- push @sub_perm_loop, {
- id => "${flag}_$sub_perm",
- perm => "$flag:$sub_perm",
- code => $sub_perm,
- description => $all_perms->{$flag}->{$sub_perm},
- checked => 1
- };
- }
+ }
+ } else {
+ if (exists $user_perms->{$flag}) {
+ $expand_parent = 1;
+ # put selected ones first
+ foreach my $sub_perm (sort keys %{ $user_perms->{$flag} }) {
+ push @sub_perm_loop, {
+ id => "${flag}_$sub_perm",
+ perm => "$flag:$sub_perm",
+ code => $sub_perm,
+ description => $all_perms->{$flag}->{$sub_perm},
+ checked => 1
+ };
}
- # then ones not selected
- if (exists $all_perms->{$flag}) {
- foreach my $sub_perm (sort keys %{ $all_perms->{$flag} }) {
- push @sub_perm_loop, {
- id => "${flag}_$sub_perm",
- perm => "$flag:$sub_perm",
- code => $sub_perm,
- description => $all_perms->{$flag}->{$sub_perm},
- checked => 0
- } unless exists $user_perms->{$flag} and exists $user_perms->{$flag}->{$sub_perm};
- }
+ }
+ # then ones not selected
+ if (exists $all_perms->{$flag}) {
+ foreach my $sub_perm (sort keys %{ $all_perms->{$flag} }) {
+ push @sub_perm_loop, {
+ id => "${flag}_$sub_perm",
+ perm => "$flag:$sub_perm",
+ code => $sub_perm,
+ description => $all_perms->{$flag}->{$sub_perm},
+ checked => 0
+ } unless exists $user_perms->{$flag} and exists $user_perms->{$flag}->{$sub_perm};
}
}
- $row{expand} = $expand_parent;
- if ($#sub_perm_loop > -1) {
+ }
+ $row{expand} = $expand_parent;
+ if ($#sub_perm_loop > -1) {
$row{sub_perm_loop} = \@sub_perm_loop;
- }
}
push @loop, \%row;
}
- my $borrowercategory = GetBorrowercategory( $bor->{'categorycode'} );
-my $category_type = $borrowercategory->{'category_type'};
-( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' );
+ if ( $bor->{'category_type'} eq 'C') {
+ my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
+ my $cnt = scalar(@$catcodes);
+ $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
+ $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
+ }
- $template->param(borrowernumber => $member,
- borrowernumber => $bor->{'borrowernumber'},
- cardnumber => $bor->{'cardnumber'},
- surname => $bor->{'surname'},
- firstname => $bor->{'firstname'},
- categorycode => $bor->{'categorycode'},
- category_type => $bor->{'category_type'},
- category_description => $bor->{'description'},
- address => $bor->{'address'},
- address2 => $bor->{'address2'},
- city => $bor->{'city'},
- zipcode => $bor->{'zipcode'},
- phone => $bor->{'phone'},
- email => $bor->{'email'},
- branchcode => $bor->{'branchcode'},
- loop => \@loop,
- );
+$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' );
+ my ($picture, $dberror) = GetPatronImage($bor->{'cardnumber'});
+ $template->param( picture => 1 ) if $picture;
+
+if (C4::Context->preference('ExtendedPatronAttributes')) {
+ my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
+ $template->param(
+ ExtendedPatronAttributes => 1,
+ extendedattributes => $attributes
+ );
+}
+
+$template->param(
+ borrowernumber => $bor->{'borrowernumber'},
+ cardnumber => $bor->{'cardnumber'},
+ surname => $bor->{'surname'},
+ firstname => $bor->{'firstname'},
+ categorycode => $bor->{'categorycode'},
+ category_type => $bor->{'category_type'},
+ categoryname => $bor->{'description'},
+ address => $bor->{'address'},
+ address2 => $bor->{'address2'},
+ city => $bor->{'city'},
+ state => $bor->{'state'},
+ zipcode => $bor->{'zipcode'},
+ country => $bor->{'country'},
+ phone => $bor->{'phone'},
+ email => $bor->{'email'},
+ branchcode => $bor->{'branchcode'},
+ branchname => GetBranchName($bor->{'branchcode'}),
+ loop => \@loop,
+ is_child => ($bor->{'category_type'} eq 'C'),
+ );
output_html_with_http_headers $input, $cookie, $template->output;