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';
44$langs->loadLangs(array(
"companies",
"mails",
"admin",
"other",
"errors"));
47$action =
GETPOST(
'action',
'aZ09');
48$contactid =
GETPOST(
'contactid',
'alpha');
50$optioncss =
GETPOST(
'optioncss',
'aZ');
54 $socid = $user->socid;
58$hookmanager->initHooks(array(
'thirdpartynotification',
'globalcard'));
63$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
64$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
70 $sortfield =
"n.daten";
72if (empty($page) || $page == -1) {
75$offset = $limit * $page;
84$permissiontoadd = $user->hasRight(
'societe',
'lire');
91if (
GETPOST(
'cancel',
'alpha')) {
95$parameters = array(
'id' => $socid);
96$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
101if (empty($reshook)) {
105 if ($action ==
'add' && $permissiontoadd) {
106 if (empty($contactid)) {
107 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Contact")),
null,
'errors');
110 if ($actionid <= 0) {
111 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Action")),
null,
'errors');
119 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def";
120 $sql .=
" WHERE fk_soc=".((int) $socid).
" AND fk_contact=".((int) $contactid).
" AND fk_action = ".((int) $actionid);
121 if ($db->query($sql)) {
122 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify_def (datec,fk_soc, fk_contact, fk_action)";
123 $sql .=
" VALUES ('".$db->idate($now).
"', ".((int) $socid).
",".((int) $contactid).
",".((int) $actionid).
")";
125 if (!$db->query($sql)) {
143 if ($action ==
'delete' && $permissiontoadd) {
144 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def where rowid = ".
GETPOSTINT(
'actid');
155$form =
new Form($db);
158$result =
$object->fetch($socid);
160$title = $langs->trans(
"ThirdParty").
' - '.$langs->trans(
"Notification");
162 $title =
$object->name.
' - '.$langs->trans(
"Notification");
164$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
170 $langs->load(
"other");
174 print
dol_get_fiche_head($head,
'notify', $langs->trans(
"ThirdParty"), -1,
'company');
176 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
178 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
180 print
'<div class="fichecenter">';
182 print
'<div class="underbanner clearboth"></div>';
183 print
'<table class="border centpercent tableforfield">';
186 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
191 print
'<tr><td class="titlefield">';
192 print $langs->trans(
'CustomerCode').
'</td><td colspan="3">';
194 $tmpcheck =
$object->check_codeclient();
195 if ($tmpcheck != 0 && $tmpcheck != -5) {
196 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
202 print
'<tr><td class="titlefield">';
203 print $langs->trans(
'SupplierCode').
'</td><td colspan="3">';
205 $tmpcheck =
$object->check_codefournisseur();
206 if ($tmpcheck != 0 && $tmpcheck != -5) {
207 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
234 print
'<div class="opacitymedium hideonsmartphone">';
235 print $langs->trans(
"NotificationsDesc");
236 print
'<br>'.$langs->trans(
"NotificationsDescUser");
237 print
'<br>'.$langs->trans(
"NotificationsDescContact").
' - '.$langs->trans(
"YouAreHere");
238 print
'<br>'.$langs->trans(
"NotificationsDescGlobal");
242 print
'<br><br>'.
"\n";
247 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.urlencode((
string) $socid).
'" method="POST">';
248 print
'<input type="hidden" name="token" value="'.newToken().
'">';
249 print
'<input type="hidden" name="page_y" value="">';
250 if ($action ==
'create') {
251 print
'<input type="hidden" name="action" id="action" value="add">';
254 $nbtotalofrecords =
'';
257 $sql =
"SELECT n.rowid, n.type,";
258 $sql .=
" a.code, a.label,";
259 $sql .=
" c.rowid as contactid, c.lastname, c.firstname, c.email";
260 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
261 $sql .=
" ".MAIN_DB_PREFIX.
"notify_def as n,";
262 $sql .=
" ".MAIN_DB_PREFIX.
"socpeople as c";
263 $sql .=
" WHERE a.rowid = n.fk_action";
264 $sql .=
" AND c.rowid = n.fk_contact";
265 $sql .=
" AND c.fk_soc = ".((int)
$object->id);
267 $resql = $db->query($sql);
269 $nbtotalofrecords = $db->num_rows($resql);
274 $param =
"&socid=".$socid;
277 $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"));
279 $titlelist = $form->textwithpicto($langs->trans(
"ListOfActiveNotifications"), $langs->trans(
"ListOfActiveNotificationsHelp", $langs->transnoentitiesnoconv(
"Target"), $langs->transnoentitiesnoconv(
"Event")));
281 $num = $nbtotalofrecords;
283 $limitforsubscription = 0;
286 print_barre_liste($titlelist, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, (empty($nbtotalofrecords) ? -1 : $nbtotalofrecords),
'email', 0, $newcardbutton,
'', $limitforsubscription, 0, 0, 1);
289 print
'<div class="div-table-responsive-no-min">';
290 print
'<table class="noborder centpercent">';
291 print
'<tr class="liste_titre">';
292 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'width="45%"', $sortfield, $sortorder);
294 print_liste_field_titre(
"Type", $_SERVER[
"PHP_SELF"],
"n.type",
'', $param,
'width="10%"', $sortfield, $sortorder);
299 if ($action ==
'create') {
300 $listofemails =
$object->thirdparty_and_contact_email_array();
301 if (count($listofemails) > 0) {
306 $listofmanagedeventfornotification = $notificationtrigger->getListOfManagedEvents();
308 foreach ($listofmanagedeventfornotification as $managedeventfornotification) {
309 $label = ($langs->trans(
"Notify_".$managedeventfornotification[
'code']) !=
"Notify_".$managedeventfornotification[
'code'] ? $langs->trans(
"Notify_".$managedeventfornotification[
'code']) : $managedeventfornotification[
'label']);
310 $actions[$managedeventfornotification[
'rowid']] = $label;
313 $newlistofemails = array();
314 foreach ($listofemails as $tmpkey => $tmpval) {
315 $labelhtml = str_replace(array(
'<',
'>'), array(
' - <span class="opacitymedium">',
'</span>'), $tmpval);
316 $newlistofemails[$tmpkey] = array(
'label' =>
dol_string_nohtmltag($tmpval),
'id' => $tmpkey,
'data-html' => $labelhtml);
319 print
'<tr class="oddeven nohover">';
320 print
'<td class="nowraponall">';
321 print
img_picto(
'',
'contact',
'', 0, 0, 0,
'',
'paddingright');
322 print $form->selectarray(
"contactid", $newlistofemails,
'', 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100imp maxwidthonsmartphone');
324 print
'<td class="tdoverflowmax200">';
325 print
img_picto(
'',
'object_action',
'', 0, 0, 0,
'',
'paddingright');
326 print $form->selectarray(
"actionid", $actions,
'', 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100imp maxwidthonsmartphone');
329 $type = array(
'email' => $langs->trans(
"EMail"));
330 print $form->selectarray(
"typeid", $type,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth75imp');
332 print
'<td class="right nowraponall">';
333 print
'<input type="submit" class="button button-add small" value="'.$langs->trans(
"Add").
'">';
335 print
'<input type="submit" class="button button-cancel small" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
339 print
'<tr class="oddeven"><td colspan="4" class="opacitymedium">';
340 print $langs->trans(
"YouMustCreateContactFirst");
347 $contactstatic =
new Contact($db);
350 $obj = $db->fetch_object($resql);
352 $contactstatic->id = $obj->contactid;
353 $contactstatic->lastname = $obj->lastname;
354 $contactstatic->firstname = $obj->firstname;
356 print
'<tr class="oddeven">';
357 print
'<td>'.$contactstatic->getNomUrl(1);
358 if ($obj->type ==
'email') {
360 print
' <'.$obj->email.
'>';
362 $langs->load(
"errors");
363 print
' '.img_warning().
' <span class="warning">'.$langs->trans(
"ErrorBadEMail", $obj->email).
'</span>';
368 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
369 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($label).
'">';
370 print
img_picto(
'',
'object_action',
'', 0, 0, 0,
'',
'pictofixedwidth').$label;
373 if ($obj->type ==
'email') {
374 print $langs->trans(
"Email");
376 if ($obj->type ==
'sms') {
377 print $langs->trans(
"SMS");
380 print
'<td class="right"><a href="card.php?socid='.$socid.
'&action=delete&token='.
newToken().
'&actid='.$obj->rowid.
'">'.
img_delete().
'</a></td>';
386 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
396 print
'<br><br>'.
"\n";
400 $sql =
"SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
401 $sql .=
" c.rowid as id, c.lastname, c.firstname, c.email as contactemail,";
402 $sql .=
" a.code, a.label";
403 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
404 $sql .=
" ".MAIN_DB_PREFIX.
"notify as n ";
405 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as c ON n.fk_contact = c.rowid";
406 $sql .=
" WHERE a.rowid = n.fk_action";
407 $sql .=
" AND n.fk_soc = ".((int)
$object->id);
408 $sql .= $db->order($sortfield, $sortorder);
411 $nbtotalofrecords =
'';
413 $result = $db->query($sql);
414 $nbtotalofrecords = $db->num_rows($result);
415 if (($page * $limit) > (int) $nbtotalofrecords) {
421 $sql .= $db->plimit($limit + 1, $offset);
423 $resql = $db->query($sql);
425 $num = $db->num_rows($resql);
430 $param =
'&socid='.$object->id;
431 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
432 $param .=
'&contextpage='.$contextpage;
434 if ($limit > 0 && $limit != $conf->liste_limit) {
435 $param .=
'&limit='.$limit;
438 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
439 if ($optioncss !=
'') {
440 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
442 print
'<input type="hidden" name="token" value="'.newToken().
'">';
443 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
444 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
445 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
446 print
'<input type="hidden" name="page" value="'.$page.
'">';
447 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
449 $titlelist = $form->textwithpicto($langs->trans(
"ListOfNotificationsDone"), $langs->trans(
"ListOfNotificationsDoneHelp"));
452 print_barre_liste($titlelist, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, empty($nbtotalofrecords) ? -1 : $nbtotalofrecords,
'email', 0,
'',
'', $limit,
'');
455 print
'<div class="div-table-responsive-no-min">';
456 print
'<table class="centpercent noborder">';
457 print
'<tr class="liste_titre">';
458 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
462 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"n.daten",
'', $param,
'', $sortfield, $sortorder,
'right ');
468 $contactstatic =
new Contact($db);
471 $obj = $db->fetch_object($resql);
473 print
'<tr class="oddeven"><td>';
475 $contactstatic->id = $obj->id;
476 $contactstatic->lastname = $obj->lastname;
477 $contactstatic->firstname = $obj->firstname;
478 print $contactstatic->getNomUrl(1);
479 print $obj->email ?
' <'.$obj->email.
'>' : $langs->trans(
"NoMail");
485 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
489 if ($obj->type ==
'email') {
490 print $langs->trans(
"Email");
492 if ($obj->type ==
'sms') {
493 print $langs->trans(
"Sms");
506 print
'<td class="right">'.dol_print_date($db->jdate($obj->daten),
'dayhour').
'</td>';
512 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
dol_now($mode='gmt')
Return date for now.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $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, $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_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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, $morecssdiv='')
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
isModEnabled($module)
Is Dolibarr module enabled.
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.