From f95acb24ff0c758c5fa744923e76d662d1ed064b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Oct 2016 10:13:55 +0100 Subject: [PATCH] Uniformize code --- htdocs/expedition/contact.php | 18 ++++++---- htdocs/expedition/note.php | 68 +++++++++++++++++++---------------- htdocs/livraison/card.php | 29 ++++++++------- 3 files changed, 63 insertions(+), 52 deletions(-) diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index 65a44cb64f9..80ceb1e8bd5 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -29,6 +29,10 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +if (! empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +} $langs->load("orders"); $langs->load("sendings"); @@ -165,11 +169,10 @@ if ($id > 0 || ! empty($ref)) // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); // Project - /* if (! empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '
' . $langs->trans('Project') . ' '; - if ($user->rights->supplier_proposal->creer) { + if (0) { // Do not change on shipment if ($action != 'classify') { $morehtmlref .= '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; } @@ -185,17 +188,20 @@ if ($id > 0 || ! empty($ref)) $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + // We don't have project on shipment, so we will use the project or source object instead + // TODO Add project on shipment + $morehtmlref .= ' : '; + if (! empty($objectsrc->fk_project)) { $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; + $proj->fetch($objectsrc->fk_project); + $morehtmlref .= ''; $morehtmlref .= $proj->ref; $morehtmlref .= ''; } else { $morehtmlref .= ''; } } - }*/ + } $morehtmlref.=''; diff --git a/htdocs/expedition/note.php b/htdocs/expedition/note.php index 849ec6e66bc..031ba85322e 100644 --- a/htdocs/expedition/note.php +++ b/htdocs/expedition/note.php @@ -27,6 +27,10 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php'; +if (! empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +} $langs->load("sendings"); $langs->load("companies"); @@ -110,37 +114,39 @@ if ($id > 0 || ! empty($ref)) // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); // Project - /* - if (! empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
' . $langs->trans('Project') . ' '; - if ($user->rights->supplier_proposal->creer) { - if ($action != 'classify') { - $morehtmlref .= '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - } - if ($action == 'classify') { - // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } - }*/ + if (! empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= '
' . $langs->trans('Project') . ' '; + if (0) { // Do not change on shipment + if ($action != 'classify') { + $morehtmlref .= '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + } + if ($action == 'classify') { + // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + // We don't have project on shipment, so we will use the project or source object instead + // TODO Add project on shipment + $morehtmlref .= ' : '; + if (! empty($objectsrc->fk_project)) { + $proj = new Project($db); + $proj->fetch($objectsrc->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } + } $morehtmlref.=''; diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index fcd32762139..c1236f239bd 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -40,7 +40,11 @@ if (! empty($conf->expedition_bon->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; - +if (! empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +} + $langs->load("sendings"); $langs->load("bills"); @@ -312,13 +316,8 @@ else { if ($object->id > 0) { - // Origin of a 'livraison' (delivery) is ALWAYS 'expedition' (shipment). + // Origin of a 'livraison' (delivery receipt) is ALWAYS 'expedition' (shipment). // However, origin of shipment in future may differs (commande, proposal, ...) - // TODO REGIS: - // Je ne suis pas d'accord, beaucoup entreprises n'utilisent pas les bons d'expéditions car ces derniers sont gérés par le transporteur, - // donc les bons de livraisons peuvent avoir une origine différente de 'expedition' - // les bons de livraisons et d'expéditions devraient être considérés comme des objets à part entière, voir des modules différents comme une propal ou autres. - $expedition=new Expedition($db); $result = $expedition->fetch($object->origin_id); $typeobject = $expedition->origin; // example: commande @@ -369,17 +368,17 @@ else * Livraison */ - if ($typeobject == 'commande' && $expedition->$typeobject->id && ! empty($conf->commande->enabled)) + if ($typeobject == 'commande' && $expedition->origin_id > 0 && ! empty($conf->commande->enabled)) { $objectsrc=new Commande($db); - $objectsrc->fetch($expedition->$typeobject->id); + $objectsrc->fetch($expedition->origin_id); } - if ($typeobject == 'propal' && $expedition->$typeobject->id && ! empty($conf->propal->enabled)) + if ($typeobject == 'propal' && $expedition->origin_id > 0 && ! empty($conf->propal->enabled)) { $objectsrc=new Propal($db); - $objectsrc->fetch($expedition->$typeobject->id); + $objectsrc->fetch($expedition->origin_id); } - + // Shipment card $linkback = ''.$langs->trans("BackToList").''; @@ -411,10 +410,10 @@ else } } else { $morehtmlref .= ' : '; - if (! empty($expeditionsrc->fk_project)) { + if (! empty($objectsrc->fk_project)) { $proj = new Project($db); - $proj->fetch($expeditionsrc->fk_project); - $morehtmlref .= ''; + $proj->fetch($objectsrc->fk_project); + $morehtmlref .= ''; $morehtmlref .= $proj->ref; $morehtmlref .= ''; } else {