clean triggers
This commit is contained in:
parent
82db2636f0
commit
3e686e167c
@ -70,8 +70,19 @@ abstract class DolibarrTriggers
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
/**
|
||||
* @var string module is in development
|
||||
*/
|
||||
const VERSION_DEVELOPMENT = 'development';
|
||||
|
||||
/**
|
||||
* @var string module is experimental
|
||||
*/
|
||||
const VERSION_EXPERIMENTAL = 'experimental';
|
||||
|
||||
/**
|
||||
* @var string module is dolibarr
|
||||
*/
|
||||
const VERSION_DOLIBARR = 'dolibarr';
|
||||
|
||||
/**
|
||||
@ -84,8 +95,7 @@ abstract class DolibarrTriggers
|
||||
|
||||
$this->db = $db;
|
||||
|
||||
if (empty($this->name))
|
||||
{
|
||||
if (empty($this->name)) {
|
||||
$this->name = preg_replace('/^Interface/i', '', get_class($this));
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,20 +31,27 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
||||
*/
|
||||
class InterfaceLogevents extends DolibarrTriggers
|
||||
{
|
||||
/**
|
||||
* @var string Image of the trigger
|
||||
*/
|
||||
public $picto = 'technic';
|
||||
/**
|
||||
* @var DoliDB Database handler
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
public $family = 'core';
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
|
||||
public $description = "Triggers of this module allows to add security event records inside Dolibarr.";
|
||||
|
||||
/**
|
||||
* Version of the trigger
|
||||
* @var string
|
||||
*/
|
||||
public $version = self::VERSION_DOLIBARR;
|
||||
$this->name = preg_replace('/^Interface/i', '', get_class($this));
|
||||
$this->family = "core";
|
||||
$this->description = "Triggers of this module allows to add security event records inside Dolibarr.";
|
||||
// 'development', 'experimental', 'dolibarr' or version
|
||||
$this->version = self::VERSION_DOLIBARR;
|
||||
$this->picto = 'technic';
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when a Dolibarrr security audit event is done.
|
||||
@ -70,8 +77,7 @@ class InterfaceLogevents extends DolibarrTriggers
|
||||
$date = dol_now();
|
||||
|
||||
// Actions
|
||||
if ($action == 'USER_LOGIN')
|
||||
{
|
||||
if ($action == 'USER_LOGIN') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
|
||||
$langs->load("users");
|
||||
@ -81,16 +87,14 @@ class InterfaceLogevents extends DolibarrTriggers
|
||||
$desc = "(UserLogged,".$object->login.")";
|
||||
$desc .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg);
|
||||
}
|
||||
if ($action == 'USER_LOGIN_FAILED')
|
||||
{
|
||||
if ($action == 'USER_LOGIN_FAILED') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
$text = $object->trigger_mesg; // Message direct
|
||||
$desc = $object->trigger_mesg; // Message direct
|
||||
}
|
||||
if ($action == 'USER_LOGOUT')
|
||||
{
|
||||
if ($action == 'USER_LOGOUT') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
|
||||
$langs->load("users");
|
||||
@ -98,47 +102,40 @@ class InterfaceLogevents extends DolibarrTriggers
|
||||
$text = "(UserLogoff,".$object->login.")";
|
||||
$desc = "(UserLogoff,".$object->login.")";
|
||||
}
|
||||
if ($action == 'USER_CREATE')
|
||||
{
|
||||
if ($action == 'USER_CREATE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("users");
|
||||
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
$text = $langs->transnoentities("NewUserCreated", $object->login);
|
||||
$desc = $langs->transnoentities("NewUserCreated", $object->login);
|
||||
} elseif ($action == 'USER_MODIFY')
|
||||
{
|
||||
} elseif ($action == 'USER_MODIFY') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("users");
|
||||
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
$text = $langs->transnoentities("EventUserModified", $object->login);
|
||||
$desc = $langs->transnoentities("EventUserModified", $object->login);
|
||||
} elseif ($action == 'USER_NEW_PASSWORD')
|
||||
{
|
||||
} elseif ($action == 'USER_NEW_PASSWORD') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("users");
|
||||
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
$text = $langs->transnoentities("NewUserPassword", $object->login);
|
||||
$desc = $langs->transnoentities("NewUserPassword", $object->login);
|
||||
} elseif ($action == 'USER_ENABLEDISABLE')
|
||||
{
|
||||
} elseif ($action == 'USER_ENABLEDISABLE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("users");
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
if ($object->statut == 0)
|
||||
{
|
||||
if ($object->statut == 0) {
|
||||
$text = $langs->transnoentities("UserEnabled", $object->login);
|
||||
$desc = $langs->transnoentities("UserEnabled", $object->login);
|
||||
}
|
||||
if ($object->statut == 1)
|
||||
{
|
||||
if ($object->statut == 1) {
|
||||
$text = $langs->transnoentities("UserDisabled", $object->login);
|
||||
$desc = $langs->transnoentities("UserDisabled", $object->login);
|
||||
}
|
||||
} elseif ($action == 'USER_DELETE')
|
||||
{
|
||||
} elseif ($action == 'USER_DELETE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("users");
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
@ -147,22 +144,19 @@ class InterfaceLogevents extends DolibarrTriggers
|
||||
}
|
||||
|
||||
// Groupes
|
||||
elseif ($action == 'USERGROUP_CREATE')
|
||||
{
|
||||
elseif ($action == 'USERGROUP_CREATE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("users");
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
$text = $langs->transnoentities("NewGroupCreated", $object->name);
|
||||
$desc = $langs->transnoentities("NewGroupCreated", $object->name);
|
||||
} elseif ($action == 'USERGROUP_MODIFY')
|
||||
{
|
||||
} elseif ($action == 'USERGROUP_MODIFY') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("users");
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
$text = $langs->transnoentities("GroupModified", $object->name);
|
||||
$desc = $langs->transnoentities("GroupModified", $object->name);
|
||||
} elseif ($action == 'USERGROUP_DELETE')
|
||||
{
|
||||
} elseif ($action == 'USERGROUP_DELETE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("users");
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
@ -193,8 +187,7 @@ class InterfaceLogevents extends DolibarrTriggers
|
||||
$event->user_agent = $_SERVER["HTTP_USER_AGENT"];
|
||||
|
||||
$result = $event->create($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
return 1;
|
||||
} else {
|
||||
$error = "Failed to insert security event: ".$event->error;
|
||||
|
||||
@ -32,19 +32,27 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
||||
|
||||
class InterfaceWorkflowManager extends DolibarrTriggers
|
||||
{
|
||||
/**
|
||||
* @var string Image of the trigger
|
||||
*/
|
||||
public $picto = 'technic';
|
||||
/**
|
||||
* @var DoliDB Database handler
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
public $family = 'core';
|
||||
public $description = "Triggers of this module allows to manage workflows";
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
|
||||
/**
|
||||
* Version of the trigger
|
||||
* @var string
|
||||
*/
|
||||
public $version = self::VERSION_DOLIBARR;
|
||||
$this->name = preg_replace('/^Interface/i', '', get_class($this));
|
||||
$this->family = "core";
|
||||
$this->description = "Triggers of this module allows to manage workflows";
|
||||
// 'development', 'experimental', 'dolibarr' or version
|
||||
$this->version = self::VERSION_DOLIBARR;
|
||||
$this->picto = 'technic';
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when a Dolibarrr business event is done.
|
||||
@ -62,11 +70,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
||||
if (empty($conf->workflow->enabled)) return 0; // Module not active, we do nothing
|
||||
|
||||
// Proposals to order
|
||||
if ($action == 'PROPAL_CLOSE_SIGNED')
|
||||
{
|
||||
if ($action == 'PROPAL_CLOSE_SIGNED') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->commande->enabled) && !empty($conf->global->WORKFLOW_PROPAL_AUTOCREATE_ORDER))
|
||||
{
|
||||
if (!empty($conf->commande->enabled) && !empty($conf->global->WORKFLOW_PROPAL_AUTOCREATE_ORDER)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
$newobject = new Commande($this->db);
|
||||
|
||||
@ -81,11 +87,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
||||
}
|
||||
|
||||
// Order to invoice
|
||||
if ($action == 'ORDER_CLOSE')
|
||||
{
|
||||
if ($action == 'ORDER_CLOSE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->facture->enabled) && !empty($conf->global->WORKFLOW_ORDER_AUTOCREATE_INVOICE))
|
||||
{
|
||||
if (!empty($conf->facture->enabled) && !empty($conf->global->WORKFLOW_ORDER_AUTOCREATE_INVOICE)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$newobject = new Facture($this->db);
|
||||
|
||||
@ -100,24 +104,18 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
||||
}
|
||||
|
||||
// Order classify billed proposal
|
||||
if ($action == 'ORDER_CLASSIFY_BILLED')
|
||||
{
|
||||
if ($action == 'ORDER_CLASSIFY_BILLED') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->propal->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL))
|
||||
{
|
||||
if (!empty($conf->propal->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL)) {
|
||||
$object->fetchObjectLinked('', 'propal', $object->id, $object->element);
|
||||
if (!empty($object->linkedObjects))
|
||||
{
|
||||
if (!empty($object->linkedObjects)) {
|
||||
$totalonlinkedelements = 0;
|
||||
foreach ($object->linkedObjects['propal'] as $element)
|
||||
{
|
||||
foreach ($object->linkedObjects['propal'] as $element) {
|
||||
if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht;
|
||||
}
|
||||
dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of order = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
|
||||
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht))
|
||||
{
|
||||
foreach ($object->linkedObjects['propal'] as $element)
|
||||
{
|
||||
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) {
|
||||
foreach ($object->linkedObjects['propal'] as $element) {
|
||||
$ret = $element->classifyBilled($user);
|
||||
}
|
||||
}
|
||||
@ -127,27 +125,21 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
||||
}
|
||||
|
||||
// classify billed order & billed propososal
|
||||
if ($action == 'BILL_VALIDATE')
|
||||
{
|
||||
if ($action == 'BILL_VALIDATE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$ret = 0;
|
||||
|
||||
// First classify billed the order to allow the proposal classify process
|
||||
if (!empty($conf->commande->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER))
|
||||
{
|
||||
if (!empty($conf->commande->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) {
|
||||
$object->fetchObjectLinked('', 'commande', $object->id, $object->element);
|
||||
if (!empty($object->linkedObjects))
|
||||
{
|
||||
if (!empty($object->linkedObjects)) {
|
||||
$totalonlinkedelements = 0;
|
||||
foreach ($object->linkedObjects['commande'] as $element)
|
||||
{
|
||||
foreach ($object->linkedObjects['commande'] as $element) {
|
||||
if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht;
|
||||
}
|
||||
dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
|
||||
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht))
|
||||
{
|
||||
foreach ($object->linkedObjects['commande'] as $element)
|
||||
{
|
||||
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) {
|
||||
foreach ($object->linkedObjects['commande'] as $element) {
|
||||
$ret = $element->classifyBilled($user);
|
||||
}
|
||||
}
|
||||
@ -155,21 +147,16 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
||||
}
|
||||
|
||||
// Second classify billed the proposal.
|
||||
if (!empty($conf->propal->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL))
|
||||
{
|
||||
if (!empty($conf->propal->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL)) {
|
||||
$object->fetchObjectLinked('', 'propal', $object->id, $object->element);
|
||||
if (!empty($object->linkedObjects))
|
||||
{
|
||||
if (!empty($object->linkedObjects)) {
|
||||
$totalonlinkedelements = 0;
|
||||
foreach ($object->linkedObjects['propal'] as $element)
|
||||
{
|
||||
foreach ($object->linkedObjects['propal'] as $element) {
|
||||
if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht;
|
||||
}
|
||||
dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
|
||||
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht))
|
||||
{
|
||||
foreach ($object->linkedObjects['propal'] as $element)
|
||||
{
|
||||
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) {
|
||||
foreach ($object->linkedObjects['propal'] as $element) {
|
||||
$ret = $element->classifyBilled($user);
|
||||
}
|
||||
}
|
||||
@ -180,26 +167,20 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
||||
}
|
||||
|
||||
// classify billed order & billed propososal
|
||||
if ($action == 'BILL_SUPPLIER_VALIDATE')
|
||||
{
|
||||
if ($action == 'BILL_SUPPLIER_VALIDATE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
|
||||
// First classify billed the order to allow the proposal classify process
|
||||
if (!empty($conf->fournisseur->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER))
|
||||
{
|
||||
if (!empty($conf->fournisseur->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) {
|
||||
$object->fetchObjectLinked('', 'order_supplier', $object->id, $object->element);
|
||||
if (!empty($object->linkedObjects))
|
||||
{
|
||||
if (!empty($object->linkedObjects)) {
|
||||
$totalonlinkedelements = 0;
|
||||
foreach ($object->linkedObjects['order_supplier'] as $element)
|
||||
{
|
||||
foreach ($object->linkedObjects['order_supplier'] as $element) {
|
||||
if ($element->statut == CommandeFournisseur::STATUS_ACCEPTED || $element->statut == CommandeFournisseur::STATUS_ORDERSENT || $element->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY || $element->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) $totalonlinkedelements += $element->total_ht;
|
||||
}
|
||||
dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
|
||||
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht))
|
||||
{
|
||||
foreach ($object->linkedObjects['order_supplier'] as $element)
|
||||
{
|
||||
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) {
|
||||
foreach ($object->linkedObjects['order_supplier'] as $element) {
|
||||
$ret = $element->classifyBilled($user);
|
||||
}
|
||||
}
|
||||
@ -208,21 +189,16 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
||||
}
|
||||
|
||||
// Second classify billed the proposal.
|
||||
if (!empty($conf->supplier_proposal->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_SUPPLIER_PROPOSAL))
|
||||
{
|
||||
if (!empty($conf->supplier_proposal->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_SUPPLIER_PROPOSAL)) {
|
||||
$object->fetchObjectLinked('', 'supplier_proposal', $object->id, $object->element);
|
||||
if (!empty($object->linkedObjects))
|
||||
{
|
||||
if (!empty($object->linkedObjects)) {
|
||||
$totalonlinkedelements = 0;
|
||||
foreach ($object->linkedObjects['supplier_proposal'] as $element)
|
||||
{
|
||||
foreach ($object->linkedObjects['supplier_proposal'] as $element) {
|
||||
if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht;
|
||||
}
|
||||
dol_syslog("Amount of linked supplier proposals = ".$totalonlinkedelements.", of supplier invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
|
||||
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht))
|
||||
{
|
||||
foreach ($object->linkedObjects['supplier_proposal'] as $element)
|
||||
{
|
||||
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) {
|
||||
foreach ($object->linkedObjects['supplier_proposal'] as $element) {
|
||||
$ret = $element->classifyBilled($user);
|
||||
}
|
||||
}
|
||||
@ -232,25 +208,19 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
||||
}
|
||||
|
||||
// Invoice classify billed order
|
||||
if ($action == 'BILL_PAYED')
|
||||
{
|
||||
if ($action == 'BILL_PAYED') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
|
||||
if (!empty($conf->commande->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER))
|
||||
{
|
||||
if (!empty($conf->commande->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER)) {
|
||||
$object->fetchObjectLinked('', 'commande', $object->id, $object->element);
|
||||
if (!empty($object->linkedObjects))
|
||||
{
|
||||
if (!empty($object->linkedObjects)) {
|
||||
$totalonlinkedelements = 0;
|
||||
foreach ($object->linkedObjects['commande'] as $element)
|
||||
{
|
||||
foreach ($object->linkedObjects['commande'] as $element) {
|
||||
if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht;
|
||||
}
|
||||
dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
|
||||
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht))
|
||||
{
|
||||
foreach ($object->linkedObjects['commande'] as $element)
|
||||
{
|
||||
if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) {
|
||||
foreach ($object->linkedObjects['commande'] as $element) {
|
||||
$ret = $element->classifyBilled($user);
|
||||
}
|
||||
}
|
||||
@ -259,12 +229,10 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'SHIPPING_VALIDATE')
|
||||
{
|
||||
if ($action == 'SHIPPING_VALIDATE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
|
||||
if (!empty($conf->commande->enabled) && !empty($conf->expedition->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING))
|
||||
{
|
||||
if (!empty($conf->commande->enabled) && !empty($conf->expedition->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING)) {
|
||||
$qtyshipped = array();
|
||||
$qtyordred = array();
|
||||
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
@ -318,25 +286,19 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
||||
}
|
||||
}
|
||||
// classify billed reception
|
||||
if ($action == 'BILL_SUPPLIER_VALIDATE')
|
||||
{
|
||||
if ($action == 'BILL_SUPPLIER_VALIDATE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id, LOG_DEBUG);
|
||||
|
||||
if (!empty($conf->reception->enabled) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION))
|
||||
{
|
||||
if (!empty($conf->reception->enabled) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) {
|
||||
$object->fetchObjectLinked('', 'reception', $object->id, $object->element);
|
||||
if (!empty($object->linkedObjects))
|
||||
{
|
||||
if (!empty($object->linkedObjects)) {
|
||||
$totalonlinkedelements = 0;
|
||||
foreach ($object->linkedObjects['reception'] as $element)
|
||||
{
|
||||
foreach ($object->linkedObjects['reception'] as $element) {
|
||||
if ($element->statut == Reception::STATUS_VALIDATED) $totalonlinkedelements += $element->total_ht;
|
||||
}
|
||||
dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG);
|
||||
if ($totalonlinkedelements == $object->total_ht)
|
||||
{
|
||||
foreach ($object->linkedObjects['reception'] as $element)
|
||||
{
|
||||
if ($totalonlinkedelements == $object->total_ht) {
|
||||
foreach ($object->linkedObjects['reception'] as $element) {
|
||||
$ret = $element->set_billed();
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,31 +57,10 @@ class InterfaceZapierTriggers extends DolibarrTriggers
|
||||
$this->family = "technic";
|
||||
$this->description = "Zapier triggers.";
|
||||
// 'development', 'experimental', 'dolibarr' or version
|
||||
$this->version = 'development';
|
||||
$this->version = self::VERSION_DEVELOPMENT;
|
||||
$this->picto = 'zapier';
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger name
|
||||
*
|
||||
* @return string Name of trigger file
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger description
|
||||
*
|
||||
* @return string Description of trigger file
|
||||
*/
|
||||
public function getDesc()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function called when a Dolibarrr business event is done.
|
||||
* All functions "runTrigger" are triggered if file
|
||||
@ -96,7 +75,6 @@ class InterfaceZapierTriggers extends DolibarrTriggers
|
||||
*/
|
||||
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
|
||||
{
|
||||
global $db;
|
||||
if (empty($conf->zapier->enabled)) {
|
||||
// Module not active, we do nothing
|
||||
return 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user