29 require
'../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/triggers/interface_50_modNotification_Notification.class.php';
36 $langs->loadLangs(array(
'companies',
'mails',
'admin',
'other',
'errors'));
41 $action =
GETPOST(
'action',
'aZ09');
42 $actionid =
GETPOST(
'actionid',
'int');
44 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
45 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
46 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
52 $sortfield =
"n.daten";
54 if (empty($page) || $page == -1) {
57 $offset = $limit * $page;
58 $pageprev = $page - 1;
59 $pagenext = $page + 1;
64 $object =
new User($db);
65 if ($id > 0 || !empty($ref)) {
66 $result = $object->fetch($id, $ref,
'', 1);
70 $permissiontoadd = (($object->id == $user->id) || (!empty($user->rights->user->user->lire)));
83 if (
GETPOST(
'cancel',
'alpha')) {
88 if ($action ==
'add') {
92 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Action")),
null,
'errors');
100 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def";
101 $sql .=
" WHERE fk_user=".((int) $id).
" AND fk_action=".((int) $actionid);
102 if ($db->query($sql)) {
103 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify_def (datec, fk_user, fk_action)";
104 $sql .=
" VALUES ('".$db->idate($now).
"', ".((int) $id).
", ".((int) $actionid).
")";
106 if (!$db->query($sql)) {
124 if ($action ==
'delete') {
125 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def where rowid=".
GETPOST(
"actid",
"int");
137 $object =
new User($db);
138 $result = $object->fetch($id,
'',
'', 1);
139 $object->getrights();
141 $title = $langs->trans(
"ThirdParty").
' - '.$langs->trans(
"Notification");
142 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
143 $title = $object->name.
' - '.$langs->trans(
"Notification");
145 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
150 $langs->load(
"other");
156 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
158 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/user/vcard.php?id='.$object->id.
'" class="refid">';
159 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
160 $morehtmlref .=
'</a>';
162 dol_banner_tab($object,
'id', $linkback, $user->rights->user->user->lire || $user->admin,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'', 0,
'');
164 print
'<div class="fichecenter">';
166 print
'<div class="underbanner clearboth"></div>';
167 print
'<table class="border centpercent tableforfield">';
170 print
'<tr><td class="titlefield">'.$langs->trans(
"Login").
'</td>';
171 if (!empty($object->ldap_sid) && $object->statut == 0) {
172 print
'<td class="error">';
173 print $langs->trans(
"LoginAccountDisableInDolibarr");
178 if (property_exists($object,
'admin')) {
179 if (
isModEnabled(
'multicompany') && !empty($object->admin) && empty($object->entity)) {
180 $addadmin .=
img_picto($langs->trans(
"SuperAdministratorDesc"),
"redstar",
'class="paddingleft"');
181 } elseif (!empty($object->admin)) {
182 $addadmin .=
img_picto($langs->trans(
"AdministratorDesc"),
"star",
'class="paddingleft"');
211 print
'<span class="opacitymedium">';
212 print
'<br>'.$langs->trans(
"NotificationsDesc");
213 print
'<br>'.$langs->trans(
"NotificationsDescUser");
214 print
'<br>'.$langs->trans(
"NotificationsDescContact");
215 print
'<br>'.$langs->trans(
"NotificationsDescGlobal");
218 print
'<br><br><br>'.
"\n";
224 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.urlencode($id).
'" method="POST">';
225 print
'<input type="hidden" name="token" value="'.newToken().
'">';
226 print
'<input type="hidden" name="action" value="add">';
228 $param =
"&id=".urlencode($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.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 c.entity IN (".getEntity(
'user').
')';
255 $resql = $db->query($sql);
257 $num = $db->num_rows(
$resql);
262 $newcardbutton =
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
264 $title = $langs->trans(
"ListOfActiveNotifications");
268 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $num,
'email', 0, $newcardbutton,
'', $limit, 0, 0, 1);
271 print
'<table width="100%" class="noborder">';
272 print
'<tr class="liste_titre">';
273 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'width="45%"', $sortfield, $sortorder);
274 print_liste_field_titre(
"Action", $_SERVER[
"PHP_SELF"],
"",
'', $param,
'width="35%"', $sortfield, $sortorder);
275 print_liste_field_titre(
"Type", $_SERVER[
"PHP_SELF"],
"n.type",
'', $param,
'width="10%"', $sortfield, $sortorder);
280 if ($action ==
'create') {
282 if ($object->email) {
287 $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
289 foreach ($listofnotifiedevents as $notifiedevent) {
290 $label = ($langs->trans(
"Notify_".$notifiedevent[
'code']) !=
"Notify_".$notifiedevent[
'code'] ? $langs->trans(
"Notify_".$notifiedevent[
'code']) : $notifiedevent[
'label']);
291 $actions[$notifiedevent[
'rowid']] = $label;
293 print
'<tr class="oddeven nohover"><td>';
294 print $object->getNomUrl(1);
296 print
' <'.$object->email.
'>';
298 $langs->load(
"errors");
299 print
' '.img_warning().
' '.$langs->trans(
"ErrorBadEMail", $object->email);
303 print
img_picto(
'',
'object_action',
'',
false, 0, 0,
'',
'paddingright').$form->selectarray(
"actionid", $actions,
'', 1);
306 $type = array(
'email'=>$langs->trans(
"EMail"));
307 print
$form->selectarray(
"typeid", $type);
309 print
'<td class="nowraponall">';
310 print
'<input type="submit" class="button button-add" value="'.$langs->trans(
"Add").
'">';
312 print
'<input type="submit" class="button" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
316 print
'<tr class="oddeven"><td colspan="4">';
317 print $langs->trans(
"YouMustAssignUserMailFirst");
324 $userstatic =
new user($db);
327 $obj = $db->fetch_object(
$resql);
329 $userstatic->id = $obj->userid;
330 $userstatic->lastname = $obj->lastname;
331 $userstatic->firstname = $obj->firstname;
332 $userstatic->email = $obj->email;
333 $userstatic->statut = $obj->status;
335 print
'<tr class="oddeven"><td>'.$userstatic->getNomUrl(1);
336 if ($obj->type ==
'email') {
338 print
' <'.$obj->email.
'>';
340 $langs->load(
"errors");
341 print
' '.img_warning().
' '.$langs->trans(
"ErrorBadEMail", $obj->email);
346 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
347 print
img_picto(
'',
'object_action',
'',
false, 0, 0,
'',
'paddingright').$label;
350 if ($obj->type ==
'email') {
351 print $langs->trans(
"Email");
353 if ($obj->type ==
'sms') {
354 print $langs->trans(
"SMS");
357 print
'<td class="right"><a href="card.php?id='.$id.
'&action=delete&token='.
newToken().
'&actid='.$obj->rowid.
'">'.
img_delete().
'</a></td>';
411 print
'<br><br>'.
"\n";
415 $sql =
"SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
416 $sql .=
" c.rowid as id, c.lastname, c.firstname, c.email as contactemail, c.statut as status,";
417 $sql .=
" a.code, a.label";
418 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
419 $sql .=
" ".MAIN_DB_PREFIX.
"notify as n";
420 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as c ON n.fk_user = c.rowid";
421 $sql .=
" WHERE a.rowid = n.fk_action";
422 $sql .=
" AND n.fk_user = ".((int) $object->id);
423 $sql .= $db->order($sortfield, $sortorder);
427 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
428 $result = $db->query($sql);
436 $sql .= $db->plimit($limit + 1, $offset);
438 $resql = $db->query($sql);
440 $num = $db->num_rows(
$resql);
445 $param =
'&id='.$object->id;
446 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
447 $param .=
'&contextpage='.$contextpage;
449 if ($limit > 0 && $limit != $conf->liste_limit) {
450 $param .=
'&limit='.$limit;
453 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
454 if (isset($optioncss) && $optioncss !=
'') {
455 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
457 print
'<input type="hidden" name="token" value="'.newToken().
'">';
458 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
459 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
460 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
461 print
'<input type="hidden" name="page" value="'.$page.
'">';
462 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
465 print_barre_liste($langs->trans(
"ListOfNotificationsDone"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num,
$nbtotalofrecords,
'email', 0,
'',
'', $limit);
468 print
'<table width="100%" class="noborder">';
469 print
'<tr class="liste_titre">';
470 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
474 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"n.daten",
'', $param,
'', $sortfield, $sortorder,
'right ');
480 $userstatic =
new User($db);
483 $obj = $db->fetch_object(
$resql);
485 print
'<tr class="oddeven"><td>';
487 $userstatic->id = $obj->id;
488 $userstatic->lastname = $obj->lastname;
489 $userstatic->firstname = $obj->firstname;
490 $userstatic->statut = $obj->status;
491 $userstatic->email = $obj->email;
492 print $userstatic->getNomUrl(1);
493 print $obj->email ?
' <'.$obj->email.
'>' : $langs->trans(
"NoMail");
499 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
503 if ($obj->type ==
'email') {
504 print $langs->trans(
"Email");
506 if ($obj->type ==
'sms') {
507 print $langs->trans(
"Sms");
519 print
'<td class="right">'.dol_print_date($db->jdate($obj->daten),
'dayhour').
'</td>';
525 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
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_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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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 from a POST of a form.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
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.
user_prepare_head(User $object)
Prepare array with list of tabs.