dolibarr  9.0.0
website.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
24 require '../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
33 
34 // Load translation files required by the page
35 $langs->loadlangs(array('errors', 'admin', 'companies', 'website'));
36 
37 $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
38 $confirm=GETPOST('confirm','alpha');
39 $backtopage = GETPOST('backtopage', 'alpha');
40 
41 $rowid=GETPOST('rowid','alpha');
42 
43 $id=1;
44 
45 if (!$user->admin) accessforbidden();
46 
47 $acts[0] = "activate";
48 $acts[1] = "disable";
49 $actl[0] = img_picto($langs->trans("Disabled"),'switch_off');
50 $actl[1] = img_picto($langs->trans("Activated"),'switch_on');
51 
52 $status = 1;
53 
54 // Load variable for pagination
55 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
56 $sortfield = GETPOST('sortfield','alpha');
57 $sortorder = GETPOST('sortorder','alpha');
58 $page = GETPOST('page','int');
59 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
60 $offset = $limit * $page;
61 $pageprev = $page - 1;
62 $pagenext = $page + 1;
63 
64 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
65 $hookmanager->initHooks(array('website'));
66 
67 // Name of SQL tables of dictionaries
68 $tabname=array();
69 $tabname[1] = MAIN_DB_PREFIX."website";
70 
71 // Dictionary labels
72 $tablib=array();
73 $tablib[1] = "Websites";
74 
75 // Requests to extract data
76 $tabsql=array();
77 $tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.virtualhost, f.status FROM ".MAIN_DB_PREFIX.'website as f WHERE f.entity IN ('.getEntity('website').')';
78 
79 // Criteria to sort dictionaries
80 $tabsqlsort=array();
81 $tabsqlsort[1] ="ref ASC";
82 
83 // Nom des champs en resultat de select pour affichage du dictionnaire
84 $tabfield=array();
85 $tabfield[1] = "ref,description,virtualhost";
86 
87 // Nom des champs d'edition pour modification d'un enregistrement
88 $tabfieldvalue=array();
89 $tabfieldvalue[1] = "ref,description,virtualhost";
90 
91 // Nom des champs dans la table pour insertion d'un enregistrement
92 $tabfieldinsert=array();
93 $tabfieldinsert[1] = "ref,description,virtualhost,entity";
94 
95 // Nom du rowid si le champ n'est pas de type autoincrement
96 // Example: "" if id field is "rowid" and has autoincrement on
97 // "nameoffield" if id field is not "rowid" or has not autoincrement on
98 $tabrowid=array();
99 $tabrowid[1] = "";
100 
101 // Condition to show dictionary in setup page
102 $tabcond=array();
103 $tabcond[1] = (! empty($conf->website->enabled));
104 
105 // List of help for fields
106 $tabhelp=array();
107 $tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>websiteref</i>'));
108 
109 // List of check for fields (NOT USED YET)
110 $tabfieldcheck=array();
111 $tabfieldcheck[1] = array();
112 
113 
114 // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
115 $elementList = array();
116 $sourceList=array();
117 
118 
119 /*
120  * Actions
121  */
122 
123 // Actions add or modify a website
124 if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha'))
125 {
126  $listfield=explode(',',$tabfield[$id]);
127  $listfieldinsert=explode(',',$tabfieldinsert[$id]);
128  $listfieldmodify=explode(',',$tabfieldinsert[$id]);
129  $listfieldvalue=explode(',',$tabfieldvalue[$id]);
130 
131  // Check that all fields are filled
132  $ok=1;
133  foreach ($listfield as $f => $value)
134  {
135  if ($value == 'ref' && (! isset($_POST[$value]) || $_POST[$value]==''))
136  {
137  $ok=0;
138  $fieldnamekey=$listfield[$f];
139  setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
140  break;
141  }
142  elseif ($value == 'ref' && ! preg_match('/^[a-z0-9_\-\.]+$/i', $_POST[$value]))
143  {
144  $ok=0;
145  $fieldnamekey=$listfield[$f];
146  setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities($fieldnamekey)), null, 'errors');
147  break;
148  }
149  }
150 
151  // Clean parameters
152  if (! empty($_POST['ref']))
153  {
154  $websitekey=strtolower($_POST['ref']);
155  }
156 
157  // Si verif ok et action add, on ajoute la ligne
158  if ($ok && GETPOST('actionadd','alpha'))
159  {
160  if ($tabrowid[$id])
161  {
162  // Recupere id libre pour insertion
163  $newid=0;
164  $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
165  $result = $db->query($sql);
166  if ($result)
167  {
168  $obj = $db->fetch_object($result);
169  $newid=($obj->newid + 1);
170  } else {
171  dol_print_error($db);
172  }
173  }
174 
175  /* $website=new Website($db);
176  $website->ref=
177  $website->description=
178  $website->virtualhost=
179  $website->create($user); */
180 
181  // Add new entry
182  $sql = "INSERT INTO ".$tabname[$id]." (";
183  // List of fields
184  if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
185  $sql.= $tabrowid[$id].",";
186  $sql.= $tabfieldinsert[$id];
187  $sql.=",status)";
188  $sql.= " VALUES(";
189 
190  // List of values
191  if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
192  $sql.= $newid.",";
193  $i=0;
194  foreach ($listfieldinsert as $f => $value)
195  {
196  if ($value == 'entity') {
197  $_POST[$listfieldvalue[$i]] = $conf->entity;
198  }
199  if ($value == 'ref') {
200  $_POST[$listfieldvalue[$i]] = strtolower($_POST[$listfieldvalue[$i]]);
201  }
202  if ($i) $sql.=",";
203  if ($_POST[$listfieldvalue[$i]] == '') $sql.="null";
204  else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
205  $i++;
206  }
207  $sql.=",1)";
208 
209  dol_syslog("actionadd", LOG_DEBUG);
210  $result = $db->query($sql);
211  if ($result) // Add is ok
212  {
213  setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
214  unset($_POST); // Clean $_POST array, we keep only
215  }
216  else
217  {
218  if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
219  setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
220  }
221  else {
222  dol_print_error($db);
223  }
224  }
225  }
226 
227  // Si verif ok et action modify, on modifie la ligne
228  if ($ok && GETPOST('actionmodify','alpha'))
229  {
230  if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
231  else { $rowidcol="rowid"; }
232 
233  $db->begin();
234 
235  $website=new Website($db);
236  $rowid=GETPOST('rowid','int');
237  $website->fetch($rowid);
238 
239  // Modify entry
240  $sql = "UPDATE ".$tabname[$id]." SET ";
241  // Modifie valeur des champs
242  if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify))
243  {
244  $sql.= $tabrowid[$id]."=";
245  $sql.= "'".$db->escape($rowid)."', ";
246  }
247  $i = 0;
248  foreach ($listfieldmodify as $field)
249  {
250  if ($field == 'entity') {
251  $_POST[$listfieldvalue[$i]] = $conf->entity;
252  }
253  if ($i) $sql.=",";
254  $sql.= $field."=";
255  if ($_POST[$listfieldvalue[$i]] == '') $sql.="null";
256  else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
257  $i++;
258  }
259  $sql.= " WHERE ".$rowidcol." = '".$rowid."'";
260 
261  dol_syslog("actionmodify", LOG_DEBUG);
262  //print $sql;
263  $resql = $db->query($sql);
264  if ($resql)
265  {
266  $newname = dol_sanitizeFileName(GETPOST('ref','aZ09'));
267  if ($newname != $website->ref)
268  {
269  $srcfile=DOL_DATA_ROOT.'/website/'.$website->ref;
270  $destfile=DOL_DATA_ROOT.'/website/'.$newname;
271 
272  if (dol_is_dir($destfile))
273  {
274  $error++;
275  setEventMessages($langs->trans('ErrorDirAlreadyExists', $destfile), null, 'errors');
276  }
277  else
278  {
279  @rename($srcfile, $destfile);
280 
281  // We must now rename $website->ref into $newname inside files
282  $arrayreplacement = array($website->ref.'/htmlheader.html' => $newname.'/htmlheader.html');
283  $listofilestochange = dol_dir_list($destfile, 'files', 0, '\.php$');
284  foreach ($listofilestochange as $key => $value)
285  {
286  dolReplaceInFile($value['fullname'], $arrayreplacement);
287  }
288  }
289  }
290  }
291  else
292  {
293  $error++;
294  setEventMessages($db->lasterror(), null, 'errors');
295  }
296 
297  if (! $error)
298  {
299  $db->commit();
300  }
301  else
302  {
303  $db->rollback();
304  }
305  }
306  //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
307 }
308 
309 if (GETPOST('actioncancel','alpha'))
310 {
311  //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
312 }
313 
314 if ($action == 'confirm_delete' && $confirm == 'yes') // delete
315 {
316  if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
317  else { $rowidcol="rowid"; }
318 
319  $website = new Website($db);
320  $website->fetch($rowid);
321 
322  if ($website->id > 0)
323  {
324  $sql = "DELETE from ".MAIN_DB_PREFIX."website_account WHERE fk_website ='".$rowid."'";
325  $result = $db->query($sql);
326 
327  $sql = "DELETE from ".MAIN_DB_PREFIX."website_page WHERE fk_website ='".$rowid."'";
328  $result = $db->query($sql);
329 
330  $sql = "DELETE from ".MAIN_DB_PREFIX."website_extrafields WHERE fk_object ='".$rowid."'";
331  $result = $db->query($sql);
332 
333  $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'";
334  $result = $db->query($sql);
335  if (! $result)
336  {
337  if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
338  {
339  setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
340  }
341  else
342  {
343  dol_print_error($db);
344  }
345  }
346 
347  if ($website->ref)
348  {
349  dol_delete_dir_recursive($conf->website->dir_output.'/'.$website->ref);
350  }
351  }
352  else
353  {
354  dol_print_error($db, 'Failed to load website with id '.$rowid);
355  }
356 }
357 
358 // activate
359 if ($action == $acts[0])
360 {
361  if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
362  else { $rowidcol="rowid"; }
363 
364  if ($rowid) {
365  $sql = "UPDATE ".$tabname[$id]." SET status = 1 WHERE rowid ='".$rowid."'";
366  }
367 
368  $result = $db->query($sql);
369  if (!$result)
370  {
371  dol_print_error($db);
372  }
373 }
374 
375 // disable
376 if ($action == $acts[1])
377 {
378  if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
379  else { $rowidcol="rowid"; }
380 
381  if ($rowid) {
382  $sql = "UPDATE ".$tabname[$id]." SET status = 0 WHERE rowid ='".$rowid."'";
383  }
384 
385  $result = $db->query($sql);
386  if (!$result)
387  {
388  dol_print_error($db);
389  }
390 }
391 
392 
393 
394 /*
395  * View
396  */
397 
398 $form = new Form($db);
399 $formadmin=new FormAdmin($db);
400 
401 llxHeader('', $langs->trans("WebsiteSetup"));
402 
403 $titre=$langs->trans("WebsiteSetup");
404 $linkback='<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
405 print load_fiche_titre($titre,$linkback,'title_setup');
406 
407 // Onglets
408 $head=array();
409 $h = 0;
410 
411 $head[$h][0] = DOL_URL_ROOT."/admin/website.php";
412 $head[$h][1] = $langs->trans("WebSites");
413 $head[$h][2] = 'website';
414 $h++;
415 
416 $head[$h][0] = DOL_URL_ROOT."/admin/website_options.php";
417 $head[$h][1] = $langs->trans("Options");
418 $head[$h][2] = 'options';
419 $h++;
420 
421 dol_fiche_head($head, 'website', '', -1);
422 
423 
424 print $langs->trans("WebsiteSetupDesc").'<br>';
425 print "<br>\n";
426 
427 
428 // Confirmation de la suppression de la ligne
429 if ($action == 'delete')
430 {
431  print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete','',0,1);
432 }
433 //var_dump($elementList);
434 
435 /*
436  * Show website list
437  */
438 if ($id)
439 {
440  // Complete requete recherche valeurs avec critere de tri
441  $sql=$tabsql[$id];
442  $sql.=$db->order($sortfield,$sortorder);
443  $sql.=$db->plimit($limit+1, $offset);
444  //print $sql;
445 
446  $fieldlist=explode(',',$tabfield[$id]);
447 
448  print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
449  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
450  print '<table class="noborder" width="100%">';
451 
452  // Form to add a new line
453  if ($tabname[$id])
454  {
455  $alabelisused=0;
456  $var=false;
457 
458  $fieldlist=explode(',',$tabfield[$id]);
459 
460  // Line for title
461  print '<tr class="liste_titre">';
462  foreach ($fieldlist as $field => $value)
463  {
464  // Determine le nom du champ par rapport aux noms possibles
465  // dans les dictionnaires de donnees
466  $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
467  $valuetoshow=$langs->trans($valuetoshow); // try to translate
468  $align='';
469  if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
470  if ($valuetoshow != '')
471  {
472  print '<td class="'.$align.'">';
473  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>';
474  elseif (! empty($tabhelp[$id][$value]))
475  {
476  if ($value == 'virtualhost') print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltipvirtual');
477  else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
478  }
479  else print $valuetoshow;
480  print '</td>';
481  }
482  if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
483  }
484 
485  print '<td colspan="4">';
486  print '</td>';
487  print '</tr>';
488 
489  // Line to enter new values
490  print "<tr ".$bcnd[$var].">";
491 
492  $obj = new stdClass();
493  // If data was already input, we define them in obj to populate input fields.
494  if (GETPOST('actionadd','alpha'))
495  {
496  foreach ($fieldlist as $key=>$val)
497  {
498  if (GETPOST($val,'alpha'))
499  $obj->$val=GETPOST($val);
500  }
501  }
502 
503  fieldListWebsites($fieldlist,$obj,$tabname[$id],'add');
504 
505  print '<td colspan="3" align="right">';
506  if ($action != 'edit')
507  {
508  print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">';
509  }
510  print '</td>';
511  print "</tr>";
512 
513  $colspan=count($fieldlist)+2;
514  }
515 
516  print '</table>';
517  print '</form>';
518 
519 
520  // List of websites in database
521  $resql=$db->query($sql);
522  if ($resql)
523  {
524  $num = $db->num_rows($resql);
525  $i = 0;
526  if ($num)
527  {
528  print '<br>';
529 
530  print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
531  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
532  print '<input type="hidden" name="page" value="'.$page.'">';
533  print '<input type="hidden" name="rowid" value="'.$rowid.'">';
534 
535  print '<table class="noborder" width="100%">';
536 
537  // Title of lines
538  print '<tr class="liste_titre">';
539  foreach ($fieldlist as $field => $value)
540  {
541  // Determine le nom du champ par rapport aux noms possibles
542  // dans les dictionnaires de donnees
543  $showfield=1; // Par defaut
544  $align="left";
545  $sortable=1;
546  $valuetoshow='';
547  /*
548  $tmparray=getLabelOfField($fieldlist[$field]);
549  $showfield=$tmp['showfield'];
550  $valuetoshow=$tmp['valuetoshow'];
551  $align=$tmp['align'];
552  $sortable=$tmp['sortable'];
553  */
554  $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
555  $valuetoshow=$langs->trans($valuetoshow); // try to translate
556  if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
557  if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
558  if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
559 
560  // Affiche nom du champ
561  if ($showfield)
562  {
563  print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':''),"","align=".$align,$sortfield,$sortorder);
564  }
565  }
566 
567  print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"status",($page?'page='.$page.'&':''),"",'align="center"',$sortfield,$sortorder);
570  print '</tr>';
571 
572  // Lines with values
573  while ($i < $num)
574  {
575 
576  $obj = $db->fetch_object($resql);
577  //print_r($obj);
578  print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
579  if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
580  {
581  $tmpaction='edit';
582  $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
583  $reshook=$hookmanager->executeHooks('editWebsiteFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
584  $error=$hookmanager->error; $errors=$hookmanager->errors;
585 
586  if (empty($reshook)) fieldListWebsites($fieldlist,$obj,$tabname[$id],'edit');
587 
588  print '<td colspan="3" align="right"><a name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
589  print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
590  }
591  else
592  {
593  $tmpaction = 'view';
594  $parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
595  $reshook=$hookmanager->executeHooks('viewWebsiteFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
596 
597  $error=$hookmanager->error; $errors=$hookmanager->errors;
598 
599  if (empty($reshook))
600  {
601  foreach ($fieldlist as $field => $value)
602  {
603  $showfield=1;
604  $align="left";
605  $fieldname=$fieldlist[$field];
606  $valuetoshow=$obj->$fieldname;
607 
608  // Show value for field
609  if ($showfield) print '<td align="'.$align.'">'.$valuetoshow.'</td>';
610  }
611  }
612 
613  // Can an entry be erased or disabled ?
614  $iserasable=1; $isdisable=1; // true by default
615  if ($obj->status) $iserasable=0; // We can't delete a website on. Disable it first.
616 
617  $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&amp;code='.(! empty($obj->code)?urlencode($obj->code):'').'&amp;';
618 
619  // Active
620  print '<td align="center" class="nowrap">';
621  print '<a href="'.$url.'action='.$acts[$obj->status].'">'.$actl[$obj->status].'</a>';
622  print "</td>";
623 
624  // Modify link
625  print '<td align="center"><a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a></td>';
626 
627  // Delete link
628  if ($iserasable) print '<td align="center"><a href="'.$url.'action=delete">'.img_delete().'</a></td>';
629  else print '<td align="center">'.img_delete($langs->trans("DisableSiteFirst"), 'class="opacitymedium"').'</td>';
630 
631  print "</tr>\n";
632  }
633  $i++;
634  }
635 
636  print '</table>';
637 
638  print '</form>';
639  }
640  }
641  else {
642  dol_print_error($db);
643  }
644 }
645 
646 dol_fiche_end();
647 
648 // End of page
649 llxFooter();
650 $db->close();
651 
652 
662 function fieldListWebsites($fieldlist, $obj='', $tabname='', $context='')
663 {
664  global $conf,$langs,$db;
665  global $form;
666  global $region_id;
667  global $elementList,$sourceList,$localtax_typeList;
668  global $bc;
669 
670  $formadmin = new FormAdmin($db);
671 
672  foreach ($fieldlist as $field => $value)
673  {
674  $fieldname = $fieldlist[$field];
675  if ($fieldlist[$field] == 'lang')
676  {
677  print '<td>';
678  print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT,'lang');
679  print '</td>';
680  }
681  elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldname)) {
682  print '<td><input type="text" class="flat" value="'.(! empty($obj->$fieldname)?$obj->$fieldname:'').'" size="10" name="'.$fieldlist[$field].'"></td>';
683  }
684  else
685  {
686  print '<td>';
687  $size='';
688  if ($fieldlist[$field]=='code') $size='size="8" ';
689  if ($fieldlist[$field]=='position') $size='size="4" ';
690  if ($fieldlist[$field]=='libelle') $size='size="32" ';
691  if ($fieldlist[$field]=='tracking') $size='size="92" ';
692  if ($fieldlist[$field]=='sortorder') $size='size="2" ';
693  print '<input type="text" '.$size.' class="flat" value="'.(isset($obj->$fieldname)?$obj->$fieldname:'').'" name="'.$fieldlist[$field].'">';
694  print '</td>';
695  }
696  }
697 }
698 
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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:1053
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
Class Website.
img_edit($titlealt='default', $float=0, $other='class="pictoedit"')
Show logo editer/modifier fiche.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
dol_is_dir($folder)
Test if filename is a directory.
Definition: files.lib.php:438
img_delete($titlealt='default', $other='class="pictodelete"')
Show delete logo.
Class to generate html code for admin pages.
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.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='')
Get title line of an array.
fieldListWebsites($fieldlist, $obj='', $tabname='', $context='')
Show fields in insert/edit mode.
Definition: website.php:662
dol_fiche_end($notab=0)
Show tab footer of a card.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories) ...
Definition: files.lib.php:1273
llxHeader()
Empty header.
Definition: wrapper.php:44
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:59
dolReplaceInFile($srcfile, $arrayreplacement, $destfile='', $newmask=0, $indexdatabase=0)
Make replacement of strings into a file.
Definition: files.lib.php:581
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.