Bug 18789: Pass a Koha::Patron object from returns.pl
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 1 Jun 2017 16:14:29 +0000 (13:14 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 16 Feb 2018 16:03:58 +0000 (13:03 -0300)
This is a specific patch for returns.pl

Test plan:
Do some checkin for a patron and make sure the info are correctly
displayed (and info from someone that has placed a hold on this item)

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

circ/returns.pl
koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt

index bd30f5c..162f8fd 100755 (executable)
@@ -177,11 +177,7 @@ if ( $query->param('reserve_id') ) {
             itembiblionumber => $biblio->biblionumber,
             iteminfo       => $biblio->author,
             name           => $name,
-            borrowernumber => $borrowernumber,
-            borcnum        => $patron->cardnumber,
-            borfirstname   => $patron->firstname,
-            borsurname     => $patron->surname,
-            borcategory    => $patron->category->description,
+            patron         => $patron,
             diffbranch     => 1,
         );
     }
@@ -293,7 +289,6 @@ if ($barcode) {
             ccode            => $item->ccode,
             itembiblionumber => $biblio->biblionumber,
             biblionumber     => $biblio->biblionumber,
-            borrower         => $borrower,
             additional_materials => $materials,
             issue            => $checkout,
         );
@@ -404,23 +399,8 @@ if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
         my $patron = Koha::Patrons->find( $reserve->{'borrowernumber'} );
         my $name = $patron->surname . ", " . $patron->title . " " . $patron->firstname;
         $template->param(
-            # FIXME The full patron object should be passed to the template
-                wname           => $name,
-                wborfirstname   => $patron->firstname,
-                wborsurname     => $patron->surname,
-                wborcategory    => $patron->category->description,
-                wbortitle       => $patron->title,
-                wborphone       => $patron->phone,
-                wboremail       => $patron->email,
-                streetnumber    => $patron->streetnumber,
-                address         => $patron->address,
-                address2        => $patron->address2,
-                city            => $patron->city,
-                zipcode         => $patron->zipcode,
-                state           => $patron->state,
-                country         => $patron->country,
-                wborrowernumber => $reserve->{'borrowernumber'},
-                wborcnum        => $patron->cardnumber,
+            wname  => $name,
+            patron => $patron,
         );
     }
     $template->param(
@@ -454,22 +434,6 @@ if ( $messages->{'ResFound'}) {
             # FIXME The full patron object should be passed to the template
             found          => 1,
             name           => $patron->surname . ", " . $patron->title . " " . $patron->firstname,
-            borfirstname   => $patron->firstname,
-            borsurname     => $patron->surname,
-            borcategory    => $patron->category->description,
-            bortitle       => $patron->title,
-            borphone       => $patron->phone,
-            boremail       => $patron->email,
-            boraddress     => $patron->address,
-            boraddress2    => $patron->address2,
-            streetnumber   => $patron->streetnumber,
-            city           => $patron->city,
-            zipcode        => $patron->zipcode,
-            state          => $patron->state,
-            country        => $patron->country,
-            borcnum        => $patron->cardnumber,
-            debarred       => $patron->debarred,
-            gonenoaddress  => $patron->gonenoaddress,
             barcode        => $barcode,
             destbranch     => $reserve->{'branchcode'},
             borrowernumber => $reserve->{'borrowernumber'},
@@ -580,13 +544,7 @@ foreach ( sort { $a <=> $b } keys %returneditems ) {
             } else {
                 $ri{return_overdue} = 1 if (DateTime->compare($duedate, $dropboxdate) == -1);
             }
-            $ri{borrowernumber} = $patron->borrowernumber;
-            $ri{borcnum}        = $patron->cardnumber;
-            $ri{borfirstname}   = $patron->firstname;
-            $ri{borsurname}     = $patron->surname;
-            $ri{bortitle}       = $patron->title;
-            $ri{bornote}        = $patron->borrowernotes;
-            $ri{borcategorycode}= $patron->categorycode;
+            $ri{patron} = $patron,
             $ri{borissuescount} = $patron->checkouts->count;
         }
         else {
index 62878d6..6395eb5 100644 (file)
 [% IF return_date_was_overriden && Borrowers.IsDebarred( borrower ) %]
     <div id="restricted_backdated" class="dialog message">
         <h3>
-            <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber %]">
-                [% borrower.firstname %] [% borrower.surname %]
+            <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber %]">
+                [% patron.firstname %] [% patron.surname %]
             </a>
             is restricted. Please verify this patron should still be restricted.
         </h3>
             <p><a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=[% itembiblionumber %]">[% itembarcode |html %]: [% title |html %]</a></p>
         <button type="submit" class="openWin" data-url="transfer-slip.pl?transferitem=[% itemnumber %]&amp;&amp;branchcode=[% TransferWaitingAt %]&amp;op=slip"><i class="fa fa-print"></i> Print transfer slip</button>
         <button class="deny" type="submit" onclick="window.location.href='/cgi-bin/koha/circ/returns.pl?itemnumber=[% itemnumber %]&amp;canceltransfer=1'"><i class="fa fa-times"></i> Cancel transfer</button>
-[% IF ( wborcnum ) %]<h5>Hold for:</h5>
+[% IF ( patron.cardnumber ) %]<h5>Hold for:</h5>
         <ul>
-            <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">
-            [% borsurname %], [% borfirstname %]</a> ([% borcnum %]) <span class="patron-category"> - [% wborcategory %]</span> </li>
+            <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber %]">
+            [% patron.surname %], [% patron.firstname %]</a> ([% patron.cardnumber %]) <span class="patron-category"> - [% patron.category.description %]</span> </li>
             [% INCLUDE display_holdpatron_address %]
-            [% IF ( wborphone ) %]<li>[% wborphone %]</li>[% END %]
-            [% IF ( wboremail ) %]<li><a id="boremail" href="mailto:[% wboremail %]">[% wboremail %]</a></li>[% END %]
+            [% IF ( patron.phone ) %]<li>[% patron.phone %]</li>[% END %]
+            [% IF ( patron.email ) %]<li><a id="boremail" href="mailto:[% patron.email %]">[% patron.email %]</a></li>[% END %]
         </ul>
 
     <form method="post" action="returns.pl" class="confirm">
             <input type="hidden" name="WT-From" value="[% wtransfertFrom %]" />
             <button type="submit" class="approve"><i class="fa fa-check"></i> Confirm</button>
             <input type="hidden" name="print_slip" value="0" />
-            <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
+            <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]" />
             <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
             <button type="submit" class="print" onclick="this.form.print_slip.value = 1; this.form.submit();"><i class="fa fa-print"></i> Print slip and confirm</button>
         <input type="hidden" name="return_date_override" value="[% return_date_override %]" />
                     <h4>Hold for:</h4>
                     <ul>
                     <li>
-                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borsurname %], [% borfirstname %]</a> ([% borcnum %])
-                        <span class="patron-category"> - [% borcategory %]</span>
+                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber %]">[% patron.surname %], [% patron.firstname %]</a> ([% patron.cardnumber %])
+                        <span class="patron-category"> - [% patron.category.description %]</span>
                     </li>
                     [% INCLUDE display_holdpatron_address %]
-                    [% IF ( borphone ) %]
-                        <li> [% borphone %]</li>
+                    [% IF ( patron.phone ) %]
+                        <li> [% patron.phone %]</li>
                     [% END %]
 
-                    [% IF ( boremail ) %]
-                        <li><a id="boremail" href="mailto:[% boremail %]">[% boremail %]</a></li>
+                    [% IF ( patron.email ) %]
+                        <li><a id="boremail" href="mailto:[% patron.email %]">[% patron.email %]</a></li>
                     [% END %]
 
-                    [% IF ( debarred ) %]
+                    [% IF ( patron.debarred ) %]
                         <li class="error">Patron is RESTRICTED</li>
                     [% END %]
 
-                    [% IF ( gonenoaddress ) %]
+                    [% IF ( patron.gonenoaddress ) %]
                         <li class="error">Patron's address is in doubt</li>
                     [% END %]
                     </ul>
                     [% END %]
 
                     <input type="hidden" name="itemnumber" value="[% itemnumber %]" />
-                    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
+                    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]" />
                     <input type="hidden" name="biblionumber" value="[% itembiblionumber %]" />
                     <input type="hidden" name="reserve_id" value="[% reserve_id %]" />
                     <input type="hidden" name="diffBranch" value="[% destbranch %]" />
                 <p><a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=[% itembiblionumber %]">[% itembarcode |html %]: [% title |html %]</a></p>
                 <h4>Hold for: </h4>
                     <ul>
-                        <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borsurname %], [% borfirstname %]</a> ([% borcnum %]) <span class="patron-category"> - [% wborcategory %]</span> </li>
+                        <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber %]">[% patron.surname %], [% patron.firstname %]</a> ([% patron.cardnumber %]) <span class="patron-category"> - [% patron.category.description %]</span> </li>
                         [% INCLUDE display_holdpatron_address %]
-                        [% IF ( borphone ) %]<li>[% borphone %]</li>[% END %]
-                        [% IF ( boremail ) %]<li>[% IF ( transfertodo ) %][% boremail %][% ELSE %]<a id="boremail" href="mailto:[% boremail %]">[% boremail %]</a>[% END %]</li>[% END %]
-[% IF ( debarred ) %]<li class="error">Patron is RESTRICTED</li>[% END %]
-[% IF ( gonenoaddress ) %]<li class="error">Patron's address is in doubt</li>[% END %]
+                        [% IF ( patron.phone ) %]<li>[% patron.phone %]</li>[% END %]
+                        [% IF ( patron.email ) %]<li>[% IF ( transfertodo ) %][% patron.email %][% ELSE %]<a id="boremail" href="mailto:[% patron.email %]">[% patron.email %]</a>[% END %]</li>[% END %]
+[% IF ( patron.debarred ) %]<li class="error">Patron is RESTRICTED</li>[% END %]
+[% IF ( patron.gonenoaddress ) %]<li class="error">Patron's address is in doubt</li>[% END %]
                     </ul>
         [% IF ( transfertodo ) %]
             <h4><strong>Transfer to:</strong> [% Branches.GetName( destbranch ) %]</h4>
         <form method="post" action="returns.pl" class="confirm">
             <button type="submit" class="approve"><i class="fa fa-check"></i> Confirm</button>
             <input type="hidden" name="print_slip" value="0" />
-            <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
+            <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]" />
             <input type="hidden" name="biblionumber" value="[% itembiblionumber %]" />
             <button type="submit" class="print" onclick="this.form.print_slip.value = 1; this.form.submit();"><i class="fa fa-print"></i> Print slip and continue</button>
             [% FOREACH inputloo IN inputloop %]
                     [% END %]
                     <h5>Hold for:</h5>
                         <li>
-                            <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">
-                                [% borsurname %], [% borfirstname %]
+                            <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber %]">
+                                [% patron.surname %], [% patron.firstname %]
                             </a>
-                            ([% borcnum %])
-                            <span class="patron-category"> - [% borcategory %]</span>
+                            ([% patron.cardnumber %])
+                            <span class="patron-category"> - [% patron.category.description %]</span>
                         </li>
 
                         [% INCLUDE display_holdpatron_address %]
 
-                        [% IF ( borphone ) %]
-                            <li>[% borphone %]</li>
+                        [% IF ( patron.phone ) %]
+                            <li>[% patron.phone  %]</li>
                         [% END %]
 
-                        [% IF ( boremail ) %]
+                        [% IF ( patron.email ) %]
                             <li>
                                 [% IF ( transfertodo ) %]
-                                    [% boremail %]
+                                    [% patron.email %]
                                 [% ELSE %]
-                                    <a id="boremail" href="mailto:[% boremail %]">[% boremail %]</a>
+                                    <a id="boremail" href="mailto:[% patron.email %]">[% patron.email %]</a>
                                 [% END %]
                             </li>
                         [% END %]
                             [% INCLUDE display_bormessagepref %]
                         [% END %]
 
-                        [% IF ( debarred ) %]
+                        [% IF ( patron.debarred ) %]
                             <li class="error">Patron is RESTRICTED</li>
                         [% END %]
 
-                        [% IF ( gonenoaddress ) %]
+                        [% IF ( patron.gonenoaddress ) %]
                             <li class="error">Patron's address is in doubt</li>
                         [% END %]
 
                     [% END %]
 
                     <input type="hidden" name="itemnumber" value="[% itemnumber %]" />
-                    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
+                    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]" />
                     <input type="hidden" name="biblionumber" value="[% itembiblionumber %]" />
                     <input type="hidden" name="reserve_id" value="[% reserve_id %]" />
                     <input type="hidden" name="diffBranch" value="[% destbranch %]" />
             $(".modal").on('hidden.bs.modal', function (e) { $("#barcode").focus(); });
 
             [% IF print_slip %]
-                Dopop('hold-transfer-slip.pl?borrowernumber=[% borrowernumber %]&amp;biblionumber=[% biblionumber %]');
+                Dopop('hold-transfer-slip.pl?borrowernumber=[% patron.borrowernumber %]&amp;biblionumber=[% biblionumber %]');
             [% END %]
 
             var columns_settings = [% ColumnsSettings.GetColumns( 'circ', 'returns', 'checkedintable', 'json' ) %]