Lines 42-50
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
42 |
} |
42 |
} |
43 |
); |
43 |
); |
44 |
|
44 |
|
|
|
45 |
my @errors; |
46 |
my @messages; |
47 |
my $colId = $query->param('colId'); |
48 |
my $collection = Koha::RotatingCollections->find($colId); |
49 |
|
45 |
if ( $query->param('action') eq 'addItem' ) { |
50 |
if ( $query->param('action') eq 'addItem' ) { |
46 |
## Add the given item to the collection |
51 |
## Add the given item to the collection |
47 |
my $colId = $query->param('colId'); |
|
|
48 |
my $barcode = $query->param('barcode'); |
52 |
my $barcode = $query->param('barcode'); |
49 |
my $removeItem = $query->param('removeItem'); |
53 |
my $removeItem = $query->param('removeItem'); |
50 |
my $item = Koha::Items->find({barcode => $barcode}); |
54 |
my $item = Koha::Items->find({barcode => $barcode}); |
Lines 55-74
if ( $query->param('action') eq 'addItem' ) {
Link Here
|
55 |
$template->param( barcode => $barcode ); |
59 |
$template->param( barcode => $barcode ); |
56 |
|
60 |
|
57 |
if ( !$removeItem ) { |
61 |
if ( !$removeItem ) { |
58 |
( $success, $errorCode, $errorMessage ) = |
62 |
my $added = eval { $collection->add_item( $item ) }; |
59 |
AddItemToCollection( $colId, $itemnumber ); |
63 |
|
|
|
64 |
if ( $@ or not $added ) { |
65 |
push @errors, { code => 'error_adding_item' }; |
66 |
} else { |
67 |
push @messages, { code => 'success_adding_item' }; |
68 |
} |
60 |
|
69 |
|
61 |
$template->param( |
70 |
$template->param( |
62 |
previousActionAdd => 1, |
71 |
previousActionAdd => 1, |
63 |
); |
72 |
); |
64 |
|
|
|
65 |
if ($success) { |
66 |
$template->param( addSuccess => 1 ); |
67 |
} |
68 |
else { |
69 |
$template->param( addFailure => 1 ); |
70 |
$template->param( failureMessage => $errorMessage ); |
71 |
} |
72 |
} |
73 |
} |
73 |
else { |
74 |
else { |
74 |
## Remove the given item from the collection |
75 |
## Remove the given item from the collection |
Lines 91-101
if ( $query->param('action') eq 'addItem' ) {
Link Here
|
91 |
} |
92 |
} |
92 |
} |
93 |
} |
93 |
|
94 |
|
94 |
my $colId = $query->param('colId'); |
|
|
95 |
my $collection = Koha::RotatingCollections->find($colId); |
96 |
|
97 |
$template->param( |
95 |
$template->param( |
98 |
collection => $collection, |
96 |
collection => $collection, |
|
|
97 |
messages => \@messages, |
98 |
errors => \@errors, |
99 |
); |
99 |
); |
100 |
|
100 |
|
101 |
output_html_with_http_headers $query, $cookie, $template->output; |
101 |
output_html_with_http_headers $query, $cookie, $template->output; |
102 |
- |
|
|