societe.php 33 KB

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