dolibarr  13.0.2
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 <https://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 // Load variable for pagination
53 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
54 $sortfield = GETPOST('sortfield', 'aZ09comma');
55 $sortorder = GETPOST('sortorder', 'aZ09comma');
56 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
57 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
58 $offset = $limit * $page;
59 $pageprev = $page - 1;
60 $pagenext = $page + 1;
61 
62 if (empty($sortfield)) $sortfield = 'position, ref';
63 if (empty($sortorder)) $sortorder = 'ASC';
64 
65 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
66 $hookmanager->initHooks(array('website'));
67 
68 // Name of SQL tables of dictionaries
69 $tabname = array();
70 $tabname[1] = MAIN_DB_PREFIX."website";
71 
72 // Dictionary labels
73 $tablib = array();
74 $tablib[1] = "Websites";
75 
76 // Requests to extract data
77 $tabsql = array();
78 $tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.virtualhost, f.position, f.status FROM ".MAIN_DB_PREFIX.'website as f WHERE f.entity IN ('.getEntity('website').')';
79 
80 // Criteria to sort dictionaries
81 $tabsqlsort = array();
82 $tabsqlsort[1] = "ref ASC";
83 
84 // Nom des champs en resultat de select pour affichage du dictionnaire
85 $tabfield = array();
86 $tabfield[1] = "ref,description,virtualhost,position";
87 
88 // Nom des champs d'edition pour modification d'un enregistrement
89 $tabfieldvalue = array();
90 $tabfieldvalue[1] = "ref,description,virtualhost,position";
91 
92 // Nom des champs dans la table pour insertion d'un enregistrement
93 $tabfieldinsert = array();
94 $tabfieldinsert[1] = "ref,description,virtualhost,position,entity";
95 
96 // Nom du rowid si le champ n'est pas de type autoincrement
97 // Example: "" if id field is "rowid" and has autoincrement on
98 // "nameoffield" if id field is not "rowid" or has not autoincrement on
99 $tabrowid = array();
100 $tabrowid[1] = "";
101 
102 // Condition to show dictionary in setup page
103 $tabcond = array();
104 $tabcond[1] = (!empty($conf->website->enabled));
105 
106 // List of help for fields
107 $tabhelp = array();
108 $tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>websiteref</i>'));
109 
110 // List of check for fields (NOT USED YET)
111 $tabfieldcheck = array();
112 $tabfieldcheck[1] = array();
113 
114 
115 // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
116 $elementList = array();
117 $sourceList = array();
118 
119 
120 /*
121  * Actions
122  */
123 
124 // Actions add or modify a website
125 if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
126 {
127  $listfield = explode(',', $tabfield[$id]);
128  $listfieldinsert = explode(',', $tabfieldinsert[$id]);
129  $listfieldmodify = explode(',', $tabfieldinsert[$id]);
130  $listfieldvalue = explode(',', $tabfieldvalue[$id]);
131 
132  // Check that all fields are filled
133  $ok = 1;
134  foreach ($listfield as $f => $value)
135  {
136  if ($value == 'ref' && (!GETPOSTISSET($value) || GETPOST($value) == ''))
137  {
138  $ok = 0;
139  $fieldnamekey = $listfield[$f];
140  setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
141  break;
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  } else {
216  if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
217  setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
218  } else {
219  dol_print_error($db);
220  }
221  }
222  }
223 
224  // Si verif ok et action modify, on modifie la ligne
225  if ($ok && GETPOST('actionmodify', 'alpha'))
226  {
227  if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
228 
229  $db->begin();
230 
231  $website = new Website($db);
232  $rowid = GETPOST('rowid', 'int');
233  $website->fetch($rowid);
234 
235  // Modify entry
236  $sql = "UPDATE ".$tabname[$id]." SET ";
237  // Modifie valeur des champs
238  if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
239  {
240  $sql .= $tabrowid[$id]."=";
241  $sql .= "'".$db->escape($rowid)."', ";
242  }
243  $i = 0;
244  foreach ($listfieldmodify as $field)
245  {
246  if ($field == 'entity') {
247  $_POST[$listfieldvalue[$i]] = $conf->entity;
248  }
249  if ($i) $sql .= ",";
250  $sql .= $field."=";
251  if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null";
252  else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
253  $i++;
254  }
255  $sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
256 
257  dol_syslog("actionmodify", LOG_DEBUG);
258  //print $sql;
259  $resql = $db->query($sql);
260  if ($resql)
261  {
262  $newname = dol_sanitizeFileName(GETPOST('ref', 'aZ09'));
263  if ($newname != $website->ref)
264  {
265  $srcfile = DOL_DATA_ROOT.'/website/'.$website->ref;
266  $destfile = DOL_DATA_ROOT.'/website/'.$newname;
267 
268  if (dol_is_dir($destfile))
269  {
270  $error++;
271  setEventMessages($langs->trans('ErrorDirAlreadyExists', $destfile), null, 'errors');
272  } else {
273  @rename($srcfile, $destfile);
274 
275  // We must now rename $website->ref into $newname inside files
276  $arrayreplacement = array($website->ref.'/htmlheader.html' => $newname.'/htmlheader.html');
277  $listofilestochange = dol_dir_list($destfile, 'files', 0, '\.php$');
278  foreach ($listofilestochange as $key => $value)
279  {
280  dolReplaceInFile($value['fullname'], $arrayreplacement);
281  }
282  }
283  }
284  } else {
285  $error++;
286  setEventMessages($db->lasterror(), null, 'errors');
287  }
288 
289  if (!$error)
290  {
291  $db->commit();
292  } else {
293  $db->rollback();
294  }
295  }
296  //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
297 }
298 
299 if (GETPOST('actioncancel', 'alpha'))
300 {
301  //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
302 }
303 
304 if ($action == 'confirm_delete' && $confirm == 'yes') // delete
305 {
306  if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
307 
308  $website = new Website($db);
309  $website->fetch($rowid);
310 
311  if ($website->id > 0)
312  {
313  $sql = "DELETE from ".MAIN_DB_PREFIX."website_account WHERE fk_website = ".((int) $rowid);
314  $result = $db->query($sql);
315 
316  $sql = "DELETE from ".MAIN_DB_PREFIX."website_page WHERE fk_website = ".((int) $rowid);
317  $result = $db->query($sql);
318 
319  $sql = "DELETE from ".MAIN_DB_PREFIX."website_extrafields WHERE fk_object = ".((int) $rowid);
320  $result = $db->query($sql);
321 
322  $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid = ".((int) $rowid);
323  $result = $db->query($sql);
324  if (!$result)
325  {
326  if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
327  {
328  setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
329  } else {
330  dol_print_error($db);
331  }
332  }
333 
334  if ($website->ref)
335  {
336  dol_delete_dir_recursive($conf->website->dir_output.'/'.$website->ref);
337  }
338  } else {
339  dol_print_error($db, 'Failed to load website with id '.$rowid);
340  }
341 }
342 
343 // activate
344 if ($action == $acts[0])
345 {
346  if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
347 
348  if ($rowid) {
349  $sql = "UPDATE ".$tabname[$id]." SET status = 1 WHERE rowid = ".((int) $rowid);
350  }
351 
352  $result = $db->query($sql);
353  if (!$result)
354  {
355  dol_print_error($db);
356  }
357 }
358 
359 // disable
360 if ($action == $acts[1])
361 {
362  if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
363 
364  if ($rowid) {
365  $sql = "UPDATE ".$tabname[$id]." SET status = 0 WHERE rowid = ".((int) $rowid);
366  }
367 
368  $result = $db->query($sql);
369  if (!$result)
370  {
371  dol_print_error($db);
372  }
373 }
374 
375 
376 
377 /*
378  * View
379  */
380 
381 $form = new Form($db);
382 $formadmin = new FormAdmin($db);
383 
384 llxHeader('', $langs->trans("WebsiteSetup"));
385 
386 $titre = $langs->trans("WebsiteSetup");
387 $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
388 print load_fiche_titre($titre, $linkback, 'title_setup');
389 
390 // Onglets
391 $head = array();
392 $h = 0;
393 
394 $head[$h][0] = DOL_URL_ROOT."/admin/website.php";
395 $head[$h][1] = $langs->trans("WebSites");
396 $head[$h][2] = 'website';
397 $h++;
398 
399 $head[$h][0] = DOL_URL_ROOT."/admin/website_options.php";
400 $head[$h][1] = $langs->trans("Options");
401 $head[$h][2] = 'options';
402 $h++;
403 
404 print dol_get_fiche_head($head, 'website', '', -1);
405 
406 
407 print '<span class="opacitymedium">'.$langs->trans("WebsiteSetupDesc").'</span><br>';
408 print "<br>\n";
409 
410 
411 // Confirmation de la suppression de la ligne
412 if ($action == 'delete')
413 {
414  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, 220);
415 }
416 //var_dump($elementList);
417 
418 /*
419  * Show website list
420  */
421 if ($id)
422 {
423  // Complete requete recherche valeurs avec critere de tri
424  $sql = $tabsql[$id];
425  $sql .= $db->order($sortfield, $sortorder);
426  $sql .= $db->plimit($limit + 1, $offset);
427  //print $sql;
428 
429  $fieldlist = explode(',', $tabfield[$id]);
430 
431  print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
432  print '<input type="hidden" name="token" value="'.newToken().'">';
433  print '<table class="noborder centpercent">';
434 
435  // Form to add a new line
436  if ($tabname[$id])
437  {
438  $fieldlist = explode(',', $tabfield[$id]);
439 
440  // Line for title
441  print '<tr class="liste_titre">';
442  foreach ($fieldlist as $field => $value)
443  {
444  // Determine le nom du champ par rapport aux noms possibles
445  // dans les dictionnaires de donnees
446  $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
447  $valuetoshow = $langs->trans($valuetoshow); // try to translate
448  $align = '';
449  if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); }
450  if ($valuetoshow != '')
451  {
452  print '<td class="'.$align.'">';
453  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>';
454  elseif (!empty($tabhelp[$id][$value]))
455  {
456  if ($value == 'virtualhost') print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltipvirtual');
457  else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
458  } else print $valuetoshow;
459  print '</td>';
460  }
461  }
462 
463  print '<td colspan="4">';
464  print '</td>';
465  print '</tr>';
466 
467  // Line to enter new values
468  print '<tr class="oddeven">';
469 
470  $obj = new stdClass();
471  // If data was already input, we define them in obj to populate input fields.
472  if (GETPOST('actionadd', 'alpha'))
473  {
474  foreach ($fieldlist as $key=>$val)
475  {
476  if (GETPOST($val, 'alpha'))
477  $obj->$val = GETPOST($val);
478  }
479  }
480 
481  fieldListWebsites($fieldlist, $obj, $tabname[$id], 'add');
482 
483  print '<td colspan="3" class="right">';
484  if ($action != 'edit')
485  {
486  print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">';
487  }
488  print '</td>';
489  print "</tr>";
490 
491  $colspan = count($fieldlist) + 2;
492  }
493 
494  print '</table>';
495  print '</form>';
496 
497 
498  // List of websites in database
499  $resql = $db->query($sql);
500  if ($resql)
501  {
502  $num = $db->num_rows($resql);
503  $i = 0;
504  if ($num)
505  {
506  print '<br>';
507 
508  print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
509  print '<input type="hidden" name="token" value="'.newToken().'">';
510  print '<input type="hidden" name="page" value="'.$page.'">';
511  print '<input type="hidden" name="rowid" value="'.$rowid.'">';
512 
513  print '<table class="noborder centpercent">';
514 
515  // Title of lines
516  print '<tr class="liste_titre">';
517  foreach ($fieldlist as $field => $value)
518  {
519  // Determine le nom du champ par rapport aux noms possibles
520  // dans les dictionnaires de donnees
521  $showfield = 1; // Par defaut
522  $align = "left";
523  $sortable = 1;
524  $valuetoshow = '';
525  /*
526  $tmparray=getLabelOfField($fieldlist[$field]);
527  $showfield=$tmp['showfield'];
528  $valuetoshow=$tmp['valuetoshow'];
529  $align=$tmp['align'];
530  $sortable=$tmp['sortable'];
531  */
532  $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
533  $valuetoshow = $langs->trans($valuetoshow); // try to translate
534  if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); }
535  if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); }
536  if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); }
537 
538  // Affiche nom du champ
539  if ($showfield)
540  {
541  print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), "", "align=".$align, $sortfield, $sortorder);
542  }
543  }
544 
545  print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "status", ($page ? 'page='.$page.'&' : ''), "", 'align="center"', $sortfield, $sortorder);
548  print '</tr>';
549 
550  // Lines with values
551  while ($i < $num)
552  {
553  $obj = $db->fetch_object($resql);
554  //print_r($obj);
555  print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
556  if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)))
557  {
558  $tmpaction = 'edit';
559  $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
560  $reshook = $hookmanager->executeHooks('editWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
561  $error = $hookmanager->error; $errors = $hookmanager->errors;
562 
563  if (empty($reshook)) fieldListWebsites($fieldlist, $obj, $tabname[$id], 'edit');
564 
565  print '<td colspan="3" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
566  print '&nbsp;<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
567  } else {
568  $tmpaction = 'view';
569  $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
570  $reshook = $hookmanager->executeHooks('viewWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
571 
572  $error = $hookmanager->error; $errors = $hookmanager->errors;
573 
574  if (empty($reshook))
575  {
576  foreach ($fieldlist as $field => $value)
577  {
578  $showfield = 1;
579  $align = "left";
580  $fieldname = $fieldlist[$field];
581  $valuetoshow = $obj->$fieldname;
582 
583  // Show value for field
584  if ($showfield) print '<td align="'.$align.'">'.$valuetoshow.'</td>';
585  }
586  }
587 
588  // Can an entry be erased or disabled ?
589  $iserasable = 1; $isdisable = 1; // true by default
590  if ($obj->status) $iserasable = 0; // We can't delete a website on. Disable it first.
591 
592  $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;';
593 
594  // Active
595  print '<td align="center" class="nowrap">';
596  print '<a class="reposition" href="'.$url.'action='.$acts[($obj->status ? 1 : 0)].'">'.$actl[($obj->status ? 1 : 0)].'</a>';
597  print "</td>";
598 
599  // Modify link
600  print '<td align="center"><a class="reposition" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>';
601 
602  // Delete link
603  if ($iserasable) print '<td align="center"><a class="reposition" href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a></td>';
604  else print '<td class="center">'.img_delete($langs->trans("DisableSiteFirst"), 'class="opacitymedium"').'</td>';
605 
606  print "</tr>\n";
607  }
608  $i++;
609  }
610 
611  print '</table>';
612 
613  print '</form>';
614  }
615  } else {
616  dol_print_error($db);
617  }
618 }
619 
621 
622 // End of page
623 llxFooter();
624 $db->close();
625 
626 
636 function fieldListWebsites($fieldlist, $obj = '', $tabname = '', $context = '')
637 {
638  global $conf, $langs, $db;
639  global $form;
640  global $region_id;
641  global $elementList, $sourceList, $localtax_typeList;
642  global $bc;
643 
644  $formadmin = new FormAdmin($db);
645 
646  foreach ($fieldlist as $field => $value)
647  {
648  $fieldname = $fieldlist[$field];
649  if ($fieldlist[$field] == 'lang')
650  {
651  print '<td>';
652  print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'lang');
653  print '</td>';
654  } elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldname)) {
655  print '<td><input type="text" class="flat" value="'.(!empty($obj->$fieldname) ? $obj->$fieldname : '').'" size="10" name="'.$fieldlist[$field].'"></td>';
656  } else {
657  print '<td>';
658  $size = '';
659  if ($fieldlist[$field] == 'code') $size = 'size="8" ';
660  if ($fieldlist[$field] == 'position') $size = 'size="4" ';
661  if ($fieldlist[$field] == 'libelle') $size = 'size="32" ';
662  if ($fieldlist[$field] == 'tracking') $size = 'size="92" ';
663  if ($fieldlist[$field] == 'sortorder') $size = 'size="2" ';
664  print '<input type="text" '.$size.' class="flat" value="'.(isset($obj->$fieldname) ? $obj->$fieldname : '').'" name="'.$fieldlist[$field].'">';
665  print '</td>';
666  }
667  }
668 }
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
fieldListWebsites($fieldlist, $obj= '', $tabname= '', $context= '')
Show fields in insert/edit mode.
Definition: website.php:636
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor &quot;?&quot;.
Class Website.
dol_is_dir($folder)
Test if filename is a directory.
Definition: files.lib.php:432
Class to generate html code for admin pages.
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
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&#39;s its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
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:1286
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
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:60
print $_SERVER["PHP_SELF"]
Edit parameters.
dolReplaceInFile($srcfile, $arrayreplacement, $destfile= '', $newmask=0, $indexdatabase=0, $arrayreplacementisregex=0)
Make replacement of strings into a file.
Definition: files.lib.php:585
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.
Definition: index.php:89
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.
Definition: index.php:1232
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 &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
llxFooter()
Empty footer.
Definition: wrapper.php:59
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.