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