&GetOpenIssue
&AnonymiseIssueHistory
&CheckIfIssuedToPatron
+ &IsItemIssued
);
# subs to deal with returns
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;
"aoColumnDefs": [
{ "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }
],
- "bPaginate": false
+ "bPaginate": false,
}));
$("#selectallbutton").click(function(){
$("#itemst").checkCheckboxes();
$("#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'){
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");
$("#"+row).html("");
}
});
+
});
//]]>
</script>
<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>
</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>
--- /dev/null
+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' };
+}
$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;