@@ -31,41 +31,41 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | class InterfaceLogevents extends DolibarrTriggers |
| 33 | 33 | {
|
| 34 | - /** |
|
| 35 | - * @var string Image of the trigger |
|
| 36 | - */ |
|
| 37 | - public $picto = 'technic'; |
|
| 38 | - |
|
| 39 | - public $family = 'core'; |
|
| 40 | - |
|
| 41 | - public $description = "Triggers of this module allows to add security event records inside Dolibarr."; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Version of the trigger |
|
| 45 | - * @var string |
|
| 46 | - */ |
|
| 47 | - public $version = self::VERSION_DOLIBARR; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Function called when a Dolibarrr business event is done. |
|
| 51 | - * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) |
|
| 52 | - * |
|
| 53 | - * @param string $action Event action code |
|
| 54 | - * @param Object $object Object |
|
| 55 | - * @param User $user Object user |
|
| 56 | - * @param Translate $langs Object langs |
|
| 57 | - * @param conf $conf Object conf |
|
| 58 | - * @return int <0 if KO, 0 if no triggered ran, >0 if OK |
|
| 59 | - */ |
|
| 60 | - public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
|
| 34 | + /** |
|
| 35 | + * @var string Image of the trigger |
|
| 36 | + */ |
|
| 37 | + public $picto = 'technic'; |
|
| 38 | + |
|
| 39 | + public $family = 'core'; |
|
| 40 | + |
|
| 41 | + public $description = "Triggers of this module allows to add security event records inside Dolibarr."; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Version of the trigger |
|
| 45 | + * @var string |
|
| 46 | + */ |
|
| 47 | + public $version = self::VERSION_DOLIBARR; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Function called when a Dolibarrr business event is done. |
|
| 51 | + * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) |
|
| 52 | + * |
|
| 53 | + * @param string $action Event action code |
|
| 54 | + * @param Object $object Object |
|
| 55 | + * @param User $user Object user |
|
| 56 | + * @param Translate $langs Object langs |
|
| 57 | + * @param conf $conf Object conf |
|
| 58 | + * @return int <0 if KO, 0 if no triggered ran, >0 if OK |
|
| 59 | + */ |
|
| 60 | + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
|
| 61 | 61 | {
|
| 62 | - if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0; // Log events is disabled (hidden features) |
|
| 62 | + if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0; // Log events is disabled (hidden features) |
|
| 63 | 63 | |
| 64 | - $key='MAIN_LOGEVENTS_'.$action; |
|
| 65 | - //dol_syslog("xxxxxxxxxxx".$key);
|
|
| 66 | - if (empty($conf->global->$key)) return 0; // Log events not enabled for this action |
|
| 64 | + $key='MAIN_LOGEVENTS_'.$action; |
|
| 65 | + //dol_syslog("xxxxxxxxxxx".$key);
|
|
| 66 | + if (empty($conf->global->$key)) return 0; // Log events not enabled for this action |
|
| 67 | 67 | |
| 68 | - if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form) |
|
| 68 | + if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form) |
|
| 69 | 69 | |
| 70 | 70 | $date = dol_now(); |
| 71 | 71 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | // Initialisation donnees (date,duree,texte,desc) |
| 107 | 107 | $text=$langs->transnoentities("NewUserCreated",$object->login);
|
| 108 | 108 | $desc=$langs->transnoentities("NewUserCreated",$object->login);
|
| 109 | - } |
|
| 109 | + } |
|
| 110 | 110 | elseif ($action == 'USER_MODIFY') |
| 111 | 111 | {
|
| 112 | 112 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
@@ -130,16 +130,16 @@ discard block |
||
| 130 | 130 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 131 | 131 | $langs->load("users");
|
| 132 | 132 | // Initialisation donnees (date,duree,texte,desc) |
| 133 | - if ($object->statut == 0) |
|
| 134 | - {
|
|
| 135 | - $text=$langs->transnoentities("UserEnabled",$object->login);
|
|
| 136 | - $desc=$langs->transnoentities("UserEnabled",$object->login);
|
|
| 137 | - } |
|
| 138 | - if ($object->statut == 1) |
|
| 139 | - {
|
|
| 140 | - $text=$langs->transnoentities("UserDisabled",$object->login);
|
|
| 141 | - $desc=$langs->transnoentities("UserDisabled",$object->login);
|
|
| 142 | - } |
|
| 133 | + if ($object->statut == 0) |
|
| 134 | + {
|
|
| 135 | + $text=$langs->transnoentities("UserEnabled",$object->login);
|
|
| 136 | + $desc=$langs->transnoentities("UserEnabled",$object->login);
|
|
| 137 | + } |
|
| 138 | + if ($object->statut == 1) |
|
| 139 | + {
|
|
| 140 | + $text=$langs->transnoentities("UserDisabled",$object->login);
|
|
| 141 | + $desc=$langs->transnoentities("UserDisabled",$object->login);
|
|
| 142 | + } |
|
| 143 | 143 | } |
| 144 | 144 | elseif ($action == 'USER_DELETE') |
| 145 | 145 | {
|
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | $desc=$langs->transnoentities("UserDeleted",$object->login);
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - // Groupes |
|
| 153 | + // Groupes |
|
| 154 | 154 | elseif ($action == 'GROUP_CREATE') |
| 155 | 155 | {
|
| 156 | 156 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | // Initialisation donnees (date,duree,texte,desc) |
| 159 | 159 | $text=$langs->transnoentities("NewGroupCreated",$object->name);
|
| 160 | 160 | $desc=$langs->transnoentities("NewGroupCreated",$object->name);
|
| 161 | - } |
|
| 161 | + } |
|
| 162 | 162 | elseif ($action == 'GROUP_MODIFY') |
| 163 | 163 | {
|
| 164 | 164 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | // Initialisation donnees (date,duree,texte,desc) |
| 167 | 167 | $text=$langs->transnoentities("GroupModified",$object->name);
|
| 168 | 168 | $desc=$langs->transnoentities("GroupModified",$object->name);
|
| 169 | - } |
|
| 169 | + } |
|
| 170 | 170 | elseif ($action == 'GROUP_DELETE') |
| 171 | 171 | {
|
| 172 | 172 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | // Initialisation donnees (date,duree,texte,desc) |
| 175 | 175 | $text=$langs->transnoentities("GroupDeleted",$object->name);
|
| 176 | 176 | $desc=$langs->transnoentities("GroupDeleted",$object->name);
|
| 177 | - } |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - // If not found |
|
| 179 | + // If not found |
|
| 180 | 180 | /* |
| 181 | 181 | else |
| 182 | 182 | {
|
@@ -185,18 +185,18 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | */ |
| 187 | 187 | |
| 188 | - // Add more information into desc from the context property |
|
| 189 | - if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit']; |
|
| 188 | + // Add more information into desc from the context property |
|
| 189 | + if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit']; |
|
| 190 | 190 | |
| 191 | 191 | // Add entry in event table |
| 192 | - include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; |
|
| 192 | + include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; |
|
| 193 | 193 | |
| 194 | - $event=new Events($this->db); |
|
| 194 | + $event=new Events($this->db); |
|
| 195 | 195 | $event->type=$action; |
| 196 | 196 | $event->dateevent=$date; |
| 197 | 197 | $event->label=$text; |
| 198 | 198 | $event->description=$desc; |
| 199 | - $event->user_agent=$_SERVER["HTTP_USER_AGENT"]; |
|
| 199 | + $event->user_agent=$_SERVER["HTTP_USER_AGENT"]; |
|
| 200 | 200 | |
| 201 | 201 | $result=$event->create($user); |
| 202 | 202 | if ($result > 0) |
@@ -59,13 +59,13 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 61 | 61 | {
|
| 62 | - if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0; // Log events is disabled (hidden features) |
|
| 62 | + if (!empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0; // Log events is disabled (hidden features) |
|
| 63 | 63 | |
| 64 | - $key='MAIN_LOGEVENTS_'.$action; |
|
| 64 | + $key = 'MAIN_LOGEVENTS_'.$action; |
|
| 65 | 65 | //dol_syslog("xxxxxxxxxxx".$key);
|
| 66 | - if (empty($conf->global->$key)) return 0; // Log events not enabled for this action |
|
| 66 | + if (empty($conf->global->$key)) return 0; // Log events not enabled for this action |
|
| 67 | 67 | |
| 68 | - if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form) |
|
| 68 | + if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form) |
|
| 69 | 69 | |
| 70 | 70 | $date = dol_now(); |
| 71 | 71 | |
@@ -76,18 +76,18 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | $langs->load("users");
|
| 78 | 78 | // Initialisation donnees (date,duree,texte,desc) |
| 79 | - $text="(UserLogged,".$object->login.")"; |
|
| 80 | - $text.=(empty($object->trigger_mesg)?'':' - '.$object->trigger_mesg); |
|
| 81 | - $desc="(UserLogged,".$object->login.")"; |
|
| 82 | - $desc.=(empty($object->trigger_mesg)?'':' - '.$object->trigger_mesg); |
|
| 79 | + $text = "(UserLogged,".$object->login.")"; |
|
| 80 | + $text .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg); |
|
| 81 | + $desc = "(UserLogged,".$object->login.")"; |
|
| 82 | + $desc .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg); |
|
| 83 | 83 | } |
| 84 | 84 | if ($action == 'USER_LOGIN_FAILED') |
| 85 | 85 | {
|
| 86 | 86 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 87 | 87 | |
| 88 | 88 | // Initialisation donnees (date,duree,texte,desc) |
| 89 | - $text=$object->trigger_mesg; // Message direct |
|
| 90 | - $desc=$object->trigger_mesg; // Message direct |
|
| 89 | + $text = $object->trigger_mesg; // Message direct |
|
| 90 | + $desc = $object->trigger_mesg; // Message direct |
|
| 91 | 91 | } |
| 92 | 92 | if ($action == 'USER_LOGOUT') |
| 93 | 93 | {
|
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | $langs->load("users");
|
| 97 | 97 | // Initialisation donnees (date,duree,texte,desc) |
| 98 | - $text="(UserLogoff,".$object->login.")"; |
|
| 99 | - $desc="(UserLogoff,".$object->login.")"; |
|
| 98 | + $text = "(UserLogoff,".$object->login.")"; |
|
| 99 | + $desc = "(UserLogoff,".$object->login.")"; |
|
| 100 | 100 | } |
| 101 | 101 | if ($action == 'USER_CREATE') |
| 102 | 102 | {
|
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | $langs->load("users");
|
| 105 | 105 | |
| 106 | 106 | // Initialisation donnees (date,duree,texte,desc) |
| 107 | - $text=$langs->transnoentities("NewUserCreated",$object->login);
|
|
| 108 | - $desc=$langs->transnoentities("NewUserCreated",$object->login);
|
|
| 107 | + $text = $langs->transnoentities("NewUserCreated", $object->login);
|
|
| 108 | + $desc = $langs->transnoentities("NewUserCreated", $object->login);
|
|
| 109 | 109 | } |
| 110 | 110 | elseif ($action == 'USER_MODIFY') |
| 111 | 111 | {
|
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | $langs->load("users");
|
| 114 | 114 | |
| 115 | 115 | // Initialisation donnees (date,duree,texte,desc) |
| 116 | - $text=$langs->transnoentities("EventUserModified",$object->login);
|
|
| 117 | - $desc=$langs->transnoentities("EventUserModified",$object->login);
|
|
| 116 | + $text = $langs->transnoentities("EventUserModified", $object->login);
|
|
| 117 | + $desc = $langs->transnoentities("EventUserModified", $object->login);
|
|
| 118 | 118 | } |
| 119 | 119 | elseif ($action == 'USER_NEW_PASSWORD') |
| 120 | 120 | {
|
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | $langs->load("users");
|
| 123 | 123 | |
| 124 | 124 | // Initialisation donnees (date,duree,texte,desc) |
| 125 | - $text=$langs->transnoentities("NewUserPassword",$object->login);
|
|
| 126 | - $desc=$langs->transnoentities("NewUserPassword",$object->login);
|
|
| 125 | + $text = $langs->transnoentities("NewUserPassword", $object->login);
|
|
| 126 | + $desc = $langs->transnoentities("NewUserPassword", $object->login);
|
|
| 127 | 127 | } |
| 128 | 128 | elseif ($action == 'USER_ENABLEDISABLE') |
| 129 | 129 | {
|
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | // Initialisation donnees (date,duree,texte,desc) |
| 133 | 133 | if ($object->statut == 0) |
| 134 | 134 | {
|
| 135 | - $text=$langs->transnoentities("UserEnabled",$object->login);
|
|
| 136 | - $desc=$langs->transnoentities("UserEnabled",$object->login);
|
|
| 135 | + $text = $langs->transnoentities("UserEnabled", $object->login);
|
|
| 136 | + $desc = $langs->transnoentities("UserEnabled", $object->login);
|
|
| 137 | 137 | } |
| 138 | 138 | if ($object->statut == 1) |
| 139 | 139 | {
|
| 140 | - $text=$langs->transnoentities("UserDisabled",$object->login);
|
|
| 141 | - $desc=$langs->transnoentities("UserDisabled",$object->login);
|
|
| 140 | + $text = $langs->transnoentities("UserDisabled", $object->login);
|
|
| 141 | + $desc = $langs->transnoentities("UserDisabled", $object->login);
|
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | elseif ($action == 'USER_DELETE') |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 147 | 147 | $langs->load("users");
|
| 148 | 148 | // Initialisation donnees (date,duree,texte,desc) |
| 149 | - $text=$langs->transnoentities("UserDeleted",$object->login);
|
|
| 150 | - $desc=$langs->transnoentities("UserDeleted",$object->login);
|
|
| 149 | + $text = $langs->transnoentities("UserDeleted", $object->login);
|
|
| 150 | + $desc = $langs->transnoentities("UserDeleted", $object->login);
|
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // Groupes |
@@ -156,24 +156,24 @@ discard block |
||
| 156 | 156 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 157 | 157 | $langs->load("users");
|
| 158 | 158 | // Initialisation donnees (date,duree,texte,desc) |
| 159 | - $text=$langs->transnoentities("NewGroupCreated",$object->name);
|
|
| 160 | - $desc=$langs->transnoentities("NewGroupCreated",$object->name);
|
|
| 159 | + $text = $langs->transnoentities("NewGroupCreated", $object->name);
|
|
| 160 | + $desc = $langs->transnoentities("NewGroupCreated", $object->name);
|
|
| 161 | 161 | } |
| 162 | 162 | elseif ($action == 'GROUP_MODIFY') |
| 163 | 163 | {
|
| 164 | 164 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 165 | 165 | $langs->load("users");
|
| 166 | 166 | // Initialisation donnees (date,duree,texte,desc) |
| 167 | - $text=$langs->transnoentities("GroupModified",$object->name);
|
|
| 168 | - $desc=$langs->transnoentities("GroupModified",$object->name);
|
|
| 167 | + $text = $langs->transnoentities("GroupModified", $object->name);
|
|
| 168 | + $desc = $langs->transnoentities("GroupModified", $object->name);
|
|
| 169 | 169 | } |
| 170 | 170 | elseif ($action == 'GROUP_DELETE') |
| 171 | 171 | {
|
| 172 | 172 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 173 | 173 | $langs->load("users");
|
| 174 | 174 | // Initialisation donnees (date,duree,texte,desc) |
| 175 | - $text=$langs->transnoentities("GroupDeleted",$object->name);
|
|
| 176 | - $desc=$langs->transnoentities("GroupDeleted",$object->name);
|
|
| 175 | + $text = $langs->transnoentities("GroupDeleted", $object->name);
|
|
| 176 | + $desc = $langs->transnoentities("GroupDeleted", $object->name);
|
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | // If not found |
@@ -186,27 +186,27 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | |
| 188 | 188 | // Add more information into desc from the context property |
| 189 | - if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit']; |
|
| 189 | + if (!empty($desc) && !empty($object->context['audit'])) $desc .= ' - '.$object->context['audit']; |
|
| 190 | 190 | |
| 191 | 191 | // Add entry in event table |
| 192 | 192 | include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; |
| 193 | 193 | |
| 194 | - $event=new Events($this->db); |
|
| 195 | - $event->type=$action; |
|
| 196 | - $event->dateevent=$date; |
|
| 197 | - $event->label=$text; |
|
| 198 | - $event->description=$desc; |
|
| 199 | - $event->user_agent=$_SERVER["HTTP_USER_AGENT"]; |
|
| 194 | + $event = new Events($this->db); |
|
| 195 | + $event->type = $action; |
|
| 196 | + $event->dateevent = $date; |
|
| 197 | + $event->label = $text; |
|
| 198 | + $event->description = $desc; |
|
| 199 | + $event->user_agent = $_SERVER["HTTP_USER_AGENT"]; |
|
| 200 | 200 | |
| 201 | - $result=$event->create($user); |
|
| 201 | + $result = $event->create($user); |
|
| 202 | 202 | if ($result > 0) |
| 203 | 203 | {
|
| 204 | 204 | return 1; |
| 205 | 205 | } |
| 206 | 206 | else |
| 207 | 207 | {
|
| 208 | - $error ="Failed to insert security event: ".$event->error; |
|
| 209 | - $this->error=$error; |
|
| 208 | + $error = "Failed to insert security event: ".$event->error; |
|
| 209 | + $this->error = $error; |
|
| 210 | 210 | |
| 211 | 211 | dol_syslog(get_class($this).": ".$this->error, LOG_ERR); |
| 212 | 212 | return -1; |
@@ -59,13 +59,22 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 61 | 61 | {
|
| 62 | - if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0; // Log events is disabled (hidden features) |
|
| 62 | + if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) { |
|
| 63 | + return 0; |
|
| 64 | + } |
|
| 65 | + // Log events is disabled (hidden features) |
|
| 63 | 66 | |
| 64 | 67 | $key='MAIN_LOGEVENTS_'.$action; |
| 65 | 68 | //dol_syslog("xxxxxxxxxxx".$key);
|
| 66 | - if (empty($conf->global->$key)) return 0; // Log events not enabled for this action |
|
| 69 | + if (empty($conf->global->$key)) { |
|
| 70 | + return 0; |
|
| 71 | + } |
|
| 72 | + // Log events not enabled for this action |
|
| 67 | 73 | |
| 68 | - if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form) |
|
| 74 | + if (empty($conf->entity)) { |
|
| 75 | + $conf->entity = $entity; |
|
| 76 | + } |
|
| 77 | + // forcing of the entity if it's not defined (ex: in login form) |
|
| 69 | 78 | |
| 70 | 79 | $date = dol_now(); |
| 71 | 80 | |
@@ -106,8 +115,7 @@ discard block |
||
| 106 | 115 | // Initialisation donnees (date,duree,texte,desc) |
| 107 | 116 | $text=$langs->transnoentities("NewUserCreated",$object->login);
|
| 108 | 117 | $desc=$langs->transnoentities("NewUserCreated",$object->login);
|
| 109 | - } |
|
| 110 | - elseif ($action == 'USER_MODIFY') |
|
| 118 | + } elseif ($action == 'USER_MODIFY') |
|
| 111 | 119 | {
|
| 112 | 120 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 113 | 121 | $langs->load("users");
|
@@ -115,8 +123,7 @@ discard block |
||
| 115 | 123 | // Initialisation donnees (date,duree,texte,desc) |
| 116 | 124 | $text=$langs->transnoentities("EventUserModified",$object->login);
|
| 117 | 125 | $desc=$langs->transnoentities("EventUserModified",$object->login);
|
| 118 | - } |
|
| 119 | - elseif ($action == 'USER_NEW_PASSWORD') |
|
| 126 | + } elseif ($action == 'USER_NEW_PASSWORD') |
|
| 120 | 127 | {
|
| 121 | 128 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 122 | 129 | $langs->load("users");
|
@@ -124,8 +131,7 @@ discard block |
||
| 124 | 131 | // Initialisation donnees (date,duree,texte,desc) |
| 125 | 132 | $text=$langs->transnoentities("NewUserPassword",$object->login);
|
| 126 | 133 | $desc=$langs->transnoentities("NewUserPassword",$object->login);
|
| 127 | - } |
|
| 128 | - elseif ($action == 'USER_ENABLEDISABLE') |
|
| 134 | + } elseif ($action == 'USER_ENABLEDISABLE') |
|
| 129 | 135 | {
|
| 130 | 136 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 131 | 137 | $langs->load("users");
|
@@ -140,8 +146,7 @@ discard block |
||
| 140 | 146 | $text=$langs->transnoentities("UserDisabled",$object->login);
|
| 141 | 147 | $desc=$langs->transnoentities("UserDisabled",$object->login);
|
| 142 | 148 | } |
| 143 | - } |
|
| 144 | - elseif ($action == 'USER_DELETE') |
|
| 149 | + } elseif ($action == 'USER_DELETE') |
|
| 145 | 150 | {
|
| 146 | 151 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 147 | 152 | $langs->load("users");
|
@@ -158,16 +163,14 @@ discard block |
||
| 158 | 163 | // Initialisation donnees (date,duree,texte,desc) |
| 159 | 164 | $text=$langs->transnoentities("NewGroupCreated",$object->name);
|
| 160 | 165 | $desc=$langs->transnoentities("NewGroupCreated",$object->name);
|
| 161 | - } |
|
| 162 | - elseif ($action == 'GROUP_MODIFY') |
|
| 166 | + } elseif ($action == 'GROUP_MODIFY') |
|
| 163 | 167 | {
|
| 164 | 168 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 165 | 169 | $langs->load("users");
|
| 166 | 170 | // Initialisation donnees (date,duree,texte,desc) |
| 167 | 171 | $text=$langs->transnoentities("GroupModified",$object->name);
|
| 168 | 172 | $desc=$langs->transnoentities("GroupModified",$object->name);
|
| 169 | - } |
|
| 170 | - elseif ($action == 'GROUP_DELETE') |
|
| 173 | + } elseif ($action == 'GROUP_DELETE') |
|
| 171 | 174 | {
|
| 172 | 175 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 173 | 176 | $langs->load("users");
|
@@ -186,7 +189,9 @@ discard block |
||
| 186 | 189 | */ |
| 187 | 190 | |
| 188 | 191 | // Add more information into desc from the context property |
| 189 | - if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit']; |
|
| 192 | + if (! empty($desc) && ! empty($object->context['audit'])) { |
|
| 193 | + $desc.=' - '.$object->context['audit']; |
|
| 194 | + } |
|
| 190 | 195 | |
| 191 | 196 | // Add entry in event table |
| 192 | 197 | include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; |
@@ -202,8 +207,7 @@ discard block |
||
| 202 | 207 | if ($result > 0) |
| 203 | 208 | {
|
| 204 | 209 | return 1; |
| 205 | - } |
|
| 206 | - else |
|
| 210 | + } else |
|
| 207 | 211 | {
|
| 208 | 212 | $error ="Failed to insert security event: ".$event->error; |
| 209 | 213 | $this->error=$error; |
@@ -34,58 +34,58 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | class InterfaceActionsAuto extends DolibarrTriggers |
| 36 | 36 | {
|
| 37 | - public $family = 'agenda'; |
|
| 38 | - public $description = "Triggers of this module add actions in agenda according to setup made in agenda setup."; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Version of the trigger |
|
| 42 | - * @var string |
|
| 43 | - */ |
|
| 44 | - public $version = self::VERSION_DOLIBARR; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @var string Image of the trigger |
|
| 48 | - */ |
|
| 49 | - public $picto = 'action'; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Function called when a Dolibarrr business event is done. |
|
| 53 | - * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) |
|
| 54 | - * |
|
| 55 | - * Following properties may be set before calling trigger. The may be completed by this trigger to be used for writing the event into database: |
|
| 56 | - * $object->actiontypecode (translation action code: AC_OTH, ...) |
|
| 57 | - * $object->actionmsg (note, long text) |
|
| 58 | - * $object->actionmsg2 (label, short text) |
|
| 59 | - * $object->sendtoid (id of contact or array of ids) |
|
| 60 | - * $object->socid (id of thirdparty) |
|
| 61 | - * $object->fk_project |
|
| 62 | - * $object->fk_element |
|
| 63 | - * $object->elementtype |
|
| 64 | - * |
|
| 65 | - * @param string $action Event action code |
|
| 66 | - * @param Object $object Object |
|
| 67 | - * @param User $user Object user |
|
| 68 | - * @param Translate $langs Object langs |
|
| 69 | - * @param conf $conf Object conf |
|
| 70 | - * @return int <0 if KO, 0 if no triggered ran, >0 if OK |
|
| 71 | - */ |
|
| 72 | - public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
|
| 73 | - {
|
|
| 37 | + public $family = 'agenda'; |
|
| 38 | + public $description = "Triggers of this module add actions in agenda according to setup made in agenda setup."; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Version of the trigger |
|
| 42 | + * @var string |
|
| 43 | + */ |
|
| 44 | + public $version = self::VERSION_DOLIBARR; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @var string Image of the trigger |
|
| 48 | + */ |
|
| 49 | + public $picto = 'action'; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Function called when a Dolibarrr business event is done. |
|
| 53 | + * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) |
|
| 54 | + * |
|
| 55 | + * Following properties may be set before calling trigger. The may be completed by this trigger to be used for writing the event into database: |
|
| 56 | + * $object->actiontypecode (translation action code: AC_OTH, ...) |
|
| 57 | + * $object->actionmsg (note, long text) |
|
| 58 | + * $object->actionmsg2 (label, short text) |
|
| 59 | + * $object->sendtoid (id of contact or array of ids) |
|
| 60 | + * $object->socid (id of thirdparty) |
|
| 61 | + * $object->fk_project |
|
| 62 | + * $object->fk_element |
|
| 63 | + * $object->elementtype |
|
| 64 | + * |
|
| 65 | + * @param string $action Event action code |
|
| 66 | + * @param Object $object Object |
|
| 67 | + * @param User $user Object user |
|
| 68 | + * @param Translate $langs Object langs |
|
| 69 | + * @param conf $conf Object conf |
|
| 70 | + * @return int <0 if KO, 0 if no triggered ran, >0 if OK |
|
| 71 | + */ |
|
| 72 | + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
|
| 73 | + {
|
|
| 74 | 74 | if (empty($conf->agenda->enabled)) return 0; // Module not active, we do nothing |
| 75 | 75 | |
| 76 | - $key = 'MAIN_AGENDA_ACTIONAUTO_'.$action; |
|
| 76 | + $key = 'MAIN_AGENDA_ACTIONAUTO_'.$action; |
|
| 77 | 77 | |
| 78 | - // Do not log events not enabled for this action |
|
| 79 | - if (empty($conf->global->$key)) {
|
|
| 80 | - return 0; |
|
| 81 | - } |
|
| 78 | + // Do not log events not enabled for this action |
|
| 79 | + if (empty($conf->global->$key)) {
|
|
| 80 | + return 0; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - $langs->load("agenda");
|
|
| 83 | + $langs->load("agenda");
|
|
| 84 | 84 | |
| 85 | - if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO'; |
|
| 85 | + if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO'; |
|
| 86 | 86 | |
| 87 | - // Actions |
|
| 88 | - if ($action == 'COMPANY_CREATE') |
|
| 87 | + // Actions |
|
| 88 | + if ($action == 'COMPANY_CREATE') |
|
| 89 | 89 | {
|
| 90 | 90 | // Load translation files required by the page |
| 91 | 91 | $langs->loadLangs(array("agenda","other","companies"));
|
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->name);
|
| 95 | 95 | if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")";
|
| 96 | 96 | |
| 97 | - $object->sendtoid=0; |
|
| 98 | - $object->socid=$object->id; |
|
| 97 | + $object->sendtoid=0; |
|
| 98 | + $object->socid=$object->id; |
|
| 99 | 99 | } |
| 100 | 100 | elseif ($action == 'COMPANY_SENTBYMAIL') |
| 101 | 101 | {
|
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | // Parameters $object->sendtoid defined by caller |
| 108 | 108 | //$object->sendtoid=0; |
| 109 | - } |
|
| 109 | + } |
|
| 110 | 110 | elseif ($action == 'CONTRACT_VALIDATE') |
| 111 | 111 | {
|
| 112 | 112 | // Load translation files required by the page |
@@ -116,22 +116,22 @@ discard block |
||
| 116 | 116 | $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 117 | 117 | |
| 118 | 118 | $object->sendtoid=0; |
| 119 | - } |
|
| 120 | - elseif ($action == 'CONTRACT_SENTBYMAIL') |
|
| 121 | - {
|
|
| 122 | - // Load translation files required by the page |
|
| 119 | + } |
|
| 120 | + elseif ($action == 'CONTRACT_SENTBYMAIL') |
|
| 121 | + {
|
|
| 122 | + // Load translation files required by the page |
|
| 123 | 123 | $langs->loadLangs(array("agenda","other","contracts"));
|
| 124 | 124 | |
| 125 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractSentByEMail",$object->ref);
|
|
| 126 | - if (empty($object->actionmsg)) |
|
| 127 | - {
|
|
| 128 | - $object->actionmsg=$langs->transnoentities("ContractSentByEMail",$object->ref);
|
|
| 129 | - } |
|
| 125 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractSentByEMail",$object->ref);
|
|
| 126 | + if (empty($object->actionmsg)) |
|
| 127 | + {
|
|
| 128 | + $object->actionmsg=$langs->transnoentities("ContractSentByEMail",$object->ref);
|
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - // Parameters $object->sendtoid defined by caller |
|
| 132 | - //$object->sendtoid=0; |
|
| 133 | - } |
|
| 134 | - elseif ($action == 'PROPAL_VALIDATE') |
|
| 131 | + // Parameters $object->sendtoid defined by caller |
|
| 132 | + //$object->sendtoid=0; |
|
| 133 | + } |
|
| 134 | + elseif ($action == 'PROPAL_VALIDATE') |
|
| 135 | 135 | {
|
| 136 | 136 | // Load translation files required by the page |
| 137 | 137 | $langs->loadLangs(array("agenda","other","propal"));
|
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 140 | 140 | $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 141 | 141 | |
| 142 | - $object->sendtoid=0; |
|
| 143 | - } |
|
| 142 | + $object->sendtoid=0; |
|
| 143 | + } |
|
| 144 | 144 | elseif ($action == 'PROPAL_SENTBYMAIL') |
| 145 | 145 | {
|
| 146 | 146 | // Load translation files required by the page |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | // Parameters $object->sendtoid defined by caller |
| 156 | 156 | //$object->sendtoid=0; |
| 157 | - } |
|
| 158 | - elseif ($action == 'PROPAL_CLOSE_SIGNED') |
|
| 157 | + } |
|
| 158 | + elseif ($action == 'PROPAL_CLOSE_SIGNED') |
|
| 159 | 159 | {
|
| 160 | 160 | // Load translation files required by the page |
| 161 | 161 | $langs->loadLangs(array("agenda","other","propal"));
|
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
| 164 | 164 | $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
| 165 | 165 | |
| 166 | - $object->sendtoid=0; |
|
| 167 | - } |
|
| 168 | - elseif ($action == 'PROPAL_CLASSIFY_BILLED') |
|
| 166 | + $object->sendtoid=0; |
|
| 167 | + } |
|
| 168 | + elseif ($action == 'PROPAL_CLASSIFY_BILLED') |
|
| 169 | 169 | {
|
| 170 | 170 | // Load translation files required by the page |
| 171 | 171 | $langs->loadLangs(array("agenda","other","propal"));
|
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
|
| 174 | 174 | $object->actionmsg=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
|
| 175 | 175 | |
| 176 | - $object->sendtoid=0; |
|
| 177 | - } |
|
| 178 | - elseif ($action == 'PROPAL_CLOSE_REFUSED') |
|
| 176 | + $object->sendtoid=0; |
|
| 177 | + } |
|
| 178 | + elseif ($action == 'PROPAL_CLOSE_REFUSED') |
|
| 179 | 179 | {
|
| 180 | 180 | // Load translation files required by the page |
| 181 | 181 | $langs->loadLangs(array("agenda","other","propal"));
|
@@ -183,9 +183,9 @@ discard block |
||
| 183 | 183 | if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
| 184 | 184 | $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
| 185 | 185 | |
| 186 | - $object->sendtoid=0; |
|
| 187 | - } |
|
| 188 | - elseif ($action == 'ORDER_VALIDATE') |
|
| 186 | + $object->sendtoid=0; |
|
| 187 | + } |
|
| 188 | + elseif ($action == 'ORDER_VALIDATE') |
|
| 189 | 189 | {
|
| 190 | 190 | // Load translation files required by the page |
| 191 | 191 | $langs->loadLangs(array("agenda","orders"));
|
@@ -193,9 +193,9 @@ discard block |
||
| 193 | 193 | if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 194 | 194 | $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 195 | 195 | |
| 196 | - $object->sendtoid=0; |
|
| 197 | - } |
|
| 198 | - elseif ($action == 'ORDER_CLOSE') |
|
| 196 | + $object->sendtoid=0; |
|
| 197 | + } |
|
| 198 | + elseif ($action == 'ORDER_CLOSE') |
|
| 199 | 199 | {
|
| 200 | 200 | // Load translation files required by the page |
| 201 | 201 | $langs->loadLangs(array("agenda","other","orders"));
|
@@ -203,9 +203,9 @@ discard block |
||
| 203 | 203 | if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
|
| 204 | 204 | $object->actionmsg=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
|
| 205 | 205 | |
| 206 | - $object->sendtoid=0; |
|
| 207 | - } |
|
| 208 | - elseif ($action == 'ORDER_CLASSIFY_BILLED') |
|
| 206 | + $object->sendtoid=0; |
|
| 207 | + } |
|
| 208 | + elseif ($action == 'ORDER_CLASSIFY_BILLED') |
|
| 209 | 209 | {
|
| 210 | 210 | // Load translation files required by the page |
| 211 | 211 | $langs->loadLangs(array("agenda","other","orders"));
|
@@ -213,9 +213,9 @@ discard block |
||
| 213 | 213 | if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
|
| 214 | 214 | $object->actionmsg=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
|
| 215 | 215 | |
| 216 | - $object->sendtoid=0; |
|
| 217 | - } |
|
| 218 | - elseif ($action == 'ORDER_CANCEL') |
|
| 216 | + $object->sendtoid=0; |
|
| 217 | + } |
|
| 218 | + elseif ($action == 'ORDER_CANCEL') |
|
| 219 | 219 | {
|
| 220 | 220 | // Load translation files required by the page |
| 221 | 221 | $langs->loadLangs(array("agenda","other","orders"));
|
@@ -223,9 +223,9 @@ discard block |
||
| 223 | 223 | if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
|
| 224 | 224 | $object->actionmsg=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
|
| 225 | 225 | |
| 226 | - $object->sendtoid=0; |
|
| 227 | - } |
|
| 228 | - elseif ($action == 'ORDER_SENTBYMAIL') |
|
| 226 | + $object->sendtoid=0; |
|
| 227 | + } |
|
| 228 | + elseif ($action == 'ORDER_SENTBYMAIL') |
|
| 229 | 229 | {
|
| 230 | 230 | // Load translation files required by the page |
| 231 | 231 | $langs->loadLangs(array("agenda","other","orders"));
|
@@ -238,8 +238,8 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | // Parameters $object->sendtoid defined by caller |
| 240 | 240 | //$object->sendtoid=0; |
| 241 | - } |
|
| 242 | - elseif ($action == 'BILL_VALIDATE') |
|
| 241 | + } |
|
| 242 | + elseif ($action == 'BILL_VALIDATE') |
|
| 243 | 243 | {
|
| 244 | 244 | // Load translation files required by the page |
| 245 | 245 | $langs->loadLangs(array("agenda","other","bills"));
|
@@ -247,18 +247,18 @@ discard block |
||
| 247 | 247 | if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 248 | 248 | $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 249 | 249 | |
| 250 | - $object->sendtoid=0; |
|
| 251 | - } |
|
| 252 | - elseif ($action == 'BILL_UNVALIDATE') |
|
| 250 | + $object->sendtoid=0; |
|
| 251 | + } |
|
| 252 | + elseif ($action == 'BILL_UNVALIDATE') |
|
| 253 | 253 | {
|
| 254 | - // Load translation files required by the page |
|
| 254 | + // Load translation files required by the page |
|
| 255 | 255 | $langs->loadLangs(array("agenda","other","bills"));
|
| 256 | 256 | |
| 257 | 257 | if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
|
| 258 | 258 | $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
|
| 259 | 259 | |
| 260 | - $object->sendtoid=0; |
|
| 261 | - } |
|
| 260 | + $object->sendtoid=0; |
|
| 261 | + } |
|
| 262 | 262 | elseif ($action == 'BILL_SENTBYMAIL') |
| 263 | 263 | {
|
| 264 | 264 | // Load translation files required by the page |
@@ -272,8 +272,8 @@ discard block |
||
| 272 | 272 | |
| 273 | 273 | // Parameters $object->sendtoid defined by caller |
| 274 | 274 | //$object->sendtoid=0; |
| 275 | - } |
|
| 276 | - elseif ($action == 'BILL_PAYED') |
|
| 275 | + } |
|
| 276 | + elseif ($action == 'BILL_PAYED') |
|
| 277 | 277 | {
|
| 278 | 278 | // Load translation files required by the page |
| 279 | 279 | $langs->loadLangs(array("agenda","other","bills"));
|
@@ -283,8 +283,8 @@ discard block |
||
| 283 | 283 | $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
|
| 284 | 284 | |
| 285 | 285 | $object->sendtoid=0; |
| 286 | - } |
|
| 287 | - elseif ($action == 'BILL_CANCEL') |
|
| 286 | + } |
|
| 287 | + elseif ($action == 'BILL_CANCEL') |
|
| 288 | 288 | {
|
| 289 | 289 | // Load translation files required by the page |
| 290 | 290 | $langs->loadLangs(array("agenda","other","bills"));
|
@@ -293,8 +293,8 @@ discard block |
||
| 293 | 293 | $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
|
| 294 | 294 | |
| 295 | 295 | $object->sendtoid=0; |
| 296 | - } |
|
| 297 | - elseif ($action == 'FICHINTER_CREATE') |
|
| 296 | + } |
|
| 297 | + elseif ($action == 'FICHINTER_CREATE') |
|
| 298 | 298 | {
|
| 299 | 299 | // Load translation files required by the page |
| 300 | 300 | $langs->loadLangs(array("agenda","other","interventions"));
|
@@ -303,10 +303,10 @@ discard block |
||
| 303 | 303 | $object->actionmsg=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref);
|
| 304 | 304 | |
| 305 | 305 | $object->sendtoid=0; |
| 306 | - $object->fk_element=0; |
|
| 307 | - $object->elementtype=''; |
|
| 308 | - } |
|
| 309 | - elseif ($action == 'FICHINTER_VALIDATE') |
|
| 306 | + $object->fk_element=0; |
|
| 307 | + $object->elementtype=''; |
|
| 308 | + } |
|
| 309 | + elseif ($action == 'FICHINTER_VALIDATE') |
|
| 310 | 310 | {
|
| 311 | 311 | // Load translation files required by the page |
| 312 | 312 | $langs->loadLangs(array("agenda","other","interventions"));
|
@@ -315,10 +315,10 @@ discard block |
||
| 315 | 315 | $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 316 | 316 | |
| 317 | 317 | $object->sendtoid=0; |
| 318 | - $object->fk_element=0; |
|
| 319 | - $object->elementtype=''; |
|
| 320 | - } |
|
| 321 | - elseif ($action == 'FICHINTER_MODIFY') |
|
| 318 | + $object->fk_element=0; |
|
| 319 | + $object->elementtype=''; |
|
| 320 | + } |
|
| 321 | + elseif ($action == 'FICHINTER_MODIFY') |
|
| 322 | 322 | {
|
| 323 | 323 | // Load translation files required by the page |
| 324 | 324 | $langs->loadLangs(array("agenda","other","interventions"));
|
@@ -327,10 +327,10 @@ discard block |
||
| 327 | 327 | $object->actionmsg=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref);
|
| 328 | 328 | |
| 329 | 329 | $object->sendtoid=0; |
| 330 | - $object->fk_element=0; |
|
| 331 | - $object->elementtype=''; |
|
| 332 | - } |
|
| 333 | - elseif ($action == 'FICHINTER_SENTBYMAIL') |
|
| 330 | + $object->fk_element=0; |
|
| 331 | + $object->elementtype=''; |
|
| 332 | + } |
|
| 333 | + elseif ($action == 'FICHINTER_SENTBYMAIL') |
|
| 334 | 334 | {
|
| 335 | 335 | // Load translation files required by the page |
| 336 | 336 | $langs->loadLangs(array("agenda","other","interventions"));
|
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref);
|
| 339 | 339 | if (empty($object->actionmsg)) |
| 340 | 340 | {
|
| 341 | - $object->actionmsg=$langs->transnoentities("InterventionSentByEMail",$object->ref);
|
|
| 341 | + $object->actionmsg=$langs->transnoentities("InterventionSentByEMail",$object->ref);
|
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | // Parameters $object->sendtoid defined by caller |
@@ -349,18 +349,18 @@ discard block |
||
| 349 | 349 | // Load translation files required by the page |
| 350 | 350 | $langs->loadLangs(array("agenda","other","interventions"));
|
| 351 | 351 | |
| 352 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
|
|
| 353 | - $object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
|
|
| 352 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
|
|
| 353 | + $object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
|
|
| 354 | 354 | |
| 355 | 355 | $object->sendtoid=0; |
| 356 | 356 | } |
| 357 | - elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED') |
|
| 357 | + elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED') |
|
| 358 | 358 | {
|
| 359 | 359 | // Load translation files required by the page |
| 360 | 360 | $langs->loadLangs(array("agenda","other","interventions"));
|
| 361 | 361 | |
| 362 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
|
|
| 363 | - $object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
|
|
| 362 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
|
|
| 363 | + $object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
|
|
| 364 | 364 | |
| 365 | 365 | $object->sendtoid=0; |
| 366 | 366 | } |
@@ -373,24 +373,24 @@ discard block |
||
| 373 | 373 | $object->actionmsg=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref);
|
| 374 | 374 | |
| 375 | 375 | $object->sendtoid=0; |
| 376 | - $object->fk_element=0; |
|
| 377 | - $object->elementtype=''; |
|
| 378 | - } |
|
| 376 | + $object->fk_element=0; |
|
| 377 | + $object->elementtype=''; |
|
| 378 | + } |
|
| 379 | 379 | elseif ($action == 'SHIPPING_VALIDATE') |
| 380 | 380 | {
|
| 381 | 381 | // Load translation files required by the page |
| 382 | 382 | $langs->loadLangs(array("agenda","other","sendings"));
|
| 383 | 383 | |
| 384 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
|
|
| 385 | - if (empty($object->actionmsg)) |
|
| 386 | - {
|
|
| 387 | - $object->actionmsg=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
|
|
| 388 | - } |
|
| 384 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
|
|
| 385 | + if (empty($object->actionmsg)) |
|
| 386 | + {
|
|
| 387 | + $object->actionmsg=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
|
|
| 388 | + } |
|
| 389 | 389 | |
| 390 | - // Parameters $object->sendtoid defined by caller |
|
| 391 | - //$object->sendtoid=0; |
|
| 390 | + // Parameters $object->sendtoid defined by caller |
|
| 391 | + //$object->sendtoid=0; |
|
| 392 | 392 | } |
| 393 | - elseif ($action == 'SHIPPING_SENTBYMAIL') |
|
| 393 | + elseif ($action == 'SHIPPING_SENTBYMAIL') |
|
| 394 | 394 | {
|
| 395 | 395 | // Load translation files required by the page |
| 396 | 396 | $langs->loadLangs(array("agenda","other","sendings"));
|
@@ -403,22 +403,22 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | // Parameters $object->sendtoid defined by caller |
| 405 | 405 | //$object->sendtoid=0; |
| 406 | - } elseif ($action == 'RECEPTION_VALIDATE') |
|
| 406 | + } elseif ($action == 'RECEPTION_VALIDATE') |
|
| 407 | 407 | {
|
| 408 | 408 | $langs->load("agenda");
|
| 409 | 409 | $langs->load("other");
|
| 410 | - $langs->load("receptions");
|
|
| 410 | + $langs->load("receptions");
|
|
| 411 | 411 | |
| 412 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
|
|
| 413 | - if (empty($object->actionmsg)) |
|
| 414 | - {
|
|
| 415 | - $object->actionmsg=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
|
|
| 416 | - } |
|
| 412 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
|
|
| 413 | + if (empty($object->actionmsg)) |
|
| 414 | + {
|
|
| 415 | + $object->actionmsg=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
|
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | - // Parameters $object->sendtoid defined by caller |
|
| 419 | - //$object->sendtoid=0; |
|
| 418 | + // Parameters $object->sendtoid defined by caller |
|
| 419 | + //$object->sendtoid=0; |
|
| 420 | 420 | } |
| 421 | - elseif ($action == 'RECEPTION_SENTBYMAIL') |
|
| 421 | + elseif ($action == 'RECEPTION_SENTBYMAIL') |
|
| 422 | 422 | {
|
| 423 | 423 | $langs->load("agenda");
|
| 424 | 424 | $langs->load("other");
|
@@ -432,52 +432,52 @@ discard block |
||
| 432 | 432 | |
| 433 | 433 | // Parameters $object->sendtoid defined by caller |
| 434 | 434 | //$object->sendtoid=0; |
| 435 | - } |
|
| 436 | - elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE') |
|
| 437 | - {
|
|
| 438 | - // Load translation files required by the page |
|
| 435 | + } |
|
| 436 | + elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE') |
|
| 437 | + {
|
|
| 438 | + // Load translation files required by the page |
|
| 439 | 439 | $langs->loadLangs(array("agenda","other","propal"));
|
| 440 | 440 | |
| 441 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 442 | - $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 441 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 442 | + $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 443 | 443 | |
| 444 | - $object->sendtoid=0; |
|
| 445 | - } |
|
| 446 | - elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL') |
|
| 447 | - {
|
|
| 448 | - // Load translation files required by the page |
|
| 444 | + $object->sendtoid=0; |
|
| 445 | + } |
|
| 446 | + elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL') |
|
| 447 | + {
|
|
| 448 | + // Load translation files required by the page |
|
| 449 | 449 | $langs->loadLangs(array("agenda","other","propal"));
|
| 450 | 450 | |
| 451 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
|
|
| 452 | - if (empty($object->actionmsg)) |
|
| 453 | - {
|
|
| 454 | - $object->actionmsg=$langs->transnoentities("ProposalSentByEMail",$object->ref);
|
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - // Parameters $object->sendtoid defined by caller |
|
| 458 | - //$object->sendtoid=0; |
|
| 459 | - } |
|
| 460 | - elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED') |
|
| 461 | - {
|
|
| 462 | - // Load translation files required by the page |
|
| 451 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
|
|
| 452 | + if (empty($object->actionmsg)) |
|
| 453 | + {
|
|
| 454 | + $object->actionmsg=$langs->transnoentities("ProposalSentByEMail",$object->ref);
|
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + // Parameters $object->sendtoid defined by caller |
|
| 458 | + //$object->sendtoid=0; |
|
| 459 | + } |
|
| 460 | + elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED') |
|
| 461 | + {
|
|
| 462 | + // Load translation files required by the page |
|
| 463 | 463 | $langs->loadLangs(array("agenda","other","propal"));
|
| 464 | 464 | |
| 465 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
|
| 466 | - $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
|
| 465 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
|
| 466 | + $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
|
| 467 | 467 | |
| 468 | - $object->sendtoid=0; |
|
| 469 | - } |
|
| 470 | - elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED') |
|
| 471 | - {
|
|
| 472 | - // Load translation files required by the page |
|
| 468 | + $object->sendtoid=0; |
|
| 469 | + } |
|
| 470 | + elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED') |
|
| 471 | + {
|
|
| 472 | + // Load translation files required by the page |
|
| 473 | 473 | $langs->loadLangs(array("agenda","other","propal"));
|
| 474 | 474 | |
| 475 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
|
| 476 | - $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
|
| 475 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
|
| 476 | + $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
|
| 477 | 477 | |
| 478 | - $object->sendtoid=0; |
|
| 479 | - } |
|
| 480 | - elseif ($action == 'ORDER_SUPPLIER_CREATE') |
|
| 478 | + $object->sendtoid=0; |
|
| 479 | + } |
|
| 480 | + elseif ($action == 'ORDER_SUPPLIER_CREATE') |
|
| 481 | 481 | {
|
| 482 | 482 | // Load translation files required by the page |
| 483 | 483 | $langs->loadLangs(array("agenda","other","orders"));
|
@@ -486,8 +486,8 @@ discard block |
||
| 486 | 486 | $object->actionmsg=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 487 | 487 | |
| 488 | 488 | $object->sendtoid=0; |
| 489 | - } |
|
| 490 | - elseif ($action == 'ORDER_SUPPLIER_VALIDATE') |
|
| 489 | + } |
|
| 490 | + elseif ($action == 'ORDER_SUPPLIER_VALIDATE') |
|
| 491 | 491 | {
|
| 492 | 492 | // Load translation files required by the page |
| 493 | 493 | $langs->loadLangs(array("agenda","other","orders"));
|
@@ -496,28 +496,28 @@ discard block |
||
| 496 | 496 | $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 497 | 497 | |
| 498 | 498 | $object->sendtoid=0; |
| 499 | - } |
|
| 500 | - elseif ($action == 'ORDER_SUPPLIER_APPROVE') |
|
| 501 | - {
|
|
| 499 | + } |
|
| 500 | + elseif ($action == 'ORDER_SUPPLIER_APPROVE') |
|
| 501 | + {
|
|
| 502 | 502 | // Load translation files required by the page |
| 503 | 503 | $langs->loadLangs(array("agenda","other","orders"));
|
| 504 | 504 | |
| 505 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
|
|
| 506 | - $object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
|
|
| 505 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
|
|
| 506 | + $object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
|
|
| 507 | 507 | |
| 508 | - $object->sendtoid=0; |
|
| 509 | - } |
|
| 510 | - elseif ($action == 'ORDER_SUPPLIER_REFUSE') |
|
| 511 | - {
|
|
| 508 | + $object->sendtoid=0; |
|
| 509 | + } |
|
| 510 | + elseif ($action == 'ORDER_SUPPLIER_REFUSE') |
|
| 511 | + {
|
|
| 512 | 512 | // Load translation files required by the page |
| 513 | 513 | $langs->loadLangs(array("agenda","other","orders"));
|
| 514 | 514 | |
| 515 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
|
|
| 516 | - $object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
|
|
| 515 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
|
|
| 516 | + $object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
|
|
| 517 | 517 | |
| 518 | - $object->sendtoid=0; |
|
| 519 | - } |
|
| 520 | - elseif ($action == 'ORDER_SUPPLIER_SUBMIT') |
|
| 518 | + $object->sendtoid=0; |
|
| 519 | + } |
|
| 520 | + elseif ($action == 'ORDER_SUPPLIER_SUBMIT') |
|
| 521 | 521 | {
|
| 522 | 522 | // Load translation files required by the page |
| 523 | 523 | $langs->loadLangs(array("agenda","other","orders"));
|
@@ -526,8 +526,8 @@ discard block |
||
| 526 | 526 | $object->actionmsg=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 527 | 527 | |
| 528 | 528 | $object->sendtoid=0; |
| 529 | - } |
|
| 530 | - elseif ($action == 'ORDER_SUPPLIER_RECEIVE') |
|
| 529 | + } |
|
| 530 | + elseif ($action == 'ORDER_SUPPLIER_RECEIVE') |
|
| 531 | 531 | {
|
| 532 | 532 | // Load translation files required by the page |
| 533 | 533 | $langs->loadLangs(array("agenda","other","orders"));
|
@@ -536,8 +536,8 @@ discard block |
||
| 536 | 536 | $object->actionmsg=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 537 | 537 | |
| 538 | 538 | $object->sendtoid=0; |
| 539 | - } |
|
| 540 | - elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') |
|
| 539 | + } |
|
| 540 | + elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') |
|
| 541 | 541 | {
|
| 542 | 542 | // Load translation files required by the page |
| 543 | 543 | $langs->loadLangs(array("agenda","other","bills","orders"));
|
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | // Parameters $object->sendtoid defined by caller |
| 552 | 552 | //$object->sendtoid=0; |
| 553 | 553 | } |
| 554 | - elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED') |
|
| 554 | + elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED') |
|
| 555 | 555 | {
|
| 556 | 556 | // Load translation files required by the page |
| 557 | 557 | $langs->loadLangs(array("agenda","other","bills","orders"));
|
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | |
| 565 | 565 | $object->sendtoid=0; |
| 566 | 566 | } |
| 567 | - elseif ($action == 'BILL_SUPPLIER_VALIDATE') |
|
| 567 | + elseif ($action == 'BILL_SUPPLIER_VALIDATE') |
|
| 568 | 568 | {
|
| 569 | 569 | // Load translation files required by the page |
| 570 | 570 | $langs->loadLangs(array("agenda","other","bills"));
|
@@ -573,8 +573,8 @@ discard block |
||
| 573 | 573 | $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 574 | 574 | |
| 575 | 575 | $object->sendtoid=0; |
| 576 | - } |
|
| 577 | - elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') |
|
| 576 | + } |
|
| 577 | + elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') |
|
| 578 | 578 | {
|
| 579 | 579 | // Load translation files required by the page |
| 580 | 580 | $langs->loadLangs(array("agenda","other","bills"));
|
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
|
| 584 | 584 | |
| 585 | 585 | $object->sendtoid=0; |
| 586 | - } |
|
| 586 | + } |
|
| 587 | 587 | elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') |
| 588 | 588 | {
|
| 589 | 589 | // Load translation files required by the page |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | // Parameters $object->sendtoid defined by caller |
| 599 | 599 | //$object->sendtoid=0; |
| 600 | 600 | } |
| 601 | - elseif ($action == 'BILL_SUPPLIER_PAYED') |
|
| 601 | + elseif ($action == 'BILL_SUPPLIER_PAYED') |
|
| 602 | 602 | {
|
| 603 | 603 | // Load translation files required by the page |
| 604 | 604 | $langs->loadLangs(array("agenda","other","bills"));
|
@@ -606,9 +606,9 @@ discard block |
||
| 606 | 606 | if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
|
| 607 | 607 | $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
|
| 608 | 608 | |
| 609 | - $object->sendtoid=0; |
|
| 610 | - } |
|
| 611 | - elseif ($action == 'BILL_SUPPLIER_CANCELED') |
|
| 609 | + $object->sendtoid=0; |
|
| 610 | + } |
|
| 611 | + elseif ($action == 'BILL_SUPPLIER_CANCELED') |
|
| 612 | 612 | {
|
| 613 | 613 | // Load translation files required by the page |
| 614 | 614 | $langs->loadLangs(array("agenda","other","bills"));
|
@@ -616,8 +616,8 @@ discard block |
||
| 616 | 616 | if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
|
| 617 | 617 | $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
|
| 618 | 618 | |
| 619 | - $object->sendtoid=0; |
|
| 620 | - } |
|
| 619 | + $object->sendtoid=0; |
|
| 620 | + } |
|
| 621 | 621 | |
| 622 | 622 | // Members |
| 623 | 623 | elseif ($action == 'MEMBER_VALIDATE') |
@@ -630,9 +630,9 @@ discard block |
||
| 630 | 630 | $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
| 631 | 631 | $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
| 632 | 632 | |
| 633 | - $object->sendtoid=0; |
|
| 633 | + $object->sendtoid=0; |
|
| 634 | 634 | } |
| 635 | - elseif ($action == 'MEMBER_MODIFY') |
|
| 635 | + elseif ($action == 'MEMBER_MODIFY') |
|
| 636 | 636 | {
|
| 637 | 637 | // Load translation files required by the page |
| 638 | 638 | $langs->loadLangs(array("agenda","other","members"));
|
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
| 644 | 644 | |
| 645 | 645 | $object->sendtoid=0; |
| 646 | - } |
|
| 646 | + } |
|
| 647 | 647 | elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE') |
| 648 | 648 | {
|
| 649 | 649 | // Load translation files required by the page |
@@ -656,38 +656,38 @@ discard block |
||
| 656 | 656 | $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
|
| 657 | 657 | $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
|
| 658 | 658 | |
| 659 | - $object->sendtoid=0; |
|
| 660 | - if ($object->fk_soc > 0) $object->socid=$object->fk_soc; |
|
| 659 | + $object->sendtoid=0; |
|
| 660 | + if ($object->fk_soc > 0) $object->socid=$object->fk_soc; |
|
| 661 | 661 | } |
| 662 | 662 | elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY') |
| 663 | 663 | {
|
| 664 | - // Load translation files required by the page |
|
| 664 | + // Load translation files required by the page |
|
| 665 | 665 | $langs->loadLangs(array("agenda","other","members"));
|
| 666 | 666 | |
| 667 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 668 | - $object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 669 | - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 670 | - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 671 | - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
|
|
| 672 | - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
|
|
| 667 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 668 | + $object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 669 | + $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 670 | + $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 671 | + $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
|
|
| 672 | + $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
|
|
| 673 | 673 | |
| 674 | - $object->sendtoid=0; |
|
| 675 | - if ($object->fk_soc > 0) $object->socid=$object->fk_soc; |
|
| 674 | + $object->sendtoid=0; |
|
| 675 | + if ($object->fk_soc > 0) $object->socid=$object->fk_soc; |
|
| 676 | 676 | } |
| 677 | 677 | elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE') |
| 678 | 678 | {
|
| 679 | - // Load translation files required by the page |
|
| 679 | + // Load translation files required by the page |
|
| 680 | 680 | $langs->loadLangs(array("agenda","other","members"));
|
| 681 | 681 | |
| 682 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 683 | - $object->actionmsg=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 684 | - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 685 | - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 686 | - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
|
|
| 687 | - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
|
|
| 682 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 683 | + $object->actionmsg=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 684 | + $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 685 | + $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 686 | + $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
|
|
| 687 | + $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
|
|
| 688 | 688 | |
| 689 | - $object->sendtoid=0; |
|
| 690 | - if ($object->fk_soc > 0) $object->socid=$object->fk_soc; |
|
| 689 | + $object->sendtoid=0; |
|
| 690 | + if ($object->fk_soc > 0) $object->socid=$object->fk_soc; |
|
| 691 | 691 | } |
| 692 | 692 | elseif ($action == 'MEMBER_RESILIATE') |
| 693 | 693 | {
|
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
| 700 | 700 | $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
| 701 | 701 | |
| 702 | - $object->sendtoid=0; |
|
| 702 | + $object->sendtoid=0; |
|
| 703 | 703 | } |
| 704 | 704 | elseif ($action == 'MEMBER_DELETE') |
| 705 | 705 | {
|
@@ -711,7 +711,7 @@ discard block |
||
| 711 | 711 | $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
| 712 | 712 | $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
| 713 | 713 | |
| 714 | - $object->sendtoid=0; |
|
| 714 | + $object->sendtoid=0; |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | // Projects |
@@ -720,11 +720,11 @@ discard block |
||
| 720 | 720 | // Load translation files required by the page |
| 721 | 721 | $langs->loadLangs(array("agenda","other","projects"));
|
| 722 | 722 | |
| 723 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
|
|
| 724 | - $object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
|
|
| 725 | - $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
|
|
| 723 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
|
|
| 724 | + $object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
|
|
| 725 | + $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
|
|
| 726 | 726 | |
| 727 | - $object->sendtoid=0; |
|
| 727 | + $object->sendtoid=0; |
|
| 728 | 728 | } |
| 729 | 729 | elseif($action == 'PROJECT_VALIDATE') |
| 730 | 730 | {
|
@@ -749,74 +749,74 @@ discard block |
||
| 749 | 749 | $object->sendtoid=0; |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | - // Project tasks |
|
| 753 | - elseif($action == 'TASK_CREATE') |
|
| 754 | - {
|
|
| 752 | + // Project tasks |
|
| 753 | + elseif($action == 'TASK_CREATE') |
|
| 754 | + {
|
|
| 755 | 755 | // Load translation files required by the page |
| 756 | 756 | $langs->loadLangs(array("agenda","other","projects"));
|
| 757 | 757 | |
| 758 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
|
|
| 759 | - $object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
|
|
| 760 | - $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
|
|
| 758 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
|
|
| 759 | + $object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
|
|
| 760 | + $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
|
|
| 761 | 761 | |
| 762 | - $object->sendtoid=0; |
|
| 763 | - } |
|
| 762 | + $object->sendtoid=0; |
|
| 763 | + } |
|
| 764 | 764 | |
| 765 | - elseif($action == 'TASK_MODIFY') |
|
| 766 | - {
|
|
| 765 | + elseif($action == 'TASK_MODIFY') |
|
| 766 | + {
|
|
| 767 | 767 | // Load translation files required by the page |
| 768 | 768 | $langs->loadLangs(array("agenda","other","projects"));
|
| 769 | 769 | |
| 770 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref);
|
|
| 771 | - $object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr",$object->ref);
|
|
| 772 | - $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
|
|
| 770 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref);
|
|
| 771 | + $object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr",$object->ref);
|
|
| 772 | + $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
|
|
| 773 | 773 | |
| 774 | - $object->sendtoid=0; |
|
| 775 | - } |
|
| 774 | + $object->sendtoid=0; |
|
| 775 | + } |
|
| 776 | 776 | |
| 777 | - elseif($action == 'TASK_DELETE') |
|
| 778 | - {
|
|
| 777 | + elseif($action == 'TASK_DELETE') |
|
| 778 | + {
|
|
| 779 | 779 | // Load translation files required by the page |
| 780 | 780 | $langs->loadLangs(array("agenda","other","projects"));
|
| 781 | 781 | |
| 782 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
|
|
| 783 | - $object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
|
|
| 784 | - $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
|
|
| 785 | - |
|
| 786 | - $object->sendtoid=0; |
|
| 787 | - } |
|
| 788 | - // TODO Merge all previous cases into this generic one |
|
| 789 | - else // $action = TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, ... |
|
| 790 | - {
|
|
| 791 | - // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function) |
|
| 792 | - // Load translation files required by the page |
|
| 782 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
|
|
| 783 | + $object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
|
|
| 784 | + $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
|
|
| 785 | + |
|
| 786 | + $object->sendtoid=0; |
|
| 787 | + } |
|
| 788 | + // TODO Merge all previous cases into this generic one |
|
| 789 | + else // $action = TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, ... |
|
| 790 | + {
|
|
| 791 | + // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function) |
|
| 792 | + // Load translation files required by the page |
|
| 793 | 793 | $langs->loadLangs(array("agenda","other"));
|
| 794 | 794 | |
| 795 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref); |
|
| 796 | - if (empty($object->actionmsg)) $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref); |
|
| 795 | + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref); |
|
| 796 | + if (empty($object->actionmsg)) $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref); |
|
| 797 | 797 | |
| 798 | - $object->sendtoid=0; |
|
| 799 | - } |
|
| 798 | + $object->sendtoid=0; |
|
| 799 | + } |
|
| 800 | 800 | |
| 801 | - $object->actionmsg = $langs->transnoentities("Author").': '.$user->login."\n".$object->actionmsg;
|
|
| 801 | + $object->actionmsg = $langs->transnoentities("Author").': '.$user->login."\n".$object->actionmsg;
|
|
| 802 | 802 | |
| 803 | - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 803 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 804 | 804 | |
| 805 | 805 | // Add entry in event table |
| 806 | - $now=dol_now(); |
|
| 806 | + $now=dol_now(); |
|
| 807 | 807 | |
| 808 | - if (isset($_SESSION['listofnames-'.$object->trackid])) |
|
| 809 | - {
|
|
| 810 | - $attachs=$_SESSION['listofnames-'.$object->trackid]; |
|
| 811 | - if ($attachs && strpos($action,'SENTBYMAIL')) |
|
| 812 | - {
|
|
| 808 | + if (isset($_SESSION['listofnames-'.$object->trackid])) |
|
| 809 | + {
|
|
| 810 | + $attachs=$_SESSION['listofnames-'.$object->trackid]; |
|
| 811 | + if ($attachs && strpos($action,'SENTBYMAIL')) |
|
| 812 | + {
|
|
| 813 | 813 | $object->actionmsg=dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs);
|
| 814 | - } |
|
| 815 | - } |
|
| 814 | + } |
|
| 815 | + } |
|
| 816 | 816 | |
| 817 | 817 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
| 818 | 818 | require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
| 819 | - $contactforaction=new Contact($this->db); |
|
| 819 | + $contactforaction=new Contact($this->db); |
|
| 820 | 820 | $societeforaction=new Societe($this->db); |
| 821 | 821 | // Set contactforaction if there is only 1 contact. |
| 822 | 822 | if (is_array($object->sendtoid)) |
@@ -838,87 +838,87 @@ discard block |
||
| 838 | 838 | $elementtype = $object->element; |
| 839 | 839 | if ($object->element == 'subscription') |
| 840 | 840 | {
|
| 841 | - $elementid = $object->fk_adherent; |
|
| 842 | - $elementtype = 'member'; |
|
| 841 | + $elementid = $object->fk_adherent; |
|
| 842 | + $elementtype = 'member'; |
|
| 843 | 843 | } |
| 844 | 844 | //var_dump($societeforaction);var_dump($contactforaction);exit; |
| 845 | 845 | |
| 846 | - // Insertion action |
|
| 847 | - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
| 848 | - $actioncomm = new ActionComm($this->db); |
|
| 849 | - $actioncomm->type_code = $object->actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
|
|
| 850 | - $actioncomm->code = 'AC_'.$action; |
|
| 851 | - $actioncomm->label = $object->actionmsg2; |
|
| 852 | - $actioncomm->note = $object->actionmsg; // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg) |
|
| 853 | - $actioncomm->fk_project = $projectid; |
|
| 854 | - $actioncomm->datep = $now; |
|
| 855 | - $actioncomm->datef = $now; |
|
| 856 | - $actioncomm->durationp = 0; |
|
| 857 | - $actioncomm->punctual = 1; |
|
| 858 | - $actioncomm->percentage = -1; // Not applicable |
|
| 859 | - $actioncomm->societe = $societeforaction; |
|
| 860 | - $actioncomm->contact = $contactforaction; |
|
| 861 | - $actioncomm->socid = $societeforaction->id; |
|
| 862 | - $actioncomm->contactid = $contactforaction->id; |
|
| 863 | - $actioncomm->authorid = $user->id; // User saving action |
|
| 864 | - $actioncomm->userownerid = $user->id; // Owner of action |
|
| 846 | + // Insertion action |
|
| 847 | + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
| 848 | + $actioncomm = new ActionComm($this->db); |
|
| 849 | + $actioncomm->type_code = $object->actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
|
|
| 850 | + $actioncomm->code = 'AC_'.$action; |
|
| 851 | + $actioncomm->label = $object->actionmsg2; |
|
| 852 | + $actioncomm->note = $object->actionmsg; // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg) |
|
| 853 | + $actioncomm->fk_project = $projectid; |
|
| 854 | + $actioncomm->datep = $now; |
|
| 855 | + $actioncomm->datef = $now; |
|
| 856 | + $actioncomm->durationp = 0; |
|
| 857 | + $actioncomm->punctual = 1; |
|
| 858 | + $actioncomm->percentage = -1; // Not applicable |
|
| 859 | + $actioncomm->societe = $societeforaction; |
|
| 860 | + $actioncomm->contact = $contactforaction; |
|
| 861 | + $actioncomm->socid = $societeforaction->id; |
|
| 862 | + $actioncomm->contactid = $contactforaction->id; |
|
| 863 | + $actioncomm->authorid = $user->id; // User saving action |
|
| 864 | + $actioncomm->userownerid = $user->id; // Owner of action |
|
| 865 | 865 | // Fields defined when action is an email (content should be into object->actionmsg to be added into note, subject into object->actionms2 to be added into label) |
| 866 | - $actioncomm->email_msgid = $object->email_msgid; |
|
| 867 | - $actioncomm->email_from = $object->email_from; |
|
| 868 | - $actioncomm->email_sender = $object->email_sender; |
|
| 869 | - $actioncomm->email_to = $object->email_to; |
|
| 870 | - $actioncomm->email_tocc = $object->email_tocc; |
|
| 871 | - $actioncomm->email_tobcc = $object->email_tobcc; |
|
| 872 | - $actioncomm->email_subject = $object->email_subject; |
|
| 873 | - $actioncomm->errors_to = $object->errors_to; |
|
| 874 | - |
|
| 875 | - // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table |
|
| 876 | - // for such objects because there is already a dedicated field into table llx_actioncomm. |
|
| 877 | - if (! in_array($elementtype, array('societe','contact','project')))
|
|
| 878 | - {
|
|
| 879 | - $actioncomm->fk_element = $elementid; |
|
| 880 | - $actioncomm->elementtype = $elementtype; |
|
| 881 | - } |
|
| 882 | - |
|
| 883 | - if (property_exists($object,'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles)>0) {
|
|
| 884 | - $actioncomm->attachedfiles=$object->attachedfiles; |
|
| 885 | - } |
|
| 886 | - if (property_exists($object,'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid)>0) {
|
|
| 887 | - $actioncomm->userassigned=$object->sendtouserid; |
|
| 888 | - } |
|
| 889 | - |
|
| 890 | - $ret=$actioncomm->create($user); // User creating action |
|
| 891 | - |
|
| 892 | - if ($ret > 0 && $conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO) |
|
| 893 | - {
|
|
| 894 | - if (is_array($object->attachedfiles) && array_key_exists('paths',$object->attachedfiles) && count($object->attachedfiles['paths'])>0) {
|
|
| 895 | - foreach($object->attachedfiles['paths'] as $key=>$filespath) {
|
|
| 896 | - $srcfile = $filespath; |
|
| 897 | - $destdir = $conf->agenda->dir_output . '/' . $ret; |
|
| 898 | - $destfile = $destdir . '/' . $object->attachedfiles['names'][$key]; |
|
| 899 | - if (dol_mkdir($destdir) >= 0) {
|
|
| 900 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 901 | - dol_copy($srcfile, $destfile); |
|
| 902 | - } |
|
| 903 | - } |
|
| 904 | - } |
|
| 905 | - } |
|
| 906 | - |
|
| 907 | - unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. |
|
| 908 | - |
|
| 909 | - if ($ret > 0) |
|
| 910 | - {
|
|
| 911 | - $_SESSION['LAST_ACTION_CREATED'] = $ret; |
|
| 912 | - return 1; |
|
| 913 | - } |
|
| 914 | - else |
|
| 915 | - {
|
|
| 866 | + $actioncomm->email_msgid = $object->email_msgid; |
|
| 867 | + $actioncomm->email_from = $object->email_from; |
|
| 868 | + $actioncomm->email_sender = $object->email_sender; |
|
| 869 | + $actioncomm->email_to = $object->email_to; |
|
| 870 | + $actioncomm->email_tocc = $object->email_tocc; |
|
| 871 | + $actioncomm->email_tobcc = $object->email_tobcc; |
|
| 872 | + $actioncomm->email_subject = $object->email_subject; |
|
| 873 | + $actioncomm->errors_to = $object->errors_to; |
|
| 874 | + |
|
| 875 | + // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table |
|
| 876 | + // for such objects because there is already a dedicated field into table llx_actioncomm. |
|
| 877 | + if (! in_array($elementtype, array('societe','contact','project')))
|
|
| 878 | + {
|
|
| 879 | + $actioncomm->fk_element = $elementid; |
|
| 880 | + $actioncomm->elementtype = $elementtype; |
|
| 881 | + } |
|
| 882 | + |
|
| 883 | + if (property_exists($object,'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles)>0) {
|
|
| 884 | + $actioncomm->attachedfiles=$object->attachedfiles; |
|
| 885 | + } |
|
| 886 | + if (property_exists($object,'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid)>0) {
|
|
| 887 | + $actioncomm->userassigned=$object->sendtouserid; |
|
| 888 | + } |
|
| 889 | + |
|
| 890 | + $ret=$actioncomm->create($user); // User creating action |
|
| 891 | + |
|
| 892 | + if ($ret > 0 && $conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO) |
|
| 893 | + {
|
|
| 894 | + if (is_array($object->attachedfiles) && array_key_exists('paths',$object->attachedfiles) && count($object->attachedfiles['paths'])>0) {
|
|
| 895 | + foreach($object->attachedfiles['paths'] as $key=>$filespath) {
|
|
| 896 | + $srcfile = $filespath; |
|
| 897 | + $destdir = $conf->agenda->dir_output . '/' . $ret; |
|
| 898 | + $destfile = $destdir . '/' . $object->attachedfiles['names'][$key]; |
|
| 899 | + if (dol_mkdir($destdir) >= 0) {
|
|
| 900 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 901 | + dol_copy($srcfile, $destfile); |
|
| 902 | + } |
|
| 903 | + } |
|
| 904 | + } |
|
| 905 | + } |
|
| 906 | + |
|
| 907 | + unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. |
|
| 908 | + |
|
| 909 | + if ($ret > 0) |
|
| 910 | + {
|
|
| 911 | + $_SESSION['LAST_ACTION_CREATED'] = $ret; |
|
| 912 | + return 1; |
|
| 913 | + } |
|
| 914 | + else |
|
| 915 | + {
|
|
| 916 | 916 | $error ="Failed to insert event : ".$actioncomm->error." ".join(',',$actioncomm->errors);
|
| 917 | 917 | $this->error=$error; |
| 918 | 918 | $this->errors=$actioncomm->errors; |
| 919 | 919 | |
| 920 | 920 | dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR);
|
| 921 | 921 | return -1; |
| 922 | - } |
|
| 922 | + } |
|
| 923 | 923 | } |
| 924 | 924 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 73 | 73 | {
|
| 74 | - if (empty($conf->agenda->enabled)) return 0; // Module not active, we do nothing |
|
| 74 | + if (empty($conf->agenda->enabled)) return 0; // Module not active, we do nothing |
|
| 75 | 75 | |
| 76 | 76 | $key = 'MAIN_AGENDA_ACTIONAUTO_'.$action; |
| 77 | 77 | |
@@ -82,25 +82,25 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $langs->load("agenda");
|
| 84 | 84 | |
| 85 | - if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO'; |
|
| 85 | + if (empty($object->actiontypecode)) $object->actiontypecode = 'AC_OTH_AUTO'; |
|
| 86 | 86 | |
| 87 | 87 | // Actions |
| 88 | 88 | if ($action == 'COMPANY_CREATE') |
| 89 | 89 | {
|
| 90 | 90 | // Load translation files required by the page |
| 91 | - $langs->loadLangs(array("agenda","other","companies"));
|
|
| 91 | + $langs->loadLangs(array("agenda", "other", "companies"));
|
|
| 92 | 92 | |
| 93 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->name);
|
|
| 94 | - $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->name);
|
|
| 95 | - if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")";
|
|
| 93 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("NewCompanyToDolibarr", $object->name);
|
|
| 94 | + $object->actionmsg = $langs->transnoentities("NewCompanyToDolibarr", $object->name);
|
|
| 95 | + if (!empty($object->prefix)) $object->actionmsg .= " (".$object->prefix.")";
|
|
| 96 | 96 | |
| 97 | - $object->sendtoid=0; |
|
| 98 | - $object->socid=$object->id; |
|
| 97 | + $object->sendtoid = 0; |
|
| 98 | + $object->socid = $object->id; |
|
| 99 | 99 | } |
| 100 | 100 | elseif ($action == 'COMPANY_SENTBYMAIL') |
| 101 | 101 | {
|
| 102 | 102 | // Load translation files required by the page |
| 103 | - $langs->loadLangs(array("agenda","other","orders"));
|
|
| 103 | + $langs->loadLangs(array("agenda", "other", "orders"));
|
|
| 104 | 104 | |
| 105 | 105 | if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR);
|
| 106 | 106 | |
@@ -110,22 +110,22 @@ discard block |
||
| 110 | 110 | elseif ($action == 'CONTRACT_VALIDATE') |
| 111 | 111 | {
|
| 112 | 112 | // Load translation files required by the page |
| 113 | - $langs->loadLangs(array("agenda","other","contracts"));
|
|
| 113 | + $langs->loadLangs(array("agenda", "other", "contracts"));
|
|
| 114 | 114 | |
| 115 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 116 | - $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 115 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 116 | + $object->actionmsg = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 117 | 117 | |
| 118 | - $object->sendtoid=0; |
|
| 118 | + $object->sendtoid = 0; |
|
| 119 | 119 | } |
| 120 | 120 | elseif ($action == 'CONTRACT_SENTBYMAIL') |
| 121 | 121 | {
|
| 122 | 122 | // Load translation files required by the page |
| 123 | - $langs->loadLangs(array("agenda","other","contracts"));
|
|
| 123 | + $langs->loadLangs(array("agenda", "other", "contracts"));
|
|
| 124 | 124 | |
| 125 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractSentByEMail",$object->ref);
|
|
| 125 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ContractSentByEMail", $object->ref);
|
|
| 126 | 126 | if (empty($object->actionmsg)) |
| 127 | 127 | {
|
| 128 | - $object->actionmsg=$langs->transnoentities("ContractSentByEMail",$object->ref);
|
|
| 128 | + $object->actionmsg = $langs->transnoentities("ContractSentByEMail", $object->ref);
|
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // Parameters $object->sendtoid defined by caller |
@@ -134,22 +134,22 @@ discard block |
||
| 134 | 134 | elseif ($action == 'PROPAL_VALIDATE') |
| 135 | 135 | {
|
| 136 | 136 | // Load translation files required by the page |
| 137 | - $langs->loadLangs(array("agenda","other","propal"));
|
|
| 137 | + $langs->loadLangs(array("agenda", "other", "propal"));
|
|
| 138 | 138 | |
| 139 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 140 | - $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 139 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 140 | + $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 141 | 141 | |
| 142 | - $object->sendtoid=0; |
|
| 142 | + $object->sendtoid = 0; |
|
| 143 | 143 | } |
| 144 | 144 | elseif ($action == 'PROPAL_SENTBYMAIL') |
| 145 | 145 | {
|
| 146 | 146 | // Load translation files required by the page |
| 147 | - $langs->loadLangs(array("agenda","other","propal"));
|
|
| 147 | + $langs->loadLangs(array("agenda", "other", "propal"));
|
|
| 148 | 148 | |
| 149 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
|
|
| 149 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref);
|
|
| 150 | 150 | if (empty($object->actionmsg)) |
| 151 | 151 | {
|
| 152 | - $object->actionmsg=$langs->transnoentities("ProposalSentByEMail",$object->ref);
|
|
| 152 | + $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref);
|
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | // Parameters $object->sendtoid defined by caller |
@@ -158,82 +158,82 @@ discard block |
||
| 158 | 158 | elseif ($action == 'PROPAL_CLOSE_SIGNED') |
| 159 | 159 | {
|
| 160 | 160 | // Load translation files required by the page |
| 161 | - $langs->loadLangs(array("agenda","other","propal"));
|
|
| 161 | + $langs->loadLangs(array("agenda", "other", "propal"));
|
|
| 162 | 162 | |
| 163 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
|
| 164 | - $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
|
| 163 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
|
|
| 164 | + $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
|
|
| 165 | 165 | |
| 166 | - $object->sendtoid=0; |
|
| 166 | + $object->sendtoid = 0; |
|
| 167 | 167 | } |
| 168 | 168 | elseif ($action == 'PROPAL_CLASSIFY_BILLED') |
| 169 | 169 | {
|
| 170 | 170 | // Load translation files required by the page |
| 171 | - $langs->loadLangs(array("agenda","other","propal"));
|
|
| 171 | + $langs->loadLangs(array("agenda", "other", "propal"));
|
|
| 172 | 172 | |
| 173 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
|
|
| 174 | - $object->actionmsg=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
|
|
| 173 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref);
|
|
| 174 | + $object->actionmsg = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref);
|
|
| 175 | 175 | |
| 176 | - $object->sendtoid=0; |
|
| 176 | + $object->sendtoid = 0; |
|
| 177 | 177 | } |
| 178 | 178 | elseif ($action == 'PROPAL_CLOSE_REFUSED') |
| 179 | 179 | {
|
| 180 | 180 | // Load translation files required by the page |
| 181 | - $langs->loadLangs(array("agenda","other","propal"));
|
|
| 181 | + $langs->loadLangs(array("agenda", "other", "propal"));
|
|
| 182 | 182 | |
| 183 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
|
| 184 | - $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
|
| 183 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
|
|
| 184 | + $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
|
|
| 185 | 185 | |
| 186 | - $object->sendtoid=0; |
|
| 186 | + $object->sendtoid = 0; |
|
| 187 | 187 | } |
| 188 | 188 | elseif ($action == 'ORDER_VALIDATE') |
| 189 | 189 | {
|
| 190 | 190 | // Load translation files required by the page |
| 191 | - $langs->loadLangs(array("agenda","orders"));
|
|
| 191 | + $langs->loadLangs(array("agenda", "orders"));
|
|
| 192 | 192 | |
| 193 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 194 | - $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 193 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 194 | + $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 195 | 195 | |
| 196 | - $object->sendtoid=0; |
|
| 196 | + $object->sendtoid = 0; |
|
| 197 | 197 | } |
| 198 | 198 | elseif ($action == 'ORDER_CLOSE') |
| 199 | 199 | {
|
| 200 | 200 | // Load translation files required by the page |
| 201 | - $langs->loadLangs(array("agenda","other","orders"));
|
|
| 201 | + $langs->loadLangs(array("agenda", "other", "orders"));
|
|
| 202 | 202 | |
| 203 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
|
|
| 204 | - $object->actionmsg=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
|
|
| 203 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref);
|
|
| 204 | + $object->actionmsg = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref);
|
|
| 205 | 205 | |
| 206 | - $object->sendtoid=0; |
|
| 206 | + $object->sendtoid = 0; |
|
| 207 | 207 | } |
| 208 | 208 | elseif ($action == 'ORDER_CLASSIFY_BILLED') |
| 209 | 209 | {
|
| 210 | 210 | // Load translation files required by the page |
| 211 | - $langs->loadLangs(array("agenda","other","orders"));
|
|
| 211 | + $langs->loadLangs(array("agenda", "other", "orders"));
|
|
| 212 | 212 | |
| 213 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
|
|
| 214 | - $object->actionmsg=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
|
|
| 213 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderBilledInDolibarr", $object->ref);
|
|
| 214 | + $object->actionmsg = $langs->transnoentities("OrderBilledInDolibarr", $object->ref);
|
|
| 215 | 215 | |
| 216 | - $object->sendtoid=0; |
|
| 216 | + $object->sendtoid = 0; |
|
| 217 | 217 | } |
| 218 | 218 | elseif ($action == 'ORDER_CANCEL') |
| 219 | 219 | {
|
| 220 | 220 | // Load translation files required by the page |
| 221 | - $langs->loadLangs(array("agenda","other","orders"));
|
|
| 221 | + $langs->loadLangs(array("agenda", "other", "orders"));
|
|
| 222 | 222 | |
| 223 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
|
|
| 224 | - $object->actionmsg=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
|
|
| 223 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
|
|
| 224 | + $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
|
|
| 225 | 225 | |
| 226 | - $object->sendtoid=0; |
|
| 226 | + $object->sendtoid = 0; |
|
| 227 | 227 | } |
| 228 | 228 | elseif ($action == 'ORDER_SENTBYMAIL') |
| 229 | 229 | {
|
| 230 | 230 | // Load translation files required by the page |
| 231 | - $langs->loadLangs(array("agenda","other","orders"));
|
|
| 231 | + $langs->loadLangs(array("agenda", "other", "orders"));
|
|
| 232 | 232 | |
| 233 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderSentByEMail",$object->ref);
|
|
| 233 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderSentByEMail", $object->ref);
|
|
| 234 | 234 | if (empty($object->actionmsg)) |
| 235 | 235 | {
|
| 236 | - $object->actionmsg=$langs->transnoentities("OrderSentByEMail",$object->ref);
|
|
| 236 | + $object->actionmsg = $langs->transnoentities("OrderSentByEMail", $object->ref);
|
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | // Parameters $object->sendtoid defined by caller |
@@ -242,32 +242,32 @@ discard block |
||
| 242 | 242 | elseif ($action == 'BILL_VALIDATE') |
| 243 | 243 | {
|
| 244 | 244 | // Load translation files required by the page |
| 245 | - $langs->loadLangs(array("agenda","other","bills"));
|
|
| 245 | + $langs->loadLangs(array("agenda", "other", "bills"));
|
|
| 246 | 246 | |
| 247 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 248 | - $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 247 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 248 | + $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 249 | 249 | |
| 250 | - $object->sendtoid=0; |
|
| 250 | + $object->sendtoid = 0; |
|
| 251 | 251 | } |
| 252 | 252 | elseif ($action == 'BILL_UNVALIDATE') |
| 253 | 253 | {
|
| 254 | 254 | // Load translation files required by the page |
| 255 | - $langs->loadLangs(array("agenda","other","bills"));
|
|
| 255 | + $langs->loadLangs(array("agenda", "other", "bills"));
|
|
| 256 | 256 | |
| 257 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
|
|
| 258 | - $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
|
|
| 257 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
|
|
| 258 | + $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
|
|
| 259 | 259 | |
| 260 | - $object->sendtoid=0; |
|
| 260 | + $object->sendtoid = 0; |
|
| 261 | 261 | } |
| 262 | 262 | elseif ($action == 'BILL_SENTBYMAIL') |
| 263 | 263 | {
|
| 264 | 264 | // Load translation files required by the page |
| 265 | - $langs->loadLangs(array("agenda","other","bills"));
|
|
| 265 | + $langs->loadLangs(array("agenda", "other", "bills"));
|
|
| 266 | 266 | |
| 267 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceSentByEMail",$object->ref);
|
|
| 267 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceSentByEMail", $object->ref);
|
|
| 268 | 268 | if (empty($object->actionmsg)) |
| 269 | 269 | {
|
| 270 | - $object->actionmsg=$langs->transnoentities("InvoiceSentByEMail",$object->ref);
|
|
| 270 | + $object->actionmsg = $langs->transnoentities("InvoiceSentByEMail", $object->ref);
|
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | // Parameters $object->sendtoid defined by caller |
@@ -276,69 +276,69 @@ discard block |
||
| 276 | 276 | elseif ($action == 'BILL_PAYED') |
| 277 | 277 | {
|
| 278 | 278 | // Load translation files required by the page |
| 279 | - $langs->loadLangs(array("agenda","other","bills"));
|
|
| 279 | + $langs->loadLangs(array("agenda", "other", "bills"));
|
|
| 280 | 280 | |
| 281 | 281 | // Values for this action can't be defined by caller. |
| 282 | - $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
|
|
| 283 | - $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
|
|
| 282 | + $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
|
|
| 283 | + $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
|
|
| 284 | 284 | |
| 285 | - $object->sendtoid=0; |
|
| 285 | + $object->sendtoid = 0; |
|
| 286 | 286 | } |
| 287 | 287 | elseif ($action == 'BILL_CANCEL') |
| 288 | 288 | {
|
| 289 | 289 | // Load translation files required by the page |
| 290 | - $langs->loadLangs(array("agenda","other","bills"));
|
|
| 290 | + $langs->loadLangs(array("agenda", "other", "bills"));
|
|
| 291 | 291 | |
| 292 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
|
|
| 293 | - $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
|
|
| 292 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
|
|
| 293 | + $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
|
|
| 294 | 294 | |
| 295 | - $object->sendtoid=0; |
|
| 295 | + $object->sendtoid = 0; |
|
| 296 | 296 | } |
| 297 | 297 | elseif ($action == 'FICHINTER_CREATE') |
| 298 | 298 | {
|
| 299 | 299 | // Load translation files required by the page |
| 300 | - $langs->loadLangs(array("agenda","other","interventions"));
|
|
| 300 | + $langs->loadLangs(array("agenda", "other", "interventions"));
|
|
| 301 | 301 | |
| 302 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref);
|
|
| 303 | - $object->actionmsg=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref);
|
|
| 302 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref);
|
|
| 303 | + $object->actionmsg = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref);
|
|
| 304 | 304 | |
| 305 | - $object->sendtoid=0; |
|
| 306 | - $object->fk_element=0; |
|
| 307 | - $object->elementtype=''; |
|
| 305 | + $object->sendtoid = 0; |
|
| 306 | + $object->fk_element = 0; |
|
| 307 | + $object->elementtype = ''; |
|
| 308 | 308 | } |
| 309 | 309 | elseif ($action == 'FICHINTER_VALIDATE') |
| 310 | 310 | {
|
| 311 | 311 | // Load translation files required by the page |
| 312 | - $langs->loadLangs(array("agenda","other","interventions"));
|
|
| 312 | + $langs->loadLangs(array("agenda", "other", "interventions"));
|
|
| 313 | 313 | |
| 314 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 315 | - $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 314 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 315 | + $object->actionmsg = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 316 | 316 | |
| 317 | - $object->sendtoid=0; |
|
| 318 | - $object->fk_element=0; |
|
| 319 | - $object->elementtype=''; |
|
| 317 | + $object->sendtoid = 0; |
|
| 318 | + $object->fk_element = 0; |
|
| 319 | + $object->elementtype = ''; |
|
| 320 | 320 | } |
| 321 | 321 | elseif ($action == 'FICHINTER_MODIFY') |
| 322 | 322 | {
|
| 323 | 323 | // Load translation files required by the page |
| 324 | - $langs->loadLangs(array("agenda","other","interventions"));
|
|
| 324 | + $langs->loadLangs(array("agenda", "other", "interventions"));
|
|
| 325 | 325 | |
| 326 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref);
|
|
| 327 | - $object->actionmsg=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref);
|
|
| 326 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref);
|
|
| 327 | + $object->actionmsg = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref);
|
|
| 328 | 328 | |
| 329 | - $object->sendtoid=0; |
|
| 330 | - $object->fk_element=0; |
|
| 331 | - $object->elementtype=''; |
|
| 329 | + $object->sendtoid = 0; |
|
| 330 | + $object->fk_element = 0; |
|
| 331 | + $object->elementtype = ''; |
|
| 332 | 332 | } |
| 333 | 333 | elseif ($action == 'FICHINTER_SENTBYMAIL') |
| 334 | 334 | {
|
| 335 | 335 | // Load translation files required by the page |
| 336 | - $langs->loadLangs(array("agenda","other","interventions"));
|
|
| 336 | + $langs->loadLangs(array("agenda", "other", "interventions"));
|
|
| 337 | 337 | |
| 338 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref);
|
|
| 338 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionSentByEMail", $object->ref);
|
|
| 339 | 339 | if (empty($object->actionmsg)) |
| 340 | 340 | {
|
| 341 | - $object->actionmsg=$langs->transnoentities("InterventionSentByEMail",$object->ref);
|
|
| 341 | + $object->actionmsg = $langs->transnoentities("InterventionSentByEMail", $object->ref);
|
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | // Parameters $object->sendtoid defined by caller |
@@ -347,44 +347,44 @@ discard block |
||
| 347 | 347 | elseif ($action == 'FICHINTER_CLASSIFY_BILLED') |
| 348 | 348 | {
|
| 349 | 349 | // Load translation files required by the page |
| 350 | - $langs->loadLangs(array("agenda","other","interventions"));
|
|
| 350 | + $langs->loadLangs(array("agenda", "other", "interventions"));
|
|
| 351 | 351 | |
| 352 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
|
|
| 353 | - $object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
|
|
| 352 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref);
|
|
| 353 | + $object->actionmsg = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref);
|
|
| 354 | 354 | |
| 355 | - $object->sendtoid=0; |
|
| 355 | + $object->sendtoid = 0; |
|
| 356 | 356 | } |
| 357 | 357 | elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED') |
| 358 | 358 | {
|
| 359 | 359 | // Load translation files required by the page |
| 360 | - $langs->loadLangs(array("agenda","other","interventions"));
|
|
| 360 | + $langs->loadLangs(array("agenda", "other", "interventions"));
|
|
| 361 | 361 | |
| 362 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
|
|
| 363 | - $object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
|
|
| 362 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref);
|
|
| 363 | + $object->actionmsg = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref);
|
|
| 364 | 364 | |
| 365 | - $object->sendtoid=0; |
|
| 365 | + $object->sendtoid = 0; |
|
| 366 | 366 | } |
| 367 | 367 | elseif ($action == 'FICHINTER_DELETE') |
| 368 | 368 | {
|
| 369 | 369 | // Load translation files required by the page |
| 370 | - $langs->loadLangs(array("agenda","other","interventions"));
|
|
| 370 | + $langs->loadLangs(array("agenda", "other", "interventions"));
|
|
| 371 | 371 | |
| 372 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref);
|
|
| 373 | - $object->actionmsg=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref);
|
|
| 372 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref);
|
|
| 373 | + $object->actionmsg = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref);
|
|
| 374 | 374 | |
| 375 | - $object->sendtoid=0; |
|
| 376 | - $object->fk_element=0; |
|
| 377 | - $object->elementtype=''; |
|
| 375 | + $object->sendtoid = 0; |
|
| 376 | + $object->fk_element = 0; |
|
| 377 | + $object->elementtype = ''; |
|
| 378 | 378 | } |
| 379 | 379 | elseif ($action == 'SHIPPING_VALIDATE') |
| 380 | 380 | {
|
| 381 | 381 | // Load translation files required by the page |
| 382 | - $langs->loadLangs(array("agenda","other","sendings"));
|
|
| 382 | + $langs->loadLangs(array("agenda", "other", "sendings"));
|
|
| 383 | 383 | |
| 384 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
|
|
| 384 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref));
|
|
| 385 | 385 | if (empty($object->actionmsg)) |
| 386 | 386 | {
|
| 387 | - $object->actionmsg=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
|
|
| 387 | + $object->actionmsg = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref));
|
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | // Parameters $object->sendtoid defined by caller |
@@ -393,12 +393,12 @@ discard block |
||
| 393 | 393 | elseif ($action == 'SHIPPING_SENTBYMAIL') |
| 394 | 394 | {
|
| 395 | 395 | // Load translation files required by the page |
| 396 | - $langs->loadLangs(array("agenda","other","sendings"));
|
|
| 396 | + $langs->loadLangs(array("agenda", "other", "sendings"));
|
|
| 397 | 397 | |
| 398 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail",$object->ref);
|
|
| 398 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ShippingSentByEMail", $object->ref);
|
|
| 399 | 399 | if (empty($object->actionmsg)) |
| 400 | 400 | {
|
| 401 | - $object->actionmsg=$langs->transnoentities("ShippingSentByEMail",$object->ref);
|
|
| 401 | + $object->actionmsg = $langs->transnoentities("ShippingSentByEMail", $object->ref);
|
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | // Parameters $object->sendtoid defined by caller |
@@ -409,10 +409,10 @@ discard block |
||
| 409 | 409 | $langs->load("other");
|
| 410 | 410 | $langs->load("receptions");
|
| 411 | 411 | |
| 412 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
|
|
| 412 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref));
|
|
| 413 | 413 | if (empty($object->actionmsg)) |
| 414 | 414 | {
|
| 415 | - $object->actionmsg=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
|
|
| 415 | + $object->actionmsg = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref));
|
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | // Parameters $object->sendtoid defined by caller |
@@ -424,10 +424,10 @@ discard block |
||
| 424 | 424 | $langs->load("other");
|
| 425 | 425 | $langs->load("receptions");
|
| 426 | 426 | |
| 427 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionSentByEMail",$object->ref);
|
|
| 427 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ReceptionSentByEMail", $object->ref);
|
|
| 428 | 428 | if (empty($object->actionmsg)) |
| 429 | 429 | {
|
| 430 | - $object->actionmsg=$langs->transnoentities("ReceptionSentByEMail",$object->ref);
|
|
| 430 | + $object->actionmsg = $langs->transnoentities("ReceptionSentByEMail", $object->ref);
|
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | // Parameters $object->sendtoid defined by caller |
@@ -436,22 +436,22 @@ discard block |
||
| 436 | 436 | elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE') |
| 437 | 437 | {
|
| 438 | 438 | // Load translation files required by the page |
| 439 | - $langs->loadLangs(array("agenda","other","propal"));
|
|
| 439 | + $langs->loadLangs(array("agenda", "other", "propal"));
|
|
| 440 | 440 | |
| 441 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 442 | - $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 441 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 442 | + $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 443 | 443 | |
| 444 | - $object->sendtoid=0; |
|
| 444 | + $object->sendtoid = 0; |
|
| 445 | 445 | } |
| 446 | 446 | elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL') |
| 447 | 447 | {
|
| 448 | 448 | // Load translation files required by the page |
| 449 | - $langs->loadLangs(array("agenda","other","propal"));
|
|
| 449 | + $langs->loadLangs(array("agenda", "other", "propal"));
|
|
| 450 | 450 | |
| 451 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
|
|
| 451 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref);
|
|
| 452 | 452 | if (empty($object->actionmsg)) |
| 453 | 453 | {
|
| 454 | - $object->actionmsg=$langs->transnoentities("ProposalSentByEMail",$object->ref);
|
|
| 454 | + $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref);
|
|
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | // Parameters $object->sendtoid defined by caller |
@@ -460,92 +460,92 @@ discard block |
||
| 460 | 460 | elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED') |
| 461 | 461 | {
|
| 462 | 462 | // Load translation files required by the page |
| 463 | - $langs->loadLangs(array("agenda","other","propal"));
|
|
| 463 | + $langs->loadLangs(array("agenda", "other", "propal"));
|
|
| 464 | 464 | |
| 465 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
|
| 466 | - $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
|
| 465 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
|
|
| 466 | + $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
|
|
| 467 | 467 | |
| 468 | - $object->sendtoid=0; |
|
| 468 | + $object->sendtoid = 0; |
|
| 469 | 469 | } |
| 470 | 470 | elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED') |
| 471 | 471 | {
|
| 472 | 472 | // Load translation files required by the page |
| 473 | - $langs->loadLangs(array("agenda","other","propal"));
|
|
| 473 | + $langs->loadLangs(array("agenda", "other", "propal"));
|
|
| 474 | 474 | |
| 475 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
|
| 476 | - $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
|
| 475 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
|
|
| 476 | + $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
|
|
| 477 | 477 | |
| 478 | - $object->sendtoid=0; |
|
| 478 | + $object->sendtoid = 0; |
|
| 479 | 479 | } |
| 480 | 480 | elseif ($action == 'ORDER_SUPPLIER_CREATE') |
| 481 | 481 | {
|
| 482 | 482 | // Load translation files required by the page |
| 483 | - $langs->loadLangs(array("agenda","other","orders"));
|
|
| 483 | + $langs->loadLangs(array("agenda", "other", "orders"));
|
|
| 484 | 484 | |
| 485 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 486 | - $object->actionmsg=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 485 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 486 | + $object->actionmsg = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 487 | 487 | |
| 488 | - $object->sendtoid=0; |
|
| 488 | + $object->sendtoid = 0; |
|
| 489 | 489 | } |
| 490 | 490 | elseif ($action == 'ORDER_SUPPLIER_VALIDATE') |
| 491 | 491 | {
|
| 492 | 492 | // Load translation files required by the page |
| 493 | - $langs->loadLangs(array("agenda","other","orders"));
|
|
| 493 | + $langs->loadLangs(array("agenda", "other", "orders"));
|
|
| 494 | 494 | |
| 495 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 496 | - $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 495 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 496 | + $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 497 | 497 | |
| 498 | - $object->sendtoid=0; |
|
| 498 | + $object->sendtoid = 0; |
|
| 499 | 499 | } |
| 500 | 500 | elseif ($action == 'ORDER_SUPPLIER_APPROVE') |
| 501 | 501 | {
|
| 502 | 502 | // Load translation files required by the page |
| 503 | - $langs->loadLangs(array("agenda","other","orders"));
|
|
| 503 | + $langs->loadLangs(array("agenda", "other", "orders"));
|
|
| 504 | 504 | |
| 505 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
|
|
| 506 | - $object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
|
|
| 505 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref);
|
|
| 506 | + $object->actionmsg = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref);
|
|
| 507 | 507 | |
| 508 | - $object->sendtoid=0; |
|
| 508 | + $object->sendtoid = 0; |
|
| 509 | 509 | } |
| 510 | 510 | elseif ($action == 'ORDER_SUPPLIER_REFUSE') |
| 511 | 511 | {
|
| 512 | 512 | // Load translation files required by the page |
| 513 | - $langs->loadLangs(array("agenda","other","orders"));
|
|
| 513 | + $langs->loadLangs(array("agenda", "other", "orders"));
|
|
| 514 | 514 | |
| 515 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
|
|
| 516 | - $object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
|
|
| 515 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref);
|
|
| 516 | + $object->actionmsg = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref);
|
|
| 517 | 517 | |
| 518 | - $object->sendtoid=0; |
|
| 518 | + $object->sendtoid = 0; |
|
| 519 | 519 | } |
| 520 | 520 | elseif ($action == 'ORDER_SUPPLIER_SUBMIT') |
| 521 | 521 | {
|
| 522 | 522 | // Load translation files required by the page |
| 523 | - $langs->loadLangs(array("agenda","other","orders"));
|
|
| 523 | + $langs->loadLangs(array("agenda", "other", "orders"));
|
|
| 524 | 524 | |
| 525 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 526 | - $object->actionmsg=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 525 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 526 | + $object->actionmsg = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 527 | 527 | |
| 528 | - $object->sendtoid=0; |
|
| 528 | + $object->sendtoid = 0; |
|
| 529 | 529 | } |
| 530 | 530 | elseif ($action == 'ORDER_SUPPLIER_RECEIVE') |
| 531 | 531 | {
|
| 532 | 532 | // Load translation files required by the page |
| 533 | - $langs->loadLangs(array("agenda","other","orders"));
|
|
| 533 | + $langs->loadLangs(array("agenda", "other", "orders"));
|
|
| 534 | 534 | |
| 535 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 536 | - $object->actionmsg=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 535 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 536 | + $object->actionmsg = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 537 | 537 | |
| 538 | - $object->sendtoid=0; |
|
| 538 | + $object->sendtoid = 0; |
|
| 539 | 539 | } |
| 540 | 540 | elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') |
| 541 | 541 | {
|
| 542 | 542 | // Load translation files required by the page |
| 543 | - $langs->loadLangs(array("agenda","other","bills","orders"));
|
|
| 543 | + $langs->loadLangs(array("agenda", "other", "bills", "orders"));
|
|
| 544 | 544 | |
| 545 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref);
|
|
| 545 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref);
|
|
| 546 | 546 | if (empty($object->actionmsg)) |
| 547 | 547 | {
|
| 548 | - $object->actionmsg=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref);
|
|
| 548 | + $object->actionmsg = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref);
|
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | // Parameters $object->sendtoid defined by caller |
@@ -554,45 +554,45 @@ discard block |
||
| 554 | 554 | elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED') |
| 555 | 555 | {
|
| 556 | 556 | // Load translation files required by the page |
| 557 | - $langs->loadLangs(array("agenda","other","bills","orders"));
|
|
| 557 | + $langs->loadLangs(array("agenda", "other", "bills", "orders"));
|
|
| 558 | 558 | |
| 559 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderClassifiedBilled",$object->ref);
|
|
| 559 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref);
|
|
| 560 | 560 | if (empty($object->actionmsg)) |
| 561 | 561 | {
|
| 562 | - $object->actionmsg=$langs->transnoentities("SupplierOrderClassifiedBilled",$object->ref);
|
|
| 562 | + $object->actionmsg = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref);
|
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - $object->sendtoid=0; |
|
| 565 | + $object->sendtoid = 0; |
|
| 566 | 566 | } |
| 567 | 567 | elseif ($action == 'BILL_SUPPLIER_VALIDATE') |
| 568 | 568 | {
|
| 569 | 569 | // Load translation files required by the page |
| 570 | - $langs->loadLangs(array("agenda","other","bills"));
|
|
| 570 | + $langs->loadLangs(array("agenda", "other", "bills"));
|
|
| 571 | 571 | |
| 572 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 573 | - $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 572 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 573 | + $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
|
|
| 574 | 574 | |
| 575 | - $object->sendtoid=0; |
|
| 575 | + $object->sendtoid = 0; |
|
| 576 | 576 | } |
| 577 | 577 | elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') |
| 578 | 578 | {
|
| 579 | 579 | // Load translation files required by the page |
| 580 | - $langs->loadLangs(array("agenda","other","bills"));
|
|
| 580 | + $langs->loadLangs(array("agenda", "other", "bills"));
|
|
| 581 | 581 | |
| 582 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
|
|
| 583 | - $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
|
|
| 582 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
|
|
| 583 | + $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
|
|
| 584 | 584 | |
| 585 | - $object->sendtoid=0; |
|
| 585 | + $object->sendtoid = 0; |
|
| 586 | 586 | } |
| 587 | 587 | elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') |
| 588 | 588 | {
|
| 589 | 589 | // Load translation files required by the page |
| 590 | - $langs->loadLangs(array("agenda","other","bills","orders"));
|
|
| 590 | + $langs->loadLangs(array("agenda", "other", "bills", "orders"));
|
|
| 591 | 591 | |
| 592 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref);
|
|
| 592 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref);
|
|
| 593 | 593 | if (empty($object->actionmsg)) |
| 594 | 594 | {
|
| 595 | - $object->actionmsg=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref);
|
|
| 595 | + $object->actionmsg = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref);
|
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | // Parameters $object->sendtoid defined by caller |
@@ -601,201 +601,201 @@ discard block |
||
| 601 | 601 | elseif ($action == 'BILL_SUPPLIER_PAYED') |
| 602 | 602 | {
|
| 603 | 603 | // Load translation files required by the page |
| 604 | - $langs->loadLangs(array("agenda","other","bills"));
|
|
| 604 | + $langs->loadLangs(array("agenda", "other", "bills"));
|
|
| 605 | 605 | |
| 606 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
|
|
| 607 | - $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
|
|
| 606 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
|
|
| 607 | + $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
|
|
| 608 | 608 | |
| 609 | - $object->sendtoid=0; |
|
| 609 | + $object->sendtoid = 0; |
|
| 610 | 610 | } |
| 611 | 611 | elseif ($action == 'BILL_SUPPLIER_CANCELED') |
| 612 | 612 | {
|
| 613 | 613 | // Load translation files required by the page |
| 614 | - $langs->loadLangs(array("agenda","other","bills"));
|
|
| 614 | + $langs->loadLangs(array("agenda", "other", "bills"));
|
|
| 615 | 615 | |
| 616 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
|
|
| 617 | - $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
|
|
| 616 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
|
|
| 617 | + $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
|
|
| 618 | 618 | |
| 619 | - $object->sendtoid=0; |
|
| 619 | + $object->sendtoid = 0; |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | // Members |
| 623 | 623 | elseif ($action == 'MEMBER_VALIDATE') |
| 624 | 624 | {
|
| 625 | 625 | // Load translation files required by the page |
| 626 | - $langs->loadLangs(array("agenda","other","members"));
|
|
| 626 | + $langs->loadLangs(array("agenda", "other", "members"));
|
|
| 627 | 627 | |
| 628 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",$object->getFullName($langs));
|
|
| 629 | - $object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr",$object->getFullName($langs));
|
|
| 630 | - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 631 | - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 628 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs));
|
|
| 629 | + $object->actionmsg = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs));
|
|
| 630 | + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 631 | + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 632 | 632 | |
| 633 | - $object->sendtoid=0; |
|
| 633 | + $object->sendtoid = 0; |
|
| 634 | 634 | } |
| 635 | 635 | elseif ($action == 'MEMBER_MODIFY') |
| 636 | 636 | {
|
| 637 | 637 | // Load translation files required by the page |
| 638 | - $langs->loadLangs(array("agenda","other","members"));
|
|
| 638 | + $langs->loadLangs(array("agenda", "other", "members"));
|
|
| 639 | 639 | |
| 640 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberModifiedInDolibarr",$object->getFullName($langs));
|
|
| 641 | - $object->actionmsg=$langs->transnoentities("MemberModifiedInDolibarr",$object->getFullName($langs));
|
|
| 642 | - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 643 | - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 640 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs));
|
|
| 641 | + $object->actionmsg = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs));
|
|
| 642 | + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 643 | + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 644 | 644 | |
| 645 | - $object->sendtoid=0; |
|
| 645 | + $object->sendtoid = 0; |
|
| 646 | 646 | } |
| 647 | 647 | elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE') |
| 648 | 648 | {
|
| 649 | 649 | // Load translation files required by the page |
| 650 | - $langs->loadLangs(array("agenda","other","members"));
|
|
| 650 | + $langs->loadLangs(array("agenda", "other", "members"));
|
|
| 651 | 651 | |
| 652 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 653 | - $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 654 | - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 655 | - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 656 | - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
|
|
| 657 | - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
|
|
| 652 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref, $object->getFullName($langs));
|
|
| 653 | + $object->actionmsg = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref, $object->getFullName($langs));
|
|
| 654 | + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 655 | + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 656 | + $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
|
|
| 657 | + $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day');
|
|
| 658 | 658 | |
| 659 | - $object->sendtoid=0; |
|
| 660 | - if ($object->fk_soc > 0) $object->socid=$object->fk_soc; |
|
| 659 | + $object->sendtoid = 0; |
|
| 660 | + if ($object->fk_soc > 0) $object->socid = $object->fk_soc; |
|
| 661 | 661 | } |
| 662 | 662 | elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY') |
| 663 | 663 | {
|
| 664 | 664 | // Load translation files required by the page |
| 665 | - $langs->loadLangs(array("agenda","other","members"));
|
|
| 665 | + $langs->loadLangs(array("agenda", "other", "members"));
|
|
| 666 | 666 | |
| 667 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 668 | - $object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 669 | - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 670 | - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 671 | - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
|
|
| 672 | - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
|
|
| 667 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->ref, $object->getFullName($langs));
|
|
| 668 | + $object->actionmsg = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->ref, $object->getFullName($langs));
|
|
| 669 | + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 670 | + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 671 | + $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
|
|
| 672 | + $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day');
|
|
| 673 | 673 | |
| 674 | - $object->sendtoid=0; |
|
| 675 | - if ($object->fk_soc > 0) $object->socid=$object->fk_soc; |
|
| 674 | + $object->sendtoid = 0; |
|
| 675 | + if ($object->fk_soc > 0) $object->socid = $object->fk_soc; |
|
| 676 | 676 | } |
| 677 | 677 | elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE') |
| 678 | 678 | {
|
| 679 | 679 | // Load translation files required by the page |
| 680 | - $langs->loadLangs(array("agenda","other","members"));
|
|
| 680 | + $langs->loadLangs(array("agenda", "other", "members"));
|
|
| 681 | 681 | |
| 682 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 683 | - $object->actionmsg=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 684 | - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 685 | - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 686 | - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
|
|
| 687 | - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
|
|
| 682 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs));
|
|
| 683 | + $object->actionmsg = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs));
|
|
| 684 | + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 685 | + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 686 | + $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
|
|
| 687 | + $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day');
|
|
| 688 | 688 | |
| 689 | - $object->sendtoid=0; |
|
| 690 | - if ($object->fk_soc > 0) $object->socid=$object->fk_soc; |
|
| 689 | + $object->sendtoid = 0; |
|
| 690 | + if ($object->fk_soc > 0) $object->socid = $object->fk_soc; |
|
| 691 | 691 | } |
| 692 | 692 | elseif ($action == 'MEMBER_RESILIATE') |
| 693 | 693 | {
|
| 694 | 694 | // Load translation files required by the page |
| 695 | - $langs->loadLangs(array("agenda","other","members"));
|
|
| 695 | + $langs->loadLangs(array("agenda", "other", "members"));
|
|
| 696 | 696 | |
| 697 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr",$object->getFullName($langs));
|
|
| 698 | - $object->actionmsg=$langs->transnoentities("MemberResiliatedInDolibarr",$object->getFullName($langs));
|
|
| 699 | - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 700 | - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 697 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs));
|
|
| 698 | + $object->actionmsg = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs));
|
|
| 699 | + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 700 | + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 701 | 701 | |
| 702 | - $object->sendtoid=0; |
|
| 702 | + $object->sendtoid = 0; |
|
| 703 | 703 | } |
| 704 | 704 | elseif ($action == 'MEMBER_DELETE') |
| 705 | 705 | {
|
| 706 | 706 | // Load translation files required by the page |
| 707 | - $langs->loadLangs(array("agenda","other","members"));
|
|
| 707 | + $langs->loadLangs(array("agenda", "other", "members"));
|
|
| 708 | 708 | |
| 709 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr",$object->getFullName($langs));
|
|
| 710 | - $object->actionmsg=$langs->transnoentities("MemberDeletedInDolibarr",$object->getFullName($langs));
|
|
| 711 | - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 712 | - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 709 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs));
|
|
| 710 | + $object->actionmsg = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs));
|
|
| 711 | + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
|
| 712 | + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
|
|
| 713 | 713 | |
| 714 | - $object->sendtoid=0; |
|
| 714 | + $object->sendtoid = 0; |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | // Projects |
| 718 | 718 | elseif ($action == 'PROJECT_CREATE') |
| 719 | 719 | {
|
| 720 | 720 | // Load translation files required by the page |
| 721 | - $langs->loadLangs(array("agenda","other","projects"));
|
|
| 721 | + $langs->loadLangs(array("agenda", "other", "projects"));
|
|
| 722 | 722 | |
| 723 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
|
|
| 724 | - $object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
|
|
| 725 | - $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
|
|
| 723 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref);
|
|
| 724 | + $object->actionmsg = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref);
|
|
| 725 | + $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref;
|
|
| 726 | 726 | |
| 727 | - $object->sendtoid=0; |
|
| 727 | + $object->sendtoid = 0; |
|
| 728 | 728 | } |
| 729 | - elseif($action == 'PROJECT_VALIDATE') |
|
| 729 | + elseif ($action == 'PROJECT_VALIDATE') |
|
| 730 | 730 | {
|
| 731 | 731 | // Load translation files required by the page |
| 732 | - $langs->loadLangs(array("agenda","other","projects"));
|
|
| 732 | + $langs->loadLangs(array("agenda", "other", "projects"));
|
|
| 733 | 733 | |
| 734 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref);
|
|
| 735 | - $object->actionmsg=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref);
|
|
| 736 | - $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
|
|
| 734 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref);
|
|
| 735 | + $object->actionmsg = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref);
|
|
| 736 | + $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref;
|
|
| 737 | 737 | |
| 738 | - $object->sendtoid=0; |
|
| 738 | + $object->sendtoid = 0; |
|
| 739 | 739 | } |
| 740 | - elseif($action == 'PROJECT_MODIFY') |
|
| 740 | + elseif ($action == 'PROJECT_MODIFY') |
|
| 741 | 741 | {
|
| 742 | 742 | // Load translation files required by the page |
| 743 | - $langs->loadLangs(array("agenda","other","projects"));
|
|
| 743 | + $langs->loadLangs(array("agenda", "other", "projects"));
|
|
| 744 | 744 | |
| 745 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref);
|
|
| 746 | - $object->actionmsg=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref);
|
|
| 747 | - $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
|
|
| 745 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref);
|
|
| 746 | + $object->actionmsg = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref);
|
|
| 747 | + $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
|
|
| 748 | 748 | |
| 749 | - $object->sendtoid=0; |
|
| 749 | + $object->sendtoid = 0; |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | // Project tasks |
| 753 | - elseif($action == 'TASK_CREATE') |
|
| 753 | + elseif ($action == 'TASK_CREATE') |
|
| 754 | 754 | {
|
| 755 | 755 | // Load translation files required by the page |
| 756 | - $langs->loadLangs(array("agenda","other","projects"));
|
|
| 756 | + $langs->loadLangs(array("agenda", "other", "projects"));
|
|
| 757 | 757 | |
| 758 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
|
|
| 759 | - $object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
|
|
| 760 | - $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
|
|
| 758 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref);
|
|
| 759 | + $object->actionmsg = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref);
|
|
| 760 | + $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
|
|
| 761 | 761 | |
| 762 | - $object->sendtoid=0; |
|
| 762 | + $object->sendtoid = 0; |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | - elseif($action == 'TASK_MODIFY') |
|
| 765 | + elseif ($action == 'TASK_MODIFY') |
|
| 766 | 766 | {
|
| 767 | 767 | // Load translation files required by the page |
| 768 | - $langs->loadLangs(array("agenda","other","projects"));
|
|
| 768 | + $langs->loadLangs(array("agenda", "other", "projects"));
|
|
| 769 | 769 | |
| 770 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref);
|
|
| 771 | - $object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr",$object->ref);
|
|
| 772 | - $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
|
|
| 770 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TaskModifiedInDolibarr", $object->ref);
|
|
| 771 | + $object->actionmsg = $langs->transnoentities("TaskModifieddInDolibarr", $object->ref);
|
|
| 772 | + $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
|
|
| 773 | 773 | |
| 774 | - $object->sendtoid=0; |
|
| 774 | + $object->sendtoid = 0; |
|
| 775 | 775 | } |
| 776 | 776 | |
| 777 | - elseif($action == 'TASK_DELETE') |
|
| 777 | + elseif ($action == 'TASK_DELETE') |
|
| 778 | 778 | {
|
| 779 | 779 | // Load translation files required by the page |
| 780 | - $langs->loadLangs(array("agenda","other","projects"));
|
|
| 780 | + $langs->loadLangs(array("agenda", "other", "projects"));
|
|
| 781 | 781 | |
| 782 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
|
|
| 783 | - $object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
|
|
| 784 | - $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
|
|
| 782 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref);
|
|
| 783 | + $object->actionmsg = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref);
|
|
| 784 | + $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
|
|
| 785 | 785 | |
| 786 | - $object->sendtoid=0; |
|
| 786 | + $object->sendtoid = 0; |
|
| 787 | 787 | } |
| 788 | 788 | // TODO Merge all previous cases into this generic one |
| 789 | 789 | else // $action = TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, ... |
| 790 | 790 | {
|
| 791 | 791 | // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function) |
| 792 | 792 | // Load translation files required by the page |
| 793 | - $langs->loadLangs(array("agenda","other"));
|
|
| 793 | + $langs->loadLangs(array("agenda", "other"));
|
|
| 794 | 794 | |
| 795 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref); |
|
| 796 | - if (empty($object->actionmsg)) $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref); |
|
| 795 | + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities($action."InDolibarr", $object->ref); |
|
| 796 | + if (empty($object->actionmsg)) $object->actionmsg = $langs->transnoentities($action."InDolibarr", $object->ref); |
|
| 797 | 797 | |
| 798 | - $object->sendtoid=0; |
|
| 798 | + $object->sendtoid = 0; |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | $object->actionmsg = $langs->transnoentities("Author").': '.$user->login."\n".$object->actionmsg;
|
@@ -803,21 +803,21 @@ discard block |
||
| 803 | 803 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 804 | 804 | |
| 805 | 805 | // Add entry in event table |
| 806 | - $now=dol_now(); |
|
| 806 | + $now = dol_now(); |
|
| 807 | 807 | |
| 808 | 808 | if (isset($_SESSION['listofnames-'.$object->trackid])) |
| 809 | 809 | {
|
| 810 | - $attachs=$_SESSION['listofnames-'.$object->trackid]; |
|
| 811 | - if ($attachs && strpos($action,'SENTBYMAIL')) |
|
| 810 | + $attachs = $_SESSION['listofnames-'.$object->trackid]; |
|
| 811 | + if ($attachs && strpos($action, 'SENTBYMAIL')) |
|
| 812 | 812 | {
|
| 813 | - $object->actionmsg=dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs);
|
|
| 813 | + $object->actionmsg = dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs);
|
|
| 814 | 814 | } |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
| 818 | 818 | require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
| 819 | - $contactforaction=new Contact($this->db); |
|
| 820 | - $societeforaction=new Societe($this->db); |
|
| 819 | + $contactforaction = new Contact($this->db); |
|
| 820 | + $societeforaction = new Societe($this->db); |
|
| 821 | 821 | // Set contactforaction if there is only 1 contact. |
| 822 | 822 | if (is_array($object->sendtoid)) |
| 823 | 823 | {
|
@@ -831,7 +831,7 @@ discard block |
||
| 831 | 831 | if ($object->socid > 0) $societeforaction->fetch($object->socid); |
| 832 | 832 | elseif ($object->fk_soc > 0) $societeforaction->fetch($object->fk_soc); |
| 833 | 833 | |
| 834 | - $projectid = isset($object->fk_project)?$object->fk_project:0; |
|
| 834 | + $projectid = isset($object->fk_project) ? $object->fk_project : 0; |
|
| 835 | 835 | if ($object->element == 'project') $projectid = $object->id; |
| 836 | 836 | |
| 837 | 837 | $elementid = $object->id; |
@@ -846,22 +846,22 @@ discard block |
||
| 846 | 846 | // Insertion action |
| 847 | 847 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
| 848 | 848 | $actioncomm = new ActionComm($this->db); |
| 849 | - $actioncomm->type_code = $object->actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
|
|
| 849 | + $actioncomm->type_code = $object->actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
|
|
| 850 | 850 | $actioncomm->code = 'AC_'.$action; |
| 851 | 851 | $actioncomm->label = $object->actionmsg2; |
| 852 | - $actioncomm->note = $object->actionmsg; // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg) |
|
| 852 | + $actioncomm->note = $object->actionmsg; // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg) |
|
| 853 | 853 | $actioncomm->fk_project = $projectid; |
| 854 | 854 | $actioncomm->datep = $now; |
| 855 | 855 | $actioncomm->datef = $now; |
| 856 | 856 | $actioncomm->durationp = 0; |
| 857 | 857 | $actioncomm->punctual = 1; |
| 858 | - $actioncomm->percentage = -1; // Not applicable |
|
| 858 | + $actioncomm->percentage = -1; // Not applicable |
|
| 859 | 859 | $actioncomm->societe = $societeforaction; |
| 860 | 860 | $actioncomm->contact = $contactforaction; |
| 861 | 861 | $actioncomm->socid = $societeforaction->id; |
| 862 | 862 | $actioncomm->contactid = $contactforaction->id; |
| 863 | - $actioncomm->authorid = $user->id; // User saving action |
|
| 864 | - $actioncomm->userownerid = $user->id; // Owner of action |
|
| 863 | + $actioncomm->authorid = $user->id; // User saving action |
|
| 864 | + $actioncomm->userownerid = $user->id; // Owner of action |
|
| 865 | 865 | // Fields defined when action is an email (content should be into object->actionmsg to be added into note, subject into object->actionms2 to be added into label) |
| 866 | 866 | $actioncomm->email_msgid = $object->email_msgid; |
| 867 | 867 | $actioncomm->email_from = $object->email_from; |
@@ -874,28 +874,28 @@ discard block |
||
| 874 | 874 | |
| 875 | 875 | // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table |
| 876 | 876 | // for such objects because there is already a dedicated field into table llx_actioncomm. |
| 877 | - if (! in_array($elementtype, array('societe','contact','project')))
|
|
| 877 | + if (!in_array($elementtype, array('societe', 'contact', 'project')))
|
|
| 878 | 878 | {
|
| 879 | 879 | $actioncomm->fk_element = $elementid; |
| 880 | 880 | $actioncomm->elementtype = $elementtype; |
| 881 | 881 | } |
| 882 | 882 | |
| 883 | - if (property_exists($object,'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles)>0) {
|
|
| 884 | - $actioncomm->attachedfiles=$object->attachedfiles; |
|
| 883 | + if (property_exists($object, 'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles) > 0) {
|
|
| 884 | + $actioncomm->attachedfiles = $object->attachedfiles; |
|
| 885 | 885 | } |
| 886 | - if (property_exists($object,'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid)>0) {
|
|
| 887 | - $actioncomm->userassigned=$object->sendtouserid; |
|
| 886 | + if (property_exists($object, 'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid) > 0) {
|
|
| 887 | + $actioncomm->userassigned = $object->sendtouserid; |
|
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - $ret=$actioncomm->create($user); // User creating action |
|
| 890 | + $ret = $actioncomm->create($user); // User creating action |
|
| 891 | 891 | |
| 892 | 892 | if ($ret > 0 && $conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO) |
| 893 | 893 | {
|
| 894 | - if (is_array($object->attachedfiles) && array_key_exists('paths',$object->attachedfiles) && count($object->attachedfiles['paths'])>0) {
|
|
| 895 | - foreach($object->attachedfiles['paths'] as $key=>$filespath) {
|
|
| 894 | + if (is_array($object->attachedfiles) && array_key_exists('paths', $object->attachedfiles) && count($object->attachedfiles['paths']) > 0) {
|
|
| 895 | + foreach ($object->attachedfiles['paths'] as $key=>$filespath) {
|
|
| 896 | 896 | $srcfile = $filespath; |
| 897 | - $destdir = $conf->agenda->dir_output . '/' . $ret; |
|
| 898 | - $destfile = $destdir . '/' . $object->attachedfiles['names'][$key]; |
|
| 897 | + $destdir = $conf->agenda->dir_output.'/'.$ret; |
|
| 898 | + $destfile = $destdir.'/'.$object->attachedfiles['names'][$key]; |
|
| 899 | 899 | if (dol_mkdir($destdir) >= 0) {
|
| 900 | 900 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 901 | 901 | dol_copy($srcfile, $destfile); |
@@ -904,7 +904,7 @@ discard block |
||
| 904 | 904 | } |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | - unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. |
|
| 907 | + unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. |
|
| 908 | 908 | |
| 909 | 909 | if ($ret > 0) |
| 910 | 910 | {
|
@@ -913,9 +913,9 @@ discard block |
||
| 913 | 913 | } |
| 914 | 914 | else |
| 915 | 915 | {
|
| 916 | - $error ="Failed to insert event : ".$actioncomm->error." ".join(',',$actioncomm->errors);
|
|
| 917 | - $this->error=$error; |
|
| 918 | - $this->errors=$actioncomm->errors; |
|
| 916 | + $error = "Failed to insert event : ".$actioncomm->error." ".join(',', $actioncomm->errors);
|
|
| 917 | + $this->error = $error; |
|
| 918 | + $this->errors = $actioncomm->errors; |
|
| 919 | 919 | |
| 920 | 920 | dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR);
|
| 921 | 921 | return -1; |
@@ -71,7 +71,10 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 73 | 73 | {
|
| 74 | - if (empty($conf->agenda->enabled)) return 0; // Module not active, we do nothing |
|
| 74 | + if (empty($conf->agenda->enabled)) { |
|
| 75 | + return 0; |
|
| 76 | + } |
|
| 77 | + // Module not active, we do nothing |
|
| 75 | 78 | |
| 76 | 79 | $key = 'MAIN_AGENDA_ACTIONAUTO_'.$action; |
| 77 | 80 | |
@@ -82,7 +85,9 @@ discard block |
||
| 82 | 85 | |
| 83 | 86 | $langs->load("agenda");
|
| 84 | 87 | |
| 85 | - if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO'; |
|
| 88 | + if (empty($object->actiontypecode)) { |
|
| 89 | + $object->actiontypecode='AC_OTH_AUTO'; |
|
| 90 | + } |
|
| 86 | 91 | |
| 87 | 92 | // Actions |
| 88 | 93 | if ($action == 'COMPANY_CREATE') |
@@ -90,39 +95,46 @@ discard block |
||
| 90 | 95 | // Load translation files required by the page |
| 91 | 96 | $langs->loadLangs(array("agenda","other","companies"));
|
| 92 | 97 | |
| 93 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->name);
|
|
| 98 | + if (empty($object->actionmsg2)) { |
|
| 99 | + $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->name); |
|
| 100 | + } |
|
| 94 | 101 | $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->name);
|
| 95 | - if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")";
|
|
| 102 | + if (! empty($object->prefix)) { |
|
| 103 | + $object->actionmsg.=" (".$object->prefix.")"; |
|
| 104 | + } |
|
| 96 | 105 | |
| 97 | 106 | $object->sendtoid=0; |
| 98 | 107 | $object->socid=$object->id; |
| 99 | - } |
|
| 100 | - elseif ($action == 'COMPANY_SENTBYMAIL') |
|
| 108 | + } elseif ($action == 'COMPANY_SENTBYMAIL') |
|
| 101 | 109 | {
|
| 102 | 110 | // Load translation files required by the page |
| 103 | 111 | $langs->loadLangs(array("agenda","other","orders"));
|
| 104 | 112 | |
| 105 | - if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR);
|
|
| 113 | + if (empty($object->actionmsg2)) { |
|
| 114 | + dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR); |
|
| 115 | + } |
|
| 106 | 116 | |
| 107 | 117 | // Parameters $object->sendtoid defined by caller |
| 108 | 118 | //$object->sendtoid=0; |
| 109 | - } |
|
| 110 | - elseif ($action == 'CONTRACT_VALIDATE') |
|
| 119 | + } elseif ($action == 'CONTRACT_VALIDATE') |
|
| 111 | 120 | {
|
| 112 | 121 | // Load translation files required by the page |
| 113 | 122 | $langs->loadLangs(array("agenda","other","contracts"));
|
| 114 | 123 | |
| 115 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 124 | + if (empty($object->actionmsg2)) { |
|
| 125 | + $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); |
|
| 126 | + } |
|
| 116 | 127 | $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 117 | 128 | |
| 118 | 129 | $object->sendtoid=0; |
| 119 | - } |
|
| 120 | - elseif ($action == 'CONTRACT_SENTBYMAIL') |
|
| 130 | + } elseif ($action == 'CONTRACT_SENTBYMAIL') |
|
| 121 | 131 | {
|
| 122 | 132 | // Load translation files required by the page |
| 123 | 133 | $langs->loadLangs(array("agenda","other","contracts"));
|
| 124 | 134 | |
| 125 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractSentByEMail",$object->ref);
|
|
| 135 | + if (empty($object->actionmsg2)) { |
|
| 136 | + $object->actionmsg2=$langs->transnoentities("ContractSentByEMail",$object->ref); |
|
| 137 | + } |
|
| 126 | 138 | if (empty($object->actionmsg)) |
| 127 | 139 | {
|
| 128 | 140 | $object->actionmsg=$langs->transnoentities("ContractSentByEMail",$object->ref);
|
@@ -130,23 +142,25 @@ discard block |
||
| 130 | 142 | |
| 131 | 143 | // Parameters $object->sendtoid defined by caller |
| 132 | 144 | //$object->sendtoid=0; |
| 133 | - } |
|
| 134 | - elseif ($action == 'PROPAL_VALIDATE') |
|
| 145 | + } elseif ($action == 'PROPAL_VALIDATE') |
|
| 135 | 146 | {
|
| 136 | 147 | // Load translation files required by the page |
| 137 | 148 | $langs->loadLangs(array("agenda","other","propal"));
|
| 138 | 149 | |
| 139 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 150 | + if (empty($object->actionmsg2)) { |
|
| 151 | + $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); |
|
| 152 | + } |
|
| 140 | 153 | $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 141 | 154 | |
| 142 | 155 | $object->sendtoid=0; |
| 143 | - } |
|
| 144 | - elseif ($action == 'PROPAL_SENTBYMAIL') |
|
| 156 | + } elseif ($action == 'PROPAL_SENTBYMAIL') |
|
| 145 | 157 | {
|
| 146 | 158 | // Load translation files required by the page |
| 147 | 159 | $langs->loadLangs(array("agenda","other","propal"));
|
| 148 | 160 | |
| 149 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
|
|
| 161 | + if (empty($object->actionmsg2)) { |
|
| 162 | + $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref); |
|
| 163 | + } |
|
| 150 | 164 | if (empty($object->actionmsg)) |
| 151 | 165 | {
|
| 152 | 166 | $object->actionmsg=$langs->transnoentities("ProposalSentByEMail",$object->ref);
|
@@ -154,83 +168,91 @@ discard block |
||
| 154 | 168 | |
| 155 | 169 | // Parameters $object->sendtoid defined by caller |
| 156 | 170 | //$object->sendtoid=0; |
| 157 | - } |
|
| 158 | - elseif ($action == 'PROPAL_CLOSE_SIGNED') |
|
| 171 | + } elseif ($action == 'PROPAL_CLOSE_SIGNED') |
|
| 159 | 172 | {
|
| 160 | 173 | // Load translation files required by the page |
| 161 | 174 | $langs->loadLangs(array("agenda","other","propal"));
|
| 162 | 175 | |
| 163 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
|
| 176 | + if (empty($object->actionmsg2)) { |
|
| 177 | + $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref); |
|
| 178 | + } |
|
| 164 | 179 | $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
| 165 | 180 | |
| 166 | 181 | $object->sendtoid=0; |
| 167 | - } |
|
| 168 | - elseif ($action == 'PROPAL_CLASSIFY_BILLED') |
|
| 182 | + } elseif ($action == 'PROPAL_CLASSIFY_BILLED') |
|
| 169 | 183 | {
|
| 170 | 184 | // Load translation files required by the page |
| 171 | 185 | $langs->loadLangs(array("agenda","other","propal"));
|
| 172 | 186 | |
| 173 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
|
|
| 187 | + if (empty($object->actionmsg2)) { |
|
| 188 | + $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref); |
|
| 189 | + } |
|
| 174 | 190 | $object->actionmsg=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
|
| 175 | 191 | |
| 176 | 192 | $object->sendtoid=0; |
| 177 | - } |
|
| 178 | - elseif ($action == 'PROPAL_CLOSE_REFUSED') |
|
| 193 | + } elseif ($action == 'PROPAL_CLOSE_REFUSED') |
|
| 179 | 194 | {
|
| 180 | 195 | // Load translation files required by the page |
| 181 | 196 | $langs->loadLangs(array("agenda","other","propal"));
|
| 182 | 197 | |
| 183 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
|
| 198 | + if (empty($object->actionmsg2)) { |
|
| 199 | + $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref); |
|
| 200 | + } |
|
| 184 | 201 | $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
| 185 | 202 | |
| 186 | 203 | $object->sendtoid=0; |
| 187 | - } |
|
| 188 | - elseif ($action == 'ORDER_VALIDATE') |
|
| 204 | + } elseif ($action == 'ORDER_VALIDATE') |
|
| 189 | 205 | {
|
| 190 | 206 | // Load translation files required by the page |
| 191 | 207 | $langs->loadLangs(array("agenda","orders"));
|
| 192 | 208 | |
| 193 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 209 | + if (empty($object->actionmsg2)) { |
|
| 210 | + $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); |
|
| 211 | + } |
|
| 194 | 212 | $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 195 | 213 | |
| 196 | 214 | $object->sendtoid=0; |
| 197 | - } |
|
| 198 | - elseif ($action == 'ORDER_CLOSE') |
|
| 215 | + } elseif ($action == 'ORDER_CLOSE') |
|
| 199 | 216 | {
|
| 200 | 217 | // Load translation files required by the page |
| 201 | 218 | $langs->loadLangs(array("agenda","other","orders"));
|
| 202 | 219 | |
| 203 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
|
|
| 220 | + if (empty($object->actionmsg2)) { |
|
| 221 | + $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref); |
|
| 222 | + } |
|
| 204 | 223 | $object->actionmsg=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
|
| 205 | 224 | |
| 206 | 225 | $object->sendtoid=0; |
| 207 | - } |
|
| 208 | - elseif ($action == 'ORDER_CLASSIFY_BILLED') |
|
| 226 | + } elseif ($action == 'ORDER_CLASSIFY_BILLED') |
|
| 209 | 227 | {
|
| 210 | 228 | // Load translation files required by the page |
| 211 | 229 | $langs->loadLangs(array("agenda","other","orders"));
|
| 212 | 230 | |
| 213 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
|
|
| 231 | + if (empty($object->actionmsg2)) { |
|
| 232 | + $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr",$object->ref); |
|
| 233 | + } |
|
| 214 | 234 | $object->actionmsg=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
|
| 215 | 235 | |
| 216 | 236 | $object->sendtoid=0; |
| 217 | - } |
|
| 218 | - elseif ($action == 'ORDER_CANCEL') |
|
| 237 | + } elseif ($action == 'ORDER_CANCEL') |
|
| 219 | 238 | {
|
| 220 | 239 | // Load translation files required by the page |
| 221 | 240 | $langs->loadLangs(array("agenda","other","orders"));
|
| 222 | 241 | |
| 223 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
|
|
| 242 | + if (empty($object->actionmsg2)) { |
|
| 243 | + $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref); |
|
| 244 | + } |
|
| 224 | 245 | $object->actionmsg=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
|
| 225 | 246 | |
| 226 | 247 | $object->sendtoid=0; |
| 227 | - } |
|
| 228 | - elseif ($action == 'ORDER_SENTBYMAIL') |
|
| 248 | + } elseif ($action == 'ORDER_SENTBYMAIL') |
|
| 229 | 249 | {
|
| 230 | 250 | // Load translation files required by the page |
| 231 | 251 | $langs->loadLangs(array("agenda","other","orders"));
|
| 232 | 252 | |
| 233 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderSentByEMail",$object->ref);
|
|
| 253 | + if (empty($object->actionmsg2)) { |
|
| 254 | + $object->actionmsg2=$langs->transnoentities("OrderSentByEMail",$object->ref); |
|
| 255 | + } |
|
| 234 | 256 | if (empty($object->actionmsg)) |
| 235 | 257 | {
|
| 236 | 258 | $object->actionmsg=$langs->transnoentities("OrderSentByEMail",$object->ref);
|
@@ -238,33 +260,36 @@ discard block |
||
| 238 | 260 | |
| 239 | 261 | // Parameters $object->sendtoid defined by caller |
| 240 | 262 | //$object->sendtoid=0; |
| 241 | - } |
|
| 242 | - elseif ($action == 'BILL_VALIDATE') |
|
| 263 | + } elseif ($action == 'BILL_VALIDATE') |
|
| 243 | 264 | {
|
| 244 | 265 | // Load translation files required by the page |
| 245 | 266 | $langs->loadLangs(array("agenda","other","bills"));
|
| 246 | 267 | |
| 247 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 268 | + if (empty($object->actionmsg2)) { |
|
| 269 | + $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); |
|
| 270 | + } |
|
| 248 | 271 | $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 249 | 272 | |
| 250 | 273 | $object->sendtoid=0; |
| 251 | - } |
|
| 252 | - elseif ($action == 'BILL_UNVALIDATE') |
|
| 274 | + } elseif ($action == 'BILL_UNVALIDATE') |
|
| 253 | 275 | {
|
| 254 | 276 | // Load translation files required by the page |
| 255 | 277 | $langs->loadLangs(array("agenda","other","bills"));
|
| 256 | 278 | |
| 257 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
|
|
| 279 | + if (empty($object->actionmsg2)) { |
|
| 280 | + $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); |
|
| 281 | + } |
|
| 258 | 282 | $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
|
| 259 | 283 | |
| 260 | 284 | $object->sendtoid=0; |
| 261 | - } |
|
| 262 | - elseif ($action == 'BILL_SENTBYMAIL') |
|
| 285 | + } elseif ($action == 'BILL_SENTBYMAIL') |
|
| 263 | 286 | {
|
| 264 | 287 | // Load translation files required by the page |
| 265 | 288 | $langs->loadLangs(array("agenda","other","bills"));
|
| 266 | 289 | |
| 267 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceSentByEMail",$object->ref);
|
|
| 290 | + if (empty($object->actionmsg2)) { |
|
| 291 | + $object->actionmsg2=$langs->transnoentities("InvoiceSentByEMail",$object->ref); |
|
| 292 | + } |
|
| 268 | 293 | if (empty($object->actionmsg)) |
| 269 | 294 | {
|
| 270 | 295 | $object->actionmsg=$langs->transnoentities("InvoiceSentByEMail",$object->ref);
|
@@ -272,8 +297,7 @@ discard block |
||
| 272 | 297 | |
| 273 | 298 | // Parameters $object->sendtoid defined by caller |
| 274 | 299 | //$object->sendtoid=0; |
| 275 | - } |
|
| 276 | - elseif ($action == 'BILL_PAYED') |
|
| 300 | + } elseif ($action == 'BILL_PAYED') |
|
| 277 | 301 | {
|
| 278 | 302 | // Load translation files required by the page |
| 279 | 303 | $langs->loadLangs(array("agenda","other","bills"));
|
@@ -283,59 +307,64 @@ discard block |
||
| 283 | 307 | $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
|
| 284 | 308 | |
| 285 | 309 | $object->sendtoid=0; |
| 286 | - } |
|
| 287 | - elseif ($action == 'BILL_CANCEL') |
|
| 310 | + } elseif ($action == 'BILL_CANCEL') |
|
| 288 | 311 | {
|
| 289 | 312 | // Load translation files required by the page |
| 290 | 313 | $langs->loadLangs(array("agenda","other","bills"));
|
| 291 | 314 | |
| 292 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
|
|
| 315 | + if (empty($object->actionmsg2)) { |
|
| 316 | + $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); |
|
| 317 | + } |
|
| 293 | 318 | $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
|
| 294 | 319 | |
| 295 | 320 | $object->sendtoid=0; |
| 296 | - } |
|
| 297 | - elseif ($action == 'FICHINTER_CREATE') |
|
| 321 | + } elseif ($action == 'FICHINTER_CREATE') |
|
| 298 | 322 | {
|
| 299 | 323 | // Load translation files required by the page |
| 300 | 324 | $langs->loadLangs(array("agenda","other","interventions"));
|
| 301 | 325 | |
| 302 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref);
|
|
| 326 | + if (empty($object->actionmsg2)) { |
|
| 327 | + $object->actionmsg2=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref); |
|
| 328 | + } |
|
| 303 | 329 | $object->actionmsg=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref);
|
| 304 | 330 | |
| 305 | 331 | $object->sendtoid=0; |
| 306 | 332 | $object->fk_element=0; |
| 307 | 333 | $object->elementtype=''; |
| 308 | - } |
|
| 309 | - elseif ($action == 'FICHINTER_VALIDATE') |
|
| 334 | + } elseif ($action == 'FICHINTER_VALIDATE') |
|
| 310 | 335 | {
|
| 311 | 336 | // Load translation files required by the page |
| 312 | 337 | $langs->loadLangs(array("agenda","other","interventions"));
|
| 313 | 338 | |
| 314 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 339 | + if (empty($object->actionmsg2)) { |
|
| 340 | + $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); |
|
| 341 | + } |
|
| 315 | 342 | $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 316 | 343 | |
| 317 | 344 | $object->sendtoid=0; |
| 318 | 345 | $object->fk_element=0; |
| 319 | 346 | $object->elementtype=''; |
| 320 | - } |
|
| 321 | - elseif ($action == 'FICHINTER_MODIFY') |
|
| 347 | + } elseif ($action == 'FICHINTER_MODIFY') |
|
| 322 | 348 | {
|
| 323 | 349 | // Load translation files required by the page |
| 324 | 350 | $langs->loadLangs(array("agenda","other","interventions"));
|
| 325 | 351 | |
| 326 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref);
|
|
| 352 | + if (empty($object->actionmsg2)) { |
|
| 353 | + $object->actionmsg2=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref); |
|
| 354 | + } |
|
| 327 | 355 | $object->actionmsg=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref);
|
| 328 | 356 | |
| 329 | 357 | $object->sendtoid=0; |
| 330 | 358 | $object->fk_element=0; |
| 331 | 359 | $object->elementtype=''; |
| 332 | - } |
|
| 333 | - elseif ($action == 'FICHINTER_SENTBYMAIL') |
|
| 360 | + } elseif ($action == 'FICHINTER_SENTBYMAIL') |
|
| 334 | 361 | {
|
| 335 | 362 | // Load translation files required by the page |
| 336 | 363 | $langs->loadLangs(array("agenda","other","interventions"));
|
| 337 | 364 | |
| 338 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref);
|
|
| 365 | + if (empty($object->actionmsg2)) { |
|
| 366 | + $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref); |
|
| 367 | + } |
|
| 339 | 368 | if (empty($object->actionmsg)) |
| 340 | 369 | {
|
| 341 | 370 | $object->actionmsg=$langs->transnoentities("InterventionSentByEMail",$object->ref);
|
@@ -343,45 +372,49 @@ discard block |
||
| 343 | 372 | |
| 344 | 373 | // Parameters $object->sendtoid defined by caller |
| 345 | 374 | //$object->sendtoid=0; |
| 346 | - } |
|
| 347 | - elseif ($action == 'FICHINTER_CLASSIFY_BILLED') |
|
| 375 | + } elseif ($action == 'FICHINTER_CLASSIFY_BILLED') |
|
| 348 | 376 | {
|
| 349 | 377 | // Load translation files required by the page |
| 350 | 378 | $langs->loadLangs(array("agenda","other","interventions"));
|
| 351 | 379 | |
| 352 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
|
|
| 380 | + if (empty($object->actionmsg2)) { |
|
| 381 | + $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref); |
|
| 382 | + } |
|
| 353 | 383 | $object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
|
| 354 | 384 | |
| 355 | 385 | $object->sendtoid=0; |
| 356 | - } |
|
| 357 | - elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED') |
|
| 386 | + } elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED') |
|
| 358 | 387 | {
|
| 359 | 388 | // Load translation files required by the page |
| 360 | 389 | $langs->loadLangs(array("agenda","other","interventions"));
|
| 361 | 390 | |
| 362 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
|
|
| 391 | + if (empty($object->actionmsg2)) { |
|
| 392 | + $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref); |
|
| 393 | + } |
|
| 363 | 394 | $object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
|
| 364 | 395 | |
| 365 | 396 | $object->sendtoid=0; |
| 366 | - } |
|
| 367 | - elseif ($action == 'FICHINTER_DELETE') |
|
| 397 | + } elseif ($action == 'FICHINTER_DELETE') |
|
| 368 | 398 | {
|
| 369 | 399 | // Load translation files required by the page |
| 370 | 400 | $langs->loadLangs(array("agenda","other","interventions"));
|
| 371 | 401 | |
| 372 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref);
|
|
| 402 | + if (empty($object->actionmsg2)) { |
|
| 403 | + $object->actionmsg2=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref); |
|
| 404 | + } |
|
| 373 | 405 | $object->actionmsg=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref);
|
| 374 | 406 | |
| 375 | 407 | $object->sendtoid=0; |
| 376 | 408 | $object->fk_element=0; |
| 377 | 409 | $object->elementtype=''; |
| 378 | - } |
|
| 379 | - elseif ($action == 'SHIPPING_VALIDATE') |
|
| 410 | + } elseif ($action == 'SHIPPING_VALIDATE') |
|
| 380 | 411 | {
|
| 381 | 412 | // Load translation files required by the page |
| 382 | 413 | $langs->loadLangs(array("agenda","other","sendings"));
|
| 383 | 414 | |
| 384 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
|
|
| 415 | + if (empty($object->actionmsg2)) { |
|
| 416 | + $object->actionmsg2=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref)); |
|
| 417 | + } |
|
| 385 | 418 | if (empty($object->actionmsg)) |
| 386 | 419 | {
|
| 387 | 420 | $object->actionmsg=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
|
@@ -389,13 +422,14 @@ discard block |
||
| 389 | 422 | |
| 390 | 423 | // Parameters $object->sendtoid defined by caller |
| 391 | 424 | //$object->sendtoid=0; |
| 392 | - } |
|
| 393 | - elseif ($action == 'SHIPPING_SENTBYMAIL') |
|
| 425 | + } elseif ($action == 'SHIPPING_SENTBYMAIL') |
|
| 394 | 426 | {
|
| 395 | 427 | // Load translation files required by the page |
| 396 | 428 | $langs->loadLangs(array("agenda","other","sendings"));
|
| 397 | 429 | |
| 398 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail",$object->ref);
|
|
| 430 | + if (empty($object->actionmsg2)) { |
|
| 431 | + $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail",$object->ref); |
|
| 432 | + } |
|
| 399 | 433 | if (empty($object->actionmsg)) |
| 400 | 434 | {
|
| 401 | 435 | $object->actionmsg=$langs->transnoentities("ShippingSentByEMail",$object->ref);
|
@@ -409,7 +443,9 @@ discard block |
||
| 409 | 443 | $langs->load("other");
|
| 410 | 444 | $langs->load("receptions");
|
| 411 | 445 | |
| 412 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
|
|
| 446 | + if (empty($object->actionmsg2)) { |
|
| 447 | + $object->actionmsg2=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref)); |
|
| 448 | + } |
|
| 413 | 449 | if (empty($object->actionmsg)) |
| 414 | 450 | {
|
| 415 | 451 | $object->actionmsg=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
|
@@ -417,14 +453,15 @@ discard block |
||
| 417 | 453 | |
| 418 | 454 | // Parameters $object->sendtoid defined by caller |
| 419 | 455 | //$object->sendtoid=0; |
| 420 | - } |
|
| 421 | - elseif ($action == 'RECEPTION_SENTBYMAIL') |
|
| 456 | + } elseif ($action == 'RECEPTION_SENTBYMAIL') |
|
| 422 | 457 | {
|
| 423 | 458 | $langs->load("agenda");
|
| 424 | 459 | $langs->load("other");
|
| 425 | 460 | $langs->load("receptions");
|
| 426 | 461 | |
| 427 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionSentByEMail",$object->ref);
|
|
| 462 | + if (empty($object->actionmsg2)) { |
|
| 463 | + $object->actionmsg2=$langs->transnoentities("ReceptionSentByEMail",$object->ref); |
|
| 464 | + } |
|
| 428 | 465 | if (empty($object->actionmsg)) |
| 429 | 466 | {
|
| 430 | 467 | $object->actionmsg=$langs->transnoentities("ReceptionSentByEMail",$object->ref);
|
@@ -432,23 +469,25 @@ discard block |
||
| 432 | 469 | |
| 433 | 470 | // Parameters $object->sendtoid defined by caller |
| 434 | 471 | //$object->sendtoid=0; |
| 435 | - } |
|
| 436 | - elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE') |
|
| 472 | + } elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE') |
|
| 437 | 473 | {
|
| 438 | 474 | // Load translation files required by the page |
| 439 | 475 | $langs->loadLangs(array("agenda","other","propal"));
|
| 440 | 476 | |
| 441 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 477 | + if (empty($object->actionmsg2)) { |
|
| 478 | + $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); |
|
| 479 | + } |
|
| 442 | 480 | $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 443 | 481 | |
| 444 | 482 | $object->sendtoid=0; |
| 445 | - } |
|
| 446 | - elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL') |
|
| 483 | + } elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL') |
|
| 447 | 484 | {
|
| 448 | 485 | // Load translation files required by the page |
| 449 | 486 | $langs->loadLangs(array("agenda","other","propal"));
|
| 450 | 487 | |
| 451 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
|
|
| 488 | + if (empty($object->actionmsg2)) { |
|
| 489 | + $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref); |
|
| 490 | + } |
|
| 452 | 491 | if (empty($object->actionmsg)) |
| 453 | 492 | {
|
| 454 | 493 | $object->actionmsg=$langs->transnoentities("ProposalSentByEMail",$object->ref);
|
@@ -456,93 +495,102 @@ discard block |
||
| 456 | 495 | |
| 457 | 496 | // Parameters $object->sendtoid defined by caller |
| 458 | 497 | //$object->sendtoid=0; |
| 459 | - } |
|
| 460 | - elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED') |
|
| 498 | + } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED') |
|
| 461 | 499 | {
|
| 462 | 500 | // Load translation files required by the page |
| 463 | 501 | $langs->loadLangs(array("agenda","other","propal"));
|
| 464 | 502 | |
| 465 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
|
| 503 | + if (empty($object->actionmsg2)) { |
|
| 504 | + $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref); |
|
| 505 | + } |
|
| 466 | 506 | $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
| 467 | 507 | |
| 468 | 508 | $object->sendtoid=0; |
| 469 | - } |
|
| 470 | - elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED') |
|
| 509 | + } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED') |
|
| 471 | 510 | {
|
| 472 | 511 | // Load translation files required by the page |
| 473 | 512 | $langs->loadLangs(array("agenda","other","propal"));
|
| 474 | 513 | |
| 475 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
|
| 514 | + if (empty($object->actionmsg2)) { |
|
| 515 | + $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref); |
|
| 516 | + } |
|
| 476 | 517 | $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
| 477 | 518 | |
| 478 | 519 | $object->sendtoid=0; |
| 479 | - } |
|
| 480 | - elseif ($action == 'ORDER_SUPPLIER_CREATE') |
|
| 520 | + } elseif ($action == 'ORDER_SUPPLIER_CREATE') |
|
| 481 | 521 | {
|
| 482 | 522 | // Load translation files required by the page |
| 483 | 523 | $langs->loadLangs(array("agenda","other","orders"));
|
| 484 | 524 | |
| 485 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 525 | + if (empty($object->actionmsg2)) { |
|
| 526 | + $object->actionmsg2=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref)); |
|
| 527 | + } |
|
| 486 | 528 | $object->actionmsg=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 487 | 529 | |
| 488 | 530 | $object->sendtoid=0; |
| 489 | - } |
|
| 490 | - elseif ($action == 'ORDER_SUPPLIER_VALIDATE') |
|
| 531 | + } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') |
|
| 491 | 532 | {
|
| 492 | 533 | // Load translation files required by the page |
| 493 | 534 | $langs->loadLangs(array("agenda","other","orders"));
|
| 494 | 535 | |
| 495 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 536 | + if (empty($object->actionmsg2)) { |
|
| 537 | + $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); |
|
| 538 | + } |
|
| 496 | 539 | $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 497 | 540 | |
| 498 | 541 | $object->sendtoid=0; |
| 499 | - } |
|
| 500 | - elseif ($action == 'ORDER_SUPPLIER_APPROVE') |
|
| 542 | + } elseif ($action == 'ORDER_SUPPLIER_APPROVE') |
|
| 501 | 543 | {
|
| 502 | 544 | // Load translation files required by the page |
| 503 | 545 | $langs->loadLangs(array("agenda","other","orders"));
|
| 504 | 546 | |
| 505 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
|
|
| 547 | + if (empty($object->actionmsg2)) { |
|
| 548 | + $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref); |
|
| 549 | + } |
|
| 506 | 550 | $object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
|
| 507 | 551 | |
| 508 | 552 | $object->sendtoid=0; |
| 509 | - } |
|
| 510 | - elseif ($action == 'ORDER_SUPPLIER_REFUSE') |
|
| 553 | + } elseif ($action == 'ORDER_SUPPLIER_REFUSE') |
|
| 511 | 554 | {
|
| 512 | 555 | // Load translation files required by the page |
| 513 | 556 | $langs->loadLangs(array("agenda","other","orders"));
|
| 514 | 557 | |
| 515 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
|
|
| 558 | + if (empty($object->actionmsg2)) { |
|
| 559 | + $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref); |
|
| 560 | + } |
|
| 516 | 561 | $object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
|
| 517 | 562 | |
| 518 | 563 | $object->sendtoid=0; |
| 519 | - } |
|
| 520 | - elseif ($action == 'ORDER_SUPPLIER_SUBMIT') |
|
| 564 | + } elseif ($action == 'ORDER_SUPPLIER_SUBMIT') |
|
| 521 | 565 | {
|
| 522 | 566 | // Load translation files required by the page |
| 523 | 567 | $langs->loadLangs(array("agenda","other","orders"));
|
| 524 | 568 | |
| 525 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 569 | + if (empty($object->actionmsg2)) { |
|
| 570 | + $object->actionmsg2=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref)); |
|
| 571 | + } |
|
| 526 | 572 | $object->actionmsg=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 527 | 573 | |
| 528 | 574 | $object->sendtoid=0; |
| 529 | - } |
|
| 530 | - elseif ($action == 'ORDER_SUPPLIER_RECEIVE') |
|
| 575 | + } elseif ($action == 'ORDER_SUPPLIER_RECEIVE') |
|
| 531 | 576 | {
|
| 532 | 577 | // Load translation files required by the page |
| 533 | 578 | $langs->loadLangs(array("agenda","other","orders"));
|
| 534 | 579 | |
| 535 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 580 | + if (empty($object->actionmsg2)) { |
|
| 581 | + $object->actionmsg2=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref)); |
|
| 582 | + } |
|
| 536 | 583 | $object->actionmsg=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 537 | 584 | |
| 538 | 585 | $object->sendtoid=0; |
| 539 | - } |
|
| 540 | - elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') |
|
| 586 | + } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') |
|
| 541 | 587 | {
|
| 542 | 588 | // Load translation files required by the page |
| 543 | 589 | $langs->loadLangs(array("agenda","other","bills","orders"));
|
| 544 | 590 | |
| 545 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref);
|
|
| 591 | + if (empty($object->actionmsg2)) { |
|
| 592 | + $object->actionmsg2=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref); |
|
| 593 | + } |
|
| 546 | 594 | if (empty($object->actionmsg)) |
| 547 | 595 | {
|
| 548 | 596 | $object->actionmsg=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref);
|
@@ -550,46 +598,50 @@ discard block |
||
| 550 | 598 | |
| 551 | 599 | // Parameters $object->sendtoid defined by caller |
| 552 | 600 | //$object->sendtoid=0; |
| 553 | - } |
|
| 554 | - elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED') |
|
| 601 | + } elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED') |
|
| 555 | 602 | {
|
| 556 | 603 | // Load translation files required by the page |
| 557 | 604 | $langs->loadLangs(array("agenda","other","bills","orders"));
|
| 558 | 605 | |
| 559 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderClassifiedBilled",$object->ref);
|
|
| 606 | + if (empty($object->actionmsg2)) { |
|
| 607 | + $object->actionmsg2=$langs->transnoentities("SupplierOrderClassifiedBilled",$object->ref); |
|
| 608 | + } |
|
| 560 | 609 | if (empty($object->actionmsg)) |
| 561 | 610 | {
|
| 562 | 611 | $object->actionmsg=$langs->transnoentities("SupplierOrderClassifiedBilled",$object->ref);
|
| 563 | 612 | } |
| 564 | 613 | |
| 565 | 614 | $object->sendtoid=0; |
| 566 | - } |
|
| 567 | - elseif ($action == 'BILL_SUPPLIER_VALIDATE') |
|
| 615 | + } elseif ($action == 'BILL_SUPPLIER_VALIDATE') |
|
| 568 | 616 | {
|
| 569 | 617 | // Load translation files required by the page |
| 570 | 618 | $langs->loadLangs(array("agenda","other","bills"));
|
| 571 | 619 | |
| 572 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
|
| 620 | + if (empty($object->actionmsg2)) { |
|
| 621 | + $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); |
|
| 622 | + } |
|
| 573 | 623 | $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
| 574 | 624 | |
| 575 | 625 | $object->sendtoid=0; |
| 576 | - } |
|
| 577 | - elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') |
|
| 626 | + } elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') |
|
| 578 | 627 | {
|
| 579 | 628 | // Load translation files required by the page |
| 580 | 629 | $langs->loadLangs(array("agenda","other","bills"));
|
| 581 | 630 | |
| 582 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
|
|
| 631 | + if (empty($object->actionmsg2)) { |
|
| 632 | + $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); |
|
| 633 | + } |
|
| 583 | 634 | $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
|
| 584 | 635 | |
| 585 | 636 | $object->sendtoid=0; |
| 586 | - } |
|
| 587 | - elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') |
|
| 637 | + } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') |
|
| 588 | 638 | {
|
| 589 | 639 | // Load translation files required by the page |
| 590 | 640 | $langs->loadLangs(array("agenda","other","bills","orders"));
|
| 591 | 641 | |
| 592 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref);
|
|
| 642 | + if (empty($object->actionmsg2)) { |
|
| 643 | + $object->actionmsg2=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref); |
|
| 644 | + } |
|
| 593 | 645 | if (empty($object->actionmsg)) |
| 594 | 646 | {
|
| 595 | 647 | $object->actionmsg=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref);
|
@@ -597,23 +649,25 @@ discard block |
||
| 597 | 649 | |
| 598 | 650 | // Parameters $object->sendtoid defined by caller |
| 599 | 651 | //$object->sendtoid=0; |
| 600 | - } |
|
| 601 | - elseif ($action == 'BILL_SUPPLIER_PAYED') |
|
| 652 | + } elseif ($action == 'BILL_SUPPLIER_PAYED') |
|
| 602 | 653 | {
|
| 603 | 654 | // Load translation files required by the page |
| 604 | 655 | $langs->loadLangs(array("agenda","other","bills"));
|
| 605 | 656 | |
| 606 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
|
|
| 657 | + if (empty($object->actionmsg2)) { |
|
| 658 | + $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); |
|
| 659 | + } |
|
| 607 | 660 | $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
|
| 608 | 661 | |
| 609 | 662 | $object->sendtoid=0; |
| 610 | - } |
|
| 611 | - elseif ($action == 'BILL_SUPPLIER_CANCELED') |
|
| 663 | + } elseif ($action == 'BILL_SUPPLIER_CANCELED') |
|
| 612 | 664 | {
|
| 613 | 665 | // Load translation files required by the page |
| 614 | 666 | $langs->loadLangs(array("agenda","other","bills"));
|
| 615 | 667 | |
| 616 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
|
|
| 668 | + if (empty($object->actionmsg2)) { |
|
| 669 | + $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); |
|
| 670 | + } |
|
| 617 | 671 | $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
|
| 618 | 672 | |
| 619 | 673 | $object->sendtoid=0; |
@@ -625,31 +679,35 @@ discard block |
||
| 625 | 679 | // Load translation files required by the page |
| 626 | 680 | $langs->loadLangs(array("agenda","other","members"));
|
| 627 | 681 | |
| 628 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",$object->getFullName($langs));
|
|
| 682 | + if (empty($object->actionmsg2)) { |
|
| 683 | + $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",$object->getFullName($langs)); |
|
| 684 | + } |
|
| 629 | 685 | $object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr",$object->getFullName($langs));
|
| 630 | 686 | $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
| 631 | 687 | $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
| 632 | 688 | |
| 633 | 689 | $object->sendtoid=0; |
| 634 | - } |
|
| 635 | - elseif ($action == 'MEMBER_MODIFY') |
|
| 690 | + } elseif ($action == 'MEMBER_MODIFY') |
|
| 636 | 691 | {
|
| 637 | 692 | // Load translation files required by the page |
| 638 | 693 | $langs->loadLangs(array("agenda","other","members"));
|
| 639 | 694 | |
| 640 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberModifiedInDolibarr",$object->getFullName($langs));
|
|
| 695 | + if (empty($object->actionmsg2)) { |
|
| 696 | + $object->actionmsg2=$langs->transnoentities("MemberModifiedInDolibarr",$object->getFullName($langs)); |
|
| 697 | + } |
|
| 641 | 698 | $object->actionmsg=$langs->transnoentities("MemberModifiedInDolibarr",$object->getFullName($langs));
|
| 642 | 699 | $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
| 643 | 700 | $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
| 644 | 701 | |
| 645 | 702 | $object->sendtoid=0; |
| 646 | - } |
|
| 647 | - elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE') |
|
| 703 | + } elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE') |
|
| 648 | 704 | {
|
| 649 | 705 | // Load translation files required by the page |
| 650 | 706 | $langs->loadLangs(array("agenda","other","members"));
|
| 651 | 707 | |
| 652 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 708 | + if (empty($object->actionmsg2)) { |
|
| 709 | + $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs)); |
|
| 710 | + } |
|
| 653 | 711 | $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs));
|
| 654 | 712 | $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
| 655 | 713 | $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
@@ -657,14 +715,17 @@ discard block |
||
| 657 | 715 | $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
|
| 658 | 716 | |
| 659 | 717 | $object->sendtoid=0; |
| 660 | - if ($object->fk_soc > 0) $object->socid=$object->fk_soc; |
|
| 661 | - } |
|
| 662 | - elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY') |
|
| 718 | + if ($object->fk_soc > 0) { |
|
| 719 | + $object->socid=$object->fk_soc; |
|
| 720 | + } |
|
| 721 | + } elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY') |
|
| 663 | 722 | {
|
| 664 | 723 | // Load translation files required by the page |
| 665 | 724 | $langs->loadLangs(array("agenda","other","members"));
|
| 666 | 725 | |
| 667 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 726 | + if (empty($object->actionmsg2)) { |
|
| 727 | + $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs)); |
|
| 728 | + } |
|
| 668 | 729 | $object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
|
| 669 | 730 | $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
| 670 | 731 | $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
@@ -672,14 +733,17 @@ discard block |
||
| 672 | 733 | $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
|
| 673 | 734 | |
| 674 | 735 | $object->sendtoid=0; |
| 675 | - if ($object->fk_soc > 0) $object->socid=$object->fk_soc; |
|
| 676 | - } |
|
| 677 | - elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE') |
|
| 736 | + if ($object->fk_soc > 0) { |
|
| 737 | + $object->socid=$object->fk_soc; |
|
| 738 | + } |
|
| 739 | + } elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE') |
|
| 678 | 740 | {
|
| 679 | 741 | // Load translation files required by the page |
| 680 | 742 | $langs->loadLangs(array("agenda","other","members"));
|
| 681 | 743 | |
| 682 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
|
|
| 744 | + if (empty($object->actionmsg2)) { |
|
| 745 | + $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs)); |
|
| 746 | + } |
|
| 683 | 747 | $object->actionmsg=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
|
| 684 | 748 | $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
| 685 | 749 | $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
@@ -687,26 +751,30 @@ discard block |
||
| 687 | 751 | $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
|
| 688 | 752 | |
| 689 | 753 | $object->sendtoid=0; |
| 690 | - if ($object->fk_soc > 0) $object->socid=$object->fk_soc; |
|
| 691 | - } |
|
| 692 | - elseif ($action == 'MEMBER_RESILIATE') |
|
| 754 | + if ($object->fk_soc > 0) { |
|
| 755 | + $object->socid=$object->fk_soc; |
|
| 756 | + } |
|
| 757 | + } elseif ($action == 'MEMBER_RESILIATE') |
|
| 693 | 758 | {
|
| 694 | 759 | // Load translation files required by the page |
| 695 | 760 | $langs->loadLangs(array("agenda","other","members"));
|
| 696 | 761 | |
| 697 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr",$object->getFullName($langs));
|
|
| 762 | + if (empty($object->actionmsg2)) { |
|
| 763 | + $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr",$object->getFullName($langs)); |
|
| 764 | + } |
|
| 698 | 765 | $object->actionmsg=$langs->transnoentities("MemberResiliatedInDolibarr",$object->getFullName($langs));
|
| 699 | 766 | $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
| 700 | 767 | $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
| 701 | 768 | |
| 702 | 769 | $object->sendtoid=0; |
| 703 | - } |
|
| 704 | - elseif ($action == 'MEMBER_DELETE') |
|
| 770 | + } elseif ($action == 'MEMBER_DELETE') |
|
| 705 | 771 | {
|
| 706 | 772 | // Load translation files required by the page |
| 707 | 773 | $langs->loadLangs(array("agenda","other","members"));
|
| 708 | 774 | |
| 709 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr",$object->getFullName($langs));
|
|
| 775 | + if (empty($object->actionmsg2)) { |
|
| 776 | + $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr",$object->getFullName($langs)); |
|
| 777 | + } |
|
| 710 | 778 | $object->actionmsg=$langs->transnoentities("MemberDeletedInDolibarr",$object->getFullName($langs));
|
| 711 | 779 | $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
|
| 712 | 780 | $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
|
@@ -720,29 +788,33 @@ discard block |
||
| 720 | 788 | // Load translation files required by the page |
| 721 | 789 | $langs->loadLangs(array("agenda","other","projects"));
|
| 722 | 790 | |
| 723 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
|
|
| 791 | + if (empty($object->actionmsg2)) { |
|
| 792 | + $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref); |
|
| 793 | + } |
|
| 724 | 794 | $object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
|
| 725 | 795 | $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
|
| 726 | 796 | |
| 727 | 797 | $object->sendtoid=0; |
| 728 | - } |
|
| 729 | - elseif($action == 'PROJECT_VALIDATE') |
|
| 798 | + } elseif($action == 'PROJECT_VALIDATE') |
|
| 730 | 799 | {
|
| 731 | 800 | // Load translation files required by the page |
| 732 | 801 | $langs->loadLangs(array("agenda","other","projects"));
|
| 733 | 802 | |
| 734 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref);
|
|
| 803 | + if (empty($object->actionmsg2)) { |
|
| 804 | + $object->actionmsg2=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref); |
|
| 805 | + } |
|
| 735 | 806 | $object->actionmsg=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref);
|
| 736 | 807 | $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
|
| 737 | 808 | |
| 738 | 809 | $object->sendtoid=0; |
| 739 | - } |
|
| 740 | - elseif($action == 'PROJECT_MODIFY') |
|
| 810 | + } elseif($action == 'PROJECT_MODIFY') |
|
| 741 | 811 | {
|
| 742 | 812 | // Load translation files required by the page |
| 743 | 813 | $langs->loadLangs(array("agenda","other","projects"));
|
| 744 | 814 | |
| 745 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref);
|
|
| 815 | + if (empty($object->actionmsg2)) { |
|
| 816 | + $object->actionmsg2=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref); |
|
| 817 | + } |
|
| 746 | 818 | $object->actionmsg=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref);
|
| 747 | 819 | $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
|
| 748 | 820 | |
@@ -755,31 +827,33 @@ discard block |
||
| 755 | 827 | // Load translation files required by the page |
| 756 | 828 | $langs->loadLangs(array("agenda","other","projects"));
|
| 757 | 829 | |
| 758 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
|
|
| 830 | + if (empty($object->actionmsg2)) { |
|
| 831 | + $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref); |
|
| 832 | + } |
|
| 759 | 833 | $object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
|
| 760 | 834 | $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
|
| 761 | 835 | |
| 762 | 836 | $object->sendtoid=0; |
| 763 | - } |
|
| 764 | - |
|
| 765 | - elseif($action == 'TASK_MODIFY') |
|
| 837 | + } elseif($action == 'TASK_MODIFY') |
|
| 766 | 838 | {
|
| 767 | 839 | // Load translation files required by the page |
| 768 | 840 | $langs->loadLangs(array("agenda","other","projects"));
|
| 769 | 841 | |
| 770 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref);
|
|
| 842 | + if (empty($object->actionmsg2)) { |
|
| 843 | + $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref); |
|
| 844 | + } |
|
| 771 | 845 | $object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr",$object->ref);
|
| 772 | 846 | $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
|
| 773 | 847 | |
| 774 | 848 | $object->sendtoid=0; |
| 775 | - } |
|
| 776 | - |
|
| 777 | - elseif($action == 'TASK_DELETE') |
|
| 849 | + } elseif($action == 'TASK_DELETE') |
|
| 778 | 850 | {
|
| 779 | 851 | // Load translation files required by the page |
| 780 | 852 | $langs->loadLangs(array("agenda","other","projects"));
|
| 781 | 853 | |
| 782 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
|
|
| 854 | + if (empty($object->actionmsg2)) { |
|
| 855 | + $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref); |
|
| 856 | + } |
|
| 783 | 857 | $object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
|
| 784 | 858 | $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
|
| 785 | 859 | |
@@ -792,8 +866,12 @@ discard block |
||
| 792 | 866 | // Load translation files required by the page |
| 793 | 867 | $langs->loadLangs(array("agenda","other"));
|
| 794 | 868 | |
| 795 | - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref); |
|
| 796 | - if (empty($object->actionmsg)) $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref); |
|
| 869 | + if (empty($object->actionmsg2)) { |
|
| 870 | + $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref); |
|
| 871 | + } |
|
| 872 | + if (empty($object->actionmsg)) { |
|
| 873 | + $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref); |
|
| 874 | + } |
|
| 797 | 875 | |
| 798 | 876 | $object->sendtoid=0; |
| 799 | 877 | } |
@@ -821,18 +899,26 @@ discard block |
||
| 821 | 899 | // Set contactforaction if there is only 1 contact. |
| 822 | 900 | if (is_array($object->sendtoid)) |
| 823 | 901 | {
|
| 824 | - if (count($object->sendtoid) == 1) $contactforaction->fetch(reset($object->sendtoid)); |
|
| 825 | - } |
|
| 826 | - else |
|
| 902 | + if (count($object->sendtoid) == 1) { |
|
| 903 | + $contactforaction->fetch(reset($object->sendtoid)); |
|
| 904 | + } |
|
| 905 | + } else |
|
| 827 | 906 | {
|
| 828 | - if ($object->sendtoid > 0) $contactforaction->fetch($object->sendtoid); |
|
| 907 | + if ($object->sendtoid > 0) { |
|
| 908 | + $contactforaction->fetch($object->sendtoid); |
|
| 909 | + } |
|
| 829 | 910 | } |
| 830 | 911 | // Set societeforaction. |
| 831 | - if ($object->socid > 0) $societeforaction->fetch($object->socid); |
|
| 832 | - elseif ($object->fk_soc > 0) $societeforaction->fetch($object->fk_soc); |
|
| 912 | + if ($object->socid > 0) { |
|
| 913 | + $societeforaction->fetch($object->socid); |
|
| 914 | + } elseif ($object->fk_soc > 0) { |
|
| 915 | + $societeforaction->fetch($object->fk_soc); |
|
| 916 | + } |
|
| 833 | 917 | |
| 834 | 918 | $projectid = isset($object->fk_project)?$object->fk_project:0; |
| 835 | - if ($object->element == 'project') $projectid = $object->id; |
|
| 919 | + if ($object->element == 'project') { |
|
| 920 | + $projectid = $object->id; |
|
| 921 | + } |
|
| 836 | 922 | |
| 837 | 923 | $elementid = $object->id; |
| 838 | 924 | $elementtype = $object->element; |
@@ -910,8 +996,7 @@ discard block |
||
| 910 | 996 | {
|
| 911 | 997 | $_SESSION['LAST_ACTION_CREATED'] = $ret; |
| 912 | 998 | return 1; |
| 913 | - } |
|
| 914 | - else |
|
| 999 | + } else |
|
| 915 | 1000 | {
|
| 916 | 1001 | $error ="Failed to insert event : ".$actioncomm->error." ".join(',',$actioncomm->errors);
|
| 917 | 1002 | $this->error=$error; |
@@ -30,121 +30,121 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | class InterfaceActionsBlockedLog extends DolibarrTriggers |
| 32 | 32 | {
|
| 33 | - public $family = 'system'; |
|
| 34 | - public $description = "Triggers of this module add action for BlockedLog module."; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Version of the trigger |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 40 | - public $version = self::VERSION_DOLIBARR; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @var string Image of the trigger |
|
| 44 | - */ |
|
| 45 | - public $picto = 'technic'; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Function called on Dolibarrr payment or invoice event. |
|
| 49 | - * |
|
| 50 | - * @param string $action Event action code |
|
| 51 | - * @param Object $object Object |
|
| 52 | - * @param User $user Object user |
|
| 53 | - * @param Translate $langs Object langs |
|
| 54 | - * @param conf $conf Object conf |
|
| 55 | - * @return int <0 if KO, 0 if no triggered ran, >0 if OK |
|
| 56 | - */ |
|
| 57 | - public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
|
| 58 | - {
|
|
| 59 | - if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing |
|
| 60 | - |
|
| 61 | - // Test if event/record is qualified |
|
| 62 | - $listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription', 'payment_various', 'cashcontrol');
|
|
| 63 | - if (! in_array($object->element, $listofqualifiedelement)) return 1; |
|
| 64 | - |
|
| 65 | - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 66 | - |
|
| 67 | - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; |
|
| 68 | - $b=new BlockedLog($this->db); |
|
| 69 | - |
|
| 70 | - // Tracked events |
|
| 71 | - if (! in_array($action, array_keys($b->trackedevents))) |
|
| 72 | - {
|
|
| 73 | - return 0; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - // Event/record is qualified |
|
| 77 | - $qualified = 0; |
|
| 78 | - $amounts = 0; |
|
| 79 | - if ($action==='BILL_VALIDATE' || $action==='BILL_DELETE' || $action === 'BILL_SENTBYMAIL' |
|
| 80 | - || $action==='BILL_SUPPLIER_VALIDATE' || $action==='BILL_SUPPLIER_DELETE' || $action === 'BILL_SUPPLIER_SENTBYMAIL' |
|
| 81 | - || $action==='MEMBER_SUBSCRIPTION_CREATE' || $action==='MEMBER_SUBSCRIPTION_MODIFY' || $action==='MEMBER_SUBSCRIPTION_DELETE' |
|
| 82 | - || $action==='DON_VALIDATE' || $action==='DON_MODIFY' || $action==='DON_DELETE' |
|
| 83 | - || $action==='CASHCONTROL_VALIDATE' |
|
| 84 | - || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_DOWNLOAD') || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_PREVIEW')
|
|
| 85 | - ) |
|
| 86 | - {
|
|
| 87 | - $qualified++; |
|
| 88 | - |
|
| 89 | - if (in_array($action, array( |
|
| 90 | - 'MEMBER_SUBSCRIPTION_CREATE','MEMBER_SUBSCRIPTION_MODIFY','MEMBER_SUBSCRIPTION_DELETE', |
|
| 91 | - 'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) $amounts = (double) $object->amount; |
|
| 92 | - elseif ($action == 'CASHCONTROL_VALIDATE') |
|
| 93 | - {
|
|
| 94 | - $amounts = (double) $object->cash + (double) $object->cheque + (double) $object->card; |
|
| 95 | - } |
|
| 96 | - else $amounts = (double) $object->total_ttc; |
|
| 97 | - } |
|
| 98 | - /*if ($action === 'BILL_PAYED' || $action==='BILL_UNPAYED' |
|
| 33 | + public $family = 'system'; |
|
| 34 | + public $description = "Triggers of this module add action for BlockedLog module."; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Version of the trigger |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | + public $version = self::VERSION_DOLIBARR; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @var string Image of the trigger |
|
| 44 | + */ |
|
| 45 | + public $picto = 'technic'; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Function called on Dolibarrr payment or invoice event. |
|
| 49 | + * |
|
| 50 | + * @param string $action Event action code |
|
| 51 | + * @param Object $object Object |
|
| 52 | + * @param User $user Object user |
|
| 53 | + * @param Translate $langs Object langs |
|
| 54 | + * @param conf $conf Object conf |
|
| 55 | + * @return int <0 if KO, 0 if no triggered ran, >0 if OK |
|
| 56 | + */ |
|
| 57 | + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
|
| 58 | + {
|
|
| 59 | + if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing |
|
| 60 | + |
|
| 61 | + // Test if event/record is qualified |
|
| 62 | + $listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription', 'payment_various', 'cashcontrol');
|
|
| 63 | + if (! in_array($object->element, $listofqualifiedelement)) return 1; |
|
| 64 | + |
|
| 65 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 66 | + |
|
| 67 | + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; |
|
| 68 | + $b=new BlockedLog($this->db); |
|
| 69 | + |
|
| 70 | + // Tracked events |
|
| 71 | + if (! in_array($action, array_keys($b->trackedevents))) |
|
| 72 | + {
|
|
| 73 | + return 0; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + // Event/record is qualified |
|
| 77 | + $qualified = 0; |
|
| 78 | + $amounts = 0; |
|
| 79 | + if ($action==='BILL_VALIDATE' || $action==='BILL_DELETE' || $action === 'BILL_SENTBYMAIL' |
|
| 80 | + || $action==='BILL_SUPPLIER_VALIDATE' || $action==='BILL_SUPPLIER_DELETE' || $action === 'BILL_SUPPLIER_SENTBYMAIL' |
|
| 81 | + || $action==='MEMBER_SUBSCRIPTION_CREATE' || $action==='MEMBER_SUBSCRIPTION_MODIFY' || $action==='MEMBER_SUBSCRIPTION_DELETE' |
|
| 82 | + || $action==='DON_VALIDATE' || $action==='DON_MODIFY' || $action==='DON_DELETE' |
|
| 83 | + || $action==='CASHCONTROL_VALIDATE' |
|
| 84 | + || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_DOWNLOAD') || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_PREVIEW')
|
|
| 85 | + ) |
|
| 86 | + {
|
|
| 87 | + $qualified++; |
|
| 88 | + |
|
| 89 | + if (in_array($action, array( |
|
| 90 | + 'MEMBER_SUBSCRIPTION_CREATE','MEMBER_SUBSCRIPTION_MODIFY','MEMBER_SUBSCRIPTION_DELETE', |
|
| 91 | + 'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) $amounts = (double) $object->amount; |
|
| 92 | + elseif ($action == 'CASHCONTROL_VALIDATE') |
|
| 93 | + {
|
|
| 94 | + $amounts = (double) $object->cash + (double) $object->cheque + (double) $object->card; |
|
| 95 | + } |
|
| 96 | + else $amounts = (double) $object->total_ttc; |
|
| 97 | + } |
|
| 98 | + /*if ($action === 'BILL_PAYED' || $action==='BILL_UNPAYED' |
|
| 99 | 99 | || $action === 'BILL_SUPPLIER_PAYED' || $action === 'BILL_SUPPLIER_UNPAYED') |
| 100 | 100 | {
|
| 101 | 101 | $qualified++; |
| 102 | 102 | $amounts= (double) $object->total_ttc; |
| 103 | 103 | }*/ |
| 104 | - if ($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_SUPPLIER_CREATE' || $action === 'DONATION_PAYMENT_CREATE' |
|
| 105 | - || $action === 'PAYMENT_CUSTOMER_DELETE' || $action === 'PAYMENT_SUPPLIER_DELETE' || $action === 'DONATION_PAYMENT_DELETE') |
|
| 106 | - {
|
|
| 107 | - $qualified++; |
|
| 108 | - $amounts = 0; |
|
| 109 | - if(!empty($object->amounts)) {
|
|
| 110 | - foreach($object->amounts as $amount) {
|
|
| 111 | - $amounts += price2num($amount); |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - elseif (strpos($action,'PAYMENT')!==false && ! in_array($action, array('PAYMENT_ADD_TO_BANK')))
|
|
| 116 | - {
|
|
| 117 | - $qualified++; |
|
| 118 | - $amounts = (double) $object->amount; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - // Another protection. |
|
| 122 | - // May be used when event is DOC_DOWNLOAD or DOC_PREVIEW and element is not an invoice |
|
| 123 | - if (! $qualified) |
|
| 124 | - {
|
|
| 125 | - return 0; // not implemented action log |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - $result = $b->setObjectData($object, $action, $amounts, $user); // Set field date_object, ref_object, fk_object, element, object_data |
|
| 129 | - |
|
| 130 | - if ($result < 0) |
|
| 131 | - {
|
|
| 132 | - $this->error = $b->error; |
|
| 133 | - $this->errors = $b->errors; |
|
| 134 | - return -1; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - $res = $b->create($user); |
|
| 138 | - |
|
| 139 | - if ($res < 0) |
|
| 140 | - {
|
|
| 141 | - $this->error = $b->error; |
|
| 142 | - $this->errors = $b->errors; |
|
| 143 | - return -1; |
|
| 144 | - } |
|
| 145 | - else |
|
| 146 | - {
|
|
| 147 | - return 1; |
|
| 148 | - } |
|
| 104 | + if ($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_SUPPLIER_CREATE' || $action === 'DONATION_PAYMENT_CREATE' |
|
| 105 | + || $action === 'PAYMENT_CUSTOMER_DELETE' || $action === 'PAYMENT_SUPPLIER_DELETE' || $action === 'DONATION_PAYMENT_DELETE') |
|
| 106 | + {
|
|
| 107 | + $qualified++; |
|
| 108 | + $amounts = 0; |
|
| 109 | + if(!empty($object->amounts)) {
|
|
| 110 | + foreach($object->amounts as $amount) {
|
|
| 111 | + $amounts += price2num($amount); |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + elseif (strpos($action,'PAYMENT')!==false && ! in_array($action, array('PAYMENT_ADD_TO_BANK')))
|
|
| 116 | + {
|
|
| 117 | + $qualified++; |
|
| 118 | + $amounts = (double) $object->amount; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + // Another protection. |
|
| 122 | + // May be used when event is DOC_DOWNLOAD or DOC_PREVIEW and element is not an invoice |
|
| 123 | + if (! $qualified) |
|
| 124 | + {
|
|
| 125 | + return 0; // not implemented action log |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + $result = $b->setObjectData($object, $action, $amounts, $user); // Set field date_object, ref_object, fk_object, element, object_data |
|
| 129 | + |
|
| 130 | + if ($result < 0) |
|
| 131 | + {
|
|
| 132 | + $this->error = $b->error; |
|
| 133 | + $this->errors = $b->errors; |
|
| 134 | + return -1; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + $res = $b->create($user); |
|
| 138 | + |
|
| 139 | + if ($res < 0) |
|
| 140 | + {
|
|
| 141 | + $this->error = $b->error; |
|
| 142 | + $this->errors = $b->errors; |
|
| 143 | + return -1; |
|
| 144 | + } |
|
| 145 | + else |
|
| 146 | + {
|
|
| 147 | + return 1; |
|
| 148 | + } |
|
| 149 | 149 | } |
| 150 | 150 | } |
@@ -56,19 +56,19 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 58 | 58 | {
|
| 59 | - if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing |
|
| 59 | + if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing |
|
| 60 | 60 | |
| 61 | 61 | // Test if event/record is qualified |
| 62 | 62 | $listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription', 'payment_various', 'cashcontrol');
|
| 63 | - if (! in_array($object->element, $listofqualifiedelement)) return 1; |
|
| 63 | + if (!in_array($object->element, $listofqualifiedelement)) return 1; |
|
| 64 | 64 | |
| 65 | 65 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 66 | 66 | |
| 67 | 67 | require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; |
| 68 | - $b=new BlockedLog($this->db); |
|
| 68 | + $b = new BlockedLog($this->db); |
|
| 69 | 69 | |
| 70 | 70 | // Tracked events |
| 71 | - if (! in_array($action, array_keys($b->trackedevents))) |
|
| 71 | + if (!in_array($action, array_keys($b->trackedevents))) |
|
| 72 | 72 | {
|
| 73 | 73 | return 0; |
| 74 | 74 | } |
@@ -76,19 +76,19 @@ discard block |
||
| 76 | 76 | // Event/record is qualified |
| 77 | 77 | $qualified = 0; |
| 78 | 78 | $amounts = 0; |
| 79 | - if ($action==='BILL_VALIDATE' || $action==='BILL_DELETE' || $action === 'BILL_SENTBYMAIL' |
|
| 80 | - || $action==='BILL_SUPPLIER_VALIDATE' || $action==='BILL_SUPPLIER_DELETE' || $action === 'BILL_SUPPLIER_SENTBYMAIL' |
|
| 81 | - || $action==='MEMBER_SUBSCRIPTION_CREATE' || $action==='MEMBER_SUBSCRIPTION_MODIFY' || $action==='MEMBER_SUBSCRIPTION_DELETE' |
|
| 82 | - || $action==='DON_VALIDATE' || $action==='DON_MODIFY' || $action==='DON_DELETE' |
|
| 83 | - || $action==='CASHCONTROL_VALIDATE' |
|
| 84 | - || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_DOWNLOAD') || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_PREVIEW')
|
|
| 79 | + if ($action === 'BILL_VALIDATE' || $action === 'BILL_DELETE' || $action === 'BILL_SENTBYMAIL' |
|
| 80 | + || $action === 'BILL_SUPPLIER_VALIDATE' || $action === 'BILL_SUPPLIER_DELETE' || $action === 'BILL_SUPPLIER_SENTBYMAIL' |
|
| 81 | + || $action === 'MEMBER_SUBSCRIPTION_CREATE' || $action === 'MEMBER_SUBSCRIPTION_MODIFY' || $action === 'MEMBER_SUBSCRIPTION_DELETE' |
|
| 82 | + || $action === 'DON_VALIDATE' || $action === 'DON_MODIFY' || $action === 'DON_DELETE' |
|
| 83 | + || $action === 'CASHCONTROL_VALIDATE' |
|
| 84 | + || (in_array($object->element, array('facture', 'suplier_invoice')) && $action === 'DOC_DOWNLOAD') || (in_array($object->element, array('facture', 'suplier_invoice')) && $action === 'DOC_PREVIEW')
|
|
| 85 | 85 | ) |
| 86 | 86 | {
|
| 87 | 87 | $qualified++; |
| 88 | 88 | |
| 89 | 89 | if (in_array($action, array( |
| 90 | - 'MEMBER_SUBSCRIPTION_CREATE','MEMBER_SUBSCRIPTION_MODIFY','MEMBER_SUBSCRIPTION_DELETE', |
|
| 91 | - 'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) $amounts = (double) $object->amount; |
|
| 90 | + 'MEMBER_SUBSCRIPTION_CREATE', 'MEMBER_SUBSCRIPTION_MODIFY', 'MEMBER_SUBSCRIPTION_DELETE', |
|
| 91 | + 'DON_VALIDATE', 'DON_MODIFY', 'DON_DELETE'))) $amounts = (double) $object->amount; |
|
| 92 | 92 | elseif ($action == 'CASHCONTROL_VALIDATE') |
| 93 | 93 | {
|
| 94 | 94 | $amounts = (double) $object->cash + (double) $object->cheque + (double) $object->card; |
@@ -106,13 +106,13 @@ discard block |
||
| 106 | 106 | {
|
| 107 | 107 | $qualified++; |
| 108 | 108 | $amounts = 0; |
| 109 | - if(!empty($object->amounts)) {
|
|
| 110 | - foreach($object->amounts as $amount) {
|
|
| 109 | + if (!empty($object->amounts)) {
|
|
| 110 | + foreach ($object->amounts as $amount) {
|
|
| 111 | 111 | $amounts += price2num($amount); |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | - elseif (strpos($action,'PAYMENT')!==false && ! in_array($action, array('PAYMENT_ADD_TO_BANK')))
|
|
| 115 | + elseif (strpos($action, 'PAYMENT') !== false && !in_array($action, array('PAYMENT_ADD_TO_BANK')))
|
|
| 116 | 116 | {
|
| 117 | 117 | $qualified++; |
| 118 | 118 | $amounts = (double) $object->amount; |
@@ -120,12 +120,12 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | // Another protection. |
| 122 | 122 | // May be used when event is DOC_DOWNLOAD or DOC_PREVIEW and element is not an invoice |
| 123 | - if (! $qualified) |
|
| 123 | + if (!$qualified) |
|
| 124 | 124 | {
|
| 125 | 125 | return 0; // not implemented action log |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $result = $b->setObjectData($object, $action, $amounts, $user); // Set field date_object, ref_object, fk_object, element, object_data |
|
| 128 | + $result = $b->setObjectData($object, $action, $amounts, $user); // Set field date_object, ref_object, fk_object, element, object_data |
|
| 129 | 129 | |
| 130 | 130 | if ($result < 0) |
| 131 | 131 | {
|
@@ -56,11 +56,16 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 58 | 58 | {
|
| 59 | - if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing |
|
| 59 | + if (empty($conf->blockedlog->enabled)) { |
|
| 60 | + return 0; |
|
| 61 | + } |
|
| 62 | + // Module not active, we do nothing |
|
| 60 | 63 | |
| 61 | 64 | // Test if event/record is qualified |
| 62 | 65 | $listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription', 'payment_various', 'cashcontrol');
|
| 63 | - if (! in_array($object->element, $listofqualifiedelement)) return 1; |
|
| 66 | + if (! in_array($object->element, $listofqualifiedelement)) { |
|
| 67 | + return 1; |
|
| 68 | + } |
|
| 64 | 69 | |
| 65 | 70 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 66 | 71 | |
@@ -88,12 +93,14 @@ discard block |
||
| 88 | 93 | |
| 89 | 94 | if (in_array($action, array( |
| 90 | 95 | 'MEMBER_SUBSCRIPTION_CREATE','MEMBER_SUBSCRIPTION_MODIFY','MEMBER_SUBSCRIPTION_DELETE', |
| 91 | - 'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) $amounts = (double) $object->amount; |
|
| 92 | - elseif ($action == 'CASHCONTROL_VALIDATE') |
|
| 96 | + 'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) { |
|
| 97 | + $amounts = (double) $object->amount; |
|
| 98 | + } elseif ($action == 'CASHCONTROL_VALIDATE') |
|
| 93 | 99 | {
|
| 94 | 100 | $amounts = (double) $object->cash + (double) $object->cheque + (double) $object->card; |
| 95 | - } |
|
| 96 | - else $amounts = (double) $object->total_ttc; |
|
| 101 | + } else { |
|
| 102 | + $amounts = (double) $object->total_ttc; |
|
| 103 | + } |
|
| 97 | 104 | } |
| 98 | 105 | /*if ($action === 'BILL_PAYED' || $action==='BILL_UNPAYED' |
| 99 | 106 | || $action === 'BILL_SUPPLIER_PAYED' || $action === 'BILL_SUPPLIER_UNPAYED') |
@@ -111,8 +118,7 @@ discard block |
||
| 111 | 118 | $amounts += price2num($amount); |
| 112 | 119 | } |
| 113 | 120 | } |
| 114 | - } |
|
| 115 | - elseif (strpos($action,'PAYMENT')!==false && ! in_array($action, array('PAYMENT_ADD_TO_BANK')))
|
|
| 121 | + } elseif (strpos($action,'PAYMENT')!==false && ! in_array($action, array('PAYMENT_ADD_TO_BANK')))
|
|
| 116 | 122 | {
|
| 117 | 123 | $qualified++; |
| 118 | 124 | $amounts = (double) $object->amount; |
@@ -141,8 +147,7 @@ discard block |
||
| 141 | 147 | $this->error = $b->error; |
| 142 | 148 | $this->errors = $b->errors; |
| 143 | 149 | return -1; |
| 144 | - } |
|
| 145 | - else |
|
| 150 | + } else |
|
| 146 | 151 | {
|
| 147 | 152 | return 1; |
| 148 | 153 | } |
@@ -30,119 +30,119 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | class InterfaceNotification extends DolibarrTriggers |
| 32 | 32 | {
|
| 33 | - public $family = 'notification'; |
|
| 34 | - public $description = "Triggers of this module send email notifications according to Notification module setup."; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Version of the trigger |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 40 | - public $version = self::VERSION_DOLIBARR; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @var string Image of the trigger |
|
| 44 | - */ |
|
| 45 | - public $picto = 'email'; |
|
| 46 | - |
|
| 47 | - // @TODO Defined also into notify.class.php) |
|
| 48 | - public $listofmanagedevents=array( |
|
| 49 | - 'BILL_VALIDATE', |
|
| 50 | - 'BILL_PAYED', |
|
| 51 | - 'ORDER_VALIDATE', |
|
| 52 | - 'PROPAL_VALIDATE', |
|
| 53 | - 'PROPAL_CLOSE_SIGNED', |
|
| 54 | - 'FICHINTER_VALIDATE', |
|
| 55 | - 'FICHINTER_ADD_CONTACT', |
|
| 56 | - 'ORDER_SUPPLIER_VALIDATE', |
|
| 57 | - 'ORDER_SUPPLIER_APPROVE', |
|
| 58 | - 'ORDER_SUPPLIER_REFUSE', |
|
| 59 | - 'SHIPPING_VALIDATE', |
|
| 60 | - 'EXPENSE_REPORT_VALIDATE', |
|
| 61 | - 'EXPENSE_REPORT_APPROVE', |
|
| 62 | - 'HOLIDAY_VALIDATE', |
|
| 63 | - 'HOLIDAY_APPROVE' |
|
| 64 | - ); |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Function called when a Dolibarrr business event is done. |
|
| 68 | - * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) |
|
| 69 | - * |
|
| 70 | - * @param string $action Event action code |
|
| 71 | - * @param Object $object Object |
|
| 72 | - * @param User $user Object user |
|
| 73 | - * @param Translate $langs Object langs |
|
| 74 | - * @param conf $conf Object conf |
|
| 75 | - * @return int <0 if KO, 0 if no triggered ran, >0 if OK |
|
| 76 | - */ |
|
| 77 | - public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
|
| 78 | - {
|
|
| 79 | - if (empty($conf->notification->enabled)) return 0; // Module not active, we do nothing |
|
| 80 | - |
|
| 81 | - require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; |
|
| 82 | - $notify = new Notify($this->db); |
|
| 83 | - |
|
| 84 | - if (! in_array($action, $notify->arrayofnotifsupported)) return 0; |
|
| 85 | - |
|
| 86 | - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 87 | - |
|
| 88 | - $notify->send($action, $object); |
|
| 89 | - |
|
| 90 | - return 1; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Return list of events managed by notification module |
|
| 96 | - * |
|
| 97 | - * @return array Array of events managed by notification module |
|
| 98 | - */ |
|
| 99 | - function getListOfManagedEvents() |
|
| 100 | - {
|
|
| 101 | - global $conf; |
|
| 102 | - |
|
| 103 | - $ret=array(); |
|
| 104 | - |
|
| 105 | - $sql = "SELECT rowid, code, label, description, elementtype"; |
|
| 106 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger"; |
|
| 107 | - $sql.= $this->db->order("rang, elementtype, code");
|
|
| 108 | - dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG);
|
|
| 109 | - $resql=$this->db->query($sql); |
|
| 110 | - if ($resql) |
|
| 111 | - {
|
|
| 112 | - $num=$this->db->num_rows($resql); |
|
| 113 | - $i=0; |
|
| 114 | - while ($i < $num) |
|
| 115 | - {
|
|
| 116 | - $obj=$this->db->fetch_object($resql); |
|
| 117 | - |
|
| 118 | - $qualified=0; |
|
| 119 | - // Check is this event is supported by notification module |
|
| 120 | - if (in_array($obj->code, $this->listofmanagedevents)) $qualified=1; |
|
| 121 | - // Check if module for this event is active |
|
| 122 | - if ($qualified) |
|
| 123 | - {
|
|
| 124 | - //print 'xx'.$obj->code; |
|
| 125 | - $element=$obj->elementtype; |
|
| 126 | - |
|
| 127 | - // Exclude events if related module is disabled |
|
| 128 | - if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0; |
|
| 129 | - elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0; |
|
| 130 | - elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0; |
|
| 131 | - elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0; |
|
| 132 | - elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0; |
|
| 133 | - elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member','expensereport')) && empty($conf->$element->enabled)) $qualified=0;
|
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - if ($qualified) |
|
| 137 | - {
|
|
| 138 | - $ret[]=array('rowid'=>$obj->rowid,'code'=>$obj->code,'label'=>$obj->label,'description'=>$obj->description,'elementtype'=>$obj->elementtype);
|
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - $i++; |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - else dol_print_error($this->db); |
|
| 145 | - |
|
| 146 | - return $ret; |
|
| 147 | - } |
|
| 33 | + public $family = 'notification'; |
|
| 34 | + public $description = "Triggers of this module send email notifications according to Notification module setup."; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Version of the trigger |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | + public $version = self::VERSION_DOLIBARR; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @var string Image of the trigger |
|
| 44 | + */ |
|
| 45 | + public $picto = 'email'; |
|
| 46 | + |
|
| 47 | + // @TODO Defined also into notify.class.php) |
|
| 48 | + public $listofmanagedevents=array( |
|
| 49 | + 'BILL_VALIDATE', |
|
| 50 | + 'BILL_PAYED', |
|
| 51 | + 'ORDER_VALIDATE', |
|
| 52 | + 'PROPAL_VALIDATE', |
|
| 53 | + 'PROPAL_CLOSE_SIGNED', |
|
| 54 | + 'FICHINTER_VALIDATE', |
|
| 55 | + 'FICHINTER_ADD_CONTACT', |
|
| 56 | + 'ORDER_SUPPLIER_VALIDATE', |
|
| 57 | + 'ORDER_SUPPLIER_APPROVE', |
|
| 58 | + 'ORDER_SUPPLIER_REFUSE', |
|
| 59 | + 'SHIPPING_VALIDATE', |
|
| 60 | + 'EXPENSE_REPORT_VALIDATE', |
|
| 61 | + 'EXPENSE_REPORT_APPROVE', |
|
| 62 | + 'HOLIDAY_VALIDATE', |
|
| 63 | + 'HOLIDAY_APPROVE' |
|
| 64 | + ); |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * Function called when a Dolibarrr business event is done. |
|
| 68 | + * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) |
|
| 69 | + * |
|
| 70 | + * @param string $action Event action code |
|
| 71 | + * @param Object $object Object |
|
| 72 | + * @param User $user Object user |
|
| 73 | + * @param Translate $langs Object langs |
|
| 74 | + * @param conf $conf Object conf |
|
| 75 | + * @return int <0 if KO, 0 if no triggered ran, >0 if OK |
|
| 76 | + */ |
|
| 77 | + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
|
| 78 | + {
|
|
| 79 | + if (empty($conf->notification->enabled)) return 0; // Module not active, we do nothing |
|
| 80 | + |
|
| 81 | + require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; |
|
| 82 | + $notify = new Notify($this->db); |
|
| 83 | + |
|
| 84 | + if (! in_array($action, $notify->arrayofnotifsupported)) return 0; |
|
| 85 | + |
|
| 86 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 87 | + |
|
| 88 | + $notify->send($action, $object); |
|
| 89 | + |
|
| 90 | + return 1; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Return list of events managed by notification module |
|
| 96 | + * |
|
| 97 | + * @return array Array of events managed by notification module |
|
| 98 | + */ |
|
| 99 | + function getListOfManagedEvents() |
|
| 100 | + {
|
|
| 101 | + global $conf; |
|
| 102 | + |
|
| 103 | + $ret=array(); |
|
| 104 | + |
|
| 105 | + $sql = "SELECT rowid, code, label, description, elementtype"; |
|
| 106 | + $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger"; |
|
| 107 | + $sql.= $this->db->order("rang, elementtype, code");
|
|
| 108 | + dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG);
|
|
| 109 | + $resql=$this->db->query($sql); |
|
| 110 | + if ($resql) |
|
| 111 | + {
|
|
| 112 | + $num=$this->db->num_rows($resql); |
|
| 113 | + $i=0; |
|
| 114 | + while ($i < $num) |
|
| 115 | + {
|
|
| 116 | + $obj=$this->db->fetch_object($resql); |
|
| 117 | + |
|
| 118 | + $qualified=0; |
|
| 119 | + // Check is this event is supported by notification module |
|
| 120 | + if (in_array($obj->code, $this->listofmanagedevents)) $qualified=1; |
|
| 121 | + // Check if module for this event is active |
|
| 122 | + if ($qualified) |
|
| 123 | + {
|
|
| 124 | + //print 'xx'.$obj->code; |
|
| 125 | + $element=$obj->elementtype; |
|
| 126 | + |
|
| 127 | + // Exclude events if related module is disabled |
|
| 128 | + if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0; |
|
| 129 | + elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0; |
|
| 130 | + elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0; |
|
| 131 | + elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0; |
|
| 132 | + elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0; |
|
| 133 | + elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member','expensereport')) && empty($conf->$element->enabled)) $qualified=0;
|
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + if ($qualified) |
|
| 137 | + {
|
|
| 138 | + $ret[]=array('rowid'=>$obj->rowid,'code'=>$obj->code,'label'=>$obj->label,'description'=>$obj->description,'elementtype'=>$obj->elementtype);
|
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + $i++; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + else dol_print_error($this->db); |
|
| 145 | + |
|
| 146 | + return $ret; |
|
| 147 | + } |
|
| 148 | 148 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | public $picto = 'email'; |
| 46 | 46 | |
| 47 | 47 | // @TODO Defined also into notify.class.php) |
| 48 | - public $listofmanagedevents=array( |
|
| 48 | + public $listofmanagedevents = array( |
|
| 49 | 49 | 'BILL_VALIDATE', |
| 50 | 50 | 'BILL_PAYED', |
| 51 | 51 | 'ORDER_VALIDATE', |
@@ -76,12 +76,12 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 78 | 78 | {
|
| 79 | - if (empty($conf->notification->enabled)) return 0; // Module not active, we do nothing |
|
| 79 | + if (empty($conf->notification->enabled)) return 0; // Module not active, we do nothing |
|
| 80 | 80 | |
| 81 | - require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; |
|
| 81 | + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; |
|
| 82 | 82 | $notify = new Notify($this->db); |
| 83 | 83 | |
| 84 | - if (! in_array($action, $notify->arrayofnotifsupported)) return 0; |
|
| 84 | + if (!in_array($action, $notify->arrayofnotifsupported)) return 0; |
|
| 85 | 85 | |
| 86 | 86 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 87 | 87 | |
@@ -100,42 +100,42 @@ discard block |
||
| 100 | 100 | {
|
| 101 | 101 | global $conf; |
| 102 | 102 | |
| 103 | - $ret=array(); |
|
| 103 | + $ret = array(); |
|
| 104 | 104 | |
| 105 | 105 | $sql = "SELECT rowid, code, label, description, elementtype"; |
| 106 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger"; |
|
| 107 | - $sql.= $this->db->order("rang, elementtype, code");
|
|
| 106 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger"; |
|
| 107 | + $sql .= $this->db->order("rang, elementtype, code");
|
|
| 108 | 108 | dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG);
|
| 109 | - $resql=$this->db->query($sql); |
|
| 109 | + $resql = $this->db->query($sql); |
|
| 110 | 110 | if ($resql) |
| 111 | 111 | {
|
| 112 | - $num=$this->db->num_rows($resql); |
|
| 113 | - $i=0; |
|
| 112 | + $num = $this->db->num_rows($resql); |
|
| 113 | + $i = 0; |
|
| 114 | 114 | while ($i < $num) |
| 115 | 115 | {
|
| 116 | - $obj=$this->db->fetch_object($resql); |
|
| 116 | + $obj = $this->db->fetch_object($resql); |
|
| 117 | 117 | |
| 118 | - $qualified=0; |
|
| 118 | + $qualified = 0; |
|
| 119 | 119 | // Check is this event is supported by notification module |
| 120 | - if (in_array($obj->code, $this->listofmanagedevents)) $qualified=1; |
|
| 120 | + if (in_array($obj->code, $this->listofmanagedevents)) $qualified = 1; |
|
| 121 | 121 | // Check if module for this event is active |
| 122 | 122 | if ($qualified) |
| 123 | 123 | {
|
| 124 | 124 | //print 'xx'.$obj->code; |
| 125 | - $element=$obj->elementtype; |
|
| 125 | + $element = $obj->elementtype; |
|
| 126 | 126 | |
| 127 | 127 | // Exclude events if related module is disabled |
| 128 | - if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0; |
|
| 129 | - elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0; |
|
| 130 | - elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0; |
|
| 131 | - elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0; |
|
| 132 | - elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0; |
|
| 133 | - elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member','expensereport')) && empty($conf->$element->enabled)) $qualified=0;
|
|
| 128 | + if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified = 0; |
|
| 129 | + elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified = 0; |
|
| 130 | + elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified = 0; |
|
| 131 | + elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified = 0; |
|
| 132 | + elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified = 0; |
|
| 133 | + elseif (!in_array($element, array('order_supplier', 'invoice_supplier', 'withdraw', 'shipping', 'member', 'expensereport')) && empty($conf->$element->enabled)) $qualified = 0;
|
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | if ($qualified) |
| 137 | 137 | {
|
| 138 | - $ret[]=array('rowid'=>$obj->rowid,'code'=>$obj->code,'label'=>$obj->label,'description'=>$obj->description,'elementtype'=>$obj->elementtype);
|
|
| 138 | + $ret[] = array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$obj->label, 'description'=>$obj->description, 'elementtype'=>$obj->elementtype);
|
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $i++; |
@@ -76,12 +76,17 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 78 | 78 | {
|
| 79 | - if (empty($conf->notification->enabled)) return 0; // Module not active, we do nothing |
|
| 79 | + if (empty($conf->notification->enabled)) { |
|
| 80 | + return 0; |
|
| 81 | + } |
|
| 82 | + // Module not active, we do nothing |
|
| 80 | 83 | |
| 81 | 84 | require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; |
| 82 | 85 | $notify = new Notify($this->db); |
| 83 | 86 | |
| 84 | - if (! in_array($action, $notify->arrayofnotifsupported)) return 0; |
|
| 87 | + if (! in_array($action, $notify->arrayofnotifsupported)) { |
|
| 88 | + return 0; |
|
| 89 | + } |
|
| 85 | 90 | |
| 86 | 91 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 87 | 92 | |
@@ -117,7 +122,9 @@ discard block |
||
| 117 | 122 | |
| 118 | 123 | $qualified=0; |
| 119 | 124 | // Check is this event is supported by notification module |
| 120 | - if (in_array($obj->code, $this->listofmanagedevents)) $qualified=1; |
|
| 125 | + if (in_array($obj->code, $this->listofmanagedevents)) { |
|
| 126 | + $qualified=1; |
|
| 127 | + } |
|
| 121 | 128 | // Check if module for this event is active |
| 122 | 129 | if ($qualified) |
| 123 | 130 | {
|
@@ -125,12 +132,19 @@ discard block |
||
| 125 | 132 | $element=$obj->elementtype; |
| 126 | 133 | |
| 127 | 134 | // Exclude events if related module is disabled |
| 128 | - if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0; |
|
| 129 | - elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0; |
|
| 130 | - elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0; |
|
| 131 | - elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0; |
|
| 132 | - elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0; |
|
| 133 | - elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member','expensereport')) && empty($conf->$element->enabled)) $qualified=0;
|
|
| 135 | + if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) { |
|
| 136 | + $qualified=0; |
|
| 137 | + } elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) { |
|
| 138 | + $qualified=0; |
|
| 139 | + } elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) { |
|
| 140 | + $qualified=0; |
|
| 141 | + } elseif ($element == 'shipping' && empty($conf->expedition->enabled)) { |
|
| 142 | + $qualified=0; |
|
| 143 | + } elseif ($element == 'member' && empty($conf->adherent->enabled)) { |
|
| 144 | + $qualified=0; |
|
| 145 | + } elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member','expensereport')) && empty($conf->$element->enabled)) { |
|
| 146 | + $qualified=0; |
|
| 147 | + } |
|
| 134 | 148 | } |
| 135 | 149 | |
| 136 | 150 | if ($qualified) |
@@ -140,8 +154,9 @@ discard block |
||
| 140 | 154 | |
| 141 | 155 | $i++; |
| 142 | 156 | } |
| 143 | - } |
|
| 144 | - else dol_print_error($this->db); |
|
| 157 | + } else { |
|
| 158 | + dol_print_error($this->db); |
|
| 159 | + } |
|
| 145 | 160 | |
| 146 | 161 | return $ret; |
| 147 | 162 | } |
@@ -107,233 +107,233 @@ |
||
| 107 | 107 | */ |
| 108 | 108 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 109 | 109 | {
|
| 110 | - $ok = 0; |
|
| 111 | - |
|
| 112 | - switch ($action) {
|
|
| 113 | - case 'TICKET_ASSIGNED': |
|
| 114 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 115 | - |
|
| 116 | - if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id) |
|
| 117 | - {
|
|
| 118 | - $userstat = new User($this->db); |
|
| 119 | - $res = $userstat->fetch($object->fk_user_assign); |
|
| 120 | - if ($res > 0) |
|
| 121 | - {
|
|
| 122 | - if (empty($conf->global->TICKET_DISABLE_ALL_MAILS)) |
|
| 123 | - {
|
|
| 124 | - // Init to avoid errors |
|
| 125 | - $filepath = array(); |
|
| 126 | - $filename = array(); |
|
| 127 | - $mimetype = array(); |
|
| 128 | - |
|
| 129 | - // Send email to assigned user |
|
| 130 | - $subject = '[' . $conf->global->MAIN_INFO_SOCIETE_NOM . '] ' . $langs->transnoentities('TicketAssignedToYou');
|
|
| 131 | - $message = '<p>' . $langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname)) . "</p>";
|
|
| 132 | - $message .= '<ul><li>' . $langs->trans('Title') . ' : ' . $object->subject . '</li>';
|
|
| 133 | - $message .= '<li>' . $langs->trans('Type') . ' : ' . $object->type_label . '</li>';
|
|
| 134 | - $message .= '<li>' . $langs->trans('Category') . ' : ' . $object->category_label . '</li>';
|
|
| 135 | - $message .= '<li>' . $langs->trans('Severity') . ' : ' . $object->severity_label . '</li>';
|
|
| 136 | - // Extrafields |
|
| 137 | - if (is_array($object->array_options) && count($object->array_options) > 0) {
|
|
| 138 | - foreach ($object->array_options as $key => $value) {
|
|
| 139 | - $message .= '<li>' . $langs->trans($key) . ' : ' . $value . '</li>'; |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - $message .= '</ul>'; |
|
| 144 | - $message .= '<p>' . $langs->trans('Message') . ' : <br>' . $object->message . '</p>';
|
|
| 145 | - $message .= '<p><a href="' . dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id . '">' . $langs->trans('SeeThisTicketIntomanagementInterface') . '</a></p>';
|
|
| 146 | - |
|
| 147 | - $sendto = $userstat->email; |
|
| 148 | - $from = dolGetFirstLastname($user->firstname, $user->lastname) . '<' . $user->email . '>'; |
|
| 149 | - |
|
| 150 | - $message = dol_nl2br($message); |
|
| 151 | - |
|
| 152 | - if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
| 153 | - $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; |
|
| 154 | - $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; |
|
| 155 | - } |
|
| 156 | - include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; |
|
| 157 | - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1); |
|
| 158 | - if ($mailfile->error) {
|
|
| 159 | - setEventMessages($mailfile->error, $mailfile->errors, 'errors'); |
|
| 160 | - } else {
|
|
| 161 | - $result = $mailfile->sendfile(); |
|
| 162 | - } |
|
| 163 | - if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
| 164 | - $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; |
|
| 165 | - } |
|
| 166 | - } |
|
| 110 | + $ok = 0; |
|
| 111 | + |
|
| 112 | + switch ($action) {
|
|
| 113 | + case 'TICKET_ASSIGNED': |
|
| 114 | + dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 115 | + |
|
| 116 | + if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id) |
|
| 117 | + {
|
|
| 118 | + $userstat = new User($this->db); |
|
| 119 | + $res = $userstat->fetch($object->fk_user_assign); |
|
| 120 | + if ($res > 0) |
|
| 121 | + {
|
|
| 122 | + if (empty($conf->global->TICKET_DISABLE_ALL_MAILS)) |
|
| 123 | + {
|
|
| 124 | + // Init to avoid errors |
|
| 125 | + $filepath = array(); |
|
| 126 | + $filename = array(); |
|
| 127 | + $mimetype = array(); |
|
| 128 | + |
|
| 129 | + // Send email to assigned user |
|
| 130 | + $subject = '[' . $conf->global->MAIN_INFO_SOCIETE_NOM . '] ' . $langs->transnoentities('TicketAssignedToYou');
|
|
| 131 | + $message = '<p>' . $langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname)) . "</p>";
|
|
| 132 | + $message .= '<ul><li>' . $langs->trans('Title') . ' : ' . $object->subject . '</li>';
|
|
| 133 | + $message .= '<li>' . $langs->trans('Type') . ' : ' . $object->type_label . '</li>';
|
|
| 134 | + $message .= '<li>' . $langs->trans('Category') . ' : ' . $object->category_label . '</li>';
|
|
| 135 | + $message .= '<li>' . $langs->trans('Severity') . ' : ' . $object->severity_label . '</li>';
|
|
| 136 | + // Extrafields |
|
| 137 | + if (is_array($object->array_options) && count($object->array_options) > 0) {
|
|
| 138 | + foreach ($object->array_options as $key => $value) {
|
|
| 139 | + $message .= '<li>' . $langs->trans($key) . ' : ' . $value . '</li>'; |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + $message .= '</ul>'; |
|
| 144 | + $message .= '<p>' . $langs->trans('Message') . ' : <br>' . $object->message . '</p>';
|
|
| 145 | + $message .= '<p><a href="' . dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id . '">' . $langs->trans('SeeThisTicketIntomanagementInterface') . '</a></p>';
|
|
| 146 | + |
|
| 147 | + $sendto = $userstat->email; |
|
| 148 | + $from = dolGetFirstLastname($user->firstname, $user->lastname) . '<' . $user->email . '>'; |
|
| 149 | + |
|
| 150 | + $message = dol_nl2br($message); |
|
| 151 | + |
|
| 152 | + if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
| 153 | + $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; |
|
| 154 | + $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; |
|
| 155 | + } |
|
| 156 | + include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; |
|
| 157 | + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1); |
|
| 158 | + if ($mailfile->error) {
|
|
| 159 | + setEventMessages($mailfile->error, $mailfile->errors, 'errors'); |
|
| 160 | + } else {
|
|
| 161 | + $result = $mailfile->sendfile(); |
|
| 162 | + } |
|
| 163 | + if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
| 164 | + $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | 168 | $ok = 1; |
| 169 | - } |
|
| 170 | - else |
|
| 171 | - {
|
|
| 172 | - $this->error = $userstat->error; |
|
| 173 | - $this->errors = $userstat->errors; |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - break; |
|
| 177 | - |
|
| 178 | - case 'TICKET_CREATE': |
|
| 179 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 180 | - |
|
| 181 | - $langs->load('ticket');
|
|
| 182 | - |
|
| 183 | - $object->fetch('', $object->track_id); // Should be useless
|
|
| 184 | - |
|
| 185 | - |
|
| 186 | - // Send email to notification email |
|
| 187 | - |
|
| 188 | - if (empty($conf->global->TICKET_DISABLE_ALL_MAILS) && empty($object->context['disableticketemail'])) |
|
| 189 | - {
|
|
| 190 | - $sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; |
|
| 191 | - |
|
| 192 | - if ($sendto) |
|
| 193 | - {
|
|
| 194 | - // Init to avoid errors |
|
| 195 | - $filepath = array(); |
|
| 196 | - $filename = array(); |
|
| 197 | - $mimetype = array(); |
|
| 198 | - |
|
| 199 | - /* Send email to admin */ |
|
| 200 | - $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin');
|
|
| 201 | - $message_admin= $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
|
|
| 202 | - $message_admin.='<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
|
|
| 203 | - $message_admin.='<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
|
|
| 204 | - $message_admin.='<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
|
|
| 205 | - $message_admin.='<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
|
|
| 206 | - $message_admin.='<li>'.$langs->trans('From').' : '.( $object->email_from ? $object->email_from : ( $object->fk_user_create > 0 ? $langs->trans('Internal') : '') ).'</li>';
|
|
| 207 | - // Extrafields |
|
| 208 | - if (is_array($object->array_options) && count($object->array_options) > 0) {
|
|
| 209 | - foreach ($object->array_options as $key => $value) {
|
|
| 210 | - $message_admin.='<li>'.$langs->trans($key).' : '.$value.'</li>'; |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - $message_admin.='</ul>'; |
|
| 214 | - |
|
| 215 | - if ($object->fk_soc > 0) {
|
|
| 216 | - $object->fetch_thirdparty(); |
|
| 217 | - $message_admin.='<p>'.$langs->trans('Company'). ' : '.$object->thirdparty->name.'</p>';
|
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - $message_admin.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
|
|
| 221 | - $message_admin.='<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
|
|
| 222 | - |
|
| 223 | - $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>'; |
|
| 224 | - $replyto = $from; |
|
| 225 | - |
|
| 226 | - $message_admin = dol_nl2br($message_admin); |
|
| 227 | - |
|
| 228 | - if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
| 229 | - $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; |
|
| 230 | - $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; |
|
| 231 | - } |
|
| 232 | - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; |
|
| 233 | - $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1); |
|
| 234 | - if ($mailfile->error) {
|
|
| 235 | - dol_syslog($mailfile->error, LOG_DEBUG); |
|
| 236 | - } else {
|
|
| 237 | - $result=$mailfile->sendfile(); |
|
| 238 | - } |
|
| 239 | - if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
| 240 | - $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; |
|
| 241 | - } |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - // Send email to customer |
|
| 246 | - |
|
| 247 | - if (empty($conf->global->TICKET_DISABLE_ALL_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create) |
|
| 248 | - {
|
|
| 249 | - $sendto = ''; |
|
| 250 | - if (empty($user->socid) && empty($user->email)) {
|
|
| 251 | - $object->fetch_thirdparty(); |
|
| 252 | - $sendto = $object->thirdparty->email; |
|
| 253 | - } else {
|
|
| 254 | - $sendto = $user->email; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - if ($sendto) {
|
|
| 258 | - // Init to avoid errors |
|
| 259 | - $filepath = array(); |
|
| 260 | - $filename = array(); |
|
| 261 | - $mimetype = array(); |
|
| 262 | - |
|
| 263 | - $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectCustomer');
|
|
| 264 | - $message_customer= $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id)."\n\n";
|
|
| 265 | - $message_customer.='<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
|
|
| 266 | - $message_customer.='<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
|
|
| 267 | - $message_customer.='<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
|
|
| 268 | - $message_customer.='<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
|
|
| 269 | - |
|
| 270 | - // Extrafields |
|
| 271 | - foreach ($this->attributes[$object->table_element]['label'] as $key => $value) |
|
| 272 | - {
|
|
| 273 | - $enabled = 1; |
|
| 274 | - if ($enabled && isset($this->attributes[$object->table_element]['list'][$key])) |
|
| 275 | - {
|
|
| 276 | - $enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1); |
|
| 277 | - } |
|
| 278 | - $perms = 1; |
|
| 279 | - if ($perms && isset($this->attributes[$object->table_element]['perms'][$key])) |
|
| 280 | - {
|
|
| 281 | - $perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1); |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - $qualified = true; |
|
| 285 | - if (empty($enabled)) $qualified = false; |
|
| 286 | - if (empty($perms)) $qualified = false; |
|
| 287 | - |
|
| 288 | - if ($qualified) $message_customer.='<li>'.$langs->trans($key).' : '.$value.'</li>'; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - $message_customer.='</ul>'; |
|
| 292 | - $message_customer.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
|
|
| 293 | - $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE?$conf->global->TICKET_URL_PUBLIC_INTERFACE.'/':dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id;
|
|
| 294 | - $message_customer.='<p>' . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : <a href="'.$url_public_ticket.'">'.$url_public_ticket.'</a></p>';
|
|
| 295 | - $message_customer.='<p>'.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'</p>';
|
|
| 296 | - |
|
| 297 | - $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>'; |
|
| 298 | - $replyto = $from; |
|
| 299 | - |
|
| 300 | - $message_customer = dol_nl2br($message_customer); |
|
| 301 | - |
|
| 302 | - if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
| 303 | - $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; |
|
| 304 | - $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; |
|
| 305 | - } |
|
| 306 | - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; |
|
| 307 | - $mailfile = new CMailFile($subject, $sendto, $from, $message_customer, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1); |
|
| 308 | - if ($mailfile->error) {
|
|
| 309 | - dol_syslog($mailfile->error, LOG_DEBUG); |
|
| 310 | - } else {
|
|
| 311 | - $result=$mailfile->sendfile(); |
|
| 312 | - } |
|
| 313 | - if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
| 314 | - $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; |
|
| 315 | - } |
|
| 316 | - } |
|
| 317 | - } |
|
| 169 | + } |
|
| 170 | + else |
|
| 171 | + {
|
|
| 172 | + $this->error = $userstat->error; |
|
| 173 | + $this->errors = $userstat->errors; |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + break; |
|
| 177 | + |
|
| 178 | + case 'TICKET_CREATE': |
|
| 179 | + dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 180 | + |
|
| 181 | + $langs->load('ticket');
|
|
| 182 | + |
|
| 183 | + $object->fetch('', $object->track_id); // Should be useless
|
|
| 184 | + |
|
| 185 | + |
|
| 186 | + // Send email to notification email |
|
| 187 | + |
|
| 188 | + if (empty($conf->global->TICKET_DISABLE_ALL_MAILS) && empty($object->context['disableticketemail'])) |
|
| 189 | + {
|
|
| 190 | + $sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; |
|
| 191 | + |
|
| 192 | + if ($sendto) |
|
| 193 | + {
|
|
| 194 | + // Init to avoid errors |
|
| 195 | + $filepath = array(); |
|
| 196 | + $filename = array(); |
|
| 197 | + $mimetype = array(); |
|
| 198 | + |
|
| 199 | + /* Send email to admin */ |
|
| 200 | + $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin');
|
|
| 201 | + $message_admin= $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
|
|
| 202 | + $message_admin.='<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
|
|
| 203 | + $message_admin.='<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
|
|
| 204 | + $message_admin.='<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
|
|
| 205 | + $message_admin.='<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
|
|
| 206 | + $message_admin.='<li>'.$langs->trans('From').' : '.( $object->email_from ? $object->email_from : ( $object->fk_user_create > 0 ? $langs->trans('Internal') : '') ).'</li>';
|
|
| 207 | + // Extrafields |
|
| 208 | + if (is_array($object->array_options) && count($object->array_options) > 0) {
|
|
| 209 | + foreach ($object->array_options as $key => $value) {
|
|
| 210 | + $message_admin.='<li>'.$langs->trans($key).' : '.$value.'</li>'; |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + $message_admin.='</ul>'; |
|
| 214 | + |
|
| 215 | + if ($object->fk_soc > 0) {
|
|
| 216 | + $object->fetch_thirdparty(); |
|
| 217 | + $message_admin.='<p>'.$langs->trans('Company'). ' : '.$object->thirdparty->name.'</p>';
|
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + $message_admin.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
|
|
| 221 | + $message_admin.='<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
|
|
| 222 | + |
|
| 223 | + $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>'; |
|
| 224 | + $replyto = $from; |
|
| 225 | + |
|
| 226 | + $message_admin = dol_nl2br($message_admin); |
|
| 227 | + |
|
| 228 | + if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
| 229 | + $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; |
|
| 230 | + $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; |
|
| 231 | + } |
|
| 232 | + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; |
|
| 233 | + $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1); |
|
| 234 | + if ($mailfile->error) {
|
|
| 235 | + dol_syslog($mailfile->error, LOG_DEBUG); |
|
| 236 | + } else {
|
|
| 237 | + $result=$mailfile->sendfile(); |
|
| 238 | + } |
|
| 239 | + if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
| 240 | + $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + // Send email to customer |
|
| 246 | + |
|
| 247 | + if (empty($conf->global->TICKET_DISABLE_ALL_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create) |
|
| 248 | + {
|
|
| 249 | + $sendto = ''; |
|
| 250 | + if (empty($user->socid) && empty($user->email)) {
|
|
| 251 | + $object->fetch_thirdparty(); |
|
| 252 | + $sendto = $object->thirdparty->email; |
|
| 253 | + } else {
|
|
| 254 | + $sendto = $user->email; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + if ($sendto) {
|
|
| 258 | + // Init to avoid errors |
|
| 259 | + $filepath = array(); |
|
| 260 | + $filename = array(); |
|
| 261 | + $mimetype = array(); |
|
| 262 | + |
|
| 263 | + $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectCustomer');
|
|
| 264 | + $message_customer= $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id)."\n\n";
|
|
| 265 | + $message_customer.='<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
|
|
| 266 | + $message_customer.='<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
|
|
| 267 | + $message_customer.='<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
|
|
| 268 | + $message_customer.='<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
|
|
| 269 | + |
|
| 270 | + // Extrafields |
|
| 271 | + foreach ($this->attributes[$object->table_element]['label'] as $key => $value) |
|
| 272 | + {
|
|
| 273 | + $enabled = 1; |
|
| 274 | + if ($enabled && isset($this->attributes[$object->table_element]['list'][$key])) |
|
| 275 | + {
|
|
| 276 | + $enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1); |
|
| 277 | + } |
|
| 278 | + $perms = 1; |
|
| 279 | + if ($perms && isset($this->attributes[$object->table_element]['perms'][$key])) |
|
| 280 | + {
|
|
| 281 | + $perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1); |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + $qualified = true; |
|
| 285 | + if (empty($enabled)) $qualified = false; |
|
| 286 | + if (empty($perms)) $qualified = false; |
|
| 287 | + |
|
| 288 | + if ($qualified) $message_customer.='<li>'.$langs->trans($key).' : '.$value.'</li>'; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + $message_customer.='</ul>'; |
|
| 292 | + $message_customer.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
|
|
| 293 | + $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE?$conf->global->TICKET_URL_PUBLIC_INTERFACE.'/':dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id;
|
|
| 294 | + $message_customer.='<p>' . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : <a href="'.$url_public_ticket.'">'.$url_public_ticket.'</a></p>';
|
|
| 295 | + $message_customer.='<p>'.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'</p>';
|
|
| 296 | + |
|
| 297 | + $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>'; |
|
| 298 | + $replyto = $from; |
|
| 299 | + |
|
| 300 | + $message_customer = dol_nl2br($message_customer); |
|
| 301 | + |
|
| 302 | + if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
| 303 | + $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; |
|
| 304 | + $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; |
|
| 305 | + } |
|
| 306 | + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; |
|
| 307 | + $mailfile = new CMailFile($subject, $sendto, $from, $message_customer, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1); |
|
| 308 | + if ($mailfile->error) {
|
|
| 309 | + dol_syslog($mailfile->error, LOG_DEBUG); |
|
| 310 | + } else {
|
|
| 311 | + $result=$mailfile->sendfile(); |
|
| 312 | + } |
|
| 313 | + if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
| 314 | + $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | 318 | $ok = 1; |
| 319 | - break; |
|
| 319 | + break; |
|
| 320 | 320 | |
| 321 | 321 | case 'TICKET_DELETE': |
| 322 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 323 | - break; |
|
| 322 | + dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 323 | + break; |
|
| 324 | 324 | |
| 325 | - case 'TICKET_MODIFY': |
|
| 326 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 327 | - break; |
|
| 325 | + case 'TICKET_MODIFY': |
|
| 326 | + dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 327 | + break; |
|
| 328 | 328 | |
| 329 | - case 'TICKET_MARK_READ': |
|
| 330 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 331 | - break; |
|
| 329 | + case 'TICKET_MARK_READ': |
|
| 330 | + dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 331 | + break; |
|
| 332 | 332 | |
| 333 | - case 'TICKET_CLOSE': |
|
| 334 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 335 | - break; |
|
| 336 | - } |
|
| 333 | + case 'TICKET_CLOSE': |
|
| 334 | + dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 335 | + break; |
|
| 336 | + } |
|
| 337 | 337 | |
| 338 | 338 | |
| 339 | 339 | return $ok; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | switch ($action) {
|
| 113 | 113 | case 'TICKET_ASSIGNED': |
| 114 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 114 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 115 | 115 | |
| 116 | 116 | if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id) |
| 117 | 117 | {
|
@@ -127,25 +127,25 @@ discard block |
||
| 127 | 127 | $mimetype = array(); |
| 128 | 128 | |
| 129 | 129 | // Send email to assigned user |
| 130 | - $subject = '[' . $conf->global->MAIN_INFO_SOCIETE_NOM . '] ' . $langs->transnoentities('TicketAssignedToYou');
|
|
| 131 | - $message = '<p>' . $langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname)) . "</p>";
|
|
| 132 | - $message .= '<ul><li>' . $langs->trans('Title') . ' : ' . $object->subject . '</li>';
|
|
| 133 | - $message .= '<li>' . $langs->trans('Type') . ' : ' . $object->type_label . '</li>';
|
|
| 134 | - $message .= '<li>' . $langs->trans('Category') . ' : ' . $object->category_label . '</li>';
|
|
| 135 | - $message .= '<li>' . $langs->trans('Severity') . ' : ' . $object->severity_label . '</li>';
|
|
| 130 | + $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketAssignedToYou');
|
|
| 131 | + $message = '<p>'.$langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname))."</p>";
|
|
| 132 | + $message .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
|
|
| 133 | + $message .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
|
|
| 134 | + $message .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
|
|
| 135 | + $message .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
|
|
| 136 | 136 | // Extrafields |
| 137 | 137 | if (is_array($object->array_options) && count($object->array_options) > 0) {
|
| 138 | 138 | foreach ($object->array_options as $key => $value) {
|
| 139 | - $message .= '<li>' . $langs->trans($key) . ' : ' . $value . '</li>'; |
|
| 139 | + $message .= '<li>'.$langs->trans($key).' : '.$value.'</li>'; |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | $message .= '</ul>'; |
| 144 | - $message .= '<p>' . $langs->trans('Message') . ' : <br>' . $object->message . '</p>';
|
|
| 145 | - $message .= '<p><a href="' . dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id . '">' . $langs->trans('SeeThisTicketIntomanagementInterface') . '</a></p>';
|
|
| 144 | + $message .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
|
|
| 145 | + $message .= '<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
|
|
| 146 | 146 | |
| 147 | 147 | $sendto = $userstat->email; |
| 148 | - $from = dolGetFirstLastname($user->firstname, $user->lastname) . '<' . $user->email . '>'; |
|
| 148 | + $from = dolGetFirstLastname($user->firstname, $user->lastname).'<'.$user->email.'>'; |
|
| 149 | 149 | |
| 150 | 150 | $message = dol_nl2br($message); |
| 151 | 151 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; |
| 154 | 154 | $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; |
| 155 | 155 | } |
| 156 | - include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; |
|
| 156 | + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; |
|
| 157 | 157 | $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1); |
| 158 | 158 | if ($mailfile->error) {
|
| 159 | 159 | setEventMessages($mailfile->error, $mailfile->errors, 'errors'); |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | break; |
| 177 | 177 | |
| 178 | 178 | case 'TICKET_CREATE': |
| 179 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 179 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 180 | 180 | |
| 181 | 181 | $langs->load('ticket');
|
| 182 | 182 | |
| 183 | - $object->fetch('', $object->track_id); // Should be useless
|
|
| 183 | + $object->fetch('', $object->track_id); // Should be useless
|
|
| 184 | 184 | |
| 185 | 185 | |
| 186 | 186 | // Send email to notification email |
@@ -198,27 +198,27 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | /* Send email to admin */ |
| 200 | 200 | $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin');
|
| 201 | - $message_admin= $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
|
|
| 202 | - $message_admin.='<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
|
|
| 203 | - $message_admin.='<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
|
|
| 204 | - $message_admin.='<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
|
|
| 205 | - $message_admin.='<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
|
|
| 206 | - $message_admin.='<li>'.$langs->trans('From').' : '.( $object->email_from ? $object->email_from : ( $object->fk_user_create > 0 ? $langs->trans('Internal') : '') ).'</li>';
|
|
| 201 | + $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
|
|
| 202 | + $message_admin .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
|
|
| 203 | + $message_admin .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
|
|
| 204 | + $message_admin .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
|
|
| 205 | + $message_admin .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
|
|
| 206 | + $message_admin .= '<li>'.$langs->trans('From').' : '.($object->email_from ? $object->email_from : ($object->fk_user_create > 0 ? $langs->trans('Internal') : '')).'</li>';
|
|
| 207 | 207 | // Extrafields |
| 208 | 208 | if (is_array($object->array_options) && count($object->array_options) > 0) {
|
| 209 | 209 | foreach ($object->array_options as $key => $value) {
|
| 210 | - $message_admin.='<li>'.$langs->trans($key).' : '.$value.'</li>'; |
|
| 210 | + $message_admin .= '<li>'.$langs->trans($key).' : '.$value.'</li>'; |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | - $message_admin.='</ul>'; |
|
| 213 | + $message_admin .= '</ul>'; |
|
| 214 | 214 | |
| 215 | 215 | if ($object->fk_soc > 0) {
|
| 216 | 216 | $object->fetch_thirdparty(); |
| 217 | - $message_admin.='<p>'.$langs->trans('Company'). ' : '.$object->thirdparty->name.'</p>';
|
|
| 217 | + $message_admin .= '<p>'.$langs->trans('Company').' : '.$object->thirdparty->name.'</p>';
|
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - $message_admin.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
|
|
| 221 | - $message_admin.='<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
|
|
| 220 | + $message_admin .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
|
|
| 221 | + $message_admin .= '<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
|
|
| 222 | 222 | |
| 223 | 223 | $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>'; |
| 224 | 224 | $replyto = $from; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | if ($mailfile->error) {
|
| 235 | 235 | dol_syslog($mailfile->error, LOG_DEBUG); |
| 236 | 236 | } else {
|
| 237 | - $result=$mailfile->sendfile(); |
|
| 237 | + $result = $mailfile->sendfile(); |
|
| 238 | 238 | } |
| 239 | 239 | if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
| 240 | 240 | $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | $mimetype = array(); |
| 262 | 262 | |
| 263 | 263 | $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectCustomer');
|
| 264 | - $message_customer= $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id)."\n\n";
|
|
| 265 | - $message_customer.='<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
|
|
| 266 | - $message_customer.='<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
|
|
| 267 | - $message_customer.='<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
|
|
| 268 | - $message_customer.='<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
|
|
| 264 | + $message_customer = $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id)."\n\n";
|
|
| 265 | + $message_customer .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
|
|
| 266 | + $message_customer .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
|
|
| 267 | + $message_customer .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
|
|
| 268 | + $message_customer .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
|
|
| 269 | 269 | |
| 270 | 270 | // Extrafields |
| 271 | 271 | foreach ($this->attributes[$object->table_element]['label'] as $key => $value) |
@@ -285,14 +285,14 @@ discard block |
||
| 285 | 285 | if (empty($enabled)) $qualified = false; |
| 286 | 286 | if (empty($perms)) $qualified = false; |
| 287 | 287 | |
| 288 | - if ($qualified) $message_customer.='<li>'.$langs->trans($key).' : '.$value.'</li>'; |
|
| 288 | + if ($qualified) $message_customer .= '<li>'.$langs->trans($key).' : '.$value.'</li>'; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - $message_customer.='</ul>'; |
|
| 292 | - $message_customer.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
|
|
| 293 | - $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE?$conf->global->TICKET_URL_PUBLIC_INTERFACE.'/':dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id;
|
|
| 294 | - $message_customer.='<p>' . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : <a href="'.$url_public_ticket.'">'.$url_public_ticket.'</a></p>';
|
|
| 295 | - $message_customer.='<p>'.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'</p>';
|
|
| 291 | + $message_customer .= '</ul>'; |
|
| 292 | + $message_customer .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
|
|
| 293 | + $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/' : dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id;
|
|
| 294 | + $message_customer .= '<p>'.$langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer').' : <a href="'.$url_public_ticket.'">'.$url_public_ticket.'</a></p>';
|
|
| 295 | + $message_customer .= '<p>'.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'</p>';
|
|
| 296 | 296 | |
| 297 | 297 | $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>'; |
| 298 | 298 | $replyto = $from; |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | if ($mailfile->error) {
|
| 309 | 309 | dol_syslog($mailfile->error, LOG_DEBUG); |
| 310 | 310 | } else {
|
| 311 | - $result=$mailfile->sendfile(); |
|
| 311 | + $result = $mailfile->sendfile(); |
|
| 312 | 312 | } |
| 313 | 313 | if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
| 314 | 314 | $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; |
@@ -319,19 +319,19 @@ discard block |
||
| 319 | 319 | break; |
| 320 | 320 | |
| 321 | 321 | case 'TICKET_DELETE': |
| 322 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 322 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 323 | 323 | break; |
| 324 | 324 | |
| 325 | 325 | case 'TICKET_MODIFY': |
| 326 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 326 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 327 | 327 | break; |
| 328 | 328 | |
| 329 | 329 | case 'TICKET_MARK_READ': |
| 330 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 330 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 331 | 331 | break; |
| 332 | 332 | |
| 333 | 333 | case 'TICKET_CLOSE': |
| 334 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 334 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 335 | 335 | break; |
| 336 | 336 | } |
| 337 | 337 | |
@@ -166,8 +166,7 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $ok = 1; |
| 169 | - } |
|
| 170 | - else |
|
| 169 | + } else |
|
| 171 | 170 | {
|
| 172 | 171 | $this->error = $userstat->error; |
| 173 | 172 | $this->errors = $userstat->errors; |
@@ -282,10 +281,16 @@ discard block |
||
| 282 | 281 | } |
| 283 | 282 | |
| 284 | 283 | $qualified = true; |
| 285 | - if (empty($enabled)) $qualified = false; |
|
| 286 | - if (empty($perms)) $qualified = false; |
|
| 287 | - |
|
| 288 | - if ($qualified) $message_customer.='<li>'.$langs->trans($key).' : '.$value.'</li>'; |
|
| 284 | + if (empty($enabled)) { |
|
| 285 | + $qualified = false; |
|
| 286 | + } |
|
| 287 | + if (empty($perms)) { |
|
| 288 | + $qualified = false; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + if ($qualified) { |
|
| 292 | + $message_customer.='<li>'.$langs->trans($key).' : '.$value.'</li>'; |
|
| 293 | + } |
|
| 289 | 294 | } |
| 290 | 295 | |
| 291 | 296 | $message_customer.='</ul>'; |
@@ -29,33 +29,33 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | class InterfaceMailmanSpipsynchro extends DolibarrTriggers |
| 31 | 31 | {
|
| 32 | - public $family = 'mailmanspip'; |
|
| 33 | - public $description = "Triggers of this module allows to synchronize Mailman an Spip."; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Version of the trigger |
|
| 37 | - * @var string |
|
| 38 | - */ |
|
| 39 | - public $version = self::VERSION_DOLIBARR; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @var string Image of the trigger |
|
| 43 | - */ |
|
| 44 | - public $picto = 'technic'; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Function called when a Dolibarrr business event is done. |
|
| 48 | - * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) |
|
| 49 | - * |
|
| 50 | - * @param string $action Event action code |
|
| 51 | - * @param Object $object Object |
|
| 52 | - * @param User $user Object user |
|
| 53 | - * @param Translate $langs Object langs |
|
| 54 | - * @param conf $conf Object conf |
|
| 55 | - * @return int <0 if KO, 0 if no triggered ran, >0 if OK |
|
| 56 | - */ |
|
| 57 | - public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
|
| 58 | - {
|
|
| 32 | + public $family = 'mailmanspip'; |
|
| 33 | + public $description = "Triggers of this module allows to synchronize Mailman an Spip."; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Version of the trigger |
|
| 37 | + * @var string |
|
| 38 | + */ |
|
| 39 | + public $version = self::VERSION_DOLIBARR; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @var string Image of the trigger |
|
| 43 | + */ |
|
| 44 | + public $picto = 'technic'; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Function called when a Dolibarrr business event is done. |
|
| 48 | + * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) |
|
| 49 | + * |
|
| 50 | + * @param string $action Event action code |
|
| 51 | + * @param Object $object Object |
|
| 52 | + * @param User $user Object user |
|
| 53 | + * @param Translate $langs Object langs |
|
| 54 | + * @param conf $conf Object conf |
|
| 55 | + * @return int <0 if KO, 0 if no triggered ran, >0 if OK |
|
| 56 | + */ |
|
| 57 | + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
|
| 58 | + {
|
|
| 59 | 59 | if (empty($conf->mailmanspip->enabled)) return 0; // Module not active, we do nothing |
| 60 | 60 | |
| 61 | 61 | require_once DOL_DOCUMENT_ROOT."/mailmanspip/class/mailmanspip.class.php"; |
@@ -63,39 +63,39 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | if ($action == 'CATEGORY_LINK') |
| 65 | 65 | {
|
| 66 | - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 67 | - |
|
| 68 | - // We add subscription if we change category (new category may means more mailing-list to subscribe) |
|
| 69 | - if (is_object($object->context['linkto']) && method_exists($object->context['linkto'], 'add_to_abo') && $object->context['linkto']->add_to_abo() < 0) |
|
| 70 | - {
|
|
| 71 | - $this->error=$object->context['linkto']->error; |
|
| 72 | - $this->errors=$object->context['linkto']->errors; |
|
| 73 | - $return=-1; |
|
| 74 | - } |
|
| 75 | - else |
|
| 76 | - {
|
|
| 77 | - $return=1; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - return $return; |
|
| 66 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 67 | + |
|
| 68 | + // We add subscription if we change category (new category may means more mailing-list to subscribe) |
|
| 69 | + if (is_object($object->context['linkto']) && method_exists($object->context['linkto'], 'add_to_abo') && $object->context['linkto']->add_to_abo() < 0) |
|
| 70 | + {
|
|
| 71 | + $this->error=$object->context['linkto']->error; |
|
| 72 | + $this->errors=$object->context['linkto']->errors; |
|
| 73 | + $return=-1; |
|
| 74 | + } |
|
| 75 | + else |
|
| 76 | + {
|
|
| 77 | + $return=1; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + return $return; |
|
| 81 | 81 | } |
| 82 | 82 | elseif ($action == 'CATEGORY_UNLINK') |
| 83 | 83 | {
|
| 84 | - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 85 | - |
|
| 86 | - // We remove subscription if we change category (lessw category may means less mailing-list to subscribe) |
|
| 87 | - if (is_object($object->context['unlinkoff']) && method_exists($object->context['unlinkoff'], 'del_to_abo') && $object->context['unlinkoff']->del_to_abo() < 0) |
|
| 88 | - {
|
|
| 89 | - $this->error=$object->context['unlinkoff']->error; |
|
| 90 | - $this->errors=$object->context['unlinkoff']->errors; |
|
| 91 | - $return=-1; |
|
| 92 | - } |
|
| 93 | - else |
|
| 94 | - {
|
|
| 95 | - $return=1; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - return $return; |
|
| 84 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 85 | + |
|
| 86 | + // We remove subscription if we change category (lessw category may means less mailing-list to subscribe) |
|
| 87 | + if (is_object($object->context['unlinkoff']) && method_exists($object->context['unlinkoff'], 'del_to_abo') && $object->context['unlinkoff']->del_to_abo() < 0) |
|
| 88 | + {
|
|
| 89 | + $this->error=$object->context['unlinkoff']->error; |
|
| 90 | + $this->errors=$object->context['unlinkoff']->errors; |
|
| 91 | + $return=-1; |
|
| 92 | + } |
|
| 93 | + else |
|
| 94 | + {
|
|
| 95 | + $return=1; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + return $return; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Members |
@@ -103,37 +103,37 @@ discard block |
||
| 103 | 103 | {
|
| 104 | 104 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 105 | 105 | |
| 106 | - $return=0; |
|
| 106 | + $return=0; |
|
| 107 | 107 | // Add user into some linked tools (mailman, spip, etc...) |
| 108 | - if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) // TODO Do del/add also if type change |
|
| 109 | - {
|
|
| 110 | - if (is_object($object->oldcopy) && ($object->oldcopy->email != $object->email)) // If email has changed we delete mailman subscription for old email |
|
| 111 | - {
|
|
| 112 | - if ($object->oldcopy->del_to_abo() < 0) |
|
| 113 | - {
|
|
| 114 | - if (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error; |
|
| 115 | - $this->errors=$object->oldcopy->errors; |
|
| 116 | - $return=-1; |
|
| 117 | - } |
|
| 118 | - else |
|
| 119 | - {
|
|
| 120 | - $return=1; |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - // We add subscription if new email or new type (new type may means more mailing-list to subscribe) |
|
| 124 | - if ($object->add_to_abo() < 0) |
|
| 125 | - {
|
|
| 126 | - if (! empty($object->error)) $this->error=$object->error; |
|
| 127 | - $this->errors=$object->errors; |
|
| 128 | - $return=-1; |
|
| 129 | - } |
|
| 130 | - else |
|
| 131 | - {
|
|
| 132 | - $return=1; |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - return $return; |
|
| 108 | + if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) // TODO Do del/add also if type change |
|
| 109 | + {
|
|
| 110 | + if (is_object($object->oldcopy) && ($object->oldcopy->email != $object->email)) // If email has changed we delete mailman subscription for old email |
|
| 111 | + {
|
|
| 112 | + if ($object->oldcopy->del_to_abo() < 0) |
|
| 113 | + {
|
|
| 114 | + if (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error; |
|
| 115 | + $this->errors=$object->oldcopy->errors; |
|
| 116 | + $return=-1; |
|
| 117 | + } |
|
| 118 | + else |
|
| 119 | + {
|
|
| 120 | + $return=1; |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + // We add subscription if new email or new type (new type may means more mailing-list to subscribe) |
|
| 124 | + if ($object->add_to_abo() < 0) |
|
| 125 | + {
|
|
| 126 | + if (! empty($object->error)) $this->error=$object->error; |
|
| 127 | + $this->errors=$object->errors; |
|
| 128 | + $return=-1; |
|
| 129 | + } |
|
| 130 | + else |
|
| 131 | + {
|
|
| 132 | + $return=1; |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + return $return; |
|
| 137 | 137 | } |
| 138 | 138 | elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE') |
| 139 | 139 | {
|
@@ -141,20 +141,20 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | $return=0; |
| 143 | 143 | // Remove from external tools (mailman, spip, etc...) |
| 144 | - if ($object->del_to_abo() < 0) |
|
| 145 | - {
|
|
| 146 | - if (! empty($object->error)) $this->error=$object->error; |
|
| 147 | - $this->errors=$object->errors; |
|
| 148 | - $return=-1; |
|
| 149 | - } |
|
| 150 | - else |
|
| 151 | - {
|
|
| 152 | - $return=1; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - return $return; |
|
| 144 | + if ($object->del_to_abo() < 0) |
|
| 145 | + {
|
|
| 146 | + if (! empty($object->error)) $this->error=$object->error; |
|
| 147 | + $this->errors=$object->errors; |
|
| 148 | + $return=-1; |
|
| 149 | + } |
|
| 150 | + else |
|
| 151 | + {
|
|
| 152 | + $return=1; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + return $return; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - return 0; |
|
| 158 | + return 0; |
|
| 159 | 159 | } |
| 160 | 160 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 58 | 58 | {
|
| 59 | - if (empty($conf->mailmanspip->enabled)) return 0; // Module not active, we do nothing |
|
| 59 | + if (empty($conf->mailmanspip->enabled)) return 0; // Module not active, we do nothing |
|
| 60 | 60 | |
| 61 | 61 | require_once DOL_DOCUMENT_ROOT."/mailmanspip/class/mailmanspip.class.php"; |
| 62 | 62 | require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"; |
@@ -68,13 +68,13 @@ discard block |
||
| 68 | 68 | // We add subscription if we change category (new category may means more mailing-list to subscribe) |
| 69 | 69 | if (is_object($object->context['linkto']) && method_exists($object->context['linkto'], 'add_to_abo') && $object->context['linkto']->add_to_abo() < 0) |
| 70 | 70 | {
|
| 71 | - $this->error=$object->context['linkto']->error; |
|
| 72 | - $this->errors=$object->context['linkto']->errors; |
|
| 73 | - $return=-1; |
|
| 71 | + $this->error = $object->context['linkto']->error; |
|
| 72 | + $this->errors = $object->context['linkto']->errors; |
|
| 73 | + $return = -1; |
|
| 74 | 74 | } |
| 75 | 75 | else |
| 76 | 76 | {
|
| 77 | - $return=1; |
|
| 77 | + $return = 1; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | return $return; |
@@ -86,13 +86,13 @@ discard block |
||
| 86 | 86 | // We remove subscription if we change category (lessw category may means less mailing-list to subscribe) |
| 87 | 87 | if (is_object($object->context['unlinkoff']) && method_exists($object->context['unlinkoff'], 'del_to_abo') && $object->context['unlinkoff']->del_to_abo() < 0) |
| 88 | 88 | {
|
| 89 | - $this->error=$object->context['unlinkoff']->error; |
|
| 90 | - $this->errors=$object->context['unlinkoff']->errors; |
|
| 91 | - $return=-1; |
|
| 89 | + $this->error = $object->context['unlinkoff']->error; |
|
| 90 | + $this->errors = $object->context['unlinkoff']->errors; |
|
| 91 | + $return = -1; |
|
| 92 | 92 | } |
| 93 | 93 | else |
| 94 | 94 | {
|
| 95 | - $return=1; |
|
| 95 | + $return = 1; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | return $return; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | {
|
| 104 | 104 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 105 | 105 | |
| 106 | - $return=0; |
|
| 106 | + $return = 0; |
|
| 107 | 107 | // Add user into some linked tools (mailman, spip, etc...) |
| 108 | 108 | if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) // TODO Do del/add also if type change |
| 109 | 109 | {
|
@@ -111,25 +111,25 @@ discard block |
||
| 111 | 111 | {
|
| 112 | 112 | if ($object->oldcopy->del_to_abo() < 0) |
| 113 | 113 | {
|
| 114 | - if (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error; |
|
| 115 | - $this->errors=$object->oldcopy->errors; |
|
| 116 | - $return=-1; |
|
| 114 | + if (!empty($object->oldcopy->error)) $this->error = $object->oldcopy->error; |
|
| 115 | + $this->errors = $object->oldcopy->errors; |
|
| 116 | + $return = -1; |
|
| 117 | 117 | } |
| 118 | 118 | else |
| 119 | 119 | {
|
| 120 | - $return=1; |
|
| 120 | + $return = 1; |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | // We add subscription if new email or new type (new type may means more mailing-list to subscribe) |
| 124 | 124 | if ($object->add_to_abo() < 0) |
| 125 | 125 | {
|
| 126 | - if (! empty($object->error)) $this->error=$object->error; |
|
| 127 | - $this->errors=$object->errors; |
|
| 128 | - $return=-1; |
|
| 126 | + if (!empty($object->error)) $this->error = $object->error; |
|
| 127 | + $this->errors = $object->errors; |
|
| 128 | + $return = -1; |
|
| 129 | 129 | } |
| 130 | 130 | else |
| 131 | 131 | {
|
| 132 | - $return=1; |
|
| 132 | + $return = 1; |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
@@ -139,17 +139,17 @@ discard block |
||
| 139 | 139 | {
|
| 140 | 140 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 141 | 141 | |
| 142 | - $return=0; |
|
| 142 | + $return = 0; |
|
| 143 | 143 | // Remove from external tools (mailman, spip, etc...) |
| 144 | 144 | if ($object->del_to_abo() < 0) |
| 145 | 145 | {
|
| 146 | - if (! empty($object->error)) $this->error=$object->error; |
|
| 147 | - $this->errors=$object->errors; |
|
| 148 | - $return=-1; |
|
| 146 | + if (!empty($object->error)) $this->error = $object->error; |
|
| 147 | + $this->errors = $object->errors; |
|
| 148 | + $return = -1; |
|
| 149 | 149 | } |
| 150 | 150 | else |
| 151 | 151 | {
|
| 152 | - $return=1; |
|
| 152 | + $return = 1; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | return $return; |
@@ -56,7 +56,10 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 58 | 58 | {
|
| 59 | - if (empty($conf->mailmanspip->enabled)) return 0; // Module not active, we do nothing |
|
| 59 | + if (empty($conf->mailmanspip->enabled)) { |
|
| 60 | + return 0; |
|
| 61 | + } |
|
| 62 | + // Module not active, we do nothing |
|
| 60 | 63 | |
| 61 | 64 | require_once DOL_DOCUMENT_ROOT."/mailmanspip/class/mailmanspip.class.php"; |
| 62 | 65 | require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"; |
@@ -71,15 +74,13 @@ discard block |
||
| 71 | 74 | $this->error=$object->context['linkto']->error; |
| 72 | 75 | $this->errors=$object->context['linkto']->errors; |
| 73 | 76 | $return=-1; |
| 74 | - } |
|
| 75 | - else |
|
| 77 | + } else |
|
| 76 | 78 | {
|
| 77 | 79 | $return=1; |
| 78 | 80 | } |
| 79 | 81 | |
| 80 | 82 | return $return; |
| 81 | - } |
|
| 82 | - elseif ($action == 'CATEGORY_UNLINK') |
|
| 83 | + } elseif ($action == 'CATEGORY_UNLINK') |
|
| 83 | 84 | {
|
| 84 | 85 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 85 | 86 | |
@@ -89,8 +90,7 @@ discard block |
||
| 89 | 90 | $this->error=$object->context['unlinkoff']->error; |
| 90 | 91 | $this->errors=$object->context['unlinkoff']->errors; |
| 91 | 92 | $return=-1; |
| 92 | - } |
|
| 93 | - else |
|
| 93 | + } else |
|
| 94 | 94 | {
|
| 95 | 95 | $return=1; |
| 96 | 96 | } |
@@ -105,17 +105,18 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | $return=0; |
| 107 | 107 | // Add user into some linked tools (mailman, spip, etc...) |
| 108 | - if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) // TODO Do del/add also if type change |
|
| 108 | + if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) { |
|
| 109 | + // TODO Do del/add also if type change |
|
| 109 | 110 | {
|
| 110 | 111 | if (is_object($object->oldcopy) && ($object->oldcopy->email != $object->email)) // If email has changed we delete mailman subscription for old email |
| 111 | 112 | {
|
| 112 | 113 | if ($object->oldcopy->del_to_abo() < 0) |
| 113 | 114 | {
|
| 114 | - if (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error; |
|
| 115 | + if (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error; |
|
| 116 | + } |
|
| 115 | 117 | $this->errors=$object->oldcopy->errors; |
| 116 | 118 | $return=-1; |
| 117 | - } |
|
| 118 | - else |
|
| 119 | + } else |
|
| 119 | 120 | {
|
| 120 | 121 | $return=1; |
| 121 | 122 | } |
@@ -123,19 +124,19 @@ discard block |
||
| 123 | 124 | // We add subscription if new email or new type (new type may means more mailing-list to subscribe) |
| 124 | 125 | if ($object->add_to_abo() < 0) |
| 125 | 126 | {
|
| 126 | - if (! empty($object->error)) $this->error=$object->error; |
|
| 127 | + if (! empty($object->error)) { |
|
| 128 | + $this->error=$object->error; |
|
| 129 | + } |
|
| 127 | 130 | $this->errors=$object->errors; |
| 128 | 131 | $return=-1; |
| 129 | - } |
|
| 130 | - else |
|
| 132 | + } else |
|
| 131 | 133 | {
|
| 132 | 134 | $return=1; |
| 133 | 135 | } |
| 134 | 136 | } |
| 135 | 137 | |
| 136 | 138 | return $return; |
| 137 | - } |
|
| 138 | - elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE') |
|
| 139 | + } elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE') |
|
| 139 | 140 | {
|
| 140 | 141 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 141 | 142 | |
@@ -143,11 +144,12 @@ discard block |
||
| 143 | 144 | // Remove from external tools (mailman, spip, etc...) |
| 144 | 145 | if ($object->del_to_abo() < 0) |
| 145 | 146 | {
|
| 146 | - if (! empty($object->error)) $this->error=$object->error; |
|
| 147 | + if (! empty($object->error)) { |
|
| 148 | + $this->error=$object->error; |
|
| 149 | + } |
|
| 147 | 150 | $this->errors=$object->errors; |
| 148 | 151 | $return=-1; |
| 149 | - } |
|
| 150 | - else |
|
| 152 | + } else |
|
| 151 | 153 | {
|
| 152 | 154 | $return=1; |
| 153 | 155 | } |
@@ -50,221 +50,221 @@ |
||
| 50 | 50 | $this->db = $db; |
| 51 | 51 | |
| 52 | 52 | $this->name = preg_replace('/^Interface/i', '', get_class($this));
|
| 53 | - $this->family = 'stripe'; |
|
| 53 | + $this->family = 'stripe'; |
|
| 54 | 54 | $this->description = "Triggers of the module Stripe"; |
| 55 | 55 | $this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version |
| 56 | 56 | $this->picto = 'stripe@stripe'; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Trigger name |
|
| 61 | - * |
|
| 62 | - * @return string Name of trigger file |
|
| 63 | - */ |
|
| 64 | - public function getName() |
|
| 65 | - {
|
|
| 66 | - return $this->name; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Trigger description |
|
| 72 | - * |
|
| 73 | - * @return string Description of trigger file |
|
| 74 | - */ |
|
| 75 | - public function getDesc() |
|
| 76 | - {
|
|
| 77 | - return $this->description; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Trigger version |
|
| 82 | - * |
|
| 83 | - * @return string Version of trigger file |
|
| 84 | - */ |
|
| 85 | - public function getVersion() |
|
| 86 | - {
|
|
| 87 | - global $langs; |
|
| 88 | - $langs->load("admin");
|
|
| 89 | - |
|
| 90 | - if ($this->version == 'development') {
|
|
| 91 | - return $langs->trans("Development");
|
|
| 92 | - } elseif ($this->version == 'experimental') {
|
|
| 93 | - return $langs->trans("Experimental");
|
|
| 94 | - } elseif ($this->version == 'dolibarr') {
|
|
| 95 | - return DOL_VERSION; |
|
| 96 | - } elseif ($this->version) {
|
|
| 97 | - return $this->version; |
|
| 98 | - } else {
|
|
| 99 | - return $langs->trans("Unknown");
|
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Function called when a Dolibarrr business event is done. |
|
| 105 | - * All functions "runTrigger" are triggered if file |
|
| 106 | - * is inside directory core/triggers |
|
| 107 | - * |
|
| 108 | - * @param string $action Event action code |
|
| 109 | - * @param CommonObject $object Object |
|
| 110 | - * @param User $user Object user |
|
| 111 | - * @param Translate $langs Object langs |
|
| 112 | - * @param Conf $conf Object conf |
|
| 113 | - * @return int <0 if KO, 0 if no triggered ran, >0 if OK |
|
| 114 | - */ |
|
| 115 | - public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
|
| 116 | - {
|
|
| 117 | - // Put here code you want to execute when a Dolibarr business event occurs. |
|
| 118 | - // Data and type of action are stored into $object and $action |
|
| 119 | - global $langs, $db, $conf; |
|
| 120 | - |
|
| 121 | - // Load translation files required by the page |
|
| 59 | + /** |
|
| 60 | + * Trigger name |
|
| 61 | + * |
|
| 62 | + * @return string Name of trigger file |
|
| 63 | + */ |
|
| 64 | + public function getName() |
|
| 65 | + {
|
|
| 66 | + return $this->name; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Trigger description |
|
| 72 | + * |
|
| 73 | + * @return string Description of trigger file |
|
| 74 | + */ |
|
| 75 | + public function getDesc() |
|
| 76 | + {
|
|
| 77 | + return $this->description; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Trigger version |
|
| 82 | + * |
|
| 83 | + * @return string Version of trigger file |
|
| 84 | + */ |
|
| 85 | + public function getVersion() |
|
| 86 | + {
|
|
| 87 | + global $langs; |
|
| 88 | + $langs->load("admin");
|
|
| 89 | + |
|
| 90 | + if ($this->version == 'development') {
|
|
| 91 | + return $langs->trans("Development");
|
|
| 92 | + } elseif ($this->version == 'experimental') {
|
|
| 93 | + return $langs->trans("Experimental");
|
|
| 94 | + } elseif ($this->version == 'dolibarr') {
|
|
| 95 | + return DOL_VERSION; |
|
| 96 | + } elseif ($this->version) {
|
|
| 97 | + return $this->version; |
|
| 98 | + } else {
|
|
| 99 | + return $langs->trans("Unknown");
|
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Function called when a Dolibarrr business event is done. |
|
| 105 | + * All functions "runTrigger" are triggered if file |
|
| 106 | + * is inside directory core/triggers |
|
| 107 | + * |
|
| 108 | + * @param string $action Event action code |
|
| 109 | + * @param CommonObject $object Object |
|
| 110 | + * @param User $user Object user |
|
| 111 | + * @param Translate $langs Object langs |
|
| 112 | + * @param Conf $conf Object conf |
|
| 113 | + * @return int <0 if KO, 0 if no triggered ran, >0 if OK |
|
| 114 | + */ |
|
| 115 | + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
|
| 116 | + {
|
|
| 117 | + // Put here code you want to execute when a Dolibarr business event occurs. |
|
| 118 | + // Data and type of action are stored into $object and $action |
|
| 119 | + global $langs, $db, $conf; |
|
| 120 | + |
|
| 121 | + // Load translation files required by the page |
|
| 122 | 122 | $langs->loadLangs(array("members","other","users","mails"));
|
| 123 | 123 | |
| 124 | - require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; |
|
| 125 | - $stripe = new Stripe($db); |
|
| 126 | - |
|
| 127 | - if (empty($conf->stripe->enabled)) return 0; |
|
| 128 | - |
|
| 129 | - $ok = 1; |
|
| 130 | - |
|
| 131 | - $service = 'StripeTest'; |
|
| 132 | - $servicestatus = 0; |
|
| 133 | - if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha'))
|
|
| 134 | - {
|
|
| 135 | - $service = 'StripeLive'; |
|
| 136 | - $servicestatus = 1; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - // If customer is linked to Stripe, we update/delete Stripe too |
|
| 140 | - if ($action == 'COMPANY_MODIFY') {
|
|
| 141 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 142 | - |
|
| 143 | - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 144 | - |
|
| 145 | - if ($object->client != 0) {
|
|
| 146 | - $customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); // This make a network request |
|
| 147 | - if ($customer) |
|
| 148 | - {
|
|
| 149 | - $namecleaned = $object->name ? $object->name : null; |
|
| 150 | - $vatcleaned = $object->tva_intra ? $object->tva_intra : null; |
|
| 151 | - |
|
| 152 | - $taxinfo = array('type'=>'vat');
|
|
| 153 | - if ($vatcleaned) |
|
| 154 | - {
|
|
| 155 | - $taxinfo["tax_id"] = $vatcleaned; |
|
| 156 | - } |
|
| 157 | - // We force data to "null" if not defined as expected by Stripe |
|
| 158 | - if (empty($vatcleaned)) $taxinfo=null; |
|
| 159 | - |
|
| 160 | - // Detect if we change a Stripe info (email, description, vat id) |
|
| 161 | - $changerequested = 0; |
|
| 162 | - if (! empty($object->email) && $object->email != $customer->email) $changerequested++; |
|
| 163 | - if ($namecleaned != $customer->description) $changerequested++; |
|
| 164 | - if (! isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned)) $changerequested++; |
|
| 165 | - elseif (isset($customer->tax_info['tax_id']) && is_null($vatcleaned)) $changerequested++; |
|
| 166 | - elseif (isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned)) |
|
| 167 | - {
|
|
| 168 | - if ($vatcleaned != $customer->tax_info['tax_id']) $changerequested++; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - if ($changerequested) |
|
| 172 | - {
|
|
| 173 | - if (! empty($object->email)) $customer->email = $object->email; |
|
| 174 | - $customer->description = $namecleaned; |
|
| 175 | - if (empty($taxinfo)) $customer->tax_info = array('type'=>'vat', 'tax_id'=>null);
|
|
| 176 | - else $customer->tax_info = $taxinfo; |
|
| 177 | - |
|
| 178 | - $customer->save(); |
|
| 179 | - } |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - if ($action == 'COMPANY_DELETE') {
|
|
| 184 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 185 | - |
|
| 186 | - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 187 | - |
|
| 188 | - $customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
| 189 | - if ($customer) |
|
| 190 | - {
|
|
| 191 | - $customer->delete(); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account"; |
|
| 195 | - $sql.= " WHERE site='stripe' AND fk_soc = " . $object->id; |
|
| 196 | - $this->db->query($sql); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - // If payment mode is linked to Stripee, we update/delete Stripe too |
|
| 200 | - if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') {
|
|
| 201 | - |
|
| 202 | - // For creation of credit card, we do not create in Stripe automatically |
|
| 203 | - } |
|
| 204 | - if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') {
|
|
| 205 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 206 | - |
|
| 207 | - if (! empty($object->stripe_card_ref)) |
|
| 208 | - {
|
|
| 209 | - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 210 | - $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this |
|
| 211 | - |
|
| 212 | - if ($stripecu) |
|
| 213 | - {
|
|
| 214 | - // Get customer (required to get a card) |
|
| 215 | - if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
|
|
| 216 | - $customer = \Stripe\Customer::retrieve($stripecu); |
|
| 217 | - } else {
|
|
| 218 | - $customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc));
|
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - if ($customer) |
|
| 222 | - {
|
|
| 223 | - $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus); |
|
| 224 | - if ($card) {
|
|
| 225 | - $card->metadata=array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']));
|
|
| 226 | - try {
|
|
| 227 | - $card->save($dataforcard); |
|
| 228 | - } |
|
| 229 | - catch(Exception $e) |
|
| 230 | - {
|
|
| 231 | - $ok = -1; |
|
| 232 | - $this->error = $e->getMessages(); |
|
| 233 | - } |
|
| 234 | - } |
|
| 235 | - } |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - if ($action == 'COMPANYPAYMENTMODE_DELETE' && $object->type == 'card') {
|
|
| 240 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 241 | - |
|
| 242 | - if (! empty($object->stripe_card_ref)) |
|
| 243 | - {
|
|
| 244 | - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 245 | - $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this |
|
| 246 | - |
|
| 247 | - if ($stripecu) |
|
| 248 | - {
|
|
| 249 | - // Get customer (required to get a card) |
|
| 250 | - if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
|
|
| 251 | - $customer = \Stripe\Customer::retrieve($stripecu); |
|
| 252 | - } else {
|
|
| 253 | - $customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc));
|
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - if ($customer) |
|
| 257 | - {
|
|
| 258 | - $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus); |
|
| 259 | - if ($card) {
|
|
| 260 | - if (method_exists($card, 'detach')) $card->detach(); |
|
| 261 | - else $card->delete(); |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - return $ok; |
|
| 269 | - } |
|
| 124 | + require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; |
|
| 125 | + $stripe = new Stripe($db); |
|
| 126 | + |
|
| 127 | + if (empty($conf->stripe->enabled)) return 0; |
|
| 128 | + |
|
| 129 | + $ok = 1; |
|
| 130 | + |
|
| 131 | + $service = 'StripeTest'; |
|
| 132 | + $servicestatus = 0; |
|
| 133 | + if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha'))
|
|
| 134 | + {
|
|
| 135 | + $service = 'StripeLive'; |
|
| 136 | + $servicestatus = 1; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + // If customer is linked to Stripe, we update/delete Stripe too |
|
| 140 | + if ($action == 'COMPANY_MODIFY') {
|
|
| 141 | + dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 142 | + |
|
| 143 | + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 144 | + |
|
| 145 | + if ($object->client != 0) {
|
|
| 146 | + $customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); // This make a network request |
|
| 147 | + if ($customer) |
|
| 148 | + {
|
|
| 149 | + $namecleaned = $object->name ? $object->name : null; |
|
| 150 | + $vatcleaned = $object->tva_intra ? $object->tva_intra : null; |
|
| 151 | + |
|
| 152 | + $taxinfo = array('type'=>'vat');
|
|
| 153 | + if ($vatcleaned) |
|
| 154 | + {
|
|
| 155 | + $taxinfo["tax_id"] = $vatcleaned; |
|
| 156 | + } |
|
| 157 | + // We force data to "null" if not defined as expected by Stripe |
|
| 158 | + if (empty($vatcleaned)) $taxinfo=null; |
|
| 159 | + |
|
| 160 | + // Detect if we change a Stripe info (email, description, vat id) |
|
| 161 | + $changerequested = 0; |
|
| 162 | + if (! empty($object->email) && $object->email != $customer->email) $changerequested++; |
|
| 163 | + if ($namecleaned != $customer->description) $changerequested++; |
|
| 164 | + if (! isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned)) $changerequested++; |
|
| 165 | + elseif (isset($customer->tax_info['tax_id']) && is_null($vatcleaned)) $changerequested++; |
|
| 166 | + elseif (isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned)) |
|
| 167 | + {
|
|
| 168 | + if ($vatcleaned != $customer->tax_info['tax_id']) $changerequested++; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + if ($changerequested) |
|
| 172 | + {
|
|
| 173 | + if (! empty($object->email)) $customer->email = $object->email; |
|
| 174 | + $customer->description = $namecleaned; |
|
| 175 | + if (empty($taxinfo)) $customer->tax_info = array('type'=>'vat', 'tax_id'=>null);
|
|
| 176 | + else $customer->tax_info = $taxinfo; |
|
| 177 | + |
|
| 178 | + $customer->save(); |
|
| 179 | + } |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + if ($action == 'COMPANY_DELETE') {
|
|
| 184 | + dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 185 | + |
|
| 186 | + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 187 | + |
|
| 188 | + $customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
| 189 | + if ($customer) |
|
| 190 | + {
|
|
| 191 | + $customer->delete(); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account"; |
|
| 195 | + $sql.= " WHERE site='stripe' AND fk_soc = " . $object->id; |
|
| 196 | + $this->db->query($sql); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + // If payment mode is linked to Stripee, we update/delete Stripe too |
|
| 200 | + if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') {
|
|
| 201 | + |
|
| 202 | + // For creation of credit card, we do not create in Stripe automatically |
|
| 203 | + } |
|
| 204 | + if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') {
|
|
| 205 | + dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 206 | + |
|
| 207 | + if (! empty($object->stripe_card_ref)) |
|
| 208 | + {
|
|
| 209 | + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 210 | + $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this |
|
| 211 | + |
|
| 212 | + if ($stripecu) |
|
| 213 | + {
|
|
| 214 | + // Get customer (required to get a card) |
|
| 215 | + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
|
|
| 216 | + $customer = \Stripe\Customer::retrieve($stripecu); |
|
| 217 | + } else {
|
|
| 218 | + $customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc));
|
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + if ($customer) |
|
| 222 | + {
|
|
| 223 | + $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus); |
|
| 224 | + if ($card) {
|
|
| 225 | + $card->metadata=array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']));
|
|
| 226 | + try {
|
|
| 227 | + $card->save($dataforcard); |
|
| 228 | + } |
|
| 229 | + catch(Exception $e) |
|
| 230 | + {
|
|
| 231 | + $ok = -1; |
|
| 232 | + $this->error = $e->getMessages(); |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + if ($action == 'COMPANYPAYMENTMODE_DELETE' && $object->type == 'card') {
|
|
| 240 | + dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 241 | + |
|
| 242 | + if (! empty($object->stripe_card_ref)) |
|
| 243 | + {
|
|
| 244 | + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 245 | + $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this |
|
| 246 | + |
|
| 247 | + if ($stripecu) |
|
| 248 | + {
|
|
| 249 | + // Get customer (required to get a card) |
|
| 250 | + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
|
|
| 251 | + $customer = \Stripe\Customer::retrieve($stripecu); |
|
| 252 | + } else {
|
|
| 253 | + $customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc));
|
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + if ($customer) |
|
| 257 | + {
|
|
| 258 | + $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus); |
|
| 259 | + if ($card) {
|
|
| 260 | + if (method_exists($card, 'detach')) $card->detach(); |
|
| 261 | + else $card->delete(); |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + return $ok; |
|
| 269 | + } |
|
| 270 | 270 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | global $langs, $db, $conf; |
| 120 | 120 | |
| 121 | 121 | // Load translation files required by the page |
| 122 | - $langs->loadLangs(array("members","other","users","mails"));
|
|
| 122 | + $langs->loadLangs(array("members", "other", "users", "mails"));
|
|
| 123 | 123 | |
| 124 | 124 | require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; |
| 125 | 125 | $stripe = new Stripe($db); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | $service = 'StripeTest'; |
| 132 | 132 | $servicestatus = 0; |
| 133 | - if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha'))
|
|
| 133 | + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha'))
|
|
| 134 | 134 | {
|
| 135 | 135 | $service = 'StripeLive'; |
| 136 | 136 | $servicestatus = 1; |
@@ -138,12 +138,12 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | // If customer is linked to Stripe, we update/delete Stripe too |
| 140 | 140 | if ($action == 'COMPANY_MODIFY') {
|
| 141 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 141 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 142 | 142 | |
| 143 | - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 143 | + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 144 | 144 | |
| 145 | 145 | if ($object->client != 0) {
|
| 146 | - $customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); // This make a network request |
|
| 146 | + $customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); // This make a network request |
|
| 147 | 147 | if ($customer) |
| 148 | 148 | {
|
| 149 | 149 | $namecleaned = $object->name ? $object->name : null; |
@@ -155,22 +155,22 @@ discard block |
||
| 155 | 155 | $taxinfo["tax_id"] = $vatcleaned; |
| 156 | 156 | } |
| 157 | 157 | // We force data to "null" if not defined as expected by Stripe |
| 158 | - if (empty($vatcleaned)) $taxinfo=null; |
|
| 158 | + if (empty($vatcleaned)) $taxinfo = null; |
|
| 159 | 159 | |
| 160 | 160 | // Detect if we change a Stripe info (email, description, vat id) |
| 161 | 161 | $changerequested = 0; |
| 162 | - if (! empty($object->email) && $object->email != $customer->email) $changerequested++; |
|
| 162 | + if (!empty($object->email) && $object->email != $customer->email) $changerequested++; |
|
| 163 | 163 | if ($namecleaned != $customer->description) $changerequested++; |
| 164 | - if (! isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned)) $changerequested++; |
|
| 164 | + if (!isset($customer->tax_info['tax_id']) && !is_null($vatcleaned)) $changerequested++; |
|
| 165 | 165 | elseif (isset($customer->tax_info['tax_id']) && is_null($vatcleaned)) $changerequested++; |
| 166 | - elseif (isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned)) |
|
| 166 | + elseif (isset($customer->tax_info['tax_id']) && !is_null($vatcleaned)) |
|
| 167 | 167 | {
|
| 168 | 168 | if ($vatcleaned != $customer->tax_info['tax_id']) $changerequested++; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | if ($changerequested) |
| 172 | 172 | {
|
| 173 | - if (! empty($object->email)) $customer->email = $object->email; |
|
| 173 | + if (!empty($object->email)) $customer->email = $object->email; |
|
| 174 | 174 | $customer->description = $namecleaned; |
| 175 | 175 | if (empty($taxinfo)) $customer->tax_info = array('type'=>'vat', 'tax_id'=>null);
|
| 176 | 176 | else $customer->tax_info = $taxinfo; |
@@ -181,9 +181,9 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | if ($action == 'COMPANY_DELETE') {
|
| 184 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 184 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 185 | 185 | |
| 186 | - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 186 | + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 187 | 187 | |
| 188 | 188 | $customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); |
| 189 | 189 | if ($customer) |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account"; |
| 195 | - $sql.= " WHERE site='stripe' AND fk_soc = " . $object->id; |
|
| 195 | + $sql .= " WHERE site='stripe' AND fk_soc = ".$object->id; |
|
| 196 | 196 | $this->db->query($sql); |
| 197 | 197 | } |
| 198 | 198 | |
@@ -202,12 +202,12 @@ discard block |
||
| 202 | 202 | // For creation of credit card, we do not create in Stripe automatically |
| 203 | 203 | } |
| 204 | 204 | if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') {
|
| 205 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 205 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 206 | 206 | |
| 207 | - if (! empty($object->stripe_card_ref)) |
|
| 207 | + if (!empty($object->stripe_card_ref)) |
|
| 208 | 208 | {
|
| 209 | - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 210 | - $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this |
|
| 209 | + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 210 | + $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this |
|
| 211 | 211 | |
| 212 | 212 | if ($stripecu) |
| 213 | 213 | {
|
@@ -222,11 +222,11 @@ discard block |
||
| 222 | 222 | {
|
| 223 | 223 | $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus); |
| 224 | 224 | if ($card) {
|
| 225 | - $card->metadata=array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']));
|
|
| 225 | + $card->metadata = array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']));
|
|
| 226 | 226 | try {
|
| 227 | 227 | $card->save($dataforcard); |
| 228 | 228 | } |
| 229 | - catch(Exception $e) |
|
| 229 | + catch (Exception $e) |
|
| 230 | 230 | {
|
| 231 | 231 | $ok = -1; |
| 232 | 232 | $this->error = $e->getMessages(); |
@@ -237,12 +237,12 @@ discard block |
||
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | if ($action == 'COMPANYPAYMENTMODE_DELETE' && $object->type == 'card') {
|
| 240 | - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
|
| 240 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 241 | 241 | |
| 242 | - if (! empty($object->stripe_card_ref)) |
|
| 242 | + if (!empty($object->stripe_card_ref)) |
|
| 243 | 243 | {
|
| 244 | - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 245 | - $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this |
|
| 244 | + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. |
|
| 245 | + $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this |
|
| 246 | 246 | |
| 247 | 247 | if ($stripecu) |
| 248 | 248 | {
|
@@ -124,7 +124,9 @@ discard block |
||
| 124 | 124 | require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; |
| 125 | 125 | $stripe = new Stripe($db); |
| 126 | 126 | |
| 127 | - if (empty($conf->stripe->enabled)) return 0; |
|
| 127 | + if (empty($conf->stripe->enabled)) { |
|
| 128 | + return 0; |
|
| 129 | + } |
|
| 128 | 130 | |
| 129 | 131 | $ok = 1; |
| 130 | 132 | |
@@ -155,25 +157,40 @@ discard block |
||
| 155 | 157 | $taxinfo["tax_id"] = $vatcleaned; |
| 156 | 158 | } |
| 157 | 159 | // We force data to "null" if not defined as expected by Stripe |
| 158 | - if (empty($vatcleaned)) $taxinfo=null; |
|
| 160 | + if (empty($vatcleaned)) { |
|
| 161 | + $taxinfo=null; |
|
| 162 | + } |
|
| 159 | 163 | |
| 160 | 164 | // Detect if we change a Stripe info (email, description, vat id) |
| 161 | 165 | $changerequested = 0; |
| 162 | - if (! empty($object->email) && $object->email != $customer->email) $changerequested++; |
|
| 163 | - if ($namecleaned != $customer->description) $changerequested++; |
|
| 164 | - if (! isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned)) $changerequested++; |
|
| 165 | - elseif (isset($customer->tax_info['tax_id']) && is_null($vatcleaned)) $changerequested++; |
|
| 166 | - elseif (isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned)) |
|
| 166 | + if (! empty($object->email) && $object->email != $customer->email) { |
|
| 167 | + $changerequested++; |
|
| 168 | + } |
|
| 169 | + if ($namecleaned != $customer->description) { |
|
| 170 | + $changerequested++; |
|
| 171 | + } |
|
| 172 | + if (! isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned)) { |
|
| 173 | + $changerequested++; |
|
| 174 | + } elseif (isset($customer->tax_info['tax_id']) && is_null($vatcleaned)) { |
|
| 175 | + $changerequested++; |
|
| 176 | + } elseif (isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned)) |
|
| 167 | 177 | {
|
| 168 | - if ($vatcleaned != $customer->tax_info['tax_id']) $changerequested++; |
|
| 178 | + if ($vatcleaned != $customer->tax_info['tax_id']) { |
|
| 179 | + $changerequested++; |
|
| 180 | + } |
|
| 169 | 181 | } |
| 170 | 182 | |
| 171 | 183 | if ($changerequested) |
| 172 | 184 | {
|
| 173 | - if (! empty($object->email)) $customer->email = $object->email; |
|
| 185 | + if (! empty($object->email)) { |
|
| 186 | + $customer->email = $object->email; |
|
| 187 | + } |
|
| 174 | 188 | $customer->description = $namecleaned; |
| 175 | - if (empty($taxinfo)) $customer->tax_info = array('type'=>'vat', 'tax_id'=>null);
|
|
| 176 | - else $customer->tax_info = $taxinfo; |
|
| 189 | + if (empty($taxinfo)) { |
|
| 190 | + $customer->tax_info = array('type'=>'vat', 'tax_id'=>null); |
|
| 191 | + } else { |
|
| 192 | + $customer->tax_info = $taxinfo; |
|
| 193 | + } |
|
| 177 | 194 | |
| 178 | 195 | $customer->save(); |
| 179 | 196 | } |
@@ -225,8 +242,7 @@ discard block |
||
| 225 | 242 | $card->metadata=array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']));
|
| 226 | 243 | try {
|
| 227 | 244 | $card->save($dataforcard); |
| 228 | - } |
|
| 229 | - catch(Exception $e) |
|
| 245 | + } catch(Exception $e) |
|
| 230 | 246 | {
|
| 231 | 247 | $ok = -1; |
| 232 | 248 | $this->error = $e->getMessages(); |
@@ -257,8 +273,11 @@ discard block |
||
| 257 | 273 | {
|
| 258 | 274 | $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus); |
| 259 | 275 | if ($card) {
|
| 260 | - if (method_exists($card, 'detach')) $card->detach(); |
|
| 261 | - else $card->delete(); |
|
| 276 | + if (method_exists($card, 'detach')) { |
|
| 277 | + $card->detach(); |
|
| 278 | + } else { |
|
| 279 | + $card->delete(); |
|
| 280 | + } |
|
| 262 | 281 | } |
| 263 | 282 | } |
| 264 | 283 | } |
@@ -32,39 +32,39 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | class InterfaceWorkflowManager extends DolibarrTriggers |
| 34 | 34 | {
|
| 35 | - /** |
|
| 36 | - * @var string Image of the trigger |
|
| 37 | - */ |
|
| 38 | - public $picto = 'technic'; |
|
| 35 | + /** |
|
| 36 | + * @var string Image of the trigger |
|
| 37 | + */ |
|
| 38 | + public $picto = 'technic'; |
|
| 39 | 39 | |
| 40 | - public $family = 'core'; |
|
| 41 | - public $description = "Triggers of this module allows to manage workflows"; |
|
| 40 | + public $family = 'core'; |
|
| 41 | + public $description = "Triggers of this module allows to manage workflows"; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Version of the trigger |
|
| 45 | - * @var string |
|
| 46 | - */ |
|
| 47 | - public $version = self::VERSION_DOLIBARR; |
|
| 43 | + /** |
|
| 44 | + * Version of the trigger |
|
| 45 | + * @var string |
|
| 46 | + */ |
|
| 47 | + public $version = self::VERSION_DOLIBARR; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Function called when a Dolibarrr business event is done. |
|
| 51 | - * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) |
|
| 52 | - * |
|
| 53 | - * @param string $action Event action code |
|
| 54 | - * @param Object $object Object |
|
| 55 | - * @param User $user Object user |
|
| 56 | - * @param Translate $langs Object langs |
|
| 57 | - * @param conf $conf Object conf |
|
| 58 | - * @return int <0 if KO, 0 if no triggered ran, >0 if OK |
|
| 59 | - */ |
|
| 60 | - public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
|
| 49 | + /** |
|
| 50 | + * Function called when a Dolibarrr business event is done. |
|
| 51 | + * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) |
|
| 52 | + * |
|
| 53 | + * @param string $action Event action code |
|
| 54 | + * @param Object $object Object |
|
| 55 | + * @param User $user Object user |
|
| 56 | + * @param Translate $langs Object langs |
|
| 57 | + * @param conf $conf Object conf |
|
| 58 | + * @return int <0 if KO, 0 if no triggered ran, >0 if OK |
|
| 59 | + */ |
|
| 60 | + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
|
| 61 | 61 | {
|
| 62 | 62 | if (empty($conf->workflow->enabled)) return 0; // Module not active, we do nothing |
| 63 | 63 | |
| 64 | 64 | // Proposals to order |
| 65 | 65 | if ($action == 'PROPAL_CLOSE_SIGNED') |
| 66 | 66 | {
|
| 67 | - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 67 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 68 | 68 | if (! empty($conf->commande->enabled) && ! empty($conf->global->WORKFLOW_PROPAL_AUTOCREATE_ORDER)) |
| 69 | 69 | {
|
| 70 | 70 | include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
@@ -102,132 +102,132 @@ discard block |
||
| 102 | 102 | // Order classify billed proposal |
| 103 | 103 | if ($action == 'ORDER_CLASSIFY_BILLED') |
| 104 | 104 | {
|
| 105 | - dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id ); |
|
| 106 | - if (! empty($conf->propal->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL)) |
|
| 107 | - {
|
|
| 108 | - $object->fetchObjectLinked('','propal',$object->id,$object->element);
|
|
| 109 | - if (! empty($object->linkedObjects)) |
|
| 110 | - {
|
|
| 111 | - $totalonlinkedelements=0; |
|
| 112 | - foreach($object->linkedObjects['propal'] as $element) |
|
| 113 | - {
|
|
| 114 | - if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; |
|
| 115 | - } |
|
| 116 | - dol_syslog( "Amount of linked proposals = ".$totalonlinkedelements.", of order = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 117 | - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 118 | - {
|
|
| 119 | - foreach($object->linkedObjects['propal'] as $element) |
|
| 120 | - {
|
|
| 121 | - $ret=$element->classifyBilled($user); |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - return $ret; |
|
| 126 | - } |
|
| 105 | + dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id ); |
|
| 106 | + if (! empty($conf->propal->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL)) |
|
| 107 | + {
|
|
| 108 | + $object->fetchObjectLinked('','propal',$object->id,$object->element);
|
|
| 109 | + if (! empty($object->linkedObjects)) |
|
| 110 | + {
|
|
| 111 | + $totalonlinkedelements=0; |
|
| 112 | + foreach($object->linkedObjects['propal'] as $element) |
|
| 113 | + {
|
|
| 114 | + if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; |
|
| 115 | + } |
|
| 116 | + dol_syslog( "Amount of linked proposals = ".$totalonlinkedelements.", of order = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 117 | + if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 118 | + {
|
|
| 119 | + foreach($object->linkedObjects['propal'] as $element) |
|
| 120 | + {
|
|
| 121 | + $ret=$element->classifyBilled($user); |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + return $ret; |
|
| 126 | + } |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // classify billed order & billed propososal |
| 130 | 130 | if ($action == 'BILL_VALIDATE') |
| 131 | 131 | {
|
| 132 | - dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id ); |
|
| 132 | + dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id ); |
|
| 133 | 133 | |
| 134 | - // First classify billed the order to allow the proposal classify process |
|
| 135 | - if (! empty($conf->commande->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) |
|
| 136 | - {
|
|
| 137 | - $object->fetchObjectLinked('','commande',$object->id,$object->element);
|
|
| 138 | - if (! empty($object->linkedObjects)) |
|
| 139 | - {
|
|
| 140 | - $totalonlinkedelements=0; |
|
| 141 | - foreach($object->linkedObjects['commande'] as $element) |
|
| 142 | - {
|
|
| 143 | - if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; |
|
| 144 | - } |
|
| 145 | - dol_syslog( "Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 146 | - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 147 | - {
|
|
| 148 | - foreach($object->linkedObjects['commande'] as $element) |
|
| 149 | - {
|
|
| 150 | - $ret=$element->classifyBilled($user); |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - return $ret; |
|
| 155 | - } |
|
| 134 | + // First classify billed the order to allow the proposal classify process |
|
| 135 | + if (! empty($conf->commande->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) |
|
| 136 | + {
|
|
| 137 | + $object->fetchObjectLinked('','commande',$object->id,$object->element);
|
|
| 138 | + if (! empty($object->linkedObjects)) |
|
| 139 | + {
|
|
| 140 | + $totalonlinkedelements=0; |
|
| 141 | + foreach($object->linkedObjects['commande'] as $element) |
|
| 142 | + {
|
|
| 143 | + if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; |
|
| 144 | + } |
|
| 145 | + dol_syslog( "Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 146 | + if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 147 | + {
|
|
| 148 | + foreach($object->linkedObjects['commande'] as $element) |
|
| 149 | + {
|
|
| 150 | + $ret=$element->classifyBilled($user); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + return $ret; |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - // Second classify billed the proposal. |
|
| 158 | - if (! empty($conf->propal->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL)) |
|
| 159 | - {
|
|
| 160 | - $object->fetchObjectLinked('','propal',$object->id,$object->element);
|
|
| 161 | - if (! empty($object->linkedObjects)) |
|
| 162 | - {
|
|
| 163 | - $totalonlinkedelements=0; |
|
| 164 | - foreach($object->linkedObjects['propal'] as $element) |
|
| 165 | - {
|
|
| 166 | - if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; |
|
| 167 | - } |
|
| 168 | - dol_syslog( "Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 169 | - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 170 | - {
|
|
| 171 | - foreach($object->linkedObjects['propal'] as $element) |
|
| 172 | - {
|
|
| 173 | - $ret=$element->classifyBilled($user); |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - return $ret; |
|
| 178 | - } |
|
| 157 | + // Second classify billed the proposal. |
|
| 158 | + if (! empty($conf->propal->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL)) |
|
| 159 | + {
|
|
| 160 | + $object->fetchObjectLinked('','propal',$object->id,$object->element);
|
|
| 161 | + if (! empty($object->linkedObjects)) |
|
| 162 | + {
|
|
| 163 | + $totalonlinkedelements=0; |
|
| 164 | + foreach($object->linkedObjects['propal'] as $element) |
|
| 165 | + {
|
|
| 166 | + if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; |
|
| 167 | + } |
|
| 168 | + dol_syslog( "Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 169 | + if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 170 | + {
|
|
| 171 | + foreach($object->linkedObjects['propal'] as $element) |
|
| 172 | + {
|
|
| 173 | + $ret=$element->classifyBilled($user); |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + return $ret; |
|
| 178 | + } |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // classify billed order & billed propososal |
| 182 | 182 | if ($action == 'BILL_SUPPLIER_VALIDATE') |
| 183 | 183 | {
|
| 184 | - dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id ); |
|
| 184 | + dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id ); |
|
| 185 | 185 | |
| 186 | - // First classify billed the order to allow the proposal classify process |
|
| 187 | - if (! empty($conf->fournisseur->commande->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) |
|
| 188 | - {
|
|
| 189 | - $object->fetchObjectLinked('','order_supplier',$object->id,$object->element);
|
|
| 190 | - if (! empty($object->linkedObjects)) |
|
| 191 | - {
|
|
| 192 | - $totalonlinkedelements=0; |
|
| 193 | - foreach($object->linkedObjects['order_supplier'] as $element) |
|
| 194 | - {
|
|
| 195 | - 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; |
|
| 196 | - } |
|
| 197 | - dol_syslog( "Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 198 | - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 199 | - {
|
|
| 200 | - foreach($object->linkedObjects['order_supplier'] as $element) |
|
| 201 | - {
|
|
| 202 | - $ret=$element->classifyBilled($user); |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - return $ret; |
|
| 207 | - } |
|
| 186 | + // First classify billed the order to allow the proposal classify process |
|
| 187 | + if (! empty($conf->fournisseur->commande->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) |
|
| 188 | + {
|
|
| 189 | + $object->fetchObjectLinked('','order_supplier',$object->id,$object->element);
|
|
| 190 | + if (! empty($object->linkedObjects)) |
|
| 191 | + {
|
|
| 192 | + $totalonlinkedelements=0; |
|
| 193 | + foreach($object->linkedObjects['order_supplier'] as $element) |
|
| 194 | + {
|
|
| 195 | + 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; |
|
| 196 | + } |
|
| 197 | + dol_syslog( "Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 198 | + if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 199 | + {
|
|
| 200 | + foreach($object->linkedObjects['order_supplier'] as $element) |
|
| 201 | + {
|
|
| 202 | + $ret=$element->classifyBilled($user); |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + return $ret; |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - // Second classify billed the proposal. |
|
| 210 | - if (! empty($conf->supplier_proposal->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_SUPPLIER_PROPOSAL)) |
|
| 211 | - {
|
|
| 212 | - $object->fetchObjectLinked('','supplier_proposal',$object->id,$object->element);
|
|
| 213 | - if (! empty($object->linkedObjects)) |
|
| 214 | - {
|
|
| 215 | - $totalonlinkedelements=0; |
|
| 216 | - foreach($object->linkedObjects['supplier_proposal'] as $element) |
|
| 217 | - {
|
|
| 218 | - if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; |
|
| 219 | - } |
|
| 220 | - dol_syslog( "Amount of linked supplier proposals = ".$totalonlinkedelements.", of supplier invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 221 | - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 222 | - {
|
|
| 223 | - foreach($object->linkedObjects['supplier_proposal'] as $element) |
|
| 224 | - {
|
|
| 225 | - $ret=$element->classifyBilled($user); |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - return $ret; |
|
| 230 | - } |
|
| 209 | + // Second classify billed the proposal. |
|
| 210 | + if (! empty($conf->supplier_proposal->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_SUPPLIER_PROPOSAL)) |
|
| 211 | + {
|
|
| 212 | + $object->fetchObjectLinked('','supplier_proposal',$object->id,$object->element);
|
|
| 213 | + if (! empty($object->linkedObjects)) |
|
| 214 | + {
|
|
| 215 | + $totalonlinkedelements=0; |
|
| 216 | + foreach($object->linkedObjects['supplier_proposal'] as $element) |
|
| 217 | + {
|
|
| 218 | + if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; |
|
| 219 | + } |
|
| 220 | + dol_syslog( "Amount of linked supplier proposals = ".$totalonlinkedelements.", of supplier invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 221 | + if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 222 | + {
|
|
| 223 | + foreach($object->linkedObjects['supplier_proposal'] as $element) |
|
| 224 | + {
|
|
| 225 | + $ret=$element->classifyBilled($user); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + return $ret; |
|
| 230 | + } |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // Invoice classify billed order |
@@ -260,88 +260,88 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | if ($action=='SHIPPING_VALIDATE') |
| 262 | 262 | {
|
| 263 | - dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id ); |
|
| 263 | + dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id ); |
|
| 264 | 264 | |
| 265 | - if (! empty($conf->commande->enabled) && ! empty($conf->expedition->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING)) |
|
| 266 | - {
|
|
| 267 | - $qtyshipped=array(); |
|
| 268 | - $qtyordred=array(); |
|
| 269 | - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 265 | + if (! empty($conf->commande->enabled) && ! empty($conf->expedition->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING)) |
|
| 266 | + {
|
|
| 267 | + $qtyshipped=array(); |
|
| 268 | + $qtyordred=array(); |
|
| 269 | + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 270 | 270 | |
| 271 | - //find all shippement on order origin |
|
| 272 | - $order = new Commande($this->db); |
|
| 273 | - $ret=$order->fetch($object->origin_id); |
|
| 274 | - if ($ret<0) {
|
|
| 275 | - $this->error=$order->error; $this->errors=$order->errors; |
|
| 276 | - return $ret; |
|
| 277 | - } |
|
| 278 | - $ret=$order->fetchObjectLinked($order->id,'commande',null,'shipping'); |
|
| 279 | - if ($ret<0) {
|
|
| 280 | - $this->error=$order->error; $this->errors=$order->errors; |
|
| 281 | - return $ret; |
|
| 282 | - } |
|
| 283 | - //Build array of quantity shipped by product for an order |
|
| 284 | - if (is_array($order->linkedObjects) && count($order->linkedObjects)>0) {
|
|
| 285 | - foreach($order->linkedObjects as $type=>$shipping_array) {
|
|
| 286 | - if ($type=='shipping' && is_array($shipping_array) && count($shipping_array)>0) {
|
|
| 287 | - foreach ($shipping_array as $shipping) {
|
|
| 288 | - if (is_array($shipping->lines) && count($shipping->lines)>0) {
|
|
| 289 | - foreach($shipping->lines as $shippingline) {
|
|
| 290 | - $qtyshipped[$shippingline->fk_product]+=$shippingline->qty; |
|
| 291 | - } |
|
| 292 | - } |
|
| 293 | - } |
|
| 294 | - } |
|
| 295 | - } |
|
| 296 | - } |
|
| 271 | + //find all shippement on order origin |
|
| 272 | + $order = new Commande($this->db); |
|
| 273 | + $ret=$order->fetch($object->origin_id); |
|
| 274 | + if ($ret<0) {
|
|
| 275 | + $this->error=$order->error; $this->errors=$order->errors; |
|
| 276 | + return $ret; |
|
| 277 | + } |
|
| 278 | + $ret=$order->fetchObjectLinked($order->id,'commande',null,'shipping'); |
|
| 279 | + if ($ret<0) {
|
|
| 280 | + $this->error=$order->error; $this->errors=$order->errors; |
|
| 281 | + return $ret; |
|
| 282 | + } |
|
| 283 | + //Build array of quantity shipped by product for an order |
|
| 284 | + if (is_array($order->linkedObjects) && count($order->linkedObjects)>0) {
|
|
| 285 | + foreach($order->linkedObjects as $type=>$shipping_array) {
|
|
| 286 | + if ($type=='shipping' && is_array($shipping_array) && count($shipping_array)>0) {
|
|
| 287 | + foreach ($shipping_array as $shipping) {
|
|
| 288 | + if (is_array($shipping->lines) && count($shipping->lines)>0) {
|
|
| 289 | + foreach($shipping->lines as $shippingline) {
|
|
| 290 | + $qtyshipped[$shippingline->fk_product]+=$shippingline->qty; |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | + } |
|
| 294 | + } |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | - //Build array of quantity ordered by product |
|
| 299 | - if (is_array($order->lines) && count($order->lines)>0) {
|
|
| 300 | - foreach($order->lines as $orderline) {
|
|
| 301 | - $qtyordred[$orderline->fk_product]+=$orderline->qty; |
|
| 302 | - } |
|
| 303 | - } |
|
| 304 | - //dol_syslog(var_export($qtyordred,true),LOG_DEBUG); |
|
| 305 | - //dol_syslog(var_export($qtyshipped,true),LOG_DEBUG); |
|
| 306 | - //Compare array |
|
| 307 | - $diff_array=array_diff_assoc($qtyordred,$qtyshipped); |
|
| 308 | - if (count($diff_array)==0) {
|
|
| 309 | - //No diff => mean everythings is shipped |
|
| 310 | - $ret=$object->setStatut(Commande::STATUS_CLOSED, $object->origin_id, $object->origin); |
|
| 311 | - if ($ret<0) {
|
|
| 312 | - $this->error=$object->error; $this->errors=$object->errors; |
|
| 313 | - return $ret; |
|
| 314 | - } |
|
| 315 | - } |
|
| 316 | - } |
|
| 298 | + //Build array of quantity ordered by product |
|
| 299 | + if (is_array($order->lines) && count($order->lines)>0) {
|
|
| 300 | + foreach($order->lines as $orderline) {
|
|
| 301 | + $qtyordred[$orderline->fk_product]+=$orderline->qty; |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | + //dol_syslog(var_export($qtyordred,true),LOG_DEBUG); |
|
| 305 | + //dol_syslog(var_export($qtyshipped,true),LOG_DEBUG); |
|
| 306 | + //Compare array |
|
| 307 | + $diff_array=array_diff_assoc($qtyordred,$qtyshipped); |
|
| 308 | + if (count($diff_array)==0) {
|
|
| 309 | + //No diff => mean everythings is shipped |
|
| 310 | + $ret=$object->setStatut(Commande::STATUS_CLOSED, $object->origin_id, $object->origin); |
|
| 311 | + if ($ret<0) {
|
|
| 312 | + $this->error=$object->error; $this->errors=$object->errors; |
|
| 313 | + return $ret; |
|
| 314 | + } |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | 317 | } |
| 318 | - // classify billed reception |
|
| 318 | + // classify billed reception |
|
| 319 | 319 | if ($action == 'BILL_SUPPLIER_VALIDATE') |
| 320 | 320 | {
|
| 321 | - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id, LOG_DEBUG);
|
|
| 321 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id, LOG_DEBUG);
|
|
| 322 | 322 | |
| 323 | - if (! empty($conf->reception->enabled) && ! empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) |
|
| 324 | - {
|
|
| 325 | - $object->fetchObjectLinked('','reception',$object->id,$object->element);
|
|
| 326 | - if (! empty($object->linkedObjects)) |
|
| 327 | - {
|
|
| 328 | - $totalonlinkedelements=0; |
|
| 329 | - foreach($object->linkedObjects['reception'] as $element) |
|
| 330 | - {
|
|
| 331 | - if ($element->statut == Reception::STATUS_VALIDATED) $totalonlinkedelements += $element->total_ht; |
|
| 332 | - } |
|
| 333 | - dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG);
|
|
| 334 | - if ($totalonlinkedelements == $object->total_ht) |
|
| 335 | - {
|
|
| 336 | - foreach($object->linkedObjects['reception'] as $element) |
|
| 337 | - {
|
|
| 338 | - $ret=$element->set_billed(); |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - } |
|
| 342 | - return $ret; |
|
| 343 | - } |
|
| 344 | - } |
|
| 323 | + if (! empty($conf->reception->enabled) && ! empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) |
|
| 324 | + {
|
|
| 325 | + $object->fetchObjectLinked('','reception',$object->id,$object->element);
|
|
| 326 | + if (! empty($object->linkedObjects)) |
|
| 327 | + {
|
|
| 328 | + $totalonlinkedelements=0; |
|
| 329 | + foreach($object->linkedObjects['reception'] as $element) |
|
| 330 | + {
|
|
| 331 | + if ($element->statut == Reception::STATUS_VALIDATED) $totalonlinkedelements += $element->total_ht; |
|
| 332 | + } |
|
| 333 | + dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG);
|
|
| 334 | + if ($totalonlinkedelements == $object->total_ht) |
|
| 335 | + {
|
|
| 336 | + foreach($object->linkedObjects['reception'] as $element) |
|
| 337 | + {
|
|
| 338 | + $ret=$element->set_billed(); |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + } |
|
| 342 | + return $ret; |
|
| 343 | + } |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | 346 | return 0; |
| 347 | 347 | } |
@@ -59,13 +59,13 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 61 | 61 | {
|
| 62 | - if (empty($conf->workflow->enabled)) return 0; // Module not active, we do nothing |
|
| 62 | + if (empty($conf->workflow->enabled)) return 0; // Module not active, we do nothing |
|
| 63 | 63 | |
| 64 | 64 | // Proposals to order |
| 65 | 65 | if ($action == 'PROPAL_CLOSE_SIGNED') |
| 66 | 66 | {
|
| 67 | 67 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 68 | - if (! empty($conf->commande->enabled) && ! empty($conf->global->WORKFLOW_PROPAL_AUTOCREATE_ORDER)) |
|
| 68 | + if (!empty($conf->commande->enabled) && !empty($conf->global->WORKFLOW_PROPAL_AUTOCREATE_ORDER)) |
|
| 69 | 69 | {
|
| 70 | 70 | include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
| 71 | 71 | $newobject = new Commande($this->db); |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | $newobject->context['origin'] = $object->element; |
| 75 | 75 | $newobject->context['origin_id'] = $object->id; |
| 76 | 76 | |
| 77 | - $ret=$newobject->createFromProposal($object, $user); |
|
| 78 | - if ($ret < 0) { $this->error=$newobject->error; $this->errors[]=$newobject->error; }
|
|
| 77 | + $ret = $newobject->createFromProposal($object, $user); |
|
| 78 | + if ($ret < 0) { $this->error = $newobject->error; $this->errors[] = $newobject->error; }
|
|
| 79 | 79 | return $ret; |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | if ($action == 'ORDER_CLOSE') |
| 85 | 85 | {
|
| 86 | 86 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
| 87 | - if (! empty($conf->facture->enabled) && ! empty($conf->global->WORKFLOW_ORDER_AUTOCREATE_INVOICE)) |
|
| 87 | + if (!empty($conf->facture->enabled) && !empty($conf->global->WORKFLOW_ORDER_AUTOCREATE_INVOICE)) |
|
| 88 | 88 | {
|
| 89 | 89 | include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
| 90 | 90 | $newobject = new Facture($this->db); |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | $newobject->context['origin'] = $object->element; |
| 94 | 94 | $newobject->context['origin_id'] = $object->id; |
| 95 | 95 | |
| 96 | - $ret=$newobject->createFromOrder($object, $user); |
|
| 97 | - if ($ret < 0) { $this->error=$newobject->error; $this->errors[]=$newobject->error; }
|
|
| 96 | + $ret = $newobject->createFromOrder($object, $user); |
|
| 97 | + if ($ret < 0) { $this->error = $newobject->error; $this->errors[] = $newobject->error; }
|
|
| 98 | 98 | return $ret; |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -102,23 +102,23 @@ discard block |
||
| 102 | 102 | // Order classify billed proposal |
| 103 | 103 | if ($action == 'ORDER_CLASSIFY_BILLED') |
| 104 | 104 | {
|
| 105 | - dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id ); |
|
| 106 | - if (! empty($conf->propal->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL)) |
|
| 105 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 106 | + if (!empty($conf->propal->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL)) |
|
| 107 | 107 | {
|
| 108 | - $object->fetchObjectLinked('','propal',$object->id,$object->element);
|
|
| 109 | - if (! empty($object->linkedObjects)) |
|
| 108 | + $object->fetchObjectLinked('', 'propal', $object->id, $object->element);
|
|
| 109 | + if (!empty($object->linkedObjects)) |
|
| 110 | 110 | {
|
| 111 | - $totalonlinkedelements=0; |
|
| 112 | - foreach($object->linkedObjects['propal'] as $element) |
|
| 111 | + $totalonlinkedelements = 0; |
|
| 112 | + foreach ($object->linkedObjects['propal'] as $element) |
|
| 113 | 113 | {
|
| 114 | 114 | if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; |
| 115 | 115 | } |
| 116 | - dol_syslog( "Amount of linked proposals = ".$totalonlinkedelements.", of order = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 117 | - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 116 | + dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of order = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
|
|
| 117 | + if (($totalonlinkedelements == $object->total_ht) || (!empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS))) |
|
| 118 | 118 | {
|
| 119 | - foreach($object->linkedObjects['propal'] as $element) |
|
| 119 | + foreach ($object->linkedObjects['propal'] as $element) |
|
| 120 | 120 | {
|
| 121 | - $ret=$element->classifyBilled($user); |
|
| 121 | + $ret = $element->classifyBilled($user); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -129,25 +129,25 @@ discard block |
||
| 129 | 129 | // classify billed order & billed propososal |
| 130 | 130 | if ($action == 'BILL_VALIDATE') |
| 131 | 131 | {
|
| 132 | - dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id ); |
|
| 132 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 133 | 133 | |
| 134 | 134 | // First classify billed the order to allow the proposal classify process |
| 135 | - if (! empty($conf->commande->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) |
|
| 135 | + if (!empty($conf->commande->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) |
|
| 136 | 136 | {
|
| 137 | - $object->fetchObjectLinked('','commande',$object->id,$object->element);
|
|
| 138 | - if (! empty($object->linkedObjects)) |
|
| 137 | + $object->fetchObjectLinked('', 'commande', $object->id, $object->element);
|
|
| 138 | + if (!empty($object->linkedObjects)) |
|
| 139 | 139 | {
|
| 140 | - $totalonlinkedelements=0; |
|
| 141 | - foreach($object->linkedObjects['commande'] as $element) |
|
| 140 | + $totalonlinkedelements = 0; |
|
| 141 | + foreach ($object->linkedObjects['commande'] as $element) |
|
| 142 | 142 | {
|
| 143 | 143 | if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; |
| 144 | 144 | } |
| 145 | - dol_syslog( "Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 146 | - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 145 | + dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
|
|
| 146 | + if (($totalonlinkedelements == $object->total_ht) || (!empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS))) |
|
| 147 | 147 | {
|
| 148 | - foreach($object->linkedObjects['commande'] as $element) |
|
| 148 | + foreach ($object->linkedObjects['commande'] as $element) |
|
| 149 | 149 | {
|
| 150 | - $ret=$element->classifyBilled($user); |
|
| 150 | + $ret = $element->classifyBilled($user); |
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | } |
@@ -155,22 +155,22 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | // Second classify billed the proposal. |
| 158 | - if (! empty($conf->propal->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL)) |
|
| 158 | + if (!empty($conf->propal->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL)) |
|
| 159 | 159 | {
|
| 160 | - $object->fetchObjectLinked('','propal',$object->id,$object->element);
|
|
| 161 | - if (! empty($object->linkedObjects)) |
|
| 160 | + $object->fetchObjectLinked('', 'propal', $object->id, $object->element);
|
|
| 161 | + if (!empty($object->linkedObjects)) |
|
| 162 | 162 | {
|
| 163 | - $totalonlinkedelements=0; |
|
| 164 | - foreach($object->linkedObjects['propal'] as $element) |
|
| 163 | + $totalonlinkedelements = 0; |
|
| 164 | + foreach ($object->linkedObjects['propal'] as $element) |
|
| 165 | 165 | {
|
| 166 | 166 | if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; |
| 167 | 167 | } |
| 168 | - dol_syslog( "Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 169 | - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 168 | + dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
|
|
| 169 | + if (($totalonlinkedelements == $object->total_ht) || (!empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS))) |
|
| 170 | 170 | {
|
| 171 | - foreach($object->linkedObjects['propal'] as $element) |
|
| 171 | + foreach ($object->linkedObjects['propal'] as $element) |
|
| 172 | 172 | {
|
| 173 | - $ret=$element->classifyBilled($user); |
|
| 173 | + $ret = $element->classifyBilled($user); |
|
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -181,25 +181,25 @@ discard block |
||
| 181 | 181 | // classify billed order & billed propososal |
| 182 | 182 | if ($action == 'BILL_SUPPLIER_VALIDATE') |
| 183 | 183 | {
|
| 184 | - dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id ); |
|
| 184 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 185 | 185 | |
| 186 | 186 | // First classify billed the order to allow the proposal classify process |
| 187 | - if (! empty($conf->fournisseur->commande->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) |
|
| 187 | + if (!empty($conf->fournisseur->commande->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) |
|
| 188 | 188 | {
|
| 189 | - $object->fetchObjectLinked('','order_supplier',$object->id,$object->element);
|
|
| 190 | - if (! empty($object->linkedObjects)) |
|
| 189 | + $object->fetchObjectLinked('', 'order_supplier', $object->id, $object->element);
|
|
| 190 | + if (!empty($object->linkedObjects)) |
|
| 191 | 191 | {
|
| 192 | - $totalonlinkedelements=0; |
|
| 193 | - foreach($object->linkedObjects['order_supplier'] as $element) |
|
| 192 | + $totalonlinkedelements = 0; |
|
| 193 | + foreach ($object->linkedObjects['order_supplier'] as $element) |
|
| 194 | 194 | {
|
| 195 | 195 | 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; |
| 196 | 196 | } |
| 197 | - dol_syslog( "Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 198 | - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 197 | + dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
|
|
| 198 | + if (($totalonlinkedelements == $object->total_ht) || (!empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS))) |
|
| 199 | 199 | {
|
| 200 | - foreach($object->linkedObjects['order_supplier'] as $element) |
|
| 200 | + foreach ($object->linkedObjects['order_supplier'] as $element) |
|
| 201 | 201 | {
|
| 202 | - $ret=$element->classifyBilled($user); |
|
| 202 | + $ret = $element->classifyBilled($user); |
|
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | } |
@@ -207,22 +207,22 @@ discard block |
||
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | // Second classify billed the proposal. |
| 210 | - if (! empty($conf->supplier_proposal->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_SUPPLIER_PROPOSAL)) |
|
| 210 | + if (!empty($conf->supplier_proposal->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_SUPPLIER_PROPOSAL)) |
|
| 211 | 211 | {
|
| 212 | - $object->fetchObjectLinked('','supplier_proposal',$object->id,$object->element);
|
|
| 213 | - if (! empty($object->linkedObjects)) |
|
| 212 | + $object->fetchObjectLinked('', 'supplier_proposal', $object->id, $object->element);
|
|
| 213 | + if (!empty($object->linkedObjects)) |
|
| 214 | 214 | {
|
| 215 | - $totalonlinkedelements=0; |
|
| 216 | - foreach($object->linkedObjects['supplier_proposal'] as $element) |
|
| 215 | + $totalonlinkedelements = 0; |
|
| 216 | + foreach ($object->linkedObjects['supplier_proposal'] as $element) |
|
| 217 | 217 | {
|
| 218 | 218 | if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; |
| 219 | 219 | } |
| 220 | - dol_syslog( "Amount of linked supplier proposals = ".$totalonlinkedelements.", of supplier invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 221 | - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 220 | + dol_syslog("Amount of linked supplier proposals = ".$totalonlinkedelements.", of supplier invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
|
|
| 221 | + if (($totalonlinkedelements == $object->total_ht) || (!empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS))) |
|
| 222 | 222 | {
|
| 223 | - foreach($object->linkedObjects['supplier_proposal'] as $element) |
|
| 223 | + foreach ($object->linkedObjects['supplier_proposal'] as $element) |
|
| 224 | 224 | {
|
| 225 | - $ret=$element->classifyBilled($user); |
|
| 225 | + $ret = $element->classifyBilled($user); |
|
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -233,24 +233,24 @@ discard block |
||
| 233 | 233 | // Invoice classify billed order |
| 234 | 234 | if ($action == 'BILL_PAYED') |
| 235 | 235 | {
|
| 236 | - dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id ); |
|
| 236 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 237 | 237 | |
| 238 | - if (! empty($conf->commande->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER)) |
|
| 238 | + if (!empty($conf->commande->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER)) |
|
| 239 | 239 | {
|
| 240 | - $object->fetchObjectLinked('','commande',$object->id,$object->element);
|
|
| 241 | - if (! empty($object->linkedObjects)) |
|
| 240 | + $object->fetchObjectLinked('', 'commande', $object->id, $object->element);
|
|
| 241 | + if (!empty($object->linkedObjects)) |
|
| 242 | 242 | {
|
| 243 | - $totalonlinkedelements=0; |
|
| 244 | - foreach($object->linkedObjects['commande'] as $element) |
|
| 243 | + $totalonlinkedelements = 0; |
|
| 244 | + foreach ($object->linkedObjects['commande'] as $element) |
|
| 245 | 245 | {
|
| 246 | 246 | if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; |
| 247 | 247 | } |
| 248 | - dol_syslog( "Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
|
| 249 | - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
|
| 248 | + dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht));
|
|
| 249 | + if (($totalonlinkedelements == $object->total_ht) || (!empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS))) |
|
| 250 | 250 | {
|
| 251 | - foreach($object->linkedObjects['commande'] as $element) |
|
| 251 | + foreach ($object->linkedObjects['commande'] as $element) |
|
| 252 | 252 | {
|
| 253 | - $ret=$element->classifyBilled($user); |
|
| 253 | + $ret = $element->classifyBilled($user); |
|
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | } |
@@ -258,36 +258,36 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - if ($action=='SHIPPING_VALIDATE') |
|
| 261 | + if ($action == 'SHIPPING_VALIDATE') |
|
| 262 | 262 | {
|
| 263 | - dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id ); |
|
| 263 | + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
| 264 | 264 | |
| 265 | - if (! empty($conf->commande->enabled) && ! empty($conf->expedition->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING)) |
|
| 265 | + if (!empty($conf->commande->enabled) && !empty($conf->expedition->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING)) |
|
| 266 | 266 | {
|
| 267 | - $qtyshipped=array(); |
|
| 268 | - $qtyordred=array(); |
|
| 267 | + $qtyshipped = array(); |
|
| 268 | + $qtyordred = array(); |
|
| 269 | 269 | require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
| 270 | 270 | |
| 271 | 271 | //find all shippement on order origin |
| 272 | 272 | $order = new Commande($this->db); |
| 273 | - $ret=$order->fetch($object->origin_id); |
|
| 274 | - if ($ret<0) {
|
|
| 275 | - $this->error=$order->error; $this->errors=$order->errors; |
|
| 273 | + $ret = $order->fetch($object->origin_id); |
|
| 274 | + if ($ret < 0) {
|
|
| 275 | + $this->error = $order->error; $this->errors = $order->errors; |
|
| 276 | 276 | return $ret; |
| 277 | 277 | } |
| 278 | - $ret=$order->fetchObjectLinked($order->id,'commande',null,'shipping'); |
|
| 279 | - if ($ret<0) {
|
|
| 280 | - $this->error=$order->error; $this->errors=$order->errors; |
|
| 278 | + $ret = $order->fetchObjectLinked($order->id, 'commande', null, 'shipping'); |
|
| 279 | + if ($ret < 0) {
|
|
| 280 | + $this->error = $order->error; $this->errors = $order->errors; |
|
| 281 | 281 | return $ret; |
| 282 | 282 | } |
| 283 | 283 | //Build array of quantity shipped by product for an order |
| 284 | - if (is_array($order->linkedObjects) && count($order->linkedObjects)>0) {
|
|
| 285 | - foreach($order->linkedObjects as $type=>$shipping_array) {
|
|
| 286 | - if ($type=='shipping' && is_array($shipping_array) && count($shipping_array)>0) {
|
|
| 284 | + if (is_array($order->linkedObjects) && count($order->linkedObjects) > 0) {
|
|
| 285 | + foreach ($order->linkedObjects as $type=>$shipping_array) {
|
|
| 286 | + if ($type == 'shipping' && is_array($shipping_array) && count($shipping_array) > 0) {
|
|
| 287 | 287 | foreach ($shipping_array as $shipping) {
|
| 288 | - if (is_array($shipping->lines) && count($shipping->lines)>0) {
|
|
| 289 | - foreach($shipping->lines as $shippingline) {
|
|
| 290 | - $qtyshipped[$shippingline->fk_product]+=$shippingline->qty; |
|
| 288 | + if (is_array($shipping->lines) && count($shipping->lines) > 0) {
|
|
| 289 | + foreach ($shipping->lines as $shippingline) {
|
|
| 290 | + $qtyshipped[$shippingline->fk_product] += $shippingline->qty; |
|
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | } |
@@ -296,20 +296,20 @@ discard block |
||
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | //Build array of quantity ordered by product |
| 299 | - if (is_array($order->lines) && count($order->lines)>0) {
|
|
| 300 | - foreach($order->lines as $orderline) {
|
|
| 301 | - $qtyordred[$orderline->fk_product]+=$orderline->qty; |
|
| 299 | + if (is_array($order->lines) && count($order->lines) > 0) {
|
|
| 300 | + foreach ($order->lines as $orderline) {
|
|
| 301 | + $qtyordred[$orderline->fk_product] += $orderline->qty; |
|
| 302 | 302 | } |
| 303 | 303 | } |
| 304 | 304 | //dol_syslog(var_export($qtyordred,true),LOG_DEBUG); |
| 305 | 305 | //dol_syslog(var_export($qtyshipped,true),LOG_DEBUG); |
| 306 | 306 | //Compare array |
| 307 | - $diff_array=array_diff_assoc($qtyordred,$qtyshipped); |
|
| 308 | - if (count($diff_array)==0) {
|
|
| 307 | + $diff_array = array_diff_assoc($qtyordred, $qtyshipped); |
|
| 308 | + if (count($diff_array) == 0) {
|
|
| 309 | 309 | //No diff => mean everythings is shipped |
| 310 | - $ret=$object->setStatut(Commande::STATUS_CLOSED, $object->origin_id, $object->origin); |
|
| 311 | - if ($ret<0) {
|
|
| 312 | - $this->error=$object->error; $this->errors=$object->errors; |
|
| 310 | + $ret = $object->setStatut(Commande::STATUS_CLOSED, $object->origin_id, $object->origin); |
|
| 311 | + if ($ret < 0) {
|
|
| 312 | + $this->error = $object->error; $this->errors = $object->errors; |
|
| 313 | 313 | return $ret; |
| 314 | 314 | } |
| 315 | 315 | } |
@@ -320,22 +320,22 @@ discard block |
||
| 320 | 320 | {
|
| 321 | 321 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id, LOG_DEBUG);
|
| 322 | 322 | |
| 323 | - if (! empty($conf->reception->enabled) && ! empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) |
|
| 323 | + if (!empty($conf->reception->enabled) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) |
|
| 324 | 324 | {
|
| 325 | - $object->fetchObjectLinked('','reception',$object->id,$object->element);
|
|
| 326 | - if (! empty($object->linkedObjects)) |
|
| 325 | + $object->fetchObjectLinked('', 'reception', $object->id, $object->element);
|
|
| 326 | + if (!empty($object->linkedObjects)) |
|
| 327 | 327 | {
|
| 328 | - $totalonlinkedelements=0; |
|
| 329 | - foreach($object->linkedObjects['reception'] as $element) |
|
| 328 | + $totalonlinkedelements = 0; |
|
| 329 | + foreach ($object->linkedObjects['reception'] as $element) |
|
| 330 | 330 | {
|
| 331 | 331 | if ($element->statut == Reception::STATUS_VALIDATED) $totalonlinkedelements += $element->total_ht; |
| 332 | 332 | } |
| 333 | 333 | dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG);
|
| 334 | 334 | if ($totalonlinkedelements == $object->total_ht) |
| 335 | 335 | {
|
| 336 | - foreach($object->linkedObjects['reception'] as $element) |
|
| 336 | + foreach ($object->linkedObjects['reception'] as $element) |
|
| 337 | 337 | {
|
| 338 | - $ret=$element->set_billed(); |
|
| 338 | + $ret = $element->set_billed(); |
|
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | } |
@@ -59,7 +59,10 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 61 | 61 | {
|
| 62 | - if (empty($conf->workflow->enabled)) return 0; // Module not active, we do nothing |
|
| 62 | + if (empty($conf->workflow->enabled)) { |
|
| 63 | + return 0; |
|
| 64 | + } |
|
| 65 | + // Module not active, we do nothing |
|
| 63 | 66 | |
| 64 | 67 | // Proposals to order |
| 65 | 68 | if ($action == 'PROPAL_CLOSE_SIGNED') |
@@ -111,7 +114,9 @@ discard block |
||
| 111 | 114 | $totalonlinkedelements=0; |
| 112 | 115 | foreach($object->linkedObjects['propal'] as $element) |
| 113 | 116 | {
|
| 114 | - if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; |
|
| 117 | + if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) { |
|
| 118 | + $totalonlinkedelements += $element->total_ht; |
|
| 119 | + } |
|
| 115 | 120 | } |
| 116 | 121 | dol_syslog( "Amount of linked proposals = ".$totalonlinkedelements.", of order = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
| 117 | 122 | if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
@@ -140,7 +145,9 @@ discard block |
||
| 140 | 145 | $totalonlinkedelements=0; |
| 141 | 146 | foreach($object->linkedObjects['commande'] as $element) |
| 142 | 147 | {
|
| 143 | - if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; |
|
| 148 | + if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) { |
|
| 149 | + $totalonlinkedelements += $element->total_ht; |
|
| 150 | + } |
|
| 144 | 151 | } |
| 145 | 152 | dol_syslog( "Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
| 146 | 153 | if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
@@ -163,7 +170,9 @@ discard block |
||
| 163 | 170 | $totalonlinkedelements=0; |
| 164 | 171 | foreach($object->linkedObjects['propal'] as $element) |
| 165 | 172 | {
|
| 166 | - if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; |
|
| 173 | + if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) { |
|
| 174 | + $totalonlinkedelements += $element->total_ht; |
|
| 175 | + } |
|
| 167 | 176 | } |
| 168 | 177 | dol_syslog( "Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
| 169 | 178 | if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
@@ -192,7 +201,9 @@ discard block |
||
| 192 | 201 | $totalonlinkedelements=0; |
| 193 | 202 | foreach($object->linkedObjects['order_supplier'] as $element) |
| 194 | 203 | {
|
| 195 | - 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; |
|
| 204 | + if ($element->statut == CommandeFournisseur::STATUS_ACCEPTED || $element->statut == CommandeFournisseur::STATUS_ORDERSENT || $element->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY || $element->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) { |
|
| 205 | + $totalonlinkedelements += $element->total_ht; |
|
| 206 | + } |
|
| 196 | 207 | } |
| 197 | 208 | dol_syslog( "Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
| 198 | 209 | if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
@@ -215,7 +226,9 @@ discard block |
||
| 215 | 226 | $totalonlinkedelements=0; |
| 216 | 227 | foreach($object->linkedObjects['supplier_proposal'] as $element) |
| 217 | 228 | {
|
| 218 | - if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; |
|
| 229 | + if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_BILLED) { |
|
| 230 | + $totalonlinkedelements += $element->total_ht; |
|
| 231 | + } |
|
| 219 | 232 | } |
| 220 | 233 | dol_syslog( "Amount of linked supplier proposals = ".$totalonlinkedelements.", of supplier invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
| 221 | 234 | if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
@@ -243,7 +256,9 @@ discard block |
||
| 243 | 256 | $totalonlinkedelements=0; |
| 244 | 257 | foreach($object->linkedObjects['commande'] as $element) |
| 245 | 258 | {
|
| 246 | - if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; |
|
| 259 | + if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) { |
|
| 260 | + $totalonlinkedelements += $element->total_ht; |
|
| 261 | + } |
|
| 247 | 262 | } |
| 248 | 263 | dol_syslog( "Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); |
| 249 | 264 | if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) |
@@ -328,7 +343,9 @@ discard block |
||
| 328 | 343 | $totalonlinkedelements=0; |
| 329 | 344 | foreach($object->linkedObjects['reception'] as $element) |
| 330 | 345 | {
|
| 331 | - if ($element->statut == Reception::STATUS_VALIDATED) $totalonlinkedelements += $element->total_ht; |
|
| 346 | + if ($element->statut == Reception::STATUS_VALIDATED) { |
|
| 347 | + $totalonlinkedelements += $element->total_ht; |
|
| 348 | + } |
|
| 332 | 349 | } |
| 333 | 350 | dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG);
|
| 334 | 351 | if ($totalonlinkedelements == $object->total_ht) |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $arraycontext = array($arraycontext); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $this->contextarray = array_unique(array_merge($arraycontext, $this->contextarray)); // All contexts are concatenated |
|
| 77 | + $this->contextarray = array_unique(array_merge($arraycontext, $this->contextarray)); // All contexts are concatenated |
|
| 78 | 78 | |
| 79 | 79 | foreach (Globals::$conf->modules_parts['hooks'] as $module => $hooks) { // Loop on each module that brings hooks |
| 80 | 80 | if (empty(Globals::$conf->$module->enabled)) { |
@@ -84,20 +84,20 @@ discard block |
||
| 84 | 84 | //dol_syslog(get_class($this).'::initHooks module='.$module.' arraycontext='.join(',',$arraycontext)); |
| 85 | 85 | foreach ($arraycontext as $context) { |
| 86 | 86 | if (is_array($hooks)) { |
| 87 | - $arrayhooks = $hooks; // New system |
|
| 87 | + $arrayhooks = $hooks; // New system |
|
| 88 | 88 | } else { |
| 89 | - $arrayhooks = explode(':', $hooks); // Old system (for backward compatibility) |
|
| 89 | + $arrayhooks = explode(':', $hooks); // Old system (for backward compatibility) |
|
| 90 | 90 | } |
| 91 | 91 | if (in_array($context, $arrayhooks) || in_array('all', $arrayhooks)) { // We instantiate action class only if initialized hook is handled by module |
| 92 | 92 | // Include actions class overwriting hooks |
| 93 | 93 | if (!is_object($this->hooks[$context][$module])) { // If set, class was already loaded |
| 94 | - $path = '/' . $module . '/class/'; |
|
| 95 | - $actionfile = 'actions_' . $module . '.class.php'; |
|
| 94 | + $path = '/'.$module.'/class/'; |
|
| 95 | + $actionfile = 'actions_'.$module.'.class.php'; |
|
| 96 | 96 | |
| 97 | - dol_syslog(get_class($this) . '::initHooks Loading hook class for context ' . $context . ": " . $actionfile, LOG_INFO); |
|
| 98 | - $resaction = dol_include_once($path . $actionfile); |
|
| 97 | + dol_syslog(get_class($this).'::initHooks Loading hook class for context '.$context.": ".$actionfile, LOG_INFO); |
|
| 98 | + $resaction = dol_include_once($path.$actionfile); |
|
| 99 | 99 | if ($resaction) { |
| 100 | - $controlclassname = 'Actions' . ucfirst($module); |
|
| 100 | + $controlclassname = 'Actions'.ucfirst($module); |
|
| 101 | 101 | $actionInstance = new $controlclassname($this->db); |
| 102 | 102 | $this->hooks[$context][$module] = $actionInstance; |
| 103 | 103 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | $actionclassinstance->error = 0; |
| 221 | 221 | $actionclassinstance->errors = array(); |
| 222 | 222 | |
| 223 | - dol_syslog(get_class($this) . "::executeHooks Qualified hook found (hooktype=" . $hooktype . "). We call method " . $method . " of class " . get_class($actionclassinstance) . ", module=" . $module . ", action=" . $action . " context=" . $context, LOG_DEBUG); |
|
| 223 | + dol_syslog(get_class($this)."::executeHooks Qualified hook found (hooktype=".$hooktype."). We call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", action=".$action." context=".$context, LOG_DEBUG); |
|
| 224 | 224 | |
| 225 | 225 | // Add current context to avoid method execution in bad context, you can add this test in your method : eg if($currentcontext != 'formfile') return; |
| 226 | 226 | $parameters['currentcontext'] = $context; |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | $error++; |
| 232 | 232 | $this->error = $actionclassinstance->error; |
| 233 | 233 | $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors); |
| 234 | - dol_syslog("Error on hook module=" . $module . ", method " . $method . ", class " . get_class($actionclassinstance) . ", hooktype=" . $hooktype . (empty($this->error) ? '' : " " . $this->error) . (empty($this->errors) ? '' : " " . join(",", $this->errors)), LOG_ERR); |
|
| 234 | + dol_syslog("Error on hook module=".$module.", method ".$method.", class ".get_class($actionclassinstance).", hooktype=".$hooktype.(empty($this->error) ? '' : " ".$this->error).(empty($this->errors) ? '' : " ".join(",", $this->errors)), LOG_ERR); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | if (isset($actionclassinstance->results) && is_array($actionclassinstance->results)) |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | $this->resPrint .= $actionclassinstance->resprints; |
| 255 | 255 | // TODO dead code to remove (do not enable this, but fix hook instead): result must not be a string but an int. you must use $actionclassinstance->resprints to return a string |
| 256 | 256 | if (!is_array($resaction) && !is_numeric($resaction)) { |
| 257 | - dol_syslog('Error: Bug into hook ' . $method . ' of module class ' . get_class($actionclassinstance) . '. Method must not return a string but an int (0=OK, 1=Replace, -1=KO) and set string into ->resprints', LOG_ERR); |
|
| 257 | + dol_syslog('Error: Bug into hook '.$method.' of module class '.get_class($actionclassinstance).'. Method must not return a string but an int (0=OK, 1=Replace, -1=KO) and set string into ->resprints', LOG_ERR); |
|
| 258 | 258 | if (empty($actionclassinstance->resprints)) { |
| 259 | 259 | $this->resPrint .= $resaction; |
| 260 | 260 | $resaction = 0; |
@@ -138,8 +138,9 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | function executeHooks($method, $parameters = array(), &$object = '', &$action = '') |
| 140 | 140 | { |
| 141 | - if (!is_array($this->hooks) || empty($this->hooks)) |
|
| 142 | - return ''; |
|
| 141 | + if (!is_array($this->hooks) || empty($this->hooks)) { |
|
| 142 | + return ''; |
|
| 143 | + } |
|
| 143 | 144 | |
| 144 | 145 | $parameters['context'] = join(':', $this->contextarray); |
| 145 | 146 | //dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']); |
@@ -199,8 +200,9 @@ discard block |
||
| 199 | 200 | 'setContentSecurityPolicy', |
| 200 | 201 | 'setHtmlTitle' |
| 201 | 202 | ) |
| 202 | - )) |
|
| 203 | - $hooktype = 'addreplace'; |
|
| 203 | + )) { |
|
| 204 | + $hooktype = 'addreplace'; |
|
| 205 | + } |
|
| 204 | 206 | |
| 205 | 207 | if ($method == 'insertExtraFields') { |
| 206 | 208 | $hooktype = 'returnvalue'; // @deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available. |
@@ -222,12 +224,14 @@ discard block |
||
| 222 | 224 | foreach ($modules as $module => $actionclassinstance) { |
| 223 | 225 | //print "Before hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction." result=".$result."<br>\n"; |
| 224 | 226 | // test to avoid running twice a hook, when a module implements several active contexts |
| 225 | - if (in_array($module, $modulealreadyexecuted)) |
|
| 226 | - continue; |
|
| 227 | + if (in_array($module, $modulealreadyexecuted)) { |
|
| 228 | + continue; |
|
| 229 | + } |
|
| 227 | 230 | |
| 228 | 231 | // jump to next module/class if method does not exist |
| 229 | - if (!method_exists($actionclassinstance, $method)) |
|
| 230 | - continue; |
|
| 232 | + if (!method_exists($actionclassinstance, $method)) { |
|
| 233 | + continue; |
|
| 234 | + } |
|
| 231 | 235 | |
| 232 | 236 | $this->resNbOfHooks++; |
| 233 | 237 | |
@@ -250,24 +254,29 @@ discard block |
||
| 250 | 254 | dol_syslog("Error on hook module=" . $module . ", method " . $method . ", class " . get_class($actionclassinstance) . ", hooktype=" . $hooktype . (empty($this->error) ? '' : " " . $this->error) . (empty($this->errors) ? '' : " " . join(",", $this->errors)), LOG_ERR); |
| 251 | 255 | } |
| 252 | 256 | |
| 253 | - if (isset($actionclassinstance->results) && is_array($actionclassinstance->results)) |
|
| 254 | - $this->resArray = array_merge($this->resArray, $actionclassinstance->results); |
|
| 255 | - if (!empty($actionclassinstance->resprints)) |
|
| 256 | - $this->resPrint .= $actionclassinstance->resprints; |
|
| 257 | + if (isset($actionclassinstance->results) && is_array($actionclassinstance->results)) { |
|
| 258 | + $this->resArray = array_merge($this->resArray, $actionclassinstance->results); |
|
| 259 | + } |
|
| 260 | + if (!empty($actionclassinstance->resprints)) { |
|
| 261 | + $this->resPrint .= $actionclassinstance->resprints; |
|
| 262 | + } |
|
| 257 | 263 | } |
| 258 | 264 | // Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...) |
| 259 | 265 | else { |
| 260 | 266 | // TODO. this test should be done into the method of hook by returning nothing |
| 261 | - if (is_array($parameters) && !empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) |
|
| 262 | - continue; |
|
| 267 | + if (is_array($parameters) && !empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) { |
|
| 268 | + continue; |
|
| 269 | + } |
|
| 263 | 270 | |
| 264 | 271 | //dol_syslog("Call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", hooktype=".$hooktype, LOG_DEBUG); |
| 265 | 272 | $resaction = $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) |
| 266 | 273 | |
| 267 | - if (!empty($actionclassinstance->results) && is_array($actionclassinstance->results)) |
|
| 268 | - $this->resArray = array_merge($this->resArray, $actionclassinstance->results); |
|
| 269 | - if (!empty($actionclassinstance->resprints)) |
|
| 270 | - $this->resPrint .= $actionclassinstance->resprints; |
|
| 274 | + if (!empty($actionclassinstance->results) && is_array($actionclassinstance->results)) { |
|
| 275 | + $this->resArray = array_merge($this->resArray, $actionclassinstance->results); |
|
| 276 | + } |
|
| 277 | + if (!empty($actionclassinstance->resprints)) { |
|
| 278 | + $this->resPrint .= $actionclassinstance->resprints; |
|
| 279 | + } |
|
| 271 | 280 | // TODO dead code to remove (do not enable this, but fix hook instead): result must not be a string but an int. you must use $actionclassinstance->resprints to return a string |
| 272 | 281 | if (!is_array($resaction) && !is_numeric($resaction)) { |
| 273 | 282 | dol_syslog('Error: Bug into hook ' . $method . ' of module class ' . get_class($actionclassinstance) . '. Method must not return a string but an int (0=OK, 1=Replace, -1=KO) and set string into ->resprints', LOG_ERR); |