29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/triggers/interface_50_modNotification_Notification.class.php';
35$langs->loadLangs(array(
"companies",
"mails",
"admin",
"other",
"errors"));
38$action =
GETPOST(
'action',
'aZ09');
39$contactid =
GETPOST(
'contactid',
'alpha');
41$optioncss =
GETPOST(
'optioncss',
'aZ');
45 $socid = $user->socid;
50$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
51$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
57 $sortfield =
"n.daten";
59if (empty($page) || $page == -1) {
62$offset = $limit * $page;
71$hookmanager->initHooks(array(
'thirdpartynotification',
'globalcard'));
79$parameters = array(
'id' => $socid);
80$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
88 if (
GETPOST(
'cancel',
'alpha')) {
93 if ($action ==
'add') {
94 if (empty($contactid)) {
95 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Contact")),
null,
'errors');
99 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Action")),
null,
'errors');
106 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def";
107 $sql .=
" WHERE fk_soc=".((int) $socid).
" AND fk_contact=".((int) $contactid).
" AND fk_action=".((int) $actionid);
108 if ($db->query($sql)) {
109 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify_def (datec,fk_soc, fk_contact, fk_action)";
110 $sql .=
" VALUES ('".$db->idate($now).
"',".((int) $socid).
",".((int) $contactid).
",".((int) $actionid).
")";
112 if (!$db->query($sql)) {
129 if ($action ==
'delete') {
130 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def where rowid=".
GETPOSTINT(
'actid');
141$form =
new Form($db);
144$result =
$object->fetch($socid);
146$title = $langs->trans(
"ThirdParty").
' - '.$langs->trans(
"Notification");
148 $title =
$object->name.
' - '.$langs->trans(
"Notification");
150$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
156 $langs->load(
"other");
160 print
dol_get_fiche_head($head,
'notify', $langs->trans(
"ThirdParty"), -1,
'company');
162 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
164 dol_banner_tab(
$object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
166 print
'<div class="fichecenter">';
168 print
'<div class="underbanner clearboth"></div>';
169 print
'<table class="border centpercent tableforfield">';
172 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
178 print
'<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.
$object->prefix_comm.
'</td></tr>';
182 print
'<tr><td class="titlefield">';
183 print $langs->trans(
'CustomerCode').
'</td><td colspan="3">';
185 $tmpcheck =
$object->check_codeclient();
186 if ($tmpcheck != 0 && $tmpcheck != -5) {
187 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
192 if ((isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) &&
$object->fournisseur && $user->hasRight(
'fournisseur',
'lire')) {
193 print
'<tr><td class="titlefield">';
194 print $langs->trans(
'SupplierCode').
'</td><td colspan="3">';
196 $tmpcheck =
$object->check_codefournisseur();
197 if ($tmpcheck != 0 && $tmpcheck != -5) {
198 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
224 print
'<div class="opacitymedium hideonsmartphone">';
225 print $langs->trans(
"NotificationsDesc");
226 print
'<br>'.$langs->trans(
"NotificationsDescUser");
227 print
'<br>'.$langs->trans(
"NotificationsDescContact").
' - '.$langs->trans(
"YouAreHere");
228 print
'<br>'.$langs->trans(
"NotificationsDescGlobal");
232 print
'<br><br>'.
"\n";
234 $nbtotalofrecords =
'';
237 $sql =
"SELECT n.rowid, n.type,";
238 $sql .=
" a.code, a.label,";
239 $sql .=
" c.rowid as contactid, c.lastname, c.firstname, c.email";
240 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
241 $sql .=
" ".MAIN_DB_PREFIX.
"notify_def as n,";
242 $sql .=
" ".MAIN_DB_PREFIX.
"socpeople as c";
243 $sql .=
" WHERE a.rowid = n.fk_action";
244 $sql .=
" AND c.rowid = n.fk_contact";
245 $sql .=
" AND c.fk_soc = ".((int)
$object->id);
247 $resql = $db->query($sql);
249 $nbtotalofrecords = $db->num_rows($resql);
256 $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"));
258 $titlelist = $langs->trans(
"ListOfActiveNotifications");
262 $num = $nbtotalofrecords;
263 print_barre_liste($titlelist, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, (empty($nbtotalofrecords) ? -1 : $nbtotalofrecords),
'email', 0, $newcardbutton,
'', $limit, 0, 0, 1);
265 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$socid.
'" method="post">';
266 print
'<input type="hidden" name="token" value="'.newToken().
'">';
267 print
'<input type="hidden" name="action" value="add">';
269 $param =
"&socid=".$socid;
272 print
'<div class="div-table-responsive-no-min">';
273 print
'<table class="centpercent noborder">';
274 print
'<tr class="liste_titre">';
275 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'width="45%"', $sortfield, $sortorder);
276 print_liste_field_titre(
"Action", $_SERVER[
"PHP_SELF"],
"",
'', $param,
'width="35%"', $sortfield, $sortorder);
277 print_liste_field_titre(
"Type", $_SERVER[
"PHP_SELF"],
"n.type",
'', $param,
'width="10%"', $sortfield, $sortorder);
282 if ($action ==
'create') {
283 $listofemails =
$object->thirdparty_and_contact_email_array();
284 if (count($listofemails) > 0) {
289 $listofmanagedeventfornotification = $notificationtrigger->getListOfManagedEvents();
291 foreach ($listofmanagedeventfornotification as $managedeventfornotification) {
292 $label = ($langs->trans(
"Notify_".$managedeventfornotification[
'code']) !=
"Notify_".$managedeventfornotification[
'code'] ? $langs->trans(
"Notify_".$managedeventfornotification[
'code']) : $managedeventfornotification[
'label']);
293 $actions[$managedeventfornotification[
'rowid']] = $label;
296 $newlistofemails = array();
297 foreach ($listofemails as $tmpkey => $tmpval) {
298 $labelhtml = str_replace(array(
'<',
'>'), array(
' - <span class="opacitymedium">',
'</span>'), $tmpval);
299 $newlistofemails[$tmpkey] = array(
'label' =>
dol_string_nohtmltag($tmpval),
'id' => $tmpkey,
'data-html' => $labelhtml);
302 print
'<tr class="oddeven nohover">';
303 print
'<td class="nowraponall">';
304 print
img_picto(
'',
'contact',
'',
false, 0, 0,
'',
'paddingright');
305 print $form->selectarray(
"contactid", $newlistofemails,
'', 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100imp maxwidthonsmartphone');
307 print
'<td class="nowraponall">';
308 print
img_picto(
'',
'object_action',
'',
false, 0, 0,
'',
'paddingright');
309 print $form->selectarray(
"actionid", $actions,
'', 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100imp maxwidthonsmartphone');
312 $type = array(
'email' => $langs->trans(
"EMail"));
313 print $form->selectarray(
"typeid", $type,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth75imp');
315 print
'<td class="right nowraponall">';
316 print
'<input type="submit" class="button button-add small" value="'.$langs->trans(
"Add").
'">';
317 print
'<input type="submit" class="button button-cancel small" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
321 print
'<tr class="oddeven"><td colspan="4" class="opacitymedium">';
322 print $langs->trans(
"YouMustCreateContactFirst");
329 $contactstatic =
new Contact($db);
332 $obj = $db->fetch_object($resql);
334 $contactstatic->id = $obj->contactid;
335 $contactstatic->lastname = $obj->lastname;
336 $contactstatic->firstname = $obj->firstname;
338 print
'<tr class="oddeven">';
339 print
'<td>'.$contactstatic->getNomUrl(1);
340 if ($obj->type ==
'email') {
342 print
' <'.$obj->email.
'>';
344 $langs->load(
"errors");
345 print
' '.img_warning().
' <span class="warning">'.$langs->trans(
"ErrorBadEMail", $obj->email).
'</span>';
350 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
351 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($label).
'">';
352 print
img_picto(
'',
'object_action',
'',
false, 0, 0,
'',
'paddingright').$label;
355 if ($obj->type ==
'email') {
356 print $langs->trans(
"Email");
358 if ($obj->type ==
'sms') {
359 print $langs->trans(
"SMS");
362 print
'<td class="right"><a href="card.php?socid='.$socid.
'&action=delete&token='.
newToken().
'&actid='.$obj->rowid.
'">'.
img_delete().
'</a></td>';
368 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
378 print
'<br><br>'.
"\n";
382 $sql =
"SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
383 $sql .=
" c.rowid as id, c.lastname, c.firstname, c.email as contactemail,";
384 $sql .=
" a.code, a.label";
385 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
386 $sql .=
" ".MAIN_DB_PREFIX.
"notify as n ";
387 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as c ON n.fk_contact = c.rowid";
388 $sql .=
" WHERE a.rowid = n.fk_action";
389 $sql .=
" AND n.fk_soc = ".((int)
$object->id);
390 $sql .= $db->order($sortfield, $sortorder);
393 $nbtotalofrecords =
'';
395 $result = $db->query($sql);
396 $nbtotalofrecords = $db->num_rows($result);
397 if (($page * $limit) > $nbtotalofrecords) {
403 $sql .= $db->plimit($limit + 1, $offset);
405 $resql = $db->query($sql);
407 $num = $db->num_rows($resql);
412 $param =
'&socid='.$object->id;
413 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
414 $param .=
'&contextpage='.$contextpage;
416 if ($limit > 0 && $limit != $conf->liste_limit) {
417 $param .=
'&limit='.$limit;
420 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
421 if ($optioncss !=
'') {
422 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
424 print
'<input type="hidden" name="token" value="'.newToken().
'">';
425 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
426 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
427 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
428 print
'<input type="hidden" name="page" value="'.$page.
'">';
429 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
432 print_barre_liste($langs->trans(
"ListOfNotificationsDone"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, empty($nbtotalofrecords) ? -1 : $nbtotalofrecords,
'email', 0,
'',
'', $limit);
435 print
'<div class="div-table-responsive-no-min">';
436 print
'<table class="centpercent noborder">';
437 print
'<tr class="liste_titre">';
438 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
442 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"n.daten",
'', $param,
'', $sortfield, $sortorder,
'right ');
448 $contactstatic =
new Contact($db);
451 $obj = $db->fetch_object($resql);
453 print
'<tr class="oddeven"><td>';
455 $contactstatic->id = $obj->id;
456 $contactstatic->lastname = $obj->lastname;
457 $contactstatic->firstname = $obj->firstname;
458 print $contactstatic->getNomUrl(1);
459 print $obj->email ?
' <'.$obj->email.
'>' : $langs->trans(
"NoMail");
465 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
469 if ($obj->type ==
'email') {
470 print $langs->trans(
"Email");
472 if ($obj->type ==
'sms') {
473 print $langs->trans(
"Sms");
486 print
'<td class="right">'.dol_print_date($db->jdate($obj->daten),
'dayhour').
'</td>';
492 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()
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.
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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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.