386 |
386 |
dbh => $dbh);
|
387 |
387 |
}
|
388 |
388 |
|
389 |
|
# search for orphaned doi
|
390 |
|
$query = sprintf 'SELECT id FROM delivery_order_items WHERE delivery_order_id = ? AND NOT id IN (%s)', join ', ', ("?") x scalar @processed_doi;
|
391 |
|
@values = (conv_i($form->{id}), map { conv_i($_) } @processed_doi);
|
392 |
|
my @orphaned_ids = map { $_->{id} } selectall_hashref_query($form, $dbh, $query, @values);
|
393 |
|
if (scalar @orphaned_ids) {
|
394 |
|
# clean up delivery_order_items
|
395 |
|
$query = sprintf 'DELETE FROM delivery_order_items WHERE id IN (%s)', join ', ', ("?") x scalar @orphaned_ids;
|
396 |
|
do_query($form, $dbh, $query, @orphaned_ids);
|
397 |
|
}
|
398 |
|
# search for orphaned dois
|
|
389 |
# 1. search for orphaned dois; processed_dois may be empty (no transfer) TODO: be supersafe and alter same statement for doi and oi
|
399 |
390 |
$query = sprintf 'SELECT id FROM delivery_order_items_stock WHERE delivery_order_item_id in
|
400 |
|
(select id from delivery_order_items where delivery_order_id = ?) AND NOT id IN (%s)', join ', ', ("?") x scalar @processed_dois;
|
|
391 |
(select id from delivery_order_items where delivery_order_id = ?)';
|
|
392 |
$query .= sprintf ' AND NOT id IN (%s)', join ', ', ("?") x scalar @processed_dois if (scalar @processed_dois);
|
401 |
393 |
@values = (conv_i($form->{id}), map { conv_i($_) } @processed_dois);
|
402 |
394 |
my @orphaned_dois_ids = map { $_->{id} } selectall_hashref_query($form, $dbh, $query, @values);
|
403 |
395 |
if (scalar @orphaned_dois_ids) {
|
... | ... | |
405 |
397 |
$query = sprintf 'DELETE FROM delivery_order_items_stock WHERE id IN (%s)', join ', ', ("?") x scalar @orphaned_dois_ids;
|
406 |
398 |
do_query($form, $dbh, $query, @orphaned_dois_ids);
|
407 |
399 |
}
|
|
400 |
# 2. search for orphaned doi
|
|
401 |
$query = sprintf 'SELECT id FROM delivery_order_items WHERE delivery_order_id = ? AND NOT id IN (%s)', join ', ', ("?") x scalar @processed_doi;
|
|
402 |
@values = (conv_i($form->{id}), map { conv_i($_) } @processed_doi);
|
|
403 |
my @orphaned_ids = map { $_->{id} } selectall_hashref_query($form, $dbh, $query, @values);
|
|
404 |
if (scalar @orphaned_ids) {
|
|
405 |
# clean up delivery_order_items
|
|
406 |
$query = sprintf 'DELETE FROM delivery_order_items WHERE id IN (%s)', join ', ', ("?") x scalar @orphaned_ids;
|
|
407 |
do_query($form, $dbh, $query, @orphaned_ids);
|
|
408 |
}
|
408 |
409 |
$h_item->finish();
|
409 |
410 |
$h_item_stock->finish();
|
410 |
411 |
|
delivery_order_items_stock persistent machen Teil 3
Stichproben:
Verkaufs-LS als neu speichern i.O.
Einkaufs-LS mittlere Position löschen (mit und ohne dois) i.O.
Einkaufs-LS E-Mail-Knopf statt Speichern i.O.
Einkaufs-LS Rechnung (keine hiddens doi!) i.O.
Einkaufs-LS mit dois Löschen i.O. (keine verwaisten doi oder dois)