Koha/rotating_collections/editCollections.pl
Frédéric Demians f650aad34b Rotating Collections
This feature is designed to manage collections of items that move
from library to library periodically. Koha can already track who *has*
and item, and who *owns* and item, but not who *should have* an item.
That is the issue this feature addresses.

It allows a persion to create a collection, and add any number of items
to that collection. The collection can then be transferred from library
to library. If an item shows up at a library that does not currently
'hold' that collection, Koha will ask you to transfer it to the library
that does currently 'hold it. In that way, one can even transfer
collections where some of the items are currently checked out. As soon
as they make it back to a library, they will get transferred to the
current library holding that collection.

The feature consists of 4 main pages.
'Home' Page: The landing page, lists collections and provides access to
the rest of the tools.
  Access is via the Tools page.
Edit Collections: Add/Delete new rotating collections
Add/Remove Items: Add/Remove items from a given collection
Transfer Collection: Set the current 'holder' of a given collection.

Librarian access is controlled by 'CAN_user_tools_rotating_collections'
2010-01-20 22:35:15 +01:00

103 lines
3.1 KiB
Perl
Executable file

#!/usr/bin/perl
use strict;
require Exporter;
use CGI;
use C4::Output;
use C4::Auth;
use C4::Context;
use C4::RotatingCollections;
my $query = new CGI;
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "rotating_collections/editCollections.tmpl",
query => $query,
type => "intranet",
authnotrequired => 1,
flagsrequired => {parameters => 1},
debug => 1,
});
# Create new Collection
if ( $query->param('action') eq 'create' ) {
my $title = $query->param('title');
my $description = $query->param('description');
my ( $createdSuccessfully, $errorCode, $errorMessage ) = CreateCollection( $title, $description );
$template->param(
previousActionCreate => 1,
createdTitle => $title,
);
if ( $createdSuccessfully ) {
$template->param( createSuccess => 1 );
} else {
$template->param( createFailure => 1 );
$template->param( failureMessage => $errorMessage );
}
}
## Delete a club or service
elsif ( $query->param('action') eq 'delete' ) {
my $colId = $query->param('colId');
my ( $success, $errorCode, $errorMessage ) = DeleteCollection( $colId );
$template->param( previousActionDelete => 1 );
if ( $success ) {
$template->param( deleteSuccess => 1 );
} else {
$template->param( deleteFailure => 1 );
$template->param( failureMessage => $errorMessage );
}
}
## Edit a club or service: grab data, put in form.
elsif ( $query->param('action') eq 'edit' ) {
my $colId = $query->param('colId');
my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection( $colId );
$template->param(
previousActionEdit => 1,
editColId => $colId,
editColTitle => $colTitle,
editColDescription => $colDesc,
);
}
# Update a Club or Service
elsif ( $query->param('action') eq 'update' ) {
my $colId = $query->param('colId');
my $title = $query->param('title');
my $description = $query->param('description');
my ( $createdSuccessfully, $errorCode, $errorMessage )
= UpdateCollection( $colId, $title, $description );
$template->param(
previousActionUpdate => 1,
updatedTitle => $title,
);
if ( $createdSuccessfully ) {
$template->param( updateSuccess => 1 );
} else {
$template->param( updateFailure => 1 );
$template->param( failureMessage => $errorMessage );
}
}
my $collections = GetCollections();
$template->param(
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
IntranetNav => C4::Context->preference("IntranetNav"),
collectionsLoop => $collections,
);
output_html_with_http_headers $query, $cookie, $template->output;