25require_once DOL_DOCUMENT_ROOT.
'/core/triggers/dolibarrtriggers.class.php';
42 $this->
name = preg_replace(
'/^Interface/i',
'', get_class($this));
43 $this->family =
"system";
44 $this->
description =
"Triggers of this module add action for BlockedLog module (Module of unalterable logs).";
45 $this->version = self::VERSIONS[
'prod'];
46 $this->picto =
'technic';
61 if (!isModEnabled(
'blockedlog')) {
68 $listofqualifiedelement = array(
'facture',
'don',
'payment',
'payment_donation',
'subscription',
'payment_various',
'cashcontrol');
69 if (!is_object(
$object) || !property_exists(
$object,
'element') || !in_array(
$object->element, $listofqualifiedelement)) {
74 dol_syslog(
"Trigger '".$this->
name.
"' for action '".$action.
"' launched by ".__FILE__.
". id=".
$object->id);
76 require_once DOL_DOCUMENT_ROOT.
'/blockedlog/class/blockedlog.class.php';
78 $b->loadTrackedEvents();
81 if (!in_array($action, array_keys($b->trackedevents))) {
88 if ($action ===
'BILL_VALIDATE' || (($action ===
'BILL_DELETE' || $action ===
'BILL_SENTBYMAIL') &&
$object->statut != 0)
89 || $action ===
'BILL_SUPPLIER_VALIDATE' || (($action ===
'BILL_SUPPLIER_DELETE' || $action ===
'BILL_SUPPLIER_SENTBYMAIL') &&
$object->statut != 0)
90 || $action ===
'MEMBER_SUBSCRIPTION_CREATE' || $action ===
'MEMBER_SUBSCRIPTION_MODIFY' || $action ===
'MEMBER_SUBSCRIPTION_DELETE'
91 || $action ===
'DON_VALIDATE' || (($action ===
'DON_MODIFY' || $action ===
'DON_DELETE') &&
$object->statut != 0)
92 || $action ===
'CASHCONTROL_VALIDATE'
93 || (in_array(
$object->element, array(
'facture',
'supplier_invoice')) && $action ===
'DOC_DOWNLOAD' &&
$object->statut != 0)
94 || (in_array(
$object->element, array(
'facture',
'supplier_invoice')) && $action ===
'DOC_PREVIEW' &&
$object->statut != 0)
99 if (in_array($action, array(
100 'MEMBER_SUBSCRIPTION_CREATE',
'MEMBER_SUBSCRIPTION_MODIFY',
'MEMBER_SUBSCRIPTION_DELETE',
101 'DON_VALIDATE',
'DON_MODIFY',
'DON_DELETE'))) {
102 $amounts = (float)
$object->amount;
103 } elseif ($action ==
'CASHCONTROL_VALIDATE') {
105 } elseif (property_exists(
$object,
'total_ttc')) {
106 $amounts = (float)
$object->total_ttc;
115 if ($action ===
'PAYMENT_CUSTOMER_CREATE' || $action ===
'PAYMENT_SUPPLIER_CREATE' || $action ===
'DONATION_PAYMENT_CREATE'
116 || $action ===
'PAYMENT_CUSTOMER_DELETE' || $action ===
'PAYMENT_SUPPLIER_DELETE' || $action ===
'DONATION_PAYMENT_DELETE') {
119 if (!empty(
$object->amounts)) {
120 foreach (
$object->amounts as $amount) {
121 $amounts += (float) $amount;
123 } elseif (!empty(
$object->amount)) {
126 } elseif (strpos($action,
'PAYMENT') !==
false && !in_array($action, array(
'PAYMENT_ADD_TO_BANK'))) {
128 $amounts = (float)
$object->amount;
138 $result = $b->setObjectData(
$object, $action, $amounts, $user);
142 $this->error = $b->error;
143 $this->errors = $b->errors;
147 $res = $b->create($user);
150 $this->error = $b->error;
151 $this->errors = $b->errors;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage Blocked Log.
Class to stock current configuration.
Class that all triggers must inherit.
Class of triggered functions for agenda module.
__construct($db)
Constructor.
runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
Function called on Dolibarr payment or invoice event.
Class to manage translations.
Class to manage Dolibarr users.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
$conf db name
Only used if Module[ID]Name translation string is not found.