Skip to content

Commit

Permalink
Merge pull request #1001 from lrq3000/develop
Browse files Browse the repository at this point in the history
Add Invoice hook in orderstoinvoice.php + Standardization
  • Loading branch information
eldy committed May 29, 2013
2 parents 832bd0a + 3b9af82 commit 70e7726
Showing 1 changed file with 32 additions and 20 deletions.
52 changes: 32 additions & 20 deletions htdocs/commande/orderstoinvoice.php
Expand Up @@ -78,6 +78,12 @@
}
}

// 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
*/
Expand Down Expand Up @@ -200,18 +206,18 @@

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++)
Expand Down Expand Up @@ -306,7 +312,7 @@
}
else
{
$mesgs[]=$srcobject->error;
$mesgs[]=$objectsrc->error;
$error++;
}
$ii++;
Expand Down Expand Up @@ -424,6 +430,23 @@
select_projects($soc->id, $projectid, 'projectid');
print '</td></tr>';
}

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 '<tr><td>'.$langs->trans('Model').'</td>';
print '<td>';
Expand All @@ -438,18 +461,7 @@
print '<td valign="top" colspan="2">';
print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">';

dol_include_once('/commande/class/commande.class.php');
$srcobject = new Commande($db);
$listoforders = '';
foreach ($selected as $sel)
{
$result=$srcobject->fetch($sel);
if ($result > 0)
{
$listoforders .= ($listoforders?', ':'').$srcobject->ref;
}
}
print $langs->trans("Orders").": ".$listoforders;
print $langs->trans("Orders").": ".implode(', ', $listoforders);

print '</textarea></td></tr>';
// Private note
Expand Down

0 comments on commit 70e7726

Please sign in to comment.