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;
181 $sql .=
" ORDER BY type, position, module";
183 dol_syslog(get_class($this).
"::liste_array", LOG_DEBUG);
184 $resql = $this->db->query($sql);
186 $nump = $this->db->num_rows($resql);
188 $idforallfornewmodule = 97;
191 $obj = $this->db->fetch_object($resql);
199 if ($qualified && $onlyautoornot > 0 && preg_match(
'/^system/', $obj->type) && !preg_match(
'/^AC_OTH/', $obj->code)) {
203 if ($qualified && !empty($obj->module)) {
207 if ($obj->module ==
'invoice' && isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire')) {
210 if ($obj->module ==
'order' && isModEnabled(
'commande') && !$user->hasRight(
'commande',
'lire')) {
213 if ($obj->module ==
'propal' && isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
216 if ($obj->module ==
'invoice_supplier' && ((isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->facture->lire)) || (isModEnabled(
'supplier_invoice') && !empty($user->rights->supplier_invoice->lire)))) {
219 if ($obj->module ==
'order_supplier' && ((isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->commande->lire)) || (!isModEnabled(
'supplier_order') && !empty($user->rights->supplier_order->lire)))) {
222 if ($obj->module ==
'shipping' && isModEnabled(
"expedition") && !empty($user->rights->expedition->lire)) {
226 $tmparray = explode(
"@", $obj->module);
227 if (count($tmparray) > 1 && $tmparray[1] ==
'eventorganization' && isModEnabled(
'eventorganization')) {
232 if (preg_match(
'/^module/', $obj->type)) {
233 if (preg_match(
'/^(.+)@(.+)$/', $obj->module, $regs)) {
234 $tmpobject = $regs[1];
235 $tmpmodule = $regs[2];
237 if ($tmpmodule && isset($conf->$tmpmodule) && isModEnabled($tmpmodule) && (!empty($user->rights->$tmpmodule->read) || !empty($user->rights->$tmpmodule->lire) || !empty($user->rights->$tmpmodule->$tmpobject->read) || !empty($user->rights->$tmpmodule->$tmpobject->lire))) {
243 if (! in_array($obj->type, array(
'system',
'systemauto',
'module',
'moduleauto'))) {
244 $tmpmodule = $obj->module;
246 if ($tmpmodule && isset($conf->$tmpmodule) && isModEnabled($tmpmodule)) {
256 $typecalendar = $obj->type;
258 if ($onlyautoornot > 0 && $typecalendar ==
'system') {
260 } elseif ($onlyautoornot > 0 && $typecalendar ==
'systemauto') {
262 } elseif ($onlyautoornot > 0) {
263 $code =
'AC_'.strtoupper($obj->module);
267 $keyfortrans =
"Action".$code.
'Short';
268 $transcode = $langs->trans($keyfortrans);
270 if (empty($keyfortrans) || $keyfortrans == $transcode) {
271 $keyfortrans =
"Action".$code;
272 $transcode = $langs->trans($keyfortrans);
274 $label = (($transcode != $keyfortrans) ? $transcode : $langs->trans($obj->label));
275 if (($onlyautoornot == -1 || $onlyautoornot == -2) && !empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
276 if ($typecalendar ==
'system') {
277 $label =
' '.$label;
278 $repid[-99] = $langs->trans(
"ActionAC_MANUAL");
279 $repcode[
'AC_NON_AUTO'] =
'-- '.$langs->trans(
"ActionAC_MANUAL");
281 if ($typecalendar ==
'systemauto') {
282 $label =
' '.$label;
283 $repid[-98] = $langs->trans(
"ActionAC_AUTO");
284 $repcode[
'AC_ALL_AUTO'] =
'-- '.$langs->trans(
"ActionAC_AUTO");
286 if ($typecalendar ==
'module') {
288 if (preg_match(
'/@/', $obj->module)) {
289 $module = explode(
'@', $obj->module)[1];
291 $module = $obj->module;
293 $label =
' '.$label;
294 if (!isset($repcode[
'AC_ALL_'.strtoupper($module)])) {
295 $idforallfornewmodule--;
297 $repid[$idforallfornewmodule] = $langs->trans(
"ActionAC_ALL_".strtoupper($module));
298 $repcode[
'AC_ALL_'.strtoupper($module)] =
'-- '.$langs->trans(
"Module").
' '.ucfirst($module);
301 $repid[$obj->id] = $label;
302 $repcode[$obj->code] = $label;
303 $repall[$obj->code] = array(
'id' => $label,
'label' => $label,
'type' => $typecalendar,
'color' => $obj->color,
'picto' => $obj->picto);
304 if ($onlyautoornot > 0 && preg_match(
'/^module/', $obj->type) && $obj->module) {
305 $repcode[$obj->code] .=
' ('.$langs->trans(
"Module").
': '.$obj->module.
')';
306 $repall[$obj->code][
'label'] .=
' ('.$langs->trans(
"Module").
': '.$obj->module.
')';
313 if ($idorcode ==
'id') {
315 } elseif ($idorcode ==
'code') {
321 return $this->liste_array;
323 $this->error = $this->db->lasterror();