29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/triggers/interface_50_modNotification_Notification.class.php';
36$langs->loadLangs(array(
'companies',
'mails',
'admin',
'other',
'errors'));
41if (!isset($id) || empty($id)) {
45$action =
GETPOST(
'action',
'aZ09');
46$actionid =
GETPOST(
'actionid',
'int');
48$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
49$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
51$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
56 $sortfield =
"n.daten";
58if (empty($page) || $page == -1) {
61$offset = $limit * $page;
68$object =
new User($db);
69if ($id > 0 || !empty($ref)) {
70 $result = $object->fetch($id, $ref,
'', 1);
74$permissiontoadd = (($object->id == $user->id) || (!empty($user->rights->user->user->lire)));
87if (
GETPOST(
'cancel',
'alpha')) {
92if ($action ==
'add') {
96 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Action")),
null,
'errors');
104 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def";
105 $sql .=
" WHERE fk_user=".((int) $id).
" AND fk_action=".((int) $actionid);
106 if ($db->query($sql)) {
107 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify_def (datec, fk_user, fk_action)";
108 $sql .=
" VALUES ('".$db->idate($now).
"', ".((int) $id).
", ".((int) $actionid).
")";
110 if (!$db->query($sql)) {
128if ($action ==
'delete') {
129 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def where rowid=".
GETPOST(
"actid",
"int");
139$form =
new Form($db);
141$object =
new User($db);
142$result = $object->fetch($id,
'',
'', 1);
145$title = $langs->trans(
"ThirdParty").
' - '.$langs->trans(
"Notification");
146if (
getDolGlobalString(
'MAIN_HTML_TITLE') && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
147 $title = $object->name.
' - '.$langs->trans(
"Notification");
149$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
154 $langs->load(
"other");
160 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
162 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/user/vcard.php?id='.$object->id.
'&output=file&file='.urlencode(
dol_sanitizeFileName($object->getFullName($langs).
'.vcf')).
'" class="refid" rel="noopener">';
163 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
164 $morehtmlref .=
'</a>';
166 $urltovirtualcard =
'/user/virtualcard.php?id='.((int) $object->id);
167 $morehtmlref .=
dolButtonToOpenUrlInDialogPopup(
'publicvirtualcard', $langs->transnoentitiesnoconv(
"PublicVirtualCardUrl").
' - '.$object->getFullName($langs),
img_picto($langs->trans(
"PublicVirtualCardUrl"),
'card',
'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard,
'',
'nohover');
169 dol_banner_tab($object,
'id', $linkback, $user->hasRight(
'user',
'user',
'lire') || $user->admin,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'', 0,
'');
171 print
'<div class="fichecenter">';
173 print
'<div class="underbanner clearboth"></div>';
174 print
'<table class="border centpercent tableforfield">';
177 print
'<tr><td class="titlefield">'.$langs->trans(
"Login").
'</td>';
178 if (!empty($object->ldap_sid) && $object->statut == 0) {
179 print
'<td class="error">';
180 print $langs->trans(
"LoginAccountDisableInDolibarr");
185 if (property_exists($object,
'admin')) {
186 if (isModEnabled(
'multicompany') && !empty($object->admin) && empty($object->entity)) {
187 $addadmin .=
img_picto($langs->trans(
"SuperAdministratorDesc"),
"redstar",
'class="paddingleft"');
188 } elseif (!empty($object->admin)) {
189 $addadmin .=
img_picto($langs->trans(
"AdministratorDesc"),
"star",
'class="paddingleft"');
218 print
'<span class="opacitymedium">';
219 print
'<br>'.$langs->trans(
"NotificationsDesc");
220 print
'<br>'.$langs->trans(
"NotificationsDescUser");
221 print
'<br>'.$langs->trans(
"NotificationsDescContact");
222 print
'<br>'.$langs->trans(
"NotificationsDescGlobal");
225 print
'<br><br><br>'.
"\n";
231 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.urlencode($id).
'" method="POST">';
232 print
'<input type="hidden" name="token" value="'.newToken().
'">';
233 print
'<input type="hidden" name="action" value="add">';
235 $param =
"&id=".urlencode($id);
251 $sql =
"SELECT n.rowid, n.type,";
252 $sql .=
" a.code, a.label,";
253 $sql .=
" c.rowid as userid, c.entity, c.login, c.lastname, c.firstname, c.email, c.statut as status";
254 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
255 $sql .=
" ".MAIN_DB_PREFIX.
"notify_def as n,";
256 $sql .=
" ".MAIN_DB_PREFIX.
"user c";
257 $sql .=
" WHERE a.rowid = n.fk_action";
258 $sql .=
" AND c.rowid = n.fk_user";
259 $sql .=
" AND c.rowid = ".((int) $object->id);
260 $sql .=
" AND c.entity IN (".getEntity(
'user').
')';
262 $resql = $db->query($sql);
264 $num = $db->num_rows($resql);
270 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
272 $title = $langs->trans(
"ListOfActiveNotifications");
276 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $num,
'email', 0, $newcardbutton,
'', $limit, 0, 0, 1);
279 print
'<table width="100%" class="noborder">';
280 print
'<tr class="liste_titre">';
281 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'width="45%"', $sortfield, $sortorder);
282 print_liste_field_titre(
"Action", $_SERVER[
"PHP_SELF"],
"",
'', $param,
'width="35%"', $sortfield, $sortorder);
283 print_liste_field_titre(
"Type", $_SERVER[
"PHP_SELF"],
"n.type",
'', $param,
'width="10%"', $sortfield, $sortorder);
288 if ($action ==
'create') {
290 if ($object->email) {
295 $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
297 foreach ($listofnotifiedevents as $notifiedevent) {
298 $label = ($langs->trans(
"Notify_".$notifiedevent[
'code']) !=
"Notify_".$notifiedevent[
'code'] ? $langs->trans(
"Notify_".$notifiedevent[
'code']) : $notifiedevent[
'label']);
299 $actions[$notifiedevent[
'rowid']] = $label;
301 print
'<tr class="oddeven nohover"><td>';
302 print $object->getNomUrl(1);
304 print
' <'.$object->email.
'>';
306 $langs->load(
"errors");
307 print
' '.img_warning().
' '.$langs->trans(
"ErrorBadEMail", $object->email);
311 print
img_picto(
'',
'object_action',
'',
false, 0, 0,
'',
'paddingright').$form->selectarray(
"actionid", $actions,
'', 1);
314 $type = array(
'email'=>$langs->trans(
"EMail"));
315 print $form->selectarray(
"typeid", $type);
317 print
'<td class="nowraponall">';
318 print
'<input type="submit" class="button button-add" value="'.$langs->trans(
"Add").
'">';
320 print
'<input type="submit" class="button" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
324 print
'<tr class="oddeven"><td colspan="4">';
325 print $langs->trans(
"YouMustAssignUserMailFirst");
332 $userstatic =
new User($db);
335 $obj = $db->fetch_object($resql);
337 $userstatic->id = $obj->userid;
338 $userstatic->lastname = $obj->lastname;
339 $userstatic->firstname = $obj->firstname;
340 $userstatic->email = $obj->email;
341 $userstatic->statut = $obj->status;
343 print
'<tr class="oddeven">';
344 print
'<td>'.$userstatic->getNomUrl(1);
345 if ($obj->type ==
'email') {
347 print
' <'.$obj->email.
'>';
349 $langs->load(
"errors");
350 print
' '.img_warning().
' '.$langs->trans(
"ErrorBadEMail", $obj->email);
355 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
356 print
img_picto(
'',
'object_action',
'',
false, 0, 0,
'',
'paddingright').$label;
359 if ($obj->type ==
'email') {
360 print $langs->trans(
"Email");
362 if ($obj->type ==
'sms') {
363 print $langs->trans(
"SMS");
366 print
'<td class="right"><a href="card.php?id='.$id.
'&action=delete&token='.newToken().
'&actid='.$obj->rowid.
'">'.
img_delete().
'</a></td>';
372 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
421 print
'<br><br>'.
"\n";
425 $sql =
"SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
426 $sql .=
" c.rowid as id, c.lastname, c.firstname, c.email as contactemail, c.statut as status,";
427 $sql .=
" a.code, a.label";
428 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
429 $sql .=
" ".MAIN_DB_PREFIX.
"notify as n";
430 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as c ON n.fk_user = c.rowid";
431 $sql .=
" WHERE a.rowid = n.fk_action";
432 $sql .=
" AND n.fk_user = ".((int) $object->id);
433 $sql .= $db->order($sortfield, $sortorder);
436 $nbtotalofrecords =
'';
438 $result = $db->query($sql);
439 $nbtotalofrecords = $db->num_rows($result);
440 if (($page * $limit) > $nbtotalofrecords) {
446 $sql .= $db->plimit($limit + 1, $offset);
448 $resql = $db->query($sql);
450 $num = $db->num_rows($resql);
455 $param =
'&id='.$object->id;
456 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
457 $param .=
'&contextpage='.$contextpage;
459 if ($limit > 0 && $limit != $conf->liste_limit) {
460 $param .=
'&limit='.$limit;
463 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
464 if (isset($optioncss) && $optioncss !=
'') {
465 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
467 print
'<input type="hidden" name="token" value="'.newToken().
'">';
468 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
469 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
470 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
471 print
'<input type="hidden" name="page" value="'.$page.
'">';
472 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
475 print_barre_liste($langs->trans(
"ListOfNotificationsDone"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'email', 0,
'',
'', $limit);
478 print
'<table width="100%" class="noborder">';
479 print
'<tr class="liste_titre">';
480 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
484 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"n.daten",
'', $param,
'', $sortfield, $sortorder,
'right ');
490 $userstatic =
new User($db);
493 $obj = $db->fetch_object($resql);
495 print
'<tr class="oddeven"><td>';
497 $userstatic->id = $obj->id;
498 $userstatic->lastname = $obj->lastname;
499 $userstatic->firstname = $obj->firstname;
500 $userstatic->statut = $obj->status;
501 $userstatic->email = $obj->email;
502 print $userstatic->getNomUrl(1);
503 print $obj->email ?
' <'.$obj->email.
'>' : $langs->trans(
"NoMail");
509 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
513 if ($obj->type ==
'email') {
514 print $langs->trans(
"Email");
516 if ($obj->type ==
'sms') {
517 print $langs->trans(
"Sms");
529 print
'<td class="right">'.dol_print_date($db->jdate($obj->daten),
'dayhour').
'</td>';
535 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class of triggers for notification module.
Class to manage Dolibarr users.
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.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
user_prepare_head(User $object)
Prepare array with list of tabs.