27 require
'../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/triggers/interface_50_modNotification_Notification.class.php';
33 $langs->loadLangs(array(
"companies",
"mails",
"admin",
"other"));
35 $socid =
GETPOST(
"socid",
'int');
36 $action =
GETPOST(
'action',
'aZ09');
37 $contactid =
GETPOST(
'contactid');
38 $actionid =
GETPOST(
'actionid');
39 $optioncss =
GETPOST(
'optioncss',
'aZ');
42 if ($user->socid) $socid = $user->socid;
45 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
46 $sortfield =
GETPOST(
"sortfield",
'alpha');
47 $sortorder =
GETPOST(
"sortorder",
'alpha');
49 if (!$sortorder) $sortorder =
"DESC";
50 if (!$sortfield) $sortfield =
"n.daten";
51 if (empty($page) || $page == -1) { $page = 0; }
52 $offset = $limit * $page;
53 $pageprev = $page - 1;
54 $pagenext = $page + 1;
61 $hookmanager->initHooks(array(
'thirdpartynotification',
'globalcard'));
69 $parameters = array(
'id'=>$socid);
70 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
71 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
80 if (empty($contactid))
82 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Contact")), null,
'errors');
87 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Action")), null,
'errors');
95 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def";
96 $sql .=
" WHERE fk_soc=".$socid.
" AND fk_contact=".$contactid.
" AND fk_action=".$actionid;
99 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify_def (datec,fk_soc, fk_contact, fk_action)";
100 $sql .=
" VALUES ('".$db->idate($now).
"',".$socid.
",".$contactid.
",".$actionid.
")";
102 if (!$db->query($sql))
121 if ($action ==
'delete')
123 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def where rowid=".
GETPOST(
'actid',
'int');
134 $form =
new Form($db);
137 $result = $object->fetch($socid);
139 $title = $langs->trans(
"ThirdParty").
' - '.$langs->trans(
"Notification");
140 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.
' - '.$langs->trans(
"Notification");
141 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
147 $langs->load(
"other");
153 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
155 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
157 print '<div class="fichecenter">';
159 print '<div class="underbanner clearboth"></div>';
160 print '<table class="border centpercent tableforfield">';
163 if (!empty($conf->global->SOCIETE_USEPREFIX))
165 print '<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.$object->prefix_comm.
'</td></tr>';
168 if ($object->client) {
169 print '<tr><td class="titlefield">';
170 print $langs->trans(
'CustomerCode').
'</td><td colspan="3">';
171 print $object->code_client;
172 $tmpcheck = $object->check_codeclient();
173 if ($tmpcheck != 0 && $tmpcheck != -5) {
174 print ' <font class="error">('.$langs->trans(
"WrongCustomerCode").
')</font>';
179 if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) {
180 print '<tr><td class="titlefield">';
181 print $langs->trans(
'SupplierCode').
'</td><td colspan="3">';
182 print $object->code_fournisseur;
183 $tmpcheck = $object->check_codefournisseur();
184 if ($tmpcheck != 0 && $tmpcheck != -5) {
185 print ' <font class="error">('.$langs->trans(
"WrongSupplierCode").
')</font>';
211 print '<div class="opacitymedium">';
212 print $langs->trans(
"NotificationsDesc");
213 print '<br>'.$langs->trans(
"NotificationsDescUser");
214 print '<br>'.$langs->trans(
"NotificationsDescContact");
215 print '<br>'.$langs->trans(
"NotificationsDescGlobal");
218 print '<br><br>'.
"\n";
224 print '<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$socid.
'" method="post">';
225 print '<input type="hidden" name="token" value="'.newToken().
'">';
226 print '<input type="hidden" name="action" value="add">';
228 $param =
"&socid=".$socid;
231 print '<table width="100%" class="noborder">';
232 print '<tr class="liste_titre">';
240 $listofemails = $object->thirdparty_and_contact_email_array();
241 if (count($listofemails) > 0)
247 $listofmanagedeventfornotification = $notificationtrigger->getListOfManagedEvents();
249 foreach ($listofmanagedeventfornotification as $managedeventfornotification)
251 $label = ($langs->trans(
"Notify_".$managedeventfornotification[
'code']) !=
"Notify_".$managedeventfornotification[
'code'] ? $langs->trans(
"Notify_".$managedeventfornotification[
'code']) : $managedeventfornotification[
'label']);
252 $actions[$managedeventfornotification[
'rowid']] = $label;
254 print '<tr class="oddeven nohover"><td class="maxwidthonsmartphone">';
255 print img_picto(
'',
'contact',
'',
false, 0, 0,
'',
'paddingright').$form->selectarray(
"contactid", $listofemails,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidthonsmartphone');
257 print '<td class="maxwidthonsmartphone">';
258 print img_picto(
'',
'object_action',
'',
false, 0, 0,
'',
'paddingright').$form->selectarray(
"actionid", $actions,
'', 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidthonsmartphone');
261 $type = array(
'email'=>$langs->trans(
"EMail"));
262 print $form->selectarray(
"typeid", $type);
264 print '<td class="right"><input type="submit" class="button" value="'.$langs->trans(
"Add").
'"></td>';
267 print '<tr class="oddeven"><td colspan="4" class="opacitymedium">';
268 print $langs->trans(
"YouMustCreateContactFirst");
280 $sql =
"SELECT n.rowid, n.type,";
281 $sql .=
" a.code, a.label,";
282 $sql .=
" c.rowid as contactid, c.lastname, c.firstname, c.email";
283 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
284 $sql .=
" ".MAIN_DB_PREFIX.
"notify_def as n,";
285 $sql .=
" ".MAIN_DB_PREFIX.
"socpeople c";
286 $sql .=
" WHERE a.rowid = n.fk_action";
287 $sql .=
" AND c.rowid = n.fk_contact";
288 $sql .=
" AND c.fk_soc = ".$object->id;
290 $resql = $db->query($sql);
293 $num = $db->num_rows(
$resql);
299 print load_fiche_titre($langs->trans(
"ListOfActiveNotifications").
' <span class="opacitymedium colorblack paddingleft">('.$num.
')</span>',
'',
'');
302 print '<table width="100%" class="noborder">';
303 print
'<tr class="liste_titre">';
310 $langs->load(
"errors");
311 $langs->load(
"other");
317 $contactstatic =
new Contact($db);
321 $obj = $db->fetch_object(
$resql);
323 $contactstatic->id = $obj->contact_id;
324 $contactstatic->lastname = $obj->lastname;
325 $contactstatic->firstname = $obj->firstname;
326 print
'<tr class="oddeven"><td>'.$contactstatic->getNomUrl(1);
327 if ($obj->type ==
'email')
331 print
' <'.$obj->email.
'>';
333 $langs->load(
"errors");
334 print
' '.img_warning().
' '.$langs->trans(
"ErrorBadEMail", $obj->email);
339 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
340 print
img_picto(
'',
'object_action',
'',
false, 0, 0,
'',
'paddingright').$label;
343 if ($obj->type ==
'email') print $langs->trans(
"Email");
344 if ($obj->type ==
'sms') print $langs->trans(
"SMS");
346 print
'<td class="right"><a href="card.php?socid='.$socid.
'&action=delete&token='.
newToken().
'&actid='.$obj->rowid.
'">'.
img_delete().
'</a></td>';
407 print
'<br><br>'.
"\n";
411 $sql =
"SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
412 $sql .=
" c.rowid as id, c.lastname, c.firstname, c.email as contactemail,";
413 $sql .=
" a.code, a.label";
414 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
415 $sql .=
" ".MAIN_DB_PREFIX.
"notify as n ";
416 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as c ON n.fk_contact = c.rowid";
417 $sql .=
" WHERE a.rowid = n.fk_action";
418 $sql .=
" AND n.fk_soc = ".$object->id;
419 $sql .= $db->order($sortfield, $sortorder);
422 $nbtotalofrecords =
'';
423 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
425 $result = $db->query($sql);
426 $nbtotalofrecords = $db->num_rows($result);
427 if (($page * $limit) > $nbtotalofrecords)
434 $sql .= $db->plimit($limit + 1, $offset);
436 $resql = $db->query($sql);
439 $num = $db->num_rows(
$resql);
444 $param =
'&socid='.$object->id;
445 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.$contextpage;
446 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.$limit;
448 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
449 if ($optioncss !=
'') print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
450 print
'<input type="hidden" name="token" value="'.newToken().
'">';
451 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
452 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
453 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
454 print
'<input type="hidden" name="page" value="'.$page.
'">';
455 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
458 print_barre_liste($langs->trans(
"ListOfNotificationsDone"), $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
461 print
'<table width="100%" class="noborder">';
462 print
'<tr class="liste_titre">';
463 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"c.lastname,c.firstname",
'', $param,
'', $sortfield, $sortorder);
467 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"n.daten",
'', $param,
'', $sortfield, $sortorder,
'right ');
474 $contactstatic =
new Contact($db);
478 $obj = $db->fetch_object(
$resql);
480 print
'<tr class="oddeven"><td>';
483 $contactstatic->id = $obj->id;
484 $contactstatic->lastname = $obj->lastname;
485 $contactstatic->firstname = $obj->firstname;
486 print $contactstatic->getNomUrl(1);
487 print $obj->email ?
' <'.$obj->email.
'>' : $langs->trans(
"NoMail");
493 $label = ($langs->trans(
"Notify_".$obj->code) !=
"Notify_".$obj->code ? $langs->trans(
"Notify_".$obj->code) : $obj->label);
497 if ($obj->type ==
'email') print $langs->trans(
"Email");
498 if ($obj->type ==
'sms') print $langs->trans(
"Sms");
510 print
'<td class="right">'.dol_print_date($db->jdate($obj->daten),
'dayhour').
'</td>';
516 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class of triggers for notification module.
dol_now($mode= 'auto')
Return date for now.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
isValidEmail($address, $acceptsupervisorkey=0)
Return true if email syntax is ok.