3 # Script to manage the opac news.
5 # Casta�eda, Carlos Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina
6 # Modified to include news to KOHA intranet - tgarip@neu.edu.tr NEU library -Cyprus
7 # Copyright 2000-2002 Katipo Communications
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA 02111-1307 USA
33 use Date::Calc qw/Date_to_Days Today/;
37 my $id = $cgi->param('id');
38 my $title = $cgi->param('title');
39 my $new = $cgi->param('new');
40 my $expirationdate = format_date_in_iso($cgi->param('expirationdate'));
41 my $number = $cgi->param('number');
42 my $lang = $cgi->param('lang');
44 my $new_detail = get_opac_new($id);
46 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
48 template_name => "tools/koha-news.tmpl",
52 flagsrequired => { tools => 1 },
59 my $tlangs = getTranslatedLanguages() ;
60 foreach my $language ( @$tlangs ) {
63 language => $language->{'language_code'},
64 selected => ( $new_detail->{lang} eq $language->{'language_code'} ? 1 : 0 ),
68 $template->param( lang_list => \@lang_list );
70 my $op = $cgi->param('op');
72 if ( $op eq 'add_form' ) {
73 $template->param( add_form => 1,
74 DHTMLcalendar_dateformat => get_date_format_string_for_DHTMLcalendar(),
79 id => $new_detail->{'idnew'},
81 $template->param($new_detail,);
84 $template->param( op => 'add',
88 elsif ( $op eq 'add' ) {
89 add_opac_new( $title, $new, $lang, $expirationdate, $number );
90 print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
92 elsif ( $op eq 'edit' ) {
93 upd_opac_new( $id, $title, $new, $lang, $expirationdate, $number );
94 print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
96 elsif ( $op eq 'del' ) {
97 my @ids = $cgi->param('ids');
98 del_opac_new( join ",", @ids );
99 print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
104 my ( $opac_news_count, $opac_news ) = &get_opac_news( undef, $lang );
106 foreach my $new ( @$opac_news ) {
107 next unless $new->{'expirationdate'};
108 next if $new->{'expirationdate'} eq '0000-00-00';
109 if (Date_to_Days( split "-" ,format_date_in_iso($new->{'expirationdate'}) ) < Date_to_Days(&Today) ){
110 $new->{'hasexpirated'} = 1;
116 opac_news => $opac_news,
117 opac_news_count => $opac_news_count
121 output_html_with_http_headers $cgi, $cookie, $template->output;