Bug 10403: (follow-up) fix test to use vendor created earlier during test
[koha.git] / members / moremember.pl
index 0524ecb..86c61c1 100755 (executable)
@@ -47,13 +47,11 @@ use C4::Circulation;
 use C4::Koha;
 use C4::Letters;
 use C4::Biblio;
-use C4::Reserves;
 use C4::Branch; # GetBranchName
-use C4::Overdues qw/CheckBorrowerDebarred/;
 use C4::Form::MessagingPreferences;
 use List::MoreUtils qw/uniq/;
 use C4::Members::Attributes qw(GetBorrowerAttributes);
-
+use Koha::Borrower::Debarments qw(GetDebarments);
 #use Smart::Comments;
 #use Data::Dumper;
 use DateTime;
@@ -85,7 +83,9 @@ my $quickslip = 0;
 my $flagsrequired;
 if ($print eq "page") {
     $template_name = "members/moremember-print.tmpl";
-    $flagsrequired = { borrowers => 1 };
+    # circ staff who process checkouts but can't edit
+    # patrons still need to be able to access print view
+    $flagsrequired = { circulate => "circulate_remaining_permissions" };
 } elsif ($print eq "slip") {
     $template_name = "members/moremember-receipt.tmpl";
     # circ staff who process checkouts but can't edit
@@ -117,7 +117,6 @@ my $borrowernumber = $input->param('borrowernumber');
 
 #start the page and read in includes
 my $data           = GetMember( 'borrowernumber' => $borrowernumber );
-my $reregistration = $input->param('reregistration');
 
 if ( not defined $data ) {
     $template->param (unknowuser => 1);
@@ -125,11 +124,6 @@ if ( not defined $data ) {
     exit;
 }
 
-# re-reregistration function to automatic calcul of date expiry
-if ( $reregistration eq 'y' ) {
-       $data->{'dateexpiry'} = ExtendMemberSubscriptionTo( $borrowernumber );
-}
-
 my $category_type = $data->{'category_type'};
 
 ### $category_type
@@ -152,7 +146,7 @@ for (qw(gonenoaddress lost borrowernotes)) {
         $data->{$_} and $template->param(flagged => 1) and last;
 }
 
-my $debar = CheckBorrowerDebarred($borrowernumber);
+my $debar = $data->{'debarred'};
 if ($debar) {
     $template->param( 'userdebarred' => 1, 'flagged' => 1 );
     if ( $debar ne "9999-12-31" ) {
@@ -217,7 +211,7 @@ $bor{'borrowernumber'} = $borrowernumber;
 
 # Converts the branchcode to the branch name
 my $samebranch;
-if ( C4::Context->preference("IndependantBranches") ) {
+if ( C4::Context->preference("IndependentBranches") ) {
     my $userenv = C4::Context->userenv;
     unless ( $userenv->{flags} % 2 == 1 ) {
         $samebranch = ( $data->{'branchcode'} eq $userenv->{branch} );
@@ -279,7 +273,7 @@ if ($borrowernumber) {
         foreach (qw(waiting transfered nottransfered)) {
             $getreserv{$_} = 0;
         }
-        $getreserv{reservedate}  = C4::Dates->new($num_res->{'reservedate'},'iso')->output('syspref');
+        $getreserv{reservedate}  = $num_res->{'reservedate'};
         foreach (qw(biblionumber title author itemcallnumber )) {
             $getreserv{$_} = $getiteminfo->{$_};
         }
@@ -307,6 +301,8 @@ if ($borrowernumber) {
             $getreserv{nottransferedby} =
                 GetBranchName( $getiteminfo->{'holdingbranch'} );
         }
+        $getreserv{title}          = $getiteminfo->{'title'};
+        $getreserv{subtitle}       = GetRecordValue('subtitle', GetMarcBiblio($getiteminfo->{biblionumber}), GetFrameworkCode($getiteminfo->{biblionumber}));
 
 #              if we don't have a reserv on item, we put the biblio infos and the waiting position
         if ( $getiteminfo->{'title'} eq '' ) {
@@ -314,6 +310,7 @@ if ($borrowernumber) {
             my $getbibtype = getitemtypeinfo( $getbibinfo->{'itemtype'} );
             $getreserv{color}           = 'inwait';
             $getreserv{title}           = $getbibinfo->{'title'};
+            $getreserv{subtitle}        = GetRecordValue('subtitle', GetMarcBiblio($num_res->{biblionumber}), GetFrameworkCode($num_res->{biblionumber}));
             $getreserv{nottransfered}   = 0;
             $getreserv{itemtype}        = $getbibtype->{'description'};
             $getreserv{author}          = $getbibinfo->{'author'};
@@ -322,6 +319,8 @@ if ($borrowernumber) {
         $getreserv{waitingposition} = $num_res->{'priority'};
         $getreserv{suspend} = $num_res->{'suspend'};
         $getreserv{suspend_until} = $num_res->{'suspend_until'};
+        $getreserv{expirationdate} = $num_res->{'expirationdate'};
+        $getreserv{reserve_id} = $num_res->{'reserve_id'};
 
         push( @reservloop, \%getreserv );
     }
@@ -343,7 +342,7 @@ my $candeleteuser;
 my $userenv = C4::Context->userenv;
 if($userenv->{flags} % 2 == 1){
     $candeleteuser = 1;
-}elsif ( C4::Context->preference("IndependantBranches") ) {
+}elsif ( C4::Context->preference("IndependentBranches") ) {
     $candeleteuser = ( $data->{'branchcode'} eq $userenv->{branch} );
 }else{
     if( C4::Auth::getuserflags( $userenv->{flags},$userenv->{number})->{borrowers} ) {
@@ -356,7 +355,7 @@ if($userenv->{flags} % 2 == 1){
 # check to see if patron's image exists in the database
 # basically this gives us a template var to condition the display of
 # patronimage related interface on
-my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
+my ($picture, $dberror) = GetPatronImage($data->{'borrowernumber'});
 $template->param( picture => 1 ) if $picture;
 
 my $branch=C4::Context->userenv->{'branch'};
@@ -406,13 +405,12 @@ $template->param( $data->{'categorycode'} => 1 );
 $template->param(
     detailview => 1,
     AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"),
-    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
     CANDELETEUSER    => $candeleteuser,
     roaddetails     => $roaddetails,
     borrowernumber  => $borrowernumber,
     othernames      => $data->{'othernames'},
     categoryname    => $data->{'description'},
-    reregistration  => $reregistration,
+    was_renewed     => $input->param('was_renewed') ? 1 : 0,
     branch          => $branch,
     todaysdate      => C4::Dates->today(),
     totalprice      => sprintf("%.2f", $totalprice),
@@ -425,13 +423,13 @@ $template->param(
     StaffMember     => ($category_type eq 'S'),
     is_child        => ($category_type eq 'C'),
 #   reserveloop     => \@reservedata,
-    dateformat      => C4::Context->preference("dateformat"),
-    "dateformat_" . (C4::Context->preference("dateformat") || '') => 1,
     samebranch     => $samebranch,
     quickslip            => $quickslip,
     activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''),
     AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
     SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
+    RoutingSerials => C4::Context->preference('RoutingSerials'),
+    debarments => GetDebarments({ borrowernumber => $borrowernumber }),
 );
 $template->param( $error => 1 ) if $error;
 
@@ -453,10 +451,7 @@ sub build_issue_data {
         if ($issue->{issuedate} ) {
            $issuedate = $issue->{issuedate}->clone();
         }
-
-        $issue->{date_due}  = output_pref( $issue->{date_due} );
-        $issue->{issuedate} = output_pref( $issue->{issuedate} ) if defined $issue->{issuedate};
-        my $biblionumber = $issue->{biblionumber};
+        $issue->{subtitle} = GetRecordValue('subtitle', GetMarcBiblio($issue->{biblionumber}), GetFrameworkCode($issue->{biblionumber}));
         $issue->{issuingbranchname} = GetBranchName($issue->{branchcode});
         my %row          = %{$issue};
         $totalprice += $issue->{replacementprice};