FIX data integrity for llx_delivery table

This commit is contained in:
Laurent Destailleur 2022-09-06 01:42:48 +02:00
parent 0d9e595f0e
commit c28966864b
3 changed files with 12 additions and 3 deletions

View File

@ -256,9 +256,10 @@ llxHeader('', $title, 'Livraison');
$form = new Form($db);
$formfile = new FormFile($db);
if ($action == 'create') { // Create. Seems to no be used
} else // View
{
if ($action == 'create') {
// Create. Seems to no be used
} else {
// View
if ($object->id > 0) {
// Origin of a 'livraison' (delivery receipt) is ALWAYS 'expedition' (shipment).
// However, origin of shipment in future may differs (commande, proposal, ...)

View File

@ -405,11 +405,17 @@ if (empty($reshook)) {
}
} elseif ($action == 'create_delivery' && $conf->delivery_note->enabled && $user->rights->expedition->delivery->creer) {
// Build a receiving receipt
$db->begin();
$result = $object->create_delivery($user);
if ($result > 0) {
$db->commit();
header("Location: ".DOL_URL_ROOT.'/delivery/card.php?action=create_delivery&id='.$result);
exit;
} else {
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'confirm_valid' && $confirm == 'yes' &&

View File

@ -194,11 +194,13 @@ delete from llx_delivery where rowid not in (select fk_target from llx_elemen
-- Fix delete element_element orphelins (right side)
delete from llx_element_element where targettype='shipping' and fk_target not in (select rowid from llx_expedition);
delete from llx_element_element where targettype='delivery' and fk_target not in (select rowid from llx_delivery);
delete from llx_element_element where targettype='propal' and fk_target not in (select rowid from llx_propal);
delete from llx_element_element where targettype='facture' and fk_target not in (select rowid from llx_facture);
delete from llx_element_element where targettype='commande' and fk_target not in (select rowid from llx_commande);
-- Fix delete element_element orphelins (left side)
delete from llx_element_element where sourcetype='shipping' and fk_source not in (select rowid from llx_expedition);
delete from llx_element_element where sourcetype='delivery' and fk_source not in (select rowid from llx_delivery);
delete from llx_element_element where sourcetype='propal' and fk_source not in (select rowid from llx_propal);
delete from llx_element_element where sourcetype='facture' and fk_source not in (select rowid from llx_facture);
delete from llx_element_element where sourcetype='commande' and fk_source not in (select rowid from llx_commande);