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';
46$langs->loadLangs(array(
'companies',
'mails',
'admin',
'other',
'errors'));
51if (!isset($id) || empty($id)) {
55$action =
GETPOST(
'action',
'aZ09');
59$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
60$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
66 $sortfield =
"n.daten";
68if (empty($page) || $page == -1) {
71$offset = $limit * $page;
79if ($id > 0 || !empty($ref)) {
80 $result =
$object->fetch($id, $ref,
'', 1);
84$permissiontoadd = ((
$object->id == $user->id) || ($user->hasRight(
'user',
'user',
'lire')));
97if (
GETPOST(
'cancel',
'alpha')) {
104if ($action ==
'add' && $permissiontoadd) {
105 if ($actionid <= 0) {
106 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Action")),
null,
'errors');
114 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def";
115 $sql .=
" WHERE fk_user = ".((int) $id).
" AND fk_action = ".((int) $actionid);
116 if ($db->query($sql)) {
117 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify_def (datec, fk_user, fk_action)";
118 $sql .=
" VALUES ('".$db->idate($now).
"', ".((int) $id).
", ".((int) $actionid).
")";
120 if (!$db->query($sql)) {
138if ($action ==
'delete' && $permissiontoadd) {
139 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def where rowid = ".
GETPOSTINT(
"actid");
149$form =
new Form($db);
152$result =
$object->fetch($id,
'',
'', 1);
155$title = $langs->trans(
"ThirdParty").
' - '.$langs->trans(
"Notification");
157 $title =
$object->name.
' - '.$langs->trans(
"Notification");
159$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
161llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-user page-notify_card');
165 $langs->load(
"other");
171 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
173 $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">';
174 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
175 $morehtmlref .=
'</a>';
177 $urltovirtualcard =
'/user/virtualcard.php?id='.((int)
$object->id);
178 $morehtmlref .=
dolButtonToOpenUrlInDialogPopup(
'publicvirtualcard', $langs->transnoentitiesnoconv(
"PublicVirtualCardUrl").
' - '.
$object->getFullName($langs),
img_picto($langs->trans(
"PublicVirtualCardUrl"),
'card',
'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard,
'',
'nohover');
180 dol_banner_tab(
$object,
'id', $linkback, $user->hasRight(
'user',
'user',
'lire') || $user->admin,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'', 0,
'');
182 print
'<div class="fichecenter">';
184 print
'<div class="underbanner clearboth"></div>';
185 print
'<table class="border centpercent tableforfield">';
188 print
'<tr><td class="titlefield">'.$langs->trans(
"Login").
'</td>';
190 print
'<td class="error">';
191 print $langs->trans(
"LoginAccountDisableInDolibarr");
196 if (property_exists(
$object,
'admin')) {
197 if (isModEnabled(
'multicompany') && !empty(
$object->admin) && empty(
$object->entity)) {
198 $addadmin .=
img_picto($langs->trans(
"SuperAdministratorDesc"),
"redstar",
'class="paddingleft"');
199 } elseif (!empty(
$object->admin)) {
200 $addadmin .=
img_picto($langs->trans(
"AdministratorDesc"),
"star",
'class="paddingleft"');
217 print
'<span class="opacitymedium hideonsmartphone">';
218 print
'<br>'.$langs->trans(
"NotificationsDesc");
219 print
'<br>'.$langs->trans(
"NotificationsDescUser").
' - '.$langs->trans(
"YouAreHere");
220 if (isModEnabled(
'societe')) {
221 print
'<br>'.$langs->trans(
"NotificationsDescContact");
223 print
'<br>'.$langs->trans(
"NotificationsDescGlobal");
226 print
'<br><br><br>'.
"\n";
231 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.urlencode((
string) ($id)).
'" method="POST">';
232 print
'<input type="hidden" name="token" value="'.newToken().
'">';
233 print
'<input type="hidden" name="page_y" value="">';
234 if ($action ==
'create') {
235 print
'<input type="hidden" name="action" id="action" value="add">';
238 $param =
"&id=".urlencode((
string) ($id));
243 $sql =
"SELECT n.rowid, n.type,";
244 $sql .=
" a.code, a.label,";
245 $sql .=
" c.rowid as userid, c.entity, c.login, c.lastname, c.firstname, c.email, c.photo, c.gender, c.statut as status";
246 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
247 $sql .=
" ".MAIN_DB_PREFIX.
"notify_def as n,";
248 $sql .=
" ".MAIN_DB_PREFIX.
"user c";
249 $sql .=
" WHERE a.rowid = n.fk_action";
250 $sql .=
" AND c.rowid = n.fk_user";
251 $sql .=
" AND c.rowid = ".((int)
$object->id);
252 $sql .=
" AND n.entity IN (".getEntity(
'notify_def').
')';
254 $resql = $db->query($sql);
256 $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']),
'', (
int) $permissiontoadd);
264 $titlelist = $form->textwithpicto($langs->trans(
"ListOfActiveNotifications"), $langs->trans(
"ListOfActiveNotificationsHelp", $langs->transnoentitiesnoconv(
"Target"), $langs->transnoentitiesnoconv(
"Event")));
266 $limitforsubscription = 0;
269 print_barre_liste($titlelist, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $num,
'email', 0, $newcardbutton,
'', $limitforsubscription, 0, 0, 1);
272 print
'<div class="div-table-responsive-no-min">';
273 print
'<table class="noborder centpercent">';
274 print
'<tr class="liste_titre">';
275 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
282 if ($action ==
'create') {
289 $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
291 foreach ($listofnotifiedevents as $notifiedevent) {
292 $label = ($langs->trans(
"Notify_".$notifiedevent[
'code']) !=
"Notify_".$notifiedevent[
'code'] ? $langs->trans(
"Notify_".$notifiedevent[
'code']) : $notifiedevent[
'label']);
293 $actions[$notifiedevent[
'rowid']] = $label;
295 print
'<tr class="oddeven nohover"><td>';
298 print
' <'.$object->email.
'>';
300 $langs->load(
"errors");
301 print
' '.img_warning().
' '.$langs->trans(
"ErrorBadEMail",
$object->email);
304 print
'<td class="tdoverflowmax200">';
305 print
img_picto(
'',
'object_action',
'', 0, 0, 0,
'',
'paddingright').$form->selectarray(
"actionid", $actions,
'', 1);
308 $type = array(
'email' => $langs->trans(
"EMail"));
309 print $form->selectarray(
"typeid", $type);
311 print
'<td class="nowraponall">';
312 print
'<input type="submit" class="button button-add small" value="'.$langs->trans(
"Add").
'">';
314 print
'<input type="submit" class="button button-cancel small" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
318 print
'<tr class="oddeven"><td colspan="4" class="opacitymedium">';
319 print $langs->trans(
"YouMustAssignUserMailFirst");
326 $userstatic =
new User($db);
329 $obj = $db->fetch_object($resql);
331 $userstatic->id = $obj->userid;
332 $userstatic->lastname = $obj->lastname;
333 $userstatic->firstname = $obj->firstname;
334 $userstatic->email = $obj->email;
335 $userstatic->status = $obj->status;
336 $userstatic->photo = $obj->photo;
337 $userstatic->gender = $obj->gender;
339 print
'<tr class="oddeven">';
340 print
'<td>'.$userstatic->getNomUrl(-1);
341 if ($obj->type ==
'email') {
343 print
' <'.$obj->email.
'>';
345 $langs->load(
"errors");
346 print
' '.img_warning().
' <span class="warning">'.$langs->trans(
"ErrorBadEMail", $obj->email).
'</span>';
351 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
352 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($label).
'">';
353 print
img_picto(
'',
'object_action',
'', 0, 0, 0,
'',
'pictofixedwidth').$label;
357 if ($obj->type ==
'email') {
358 print $langs->trans(
"Email");
360 if ($obj->type ==
'sms') {
361 print $langs->trans(
"SMS");
364 print
'<td class="right"><a href="card.php?id='.$id.
'&action=delete&token='.
newToken().
'&actid='.$obj->rowid.
'">'.
img_delete().
'</a></td>';
370 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.photo, c.gender, 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.
'">';
473 $titlelist = $form->textwithpicto($langs->trans(
"ListOfNotificationsDone"), $langs->trans(
"ListOfNotificationsDoneHelp"));
476 print_barre_liste($titlelist, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'email', 0,
'',
'', $limit,
'');
479 print
'<div class="div-table-responsive-no-min">';
480 print
'<table class="centpercent noborder">';
481 print
'<tr class="liste_titre">';
482 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
486 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"n.daten",
'', $param,
'', $sortfield, $sortorder,
'right ');
492 $userstatic =
new User($db);
495 $obj = $db->fetch_object($resql);
497 print
'<tr class="oddeven"><td>';
499 $userstatic->id = $obj->id;
500 $userstatic->lastname = $obj->lastname;
501 $userstatic->firstname = $obj->firstname;
502 $userstatic->status = $obj->status;
503 $userstatic->email = $obj->email;
504 $userstatic->photo = $obj->photo;
505 $userstatic->gender = $obj->gender;
507 print $userstatic->getNomUrl(-1);
508 print $obj->email ?
' <'.$obj->email.
'>' : $langs->trans(
"NoMail");
514 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
515 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($label).
'">';
516 print
img_picto(
'',
'object_action',
'', 0, 0, 0,
'',
'pictofixedwidth').$label;
519 if ($obj->type ==
'email') {
520 print $langs->trans(
"Email");
522 if ($obj->type ==
'sms') {
523 print $langs->trans(
"Sms");
535 print
'<td class="right">'.dol_print_date($db->jdate($obj->daten),
'dayhour').
'</td>';
541 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.