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

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

Return to bug 12626