From 1fa13fc7478bae4c5945f13a15b73a1fed22f87e Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 12 Jul 2018 18:27:09 +0200 Subject: [PATCH] fix list of event unformize code --- htdocs/core/lib/company.lib.php | 50 ++---------------------------- htdocs/core/lib/functions2.lib.php | 6 +++- 2 files changed, 8 insertions(+), 48 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index ea91c4796d2..4118bf0746c 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1478,10 +1478,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions=new FormActions($db); @@ -1490,12 +1487,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $userstatic=new User($db); $contactstatic = new Contact($db); - // TODO mutualize/uniformize - $propalstatic=new Propal($db); - $orderstatic=new Commande($db); - $supplierorderstatic=new CommandeFournisseur($db); - $facturestatic=new Facture($db); - $out.='
'; if ($objcon && get_class($objcon) == 'Contact' && $filterobj && get_class($filterobj) == 'Societe') { @@ -1656,45 +1647,10 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= //$out.=''.dol_trunc($histo[$key]['note'], 40).''; // Objet lie - // TODO mutualize/uniformize $out.=''; - //var_dump($histo[$key]['elementtype']); - if (isset($histo[$key]['elementtype'])) + if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) { - if ($histo[$key]['elementtype'] == 'propal' && ! empty($conf->propal->enabled)) - { - //$propalstatic->ref=$langs->trans("ProposalShort"); - //$propalstatic->id=$histo[$key]['fk_element']; - if ($propalstatic->fetch($histo[$key]['fk_element'])>0) { - $propalstatic->type=$histo[$key]['ftype']; - $out.=$propalstatic->getNomUrl(1); - } else { - //$out.= ''.$langs->trans("ProposalDeleted").''; - } - } - elseif (($histo[$key]['elementtype'] == 'order' || $histo[$key]['elementtype'] == 'commande') && ! empty($conf->commande->enabled)) - { - //$orderstatic->ref=$langs->trans("Order"); - //$orderstatic->id=$histo[$key]['fk_element']; - if ($orderstatic->fetch($histo[$key]['fk_element'])>0) { - $orderstatic->type=$histo[$key]['ftype']; - $out.=$orderstatic->getNomUrl(1); - } else { - //$out.= ''.$langs->trans("OrderDeleted").''; - } - } - elseif (($histo[$key]['elementtype'] == 'invoice' || $histo[$key]['elementtype'] == 'facture') && ! empty($conf->facture->enabled)) - { - //$facturestatic->ref=$langs->trans("Invoice"); - //$facturestatic->id=$histo[$key]['fk_element']; - if ($facturestatic->fetch($histo[$key]['fk_element'])>0) { - $facturestatic->type=$histo[$key]['ftype']; - $out.=$facturestatic->getNomUrl(1,'compta'); - } else { - //$out.= ''.$langs->trans("InvoiceDeleted").''; - } - } - else $out.=' '; + $out.=dolGetElementUrl($histo[$key]['fk_element'],$histo[$key]['elementtype'],1); } else $out.=' '; $out.=''; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index c95deeef81f..5fd565fb191 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1865,7 +1865,11 @@ function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='') { $object = new $classname($db); $res=$object->fetch($objectid); - if ($res > 0) $ret=$object->getNomUrl($withpicto,$option); + if ($res > 0) { + $ret=$object->getNomUrl($withpicto,$option); + } elseif($res==0) { + $ret=$langs->trans('Deleted'); + } unset($object); } else dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR);