Finalized XML version for intranet
[koha-equinox.git] / admin / koha-electronic.pl
1 #!/usr/bin/perl
2
3 # Script to manage the opac news.
4 # written 11/04
5 # CastaƱeda, Carlos Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina
6
7 # Copyright 2000-2002 Katipo Communications
8 #
9 # This file is part of Koha.
10 #
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
14 # version.
15 #
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.
19 #
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
23
24 use strict;
25 use CGI;
26
27 use C4::Auth;
28 use C4::Context;
29 use C4::Output;
30 use C4::Interface::CGI::Output;
31 use C4::NewsChannels;
32
33
34 my $cgi = new CGI;
35
36 my ($template, $borrowernumber, $cookie)
37     = get_template_and_user({template_name => "admin/koha-electronic.tmpl",
38                              query => $cgi,
39                              type => "intranet",
40                              authnotrequired => 0,
41                              flagsrequired => {parameters => 1},
42                              debug => 1,
43                              });
44
45 my $op = $cgi->param('op');
46
47 if ($op eq 'add_form') {
48         $template->param(add_form => 1);
49         my $id = $cgi->param("id");
50         my $edata;
51 # warn "add_form";      
52         if ($id) {
53                 $template->param(op => 'edit');
54                 $edata = get_opac_electronic($id);
55                 $template->param($edata);
56                 $template->param(id => $edata->{'idelectronic'});
57         } else {
58                 $template->param(op => 'add');
59         }
60         
61 } elsif ($op eq 'add') {
62 # warn "add";
63         my $title       = $cgi->param('title');
64         my $edata       = $cgi->param('edata');
65         my $lang        = $cgi->param('lang');
66         my $image       = $cgi->param('image');
67         my $href        = $cgi->param('href');
68         my $section     = $cgi->param('section');
69         add_opac_electronic($title, $edata, $lang,$image, $href,$section);
70         print $cgi->redirect('/cgi-bin/koha/admin/koha-electronic.pl');
71
72 } elsif ($op eq 'edit') {
73 # warn "edit";
74         my $id          = $cgi->param('id');
75         my $title       = $cgi->param('title');
76         my $edata       = $cgi->param('edata');
77         my $lang        = $cgi->param('lang');
78         my $image       = $cgi->param('image');
79         my $href        = $cgi->param('href');
80         my $section     = $cgi->param('section');
81         upd_opac_electronic($id, $title, $edata, $lang,$image,$href,$section);
82         print $cgi->redirect('/cgi-bin/koha/admin/koha-electronic.pl');
83
84 } elsif ($op eq 'del') {
85 # warn "del";
86         my @ids = $cgi->param('ids');
87         del_opac_electronic(join ",", @ids);
88         print $cgi->redirect('/cgi-bin/koha/admin/koha-electronic.pl');
89
90 } else { 
91 # warn "else";
92
93         my $lang = $cgi->param('lang');
94
95         my ($opac_electronic_count, $opac_electronic) = &get_opac_electronics(undef, $lang);
96         $template->param($lang => 1);
97         $template->param(opac_electronic => $opac_electronic);
98         $template->param(opac_electronic_count => $opac_electronic_count);
99
100 }
101
102 output_html_with_http_headers $cgi, $cookie, $template->output;