[18/40] Work on label item search.
This commit is contained in:
parent
86a5bc80e2
commit
c9e6962fd4
|
|
@ -78,24 +78,29 @@ C4::Labels::Batch - A class for creating and manipulating batch objects in Koha
|
|||
=cut
|
||||
|
||||
sub new {
|
||||
my ($invocant, %params) = @_;
|
||||
my ($invocant) = shift;
|
||||
my $type = ref($invocant) || $invocant;
|
||||
my $self = {
|
||||
batch_id => 0,
|
||||
items => [],
|
||||
branch_code => 'NB',
|
||||
batch_stat => 0, # False if any data has changed and the db has not been updated
|
||||
@_,
|
||||
};
|
||||
my $sth = C4::Context->dbh->prepare("SELECT MAX(batch_id) FROM labels_batches;");
|
||||
$sth->execute();
|
||||
my $batch_id = $sth->fetchrow_array;
|
||||
$self->{'batch_id'} = ++$batch_id;
|
||||
bless ($self, $type);
|
||||
return $self;
|
||||
}
|
||||
|
||||
=head2 $batch->add_item($item_number)
|
||||
=head2 $batch->add_item(item_number => $item_number, branch_code => $branch_code)
|
||||
|
||||
Invoking the I<add_item> method will add the supplied item to the batch object.
|
||||
|
||||
example:
|
||||
$batch->add_item($item_number);
|
||||
$batch->add_item(item_number => $item_number, branch_code => $branch_code);
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -105,12 +110,16 @@ sub add_item {
|
|||
my $query = "INSERT INTO labels_batches (batch_id, item_number, branch_code) VALUES (?,?,?);";
|
||||
my $sth = C4::Context->dbh->prepare($query);
|
||||
# $sth->{'TraceLevel'} = 3;
|
||||
$sth->execute($item_number, $self->{'batch_id'});
|
||||
$sth->execute($self->{'batch_id'}, $item_number, $self->{'branch_code'});
|
||||
if ($sth->err) {
|
||||
syslog("LOG_ERR", "C4::Labels::Batch->add_item : Database returned the following error on attempted INSERT: %s", $sth->errstr);
|
||||
return -1;
|
||||
}
|
||||
push (@{$self->{'items'}}, $item_number);
|
||||
$query = "SELECT max(label_id) FROM labels_batches WHERE batch_id=? AND item_number=? AND branch_code=?;";
|
||||
my $sth1 = C4::Context->dbh->prepare($query);
|
||||
$sth1->execute($self->{'batch_id'}, $item_number, $self->{'branch_code'});
|
||||
my $label_id = $sth1->fetchrow_array;
|
||||
push (@{$self->{'items'}}, {item_number => $item_number, label_id => $label_id});
|
||||
$self->{'batch_stat'} = 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -140,16 +149,16 @@ sub get_attr {
|
|||
|
||||
sub remove_item {
|
||||
my $self = shift;
|
||||
my $item_number = shift;
|
||||
my $query = "DELETE FROM labels_batches WHERE item_number=? AND batch_id=?;";
|
||||
my $label_id = shift;
|
||||
my $query = "DELETE FROM labels_batches WHERE label_id=? AND batch_id=?;";
|
||||
my $sth = C4::Context->dbh->prepare($query);
|
||||
# $sth->{'TraceLevel'} = 3;
|
||||
$sth->execute($item_number, $self->{'batch_id'});
|
||||
$sth->execute($label_id, $self->{'batch_id'});
|
||||
if ($sth->err) {
|
||||
syslog("LOG_ERR", "C4::Labels::Batch->remove_item : Database returned the following error on attempted DELETE: %s", $sth->errstr);
|
||||
return -1;
|
||||
}
|
||||
@{$self->{'items'}} = grep{$_ != $item_number} @{$self->{'items'}};
|
||||
@{$self->{'items'}} = grep{$_->{'label_id'} != $label_id} @{$self->{'items'}};
|
||||
$self->{'batch_stat'} = 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -167,14 +176,10 @@ sub remove_item {
|
|||
|
||||
sub save {
|
||||
my $self = shift;
|
||||
my $sth = C4::Context->dbh->prepare("SELECT MAX(batch_id) FROM labels_batches;");
|
||||
$sth->execute();
|
||||
my $batch_id = $sth->fetchrow_array;
|
||||
$self->{'batch_id'} = $batch_id++;
|
||||
foreach my $item_number (@{$self->{'items'}}) {
|
||||
my $query = "INSERT INTO labels_batches (batch_id, item_number, branch_code) VALUES (?,?,?);";
|
||||
my $sth1 = C4::Context->dbh->prepare($query);
|
||||
$sth1->execute($self->{'batch_id'}, $item_number, $self->{'branch_code'});
|
||||
$sth1->execute($self->{'batch_id'}, $item_number->{'item_number'}, $self->{'branch_code'});
|
||||
if ($sth1->err) {
|
||||
syslog("LOG_ERR", "C4::Labels::Batch->save : Database returned the following error on attempted INSERT: %s", $sth1->errstr);
|
||||
return -1;
|
||||
|
|
@ -199,20 +204,24 @@ sub retrieve {
|
|||
my $invocant = shift;
|
||||
my %opts = @_;
|
||||
my $type = ref($invocant) || $invocant;
|
||||
my $record_flag = 0;
|
||||
my $query = "SELECT * FROM labels_batches WHERE batch_id = ? ORDER BY label_id";
|
||||
my $sth = C4::Context->dbh->prepare($query);
|
||||
# $sth->{'TraceLevel'} = 3;
|
||||
$sth->execute($opts{'batch_id'});
|
||||
if ($sth->err) {
|
||||
syslog("LOG_ERR", "C4::Labels::Batch->retrieve : Database returned the following error on attempted SELECT: %s", $sth->errstr);
|
||||
return 1;
|
||||
}
|
||||
my $self = {
|
||||
items => [],
|
||||
batch_id => $opts{'batch_id'},
|
||||
items => [],
|
||||
};
|
||||
while (my $record = $sth->fetchrow_hashref) {
|
||||
$self->{'batch_id'} = $record->{'batch_id'}; # FIXME: seems a bit wasteful to re-initialize these every trip: is there a better way?
|
||||
$self->{'branch_code'} = $record->{'branch_code'};
|
||||
push (@{$self->{'items'}}, $record->{'item_number'});
|
||||
push (@{$self->{'items'}}, {item_number => $record->{'item_number'}, label_id => $record->{'label_id'}});
|
||||
$record_flag = 1;
|
||||
}
|
||||
return -2 if $record_flag == 0; # a hackish sort of way of indicating no such record exists
|
||||
if ($sth->err) {
|
||||
syslog("LOG_ERR", "C4::Labels::Batch->retrieve : Database returned the following error on attempted SELECT: %s", $sth->errstr);
|
||||
return -1;
|
||||
}
|
||||
$self->{'batch_stat'} = 1;
|
||||
bless ($self, $type);
|
||||
|
|
|
|||
|
|
@ -276,9 +276,9 @@ sub get_label_summary {
|
|||
my @label_summaries = ();
|
||||
my $query = "SELECT b.title, b.author, bi.itemtype, i.barcode, i.biblionumber FROM biblio AS b, biblioitems AS bi ,items AS i, labels_batches AS l WHERE itemnumber=? AND l.item_number=i.itemnumber AND i.biblioitemnumber=bi.biblioitemnumber AND bi.biblionumber=b.biblionumber AND l.batch_id=?;";
|
||||
my $sth = C4::Context->dbh->prepare($query);
|
||||
foreach my $item_number (@{$params{'items'}}) {
|
||||
foreach my $item (@{$params{'items'}}) {
|
||||
$label_number++;
|
||||
$sth->execute($item_number, $params{'batch_id'});
|
||||
$sth->execute($item->{'item_number'}, $params{'batch_id'});
|
||||
if ($sth->err) {
|
||||
syslog("LOG_ERR", "C4::Labels::Lib::get_label_summary : Database returned the following error on attempted SELECT: %s", $sth->errstr);
|
||||
return -1;
|
||||
|
|
@ -291,7 +291,8 @@ sub get_label_summary {
|
|||
$label_summary->{'_summary'} = $record->{'title'} . " | " . ($record->{'author'} ? $record->{'author'} : 'N/A');
|
||||
$label_summary->{'_item_type'} = $record->{'itemtype'};
|
||||
$label_summary->{'_barcode'} = $record->{'barcode'};
|
||||
$label_summary->{'_item_number'} = $item_number;
|
||||
$label_summary->{'_item_number'} = $item->{'item_number'};
|
||||
$label_summary->{'_label_id'} = $item->{'label_id'};
|
||||
push (@label_summaries, $label_summary);
|
||||
}
|
||||
return \@label_summaries;
|
||||
|
|
|
|||
|
|
@ -227,6 +227,10 @@ table {
|
|||
border-right : 1px solid #BCBCBC;
|
||||
}
|
||||
|
||||
#label-search-results {
|
||||
width: 700px;
|
||||
}
|
||||
|
||||
td, th {
|
||||
border-bottom : 1px solid #BCBCBC;
|
||||
border-left : 1px solid #BCBCBC;
|
||||
|
|
@ -1694,3 +1698,17 @@ span.permissiondesc {
|
|||
color: black;
|
||||
}
|
||||
|
||||
.hintsClass {
|
||||
font-family: tahoma, verdana, arial;
|
||||
font-size: 12px;
|
||||
background-color: #f0f0f0;
|
||||
color: #000000;
|
||||
border: 1px solid #808080;
|
||||
padding: 5px;
|
||||
}
|
||||
.hintSource {
|
||||
color: green;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
<div id="toolbar">
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function Plugin(batch_id) {
|
||||
window.open("label-item-search.pl?batch_id="+batch_id+"&type=labels",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
|
||||
return false;
|
||||
}
|
||||
// prepare DOM for YUI Toolbar
|
||||
$(document).ready(function() {
|
||||
$("#additemsc").empty();
|
||||
yuiToolbar();
|
||||
});
|
||||
// YUI Toolbar Functions
|
||||
function yuiToolbar() {
|
||||
new YAHOO.widget.Button({
|
||||
id: "additems",
|
||||
type: "link",
|
||||
href: "#",
|
||||
label: _("Add item(s) to batch"),
|
||||
container: "additemsc",
|
||||
onclick: {fn:function(){Plugin(<!-- TMPL_VAR NAME="batch_id" -->)}}
|
||||
});
|
||||
new YAHOO.widget.Button("deletebatch");
|
||||
new YAHOO.widget.Button("dedup");
|
||||
new YAHOO.widget.Button("generate");
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<ul class="toolbar">
|
||||
<li id="additemsc"><a id="additems" href="#">Add item(s) to batch</a></li>
|
||||
<li><a id="deletebatch" href="/cgi-bin/koha/labels/label-manage.pl?op=delete&label_element=batch&element_id=<!-- TMPL_VAR NAME="batch_id" -->">Delete current batch</a></li>
|
||||
<!-- FIXME: should use POST to change server state, not GET -->
|
||||
<li><a id="dedup" href="/cgi-bin/koha/labels/label-manager.pl?op=deduplicate&batch_id=<!-- TMPL_VAR NAME="batch_id" -->&type=<!-- TMPL_VAR NAME="batch_type" -->">Remove duplicates</a></li>
|
||||
<li><a id="generate" href="/cgi-bin/koha/labels/label-print-<!-- TMPL_VAR NAME="outputformat" -->.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&type=<!-- TMPL_VAR NAME="batch_type" -->">Generate labels for Batch</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
@ -1,143 +1,138 @@
|
|||
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><title>Koha › Barcodes and Labels › Search Results</title><!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
|
||||
<style type="text/css">#custom-doc { width:46.23em;*width:45.04em;min-width:610px; margin:auto;margin-top: .4em; text-align:left; }</style>
|
||||
<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
$(document).ready(function(){
|
||||
$("#CheckAll").click(function(){
|
||||
$(".checkboxed").checkCheckboxes();
|
||||
return false;
|
||||
});
|
||||
$("#CheckNone").click(function(){
|
||||
$(".checkboxed").unCheckCheckboxes();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
function add_item(itemnum,batch_id,type_id){
|
||||
var getstr='';
|
||||
if (itemnum == 'checked') {
|
||||
itms= new Array;
|
||||
if(document.resultform.i_itemnumber.length > 0) {
|
||||
for (var i=0; i < document.resultform.i_itemnumber.length; i++) {
|
||||
if (document.resultform.i_itemnumber[i].checked) {
|
||||
itms.push("itemnumber=" + document.resultform.i_itemnumber[i].value);
|
||||
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
|
||||
<title>Koha › Barcodes and Labels › Search Results</title>
|
||||
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
|
||||
<style type="text/css">#custom-doc { width:46.23em;*width:45.04em;min-width:610px; margin:auto;margin-top: .4em; text-align:left; }</style>
|
||||
<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.checkboxes.pack.js"></script>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
$(document).ready(function(){
|
||||
$("#CheckAll").click(function(){
|
||||
$(".checkboxed").checkCheckboxes();
|
||||
return false;
|
||||
});
|
||||
$("#CheckNone").click(function(){
|
||||
$(".checkboxed").unCheckCheckboxes();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
function add_item(item_number,batch_id,type_id){
|
||||
var getstr='';
|
||||
if (item_number == 'checked') {
|
||||
items= new Array;
|
||||
if(document.resultform.action.length > 0) {
|
||||
for (var i=0; i < document.resultform.action.length; i++) {
|
||||
if (document.resultform.action[i].checked) {
|
||||
items.push("item_number=" + document.resultform.action[i].value);
|
||||
}
|
||||
}
|
||||
getstr = items.join("&");
|
||||
} else {
|
||||
getstr = "item_number="+document.resultform.action.value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
getstr = "item_number="+item_number;
|
||||
}
|
||||
var myurl = "label-edit-batch.pl?op=add&batch_id="+batch_id+
|
||||
"&"+getstr;
|
||||
window.opener.location.href = myurl;
|
||||
}
|
||||
}
|
||||
getstr = itms.join("&");
|
||||
} else {
|
||||
getstr = "itemnumber="+document.resultform.i_itemnumber.value;
|
||||
}
|
||||
} else {
|
||||
getstr = "itemnumber="+itemnum;
|
||||
}
|
||||
var myurl = "label-manager.pl?op=add&batch_id="+batch_id+
|
||||
// "&type="+type_id+ // The template variable NAME="TYPE" is RESERVED ('opac' or 'intranet').
|
||||
"&"+getstr;
|
||||
window.opener.location.href = myurl;
|
||||
}
|
||||
function add_item3(i_itemnumber){
|
||||
var myurl = "label-manager.pl?op=add&itemnumber="+i_itemnumber+"";
|
||||
window.opener.location.href = myurl;
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
]]>
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="custom-doc" class="yui-t7">
|
||||
<div id="bd">
|
||||
<h1>Search results</h1>
|
||||
|
||||
|
||||
<div class="results">
|
||||
<!-- TMPL_IF EXPR="displayprev || displaynext" --><p>
|
||||
<!-- TMPL_IF NAME="displayprev" -->
|
||||
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromprev" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><<</a>
|
||||
<!-- /TMPL_IF -->
|
||||
|
||||
<!-- TMPL_LOOP NAME="numbers" -->
|
||||
<!-- TMPL_IF NAME="highlight" -->
|
||||
<span class="current"><!-- TMPL_VAR NAME="number" --></span>
|
||||
<!-- TMPL_ELSE -->
|
||||
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfrom" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><!-- TMPL_VAR NAME="number" --></a>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- /TMPL_LOOP -->
|
||||
|
||||
<!-- TMPL_IF NAME="displaynext" -->
|
||||
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->">>></a>
|
||||
<!-- /TMPL_IF -->
|
||||
</p><!-- /TMPL_IF -->
|
||||
|
||||
<!-- TMPL_IF name="result" -->
|
||||
<strong>Results <!-- TMPL_VAR name="from" --> through <!-- TMPL_VAR name="to" --> <!-- TMPL_IF NAME="total" --> of <!-- TMPL_VAR name="total" --><!-- /TMPL_IF --></strong>
|
||||
<!-- TMPL_ELSE -->
|
||||
No results found
|
||||
<!-- /TMPL_IF -->
|
||||
</div>
|
||||
|
||||
|
||||
<div id="breadcrumbs"><a href="/cgi-bin/koha/labels/label-item-search.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->">Search for Items for Batch <!-- TMPL_VAR NAME="batch_id" --></a> › Search results</div>
|
||||
<form name="resultform" class="checkboxed" action=""><div style="float: right; margin-top: .5em;"><input type="submit" class="icon addchecked" value="Add checked" onclick="add_item('checked',<!-- TMPL_VAR NAME="batch_id" -->,'<!-- TMPL_VAR NAME="type" -->'); return false" /> <input type="button" class="close" value="Done" /></div><div style="line-height: 2em; margin-left: .7em;"><a id="CheckAll" href="/cgi-bin/koha/labels/label-item-search.pl">Select All</a><span class="clearall"><a id="CheckNone" href="/cgi-bin/koha/labels/label-item-search.pl">Clear All</a></span></div>
|
||||
|
||||
<input type="hidden" name="ccl_query" value="<!-- TMPL_VAR name="ccl_query" -->" />
|
||||
|
||||
|
||||
<!-- TMPL_LOOP name="result" -->
|
||||
<table frame="border" border="2" style="float: left; margin: .5em 0;">
|
||||
<!-- TMPL_IF name="highlight" -->
|
||||
<tr class="highlight">
|
||||
<!-- TMPL_ELSE -->
|
||||
<tr>
|
||||
<!-- /TMPL_IF -->
|
||||
<td colspan="5">
|
||||
<label style="font-weight:bold;"><!-- TMPL_VAR NAME="title" escape="html" --></label> by <!-- TMPL_VAR NAME="author" --><br />
|
||||
[<!-- TMPL_VAR NAME="itemtype" -->], <!-- TMPL_IF name="publishercode" --><!-- TMPL_VAR name="publishercode" --> <!-- /TMPL_IF --><!-- TMPL_IF name="place" --><!-- TMPL_VAR name="place" --> <!-- /TMPL_IF --><!-- TMPL_IF name="copyrightdate" --><!-- TMPL_VAR name="copyrightdate" -->, <!-- /TMPL_IF --><!-- TMPL_IF name="pages" --><!-- TMPL_VAR name="pages" --><!-- /TMPL_IF --><!-- TMPL_IF name="isbn" -->, <b>ISBN: </b><!-- TMPL_VAR name="isbn" --><!-- /TMPL_IF --><!-- TMPL_IF name="notes" -->,<br /><!-- TMPL_VAR name="notes" --><!-- /TMPL_IF -->
|
||||
<div id="custom-doc" class="yui-t7">
|
||||
<div id="bd">
|
||||
<h1>Search results</h1>
|
||||
<div class="results">
|
||||
<!-- TMPL_IF EXPR="displayprev || displaynext" -->
|
||||
<p>
|
||||
<!-- TMPL_IF NAME="displayprev" -->
|
||||
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromprev" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><<</a>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_LOOP NAME="numbers" -->
|
||||
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfrom" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><!-- TMPL_VAR NAME="number" --></a>
|
||||
<!-- /TMPL_LOOP -->
|
||||
<!-- TMPL_IF NAME="displaynext" -->
|
||||
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->">>></a>
|
||||
<!-- /TMPL_IF -->
|
||||
</p>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF name="results" -->
|
||||
<strong>Results <!-- TMPL_VAR name="from" --> through <!-- TMPL_VAR name="to" --> <!-- TMPL_IF NAME="total" --> of <!-- TMPL_VAR name="total" --><!-- /TMPL_IF --></strong>
|
||||
<!-- TMPL_ELSE -->
|
||||
No results found
|
||||
<!-- /TMPL_IF -->
|
||||
</div>
|
||||
<div id="breadcrumbs">
|
||||
<a href="/cgi-bin/koha/labels/label-item-search.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->">Search for Items for Batch <!-- TMPL_VAR NAME="batch_id" --></a> ›
|
||||
Search results
|
||||
</div>
|
||||
<form name="resultform" class="checkboxed" action="">
|
||||
<div style="float: right; margin-top: .5em; margin-left: .7em; margin-bottom: .7em">
|
||||
<input type="submit" class="icon addchecked" value="Add checked" onclick="add_item('checked',<!-- TMPL_VAR NAME="batch_id" -->,'<!-- TMPL_VAR NAME="type" -->'); return false" />
|
||||
<input type="button" class="close" value="Done" />
|
||||
</div>
|
||||
<div style="line-height: 2em; margin-left: .7em;">
|
||||
<a id="CheckAll" href="/cgi-bin/koha/labels/label-item-search.pl">Select All</a>
|
||||
<span class="clearall">
|
||||
<a id="CheckNone" href="/cgi-bin/koha/labels/label-item-search.pl">Clear All</a>
|
||||
</span>
|
||||
</div>
|
||||
<input type="hidden" name="ccl_query" value="<!-- TMPL_VAR name="ccl_query" -->" />
|
||||
<!-- TMPL_LOOP name="result_set" -->
|
||||
<table id="label-search-results" frame="border" border="2">
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<label style="font-weight:bold;"><!-- TMPL_VAR NAME="title" --></label>
|
||||
by <!-- TMPL_VAR NAME="author" --><br />
|
||||
[<!-- TMPL_VAR NAME="itemtype" -->], <!-- TMPL_IF name="publishercode" --><!-- TMPL_VAR name="publishercode" --> <!-- /TMPL_IF --><!-- TMPL_IF name="place" --><!-- TMPL_VAR name="place" --> <!-- /TMPL_IF --><!-- TMPL_IF name="copyrightdate" --><!-- TMPL_VAR name="copyrightdate" -->, <!-- /TMPL_IF --><!-- TMPL_IF name="pages" --><!-- TMPL_VAR name="pages" --><!-- /TMPL_IF --><!-- TMPL_IF name="isbn" -->, <b>ISBN: </b><!-- TMPL_VAR name="isbn" --><!-- /TMPL_IF --><!-- TMPL_IF name="notes" -->,<br /><!-- TMPL_VAR name="notes" --><!-- /TMPL_IF -->
|
||||
</td>
|
||||
</tr>
|
||||
<!-- NEW -->
|
||||
<tr>
|
||||
<th>Select</th>
|
||||
<th>Item Call Number</th>
|
||||
<th>Date Accessioned</th>
|
||||
<th>Barcode</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<!-- TMPL_IF name="item" -->
|
||||
<!-- TMPL_LOOP name="item" -->
|
||||
<!-- TMPL_IF name="i_itemnumber1" --><tr><td align="center"><label for="itm<!-- TMPL_VAR NAME="i_itemnumber1" -->" ><input type="checkbox" name="i_itemnumber" id="itm<!-- TMPL_VAR NAME="i_itemnumber1" -->" value="<!-- TMPL_VAR NAME="i_itemnumber1" -->" /></label></td><!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF name="i_itemcallnumber" --><td align="center"><!-- TMPL_VAR name="i_itemcallnumber" --><br /></td><!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF name="i_dateaccessioned" --><td align="center"><!-- TMPL_VAR name="i_dateaccessioned" --><br /></td><!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF name="i_barcode" --><td align="center"><!-- TMPL_VAR name="i_barcode" --></td><!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF name="i_itemnumber2" --><td align="center">
|
||||
<a onclick="add_item('<!-- TMPL_VAR NAME="i_itemnumber2" -->',<!-- TMPL_VAR NAME="batch_id" -->, '<!-- TMPL_VAR NAME="type" -->'); return false" href="/cgi-bin/koha/barcodes/label-manager.pl?itemnumber=<!-- TMPL_VAR NAME="i_itemnumber2" -->&batch_id=<!-- TMPL_VAR name="batch_id" -->&op=add">Add</a></td></tr>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- /NEW -->
|
||||
<!-- /TMPL_LOOP --><!-- item -->
|
||||
<!-- /TMPL_IF -->
|
||||
</table>
|
||||
<!-- /TMPL_LOOP -->
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</tr>
|
||||
<!-- TMPL_LOOP NAME="item_table" -->
|
||||
<!-- TMPL_IF NAME="header_fields" -->
|
||||
<tr>
|
||||
<!-- TMPL_LOOP NAME="header_fields" -->
|
||||
<th><!-- TMPL_VAR NAME="field_label" --></th>
|
||||
<!-- /TMPL_LOOP -->
|
||||
</tr>
|
||||
<!-- TMPL_ELSE -->
|
||||
<tr>
|
||||
<!-- TMPL_LOOP NAME="text_fields" -->
|
||||
<!-- TMPL_IF NAME="select_field" -->
|
||||
<td align="center"><input type="checkbox" name="action" value="<!-- TMPL_VAR NAME="field_value" -->"></td>
|
||||
<!-- TMPL_ELSIF NAME="link_field" -->
|
||||
<td align="center">
|
||||
<a onclick="add_item('<!-- TMPL_VAR NAME="field_value" -->',<!-- TMPL_VAR NAME="batch_id" -->, '<!-- TMPL_VAR NAME="type" -->'); return false" href="/cgi-bin/koha/barcodes/label-edit-batch.pl?op=add&batch_id=<!-- TMPL_VAR name="batch_id" -->&item_number=<!-- TMPL_VAR NAME="field_value" -->">Add</a>
|
||||
</td>
|
||||
<!-- TMPL_ELSE -->
|
||||
<td align="center"><!-- TMPL_VAR NAME="field_value" --></td>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- /TMPL_LOOP -->
|
||||
</tr>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- /TMPL_LOOP -->
|
||||
</table>
|
||||
<!-- /TMPL_LOOP -->
|
||||
</form>
|
||||
</div>
|
||||
<div class="results">
|
||||
<!-- TMPL_IF EXPR="displayprev || displaynext" --><p>
|
||||
<!-- TMPL_IF NAME="displayprev" -->
|
||||
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><<</a>
|
||||
<!-- /TMPL_IF -->
|
||||
|
||||
<!-- TMPL_LOOP NAME="numbers" -->
|
||||
<!-- TMPL_IF NAME="highlight" -->
|
||||
<span class="current"><!-- TMPL_VAR NAME="number" --></span>
|
||||
<!-- TMPL_ELSE -->
|
||||
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfrom" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><!-- TMPL_VAR NAME="number" --></a>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- /TMPL_LOOP -->
|
||||
|
||||
<!-- TMPL_IF NAME="displaynext" -->
|
||||
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->">>></a>
|
||||
<!-- /TMPL_IF -->
|
||||
</p><!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF EXPR="displayprev || displaynext" -->
|
||||
<p>
|
||||
<!-- TMPL_IF NAME="displayprev" -->
|
||||
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><<</a>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_LOOP NAME="numbers" -->
|
||||
<!-- TMPL_IF NAME="highlight" -->
|
||||
<span class="current"><!-- TMPL_VAR NAME="number" --></span>
|
||||
<!-- TMPL_ELSE -->
|
||||
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfrom" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><!-- TMPL_VAR NAME="number" --></a>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- /TMPL_LOOP -->
|
||||
<!-- TMPL_IF NAME="displaynext" -->
|
||||
<a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->">>></a>
|
||||
<!-- /TMPL_IF -->
|
||||
</p>
|
||||
<!-- /TMPL_IF -->
|
||||
</div>
|
||||
|
||||
|
||||
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
|
||||
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ use Switch qw(Perl6);
|
|||
use CGI;
|
||||
use HTML::Template::Pro;
|
||||
use Data::Dumper;
|
||||
use JSON;
|
||||
|
||||
use C4::Auth;
|
||||
use C4::Output;
|
||||
|
|
@ -55,11 +56,12 @@ my $display_columns = [ {_label_number => {label => 'Label Number', link_field
|
|||
{_summary => {label => 'Summary', link_field => 0}},
|
||||
{_item_type => {label => 'Item Type', link_field => 0}},
|
||||
{_barcode => {label => 'Barcode', link_field => 0}},
|
||||
{select => {label => 'Select', value => '_item_number'}},
|
||||
{select => {label => 'Select', value => '_label_id'}},
|
||||
];
|
||||
my $op = $cgi->param('op') || undef;
|
||||
my $label_id = $cgi->param('label_id') || undef;
|
||||
my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || undef;
|
||||
my @item_numbers = $cgi->param('item_number') if $cgi->param('item_number');
|
||||
my $branch_code = get_branch_code_from_name($template->param('LoginBranchname'));
|
||||
|
||||
if ($op eq 'remove') {
|
||||
|
|
@ -71,7 +73,19 @@ elsif ($op eq 'delete') {
|
|||
$err = C4::Labels::Batch::delete(batch_id => $batch_id, branch_code => $branch_code);
|
||||
$errstr = "batch $batch_id was not deleted." if $err;
|
||||
}
|
||||
else{
|
||||
elsif ($op eq 'add') {
|
||||
$batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
|
||||
$batch = C4::Labels::Batch->new(branch_code => $branch_code) if $batch == -2;
|
||||
foreach my $item_number (@item_numbers) {
|
||||
$err = $batch->add_item($item_number);
|
||||
}
|
||||
$errstr = "item(s) not added to batch $batch_id." if $err;
|
||||
}
|
||||
elsif ($op eq 'new') {
|
||||
$batch = C4::Labels::Batch->new(branch_code => $branch_code);
|
||||
$batch_id = $batch->get_attr('batch_id');
|
||||
}
|
||||
else { # display batch
|
||||
$batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,12 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use CGI;
|
||||
use C4::Auth;
|
||||
use HTML::Template::Pro;
|
||||
use List::Util qw( max min );
|
||||
use POSIX;
|
||||
use Data::Dumper;
|
||||
|
||||
use C4::Auth;
|
||||
use C4::Context;
|
||||
use C4::Search;
|
||||
use C4::Auth;
|
||||
|
|
@ -33,12 +37,8 @@ use C4::Acquisition;
|
|||
use C4::Search;
|
||||
use C4::Dates;
|
||||
use C4::Koha; # XXX subfield_is_koha_internal_p
|
||||
use C4::Labels::Lib qw(html_table);
|
||||
use C4::Debug;
|
||||
use List::Util qw( max min );
|
||||
use POSIX;
|
||||
|
||||
#use Smart::Comments;
|
||||
#use Data::Dumper;
|
||||
|
||||
BEGIN {
|
||||
$debug = $debug || $cgi_debug;
|
||||
|
|
@ -57,7 +57,7 @@ my $query = new CGI;
|
|||
my $type = $query->param('type');
|
||||
my $op = $query->param('op') || '';
|
||||
my $batch_id = $query->param('batch_id');
|
||||
my $ccl_query = $query->param('ccl_query');
|
||||
my $ccl_query = $query->param('ccl_query') || '';
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
|
|
@ -69,10 +69,17 @@ my (
|
|||
);
|
||||
|
||||
my $resultsperpage = C4::Context->preference('numSearchResults') || '20';
|
||||
|
||||
my $show_results = 0;
|
||||
|
||||
my $display_columns = [ {_add => {label => "Add Item", link_field => 1}},
|
||||
{_item_call_number => {label => "Call Number", link_field => 0}},
|
||||
{_date_accessioned => {label => "Accession Date", link_field => 0}},
|
||||
{_barcode => {label => "Barcode", link_field => 0}},
|
||||
{select => {label => "Select", value => "_item_number"}},
|
||||
];
|
||||
|
||||
if ( $op eq "do_search" ) {
|
||||
my @params = $query->param();
|
||||
$idx = $query->param('idx');
|
||||
$ccl_textbox = $query->param('ccl_textbox');
|
||||
if ( $ccl_textbox && $idx ) {
|
||||
|
|
@ -82,18 +89,6 @@ if ( $op eq "do_search" ) {
|
|||
$datefrom = $query->param('datefrom');
|
||||
$dateto = $query->param('dateto');
|
||||
|
||||
( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
||||
{
|
||||
template_name => "labels/result.tmpl",
|
||||
query => $query,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => { borrowers => 1 },
|
||||
flagsrequired => { catalogue => 1 },
|
||||
debug => 1,
|
||||
}
|
||||
);
|
||||
|
||||
if ($datefrom) {
|
||||
$datefrom = C4::Dates->new($datefrom);
|
||||
$ccl_query .= ' and ' if $ccl_textbox;
|
||||
|
|
@ -111,7 +106,7 @@ if ( $op eq "do_search" ) {
|
|||
( $error, $marcresults, $total_hits ) =
|
||||
SimpleSearch( $ccl_query, $offset, $resultsperpage );
|
||||
|
||||
if ($marcresults) {
|
||||
if (scalar($marcresults) > 0) {
|
||||
$show_results = scalar @$marcresults;
|
||||
}
|
||||
else {
|
||||
|
|
@ -123,71 +118,55 @@ if ( $op eq "do_search" ) {
|
|||
|
||||
if ($show_results) {
|
||||
my $hits = $show_results;
|
||||
my ( @results, @items );
|
||||
|
||||
my @results_set = ();
|
||||
my @items =();
|
||||
# This code needs to be refactored using these subs...
|
||||
#my @items = &GetItemsInfo( $biblio->{biblionumber}, 'intra' );
|
||||
#my $dat = &GetBiblioData( $biblio->{biblionumber} );
|
||||
for ( my $i = 0 ; $i < $hits ; $i++ ) {
|
||||
|
||||
my @row_data= ();
|
||||
#DEBUG Notes: Decode the MARC record from each resulting MARC record...
|
||||
my $marcrecord = MARC::File::USMARC::decode( $marcresults->[$i] );
|
||||
|
||||
#DEBUG Notes: Transform it to Koha form...
|
||||
my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
|
||||
|
||||
# Begin building the hash for the template...
|
||||
# I don't think we need this with the current template design, but I'm leaving it in place. -fbcit
|
||||
#$biblio->{highlight} = ($i % 2)?(1):(0);
|
||||
#DEBUG Notes: Stuff the bib into @results...
|
||||
push @results, $biblio;
|
||||
#DEBUG Notes: Stuff the bib into @biblio_data...
|
||||
push (@results_set, $biblio);
|
||||
my $biblionumber = $biblio->{'biblionumber'};
|
||||
|
||||
#DEBUG Notes: Grab the item numbers associated with this MARC record...
|
||||
my $itemnums = get_itemnumbers_of($biblionumber);
|
||||
|
||||
#DEBUG Notes: Retrieve the item data for each number...
|
||||
my $iii = $itemnums->{$biblionumber};
|
||||
if ($iii) {
|
||||
if (my $iii = $itemnums->{$biblionumber}) {
|
||||
my $item_results = GetItemInfosOf(@$iii);
|
||||
foreach my $item ( keys %$item_results ) {
|
||||
|
||||
#DEBUG Notes: Build an array element 'item' of the correct bib (results) hash which contains item-specific data...
|
||||
if ( $item_results->{$item}->{'biblionumber'} eq
|
||||
$results[$i]->{'biblionumber'} )
|
||||
{
|
||||
|
||||
# NOTE: The order of the elements in this array must be preserved or the table dependent on it will be incorrectly rendered.
|
||||
# This is a real hack, but I can't think of a better way right now. -fbcit
|
||||
# It is conceivable that itemcallnumber and/or barcode fields might be empty so the trinaries cover this possibility.
|
||||
push @{ $results[$i]->{'item'} }, { i_itemnumber1 =>
|
||||
$item_results->{$item}->{'itemnumber'} };
|
||||
push @{ $results[$i]->{'item'} },
|
||||
{
|
||||
i_itemcallnumber => (
|
||||
$item_results->{$item}->{'itemcallnumber'}
|
||||
? $item_results->{$item}->{'itemcallnumber'}
|
||||
: 'NA'
|
||||
)
|
||||
};
|
||||
push @{ $results[$i]->{'item'} }, { i_dateaccessioned =>
|
||||
$item_results->{$item}->{'dateaccessioned'} };
|
||||
push @{ $results[$i]->{'item'} },
|
||||
{
|
||||
i_barcode => (
|
||||
$item_results->{$item}->{'barcode'}
|
||||
? $item_results->{$item}->{'barcode'}
|
||||
: 'NA'
|
||||
)
|
||||
};
|
||||
push @{ $results[$i]->{'item'} }, { i_itemnumber2 =>
|
||||
$item_results->{$item}->{'itemnumber'} };
|
||||
#DEBUG Notes: Build an array element 'item' of the correct bib (results) hash which contains item-specific data...
|
||||
if ($item_results->{$item}->{'biblionumber'} eq $results_set[$i]->{'biblionumber'}) {
|
||||
my $item_data->{'_item_number'} = $item_results->{$item}->{'itemnumber'};
|
||||
$item_data->{'_item_call_number'} = ($item_results->{$item}->{'itemcallnumber'} ? $item_results->{$item}->{'itemcallnumber'} : 'NA');
|
||||
$item_data->{'_date_accessioned'} = $item_results->{$item}->{'dateaccessioned'};
|
||||
$item_data->{'_barcode'} = ( $item_results->{$item}->{'barcode'} ? $item_results->{$item}->{'barcode'} : 'NA');
|
||||
$item_data->{'_add'} = $item_results->{$item}->{'itemnumber'};
|
||||
unshift (@row_data, $item_data); # item numbers are given to us in descending order by get_itemnumbers_of()...
|
||||
}
|
||||
}
|
||||
$results_set[$i]->{'item_table'} = html_table($display_columns, \@row_data);
|
||||
}
|
||||
else {
|
||||
# FIXME: Some error trapping code needed
|
||||
syslog("LOG_ERR", "labels/label-item-search.pl : No item numbers retrieved for biblio number: %s", $biblionumber);
|
||||
}
|
||||
}
|
||||
$debug and warn "**********\@results**********\n";
|
||||
$debug and warn Dumper(@results);
|
||||
|
||||
( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
||||
{
|
||||
template_name => "labels/result.tmpl",
|
||||
query => $query,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => { borrowers => 1 },
|
||||
flagsrequired => { catalogue => 1 },
|
||||
debug => 1,
|
||||
}
|
||||
);
|
||||
|
||||
# build page nav stuff.
|
||||
my ( @field_data, @numbers );
|
||||
|
|
@ -242,7 +221,8 @@ if ($show_results) {
|
|||
);
|
||||
|
||||
$template->param(
|
||||
result => \@results,
|
||||
results => ($show_results ? 1 : 0),
|
||||
result_set=> \@results_set,
|
||||
batch_id => $batch_id,
|
||||
type => $type,
|
||||
idx => $idx,
|
||||
|
|
|
|||
Loading…
Reference in New Issue