View | Details | Raw Unified | Return to bug 10877
Collapse All | Expand All

(-)a/C4/ImportBatch.pm (-7 / +18 lines)
Lines 206-212 sub AddImportBatch { Link Here
206
    my (@fields, @vals);
206
    my (@fields, @vals);
207
    foreach (qw( matcher_id template_id branchcode
207
    foreach (qw( matcher_id template_id branchcode
208
                 overlay_action nomatch_action item_action
208
                 overlay_action nomatch_action item_action
209
                 import_status batch_type file_name comments record_type )) {
209
                 import_status batch_type file_name comments
210
                 record_type is_order )) {
210
        if (exists $params->{$_}) {
211
        if (exists $params->{$_}) {
211
            push @fields, $_;
212
            push @fields, $_;
212
            push @vals, $params->{$_};
213
            push @vals, $params->{$_};
Lines 319-325 sub ModAuthInBatch { Link Here
319
  ($batch_id, $num_records, $num_items, @invalid_records) = 
320
  ($batch_id, $num_records, $num_items, @invalid_records) = 
320
    BatchStageMarcRecords($encoding, $marc_records, $file_name, $marc_modification_template,
321
    BatchStageMarcRecords($encoding, $marc_records, $file_name, $marc_modification_template,
321
                          $comments, $branch_code, $parse_items,
322
                          $comments, $branch_code, $parse_items,
322
                          $leave_as_staging, 
323
                          $leave_as_staging, is_order,
323
                          $progress_interval, $progress_callback);
324
                          $progress_interval, $progress_callback);
324
325
325
=cut
326
=cut
Lines 334-339 sub BatchStageMarcRecords { Link Here
334
    my $branch_code = shift;
335
    my $branch_code = shift;
335
    my $parse_items = shift;
336
    my $parse_items = shift;
336
    my $leave_as_staging = shift;
337
    my $leave_as_staging = shift;
338
    my $is_order = shift;
337
339
338
    # optional callback to monitor status 
340
    # optional callback to monitor status 
339
    # of job
341
    # of job
Lines 353-358 sub BatchStageMarcRecords { Link Here
353
            file_name => $file_name,
355
            file_name => $file_name,
354
            comments => $comments,
356
            comments => $comments,
355
            record_type => $record_type,
357
            record_type => $record_type,
358
            is_order => $is_order,
356
        } );
359
        } );
357
    if ($parse_items) {
360
    if ($parse_items) {
358
        SetImportBatchItemAction($batch_id, 'always_add');
361
        SetImportBatchItemAction($batch_id, 'always_add');
Lines 953-973 sub GetStagedWebserviceBatches { Link Here
953
956
954
=head2 GetImportBatchRangeDesc
957
=head2 GetImportBatchRangeDesc
955
958
956
  my $results = GetImportBatchRangeDesc($offset, $results_per_group);
959
  my $results = GetImportBatchRangeDesc($offset, $results_per_group, $is_order);
957
960
958
Returns a reference to an array of hash references corresponding to
961
Returns a reference to an array of hash references corresponding to
959
import_batches rows (sorted in descending order by import_batch_id)
962
import_batches rows (sorted in descending order by import_batch_id)
960
start at the given offset.
963
start at the given offset.
961
964
965
Pass in $is_order = 1 to get only batches marked as order records
966
962
=cut
967
=cut
963
968
964
sub GetImportBatchRangeDesc {
969
sub GetImportBatchRangeDesc {
965
    my ($offset, $results_per_group) = @_;
970
    my ($offset, $results_per_group,$is_order) = @_;
971
972
    my $is_order_limit = $is_order ? "AND is_order = 1" : q{};
966
973
967
    my $dbh = C4::Context->dbh;
974
    my $dbh = C4::Context->dbh;
968
    my $query = "SELECT * FROM import_batches
975
    my $query = "
969
                                    WHERE batch_type IN ('batch', 'webservice')
976
        SELECT * FROM import_batches
970
                                    ORDER BY import_batch_id DESC";
977
        WHERE batch_type IN ('batch', 'webservice')
978
        $is_order_limit
979
        ORDER BY import_batch_id DESC
980
    ";
981
971
    my @params;
982
    my @params;
972
    if ($results_per_group){
983
    if ($results_per_group){
973
        $query .= " LIMIT ?";
984
        $query .= " LIMIT ?";
(-)a/acqui/addorderiso2709.pl (-6 / +48 lines)
Lines 58-69 my ($template, $loggedinuser, $cookie, $userflags) = get_template_and_user({ Link Here
58
my $cgiparams = $input->Vars;
58
my $cgiparams = $input->Vars;
59
my $op = $cgiparams->{'op'} || '';
59
my $op = $cgiparams->{'op'} || '';
60
my $booksellerid  = $input->param('booksellerid');
60
my $booksellerid  = $input->param('booksellerid');
61
my $is_order = $input->param('is_order');
61
my $bookseller = GetBookSellerFromId($booksellerid);
62
my $bookseller = GetBookSellerFromId($booksellerid);
62
my $data;
63
my $data;
63
64
64
$template->param(scriptname => "/cgi-bin/koha/acqui/addorderiso2709.pl",
65
$template->param(scriptname => "/cgi-bin/koha/acqui/addorderiso2709.pl",
65
                booksellerid => $booksellerid,
66
                booksellerid => $booksellerid,
66
                booksellername => $bookseller->{name},
67
                booksellername => $bookseller->{name},
68
                is_order => $is_order,
67
                );
69
                );
68
70
69
if ($cgiparams->{'import_batch_id'} && $op eq ""){
71
if ($cgiparams->{'import_batch_id'} && $op eq ""){
Lines 81-87 if (! $cgiparams->{'basketno'}){ Link Here
81
if ($op eq ""){
83
if ($op eq ""){
82
    $template->param("basketno" => $cgiparams->{'basketno'});
84
    $template->param("basketno" => $cgiparams->{'basketno'});
83
#display batches
85
#display batches
84
    import_batches_list($template);
86
    import_batches_list( $template, $is_order );
85
#
87
#
86
# 2nd step = display the content of the choosen file
88
# 2nd step = display the content of the choosen file
87
#
89
#
Lines 266-271 if ($op eq ""){ Link Here
266
            my @serials      = $input->param('serial');
268
            my @serials      = $input->param('serial');
267
            my @ind_tag   = $input->param('ind_tag');
269
            my @ind_tag   = $input->param('ind_tag');
268
            my @indicator = $input->param('indicator');
270
            my @indicator = $input->param('indicator');
271
272
            if ($is_order) {
273
                my ( $notforloan_field, $notforloan_subfield ) =
274
                  GetMarcFromKohaField('items.notforloan');
275
                push( @tags,         $notforloan_field );
276
                push( @subfields,    $notforloan_subfield );
277
                push( @field_values, '-1' );
278
279
                my ( $homebranch_field, $homebranch_subfield ) =
280
                  GetMarcFromKohaField('items.homebranch');
281
                push( @tags,         $homebranch_field );
282
                push( @subfields,    $homebranch_subfield );
283
                push( @field_values, C4::Context->userenv->{'branch'} );
284
285
                my ( $holdingbranch_field, $holdingbranch_subfield ) =
286
                  GetMarcFromKohaField('items.holdingbranch');
287
                push( @tags,         $holdingbranch_field );
288
                push( @subfields,    $holdingbranch_subfield );
289
                push( @field_values, C4::Context->userenv->{'branch'} );
290
291
                my $infos = get_infos_syspref($marcrecord, ['itype']);
292
                my ( $itype_field, $itype_subfield ) =
293
                  GetMarcFromKohaField('items.itype');
294
                push( @tags,         $itype_field );
295
                push( @subfields,    $itype_subfield );
296
                push( @field_values, $infos->{itype} );
297
                warn "ITYPE: " . $infos->{itype};
298
            }
299
269
            my $item;
300
            my $item;
270
            push @{ $item->{tags} },         $tags[0];
301
            push @{ $item->{tags} },         $tags[0];
271
            push @{ $item->{subfields} },    $subfields[0];
302
            push @{ $item->{subfields} },    $subfields[0];
Lines 345-352 output_html_with_http_headers $input, $cookie, $template->output; Link Here
345
376
346
377
347
sub import_batches_list {
378
sub import_batches_list {
348
    my ($template) = @_;
379
    my ($template, $is_order) = @_;
349
    my $batches = GetImportBatchRangeDesc();
380
    my $batches = GetImportBatchRangeDesc(undef,undef,$is_order);
350
381
351
    my @list = ();
382
    my @list = ();
352
    foreach my $batch (@$batches) {
383
    foreach my $batch (@$batches) {
Lines 440-445 sub import_biblios_list { Link Here
440
                        item_action => $item_action
471
                        item_action => $item_action
441
                    );
472
                    );
442
    batch_info($template, $batch);
473
    batch_info($template, $batch);
474
475
    return \@list;
443
}
476
}
444
477
445
sub batch_info {
478
sub batch_info {
Lines 483-490 sub add_matcher_list { Link Here
483
    $template->param(available_matchers => \@matchers);
516
    $template->param(available_matchers => \@matchers);
484
}
517
}
485
518
486
sub get_infos_syspref {
519
sub GetMarcFieldsToOrderAsYAML {
487
    my ($record, $field_list) = @_;
488
    my $syspref = C4::Context->preference('MarcFieldsToOrder');
520
    my $syspref = C4::Context->preference('MarcFieldsToOrder');
489
    $syspref = "$syspref\n\n"; # YAML is anal on ending \n. Surplus does not hurt
521
    $syspref = "$syspref\n\n"; # YAML is anal on ending \n. Surplus does not hurt
490
    my $yaml = eval {
522
    my $yaml = eval {
Lines 492-499 sub get_infos_syspref { Link Here
492
    };
524
    };
493
    if ( $@ ) {
525
    if ( $@ ) {
494
        warn "Unable to parse MarcFieldsToOrder syspref : $@";
526
        warn "Unable to parse MarcFieldsToOrder syspref : $@";
495
        return ();
527
        return;
528
    } else {
529
        return $yaml;
496
    }
530
    }
531
}
532
533
sub get_infos_syspref {
534
    my ($record, $field_list) = @_;
535
536
    my $yaml = GetMarcFieldsToOrderAsYAML;
537
    return unless $yaml;
538
497
    my $r;
539
    my $r;
498
    for my $field_name ( @$field_list ) {
540
    for my $field_name ( @$field_list ) {
499
        next unless exists $yaml->{$field_name};
541
        next unless exists $yaml->{$field_name};
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 7923-7928 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
7923
   SetVersion ($DBversion);
7923
   SetVersion ($DBversion);
7924
}
7924
}
7925
7925
7926
$DBversion = "3.13.00.XXX";
7927
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
7928
    $dbh->do("ALTER TABLE import_batches ADD is_order BOOLEAN NOT NULL DEFAULT '0' AFTER comments");
7929
   print "Upgrade to $DBversion done (Bug 10877 - Add 'Order Record' processing)\n";
7930
   SetVersion ($DBversion);
7931
7932
}
7926
=head1 FUNCTIONS
7933
=head1 FUNCTIONS
7927
7934
7928
=head2 TableExists($table)
7935
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc (+1 lines)
Lines 17-22 Link Here
17
        <li><a href="/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">From a new (empty) record</a></li>
17
        <li><a href="/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">From a new (empty) record</a></li>
18
        <li><a href="/cgi-bin/koha/acqui/z3950_search.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">From an external source</a></li>
18
        <li><a href="/cgi-bin/koha/acqui/z3950_search.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">From an external source</a></li>
19
        <li><a href="/cgi-bin/koha/acqui/addorderiso2709.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]"> From a staged file</a></li>
19
        <li><a href="/cgi-bin/koha/acqui/addorderiso2709.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]"> From a staged file</a></li>
20
        <li><a href="/cgi-bin/koha/acqui/addorderiso2709.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]&amp;is_order=1"> From a staged order file</a></li>
20
      </ul>
21
      </ul>
21
    [% ELSE %]
22
    [% ELSE %]
22
        <div class="dialog alert">
23
        <div class="dialog alert">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt (-7 / +28 lines)
Lines 118-124 Link Here
118
118
119
            return disableUnchecked($(this));
119
            return disableUnchecked($(this));
120
        });
120
        });
121
121
        $('#tabs').tabs();
122
        $('#tabs').tabs();
123
124
        [% IF is_order %]
125
            $("#checkAll").click();
126
127
            $("#all_budget_id").hide();
128
            $('label[for="all_budget_id"]').hide();
129
        [% END %]
122
    });
130
    });
123
131
124
    function disableUnchecked(form){
132
    function disableUnchecked(form){
Lines 146-152 Link Here
146
                <div id="tabs" class="toptabs">
154
                <div id="tabs" class="toptabs">
147
                  <ul>
155
                  <ul>
148
                    <li><a href="#records_to_import">Select to import</a></li>
156
                    <li><a href="#records_to_import">Select to import</a></li>
149
                    <li><a href="#items_info" class="items_info">Item information</a></li>
157
                    [% UNLESS is_order %]
158
                        <li><a href="#items_info" class="items_info">Item information</a></li>
159
                    [% END %]
150
                    <li><a href="#accounting_details">Default accounting details</a></li>
160
                    <li><a href="#accounting_details">Default accounting details</a></li>
151
                  </ul>
161
                  </ul>
152
162
Lines 163-168 Link Here
163
                            <input type="hidden" name="[% cur.currency %]" value="[% cur.rate %]" />
173
                            <input type="hidden" name="[% cur.currency %]" value="[% cur.rate %]" />
164
                        [% END %]
174
                        [% END %]
165
175
176
                        [% IF is_order %]
177
                            <p>
178
                                <input type="submit" value="Save" /><a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a>
179
                            </p>
180
                        [% END %]
181
166
                        [% FOREACH biblio IN biblio_list %]
182
                        [% FOREACH biblio IN biblio_list %]
167
                        <fieldset class="biblio unselected rows" style="float:none;">
183
                        <fieldset class="biblio unselected rows" style="float:none;">
168
                          <legend>
184
                          <legend>
Lines 228-238 Link Here
228
                        </fieldset>
244
                        </fieldset>
229
                        [% END %]
245
                        [% END %]
230
                      </div>
246
                      </div>
247
                      [% IF ( items && !is_order ) %]
231
                      <div id="items_info">
248
                      <div id="items_info">
232
                        <h2>Item information</h2>
249
                        <h2>Item information</h2>
233
                        <p>Import all the checked items in the basket with the following parameters:</p>
250
                        <p>Import all the checked items in the basket with the following parameters:</p>
234
251
235
                        [% IF ( items ) %]
236
                        <fieldset class="rows" style="float:none;">
252
                        <fieldset class="rows" style="float:none;">
237
                            <legend>Item</legend>
253
                            <legend>Item</legend>
238
                            [% IF ( NoACQframework ) %]
254
                            [% IF ( NoACQframework ) %]
Lines 264-271 Link Here
264
                            </div>
280
                            </div>
265
                            [% END %] <!-- /items -->
281
                            [% END %] <!-- /items -->
266
                        </fieldset>
282
                        </fieldset>
267
                        [% END %] <!-- items -->
268
                      </div>
283
                      </div>
284
                      [% END %] <!-- items tab -->
269
                      <div id="accounting_details">
285
                      <div id="accounting_details">
270
                        <fieldset class="rows" style="float:none;">
286
                        <fieldset class="rows" style="float:none;">
271
                            <legend>Accounting details</legend>
287
                            <legend>Accounting details</legend>
Lines 274-279 Link Here
274
                                    <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order -->
290
                                    <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order -->
275
                                    <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="1" />
291
                                    <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="1" />
276
                                </li>
292
                                </li>
293
                                [% UNLESS is_order %]
277
                                <li>
294
                                <li>
278
                                    [% IF ( close ) %]
295
                                    [% IF ( close ) %]
279
                                        <span class="label">Fund: </span>
296
                                        <span class="label">Fund: </span>
Lines 305-314 Link Here
305
                                        </li>
322
                                        </li>
306
                                    [% END %]
323
                                    [% END %]
307
                                </li>
324
                                </li>
325
                                [% END %]
308
                                <li>
326
                                <li>
309
                                    <label for="notes">Notes: </label>
327
                                    <label for="notes">Notes: </label>
310
                                    <textarea id="notes" cols="30" rows="3" name="all_notes"></textarea>
328
                                    <textarea id="notes" cols="30" rows="3" name="all_notes"></textarea>
311
                                </li>
329
                                </li>
330
                                [% UNLESS is_order %]
312
                                <li>
331
                                <li>
313
                                    <div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
332
                                    <div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
314
                                    <label for="sort1">Planning value 1: </label>
333
                                    <label for="sort1">Planning value 1: </label>
Lines 344-357 Link Here
344
                                    [% END %]
363
                                    [% END %]
345
                                  </span>
364
                                  </span>
346
                                </li>
365
                                </li>
366
                                [% END %]
347
                            </ol>
367
                            </ol>
348
                        </fieldset>
368
                        </fieldset>
349
                      </div>
369
                      </div>
350
                      </div>
370
                      </div>
351
371
352
                      <fieldset class="action">
372
                        <fieldset class="action">
353
                          <input type="submit" value="Save" /><a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a>
373
                            <input type="hidden" name="is_order" value="[% is_order %]" />
354
                      </fieldset>
374
                            <input type="submit" value="Save" /><a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a>
375
                        </fieldset>
355
                    </form>
376
                    </form>
356
                [% ELSE %]
377
                [% ELSE %]
357
                <div>
378
                <div>
Lines 375-381 Link Here
375
                        <td>[% batch_lis.import_status %]</td>
396
                        <td>[% batch_lis.import_status %]</td>
376
                        <td><span title="[% batch_lis.staged_date %]">[% batch_lis.staged_date | $KohaDates with_hours => 1 %]</span></td>
397
                        <td><span title="[% batch_lis.staged_date %]">[% batch_lis.staged_date | $KohaDates with_hours => 1 %]</span></td>
377
                        <td>[% batch_lis.num_biblios %]</td>
398
                        <td>[% batch_lis.num_biblios %]</td>
378
                        <td><a href="[% batch_lis.scriptname %]?import_batch_id=[% batch_lis.import_batch_id %]&amp;basketno=[% basketno %]&amp;booksellerid=[% booksellerid %]">Add orders</a></td>
399
                        <td><a href="[% batch_lis.scriptname %]?import_batch_id=[% batch_lis.import_batch_id %]&amp;basketno=[% basketno %]&amp;booksellerid=[% booksellerid %]&amp;is_order=[% is_order %]">Add orders</a></td>
379
                      </tr>
400
                      </tr>
380
                      [% END %]
401
                      [% END %]
381
                    </tbody>
402
                    </tbody>
(-)a/misc/stage_file.pl (+2 lines)
Lines 56-61 my $result = GetOptions( Link Here
56
    'no-replace'    => \$no_replace,
56
    'no-replace'    => \$no_replace,
57
    'comment:s'     => \$batch_comment,
57
    'comment:s'     => \$batch_comment,
58
    'authorities'   => \$authorities,
58
    'authorities'   => \$authorities,
59
    'is-order'      => \$is_order,
59
    'h|help'        => \$want_help
60
    'h|help'        => \$want_help
60
);
61
);
61
62
Lines 198-203 Parameters: Link Here
198
                            the record batch; if the comment
199
                            the record batch; if the comment
199
                            has spaces in it, surround the
200
                            has spaces in it, surround the
200
                            comment with quotation marks.
201
                            comment with quotation marks.
202
    --is-order              this file is a bibliographic order file
201
    --help or -h            show this message.
203
    --help or -h            show this message.
202
_USAGE_
204
_USAGE_
203
}
205
}
(-)a/tools/stage-marc-import.pl (-1 / +1 lines)
Lines 57-62 my $parse_items = $input->param('parse_items'); Link Here
57
my $item_action = $input->param('item_action');
57
my $item_action = $input->param('item_action');
58
my $comments = $input->param('comments');
58
my $comments = $input->param('comments');
59
my $record_type = $input->param('record_type');
59
my $record_type = $input->param('record_type');
60
my $is_order = $input->param('is_order') eq 'on';
60
my $encoding = $input->param('encoding');
61
my $encoding = $input->param('encoding');
61
my $marc_modification_template = $input->param('marc_modification_template_id');
62
my $marc_modification_template = $input->param('marc_modification_template_id');
62
63
63
- 

Return to bug 10877