Import batch portion herein. Still need to touch Labels.pm .
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
GetImportBatchRangeDesc
GetNumberOfNonZ3950ImportBatches
GetImportBibliosRange
+ GetItemNumbersFromImportBatch
GetImportBatchStatus
SetImportBatchStatus
return $results;
}
+=head2 GetItemNumbersFromImportBatch
+
+=over 4
+=back
+=cut
+
+sub GetItemNumbersFromImportBatch {
+ my ($batch_id) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare("select itemnumber from import_batches,import_records,import_items where import_batches.import_batch_id=import_records.import_batch_id and import_records.import_record_id=import_items.import_record_id and import_batches.import_batch_id=?");
+ $sth->execute($batch_id);
+ my @items ;
+ while ( my ($itm) = $sth->fetchrow_array ) {
+ push @items, $itm;
+ }
+ return @items;
+}
+
=head2 GetNumberOfImportBatches
=over 4
› Batch <!-- TMPL_VAR name="import_batch_id" -->
<!-- /TMPL_IF -->
</h1>
-
+<!-- TMPL_IF name="label_batch" -->
+<div class="alert">
+<p>Label batch created, with id: <!-- TMPL_VAR name="label_batch" --> </p>
+</div>
+<!-- /TMPL_IF -->
<!-- TMPL_IF name="batch_info" -->
<p><label>File name</label> <!-- TMPL_VAR name="file_name" --></p>
<p><label>Comments</label> <!-- TMPL_VAR name="comments" --></p>
<td><!-- TMPL_VAR name="import_status" --></td>
<td><!-- TMPL_VAR name="upload_timestamp" --></td>
<td><!-- TMPL_VAR name="num_biblios" --></td>
- <td><!-- TMPL_VAR name="num_items" --></td>
+ <td><!-- TMPL_VAR name="num_items" --><!-- TMPL_IF NAME="num_items" --><a href="<!-- TMPL_VAR name="script_name" -->?import_batch_id=<!-- TMPL_VAR name="import_batch_id" -->&op=create_labels">(Create Label Batch)</a><!-- /TMPL_IF --></td>
</tr>
<!-- /TMPL_LOOP -->
</table>
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
<li><!-- TMPL_VAR name="num_items" --> item records found and staged</li>
- <li><a href="/cgi-bin/koha/tools/manage-marc-import.pl?import_batch_id=<!-- TMPL_VAR name="import_batch_id" -->">Manage staged records</a></li>
+ <<!-- TMPL_IF name="label_batch" -->
+ <li>New label batch created: # <!-- TMPL_VAR name="label_batch" --> </li>
+ <!-- /TMPL_IF -->
+ <li><a href="/cgi-bin/koha/tools/manage-marc-import.pl?import_batch_id=<!-- TMPL_VAR name="import_batch_id" -->">Manage staged records</a></li>
<li><a href="/cgi-bin/koha/tools/tools-home.pl">Back</a></li>
</ul>
<!-- TMPL_ELSE -->
<li class="radio">
<input type="radio" id="parse_itemsyes" name="parse_items" value="1" checked="checked" />
<label for="parse_itemsyes">Yes</label>
+ <ul class="inline"><li class="inline">
+ <input type="checkbox" id="create_labelbatch" name="create_labelbatch" />
+ <label for="create_labelbatch">Create a label batch for this import?</label>
+ </li></ul>
</li>
<li class="radio">
<input type="radio" id="parse_itemsno" name="parse_items" value="0" />
my $sessionID = $cookies{'CGISESSID'}->value;
my $dbh = C4::Context->dbh;
+if ($op eq "create_labels") {
+ #create a batch of labels, then lose $op & $import_batch_id so we get back to import batch list.
+ my $label_batch_id = create_labelbatch_from_importbatch($import_batch_id);
+ $template->param( label_batch => $label_batch_id );
+ $op='';
+ $import_batch_id='';
+}
if ($op) {
$template->param(script_name => $script_name, $op => 1);
} else {
my $current_matcher_id = $input->param('current_matcher_id');
redo_matching($template, $import_batch_id, $new_matcher_id, $current_matcher_id);
import_biblios_list($template, $import_batch_id, $offset, $results_per_page);
-}
+}
output_html_with_http_headers $input, $cookie, $template->output;
$template->param(num_with_matches => $num_with_matches);
}
+sub create_labelbatch_from_importbatch {
+ my ($batch_id) = @_;
+ my @items = GetItemNumbersFromImportBatch($batch_id);
+ warn join("/",@items);
+ return 0; # dummy return until C4::Labels::add_batch() takes an array
+}
+
sub import_batches_list {
my ($template, $offset, $results_per_page) = @_;
my $batches = GetImportBatchRangeDesc($offset, $results_per_page);