2
0
forked from Wavyzz/dolibarr

[ task #793 ] Add extrafield feature into Orders module

This commit is contained in:
fhenry
2013-04-05 12:43:00 +02:00
parent d8a86453e5
commit dfcb38d13f
8 changed files with 1584 additions and 1189 deletions

View File

@@ -598,7 +598,7 @@ class Commande extends CommonOrder
*/
function create($user, $notrigger=0)
{
global $conf,$langs,$mysoc;
global $conf,$langs,$mysoc,$hookmanager;
$error=0;
// Clean parameters
@@ -760,6 +760,27 @@ class Commande extends CommonOrder
}
}
}
if (! $error)
{
// Actions on extra fields (by external module or standard code)
// FIXME le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('orderdao'));
$parameters=array('socid'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
}
else if ($reshook < 0) $error++;
}
if (! $notrigger)
{
@@ -2756,6 +2777,44 @@ class Commande extends CommonOrder
return -1;
}
}
/**
* Update value of extrafields on the proposal
*
* @param User $user Object user that modify
* @param double $remise Amount discount
* @return int <0 if ko, >0 if ok
*/
function update_extrafields($user)
{
// Actions on extra fields (by external module or standard code)
// FIXME le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('orderdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
}
else if ($reshook < 0) $error++;
if (!$error)
{
return 1;
}
else
{
return -1;
}
}
/**
* Return an array of order lines