From 6c1f60f6c05d94dc7b371568b4cad2c0af8d29a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Oct 2020 17:19:15 +0100 Subject: [PATCH] Fix regression --- htdocs/core/lib/sendings.lib.php | 21 +++++++++++++++------ htdocs/delivery/card.php | 12 ++++++------ htdocs/delivery/class/delivery.class.php | 3 +++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 756b9cfe930..81775bf8dbd 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -51,7 +51,6 @@ function shipping_prepare_head($object) { // delivery link $object->fetchObjectLinked($object->id, $object->element); - var_dump($object->id); if (is_array($object->linkedObjectsIds['delivery']) && count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery { // Take first one element of array @@ -158,11 +157,21 @@ function delivery_prepare_head($object) $tmpobject = $object; } - $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$tmpobject->id; - $head[$h][1] = $langs->trans("ContactsAddresses"); - $head[$h][2] = 'contact'; - $h++; - + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $objectsrc = $tmpobject; + if ($tmpobject->origin == 'commande' && $tmpobject->origin_id > 0) + { + $objectsrc = new Commande($db); + $objectsrc->fetch($tmpobject->origin_id); + } + $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external')); + $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$tmpobject->id; + $head[$h][1] = $langs->trans("ContactsAddresses"); + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; + $head[$h][2] = 'contact'; + $h++; + } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index 5cd7d5fff8d..3510fd2a4f2 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -57,7 +57,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Security check $id = GETPOST('id', 'int'); if ($user->socid) $socid = $user->socid; -$result = restrictedArea($user, 'expedition', $id, 'delivery', 'livraison'); +$result = restrictedArea($user, 'expedition', $id, 'delivery', 'delivery'); $object = new Delivery($db); $extrafields = new ExtraFields($db); @@ -87,13 +87,14 @@ if ($action == 'add') $db->begin(); $object->date_livraison = time(); - $object->note = $_POST["note"]; - $object->commande_id = $_POST["commande_id"]; + $object->note = GETPOST("note", 'restricthtml'); + $object->note_private = GETPOST("note", 'restricthtml'); + $object->commande_id = GETPOST("commande_id", 'int'); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); if (!$conf->expedition_bon->enabled && !empty($conf->stock->enabled)) { - $expedition->entrepot_id = $_POST["entrepot_id"]; + $expedition->entrepot_id = GETPOST('entrepot_id'); } // On boucle sur chaque ligne de commande pour completer objet livraison @@ -276,7 +277,6 @@ if ($action == 'create') // Create. Seems to no be used $head = delivery_prepare_head($object); - print '
'; print ''; print ''; @@ -364,7 +364,7 @@ if ($action == 'create') // Create. Seems to no be used } $morehtmlref .= ''; - $morehtmlright = $langs->trans("StatusReceipt").' : '.$object->getLibStatut(6).'
'; + $morehtmlright = $langs->trans("StatusReceipt").' : '.$object->getLibStatut(6).'

'; dol_banner_tab($expedition, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', $morehtmlright); diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index ecf1c7bdcc4..bd6ef948c6c 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonincoterm.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; @@ -39,6 +40,8 @@ if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/ */ class Delivery extends CommonObject { + use CommonIncoterm; + /** * @var string ID to identify managed object */