Bugzilla – Attachment 19119 Details for
Bug 8836
Resurrect Rotating Collections
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8836 - Resurrect Rotating Collections - Followup 2 - Perltidy rotating collections scripts
Bug-8836---Resurrect-Rotating-Collections---Follow.patch (text/plain), 32.19 KB, created by
Kyle M Hall (khall)
on 2013-06-18 14:46:40 UTC
(
hide
)
Description:
Bug 8836 - Resurrect Rotating Collections - Followup 2 - Perltidy rotating collections scripts
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-06-18 14:46:40 UTC
Size:
32.19 KB
patch
obsolete
>From 828a00697afaa365b4c2b52473d163ccae2307ce Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 18 Jun 2013 10:36:46 -0400 >Subject: [PATCH] Bug 8836 - Resurrect Rotating Collections - Followup 2 - Perltidy rotating collections scripts > >--- > C4/RotatingCollections.pm | 511 ++++++++++++++------------- > rotating_collections/addItems.pl | 127 ++++--- > rotating_collections/editCollections.pl | 143 ++++---- > rotating_collections/rotatingCollections.pl | 33 +- > rotating_collections/transferCollection.pl | 80 +++-- > 5 files changed, 470 insertions(+), 424 deletions(-) > >diff --git a/C4/RotatingCollections.pm b/C4/RotatingCollections.pm >index e7506bd..9fbb11c 100644 >--- a/C4/RotatingCollections.pm >+++ b/C4/RotatingCollections.pm >@@ -1,9 +1,9 @@ > package C4::RotatingCollections; > >-# $Id: RotatingCollections.pm,v 0.1 2007/04/20 kylemhall >+# $Id: RotatingCollections.pm,v 0.1 2007/04/20 kylemhall > > # This package is inteded to keep track of what library >-# Items of a certain collection should be at. >+# Items of a certain collection should be at. > > # Copyright 2007 Kyle Hall > # >@@ -81,28 +81,29 @@ BEGIN { > =cut > > sub CreateCollection { >- my ( $title, $description ) = @_; >+ my ( $title, $description ) = @_; > >- ## Check for all neccessary parameters >- if ( ! $title ) { >- return ( 0, 1, "No Title Given" ); >- } >- if ( ! $description ) { >- return ( 0, 2, "No Description Given" ); >- } >+ ## Check for all neccessary parameters >+ if ( !$title ) { >+ return ( 0, 1, "No Title Given" ); >+ } >+ if ( !$description ) { >+ return ( 0, 2, "No Description Given" ); >+ } > >- my $success = 1; >+ my $success = 1; > >- my $dbh = C4::Context->dbh; >+ my $dbh = C4::Context->dbh; > >- my $sth; >- $sth = $dbh->prepare("INSERT INTO collections ( colId, colTitle, colDesc ) >- VALUES ( NULL, ?, ? )"); >- $sth->execute( $title, $description ) or return ( 0, 3, $sth->errstr() ); >- $sth->finish; >+ my $sth; >+ $sth = $dbh->prepare(" >+ INSERT INTO collections ( colId, colTitle, colDesc ) VALUES ( NULL, ?, ? ) >+ "); >+ $sth->execute( $title, $description ) or return ( 0, 3, $sth->errstr() ); >+ $sth->finish; >+ >+ return 1; > >- return 1; >- > } > > =head2 UpdateCollection >@@ -124,31 +125,31 @@ Updates a collection > =cut > > sub UpdateCollection { >- my ( $colId, $title, $description ) = @_; >- >- ## Check for all neccessary parameters >- if ( ! $colId ) { >- return ( 0, 1, "No Id Given" ); >- } >- if ( ! $title ) { >- return ( 0, 2, "No Title Given" ); >- } >- if ( ! $description ) { >- return ( 0, 3, "No Description Given" ); >- } >- >- my $dbh = C4::Context->dbh; >- >- my $sth; >- $sth = $dbh->prepare("UPDATE collections >- SET >- colTitle = ?, colDesc = ? >- WHERE colId = ?"); >- $sth->execute( $title, $description, $colId ) or return ( 0, 4, $sth->errstr() ); >- $sth->finish; >- >- return 1; >- >+ my ( $colId, $title, $description ) = @_; >+ >+ ## Check for all neccessary parameters >+ if ( !$colId ) { >+ return ( 0, 1, "No Id Given" ); >+ } >+ if ( !$title ) { >+ return ( 0, 2, "No Title Given" ); >+ } >+ if ( !$description ) { >+ return ( 0, 3, "No Description Given" ); >+ } >+ >+ my $dbh = C4::Context->dbh; >+ >+ my $sth; >+ $sth = $dbh->prepare(" >+ UPDATE collections SET colTitle = ?, colDesc = ? WHERE colId = ? >+ "); >+ $sth->execute( $title, $description, $colId ) >+ or return ( 0, 4, $sth->errstr() ); >+ $sth->finish; >+ >+ return 1; >+ > } > > =head2 DeleteCollection >@@ -167,22 +168,22 @@ sub UpdateCollection { > =cut > > sub DeleteCollection { >- my ( $colId ) = @_; >+ my ($colId) = @_; > >- ## Paramter check >- if ( ! $colId ) { >- return ( 0, 1, "No Collection Id Given" );; >- } >- >- my $dbh = C4::Context->dbh; >+ ## Paramter check >+ if ( !$colId ) { >+ return ( 0, 1, "No Collection Id Given" ); >+ } > >- my $sth; >+ my $dbh = C4::Context->dbh; > >- $sth = $dbh->prepare("DELETE FROM collections WHERE colId = ?"); >- $sth->execute( $colId ) or return ( 0, 4, $sth->errstr() ); >- $sth->finish; >+ my $sth; > >- return 1; >+ $sth = $dbh->prepare("DELETE FROM collections WHERE colId = ?"); >+ $sth->execute($colId) or return ( 0, 4, $sth->errstr() ); >+ $sth->finish; >+ >+ return 1; > } > > =head2 GetCollections >@@ -201,19 +202,19 @@ sub DeleteCollection { > > sub GetCollections { > >- my $dbh = C4::Context->dbh; >- >- my $sth = $dbh->prepare("SELECT * FROM collections"); >- $sth->execute() or return ( 1, $sth->errstr() ); >- >- my @results; >- while ( my $row = $sth->fetchrow_hashref ) { >- push( @results , $row ); >- } >- >- $sth->finish; >- >- return \@results; >+ my $dbh = C4::Context->dbh; >+ >+ my $sth = $dbh->prepare("SELECT * FROM collections"); >+ $sth->execute() or return ( 1, $sth->errstr() ); >+ >+ my @results; >+ while ( my $row = $sth->fetchrow_hashref ) { >+ push( @results, $row ); >+ } >+ >+ $sth->finish; >+ >+ return \@results; > } > > =head2 GetItemsInCollection >@@ -234,34 +235,39 @@ sub GetCollections { > =cut > > sub GetItemsInCollection { >- my ( $colId ) = @_; >- >- ## Paramter check >- if ( ! $colId ) { >- return ( 0, 0, 1, "No Collection Id Given" );; >- } >- >- my $dbh = C4::Context->dbh; >- >- my $sth = $dbh->prepare("SELECT >- biblio.title, >- items.itemcallnumber, >- items.barcode >- FROM collections, collections_tracking, items, biblio >- WHERE collections.colId = collections_tracking.colId >- AND collections_tracking.itemnumber = items.itemnumber >- AND items.biblionumber = biblio.biblionumber >- AND collections.colId = ? ORDER BY biblio.title"); >- $sth->execute( $colId ) or return ( 0, 0, 2, $sth->errstr() ); >- >- my @results; >- while ( my $row = $sth->fetchrow_hashref ) { >- push( @results , $row ); >- } >- >- $sth->finish; >- >- return \@results; >+ my ($colId) = @_; >+ >+ ## Paramter check >+ if ( !$colId ) { >+ return ( 0, 0, 1, "No Collection Id Given" ); >+ } >+ >+ my $dbh = C4::Context->dbh; >+ >+ my $sth = $dbh->prepare(" >+ SELECT >+ biblio.title, >+ items.itemcallnumber, >+ items.barcode >+ FROM >+ collections, >+ collections_tracking, >+ items, biblio >+ WHERE collections.colId = collections_tracking.colId >+ AND collections_tracking.itemnumber = items.itemnumber >+ AND items.biblionumber = biblio.biblionumber >+ AND collections.colId = ? ORDER BY biblio.title >+ "); >+ $sth->execute($colId) or return ( 0, 0, 2, $sth->errstr() ); >+ >+ my @results; >+ while ( my $row = $sth->fetchrow_hashref ) { >+ push( @results, $row ); >+ } >+ >+ $sth->finish; >+ >+ return \@results; > } > > =head2 GetCollection >@@ -278,25 +284,23 @@ Returns information about a collection > =cut > > sub GetCollection { >- my ( $colId ) = @_; >- >- my $dbh = C4::Context->dbh; >- >- my ( $sth, @results ); >- $sth = $dbh->prepare("SELECT * FROM collections WHERE colId = ?"); >- $sth->execute( $colId ) or return 0; >- >- my $row = $sth->fetchrow_hashref; >- >- $sth->finish; >- >- return ( >- $$row{'colId'}, >- $$row{'colTitle'}, >- $$row{'colDesc'}, >- $$row{'colBranchcode'} >- ); >- >+ my ($colId) = @_; >+ >+ my $dbh = C4::Context->dbh; >+ >+ my ( $sth, @results ); >+ $sth = $dbh->prepare("SELECT * FROM collections WHERE colId = ?"); >+ $sth->execute($colId) or return 0; >+ >+ my $row = $sth->fetchrow_hashref; >+ >+ $sth->finish; >+ >+ return ( >+ $$row{'colId'}, $$row{'colTitle'}, >+ $$row{'colDesc'}, $$row{'colBranchcode'} >+ ); >+ > } > > =head2 AddItemToCollection >@@ -316,32 +320,38 @@ Adds an item to a rotating collection. > =cut > > sub AddItemToCollection { >- my ( $colId, $itemnumber ) = @_; >- >- ## Check for all neccessary parameters >- if ( ! $colId ) { >- return ( 0, 1, "No Collection Given" ); >- } >- if ( ! $itemnumber ) { >- return ( 0, 2, "No Itemnumber Given" ); >- } >- >- if ( isItemInThisCollection( $itemnumber, $colId ) ) { >- return ( 0, 2, "Item is already in the collection!" ); >- } elsif ( isItemInAnyCollection( $itemnumber ) ) { >- return ( 0, 3, "Item is already in a different collection!" ); >- } >- >- my $dbh = C4::Context->dbh; >- >- my $sth; >- $sth = $dbh->prepare("INSERT INTO collections_tracking ( ctId, colId, itemnumber ) >- VALUES ( NULL, ?, ? )"); >- $sth->execute( $colId, $itemnumber ) or return ( 0, 3, $sth->errstr() ); >- $sth->finish; >- >- return 1; >- >+ my ( $colId, $itemnumber ) = @_; >+ >+ ## Check for all neccessary parameters >+ if ( !$colId ) { >+ return ( 0, 1, "No Collection Given" ); >+ } >+ if ( !$itemnumber ) { >+ return ( 0, 2, "No Itemnumber Given" ); >+ } >+ >+ if ( isItemInThisCollection( $itemnumber, $colId ) ) { >+ return ( 0, 2, "Item is already in the collection!" ); >+ } >+ elsif ( isItemInAnyCollection($itemnumber) ) { >+ return ( 0, 3, "Item is already in a different collection!" ); >+ } >+ >+ my $dbh = C4::Context->dbh; >+ >+ my $sth; >+ $sth = $dbh->prepare(" >+ INSERT INTO collections_tracking ( >+ ctId, >+ colId, i >+ temnumber >+ ) VALUES ( NULL, ?, ? ) >+ "); >+ $sth->execute( $colId, $itemnumber ) or return ( 0, 3, $sth->errstr() ); >+ $sth->finish; >+ >+ return 1; >+ > } > > =head2 RemoveItemFromCollection >@@ -362,26 +372,25 @@ Removes an item to a collection > =cut > > sub RemoveItemFromCollection { >- my ( $colId, $itemnumber ) = @_; >- >- ## Check for all neccessary parameters >- if ( ! $itemnumber ) { >- return ( 0, 2, "No Itemnumber Given" ); >- } >- >- if ( ! isItemInThisCollection( $itemnumber, $colId ) ) { >- return ( 0, 2, "Item is not in the collection!" ); >- } >- >- my $dbh = C4::Context->dbh; >- >- my $sth; >- $sth = $dbh->prepare("DELETE FROM collections_tracking >- WHERE itemnumber = ?"); >- $sth->execute( $itemnumber ) or return ( 0, 3, $sth->errstr() ); >- $sth->finish; >- >- return 1; >+ my ( $colId, $itemnumber ) = @_; >+ >+ ## Check for all neccessary parameters >+ if ( !$itemnumber ) { >+ return ( 0, 2, "No Itemnumber Given" ); >+ } >+ >+ if ( !isItemInThisCollection( $itemnumber, $colId ) ) { >+ return ( 0, 2, "Item is not in the collection!" ); >+ } >+ >+ my $dbh = C4::Context->dbh; >+ >+ my $sth; >+ $sth = $dbh->prepare("DELETE FROM collections_tracking WHERE itemnumber = ?"); >+ $sth->execute($itemnumber) or return ( 0, 3, $sth->errstr() ); >+ $sth->finish; >+ >+ return 1; > } > > =head2 TransferCollection >@@ -402,39 +411,41 @@ Transfers a collection to another branch > =cut > > sub TransferCollection { >- my ( $colId, $colBranchcode ) = @_; >- >- ## Check for all neccessary parameters >- if ( ! $colId ) { >- return ( 0, 1, "No Id Given" ); >- } >- if ( ! $colBranchcode ) { >- return ( 0, 2, "No Branchcode Given" ); >- } >- >- my $dbh = C4::Context->dbh; >- >- my $sth; >- $sth = $dbh->prepare("UPDATE collections >- SET >- colBranchcode = ? >- WHERE colId = ?"); >- $sth->execute( $colBranchcode, $colId ) or return ( 0, 4, $sth->errstr() ); >- $sth->finish; >- >- $sth = $dbh->prepare("SELECT barcode FROM items, collections_tracking >- WHERE items.itemnumber = collections_tracking.itemnumber >- AND collections_tracking.colId = ?"); >- $sth->execute( $colId ) or return ( 0, 4, $sth->errstr ); >- my @results; >- while ( my $item = $sth->fetchrow_hashref ) { >- my ( $dotransfer, $messages, $iteminformation ) = transferbook( $colBranchcode, $item->{'barcode'}, my $ignore_reserves = 1); >- } >- >- >- >- return 1; >- >+ my ( $colId, $colBranchcode ) = @_; >+ >+ ## Check for all neccessary parameters >+ if ( !$colId ) { >+ return ( 0, 1, "No Id Given" ); >+ } >+ if ( !$colBranchcode ) { >+ return ( 0, 2, "No Branchcode Given" ); >+ } >+ >+ my $dbh = C4::Context->dbh; >+ >+ my $sth; >+ $sth = $dbh->prepare("UPDATE collections SET colBranchcode = ? WHERE colId = ?"); >+ $sth->execute( $colBranchcode, $colId ) or return ( 0, 4, $sth->errstr() ); >+ $sth->finish; >+ >+ $sth = $dbh->prepare(" >+ SELECT barcode >+ FROM >+ items, >+ collections_tracking >+ WHERE items.itemnumber = collections_tracking.itemnumber >+ AND collections_tracking.colId = ? >+ "); >+ $sth->execute($colId) or return ( 0, 4, $sth->errstr ); >+ my @results; >+ while ( my $item = $sth->fetchrow_hashref ) { >+ my ( $dotransfer, $messages, $iteminformation ) = >+ transferbook( $colBranchcode, $item->{'barcode'}, >+ my $ignore_reserves = 1 ); >+ } >+ >+ return 1; >+ > } > > =head2 GetCollectionItemBranches >@@ -444,29 +455,34 @@ sub TransferCollection { > =cut > > sub GetCollectionItemBranches { >- my ( $itemnumber ) = @_; >- >- if ( ! $itemnumber ) { >- return; >- } >- >- my $dbh = C4::Context->dbh; >- >- my ( $sth, @results ); >- $sth = $dbh->prepare("SELECT holdingbranch, colBranchcode FROM items, collections, collections_tracking >- WHERE items.itemnumber = collections_tracking.itemnumber >- AND collections.colId = collections_tracking.colId >- AND items.itemnumber = ?"); >- $sth->execute( $itemnumber ); >- >- my $row = $sth->fetchrow_hashref; >- >- $sth->finish; >- >- return ( >- $$row{'holdingbranch'}, >- $$row{'colBranchcode'}, >- ); >+ my ($itemnumber) = @_; >+ >+ if ( !$itemnumber ) { >+ return; >+ } >+ >+ my $dbh = C4::Context->dbh; >+ >+ my ( $sth, @results ); >+ $sth = $dbh->prepare(" >+ SELECT >+ holdingbranch, >+ colBranchcode >+ FROM >+ items, >+ collections, >+ collections_tracking >+ WHERE items.itemnumber = collections_tracking.itemnumber >+ AND collections.colId = collections_tracking.colId >+ AND items.itemnumber = ? >+ "); >+ $sth->execute($itemnumber); >+ >+ my $row = $sth->fetchrow_hashref; >+ >+ $sth->finish; >+ >+ return ( $$row{'holdingbranch'}, $$row{'colBranchcode'}, ); > } > > =head2 isItemInThisCollection >@@ -476,16 +492,18 @@ sub GetCollectionItemBranches { > =cut > > sub isItemInThisCollection { >- my ( $itemnumber, $colId ) = @_; >- >- my $dbh = C4::Context->dbh; >- >- my $sth = $dbh->prepare("SELECT COUNT(*) as inCollection FROM collections_tracking WHERE itemnumber = ? AND colId = ?"); >- $sth->execute( $itemnumber, $colId ) or return( 0 ); >- >- my $row = $sth->fetchrow_hashref; >- >- return $$row{'inCollection'}; >+ my ( $itemnumber, $colId ) = @_; >+ >+ my $dbh = C4::Context->dbh; >+ >+ my $sth = $dbh->prepare(" >+ SELECT COUNT(*) as inCollection FROM collections_tracking WHERE itemnumber = ? AND colId = ? >+ "); >+ $sth->execute( $itemnumber, $colId ) or return (0); >+ >+ my $row = $sth->fetchrow_hashref; >+ >+ return $$row{'inCollection'}; > } > > =head2 isItemInAnyCollection >@@ -495,23 +513,26 @@ $inCollection = isItemInAnyCollection( $itemnumber ); > =cut > > sub isItemInAnyCollection { >- my ( $itemnumber ) = @_; >- >- my $dbh = C4::Context->dbh; >- >- my $sth = $dbh->prepare("SELECT itemnumber FROM collections_tracking WHERE itemnumber = ?"); >- $sth->execute( $itemnumber ) or return( 0 ); >- >- my $row = $sth->fetchrow_hashref; >- >- $itemnumber = $row->{itemnumber}; >- $sth->finish; >- >- if ( $itemnumber ) { >- return 1; >- } else { >- return 0; >- } >+ my ($itemnumber) = @_; >+ >+ my $dbh = C4::Context->dbh; >+ >+ my $sth = $dbh->prepare(" >+ SELECT itemnumber FROM collections_tracking WHERE itemnumber = ? >+ "); >+ $sth->execute($itemnumber) or return (0); >+ >+ my $row = $sth->fetchrow_hashref; >+ >+ $itemnumber = $row->{itemnumber}; >+ $sth->finish; >+ >+ if ($itemnumber) { >+ return 1; >+ } >+ else { >+ return 0; >+ } > } > > 1; >diff --git a/rotating_collections/addItems.pl b/rotating_collections/addItems.pl >index 7302db2..06a9496 100755 >--- a/rotating_collections/addItems.pl >+++ b/rotating_collections/addItems.pl >@@ -27,73 +27,82 @@ use C4::Items; > use CGI; > > my $query = new CGI; >-my ($template, $loggedinuser, $cookie) >- = get_template_and_user({template_name => "rotating_collections/addItems.tmpl", >- query => $query, >- type => "intranet", >- authnotrequired => 0, >- flagsrequired => { tools => 'rotating_collections' }, >- debug => 1, >- }); >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "rotating_collections/addItems.tmpl", >+ query => $query, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { tools => 'rotating_collections' }, >+ debug => 1, >+ } >+); > > if ( $query->param('action') eq 'addItem' ) { >- ## Add the given item to the collection >- my $colId = $query->param('colId'); >- my $barcode = $query->param('barcode'); >- my $removeItem = $query->param('removeItem'); >- my $itemnumber = GetItemnumberFromBarcode( $barcode ); >- >- my ( $success, $errorCode, $errorMessage ); >- >- if ( ! $removeItem ) { >- ( $success, $errorCode, $errorMessage ) = AddItemToCollection( $colId, $itemnumber ); >- >- $template->param( >- previousActionAdd => 1, >- addedBarcode => $barcode, >- ); >- >- if ( $success ) { >- $template->param( addSuccess => 1 ); >- } else { >- $template->param( addFailure => 1 ); >- $template->param( failureMessage => $errorMessage ); >- } >- } else { >- ## Remove the given item from the collection >- ( $success, $errorCode, $errorMessage ) = RemoveItemFromCollection( $colId, $itemnumber ); >- >- $template->param( >- previousActionRemove => 1, >- removedBarcode => $barcode, >- removeChecked => 1, >- ); >- >- if ( $success ) { >- $template->param( removeSuccess => 1 ); >- } else { >- $template->param( removeFailure => 1 ); >- $template->param( failureMessage => $errorMessage ); >+ ## Add the given item to the collection >+ my $colId = $query->param('colId'); >+ my $barcode = $query->param('barcode'); >+ my $removeItem = $query->param('removeItem'); >+ my $itemnumber = GetItemnumberFromBarcode($barcode); >+ >+ my ( $success, $errorCode, $errorMessage ); >+ >+ if ( !$removeItem ) { >+ ( $success, $errorCode, $errorMessage ) = >+ AddItemToCollection( $colId, $itemnumber ); >+ >+ $template->param( >+ previousActionAdd => 1, >+ addedBarcode => $barcode, >+ ); >+ >+ if ($success) { >+ $template->param( addSuccess => 1 ); >+ } >+ else { >+ $template->param( addFailure => 1 ); >+ $template->param( failureMessage => $errorMessage ); >+ } > } >+ else { >+ ## Remove the given item from the collection >+ ( $success, $errorCode, $errorMessage ) = >+ RemoveItemFromCollection( $colId, $itemnumber ); >+ >+ $template->param( >+ previousActionRemove => 1, >+ removedBarcode => $barcode, >+ removeChecked => 1, >+ ); >+ >+ if ($success) { >+ $template->param( removeSuccess => 1 ); >+ } >+ else { >+ $template->param( removeFailure => 1 ); >+ $template->param( failureMessage => $errorMessage ); >+ } > >- } >+ } > } > >-my ( $colId, $colTitle, $colDescription, $colBranchcode ) = GetCollection( $query->param('colId') ); >-my $collectionItems = GetItemsInCollection( $colId ); >-if ( $collectionItems ) { >- $template->param( collectionItemsLoop => $collectionItems ); >+my ( $colId, $colTitle, $colDescription, $colBranchcode ) = >+ GetCollection( $query->param('colId') ); >+my $collectionItems = GetItemsInCollection($colId); >+if ($collectionItems) { >+ $template->param( collectionItemsLoop => $collectionItems ); > } > > $template->param( >- intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), >- intranetstylesheet => C4::Context->preference("intranetstylesheet"), >- IntranetNav => C4::Context->preference("IntranetNav"), >- >- colId => $colId, >- colTitle => $colTitle, >- colDescription => $colDescription, >- colBranchcode => $colBranchcode, >- ); >+ intranetcolorstylesheet => >+ C4::Context->preference("intranetcolorstylesheet"), >+ intranetstylesheet => C4::Context->preference("intranetstylesheet"), >+ IntranetNav => C4::Context->preference("IntranetNav"), >+ >+ colId => $colId, >+ colTitle => $colTitle, >+ colDescription => $colDescription, >+ colBranchcode => $colBranchcode, >+); > > output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/rotating_collections/editCollections.pl b/rotating_collections/editCollections.pl >index a6e2f8b..577b85b 100755 >--- a/rotating_collections/editCollections.pl >+++ b/rotating_collections/editCollections.pl >@@ -27,92 +27,99 @@ 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 => 0, >- flagsrequired => { tools => 'rotating_collections' }, >- debug => 1, >- }); >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "rotating_collections/editCollections.tmpl", >+ query => $query, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { tools => 'rotating_collections' }, >+ 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 ); >- } >+ 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 ); >- } >+ 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, >- ); >+ 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 $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, >- ); >+ 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; >diff --git a/rotating_collections/rotatingCollections.pl b/rotating_collections/rotatingCollections.pl >index d574692..2fa77da 100755 >--- a/rotating_collections/rotatingCollections.pl >+++ b/rotating_collections/rotatingCollections.pl >@@ -26,25 +26,28 @@ use C4::Context; > use C4::RotatingCollections; > > my $query = new CGI; >-my ($template, $loggedinuser, $cookie) >- = get_template_and_user({template_name => "rotating_collections/rotatingCollections.tmpl", >- query => $query, >- type => "intranet", >- authnotrequired => 0, >- flagsrequired => { tools => 'rotating_collections' }, >- debug => 1, >- }); >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "rotating_collections/rotatingCollections.tmpl", >+ query => $query, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { tools => 'rotating_collections' }, >+ debug => 1, >+ } >+); > > my $branchcode = $query->cookie('branch'); > > my $collections = GetCollections(); > > $template->param( >- intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), >- intranetstylesheet => C4::Context->preference("intranetstylesheet"), >- IntranetNav => C4::Context->preference("IntranetNav"), >- >- collectionsLoop => $collections, >- ); >- >+ 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; >diff --git a/rotating_collections/transferCollection.pl b/rotating_collections/transferCollection.pl >index 8673b83..630c222 100755 >--- a/rotating_collections/transferCollection.pl >+++ b/rotating_collections/transferCollection.pl >@@ -28,55 +28,61 @@ use CGI; > > my $query = new CGI; > >-my $colId = $query->param('colId'); >+my $colId = $query->param('colId'); > my $toBranch = $query->param('toBranch'); > >-my ($template, $loggedinuser, $cookie) >- = get_template_and_user({template_name => "rotating_collections/transferCollection.tmpl", >- query => $query, >- type => "intranet", >- authnotrequired => 0, >- flagsrequired => { tools => 'rotating_collections' }, >- debug => 1, >- }); >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "rotating_collections/transferCollection.tmpl", >+ query => $query, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { tools => 'rotating_collections' }, >+ debug => 1, >+ } >+); > > ## Transfer collection > my ( $success, $errorCode, $errorMessage ); >-if ( $toBranch ) { >- ( $success, $errorCode, $errorMessage ) = TransferCollection( $colId, $toBranch ); >+if ($toBranch) { >+ ( $success, $errorCode, $errorMessage ) = >+ TransferCollection( $colId, $toBranch ); > >- if ( $success ) { >- $template->param( transferSuccess => 1 ); >- } else { >- $template->param( transferFailure => 1, >- errorCode => $errorCode, >- errorMessage => $errorMessage >- ); >- } >+ if ($success) { >+ $template->param( transferSuccess => 1 ); >+ } >+ else { >+ $template->param( >+ transferFailure => 1, >+ errorCode => $errorCode, >+ errorMessage => $errorMessage >+ ); >+ } > } > > ## Set up the toBranch select options > my $branches = GetBranches(); > my @branchoptionloop; >-foreach my $br (keys %$branches) { >- my %branch; >- $branch{code}=$br; >- $branch{name}=$branches->{$br}->{'branchname'}; >- push (@branchoptionloop, \%branch); >+foreach my $br ( keys %$branches ) { >+ my %branch; >+ $branch{code} = $br; >+ $branch{name} = $branches->{$br}->{'branchname'}; >+ push( @branchoptionloop, \%branch ); > } >- >+ > ## Get data about collection >-my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection( $colId ); >+my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection($colId); > $template->param( >- intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), >- intranetstylesheet => C4::Context->preference("intranetstylesheet"), >- IntranetNav => C4::Context->preference("IntranetNav"), >- >- colId => $colId, >- colTitle => $colTitle, >- colDesc => $colDesc, >- colBranchcode => $colBranchcode, >- branchoptionloop => \@branchoptionloop >- ); >- >+ intranetcolorstylesheet => >+ C4::Context->preference("intranetcolorstylesheet"), >+ intranetstylesheet => C4::Context->preference("intranetstylesheet"), >+ IntranetNav => C4::Context->preference("IntranetNav"), >+ >+ colId => $colId, >+ colTitle => $colTitle, >+ colDesc => $colDesc, >+ colBranchcode => $colBranchcode, >+ branchoptionloop => \@branchoptionloop >+); >+ > output_html_with_http_headers $query, $cookie, $template->output; >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8836
:
12560
|
16746
|
19118
|
19119
|
19337
|
19339
|
21008
|
21009
|
21010
|
21011
|
23966
|
23967
|
23968
|
23969
|
23970
|
23971
|
23976
|
28140
|
28141
|
30838
|
30921
|
31087
|
32361
|
32362
|
32588
|
32589
|
32690
|
32691
|
32693
|
32773
|
32774
|
32973
|
32974
|
32975
|
32976
|
32994
|
32999
|
33000
|
33001
|
33002
|
33045
|
33046
|
33047
|
33048
|
33050
|
33051
|
33058
|
33059
|
33060
|
33061
|
33062
|
33063
|
33064
|
33065
|
33066
|
33068
|
33070
|
33095
|
33096
|
33097
|
33098
|
33099
|
33100
|
33101
|
33102
|
33103
|
33330
|
33331
|
33374