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 (!empty($conf->global->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->trans(
"PublicVirtualCardUrl").
' - '.$object->getFullName($langs),
img_picto($langs->trans(
"PublicVirtualCardUrl"),
'card',
'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard,
'',
'nohover');
169 dol_banner_tab($object,
'id', $linkback, $user->rights->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);
269 $newcardbutton =
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
271 $title = $langs->trans(
"ListOfActiveNotifications");
275 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $num,
'email', 0, $newcardbutton,
'', $limit, 0, 0, 1);
278 print
'<table width="100%" class="noborder">';
279 print
'<tr class="liste_titre">';
280 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'width="45%"', $sortfield, $sortorder);
281 print_liste_field_titre(
"Action", $_SERVER[
"PHP_SELF"],
"",
'', $param,
'width="35%"', $sortfield, $sortorder);
282 print_liste_field_titre(
"Type", $_SERVER[
"PHP_SELF"],
"n.type",
'', $param,
'width="10%"', $sortfield, $sortorder);
287 if ($action ==
'create') {
289 if ($object->email) {
294 $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
296 foreach ($listofnotifiedevents as $notifiedevent) {
297 $label = ($langs->trans(
"Notify_".$notifiedevent[
'code']) !=
"Notify_".$notifiedevent[
'code'] ? $langs->trans(
"Notify_".$notifiedevent[
'code']) : $notifiedevent[
'label']);
298 $actions[$notifiedevent[
'rowid']] = $label;
300 print
'<tr class="oddeven nohover"><td>';
301 print $object->getNomUrl(1);
303 print
' <'.$object->email.
'>';
305 $langs->load(
"errors");
306 print
' '.img_warning().
' '.$langs->trans(
"ErrorBadEMail", $object->email);
310 print
img_picto(
'',
'object_action',
'',
false, 0, 0,
'',
'paddingright').$form->selectarray(
"actionid", $actions,
'', 1);
313 $type = array(
'email'=>$langs->trans(
"EMail"));
314 print $form->selectarray(
"typeid", $type);
316 print
'<td class="nowraponall">';
317 print
'<input type="submit" class="button button-add" value="'.$langs->trans(
"Add").
'">';
319 print
'<input type="submit" class="button" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
323 print
'<tr class="oddeven"><td colspan="4">';
324 print $langs->trans(
"YouMustAssignUserMailFirst");
331 $userstatic =
new User($db);
334 $obj = $db->fetch_object($resql);
336 $userstatic->id = $obj->userid;
337 $userstatic->lastname = $obj->lastname;
338 $userstatic->firstname = $obj->firstname;
339 $userstatic->email = $obj->email;
340 $userstatic->statut = $obj->status;
342 print
'<tr class="oddeven">';
343 print
'<td>'.$userstatic->getNomUrl(1);
344 if ($obj->type ==
'email') {
346 print
' <'.$obj->email.
'>';
348 $langs->load(
"errors");
349 print
' '.img_warning().
' '.$langs->trans(
"ErrorBadEMail", $obj->email);
354 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
355 print
img_picto(
'',
'object_action',
'',
false, 0, 0,
'',
'paddingright').$label;
358 if ($obj->type ==
'email') {
359 print $langs->trans(
"Email");
361 if ($obj->type ==
'sms') {
362 print $langs->trans(
"SMS");
365 print
'<td class="right"><a href="card.php?id='.$id.
'&action=delete&token='.newToken().
'&actid='.$obj->rowid.
'">'.
img_delete().
'</a></td>';
371 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
420 print
'<br><br>'.
"\n";
424 $sql =
"SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
425 $sql .=
" c.rowid as id, c.lastname, c.firstname, c.email as contactemail, c.statut as status,";
426 $sql .=
" a.code, a.label";
427 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
428 $sql .=
" ".MAIN_DB_PREFIX.
"notify as n";
429 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as c ON n.fk_user = c.rowid";
430 $sql .=
" WHERE a.rowid = n.fk_action";
431 $sql .=
" AND n.fk_user = ".((int) $object->id);
432 $sql .= $db->order($sortfield, $sortorder);
435 $nbtotalofrecords =
'';
437 $result = $db->query($sql);
438 $nbtotalofrecords = $db->num_rows($result);
439 if (($page * $limit) > $nbtotalofrecords) {
445 $sql .= $db->plimit($limit + 1, $offset);
447 $resql = $db->query($sql);
449 $num = $db->num_rows($resql);
454 $param =
'&id='.$object->id;
455 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
456 $param .=
'&contextpage='.$contextpage;
458 if ($limit > 0 && $limit != $conf->liste_limit) {
459 $param .=
'&limit='.$limit;
462 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
463 if (isset($optioncss) && $optioncss !=
'') {
464 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
466 print
'<input type="hidden" name="token" value="'.newToken().
'">';
467 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
468 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
469 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
470 print
'<input type="hidden" name="page" value="'.$page.
'">';
471 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
474 print_barre_liste($langs->trans(
"ListOfNotificationsDone"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'email', 0,
'',
'', $limit);
477 print
'<table width="100%" class="noborder">';
478 print
'<tr class="liste_titre">';
479 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
483 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"n.daten",
'', $param,
'', $sortfield, $sortorder,
'right ');
489 $userstatic =
new User($db);
492 $obj = $db->fetch_object($resql);
494 print
'<tr class="oddeven"><td>';
496 $userstatic->id = $obj->id;
497 $userstatic->lastname = $obj->lastname;
498 $userstatic->firstname = $obj->firstname;
499 $userstatic->statut = $obj->status;
500 $userstatic->email = $obj->email;
501 print $userstatic->getNomUrl(1);
502 print $obj->email ?
' <'.$obj->email.
'>' : $langs->trans(
"NoMail");
508 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
512 if ($obj->type ==
'email') {
513 print $langs->trans(
"Email");
515 if ($obj->type ==
'sms') {
516 print $langs->trans(
"Sms");
528 print
'<td class="right">'.dol_print_date($db->jdate($obj->daten),
'dayhour').
'</td>';
534 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 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.
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.