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