113 $sql =
"SELECT id, code, type, libelle as label, color, active, picto";
114 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm";
115 if (is_numeric($id)) {
116 $sql .=
" WHERE id=".(int) $id;
118 $sql .=
" WHERE code='".$this->db->escape($id).
"'";
121 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
122 $resql = $this->db->query($sql);
124 if ($this->db->num_rows($resql)) {
125 $obj = $this->db->fetch_object($resql);
127 $this->
id = $obj->id;
128 $this->code = $obj->code;
129 $this->
type = $obj->type;
130 $this->libelle = $obj->label;
131 $this->label = $obj->label;
132 $this->active = $obj->active;
133 $this->color = $obj->color;
135 $this->db->free($resql);
138 $this->db->free($resql);
142 $this->error = $this->db->error();
159 public function liste_array($active =
'', $idorcode =
'id', $excludetype =
'', $onlyautoornot = 0, $morefilter =
'', $shortlabel = 0)
162 global $langs, $conf, $user;
163 $langs->load(
"commercial");
169 $sql =
"SELECT id, code, libelle as label, module, type, color, picto";
170 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm";
171 $sql .=
" WHERE 1=1";
173 $sql .=
" AND active=".(int) $active;
175 if (!empty($excludetype)) {
176 $sql .=
" AND type <> '".$this->db->escape($excludetype).
"'";
179 $sql .=
" AND ".$morefilter;
184 $sql .=
" ORDER BY position, type, module";
186 $sql .=
" ORDER BY type, position, module";
189 dol_syslog(get_class($this).
"::liste_array", LOG_DEBUG);
190 $resql = $this->db->query($sql);
192 $nump = $this->db->num_rows($resql);
194 $idforallfornewmodule = 97;
197 $obj = $this->db->fetch_object($resql);
205 if ($qualified && $onlyautoornot > 0 && preg_match(
'/^system/', $obj->type) && !preg_match(
'/^AC_OTH/', $obj->code)) {
209 if ($qualified && !empty($obj->module)) {
213 if ($obj->module ==
'invoice' && isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire')) {
216 if ($obj->module ==
'order' && isModEnabled(
'commande') && !$user->hasRight(
'commande',
'lire')) {
219 if ($obj->module ==
'propal' && isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
222 if ($obj->module ==
'invoice_supplier' && ((isModEnabled(
"fournisseur") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight(
'fournisseur',
'facture',
'lire')) || (isModEnabled(
'supplier_invoice') && $user->hasRight(
'supplier_invoice',
'lire')))) {
225 if ($obj->module ==
'order_supplier' && ((isModEnabled(
"fournisseur") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight(
'fournisseur',
'commande',
'lire')) || (!isModEnabled(
'supplier_order') && $user->hasRight(
'supplier_order',
'lire')))) {
228 if ($obj->module ==
'shipping' && isModEnabled(
"expedition") && $user->hasRight(
'expedition',
'lire')) {
232 $tmparray = explode(
"@", $obj->module);
233 if (count($tmparray) > 1 && $tmparray[1] ==
'eventorganization' && isModEnabled(
'eventorganization')) {
238 if (preg_match(
'/^module/', $obj->type)) {
239 if (preg_match(
'/^(.+)@(.+)$/', $obj->module, $regs)) {
240 $tmpobject = $regs[1];
241 $tmpmodule = $regs[2];
243 if ($tmpmodule && isset($conf->$tmpmodule) && isModEnabled($tmpmodule) && ($user->hasRight($tmpmodule,
'read') || $user->hasRight($tmpmodule,
'lire') || $user->hasRight($tmpmodule, $tmpobject,
'read') || $user->hasRight($tmpmodule, $tmpobject,
'lire'))) {
249 if (! in_array($obj->type, array(
'system',
'systemauto',
'module',
'moduleauto'))) {
250 $tmpmodule = $obj->module;
252 if ($tmpmodule && isset($conf->$tmpmodule) && isModEnabled($tmpmodule)) {
262 $typecalendar = $obj->type;
264 if ($onlyautoornot > 0 && $typecalendar ==
'system') {
266 } elseif ($onlyautoornot > 0 && $typecalendar ==
'systemauto') {
268 } elseif ($onlyautoornot > 0) {
269 $code =
'AC_'.strtoupper($obj->module);
273 $keyfortrans =
"Action".$code.
'Short';
274 $transcode = $langs->trans($keyfortrans);
276 if (empty($keyfortrans) || $keyfortrans == $transcode) {
277 $keyfortrans =
"Action".$code;
278 $transcode = $langs->trans($keyfortrans);
280 $label = (($transcode != $keyfortrans) ? $transcode : $langs->trans($obj->label));
281 if (($onlyautoornot == -1 || $onlyautoornot == -2) &&
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE')) {
282 if ($typecalendar ==
'system') {
283 $label =
' '.$label;
284 $repid[-99] = $langs->trans(
"ActionAC_MANUAL");
285 $repcode[
'AC_NON_AUTO'] =
'-- '.$langs->trans(
"ActionAC_MANUAL");
287 if ($typecalendar ==
'systemauto') {
288 $label =
' '.$label;
289 $repid[-98] = $langs->trans(
"ActionAC_AUTO");
290 $repcode[
'AC_ALL_AUTO'] =
'-- '.$langs->trans(
"ActionAC_AUTO");
292 if ($typecalendar ==
'module') {
294 if (preg_match(
'/@/', $obj->module)) {
295 $module = explode(
'@', $obj->module)[1];
297 $module = $obj->module;
299 $label =
' '.$label;
300 if (!isset($repcode[
'AC_ALL_'.strtoupper($module)])) {
301 $idforallfornewmodule--;
303 $repid[$idforallfornewmodule] = $langs->trans(
"ActionAC_ALL_".strtoupper($module));
304 $repcode[
'AC_ALL_'.strtoupper($module)] =
'-- '.$langs->trans(
"Module").
' '.ucfirst($module);
307 $repid[$obj->id] = $label;
308 $repcode[$obj->code] = $label;
309 $repall[$obj->code] = array(
'id' => $label,
'label' => $label,
'type' => $typecalendar,
'color' => $obj->color,
'picto' => $obj->picto);
310 if ($onlyautoornot > 0 && preg_match(
'/^module/', $obj->type) && $obj->module) {
311 $repcode[$obj->code] .=
' ('.$langs->trans(
"Module").
': '.$obj->module.
')';
312 $repall[$obj->code][
'label'] .=
' ('.$langs->trans(
"Module").
': '.$obj->module.
')';
319 if ($idorcode ==
'id') {
321 } elseif ($idorcode ==
'code') {
327 return $this->liste_array;
329 $this->error = $this->db->lasterror();