societe.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  4. * Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/societe/admin/societe.php
  23. * \ingroup company
  24. * \brief Third party module setup page
  25. */
  26. require '../../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  30. $langs->loadLangs(array("admin", "companies", "other"));
  31. $action = GETPOST('action', 'aZ09');
  32. $value = GETPOST('value', 'alpha');
  33. if (!$user->admin) {
  34. accessforbidden();
  35. }
  36. $formcompany = new FormCompany($db);
  37. /*
  38. * Actions
  39. */
  40. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  41. if ($action == 'setcodeclient') {
  42. if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) {
  43. header("Location: ".$_SERVER["PHP_SELF"]);
  44. exit;
  45. } else {
  46. dol_print_error($db);
  47. }
  48. }
  49. if ($action == 'setcodecompta') {
  50. if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) {
  51. header("Location: ".$_SERVER["PHP_SELF"]);
  52. exit;
  53. } else {
  54. dol_print_error($db);
  55. }
  56. }
  57. if ($action == 'updateoptions') {
  58. if (GETPOST('COMPANY_USE_SEARCH_TO_SELECT')) {
  59. $companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT', 'alpha');
  60. $res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch, 'chaine', 0, '', $conf->entity);
  61. if (!($res > 0)) {
  62. $error++;
  63. }
  64. if (!$error) {
  65. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  66. } else {
  67. setEventMessages($langs->trans("Error"), null, 'errors');
  68. }
  69. }
  70. if (GETPOST('CONTACT_USE_SEARCH_TO_SELECT')) {
  71. $contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT', 'alpha');
  72. $res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch, 'chaine', 0, '', $conf->entity);
  73. if (!($res > 0)) {
  74. $error++;
  75. }
  76. if (!$error) {
  77. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  78. } else {
  79. setEventMessages($langs->trans("Error"), null, 'errors');
  80. }
  81. }
  82. if (GETPOST('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')) {
  83. $customertypedefault = GETPOST('defaultcustomertype', 'int');
  84. $res = dolibarr_set_const($db, "THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT", $customertypedefault, 'chaine', 0, '', $conf->entity);
  85. if (!($res > 0)) {
  86. $error++;
  87. }
  88. if (!$error) {
  89. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  90. } else {
  91. setEventMessages($langs->trans("Error"), null, 'errors');
  92. }
  93. }
  94. }
  95. // Activate a document generator module
  96. if ($action == 'set') {
  97. $label = GETPOST('label', 'alpha');
  98. $scandir = GETPOST('scan_dir', 'alpha');
  99. $type = 'company';
  100. $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
  101. $sql .= " VALUES ('".$db->escape($value)."', '".$db->escape($type)."', ".((int) $conf->entity).", ";
  102. $sql .= ($label ? "'".$db->escape($label)."'" : 'null').", ";
  103. $sql .= (!empty($scandir) ? "'".$db->escape($scandir)."'" : "null");
  104. $sql .= ")";
  105. $resql = $db->query($sql);
  106. if (!$resql) {
  107. dol_print_error($db);
  108. }
  109. }
  110. // Disable a document generator module
  111. if ($action == 'del') {
  112. $type = 'company';
  113. $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
  114. $sql .= " WHERE nom='".$db->escape($value)."' AND type='".$db->escape($type)."' AND entity=".((int) $conf->entity);
  115. $resql = $db->query($sql);
  116. if (!$resql) {
  117. dol_print_error($db);
  118. }
  119. }
  120. // Define default generator
  121. if ($action == 'setdoc') {
  122. $label = GETPOST('label', 'alpha');
  123. $scandir = GETPOST('scan_dir', 'alpha');
  124. $db->begin();
  125. dolibarr_set_const($db, "COMPANY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity);
  126. // On active le modele
  127. $type = 'company';
  128. $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
  129. $sql_del .= " WHERE nom = '".$db->escape(GETPOST('value', 'alpha'))."'";
  130. $sql_del .= " AND type = '".$db->escape($type)."'";
  131. $sql_del .= " AND entity = ".((int) $conf->entity);
  132. dol_syslog("societe.php ".$sql);
  133. $result1 = $db->query($sql_del);
  134. $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
  135. $sql .= " VALUES ('".$db->escape($value)."', '".$db->escape($type)."', ".((int) $conf->entity).", ";
  136. $sql .= ($label ? "'".$db->escape($label)."'" : 'null').", ";
  137. $sql .= (!empty($scandir) ? "'".$db->escape($scandir)."'" : "null");
  138. $sql .= ")";
  139. dol_syslog("societe.php", LOG_DEBUG);
  140. $result2 = $db->query($sql);
  141. if ($result1 && $result2) {
  142. $db->commit();
  143. } else {
  144. $db->rollback();
  145. }
  146. }
  147. //Activate Set ref in list
  148. if ($action == "setaddrefinlist") {
  149. $setaddrefinlist = GETPOST('value', 'int');
  150. $res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist, 'yesno', 0, '', $conf->entity);
  151. if (!($res > 0)) {
  152. $error++;
  153. }
  154. if (!$error) {
  155. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  156. } else {
  157. setEventMessages($langs->trans("Error"), null, 'errors');
  158. }
  159. }
  160. //Activate Set adress in list
  161. if ($action == "setaddadressinlist") {
  162. $val = GETPOST('value', 'int');
  163. $res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val, 'yesno', 0, '', $conf->entity);
  164. if (!($res > 0)) {
  165. $error++;
  166. }
  167. if (!$error) {
  168. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  169. } else {
  170. setEventMessages($langs->trans("Error"), null, 'errors');
  171. }
  172. }
  173. //Activate Set email phone town in contact list
  174. if ($action == "setaddemailphonetownincontactlist") {
  175. $val = GETPOST('value', 'int');
  176. $res = dolibarr_set_const($db, "CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST", $val, 'yesno', 0, '', $conf->entity);
  177. if (!($res > 0)) {
  178. $error++;
  179. }
  180. if (!$error) {
  181. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  182. } else {
  183. setEventMessages($langs->trans("Error"), null, 'errors');
  184. }
  185. }
  186. //Activate Ask For Preferred Shipping Method
  187. if ($action == "setaskforshippingmet") {
  188. $setaskforshippingmet = GETPOST('value', 'int');
  189. $res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet, 'yesno', 0, '', $conf->entity);
  190. if (!($res > 0)) {
  191. $error++;
  192. }
  193. if (!$error) {
  194. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  195. } else {
  196. setEventMessages($langs->trans("Error"), null, 'errors');
  197. }
  198. }
  199. //Activate "Disable prospect/customer type"
  200. if ($action == "setdisableprospectcustomer") {
  201. $setdisableprospectcustomer = GETPOST('value', 'int');
  202. $res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer, 'yesno', 0, '', $conf->entity);
  203. if (!($res > 0)) {
  204. $error++;
  205. }
  206. if (!$error) {
  207. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  208. } else {
  209. setEventMessages($langs->trans("Error"), null, 'errors');
  210. }
  211. }
  212. //Activate ProfId unique
  213. if ($action == 'setprofid') {
  214. $status = GETPOST('status', 'alpha');
  215. $idprof = "SOCIETE_".$value."_UNIQUE";
  216. if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) {
  217. //header("Location: ".$_SERVER["PHP_SELF"]);
  218. //exit;
  219. } else {
  220. dol_print_error($db);
  221. }
  222. }
  223. //Activate ProfId mandatory
  224. if ($action == 'setprofidmandatory') {
  225. $status = GETPOST('status', 'alpha');
  226. $idprof = "SOCIETE_".$value."_MANDATORY";
  227. if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) {
  228. //header("Location: ".$_SERVER["PHP_SELF"]);
  229. //exit;
  230. } else {
  231. dol_print_error($db);
  232. }
  233. }
  234. //Activate ProfId invoice mandatory
  235. if ($action == 'setprofidinvoicemandatory') {
  236. $status = GETPOST('status', 'alpha');
  237. $idprof = "SOCIETE_".$value."_INVOICE_MANDATORY";
  238. if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) {
  239. //header("Location: ".$_SERVER["PHP_SELF"]);
  240. //exit;
  241. } else {
  242. dol_print_error($db);
  243. }
  244. }
  245. //Set hide closed customer into combox or select
  246. if ($action == 'sethideinactivethirdparty') {
  247. $status = GETPOST('status', 'alpha');
  248. if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) {
  249. header("Location: ".$_SERVER["PHP_SELF"]);
  250. exit;
  251. } else {
  252. dol_print_error($db);
  253. }
  254. }
  255. if ($action == 'setonsearchandlistgooncustomerorsuppliercard') {
  256. $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int');
  257. $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity);
  258. if (!($res > 0)) {
  259. $error++;
  260. }
  261. if (!$error) {
  262. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  263. } else {
  264. setEventMessages($langs->trans("Error"), null, 'errors');
  265. }
  266. }
  267. /*
  268. * View
  269. */
  270. clearstatcache();
  271. $form = new Form($db);
  272. $help_url = 'EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers|ES:Configuración_del_módulo_terceros';
  273. llxHeader('', $langs->trans("CompanySetup"), $help_url);
  274. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  275. print load_fiche_titre($langs->trans("CompanySetup"), $linkback, 'title_setup');
  276. $head = societe_admin_prepare_head();
  277. print dol_get_fiche_head($head, 'general', $langs->trans("ThirdParties"), -1, 'company');
  278. $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
  279. foreach ($conf->modules_parts['models'] as $mo) {
  280. $dirsociete[] = $mo.'core/modules/societe/'; //Add more models
  281. }
  282. // Module to manage customer/supplier code
  283. print load_fiche_titre($langs->trans("CompanyCodeChecker"), '', '');
  284. print '<div class="div-table-responsive-no-min">';
  285. print '<table class="noborder centpercent">'."\n";
  286. print '<tr class="liste_titre">'."\n";
  287. print ' <td>'.$langs->trans("Name").'</td>';
  288. print ' <td>'.$langs->trans("Description").'</td>';
  289. print ' <td>'.$langs->trans("Example").'</td>';
  290. print ' <td class="center" width="80">'.$langs->trans("Status").'</td>';
  291. print ' <td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
  292. print "</tr>\n";
  293. $arrayofmodules = array();
  294. foreach ($dirsociete as $dirroot) {
  295. $dir = dol_buildpath($dirroot, 0);
  296. $handle = @opendir($dir);
  297. if (is_resource($handle)) {
  298. // Loop on each module find in opened directory
  299. while (($file = readdir($handle)) !== false) {
  300. if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php') {
  301. $file = substr($file, 0, dol_strlen($file) - 4);
  302. try {
  303. dol_include_once($dirroot.$file.'.php');
  304. } catch (Exception $e) {
  305. dol_syslog($e->getMessage(), LOG_ERR);
  306. }
  307. $modCodeTiers = new $file;
  308. // Show modules according to features level
  309. if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  310. continue;
  311. }
  312. if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  313. continue;
  314. }
  315. $arrayofmodules[$file] = $modCodeTiers;
  316. }
  317. }
  318. closedir($handle);
  319. }
  320. }
  321. $arrayofmodules = dol_sort_array($arrayofmodules, 'position');
  322. foreach ($arrayofmodules as $file => $modCodeTiers) {
  323. print '<tr class="oddeven">'."\n";
  324. print '<td width="140">'.$modCodeTiers->name.'</td>'."\n";
  325. print '<td>'.$modCodeTiers->info($langs).'</td>'."\n";
  326. print '<td class="nowrap">'.$modCodeTiers->getExample($langs).'</td>'."\n";
  327. if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file") {
  328. print '<td class="center">'."\n";
  329. print img_picto($langs->trans("Activated"), 'switch_on');
  330. print "</td>\n";
  331. } else {
  332. $disabled = (!empty($conf->multicompany->enabled) && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false);
  333. print '<td class="center">';
  334. if (!$disabled) {
  335. print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&token='.newToken().'&value='.urlencode($file).'">';
  336. }
  337. print img_picto($langs->trans("Disabled"), 'switch_off');
  338. if (!$disabled) {
  339. print '</a>';
  340. }
  341. print '</td>';
  342. }
  343. print '<td class="center">';
  344. $s = $modCodeTiers->getToolTip($langs, null, -1);
  345. print $form->textwithpicto('', $s, 1);
  346. print '</td>';
  347. print '</tr>';
  348. }
  349. print '</table>';
  350. print '</div>';
  351. print "<br>";
  352. // Select accountancy code numbering module
  353. print load_fiche_titre($langs->trans("AccountCodeManager"), '', '');
  354. print '<div class="div-table-responsive-no-min">';
  355. print '<table class="noborder centpercent">';
  356. print '<tr class="liste_titre">';
  357. print '<td width="140">'.$langs->trans("Name").'</td>';
  358. print '<td>'.$langs->trans("Description").'</td>';
  359. print '<td>'.$langs->trans("Example").'</td>';
  360. print '<td class="center" width="80">'.$langs->trans("Status").'</td>';
  361. print '<td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
  362. print "</tr>\n";
  363. $arrayofmodules = array();
  364. foreach ($dirsociete as $dirroot) {
  365. $dir = dol_buildpath($dirroot, 0);
  366. $handle = @opendir($dir);
  367. if (is_resource($handle)) {
  368. while (($file = readdir($handle)) !== false) {
  369. if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php') {
  370. $file = substr($file, 0, dol_strlen($file) - 4);
  371. try {
  372. dol_include_once($dirroot.$file.'.php');
  373. } catch (Exception $e) {
  374. dol_syslog($e->getMessage(), LOG_ERR);
  375. }
  376. $modCodeCompta = new $file;
  377. $arrayofmodules[$file] = $modCodeCompta;
  378. }
  379. }
  380. closedir($handle);
  381. }
  382. }
  383. $arrayofmodules = dol_sort_array($arrayofmodules, 'position');
  384. foreach ($arrayofmodules as $file => $modCodeCompta) {
  385. print '<tr class="oddeven">';
  386. print '<td>'.$modCodeCompta->name."</td><td>\n";
  387. print $modCodeCompta->info($langs);
  388. print '</td>';
  389. print '<td class="nowrap">'.$modCodeCompta->getExample($langs)."</td>\n";
  390. if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file") {
  391. print '<td class="center">';
  392. print img_picto($langs->trans("Activated"), 'switch_on');
  393. print '</td>';
  394. } else {
  395. print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodecompta&token='.newToken().'&value='.urlencode($file).'">';
  396. print img_picto($langs->trans("Disabled"), 'switch_off');
  397. print '</a></td>';
  398. }
  399. print '<td class="center">';
  400. $s = $modCodeCompta->getToolTip($langs, null, -1);
  401. print $form->textwithpicto('', $s, 1);
  402. print '</td>';
  403. print "</tr>\n";
  404. }
  405. print "</table>\n";
  406. print '</div>';
  407. /*
  408. * Document templates generators
  409. */
  410. print '<br>';
  411. print load_fiche_titre($langs->trans("ModelModules"), '', '');
  412. // Load array def with activated templates
  413. $def = array();
  414. $sql = "SELECT nom";
  415. $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
  416. $sql .= " WHERE type = 'company'";
  417. $sql .= " AND entity = ".$conf->entity;
  418. $resql = $db->query($sql);
  419. if ($resql) {
  420. $i = 0;
  421. $num_rows = $db->num_rows($resql);
  422. while ($i < $num_rows) {
  423. $array = $db->fetch_array($resql);
  424. array_push($def, $array[0]);
  425. $i++;
  426. }
  427. } else {
  428. dol_print_error($db);
  429. }
  430. print '<div class="div-table-responsive-no-min">';
  431. print '<table class="noborder centpercent">';
  432. print '<tr class="liste_titre">';
  433. print '<td width="140">'.$langs->trans("Name").'</td>';
  434. print '<td>'.$langs->trans("Description").'</td>';
  435. print '<td class="center" width="80">'.$langs->trans("Status").'</td>';
  436. print '<td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
  437. print '<td class="center" width="60">'.$langs->trans("Preview").'</td>';
  438. print "</tr>\n";
  439. foreach ($dirsociete as $dirroot) {
  440. $dir = dol_buildpath($dirroot.'doc/', 0);
  441. $handle = @opendir($dir);
  442. if (is_resource($handle)) {
  443. while (($file = readdir($handle)) !== false) {
  444. if (preg_match('/\.modules\.php$/i', $file)) {
  445. $name = substr($file, 4, dol_strlen($file) - 16);
  446. $classname = substr($file, 0, dol_strlen($file) - 12);
  447. try {
  448. dol_include_once($dirroot.'doc/'.$file);
  449. } catch (Exception $e) {
  450. dol_syslog($e->getMessage(), LOG_ERR);
  451. }
  452. $module = new $classname($db);
  453. $modulequalified = 1;
  454. if (!empty($module->version)) {
  455. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  456. $modulequalified = 0;
  457. } elseif ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  458. $modulequalified = 0;
  459. }
  460. }
  461. if ($modulequalified) {
  462. print '<tr class="oddeven"><td width="100">';
  463. print $module->name;
  464. print "</td><td>\n";
  465. if (method_exists($module, 'info')) {
  466. print $module->info($langs);
  467. } else {
  468. print $module->description;
  469. }
  470. print '</td>';
  471. // Activate / Disable
  472. if (in_array($name, $def)) {
  473. print "<td class=\"center\">\n";
  474. //if ($conf->global->COMPANY_ADDON_PDF != "$name")
  475. //{
  476. print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'&token='.newToken().'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">';
  477. print img_picto($langs->trans("Enabled"), 'switch_on');
  478. print '</a>';
  479. //}
  480. //else
  481. //{
  482. // print img_picto($langs->trans("Enabled"),'on');
  483. //}
  484. print "</td>";
  485. } else {
  486. if (versioncompare($module->phpmin, versionphparray()) > 0) {
  487. print '<td class="center">'."\n";
  488. print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion", join('.', $module->phpmin))), 'switch_off');
  489. print "</td>";
  490. } else {
  491. print '<td class="center">'."\n";
  492. print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.urlencode($name).'&token='.newToken().'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
  493. print "</td>";
  494. }
  495. }
  496. // Info
  497. $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
  498. $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
  499. if ($module->type == 'pdf') {
  500. $htmltooltip .= '<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur;
  501. }
  502. $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
  503. $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraft").': '.yn((!empty($module->option_draft_watermark) ? $module->option_draft_watermark : ''), 1, 1);
  504. print '<td class="center nowrap">';
  505. print $form->textwithpicto('', $htmltooltip, 1, 0);
  506. print '</td>';
  507. // Preview
  508. print '<td class="center nowrap">';
  509. if ($module->type == 'pdf') {
  510. $linkspec = '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&token='.newToken().'&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
  511. } else {
  512. $linkspec = img_object($langs->trans("PreviewNotAvailable"), 'generic');
  513. }
  514. print $linkspec;
  515. print '</td>';
  516. print "</tr>\n";
  517. }
  518. }
  519. }
  520. closedir($handle);
  521. }
  522. }
  523. print '</table>';
  524. print '</div>';
  525. print '<br>';
  526. //IDProf
  527. print load_fiche_titre($langs->trans("CompanyIdProfChecker"), '', '');
  528. print '<div class="div-table-responsive-no-min">';
  529. print '<table class="noborder centpercent">';
  530. print '<tr class="liste_titre">';
  531. print '<td>'.$langs->trans("Name").'</td>';
  532. print '<td>'.$langs->trans("Description").'</td>';
  533. print '<td class="center">'.$langs->trans("MustBeUnique").'</td>';
  534. print '<td class="center">'.$langs->trans("MustBeMandatory").'</td>';
  535. print '<td class="center">'.$langs->trans("MustBeInvoiceMandatory").'</td>';
  536. print "</tr>\n";
  537. $profid['IDPROF1'][0] = $langs->trans("ProfId1");
  538. $profid['IDPROF1'][1] = $langs->transcountry('ProfId1', $mysoc->country_code);
  539. $profid['IDPROF2'][0] = $langs->trans("ProfId2");
  540. $profid['IDPROF2'][1] = $langs->transcountry('ProfId2', $mysoc->country_code);
  541. $profid['IDPROF3'][0] = $langs->trans("ProfId3");
  542. $profid['IDPROF3'][1] = $langs->transcountry('ProfId3', $mysoc->country_code);
  543. $profid['IDPROF4'][0] = $langs->trans("ProfId4");
  544. $profid['IDPROF4'][1] = $langs->transcountry('ProfId4', $mysoc->country_code);
  545. $profid['IDPROF5'][0] = $langs->trans("ProfId5");
  546. $profid['IDPROF5'][1] = $langs->transcountry('ProfId5', $mysoc->country_code);
  547. $profid['IDPROF6'][0] = $langs->trans("ProfId6");
  548. $profid['IDPROF6'][1] = $langs->transcountry('ProfId6', $mysoc->country_code);
  549. $profid['EMAIL'][0] = $langs->trans("EMail");
  550. $profid['EMAIL'][1] = $langs->trans('Email');
  551. $nbofloop = count($profid);
  552. foreach ($profid as $key => $val) {
  553. if ($profid[$key][1] != '-') {
  554. print '<tr class="oddeven">';
  555. print '<td>'.$profid[$key][0]."</td><td>\n";
  556. print $profid[$key][1];
  557. print '</td>';
  558. $idprof_unique = 'SOCIETE_'.$key.'_UNIQUE';
  559. $idprof_mandatory = 'SOCIETE_'.$key.'_MANDATORY';
  560. $idprof_invoice_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY';
  561. $verif = (empty($conf->global->$idprof_unique) ?false:true);
  562. $mandatory = (empty($conf->global->$idprof_mandatory) ?false:true);
  563. $invoice_mandatory = (empty($conf->global->$idprof_invoice_mandatory) ?false:true);
  564. if ($verif) {
  565. print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&token='.newToken().'&value='.$key.'&status=0">';
  566. print img_picto($langs->trans("Activated"), 'switch_on');
  567. print '</a></td>';
  568. } else {
  569. print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&token='.newToken().'&value='.$key.'&status=1">';
  570. print img_picto($langs->trans("Disabled"), 'switch_off');
  571. print '</a></td>';
  572. }
  573. if ($mandatory) {
  574. print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&token='.newToken().'&value='.$key.'&status=0">';
  575. print img_picto($langs->trans("Activated"), 'switch_on');
  576. print '</a></td>';
  577. } else {
  578. print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&token='.newToken().'&value='.$key.'&status=1">';
  579. print img_picto($langs->trans("Disabled"), 'switch_off');
  580. print '</a></td>';
  581. }
  582. if ($invoice_mandatory) {
  583. print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&token='.newToken().'&value='.$key.'&status=0">';
  584. print img_picto($langs->trans("Activated"), 'switch_on');
  585. print '</a></td>';
  586. } else {
  587. print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&token='.newToken().'&value='.$key.'&status=1">';
  588. print img_picto($langs->trans("Disabled"), 'switch_off');
  589. print '</a></td>';
  590. }
  591. print "</tr>\n";
  592. }
  593. $i++;
  594. }
  595. print "</table>\n";
  596. print '</div>';
  597. print "<br>\n";
  598. print load_fiche_titre($langs->trans("Other"), '', '');
  599. // Autres options
  600. $form = new Form($db);
  601. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
  602. print '<input type="hidden" name="token" value="'.newToken().'">';
  603. print '<input type="hidden" name="page_y" value="">';
  604. print '<input type="hidden" name="action" value="updateoptions">';
  605. print '<div class="div-table-responsive-no-min">';
  606. print '<table class="noborder centpercent">';
  607. print '<tr class="liste_titre">';
  608. print "<td>".$langs->trans("Parameters")."</td>\n";
  609. print '<td class="right" width="60">'.$langs->trans("Value").'</td>'."\n";
  610. print '<td width="80">&nbsp;</td></tr>'."\n";
  611. // Utilisation formulaire Ajax sur choix societe
  612. print '<tr class="oddeven">';
  613. print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectCompany"), $langs->trans('UseSearchToSelectCompanyTooltip'), 1).' </td>';
  614. if (!$conf->use_javascript_ajax) {
  615. print '<td class="nowrap right" colspan="2">';
  616. print $langs->trans("NotAvailableWhenAjaxDisabled");
  617. print "</td>";
  618. } else {
  619. print '<td width="60" class="right">';
  620. $arrval = array('0'=>$langs->trans("No"),
  621. '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
  622. '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
  623. '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
  624. );
  625. print $form->selectarray("activate_COMPANY_USE_SEARCH_TO_SELECT", $arrval, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp');
  626. print '</td><td class="right">';
  627. print '<input type="submit" class="button reposition" name="COMPANY_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
  628. print "</td>";
  629. }
  630. print '</tr>';
  631. print '<tr class="oddeven">';
  632. print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectContact"), $langs->trans('UseSearchToSelectContactTooltip'), 1).'</td>';
  633. if (!$conf->use_javascript_ajax) {
  634. print '<td class="nowrap right" colspan="2">';
  635. print $langs->trans("NotAvailableWhenAjaxDisabled");
  636. print "</td>";
  637. } else {
  638. print '<td width="60" class="right">';
  639. $arrval = array('0'=>$langs->trans("No"),
  640. '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
  641. '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
  642. '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
  643. );
  644. print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT", $arrval, $conf->global->CONTACT_USE_SEARCH_TO_SELECT, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp');
  645. print '</td><td class="right">';
  646. print '<input type="submit" class="button reposition" name="CONTACT_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
  647. print "</td>";
  648. }
  649. print '</tr>';
  650. print '<tr class="oddeven">';
  651. print '<td width="80%">'.$langs->trans("AddRefInList").'</td>';
  652. print '<td>&nbsp;</td>';
  653. print '<td class="center">';
  654. if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) {
  655. print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&token='.newToken().'&value=0">';
  656. print img_picto($langs->trans("Activated"), 'switch_on');
  657. } else {
  658. print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&token='.newToken().'&value=1">';
  659. print img_picto($langs->trans("Disabled"), 'switch_off');
  660. }
  661. print '</a></td>';
  662. print '</tr>';
  663. print '<tr class="oddeven">';
  664. print '<td width="80%">'.$langs->trans("AddAdressInList").'</td>';
  665. print '<td>&nbsp;</td>';
  666. print '<td class="center">';
  667. if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
  668. print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&token='.newToken().'&value=0">';
  669. print img_picto($langs->trans("Activated"), 'switch_on');
  670. } else {
  671. print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&token='.newToken().'&value=1">';
  672. print img_picto($langs->trans("Disabled"), 'switch_off');
  673. }
  674. print '</a></td>';
  675. print '</tr>';
  676. print '<tr class="oddeven">';
  677. print '<td width="80%">'.$langs->trans("AddEmailPhoneTownInContactList").'</td>';
  678. print '<td>&nbsp;</td>';
  679. print '<td class="center">';
  680. if (!empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
  681. print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddemailphonetownincontactlist&token='.newToken().'&value=0">';
  682. print img_picto($langs->trans("Activated"), 'switch_on');
  683. } else {
  684. print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddemailphonetownincontactlist&token='.newToken().'&value=1">';
  685. print img_picto($langs->trans("Disabled"), 'switch_off');
  686. }
  687. print '</a></td>';
  688. print '</tr>';
  689. if (!empty($conf->expedition->enabled)) {
  690. if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { // Visible on experimental only because seems to not be implemented everywhere (only on proposal)
  691. print '<tr class="oddeven">';
  692. print '<td width="80%">'.$langs->trans("AskForPreferredShippingMethod").'</td>';
  693. print '<td>&nbsp;</td>';
  694. print '<td class="center">';
  695. if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) {
  696. print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&token='.newToken().'&value=0">';
  697. print img_picto($langs->trans("Activated"), 'switch_on');
  698. } else {
  699. print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&token='.newToken().'&value=1">';
  700. print img_picto($langs->trans("Disabled"), 'switch_off');
  701. }
  702. print '</a></td>';
  703. print '</tr>';
  704. }
  705. }
  706. // Disable Prospect/Customer thirdparty type
  707. print '<tr class="oddeven">';
  708. print '<td width="80%">'.$langs->trans("DisableProspectCustomerType").'</td>';
  709. print '<td>&nbsp;</td>';
  710. print '<td class="center">';
  711. if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
  712. print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&token='.newToken().'&value=0">';
  713. print img_picto($langs->trans("Activated"), 'switch_on');
  714. } else {
  715. print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&token='.newToken().'&value=1">';
  716. print img_picto($langs->trans("Disabled"), 'switch_off');
  717. }
  718. print '</a></td>';
  719. print '</tr>';
  720. if (empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
  721. // Default Prospect/Customer thirdparty type on customer création
  722. print '<tr class="oddeven">';
  723. print '<td>'.$langs->trans("DefaultCustomerType").'</td>';
  724. print '<td>';
  725. print $formcompany->selectProspectCustomerType($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT, 'defaultcustomertype', 'defaultcustomertype', 'admin');
  726. print '</td>';
  727. print '<td class="center">';
  728. print '<input type="submit" class="button reposition" name="THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT" value="'.$langs->trans("Modify").'">';
  729. print '</td>';
  730. print '</tr>';
  731. }
  732. print '</table>';
  733. print '</div>';
  734. print '</form>';
  735. print dol_get_fiche_end();
  736. // End of page
  737. llxFooter();
  738. $db->close();