rel_3_0 moved to HEAD
[koha.git] / admin / institutions-careers.pl
1 #!/usr/bin/perl
2
3 # Script to manage the educational institutions and its careers.
4 # written 12/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::AcademicInfo;
32
33 my $cgi = new CGI;
34
35 my ($template, $borrowernumber, $cookie)
36     = get_template_and_user({template_name => "admin/institutions-careers.tmpl",
37                              query => $cgi,
38                              type => "intranet",
39                              authnotrequired => 0,
40                              flagsrequired => {editcatalogue => 1},
41                              debug => 1,
42                              });
43
44 my $op = $cgi->param('op'); 
45 my $id_institution = $cgi->param('id_institution'); 
46 my $institution_name = $cgi->param('institution_name'); 
47
48 if ($op eq 'add_form') {
49         $template->param(add_form => 1);
50         
51         if ($id_institution) {
52                 my $info = get_educational_institution($id_institution);
53                 $template->param(op => 'edit');
54                 $template->param(institution_name => $info->{'institution_name'});
55                 $template->param(id_institution => $id_institution);
56         } else {
57                 $template->param(op => 'add');
58         }
59
60 } elsif ($op eq 'add') {
61         add_educational_institution($institution_name);
62         print $cgi->redirect('/cgi-bin/koha/admin/institutions-careers.pl');
63 } elsif ($op eq 'edit') {
64         update_educational_institution($id_institution, $institution_name);
65         print $cgi->redirect('/cgi-bin/koha/admin/institutions-careers.pl');
66 } elsif ($op eq 'del') {
67         del_educational_institution($id_institution);
68         print $cgi->redirect('/cgi-bin/koha/admin/institutions-careers.pl');
69 } else {
70         my @educ_institutions = &get_careers_by_institution();
71         $template->param(institutions => \@educ_institutions);
72 }
73
74 output_html_with_http_headers $cgi, $cookie, $template->output;