+ push @previousissues, $issueslist->{$it};
+ }
+ }
+ my $od; # overdues
+ my $i = 0;
+ my $togglecolor;
+
+ # parses today & build Template array
+ foreach my $book ( sort { $b->{'timestamp'} <=> $a->{'timestamp'} }
+ @todaysissues )
+ {
+ my $dd = $book->{'date_due'};
+ my $datedue = $book->{'date_due'};
+ $dd = format_date($dd);
+ $datedue =~ s/-//g;
+ if ( $datedue < $todaysdate ) {
+ $od = 1;
+ }
+ else {
+ $od = 0;
+ }
+ if ( $i % 2 ) {
+ $togglecolor = 0;
+ }
+ else {
+ $togglecolor = 1;
+ }
+ $book->{'togglecolor'} = $togglecolor;
+ $book->{'od'} = $od;
+ $book->{'dd'} = $dd;
+ if ( $book->{'author'} eq '' ) {
+ $book->{'author'} = ' ';
+ }
+ push @realtodayissues, $book;
+ $i++;
+ }
+
+ # parses previous & build Template array
+ $i = 0;
+ foreach my $book ( sort { $a->{'date_due'} cmp $b->{'date_due'} }
+ @previousissues )
+ {
+ my $dd = $book->{'date_due'};
+ my $datedue = $book->{'date_due'};
+ $dd = format_date($dd);
+ my $pcolor = '';
+ my $od = '';
+ $datedue =~ s/-//g;
+ if ( $datedue < $todaysdate ) {
+ $od = 1;
+ }
+ else {
+ $od = 0;
+ }
+ if ( $i % 2 ) {
+ $togglecolor = 0;
+ }
+ else {
+ $togglecolor = 1;
+ }
+ $book->{'togglecolor'} = $togglecolor;
+ $book->{'dd'} = $dd;
+ $book->{'od'} = $od;
+ if ( $book->{'author'} eq '' ) {
+ $book->{'author'} = ' ';
+ }
+ push @realprevissues, $book;
+ $i++;
+ }
+}
+
+my @values;
+my %labels;
+my $CGIselectborrower;
+if ($borrowerslist) {
+ foreach (
+ sort {
+ $a->{'surname'}
+ . $a->{'firstname'} cmp $b->{'surname'}
+ . $b->{'firstname'}
+ } @$borrowerslist
+ )
+ {
+ push @values, $_->{'borrowernumber'};
+ $labels{ $_->{'borrowernumber'} } =
+"$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'}) ... $_->{'streetaddress'} ";
+ }
+ $CGIselectborrower = CGI::scrolling_list(
+ -name => 'borrnumber',
+ -values => \@values,
+ -labels => \%labels,
+ -size => 7,
+ -multiple => 0
+ );
+}
+
+#title
+
+my ( $patrontable, $flaginfotable ) = patrontable($borrower);
+my $amountold = $borrower->{flags}->{'CHARGES'}->{'message'} || 0;
+my @temp = split( /\$/, $amountold );
+
+my $CGIorganisations;
+my $member_of_institution;
+if ( C4::Context->preference("memberofinstitution") ) {
+ my $organisations = get_institutions();
+ my @orgs;
+ my %org_labels;
+ foreach my $organisation ( keys %$organisations ) {
+ push @orgs, $organisation;
+ $org_labels{$organisation} =
+ $organisations->{$organisation}->{'surname'};
+ }
+ $member_of_institution = 1;
+ $CGIorganisations = CGI::popup_menu(
+ -id => 'organisations',
+ -name => 'organisations',
+ -labels => \%org_labels,
+ -values => \@orgs,
+
+ );
+}
+
+$amountold = $temp[1];
+$template->param(
+ findborrower => $findborrower,
+ borrower => $borrower,
+ borrowernumber => $borrowernumber,
+ branch => $branch,
+ printer => $printer,
+ printername => $printer,
+ firstname => $borrower->{'firstname'},
+ surname => $borrower->{'surname'},
+ categorycode => $borrower->{'categorycode'},
+ streetaddress => $borrower->{'streetaddress'},
+ emailaddress => $borrower->{'emailaddress'},
+ borrowernotes => $borrower->{'borrowernotes'},
+ city => $borrower->{'city'},
+ phone => $borrower->{'phone'},
+ cardnumber => $borrower->{'cardnumber'},
+ amountold => $amountold,
+ barcode => $barcode,
+ stickyduedate => $stickyduedate,
+ message => $message,
+ CGIselectborrower => $CGIselectborrower,
+ todayissues => \@realtodayissues,
+ previssues => \@realprevissues,
+ inprocess => $inprocess,
+ memberofinstution => $member_of_institution,
+ CGIorganisations => $CGIorganisations,
+);
+
+# set return date if stickyduedate
+if ($stickyduedate) {
+ my $t_year = "year" . $year;
+ my $t_month = "month" . $month;
+ my $t_day = "day" . $day;
+ $template->param(
+ $t_year => 1,
+ $t_month => 1,
+ $t_day => 1,
+ );
+}
+
+
+# if ($branchcookie) {
+# $cookie=[$cookie, $branchcookie, $printercookie];
+# }
+
+output_html_with_http_headers $query, $cookie, $template->output;
+
+####################################################################
+# Extra subroutines,,,
+
+sub patrontable {
+ my ($borrower) = @_;
+ my $flags = $borrower->{'flags'};
+ my $flaginfotable = '';
+ my $flaginfotext;
+
+ #my $flaginfotext='';
+ my $flag;
+ my $color = '';
+ foreach $flag ( sort keys %$flags ) {
+
+ # my @itemswaiting='';
+ $flags->{$flag}->{'message'} =~ s/\n/<br>/g;
+ if ( $flags->{$flag}->{'noissues'} ) {
+ $template->param(
+ flagged => 1,
+ noissues => 'true',
+ );
+ if ( $flag eq 'GNA' ) {
+ $template->param( gna => 'true' );
+ }
+ if ( $flag eq 'LOST' ) {
+ $template->param( lost => 'true' );
+ }
+ if ( $flag eq 'DBARRED' ) {
+ $template->param( dbarred => 'true' );
+ }
+ if ( $flag eq 'CHARGES' ) {
+ $template->param(
+ charges => 'true',
+ chargesmsg => $flags->{'CHARGES'}->{'message'}
+ );
+ }
+ if ($flag eq 'CREDITS') {
+ $template->param(
+ credits => 'true',
+ creditsmsg => $flags->{'CREDITS'}->{'message'}
+ );