From fe9c1695bf053cc774f2dcc8bdd4dc14b189710c Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 30 Oct 2014 06:58:42 -0400 Subject: [PATCH] Bug 8836 [QA Followup 2] Signed-off-by: Brendan Gallagher --- C4/Circulation.pm | 2 +- C4/RotatingCollections.pm | 37 ++-- installer/data/mysql/updatedatabase.pl | 8 +- .../intranet-tmpl/prog/en/includes/tools-menu.inc | 2 - .../en/modules/rotating_collections/addItems.tt | 164 ++++++++------- .../rotating_collections/editCollections.tt | 209 ++++++++++---------- .../rotating_collections/rotatingCollections.tt | 81 ++++---- .../rotating_collections/transferCollection.tt | 78 ++++---- rotating_collections/addItems.pl | 4 +- rotating_collections/editCollections.pl | 18 +- 10 files changed, 315 insertions(+), 288 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index fa6a99d..aae3ba3 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1899,7 +1899,7 @@ sub AddReturn { my ($datesent,$frombranch,$tobranch) = GetTransfers( $item->{'itemnumber'} ); # if we have a transfer to do, we update the line of transfers with the datearrived - my $is_in_rotating_collection = 1 if C4::RotatingCollections::isItemInAnyCollection( $item->{'itemnumber'} ); + my $is_in_rotating_collection = C4::RotatingCollections::isItemInAnyCollection( $item->{'itemnumber'} ); if ($datesent) { if ( $tobranch eq $branch ) { my $sth = C4::Context->dbh->prepare( diff --git a/C4/RotatingCollections.pm b/C4/RotatingCollections.pm index 5a63cd8..12d835d 100644 --- a/C4/RotatingCollections.pm +++ b/C4/RotatingCollections.pm @@ -26,7 +26,7 @@ use Modern::Perl; use C4::Context; use C4::Circulation; -use C4::Reserves qw(GetReserveStatus); +use C4::Reserves qw(CheckReserves); use DBI; @@ -86,10 +86,10 @@ sub CreateCollection { ## Check for all neccessary parameters if ( !$title ) { - return ( 0, 1, "No Title Given" ); + return ( 0, 1, "NO_TITLE" ); } if ( !$description ) { - return ( 0, 2, "No Description Given" ); + return ( 0, 2, "NO_DESCRIPTION" ); } my $success = 1; @@ -130,13 +130,13 @@ sub UpdateCollection { ## Check for all neccessary parameters if ( !$colId ) { - return ( 0, 1, "No Id Given" ); + return ( 0, 1, "NO_ID" ); } if ( !$title ) { - return ( 0, 2, "No Title Given" ); + return ( 0, 2, "NO_TITLE" ); } if ( !$description ) { - return ( 0, 3, "No Description Given" ); + return ( 0, 3, "NO_DESCRIPTION" ); } my $dbh = C4::Context->dbh; @@ -175,7 +175,7 @@ sub DeleteCollection { ## Paramter check if ( !$colId ) { - return ( 0, 1, "No Collection Id Given" ); + return ( 0, 1, "NO_ID" ); } my $dbh = C4::Context->dbh; @@ -239,7 +239,7 @@ sub GetItemsInCollection { ## Paramter check if ( !$colId ) { - return ( 0, 0, 1, "No Collection Id Given" ); + return ( 0, 0, 1, "NO_ID" ); } my $dbh = C4::Context->dbh; @@ -317,17 +317,17 @@ sub AddItemToCollection { ## Check for all neccessary parameters if ( !$colId ) { - return ( 0, 1, "No Collection Given" ); + return ( 0, 1, "NO_ID" ); } if ( !$itemnumber ) { - return ( 0, 2, "No Itemnumber Given" ); + return ( 0, 2, "NO_ITEM" ); } if ( isItemInThisCollection( $itemnumber, $colId ) ) { - return ( 0, 2, "Item is already in the collection!" ); + return ( 0, 2, "IN_COLLECTION" ); } elsif ( isItemInAnyCollection($itemnumber) ) { - return ( 0, 3, "Item is already in a different collection!" ); + return ( 0, 3, "IN_COLLECTION_OTHER" ); } my $dbh = C4::Context->dbh; @@ -367,11 +367,11 @@ sub RemoveItemFromCollection { ## Check for all neccessary parameters if ( !$itemnumber ) { - return ( 0, 2, "No Itemnumber Given" ); + return ( 0, 2, "NO_ITEM" ); } if ( !isItemInThisCollection( $itemnumber, $colId ) ) { - return ( 0, 2, "Item is not in the collection!" ); + return ( 0, 2, "NOT_IN_COLLECTION" ); } my $dbh = C4::Context->dbh; @@ -408,10 +408,10 @@ sub TransferCollection { ## Check for all neccessary parameters if ( !$colId ) { - return ( 0, 1, "No Id Given" ); + return ( 0, 1, "NO_ID" ); } if ( !$colBranchcode ) { - return ( 0, 2, "No Branchcode Given" ); + return ( 0, 2, "NO_BRANCHCODE" ); } my $dbh = C4::Context->dbh; @@ -435,9 +435,8 @@ sub TransferCollection { $sth->execute($colId) or return ( 0, 4, $sth->errstr ); my @results; while ( my $item = $sth->fetchrow_hashref ) { - transferbook( $colBranchcode, $item->{barcode}, - my $ignore_reserves = 1 ) - unless ( GetReserveStatus( $item->{itemnumber} ) eq "Waiting" ); + my ($status) = CheckReserves( $item->{itemnumber} ); + transferbook( $colBranchcode, $item->{barcode}, my $ignore_reserves = 1 ) unless ( $status eq 'Waiting' ); } return 1; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 7805826..0022815 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8956,13 +8956,9 @@ if ( CheckVersion($DBversion) ) { $DBversion = "3.17.00.XXX"; if ( CheckVersion($DBversion) ) { $dbh->do(q{ - ALTER TABLE collections CHANGE colBranchcode colBranchcode VARCHAR( 10 ) NULL DEFAULT NULL - }); - $dbh->do(q{ - ALTER TABLE collections ADD INDEX ( colBranchcode ) - }); - $dbh->do(q{ ALTER TABLE collections + CHANGE colBranchcode colBranchcode VARCHAR( 10 ) NULL DEFAULT NULL, + ADD INDEX ( colBranchcode ), ADD CONSTRAINT collections_ibfk_1 FOREIGN KEY (colBranchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE }); print "Upgrade to $DBversion done (Bug 8836 - Resurrect Rotating Collections)\n"; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc index 45d9b4e..963195d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc @@ -66,11 +66,9 @@
  • Label creator
  • Quick spine label creator
  • [% END %] - [% IF ( CAN_user_tools_marc_modification_templates ) %]
  • Manage MARC modification templates
  • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt index 195b324..fef190c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt @@ -15,83 +15,107 @@ -
    -
    -
    +
    +
    +
    + [% INCLUDE 'tools-menu.inc' %] +
    -

    Rotating collections: Add/Remove items

    +
    +
    -
    -
    - [% IF ( previousActionAdd ) %] - [% IF ( addSuccess ) %] -
    Item with barcode '[% addedBarcode %]' Added successfully!
    - [% ELSE %] -
    Failed to add item with barcode '[% addedBarcode %]'!
    -
    Reason: [% failureMessage %]
    - [% END %] - [% END %] +

    Rotating collections: Add/Remove items

    - [% IF ( previousActionRemove ) %] - [% IF ( removeSuccess ) %] -
    Item with barcode '[% addedBarcode %]' Removed successfully!
    - [% ELSE %] -
    Failed to remove item with barcode '[% removedBarcode %]'!
    -
    Reason: [% failureMessage %]
    - [% END %] - [% END %] +
    +
    + [% IF ( previousActionAdd ) %] + [% IF ( addSuccess ) %] +
    Item with barcode '[% barcode %]' added successfully!
    + [% ELSE %] +
    +

    Failed to add item with barcode [% barcode %]: +

    + [% IF failureMessage == "NO_ITEM" %] + No item with matching barcode found! + [% ELSIF failureMessage == "IN_COLLECTION_OTHER" %] + Item is already in a different rotating collection! + [% ELSE %] + [% failureMessage %] + [% END %] +

    +
    + [% END %] + [% END %] -

    Add item to [% colTitle %]

    -
    + [% IF ( previousActionRemove ) %] + [% IF ( removeSuccess ) %] +
    Item with barcode [% barcode %] removed successfully!
    + [% ELSE %] +
    + Failed to remove item with barcode [% barcode %]: +

    + [% IF failureMessage == "NO_ITEM" %] + No item with matching barcode found! + [% ELSE %] + [% failureMessage %] + [% END %] +

    +
    + [% END %] + [% END %] -
    -
    - - - - - +

    Add item to [% colTitle %]

    + - - - -
    - - [% IF ( removeChecked ) %] - [% ELSE %][% END %] - -
    -
    -
    +
    +
    + + + + + -
    -

    Items in this collection

    - [% IF ( collectionItemsLoop ) %] -
    + + [% IF ( removeChecked ) %] + [% ELSE %][% END %] + +
    - - - - - - [% FOREACH collectionItemsLoo IN collectionItemsLoop %] - - - - - - [% END %] -
    TitleCall numberBarcode
    [% collectionItemsLoo.title |html %][% collectionItemsLoo.itemcallnumber %][% collectionItemsLoo.barcode %]
    - [% ELSE %] - There are no items in this collection. - [% END %] -
    + + + + + +
    -
    -
    - -
    +
    +

    Items in this collection

    + [% IF ( collectionItemsLoop ) %] + + + + + + + [% FOREACH collectionItemsLoo IN collectionItemsLoop %] + + + + + + [% END %] +
    TitleCall numberBarcode
    [% collectionItemsLoo.title |html %][% collectionItemsLoo.itemcallnumber %][% collectionItemsLoo.barcode %]
    + [% ELSE %] + There are no items in this collection. + [% END %] +
    -
    -
    -[% INCLUDE 'intranet-bottom.inc' %] +
    +
    + +
    + +
    +
    +
    +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt index e1bb2a8..fa1099a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt @@ -8,125 +8,118 @@ -
    -
    -
    -

    Rotating collections: Edit collections

    +
    +
    +
    + [% INCLUDE 'tools-menu.inc' %] +
    - + [% IF ( previousActionCreate ) %] + [% IF ( createSuccess ) %] +
    Collection [% createdTitle %] created successfully!
    + [% ELSE %] +
    +

    Collection [% createdTitle %] failed to be created!

    +

    + [% IF failureMessage == "NO_TITLE" %] + No title entered. + [% ELSIF failureMessage == "NO_DESCRIPTION" %] + No description entered. + [% ELSE %] + [% failureMessage %] + [% END %] +

    +
    + [% END %] + [% END %] + + [% IF ( previousActionDelete ) %] + [% IF ( deleteSuccess ) %] +
    Collection deleted successfully!
    + [% ELSE %] +
    Collection failed to be deleted!
    + [% END %] + [% END %] - [% IF ( previousActionUpdate ) %] - [% IF ( updateSuccess ) %] -
    Collection '[% updatedTitle %]' Updated successfully!
    - [% ELSE %] -
    Collection '[% updatedTitle %]' Failed to be updated!
    -
    Reason: [% failureMessage %]
    - [% END %] - [% END %] + [% IF ( previousActionUpdate ) %] + [% IF ( updateSuccess ) %] +
    Collection [% updatedTitle %] updated successfully!
    + [% ELSE %] +
    +

    Collection [% updatedTitle %] failed to be updated!

    +

    + [% IF failureMessage == "NO_ID" %] + No collection id given. + [% ELSE %] + [% failureMessage %] + [% END %] +

    +
    + [% END %] + [% END %] -
    - [% IF ( collectionsLoop ) %] - - - - - - - - - - - - [% FOREACH collectionsLoo IN collectionsLoop %] - - - - - - - - [% END %] - -
    TitleDescriptionHolding library  
    [% collectionsLoo.colTitle %][% collectionsLoo.colDesc %][% collectionsLoo.colBranchcode %]EditDelete
    - [% ELSE %] - There are no collections currently defined. - [% END %] -
    +
    +
    -
    -
    + [% IF action == "new" || action == "edit" %] + [% IF ( previousActionEdit ) %] +

    Edit collection [% editColTitle %]

    + [% ELSE %] +

    Create new collection

    + [% END %] - [% IF ( previousActionEdit ) %] -

    Edit Collection

    - [% ELSE %] -

    Create new collection

    - [% END %] +
    + [% IF ( previousActionEdit ) %] + + + [% ELSE %] + + [% END %] - - [% IF ( previousActionEdit ) %] - - - [% ELSE %] - - [% END %] + + + + + -
    + + + [% IF ( editColTitle ) %] + [% ELSE %][% END %] +
    - - - - - - - - - + + + + - - + + +
    - - - [% IF ( editColTitle ) %] - [% ELSE %][% END %] -
    - - - [% IF (editColDescription ) %] - [% ELSE %][% END %] -
    + + + [% IF (editColDescription ) %] + [% ELSE %][% END %] +
    - [% IF ( previousActionEdit ) %] - - [% ELSE %] - +
    + [% IF ( previousActionEdit ) %] + + [% ELSE %] + + [% END %] +
    +
    [% END %] - - - - -
    +
    -
    -
    - -
    +

    + Return to rotating collections home +

    -
    -
    +
    +
    +
    [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt index e1780ad..0a893ab 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt @@ -1,3 +1,4 @@ +[% USE Branches %] [% INCLUDE 'doc-head-open.inc' %] Koha › Tools › Rotating collections [% INCLUDE 'doc-head-close.inc' %] @@ -8,40 +9,50 @@ -
    -
    -
    +
    +
    +
    + [% INCLUDE 'tools-menu.inc' %] +
    -

    Rotating collections

    -
    - [% IF ( collectionsLoop ) %] - - - - - - - - - [% FOREACH collectionsLoo IN collectionsLoop %] - - - - - - - - [% END %] -
    TitleDescriptionCurrent locationAdd/Remove itemsTransfer collection
    [% collectionsLoo.colTitle %][% collectionsLoo.colDesc %][% collectionsLoo.colBranchcode %]Add/Remove ItemsTransfer Collection
    - [% ELSE %] - There are no collections currently defined. - [% END %] -
    +
    +
    -
    -
    - -
    -
    -
    -[% INCLUDE 'intranet-bottom.inc' %] \ No newline at end of file +

    Rotating collections

    +
    + [% IF ( collectionsLoop ) %] + + + + + + + + + + + + [% FOREACH collectionsLoo IN collectionsLoop %] + + + + + + + + + + [% END %] +
    TitleDescriptionCurrent location    
    [% collectionsLoo.colTitle %][% collectionsLoo.colDesc %][% Branches.GetName( collectionsLoo.colBranchcode ) %]Add/remove itemsTransferEditDelete
    + [% ELSE %] + There are no collections currently defined. + [% END %] +
    + +

    + Create collection +

    +
    +
    +
    +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt index 25f2cb2..fe582f6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt @@ -7,42 +7,50 @@ [% INCLUDE 'cat-search.inc' %] -
    -
    -
    -

    Rotating collections: Transfer collection

    -
    - [% IF ( transferSuccess ) %] -
    Collection transferred successfully
    - [% END %] - - [% IF ( transferFailure ) %] -
    Failed to transfer collection!
    -
    Reason: [% errorMessage %]
    - [% END %] - - [% IF ( transferSuccess ) %] - [% ELSE %] -
    -
    - - - - - -
    + +
    +
    +
    + [% INCLUDE 'tools-menu.inc' %]
    - [% END %] -
    -
    - -
    +
    +
    +

    Rotating collections: Transfer collection

    + + [% IF ( transferSuccess ) %] +
    Collection transferred successfully
    + [% ELSIF ( transferFailure ) %] +
    Failed to transfer collection!
    + [% END %] + + [% IF ( transferSuccess ) %] + [% ELSE %] +
    +
    + + + + -
    -
    + + +
    + [% END %] + +

    + Return to rotating collections home +

    + +
    +
    +
    [% INCLUDE 'intranet-bottom.inc' %] diff --git a/rotating_collections/addItems.pl b/rotating_collections/addItems.pl index 10be5cb..df87908 100755 --- a/rotating_collections/addItems.pl +++ b/rotating_collections/addItems.pl @@ -48,13 +48,14 @@ if ( $query->param('action') eq 'addItem' ) { my ( $success, $errorCode, $errorMessage ); + $template->param( barcode => $barcode ); + if ( !$removeItem ) { ( $success, $errorCode, $errorMessage ) = AddItemToCollection( $colId, $itemnumber ); $template->param( previousActionAdd => 1, - addedBarcode => $barcode, ); if ($success) { @@ -72,7 +73,6 @@ if ( $query->param('action') eq 'addItem' ) { $template->param( previousActionRemove => 1, - removedBarcode => $barcode, removeChecked => 1, ); diff --git a/rotating_collections/editCollections.pl b/rotating_collections/editCollections.pl index 39e94a5..4372074 100755 --- a/rotating_collections/editCollections.pl +++ b/rotating_collections/editCollections.pl @@ -39,8 +39,11 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +my $action = $query->param('action'); +$template->param( action => $action ); + # Create new Collection -if ( $query->param('action') eq 'create' ) { +if ( $action eq 'create' ) { my $title = $query->param('title'); my $description = $query->param('description'); @@ -62,7 +65,7 @@ if ( $query->param('action') eq 'create' ) { } ## Delete a club or service -elsif ( $query->param('action') eq 'delete' ) { +elsif ( $action eq 'delete' ) { my $colId = $query->param('colId'); my ( $success, $errorCode, $errorMessage ) = DeleteCollection($colId); @@ -77,9 +80,8 @@ elsif ( $query->param('action') eq 'delete' ) { } ## 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); +elsif ( $action eq 'edit' ) { + my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection( $query->param('colId') ); $template->param( previousActionEdit => 1, @@ -90,7 +92,7 @@ elsif ( $query->param('action') eq 'edit' ) { } # Update a Club or Service -elsif ( $query->param('action') eq 'update' ) { +elsif ( $action eq 'update' ) { my $colId = $query->param('colId'); my $title = $query->param('title'); my $description = $query->param('description'); @@ -112,15 +114,11 @@ elsif ( $query->param('action') eq 'update' ) { } } -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; -- 1.7.10.4