[Koha-patches] [PATCH] [3.0.x](bug #3396) This add batch deletion of items and fixes permissions for batch modification.
Jean-André Santoni
jeanandre.santoni at biblibre.com
Mon Jul 6 15:08:34 CEST 2009
This tool allows catalogers to delete a list (csv) of items identified by thier barcode. Batch deletion is seen as a special case of batch modification. So I reused the code of BatchMod.pl (see bug #3000).
---
.../data/mysql/en/mandatory/userpermissions.sql | 4 ++-
installer/data/mysql/updatedatabase.pl | 7 ++++
.../prog/en/modules/tools/batchMod.tmpl | 18 ++++++++-
.../prog/en/modules/tools/tools-home.tmpl | 10 +++++-
tools/batchMod.pl | 39 +++++++++++---------
5 files changed, 57 insertions(+), 21 deletions(-)
diff --git a/installer/data/mysql/en/mandatory/userpermissions.sql b/installer/data/mysql/en/mandatory/userpermissions.sql
index 29b3b05..527655c 100644
--- a/installer/data/mysql/en/mandatory/userpermissions.sql
+++ b/installer/data/mysql/en/mandatory/userpermissions.sql
@@ -15,5 +15,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES
(13, 'import_patrons', 'Import patron data'),
(13, 'delete_anonymize_patrons', 'Delete old borrowers and anonymize circulation history (deletes borrower reading history)'),
(13, 'batch_upload_patron_images', 'Upload patron images in batch or one at a time'),
- (13, 'schedule_tasks', 'Schedule tasks to run')
+ (13, 'schedule_tasks', 'Schedule tasks to run'),
+ (13, 'batchmod', 'Perform batch modification of items'),
+ (13, 'batchdel', 'Perform batch deletion of items')
;
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index cd89ab8..883d2a6 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -2509,6 +2509,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
print "Upgrade to $DBversion done (Moving max allowed reserves from system preference to issuingrule)\n";
}
+$DBversion = "3.01.00.041";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'batchmod', 'Perform batch modification of items')");
+ $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'batchdel', 'Perform batch deletion of items')");
+ print "Upgrade to $DBversion done (added permissions for batch modification and deletion)\n";
+}
+
=item DropAllForeignKeys($table)
Drop all foreign keys of the table $table
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod.tmpl
index 78314d0..138b81e 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod.tmpl
@@ -7,13 +7,21 @@
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc"-->
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › <a href="/cgi-bin/koha/tools/batchMod.pl">Modify batches of notices</a></div>
+<div id="breadcrumbs">
+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
+ <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> ›
+ <!-- TMPL_IF name="del" -->
+ <a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Delete batches of notices</a>
+ <!-- TMPL_ELSE -->
+ <a href="/cgi-bin/koha/tools/batchMod.pl">Modify batches of notices</a>
+ <!-- /TMPL_IF -->
+</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
- <h1>Batch modification</h1>
+ <h1>Batch <!-- TMPL_IF name="del" -->deletion<!-- TMPL_ELSE -->modification<!-- /TMPL_IF --></h1>
<!-- TMPL_UNLESS name="op" -->
<div class="yui-g">
<form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batchMod.pl">
@@ -33,6 +41,7 @@
</ol>
</fieldset>
<input type="hidden" name="op" value="barcodes" />
+ <!-- TMPL_IF name="del" --><input type="hidden" name="del" value="1" /><!-- /TMPL_IF -->
<fieldset class="action">
<input type="submit" value="Continue" class="button" />
</fieldset>
@@ -68,6 +77,10 @@
<!-- /TMPL_LOOP -->
</table>
<form method="post" action="/cgi-bin/koha/tools/batchMod.pl">
+ <!-- TMPL_IF name="del" -->
+ <p>This will delete the selected items.</p>
+ <input type="hidden" name="del" value="1" />
+ <!-- TMPL_ELSE -->
<fieldset class="rows">
<legend>Change items' properties</legend>
<ol>
@@ -116,6 +129,7 @@
</li>
</ol>
</fieldset>
+ <!-- /TMPL_IF -->
<input type="hidden" name="itemslst" value="<!-- TMPL_VAR name="itemslst" -->"/>
<fieldset class="action">
<input type="submit" value="Go" class="button" />
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tmpl
index 25603ab..cc2bdb5 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tmpl
@@ -61,9 +61,17 @@
<dt><a href="/cgi-bin/koha/tools/inventory.pl">Inventory/stocktaking</a></dt>
<dd>Perform inventory (stocktaking) of your catalog</dd>
<!-- /TMPL_IF -->
-
+
+ <!-- TMPL_IF NAME="CAN_user_tools_batchmod" -->
<dt><a href="/cgi-bin/koha/tools/batchMod.pl">Modify a queryset of items</a></dt>
<dd>Perform batch modification of items</dd>
+ <!-- /TMPL_IF -->
+
+ <!-- TMPL_IF NAME="CAN_user_tools_batchdel" -->
+ <dt><a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Delete a queryset of items</a></dt>
+ <dd>Perform batch deletion of items</dd>
+ <!-- /TMPL_IF -->
+
</dl>
</div>
<div class="yui-u">
diff --git a/tools/batchMod.pl b/tools/batchMod.pl
index 402047e..dd3c6af 100755
--- a/tools/batchMod.pl
+++ b/tools/batchMod.pl
@@ -31,7 +31,7 @@ use C4::Context;
use C4::Output;
use C4::Branch qw(GetBranches);
use C4::Koha qw(GetAuthorisedValues GetAuthValCode);
-use C4::Items qw(GetItemnumberFromBarcode GetItem ModItem);
+use C4::Items qw(GetItemnumberFromBarcode GetItem ModItem DelItemCheck);
use C4::Biblio qw(GetBiblioData);
use C4::Koha qw(GetItemTypes);
@@ -41,7 +41,7 @@ my ($template, $borrowernumber, $cookie)
query => $input,
type => "intranet",
authnotrequired => 0,
- flagsrequired => {tools => 'inventory'}, #FIXME: add a new permission?
+ flagsrequired => {tools => 'batchmod'},
debug => 1,
});
@@ -156,21 +156,26 @@ if ( $invars->{op} && $invars->{op} eq 'barcodes'){
);
} elsif ( $invars->{'itemslst'} ) {
for my $itemno ( split(',', $invars->{itemslst}) ) {
- my $item = GetItem($itemno);
- for my $auth (@$authvals){
- my ($authfieldname, $description, $hashfdname) = @$auth;
- my $authcode = GetAuthValCode($authfieldname);
- if ($invars->{$authcode} && $invars->{$authcode} ne '0'){
- $item->{$hashfdname}=$invars->{$authcode};
- }
- }
- if ($invars->{holdingbranch} && $invars->{holdingbranch} ne '0'){
- $item->{holdingbranch} = $invars->{holdingbranch};
- }
- if ($invars->{homebranch} && $invars->{homebranch} ne '0'){
- $item->{homebranch} = $invars->{homebranch};
- }
- ModItem($item, $item->{biblionumber}, $item->{itemnumber});
+ my $item = GetItem($itemno);
+ if ( $invars->{'del'} ) {
+ DelItemCheck(C4::Context->dbh, $item->{'biblionumber'}, $item->{'itemnumber'})
+ } else {
+ for my $auth (@$authvals){
+ my ($authfieldname, $description, $hashfdname) = @$auth;
+ my $authcode = GetAuthValCode($authfieldname);
+ if ($invars->{$authcode} && $invars->{$authcode} ne '0'){
+ $item->{$hashfdname}=$invars->{$authcode};
+ }
+ }
+ if ($invars->{holdingbranch} && $invars->{holdingbranch} ne '0'){
+ $item->{holdingbranch} = $invars->{holdingbranch};
+ }
+ if ($invars->{homebranch} && $invars->{homebranch} ne '0'){
+ $item->{homebranch} = $invars->{homebranch};
+ }
+ ModItem($item, $item->{biblionumber}, $item->{itemnumber});
+ }
}
}
+$template->param('del' => $input->param('del'));
output_html_with_http_headers $input, $cookie, $template->output;
--
1.6.0.4
More information about the Koha-patches
mailing list