Getting stored results working
[koha_fer] / tools / koha-news.pl
index 1169d3b..f979fb7 100755 (executable)
@@ -2,7 +2,7 @@
 
 # Script to manage the opac news.
 # written 11/04
-# Castañeda, Carlos Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina
+# Castaeda, Carlos Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina
 # Modified to include news to KOHA intranet - tgarip@neu.edu.tr NEU library -Cyprus
 # Copyright 2000-2002 Katipo Communications
 #
@@ -26,8 +26,8 @@ use CGI;
 use C4::Auth;
 use C4::Koha;
 use C4::Context;
+use C4::Dates qw(format_date_in_iso);
 use C4::Output;
-use C4::Interface::CGI::Output;
 use C4::NewsChannels;
 use C4::Languages;
 use Date::Calc qw/Date_to_Days Today/;
@@ -37,7 +37,7 @@ my $cgi = new CGI;
 my $id             = $cgi->param('id');
 my $title          = $cgi->param('title');
 my $new            = $cgi->param('new');
-my $expirationdate = $cgi->param('expirationdate');
+my $expirationdate = format_date_in_iso($cgi->param('expirationdate'));
 my $number         = $cgi->param('number');
 my $lang           = $cgi->param('lang');
 
@@ -102,17 +102,20 @@ else {
     
     foreach my $new ( @$opac_news ) {
         next unless $new->{'expirationdate'};
-        next if $new->{'expirationdate'} eq '0000-00-00';
-        if (Date_to_Days( split "-" ,$new->{'expirationdate'} ) < Date_to_Days(&Today) ){
-            $new->{'hasexpirated'} = 1;
+               #$new->{'expirationdate'}=format_date_in_iso($new->{'expirationdate'});
+        my @date = split (/-/,$new->{'expirationdate'});
+        if ($date[0]*$date[1]*$date[2]>0 && Date_to_Days( @date ) < Date_to_Days(&Today) ){
+                       $new->{'expired'} = 1;
         }
     }
     
     $template->param(
         $lang           => 1,
         opac_news       => $opac_news,
-        opac_news_count => $opac_news_count 
-    );
+        opac_news_count => $opac_news_count,
+               );
 }
-
+$template->param(
+                               DHTMLcalendar_dateformat =>  C4::Dates->DHTMLcalendar(),
+               );
 output_html_with_http_headers $cgi, $cookie, $template->output;