32require
'../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/triggers/interface_50_modNotification_Notification.class.php';
47$langs->loadLangs(array(
'companies',
'mails',
'admin',
'other',
'errors'));
52if (!isset($id) || empty($id)) {
56$action =
GETPOST(
'action',
'aZ09');
60$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
61$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
67 $sortfield =
"n.daten";
69if (empty($page) || $page == -1) {
72$offset = $limit * $page;
80if ($id > 0 || !empty($ref)) {
81 $result =
$object->fetch($id, $ref,
'', 1);
85$permissiontoadd = ((
$object->id == $user->id) || ($user->hasRight(
'user',
'user',
'lire')));
98if (
GETPOST(
'cancel',
'alpha')) {
105if ($action ==
'add' && $permissiontoadd) {
106 if ($actionid <= 0) {
107 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Action")),
null,
'errors');
115 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def";
116 $sql .=
" WHERE fk_user = ".((int) $id).
" AND fk_action = ".((int) $actionid);
117 if (
$db->query($sql)) {
118 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify_def (datec, fk_user, fk_action)";
119 $sql .=
" VALUES ('".$db->idate($now).
"', ".((int) $id).
", ".((int) $actionid).
")";
121 if (!
$db->query($sql)) {
139if ($action ==
'delete' && $permissiontoadd) {
140 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def where rowid = ".
GETPOSTINT(
"actid");
153$result =
$object->fetch($id,
'',
'', 1);
156$title = $langs->trans(
"ThirdParty").
' - '.$langs->trans(
"Notification");
158 $title =
$object->name.
' - '.$langs->trans(
"Notification");
160$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
162llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-user page-notify_card');
163$type = array(
'email' => $langs->trans(
"EMail"),
'sms' => $langs->trans(
"SMS"));
166 $langs->load(
"other");
172 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
174 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/user/vcard.php?id='.
$object->id.
'&output=file&file='.urlencode(
dol_sanitizeFileName(
$object->getFullName($langs).
'.vcf')).
'" class="refid valignmiddle" rel="noopener">';
175 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard',
'class="valignmiddle marginleftonly paddingrightonly"');
176 $morehtmlref .=
'</a>';
178 $urltovirtualcard =
'/user/virtualcard.php?id='.((int)
$object->id);
179 $morehtmlref .=
dolButtonToOpenUrlInDialogPopup(
'publicvirtualcard', $langs->transnoentitiesnoconv(
"PublicVirtualCardUrl").
' - '.
$object->getFullName($langs),
img_picto($langs->trans(
"PublicVirtualCardUrl"),
'card',
'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard,
'',
'refid valignmiddle nohover');
181 dol_banner_tab($object,
'id', $linkback, $user->hasRight(
'user',
'user',
'lire') || $user->admin,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'', 0,
'');
183 print
'<div class="fichecenter">';
185 print
'<div class="underbanner clearboth"></div>';
186 print
'<table class="border centpercent tableforfield">';
189 print
'<tr><td class="titlefield">'.$langs->trans(
"Login").
'</td>';
191 print
'<td class="error">';
192 print $langs->trans(
"LoginAccountDisableInDolibarr");
197 if (property_exists($object,
'admin')) {
199 $addadmin .=
img_picto($langs->trans(
"SuperAdministratorDesc"),
"superadmin",
'class="paddingleft valignmiddle"');
200 } elseif (!empty(
$object->admin)) {
201 $addadmin .=
img_picto($langs->trans(
"AdministratorDesc"),
"admin",
'class="paddingleft valignmiddle"');
204 print showValueWithClipboardCPButton(
$object->login).$addadmin;
218 print
'<span class="opacitymedium hideonsmartphone">';
219 print
'<br>'.$langs->trans(
"NotificationsDesc");
220 print
'<br>'.$langs->trans(
"NotificationsDescUser").
' - '.$langs->trans(
"YouAreHere");
222 print
'<br>'.$langs->trans(
"NotificationsDescContact");
224 print
'<br>'.$langs->trans(
"NotificationsDescGlobal");
227 print
'<br><br><br>'.
"\n";
232 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.urlencode((
string) ($id)).
'" method="POST">';
233 print
'<input type="hidden" name="token" value="'.newToken().
'">';
234 print
'<input type="hidden" name="page_y" value="">';
235 if ($action ==
'create') {
236 print
'<input type="hidden" name="action" id="action" value="add">';
239 $param =
"&id=".urlencode((
string) ($id));
244 $sql =
"SELECT n.rowid, n.type,";
245 $sql .=
" a.code, a.label,";
246 $sql .=
" c.rowid as userid, c.entity, c.login, c.lastname, c.firstname, c.email, c.photo, c.gender, c.statut as status";
247 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
248 $sql .=
" ".MAIN_DB_PREFIX.
"notify_def as n,";
249 $sql .=
" ".MAIN_DB_PREFIX.
"user c";
250 $sql .=
" WHERE a.rowid = n.fk_action";
251 $sql .=
" AND c.rowid = n.fk_user";
252 $sql .=
" AND c.rowid = ".((int)
$object->id);
253 $sql .=
" AND n.entity IN (".getEntity(
'notify_def').
')';
255 $resql =
$db->query($sql);
258 $num =
$db->num_rows($resql);
264 $newcardbutton .= dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', (
int) $permissiontoadd);
266 $titlelist = $form->textwithpicto($langs->trans(
"ListOfActiveNotifications"), $langs->trans(
"ListOfActiveNotificationsHelp", $langs->transnoentitiesnoconv(
"Target"), $langs->transnoentitiesnoconv(
"Event")));
268 $limitforsubscription = 0;
271 print_barre_liste($titlelist, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $num,
'email', 0, $newcardbutton,
'', $limitforsubscription, 0, 0, 1);
274 print
'<div class="div-table-responsive-no-min">';
275 print
'<table class="noborder centpercent">';
276 print
'<tr class="liste_titre">';
277 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
284 if ($action ==
'create') {
291 $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
293 foreach ($listofnotifiedevents as $notifiedevent) {
294 $label = ($langs->trans(
"Notify_".$notifiedevent[
'code']) !=
"Notify_".$notifiedevent[
'code'] ? $langs->trans(
"Notify_".$notifiedevent[
'code']) : $notifiedevent[
'label']);
295 $actions[$notifiedevent[
'rowid']] = $label;
297 print
'<tr class="oddeven nohover"><td>';
300 print
' <'.$object->email.
'>';
302 $langs->load(
"errors");
303 print
' '.img_warning().
' '.$langs->trans(
"ErrorBadEMail",
$object->email);
306 print
'<td class="tdoverflowmax200">';
307 print
img_picto(
'',
'object_action',
'', 0, 0, 0,
'',
'paddingright').$form->selectarray(
"actionid", $actions,
'', 1);
310 print $form->selectarray(
"typeid", $type);
312 print
'<td class="nowraponall">';
313 print
'<input type="submit" class="button button-add small" value="'.$langs->trans(
"Add").
'">';
315 print
'<input type="submit" class="button button-cancel small" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
319 print
'<tr class="oddeven"><td colspan="4" class="opacitymedium">';
320 print $langs->trans(
"YouMustAssignUserMailFirst");
330 $obj =
$db->fetch_object($resql);
332 $userstatic->id = $obj->userid;
333 $userstatic->lastname = $obj->lastname;
334 $userstatic->firstname = $obj->firstname;
335 $userstatic->email = $obj->email;
336 $userstatic->status = $obj->status;
337 $userstatic->photo = $obj->photo;
338 $userstatic->gender = $obj->gender;
340 print
'<tr class="oddeven">';
341 print
'<td>'.$userstatic->getNomUrl(-1);
342 if ($obj->type ==
'email') {
344 print
' <'.$obj->email.
'>';
346 $langs->load(
"errors");
347 print
' '.img_warning().
' <span class="warning">'.$langs->trans(
"ErrorBadEMail", $obj->email).
'</span>';
352 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
353 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($label).
'">';
354 print
img_picto(
'',
'object_action',
'', 0, 0, 0,
'',
'pictofixedwidth').$label;
358 print $type[$obj->type];
360 print
'<td class="right"><a href="card.php?id='.$id.
'&action=delete&token='.newToken().
'&actid='.$obj->rowid.
'">'.
img_delete().
'</a></td>';
366 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
416 print
'<br><br>'.
"\n";
420 $sql =
"SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
421 $sql .=
" c.rowid as id, c.lastname, c.firstname, c.email as contactemail, c.photo, c.gender, c.statut as status,";
422 $sql .=
" a.code, a.label";
423 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
424 $sql .=
" ".MAIN_DB_PREFIX.
"notify as n";
425 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as c ON n.fk_user = c.rowid";
426 $sql .=
" WHERE a.rowid = n.fk_action";
427 $sql .=
" AND n.fk_user = ".((int)
$object->id);
428 $sql .=
$db->order($sortfield, $sortorder);
431 $nbtotalofrecords =
'';
433 $result =
$db->query($sql);
434 $nbtotalofrecords =
$db->num_rows($result);
435 if (($page * $limit) > (int) $nbtotalofrecords) {
441 $sql .=
$db->plimit($limit + 1, $offset);
443 $resql =
$db->query($sql);
445 $num =
$db->num_rows($resql);
450 $param =
'&id='.$object->id;
451 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
452 $param .=
'&contextpage='.$contextpage;
454 if ($limit > 0 && $limit !=
$conf->liste_limit) {
455 $param .=
'&limit='.$limit;
458 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
462 print
'<input type="hidden" name="token" value="'.newToken().
'">';
463 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
464 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
465 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
466 print
'<input type="hidden" name="page" value="'.$page.
'">';
467 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
469 $titlelist = $form->textwithpicto($langs->trans(
"ListOfNotificationsDone"), $langs->trans(
"ListOfNotificationsDoneHelp"));
472 print_barre_liste($titlelist, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'email', 0,
'',
'', $limit,
'');
475 print
'<div class="div-table-responsive-no-min">';
476 print
'<table class="centpercent noborder">';
477 print
'<tr class="liste_titre">';
478 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
482 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"n.daten",
'', $param,
'', $sortfield, $sortorder,
'right ');
491 $obj =
$db->fetch_object($resql);
493 print
'<tr class="oddeven"><td>';
495 $userstatic->id = $obj->id;
496 $userstatic->lastname = $obj->lastname;
497 $userstatic->firstname = $obj->firstname;
498 $userstatic->status = $obj->status;
499 $userstatic->email = $obj->email;
500 $userstatic->photo = $obj->photo;
501 $userstatic->gender = $obj->gender;
503 print $userstatic->getNomUrl(-1);
504 print $obj->email ?
' <'.$obj->email.
'>' : $langs->trans(
"NoMail");
510 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
511 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($label).
'">';
512 print
img_picto(
'',
'object_action',
'', 0, 0, 0,
'',
'pictofixedwidth').$label;
515 print $type[$obj->type];
526 print
'<td class="right">'.dol_print_date(
$db->jdate($obj->daten),
'dayhour').
'</td>';
532 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
540 recordNotFound(
'', 0);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class of triggers for notification module.
Class to manage Dolibarr users.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $jsonclose='', $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_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.