koha-cvs
[Top][All Lists]
Advanced

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

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


From: Joshua Ferraro
Subject: [Koha-cvs] koha/circ circulation.pl [dev_week]
Date: Thu, 05 Oct 2006 23:23:50 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         dev_week
Changes by:     Joshua Ferraro <kados>  06/10/05 23:23:50

Modified files:
        circ           : circulation.pl 

Log message:
        fix for Bug #1196: Circulation screen should display item type counts, 
limits, and warnings

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/circ/circulation.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.81.2.14.2.8&r2=1.81.2.14.2.9

Patches:
Index: circulation.pl
===================================================================
RCS file: /sources/koha/koha/circ/circulation.pl,v
retrieving revision 1.81.2.14.2.8
retrieving revision 1.81.2.14.2.9
diff -u -b -r1.81.2.14.2.8 -r1.81.2.14.2.9
--- circulation.pl      5 Oct 2006 21:23:00 -0000       1.81.2.14.2.8
+++ circulation.pl      5 Oct 2006 23:23:50 -0000       1.81.2.14.2.9
@@ -202,14 +202,12 @@
 my @realprevissues;
 my $allowborrow;
 
-#ADDED BY JF FOR AV COUNT
-my ($videocount, $musiccdcount, $audiobookcount);
-my ($videoflag, $videoleftcount);
-my ($musiccdflag, $musiccdleftcount);
-my ($audiobookflag, $audiobookleftcount);
-my $avcount;  # Added by JF to check AVs
-my $avflag;   # ADDED BY JF for AV COUNT
-my $avleftcount; # ADDED BY JF FOR AV COUNT
+## ADDED BY JF: new itemtype issuingrules counter stuff
+my $issued_itemtypes_loop;
+my $issued_itemtypes_count;
+my $issued_itemtypes_allowed_count; # hashref with total allowed by itemtype
+my $issued_itemtypes_remaining; # hashref with remaining
+my $issued_itemtypes_flags; #hashref that stores flags
 
 if ($borrower) {
 # get each issue of the borrower & separate them in todayissues & previous 
issues
@@ -221,7 +219,7 @@
                my $issuedate = $issueslist->{$it}->{'timestamp'};
                $issuedate =~ s/-//g;
                $issuedate = substr($issuedate, 0, 8);
-               warn "today: $todaysdate issue: $issuedate";
+#              warn "today: $todaysdate issue: $issuedate";
                if ($todaysdate == $issuedate) {
                        push @todaysissues, $issueslist->{$it};
                } else {
@@ -234,29 +232,8 @@
        # parses today & build Template array
        foreach my $book (sort {$b->{'timestamp'} <=> $a->{'timestamp'}} 
@todaysissues){
 
-
-                # ADDED BY JF  Check AVs
-                my $bt = $book->{'ccode'};
-                #warn "here's bt:".$bt;
-                #if ($bt eq "Audiobook" or $bt eq "Audiobook (cassette)" or 
$bt eq "Videocassette" or $bt eq "Videocassette, juvenile non-fiction" or $bt 
eq "Videocassette, juvenile" or $bt eq "Videocassette, non-fiction" or $bt eq 
"Music CD" or $bt eq "Video disc") {
-
-                # Limit to 10 AV, AVJ, AVJN, AVNF, and DVD;
-                if ($bt eq "Videocassette" or $bt eq "Videocassette, juvenile 
non-fiction" or $bt eq "Videocassette, juvenile" or $bt eq "Videocassette, 
non-fiction" or $bt eq "Video disc") {
-                $videocount++;
-
-                # Limit to 10 CDM
-                } elsif ($bt eq "Music CD") {
-                $musiccdcount++;
-
-                # Limit to 10 AB, AC, JAC, and YAC
-                } elsif ($bt eq "Audiobook" or $bt eq "Audiobook (cassette)") {
-                $audiobookcount++;
-                }
-                # /ADDED BY JF end of Check AVs
-
-
-
-
+               # ADDED BY JF: NEW ITEMTYPE COUNT DISPLAY
+               $issued_itemtypes_count->{$book->{'itemtype'}}++;
        
                my $dd = $book->{'date_due'};
                my $datedue = $book->{'date_due'};
@@ -286,20 +263,8 @@
        $i = 0;
     foreach my $book (sort {$a->{'date_due'} cmp $b->{'date_due'}} 
@previousissues){
 
-                               # ADDED BY JF  Check AVs
-                my $bt = $book->{'ccode'};
-                # Limit to 10 AV, AVJ, AVJN, AVNF, and DVD;
-                if ($bt eq "Videocassette" or $bt eq "Videocassette, juvenile 
non-fiction" or $bt eq "Videocassette, juvenile" or $bt eq "Videocassette, 
non-fiction" or $bt eq "Video disc") {
-                $videocount++;
-
-                # Limit to 10 CDM
-                } elsif ($bt eq "Music CD") {
-                $musiccdcount++;
-
-                # Limit to 10 AB, AC, JAC, and YAC
-                } elsif ($bt eq "Audiobook" or $bt eq "Audiobook (cassette)") 
{                $audiobookcount++;
-                }
-                # /ADDED BY JF end of Check AVs
+               # ADDED BY JF: NEW ITEMTYPE COUNT DISPLAY
+               $issued_itemtypes_count->{$book->{'itemtype'}}++;
 
                my $dd = $book->{'date_due'};
                my $datedue = $book->{'date_due'};
@@ -328,31 +293,32 @@
        }
 }
 
-
-# ADDED BY JF Check the number of Videos and work some magic
- $videoleftcount = 10;
- if ($videocount >= 10) {
- $videoleftcount = 0;
- $videoflag = 1;
- } elsif ($videocount >= 1){
- $videoleftcount = 10 - $videocount;
- }
-# ADDED BY JF Check the number of Music CDs and work some magic
- $musiccdleftcount = 10;
- if ($musiccdcount >= 10) {
- $musiccdleftcount = 0;
- $musiccdflag = 1;
- } elsif ($musiccdcount >= 1){
- $musiccdleftcount = 10 - $musiccdcount;
- }
-# ADDED BY JF Check the number of Audiobooks and work some magic
- $audiobookleftcount = 10;
- if ($audiobookcount >= 10) {
- $audiobookleftcount = 0;
- $audiobookflag = 1;
- } elsif ($audiobookcount >= 1){
- $audiobookleftcount = 10 - $audiobookcount;
+#### ADDED BY JF FOR COUNTS BY ITEMTYPE RULES
+# FIXME: This should utilize all the issuingrules options rather than just the 
defaults
+# and it should be moved to a module
+my $dbh = C4::Context->dbh;
+# how many of each is allowed?
+my $issueqty_sth = $dbh->prepare("
+SELECT itemtypes.description AS description,issuingrules.itemtype,maxissueqty  
                                                         FROM issuingrules
+  LEFT JOIN itemtypes ON (itemtypes.itemtype=issuingrules.itemtype)
+  WHERE categorycode=?
+");
+my @issued_itemtypes_count;
+$issueqty_sth->execute("*");
+while (my $data = $issueqty_sth->fetchrow_hashref()) {
+    # subtract how many of each this borrower has
+       $data->{'count'} = $issued_itemtypes_count->{$data->{'description'}};
+    $data->{'left'} = ($data->{'maxissueqty'} - 
$issued_itemtypes_count->{$data->{'description'}});
+       # can't have a negative number of remaining 
+       if ($data->{'left'} < 0) { $data->{'left'} = "0" };
+       $data->{'flag'} = 1 unless ($data->{'maxissueqty'} > $data->{'count'});
+       unless (($data->{'maxissueqty'} < 1) || ($data->{'itemtype'} eq "*") || 
($data->{'itemtype'} eq "CIRC")) {
+       push @issued_itemtypes_count, $data;
  }
+}
+my $issued_itemtypes_loop = address@hidden;
+
+#### / JF
 
 my @values;
 my %labels;
@@ -376,20 +342,7 @@
 my @temp=split(/\$/,$amountold);
 $amountold=$temp[1];
 $template->param(
-
-                               videocount => $videocount,
-                musiccdcount => $musiccdcount,
-                audiobookcount => $audiobookcount,
-                videoflag => $videoflag,
-                videoleftcount => $videoleftcount,
-                musiccdflag => $musiccdflag,
-                musiccdleftcount => $musiccdleftcount,
-                audiobookflag => $audiobookflag,
-                audiobookleftcount => $audiobookleftcount,
-                avcount => $avcount,
-                avleftcount => $avleftcount,
-                avflag => $avflag,
-
+               issued_itemtypes_count_loop => $issued_itemtypes_loop,
                findborrower => $findborrower,
                borrower => $borrower,
                borrowernumber => $borrowernumber,




reply via email to

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