From 3b9af82c390c810cec813ac74b57a17febe317fd Mon Sep 17 00:00:00 2001 From: Stephen L Date: Wed, 29 May 2013 13:28:44 +0200 Subject: [PATCH] Add Invoice hook in orderstoinvoice.php + Standardization Signed-off-by: Stephen L. --- htdocs/commande/orderstoinvoice.php | 52 ++++++++++++++++++----------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index 93a4db53fbb..9631ced232b 100755 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -78,6 +78,12 @@ if ($action == 'create') } } +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; +$hookmanager=new HookManager($db); +$hookmanager->initHooks(array('orderstoinvoice')); + + /* * Actions */ @@ -200,18 +206,18 @@ if (($action == 'create' || $action == 'add') && empty($mesgs)) while ($ii < $nn) { - dol_include_once('/commande/class/commande.class.php'); - $srcobject = new Commande($db); + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $objectsrc = new Commande($db); dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); - $result=$srcobject->fetch($orders_id[$ii]); + $result=$objectsrc->fetch($orders_id[$ii]); if ($result > 0) { if($closeOrders) { - $srcobject->classer_facturee(); - $srcobject->setStatut(3); + $objectsrc->classer_facturee(); + $objectsrc->setStatut(3); } - $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); + $lines = $objectsrc->lines; + if (empty($lines) && method_exists($objectsrc,'fetch_lines')) $lines = $objectsrc->fetch_lines(); $fk_parent_line=0; $num=count($lines); for ($i=0;$i<$num;$i++) @@ -306,7 +312,7 @@ if (($action == 'create' || $action == 'add') && empty($mesgs)) } else { - $mesgs[]=$srcobject->error; + $mesgs[]=$objectsrc->error; $error++; } $ii++; @@ -424,6 +430,23 @@ if ($action == 'create' && empty($mesgs)) select_projects($soc->id, $projectid, 'projectid'); print ''; } + + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $objectsrc = new Commande($db); + $listoforders = array(); + foreach ($selected as $sel) + { + $result=$objectsrc->fetch($sel); + if ($result > 0) + { + $listoforders[] = $objectsrc->ref; + } + } + + // Other attributes + $parameters=array('objectsrc' => $objectsrc, 'idsrc' => $listoforders, 'colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + // Modele PDF print ''.$langs->trans('Model').''; print ''; @@ -438,18 +461,7 @@ if ($action == 'create' && empty($mesgs)) print ''; print ''; // Private note