|
Lines 52-101
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
| 52 |
} |
52 |
} |
| 53 |
); |
53 |
); |
| 54 |
|
54 |
|
| 55 |
$template->param( course => GetCourse($course_id) ); |
55 |
my $course = GetCourse($course_id); |
| 56 |
|
56 |
|
| 57 |
if ( !$action ) { |
57 |
if ( $course_id && $course ) { |
| 58 |
$template->param( action => 'display_form' ); |
58 |
$template->param( course => $course ); |
| 59 |
} |
|
|
| 60 |
elsif ( $action eq 'add' ) { |
| 61 |
my @barcodes = uniq( split( /\s\n/, $barcodes ) ); |
| 62 |
|
| 63 |
my @items; |
| 64 |
my @invalid_barcodes; |
| 65 |
for my $b (@barcodes) { |
| 66 |
my $item = Koha::Items->find( { barcode => $b } ); |
| 67 |
|
59 |
|
| 68 |
if ($item) { |
60 |
if ( !$action ) { |
| 69 |
push( @items, $item ); |
61 |
$template->param( action => 'display_form' ); |
| 70 |
} |
|
|
| 71 |
else { |
| 72 |
push( @invalid_barcodes, $b ); |
| 73 |
} |
| 74 |
} |
62 |
} |
|
|
63 |
elsif ( $action eq 'add' ) { |
| 64 |
my @barcodes = uniq( split( /\s\n/, $barcodes ) ); |
| 65 |
|
| 66 |
my @items; |
| 67 |
my @invalid_barcodes; |
| 68 |
for my $b (@barcodes) { |
| 69 |
my $item = Koha::Items->find( { barcode => $b } ); |
| 70 |
|
| 71 |
if ($item) { |
| 72 |
push( @items, $item ); |
| 73 |
} |
| 74 |
else { |
| 75 |
push( @invalid_barcodes, $b ); |
| 76 |
} |
| 77 |
} |
| 75 |
|
78 |
|
| 76 |
foreach my $item (@items) { |
79 |
foreach my $item (@items) { |
| 77 |
my $ci_id = ModCourseItem( |
80 |
my $ci_id = ModCourseItem( |
| 78 |
itemnumber => $item->id, |
81 |
itemnumber => $item->id, |
| 79 |
itype => $itype, |
82 |
itype => $itype, |
| 80 |
ccode => $ccode, |
83 |
ccode => $ccode, |
| 81 |
holdingbranch => $holdingbranch, |
84 |
holdingbranch => $holdingbranch, |
| 82 |
location => $location, |
85 |
location => $location, |
| 83 |
); |
86 |
); |
|
|
87 |
|
| 88 |
my $cr_id = ModCourseReserve( |
| 89 |
course_id => $course_id, |
| 90 |
ci_id => $ci_id, |
| 91 |
staff_note => $staff_note, |
| 92 |
public_note => $public_note, |
| 93 |
); |
| 94 |
} |
| 84 |
|
95 |
|
| 85 |
my $cr_id = ModCourseReserve( |
96 |
$template->param( |
| 86 |
course_id => $course_id, |
97 |
action => 'display_results', |
| 87 |
ci_id => $ci_id, |
98 |
items_added => \@items, |
| 88 |
staff_note => $staff_note, |
99 |
invalid_barcodes => \@invalid_barcodes, |
| 89 |
public_note => $public_note, |
100 |
course_id => $course_id, |
| 90 |
); |
101 |
); |
| 91 |
} |
102 |
} |
| 92 |
|
103 |
} else { |
| 93 |
$template->param( |
104 |
$template->param( action => 'invalid_course' ); |
| 94 |
action => 'display_results', |
|
|
| 95 |
items_added => \@items, |
| 96 |
invalid_barcodes => \@invalid_barcodes, |
| 97 |
course_id => $course_id, |
| 98 |
); |
| 99 |
} |
105 |
} |
| 100 |
|
106 |
|
| 101 |
output_html_with_http_headers $cgi, $cookie, $template->output; |
107 |
output_html_with_http_headers $cgi, $cookie, $template->output; |