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

(-)a/C4/Acquisition.pm (-1 / +1 lines)
Lines 1861-1867 sub DelOrder { Link Here
1861
    $sth->execute( $bibnum, $ordernumber );
1861
    $sth->execute( $bibnum, $ordernumber );
1862
    my @itemnumbers = GetItemnumbersFromOrder( $ordernumber );
1862
    my @itemnumbers = GetItemnumbersFromOrder( $ordernumber );
1863
    foreach my $itemnumber (@itemnumbers){
1863
    foreach my $itemnumber (@itemnumbers){
1864
        C4::Items::DelItem( $dbh, $bibnum, $itemnumber );
1864
        C4::Items::DelItem( $bibnum, $itemnumber );
1865
    }
1865
    }
1866
    return;
1866
    return;
1867
}
1867
}
(-)a/C4/Items.pm (-8 / +8 lines)
Lines 632-649 sub ModDateLastSeen { Link Here
632
632
633
=head2 DelItem
633
=head2 DelItem
634
634
635
  DelItem($dbh, $biblionumber, $itemnumber);
635
  DelItem( $biblionumber, $itemnumber );
636
636
637
Exported function (core API) for deleting an item record in Koha.
637
Exported function (core API) for deleting an item record in Koha.
638
638
639
=cut
639
=cut
640
640
641
sub DelItem {
641
sub DelItem {
642
    my ( $dbh, $biblionumber, $itemnumber ) = @_;
642
    my ( $biblionumber, $itemnumber ) = @_;
643
    
643
644
    # FIXME check the item has no current issues
644
    # FIXME check the item has no current issues
645
    
645
    _koha_delete_item( $itemnumber );
646
    _koha_delete_item( $dbh, $itemnumber );
647
646
648
    # get the MARC record
647
    # get the MARC record
649
    my $record = GetMarcBiblio($biblionumber);
648
    my $record = GetMarcBiblio($biblionumber);
Lines 2288-2294 sub DelItemCheck { Link Here
2288
        } elsif ($countanalytics > 0){
2287
        } elsif ($countanalytics > 0){
2289
		$error = "linked_analytics";
2288
		$error = "linked_analytics";
2290
	} else {
2289
	} else {
2291
            DelItem($dbh, $biblionumber, $itemnumber);
2290
            DelItem($biblionumber, $itemnumber);
2292
            return 1;
2291
            return 1;
2293
        }
2292
        }
2294
    }
2293
    }
Lines 2330-2344 sub _koha_modify_item { Link Here
2330
2329
2331
=head2 _koha_delete_item
2330
=head2 _koha_delete_item
2332
2331
2333
  _koha_delete_item( $dbh, $itemnum );
2332
  _koha_delete_item( $itemnum );
2334
2333
2335
Internal function to delete an item record from the koha tables
2334
Internal function to delete an item record from the koha tables
2336
2335
2337
=cut
2336
=cut
2338
2337
2339
sub _koha_delete_item {
2338
sub _koha_delete_item {
2340
    my ( $dbh, $itemnum ) = @_;
2339
    my ( $itemnum ) = @_;
2341
2340
2341
    my $dbh = C4::Context->dbh;
2342
    # save the deleted item to deleteditems table
2342
    # save the deleted item to deleteditems table
2343
    my $sth = $dbh->prepare("SELECT * FROM items WHERE itemnumber=?");
2343
    my $sth = $dbh->prepare("SELECT * FROM items WHERE itemnumber=?");
2344
    $sth->execute($itemnum);
2344
    $sth->execute($itemnum);
(-)a/t/db_dependent/Items.t (-2 / +1 lines)
Lines 58-64 subtest 'General Add, Get and Del tests' => sub { Link Here
58
    cmp_ok($moditem->{'barcode'}, '==', '987654321', 'Modified item barcode successfully to: '.$moditem->{'barcode'} . '.');
58
    cmp_ok($moditem->{'barcode'}, '==', '987654321', 'Modified item barcode successfully to: '.$moditem->{'barcode'} . '.');
59
59
60
    # Delete item.
60
    # Delete item.
61
    DelItem($dbh, $bibnum, $itemnumber);
61
    DelItem($bibnum, $itemnumber);
62
    my $getdeleted = GetItem($itemnumber);
62
    my $getdeleted = GetItem($itemnumber);
63
    is($getdeleted->{'itemnumber'}, undef, "Item deleted as expected.");
63
    is($getdeleted->{'itemnumber'}, undef, "Item deleted as expected.");
64
64
65
- 

Return to bug 12583