dolibarr  7.0.0-beta
mails_templates.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
5  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
6  * Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
7  * Copyright (C) 2011-2017 Philippe Grand <philippe.grand@atoo-net.com>
8  * Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
9  * Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
10  * Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
11  * Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
12  * Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
13  * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
14  *
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program. If not, see <http://www.gnu.org/licenses/>.
27  */
28 
35 require '../main.inc.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
43 
44 // Load traductions files requiredby by page
45 $langs->loadLangs(array("errors","admin","mails","languages"));
46 
47 $action = GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
48 $confirm = GETPOST('confirm','alpha'); // Result of a confirmation
49 
50 $id = GETPOST('id','int');
51 $rowid = GETPOST('rowid','alpha');
52 $search_label=GETPOST('search_label','alpha');
53 $search_type_template=GETPOST('search_type_template','alpha');
54 $search_lang=GETPOST('search_lang','alpha');
55 $search_fk_user=GETPOST('search_fk_user','intcomma');
56 $search_topic=GETPOST('search_topic','alpha');
57 
58 $allowed=1;
59 if (! $allowed) accessforbidden();
60 
61 $acts[0] = "activate";
62 $acts[1] = "disable";
63 $actl[0] = img_picto($langs->trans("Disabled"),'switch_off');
64 $actl[1] = img_picto($langs->trans("Activated"),'switch_on');
65 
66 $listoffset=GETPOST('listoffset','alpha');
67 $listlimit =GETPOST('listlimit','alpha')>0?GETPOST('listlimit','alpha'):1000;
68 $active = 1;
69 
70 $sortfield = GETPOST("sortfield",'alpha');
71 $sortorder = GETPOST("sortorder",'alpha');
72 $page = GETPOST("page",'int');
73 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
74 $offset = $listlimit * $page ;
75 $pageprev = $page - 1;
76 $pagenext = $page + 1;
77 
78 if (empty($sortfield)) $sortfield='label, lang, position';
79 if (empty($sortorder)) $sortorder='ASC';
80 
81 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
82 $hookmanager->initHooks(array('emailtemplates'));
83 
84 // Name of SQL tables of dictionaries
85 $tabname=array();
86 $tabname[25]= MAIN_DB_PREFIX."c_email_templates";
87 
88 // Criteria to sort dictionaries
89 $tabsqlsort=array();
90 $tabsqlsort[25]="label ASC, lang ASC, position ASC";
91 
92 // Nom des champs en resultat de select pour affichage du dictionnaire
93 $tabfield=array();
94 $tabfield[25]= "label,type_template,lang,fk_user,private,position,topic,joinfiles,content";
95 if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfield[25].=',content_lines';
96 
97 // Nom des champs d'edition pour modification d'un enregistrement
98 $tabfieldvalue=array();
99 $tabfieldvalue[25]= "label,type_template,fk_user,lang,private,position,topic,joinfiles,content";
100 if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldvalue[25].=',content_lines';
101 
102 // Nom des champs dans la table pour insertion d'un enregistrement
103 $tabfieldinsert=array();
104 $tabfieldinsert[25]= "label,type_template,fk_user,lang,private,position,topic,joinfiles,content";
105 if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldinsert[25].=',content_lines';
106 $tabfieldinsert[25].=',entity'; // Must be at end because not into other arrays
107 
108 // Condition to show dictionary in setup page
109 $tabcond=array();
110 $tabcond[25]= true;
111 
112 // List of help for fields
113 // Set MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES to allow edit of template for lines
114 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
115 $formmail=new FormMail($db);
116 if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
117 {
118  $tmp=FormMail::getAvailableSubstitKey('formemail');
119  $tmp['__(AnyTranslationKey)__']='Translation';
120  $helpsubstit = $langs->trans("AvailableVariables").':<br>';
121  $helpsubstitforlines = $langs->trans("AvailableVariables").':<br>';
122  foreach($tmp as $key => $val)
123  {
124  $helpsubstit.=$key.' -> '.$val.'<br>';
125  $helpsubstitforlines.=$key.' -> '.$val.'<br>';
126  }
127 }
128 else
129 {
130  $tmp=FormMail::getAvailableSubstitKey('formemailwithlines');
131  $tmp['__(AnyTranslationKey)__']='Translation';
132  $helpsubstit = $langs->trans("AvailableVariables").':<br>';
133  $helpsubstitforlines = $langs->trans("AvailableVariables").':<br>';
134  foreach($tmp as $key => $val)
135  {
136  $helpsubstit.=$key.' -> '.$val.'<br>';
137  }
138  $tmp=FormMail::getAvailableSubstitKey('formemailforlines');
139  foreach($tmp as $key => $val)
140  {
141  $helpsubstitforlines.=$key.' -> '.$val.'<br>';
142  }
143 }
144 
145 
146 $tabhelp=array();
147 $tabhelp[25] = array('topic'=>$helpsubstit,'joinfiles'=>$langs->trans('AttachMainDocByDefault'), 'content'=>$helpsubstit,'content_lines'=>$helpsubstitforlines,'type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList"));
148 
149 // List of check for fields (NOT USED YET)
150 $tabfieldcheck=array();
151 $tabfieldcheck[25] = array();
152 
153 
154 // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
155 $elementList = array();
156 $sourceList=array();
157 
158 // We save list of template email Dolibarr can manage. This list can found by a grep into code on "->param['models']"
159 $elementList = array();
160 if ($conf->propal->enabled) $elementList['propal_send']=$langs->trans('MailToSendProposal');
161 if ($conf->commande->enabled) $elementList['order_send']=$langs->trans('MailToSendOrder');
162 if ($conf->facture->enabled) $elementList['facture_send']=$langs->trans('MailToSendInvoice');
163 if ($conf->expedition->enabled) $elementList['shipping_send']=$langs->trans('MailToSendShipment');
164 if ($conf->ficheinter->enabled) $elementList['fichinter_send']=$langs->trans('MailToSendIntervention');
165 if ($conf->supplier_proposal->enabled) $elementList['supplier_proposal_send']=$langs->trans('MailToSendSupplierRequestForQuotation');
166 if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$langs->trans('MailToSendSupplierOrder');
167 if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$langs->trans('MailToSendSupplierInvoice');
168 if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty');
169 if ($conf->adherent->enabled) $elementList['member']=$langs->trans('MailToMember');
170 if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract');
171 $elementList['user']=$langs->trans('MailToUser');
172 $elementList['all'] =$langs->trans('VisibleEverywhere');
173 $elementList['none']=$langs->trans('VisibleNowhere');
174 
175 
176 $parameters=array('elementList'=>$elementList);
177 $reshook=$hookmanager->executeHooks('emailElementlist',$parameters); // Note that $action and $object may have been modified by some hooks
178 if ($reshook == 0) {
179  foreach ($hookmanager->resArray as $item => $value) {
180  $elementList[$item] = $value;
181  }
182 }
183 
184 $id = 25;
185 
186 
187 /*
188  * Actions
189  */
190 
191 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
192 if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
193 
194 $parameters=array();
195 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
196 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
197 
198 if (empty($reshook))
199 {
200  // Purge search criteria
201  if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
202  {
203  $search_label='';
204  $search_type_template='';
205  $search_lang='';
206  $search_fk_user='';
207  $search_topic='';
208  $toselect='';
209  $search_array_options=array();
210  }
211 
212  // Actions add or modify an entry into a dictionary
213  if (GETPOST('actionadd') || GETPOST('actionmodify'))
214  {
215  $listfield=explode(',', str_replace(' ', '',$tabfield[$id]));
216  $listfieldinsert=explode(',',$tabfieldinsert[$id]);
217  $listfieldmodify=explode(',',$tabfieldinsert[$id]);
218  $listfieldvalue=explode(',',$tabfieldvalue[$id]);
219 
220  // Check that all fields are filled
221  $ok=1;
222  foreach ($listfield as $f => $value)
223  {
224  // Not mandatory fields
225  if ($value == 'joinfiles') continue;
226  if ($value == 'content') continue;
227  if ($value == 'content_lines') continue;
228 
229  if (GETPOST('actionmodify') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid];
230 
231  if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position')
232  {
233  $ok=0;
234  $fieldnamekey=$listfield[$f];
235  // We take translate key of field
236  if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
237  if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments';
238  if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
239  if ($fieldnamekey == 'note') $fieldnamekey = 'Note';
240  if ($fieldnamekey == 'type_template') $fieldnamekey = 'TypeOfTemplate';
241  if ($fieldnamekey == 'fk_user') $fieldnamekey = 'Owner';
242  if ($fieldnamekey == 'private') $fieldnamekey = 'Private';
243  if ($fieldnamekey == 'position') $fieldnamekey = 'Position';
244  if ($fieldnamekey == 'topic') $fieldnamekey = 'Topic';
245 
246  setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
247  }
248  }
249 
250  // Si verif ok et action add, on ajoute la ligne
251  if ($ok && GETPOST('actionadd'))
252  {
253  // Add new entry
254  $sql = "INSERT INTO ".$tabname[$id]." (";
255  // List of fields
256  $sql.= $tabfieldinsert[$id];
257  $sql.=",active)";
258  $sql.= " VALUES(";
259 
260  // List of values
261  $i=0;
262  foreach ($listfieldinsert as $f => $value)
263  {
264  //var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value);
265  $keycode=$listfieldvalue[$i];
266  if ($value == 'lang') $keycode='langcode';
267  if ($value == 'entity') $_POST[$keycode] = $conf->entity;
268  if ($i) $sql.=",";
269  if ($value == 'fk_user' && ! ($_POST[$keycode] > 0)) $_POST[$keycode]='';
270  if ($value == 'private' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='0';
271  if ($value == 'position' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='1';
272  if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work
273  elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="null";
274  else $sql.="'".$db->escape($_POST[$keycode])."'";
275  $i++;
276  }
277  $sql.=",1)";
278 
279  dol_syslog("actionadd", LOG_DEBUG);
280  $result = $db->query($sql);
281  if ($result) // Add is ok
282  {
283  setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
284  $_POST=array('id'=>$id); // Clean $_POST array, we keep only
285  }
286  else
287  {
288  if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
289  setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
290  }
291  else {
292  dol_print_error($db);
293  }
294  }
295  }
296 
297  // Si verif ok et action modify, on modifie la ligne
298  if ($ok && GETPOST('actionmodify'))
299  {
300  $rowidcol="rowid";
301 
302  // Modify entry
303  $sql = "UPDATE ".$tabname[$id]." SET ";
304  // Modifie valeur des champs
305  $i = 0;
306  foreach ($listfieldmodify as $field)
307  {
308  $keycode=$listfieldvalue[$i];
309  if ($field == 'lang') $keycode='langcode';
310 
311  if ($field == 'fk_user' && ! ($_POST['fk_user'] > 0)) $_POST['fk_user']='';
312  if ($field == 'topic') $_POST['topic']=$_POST['topic-'.$rowid];
313  if ($field == 'joinfiles') $_POST['joinfiles']=$_POST['joinfiles-'.$rowid];
314  if ($field == 'content') $_POST['content']=$_POST['content-'.$rowid];
315  if ($field == 'content_lines') $_POST['content_lines']=$_POST['content_lines-'.$rowid];
316  if ($field == 'entity') $_POST[$keycode] = $conf->entity;
317  if ($i) $sql.=",";
318  $sql.= $field."=";
319  if ($_POST[$keycode] == '' || ($keycode == 'langcode' && empty($_POST[$keycode]))) $sql.="null"; // For vat, we want/accept code = ''
320  else $sql.="'".$db->escape($_POST[$keycode])."'";
321  $i++;
322  }
323  $sql.= " WHERE ".$rowidcol." = '".$rowid."'";
324 
325  dol_syslog("actionmodify", LOG_DEBUG);
326  //print $sql;
327  $resql = $db->query($sql);
328  if ($resql)
329  {
330  setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
331  }
332  else
333  {
334  setEventMessages($db->error(), null, 'errors');
335  }
336  }
337  }
338 
339  if ($action == 'confirm_delete' && $confirm == 'yes') // delete
340  {
341  $rowidcol="rowid";
342 
343  $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
344 
345  dol_syslog("delete", LOG_DEBUG);
346  $result = $db->query($sql);
347  if (! $result)
348  {
349  if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
350  {
351  setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
352  }
353  else
354  {
355  dol_print_error($db);
356  }
357  }
358  }
359 
360  // activate
361  if ($action == $acts[0])
362  {
363  $rowidcol="rowid";
364 
365  $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
366 
367  $result = $db->query($sql);
368  if (!$result)
369  {
370  dol_print_error($db);
371  }
372  }
373 
374  // disable
375  if ($action == $acts[1])
376  {
377  $rowidcol="rowid";
378 
379  $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
380 
381  $result = $db->query($sql);
382  if (!$result)
383  {
384  dol_print_error($db);
385  }
386  }
387 }
388 
389 
390 /*
391  * View
392  */
393 
394 $form = new Form($db);
395 $formadmin=new FormAdmin($db);
396 
397 llxHeader();
398 
399 $titre=$langs->trans("EMailsSetup");
400 $linkback='';
401 $titlepicto='title_setup';
402 
403 print load_fiche_titre($titre,$linkback,$titlepicto);
404 
405 $head = email_admin_prepare_head();
406 
407 dol_fiche_head($head, 'templates', '', -1);
408 
409 // Confirmation de la suppression de la ligne
410 if ($action == 'delete')
411 {
412  print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1);
413 }
414 //var_dump($elementList);
415 
416 
417 $sql="SELECT rowid as rowid, label, type_template, lang, fk_user, private, position, topic, joinfiles, content_lines, content, active";
418 $sql.=" FROM ".MAIN_DB_PREFIX."c_email_templates";
419 $sql.=" WHERE entity IN (".getEntity('email_template').")";
420 if (! $user->admin)
421 {
422  $sql.=" AND (private = 0 OR (private = 1 AND fk_user = ".$user->id."))"; // Show only public and private to me
423  $sql.=" AND (active = 1 OR fk_user = ".$user->id.")"; // Show only active or owned by me
424 }
425 if (empty($conf->global->MAIN_MULTILANGS))
426 {
427  $sql.= " AND (lang = '".$langs->defaultlang."' OR lang IS NULL OR lang = '')";
428 }
429 if ($search_label) $sql.=natural_search('label', $search_label);
430 if ($search_type_template != '' && $search_type_template != '-1') $sql.=natural_search('type_template', $search_type_template);
431 if ($search_lang) $sql.=natural_search('lang', $search_lang);
432 if ($search_fk_user != '' && $search_fk_user != '-1') $sql.=natural_search('fk_user', $search_fk_user, 2);
433 if ($search_topic) $sql.=natural_search('topic', $search_topic);
434 if ($sortfield)
435 {
436  // If sort order is "country", we use country_code instead
437  if ($sortfield == 'country') $sortfield='country_code';
438  $sql.= " ORDER BY ".$sortfield;
439  if ($sortorder)
440  {
441  $sql.=" ".strtoupper($sortorder);
442  }
443  $sql.=", ";
444  // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value
445  $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]);
446  $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]);
447 }
448 else {
449  $sql.=" ORDER BY ";
450 }
451 $sql.=$tabsqlsort[$id];
452 $sql.=$db->plimit($listlimit+1,$offset);
453 //print $sql;
454 
455 $fieldlist=explode(',',$tabfield[$id]);
456 
457 // Form to add a new line
458 $alabelisused=0;
459 $var=false;
460 
461 print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
462 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
463 print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from','alpha')).'">';
464 
465 print '<div class="div-table-responsive-no-min">';
466 print '<table class="noborder" width="100%">';
467 
468 // Line to enter new values (title)
469 print '<tr class="liste_titre">';
470 foreach ($fieldlist as $field => $value)
471 {
472  // Determine le nom du champ par rapport aux noms possibles
473  // dans les dictionnaires de donnees
474  $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
475  $valuetoshow=$langs->trans($valuetoshow); // try to translate
476  $align="left";
477  if ($fieldlist[$field]=='fk_user') { $valuetoshow=$langs->trans("Owner");}
478  if ($fieldlist[$field]=='lang') { $valuetoshow=(empty($conf->global->MAIN_MULTILANGS) ? '&nbsp;' : $langs->trans("Language")); }
479  if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
480  if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
481  if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); }
482  if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
483  if ($fieldlist[$field]=='private') { $align='center'; }
484  if ($fieldlist[$field]=='position') { $align='center'; }
485 
486  if ($fieldlist[$field]=='topic') { $valuetoshow=''; }
487  if ($fieldlist[$field]=='joinfiles') { $valuetoshow=''; }
488  if ($fieldlist[$field]=='content') { $valuetoshow=''; }
489  if ($fieldlist[$field]=='content_lines') { $valuetoshow=''; }
490 
491  if ($valuetoshow != '')
492  {
493  print '<td align="'.$align.'">';
494  if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1,$valuetoshow).'</a>';
495  else if (! empty($tabhelp[$id][$value]))
496  {
497  if (in_array($value, array('topic'))) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, $value); // Tooltip on click
498  else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover
499  }
500  else print $valuetoshow;
501  print '</td>';
502  }
503  if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
504 }
505 print '<td>';
506 print '<input type="hidden" name="id" value="' . $id . '">';
507 print '</td>';
508 print '</tr>';
509 
510 $obj = new stdClass();
511 // If data was already input, we define them in obj to populate input fields.
512 if (GETPOST('actionadd'))
513 {
514  foreach ($fieldlist as $key => $val) {
515  if (GETPOST($val) != '')
516  $obj->$val = GETPOST($val);
517  }
518 }
519 
520 $tmpaction = 'create';
521 $parameters = array(
522  'fieldlist' => $fieldlist,
523  'tabname' => $tabname[$id]
524 );
525 $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
526 $error = $hookmanager->error;
527 $errors = $hookmanager->errors;
528 
529 
530 // Line to enter new values (input fields)
531 print "<tr " . $bcnd[$var] . ">";
532 
533 if (empty($reshook))
534 {
535  if ($action == 'edit') {
536  fieldList($fieldlist, $obj, $tabname[$id], 'hide');
537  } else {
538  fieldList($fieldlist, $obj, $tabname[$id], 'add');
539  }
540 }
541 
542 print '<td align="right">';
543 print '</td>';
544 print "</tr>";
545 
546 $fieldsforcontent = array('topic', 'joinfiles', 'content');
547 if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $fieldsforcontent = array('content','content_lines'); }
548 foreach ($fieldsforcontent as $tmpfieldlist)
549 {
550  print '<tr class="impair nodrag nodrop nohover"><td colspan="6" class="nobottom">';
551  // Label
552  if ($tmpfieldlist == 'topic')
553  {
554  print '<strong>' . $form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '</strong> ';
555  }
556  if ($tmpfieldlist == 'joinfiles')
557  {
558  print '<strong>' . $form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '</strong> ';
559  }
560  if ($tmpfieldlist == 'content')
561  print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist);
562  if ($tmpfieldlist == 'content_lines')
563  print $form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '<br>';
564  // Input field
565  if ($tmpfieldlist == 'topic') {
566  print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'" value="' . (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '') . '">';
567  }
568  else if ($tmpfieldlist == 'joinfiles') {
569  print '<input type="text" class="flat maxwidth50" name="'.$tmpfieldlist.'" value="' . (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '') . '">';
570  }
571  else
572  {
573  if ($context != 'hide') {
574  // print '<textarea cols="3" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'</textarea>';
575  $okforextended = true;
576  if (empty($conf->global->FCKEDITOR_ENABLE_MAIL))
577  $okforextended = false;
578  $doleditor = new DolEditor($tmpfieldlist, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 120, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_4, '90%');
579  print $doleditor->Create(1);
580  }
581  else
582  print '&nbsp;';
583  }
584  print '</td>';
585  if ($tmpfieldlist == 'topic') {
586  print '<td align="center" rowspan="' . (count($fieldsforcontent)) . '">';
587  if ($action != 'edit') {
588  print '<input type="submit" class="button" name="actionadd" value="' . $langs->trans("Add") . '">';
589  }
590  print '</td>';
591  }
592  // else print '<td></td>';
593  print '</tr>';
594 }
595 
596 
597 
598 $colspan=count($fieldlist)+1;
599 //print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
600 
601 print '</table>';
602 print '</div>';
603 
604 print '</form>';
605 
606 print '<br>';
607 
608 
609 print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
610 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
611 print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from','alpha')).'">';
612 
613 print '<div class="div-table-responsive-no-min">';
614 print '<table class="noborder" width="100%">';
615 
616 // List of available record in database
617 dol_syslog("htdocs/admin/dict", LOG_DEBUG);
618 $resql=$db->query($sql);
619 if ($resql)
620 {
621  $num = $db->num_rows($resql);
622  $i = 0;
623  $var=true;
624 
625  $param = '&id='.$id;
626  $paramwithsearch = $param;
627  if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
628  if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
629  if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha');
630 
631  // There is several pages
632  if ($num > $listlimit)
633  {
634  print '<tr class="none"><td align="right" colspan="'.(3+count($fieldlist)).'">';
635  print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
636  print '</td></tr>';
637  }
638 
639 
640  // Title line with search boxes
641  print '<tr class="liste_titre">';
642  $filterfound=0;
643  foreach ($fieldlist as $field => $value)
644  {
645  if ($value == 'label') print '<td class="liste_titre"><input type="text" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
646  elseif ($value == 'lang')
647  {
648  print '<td class="liste_titre">';
649  print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1);
650  print '</td>';
651  }
652  elseif ($value == 'fk_user')
653  {
654  print '<td class="liste_titre">';
655  $restrictid=array();
656  if (! $user->admin) $restrictid=array($user->id);
657  //var_dump($restrictid);
658  print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, 'hierarchyme', null, 0, 0, 1, '', 0, '', 'maxwidth200');
659  print '</td>';
660  }
661  elseif ($value == 'topic') print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>';
662  elseif ($value == 'type_template')
663  {
664  print '<td class="liste_titre">'.$form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100onsmartphone').'</td>';
665  }
666  elseif (! in_array($value, array('content', 'content_lines'))) print '<td class="liste_titre"></td>';
667  }
668  if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print '<td class="liste_titre"></td>';
669  // Action column
670  print '<td class="liste_titre" align="right" width="64">';
671  $searchpicto=$form->showFilterButtons();
672  print $searchpicto;
673  print '</td>';
674  print '</tr>';
675 
676  // Title of lines
677  print '<tr class="liste_titre">';
678  foreach ($fieldlist as $field => $value)
679  {
680  // Determine le nom du champ par rapport aux noms possibles
681  // dans les dictionnaires de donnees
682  $showfield=1; // By defaut
683  $align="left";
684  $sortable=1;
685  $valuetoshow='';
686  /*
687  $tmparray=getLabelOfField($fieldlist[$field]);
688  $showfield=$tmp['showfield'];
689  $valuetoshow=$tmp['valuetoshow'];
690  $align=$tmp['align'];
691  $sortable=$tmp['sortable'];
692  */
693  $valuetoshow=ucfirst($fieldlist[$field]); // By defaut
694  $valuetoshow=$langs->trans($valuetoshow); // try to translate
695  if ($fieldlist[$field]=='fk_user') { $valuetoshow=$langs->trans("Owner"); }
696  if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
697  if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
698  if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); }
699  if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
700  if ($fieldlist[$field]=='private') { $align='center'; }
701  if ($fieldlist[$field]=='position') { $align='center'; }
702 
703  if ($fieldlist[$field]=='joinfiles') { $valuetoshow=$langs->trans("FilesAttachedToEmail"); $align='center'; }
704  if ($fieldlist[$field]=='content') { $valuetoshow=$langs->trans("Content"); $showfield=0;}
705  if ($fieldlist[$field]=='content_lines') { $valuetoshow=$langs->trans("ContentLines"); $showfield=0; }
706 
707  // Affiche nom du champ
708  if ($showfield)
709  {
710  if (! empty($tabhelp[$id][$value]))
711  {
712  if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value); // Tooltip on click
713  else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', 1); // Tooltip on hover
714  }
715  print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder);
716  }
717  }
718 
719  print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder);
721  print '</tr>';
722 
723  if ($num)
724  {
725  // Lines with values
726  while ($i < $num)
727  {
728  $obj = $db->fetch_object($resql);
729 
730  print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
731 
732  if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
733  {
734  $tmpaction='edit';
735  $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
736  $reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
737  $error=$hookmanager->error; $errors=$hookmanager->errors;
738 
739  // Show fields
740  if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit');
741 
742  print '<td></td><td></td><td></td>';
743  print '<td align="center">';
744  print '<input type="hidden" name="page" value="'.$page.'">';
745  print '<input type="hidden" name="rowid" value="'.$rowid.'">';
746  print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
747  print '<div name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"></div>';
748  print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
749  print '</td>';
750 
751  $fieldsforcontent = array('topic', 'joinfiles', 'content');
752  if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
753  {
754  $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines');
755  }
756  foreach ($fieldsforcontent as $tmpfieldlist)
757  {
758  $showfield = 1;
759  $align = "left";
760  $valuetoshow = $obj->{$tmpfieldlist};
761 
762  $class = 'tddict';
763  // Show value for field
764  if ($showfield) {
765  // Show line for topic, joinfiles and content
766  print '</tr><tr class="oddeven" nohover tr-'.$tmpfieldlist.'-'.$rowid.' ">';
767  print '<td colspan="8">';
768  if ($tmpfieldlist == 'topic')
769  {
770  print '<strong>' . $form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '</strong> ';
771  print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'-'.$rowid.'" value="' . (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '') . '">';
772  }
773  if ($tmpfieldlist == 'joinfiles')
774  {
775  print '<strong>' . $form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '</strong> ';
776  print '<input type="text" class="flat maxwidth50" name="'.$tmpfieldlist.'-'.$rowid.'" value="' . (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '') . '">';
777  }
778  if ($tmpfieldlist == 'content')
779  {
780  $okforextended = true;
781  if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false;
782  $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%');
783  print $doleditor->Create(1);
784  }
785  print '</td>';
786  print '<td></td>';
787  print '<td></td>';
788  }
789  }
790  }
791  else
792  {
793  $tmpaction = 'view';
794  $parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
795  $reshook=$hookmanager->executeHooks('viewDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
796 
797  $error=$hookmanager->error; $errors=$hookmanager->errors;
798 
799  if (empty($reshook))
800  {
801  foreach ($fieldlist as $field => $value)
802  {
803  if (in_array($fieldlist[$field], array('content','content_lines'))) continue;
804  $showfield=1;
805  $align="left";
806  $valuetoshow=$obj->{$fieldlist[$field]};
807  if ($value == 'type_template')
808  {
809  $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow;
810  }
811  if ($value == 'lang' && $valuetoshow)
812  {
813  $valuetoshow = $valuetoshow.' - '.$langs->trans("Language_".$valuetoshow);
814  }
815  if ($value == 'fk_user')
816  {
817  if ($valuetoshow > 0)
818  {
819  $fuser=new User($db);
820  $fuser->fetch($valuetoshow);
821  $valuetoshow = $fuser->getNomUrl(1);
822  }
823  }
824  if ($value == 'private')
825  {
826  $align="center";
827  if ($valuetoshow) $valuetoshow=yn($valuetoshow);
828  else $valuetoshow='';
829  }
830  if ($value == 'position')
831  {
832  $align="center";
833  }
834  if ($value == 'joinfiles')
835  {
836  $align="center";
837  if ($valuetoshow) $valuetoshow=1;
838  else $valuetoshow='';
839  }
840 
841  $class='tddict';
842  // Show value for field
843  if ($showfield)
844  {
845  print '<!-- '.$fieldlist[$field].' -->';
846  print '<td align="'.$align.'" class="'.$class.'">'.$valuetoshow.'</td>';
847  }
848  }
849  }
850 
851  // Can an entry be erased or disabled ?
852  $iserasable=1;$canbedisabled=1;$canbemodified=1; // true by default
853  if (! $user->admin && $obj->fk_user != $user->id)
854  {
855  $iserasable=0;
856  $canbedisabled=0;
857  $canbemodified=0;
858  }
859 
860  $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'');
861  if ($param) $url .= '&'.$param;
862  $url.='&';
863 
864  // Status / Active
865  print '<td align="center" class="nowrap">';
866  if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
867  print "</td>";
868 
869  // Modify link / Delete link
870  print '<td align="center" width="64">';
871  if ($canbemodified) print '<a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a>';
872  if ($iserasable)
873  {
874  print ' &nbsp; <a href="'.$url.'action=delete">'.img_delete().'</a>';
875  //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
876  }
877  print '</td>';
878 
879 
880  /*
881  $fieldsforcontent = array('content');
882  if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
883  {
884  $fieldsforcontent = array('content', 'content_lines');
885  }
886  foreach ($fieldsforcontent as $tmpfieldlist)
887  {
888  $showfield = 1;
889  $align = "left";
890  $valuetoshow = $obj->{$tmpfieldlist};
891 
892  $class = 'tddict';
893  // Show value for field
894  if ($showfield) {
895 
896  print '</tr><tr class="oddeven" nohover tr-'.$tmpfieldlist.'-'.$i.' "><td colspan="5">'; // To create an artificial CR for the current tr we are on
897  $okforextended = true;
898  if (empty($conf->global->FCKEDITOR_ENABLE_MAIL))
899  $okforextended = false;
900  $doleditor = new DolEditor($tmpfieldlist.'-'.$i, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%', 1);
901  print $doleditor->Create(1);
902  print '</td>';
903  print '<td></td><td></td><td></td>';
904 
905  }
906  }*/
907  }
908  print "</tr>\n";
909 
910 
911  $i++;
912  }
913  }
914 }
915 else {
916  dol_print_error($db);
917 }
918 
919 print '</table>';
920 print '</div>';
921 
922 print '</form>';
923 
924 
925 dol_fiche_end();
926 
927 llxFooter();
928 $db->close();
929 
930 
940 function fieldList($fieldlist, $obj='', $tabname='', $context='')
941 {
942  global $conf, $langs, $user, $db;
943  global $form;
944  global $region_id;
945  global $elementList,$sourceList,$localtax_typeList;
946  global $bc;
947 
948  $formadmin = new FormAdmin($db);
949  $formcompany = new FormCompany($db);
950 
951  foreach ($fieldlist as $field => $value)
952  {
953  if ($fieldlist[$field] == 'fk_user')
954  {
955  print '<td>';
956  if ($user->admin)
957  {
958  print $form->select_dolusers($obj->{$fieldlist[$field]}, 'fk_user', 1, null, 0, '', null, 0, 0, 1, '', 0, '', 'maxwidth200');
959  }
960  else
961  {
962  if ($context == 'add') // I am not admin and we show the add form
963  {
964  print $user->getNomUrl(1); // Me
965  $forcedvalue=$user->id;
966  }
967  else
968  {
969  if ($obj && ! empty($obj->{$fieldlist[$field]}) && $obj->{$fieldlist[$field]} > 0)
970  {
971  $fuser=new User($db);
972  $fuser->fetch($obj->{$fieldlist[$field]});
973  print $fuser->getNomUrl(1);
974  $forcedvalue=$fuser->id;
975  }
976  else
977  {
978  $forcedvalue=$obj->{$fieldlist[$field]};
979  }
980  }
981  $keyname=$fieldlist[$field];
982  print '<input type="hidden" value="'.$forcedvalue.'" name="'.$keyname.'">';
983  }
984  print '</td>';
985  }
986  elseif ($fieldlist[$field] == 'lang')
987  {
988  print '<td>';
989  if (! empty($conf->global->MAIN_MULTILANGS))
990  {
991  $selectedlang = $langs->defaultlang;
992  if ($context == 'edit') $selectedlang = $obj->{$fieldlist[$field]};
993  print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1);
994  }
995  else
996  {
997  if (! empty($obj->{$fieldlist[$field]}))
998  {
999  print $obj->{$fieldlist[$field]}.' - '.$langs->trans('Language_'.$obj->{$fieldlist[$field]});
1000  }
1001  $keyname=$fieldlist[$field];
1002  if ($keyname == 'lang') $keyname='langcode'; // Avoid conflict with lang param
1003  print '<input type="hidden" value="'.$obj->{$fieldlist[$field]}.'" name="'.$keyname.'">';
1004  }
1005  print '</td>';
1006  }
1007  // Le type de template
1008  elseif ($fieldlist[$field] == 'type_template')
1009  {
1010  print '<td>';
1011  if ($context == 'edit' && ! empty($obj->{$fieldlist[$field]}) && ! in_array($obj->{$fieldlist[$field]}, array_keys($elementList)))
1012  {
1013  // Current tempalte type is an unknown type, so we must keep it as it is.
1014  print '<input type="hidden" name="type_template" value="'.$obj->{$fieldlist[$field]}.'">';
1015  print $obj->{$fieldlist[$field]};
1016  }
1017  else
1018  {
1019  print $form->selectarray('type_template', $elementList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1);
1020  }
1021  print '</td>';
1022  }
1023  elseif ($context == 'add' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
1024  elseif ($context == 'edit' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
1025  elseif ($context == 'hide' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue;
1026  else
1027  {
1028  $size=''; $class=''; $classtd='';
1029  if ($fieldlist[$field]=='code') $class='maxwidth100';
1030  if ($fieldlist[$field]=='private') { $class='maxwidth50'; $classtd='center'; }
1031  if ($fieldlist[$field]=='position') { $class='maxwidth50'; $classtd='center'; }
1032  if ($fieldlist[$field]=='libelle') $class='quatrevingtpercent';
1033  if ($fieldlist[$field]=='topic') $class='quatrevingtpercent';
1034  if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" ';
1035 
1036  print '<td'.($classtd?' class="'.$classtd.'"':'').'>';
1037  if ($fieldlist[$field]=='private')
1038  {
1039  if (empty($user->admin))
1040  {
1041  print $form->selectyesno($fieldlist[$field], '1', 1);
1042  }
1043  else
1044  {
1045  //print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="1" name="'.$fieldlist[$field].'">';
1046  print $form->selectyesno($fieldlist[$field], (isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1);
1047  }
1048  }
1049  else
1050  {
1051  print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="'.(isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
1052  }
1053  print '</td>';
1054  }
1055  }
1056 }
1057 
llxFooter()
Empty footer.
Definition: wrapper.php:58
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
if(!GETPOST('transkey')&&!GETPOST('transphrase')) else
View.
Definition: notice.php:43
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
email_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: admin.lib.php:1600
if(GETPOST('cancel','alpha')) if(!GETPOST('confirmmassaction','alpha')&&$massaction!= 'presend'&&$massaction!= 'confirm_presend')
Draft customers invoices.
Definition: list.php:147
Class to manage Dolibarr users.
Definition: user.class.php:39
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to generate html code for admin pages.
Class to build HTML component for third parties management Only common components are here...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
fieldList($fieldlist, $obj='', $tabname='', $context='')
Show fields in insert/edit mode.
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0)
Function to show navigation arrows into lists.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='')
Get title line of an array.
dol_fiche_end($notab=0)
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
img_delete($titlealt= 'default', $other= 'class="pictodelete"')
Show delete logo.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
print
Draft customers invoices.
Definition: index.php:91
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->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)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
static getAvailableSubstitKey($mode='formemail', $object=null)
Get list of substitution keys available for emails.
Class to manage a WYSIWYG editor.
type
Definition: viewcat.php:283
img_edit($titlealt= 'default', $float=0, $other= 'class="pictoedit"')
Show logo editer/modifier fiche.