From 27c43f28b7938158ffe02c586755344492ed492f Mon Sep 17 00:00:00 2001 From: Aleisha Date: Tue, 29 Mar 2016 00:04:36 +0000 Subject: [PATCH] Bug 9259: Ability to delete a staged file once it has been cleaned To test: 1) Go to Tools -> Staged MARC Management and clean a file. If you have no files to clean, go to 'Stage MARC for import' and upload one to clean following the necessary steps. 2) Confirm that once the file has been cleaned, the Action column now shows a Delete button. Confirm this button only shows for cleaned files. 3) Click the Delete button. 4) Confirm that clicking Cancel exits the pop-up message and does not delete the file. 5) Confirm that clicking OK refreshes the list of staged records and the one you just deleted is no longer on it (has been deleted). You can confirm this by checking for the file in mysql (SELECT * FROM import_batches WHERE import_batch_id = X;) Sponsored-by: Catalyst IT Signed-off-by: Liz Rea Catalyst sign off, so needs another one but YAY this is great. --- C4/ImportBatch.pm | 19 +++++++++++++++++++ .../prog/en/modules/tools/manage-marc-import.tt | 15 +++++++++++++-- tools/manage-marc-import.pl | 6 ++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 77ba9f3..8ef5b4d 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -53,6 +53,7 @@ BEGIN { BatchCommitRecords BatchRevertRecords CleanBatch + DeleteBatch GetAllImportBatches GetStagedWebserviceBatches @@ -959,6 +960,24 @@ sub CleanBatch { SetImportBatchStatus($batch_id, 'cleaned'); } +=head2 DeleteBatch + + DeleteBatch($batch_id) + +Deletes the record from the database. This can only be done +once the batch has been cleaned. + +=cut + +sub DeleteBatch { + my $batch_id = shift; + return unless defined $batch_id; + + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare('DELETE FROM import_batches WHERE import_batch_id = ?'); + $sth->execute( $batch_id ); +} + =head2 GetAllImportBatches my $results = GetAllImportBatches(); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt index d06ff67..8e03870 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt @@ -38,6 +38,7 @@