use C4::Search; replace use C4::SearchMarc;
[koha_gimpoz] / opac / opac-user.pl
index 0ff4c48..188a3bf 100755 (executable)
@@ -6,11 +6,12 @@ use CGI;
 use C4::Auth;
 use C4::Koha;
 use C4::Circulation::Circ2;
-use C4::Circulation::Renewals2;
 use C4::Reserves2;
-use C4::Search;
+use C4::Members;
 use C4::Interface::CGI::Output;
 use HTML::Template;
+use C4::Date;
+use C4::Letters;
 
 my $query = new CGI;
 my ($template, $borrowernumber, $cookie) 
@@ -25,11 +26,15 @@ my ($template, $borrowernumber, $cookie)
 # get borrower information ....
 my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
 
-$borr->{'dateenrolled'} = slashifyDate($borr->{'dateenrolled'});
-$borr->{'expiry'}       = slashifyDate($borr->{'expiry'});
-$borr->{'dateofbirth'}  = slashifyDate($borr->{'dateofbirth'});
+$borr->{'dateenrolled'} = format_date($borr->{'dateenrolled'});
+$borr->{'expiry'}       = format_date($borr->{'expiry'});
+$borr->{'dateofbirth'}  = format_date($borr->{'dateofbirth'});
 $borr->{'ethnicity'}    = fixEthnicity($borr->{'ethnicity'});
 
+if($borr->{'debarred'} || $borr->{'gonenoaddress'} || $borr->{'lost'}){
+       $borr->{'flagged'} =1;
+}
+
 if ($borr->{'amountoutstanding'} > 5) {
     $borr->{'amountoverfive'} = 1;
 }
@@ -41,7 +46,7 @@ if ($borr->{'amountoutstanding'} < 0) {
     $borr->{'amountoutstanding'} = -1*($borr->{'amountoutstanding'});
 }
 
-$borr->{'amountoutstanding'} = sprintf "\$%.02f", $borr->{'amountoutstanding'};
+$borr->{'amountoutstanding'} = sprintf "%.02f", $borr->{'amountoutstanding'};
 
 my @bordat;
 $bordat[0] = $borr;
@@ -58,7 +63,7 @@ my @overdues;
 my @issuedat;
 foreach my $key (keys %$issues) {
     my $issue = $issues->{$key};
-    $issue->{'date_due'}  = slashifyDate($issue->{'date_due'});
+    $issue->{'date_due'}  = format_date($issue->{'date_due'});
 
     # check for reserves
     my ($restype, $res) = CheckReserves($issue->{'itemnumber'});
@@ -85,8 +90,8 @@ foreach my $key (keys %$issues) {
     my %env;
     my $status = renewstatus(\%env,$borrowernumber, $issue->{'itemnumber'});
 
-    $issue->{'renewable'} = $status;
-    
+    $issue->{'status'} = $status;
+
     if ($issue->{'overdue'}) {
        push @overdues, $issue;
        $overdues_count++;
@@ -104,12 +109,12 @@ $template->param(issues_count => $count);
 $template->param(OVERDUES => \@overdues);
 $template->param(overdues_count => $overdues_count);
 
-my $branches = getbranches();
+my $branches = GetBranches();
 
 # now the reserved items....
 my ($rcount, $reserves) = FindReserves(undef, $borrowernumber);
 foreach my $res (@$reserves) {
-    $res->{'reservedate'}  = slashifyDate($res->{'reservedate'});
+    $res->{'reservedate'}  = format_date($res->{'reservedate'});
     my $publictype = $res->{'publictype'};
     $res->{$publictype} = 1;
     $res->{'waiting'} = 1 if $res->{'found'} eq 'W';
@@ -123,14 +128,30 @@ my @waiting;
 my $wcount = 0;
 foreach my $res (@$reserves) {
     if ($res->{'itemnumber'}) {
+       my $item = getiteminformation('',$res->{'itemnumber'},'');
+       $res->{'holdingbranch'} = $branches->{$item->{'holdingbranch'}}->{'branchname'};
        $res->{'branch'} = $branches->{$res->{'branchcode'}}->{'branchname'};
+       if($res->{'holdingbranch'} eq $res->{'branch'}){
+                       $res->{'atdestination'} = 1;
+               }
        push @waiting, $res;
        $wcount++;
     }
 }
+$template->param(WAITING => \@waiting);
+
+# current alert subscriptions
+warn " B : $borrowernumber";
+my $alerts = getalert($borrowernumber);
+foreach (@$alerts) {
+       $_->{$_->{type}}=1;
+       $_->{relatedto} = findrelatedto($_->{type},$_->{externalid});
+}
 
-# $template->param(WAITING => \@waiting);
-$template->param(waiting_count => $wcount);
+$template->param(waiting_count => $wcount,
+                               textmessaging => $borr->{textmessaging},
+                               OpacPasswordChange => C4::Context->preference("OpacPasswordChange"),
+);
 
 output_html_with_http_headers $query, $cookie, $template->output;