bug 5309: tweak so that background progress doesn't exit immediately
[koha.git] / rotating_collections / addItems.pl
blobacde79aab4413b8edc1f9165a956bc539afdb17d
1 #!/usr/bin/perl
2 use strict;
3 #use warnings; FIXME - Bug 2505
4 require Exporter;
6 use C4::Output;
7 use C4::Auth;
8 use C4::Context;
9 use C4::RotatingCollections;
10 use C4::Items;
12 use CGI;
14 my $query = new CGI;
15 my ($template, $loggedinuser, $cookie)
16 = get_template_and_user({template_name => "rotating_collections/addItems.tmpl",
17 query => $query,
18 type => "intranet",
19 authnotrequired => 1,
20 flagsrequired => {parameters => 1},
21 debug => 1,
22 });
24 if ( $query->param('action') eq 'addItem' ) {
25 ## Add the given item to the collection
26 my $colId = $query->param('colId');
27 my $barcode = $query->param('barcode');
28 my $removeItem = $query->param('removeItem');
29 my $itemnumber = GetItemnumberFromBarcode( $barcode );
31 my ( $success, $errorCode, $errorMessage );
33 if ( ! $removeItem ) {
34 ( $success, $errorCode, $errorMessage ) = AddItemToCollection( $colId, $itemnumber );
36 $template->param(
37 previousActionAdd => 1,
38 addedBarcode => $barcode,
41 if ( $success ) {
42 $template->param( addSuccess => 1 );
43 } else {
44 $template->param( addFailure => 1 );
45 $template->param( failureMessage => $errorMessage );
47 } else {
48 ## Remove the given item from the collection
49 ( $success, $errorCode, $errorMessage ) = RemoveItemFromCollection( $colId, $itemnumber );
51 $template->param(
52 previousActionRemove => 1,
53 removedBarcode => $barcode,
54 removeChecked => 1,
57 if ( $success ) {
58 $template->param( removeSuccess => 1 );
59 } else {
60 $template->param( removeFailure => 1 );
61 $template->param( failureMessage => $errorMessage );
67 my ( $colId, $colTitle, $colDescription, $colBranchcode ) = GetCollection( $query->param('colId') );
68 my $collectionItems = GetItemsInCollection( $colId );
69 if ( $collectionItems ) {
70 $template->param( collectionItemsLoop => $collectionItems );
73 $template->param(
74 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
75 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
76 IntranetNav => C4::Context->preference("IntranetNav"),
78 colId => $colId,
79 colTitle => $colTitle,
80 colDescription => $colDescription,
81 colBranchcode => $colBranchcode,
84 output_html_with_http_headers $query, $cookie, $template->output;