31require
'../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/triggers/interface_50_modNotification_Notification.class.php';
38$langs->loadLangs(array(
'companies',
'mails',
'admin',
'other',
'errors'));
43if (!isset($id) || empty($id)) {
47$action =
GETPOST(
'action',
'aZ09');
51$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
52$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
58 $sortfield =
"n.daten";
60if (empty($page) || $page == -1) {
63$offset = $limit * $page;
71if ($id > 0 || !empty($ref)) {
72 $result =
$object->fetch($id, $ref,
'', 1);
76$permissiontoadd = ((
$object->id == $user->id) || ($user->hasRight(
'user',
'user',
'lire')));
89if (
GETPOST(
'cancel',
'alpha')) {
94if ($action ==
'add' && $permissiontoadd) {
98 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Action")),
null,
'errors');
106 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def";
107 $sql .=
" WHERE fk_user = ".((int) $id).
" AND fk_action = ".((int) $actionid);
108 if ($db->query($sql)) {
109 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify_def (datec, fk_user, fk_action)";
110 $sql .=
" VALUES ('".$db->idate($now).
"', ".((int) $id).
", ".((int) $actionid).
")";
112 if (!$db->query($sql)) {
130if ($action ==
'delete' && $permissiontoadd) {
131 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def where rowid = ".
GETPOSTINT(
"actid");
141$form =
new Form($db);
144$result =
$object->fetch($id,
'',
'', 1);
147$title = $langs->trans(
"ThirdParty").
' - '.$langs->trans(
"Notification");
149 $title =
$object->name.
' - '.$langs->trans(
"Notification");
151$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
152llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-user page-notify_card');
156 $langs->load(
"other");
162 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
164 $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">';
165 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
166 $morehtmlref .=
'</a>';
168 $urltovirtualcard =
'/user/virtualcard.php?id='.((int)
$object->id);
169 $morehtmlref .=
dolButtonToOpenUrlInDialogPopup(
'publicvirtualcard', $langs->transnoentitiesnoconv(
"PublicVirtualCardUrl").
' - '.
$object->getFullName($langs),
img_picto($langs->trans(
"PublicVirtualCardUrl"),
'card',
'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard,
'',
'nohover');
171 dol_banner_tab(
$object,
'id', $linkback, $user->hasRight(
'user',
'user',
'lire') || $user->admin,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'', 0,
'');
173 print
'<div class="fichecenter">';
175 print
'<div class="underbanner clearboth"></div>';
176 print
'<table class="border centpercent tableforfield">';
179 print
'<tr><td class="titlefield">'.$langs->trans(
"Login").
'</td>';
181 print
'<td class="error">';
182 print $langs->trans(
"LoginAccountDisableInDolibarr");
187 if (property_exists(
$object,
'admin')) {
188 if (isModEnabled(
'multicompany') && !empty(
$object->admin) && empty(
$object->entity)) {
189 $addadmin .=
img_picto($langs->trans(
"SuperAdministratorDesc"),
"redstar",
'class="paddingleft"');
190 } elseif (!empty(
$object->admin)) {
191 $addadmin .=
img_picto($langs->trans(
"AdministratorDesc"),
"star",
'class="paddingleft"');
220 print
'<span class="opacitymedium">';
221 print
'<br>'.$langs->trans(
"NotificationsDesc");
222 print
'<br>'.$langs->trans(
"NotificationsDescUser").
' - '.$langs->trans(
"YouAreHere");
223 if (isModEnabled(
'societe')) {
224 print
'<br>'.$langs->trans(
"NotificationsDescContact");
226 print
'<br>'.$langs->trans(
"NotificationsDescGlobal");
229 print
'<br><br><br>'.
"\n";
235 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.urlencode((
string) ($id)).
'" method="POST">';
236 print
'<input type="hidden" name="token" value="'.newToken().
'">';
237 print
'<input type="hidden" name="action" value="add">';
239 $param =
"&id=".urlencode((
string) ($id));
255 $sql =
"SELECT n.rowid, n.type,";
256 $sql .=
" a.code, a.label,";
257 $sql .=
" c.rowid as userid, c.entity, c.login, c.lastname, c.firstname, c.email, c.statut as status";
258 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
259 $sql .=
" ".MAIN_DB_PREFIX.
"notify_def as n,";
260 $sql .=
" ".MAIN_DB_PREFIX.
"user c";
261 $sql .=
" WHERE a.rowid = n.fk_action";
262 $sql .=
" AND c.rowid = n.fk_user";
263 $sql .=
" AND c.rowid = ".((int)
$object->id);
264 $sql .=
" AND c.entity IN (".getEntity(
'user').
')';
266 $resql = $db->query($sql);
268 $num = $db->num_rows($resql);
274 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', (
int) $permissiontoadd);
276 $titlelist = $langs->trans(
"ListOfActiveNotifications");
280 print_barre_liste($titlelist, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $num,
'email', 0, $newcardbutton,
'', $limit, 0, 0, 1);
283 print
'<table width="100%" class="noborder">';
284 print
'<tr class="liste_titre">';
285 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'width="45%"', $sortfield, $sortorder);
286 print_liste_field_titre(
"Action", $_SERVER[
"PHP_SELF"],
"",
'', $param,
'width="35%"', $sortfield, $sortorder);
287 print_liste_field_titre(
"Type", $_SERVER[
"PHP_SELF"],
"n.type",
'', $param,
'width="10%"', $sortfield, $sortorder);
292 if ($action ==
'create') {
299 $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
301 foreach ($listofnotifiedevents as $notifiedevent) {
302 $label = ($langs->trans(
"Notify_".$notifiedevent[
'code']) !=
"Notify_".$notifiedevent[
'code'] ? $langs->trans(
"Notify_".$notifiedevent[
'code']) : $notifiedevent[
'label']);
303 $actions[$notifiedevent[
'rowid']] = $label;
305 print
'<tr class="oddeven nohover"><td>';
308 print
' <'.$object->email.
'>';
310 $langs->load(
"errors");
311 print
' '.img_warning().
' '.$langs->trans(
"ErrorBadEMail",
$object->email);
315 print
img_picto(
'',
'object_action',
'', 0, 0, 0,
'',
'paddingright').$form->selectarray(
"actionid", $actions,
'', 1);
318 $type = array(
'email' => $langs->trans(
"EMail"));
319 print $form->selectarray(
"typeid", $type);
321 print
'<td class="nowraponall">';
322 print
'<input type="submit" class="button button-add" value="'.$langs->trans(
"Add").
'">';
324 print
'<input type="submit" class="button" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
328 print
'<tr class="oddeven"><td colspan="4">';
329 print $langs->trans(
"YouMustAssignUserMailFirst");
336 $userstatic =
new User($db);
339 $obj = $db->fetch_object($resql);
341 $userstatic->id = $obj->userid;
342 $userstatic->lastname = $obj->lastname;
343 $userstatic->firstname = $obj->firstname;
344 $userstatic->email = $obj->email;
345 $userstatic->status = $obj->status;
347 print
'<tr class="oddeven">';
348 print
'<td>'.$userstatic->getNomUrl(1);
349 if ($obj->type ==
'email') {
351 print
' <'.$obj->email.
'>';
353 $langs->load(
"errors");
354 print
' '.img_warning().
' '.$langs->trans(
"ErrorBadEMail", $obj->email);
359 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
360 print
img_picto(
'',
'object_action',
'', 0, 0, 0,
'',
'paddingright').$label;
363 if ($obj->type ==
'email') {
364 print $langs->trans(
"Email");
366 if ($obj->type ==
'sms') {
367 print $langs->trans(
"SMS");
370 print
'<td class="right"><a href="card.php?id='.$id.
'&action=delete&token='.
newToken().
'&actid='.$obj->rowid.
'">'.
img_delete().
'</a></td>';
376 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
425 print
'<br><br>'.
"\n";
429 $sql =
"SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
430 $sql .=
" c.rowid as id, c.lastname, c.firstname, c.email as contactemail, c.statut as status,";
431 $sql .=
" a.code, a.label";
432 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
433 $sql .=
" ".MAIN_DB_PREFIX.
"notify as n";
434 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as c ON n.fk_user = c.rowid";
435 $sql .=
" WHERE a.rowid = n.fk_action";
436 $sql .=
" AND n.fk_user = ".((int)
$object->id);
437 $sql .= $db->order($sortfield, $sortorder);
440 $nbtotalofrecords =
'';
442 $result = $db->query($sql);
443 $nbtotalofrecords = $db->num_rows($result);
444 if (($page * $limit) > $nbtotalofrecords) {
450 $sql .= $db->plimit($limit + 1, $offset);
452 $resql = $db->query($sql);
454 $num = $db->num_rows($resql);
459 $param =
'&id='.$object->id;
460 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
461 $param .=
'&contextpage='.$contextpage;
463 if ($limit > 0 && $limit != $conf->liste_limit) {
464 $param .=
'&limit='.$limit;
467 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
468 if (isset($optioncss) && $optioncss !=
'') {
469 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
471 print
'<input type="hidden" name="token" value="'.newToken().
'">';
472 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
473 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
474 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
475 print
'<input type="hidden" name="page" value="'.$page.
'">';
476 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
479 print_barre_liste($langs->trans(
"ListOfNotificationsDone"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'email', 0,
'',
'', $limit);
482 print
'<table width="100%" class="noborder">';
483 print
'<tr class="liste_titre">';
484 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
488 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"n.daten",
'', $param,
'', $sortfield, $sortorder,
'right ');
494 $userstatic =
new User($db);
497 $obj = $db->fetch_object($resql);
499 print
'<tr class="oddeven"><td>';
501 $userstatic->id = $obj->id;
502 $userstatic->lastname = $obj->lastname;
503 $userstatic->firstname = $obj->firstname;
504 $userstatic->status = $obj->status;
505 $userstatic->email = $obj->email;
506 print $userstatic->getNomUrl(1);
507 print $obj->email ?
' <'.$obj->email.
'>' : $langs->trans(
"NoMail");
513 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
517 if ($obj->type ==
'email') {
518 print $langs->trans(
"Email");
520 if ($obj->type ==
'sms') {
521 print $langs->trans(
"Sms");
533 print
'<td class="right">'.dol_print_date($db->jdate($obj->daten),
'dayhour').
'</td>';
539 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
Show tabs of a record.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $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, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.
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.