View | Details | Raw Unified | Return to bug 7567
Collapse All | Expand All

(-)a/C4/Members.pm (-1 / +1 lines)
Lines 2425-2431 sub IssueSlip { Link Here
2425
            'news' => [ map {
2425
            'news' => [ map {
2426
                $_->{'timestamp'} = $_->{'newdate'};
2426
                $_->{'timestamp'} = $_->{'newdate'};
2427
                { opac_news => $_ }
2427
                { opac_news => $_ }
2428
            } @{ GetNewsToDisplay("slip") } ],
2428
            } @{ GetNewsToDisplay("slip",$branch) } ],
2429
        );
2429
        );
2430
    }
2430
    }
2431
2431
(-)a/C4/NewsChannels.pm (-9 / +34 lines)
Lines 125-131 sub del_opac_new { Link Here
125
sub get_opac_new {
125
sub get_opac_new {
126
    my ($idnew) = @_;
126
    my ($idnew) = @_;
127
    my $dbh = C4::Context->dbh;
127
    my $dbh = C4::Context->dbh;
128
    my $query = q{ SELECT * FROM opac_news WHERE idnew = ? };
128
    my $query = q{
129
                  SELECT opac_news.*,branches.branchname
130
                  FROM opac_news LEFT JOIN branches
131
                      ON opac_news.branchcode=branches.branchcode
132
                  WHERE opac_news.idnew = ?;
133
                };
129
    my $sth = $dbh->prepare($query);
134
    my $sth = $dbh->prepare($query);
130
    $sth->execute($idnew);
135
    $sth->execute($idnew);
131
    my $data = $sth->fetchrow_hashref;
136
    my $data = $sth->fetchrow_hashref;
Lines 136-149 sub get_opac_new { Link Here
136
}
141
}
137
142
138
sub get_opac_news {
143
sub get_opac_news {
139
    my ($limit, $lang) = @_;
144
    my ($limit, $lang, $branchcode) = @_;
140
    my @values;
145
    my @values;
141
    my $dbh = C4::Context->dbh;
146
    my $dbh = C4::Context->dbh;
142
    my $query = q{ SELECT *, timestamp AS newdate FROM opac_news };
147
    my $query = q{
143
    if ($lang) {
148
                  SELECT opac_news.*, branches.branchname,
144
        $query.= " WHERE (lang='' OR lang=?)";
149
                         timestamp AS newdate
150
                  FROM opac_news LEFT JOIN branches
151
                      ON opac_news.branchcode=branches.branchcode
152
                };
153
    if ($lang && $branchcode) {
154
        $query .= " WHERE (opac_news.lang='' OR opac_news.lang=?)";
155
        $query .= " AND (opac_news.branchcode IS NULL OR opac_news.branchcode=?)";
156
        push @values,$lang;
157
        push @values,$branchcode;
158
    }
159
    elsif ($lang) {
160
        $query .= " WHERE (opac_news.lang='' OR opac_news.lang=?)";
145
        push @values,$lang;
161
        push @values,$lang;
146
    }
162
    }
163
    elsif ($branchcode) {
164
        $query .= " WHERE (opac_news.branchcode IS NULL OR opac_news.branchcode=?)";
165
        push @values,$branchcode;
166
    }
167
    else {
168
        # nothing
169
    }
147
    $query.= ' ORDER BY timestamp DESC ';
170
    $query.= ' ORDER BY timestamp DESC ';
148
    #if ($limit) {
171
    #if ($limit) {
149
    #    $query.= 'LIMIT 0, ' . $limit;
172
    #    $query.= 'LIMIT 0, ' . $limit;
Lines 165-178 sub get_opac_news { Link Here
165
188
166
=head2 GetNewsToDisplay
189
=head2 GetNewsToDisplay
167
190
168
    $news = &GetNewsToDisplay($lang);
191
    $news = &GetNewsToDisplay($lang,$branch);
169
    C<$news> is a ref to an array which containts
192
    C<$news> is a ref to an array which containts
170
    all news with expirationdate > today or expirationdate is null.
193
    all news with expirationdate > today or expirationdate is null
194
    that is applicable for a given branch.
171
195
172
=cut
196
=cut
173
197
174
sub GetNewsToDisplay {
198
sub GetNewsToDisplay {
175
    my ($lang) = @_;
199
    my ($lang,$branch) = @_;
176
    my $dbh = C4::Context->dbh;
200
    my $dbh = C4::Context->dbh;
177
    # SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate
201
    # SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate
178
    my $query = q{
202
    my $query = q{
Lines 185-197 sub GetNewsToDisplay { Link Here
185
     )
209
     )
186
     AND   `timestamp` < CURRENT_DATE()+1
210
     AND   `timestamp` < CURRENT_DATE()+1
187
     AND   (lang = '' OR lang = ?)
211
     AND   (lang = '' OR lang = ?)
212
     AND   (branchcode IS NULL OR branchcode = ?)
188
     ORDER BY number
213
     ORDER BY number
189
    }; # expirationdate field is NOT in ISO format?
214
    }; # expirationdate field is NOT in ISO format?
190
       # timestamp has HH:mm:ss, CURRENT_DATE generates 00:00:00
215
       # timestamp has HH:mm:ss, CURRENT_DATE generates 00:00:00
191
       #           by adding 1, that captures today correctly.
216
       #           by adding 1, that captures today correctly.
192
    my $sth = $dbh->prepare($query);
217
    my $sth = $dbh->prepare($query);
193
    $lang = $lang // q{};
218
    $lang = $lang // q{};
194
    $sth->execute($lang);
219
    $sth->execute($lang,$branch);
195
    my @results;
220
    my @results;
196
    while ( my $row = $sth->fetchrow_hashref ){
221
    while ( my $row = $sth->fetchrow_hashref ){
197
        $row->{newdate} = format_date($row->{newdate});
222
        $row->{newdate} = format_date($row->{newdate});
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt (-6 / +46 lines)
Lines 75-81 Edit News Item[% ELSE %]Add News Item[% END %][% ELSE %]News[% END %]</div> Link Here
75
			<fieldset class="rows">
75
			<fieldset class="rows">
76
            <legend>OPAC and Koha news</legend>
76
            <legend>OPAC and Koha news</legend>
77
           <ol> <li>
77
           <ol> <li>
78
            <label for="lang">([% new_detail.lang %])([% lang %])Display location</label>
78
            <label for="lang">Display location</label>
79
            <select id="lang" name="lang">
79
            <select id="lang" name="lang">
80
                [% IF ( default_lang == "" ) %]
80
                [% IF ( default_lang == "" ) %]
81
                <option value=""     selected>All</option>
81
                <option value=""     selected>All</option>
Lines 102-107 Edit News Item[% ELSE %]Add News Item[% END %][% ELSE %]News[% END %]</div> Link Here
102
            </select>
102
            </select>
103
            </li>
103
            </li>
104
            <li>
104
            <li>
105
                <label for="branch">Branch: </label>
106
                <select id="branch" name="branch">
107
                [% IF ( new_detail.branchcode == '' ) %]
108
                    <option value="" selected>All Branches</option>
109
                [% ELSE %]
110
                    <option value=""         >All Branches</option>
111
                [% END %]
112
                [% FOREACH branch_item IN branch_list %]
113
                [% IF ( branch_item.value.branchcode == new_detail.branchcode ) %]
114
                    <option value="[% branch_item.value.branchcode %]" selected>[% branch_item.value.branchname %]</option>
115
                [% ELSE %]
116
                    <option value="[% branch_item.value.branchcode %]">[% branch_item.value.branchname %]</option>
117
                [% END %]
118
                [% END %]
119
                </select>
120
            </li>
121
            <li>
105
                <label for="title">Title: </label>
122
                <label for="title">Title: </label>
106
                <input id="title" size="30" type="text" name="title" value="[% new_detail.title %]" />
123
                <input id="title" size="30" type="text" name="title" value="[% new_detail.title %]" />
107
            </li>
124
            </li>
Lines 154-160 Edit News Item[% ELSE %]Add News Item[% END %][% ELSE %]News[% END %]</div> Link Here
154
                [% IF ( lang_lis.language == lang ) %]
171
                [% IF ( lang_lis.language == lang ) %]
155
                    <option value="[% lang_lis.language %]" selected>OPAC ([% lang_lis.language %])</option>
172
                    <option value="[% lang_lis.language %]" selected>OPAC ([% lang_lis.language %])</option>
156
                [% ELSE %]
173
                [% ELSE %]
157
                    <option value="[% lang_lis.language %]">OPAC ([% lang_lis.language %])</option>
174
                    <option value="[% lang_lis.language %]"         >OPAC ([% lang_lis.language %])</option>
175
                [% END %]
176
                [% END %]
177
            </select>
178
            <label for="branch">Branch: </label>
179
            <select id="branch" name="branch">
180
                [% IF ( branchcode == "" ) %]
181
                <option value="" selected>All Branches</option>
182
                [% ELSE %]
183
                <option value=""         >All Branches</option>
184
                [% END %]
185
                [% FOREACH branch_item IN branch_list %]
186
                [% IF ( branch_item.value.branchcode == branchcode ) %]
187
                    <option value="[% branch_item.value.branchcode %]"
188
                            selected>[% branch_item.value.branchname %]
189
                    </option>
190
                [% ELSE %]
191
                    <option value="[% branch_item.value.branchcode %]"
192
                                    >[% branch_item.value.branchname %]
193
                    </option>
158
                [% END %]
194
                [% END %]
159
                [% END %]
195
                [% END %]
160
            </select>
196
            </select>
Lines 167-172 Edit News Item[% ELSE %]Add News Item[% END %][% ELSE %]News[% END %]</div> Link Here
167
                   <thead> <tr>
203
                   <thead> <tr>
168
                        <th>&nbsp;</th>
204
                        <th>&nbsp;</th>
169
                        <th>Location</th>
205
                        <th>Location</th>
206
                        <th>Branch</th>
170
                        <th>Number</th>
207
                        <th>Number</th>
171
                        <th>Creation date</th>
208
                        <th>Creation date</th>
172
                        <th>Expiration date</th>
209
                        <th>Expiration date</th>
Lines 184-200 Edit News Item[% ELSE %]Add News Item[% END %][% ELSE %]News[% END %]</div> Link Here
184
                                <input type="checkbox" name="ids" value="[% opac_new.idnew %]" />
221
                                <input type="checkbox" name="ids" value="[% opac_new.idnew %]" />
185
                            </td>
222
                            </td>
186
                            <td>[% SWITCH opac_new.lang %]
223
                            <td>[% SWITCH opac_new.lang %]
187
			        [%   CASE "koha" %]
224
			        [%   CASE 'koha' %]
188
                                    Librarian interface
225
                                    Librarian interface
189
			        [%   CASE "slip" %]
226
			        [%   CASE 'slip' %]
190
				    Slip
227
				    Slip
191
			        [%   CASE "" %]
228
			        [%   CASE '' %]
192
                                    All
229
                                    All
193
			        [%   CASE %]
230
			        [%   CASE %]
194
                                    OPAC ([% opac_new.lang %])
231
                                    OPAC ([% opac_new.lang %])
195
				[% END %]
232
				[% END %]
196
                             </td>
233
                             </td>
197
234
                            <td>[% IF ( opac_new.branchcode == "" ) -%]
235
                                All Branches
236
                                [% ELSE %][% opac_new.branchname %]
237
                                [% END %]</td>
198
                            <td>[% opac_new.number %]</td>
238
                            <td>[% opac_new.number %]</td>
199
                            <td>[% opac_new.newdate %]</td>
239
                            <td>[% opac_new.newdate %]</td>
200
                            <td>[% opac_new.expirationdate %] [% IF ( opac_new.expired ) %](<span class="expired">expired</span>)[% END %]</td>
240
                            <td>[% opac_new.expirationdate %] [% IF ( opac_new.expired ) %](<span class="expired">expired</span>)[% END %]</td>
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt (-2 / +2 lines)
Lines 21-28 Link Here
21
        <div id="notloggedin" class="yui-ge">
21
        <div id="notloggedin" class="yui-ge">
22
    [% END %]
22
    [% END %]
23
        <div class="yui-u first">
23
        <div class="yui-u first">
24
	[% IF ( koha_news_count ) %]
25
<div id="news" class="container">
24
<div id="news" class="container">
25
	[% IF ( koha_news_count ) %]
26
    <table>
26
    <table>
27
    [% FOREACH koha_new IN koha_news %]
27
    [% FOREACH koha_new IN koha_news %]
28
    <tr><th>[% koha_new.title %]</th></tr>
28
    <tr><th>[% koha_new.title %]</th></tr>
Lines 30-37 Link Here
30
                <p class="newsfooter"><i>(published on [% koha_new.newdate %])</i></p></td></tr>
30
                <p class="newsfooter"><i>(published on [% koha_new.newdate %])</i></p></td></tr>
31
    [% END %]
31
    [% END %]
32
    </table>
32
    </table>
33
</div>
34
[% END %]
33
[% END %]
34
</div>
35
35
36
      [% IF ( display_daily_quote && daily_quote ) %]
36
      [% IF ( display_daily_quote && daily_quote ) %]
37
    <div id="daily-quote" class="container"><h1>Quote of the Day</h1><div><span id="daily-quote-text">[% daily_quote.text %]</span><span id="daily-quote-sep"> ~ </span><span id="daily-quote-source">[% daily_quote.source %]</span></div></div>
37
    <div id="daily-quote" class="container"><h1>Quote of the Day</h1><div><span id="daily-quote-text">[% daily_quote.text %]</span><span id="daily-quote-sep"> ~ </span><span id="daily-quote-source">[% daily_quote.source %]</span></div></div>
(-)a/mainpage.pl (-16 / +20 lines)
Lines 1-30 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# This file is part of Koha.
4
#
3
# Copyright Paul Poulain 2002
5
# Copyright Paul Poulain 2002
4
# Parts Copyright Liblime 2007
6
# Parts Copyright Liblime 2007
7
# Copyright (C) 2013  Mark Tompsett
5
#
8
#
6
# This file is part of Koha.
9
# Koha is free software; you can redistribute it and/or modify it
10
# under the terms of the GNU General Public License as published by
11
# the Free Software Foundation; either version 3 of the License, or
12
# (at your option) any later version.
7
#
13
#
8
# Koha is free software; you can redistribute it and/or modify it under the
14
# Koha is distributed in the hope that it will be useful, but
9
# terms of the GNU General Public License as published by the Free Software
15
# WITHOUT ANY WARRANTY; without even the implied warranty of
10
# Foundation; either version 2 of the License, or (at your option) any later
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# version.
17
# GNU General Public License for more details.
12
#
18
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19
# You should have received a copy of the GNU General Public License
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20
# along with Koha; if not, see <http://www.gnu.org/licenses>.
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
21
use strict;
22
use Modern::Perl;
22
use warnings;
23
use CGI;
23
use CGI;
24
use C4::Output;
24
use C4::Output;
25
use C4::Auth;
25
use C4::Auth;
26
use C4::Koha;
26
use C4::Koha;
27
use C4::NewsChannels;
27
use C4::NewsChannels; # GetNewsToDisplay
28
use C4::Review qw/numberofreviews/;
28
use C4::Review qw/numberofreviews/;
29
use C4::Suggestions qw/CountSuggestion/;
29
use C4::Suggestions qw/CountSuggestion/;
30
use C4::Tags qw/get_count_by_tag_status/;
30
use C4::Tags qw/get_count_by_tag_status/;
Lines 42-48 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( Link Here
42
    }
42
    }
43
);
43
);
44
44
45
my $all_koha_news   = &GetNewsToDisplay("koha");
45
my $homebranch;
46
if (C4::Context->userenv) {
47
    $homebranch = C4::Context->userenv->{'branch'};
48
}
49
my $all_koha_news   = &GetNewsToDisplay("koha",$homebranch);
46
my $koha_news_count = scalar @$all_koha_news;
50
my $koha_news_count = scalar @$all_koha_news;
47
51
48
$template->param(
52
$template->param(
(-)a/opac/opac-main.pl (-14 / +19 lines)
Lines 2-27 Link Here
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
5
# Parts Copyright (C) 2013  Mark Tompsett
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 2 of the License, or (at your option) any later
8
# version.
9
#
6
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
7
# Koha is free software; you can redistribute it and/or modify it
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
8
# under the terms of the GNU General Public License as published by
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
13
#
11
#
14
# You should have received a copy of the GNU General Public License along
12
# Koha is distributed in the hope that it will be useful, but
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
19
18
20
19
use strict;
21
use Modern::Perl;
20
use warnings;
21
use CGI;
22
use CGI;
22
use C4::Auth;    # get_template_and_user
23
use C4::Auth;    # get_template_and_user
23
use C4::Output;
24
use C4::Output;
24
use C4::NewsChannels;    # get_opac_news
25
use C4::NewsChannels;    # GetNewsToDisplay
25
use C4::Languages qw(getTranslatedLanguages accept_language);
26
use C4::Languages qw(getTranslatedLanguages accept_language);
26
use C4::Koha qw( GetDailyQuote );
27
use C4::Koha qw( GetDailyQuote );
27
28
Lines 48-54 $template->param( Link Here
48
# use cookie setting for language, bug default to syspref if it's not set
49
# use cookie setting for language, bug default to syspref if it's not set
49
my ($theme, $news_lang, $availablethemes) = C4::Templates::themelanguage(C4::Context->config('opachtdocs'),'opac-main.tt','opac',$input);
50
my ($theme, $news_lang, $availablethemes) = C4::Templates::themelanguage(C4::Context->config('opachtdocs'),'opac-main.tt','opac',$input);
50
51
51
my $all_koha_news   = &GetNewsToDisplay($news_lang);
52
my $homebranch;
53
if (C4::Context->userenv) {
54
    $homebranch = C4::Context->userenv->{'branch'};
55
}
56
my $all_koha_news   = &GetNewsToDisplay($news_lang,$homebranch);
52
my $koha_news_count = scalar @$all_koha_news;
57
my $koha_news_count = scalar @$all_koha_news;
53
58
54
my $quote = GetDailyQuote();   # other options are to pass in an exact quote id or select a random quote each pass... see perldoc C4::Koha
59
my $quote = GetDailyQuote();   # other options are to pass in an exact quote id or select a random quote each pass... see perldoc C4::Koha
(-)a/t/db_dependent/NewsChannels.t (-4 / +15 lines)
Lines 23-28 my $dbh = C4::Context->dbh; Link Here
23
$dbh->{AutoCommit} = 0;
23
$dbh->{AutoCommit} = 0;
24
$dbh->{RaiseError} = 1;
24
$dbh->{RaiseError} = 1;
25
25
26
# Add LIB1, if it doesn't exist.
27
my $addbra = 'LIB1';
28
if ( !GetBranchName($addbra) ) {
29
    $dbh->do( q{ INSERT INTO branches (branchcode,branchname) VALUES (?,?) },
30
        undef, ( $addbra, "$addbra branch" ) );
31
}
32
26
# Test add_opac_new
33
# Test add_opac_new
27
my $rv = add_opac_new();    # intentionally bad
34
my $rv = add_opac_new();    # intentionally bad
28
ok( $rv == 0, 'Correctly failed on no parameter!' );
35
ok( $rv == 0, 'Correctly failed on no parameter!' );
Lines 38-43 my $href_entry1 = { Link Here
38
    expirationdate => $expirationdate1,
45
    expirationdate => $expirationdate1,
39
    timestamp      => $timestamp1,
46
    timestamp      => $timestamp1,
40
    number         => $number1,
47
    number         => $number1,
48
    branchcode     => 'LIB1',
41
};
49
};
42
50
43
$rv = add_opac_new($href_entry1);
51
$rv = add_opac_new($href_entry1);
Lines 52-57 my $href_entry2 = { Link Here
52
    expirationdate => $expirationdate2,
60
    expirationdate => $expirationdate2,
53
    timestamp      => $timestamp2,
61
    timestamp      => $timestamp2,
54
    number         => $number2,
62
    number         => $number2,
63
    branchcode     => 'LIB1',
55
};
64
};
56
$rv = add_opac_new($href_entry2);
65
$rv = add_opac_new($href_entry2);
57
ok( $rv == 1, 'Successfully added the second dummy news item!' );
66
ok( $rv == 1, 'Successfully added the second dummy news item!' );
Lines 107-117 if ( $hashref_check->{number} ne $number2 ) { $failure = $F6; } Link Here
107
ok( $failure == 0, "Successfully tested get_opac_new id2 ($failure)!" );
116
ok( $failure == 0, "Successfully tested get_opac_new id2 ($failure)!" );
108
117
109
# Test get_opac_news (multiple news items)
118
# Test get_opac_news (multiple news items)
110
my ( $opac_news_count, $arrayref_opac_news ) = get_opac_news( 0, q{} );
119
my ( $opac_news_count, $arrayref_opac_news ) = get_opac_news( 0, q{}, 'LIB1' );
111
ok( $opac_news_count >= 2, 'Successfully tested get_opac_news!' );
120
121
# using >= 2, because someone may have LIB1 news already.
122
ok( $opac_news_count >= 2, 'Successfully tested get_opac_news for LIB1!' );
112
123
113
# Test GetNewsToDisplay
124
# Test GetNewsToDisplay
114
( $opac_news_count, $arrayref_opac_news ) = GetNewsToDisplay(q{});
125
( $opac_news_count, $arrayref_opac_news ) = GetNewsToDisplay( q{}, 'LIB1' );
115
ok( $opac_news_count >= 2, 'Successfully tested GetNewsToDisplay!' );
126
ok( $opac_news_count >= 2, 'Successfully tested GetNewsToDisplay for LIB1!' );
116
127
117
$dbh->rollback;
128
$dbh->rollback;
(-)a/tools/koha-news.pl (-4 / +14 lines)
Lines 33-38 use C4::Output; Link Here
33
use C4::NewsChannels;
33
use C4::NewsChannels;
34
use C4::Languages qw(getTranslatedLanguages);
34
use C4::Languages qw(getTranslatedLanguages);
35
use Date::Calc qw/Date_to_Days Today/;
35
use Date::Calc qw/Date_to_Days Today/;
36
use C4::Branch qw/GetBranches/;
36
37
37
my $cgi = new CGI;
38
my $cgi = new CGI;
38
39
Lines 43-48 my $expirationdate = format_date_in_iso($cgi->param('expirationdate')); Link Here
43
my $timestamp      = format_date_in_iso($cgi->param('timestamp'));
44
my $timestamp      = format_date_in_iso($cgi->param('timestamp'));
44
my $number         = $cgi->param('number');
45
my $number         = $cgi->param('number');
45
my $lang           = $cgi->param('lang');
46
my $lang           = $cgi->param('lang');
47
my $branchcode     = $cgi->param('branch');
48
# Foreign Key constraints work with NULL, not ''
49
# NULL = All branches.
50
$branchcode = undef if (defined($branchcode) && $branchcode eq '');
46
51
47
my $new_detail = get_opac_new($id);
52
my $new_detail = get_opac_new($id);
48
53
Lines 68-76 foreach my $language ( @$tlangs ) { Link Here
68
      };
73
      };
69
}
74
}
70
75
71
$template->param( lang_list => \@lang_list );
76
my $branches = GetBranches;
72
77
73
my $op = $cgi->param('op');
78
$template->param( lang_list   => \@lang_list,
79
                  branch_list => $branches,
80
                  branchcode  => $branchcode );
81
82
my $op = $cgi->param('op') // '';
74
83
75
if ( $op eq 'add_form' ) {
84
if ( $op eq 'add_form' ) {
76
    $template->param( add_form => 1 );
85
    $template->param( add_form => 1 );
Lines 94-99 elsif ( $op eq 'add' ) { Link Here
94
                      expirationdate => $expirationdate,
103
                      expirationdate => $expirationdate,
95
                      timestamp      => $timestamp,
104
                      timestamp      => $timestamp,
96
                      number         => $number,
105
                      number         => $number,
106
                      branchcode     => $branchcode,
97
                  };
107
                  };
98
    add_opac_new( $hashref );
108
    add_opac_new( $hashref );
99
    print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
109
    print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
Lines 107-112 elsif ( $op eq 'edit' ) { Link Here
107
                      expirationdate => $expirationdate,
117
                      expirationdate => $expirationdate,
108
                      timestamp      => $timestamp,
118
                      timestamp      => $timestamp,
109
                      number         => $number,
119
                      number         => $number,
120
                      branchcode     => $branchcode,
110
                  };
121
                  };
111
    upd_opac_new( $hashref );
122
    upd_opac_new( $hashref );
112
    print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
123
    print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
Lines 119-125 elsif ( $op eq 'del' ) { Link Here
119
130
120
else {
131
else {
121
132
122
    my ( $opac_news_count, $opac_news ) = &get_opac_news( undef, $lang );
133
    my ( $opac_news_count, $opac_news ) = &get_opac_news( undef, $lang, $branchcode );
123
    
134
    
124
    foreach my $new ( @$opac_news ) {
135
    foreach my $new ( @$opac_news ) {
125
        next unless $new->{'expirationdate'};
136
        next unless $new->{'expirationdate'};
126
- 

Return to bug 7567