dolibarr.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <?php
  2. /* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  4. * Copyright (C) 2007-2012 Regis Houssin <regis.houssin@capnetworks.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/admin/system/dolibarr.php
  21. * \brief Page to show Dolibarr informations
  22. */
  23. require '../../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  26. $langs->load("admin");
  27. $langs->load("install");
  28. $langs->load("other");
  29. if (! $user->admin)
  30. accessforbidden();
  31. /*
  32. * View
  33. */
  34. $form=new Form($db);
  35. llxHeader();
  36. print_fiche_titre($langs->trans("InfoDolibarr"),'','setup');
  37. // Version
  38. $var=true;
  39. print '<table class="noborder" width="100%">';
  40. print '<tr class="liste_titre"><td>'.$langs->trans("Version").'</td><td>'.$langs->trans("Value").'</td></tr>'."\n";
  41. $var=!$var;
  42. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("VersionLastInstall").'</td><td>'.$conf->global->MAIN_VERSION_LAST_INSTALL.'</td></tr>'."\n";
  43. $var=!$var;
  44. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("VersionLastUpgrade").'</td><td>'.$conf->global->MAIN_VERSION_LAST_UPGRADE.'</td></tr>'."\n";
  45. $var=!$var;
  46. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("VersionProgram").'</td><td>'.DOL_VERSION;
  47. // If current version differs from last upgrade
  48. if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE))
  49. {
  50. // Compare version with last install database version (upgrades never occured)
  51. if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_INSTALL));
  52. }
  53. else
  54. {
  55. // Compare version with last upgrade database version
  56. if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE));
  57. }
  58. print '</td></tr>'."\n";
  59. print '</table>';
  60. print '<br>';
  61. // Session
  62. $var=true;
  63. print '<table class="noborder" width="100%">';
  64. print '<tr class="liste_titre"><td>'.$langs->trans("Session").'</td><td colspan="2">'.$langs->trans("Value").'</td></tr>'."\n";
  65. $var=!$var;
  66. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("SessionSavePath").'</td><td colspan="2">'.session_save_path().'</td></tr>'."\n";
  67. $var=!$var;
  68. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("SessionName").'</td><td colspan="2">'.session_name().'</td></tr>'."\n";
  69. $var=!$var;
  70. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("SessionId").'</td><td colspan="2">'.session_id().'</td></tr>'."\n";
  71. $var=!$var;
  72. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentSessionTimeOut").'</td><td>'.ini_get('session.gc_maxlifetime').' '.$langs->trans("seconds");
  73. print '</td><td align="right">';
  74. print $form->textwithpicto('',$langs->trans("SessionExplanation",ini_get("session.gc_probability"),ini_get("session.gc_divisor")));
  75. print "</td></tr>\n";
  76. $var=!$var;
  77. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentTheme").'</td><td colspan="2">'.$conf->theme.'</td></tr>'."\n";
  78. $var=!$var;
  79. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentMenuHandler").'</td><td colspan="2">';
  80. print $conf->standard_menu;
  81. print '</td></tr>'."\n";
  82. $var=!$var;
  83. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("Screen").'</td><td colspan="2">';
  84. print $_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight'];
  85. print '</td></tr>'."\n";
  86. $var=!$var;
  87. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("Session").'</td><td colspan="2">';
  88. $i=0;
  89. foreach($_SESSION as $key => $val)
  90. {
  91. if ($i > 0) print ', ';
  92. print $key.' => '.$val;
  93. $i++;
  94. }
  95. print '</td></tr>'."\n";
  96. print '</table>';
  97. print '<br>';
  98. // Shmop
  99. if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
  100. {
  101. $shmoparray=dol_listshmop();
  102. $var=true;
  103. print '<table class="noborder" width="100%">';
  104. print '<tr class="liste_titre">';
  105. print '<td>'.$langs->trans("LanguageFilesCachedIntoShmopSharedMemory").'</td>';
  106. print '<td>'.$langs->trans("NbOfEntries").'</td>';
  107. print '<td align="right">'.$langs->trans("Address").'</td>';
  108. print '</tr>'."\n";
  109. foreach($shmoparray as $key => $val)
  110. {
  111. $var=!$var;
  112. print '<tr '.$bc[$var].'><td width="300">'.$key.'</td>';
  113. print '<td>'.count($val).'</td>';
  114. print '<td align="right">'.dol_getshmopaddress($key).'</td>';
  115. print '</tr>'."\n";
  116. }
  117. print '</table>';
  118. print '<br>';
  119. }
  120. // Localisation
  121. $var=true;
  122. print '<table class="noborder" width="100%">';
  123. print '<tr class="liste_titre"><td>'.$langs->trans("LocalisationDolibarrParameters").'</td><td>'.$langs->trans("Value").'</td></tr>'."\n";
  124. $var=!$var;
  125. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("LanguageBrowserParameter","HTTP_ACCEPT_LANGUAGE").'</td><td>'.$_SERVER["HTTP_ACCEPT_LANGUAGE"].'</td></tr>'."\n";
  126. $var=!$var;
  127. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentUserLanguage").'</td><td>'.$langs->getDefaultLang().'</td></tr>'."\n";
  128. // Thousands
  129. $var=!$var;
  130. $thousand=$langs->transnoentitiesnoconv("SeparatorThousand");
  131. if ($thousand == 'SeparatorThousand') $thousand=' '; // ' ' does not work on trans method
  132. if ($thousand == 'None') $thousand='';
  133. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentValueSeparatorThousand").'</td><td>'.($thousand==' '?$langs->transnoentitiesnoconv("Space"):$thousand).'</td></tr>'."\n";
  134. // Decimals
  135. $var=!$var;
  136. $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");
  137. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentValueSeparatorDecimal").'</td><td>'.$dec.'</td></tr>'."\n";
  138. // Show results of functions to see if everything works
  139. $var=!$var;
  140. print '<tr '.$bc[$var].'><td width="300">&nbsp; => price2num(1233.56+1)</td><td>'.price2num(1233.56+1,'2').'</td></tr>'."\n";
  141. $var=!$var;
  142. print "<tr ".$bc[$var].'><td width="300">&nbsp; => price2num('."'1".$thousand."234".$dec."56')</td><td>".price2num("1".$thousand."234".$dec."56",'2')."</td></tr>\n";
  143. if (($thousand != ',' && $thousand != '.') || ($thousand != ' '))
  144. {
  145. $var=!$var;
  146. print "<tr ".$bc[$var].'><td width="300">&nbsp; => price2num('."'1 234.56')</td><td>".price2num("1 234.56",'2')."</td>";
  147. print "</tr>\n";
  148. }
  149. $var=!$var;
  150. print '<tr '.$bc[$var].'><td width="300">&nbsp; => price(1234.56)</td><td>'.price(1234.56).'</td></tr>'."\n";
  151. // Timezone
  152. $txt =$langs->trans("OSTZ").' (variable system TZ): '.(! empty($_ENV["TZ"])?$_ENV["TZ"]:$langs->trans("NotDefined")).'<br>'."\n";
  153. $txt.=$langs->trans("PHPTZ").' (php.ini date.timezone): '.(ini_get("date.timezone")?ini_get("date.timezone"):$langs->trans("NotDefined")).''."<br>\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php
  154. $txt.=$langs->trans("Dolibarr constant MAIN_SERVER_TZ").': '.(empty($conf->global->MAIN_SERVER_TZ)?$langs->trans("NotDefined"):$conf->global->MAIN_SERVER_TZ);
  155. //$txt.=$langs->trans("YouCanEditPHPTZ"); // deprecated
  156. $var=!$var;
  157. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentTimeZone").'</td><td>'; // Timezone server PHP
  158. $a=getServerTimeZoneInt('now');
  159. $b=getServerTimeZoneInt('winter');
  160. $c=getServerTimeZoneInt('summer');
  161. $daylight=(is_numeric($c) && is_numeric($b))?round($c-$b):'unknown';
  162. //print $a." ".$b." ".$c." ".$daylight;
  163. $val=($a>=0?'+':'').$a;
  164. $val.=' ('.($a==='unknown'?'unknown':($a>=0?'+':'').($a*3600)).')';
  165. $val.=' &nbsp; &nbsp; &nbsp; '.getServerTimeZoneString();
  166. $val.=' &nbsp; &nbsp; &nbsp; '.$langs->trans("DaylingSavingTime").': '.($daylight==='unknown'?'unknown':($a==$c?yn($daylight):yn(0).($daylight?' &nbsp; &nbsp; ('.$langs->trans('YesInSummer').')':'')));
  167. print $form->textwithtooltip($val,$txt,2,1,img_info(''));
  168. print '</td></tr>'."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php
  169. $var=!$var;
  170. print '<tr '.$bc[$var].'><td width="300">&nbsp; => '.$langs->trans("CurrentHour").'</td><td>'.dol_print_date(dol_now(),'dayhour','tzserver').'</td></tr>'."\n";
  171. $var=!$var;
  172. print '<tr '.$bc[$var].'><td width="300">&nbsp; => dol_print_date(0,"dayhourtext")</td><td>'.dol_print_date(0,"dayhourtext").'</td>';
  173. $var=!$var;
  174. print '<tr '.$bc[$var].'><td width="300">&nbsp; => dol_get_first_day(1970,1,false)</td><td>'.dol_get_first_day(1970,1,false).' &nbsp; &nbsp; (=> dol_print_date() or idate() of this value = '.dol_print_date(dol_get_first_day(1970,1,false),'dayhour').')</td>';
  175. $var=!$var;
  176. print '<tr '.$bc[$var].'><td width="300">&nbsp; => dol_get_first_day(1970,1,true)</td><td>'.dol_get_first_day(1970,1,true).' &nbsp; &nbsp; (=> dol_print_date() or idate() of this value = '.dol_print_date(dol_get_first_day(1970,1,true),'dayhour').')</td>';
  177. // Database timezone
  178. if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli')
  179. {
  180. $var=!$var;
  181. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("MySQLTimeZone").' (database)</td><td>'; // Timezone server base
  182. $sql="SHOW VARIABLES where variable_name = 'system_time_zone'";
  183. $resql = $db->query($sql);
  184. if ($resql)
  185. {
  186. $obj = $db->fetch_object($resql);
  187. print $form->textwithtooltip($obj->Value,$langs->trans('TZHasNoEffect'),2,1,img_info(''));
  188. }
  189. print '</td></tr>'."\n";
  190. }
  191. // Client
  192. $var=!$var;
  193. $tz=(int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst'];
  194. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("ClientTZ").'</td><td>'.($tz?($tz>=0?'+':'').$tz:'').' ('.($tz>=0?'+':'').($tz*60*60).')';
  195. print ' &nbsp; &nbsp; &nbsp; '.$_SESSION['dol_tz_string'];
  196. print ' &nbsp; &nbsp; &nbsp; '.$langs->trans("DaylingSavingTime").': ';
  197. if ($_SESSION['dol_dst']>0) print yn(1);
  198. else print yn(0);
  199. if (! empty($_SESSION['dol_dst_first'])) print ' &nbsp; &nbsp; ('.dol_print_date(dol_stringtotime($_SESSION['dol_dst_first']),'dayhour','gmt').' - '.dol_print_date(dol_stringtotime($_SESSION['dol_dst_second']),'dayhour','gmt').')';
  200. print '</td></tr>'."\n";
  201. print '</td></tr>'."\n";
  202. $var=!$var;
  203. print '<tr '.$bc[$var].'><td width="300">&nbsp; => '.$langs->trans("ClientHour").'</td><td>'.dol_print_date(dol_now(),'dayhour','tzuser').'</td></tr>'."\n";
  204. $var=!$var;
  205. $filesystemencoding=ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0
  206. print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("File encoding").' (php.ini unicode.filesystem_encoding)</td><td>'.$filesystemencoding.'</td></tr>'."\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php
  207. $var=!$var;
  208. $tmp=ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0
  209. if (empty($tmp) && ! empty($_SERVER["WINDIR"])) $tmp='iso-8859-1'; // By default for windows
  210. if (empty($tmp)) $tmp='utf-8'; // By default for other
  211. if (! empty($conf->global->MAIN_FILESYSTEM_ENCODING)) $tmp=$conf->global->MAIN_FILESYSTEM_ENCODING;
  212. print '<tr '.$bc[$var].'><td width="300">&nbsp; => '.$langs->trans("File encoding").'</td><td>'.$tmp.'</td></tr>'."\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php
  213. print '</table>';
  214. print '<br>';
  215. // Parameters in conf.php file (when a parameter start with ?, it is shown only if defined)
  216. $configfileparameters=array(
  217. 'dolibarr_main_url_root' => $langs->trans("URLRoot"),
  218. '?dolibarr_main_url_root_alt' => $langs->trans("URLRoot").' (alt)',
  219. 'dolibarr_main_document_root'=> $langs->trans("DocumentRootServer"),
  220. '?dolibarr_main_document_root_alt' => $langs->trans("DocumentRootServer").' (alt)',
  221. 'dolibarr_main_data_root' => $langs->trans("DataRootServer"),
  222. 'separator1' => '',
  223. 'dolibarr_main_db_host' => $langs->trans("DatabaseServer"),
  224. 'dolibarr_main_db_port' => $langs->trans("DatabasePort"),
  225. 'dolibarr_main_db_name' => $langs->trans("DatabaseName"),
  226. 'dolibarr_main_db_type' => $langs->trans("DriverType"),
  227. 'dolibarr_main_db_user' => $langs->trans("DatabaseUser"),
  228. 'dolibarr_main_db_pass' => $langs->trans("DatabasePassword"),
  229. 'dolibarr_main_db_character_set' => $langs->trans("DBStoringCharset"),
  230. 'dolibarr_main_db_collation' => $langs->trans("DBSortingCollation"),
  231. '?dolibarr_main_db_prefix' => $langs->trans("Prefix"),
  232. 'separator2' => '',
  233. 'dolibarr_main_authentication' => $langs->trans("AuthenticationMode"),
  234. 'separator'=> '',
  235. '?dolibarr_main_auth_ldap_login_attribute' => 'dolibarr_main_auth_ldap_login_attribute',
  236. '?dolibarr_main_auth_ldap_host' => 'dolibarr_main_auth_ldap_host',
  237. '?dolibarr_main_auth_ldap_port' => 'dolibarr_main_auth_ldap_port',
  238. '?dolibarr_main_auth_ldap_version' => 'dolibarr_main_auth_ldap_version',
  239. '?dolibarr_main_auth_ldap_dn' => 'dolibarr_main_auth_ldap_dn',
  240. '?dolibarr_main_auth_ldap_admin_login' => 'dolibarr_main_auth_ldap_admin_login',
  241. '?dolibarr_main_auth_ldap_admin_pass' => 'dolibarr_main_auth_ldap_admin_pass',
  242. '?dolibarr_main_auth_ldap_debug' => 'dolibarr_main_auth_ldap_debug',
  243. 'separator3' => '',
  244. '?dolibarr_lib_ADODB_PATH' => 'dolibarr_lib_ADODB_PATH',
  245. '?dolibarr_lib_FPDF_PATH' => 'dolibarr_lib_FPDF_PATH',
  246. '?dolibarr_lib_TCPDF_PATH' => 'dolibarr_lib_TCPDF_PATH',
  247. '?dolibarr_lib_FPDI_PATH' => 'dolibarr_lib_FPDI_PATH',
  248. '?dolibarr_lib_TCPDI_PATH' => 'dolibarr_lib_TCPDI_PATH',
  249. '?dolibarr_lib_NUSOAP_PATH' => 'dolibarr_lib_NUSOAP_PATH',
  250. '?dolibarr_lib_PHPEXCEL_PATH' => 'dolibarr_lib_PHPEXCEL_PATH',
  251. '?dolibarr_lib_GEOIP_PATH' => 'dolibarr_lib_GEOIP_PATH',
  252. '?dolibarr_lib_ODTPHP_PATH' => 'dolibarr_lib_ODTPHP_PATH',
  253. '?dolibarr_lib_ODTPHP_PATHTOPCLZIP' => 'dolibarr_lib_ODTPHP_PATHTOPCLZIP',
  254. '?dolibarr_js_CKEDITOR' => 'dolibarr_js_CKEDITOR',
  255. '?dolibarr_js_JQUERY' => 'dolibarr_js_JQUERY',
  256. '?dolibarr_js_JQUERY_UI' => 'dolibarr_js_JQUERY_UI',
  257. '?dolibarr_js_JQUERY_FLOT' => 'dolibarr_js_JQUERY_FLOT',
  258. '?dolibarr_font_DOL_DEFAULT_TTF' => 'dolibarr_font_DOL_DEFAULT_TTF',
  259. '?dolibarr_font_DOL_DEFAULT_TTF_BOLD' => 'dolibarr_font_DOL_DEFAULT_TTF_BOLD',
  260. 'separator4' => '',
  261. 'dolibarr_main_prod' => 'Production mode (Hide all error messages)',
  262. '?dolibarr_mailing_limit_sendbyweb' => 'Limit nb of email sent by page',
  263. '?dolibarr_strict_mode' => 'Strict mode is on/off',
  264. '?dolibarr_pdf_force_fpdf' => 'Force fpdf usage to generate PDF'
  265. );
  266. $var=true;
  267. print '<table class="noborder" width="100%">';
  268. print '<tr class="liste_titre">';
  269. print '<td width="300">'.$langs->trans("Parameters").' ';
  270. print $langs->trans("ConfigurationFile").' ('.$conffiletoshowshort.')';
  271. print '</td>';
  272. print '<td>'.$langs->trans("Parameter").'</td>';
  273. print '<td>'.$langs->trans("Value").'</td>';
  274. print '</tr>'."\n";
  275. foreach($configfileparameters as $key => $value)
  276. {
  277. $ignore=0;
  278. if (empty($ignore))
  279. {
  280. $newkey = preg_replace('/^\?/','',$key);
  281. if (preg_match('/^\?/',$key) && empty(${$newkey})) continue; // We discard parametes starting with ?
  282. if (strpos($newkey, 'separator') !== false && $lastkeyshown == 'separator') continue;
  283. $var=!$var;
  284. print "<tr ".$bc[$var].">";
  285. if (strpos($newkey, 'separator') !== false)
  286. {
  287. print '<td colspan="3">&nbsp;</td>';
  288. }
  289. else
  290. {
  291. // Label
  292. print "<td>".$value.'</td>';
  293. // Key
  294. print '<td>'.$newkey.'</td>';
  295. // Value
  296. print "<td>";
  297. if ($newkey == 'dolibarr_main_db_pass') print preg_replace('/./i','*',${$newkey});
  298. else if ($newkey == 'dolibarr_main_url_root' && preg_match('/__auto__/',${$newkey})) print ${$newkey}.' => '.constant('DOL_MAIN_URL_ROOT');
  299. else if ($newkey == 'dolibarr_main_document_root_alt')
  300. {
  301. $tmparray=explode(',',${$newkey});
  302. $i=0;
  303. foreach($tmparray as $value2)
  304. {
  305. if ($i > 0) print ', ';
  306. print $value2;
  307. if (! is_readable($value2))
  308. {
  309. $langs->load("errors");
  310. print ' '.img_warning($langs->trans("ErrorCantReadDir",$value2));
  311. }
  312. ++$i;
  313. }
  314. }
  315. else print ${$newkey};
  316. if ($newkey == 'dolibarr_main_url_root' && $newkey != DOL_MAIN_URL_ROOT) print ' (currently overwritten by autodetected value: '.DOL_MAIN_URL_ROOT.')';
  317. print "</td>";
  318. }
  319. print "</tr>\n";
  320. $lastkeyshown=$newkey;
  321. }
  322. }
  323. print '</table>';
  324. print '<br>';
  325. // Parameters in database
  326. print '<table class="noborder">';
  327. print '<tr class="liste_titre">';
  328. print '<td>'.$langs->trans("Parameters").' '.$langs->trans("Database").'</td>';
  329. print '<td>'.$langs->trans("Value").'</td>';
  330. if (empty($conf->multicompany->enabled) || !$user->entity) print '<td align="center">'.$langs->trans("Entity").'</td>'; // If superadmin or multicompany disabled
  331. print "</tr>\n";
  332. $sql = "SELECT";
  333. $sql.= " rowid";
  334. $sql.= ", ".$db->decrypt('name')." as name";
  335. $sql.= ", ".$db->decrypt('value')." as value";
  336. $sql.= ", type";
  337. $sql.= ", note";
  338. $sql.= ", entity";
  339. $sql.= " FROM ".MAIN_DB_PREFIX."const";
  340. if (empty($conf->multicompany->enabled))
  341. {
  342. // If no multicompany mode, admins can see global and their constantes
  343. $sql.= " WHERE entity IN (0,".$conf->entity.")";
  344. }
  345. else
  346. {
  347. // If multicompany mode, superadmin (user->entity=0) can see everything, admin are limited to their entities.
  348. if ($user->entity) $sql.= " WHERE entity IN (".$user->entity.",".$conf->entity.")";
  349. }
  350. $sql.= " ORDER BY entity, name ASC";
  351. $resql = $db->query($sql);
  352. if ($resql)
  353. {
  354. $num = $db->num_rows($resql);
  355. $i = 0;
  356. $var=True;
  357. while ($i < $num)
  358. {
  359. $obj = $db->fetch_object($resql);
  360. $var=!$var;
  361. print '<tr '.$bc[$var].'>';
  362. print '<td>'.$obj->name.'</td>'."\n";
  363. print '<td>'.$obj->value.'</td>'."\n";
  364. if (empty($conf->multicompany->enabled) || !$user->entity) print '<td align="center">'.$obj->entity.'</td>'."\n"; // If superadmin or multicompany disabled
  365. print "</tr>\n";
  366. $i++;
  367. }
  368. }
  369. print '</table>';
  370. llxFooter();
  371. $db->close();