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