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')) {
96if ($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';
153llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-user page-notify_card');
157 $langs->load(
"other");
163 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
165 $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">';
166 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
167 $morehtmlref .=
'</a>';
169 $urltovirtualcard =
'/user/virtualcard.php?id='.((int)
$object->id);
170 $morehtmlref .=
dolButtonToOpenUrlInDialogPopup(
'publicvirtualcard', $langs->transnoentitiesnoconv(
"PublicVirtualCardUrl").
' - '.
$object->getFullName($langs),
img_picto($langs->trans(
"PublicVirtualCardUrl"),
'card',
'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard,
'',
'nohover');
172 dol_banner_tab(
$object,
'id', $linkback, $user->hasRight(
'user',
'user',
'lire') || $user->admin,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'', 0,
'');
174 print
'<div class="fichecenter">';
176 print
'<div class="underbanner clearboth"></div>';
177 print
'<table class="border centpercent tableforfield">';
180 print
'<tr><td class="titlefield">'.$langs->trans(
"Login").
'</td>';
182 print
'<td class="error">';
183 print $langs->trans(
"LoginAccountDisableInDolibarr");
188 if (property_exists(
$object,
'admin')) {
189 if (isModEnabled(
'multicompany') && !empty(
$object->admin) && empty(
$object->entity)) {
190 $addadmin .=
img_picto($langs->trans(
"SuperAdministratorDesc"),
"redstar",
'class="paddingleft"');
191 } elseif (!empty(
$object->admin)) {
192 $addadmin .=
img_picto($langs->trans(
"AdministratorDesc"),
"star",
'class="paddingleft"');
209 print
'<span class="opacitymedium hideonsmartphone">';
210 print
'<br>'.$langs->trans(
"NotificationsDesc");
211 print
'<br>'.$langs->trans(
"NotificationsDescUser").
' - '.$langs->trans(
"YouAreHere");
212 if (isModEnabled(
'societe')) {
213 print
'<br>'.$langs->trans(
"NotificationsDescContact");
215 print
'<br>'.$langs->trans(
"NotificationsDescGlobal");
218 print
'<br><br><br>'.
"\n";
223 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.urlencode((
string) ($id)).
'" method="POST">';
224 print
'<input type="hidden" name="token" value="'.newToken().
'">';
225 print
'<input type="hidden" name="page_y" value="">';
226 if ($action ==
'create') {
227 print
'<input type="hidden" name="action" id="action" value="add">';
230 $param =
"&id=".urlencode((
string) ($id));
235 $sql =
"SELECT n.rowid, n.type,";
236 $sql .=
" a.code, a.label,";
237 $sql .=
" c.rowid as userid, c.entity, c.login, c.lastname, c.firstname, c.email, c.photo, c.gender, c.statut as status";
238 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
239 $sql .=
" ".MAIN_DB_PREFIX.
"notify_def as n,";
240 $sql .=
" ".MAIN_DB_PREFIX.
"user c";
241 $sql .=
" WHERE a.rowid = n.fk_action";
242 $sql .=
" AND c.rowid = n.fk_user";
243 $sql .=
" AND c.rowid = ".((int)
$object->id);
244 $sql .=
" AND n.entity IN (".getEntity(
'notify_def').
')';
246 $resql = $db->query($sql);
248 $num = $db->num_rows($resql);
254 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', (
int) $permissiontoadd);
256 $titlelist = $form->textwithpicto($langs->trans(
"ListOfActiveNotifications"), $langs->trans(
"ListOfActiveNotificationsHelp", $langs->transnoentitiesnoconv(
"Target"), $langs->transnoentitiesnoconv(
"Event")));
258 $limitforsubscription = 0;
261 print_barre_liste($titlelist, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $num,
'email', 0, $newcardbutton,
'', $limitforsubscription, 0, 0, 1);
264 print
'<div class="div-table-responsive-no-min">';
265 print
'<table class="noborder centpercent">';
266 print
'<tr class="liste_titre">';
267 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
274 if ($action ==
'create') {
281 $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
283 foreach ($listofnotifiedevents as $notifiedevent) {
284 $label = ($langs->trans(
"Notify_".$notifiedevent[
'code']) !=
"Notify_".$notifiedevent[
'code'] ? $langs->trans(
"Notify_".$notifiedevent[
'code']) : $notifiedevent[
'label']);
285 $actions[$notifiedevent[
'rowid']] = $label;
287 print
'<tr class="oddeven nohover"><td>';
290 print
' <'.$object->email.
'>';
292 $langs->load(
"errors");
293 print
' '.img_warning().
' '.$langs->trans(
"ErrorBadEMail",
$object->email);
296 print
'<td class="tdoverflowmax200">';
297 print
img_picto(
'',
'object_action',
'', 0, 0, 0,
'',
'paddingright').$form->selectarray(
"actionid", $actions,
'', 1);
300 $type = array(
'email' => $langs->trans(
"EMail"));
301 print $form->selectarray(
"typeid", $type);
303 print
'<td class="nowraponall">';
304 print
'<input type="submit" class="button button-add small" value="'.$langs->trans(
"Add").
'">';
306 print
'<input type="submit" class="button button-cancel small" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
310 print
'<tr class="oddeven"><td colspan="4" class="opacitymedium">';
311 print $langs->trans(
"YouMustAssignUserMailFirst");
318 $userstatic =
new User($db);
321 $obj = $db->fetch_object($resql);
323 $userstatic->id = $obj->userid;
324 $userstatic->lastname = $obj->lastname;
325 $userstatic->firstname = $obj->firstname;
326 $userstatic->email = $obj->email;
327 $userstatic->status = $obj->status;
328 $userstatic->photo = $obj->photo;
329 $userstatic->gender = $obj->gender;
331 print
'<tr class="oddeven">';
332 print
'<td>'.$userstatic->getNomUrl(-1);
333 if ($obj->type ==
'email') {
335 print
' <'.$obj->email.
'>';
337 $langs->load(
"errors");
338 print
' '.img_warning().
' <span class="warning">'.$langs->trans(
"ErrorBadEMail", $obj->email).
'</span>';
343 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
344 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($label).
'">';
345 print
img_picto(
'',
'object_action',
'', 0, 0, 0,
'',
'pictofixedwidth').$label;
349 if ($obj->type ==
'email') {
350 print $langs->trans(
"Email");
352 if ($obj->type ==
'sms') {
353 print $langs->trans(
"SMS");
356 print
'<td class="right"><a href="card.php?id='.$id.
'&action=delete&token='.
newToken().
'&actid='.$obj->rowid.
'">'.
img_delete().
'</a></td>';
362 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
412 print
'<br><br>'.
"\n";
416 $sql =
"SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
417 $sql .=
" c.rowid as id, c.lastname, c.firstname, c.email as contactemail, c.photo, c.gender, c.statut as status,";
418 $sql .=
" a.code, a.label";
419 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
420 $sql .=
" ".MAIN_DB_PREFIX.
"notify as n";
421 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as c ON n.fk_user = c.rowid";
422 $sql .=
" WHERE a.rowid = n.fk_action";
423 $sql .=
" AND n.fk_user = ".((int)
$object->id);
424 $sql .= $db->order($sortfield, $sortorder);
427 $nbtotalofrecords =
'';
429 $result = $db->query($sql);
430 $nbtotalofrecords = $db->num_rows($result);
431 if (($page * $limit) > $nbtotalofrecords) {
437 $sql .= $db->plimit($limit + 1, $offset);
439 $resql = $db->query($sql);
441 $num = $db->num_rows($resql);
446 $param =
'&id='.$object->id;
447 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
448 $param .=
'&contextpage='.$contextpage;
450 if ($limit > 0 && $limit != $conf->liste_limit) {
451 $param .=
'&limit='.$limit;
454 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
455 if (isset($optioncss) && $optioncss !=
'') {
456 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
458 print
'<input type="hidden" name="token" value="'.newToken().
'">';
459 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
460 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
461 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
462 print
'<input type="hidden" name="page" value="'.$page.
'">';
463 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
465 $titlelist = $form->textwithpicto($langs->trans(
"ListOfNotificationsDone"), $langs->trans(
"ListOfNotificationsDoneHelp"));
468 print_barre_liste($titlelist, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'email', 0,
'',
'', $limit,
'');
471 print
'<div class="div-table-responsive-no-min">';
472 print
'<table class="centpercent noborder">';
473 print
'<tr class="liste_titre">';
474 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
478 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"n.daten",
'', $param,
'', $sortfield, $sortorder,
'right ');
484 $userstatic =
new User($db);
487 $obj = $db->fetch_object($resql);
489 print
'<tr class="oddeven"><td>';
491 $userstatic->id = $obj->id;
492 $userstatic->lastname = $obj->lastname;
493 $userstatic->firstname = $obj->firstname;
494 $userstatic->status = $obj->status;
495 $userstatic->email = $obj->email;
496 $userstatic->photo = $obj->photo;
497 $userstatic->gender = $obj->gender;
499 print $userstatic->getNomUrl(-1);
500 print $obj->email ?
' <'.$obj->email.
'>' : $langs->trans(
"NoMail");
506 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
507 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($label).
'">';
508 print
img_picto(
'',
'object_action',
'', 0, 0, 0,
'',
'pictofixedwidth').$label;
511 if ($obj->type ==
'email') {
512 print $langs->trans(
"Email");
514 if ($obj->type ==
'sms') {
515 print $langs->trans(
"Sms");
527 print
'<td class="right">'.dol_print_date($db->jdate($obj->daten),
'dayhour').
'</td>';
533 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.
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.
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.
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.