30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/triggers/interface_50_modNotification_Notification.class.php';
36$langs->loadLangs(array(
"companies",
"mails",
"admin",
"other",
"errors"));
39$action =
GETPOST(
'action',
'aZ09');
40$contactid =
GETPOST(
'contactid',
'alpha');
42$optioncss =
GETPOST(
'optioncss',
'aZ');
46 $socid = $user->socid;
50$hookmanager->initHooks(array(
'thirdpartynotification',
'globalcard'));
55$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
56$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
62 $sortfield =
"n.daten";
64if (empty($page) || $page == -1) {
67$offset = $limit * $page;
76$permissiontoadd = $user->hasRight(
'societe',
'lire');
83if (
GETPOST(
'cancel',
'alpha')) {
87$parameters = array(
'id' => $socid);
88$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
97 if ($action ==
'add' && $permissiontoadd) {
98 if (empty($contactid)) {
99 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Contact")),
null,
'errors');
102 if ($actionid <= 0) {
103 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Action")),
null,
'errors');
111 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def";
112 $sql .=
" WHERE fk_soc=".((int) $socid).
" AND fk_contact=".((int) $contactid).
" AND fk_action = ".((int) $actionid);
113 if ($db->query($sql)) {
114 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify_def (datec,fk_soc, fk_contact, fk_action)";
115 $sql .=
" VALUES ('".$db->idate($now).
"', ".((int) $socid).
",".((int) $contactid).
",".((int) $actionid).
")";
117 if (!$db->query($sql)) {
135 if ($action ==
'delete' && $permissiontoadd) {
136 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def where rowid = ".
GETPOSTINT(
'actid');
147$form =
new Form($db);
150$result =
$object->fetch($socid);
152$title = $langs->trans(
"ThirdParty").
' - '.$langs->trans(
"Notification");
154 $title =
$object->name.
' - '.$langs->trans(
"Notification");
156$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
162 $langs->load(
"other");
166 print
dol_get_fiche_head($head,
'notify', $langs->trans(
"ThirdParty"), -1,
'company');
168 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
170 dol_banner_tab(
$object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
172 print
'<div class="fichecenter">';
174 print
'<div class="underbanner clearboth"></div>';
175 print
'<table class="border centpercent tableforfield">';
178 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
184 print
'<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.
$object->prefix_comm.
'</td></tr>';
188 print
'<tr><td class="titlefield">';
189 print $langs->trans(
'CustomerCode').
'</td><td colspan="3">';
191 $tmpcheck =
$object->check_codeclient();
192 if ($tmpcheck != 0 && $tmpcheck != -5) {
193 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
198 if ((isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) &&
$object->fournisseur && $user->hasRight(
'fournisseur',
'lire')) {
199 print
'<tr><td class="titlefield">';
200 print $langs->trans(
'SupplierCode').
'</td><td colspan="3">';
202 $tmpcheck =
$object->check_codefournisseur();
203 if ($tmpcheck != 0 && $tmpcheck != -5) {
204 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
231 print
'<div class="opacitymedium hideonsmartphone">';
232 print $langs->trans(
"NotificationsDesc");
233 print
'<br>'.$langs->trans(
"NotificationsDescUser");
234 print
'<br>'.$langs->trans(
"NotificationsDescContact").
' - '.$langs->trans(
"YouAreHere");
235 print
'<br>'.$langs->trans(
"NotificationsDescGlobal");
239 print
'<br><br>'.
"\n";
244 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.urlencode((
string) ($id)).
'" method="POST">';
245 print
'<input type="hidden" name="token" value="'.newToken().
'">';
246 print
'<input type="hidden" name="page_y" value="">';
247 if ($action ==
'create') {
248 print
'<input type="hidden" name="action" id="action" value="add">';
251 $nbtotalofrecords =
'';
254 $sql =
"SELECT n.rowid, n.type,";
255 $sql .=
" a.code, a.label,";
256 $sql .=
" c.rowid as contactid, c.lastname, c.firstname, c.email";
257 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
258 $sql .=
" ".MAIN_DB_PREFIX.
"notify_def as n,";
259 $sql .=
" ".MAIN_DB_PREFIX.
"socpeople as c";
260 $sql .=
" WHERE a.rowid = n.fk_action";
261 $sql .=
" AND c.rowid = n.fk_contact";
262 $sql .=
" AND c.fk_soc = ".((int)
$object->id);
264 $resql = $db->query($sql);
266 $nbtotalofrecords = $db->num_rows($resql);
274 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $user->hasRight(
"societe",
"creer"));
276 $titlelist = $form->textwithpicto($langs->trans(
"ListOfActiveNotifications"), $langs->trans(
"ListOfActiveNotificationsHelp", $langs->transnoentitiesnoconv(
"Target"), $langs->transnoentitiesnoconv(
"Event")));
278 $num = $nbtotalofrecords;
280 $limitforsubscription = 0;
283 print_barre_liste($titlelist, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, (empty($nbtotalofrecords) ? -1 : $nbtotalofrecords),
'email', 0, $newcardbutton,
'', $limitforsubscription, 0, 0, 1);
285 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$socid.
'" method="post">';
286 print
'<input type="hidden" name="token" value="'.newToken().
'">';
287 print
'<input type="hidden" name="action" value="add">';
289 $param =
"&socid=".$socid;
292 print
'<div class="div-table-responsive-no-min">';
293 print
'<table class="noborder centpercent">';
294 print
'<tr class="liste_titre">';
295 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'width="45%"', $sortfield, $sortorder);
297 print_liste_field_titre(
"Type", $_SERVER[
"PHP_SELF"],
"n.type",
'', $param,
'width="10%"', $sortfield, $sortorder);
302 if ($action ==
'create') {
303 $listofemails =
$object->thirdparty_and_contact_email_array();
304 if (count($listofemails) > 0) {
309 $listofmanagedeventfornotification = $notificationtrigger->getListOfManagedEvents();
311 foreach ($listofmanagedeventfornotification as $managedeventfornotification) {
312 $label = ($langs->trans(
"Notify_".$managedeventfornotification[
'code']) !=
"Notify_".$managedeventfornotification[
'code'] ? $langs->trans(
"Notify_".$managedeventfornotification[
'code']) : $managedeventfornotification[
'label']);
313 $actions[$managedeventfornotification[
'rowid']] = $label;
316 $newlistofemails = array();
317 foreach ($listofemails as $tmpkey => $tmpval) {
318 $labelhtml = str_replace(array(
'<',
'>'), array(
' - <span class="opacitymedium">',
'</span>'), $tmpval);
319 $newlistofemails[$tmpkey] = array(
'label' =>
dol_string_nohtmltag($tmpval),
'id' => $tmpkey,
'data-html' => $labelhtml);
322 print
'<tr class="oddeven nohover">';
323 print
'<td class="nowraponall">';
324 print
img_picto(
'',
'contact',
'', 0, 0, 0,
'',
'paddingright');
325 print $form->selectarray(
"contactid", $newlistofemails,
'', 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100imp maxwidthonsmartphone');
327 print
'<td class="tdoverflowmax200">';
328 print
img_picto(
'',
'object_action',
'', 0, 0, 0,
'',
'paddingright');
329 print $form->selectarray(
"actionid", $actions,
'', 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100imp maxwidthonsmartphone');
332 $type = array(
'email' => $langs->trans(
"EMail"));
333 print $form->selectarray(
"typeid", $type,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth75imp');
335 print
'<td class="right nowraponall">';
336 print
'<input type="submit" class="button button-add small" value="'.$langs->trans(
"Add").
'">';
338 print
'<input type="submit" class="button button-cancel small" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
342 print
'<tr class="oddeven"><td colspan="4" class="opacitymedium">';
343 print $langs->trans(
"YouMustCreateContactFirst");
350 $contactstatic =
new Contact($db);
353 $obj = $db->fetch_object($resql);
355 $contactstatic->id = $obj->contactid;
356 $contactstatic->lastname = $obj->lastname;
357 $contactstatic->firstname = $obj->firstname;
359 print
'<tr class="oddeven">';
360 print
'<td>'.$contactstatic->getNomUrl(1);
361 if ($obj->type ==
'email') {
363 print
' <'.$obj->email.
'>';
365 $langs->load(
"errors");
366 print
' '.img_warning().
' <span class="warning">'.$langs->trans(
"ErrorBadEMail", $obj->email).
'</span>';
371 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
372 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($label).
'">';
373 print
img_picto(
'',
'object_action',
'', 0, 0, 0,
'',
'pictofixedwidth').$label;
376 if ($obj->type ==
'email') {
377 print $langs->trans(
"Email");
379 if ($obj->type ==
'sms') {
380 print $langs->trans(
"SMS");
383 print
'<td class="right"><a href="card.php?socid='.$socid.
'&action=delete&token='.
newToken().
'&actid='.$obj->rowid.
'">'.
img_delete().
'</a></td>';
389 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
399 print
'<br><br>'.
"\n";
403 $sql =
"SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
404 $sql .=
" c.rowid as id, c.lastname, c.firstname, c.email as contactemail,";
405 $sql .=
" a.code, a.label";
406 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
407 $sql .=
" ".MAIN_DB_PREFIX.
"notify as n ";
408 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as c ON n.fk_contact = c.rowid";
409 $sql .=
" WHERE a.rowid = n.fk_action";
410 $sql .=
" AND n.fk_soc = ".((int)
$object->id);
411 $sql .= $db->order($sortfield, $sortorder);
414 $nbtotalofrecords =
'';
416 $result = $db->query($sql);
417 $nbtotalofrecords = $db->num_rows($result);
418 if (($page * $limit) > $nbtotalofrecords) {
424 $sql .= $db->plimit($limit + 1, $offset);
426 $resql = $db->query($sql);
428 $num = $db->num_rows($resql);
433 $param =
'&socid='.$object->id;
434 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
435 $param .=
'&contextpage='.$contextpage;
437 if ($limit > 0 && $limit != $conf->liste_limit) {
438 $param .=
'&limit='.$limit;
441 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
442 if ($optioncss !=
'') {
443 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
445 print
'<input type="hidden" name="token" value="'.newToken().
'">';
446 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
447 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
448 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
449 print
'<input type="hidden" name="page" value="'.$page.
'">';
450 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
452 $titlelist = $form->textwithpicto($langs->trans(
"ListOfNotificationsDone"), $langs->trans(
"ListOfNotificationsDoneHelp"));
455 print_barre_liste($titlelist, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, empty($nbtotalofrecords) ? -1 : $nbtotalofrecords,
'email', 0,
'',
'', $limit,
'');
458 print
'<div class="div-table-responsive-no-min">';
459 print
'<table class="centpercent noborder">';
460 print
'<tr class="liste_titre">';
461 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
465 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"n.daten",
'', $param,
'', $sortfield, $sortorder,
'right ');
471 $contactstatic =
new Contact($db);
474 $obj = $db->fetch_object($resql);
476 print
'<tr class="oddeven"><td>';
478 $contactstatic->id = $obj->id;
479 $contactstatic->lastname = $obj->lastname;
480 $contactstatic->firstname = $obj->firstname;
481 print $contactstatic->getNomUrl(1);
482 print $obj->email ?
' <'.$obj->email.
'>' : $langs->trans(
"NoMail");
488 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
492 if ($obj->type ==
'email') {
493 print $langs->trans(
"Email");
495 if ($obj->type ==
'sms') {
496 print $langs->trans(
"Sms");
509 print
'<td class="right">'.dol_print_date($db->jdate($obj->daten),
'dayhour').
'</td>';
515 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 third parties objects (customers, suppliers, prospects...)
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
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.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
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.
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_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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.