fixed typo that caused MARC21 leader form to emit 25 characters instead of 24
[koha_fer] / C4 / NewsChannels.pm
index 0d8f458..0d9bf61 100644 (file)
@@ -45,7 +45,7 @@ This module provides the functions needed to admin the news channels and its cat
 \r
 \r
 @ISA = qw(Exporter);\r
-@EXPORT = qw(
+@EXPORT = qw(\r
   &GetNewsToDisplay\r
   &news_channels &get_new_channel &del_channels &add_channel &update_channel\r
   &news_channels_categories &get_new_channel_category &del_channels_categories\r
@@ -240,7 +240,7 @@ sub update_channel_category {
 }\r
 \r
 sub add_opac_new {\r
-    my ($title, $new, $lang, $expirationdate, $number) = @_;
+    my ($title, $new, $lang, $expirationdate, $number) = @_;\r
     my $dbh = C4::Context->dbh;\r
     my $sth = $dbh->prepare("INSERT INTO opac_news (title, new, lang, expirationdate, number) VALUES (?,?,?,?,?)");\r
     $sth->execute($title, $new, $lang, $expirationdate, $number);\r
@@ -251,14 +251,14 @@ sub add_opac_new {
 sub upd_opac_new {\r
     my ($idnew, $title, $new, $lang, $expirationdate, $number) = @_;\r
     my $dbh = C4::Context->dbh;\r
-    my $sth = $dbh->prepare("
-        UPDATE opac_news SET 
-            title = ?,
-            new = ?,
-            lang = ?,
-            expirationdate = ?,
-            number = ?
-        WHERE idnew = ?
+    my $sth = $dbh->prepare("\r
+        UPDATE opac_news SET \r
+            title = ?,\r
+            new = ?,\r
+            lang = ?,\r
+            expirationdate = ?,\r
+            number = ?\r
+        WHERE idnew = ?\r
     ");\r
     $sth->execute($title, $new, $lang, $expirationdate,$number,$idnew);\r
     $sth->finish;\r
@@ -285,6 +285,7 @@ sub get_opac_new {
     $sth->execute($idnew);\r
     my $data = $sth->fetchrow_hashref;\r
     $data->{$data->{'lang'}} = 1;\r
+    $data->{expirationdate} = format_date($data->{expirationdate});\r
     $sth->finish;\r
     return $data;\r
 }\r
@@ -292,7 +293,7 @@ sub get_opac_new {
 sub get_opac_news {\r
     my ($limit, $lang) = @_;\r
     my $dbh = C4::Context->dbh;\r
-    my $query = "SELECT *, DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate FROM opac_news";\r
+    my $query = "SELECT *, timestamp AS newdate FROM opac_news";\r
     if ($lang) {\r
         $query.= " WHERE lang = '" .$lang ."' ";\r
     }\r
@@ -307,43 +308,44 @@ sub get_opac_news {
     while (my $row = $sth->fetchrow_hashref) {\r
         if ((($limit) && ($count < $limit)) || (!$limit)) {\r
             $row->{'newdate'} = format_date($row->{'newdate'});\r
+            $row->{'expirationdate'} = format_date($row->{'expirationdate'});\r
             push @opac_news, $row;\r
         }\r
         $count++;\r
     }\r
     return ($count, \@opac_news);\r
 }\r
-
-=head2 GetNewsToDisplay
-    
-    $news = &GetNewsToDisplay($lang);
-    C<$news> is a ref to an array which containts
-    all news with expirationdate > today or expirationdate is null.
-    
-=cut
-
-sub GetNewsToDisplay {
-    my $lang = shift;
+\r
+=head2 GetNewsToDisplay\r
+    \r
+    $news = &GetNewsToDisplay($lang);\r
+    C<$news> is a ref to an array which containts\r
+    all news with expirationdate > today or expirationdate is null.\r
+    \r
+=cut\r
+\r
+sub GetNewsToDisplay {\r
+    my $lang = shift;\r
     my $dbh = C4::Context->dbh;\r
-    my $query = "
-     SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate
-     FROM   opac_news
-     WHERE   (
-        expirationdate > CURRENT_DATE()
-        OR    expirationdate IS NULL
-        OR    expirationdate = '00-00-0000'
-      )
-      AND   lang = ?
-      ORDER BY number
-    ";
-    my $sth = $dbh->prepare($query);
-    $sth->execute($lang);
-    my @results;
-    while ( my $row = $sth->fetchrow_hashref ){
-        push @results, $row;
-    }
-    return \@results;
-}
+    my $query = "\r
+     SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate\r
+     FROM   opac_news\r
+     WHERE   (\r
+        expirationdate > CURRENT_DATE()\r
+        OR    expirationdate IS NULL\r
+        OR    expirationdate = '00-00-0000'\r
+      )\r
+      AND   lang = ?\r
+      ORDER BY number\r
+    ";\r
+    my $sth = $dbh->prepare($query);\r
+    $sth->execute($lang);\r
+    my @results;\r
+    while ( my $row = $sth->fetchrow_hashref ){\r
+        push @results, $row;\r
+    }\r
+    return \@results;\r
+}\r
 \r
 ### get electronic databases\r
 \r
@@ -424,5 +426,3 @@ END { }    # module clean-up code here (global destructor)
 TG\r
 \r
 =cut\r
-\r
-\r