}
# get the borrower information.....
-if ($borrowernumber) {
- $patron = Koha::Patrons->find( $borrowernumber );
+$patron ||= Koha::Patrons->find( $borrowernumber ) if $borrowernumber;
+if ($patron) {
my $overdues = $patron->get_overdues;
my $issues = $patron->checkouts;
my $balance = $patron->account->balance;
##################################################################################
# BUILD HTML
# show all reserves of this borrower, and the position of the reservation ....
-if ($borrowernumber) {
- my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } );
+if ($patron) {
+ my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); # FIXME must be Koha::Patron->holds
my $waiting_holds = $holds->waiting;
$template->param(
holds_count => $holds->count(),
[% USE Branches %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Patrons ›
-[% IF ( unknowuser ) %]
- Patron does not exist
-[% ELSE %]
- Statistics for [% INCLUDE 'patron-title.inc' %]
-[% END %]
+Statistics for [% INCLUDE 'patron-title.inc' %]
</title>
[% INCLUDE 'doc-head-close.inc' %]
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
<div id="breadcrumbs">
<a href="/cgi-bin/koha/mainpage.pl">Home</a>
› <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
-› [% IF ( unknowuser ) %]Patron does not exist[% ELSE %]Statistics for [% firstname %] [% surname %] ([% cardnumber %])[% END %]
+› Statistics for [% firstname %] [% surname %] ([% cardnumber %])
</div>
<div id="doc3" class="yui-t1">
#get patron details
my $patron = Koha::Patrons->find( $borrowernumber );
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+}
if ( $action eq 'reverse' ) {
ReversePayment( $input->param('accountlines_id') );
my $countissues = scalar(@$issues);
my $patron = Koha::Patrons->find( $member );
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+}
my $flags = C4::Members::patronflags( $patron->unblessed );
my $userenv = C4::Context->userenv;
exit;
}
-if ( $input->param('borrowernumber') ) {
- $borrowernumber = $input->param('borrowernumber');
+$borrowernumber = $input->param('borrowernumber');
- # Getting member data
- my $patron = Koha::Patrons->find( $borrowernumber );
+my $patron = Koha::Patrons->find( $borrowernumber );
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+}
- my $can_be_discharged = Koha::Patron::Discharge::can_be_discharged({
- borrowernumber => $borrowernumber
- });
+my $can_be_discharged = Koha::Patron::Discharge::can_be_discharged({
+ borrowernumber => $borrowernumber
+});
- my $holds = $patron->holds;
- my $has_reserves = $holds->count;
+my $holds = $patron->holds;
+my $has_reserves = $holds->count;
- # Generating discharge if needed
- if ( $input->param('discharge') and $can_be_discharged ) {
- my $is_discharged = Koha::Patron::Discharge::is_discharged({
- borrowernumber => $borrowernumber,
+# Generating discharge if needed
+if ( $input->param('discharge') and $can_be_discharged ) {
+ my $is_discharged = Koha::Patron::Discharge::is_discharged({
+ borrowernumber => $borrowernumber,
+ });
+ unless ($is_discharged) {
+ Koha::Patron::Discharge::discharge({
+ borrowernumber => $borrowernumber
});
- unless ($is_discharged) {
- Koha::Patron::Discharge::discharge({
- borrowernumber => $borrowernumber
- });
- }
- eval {
- my $pdf_path = Koha::Patron::Discharge::generate_as_pdf(
- { borrowernumber => $borrowernumber, branchcode => $patron->branchcode } );
-
- binmode(STDOUT);
- print $input->header(
- -type => 'application/pdf',
- -charset => 'utf-8',
- -attachment => "discharge_$borrowernumber.pdf",
- );
- open my $fh, '<', $pdf_path;
- my @lines = <$fh>;
- close $fh;
- print @lines;
- exit;
- };
- if ( $@ ) {
- carp $@;
- $template->param( messages => [ {type => 'error', code => 'unable_to_generate_pdf'} ] );
- }
}
+ eval {
+ my $pdf_path = Koha::Patron::Discharge::generate_as_pdf(
+ { borrowernumber => $borrowernumber, branchcode => $patron->branchcode } );
+
+ binmode(STDOUT);
+ print $input->header(
+ -type => 'application/pdf',
+ -charset => 'utf-8',
+ -attachment => "discharge_$borrowernumber.pdf",
+ );
+ open my $fh, '<', $pdf_path;
+ my @lines = <$fh>;
+ close $fh;
+ print @lines;
+ exit;
+ };
+ if ( $@ ) {
+ carp $@;
+ $template->param( messages => [ {type => 'error', code => 'unable_to_generate_pdf'} ] );
+ }
+}
- # Already generated discharges
- my $validated_discharges = Koha::Patron::Discharge::get_validated({
- borrowernumber => $borrowernumber,
- });
+# Already generated discharges
+my $validated_discharges = Koha::Patron::Discharge::get_validated({
+ borrowernumber => $borrowernumber,
+});
- $template->param( picture => 1 ) if $patron->image;
-
- $template->param(
- # FIXME The patron object should be passed to the template
- borrowernumber => $borrowernumber,
- title => $patron->title,
- initials => $patron->initials,
- surname => $patron->surname,
- borrowernumber => $borrowernumber,
- firstname => $patron->firstname,
- cardnumber => $patron->cardnumber,
- categorycode => $patron->categorycode,
- category_type => $patron->category->category_type,
- categoryname => $patron->category->description,
- address => $patron->address,
- streetnumber => $patron->streetnumber,
- streettype => $patron->streettype,
- address2 => $patron->address2,
- city => $patron->city,
- zipcode => $patron->zipcode,
- country => $patron->country,
- phone => $patron->phone,
- email => $patron->email,
- branchcode => $patron->branchcode,
- has_reserves => $has_reserves,
- can_be_discharged => $can_be_discharged,
- validated_discharges => $validated_discharges,
- );
-}
+$template->param( picture => 1 ) if $patron->image;
+
+$template->param(
+ # FIXME The patron object should be passed to the template
+ borrowernumber => $borrowernumber,
+ title => $patron->title,
+ initials => $patron->initials,
+ surname => $patron->surname,
+ borrowernumber => $borrowernumber,
+ firstname => $patron->firstname,
+ cardnumber => $patron->cardnumber,
+ categorycode => $patron->categorycode,
+ category_type => $patron->category->category_type,
+ categoryname => $patron->category->description,
+ address => $patron->address,
+ streetnumber => $patron->streetnumber,
+ streettype => $patron->streettype,
+ address2 => $patron->address2,
+ city => $patron->city,
+ zipcode => $patron->zipcode,
+ country => $patron->country,
+ phone => $patron->phone,
+ email => $patron->email,
+ branchcode => $patron->branchcode,
+ has_reserves => $has_reserves,
+ can_be_discharged => $can_be_discharged,
+ validated_discharges => $validated_discharges,
+);
$template->param( dischargeview => 1, );
}
else {
my $patron = Koha::Patrons->find( $borrowernumber );
+ unless ( $patron ) {
+ print $cgi->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+ }
+
my $patron_category = $patron->category;
$template->param(%{ $patron->unblessed});
my $borrowernumber=$input->param('borrowernumber');
my $patron = Koha::Patrons->find( $borrowernumber );
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+}
my $add=$input->param('add');
if ($add){
my $borrowernumber=$input->param('borrowernumber');
my $patron = Koha::Patrons->find( $borrowernumber );
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+}
+
my $add=$input->param('add');
if ($add){
if ( checkauth( $input, 0, $flagsrequired, 'intranet' ) ) {
my $flagsrequired = { permissions => 1 };
my $member=$input->param('member');
my $patron = Koha::Patrons->find( $member );
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$member");
+ exit;
+}
+
my $category_type = $patron->category->category_type;
my $bor = $patron->unblessed;
if( $category_type eq 'S' ) {
my @errors;
my $patron = Koha::Patrons->find( $member );
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$member");
+ exit;
+}
+
my $category_type = $patron->category->category_type;
my $bor = $patron->unblessed;
$template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 );
if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) {
my $patron = Koha::Patrons->find( $borrowernumber );
+ unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+ }
+
$borrower_data = $patron->unblessed;
$borrower_data->{category_type} = $patron->category->category_type;
}
my $borrowernumber = $input->param('borrowernumber');
my $patron = Koha::Patrons->find( $borrowernumber );
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+}
my $borrower = $patron->unblessed;
my ($template, $loggedinuser, $cookie)
# get borrower details
my $patron = Koha::Patrons->find( $borrowernumber );
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+}
my $category = $patron->category;
our $borrower = $patron->unblessed;
$borrower->{description} = $category->description;
# get borrower details
my $borrowernumber = $input->param('borrowernumber');
my $patron = Koha::Patrons->find( $borrowernumber );
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+}
my $borrower = $patron->unblessed;
my $category = $patron->category;
$borrower->{description} = $category->description;
my $accountlines_id = $input->param('accountlines_id');
my $patron = Koha::Patrons->find( $borrowernumber );
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+}
my $category = $patron->category;
my $data = $patron->unblessed;
$data->{description} = $category->description;
my $accountlines_id = $input->param('accountlines_id');
my $patron = Koha::Patrons->find( $borrowernumber );
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+}
my $category = $patron->category;
my $data = $patron->unblessed;
$data->{description} = $category->description;
my $borrowernumber = $input->param('borrowernumber');
-# Set informations for the patron
my $patron = Koha::Patrons->find( $borrowernumber );
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+}
my $category = $patron->category;
my $data = $patron->unblessed;
$data->{description} = $category->description;
if ($input->param('cardnumber')) {
$cardnumber = $input->param('cardnumber');
$patron = Koha::Patrons->find( { cardnumber => $cardnumber } );
- $data = $patron->unblessed;
- $borrowernumber = $data->{'borrowernumber'}; # we must define this as it is used to retrieve other data about the patron
}
if ($input->param('borrowernumber')) {
$borrowernumber = $input->param('borrowernumber');
$patron = Koha::Patrons->find( $borrowernumber );
- $data = $patron->unblessed;
}
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+}
+$data = $patron->unblessed;
+$borrowernumber = $patron->borrowernumber;
+
my $order = 'date_due desc';
my $limit = 0;
my $issues = ();
my $branch = C4::Context->userenv->{'branch'};
-# get the borrower information.....
-my ( $patron, $patron_info );
-if ($borrowernumber) {
- $patron = Koha::Patrons->find( $borrowernumber );
- my $category = $patron->category;
- $patron_info = $patron->unblessed;
- $patron_info->{description} = $category->description;
- $patron_info->{category_type} = $category->category_type;
-
- my $count;
- my @borrowerSubscriptions;
- ($count, @borrowerSubscriptions) = GetSubscriptionsFromBorrower($borrowernumber );
- my @subscripLoop;
-
- foreach my $num_res (@borrowerSubscriptions) {
- my %getSubscrip;
- $getSubscrip{subscriptionid} = $num_res->{'subscriptionid'};
- $getSubscrip{title} = $num_res->{'title'};
- $getSubscrip{borrowernumber} = $num_res->{'borrowernumber'};
- push( @subscripLoop, \%getSubscrip );
- }
-
- $template->param(
- countSubscrip => scalar @subscripLoop,
- subscripLoop => \@subscripLoop,
- routinglistview => 1
- );
+my $patron = Koha::Patrons->find( $borrowernumber ) if $borrowernumber;
+unless ( $patron ) {
+ print $query->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+}
- $template->param( adultborrower => 1 ) if ( $patron_info->{category_type} =~ /^(A|I)$/ );
+my $category = $patron->category;
+my $patron_info = $patron->unblessed;
+$patron_info->{description} = $category->description;
+$patron_info->{category_type} = $category->category_type;
+
+my $count;
+my @borrowerSubscriptions;
+($count, @borrowerSubscriptions) = GetSubscriptionsFromBorrower($borrowernumber );
+my @subscripLoop;
+
+foreach my $num_res (@borrowerSubscriptions) {
+ my %getSubscrip;
+ $getSubscrip{subscriptionid} = $num_res->{'subscriptionid'};
+ $getSubscrip{title} = $num_res->{'title'};
+ $getSubscrip{borrowernumber} = $num_res->{'borrowernumber'};
+ push( @subscripLoop, \%getSubscrip );
}
+$template->param(
+ countSubscrip => scalar @subscripLoop,
+ subscripLoop => \@subscripLoop,
+ routinglistview => 1
+);
+
+$template->param( adultborrower => 1 ) if ( $patron_info->{category_type} =~ /^(A|I)$/ );
+
##################################################################################
$template->param(%$patron_info);
# Set informations for the patron
my $patron = Koha::Patrons->find( $borrowernumber );
unless ( $patron ) {
- $template->param (unknowuser => 1);
- output_html_with_http_headers $input, $cookie, $template->output;
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
exit;
}
);
my $patron = Koha::Patrons->find( $borrowernumber );
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+}
my $category = $patron->category;
my $data = $patron->unblessed;
$data->{description} = $category->description;
elsif ( $op eq 'update' ) {
my $patron = Koha::Patrons->find( $borrowernumber );
+ unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+ }
my $member = $patron->unblessed;
$member->{'guarantorid'} = 0;
$member->{'categorycode'} = $catcode;
use C4::Members::Attributes qw(GetBorrowerAttributes);
my $borrowernumber = $object;
my $patron = Koha::Patrons->find( $borrowernumber );
+ unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+ }
$template->param( picture => 1 ) if $patron->image;
my $data = $patron->unblessed;