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