4 # Copyright 2012 Bywater Solutions
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
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.
31 use C4::CourseReserves;
35 my $action = $cgi->param('action') || '';
36 my $course_id = $cgi->param('course_id') || '';
37 my $barcode = $cgi->param('barcode') || '';
39 die('No course_id provided') unless ($course_id);
41 my $item = GetBiblioFromItemNumber( undef, $barcode );
43 my $step = ( $action eq 'lookup' && $item ) ? '2' : '1';
45 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
47 template_name => "course_reserves/add_items-step$step.tmpl",
51 flagsrequired => { coursereserves => 'add_reserves' },
54 $template->param( ERROR_BARCODE_NOT_FOUND => $barcode )
55 unless ( $barcode && $item && $action eq 'lookup' );
57 $template->param( course => GetCourse($course_id) );
59 if ( $action eq 'lookup' ) {
60 my $course_item = GetCourseItem( itemnumber => $item->{'itemnumber'} );
61 my $course_reserve = ($course_item)
63 course_id => $course_id,
64 ci_id => $course_item->{'ci_id'}
70 course_item => $course_item,
71 course_reserve => $course_reserve,
73 ccodes => GetAuthorisedValues('CCODE'),
74 locations => GetAuthorisedValues('LOC'),
75 itypes => GetItemTypes( style => 'array' ),
76 branches => GetBranchesLoop(),
80 elsif ( $action eq 'add' ) {
81 my $ci_id = ModCourseItem(
82 itemnumber => $cgi->param('itemnumber'),
83 itype => $cgi->param('itype'),
84 ccode => $cgi->param('ccode'),
85 holdingbranch => $cgi->param('holdingbranch'),
86 location => $cgi->param('location'),
89 my $cr_id = ModCourseReserve(
90 course_id => $course_id,
92 staff_note => $cgi->param('staff_note'),
93 public_note => $cgi->param('public_note'),
97 output_html_with_http_headers $cgi, $cookie, $template->output;