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

(-)a/C4/Biblio.pm (-6 / +22 lines)
Lines 3261-3266 sub _koha_delete_biblio_metadata { Link Here
3261
3261
3262
=head1 UNEXPORTED FUNCTIONS
3262
=head1 UNEXPORTED FUNCTIONS
3263
3263
3264
=head2 Update005Time
3265
3266
  &Update005Time( $record );
3267
3268
Updates the 005 timestamp of the given record to the current time.
3269
3270
=cut
3271
3272
sub UpdateMarcTimestamp {
3273
    my ( $record ) = @_;
3274
3275
    my $encoding = C4::Context->preference("marcflavour");
3276
3277
    if ( $encoding =~ /MARC21|UNIMARC/ ) {
3278
        my @a = (localtime) [5,4,3,2,1,0]; $a[0]+=1900; $a[1]++;
3279
        # YY MM DD HH MM SS (update year and month)
3280
        my $f005 = $record->field('005');
3281
        $f005->update( sprintf( "%4d%02d%02d%02d%02d%04.1f",@a ) ) if $f005;
3282
    }
3283
}
3284
3264
=head2 ModBiblioMarc
3285
=head2 ModBiblioMarc
3265
3286
3266
  &ModBiblioMarc($newrec,$biblionumber,$frameworkcode);
3287
  &ModBiblioMarc($newrec,$biblionumber,$frameworkcode);
Lines 3313-3324 sub ModBiblioMarc { Link Here
3313
    }
3334
    }
3314
3335
3315
    #enhancement 5374: update transaction date (005) for marc21/unimarc
3336
    #enhancement 5374: update transaction date (005) for marc21/unimarc
3316
    if($encoding =~ /MARC21|UNIMARC/) {
3337
    UpdateMarcTimestamp( $record );
3317
      my @a= (localtime) [5,4,3,2,1,0]; $a[0]+=1900; $a[1]++;
3318
        # YY MM DD HH MM SS (update year and month)
3319
      my $f005= $record->field('005');
3320
      $f005->update(sprintf("%4d%02d%02d%02d%02d%04.1f",@a)) if $f005;
3321
    }
3322
3338
3323
    my $metadata = {
3339
    my $metadata = {
3324
        biblionumber => $biblionumber,
3340
        biblionumber => $biblionumber,
(-)a/C4/ImportBatch.pm (-6 / +14 lines)
Lines 28-33 use C4::Charset; Link Here
28
use C4::AuthoritiesMarc;
28
use C4::AuthoritiesMarc;
29
use C4::MarcModificationTemplates;
29
use C4::MarcModificationTemplates;
30
use Koha::Items;
30
use Koha::Items;
31
use DateTime;
32
use DateTime::Format::Strptime;
31
use Koha::Plugins::Handler;
33
use Koha::Plugins::Handler;
32
use Koha::Logger;
34
use Koha::Logger;
33
35
Lines 1609-1618 sub _create_import_record { Link Here
1609
sub _update_import_record_marc {
1611
sub _update_import_record_marc {
1610
    my ($import_record_id, $marc_record, $marc_type) = @_;
1612
    my ($import_record_id, $marc_record, $marc_type) = @_;
1611
1613
1614
    my $upload_timestamp = _get_import_record_timestamp($marc_record);
1615
1612
    my $dbh = C4::Context->dbh;
1616
    my $dbh = C4::Context->dbh;
1613
    my $sth = $dbh->prepare("UPDATE import_records SET marc = ?, marcxml = ?
1617
    my $sth = $dbh->prepare("UPDATE import_records SET marc = ?, marcxml = ?, upload_timestamp = ?
1614
                             WHERE  import_record_id = ?");
1618
                             WHERE  import_record_id = ?");
1615
    $sth->execute($marc_record->as_usmarc(), $marc_record->as_xml($marc_type), $import_record_id);
1619
    $sth->execute($marc_record->as_usmarc(), $marc_record->as_xml($marc_type), $upload_timestamp, $import_record_id);
1616
    $sth->finish();
1620
    $sth->finish();
1617
}
1621
}
1618
1622
Lines 1633-1646 sub _add_auth_fields { Link Here
1633
sub _add_biblio_fields {
1637
sub _add_biblio_fields {
1634
    my ($import_record_id, $marc_record) = @_;
1638
    my ($import_record_id, $marc_record) = @_;
1635
1639
1640
    my $controlnumber;
1641
    if ($marc_record->field('001')) {
1642
        $controlnumber = $marc_record->field('001')->data();
1643
    }
1636
    my ($title, $author, $isbn, $issn) = _parse_biblio_fields($marc_record);
1644
    my ($title, $author, $isbn, $issn) = _parse_biblio_fields($marc_record);
1637
    my $dbh = C4::Context->dbh;
1645
    my $dbh = C4::Context->dbh;
1638
    # FIXME no controlnumber, originalsource
1646
    # FIXME no originalsource
1639
    $isbn = C4::Koha::GetNormalizedISBN($isbn);
1647
    $isbn = C4::Koha::GetNormalizedISBN($isbn);
1640
    my $sth = $dbh->prepare("INSERT INTO import_biblios (import_record_id, title, author, isbn, issn) VALUES (?, ?, ?, ?, ?)");
1648
    my $sth = $dbh->prepare("INSERT INTO import_biblios (import_record_id, title, author, isbn, issn, control_number) VALUES (?, ?, ?, ?, ?, ?)");
1641
    $sth->execute($import_record_id, $title, $author, $isbn, $issn);
1649
    $sth->execute($import_record_id, $title, $author, $isbn, $issn, $controlnumber);
1642
    $sth->finish();
1650
    $sth->finish();
1643
                
1651
1644
}
1652
}
1645
1653
1646
sub _update_biblio_fields {
1654
sub _update_biblio_fields {
(-)a/cataloguing/editor.pl (-1 / +1 lines)
Lines 50-56 my $schema = Koha::Database->new->schema; Link Here
50
$template->{VARS}->{editable_batches} = [ $schema->resultset('ImportBatch')->search(
50
$template->{VARS}->{editable_batches} = [ $schema->resultset('ImportBatch')->search(
51
    {
51
    {
52
        batch_type => [ 'batch', 'webservice' ],
52
        batch_type => [ 'batch', 'webservice' ],
53
        import_status => 'staged',
53
        import_status => [ 'staged', 'staging' ],
54
    },
54
    },
55
    { result_class => 'DBIx::Class::ResultClass::HashRefInflator' },
55
    { result_class => 'DBIx::Class::ResultClass::HashRefInflator' },
56
) ];
56
) ];
(-)a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js (+52 lines)
Lines 168-173 define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin Link Here
168
            } );
168
            } );
169
        },
169
        },
170
170
171
        GetBatchRecord: function( batch_id, id, callback ) {
172
            $.get(
173
                '/cgi-bin/koha/svc/cataloguing/import_batches/' + batch_id + '/' + id
174
            ).done( function( data ) {
175
                var record = new MARC.Record();
176
                record.loadMARCXML( data.record );
177
                callback(record);
178
            } ).fail( function( data ) {
179
                callback( { error: data } );
180
            } );
181
        },
182
183
        CreateBatch: function( batch_name, callback ) {
184
            $.ajax( {
185
                type: 'POST',
186
                url: '/cgi-bin/koha/svc/cataloguing/import_batches/',
187
                data: { batch_name: batch_name },
188
            } ).done( function( data ) {
189
                callback( data );
190
            } ).fail( function( data ) {
191
                callback( { error: data } );
192
            } );
193
        },
194
195
        CreateBatchRecord: function( record, batch_id, callback, options ) {
196
            $.ajax( {
197
                type: 'POST',
198
                url: '/cgi-bin/koha/svc/cataloguing/import_batches/' + batch_id + '/',
199
                data: { record: record.toXML(), allow_control_number_conflict: options.allow_control_number_conflict ? 1 : undefined },
200
            } ).done( function( data ) {
201
                callback( data );
202
            } ).fail( function( data ) {
203
                callback( { error: $.parseJSON( data.responseText ) || data.responseText } );
204
            } );
205
        },
206
207
        SaveBatchRecord: function( batch_id, id, record, callback, options ) {
208
            $.ajax( {
209
                type: 'POST',
210
                url: '/cgi-bin/koha/svc/cataloguing/import_batches/' + batch_id + '/' + id,
211
                data: { record: record.toXML(), allow_control_number_conflict: options.allow_control_number_conflict ? 1 : undefined },
212
            } ).done( function( data ) {
213
                callback( data );
214
            } ).fail( function( data ) {
215
                callback( { data: { error: data } } );
216
            } );
217
        },
218
219
        StartBatchExport: function( batch_id, options ) {
220
            window.open( '/cgi-bin/koha/svc/cataloguing/import_batches/' + batch_id + '?download=1&' + $.param( options ) );
221
        },
222
171
        GetTagsBy: function( frameworkcode, field, value ) {
223
        GetTagsBy: function( frameworkcode, field, value ) {
172
            var result = {};
224
            var result = {};
173
225
(-)a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/preferences.js (+2 lines)
Lines 29-38 define( function() { Link Here
29
29
30
            Preferences.user = $.extend( {
30
            Preferences.user = $.extend( {
31
                // Preference defaults
31
                // Preference defaults
32
                enabledBatches: {},
32
                fieldWidgets: true,
33
                fieldWidgets: true,
33
                font: 'monospace',
34
                font: 'monospace',
34
                fontSize: '1em',
35
                fontSize: '1em',
35
                macros: {},
36
                macros: {},
37
                selected_save_targets: {},
36
                selected_search_targets: {},
38
                selected_search_targets: {},
37
            }, saved_prefs );
39
            }, saved_prefs );
38
        },
40
        },
(-)a/koha-tmpl/intranet-tmpl/prog/css/cateditor.css (-1 / +43 lines)
Lines 65-70 body { Link Here
65
    font-size: 12px;
65
    font-size: 12px;
66
}
66
}
67
67
68
#save-targets input {
69
    display: inline-block;
70
    margin: 1px;
71
    vertical-align: middle;
72
}
73
74
#save-targets input:checked + label {
75
    color: #000;
76
}
77
78
#save-targets label {
79
    color: #666;
80
    display: inline-block;
81
    margin-left: 0.3em;
82
    padding: 0.3em 0;
83
    vertical-align: middle;
84
    width: 10em;
85
}
86
87
#save-targets li {
88
    overflow: hidden;
89
}
90
91
#shortcuts-container {
92
    font-size: 12px;
93
}
94
68
/*> MARC editor */
95
/*> MARC editor */
69
#editor .CodeMirror {
96
#editor .CodeMirror {
70
    line-height: 1.2;
97
    line-height: 1.2;
Lines 223-229 body { Link Here
223
250
224
/*> Search */
251
/*> Search */
225
252
226
#advanced-search-ui .modal-lg, #search-results-ui .modal-lg, #macro-ui .modal-lg {
253
#advanced-search-ui .modal-lg, #search-results-ui .modal-lg, #macro-ui .modal-lg .ui-modal {
254
    padding: 5px;
227
    width: 90%;
255
    width: 90%;
228
}
256
}
229
257
Lines 456-458 body { Link Here
456
.CodeMirror-gutter-wrapper {
484
.CodeMirror-gutter-wrapper {
457
    position: absolute;
485
    position: absolute;
458
}
486
}
487
488
/* >Batches */
489
#batches-list > li {
490
    border: 2px solid #F0F0F0;
491
    border-radius: 6px;
492
    display: block;
493
    line-height: 3em;
494
    font-size: 115%;
495
}
496
497
#batches-list > li input {
498
    display: inline-block;
499
    margin: 0 1em;
500
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc (-32 / +315 lines)
Lines 39-44 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
39
            recordtype: 'biblio',
39
            recordtype: 'biblio',
40
            checked: false,
40
            checked: false,
41
        },
41
        },
42
        [%- FOREACH batch = editable_batches -%]
43
            'batch:[% batch.import_batch_id %]': {
44
                name: _("Batch: ") + '[% batch.file_name %]',
45
                recordtype: 'biblio',
46
                checked: false,
47
            },
48
        [%- END -%]
42
        [%- FOREACH server = z3950_servers -%]
49
        [%- FOREACH server = z3950_servers -%]
43
            [% server.id | html %]: {
50
            [% server.id | html %]: {
44
                name: '[% server.servername | html %]',
51
                name: '[% server.servername | html %]',
Lines 64-71 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
64
71
65
    var state = {
72
    var state = {
66
        backend: '',
73
        backend: '',
67
        saveBackend: 'catalog',
74
        recordID: undefined,
68
        recordID: undefined
75
        saveTargets: {},
69
    };
76
    };
70
77
71
    var editor;
78
    var editor;
Lines 235-250 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
235
            },
242
            },
236
        },
243
        },
237
        'catalog': {
244
        'catalog': {
238
            titleForRecord: _("Editing catalog record #{ID}"),
245
            titleForRecord: _("Editing catalog record #%s"),
239
            links: [
246
            links: [
240
                { title: _("view"), href: "/cgi-bin/koha/catalogue/detail.pl?biblionumber={ID}" },
247
                { title: _("view"), href: "/cgi-bin/koha/catalogue/detail.pl?biblionumber=%s" },
241
                { title: _("edit items"), href: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber={ID}" },
248
                { title: _("edit items"), href: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=%s" },
242
            ],
249
            ],
243
            saveLabel: _("Save to catalog"),
250
            saveLabel: _("New catalog record"),
251
            saveExistingLabel: _("Catalog record #%s"),
244
            get: function( id, callback ) {
252
            get: function( id, callback ) {
245
                if ( !id ) return false;
253
                if ( !id ) return false;
246
254
247
                KohaBackend.GetRecord( id, callback );
255
                KohaBackend.GetRecord( id, function( data ) {
256
                    if ( !data.error ) {
257
                        setSaveTargetChecked( 'catalog/', false );
258
                        addSaveTarget( {
259
                            label: backends.catalog.saveExistingLabel.format( id ),
260
                            id: 'catalog/' + id,
261
                            description: '',
262
                            checked: true
263
                        } );
264
                    }
265
266
                    callback(data);
267
                } );
248
            },
268
            },
249
            save: function( id, record, done ) {
269
            save: function( id, record, done ) {
250
                function finishCb( data ) {
270
                function finishCb( data ) {
Lines 267-273 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
267
            }
287
            }
268
        },
288
        },
269
        'marcxml': {
289
        'marcxml': {
270
            saveLabel: _("Save as MARCXML (.xml) file"),
290
            saveLabel: _("New MARCXML (.xml) file"),
271
            save: function( id, record, done ) {
291
            save: function( id, record, done ) {
272
                saveAs( new Blob( [record.toXML()], { 'type': 'application/octet-stream;charset=utf-8' } ), 'record.xml' );
292
                saveAs( new Blob( [record.toXML()], { 'type': 'application/octet-stream;charset=utf-8' } ), 'record.xml' );
273
293
Lines 289-294 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
289
        },
309
        },
290
    };
310
    };
291
311
312
    var editable_batches = {
313
        [%- FOREACH batch = editable_batches -%]
314
            [% batch.import_batch_id %]: {
315
                'name': '[% batch.file_name %]',
316
            },
317
        [%- END -%]
318
    };
319
320
    function addSaveTarget( target ) {
321
        state.saveTargets[target.id] = target;
322
        if (target.enabled == null) target.enabled = true;
323
324
        // Have to check that Preferences has been initialized
325
        var saved_value = Preferences.user && Preferences.user.selected_save_targets[target.id];
326
        if ( saved_value != null ) target.checked = saved_value;
327
328
        var target_list = $.map( state.saveTargets, function( target ) {
329
            return target;
330
        } );
331
332
        target_list.sort( function( a, b ) {
333
            return a.label.localeCompare(b.label);
334
        } );
335
336
        $('#save-targets ol').empty();
337
338
        $.each( target_list, function( i, target ) {
339
            var $new_target = $(
340
                '<li><input type="checkbox" class="save-toggle-target" data-target-id="' + target.id + '" id="save-target-' + i + '"' + ( target.checked ? ' checked="checked"' : '' ) + '> <label for="save-target-' + i + '">' + target.label + '</label></li>'
341
            );
342
343
            $new_target.find('input').change( function() {
344
                target.checked = this.checked;
345
            } );
346
347
            $('#save-targets ol').append($new_target);
348
349
            if (!target.enabled) $new_target.hide();
350
        } );
351
    }
352
353
    function setSaveTargetChecked( target_id, checked ) {
354
        if ( state.saveTargets[target_id] == null ) return;
355
356
        state.saveTargets[target_id].checked = checked;
357
        $( '#save-targets input[data-target-id="' + target_id + '"]' )[0].checked = checked;
358
    }
359
360
    function setSaveTargetEnabled( target_id, enabled ) {
361
        if ( !enabled ) {
362
            setSaveTargetChecked( target_id, false );
363
        }
364
365
        state.saveTargets[target_id].enabled = enabled;
366
        $( '#save-targets input[data-target-id="' + target_id + '"]' ).closest('li').toggle(enabled);
367
    }
368
292
    function setSource(parts) {
369
    function setSource(parts) {
293
        state.backend = parts[0];
370
        state.backend = parts[0];
294
        state.recordID = parts[1];
371
        state.recordID = parts[1];
Lines 299-311 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
299
376
300
        document.location.hash = '#' + parts[0] + '/' + parts[1];
377
        document.location.hash = '#' + parts[0] + '/' + parts[1];
301
378
302
        $('#title').text( backend.titleForRecord.replace( '{ID}', parts[1] ) );
379
        $('#title').text( backend.titleForRecord.format( parts[1] ) );
303
380
304
        $.each( backend.links || [], function( i, link ) {
381
        $.each( backend.links || [], function( i, link ) {
305
            $('#title').append(' <a target="_blank" href="' + link.href.replace( '{ID}', parts[1] ) + '">(' + link.title + ')</a>' );
382
            $('#title').append(' <a target="_blank" href="' + link.href.format( parts[1] ) + '">(' + link.title + ')</a>' );
306
        } );
383
        } );
307
        $( 'title', document.head ).html( _("Koha &rsaquo; Cataloging &rsaquo; ") + backend.titleForRecord.replace( '{ID}', parts[1] ) );
384
        $( 'title', document.head ).html( _("Koha &rsaquo; Cataloging &rsaquo; ") + backend.titleForRecord.format( parts[1] ) );
308
        $('#save-record span').text( backends[ state.saveBackend ].saveLabel );
309
    }
385
    }
310
386
311
    function saveRecord( recid, editor, callback ) {
387
    function saveRecord( recid, editor, callback ) {
Lines 342-347 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
342
418
343
            if (data.newId) {
419
            if (data.newId) {
344
                setSource(data.newId);
420
                setSource(data.newId);
421
422
                var backend = backends[ parts[0] ];
423
424
                setSaveTargetChecked( recid, false );
425
                addSaveTarget( {
426
                    label: backend.saveExistingLabel.format( data.newId[1] ),
427
                    id: data.newId.join('/'),
428
                    description: '',
429
                    checked: true
430
                } );
345
            } else {
431
            } else {
346
                setSource( [ state.backend, state.recordID ] );
432
                setSource( [ state.backend, state.recordID ] );
347
            }
433
            }
Lines 600-605 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
600
        var value = Preferences.user[pref];
686
        var value = Preferences.user[pref];
601
687
602
        switch (pref) {
688
        switch (pref) {
689
            case 'enabledBatches':
690
                $.each( editable_batches, function( batch_id, batch ) {
691
                    $( '#batches-list li[data-batch-id=' + batch_id + '] input' )[0].checked = Preferences.user.enabledBatches[batch_id];
692
                    setSaveTargetEnabled( 'batch:' + batch_id + '/', Preferences.user.enabledBatches[batch_id] || false );
693
                } );
603
            case 'fieldWidgets':
694
            case 'fieldWidgets':
604
                $( '#set-field-widgets' ).text( value ? _("Show fields verbatim") : _("Show helpers for fixed and coded fields") );
695
                $( '#set-field-widgets' ).text( value ? _("Show fields verbatim") : _("Show helpers for fixed and coded fields") );
605
                break;
696
                break;
Lines 621-626 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
621
                    if ( saved_val != null ) server.checked = saved_val;
712
                    if ( saved_val != null ) server.checked = saved_val;
622
                } );
713
                } );
623
                break;
714
                break;
715
            case 'selected_save_targets':
716
                $.each( state.saveTargets, function( target_id, target ) {
717
                    var saved_val = Preferences.user.selected_save_targets[target_id];
718
719
                    if ( saved_val != null ) setSaveTargetChecked( target_id, saved_val );
720
                } );
721
                break;
722
            case 'selected_search_targets':
723
                $.each( z3950Servers, function( server_id, server ) {
724
                    var saved_val = Preferences.user.selected_search_targets[server_id];
725
726
                    if ( saved_val != null ) server.checked = saved_val;
727
                } );
728
                break;
624
        }
729
        }
625
    }
730
    }
626
731
Lines 634-640 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
634
            } );
739
            } );
635
        }
740
        }
636
741
742
        function _addLiveHandler( sel, event, handler ) {
743
            $( document ).on( event, sel, function (e) {
744
                e.preventDefault();
745
                handler.call( this, e, Preferences.user[pref] );
746
                Preferences.Save( [% USER_INFO.borrowernumber %] );
747
                showPreference(pref);
748
            } );
749
        }
750
637
        switch (pref) {
751
        switch (pref) {
752
            case 'enabledBatches':
753
                _addLiveHandler( '#batches-list input', 'change', function() {
754
                    Preferences.user.enabledBatches[ $( this ).closest('li').data('batch-id') ] = this.checked;
755
                } );
756
                break;
638
            case 'fieldWidgets':
757
            case 'fieldWidgets':
639
                _addHandler( '#set-field-widgets', 'click', function( e, oldValue ) {
758
                _addHandler( '#set-field-widgets', 'click', function( e, oldValue ) {
640
                    editor.setUseWidgets( Preferences.user.fieldWidgets = !Preferences.user.fieldWidgets );
759
                    editor.setUseWidgets( Preferences.user.fieldWidgets = !Preferences.user.fieldWidgets );
Lines 650-655 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
650
                    Preferences.user.fontSize = $( e.target ).css( 'font-size' );
769
                    Preferences.user.fontSize = $( e.target ).css( 'font-size' );
651
                } );
770
                } );
652
                break;
771
                break;
772
            case 'selected_save_targets':
773
                $( document ).on( 'change', 'input.save-toggle-target', function() {
774
                    var target_id = $( this ).data('target-id');
775
                    Preferences.user.selected_save_targets[target_id] = this.checked;
776
                    Preferences.Save( [% USER_INFO.borrowernumber %] );
777
                } );
778
                break;
653
            case 'selected_search_targets':
779
            case 'selected_search_targets':
654
                $( document ).on( 'change', 'input.search-toggle-server', function() {
780
                $( document ).on( 'change', 'input.search-toggle-server', function() {
655
                    var server_id = $( this ).closest('li').data('server-id');
781
                    var server_id = $( this ).closest('li').data('server-id');
Lines 743-748 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
743
        showSavedMacros();
869
        showSavedMacros();
744
    }
870
    }
745
871
872
    function addImportBatch(batch) {
873
        var backend_id = 'batch:' + batch.batch_id;
874
        backends[backend_id] = {
875
            titleForRecord: _("Editing record from batch: ") + batch.name,
876
            saveLabel: _("Batch: ") + batch.name,
877
            saveExistingLabel: batch.name + ": #%s",
878
            get: function( id, callback ) {
879
                KohaBackend.GetBatchRecord( batch.batch_id, id, function( data ) {
880
                    if ( !data.error ) {
881
                        setSaveTargetChecked( backend_id + '/', false );
882
                        addSaveTarget( {
883
                            label: batch.name + ": #" + id,
884
                            id: backend_id + '/' + id,
885
                            description: '',
886
                            checked: true
887
                        } );
888
                    }
889
890
                    callback(data);
891
                } );
892
            },
893
            save: function( id, record, done, options ) {
894
                function finishCb( data ) {
895
                    done( {
896
                        error: data.message || data.error,
897
                        newRecord: data.updated_record,
898
                        newId: data.import_record_id && [ backend_id, data.import_record_id ]
899
                    } );
900
                }
901
902
                if ( id ) {
903
                    KohaBackend.SaveBatchRecord( batch.batch_id, id, record, finishCb, { allow_control_number_conflict: options.override_warnings } );
904
                } else {
905
                    KohaBackend.CreateBatchRecord( record, batch.batch_id, finishCb, { allow_control_number_conflict: options.override_warnings } );
906
                }
907
            },
908
        };
909
910
        // Build batch UI
911
        var $batch_entry = $( '<li data-batch-id="' + batch.batch_id + '"><input type="checkbox" />' + batch.name + '</li>' );
912
913
        var $batch_buttons = $('<span class="batch-buttons"></span>').appendTo($batch_entry);
914
        var $export_button = $( '<button>' + _("Export...") + '</button>' ).appendTo($batch_buttons).click( function() {
915
            $('#batches-list .batch-export').hide();
916
            $export_screen.show();
917
        } );
918
919
        var $export_screen = $(
920
            '<form class="batch-export form-horizontal" style="display: none">'
921
            + '<div class="control-group">'
922
            + '<label class="control-label">' + _("Control number range:") + '</label>'
923
            + '<div class="controls"><input class="batch-control-number-start" type="text"> - <input class="batch-control-number-end" type="text"></div>'
924
            + '</div>'
925
            + '<label class="control-label">' + _("Timestamp range (YYYYMMDD or YYYMMDDHHMMSS):") + '</label>'
926
            + '<div class="controls"><input class="batch-timestamp-start" type="text"> - <input class="batch-timestamp-end" type="text"></div>'
927
            + '</div>'
928
            + '<div class="control-group">'
929
            + '<div class="controls"><button class="batch-export-start">' + _("Start export") + '</div>'
930
            + '</form>'
931
        ).appendTo($batch_entry);
932
933
        $export_screen.find('.batch-export-start').click( function() {
934
            function getFormVal(name) {
935
                return $export_screen.find( '.batch-' + name ).val();
936
            }
937
938
            var options = {
939
                start_control_number: getFormVal('control-number-start'),
940
                end_control_number: getFormVal('control-number-end'),
941
                start_timestamp: getFormVal('timestamp-start'),
942
                end_timestamp: getFormVal('timestamp-end'),
943
            };
944
945
            KohaBackend.StartBatchExport( batch.batch_id, options );
946
        } );
947
948
        $('#batches-list').append( $batch_entry );
949
    }
950
746
    $(document).ready( function() {
951
    $(document).ready( function() {
747
        // Editor setup
952
        // Editor setup
748
        editor = new MARCEditor( {
953
        editor = new MARCEditor( {
Lines 792-797 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
792
                    $(this).height( $(window).height() * .8 - $(this).prevAll('.modal-header').height() );
997
                    $(this).height( $(window).height() * .8 - $(this).prevAll('.modal-header').height() );
793
                } );
998
                } );
794
            }, 100);
999
            }, 100);
1000
795
        }
1001
        }
796
1002
797
        $( '#macro-ui' ).on( 'shown.bs.modal', function() {
1003
        $( '#macro-ui' ).on( 'shown.bs.modal', function() {
Lines 832-840 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
832
        $.each( backends, function( id, backend ) {
1038
        $.each( backends, function( id, backend ) {
833
            if ( backend.save ) saveableBackends.push( [ backend.saveLabel, id ] );
1039
            if ( backend.save ) saveableBackends.push( [ backend.saveLabel, id ] );
834
        } );
1040
        } );
835
        saveableBackends.sort();
1041
836
        $.each( saveableBackends, function( undef, backend ) {
1042
        var batch_list = [];
837
            $( '#save-dropdown' ).append( '<li><a href="#" data-backend="' + backend[1] + '">' + backend[0] + '</a></li>' );
1043
1044
        $.each( editable_batches, function( batch_id, batch ) {
1045
            batch_list.push( $.extend( { batch_id: batch_id }, batch ) );
1046
        } );
1047
        batch_list.sort( function( a, b ) {
1048
            return a.name.localeCompare(b.name);
1049
        } );
1050
        $.each( batch_list, function() {
1051
            addImportBatch( this );
838
        } );
1052
        } );
839
1053
840
        var macro_format_list = $.map( Macros.formats, function( format, name ) {
1054
        var macro_format_list = $.map( Macros.formats, function( format, name ) {
Lines 850-863 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
850
        // Click bindings
1064
        // Click bindings
851
        $( '#save-record, #save-dropdown a' ).click( function() {
1065
        $( '#save-record, #save-dropdown a' ).click( function() {
852
             $( '#save-record' ).find('i').attr( 'class', 'fa fa-spinner fa-spin' ).siblings( 'span' ).text( _("Saving...") );
1066
             $( '#save-record' ).find('i').attr( 'class', 'fa fa-spinner fa-spin' ).siblings( 'span' ).text( _("Saving...") );
1067
            var enabledTargets = [];
1068
            var targetNames = [];
1069
            $.each( state.saveTargets, function() {
1070
                if ( this.checked ) {
1071
                    enabledTargets.push(this);
1072
                    targetNames.push(this.label);
1073
                }
1074
            } );
1075
            if ( enabledTargets.length == 0 ) {
1076
                humanMsg.displayAlert( _("Please select a save target"), { className: 'humanError' } );
1077
                return false;
1078
            }
1079
1080
            $( '#save-record' ).find('i').attr( 'class', 'icon-loading' ).siblings( 'span' ).text( _("Saving...") );
1081
1082
            var targets_left = enabledTargets.length;
1083
            var errors = false;
853
1084
854
            function finishCb(result) {
1085
            function finishCb(result) {
855
                if ( result.error == 'syntax' ) {
1086
                targets_left--;
856
                    humanMsg.displayAlert( _("Incorrect syntax, cannot save"), { className: 'humanError' } );
1087
                if ( result.error ) {
857
                } else if ( result.error == 'invalid' ) {
1088
                    if ( result.error == 'syntax' ) {
858
                    humanMsg.displayAlert( _("Record structure invalid, cannot save"), { className: 'humanError' } );
1089
                        humanMsg.displayAlert( _("Incorrect syntax, cannot save"), { className: 'humanError' } );
859
                } else if ( !result.error ) {
1090
                    } else if ( result.error == 'invalid' ) {
860
                    humanMsg.displayAlert( _("Record saved "), { className: 'humanSuccess' } );
1091
                        humanMsg.displayAlert( _("Record structure invalid, cannot save"), { className: 'humanError' } );
1092
                    } else if ( result.error.type == 'control_number_match' ) {
1093
                        humanMsg.displayAlert( _("Control number conflict, cannot save"), { className: 'humanError' } );
1094
                    } else {
1095
                        humanMsg.displayAlert( _("Unknown error, record not saved to one or more targets"), { className: 'humanError' } );
1096
                    }
1097
                    errors = true;
861
                }
1098
                }
862
1099
863
                $.each( result.errors || [], function( undef, error ) {
1100
                $.each( result.errors || [], function( undef, error ) {
Lines 893-912 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
893
                    }
1130
                    }
894
                } );
1131
                } );
895
1132
896
                $( '#save-record' ).find('i').attr( 'class', 'fa fa-hdd-o' );
897
1133
898
                if ( result.error ) {
1134
                if ( targets_left == 0 ) {
899
                    // Reset backend info
1135
                    if ( !errors ) {
900
                    setSource( [ state.backend, state.recordID ] );
1136
                        humanMsg.displayMsg( "<h3>" + _("Record saved to:</h3>") + "</h3>" + '<ul><li>' + targetNames.join('</li><li>') + '</li></ul>', { className: 'humanSuccess' } );
1137
                    }
1138
1139
                    $( '#save-record' ).find('i').attr( 'class', 'icon-hdd' ).end().find('span').text( _("Save") );
901
                }
1140
                }
902
            }
1141
            }
903
1142
904
            var backend = $( this ).data( 'backend' ) || ( state.saveBackend );
1143
            $.each( enabledTargets, function() {
905
            if ( state.backend == backend ) {
1144
                saveRecord( this.id, editor, finishCb, options );
906
                saveRecord( backend + '/' + state.recordID, editor, finishCb );
1145
            } );
907
            } else {
908
                saveRecord( backend + '/', editor, finishCb );
909
            }
910
1146
911
            return false;
1147
            return false;
912
        } );
1148
        } );
Lines 1047-1057 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
1047
            }
1283
            }
1048
        } );
1284
        } );
1049
1285
1286
        $('#open-batches').click( function() {
1287
            $('#batches-ui').modal();
1288
1289
            return false;
1290
        } );
1291
1292
        $('#create-batch').click( function() {
1293
            var batch_name = prompt( _("Name of new import batch:") );
1294
            if (batch_name == null) return false;
1295
1296
            KohaBackend.CreateBatch( batch_name, function( data ) {
1297
                if ( data.error ) {
1298
                    humanMsg.displayAlert( _("Could not create import batch"), { className: 'humanError' } );
1299
                } else {
1300
                    humanMsg.displayAlert( _("Import batch created"), { className: 'humanSuccess' } );
1301
1302
                    addImportBatch( editable_batches[data.batch_id] = { batch_id: data.batch_id, name: batch_name } );
1303
1304
                    var backend_id = 'batch:' + data.batch_id;
1305
                    addSaveTarget( {
1306
                        label: backends[backend_id].saveLabel,
1307
                        id: backend_id + '/',
1308
                        description: '',
1309
                        enabled: false,
1310
                    } );
1311
                }
1312
            } );
1313
1314
            return false;
1315
        } );
1316
1317
        $('#manage-batches').click( function() {
1318
            window.open('/cgi-bin/koha/tools/manage-marc-import.pl');
1319
1320
            return false;
1321
        } );
1322
1050
        // Key bindings
1323
        // Key bindings
1051
        bindGlobalKeys();
1324
        bindGlobalKeys();
1052
1325
1053
        // Setup UI
1326
        // Setup UI
1054
        $("#advanced-search-ui, #search-results-ui, #macro-ui").each( function() {
1327
        $(".ui-modal").each( function() {
1055
            $(this).modal({ show: false });
1328
            $(this).modal({ show: false });
1056
        } );
1329
        } );
1057
1330
Lines 1113-1118 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
1113
                    $('#loading').hide();
1386
                    $('#loading').hide();
1114
                }
1387
                }
1115
            );
1388
            );
1389
        }; );
1390
1391
        $.each( backends, function( name ) {
1392
            if ( !this.save ) return; // Not a saving backend
1393
1394
            addSaveTarget( {
1395
                label: this.saveLabel,
1396
                id: name + '/',
1397
                description: '',
1398
            } );
1116
        } );
1399
        } );
1117
1400
1118
        // Start editor
1401
        // Start editor
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt (-8 / +36 lines)
Lines 35-45 Link Here
35
    <div id="toolbar" class="btn-toolbar">
35
    <div id="toolbar" class="btn-toolbar">
36
        <button class="btn btn-default btn-sm" id="new-record" title="Open fresh record"><i class="fa fa-plus"></i> <span>New record</span></button>
36
        <button class="btn btn-default btn-sm" id="new-record" title="Open fresh record"><i class="fa fa-plus"></i> <span>New record</span></button>
37
        <div class="btn-group">
37
        <div class="btn-group">
38
            <button class="btn btn-default btn-sm" id="save-record" title="Save current record (Ctrl-S)"><i class="fa fa-hdd-o"></i> <span>Save</span></button>
38
            <button class="btn btn-default btn-sm" id="save-record" title="Save current record (Ctrl-S)"><i class="fa fa-save"></i> <span>Save </span></button>
39
            <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
39
            <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
40
            <span class="caret"></span>
40
            <ul id="save-dropdown" class="dropdown-menu">
41
            </button>
41
                <li><a id="save-with-override" href="#">Save overriding warnings</a></li>
42
            <ul class="dropdown-menu" id="save-dropdown">
43
            </ul>
42
            </ul>
44
        </div>
43
        </div>
45
        <button class="btn btn-default btn-sm" id="import-records" title="Import an MARC (ISO 2709) or MARCXML record"><i class="fa fa-download"></i> <span>Import record...</span></button>
44
        <button class="btn btn-default btn-sm" id="import-records" title="Import an MARC (ISO 2709) or MARCXML record"><i class="fa fa-download"></i> <span>Import record...</span></button>
Lines 66-71 Link Here
66
                        </a>
65
                        </a>
67
                    </li>
66
                    </li>
68
                [% END %]
67
                [% END %]
68
                <li><a id="open-batches" href="#">Import batches...</a></li>
69
                <li class="divider"></li>
69
                <li class="divider"></li>
70
                <li><a class="set-fontSize" style="font-size: .92em" href="#">Small text</a></li>
70
                <li><a class="set-fontSize" style="font-size: .92em" href="#">Small text</a></li>
71
                <li><a class="set-fontSize" style="font-size: 1em" href="#">Normal text</a></li>
71
                <li><a class="set-fontSize" style="font-size: 1em" href="#">Normal text</a></li>
Lines 112-123 Link Here
112
    </fieldset>
112
    </fieldset>
113
</form>
113
</form>
114
114
115
<h3>Save to:</h3>
116
<form id="save-targets">
117
    <fieldset class="brief">
118
    <ol></ol>
119
    </fieldset>
120
</form>
121
115
</div>
122
</div>
116
123
117
</div>
124
</div>
118
</div>
125
</div>
119
126
120
<div id="advanced-search-ui" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="advanced-search-title" aria-hidden="true">
127
<div id="advanced-search-ui" class="ui-modal modal fade" tabindex="-1" role="dialog" aria-labelledby="advanced-search-title" aria-hidden="true">
121
<div class="modal-dialog modal-lg">
128
<div class="modal-dialog modal-lg">
122
<div class="modal-content">
129
<div class="modal-content">
123
130
Lines 198-204 Link Here
198
</div>
205
</div>
199
</div>
206
</div>
200
207
201
<div id="search-results-ui" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="search-results-title" aria-hidden="true">
208
<div id="search-results-ui" class="ui-modal modal fade" tabindex="-1" role="dialog" aria-labelledby="search-results-title" aria-hidden="true">
202
<div class="modal-dialog modal-lg">
209
<div class="modal-dialog modal-lg">
203
<div class="modal-content">
210
<div class="modal-content">
204
211
Lines 245-251 Link Here
245
252
246
</div>
253
</div>
247
254
248
<div id="macro-ui" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="macro-title" aria-hidden="true">
255
<div id="macro-ui" class="ui-modal modal fade" tabindex="-1" role="dialog" aria-labelledby="macro-title" aria-hidden="true">
249
<div class="modal-dialog modal-lg">
256
<div class="modal-dialog modal-lg">
250
<div class="modal-content">
257
<div class="modal-content">
251
258
Lines 271-276 Link Here
271
</div>
278
</div>
272
</div>
279
</div>
273
280
281
<div id="batches-ui" class="ui-modal modal fade" tabindex="-1" role="dialog" aria-labelledby="batches-title" aria-hidden="true">
282
283
<div class="modal-header">
284
    <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
285
    <h3 id="batches-title">Import batch settings</h3>
286
</div>
287
288
<div class="modal-body row-fluid">
289
    <div class="span9">
290
        <div id="toolbar" class="btn-toolbar">
291
            <button class="btn btn-small" type="submit" id="create-batch"><i class="icon-plus"></i> <span>Create new batch...</span></button>
292
            <button class="btn btn-small" type="submit" id="manage-batches"><i class="icon-list"></i> <span>Manage import batches...</span></button>
293
        </div>
294
        <ul id="batches-list"></ul>
295
    </div>
296
    <div class="span3">
297
    </div>
298
</div>
299
300
</div>
301
274
<div id="shortcuts-contents" style="display: none">
302
<div id="shortcuts-contents" style="display: none">
275
<table class="table table-condensed">
303
<table class="table table-condensed">
276
    <thead>
304
    <thead>
(-)a/svc/cataloguing/import_batches (-1 / +212 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
#
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use C4::Biblio qw();
23
use C4::Context;
24
use C4::ImportBatch qw( AddBiblioToBatch AddImportBatch GetImportRecordMarcXML ModBiblioInBatch );
25
use C4::Service;
26
use DateTime;
27
use DateTime::Format::Strptime;
28
use Encode qw( encode_utf8 );
29
use Koha::Database;
30
use MARC::Record;
31
32
our ( $query, $response ) = C4::Service->init( tools => 'manage_staged_marc' );
33
34
sub _parse_005_timestamp {
35
    my ( $timestamp, $default_to_end ) = @_;
36
37
    # YYYYMMDD
38
    if ( $timestamp =~ /^\d{8}$/ ) {
39
        my $parser = DateTime::Format::Strptime->new( pattern => '%Y%m%d' );
40
        my $timestamp = $parser->parse_datetime($timestamp);
41
        if ( $timestamp && $default_to_end ) {
42
            $timestamp->set(
43
                hour => 23,
44
                minute => 59,
45
                second => 59
46
            );
47
        }
48
49
        return $timestamp;
50
    # YYYYMMDDHHMMSS
51
    } elsif ( $timestamp =~ /^\d{8}\d{6}$/ ) {
52
        my $parser = DateTime::Format::Strptime->new( pattern => '%Y%m%d%H%M%S' );
53
        return $parser->parse_datetime($timestamp);
54
    }
55
}
56
57
sub download_batch {
58
    my ( $batch_id ) = @_;
59
60
    my $schema = Koha::Database->new()->schema();
61
62
    my %extra_conditions;
63
64
    my $start_control_number = $query->param( 'start_control_number' );
65
    my $end_control_number = $query->param( 'end_control_number' );
66
67
    if ( $start_control_number && $end_control_number ) {
68
        $extra_conditions{control_number} = { -between => [ $start_control_number, $end_control_number ] };
69
    }
70
71
    my $start_timestamp = $query->param( 'start_timestamp' );
72
    my $end_timestamp = $query->param( 'end_timestamp' );
73
74
    if ( $start_timestamp && $end_timestamp ) {
75
        my $start_timestamp = _parse_005_timestamp( $start_timestamp, 0 );
76
        my $end_timestamp = _parse_005_timestamp( $end_timestamp, 1 );
77
78
        my $dtf = $schema->storage->datetime_parser;
79
80
        $extra_conditions{'import_record.upload_timestamp'} = {
81
            -between => [
82
                $dtf->format_datetime($start_timestamp),
83
                $dtf->format_datetime($end_timestamp)
84
            ]
85
        };
86
    }
87
88
    my $records = $schema->resultset('ImportBiblio')->search(
89
        {
90
            'import_record.import_batch_id' => $batch_id,
91
            %extra_conditions
92
        },
93
        {
94
            join => 'import_record',
95
        }
96
    );
97
98
    my $mimetype = 'application/octet-stream';
99
    my $charset  = 'utf-8';
100
    my $filename = DateTime->now->strftime("batch-$batch_id-%Y-%m-%d-%H-%M-%S.mrc");
101
    my $content_length = $records->get_column( { length => 'import_record.marc' } )->sum || 0;
102
103
    print $query->header(
104
        -type => $mimetype,
105
        -charset => $charset,
106
        -attachment => $filename,
107
        -Content_length => $content_length
108
    );
109
110
    for my $marc ( $records->get_column( 'import_record.marc' )->all ) {
111
        print $marc;
112
    }
113
}
114
115
sub get_record {
116
    my ( $batch_id, $import_record_id ) = @_;
117
118
    my $marcxml = GetImportRecordMarcXML( $import_record_id );
119
120
    if ( !$marcxml ) {
121
        C4::Service->return_error( 'not_found' );
122
    }
123
124
    $response->param( record => $marcxml );
125
126
    C4::Service->return_success( $response );
127
}
128
129
sub _control_number_already_used {
130
    my ( $marc_record, $batch_id, $import_record_id ) = @_;
131
132
    return unless ( $marc_record->field('001') );
133
134
    my %extra_conditions;
135
136
    $extra_conditions{'import_record.import_record_id'} = { '!=', $import_record_id } if ( $import_record_id );
137
138
    my $control_number = $marc_record->field('001')->data;
139
140
    my $schema = Koha::Database->new()->schema();
141
    return $schema->resultset('ImportBiblio')->count(
142
        {
143
            control_number => $control_number,
144
            'import_record.import_batch_id' => $batch_id,
145
            %extra_conditions
146
        },
147
        {
148
            join => 'import_record',
149
        }
150
    );
151
}
152
153
sub create_record {
154
    my ( $batch_id ) = @_;
155
156
    my $marcflavour = C4::Context->preference('marcflavour') || 'marc21';
157
    my $marc_record = eval { MARC::Record::new_from_xml( $query->param('record'), "utf8", $marcflavour) };
158
    if ($@) {
159
        C4::Service->return_error( 'failed', $@ );
160
    }
161
162
    if ( !$query->param('allow_control_number_conflict') && _control_number_already_used( $marc_record, $batch_id ) ) {
163
        C4::Service->return_error( 'control_number_match', '' );
164
    }
165
166
    my $import_record_id = AddBiblioToBatch( $batch_id, 0, $marc_record, "utf8", int( rand(99999) ) );
167
    $response->param( import_record_id => $import_record_id );
168
169
    C4::Service->return_success( $response );
170
}
171
172
sub update_record {
173
    my ( $batch_id, $import_record_id ) = @_;
174
175
    my $marcflavour = C4::Context->preference('marcflavour') || 'MARC21';
176
    my $marc_record = eval { MARC::Record::new_from_xml( $query->param('record'), "utf8", $marcflavour) };
177
    if ($@) {
178
        C4::Service->return_error( 'failed', $@ );
179
    }
180
181
    if ( !$query->param('allow_control_number_conflict') &&  _control_number_already_used( $marc_record, $batch_id, $import_record_id ) ) {
182
        C4::Service->return_error( 'control_number_match', '' );
183
    }
184
185
    C4::Biblio::UpdateMarcTimestamp( $marc_record );
186
    ModBiblioInBatch( $import_record_id, $marc_record );
187
188
    $response->param( updated_record => $marc_record->as_xml_record( C4::Context->preference('marcflavour') ) );
189
190
    C4::Service->return_success( $response );
191
}
192
193
sub create_batch {
194
    my ( $batch_name ) = C4::Service->require_params( 'batch_name' );
195
196
    my $batch_id = AddImportBatch({
197
        file_name => $batch_name,
198
        record_type => 'biblio'
199
    });
200
201
    $response->param( batch_id => $batch_id );
202
203
    C4::Service->return_success( $response );
204
}
205
206
C4::Service->dispatch(
207
    [ 'GET /(\d+)', [ 'download' ], \&download_batch ],
208
    [ 'GET /(\d+)/(\d+)', [], \&get_record ],
209
    [ 'POST /(\d+)/', [], \&create_record ],
210
    [ 'POST /(\d+)/(\d+)', [], \&update_record ],
211
    [ 'POST /', [], \&create_batch ],
212
);

Return to bug 18823