Bugzilla – Attachment 19742 Details for
Bug 10599
Uncheck on loan items on the batch item modification tool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10599: Clear on loan items on the batch item modification tool
Bug-10599-Clear-on-loan-items-on-the-batch-item-mo.patch (text/plain), 7.85 KB, created by
Liz Rea
on 2013-07-18 02:01:53 UTC
(
hide
)
Description:
Bug 10599: Clear on loan items on the batch item modification tool
Filename:
MIME Type:
Creator:
Liz Rea
Created:
2013-07-18 02:01:53 UTC
Size:
7.85 KB
patch
obsolete
>From 159eaba508a458032f3d5546f0ce71a71e48cd34 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Tue, 16 Jul 2013 16:43:30 +0200 >Subject: [PATCH] Bug 10599: Clear on loan items on the batch item > modification tool > >Sometimes when using the batch item modification tool, we would like to >automatically uncheck on loan items. > >Test plan: >1/ Go to tools/batchMod.pl. >2/ Enter some barcode (at least 1 should be on loan). >3/ Click on the Continue button. >4/ Click on the "Clear on loan" link. >5/ Check that on loan items are unchecked. > >Launch the unit test file: >prove t/db_dependent/Circulation/IsItemIssued.t > >http://bugs.koha-community.org/show_bug.cgi?id=10572 >Signed-off-by: Liz Rea <liz@catalyst.net.nz> >Works as expected, only modifies items that are checked (still). No regression noted. >--- > C4/Circulation.pm | 20 ++++++++++ > .../intranet-tmpl/prog/en/js/pages/batchMod.js | 8 +++- > .../prog/en/modules/tools/batchMod-edit.tt | 30 +++++++++------ > t/db_dependent/Circulation/IsItemIssued.t | 40 ++++++++++++++++++++ > tools/batchMod.pl | 2 + > 5 files changed, 87 insertions(+), 13 deletions(-) > create mode 100644 t/db_dependent/Circulation/IsItemIssued.t > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index ca66931..4af102e 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -88,6 +88,7 @@ BEGIN { > &GetOpenIssue > &AnonymiseIssueHistory > &CheckIfIssuedToPatron >+ &IsItemIssued > ); > > # subs to deal with returns >@@ -3483,6 +3484,25 @@ sub CheckIfIssuedToPatron { > return; > } > >+=head2 IsItemIssued >+ >+ IsItemIssued( $itemnumber ) >+ >+ Return 1 if the item is on loan, otherwise return 0 >+ >+=cut >+ >+sub IsItemIssued { >+ my $itemnumber = shift; >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare(q{ >+ SELECT COUNT(*) >+ FROM issues >+ WHERE itemnumber = ? >+ }); >+ $sth->execute($itemnumber); >+ return $sth->fetchrow; >+} > > 1; > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/pages/batchMod.js b/koha-tmpl/intranet-tmpl/prog/en/js/pages/batchMod.js >index 73be545..38f971e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/pages/batchMod.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/pages/batchMod.js >@@ -102,7 +102,7 @@ function hideAllColumns(){ > "aoColumnDefs": [ > { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false } > ], >- "bPaginate": false >+ "bPaginate": false, > })); > $("#selectallbutton").click(function(){ > $("#itemst").checkCheckboxes(); >@@ -112,6 +112,12 @@ function hideAllColumns(){ > $("#itemst").unCheckCheckboxes(); > return false; > }); >+ $("#clearonloanbutton").click(function(){ >+ $("#itemst input[name='itemnumber'][data-is-onloan='1']").each(function(){ >+ $(this).attr('checked', false); >+ }); >+ return false; >+ }); > $("#selections input").change(function(e){ > var num = $(this).attr("id"); > if(num == 'showall'){ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt >index de67517..8ee771c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt >@@ -19,16 +19,7 @@ for( x=0; x<allColumns.length; x++ ){ > allColumns[x] = Number(allColumns[x]) + 2; > } > $(document).ready(function(){ >- $("#selectallbutton").click(function() { >- $("#itemst").find("input:checkbox").each(function() { >- $(this).attr("checked", "checked"); >- }); >- }); >- $("#clearallbutton").click(function() { >- $("#itemst").find("input:checkbox").each(function() { >- $(this).removeAttr("checked"); >- }); >- }); >+ > $("input[name='disable_input']").click(function() { > var row = $(this).attr("id"); > row = row.replace("row","hint"); >@@ -42,6 +33,7 @@ $(document).ready(function(){ > $("#"+row).html(""); > } > }); >+ > }); > //]]> > </script> >@@ -97,7 +89,11 @@ $(document).ready(function(){ > <input type="hidden" name="src" id="src" value="[% src %]" /> > > [% IF ( item_loop ) %] >- [% IF ( show ) %]<div id="toolbar"><a id="selectallbutton" href="#">Select All</a> | <a id="clearallbutton" href="#">Clear All</a></div>[% ELSE %][% END %] >+ [% IF show %] >+ <div id="toolbar"> >+ <a id="selectallbutton" href="#">Select all</a> | <a id="clearallbutton" href="#">Clear all</a> | <a id="clearonloanbutton" href="#">Clear on loan</a> >+ </div> >+ [% END %] > <div id="cataloguing_additem_itemlist"> > > <p id="selections"><strong>Show/hide columns:</strong> <span class="selected"><input type="checkbox" checked="checked" id="showall"/><label for="showall">Show all columns</label></span> <span><input type="checkbox" id="hideall"/><label for="hideall">Hide all columns</label></span> >@@ -116,7 +112,17 @@ $(document).ready(function(){ > </tr> > </thead> > <tbody> >- [% FOREACH item_loo IN item_loop %] <tr> [% IF ( show ) %][% IF ( item_loo.nomod ) %] <td class="error">Cannot Edit</td>[% ELSE %]<td><input type="checkbox" name="itemnumber" value="[% item_loo.itemnumber %]" id="row[% item_loo.itemnumber %]" checked="checked" /></td>[% END %][% ELSE %]<td> </td>[% END %] >+ [% FOREACH item_loo IN item_loop %] >+ <tr> >+ [% IF show %] >+ [% IF item_loo.nomod %] >+ <td class="error">Cannot Edit</td> >+ [% ELSE %] >+ <td><input type="checkbox" name="itemnumber" value="[% item_loo.itemnumber %]" id="row[% item_loo.itemnumber %]" checked="checked" data-is-onloan="[% item_loo.onloan %]" /></td> >+ [% END %] >+ [% ELSE %] >+ <td> </td> >+ [% END %] > <td><label for="row[% item_loo.itemnumber %]"><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item_loo.biblionumber %]">[% item_loo.title %]</a>[% IF ( item_loo.author ) %], by [% item_loo.author %][% END %]</label></td> > [% FOREACH item_valu IN item_loo.item_value %] <td>[% item_valu.field |html %]</td> > [% END %] </tr> >diff --git a/t/db_dependent/Circulation/IsItemIssued.t b/t/db_dependent/Circulation/IsItemIssued.t >new file mode 100644 >index 0000000..b02dba8 >--- /dev/null >+++ b/t/db_dependent/Circulation/IsItemIssued.t >@@ -0,0 +1,40 @@ >+use Modern::Perl; >+use Test::More tests => 1; >+ >+use C4::Biblio; >+use C4::Circulation; >+use C4::Items; >+use C4::Members; >+use Koha::DateUtils; >+ >+use MARC::Record; >+ >+*C4::Context::userenv = \&Mock_userenv; >+ >+my $dbh = C4::Context->dbh; >+$dbh->{AutoCommit} = 0; >+$dbh->{RaiseError} = 1; >+ >+my $borrowernumber = AddMember( >+ firstname => 'my firstname', >+ surname => 'my surname', >+ categorycode => 'S', >+ branchcode => 'CPL', >+); >+ >+ >+my $borrower = GetMember( borrowernumber => $borrowernumber ); >+my $record = MARC::Record->new(); >+my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' ); >+ >+my ( undef, undef, $itemnumber ) = AddItem( { homebranch => 'CPL', holdingbranch => 'CPL', barcode => 'i_dont_exist' }, $biblionumber ); >+my $item = GetItem( $itemnumber ); >+ >+is ( IsItemIssued( $item->{itemnumber} ), 1, "Item is issued" ); >+ >+$dbh->rollback; >+ >+# C4::Context->userenv >+sub Mock_userenv { >+ return { branch => 'CPL' }; >+} >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index acb4f0b..975d6a9 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -545,6 +545,8 @@ sub BuildItemsData{ > $row_data{title} = $row->{title}; > $row_data{isbn} = $row->{isbn}; > $row_data{biblionumber} = $row->{biblionumber}; >+ my $is_on_loan = C4::Circulation::IsItemIssued( $row->{itemnumber} ); >+ $row_data{onloan} = $is_on_loan ? 1 : 0; > push(@item_value_loop,\%row_data); > } > my @header_loop=map { { header_value=> $witness{$_}} } @witnesscodessorted; >-- >1.7.9.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 10599
:
19715
|
19742
|
20418