Merge pull request #1001 from lrq3000/develop
Add Invoice hook in orderstoinvoice.php + Standardization
This commit is contained in:
commit
70e77269f6
@ -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
|
* Actions
|
||||||
*/
|
*/
|
||||||
@ -200,18 +206,18 @@ if (($action == 'create' || $action == 'add') && empty($mesgs))
|
|||||||
|
|
||||||
while ($ii < $nn)
|
while ($ii < $nn)
|
||||||
{
|
{
|
||||||
dol_include_once('/commande/class/commande.class.php');
|
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||||
$srcobject = new Commande($db);
|
$objectsrc = new Commande($db);
|
||||||
dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
|
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 ($result > 0)
|
||||||
{
|
{
|
||||||
if($closeOrders) {
|
if($closeOrders) {
|
||||||
$srcobject->classer_facturee();
|
$objectsrc->classer_facturee();
|
||||||
$srcobject->setStatut(3);
|
$objectsrc->setStatut(3);
|
||||||
}
|
}
|
||||||
$lines = $srcobject->lines;
|
$lines = $objectsrc->lines;
|
||||||
if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines();
|
if (empty($lines) && method_exists($objectsrc,'fetch_lines')) $lines = $objectsrc->fetch_lines();
|
||||||
$fk_parent_line=0;
|
$fk_parent_line=0;
|
||||||
$num=count($lines);
|
$num=count($lines);
|
||||||
for ($i=0;$i<$num;$i++)
|
for ($i=0;$i<$num;$i++)
|
||||||
@ -306,7 +312,7 @@ if (($action == 'create' || $action == 'add') && empty($mesgs))
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesgs[]=$srcobject->error;
|
$mesgs[]=$objectsrc->error;
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
$ii++;
|
$ii++;
|
||||||
@ -424,6 +430,23 @@ if ($action == 'create' && empty($mesgs))
|
|||||||
select_projects($soc->id, $projectid, 'projectid');
|
select_projects($soc->id, $projectid, 'projectid');
|
||||||
print '</td></tr>';
|
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
|
// Modele PDF
|
||||||
print '<tr><td>'.$langs->trans('Model').'</td>';
|
print '<tr><td>'.$langs->trans('Model').'</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
@ -438,18 +461,7 @@ if ($action == 'create' && empty($mesgs))
|
|||||||
print '<td valign="top" colspan="2">';
|
print '<td valign="top" colspan="2">';
|
||||||
print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">';
|
print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">';
|
||||||
|
|
||||||
dol_include_once('/commande/class/commande.class.php');
|
print $langs->trans("Orders").": ".implode(', ', $listoforders);
|
||||||
$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 '</textarea></td></tr>';
|
print '</textarea></td></tr>';
|
||||||
// Private note
|
// Private note
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user