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

(-)a/C4/ImportBatch.pm (+19 lines)
Lines 53-58 BEGIN { Link Here
53
    BatchCommitRecords
53
    BatchCommitRecords
54
    BatchRevertRecords
54
    BatchRevertRecords
55
    CleanBatch
55
    CleanBatch
56
    DeleteBatch
56
57
57
    GetAllImportBatches
58
    GetAllImportBatches
58
    GetStagedWebserviceBatches
59
    GetStagedWebserviceBatches
Lines 959-964 sub CleanBatch { Link Here
959
    SetImportBatchStatus($batch_id, 'cleaned');
960
    SetImportBatchStatus($batch_id, 'cleaned');
960
}
961
}
961
962
963
=head2 DeleteBatch
964
965
  DeleteBatch($batch_id)
966
967
Deletes the record from the database. This can only be done
968
once the batch has been cleaned.
969
970
=cut
971
972
sub DeleteBatch {
973
    my $batch_id = shift;
974
    return unless defined $batch_id;
975
976
    my $dbh = C4::Context->dbh;
977
    my $sth = $dbh->prepare('DELETE FROM import_batches WHERE import_batch_id = ?');
978
    $sth->execute( $batch_id );
979
}
980
962
=head2 GetAllImportBatches
981
=head2 GetAllImportBatches
963
982
964
  my $results = GetAllImportBatches();
983
  my $results = GetAllImportBatches();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt (-2 / +13 lines)
Lines 39-44 Link Here
39
//<![CDATA[
39
//<![CDATA[
40
var MSG_CONFIRM_CLEAN = _("Clear all reservoir records staged in this batch?  This cannot be undone.");
40
var MSG_CONFIRM_CLEAN = _("Clear all reservoir records staged in this batch?  This cannot be undone.");
41
var MSG_CONFIRM_UNDO_IMPORT = _("Are you sure you want to undo the import of this batch into the catalog?");
41
var MSG_CONFIRM_UNDO_IMPORT = _("Are you sure you want to undo the import of this batch into the catalog?");
42
var MSG_CONFIRM_DELETE = _("Are you sure you want to permanently delete this batch?");
42
43
43
$(document).ready(function(){
44
$(document).ready(function(){
44
  $("#staged-record-matching-rules select").change(function(){
45
  $("#staged-record-matching-rules select").change(function(){
Lines 195-200 $(document).ready(function(){ Link Here
195
  <div class="dialog message">Cleaned import batch #[% import_batch_id %]</div>
196
  <div class="dialog message">Cleaned import batch #[% import_batch_id %]</div>
196
[% END %]
197
[% END %]
197
198
199
[% IF ( did_delete ) %]
200
  <div class="dialog message">Import batch deleted successfully</div>
201
[% END %]
202
198
[% UNLESS ( batch_list ) %]
203
[% UNLESS ( batch_list ) %]
199
   [% UNLESS ( batch_info ) %]
204
   [% UNLESS ( batch_info ) %]
200
   <div class="dialog message">
205
   <div class="dialog message">
Lines 449-459 Page Link Here
449
    <td>[% batch_lis.upload_timestamp %]</td>
454
    <td>[% batch_lis.upload_timestamp %]</td>
450
    <td>[% batch_lis.num_records %]</td>
455
    <td>[% batch_lis.num_records %]</td>
451
    <td>[% batch_lis.num_items %][% IF ( batch_lis.num_items ) %] <a href="[% batch_lis.script_name %]?import_batch_id=[% batch_lis.import_batch_id %]&amp;op=create_labels">(Create label batch)</a>[% END %]</td>
456
    <td>[% batch_lis.num_items %][% IF ( batch_lis.num_items ) %] <a href="[% batch_lis.script_name %]?import_batch_id=[% batch_lis.import_batch_id %]&amp;op=create_labels">(Create label batch)</a>[% END %]</td>
452
    <td>[% IF ( batch_lis.can_clean ) %]
457
    <td class="actions">[% IF ( batch_lis.can_clean ) %]
453
          <form method="post" action="[% batch_lis.script_name %]" name="clean_batch_[% batch_lis.import_batch_id %]" id="clean_batch_[% batch_lis.import_batch_id %]" >
458
          <form method="post" action="[% batch_lis.script_name %]" name="clean_batch_[% batch_lis.import_batch_id %]" id="clean_batch_[% batch_lis.import_batch_id %]" >
454
            <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id %]" />
459
            <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id %]" />
455
            <input type="hidden" name="op" value="clean-batch" />
460
            <input type="hidden" name="op" value="clean-batch" />
456
            <button class="btn btn-small" onclick="return confirm(MSG_CONFIRM_CLEAN);">Clean</button>
461
            <button class="btn btn-mini" onclick="return confirm(MSG_CONFIRM_CLEAN);"><i class="fa fa-eraser"></i> Clean</button>
462
          </form>
463
        [% ELSIF ( batch_lis.import_status == 'cleaned' ) %]
464
          <form method="post" action="/cgi-bin/koha/tools/manage-marc-import.pl" name="delete_batch_[% batch_lis.import_batch_id %]" id="delete_batch_[% batch_lis.import_batch_id %]">
465
            <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id %]" />
466
            <input type="hidden" name="op" value="delete-batch" />
467
            <button class="btn btn-mini" onclick="return confirm(MSG_CONFIRM_DELETE);"><i class="fa fa-trash"></i> Delete</button>
457
          </form>
468
          </form>
458
        [% END %]
469
        [% END %]
459
    </td>
470
    </td>
(-)a/t/db_dependent/ImportBatch.t (-1 / +30 lines)
Lines 4-10 use Modern::Perl; Link Here
4
4
5
use C4::Context;
5
use C4::Context;
6
6
7
use Test::More tests => 7;
7
use Test::More tests => 9;
8
8
9
BEGIN {
9
BEGIN {
10
        use_ok('C4::ImportBatch');
10
        use_ok('C4::ImportBatch');
Lines 117-119 $original_record->delete_fields($original_record->field($item_tag)); #Remove ite Link Here
117
my $record_from_import_biblio_without_items = C4::ImportBatch::GetRecordFromImportBiblio( $import_record_id );
117
my $record_from_import_biblio_without_items = C4::ImportBatch::GetRecordFromImportBiblio( $import_record_id );
118
$original_record->leader($record_from_import_biblio_without_items->leader());
118
$original_record->leader($record_from_import_biblio_without_items->leader());
119
is_deeply( $record_from_import_biblio_without_items, $original_record, 'GetRecordFromImportBiblio should return the record without items by default' );
119
is_deeply( $record_from_import_biblio_without_items, $original_record, 'GetRecordFromImportBiblio should return the record without items by default' );
120
121
# fresh data
122
my $sample_import_batch3 = {
123
    matcher_id => 3,
124
    template_id => 3,
125
    branchcode => 'QRT',
126
    overlay_action => 'create_new',
127
    nomatch_action => 'create_new',
128
    item_action => 'always_add',
129
    import_status => 'staged',
130
    batch_type => 'z3950',
131
    file_name => 'test.mrc',
132
    comments => 'test',
133
    record_type => 'auth',
134
};
135
136
my $id_import_batch3 = C4::ImportBatch::AddImportBatch($sample_import_batch3);
137
138
# Test CleanBatch
139
C4::ImportBatch::CleanBatch( $id_import_batch3 );
140
my $batch3_clean = $dbh->do('SELECT * FROM import_records WHERE import_batch_id = "$id_import_batch3"');
141
is_deeply( $batch3_clean, "0E0",
142
    "Batch 3 has been cleaned" );
143
144
# Test DeleteBatch
145
C4::ImportBatch::DeleteBatch( $id_import_batch3 );
146
my $batch3_results = $dbh->do('SELECT * FROM import_batches WHERE import_batch_id = "$id_import_batch3"');
147
is_deeply( $batch3_results, "0E0", # 0E0 == 0
148
    "Batch 3 has been deleted");
(-)a/tools/manage-marc-import.pl (-1 / +6 lines)
Lines 123-128 if ($op eq "") { Link Here
123
        did_clean       => 1,
123
        did_clean       => 1,
124
        import_batch_id => $import_batch_id,
124
        import_batch_id => $import_batch_id,
125
    );
125
    );
126
} elsif ($op eq "delete-batch") {
127
    DeleteBatch($import_batch_id);
128
    import_batches_list($template, $offset, $results_per_page);
129
    $template->param(
130
        did_delete      => 1,
131
    );
126
} elsif ($op eq "redo-matching") {
132
} elsif ($op eq "redo-matching") {
127
    my $new_matcher_id = $input->param('new_matcher_id');
133
    my $new_matcher_id = $input->param('new_matcher_id');
128
    my $current_matcher_id = $input->param('current_matcher_id');
134
    my $current_matcher_id = $input->param('current_matcher_id');
129
- 

Return to bug 9259