Added variables available to template: streetaddress, city, phone, cardnumber. Added...
[srvgit] / circ / circulation.pl
index 0a898a9..9f34ce5 100755 (executable)
@@ -155,9 +155,13 @@ if ($borrowernumber) {
 ##################################################################################
 # HTML code....
 
-my $responsesform = '';
+my %responseform;
+my @responsearray;
 foreach (keys %responses) {
-    $responsesform.="<input type=hidden name=response-$_ value=$responses{$_}>\n";
+#    $responsesform.="<input type=hidden name=response-$_ value=$responses{$_}>\n";
+    $responseform{'name'}=$_;
+    $responseform{'value'}=$responses{$_};
+    push @responsearray,\%responseform;
 }
 my $questionform;
 my $stickyduedate;
@@ -167,6 +171,10 @@ if ($question) {
 
 
 # Barcode entry box, with hidden inputs attached....
+
+# FIXME - How can we move this HTML into the template?  Can we create
+# arrays of the months, dates, etc and use <TMPL_LOOP> in the template to 
+# output the data that's getting built here?
 my $counter = 1;
 my $dayoptions = '';
 my $monthoptions = '';
@@ -226,12 +234,18 @@ if ($borrower) {
                my $datedue = $book->{'date_due'};
                $dd=format_date($dd);
                $datedue=~s/-//g;
+# FIXME - Instead of declaring the font color here, can we set a variable 
+# that says 'overdue'?  Then the template can check for it: <TMPL_IF
+# NAME="overdue"><font color="red"></TMPL_IF>
                if ($datedue < $todaysdate) {
                        $dd="<font color=red>$dd</font>\n";
                }
                ($tcolor eq $linecolor1) ? ($tcolor=$linecolor2) : ($tcolor=$linecolor1);
                $book->{'dd'}=$dd;
                $book->{'tcolor'}=$tcolor;
+               if ($book->{'author'} eq ''){
+                   $book->{'author'}=' ';
+               }    
                push @realtodayissues,$book;
        }
     
@@ -251,11 +265,15 @@ if ($borrower) {
        my $pcolor = '';
        $datedue=~s/-//g;
        if ($datedue < $todaysdate) {
+# FIXME - See line 233 above regarding overdues
            $dd="<font color=red>$dd</font>\n";
        }
        ($pcolor eq $linecolor1) ? ($pcolor=$linecolor2) : ($pcolor=$linecolor1); 
        $book->{'dd'}=$dd; 
-       $book->{'tcolor'}=$pcolor; 
+       $book->{'tcolor'}=$pcolor;
+       if ($book->{'author'} eq ''){
+           $book->{'author'}=' ';
+       }    
        push @realprevissues,$book
    }
 }
@@ -289,7 +307,6 @@ $template->param(
                branchname => $branches->{$branch}->{'branchname'},
                printername => $printers->{$printer}->{'printername'},
                allowborrow =>$allowborrow,
-
                #question form
                question => $question,
                title => $iteminformation->{'title'},
@@ -297,6 +314,10 @@ $template->param(
                firstname => $borrower->{'firstname'},
                surname => $borrower->{'surname'},
                categorycode => $borrower->{'categorycode'},
+               streetaddress => $borrower->{'streetaddress'},
+               city => $borrower->{'city'},
+               phone => $borrower->{'phone'},
+               cardnumber => $borrower->{'cardnumber'},
                question => $question,
                barcode => $barcode,
                questionnumber => $questionnumber,
@@ -304,14 +325,17 @@ $template->param(
                monthoptions => $monthoptions,
                yearoptions => $yearoptions,
                stickyduedate => $stickyduedate,
-               responseform => $responsesform,
                rejected => $rejected,
                message => $message,
                CGIselectborrower => $CGIselectborrower,
-
                amountold => $amountold,
                todayissues => \@realtodayissues,
-               previssues => \@realprevissues
+               previssues => \@realprevissues,
+               responseloop => \@responsearray,
+                month=>$month,
+                day=>$day,
+                year=>$year
+                
        );
 
 if ($branchcookie) {
@@ -342,6 +366,13 @@ sub fixdate {
     if (($year eq 0) && ($month eq 0) && ($year eq 0)) {
        $env{'datedue'}='';
     } else {
+       
+# FIXME - Can we set two flags here, one that says 'invalidduedate', so that 
+# the template can check for it, and then one for a particular message?
+# Ex: <TMPL_IF NAME="invalidduedate">  <TMPL_IF NAME="daysinFeb">
+# Invalid Due Date Specified. Book was not issued.  Never that many days
+# in February! </TMPL_IF> </TMPL_IF>
+
        if (($year eq 0) || ($month eq 0) || ($year eq 0)) {
            $invalidduedate="Invalid Due Date Specified. Book was not issued.<p>\n";
        } else {
@@ -370,7 +401,7 @@ sub patrontable {
     my $color='';
     foreach $flag (sort keys %$flags) {
        warn $flag;
-       my @itemswaiting='';
+#      my @itemswaiting='';
        ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
        $flags->{$flag}->{'message'}=~s/\n/<br>/g;
        if ($flags->{$flag}->{'noissues'}) {
@@ -393,6 +424,7 @@ sub patrontable {
                }
                if ($flag eq 'WAITING') {
                        my $items=$flags->{$flag}->{'itemlist'};
+                       my @itemswaiting;
                        foreach my $item (@$items) {
                        my ($iteminformation) = getiteminformation(\%env, $item->{'itemnumber'}, 0);
                        $iteminformation->{'branchname'} = $branches->{$iteminformation->{'holdingbranch'}}->{'branchname'};
@@ -414,6 +446,7 @@ sub patrontable {
                        my $currentcolor=$color;
                        {
                        my $color=$currentcolor;
+                           my @itemswaiting;
                        foreach my $item (@$items) {
                                ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
                                my ($iteminformation) = getiteminformation(\%env, $item->{'itemnumber'}, 0);