websites.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. <?php
  2. /* Copyright (C) 2004-2015 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. /**
  18. * \file htdocs/admin/websites.php
  19. * \ingroup setup
  20. * \brief Page to administer web sites
  21. */
  22. require '../main.inc.php';
  23. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  28. $langs->load("errors");
  29. $langs->load("admin");
  30. $langs->load("companies");
  31. $langs->load("website");
  32. $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
  33. $confirm=GETPOST('confirm','alpha');
  34. $id=GETPOST('id','int');
  35. $rowid=GETPOST('rowid','alpha');
  36. $id=1;
  37. if (!$user->admin) accessforbidden();
  38. $acts[0] = "activate";
  39. $acts[1] = "disable";
  40. $actl[0] = img_picto($langs->trans("Disabled"),'switch_off');
  41. $actl[1] = img_picto($langs->trans("Activated"),'switch_on');
  42. $listoffset=GETPOST('listoffset');
  43. $listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000;
  44. $status = 1;
  45. $sortfield = GETPOST("sortfield",'alpha');
  46. $sortorder = GETPOST("sortorder",'alpha');
  47. $page = GETPOST("page",'int');
  48. if ($page == -1) { $page = 0 ; }
  49. $offset = $listlimit * $page ;
  50. $pageprev = $page - 1;
  51. $pagenext = $page + 1;
  52. // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
  53. $hookmanager->initHooks(array('admin'));
  54. // This page is a generic page to edit dictionaries
  55. // Put here declaration of dictionaries properties
  56. // Name of SQL tables of dictionaries
  57. $tabname=array();
  58. $tabname[1] = MAIN_DB_PREFIX."website";
  59. // Dictionary labels
  60. $tablib=array();
  61. $tablib[1] = "Websites";
  62. // Requests to extract data
  63. $tabsql=array();
  64. $tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.status FROM ".MAIN_DB_PREFIX."website as f";
  65. // Criteria to sort dictionaries
  66. $tabsqlsort=array();
  67. $tabsqlsort[1] ="ref ASC";
  68. // Nom des champs en resultat de select pour affichage du dictionnaire
  69. $tabfield=array();
  70. $tabfield[1] = "ref,description";
  71. // Nom des champs d'edition pour modification d'un enregistrement
  72. $tabfieldvalue=array();
  73. $tabfieldvalue[1] = "ref,description";
  74. // Nom des champs dans la table pour insertion d'un enregistrement
  75. $tabfieldinsert=array();
  76. $tabfieldinsert[1] = "ref,description,entity";
  77. // Nom du rowid si le champ n'est pas de type autoincrement
  78. // Example: "" if id field is "rowid" and has autoincrement on
  79. // "nameoffield" if id field is not "rowid" or has not autoincrement on
  80. $tabrowid=array();
  81. $tabrowid[1] = "";
  82. // Condition to show dictionary in setup page
  83. $tabcond=array();
  84. $tabcond[1] = (! empty($conf->websites->enabled));
  85. // List of help for fields
  86. $tabhelp=array();
  87. $tabhelp[1] = array();
  88. // List of check for fields (NOT USED YET)
  89. $tabfieldcheck=array();
  90. $tabfieldcheck[1] = array();
  91. // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
  92. $elementList = array();
  93. $sourceList=array();
  94. // Actions add or modify an entry into a dictionary
  95. if (GETPOST('actionadd') || GETPOST('actionmodify'))
  96. {
  97. $listfield=explode(',',$tabfield[$id]);
  98. $listfieldinsert=explode(',',$tabfieldinsert[$id]);
  99. $listfieldmodify=explode(',',$tabfieldinsert[$id]);
  100. $listfieldvalue=explode(',',$tabfieldvalue[$id]);
  101. // Check that all fields are filled
  102. $ok=1;
  103. foreach ($listfield as $f => $value)
  104. {
  105. if (! isset($_POST[$value]) || $_POST[$value]=='') // Fields that are not mandatory
  106. {
  107. $ok=0;
  108. $fieldnamekey=$listfield[$f];
  109. setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
  110. }
  111. }
  112. // Si verif ok et action add, on ajoute la ligne
  113. if ($ok && GETPOST('actionadd'))
  114. {
  115. if ($tabrowid[$id])
  116. {
  117. // Recupere id libre pour insertion
  118. $newid=0;
  119. $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
  120. $result = $db->query($sql);
  121. if ($result)
  122. {
  123. $obj = $db->fetch_object($result);
  124. $newid=($obj->newid + 1);
  125. } else {
  126. dol_print_error($db);
  127. }
  128. }
  129. // Add new entry
  130. $sql = "INSERT INTO ".$tabname[$id]." (";
  131. // List of fields
  132. if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
  133. $sql.= $tabrowid[$id].",";
  134. $sql.= $tabfieldinsert[$id];
  135. $sql.=",status)";
  136. $sql.= " VALUES(";
  137. // List of values
  138. if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
  139. $sql.= $newid.",";
  140. $i=0;
  141. foreach ($listfieldinsert as $f => $value)
  142. {
  143. if ($value == 'entity') {
  144. $_POST[$listfieldvalue[$i]] = $conf->entity;
  145. }
  146. if ($i) $sql.=",";
  147. if ($_POST[$listfieldvalue[$i]] == '') $sql.="null";
  148. else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
  149. $i++;
  150. }
  151. $sql.=",1)";
  152. dol_syslog("actionadd", LOG_DEBUG);
  153. $result = $db->query($sql);
  154. if ($result) // Add is ok
  155. {
  156. setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
  157. $_POST=array('id'=>$id); // Clean $_POST array, we keep only
  158. }
  159. else
  160. {
  161. if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
  162. setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
  163. }
  164. else {
  165. dol_print_error($db);
  166. }
  167. }
  168. }
  169. // Si verif ok et action modify, on modifie la ligne
  170. if ($ok && GETPOST('actionmodify'))
  171. {
  172. if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
  173. else { $rowidcol="rowid"; }
  174. // Modify entry
  175. $sql = "UPDATE ".$tabname[$id]." SET ";
  176. // Modifie valeur des champs
  177. if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify))
  178. {
  179. $sql.= $tabrowid[$id]."=";
  180. $sql.= "'".$db->escape($rowid)."', ";
  181. }
  182. $i = 0;
  183. foreach ($listfieldmodify as $field)
  184. {
  185. if ($field == 'entity') {
  186. $_POST[$listfieldvalue[$i]] = $conf->entity;
  187. }
  188. if ($i) $sql.=",";
  189. $sql.= $field."=";
  190. if ($_POST[$listfieldvalue[$i]] == '') $sql.="null";
  191. else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
  192. $i++;
  193. }
  194. $sql.= " WHERE ".$rowidcol." = '".$rowid."'";
  195. dol_syslog("actionmodify", LOG_DEBUG);
  196. //print $sql;
  197. $resql = $db->query($sql);
  198. if (! $resql)
  199. {
  200. setEventMessages($db->error(), null, 'errors');
  201. }
  202. }
  203. //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
  204. }
  205. if (GETPOST('actioncancel'))
  206. {
  207. //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
  208. }
  209. if ($action == 'confirm_delete' && $confirm == 'yes') // delete
  210. {
  211. if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
  212. else { $rowidcol="rowid"; }
  213. $sql = "DELETE from ".MAIN_DB_PREFIX."website_pages WHERE fk_website ='".$rowid."'";
  214. $result = $db->query($sql);
  215. $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'";
  216. $result = $db->query($sql);
  217. if (! $result)
  218. {
  219. if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
  220. {
  221. setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
  222. }
  223. else
  224. {
  225. dol_print_error($db);
  226. }
  227. }
  228. }
  229. // activate
  230. if ($action == $acts[0])
  231. {
  232. if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
  233. else { $rowidcol="rowid"; }
  234. if ($rowid) {
  235. $sql = "UPDATE ".$tabname[$id]." SET status = 1 WHERE rowid ='".$rowid."'";
  236. }
  237. $result = $db->query($sql);
  238. if (!$result)
  239. {
  240. dol_print_error($db);
  241. }
  242. }
  243. // disable
  244. if ($action == $acts[1])
  245. {
  246. if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
  247. else { $rowidcol="rowid"; }
  248. if ($rowid) {
  249. $sql = "UPDATE ".$tabname[$id]." SET status = 0 WHERE rowid ='".$rowid."'";
  250. }
  251. $result = $db->query($sql);
  252. if (!$result)
  253. {
  254. dol_print_error($db);
  255. }
  256. }
  257. /*
  258. * View
  259. */
  260. $form = new Form($db);
  261. $formadmin=new FormAdmin($db);
  262. llxHeader();
  263. $titre=$langs->trans("WebsiteSetup");
  264. $linkback='';
  265. print load_fiche_titre($titre,$linkback,'title_setup');
  266. print $langs->trans("WebsiteSetupDesc").'<br>';
  267. print "<br>\n";
  268. // Confirmation de la suppression de la ligne
  269. if ($action == 'delete')
  270. {
  271. print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&id='.$id, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete','',0,1);
  272. }
  273. //var_dump($elementList);
  274. /*
  275. * Show a dictionary
  276. */
  277. if ($id)
  278. {
  279. // Complete requete recherche valeurs avec critere de tri
  280. $sql=$tabsql[$id];
  281. if ($sortfield)
  282. {
  283. // If sort order is "country", we use country_code instead
  284. $sql.= " ORDER BY ".$sortfield;
  285. if ($sortorder)
  286. {
  287. $sql.=" ".strtoupper($sortorder);
  288. }
  289. $sql.=", ";
  290. // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value
  291. $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]);
  292. $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]);
  293. }
  294. else {
  295. $sql.=" ORDER BY ";
  296. }
  297. $sql.=$tabsqlsort[$id];
  298. $sql.=$db->plimit($listlimit+1,$offset);
  299. //print $sql;
  300. $fieldlist=explode(',',$tabfield[$id]);
  301. print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
  302. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  303. print '<table class="noborder" width="100%">';
  304. // Form to add a new line
  305. if ($tabname[$id])
  306. {
  307. $alabelisused=0;
  308. $var=false;
  309. $fieldlist=explode(',',$tabfield[$id]);
  310. // Line for title
  311. print '<tr class="liste_titre">';
  312. foreach ($fieldlist as $field => $value)
  313. {
  314. // Determine le nom du champ par rapport aux noms possibles
  315. // dans les dictionnaires de donnees
  316. $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
  317. $valuetoshow=$langs->trans($valuetoshow); // try to translate
  318. $align='';
  319. if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
  320. if ($valuetoshow != '')
  321. {
  322. print '<td class="'.$align.'">';
  323. 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>';
  324. else if (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]);
  325. else print $valuetoshow;
  326. print '</td>';
  327. }
  328. if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
  329. }
  330. if ($id == 4) print '<td></td>';
  331. print '<td colspan="4">';
  332. print '<input type="hidden" name="id" value="'.$id.'">';
  333. print '</td>';
  334. print '</tr>';
  335. // Line to enter new values
  336. print "<tr ".$bcnd[$var].">";
  337. $obj = new stdClass();
  338. // If data was already input, we define them in obj to populate input fields.
  339. if (GETPOST('actionadd'))
  340. {
  341. foreach ($fieldlist as $key=>$val)
  342. {
  343. if (GETPOST($val))
  344. $obj->$val=GETPOST($val);
  345. }
  346. }
  347. $tmpaction = 'create';
  348. $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
  349. $reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
  350. $error=$hookmanager->error; $errors=$hookmanager->errors;
  351. if (empty($reshook))
  352. {
  353. fieldListWebsites($fieldlist,$obj,$tabname[$id],'add');
  354. }
  355. print '<td colspan="3" align="right">';
  356. if ($action != 'edit')
  357. {
  358. print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">';
  359. }
  360. print '</td>';
  361. print "</tr>";
  362. $colspan=count($fieldlist)+2;
  363. }
  364. print '</table>';
  365. print '</form>';
  366. // List of available values in database
  367. dol_syslog("htdocs/admin/dict", LOG_DEBUG);
  368. $resql=$db->query($sql);
  369. if ($resql)
  370. {
  371. $num = $db->num_rows($resql);
  372. $i = 0;
  373. if ($num)
  374. {
  375. print '<br>';
  376. print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
  377. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  378. print '<input type="hidden" name="page" value="'.$page.'">';
  379. print '<input type="hidden" name="rowid" value="'.$rowid.'">';
  380. print '<table class="noborder" width="100%">';
  381. // There is several pages
  382. if ($num > $listlimit)
  383. {
  384. print '<tr class="none"><td align="right" colspan="'.(3+count($fieldlist)).'">';
  385. print_fleche_navigation($page, $_SERVER["PHP_SELF"], '&id='.$id, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
  386. print '</td></tr>';
  387. }
  388. // Title of lines
  389. print '<tr class="liste_titre">';
  390. foreach ($fieldlist as $field => $value)
  391. {
  392. // Determine le nom du champ par rapport aux noms possibles
  393. // dans les dictionnaires de donnees
  394. $showfield=1; // Par defaut
  395. $align="left";
  396. $sortable=1;
  397. $valuetoshow='';
  398. /*
  399. $tmparray=getLabelOfField($fieldlist[$field]);
  400. $showfield=$tmp['showfield'];
  401. $valuetoshow=$tmp['valuetoshow'];
  402. $align=$tmp['align'];
  403. $sortable=$tmp['sortable'];
  404. */
  405. $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
  406. $valuetoshow=$langs->trans($valuetoshow); // try to translate
  407. if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
  408. if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
  409. if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
  410. // Affiche nom du champ
  411. if ($showfield)
  412. {
  413. print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':'').'&id='.$id,"","align=".$align,$sortfield,$sortorder);
  414. }
  415. }
  416. print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"status",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder);
  417. print getTitleFieldOfList('');
  418. print getTitleFieldOfList('');
  419. print '</tr>';
  420. // Lines with values
  421. while ($i < $num)
  422. {
  423. $obj = $db->fetch_object($resql);
  424. //print_r($obj);
  425. print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
  426. if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
  427. {
  428. $tmpaction='edit';
  429. $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
  430. $reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
  431. $error=$hookmanager->error; $errors=$hookmanager->errors;
  432. if (empty($reshook)) fieldListWebsites($fieldlist,$obj,$tabname[$id],'edit');
  433. 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").'">';
  434. print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
  435. }
  436. else
  437. {
  438. $tmpaction = 'view';
  439. $parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
  440. $reshook=$hookmanager->executeHooks('viewDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
  441. $error=$hookmanager->error; $errors=$hookmanager->errors;
  442. if (empty($reshook))
  443. {
  444. foreach ($fieldlist as $field => $value)
  445. {
  446. $showfield=1;
  447. $align="left";
  448. $fieldname=$fieldlist[$field];
  449. $valuetoshow=$obj->$fieldname;
  450. // Show value for field
  451. if ($showfield) print '<td align="'.$align.'">'.$valuetoshow.'</td>';
  452. }
  453. }
  454. // Can an entry be erased or disabled ?
  455. $iserasable=1;$isdisable=1; // true by default
  456. $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;id='.$id.'&amp;';
  457. // Active
  458. print '<td align="center" class="nowrap">';
  459. print '<a href="'.$url.'action='.$acts[$obj->status].'">'.$actl[$obj->status].'</a>';
  460. print "</td>";
  461. // Modify link
  462. if ($iserasable) print '<td align="center"><a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a></td>';
  463. else print '<td>&nbsp;</td>';
  464. // Delete link
  465. if ($iserasable) print '<td align="center"><a href="'.$url.'action=delete">'.img_delete().'</a></td>';
  466. else print '<td>&nbsp;</td>';
  467. print "</tr>\n";
  468. }
  469. $i++;
  470. }
  471. print '</table>';
  472. print '</form>';
  473. }
  474. }
  475. else {
  476. dol_print_error($db);
  477. }
  478. }
  479. print '<br>';
  480. llxFooter();
  481. $db->close();
  482. /**
  483. * Show fields in insert/edit mode
  484. *
  485. * @param array $fieldlist Array of fields
  486. * @param Object $obj If we show a particular record, obj is filled with record fields
  487. * @param string $tabname Name of SQL table
  488. * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered
  489. * @return void
  490. */
  491. function fieldListWebsites($fieldlist, $obj='', $tabname='', $context='')
  492. {
  493. global $conf,$langs,$db;
  494. global $form;
  495. global $region_id;
  496. global $elementList,$sourceList,$localtax_typeList;
  497. global $bc;
  498. $formadmin = new FormAdmin($db);
  499. foreach ($fieldlist as $field => $value)
  500. {
  501. $fieldname = $fieldlist[$field];
  502. if ($fieldlist[$field] == 'lang')
  503. {
  504. print '<td>';
  505. print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT,'lang');
  506. print '</td>';
  507. }
  508. elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldname)) {
  509. print '<td><input type="text" class="flat" value="'.(! empty($obj->$fieldname)?$obj->$fieldname:'').'" size="10" name="'.$fieldlist[$field].'"></td>';
  510. }
  511. else
  512. {
  513. print '<td>';
  514. $size='';
  515. if ($fieldlist[$field]=='code') $size='size="8" ';
  516. if ($fieldlist[$field]=='position') $size='size="4" ';
  517. if ($fieldlist[$field]=='libelle') $size='size="32" ';
  518. if ($fieldlist[$field]=='tracking') $size='size="92" ';
  519. if ($fieldlist[$field]=='sortorder') $size='size="2" ';
  520. print '<input type="text" '.$size.' class="flat" value="'.(isset($obj->$fieldname)?$obj->$fieldname:'').'" name="'.$fieldlist[$field].'">';
  521. print '</td>';
  522. }
  523. }
  524. }