product.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. <?php
  2. /* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
  4. * Copyright (C) 2006-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  5. * Copyright (C) 2007 Auguria SARL <info@auguria.org>
  6. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  7. * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
  8. * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
  9. * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
  10. * Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
  11. * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 3 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  25. */
  26. /**
  27. * \file htdocs/product/admin/product.php
  28. * \ingroup produit
  29. * \brief Setup page of product module
  30. */
  31. // Load Dolibarr environment
  32. require '../../main.inc.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
  35. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php';
  37. // Load translation files required by the page
  38. $langs->loadLangs(array("admin", "products"));
  39. // Security check
  40. if (!$user->admin || (!isModEnabled("product") && !isModEnabled("service"))) {
  41. accessforbidden();
  42. }
  43. $action = GETPOST('action', 'aZ09');
  44. $value = GETPOST('value', 'alpha');
  45. $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
  46. $label = GETPOST('label', 'alpha');
  47. $scandir = GETPOST('scan_dir', 'alpha');
  48. $type = 'product';
  49. // Pricing Rules
  50. $select_pricing_rules = array(
  51. 'PRODUCT_PRICE_UNIQ'=>$langs->trans('PriceCatalogue'), // Unique price
  52. 'PRODUIT_MULTIPRICES'=>$langs->trans('MultiPricesAbility'), // Several prices according to a customer level
  53. 'PRODUIT_CUSTOMER_PRICES'=>$langs->trans('PriceByCustomer'), // Different price for each customer
  54. );
  55. $keyforparam = 'PRODUIT_CUSTOMER_PRICES_BY_QTY';
  56. if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1 || !empty($conf->global->$keyforparam)) {
  57. $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY'] = $langs->trans('PriceByQuantity').' ('.$langs->trans("VersionExperimental").')'; // TODO If this is enabled, price must be hidden when price by qty is enabled, also price for quantity must be used when adding product into order/propal/invoice
  58. }
  59. $keyforparam = 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES';
  60. if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2 || !empty($conf->global->$keyforparam)) {
  61. $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'] = $langs->trans('MultiPricesAbility').'+'.$langs->trans('PriceByQuantity').' ('.$langs->trans("VersionExperimental").')';
  62. }
  63. // Clean param
  64. if (getDolGlobalString('PRODUIT_MULTIPRICES') && !getDolGlobalString('PRODUIT_MULTIPRICES_LIMIT')) {
  65. dolibarr_set_const($db, 'PRODUIT_MULTIPRICES_LIMIT', 5, 'chaine', 0, '', $conf->entity);
  66. }
  67. $error = 0;
  68. /*
  69. * Actions
  70. */
  71. $nomessageinsetmoduleoptions = 1;
  72. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  73. if ($action == 'setcodeproduct') {
  74. if (dolibarr_set_const($db, "PRODUCT_CODEPRODUCT_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) {
  75. header("Location: ".$_SERVER["PHP_SELF"]);
  76. exit;
  77. } else {
  78. dol_print_error($db);
  79. }
  80. }
  81. if ($action == 'other' && GETPOST('value_PRODUIT_LIMIT_SIZE') >= 0) {
  82. $res = dolibarr_set_const($db, "PRODUIT_LIMIT_SIZE", GETPOST('value_PRODUIT_LIMIT_SIZE'), 'chaine', 0, '', $conf->entity);
  83. if (!($res > 0)) {
  84. $error++;
  85. }
  86. }
  87. if ($action == 'other' && GETPOST('value_PRODUIT_MULTIPRICES_LIMIT') > 0) {
  88. $res = dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", GETPOST('value_PRODUIT_MULTIPRICES_LIMIT'), 'chaine', 0, '', $conf->entity);
  89. if (!($res > 0)) {
  90. $error++;
  91. }
  92. }
  93. if ($action == 'other') {
  94. $princingrules = GETPOST('princingrule', 'alpha');
  95. foreach ($select_pricing_rules as $tmprule => $tmplabel) { // Loop on each possible mode
  96. if ($tmprule == $princingrules) { // We are on selected rule, we enable it
  97. if ($princingrules == 'PRODUCT_PRICE_UNIQ') { // For this case, we disable entries manually
  98. $res = dolibarr_set_const($db, 'PRODUIT_MULTIPRICES', 0, 'chaine', 0, '', $conf->entity);
  99. $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES_BY_QTY', 0, 'chaine', 0, '', $conf->entity);
  100. $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES', 0, 'chaine', 0, '', $conf->entity);
  101. dolibarr_set_const($db, 'PRODUCT_PRICE_UNIQ', 1, 'chaine', 0, '', $conf->entity);
  102. } else {
  103. $multirule = explode('&', $princingrules);
  104. foreach ($multirule as $rulesselected) {
  105. $res = dolibarr_set_const($db, $rulesselected, 1, 'chaine', 0, '', $conf->entity);
  106. }
  107. }
  108. } else { // We clear this mode
  109. if (strpos($tmprule, '&') === false) {
  110. $res = dolibarr_set_const($db, $tmprule, 0, 'chaine', 0, '', $conf->entity);
  111. }
  112. }
  113. }
  114. $value = GETPOST('price_base_type', 'alpha');
  115. $res = dolibarr_set_const($db, "PRODUCT_PRICE_BASE_TYPE", $value, 'chaine', 0, '', $conf->entity);
  116. /*$value = GETPOST('PRODUIT_SOUSPRODUITS', 'alpha');
  117. $res = dolibarr_set_const($db, "PRODUIT_SOUSPRODUITS", $value, 'chaine', 0, '', $conf->entity);*/
  118. $value = GETPOST('PRODUIT_DESC_IN_FORM', 'alpha');
  119. $res = dolibarr_set_const($db, "PRODUIT_DESC_IN_FORM", $value, 'chaine', 0, '', $conf->entity);
  120. $value = GETPOST('activate_viewProdTextsInThirdpartyLanguage', 'alpha');
  121. $res = dolibarr_set_const($db, "PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE", $value, 'chaine', 0, '', $conf->entity);
  122. $value = GETPOST('activate_mergePropalProductCard', 'alpha');
  123. $res = dolibarr_set_const($db, "PRODUIT_PDF_MERGE_PROPAL", $value, 'chaine', 0, '', $conf->entity);
  124. $value = GETPOST('activate_usesearchtoselectproduct', 'alpha');
  125. $res = dolibarr_set_const($db, "PRODUIT_USE_SEARCH_TO_SELECT", $value, 'chaine', 0, '', $conf->entity);
  126. $value = GETPOST('activate_FillProductDescAuto', 'alpha');
  127. $res = dolibarr_set_const($db, "PRODUIT_AUTOFILL_DESC", $value, 'chaine', 0, '', $conf->entity);
  128. if (GETPOSTISSET('PRODUIT_FOURN_TEXTS')) {
  129. $value = GETPOST('PRODUIT_FOURN_TEXTS', 'alpha');
  130. $res = dolibarr_set_const($db, "PRODUIT_FOURN_TEXTS", $value, 'chaine', 0, '', $conf->entity);
  131. }
  132. if (GETPOSTISSET('PRODUCT_USE_SUPPLIER_PACKAGING')) {
  133. $value = GETPOST('PRODUCT_USE_SUPPLIER_PACKAGING', 'alpha');
  134. $res = dolibarr_set_const($db, "PRODUCT_USE_SUPPLIER_PACKAGING", $value, 'chaine', 0, '', $conf->entity);
  135. }
  136. }
  137. if ($action == 'specimen') { // For products
  138. $modele = GETPOST('module', 'alpha');
  139. $product = new Product($db);
  140. $product->initAsSpecimen();
  141. // Search template files
  142. $file = '';
  143. $classname = '';
  144. $filefound = 0;
  145. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  146. foreach ($dirmodels as $reldir) {
  147. $file = dol_buildpath($reldir."core/modules/product/doc/pdf_".$modele.".modules.php", 0);
  148. if (file_exists($file)) {
  149. $filefound = 1;
  150. $classname = "pdf_".$modele;
  151. break;
  152. }
  153. }
  154. if ($filefound) {
  155. require_once $file;
  156. $module = new $classname($db);
  157. if ($module->write_file($product, $langs, '') > 0) {
  158. header("Location: ".DOL_URL_ROOT."/document.php?modulepart=product&file=SPECIMEN.pdf");
  159. return;
  160. } else {
  161. setEventMessages($obj->error, $obj->errors, 'errors');
  162. dol_syslog($obj->error, LOG_ERR);
  163. }
  164. } else {
  165. setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
  166. dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
  167. }
  168. }
  169. // Activate a model
  170. if ($action == 'set') {
  171. $ret = addDocumentModel($value, $type, $label, $scandir);
  172. }
  173. if ($action == 'del') {
  174. $ret = delDocumentModel($value, $type);
  175. if ($ret > 0) {
  176. if (getDolGlobalString('PRODUCT_ADDON_PDF') == "$value") {
  177. dolibarr_del_const($db, 'PRODUCT_ADDON_PDF', $conf->entity);
  178. }
  179. }
  180. }
  181. // Set default model
  182. if ($action == 'setdoc') {
  183. if (dolibarr_set_const($db, "PRODUCT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
  184. // La constante qui a ete lue en avant du nouveau set
  185. // on passe donc par une variable pour avoir un affichage coherent
  186. $conf->global->PRODUCT_ADDON_PDF = $value;
  187. }
  188. // On active le modele
  189. $ret = delDocumentModel($value, $type);
  190. if ($ret > 0) {
  191. $ret = addDocumentModel($value, $type, $label, $scandir);
  192. }
  193. }
  194. if ($action == 'set') {
  195. $const = "PRODUCT_SPECIAL_".strtoupper(GETPOST('spe', 'alpha'));
  196. $value = GETPOST('value');
  197. if (GETPOST('value', 'alpha')) {
  198. $res = dolibarr_set_const($db, $const, $value, 'chaine', 0, '', $conf->entity);
  199. } else {
  200. $res = dolibarr_del_const($db, $const, $conf->entity);
  201. }
  202. if (!($res > 0)) {
  203. $error++;
  204. }
  205. }
  206. // To enable a constant whithout javascript
  207. if (preg_match('/set_(.+)/', $action, $reg)) {
  208. $keyforvar = $reg[1];
  209. if ($keyforvar) {
  210. $value = 1;
  211. $res = dolibarr_set_const($db, $keyforvar, $value, 'chaine', 0, '', $conf->entity);
  212. }
  213. }
  214. // To disable a constant whithout javascript
  215. if (preg_match('/del_(.+)/', $action, $reg)) {
  216. $keyforvar = $reg[1];
  217. if ($keyforvar) {
  218. $res = dolibarr_del_const($db, $keyforvar, $conf->entity);
  219. }
  220. }
  221. if ($action) {
  222. if (!$error) {
  223. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  224. } else {
  225. setEventMessages($langs->trans("SetupNotError"), null, 'errors');
  226. }
  227. }
  228. /*
  229. * View
  230. */
  231. $formbarcode = new FormBarCode($db);
  232. $title = $langs->trans('ProductServiceSetup');
  233. $tab = $langs->trans("ProductsAndServices");
  234. if (!isModEnabled("product")) {
  235. $title = $langs->trans('ServiceSetup');
  236. $tab = $langs->trans('Services');
  237. } elseif (!isModEnabled("service")) {
  238. $title = $langs->trans('ProductSetup');
  239. $tab = $langs->trans('Products');
  240. }
  241. llxHeader('', $title);
  242. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  243. print load_fiche_titre($title, $linkback, 'title_setup');
  244. $head = product_admin_prepare_head();
  245. print dol_get_fiche_head($head, 'general', $tab, -1, 'product');
  246. $form = new Form($db);
  247. // Module to manage product / services code
  248. $dirproduct = array('/core/modules/product/');
  249. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  250. print load_fiche_titre($langs->trans("ProductCodeChecker"), '', '');
  251. print '<div class="div-table-responsive-no-min">';
  252. print '<table class="noborder centpercent">'."\n";
  253. print '<tr class="liste_titre">'."\n";
  254. print ' <td>'.$langs->trans("Name").'</td>';
  255. print ' <td>'.$langs->trans("Description").'</td>';
  256. print ' <td>'.$langs->trans("Example").'</td>';
  257. print ' <td class="center" width="80">'.$langs->trans("Status").'</td>';
  258. print ' <td class="center"></td>';
  259. print "</tr>\n";
  260. foreach ($dirproduct as $dirroot) {
  261. $dir = dol_buildpath($dirroot, 0);
  262. $handle = @opendir($dir);
  263. if (is_resource($handle)) {
  264. // Loop on each module find in opened directory
  265. while (($file = readdir($handle)) !== false) {
  266. if (substr($file, 0, 16) == 'mod_codeproduct_' && substr($file, -3) == 'php') {
  267. $file = substr($file, 0, dol_strlen($file) - 4);
  268. try {
  269. dol_include_once($dirroot.$file.'.php');
  270. } catch (Exception $e) {
  271. dol_syslog($e->getMessage(), LOG_ERR);
  272. }
  273. $modCodeProduct = new $file();
  274. // Show modules according to features level
  275. if ($modCodeProduct->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
  276. continue;
  277. }
  278. if ($modCodeProduct->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
  279. continue;
  280. }
  281. print '<tr class="oddeven">'."\n";
  282. print '<td width="140">'.$modCodeProduct->name.'</td>'."\n";
  283. print '<td>'.$modCodeProduct->info($langs).'</td>'."\n";
  284. print '<td class="nowrap"><span class="opacitymedium">'.$modCodeProduct->getExample($langs).'</span></td>'."\n";
  285. if (getDolGlobalString('PRODUCT_CODEPRODUCT_ADDON') && $conf->global->PRODUCT_CODEPRODUCT_ADDON == $file) {
  286. print '<td class="center">'."\n";
  287. print img_picto($langs->trans("Activated"), 'switch_on');
  288. print "</td>\n";
  289. } else {
  290. $disabled = false;
  291. if (isModEnabled('multicompany') && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true) {
  292. }
  293. print '<td class="center">';
  294. if (!$disabled) {
  295. print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeproduct&token='.newToken().'&value='.urlencode($file).'">';
  296. }
  297. print img_picto($langs->trans("Disabled"), 'switch_off');
  298. if (!$disabled) {
  299. print '</a>';
  300. }
  301. print '</td>';
  302. }
  303. print '<td class="center">';
  304. $s = $modCodeProduct->getToolTip($langs, null, -1);
  305. print $form->textwithpicto('', $s, 1);
  306. print '</td>';
  307. print '</tr>';
  308. }
  309. }
  310. closedir($handle);
  311. }
  312. }
  313. print '</table>';
  314. print '</div>';
  315. // Module to build doc
  316. $def = array();
  317. $sql = "SELECT nom";
  318. $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
  319. $sql .= " WHERE type = '".$db->escape($type)."'";
  320. $sql .= " AND entity = ".$conf->entity;
  321. $resql = $db->query($sql);
  322. if ($resql) {
  323. $i = 0;
  324. $num_rows = $db->num_rows($resql);
  325. while ($i < $num_rows) {
  326. $array = $db->fetch_array($resql);
  327. array_push($def, $array[0]);
  328. $i++;
  329. }
  330. } else {
  331. dol_print_error($db);
  332. }
  333. print '<br>';
  334. print load_fiche_titre($langs->trans("ProductDocumentTemplates"), '', '');
  335. print '<div class="div-table-responsive-no-min">';
  336. print '<table class="noborder centpercent">';
  337. print '<tr class="liste_titre">';
  338. print '<td>'.$langs->trans("Name").'</td>';
  339. print '<td>'.$langs->trans("Description").'</td>';
  340. print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
  341. print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
  342. print '<td class="center"></td>';
  343. print '<td class="center" width="80">'.$langs->trans("Preview").'</td>';
  344. print "</tr>\n";
  345. clearstatcache();
  346. foreach ($dirmodels as $reldir) {
  347. foreach (array('', '/doc') as $valdir) {
  348. $dir = dol_buildpath($reldir."core/modules/product".$valdir);
  349. if (is_dir($dir)) {
  350. $handle = opendir($dir);
  351. if (is_resource($handle)) {
  352. while (($file = readdir($handle)) !== false) {
  353. $filelist[] = $file;
  354. }
  355. closedir($handle);
  356. arsort($filelist);
  357. foreach ($filelist as $file) {
  358. if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
  359. if (file_exists($dir.'/'.$file)) {
  360. $name = substr($file, 4, dol_strlen($file) - 16);
  361. $classname = substr($file, 0, dol_strlen($file) - 12);
  362. require_once $dir.'/'.$file;
  363. $module = new $classname($db);
  364. $modulequalified = 1;
  365. if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
  366. $modulequalified = 0;
  367. }
  368. if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
  369. $modulequalified = 0;
  370. }
  371. if ($modulequalified) {
  372. print '<tr class="oddeven"><td width="100">';
  373. print(empty($module->name) ? $name : $module->name);
  374. print "</td><td>\n";
  375. if (method_exists($module, 'info')) {
  376. print $module->info($langs);
  377. } else {
  378. print $module->description;
  379. }
  380. print '</td>';
  381. // Active
  382. if (in_array($name, $def)) {
  383. print '<td class="center">'."\n";
  384. print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
  385. print img_picto($langs->trans("Enabled"), 'switch_on');
  386. print '</a>';
  387. print '</td>';
  388. } else {
  389. print '<td class="center">'."\n";
  390. print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
  391. print "</td>";
  392. }
  393. // Defaut
  394. print '<td class="center">';
  395. if (getDolGlobalString('PRODUCT_ADDON_PDF') == $name) {
  396. print img_picto($langs->trans("Default"), 'on');
  397. } else {
  398. print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  399. }
  400. print '</td>';
  401. // Info
  402. $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
  403. $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
  404. if ($module->type == 'pdf') {
  405. $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
  406. }
  407. $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
  408. $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
  409. $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
  410. print '<td class="center">';
  411. print $form->textwithpicto('', $htmltooltip, 1, 0);
  412. print '</td>';
  413. // Preview
  414. print '<td class="center">';
  415. if ($module->type == 'pdf') {
  416. print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>';
  417. } else {
  418. print img_object($langs->trans("PreviewNotAvailable"), 'generic');
  419. }
  420. print '</td>';
  421. print "</tr>\n";
  422. }
  423. }
  424. }
  425. }
  426. }
  427. }
  428. }
  429. }
  430. print '</table>';
  431. print '</div>';
  432. print "<br>";
  433. /*
  434. * Other conf
  435. */
  436. print "<br>";
  437. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
  438. print '<input type="hidden" name="token" value="'.newToken().'">';
  439. print '<input type="hidden" name="action" value="other">';
  440. print '<input type="hidden" name="page_y" value="">';
  441. print load_fiche_titre($langs->trans("ProductOtherConf"), '', '');
  442. print '<div class="div-table-responsive-no-min">';
  443. print '<table class="noborder centpercent">';
  444. print '<tr class="liste_titre">';
  445. print '<td>'.$langs->trans("Parameters").'</td>'."\n";
  446. print '<td class="right" width="60">'.$langs->trans("Value").'</td>'."\n";
  447. print '</tr>'."\n";
  448. // Enable kits (subproducts)
  449. print '<tr class="oddeven">';
  450. print '<td>'.$langs->trans("AssociatedProductsAbility").'</td>';
  451. print '<td class="right">';
  452. print ajax_constantonoff("PRODUIT_SOUSPRODUITS", array(), $conf->entity, 0, 0, 1, 0);
  453. //print $form->selectyesno("PRODUIT_SOUSPRODUITS", $conf->global->PRODUIT_SOUSPRODUITS, 1);
  454. print '</td>';
  455. print '</tr>';
  456. // Enable variants
  457. print '<tr class="oddeven">';
  458. print '<td>'.$langs->trans("VariantsAbility").'</td>';
  459. print '<td class="right">';
  460. //print ajax_constantonoff("PRODUIT_SOUSPRODUITS", array(), $conf->entity, 0, 0, 1, 0);
  461. //print $form->selectyesno("PRODUIT_SOUSPRODUITS", $conf->global->PRODUIT_SOUSPRODUITS, 1);
  462. if (!isModEnabled('variants')) {
  463. print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabled", $langs->transnoentitiesnoconv("Module610Name")).'</span>';
  464. } else {
  465. print yn(1).' <span class="opacitymedium">('.$langs->trans("ModuleIsEnabled", $langs->transnoentitiesnoconv("Module610Name")).')</span>';
  466. }
  467. print '</td>';
  468. print '</tr>';
  469. // Rule for price
  470. print '<tr class="oddeven">';
  471. if (!isModEnabled('multicompany')) {
  472. print '<td>'.$langs->trans("PricingRule").'</td>';
  473. } else {
  474. print '<td>'.$form->textwithpicto($langs->trans("PricingRule"), $langs->trans("SamePriceAlsoForSharedCompanies"), 1).'</td>';
  475. }
  476. print '<td class="right">';
  477. $current_rule = 'PRODUCT_PRICE_UNIQ';
  478. if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
  479. $current_rule = 'PRODUIT_MULTIPRICES';
  480. }
  481. if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY')) {
  482. $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY';
  483. }
  484. if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES')) {
  485. $current_rule = 'PRODUIT_CUSTOMER_PRICES';
  486. }
  487. if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
  488. $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES';
  489. }
  490. print $form->selectarray("princingrule", $select_pricing_rules, $current_rule, 0, 0, 0, '', 1, 0, 0, '', 'maxwidth400', 1);
  491. print '</td>';
  492. print '</tr>';
  493. // multiprix nombre de prix a proposer
  494. if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
  495. print '<tr class="oddeven">';
  496. print '<td>'.$langs->trans("MultiPricesNumPrices").'</td>';
  497. print '<td class="right"><input size="3" type="text" class="flat right" name="value_PRODUIT_MULTIPRICES_LIMIT" value="' . getDolGlobalString('PRODUIT_MULTIPRICES_LIMIT').'"></td>';
  498. print '</tr>';
  499. }
  500. // Default product price base type
  501. print '<tr class="oddeven">';
  502. print '<td>'.$langs->trans("DefaultPriceType").'</td>';
  503. print '<td class="right">';
  504. print $form->selectPriceBaseType($conf->global->PRODUCT_PRICE_BASE_TYPE, "price_base_type");
  505. print '</td>';
  506. print '</tr>';
  507. // Use conditionnement in buying
  508. if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
  509. print '<tr class="oddeven">';
  510. print '<td>'.$form->textwithpicto($langs->trans("UseProductSupplierPackaging"), $langs->trans("PackagingForThisProductDesc")).'</td>';
  511. print '<td align="right">';
  512. print ajax_constantonoff("PRODUCT_USE_SUPPLIER_PACKAGING", array(), $conf->entity, 0, 0, 0, 0);
  513. //print $form->selectyesno("activate_useProdSupplierPackaging", (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING) ? $conf->global->PRODUCT_USE_SUPPLIER_PACKAGING : 0), 1);
  514. print '</td>';
  515. print '</tr>';
  516. print '<tr class="oddeven">';
  517. print '<td>'.$langs->trans("UseProductFournDesc").'</td>';
  518. print '<td class="right">';
  519. print ajax_constantonoff("PRODUIT_FOURN_TEXTS", array(), $conf->entity, 0, 0, 0, 0);
  520. //print $form->selectyesno("activate_useProdFournDesc", (!empty($conf->global->PRODUIT_FOURN_TEXTS) ? $conf->global->PRODUIT_FOURN_TEXTS : 0), 1);
  521. print '</td>';
  522. print '</tr>';
  523. }
  524. print '</table>';
  525. print '</div>';
  526. print '<div class="center">';
  527. print '<input type="submit" class="button reposition" value="'.$langs->trans("Modify").'">';
  528. print '</div>';
  529. print load_fiche_titre($langs->trans("UserInterface"), '', '');
  530. print '<div class="div-table-responsive-no-min">';
  531. print '<table class="noborder centpercent">';
  532. print '<tr class="liste_titre">';
  533. print '<td>'.$langs->trans("Parameters").'</td>'."\n";
  534. print '<td class="right" width="60">'.$langs->trans("Value").'</td>'."\n";
  535. print '</tr>'."\n";
  536. // Use Ajax form to select a product
  537. print '<tr class="oddeven">';
  538. print '<td>'.$form->textwithpicto($langs->trans("UseSearchToSelectProduct"), $langs->trans('UseSearchToSelectProductTooltip'), 1).'</td>';
  539. if (empty($conf->use_javascript_ajax)) {
  540. print '<td class="nowrap right">';
  541. print $langs->trans("NotAvailableWhenAjaxDisabled");
  542. print '</td>';
  543. } else {
  544. print '<td class="right">';
  545. $arrval = array(
  546. '0'=>$langs->trans("No"),
  547. '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
  548. '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
  549. '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
  550. );
  551. print $form->selectarray("activate_usesearchtoselectproduct", $arrval, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT);
  552. print '</td>';
  553. }
  554. print '</tr>';
  555. if (!getDolGlobalString('PRODUIT_USE_SEARCH_TO_SELECT')) {
  556. print '<tr class="oddeven">';
  557. print '<td>'.$langs->trans("NumberOfProductShowInSelect").'</td>';
  558. print '<td class="right"><input size="3" type="text" class="flat" name="value_PRODUIT_LIMIT_SIZE" value="' . getDolGlobalString('PRODUIT_LIMIT_SIZE').'"></td>';
  559. print '</tr>';
  560. }
  561. // Do Not Add Product description on add lines
  562. print '<tr class="oddeven">';
  563. print '<td>'.$langs->trans("OnProductSelectAddProductDesc").'</td>';
  564. print '<td class="right">';
  565. print '<!-- PRODUIT_AUTOFILL_DESC -->';
  566. print $form->selectarray(
  567. "activate_FillProductDescAuto",
  568. array(0=>'DoNotAutofillButAutoConcat', 1=>'AutoFillFormFieldBeforeSubmit', 2=>'DoNotUseDescriptionOfProdut'),
  569. !getDolGlobalString('PRODUIT_AUTOFILL_DESC') ? 0 : $conf->global->PRODUIT_AUTOFILL_DESC,
  570. 0,
  571. 0,
  572. 0,
  573. '',
  574. 1,
  575. 0,
  576. 0,
  577. '',
  578. 'minwidth100imp maxwidth400',
  579. 1
  580. );
  581. print '</td>';
  582. print '</tr>';
  583. // Visualiser description produit dans les formulaires activation/desactivation
  584. print '<tr class="oddeven">';
  585. print '<td>'.$langs->trans("ViewProductDescInFormAbility").'</td>';
  586. print '<td class="right">';
  587. $arrayofchoices = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes").' ('.$langs->trans("DesktopsOnly").')', '2' => $langs->trans("Yes").' ('.$langs->trans("DesktopsAndSmartphones").')');
  588. print $form->selectarray("PRODUIT_DESC_IN_FORM", $arrayofchoices, getDolGlobalInt('PRODUIT_DESC_IN_FORM'), 0);
  589. print '</td>';
  590. print '</tr>';
  591. // Activate propal merge produt card
  592. /* Kept as hidden feature only. PRODUIT_PDF_MERGE_PROPAL can be added manually. Still did not understand how this feature works.
  593. print '<tr class="oddeven">';
  594. print '<td>'.$langs->trans("MergePropalProductCard").'</td>';
  595. print '<td class="right">';
  596. print $form->selectyesno("activate_mergePropalProductCard",$conf->global->PRODUIT_PDF_MERGE_PROPAL,1);
  597. print '</td>';
  598. print '</tr>';
  599. */
  600. // Use units
  601. /* Kept as hidden feature only. PRODUCT_USE_UNITS is hidden for the moment. Because it seems to be a duplicated feature with already existing field to store unit of product
  602. print '<tr class="oddeven">';
  603. print '<td>'.$langs->trans("UseUnits").'</td>';
  604. print '<td class="right">';
  605. print $form->selectyesno("activate_units",$conf->global->PRODUCT_USE_UNITS,1);
  606. print '</td>';
  607. print '</tr>';
  608. */
  609. // View product description in thirdparty language
  610. if (getDolGlobalInt('MAIN_MULTILANGS')) {
  611. print '<tr class="oddeven">';
  612. print '<td>'.$langs->trans("ViewProductDescInThirdpartyLanguageAbility").'</td>';
  613. print '<td class="right">';
  614. print $form->selectyesno("activate_viewProdTextsInThirdpartyLanguage", (getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE') ? $conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE : 0), 1);
  615. print '</td>';
  616. print '</tr>';
  617. }
  618. if (getDolGlobalString('PRODUCT_CANVAS_ABILITY')) {
  619. // Add canvas feature
  620. $dir = DOL_DOCUMENT_ROOT."/product/canvas/";
  621. print '<tr class="liste_titre">';
  622. print '<td>'.$langs->trans("ProductSpecial").'</td>'."\n";
  623. print '<td class="right">'.$langs->trans("Value").'</td>'."\n";
  624. print '</tr>'."\n";
  625. if (is_dir($dir)) {
  626. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  627. $handle = opendir($dir);
  628. if (is_resource($handle)) {
  629. while (($file = readdir($handle)) !== false) {
  630. if (file_exists($dir.$file.'/product.'.$file.'.class.php')) {
  631. $classfile = $dir.$file.'/product.'.$file.'.class.php';
  632. $classname = 'Product'.ucfirst($file);
  633. require_once $classfile;
  634. $object = new $classname();
  635. $module = $object->module;
  636. if ($conf->$module->enabled) {
  637. print '<tr class="oddeven"><td>';
  638. print $object->description;
  639. print '</td><td class="right">';
  640. $const = "PRODUCT_SPECIAL_".strtoupper($file);
  641. if (getDolGlobalString($const)) {
  642. print img_picto($langs->trans("Active"), 'tick');
  643. print '</td><td class="right">';
  644. print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&spe='.urlencode($file).'&value=0">'.$langs->trans("Disable").'</a>';
  645. } else {
  646. print '&nbsp;</td><td class="right">';
  647. print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&spe='.urlencode($file).'&value=1">'.$langs->trans("Activate").'</a>';
  648. }
  649. print '</td></tr>';
  650. }
  651. }
  652. }
  653. closedir($handle);
  654. }
  655. } else {
  656. setEventMessages($dir.' '.$langs->trans("IsNotADir"), null, 'errors');
  657. }
  658. }
  659. print '</table>';
  660. print '</div>';
  661. print '<div class="center">';
  662. print '<input type="submit" class="button reposition" value="'.$langs->trans("Modify").'">';
  663. print '</div>';
  664. print '</form>';
  665. // End of page
  666. llxFooter();
  667. $db->close();