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

(-)a/C4/Acquisition.pm (-10 / +9 lines)
Lines 28-34 use MARC::Record; Link Here
28
use C4::Suggestions;
28
use C4::Suggestions;
29
use C4::Biblio;
29
use C4::Biblio;
30
use C4::Debug;
30
use C4::Debug;
31
use C4::SQLHelper qw(InsertInTable UpdateInTable);
32
use C4::Bookseller qw(GetBookSellerFromId);
31
use C4::Bookseller qw(GetBookSellerFromId);
33
use C4::Templates qw(gettemplate);
32
use C4::Templates qw(gettemplate);
34
33
Lines 1270-1287 sub NewOrder { Link Here
1270
        croak "Mandatory parameter $key missing" unless $orderinfo->{$key};
1269
        croak "Mandatory parameter $key missing" unless $orderinfo->{$key};
1271
    }
1270
    }
1272
1271
1273
    if ( defined $orderinfo->{subscription} && $orderinfo->{'subscription'} eq 'yes' ) {
1274
        $orderinfo->{'subscription'} = 1;
1275
    } else {
1276
        $orderinfo->{'subscription'} = 0;
1277
    }
1278
    $orderinfo->{'entrydate'} ||= C4::Dates->new()->output("iso");
1272
    $orderinfo->{'entrydate'} ||= C4::Dates->new()->output("iso");
1279
    if (!$orderinfo->{quantityreceived}) {
1273
    if (!$orderinfo->{quantityreceived}) {
1280
        $orderinfo->{quantityreceived} = 0;
1274
        $orderinfo->{quantityreceived} = 0;
1281
    }
1275
    }
1282
1276
1283
    my $ordernumber=InsertInTable("aqorders",$orderinfo);
1277
    # get only the columns of Aqorder
1284
    if (not $orderinfo->{parent_ordernumber}) {
1278
    my $schema = Koha::Database->new()->schema;
1279
    my $columns = ' '.join(' ', $schema->source('Aqorder')->columns).' ';
1280
    my $new_order = { map { $columns =~ / $_ / ? ($_ => $orderinfo->{$_}) : () } keys(%$orderinfo) };
1281
1282
    my $rs = $schema->resultset('Aqorder');
1283
    my $ordernumber = $rs->create($new_order)->id;
1284
    if (not $new_order->{parent_ordernumber}) {
1285
        my $sth = $dbh->prepare("
1285
        my $sth = $dbh->prepare("
1286
            UPDATE aqorders
1286
            UPDATE aqorders
1287
            SET parent_ordernumber = ordernumber
1287
            SET parent_ordernumber = ordernumber
Lines 1289-1295 sub NewOrder { Link Here
1289
        ");
1289
        ");
1290
        $sth->execute($ordernumber);
1290
        $sth->execute($ordernumber);
1291
    }
1291
    }
1292
    return ( $orderinfo->{'basketno'}, $ordernumber );
1292
    return ( $new_order->{'basketno'}, $ordernumber );
1293
}
1293
}
1294
1294
1295
1295
1296
- 

Return to bug 12626