28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/triggers/interface_50_modNotification_Notification.class.php';
35 $langs->loadLangs(array(
'companies',
'mails',
'admin',
'other'));
38 $action =
GETPOST(
'action',
'aZ09');
39 $actionid =
GETPOST(
'actionid');
42 if ($user->socid) $id = $user->socid;
45 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
46 $sortfield =
GETPOST(
"sortfield",
'alpha');
47 $sortorder =
GETPOST(
"sortorder",
'alpha');
49 if (!$sortorder) $sortorder =
"DESC";
50 if (!$sortfield) $sortfield =
"n.daten";
51 if (empty($page) || $page == -1) { $page = 0; }
52 $offset = $limit * $page;
53 $pageprev = $page - 1;
54 $pagenext = $page + 1;
70 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Action")), null,
'errors');
78 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def";
79 $sql .=
" WHERE fk_user=".$id.
" AND fk_action=".$actionid;
82 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify_def (datec,fk_user, fk_action)";
83 $sql .=
" VALUES ('".$db->idate($now).
"',".$id.
",".$actionid.
")";
85 if (!$db->query($sql))
104 if ($action ==
'delete')
106 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def where rowid=".
GETPOST(
"actid",
"int");
116 $form =
new Form($db);
118 $object =
new User($db);
119 $result = $object->fetch($id,
'',
'', 1);
120 $object->getrights();
122 $title = $langs->trans(
"ThirdParty").
' - '.$langs->trans(
"Notification");
123 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.
' - '.$langs->trans(
"Notification");
124 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
130 $langs->load(
"other");
136 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
138 dol_banner_tab($object,
'id', $linkback, $user->rights->user->user->lire || $user->admin,
'rowid',
'ref',
'',
'', 0,
'',
'', 0,
'');
140 print '<div class="fichecenter">';
142 print '<div class="underbanner clearboth"></div>';
143 print '<table class="border centpercent tableforfield">';
146 print '<tr><td class="titlefield">'.$langs->trans(
"Login").
'</td>';
147 if (!empty($object->ldap_sid) && $object->statut == 0)
149 print '<td class="error">'.$langs->trans(
"LoginAccountDisableInDolibarr").
'</td>';
151 print '<td>'.$object->login.
'</td>';
176 print '<span class="opacitymedium">';
177 print '<br>'.$langs->trans(
"NotificationsDesc");
178 print '<br>'.$langs->trans(
"NotificationsDescUser");
179 print '<br>'.$langs->trans(
"NotificationsDescContact");
180 print '<br>'.$langs->trans(
"NotificationsDescGlobal");
183 print '<br><br><br>'.
"\n";
189 print '<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'" method="post">';
190 print '<input type="hidden" name="token" value="'.newToken().
'">';
191 print '<input type="hidden" name="action" value="add">';
196 print '<table width="100%" class="noborder">';
197 print '<tr class="liste_titre">';
212 $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
214 foreach ($listofnotifiedevents as $notifiedevent)
216 $label = ($langs->trans(
"Notify_".$notifiedevent[
'code']) !=
"Notify_".$notifiedevent[
'code'] ? $langs->trans(
"Notify_".$notifiedevent[
'code']) : $notifiedevent[
'label']);
217 $actions[$notifiedevent[
'rowid']] = $label;
219 print '<tr class="oddeven nohover"><td>';
220 print $object->getNomUrl(1);
223 print ' <'.$object->email.
'>';
225 $langs->load(
"errors");
226 print ' '.img_warning().
' '.$langs->trans(
"ErrorBadEMail", $object->email);
230 print img_picto(
'',
'object_action',
'',
false, 0, 0,
'',
'paddingright').$form->selectarray(
"actionid", $actions,
'', 1);
233 $type = array(
'email'=>$langs->trans(
"EMail"));
234 print $form->selectarray(
"typeid", $type);
236 print '<td class="right"><input type="submit" class="button" value="'.$langs->trans(
"Add").
'"></td>';
239 print '<tr class="oddeven"><td colspan="4">';
240 print $langs->trans(
"YouMustAssignUserMailFirst");
250 $sql =
"SELECT n.rowid, n.type,";
251 $sql .=
" a.code, a.label,";
252 $sql .=
" c.rowid as userid, c.lastname, c.firstname, c.email";
253 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
254 $sql .=
" ".MAIN_DB_PREFIX.
"notify_def as n,";
255 $sql .=
" ".MAIN_DB_PREFIX.
"user c";
256 $sql .=
" WHERE a.rowid = n.fk_action";
257 $sql .=
" AND c.rowid = n.fk_user";
258 $sql .=
" AND c.rowid = ".$object->id;
260 $resql = $db->query($sql);
263 $num = $db->num_rows(
$resql);
272 print '<table width="100%" class="noborder">';
273 print
'<tr class="liste_titre">';
280 $langs->load(
"errors");
281 $langs->load(
"other");
287 $userstatic =
new user($db);
291 $obj = $db->fetch_object(
$resql);
293 $userstatic->id = $obj->userid;
294 $userstatic->lastname = $obj->lastname;
295 $userstatic->firstname = $obj->firstname;
296 print
'<tr class="oddeven"><td>'.$userstatic->getNomUrl(1);
297 if ($obj->type ==
'email')
301 print
' <'.$obj->email.
'>';
303 $langs->load(
"errors");
304 print
' '.img_warning().
' '.$langs->trans(
"ErrorBadEMail", $obj->email);
309 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
310 print
img_picto(
'',
'object_action',
'',
false, 0, 0,
'',
'paddingright').$label;
313 if ($obj->type ==
'email') print $langs->trans(
"Email");
314 if ($obj->type ==
'sms') print $langs->trans(
"SMS");
316 print
'<td class="right"><a href="card.php?id='.$id.
'&action=delete&token='.
newToken().
'&actid='.$obj->rowid.
'">'.
img_delete().
'</a></td>';
376 print
'<br><br>'.
"\n";
380 $sql =
"SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
381 $sql .=
" c.rowid as id, c.lastname, c.firstname, c.email as contactemail,";
382 $sql .=
" a.code, a.label";
383 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
384 $sql .=
" ".MAIN_DB_PREFIX.
"notify as n";
385 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as c ON n.fk_user = c.rowid";
386 $sql .=
" WHERE a.rowid = n.fk_action";
387 $sql .=
" AND n.fk_user = ".$object->id;
388 $sql .= $db->order($sortfield, $sortorder);
391 $nbtotalofrecords =
'';
392 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
394 $result = $db->query($sql);
395 $nbtotalofrecords = $db->num_rows($result);
396 if (($page * $limit) > $nbtotalofrecords)
403 $sql .= $db->plimit($limit + 1, $offset);
405 $resql = $db->query($sql);
408 $num = $db->num_rows(
$resql);
413 $param =
'&id='.$object->id;
414 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.$contextpage;
415 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.$limit;
417 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
418 if ($optioncss !=
'') print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
419 print
'<input type="hidden" name="token" value="'.newToken().
'">';
420 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
421 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
422 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
423 print
'<input type="hidden" name="page" value="'.$page.
'">';
424 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
427 print_barre_liste($langs->trans(
"ListOfNotificationsDone"), $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
430 print
'<table width="100%" class="noborder">';
431 print
'<tr class="liste_titre">';
432 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
436 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"n.daten",
'', $param,
'', $sortfield, $sortorder,
'right ');
443 $userstatic =
new User($db);
447 $obj = $db->fetch_object(
$resql);
449 print
'<tr class="oddeven"><td>';
452 $userstatic->id = $obj->id;
453 $userstatic->lastname = $obj->lastname;
454 $userstatic->firstname = $obj->firstname;
455 print $userstatic->getNomUrl(1);
456 print $obj->email ?
' <'.$obj->email.
'>' : $langs->trans(
"NoMail");
462 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
466 if ($obj->type ==
'email') print $langs->trans(
"Email");
467 if ($obj->type ==
'sms') print $langs->trans(
"Sms");
479 print
'<td class="right">'.dol_print_date($db->jdate($obj->daten),
'dayhour').
'</td>';
485 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
user_prepare_head($object)
Prepare array with list of tabs.
Class of triggers for notification module.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
isValidEmail($address, $acceptsupervisorkey=0)
Return true if email syntax is ok.