societe.php 32 KB

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