28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/triggers/interface_50_modNotification_Notification.class.php';
34$langs->loadLangs(array(
"companies",
"mails",
"admin",
"other",
"errors"));
36$socid =
GETPOST(
"socid",
'int');
37$action =
GETPOST(
'action',
'aZ09');
38$contactid =
GETPOST(
'contactid',
'alpha');
39$actionid =
GETPOST(
'actionid',
'int');
40$optioncss =
GETPOST(
'optioncss',
'aZ');
44 $socid = $user->socid;
48$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
49$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
51$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
56 $sortfield =
"n.daten";
58if (empty($page) || $page == -1) {
61$offset = $limit * $page;
70$hookmanager->initHooks(array(
'thirdpartynotification',
'globalcard'));
78$parameters = array(
'id'=>$socid);
79$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
88 if ($action ==
'add') {
89 if (empty($contactid)) {
90 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Contact")),
null,
'errors');
94 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Action")),
null,
'errors');
101 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def";
102 $sql .=
" WHERE fk_soc=".((int) $socid).
" AND fk_contact=".((int) $contactid).
" AND fk_action=".((int) $actionid);
103 if ($db->query($sql)) {
104 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify_def (datec,fk_soc, fk_contact, fk_action)";
105 $sql .=
" VALUES ('".$db->idate($now).
"',".((int) $socid).
",".((int) $contactid).
",".((int) $actionid).
")";
107 if (!$db->query($sql)) {
124 if ($action ==
'delete') {
125 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def where rowid=".
GETPOST(
'actid',
'int');
136$form =
new Form($db);
139$result = $object->fetch($socid);
141$title = $langs->trans(
"ThirdParty").
' - '.$langs->trans(
"Notification");
142if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
143 $title = $object->name.
' - '.$langs->trans(
"Notification");
145$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
151 $langs->load(
"other");
155 print
dol_get_fiche_head($head,
'notify', $langs->trans(
"ThirdParty"), -1,
'company');
157 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
159 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
161 print
'<div class="fichecenter">';
163 print
'<div class="underbanner clearboth"></div>';
164 print
'<table class="border centpercent tableforfield">';
167 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
168 print $object->getTypeUrl(1);
172 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
173 print
'<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.$object->prefix_comm.
'</td></tr>';
176 if ($object->client) {
177 print
'<tr><td class="titlefield">';
178 print $langs->trans(
'CustomerCode').
'</td><td colspan="3">';
180 $tmpcheck = $object->check_codeclient();
181 if ($tmpcheck != 0 && $tmpcheck != -5) {
182 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
187 if ((isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) {
188 print
'<tr><td class="titlefield">';
189 print $langs->trans(
'SupplierCode').
'</td><td colspan="3">';
191 $tmpcheck = $object->check_codefournisseur();
192 if ($tmpcheck != 0 && $tmpcheck != -5) {
193 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
219 print
'<div class="opacitymedium hideonsmartphone">';
220 print $langs->trans(
"NotificationsDesc");
221 print
'<br>'.$langs->trans(
"NotificationsDescUser");
222 print
'<br>'.$langs->trans(
"NotificationsDescContact");
223 print
'<br>'.$langs->trans(
"NotificationsDescGlobal");
231 $sql =
"SELECT n.rowid, n.type,";
232 $sql .=
" a.code, a.label,";
233 $sql .=
" c.rowid as contactid, c.lastname, c.firstname, c.email";
234 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
235 $sql .=
" ".MAIN_DB_PREFIX.
"notify_def as n,";
236 $sql .=
" ".MAIN_DB_PREFIX.
"socpeople c";
237 $sql .=
" WHERE a.rowid = n.fk_action";
238 $sql .=
" AND c.rowid = n.fk_contact";
239 $sql .=
" AND c.fk_soc = ".((int) $object->id);
241 $resql = $db->query($sql);
243 $num = $db->num_rows($resql);
250 print
load_fiche_titre($langs->trans(
"ListOfActiveNotifications").
' <span class="opacitymedium colorblack paddingleft">('.$num.
')</span>',
'',
'');
252 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$socid.
'" method="post">';
253 print
'<input type="hidden" name="token" value="'.newToken().
'">';
254 print
'<input type="hidden" name="action" value="add">';
256 $param =
"&socid=".$socid;
259 print
'<div class="div-table-responsive-no-min">';
260 print
'<table class="centpercent noborder">';
261 print
'<tr class="liste_titre">';
262 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'width="45%"', $sortfield, $sortorder);
263 print_liste_field_titre(
"Action", $_SERVER[
"PHP_SELF"],
"",
'', $param,
'width="35%"', $sortfield, $sortorder);
264 print_liste_field_titre(
"Type", $_SERVER[
"PHP_SELF"],
"n.type",
'', $param,
'width="10%"', $sortfield, $sortorder);
269 $listofemails = $object->thirdparty_and_contact_email_array();
270 if (count($listofemails) > 0) {
275 $listofmanagedeventfornotification = $notificationtrigger->getListOfManagedEvents();
277 foreach ($listofmanagedeventfornotification as $managedeventfornotification) {
278 $label = ($langs->trans(
"Notify_".$managedeventfornotification[
'code']) !=
"Notify_".$managedeventfornotification[
'code'] ? $langs->trans(
"Notify_".$managedeventfornotification[
'code']) : $managedeventfornotification[
'label']);
279 $actions[$managedeventfornotification[
'rowid']] = $label;
281 print
'<tr class="oddeven nohover">';
282 print
'<td class="nowraponall">';
283 print
img_picto(
'',
'contact',
'',
false, 0, 0,
'',
'paddingright').$form->selectarray(
"contactid", $listofemails,
'', 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100imp maxwidthonsmartphone');
285 print
'<td class="nowraponall">';
286 print
img_picto(
'',
'object_action',
'',
false, 0, 0,
'',
'paddingright').$form->selectarray(
"actionid", $actions,
'', 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100imp maxwidthonsmartphone');
289 $type = array(
'email'=>$langs->trans(
"EMail"));
290 print $form->selectarray(
"typeid", $type,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth75imp');
292 print
'<td class="right"><input type="submit" class="button button-add" value="'.$langs->trans(
"Add").
'"></td>';
295 print
'<tr class="oddeven"><td colspan="4" class="opacitymedium">';
296 print $langs->trans(
"YouMustCreateContactFirst");
304 $contactstatic =
new Contact($db);
307 $obj = $db->fetch_object($resql);
309 $contactstatic->id = $obj->contactid;
310 $contactstatic->lastname = $obj->lastname;
311 $contactstatic->firstname = $obj->firstname;
313 print
'<tr class="oddeven">';
314 print
'<td>'.$contactstatic->getNomUrl(1);
315 if ($obj->type ==
'email') {
317 print
' <'.$obj->email.
'>';
319 $langs->load(
"errors");
320 print
' '.img_warning().
' <span class="warning">'.$langs->trans(
"ErrorBadEMail", $obj->email).
'</span>';
324 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($label).
'">';
325 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
326 print
img_picto(
'',
'object_action',
'',
false, 0, 0,
'',
'paddingright').$label;
329 if ($obj->type ==
'email') {
330 print $langs->trans(
"Email");
332 if ($obj->type ==
'sms') {
333 print $langs->trans(
"SMS");
336 print
'<td class="right"><a href="card.php?socid='.$socid.
'&action=delete&token='.newToken().
'&actid='.$obj->rowid.
'">'.
img_delete().
'</a></td>';
397 print
'<br><br>'.
"\n";
401 $sql =
"SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
402 $sql .=
" c.rowid as id, c.lastname, c.firstname, c.email as contactemail,";
403 $sql .=
" a.code, a.label";
404 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
405 $sql .=
" ".MAIN_DB_PREFIX.
"notify as n ";
406 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as c ON n.fk_contact = c.rowid";
407 $sql .=
" WHERE a.rowid = n.fk_action";
408 $sql .=
" AND n.fk_soc = ".((int) $object->id);
409 $sql .= $db->order($sortfield, $sortorder);
412 $nbtotalofrecords =
'';
414 $result = $db->query($sql);
415 $nbtotalofrecords = $db->num_rows($result);
416 if (($page * $limit) > $nbtotalofrecords) {
422 $sql .= $db->plimit($limit + 1, $offset);
424 $resql = $db->query($sql);
426 $num = $db->num_rows($resql);
431 $param =
'&socid='.$object->id;
432 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
433 $param .=
'&contextpage='.$contextpage;
435 if ($limit > 0 && $limit != $conf->liste_limit) {
436 $param .=
'&limit='.$limit;
439 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
440 if ($optioncss !=
'') {
441 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
443 print
'<input type="hidden" name="token" value="'.newToken().
'">';
444 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
445 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
446 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
447 print
'<input type="hidden" name="page" value="'.$page.
'">';
448 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
451 print_barre_liste($langs->trans(
"ListOfNotificationsDone"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
454 print
'<div class="div-table-responsive-no-min">';
455 print
'<table class="centpercent noborder">';
456 print
'<tr class="liste_titre">';
457 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
461 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"n.daten",
'', $param,
'', $sortfield, $sortorder,
'right ');
467 $contactstatic =
new Contact($db);
470 $obj = $db->fetch_object($resql);
472 print
'<tr class="oddeven"><td>';
474 $contactstatic->id = $obj->id;
475 $contactstatic->lastname = $obj->lastname;
476 $contactstatic->firstname = $obj->firstname;
477 print $contactstatic->getNomUrl(1);
478 print $obj->email ?
' <'.$obj->email.
'>' : $langs->trans(
"NoMail");
484 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
488 if ($obj->type ==
'email') {
489 print $langs->trans(
"Email");
491 if ($obj->type ==
'sms') {
492 print $langs->trans(
"Sms");
505 print
'<td class="right">'.dol_print_date($db->jdate($obj->daten),
'dayhour').
'</td>';
511 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
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.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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 dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $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.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
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.