Partial commit to add Create-Label-Batch-from-Import-Batch
authorRyan Higgins <rch@liblime.com>
Tue, 18 Mar 2008 02:27:40 +0000 (21:27 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Tue, 18 Mar 2008 02:32:30 +0000 (21:32 -0500)
Import batch portion herein. Still need to touch Labels.pm .

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/ImportBatch.pm
koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tmpl
koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tmpl
tools/manage-marc-import.pl

index 283de04..bf4e186 100644 (file)
@@ -48,6 +48,7 @@ BEGIN {
     GetImportBatchRangeDesc
     GetNumberOfNonZ3950ImportBatches
     GetImportBibliosRange
+       GetItemNumbersFromImportBatch
     
     GetImportBatchStatus
     SetImportBatchStatus
@@ -720,6 +721,24 @@ sub GetImportBatchRangeDesc {
     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
index a17e362..281d99d 100644 (file)
  &rsaquo; 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>
@@ -156,7 +160,7 @@ Page
     <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>
index 014a4e8..de92a33 100644 (file)
@@ -49,7 +49,10 @@ function CheckForm(f) {
         <!-- /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 -->
@@ -105,6 +108,10 @@ function CheckForm(f) {
       <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" />
index ec55233..9f93266 100755 (executable)
@@ -59,6 +59,13 @@ my %cookies = parse CGI::Cookie($cookie);
 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 {
@@ -93,7 +100,7 @@ if ($op eq "") {
     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;
 
@@ -122,6 +129,13 @@ sub redo_matching {
     $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);