Works on module hook integration
This commit is contained in:
parent
548210a9e3
commit
5cbde19432
@ -94,8 +94,6 @@ class Propal extends CommonObject
|
||||
|
||||
var $lines = array();
|
||||
var $line;
|
||||
|
||||
var $clone_fromid;
|
||||
|
||||
var $origin;
|
||||
var $origin_id;
|
||||
@ -778,6 +776,12 @@ class Propal extends CommonObject
|
||||
$error=0;
|
||||
|
||||
$object=new Propal($this->db);
|
||||
|
||||
// Instantiate hooks of thirdparty module
|
||||
if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules))
|
||||
{
|
||||
$object->callHooks('objectcard');
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@ -785,7 +789,6 @@ class Propal extends CommonObject
|
||||
$object->fetch($fromid);
|
||||
$object->id=0;
|
||||
$object->statut=0;
|
||||
$object->clone_fromid=$fromid;
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT ."/societe/class/societe.class.php");
|
||||
$objsoc=new Societe($this->db);
|
||||
@ -825,6 +828,16 @@ class Propal extends CommonObject
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
// Hook of thirdparty module
|
||||
if (! empty($object->hooks))
|
||||
{
|
||||
foreach($object->hooks as $module)
|
||||
{
|
||||
$result = $module->createFromClone($object);
|
||||
if ($result < 0) $error++;
|
||||
}
|
||||
}
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||
$interface=new Interfaces($this->db);
|
||||
@ -1353,41 +1366,6 @@ class Propal extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Cree une commande a partir de la proposition commerciale
|
||||
* \param user Utilisateur
|
||||
* \return int <0 si ko, >=0 si ok
|
||||
* TODO move in triggers
|
||||
*/
|
||||
function create_commande($user)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if ($conf->commande->enabled)
|
||||
{
|
||||
if ($this->statut == 2)
|
||||
{
|
||||
// Propale signee
|
||||
include_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
|
||||
$commande = new Commande($this->db);
|
||||
$result=$commande->create_from_propale($user, $this->id);
|
||||
|
||||
// Ne pas passer par la commande provisoire
|
||||
if ($conf->global->COMMANDE_VALID_AFTER_CLOSE_PROPAL == 1)
|
||||
{
|
||||
$commande->fetch($result);
|
||||
$commande->valid($user);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Set draft status
|
||||
* \param user Object user that modify
|
||||
|
||||
@ -77,6 +77,8 @@ class Commande extends CommonObject
|
||||
var $remise_absolue;
|
||||
var $modelpdf;
|
||||
var $info_bits;
|
||||
var $rang;
|
||||
var $special_code;
|
||||
var $source; // Origin of order
|
||||
|
||||
var $origin;
|
||||
@ -607,7 +609,9 @@ class Commande extends CommonObject
|
||||
0,
|
||||
$this->lines[$i]->date_start,
|
||||
$this->lines[$i]->date_end,
|
||||
$this->lines[$i]->product_type
|
||||
$this->lines[$i]->product_type,
|
||||
$this->lines[$i]->rang,
|
||||
$this->lines[$i]->special_code
|
||||
);
|
||||
if ($result < 0)
|
||||
{
|
||||
@ -691,11 +695,17 @@ class Commande extends CommonObject
|
||||
*/
|
||||
function createFromClone($fromid,$invertdetail=0)
|
||||
{
|
||||
global $user,$langs;
|
||||
global $conf,$user,$langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
$object=new Commande($this->db);
|
||||
|
||||
// Instantiate hooks of thirdparty module
|
||||
if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules))
|
||||
{
|
||||
$object->callHooks('objectcard');
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@ -723,9 +733,22 @@ class Commande extends CommonObject
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
|
||||
|
||||
|
||||
// Hook of thirdparty module
|
||||
if (! empty($object->hooks))
|
||||
{
|
||||
foreach($object->hooks as $module)
|
||||
{
|
||||
$result = $module->createFromClone($object);
|
||||
if ($result < 0) $error++;
|
||||
}
|
||||
}
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('ORDER_CLONE',$object,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// Fin appel triggers
|
||||
}
|
||||
|
||||
// End
|
||||
@ -1170,7 +1193,7 @@ class Commande extends CommonObject
|
||||
$this->lines=array();
|
||||
|
||||
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.fk_commande, l.description, l.price, l.qty, l.tva_tx,';
|
||||
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.fk_remise_except, l.remise_percent, l.subprice, l.marge_tx, l.marque_tx, l.rang, l.info_bits,';
|
||||
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.fk_remise_except, l.remise_percent, l.subprice, l.marge_tx, l.marque_tx, l.rang, l.info_bits, l.special_code,';
|
||||
$sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,';
|
||||
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
|
||||
@ -1216,6 +1239,7 @@ class Commande extends CommonObject
|
||||
$line->marque_tx = $objp->marque_tx;
|
||||
$line->rang = $objp->rang;
|
||||
$line->info_bits = $objp->info_bits;
|
||||
$line->special_code = $objp->special_code;
|
||||
|
||||
$line->ref = $objp->product_ref;
|
||||
$line->libelle = $objp->label;
|
||||
|
||||
@ -484,7 +484,7 @@ if ($_POST['action'] == 'addline' && $user->rights->commande->creer)
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
|
||||
commande_pdf_create($db, $commande, $commande->modelpdf, $outputlangs);
|
||||
|
||||
unset($_POST['qty']);
|
||||
unset($_POST['type']);
|
||||
|
||||
@ -63,7 +63,7 @@
|
||||
<?php if ($line->special_code == 3) { ?>
|
||||
<td align="right" nowrap="nowrap"><?php echo $langs->trans('Option'); ?></td>
|
||||
<?php } else { ?>
|
||||
<td align="right" nowrap="nowrap"><?php price($line->total_ht); ?></td>
|
||||
<td align="right" nowrap="nowrap"><?php echo price($line->total_ht); ?></td>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->statut == 0 && $user->rights->$element->creer) { ?>
|
||||
|
||||
@ -56,7 +56,7 @@
|
||||
<?php if ($line->special_code == 3) { ?>
|
||||
<td align="right" nowrap="nowrap"><?php echo $langs->trans('Option'); ?></td>
|
||||
<?php } else { ?>
|
||||
<td align="right" nowrap="nowrap"><?php price($line->total_ht); ?></td>
|
||||
<td align="right" nowrap="nowrap"><?php echo price($line->total_ht); ?></td>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->statut == 0 && $user->rights->$element->creer) { ?>
|
||||
|
||||
@ -198,6 +198,10 @@ class InterfaceDemo
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
}
|
||||
elseif ($action == 'ORDER_CLONE')
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
}
|
||||
elseif ($action == 'ORDER_VALIDATE')
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user