[Koha-patches] [PATCH] Rotating Collections Fixes

Kyle M Hall kyle.m.hall at gmail.com
Wed Jan 27 15:06:05 CET 2010


This patch does the following:
  * Fixes the typos in updatedatabase.pl
  * Adds the rotating_collections template files that somehow were not committed
  * Adds a missing sub from RotatingCollections.pm that must been deleted by accident
  * Adds the neccessary hooks in returns.pl to warn that and item needs to be returned
    to the branch that currently holds the collection.
---
 C4/RotatingCollections.pm                          |   28 +++++
 circ/returns.pl                                    |   11 ++
 installer/data/mysql/updatedatabase.pl             |    2 +-
 .../prog/en/modules/circ/returns.tmpl              |    5 +
 .../en/modules/rotating_collections/addItems.tmpl  |   88 ++++++++++++++
 .../rotating_collections/editCollections.tmpl      |  125 ++++++++++++++++++++
 .../rotating_collections/rotatingCollections.tmpl  |   47 ++++++++
 .../rotating_collections/transferCollection.tmpl   |   48 ++++++++
 8 files changed, 353 insertions(+), 1 deletions(-)
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tmpl
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tmpl
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tmpl
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tmpl

diff --git a/C4/RotatingCollections.pm b/C4/RotatingCollections.pm
index 254453f..fd4532f 100644
--- a/C4/RotatingCollections.pm
+++ b/C4/RotatingCollections.pm
@@ -406,6 +406,34 @@ sub TransferCollection {
   
 }
 
+=item GetCollectionItemBranches
+ my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
+=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'},
+  );  
+}
 
 =item isItemInThisCollection
 $inCollection = isItemInThisCollection( $itemnumber, $colId );
diff --git a/circ/returns.pl b/circ/returns.pl
index 1ed378b..da2b574 100755
--- a/circ/returns.pl
+++ b/circ/returns.pl
@@ -549,5 +549,16 @@ $template->param(
     overduecharges => $overduecharges,
 );
 
+my $itemnumber = GetItemnumberFromBarcode( $query->param('barcode') );
+if ( $itemnumber ) {
+    my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
+    if ( ! ( $holdingBranch eq $collectionBranch ) ) {
+        $template->param(
+          collectionItemNeedsTransferred => 1,
+          collectionBranch => GetBranchName($collectionBranch),
+        );
+    }
+}                                                                                                            
+
 # actually print the page!
 output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 41dfa3f..36d1883 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -3338,7 +3338,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     $dbh->do("
         INSERT INTO permissions (module_bit, code, description) 
         VALUES ( 13, 'rotating_collections', 'Manage Rotating collections')" );
-	print "Upgrade to $DBversion done (added collection and collection_tracking tables for rotataing collection functionnality)\n";
+	print "Upgrade to $DBversion done (added collection and collection_tracking tables for rotating collections functionality)\n";
     SetVersion ($DBversion);
 }
 $DBversion = "3.01.00.106";
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tmpl
index 12b372c..baecec8 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tmpl
@@ -56,6 +56,11 @@ function Dopop(link) {
 	<div id="yui-main">
 
 <div class="yui-g">
+
+<!-- TMPL_IF Name="collectionItemNeedsTransferred" -->
+	<div class="dialog message">This item is part of a Rotating Collection and needs to be Transferred to <!-- TMPL_VAR NAME="collectionBranch" --></div>
+<!-- /TMPL_IF -->
+
 <!-- TMPL_IF NAME="wrongbranch" -->
 <div class="dialog alert"><h3>Cannot Check In</h3><p>This item must be checked in at its home library. <strong>NOT CHECKED IN</strong></p>
 </div>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tmpl
new file mode 100644
index 0000000..c70c94a
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tmpl
@@ -0,0 +1,88 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha &rsaquo; Tools &rsaquo; Rotating Collections &rsaquo; Add/Remove Items</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+</head>
+<body>
+<!-- TMPL_INCLUDE NAME="header.inc" -->
+<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
+
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Rotating Collections</a> &rsaquo; Add/Remove Items</div>
+
+<div id="doc3">
+<div id="bd">
+        <div class="yui-gb">
+
+      <h1>Rotating Collections: Add/Remove Items</h1>
+
+      <div>
+          <br />
+          <!-- TMPL_IF NAME="previousActionAdd" -->
+            <!-- TMPL_IF NAME="addSuccess" -->
+              <div>Item with barcode '<!-- TMPL_VAR NAME="addedBarcode" -->' Added Succesfully!</div>
+            <!-- TMPL_ELSE -->
+              <div>Failed to add item with barcode '<!-- TMPL_VAR NAME="addedBarcode" -->'!</div>
+              <div>Reason: <strong><!-- TMPL_VAR NAME="failureMessage" --></strong></div>
+            <!-- /TMPL_IF -->
+          <!-- /TMPL_IF -->
+
+          <!-- TMPL_IF NAME="previousActionRemove" -->
+            <!-- TMPL_IF NAME="removeSuccess" -->
+              <div>Item with barcode '<!-- TMPL_VAR NAME="addedBarcode" -->' Removed Succesfully!</div>
+            <!-- TMPL_ELSE -->
+              <div>Failed to remove item with barcode '<!-- TMPL_VAR NAME="removedBarcode" -->'!</div>
+              <div>Reason: <strong><!-- TMPL_VAR NAME="failureMessage" --></strong></div>
+            <!-- /TMPL_IF -->
+          <!-- /TMPL_IF -->
+
+          <h3>Add Item to <i><!-- TMPL_VAR NAME="colTitle" --></i></h3>
+      </div>
+
+      <div>
+        <form action="addItems.pl" method="post">
+        <table>
+          <tr>
+            <th><label for="barcode">Barcode: </label></td>
+            <td><input type="text" id="barcode" name="barcode" /></td>
+            <td>
+              <input type="checkbox" name="removeItem" <!-- TMPL_IF NAME="removeChecked" -->checked<!-- /TMPL_IF--> >
+              <label for="removeItem">Remove Item from Collection</label>
+            </td>
+          </tr>
+
+          <input type="hidden" id="colId" name="colId" value="<!-- TMPL_VAR NAME="colId" -->" />
+          <input type="hidden" name="action" value="addItem" /> 
+          <tr><td align="right" colspan="99"><input type="submit" value="Submit" /></td></tr>
+        </table>
+        </form>
+      </div>
+
+      <div>
+        <h2>Items In This Collection</h2>
+        <!-- TMPL_IF NAME="collectionItemsLoop" -->
+          <table>
+            <tr>
+              <th>Title</th>
+              <th>Callnumber</th>
+              <th>Barcode</th>
+            </tr>
+            <!-- TMPL_LOOP NAME="collectionItemsLoop" -->
+              <tr>
+                <td><!-- TMPL_VAR NAME="title" --></td>
+                <td><!-- TMPL_VAR NAME="itemcallnumber" --></td>
+                <td><!-- TMPL_VAR NAME="barcode" --></td>
+              </tr>
+            <!-- /TMPL_LOOP -->
+          </table>
+        <!-- TMPL_ELSE -->
+          There are no Items in this Collection.
+        <!-- /TMPL_IF -->
+      </div>
+
+      <div>
+        <br/>
+        <input type="button" value="Return to Rotating Collections Home" onclick="window.location.href='rotatingCollections.pl'">
+      </div>
+
+</div>
+</div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tmpl
new file mode 100644
index 0000000..93055c7
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tmpl
@@ -0,0 +1,125 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha &rsaquo; Tools &rsaquo; Rotating Collections &rsaquo; Edit Collections</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+</head>
+<body>
+<!-- TMPL_INCLUDE NAME="header.inc" -->
+<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
+
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Rotating Collections</a> &rsaquo; Edit Collections</div>
+
+<div id="doc3">
+<div id="bd">
+        <div class="yui-gb">
+      <h1>Rotating Collections: Edit Collections</h1>
+
+<!--
+      <!-- TMPL_IF NAME="previousActionCreate" -->
+        <!-- TMPL_IF NAME="createSuccess" -->
+          <div>Collection '<!-- TMPL_VAR NAME="createdTitle" -->' Created Succesfully!</div>
+        <!-- TMPL_ELSE -->
+          <div>Collection '<!-- TMPL_VAR NAME="createdTitle" -->' Failed To Be Created!</div>
+          <div>Reason: <strong><!-- TMPL_VAR NAME="failureMessage" --></strong></div>
+        <!-- /TMPL_IF -->
+      <!-- /TMPL_IF -->
+
+      <!-- TMPL_IF NAME="previousActionDelete" -->
+        <!-- TMPL_IF NAME="DeleteSuccess" -->
+          <div>Collection Deleted Succesfully!</div>
+        <!-- TMPL_ELSE -->
+          <div>Collection Failed To Be Deleted!</div>
+        <!-- /TMPL_IF -->
+      <!-- /TMPL_IF -->
+-->
+
+      <!-- TMPL_IF NAME="previousActionUpdate" -->
+        <!-- TMPL_IF NAME="updateSuccess" -->
+          <div>Collection '<!-- TMPL_VAR NAME="updatedTitle" -->' Updated Succesfully!</div>
+        <!-- TMPL_ELSE -->
+          <div>Collection '<!-- TMPL_VAR NAME="updatedTitle" -->' Failed To Be Updated!</div>
+          <div>Reason: <strong><!-- TMPL_VAR NAME="failureMessage" --></strong></div>
+        <!-- /TMPL_IF -->
+      <!-- /TMPL_IF -->
+
+      <div>
+        <!-- TMPL_IF NAME="collectionsLoop" -->
+          <table>
+            <tr>
+              <th>Title</th>
+              <th>Description</th>
+              <th>Holding Library</th>
+              <td></td>
+              <td></td>
+            </tr>
+            <!-- TMPL_LOOP NAME="collectionsLoop" -->
+              <tr>
+                <td><!-- TMPL_VAR NAME="colTitle" --></td>
+                <td><!-- TMPL_VAR NAME="colDesc" --></td>
+                <td><!-- TMPL_VAR NAME="colBranchcode" --></td>
+                <td><a href="editCollections.pl?action=edit&colId=<!-- TMPL_VAR NAME="colId" -->">Edit</a></td>
+                <td><a href="editCollections.pl?action=delete&colId=<!-- TMPL_VAR NAME="colId" -->">Delete</a></td>
+              </tr>
+            <!-- /TMPL_LOOP -->
+          </table>
+        <!-- TMPL_ELSE -->
+          There are no Collections currently defined.
+        <!-- /TMPL_IF -->
+      </div>    
+
+      <div>
+        <br />
+
+        <!-- TMPL_IF NAME="previousActionEdit" -->
+          <h1>Edit Collection</h1>
+        <!-- TMPL_ELSE -->
+          <h1>Create New Collection</h1>
+        <!-- /TMPL_IF -->
+
+        <form action="editCollections.pl" method="post">
+          <!-- TMPL_IF NAME="previousActionEdit" -->
+            <input type="hidden" name="action" value="update" />
+            <input type="hidden" name="colId" value="<!-- TMPL_VAR NAME="editColId" -->" />
+          <!-- TMPL_ELSE -->
+            <input type="hidden" name="action" value="create" />
+          <!-- /TMPL_IF -->
+
+          <table>
+            <tr>
+              <td>
+                <label for="title">Title: </label>
+              </td>
+              <td>
+               <input type="text" name="title" <!-- TMPL_IF NAME="editColTitle" --> value="<!-- TMPL_VAR NAME="editColTitle" -->" <!-- /TMPL_IF --> />
+              </td>
+            </tr>
+        
+            <tr>
+              <td>
+                <label for="description">Description: </label>
+              </td>
+              <td>
+                <input type="text" size="50" name="description" <!-- TMPL_IF NAME="editColDescription" --> value="<!-- TMPL_VAR NAME="editColDescription" -->" <!-- /TMPL_IF --> />
+              </td>
+            </tr>
+
+            <tr>
+              <td colspan="2">
+                <!-- TMPL_IF NAME="previousActionEdit" -->
+                  <input type="submit" value="Update" />
+                <!-- TMPL_ELSE -->
+                  <input type="submit" value="Create" />
+                <!-- /TMPL_IF -->
+              </td>
+            </tr>
+          </table>
+        </form>
+      </div>
+
+      <div>
+        <br/>
+        <input type="button" value="Return to Rotating Collections Home" onclick="window.location.href='rotatingCollections.pl'">
+      </div>
+
+</div>
+</div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tmpl
new file mode 100644
index 0000000..999e914
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tmpl
@@ -0,0 +1,47 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha &rsaquo; Tools &rsaquo; Rotating Collections</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+</head>
+<body>
+<!-- TMPL_INCLUDE NAME="header.inc" -->
+<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
+
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; Rotating Collections</div>
+
+<div id="doc3">
+<div id="bd">
+        <div class="yui-gb">
+
+      <h1>Rotating Collections</h1>
+      <div>
+        <!-- TMPL_IF NAME="collectionsLoop" -->
+          <table>
+            <tr>
+              <th><strong>Title</strong></th>
+              <th>Description</strong></th>
+              <th>Current Location</th>
+              <th>Add/Remove Items</th>
+              <th>Transfer Collection</th>
+            </tr>
+            <!-- TMPL_LOOP NAME="collectionsLoop" -->
+              <tr>
+                <td><!-- TMPL_VAR NAME="colTitle" --></td>
+                <td><!-- TMPL_VAR NAME="colDesc" --></td>
+                <td><!-- TMPL_VAR NAME="colBranchcode" --></td>
+                <td><a href="addItems.pl?colId=<!-- TMPL_VAR NAME="colId" -->">Add/Remove Items</a></td>
+                <td><a href="transferCollection.pl?colId=<!-- TMPL_VAR NAME="colId" -->">Transfer Collection</a></td>
+              </tr>
+            <!-- /TMPL_LOOP -->
+          </table>
+        <!-- TMPL_ELSE -->
+          There are no Collections currently defined.
+        <!-- /TMPL_IF -->
+      </div>
+
+      <div>
+	<br/>
+	<input type="button" value="Edit Collections" onclick="window.location.href='editCollections.pl'"> 
+      </div>    
+</div>
+</div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tmpl
new file mode 100644
index 0000000..56f29e8
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tmpl
@@ -0,0 +1,48 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha &rsaquo; Tools &rsaquo; Rotating Collections &rsaquo; Transfer Collection</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+</head>
+<body>
+<!-- TMPL_INCLUDE NAME="header.inc" -->
+<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
+
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Rotating Collections</a> &rsaquo; Transfer Collection</div>
+<div id="doc3">
+<div id="bd">
+        <div class="yui-gb">
+      <h1>Rotating Collections: Transfer Collection</h1>
+    <br />
+      <!-- TMPL_IF NAME="transferSuccess" -->
+        <div>Collection Transfered Successfully</div>
+      <!-- /TMPL_IF -->
+
+      <!-- TMPL_IF NAME="transferFailure" -->
+        <div>Failed to Transfer Collection!</div>
+        <div>Reason: <strong><!-- TMPL_VAR NAME="errorMessage" --></strong></div>
+      <!-- /TMPL_IF -->
+
+      <!-- TMPL_IF NAME="transferSuccess" -->
+      <!-- TMPL_ELSE -->
+        <div>
+          <form action="transferCollection.pl" method="post">
+            <input type="hidden" name="colId" value="<!-- TMPL_VAR NAME="colId" -->">
+  
+            <label for="toBranch">Choose your Library:</label>
+            <select name="toBranch">
+              <!-- TMPL_LOOP Name="branchoptionloop" -->
+                <!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR Name="code" -->" selected="selected"><!-- TMPL_VAR Name="name" --></option><!-- TMPL_ELSE --><option value="<!-- TMPL_VAR Name="code" -->"><!-- TMPL_VAR Name="name" --></option><!-- /TMPL_IF -->
+              <!-- /TMPL_LOOP -->
+            </select>
+            <INPUT type="submit" value="Transfer Collection">
+          </form>
+        </div>
+      <!-- /TMPL_IF -->
+
+      <div>
+        <br/>
+        <input type="button" value="Return to Rotating Collections Home" onclick="window.location.href='rotatingCollections.pl'">
+      </div>
+
+</div>
+</div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
-- 
1.5.6.5




More information about the Koha-patches mailing list