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