Bug 13007: Add a foreign key for suggestions.budgetid
[koha.git] / course_reserves / mod_course.pl
blobe94b4a841c65d99b9b0028c58644e15b1bf6c224
1 #!/usr/bin/perl
3 # Copyright 2012 ByWater Solutions
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 use Modern::Perl;
22 use CGI qw ( -utf8 );
24 use C4::Output;
25 use C4::Reserves;
26 use C4::Auth;
28 use C4::CourseReserves qw(DelCourse ModCourse ModCourseInstructors);
30 my $cgi = new CGI;
31 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
32 { template_name => "about.tt",
33 query => $cgi,
34 type => "intranet",
35 authnotrequired => 0,
36 flagsrequired => { coursereserves => 'manage_courses' },
40 my $action = $cgi->param('action') || '';
42 if ( $action eq 'del' ) {
43 DelCourse( $cgi->param('course_id') );
44 print $cgi->redirect("/cgi-bin/koha/course_reserves/course-reserves.pl");
45 } else {
46 my %params;
48 $params{'course_id'} = $cgi->param('course_id')
49 if ( $cgi->param('course_id') );
50 $params{'department'} = $cgi->param('department');
51 $params{'course_number'} = $cgi->param('course_number');
52 $params{'section'} = $cgi->param('section');
53 $params{'course_name'} = $cgi->param('course_name');
54 $params{'term'} = $cgi->param('term');
55 $params{'staff_note'} = $cgi->param('staff_note');
56 $params{'public_note'} = $cgi->param('public_note');
57 $params{'students_count'} = $cgi->param('students_count');
58 $params{'enabled'} = ( $cgi->param('enabled') eq 'on' ) ? 'yes' : 'no';
60 my $course_id = ModCourse(%params);
62 my @instructors = $cgi->param('instructors');
63 ModCourseInstructors(
64 mode => 'replace',
65 cardnumbers => \@instructors,
66 course_id => $course_id
68 print $cgi->redirect("/cgi-bin/koha/course_reserves/course-details.pl?course_id=$course_id");