koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha/circ returns.pl [dev_week]


From: Kyle Hall
Subject: [Koha-cvs] koha/circ returns.pl [dev_week]
Date: Mon, 09 Apr 2007 14:23:27 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         dev_week
Changes by:     Kyle Hall <kylemhall>   07/04/09 14:23:27

Modified files:
        circ           : returns.pl 

Log message:
        Added itemnotes to the ri loop

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/circ/returns.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.37.2.6.2.3&r2=1.37.2.6.2.4

Patches:
Index: returns.pl
===================================================================
RCS file: /sources/koha/koha/circ/returns.pl,v
retrieving revision 1.37.2.6.2.3
retrieving revision 1.37.2.6.2.4
diff -u -b -r1.37.2.6.2.3 -r1.37.2.6.2.4
--- returns.pl  9 Apr 2007 14:20:03 -0000       1.37.2.6.2.3
+++ returns.pl  9 Apr 2007 14:23:27 -0000       1.37.2.6.2.4
@@ -1,213 +1,504 @@
-<!-- TMPL_INCLUDE NAME="head.inc" -->
-<!-- TMPL_INCLUDE NAME="body-top.inc" -->
-<!-- TMPL_INCLUDE NAME="body-top-circ.inc" -->
-
-<div id="subTab-1">
-       <a href="/cgi-bin/koha/circ/circulation.pl">
-               <img src="<!-- TMPL_VAR NAME='themelang' 
-->/images/subTab-circulation-issues-unselected.png" border="0" />
-       </a>
-</div>
-
-<div id="subTab-2">
-       <a href="/cgi-bin/koha/circ/returns.pl">
-               <img src="<!-- TMPL_VAR NAME='themelang' 
-->/images/subTab-circulation-returns-selected.png" border="0" />
-       </a>
-</div>
-
-<div id="subTab-3">
-       <a href="/cgi-bin/koha/circ/branchtransfers.pl">
-               <img src="<!-- TMPL_VAR NAME='themelang' 
-->/images/subTab-circulation-transfers-unselected.png" border="0" />
-       </a>
-</div>
-
-<div id="subTab-4">
-       <a href="/cgi-bin/koha/circ/reserve.pl">
-               <img src="<!-- TMPL_VAR NAME='themelang' 
-->/images/subTab-circulation-reservesPending-unselected.png" border="0" />
-       </a>
-</div>
-
-<dl class="bodyPane">
-<dt class="bodyPane">Circulation: Returns</dt>
-<dd class="bodyPane">
-       <br />
-
-<div id="main">
-<!-- TMPL_IF Name="found" -->
-               <h3 class="alert">Reserve Found<!-- TMPL_IF Name="waiting" --> 
(item is already <em>consigned</em>) <!-- /TMPL_IF --></h3>
-               <!-- TMPL_IF Name="waiting" -->
-               <div class="items">
-               <table>
-               <caption><a href="/cgi-bin/koha/detail.pl?type=intra&bib=<!-- 
TMPL_VAR NAME="itembiblionumber" -->"><!-- TMPL_VAR Name="itemtitle" 
--></a></caption>
-               <tr><th>Patron: </th><td>
-                       <ul>
-                                               <li><a 
href="/cgi-bin/koha/members/moremember.pl?bornum=<!-- TMPL_VAR NAME="bornum" 
-->"><!-- TMPL_VAR Name="borcnum" --></a></li>
-                       <li><!-- TMPL_VAR Name="borsurname" -->, <!-- TMPL_VAR 
Name="borfirstname" --> </li>
-                       <li><!-- TMPL_VAR Name="borstraddress" --><br />
-                       <!-- TMPL_VAR Name="borcity" -->  <!-- TMPL_VAR 
NAME="borzip" --></li>
-                       <li><!-- TMPL_VAR Name="borphone" --></li>
-<!-- TMPL_IF NAME="boremail" --><li><!-- TMPL_UNLESS NAME="intransit" --><a 
id="reserveemail" href="mailto:<!-- TMPL_VAR Name="boremail" -->"><!-- 
/TMPL_UNLESS --><!-- TMPL_VAR Name="boremail" --><!-- TMPL_UNLESS 
NAME="intransit" --></a><!-- /TMPL_UNLESS --></li><!-- /TMPL_IF -->
-<!-- TMPL_IF NAME="debarred" --><li class="error">Patron is DEBARRED</li><!-- 
/TMPL_IF -->
-<!-- TMPL_IF NAME="gonenoaddress" --><li class="error">Patron's address is in 
doubt</li><!-- /TMPL_IF -->
-                       </ul></td></tr>
-       <tr><!-- TMPL_IF NAME="intransit" 
--><th>&nbsp;</th><td><strong>Transfer</strong> to <!-- TMPL_VAR 
Name="tobranchname" --> </td><!-- TMPL_ELSE 
--><th>&nbsp;</th><td><strong>Hold</strong> in <!-- TMPL_VAR 
Name="tobranchname" --></td><!-- /TMPL_IF --></tr>
-               </table></div><form method="post" action="returns.pl" 
name="mainform" id="mainform">
-                       <input type="submit" value="Confirm" class="submit" />
-                       <input type="hidden" name="bornum" id="bornum" 
value="<!-- TMPL_VAR name="bornum" -->" />
-                       <input type="hidden" name="itembiblionumber" 
id="itembiblionumber" value="<!-- TMPL_VAR name="itembiblionumber" -->" /><!-- 
TMPL_LOOP Name="inputloop" -->
-                               
-                               <input type="hidden" name="ri-<!-- TMPL_VAR 
Name="counter" -->" value="<!-- TMPL_VAR Name="barcode" -->" />
-                               <input type="hidden" name="dd-<!-- TMPL_VAR 
Name="counter" -->" value="<!-- TMPL_VAR Name="duedate" -->" />
-                               <input type="hidden" name="bn-<!-- TMPL_VAR 
Name="counter" -->" value="<!-- TMPL_VAR Name="bornum" -->" />
-                       <!-- /TMPL_LOOP -->
-                       <input type="hidden" name="barcode" value="0" />
-                       </form>
-               
-                       
-               <!-- /TMPL_IF -->
-               <!-- TMPL_IF Name="diffbranch" -->
-                       <h3>Item Consigned:</h3><br>
-       <div class="item">
-               <table>
-               <caption><a href="/cgi-bin/koha/detail.pl?type=intra&bib=<!-- 
TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR Name="itemtitle" 
--></a></caption>
-               <tr><th>Patron:</th><td><!-- TMPL_VAR Name="name" --></td></tr>
-               </table></div><form method="post" action="returns.pl" 
name="mainform" id="mainform"><input type="submit" value="OK" />
-                       <!-- TMPL_LOOP Name="inputloop" -->
-                               <!-- TMPL_UNLESS Name="first" -->
-                                       <input type="hidden" name="ri-<!-- 
TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="barcode" -->" />
-                                       <input type="hidden" name="dd-<!-- 
TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="duedate" -->" />
-                                       <input type="hidden" name="bn-<!-- 
TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="bornum" -->" />
-                               <!-- /TMPL_UNLESS -->
-                       <!-- /TMPL_LOOP -->
-                       <input type="hidden" name="barcode" value="0" />
-                       
-                       </form>
-               
-
-               <!-- /TMPL_IF -->
-               <!-- TMPL_IF Name="reserved" -->
-                       <div class="items">
-                       <table>
-                       <caption><a 
href="/cgi-bin/koha/detail.pl?type=intra&bib=<!-- TMPL_VAR 
NAME="itembiblionumber" -->"><!-- TMPL_VAR Name="itemtitle" --></a></caption>
-                       <tr><th>Patron: </th><td>
-                       <ul>
-                                               <li><a 
href="/cgi-bin/koha/members/moremember.pl?bornum=<!-- TMPL_VAR NAME="bornum" 
-->"><!-- TMPL_VAR Name="borcnum" --></a></li>
-                       <li><!-- TMPL_VAR Name="borsurname" -->, <!-- TMPL_VAR 
Name="borfirstname" --> </li>
-                       <li><!-- TMPL_VAR Name="borstraddress" --><br />
-                       <!-- TMPL_VAR Name="borcity" --> <!-- TMPL_VAR 
NAME="borzip" --></li>
-                       <li><!-- TMPL_VAR Name="borphone" --></li>
-                       <!-- TMPL_IF NAME="boremail" --><li><!-- TMPL_UNLESS 
NAME="intransit" --><a id="reserveemail" href="mailto:<!-- TMPL_VAR 
Name="boremail" -->"><!-- /TMPL_UNLESS --><!-- TMPL_VAR Name="boremail" --><!-- 
TMPL_UNLESS NAME="intransit" --></a><!-- /TMPL_UNLESS --></li><!-- /TMPL_IF -->
-<!-- TMPL_IF NAME="debarred" --><li class="error">Patron is DEBARRED</li><!-- 
/TMPL_IF -->
-<!-- TMPL_IF NAME="gonenoaddress" --><li class="error">Patron's address is in 
doubt</li><!-- /TMPL_IF -->
-                       </ul></td></tr>
-                       <tr><!-- TMPL_IF NAME="intransit" 
--><th>&nbsp;</th><td><strong>Transfer</strong> to <!-- TMPL_VAR 
Name="tobranchname" --> </td><!-- TMPL_ELSE 
--><th>&nbsp;</th><td><strong>Hold</strong> in <!-- TMPL_VAR 
Name="tobranchname" --></td><!-- /TMPL_IF --></tr></table>
-                       </div> <form method="post" action="returns.pl" 
name="mainform" id="mainform">
-                       <input type="submit" class="submit" value="Confirm" />
-                       <input type="hidden" name="bornum" id="bornum" 
value="<!-- TMPL_VAR name="bornum" -->" />
-                       <input type="hidden" name="itembiblionumber" 
id="itembiblionumber" value="<!-- TMPL_VAR name="itembiblionumber" -->" />
-                       <!-- TMPL_LOOP Name="inputloop" -->
-                               <input type="hidden" name="ri-<!-- TMPL_VAR 
Name="counter" -->" value="<!-- TMPL_VAR Name="barcode" -->" />
-                               <input type="hidden" name="dd-<!-- TMPL_VAR 
Name="counter" -->" value="<!-- TMPL_VAR Name="duedate" -->" />
-                               <input type="hidden" name="bn-<!-- TMPL_VAR 
Name="counter" -->" value="<!-- TMPL_VAR Name="bornum" -->" />
-                       <!-- /TMPL_LOOP -->
-                       <input type="hidden" name="itemnumber" value="<!-- 
TMPL_VAR Name="itemnumber" -->" />
-                       <input type="hidden" name="borrowernumber" value="<!-- 
TMPL_VAR Name="bornum" -->" />
-                       <input type="hidden" name="resbarcode" value="<!-- 
TMPL_VAR Name="barcode" -->" /></form>
-               <!-- /TMPL_IF -->
-       
-<!-- TMPL_ELSE -->
-<h1>Circulation: Returns</h1>
-       <div class="details">
-       <form method="post" action="/cgi-bin/koha/circ/returns.pl"  
name="mainform" id="mainform">
-                       <label for="barcode">Enter Item Barcode</label>
-                       <input name="barcode" id="barcode" size="14" 
maxlength="14" class="unfocus" onfocus="this.className='focus'" 
onblur="this.className='unfocus'" />
-                       <input type="submit" class="submit" value="Submit" />
-                       <!-- TMPL_LOOP Name="inputloop" -->
-                               <input type="hidden" name="ri-<!-- TMPL_VAR 
Name="counter" -->" value="<!-- TMPL_VAR Name="barcode" -->" />
-                               <input type="hidden" name="dd-<!-- TMPL_VAR 
Name="counter" -->" value="<!-- TMPL_VAR Name="duedate" -->" />
-                               <input type="hidden" name="bn-<!-- TMPL_VAR 
Name="counter" -->" value="<!-- TMPL_VAR Name="bornum" -->" />
-                       <!-- /TMPL_LOOP -->
-               </form><!-- TMPL_IF NAME="errmsgloop" --><!-- TMPL_LOOP 
Name="errmsgloop" -->
-                               <div class="error">
-                               <!-- TMPL_IF Name="badbarcode" -->
-                                       No Item with barcode: <!-- TMPL_VAR 
Name="msg" -->
-                               <!-- /TMPL_IF -->
-                               <!-- TMPL_IF Name="ispermanent" -->
-                                       Please return to  <!-- TMPL_VAR 
Name="msg" -->
-                               <!-- /TMPL_IF -->
-                               <!-- TMPL_IF Name="notissued" -->
-                                       Not Checked Out.
-                               <!-- /TMPL_IF -->
-                               <!-- TMPL_IF Name="waslost" -->
-                                       Item was lost, now found.
-                               <!-- /TMPL_IF -->
-                               <!-- TMPL_IF Name="withdrawn" -->
-                                       Item Cancelled
-                               <!-- /TMPL_IF -->
-                               </div>
-                       <!-- /TMPL_LOOP --><!-- /TMPL_IF -->
-</div>
-<!-- /TMPL_IF -->
-
-<!-- TMPL_IF Name="returned" -->
-<div class="table"><table>
-               <tr><th>Item Information</th><th>Patron Information</th></tr>
-               <tr><td><!-- TMPL_VAR Name="itemtitle" -->
-               </td><td><div class="flags">
-<a href="/cgi-bin/koha/members/moremember.pl?bornum=<!-- TMPL_VAR 
Name="ribornum" -->"><!-- TMPL_VAR Name="riborcnum" --></a>
-               <!-- TMPL_VAR Name="riborsurname" -->, <!-- TMPL_VAR 
Name="ribortitle" --> <!-- TMPL_VAR Name="riborfirstname" -->
-
-<!-- removed: removed-from-returns.tmpl -->
-<!-- TMPL_IF Name="flagset" -->
- (<!-- TMPL_LOOP Name="flagloop" -->
-<span class="error"><!-- TMPL_VAR Name="flag" -->, </span>
-<!-- /TMPL_LOOP -->)<!-- /TMPL_IF --></div>
-</td></tr></table>
-</div>
-<!-- /TMPL_IF -->
-
-
-
-<!-- TMPL_IF Name="riloop" -->
-<div class="table">
-               <table>
-               <caption>Returned Items</caption>
-               <tr>
-                  <th>Due Date</th>
-                  <th>Bar Code</th>
-                  <th>Title</th>
-                  <th>Author</th>
-                  <th>Type</th>
-                  <th>Patron</th>
-                  <th>Notes</th>
-                </tr>
-               <!-- TMPL_LOOP Name="riloop" -->
-                       <tr><td><!-- TMPL_IF Name="duedate" --><!-- TMPL_IF 
Name="early" --><span class="error"><!-- /TMPL_IF --><!-- TMPL_VAR 
NAME="duedate" --><!-- TMPL_IF Name="early" --></span><!-- /TMPL_IF --><!-- 
TMPL_ELSE -->Not on Checked Out.<!-- /TMPL_IF --></td>
-                       <td>
-                       <a href="/cgi-bin/koha/detail.pl?bib=<!-- TMPL_VAR 
Name="itembiblionumber" -->&type=intra"><!-- TMPL_VAR Name="barcode" 
--></a></td>
-                       <td><!-- TMPL_VAR Name="itemtitle" --><br /></td>
-                       <td><!-- TMPL_VAR Name="itemauthor" --></td>
-                       <td><!-- TMPL_VAR Name="ccode" --></td>
-                       <td>
-                       <!-- TMPL_IF Name="duedate" -->
-                               <a 
href="/cgi-bin/koha/members/moremember.pl?bornum=<!-- TMPL_VAR Name="bornum" 
-->">
-                                       <!-- TMPL_VAR Name="borcnum" -->
-                               </a> <!-- TMPL_VAR Name="borsurname" -->, <!-- 
TMPL_VAR Name="borfirstname" --> 
-                       <!-- TMPL_ELSE -->
-                       Not on Checked Out.
-                       <!-- /TMPL_IF -->
-                       </td>
-                        <td><i><!-- TMPL_VAR name="itemnotes" --></i></td>
-                        </tr>
-               <!-- /TMPL_LOOP -->
-               </table>
-               </div>
-<!-- /TMPL_IF -->
-
-</div>
-
-</div>
-</dd>
-</dl>
-</body>
-</html>
-
+#!/usr/bin/perl
+# WARNING: This file contains mixed-sized tabs! (some 4-character, some 8)
+# WARNING: Currently, 4-character tabs seem to be dominant
+# WARNING: But there are still lots of 8-character tabs
+
+#written 11/3/2002 by Finlay
+#script to execute returns of books
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+use PrintR;
+
+use strict;
+
+use CGI;
+use HTML::Template;
+use Data::Dumper;
+
+use C4::Circulation::Circ2;
+#use C4::Date;
+use C4::Search;
+use C4::Output;
+use C4::Print;
+use C4::Reserves2;
+use C4::Auth;
+use C4::Interface::CGI::Output;
+use C4::Koha;
+
+my $query = new CGI;
+
+#getting the template
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+    {
+        template_name   => "circ/returns.tmpl",
+        query           => $query,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { circulate => 1 },
+    }
+);
+
+#####################
+#Global vars
+my %env;
+my $headerbackgroundcolor = '#99cc33';
+my $linecolor1            = '#ffffcc';
+my $linecolor2            = 'white';
+
+my $branches = getbranches();
+my $printers = getprinters( \%env );
+
+my $branch  = getbranch( $query,  $branches );
+my $printer = getprinter( $query, $printers );
+
+#
+# Some code to handle the error if there is no branch or printer setting.....
+#
+
+$env{'branchcode'} = $branch;
+$env{'printer'}    = $printer;
+$env{'queue'}      = $printer;
+
+# Set up the item stack ....
+my %returneditems;
+my %riduedate;
+my %riborrowernumber;
+my @inputloop;
+foreach ( $query->param ) {
+    (next) unless (/ri-(\d*)/);
+    my %input;
+    my $counter = $1;
+    (next) if ( $counter > 20 );
+    my $barcode        = $query->param("ri-$counter");
+    my $duedate        = $query->param("dd-$counter");
+    my $borrowernumber = $query->param("bn-$counter");
+    $counter++;
+
+    # decode cuecat
+    $barcode = cuecatbarcodedecode($barcode);
+
+
+    ######################
+    #Are these lines still useful ?
+    $returneditems{$counter}    = $barcode;
+    $riduedate{$counter}        = $duedate;
+    $riborrowernumber{$counter} = $borrowernumber;
+
+    #######################
+    $input{counter} = $counter;
+    $input{barcode} = $barcode;
+    $input{duedate} = $duedate;
+    $input{bornum}  = $borrowernumber;
+    push ( @inputloop, \%input );
+}
+
+############
+# Deal with the requests....
+if ( $query->param('resbarcode') ) {
+    my $item       = $query->param('itemnumber');
+    my $borrnum    = $query->param('borrowernumber');
+    my $resbarcode = $query->param('resbarcode');
+
+    # set to waiting....
+    my $iteminfo = getiteminformation( \%env, $item );
+    my $tobranchcd = ReserveWaiting( $item, $borrnum );
+    my $branchname = $branches->{$tobranchcd}->{'branchname'};
+    my ($borr) = getpatroninformation( \%env, $borrnum, 0 );
+    my $borcnum = $borr->{'cardnumber'};
+    my $name    =
+      $borr->{'surname'} . " " . $borr->{'title'} . " " . $borr->{'firstname'};
+    my $slip = $query->param('resslip');
+#    printslip( \%env, $slip ); #removed by paul
+
+    if ( $tobranchcd ne $branch ) {
+        $template->param(
+            itemtitle  => $iteminfo->{'title'},
+            iteminfo   => $iteminfo->{'author'},
+            tobranchname => $branchname,
+            name       => $name,
+            bornum     => $borrnum,
+            borcnum    => $borcnum,
+            diffbranch => 1
+        );
+    }
+}
+
+my $iteminformation;
+my $borrower;
+my $returned = 0;
+my $messages;
+my $barcode = $query->param('barcode');
+
+# actually return book and prepare item table.....
+if ($barcode) {
+
+    #CCFLS ONLY
+    system "php /usr/local/koha/intranet/htdocs/ccflsFines/createFine.php 
$barcode";
+
+    # decode cuecat
+    $barcode = cuecatbarcodedecode($barcode);
+    ( $returned, $messages, $iteminformation, $borrower ) = returnbook( 
$barcode, $branch );
+    if ($returned) {
+        $returneditems{0}    = $barcode;
+        $riborrowernumber{0} = $borrower->{'borrowernumber'};
+        $riduedate{0}        = $iteminformation->{'date_due'};
+        my %input;
+        $input{counter} = 0;
+        $input{first}   = 1;
+        $input{barcode} = $barcode;
+        $input{duedate} = $riduedate{0};
+        $input{bornum}  = $riborrowernumber{0};
+        push ( @inputloop, \%input );
+    }
+    elsif ( !$messages->{'BadBarcode'} ) {
+        my %input;
+        $input{counter} = 0;
+        $input{first}   = 1;
+        $input{barcode} = $barcode;
+        $input{duedate} = 0;
+
+        $returneditems{0} = $barcode;
+        $riduedate{0}     = 0;
+        if ( $messages->{'wthdrawn'} ) {
+            $input{withdrawn} = 1;
+            $input{bornum}    = "Item Cancelled";
+            $riborrowernumber{0} = 'Item Cancelled';
+        }
+        else {
+            $input{bornum} = "&nbsp;";
+            $riborrowernumber{0} = '&nbsp;';
+        }
+        push ( @inputloop, \%input );
+    }
+    $template->param(
+        returned  => $returned,
+        itemtitle => $iteminformation->{'title'},
+
+        #                                                                      
itembc => $iteminformation->{'barcode'},
+        #                                                                      
itemdatedue => $iteminformation->{'datedue'},
+        itemauthor => $iteminformation->{'author'}
+    );
+}
+$template->param( inputloop => address@hidden );
+
+my $found    = 0;
+my $waiting  = 0;
+my $reserved = 0;
+
+if ( $messages->{'ResFound'} ) {
+    my $res        = $messages->{'ResFound'};
+    my $branchname = $branches->{ $res->{'branchcode'} }->{'branchname'};
+    my ($borr) = getpatroninformation( \%env, $res->{'borrowernumber'}, 0 );
+    my $name =
+      $borr->{'surname'} . " " . $borr->{'title'} . " " . $borr->{'firstname'};
+    my ($iteminfo) = getiteminformation( \%env, 0, $barcode );
+
+    if ( $res->{'ResFound'} eq "Waiting" ) {
+               if($branch eq $res->{'branchcode'}){
+                       $template->param(intransit => 0);
+               } else {
+                       $template->param(intransit => 1);
+               }
+       
+        $template->param(
+            found         => 1,
+            name          => $name,
+            borfirstname  => $borr->{'firstname'},
+            borsurname    => $borr->{'surname'},
+            bortitle      => $borr->{'title'},
+            borphone      => $borr->{'phone'},
+            boremail         => $borr->{'emailaddress'},
+            borstraddress => $borr->{'streetaddress'},
+            borcity       => $borr->{'city'},
+            borzip        => $borr->{'zipcode'},
+            bornum        => $res->{'borrowernumber'},
+            borcnum       => $borr->{'cardnumber'},
+                       debarred => $borr->{'debarred'},
+                       gonenoaddress => $borr->{'gonenoaddress'},
+                       currentbranch => $branches->{ $branch }->{'branchname'},
+            tobranchname  => $branches->{ $res->{'branchcode'} 
}->{'branchname'},
+            waiting     => 1,
+            itemnumber  => $res->{'itemnumber'},
+            itemtitle   => $iteminfo->{'title'},
+            itemauthor  => $iteminfo->{'author'},
+            itembarcode => $iteminfo->{'barcode'},
+            itemtype    => $iteminfo->{'itemtype'},
+                       ccode    => $iteminfo->{'ccode'},
+            itembiblionumber => $iteminfo->{'biblionumber'}
+        );
+
+    }
+    if ( $res->{'ResFound'} eq "Reserved" ) {
+        my @da         = localtime( time() );
+        my $todaysdate =
+          sprintf( "%0.2d", ( $da[3] + 1 ) ) . "/"
+          . sprintf( "%0.2d", ( $da[4] + 1 ) ) . "/"
+          . ( $da[5] + 1900 );
+                 
+                if($branch eq $res->{'branchcode'}){
+                       $template->param(intransit => 0);
+               } else {
+                       $template->param(intransit => 1);
+               }
+                 
+        $template->param(
+            found       => 1,
+                       currentbranch => $branches->{ $branch }->{'branchname'},
+            tobranchname  => $branches->{ $res->{'branchcode'} 
}->{'branchname'},
+            reserved    => 1,
+            today       => $todaysdate,
+            itemnumber  => $res->{'itemnumber'},
+            itemtitle   => $iteminfo->{'title'},
+            itemauthor  => $iteminfo->{'author'},
+            itembarcode => $iteminfo->{'barcode'},
+            itemtype    => $iteminfo->{'itemtype'},
+                       ccode    => $iteminfo->{'ccode'},
+            itembiblionumber => $iteminfo->{'biblionumber'},
+            borsurname       => $borr->{'surname'},
+            bortitle         => $borr->{'title'},
+            borfirstname     => $borr->{'firstname'},
+            bornum           => $res->{'borrowernumber'},
+            borcnum          => $borr->{'cardnumber'},
+            borphone         => $borr->{'phone'},
+            borstraddress    => $borr->{'streetaddress'},
+            borsub           => $borr->{'suburb'},
+            borcity          => $borr->{'city'},
+            borzip           => $borr->{'zipcode'},
+            boremail         => $borr->{'emailaddress'},
+                       debarred => $borr->{'debarred'},
+                       gonenoaddress => $borr->{'gonenoaddress'},
+            barcode          => $barcode
+        );
+    }
+}
+
+# Error Messages
+my @errmsgloop;
+foreach my $code ( keys %$messages ) {
+
+    #    warn $code;
+    my %err;
+    my $exit_required_p = 0;
+    if ( $code eq 'BadBarcode' ) {
+        $err{badbarcode} = 1;
+        $err{msg}        = $messages->{'BadBarcode'};
+    }
+    elsif ( $code eq 'NotIssued' ) {
+        $err{notissued} = 1;
+        $err{msg} = $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
+    }
+    elsif ( $code eq 'WasLost' ) {
+        $err{waslost} = 1;
+    }
+    elsif ( $code eq 'ResFound' ) {
+        ;    # FIXME... anything to do here?
+    }
+    elsif ( $code eq 'WasReturned' ) {
+        ;    # FIXME... anything to do here?
+    }
+    elsif ( $code eq 'WasTransfered' ) {
+        ;    # FIXME... anything to do here?
+    }
+    elsif ( $code eq 'wthdrawn' ) {
+        $err{withdrawn} = 1;
+        $exit_required_p = 1;
+    }
+    elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) {
+        if ( $messages->{'IsPermanent'} ne $branch ) {
+            $err{ispermanent} = 1;
+            $err{msg}         =
+              $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
+        }
+    }
+    else {
+        die "Unknown error code $code";    # XXX
+    }
+    if (%err) {
+        push ( @errmsgloop, \%err );
+    }
+    last if $exit_required_p;
+}
+$template->param( errmsgloop => address@hidden );
+
+# patrontable ....
+if ($borrower) {
+    my $flags = $borrower->{'flags'};
+    my $color = '';
+    my @flagloop;
+    my $flagset;
+    foreach my $flag ( sort keys %$flags ) {
+        my %flaginfo;
+        ( $color eq $linecolor1 ) 
+          ? ( $color = $linecolor2 )
+          : ( $color = $linecolor1 );
+        unless ($flagset) { $flagset = 1; }
+        $flaginfo{color}   = $color;
+        $flaginfo{redfont} = ( $flags->{$flag}->{'noissues'} );
+        $flaginfo{flag}    = $flag;
+        if ( $flag eq 'CHARGES' ) {
+            $flaginfo{msg}     = $flag;
+            $flaginfo{charges} = 1;
+           $flaginfo{bornum} = $borrower->{borrowernumber};
+        }
+        elsif ( $flag eq 'WAITING' ) {
+            $flaginfo{msg}     = $flag;
+            $flaginfo{waiting} = 1;
+            my @waitingitemloop;
+            my $items = $flags->{$flag}->{'itemlist'};
+            foreach my $item (@$items) {
+                my ($iteminformation) =
+                  getiteminformation( \%env, $item->{'itemnumber'}, 0 );
+                my %waitingitem;
+                $waitingitem{biblionum} = $iteminformation->{'biblionumber'};
+                $waitingitem{barcode}   = $iteminformation->{'barcode'};
+                $waitingitem{title}     = $iteminformation->{'title'};
+                $waitingitem{brname}    =
+                  $branches->{ $iteminformation->{'holdingbranch'} }->{
+                  'branchname'};
+                push ( @waitingitemloop, \%waitingitem );
+            }
+            $flaginfo{itemloop} = address@hidden;
+        }
+        elsif ( $flag eq 'ODUES' ) {
+            my $items = $flags->{$flag}->{'itemlist'};
+            my @itemloop;
+            foreach my $item ( sort { $a->{'date_due'} cmp $b->{'date_due'} }
+                @$items )
+            {
+                my ($iteminformation) =
+                  getiteminformation( \%env, $item->{'itemnumber'}, 0 );
+                my %overdueitem;
+                $overdueitem{duedate}   = $item->{'date_due'}; 
#format_date($item->{'date_due'});
+                $overdueitem{biblionum} = $iteminformation->{'biblionumber'};
+                $overdueitem{barcode}   = $iteminformation->{'barcode'};
+                $overdueitem{title}     = $iteminformation->{'title'};
+                $overdueitem{brname}    =
+                  $branches->{ $iteminformation->{'holdingbranch'} }->{
+                  'branchname'};
+                push ( @itemloop, \%overdueitem );
+            }
+            $flaginfo{itemloop} = address@hidden;
+            $flaginfo{overdue}  = 1;
+        }
+        else {
+            $flaginfo{other} = 1;
+            $flaginfo{msg}   = $flags->{$flag}->{'message'};
+        }
+        push ( @flagloop, \%flaginfo );
+    }
+    $template->param(
+        flagset        => $flagset,
+        flagloop       => address@hidden,
+        ribornum       => $borrower->{'borrowernumber'},
+        riborcnum      => $borrower->{'cardnumber'},
+        riborsurname   => $borrower->{'surname'},
+        ribortitle     => $borrower->{'title'},
+        riborfirstname => $borrower->{'firstname'}
+    );
+}
+
+my $color = '';
+
+#set up so only the last 8 returned items display (make for faster loading 
pages)
+my $count = 0;
+my @riloop;
+foreach ( sort { $a <=> $b } keys %returneditems ) {
+    my %ri;
+    if ( $count < 8 ) {
+        ( $color eq $linecolor1 ) 
+          ? ( $color = $linecolor2 )
+          : ( $color = $linecolor1 );
+        $ri{color} = $color;
+        my $barcode = $returneditems{$_};
+        my $duedate = $riduedate{$_};
+        my $overduetext;
+        my $borrowerinfo;
+        if ($duedate) {
+            my @tempdate = split ( /-/, $duedate );
+           $ri{year}=$tempdate[0];
+           $ri{month}=$tempdate[1];
+           $ri{day}=$tempdate[2];
+            my $duedatenz  = "$tempdate[2]/$tempdate[1]/$tempdate[0]";
+            my @datearr    = localtime( time() );
+            my $todaysdate =
+              $datearr[5] . '-'
+              . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
+              . sprintf( "%0.2d", $datearr[3] );
+           $ri{duedate}=$duedate; #format_date($duedate);
+            my ($borrower) =
+              getpatroninformation( \%env, $riborrowernumber{$_}, 0 );
+            $ri{bornum}       = $borrower->{'borrowernumber'};
+            $ri{borcnum}      = $borrower->{'cardnumber'};
+            $ri{borfirstname} = $borrower->{'firstname'};
+            $ri{borsurname}   = $borrower->{'surname'};
+            $ri{bortitle}     = $borrower->{'title'};
+        }
+        else {
+            $ri{bornum} = $riborrowernumber{$_};
+        }
+#        my %ri;
+        my ($iteminformation) = getiteminformation( \%env, 0, $barcode );
+        $ri{color}            = $color;
+        $ri{itembiblionumber} = $iteminformation->{'biblionumber'};
+        $ri{itemtitle}        = $iteminformation->{'title'};
+        $ri{itemauthor}       = $iteminformation->{'author'};
+        $ri{itemtype}         = $iteminformation->{'itemtype'};
+       $ri{ccode}            = $iteminformation->{'ccode'};
+        $ri{barcode}          = $barcode;
+        $ri{itemnotes}        = $iteminformation->{'itemnotes'};
+
+    }
+    else {
+        last;
+    }
+    $count++;
+    push ( @riloop, \%ri );
+}
+$template->param( riloop => address@hidden );
+
+$template->param(
+    genbrname  => $branches->{$branch}->{'branchname'},
+    genprname  => $printers->{$printer}->{'printername'},
+    branchname     => $branches->{$branch}->{'branchname'},
+    printer    => $printer,
+    errmsgloop => address@hidden,
+    intranetcolorstylesheet => 
C4::Context->preference("intranetcolorstylesheet"),
+       intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+       IntranetNav => C4::Context->preference("IntranetNav"),
+);
+
+# actually print the page!
+output_html_with_http_headers $query, $cookie, $template->output;
+
+sub cuecatbarcodedecode {
+    my ($barcode) = @_;
+    chomp($barcode);
+    my @fields = split ( /\./, $barcode );
+    my @results = map( decode($_), @fields[ 1 .. $#fields ] );
+    if ( $#results == 2 ) {
+        return $results[2];
+    }
+    else {
+        return $barcode;
+    }
+}
+
+# Local Variables:
+# tab-width: 4
+# End:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]