product.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  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 ($conf->global->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 ($conf->global->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 (!empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->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 = ''; $classname = ''; $filefound = 0;
  143. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  144. foreach ($dirmodels as $reldir) {
  145. $file = dol_buildpath($reldir."core/modules/product/doc/pdf_".$modele.".modules.php", 0);
  146. if (file_exists($file)) {
  147. $filefound = 1;
  148. $classname = "pdf_".$modele;
  149. break;
  150. }
  151. }
  152. if ($filefound) {
  153. require_once $file;
  154. $module = new $classname($db);
  155. if ($module->write_file($product, $langs, '') > 0) {
  156. header("Location: ".DOL_URL_ROOT."/document.php?modulepart=product&file=SPECIMEN.pdf");
  157. return;
  158. } else {
  159. setEventMessages($obj->error, $obj->errors, 'errors');
  160. dol_syslog($obj->error, LOG_ERR);
  161. }
  162. } else {
  163. setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
  164. dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
  165. }
  166. }
  167. // Activate a model
  168. if ($action == 'set') {
  169. $ret = addDocumentModel($value, $type, $label, $scandir);
  170. }
  171. if ($action == 'del') {
  172. $ret = delDocumentModel($value, $type);
  173. if ($ret > 0) {
  174. if (getDolGlobalString('PRODUCT_ADDON_PDF') == "$value") {
  175. dolibarr_del_const($db, 'PRODUCT_ADDON_PDF', $conf->entity);
  176. }
  177. }
  178. }
  179. // Set default model
  180. if ($action == 'setdoc') {
  181. if (dolibarr_set_const($db, "PRODUCT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
  182. // La constante qui a ete lue en avant du nouveau set
  183. // on passe donc par une variable pour avoir un affichage coherent
  184. $conf->global->PRODUCT_ADDON_PDF = $value;
  185. }
  186. // On active le modele
  187. $ret = delDocumentModel($value, $type);
  188. if ($ret > 0) {
  189. $ret = addDocumentModel($value, $type, $label, $scandir);
  190. }
  191. }
  192. if ($action == 'set') {
  193. $const = "PRODUCT_SPECIAL_".strtoupper(GETPOST('spe', 'alpha'));
  194. $value = GETPOST('value');
  195. if (GETPOST('value', 'alpha')) {
  196. $res = dolibarr_set_const($db, $const, $value, 'chaine', 0, '', $conf->entity);
  197. } else {
  198. $res = dolibarr_del_const($db, $const, $conf->entity);
  199. }
  200. if (!($res > 0)) {
  201. $error++;
  202. }
  203. }
  204. // To enable a constant whithout javascript
  205. if (preg_match('/set_(.+)/', $action, $reg)) {
  206. $keyforvar = $reg[1];
  207. if ($keyforvar) {
  208. $value = 1;
  209. $res = dolibarr_set_const($db, $keyforvar, $value, 'chaine', 0, '', $conf->entity);
  210. }
  211. }
  212. // To disable a constant whithout javascript
  213. if (preg_match('/del_(.+)/', $action, $reg)) {
  214. $keyforvar = $reg[1];
  215. if ($keyforvar) {
  216. $res = dolibarr_del_const($db, $keyforvar, $conf->entity);
  217. }
  218. }
  219. if ($action) {
  220. if (!$error) {
  221. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  222. } else {
  223. setEventMessages($langs->trans("SetupNotError"), null, 'errors');
  224. }
  225. }
  226. /*
  227. * View
  228. */
  229. $formbarcode = new FormBarCode($db);
  230. $title = $langs->trans('ProductServiceSetup');
  231. $tab = $langs->trans("ProductsAndServices");
  232. if (!isModEnabled("product")) {
  233. $title = $langs->trans('ServiceSetup');
  234. $tab = $langs->trans('Services');
  235. } elseif (!isModEnabled("service")) {
  236. $title = $langs->trans('ProductSetup');
  237. $tab = $langs->trans('Products');
  238. }
  239. llxHeader('', $title);
  240. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  241. print load_fiche_titre($title, $linkback, 'title_setup');
  242. $head = product_admin_prepare_head();
  243. print dol_get_fiche_head($head, 'general', $tab, -1, 'product');
  244. $form = new Form($db);
  245. // Module to manage product / services code
  246. $dirproduct = array('/core/modules/product/');
  247. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  248. print load_fiche_titre($langs->trans("ProductCodeChecker"), '', '');
  249. print '<div class="div-table-responsive-no-min">';
  250. print '<table class="noborder centpercent">'."\n";
  251. print '<tr class="liste_titre">'."\n";
  252. print ' <td>'.$langs->trans("Name").'</td>';
  253. print ' <td>'.$langs->trans("Description").'</td>';
  254. print ' <td>'.$langs->trans("Example").'</td>';
  255. print ' <td class="center" width="80">'.$langs->trans("Status").'</td>';
  256. print ' <td class="center"></td>';
  257. print "</tr>\n";
  258. foreach ($dirproduct as $dirroot) {
  259. $dir = dol_buildpath($dirroot, 0);
  260. $handle = @opendir($dir);
  261. if (is_resource($handle)) {
  262. // Loop on each module find in opened directory
  263. while (($file = readdir($handle)) !== false) {
  264. if (substr($file, 0, 16) == 'mod_codeproduct_' && substr($file, -3) == 'php') {
  265. $file = substr($file, 0, dol_strlen($file) - 4);
  266. try {
  267. dol_include_once($dirroot.$file.'.php');
  268. } catch (Exception $e) {
  269. dol_syslog($e->getMessage(), LOG_ERR);
  270. }
  271. $modCodeProduct = new $file;
  272. // Show modules according to features level
  273. if ($modCodeProduct->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  274. continue;
  275. }
  276. if ($modCodeProduct->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  277. continue;
  278. }
  279. print '<tr class="oddeven">'."\n";
  280. print '<td width="140">'.$modCodeProduct->name.'</td>'."\n";
  281. print '<td>'.$modCodeProduct->info($langs).'</td>'."\n";
  282. print '<td class="nowrap"><span class="opacitymedium">'.$modCodeProduct->getExample($langs).'</span></td>'."\n";
  283. if (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) && $conf->global->PRODUCT_CODEPRODUCT_ADDON == $file) {
  284. print '<td class="center">'."\n";
  285. print img_picto($langs->trans("Activated"), 'switch_on');
  286. print "</td>\n";
  287. } else {
  288. $disabled = false;
  289. if (isModEnabled('multicompany') && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true) {
  290. }
  291. print '<td class="center">';
  292. if (!$disabled) {
  293. print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeproduct&token='.newToken().'&value='.urlencode($file).'">';
  294. }
  295. print img_picto($langs->trans("Disabled"), 'switch_off');
  296. if (!$disabled) {
  297. print '</a>';
  298. }
  299. print '</td>';
  300. }
  301. print '<td class="center">';
  302. $s = $modCodeProduct->getToolTip($langs, null, -1);
  303. print $form->textwithpicto('', $s, 1);
  304. print '</td>';
  305. print '</tr>';
  306. }
  307. }
  308. closedir($handle);
  309. }
  310. }
  311. print '</table>';
  312. print '</div>';
  313. // Module to build doc
  314. $def = array();
  315. $sql = "SELECT nom";
  316. $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
  317. $sql .= " WHERE type = '".$db->escape($type)."'";
  318. $sql .= " AND entity = ".$conf->entity;
  319. $resql = $db->query($sql);
  320. if ($resql) {
  321. $i = 0;
  322. $num_rows = $db->num_rows($resql);
  323. while ($i < $num_rows) {
  324. $array = $db->fetch_array($resql);
  325. array_push($def, $array[0]);
  326. $i++;
  327. }
  328. } else {
  329. dol_print_error($db);
  330. }
  331. print '<br>';
  332. print load_fiche_titre($langs->trans("ProductDocumentTemplates"), '', '');
  333. print '<div class="div-table-responsive-no-min">';
  334. print '<table class="noborder centpercent">';
  335. print '<tr class="liste_titre">';
  336. print '<td>'.$langs->trans("Name").'</td>';
  337. print '<td>'.$langs->trans("Description").'</td>';
  338. print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
  339. print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
  340. print '<td class="center"></td>';
  341. print '<td class="center" width="80">'.$langs->trans("Preview").'</td>';
  342. print "</tr>\n";
  343. clearstatcache();
  344. foreach ($dirmodels as $reldir) {
  345. foreach (array('', '/doc') as $valdir) {
  346. $dir = dol_buildpath($reldir."core/modules/product".$valdir);
  347. if (is_dir($dir)) {
  348. $handle = opendir($dir);
  349. if (is_resource($handle)) {
  350. while (($file = readdir($handle)) !== false) {
  351. $filelist[] = $file;
  352. }
  353. closedir($handle);
  354. arsort($filelist);
  355. foreach ($filelist as $file) {
  356. if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
  357. if (file_exists($dir.'/'.$file)) {
  358. $name = substr($file, 4, dol_strlen($file) - 16);
  359. $classname = substr($file, 0, dol_strlen($file) - 12);
  360. require_once $dir.'/'.$file;
  361. $module = new $classname($db);
  362. $modulequalified = 1;
  363. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  364. $modulequalified = 0;
  365. }
  366. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  367. $modulequalified = 0;
  368. }
  369. if ($modulequalified) {
  370. print '<tr class="oddeven"><td width="100">';
  371. print (empty($module->name) ? $name : $module->name);
  372. print "</td><td>\n";
  373. if (method_exists($module, 'info')) {
  374. print $module->info($langs);
  375. } else {
  376. print $module->description;
  377. }
  378. print '</td>';
  379. // Active
  380. if (in_array($name, $def)) {
  381. print '<td class="center">'."\n";
  382. print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
  383. print img_picto($langs->trans("Enabled"), 'switch_on');
  384. print '</a>';
  385. print '</td>';
  386. } else {
  387. print '<td class="center">'."\n";
  388. 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>';
  389. print "</td>";
  390. }
  391. // Defaut
  392. print '<td class="center">';
  393. if (getDolGlobalString('PRODUCT_ADDON_PDF') == $name) {
  394. print img_picto($langs->trans("Default"), 'on');
  395. } else {
  396. 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>';
  397. }
  398. print '</td>';
  399. // Info
  400. $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
  401. $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
  402. if ($module->type == 'pdf') {
  403. $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
  404. }
  405. $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
  406. $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
  407. $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
  408. print '<td class="center">';
  409. print $form->textwithpicto('', $htmltooltip, 1, 0);
  410. print '</td>';
  411. // Preview
  412. print '<td class="center">';
  413. if ($module->type == 'pdf') {
  414. print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>';
  415. } else {
  416. print img_object($langs->trans("PreviewNotAvailable"), 'generic');
  417. }
  418. print '</td>';
  419. print "</tr>\n";
  420. }
  421. }
  422. }
  423. }
  424. }
  425. }
  426. }
  427. }
  428. print '</table>';
  429. print '</div>';
  430. print "<br>";
  431. /*
  432. * Other conf
  433. */
  434. print "<br>";
  435. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
  436. print '<input type="hidden" name="token" value="'.newToken().'">';
  437. print '<input type="hidden" name="action" value="other">';
  438. print '<input type="hidden" name="page_y" value="">';
  439. print load_fiche_titre($langs->trans("ProductOtherConf"), '', '');
  440. print '<div class="div-table-responsive-no-min">';
  441. print '<table class="noborder centpercent">';
  442. print '<tr class="liste_titre">';
  443. print '<td>'.$langs->trans("Parameters").'</td>'."\n";
  444. print '<td class="right" width="60">'.$langs->trans("Value").'</td>'."\n";
  445. print '</tr>'."\n";
  446. // Enable kits (subproducts)
  447. print '<tr class="oddeven">';
  448. print '<td>'.$langs->trans("AssociatedProductsAbility").'</td>';
  449. print '<td class="right">';
  450. print ajax_constantonoff("PRODUIT_SOUSPRODUITS", array(), $conf->entity, 0, 0, 1, 0);
  451. //print $form->selectyesno("PRODUIT_SOUSPRODUITS", $conf->global->PRODUIT_SOUSPRODUITS, 1);
  452. print '</td>';
  453. print '</tr>';
  454. // Enable variants
  455. print '<tr class="oddeven">';
  456. print '<td>'.$langs->trans("VariantsAbility").'</td>';
  457. print '<td class="right">';
  458. //print ajax_constantonoff("PRODUIT_SOUSPRODUITS", array(), $conf->entity, 0, 0, 1, 0);
  459. //print $form->selectyesno("PRODUIT_SOUSPRODUITS", $conf->global->PRODUIT_SOUSPRODUITS, 1);
  460. if (!isModEnabled('variants')) {
  461. print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabled", $langs->transnoentitiesnoconv("Module610Name")).'</span>';
  462. } else {
  463. print yn(1).' <span class="opacitymedium">('.$langs->trans("ModuleIsEnabled", $langs->transnoentitiesnoconv("Module610Name")).')</span>';
  464. }
  465. print '</td>';
  466. print '</tr>';
  467. // Rule for price
  468. print '<tr class="oddeven">';
  469. if (!isModEnabled('multicompany')) {
  470. print '<td>'.$langs->trans("PricingRule").'</td>';
  471. } else {
  472. print '<td>'.$form->textwithpicto($langs->trans("PricingRule"), $langs->trans("SamePriceAlsoForSharedCompanies"), 1).'</td>';
  473. }
  474. print '<td class="right">';
  475. $current_rule = 'PRODUCT_PRICE_UNIQ';
  476. if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
  477. $current_rule = 'PRODUIT_MULTIPRICES';
  478. }
  479. if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
  480. $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY';
  481. }
  482. if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
  483. $current_rule = 'PRODUIT_CUSTOMER_PRICES';
  484. }
  485. if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
  486. $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES';
  487. }
  488. print $form->selectarray("princingrule", $select_pricing_rules, $current_rule, 0, 0, 0, '', 1, 0, 0, '', 'maxwidth400', 1);
  489. print '</td>';
  490. print '</tr>';
  491. // multiprix nombre de prix a proposer
  492. if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
  493. print '<tr class="oddeven">';
  494. print '<td>'.$langs->trans("MultiPricesNumPrices").'</td>';
  495. print '<td class="right"><input size="3" type="text" class="flat right" name="value_PRODUIT_MULTIPRICES_LIMIT" value="' . getDolGlobalString('PRODUIT_MULTIPRICES_LIMIT').'"></td>';
  496. print '</tr>';
  497. }
  498. // Default product price base type
  499. print '<tr class="oddeven">';
  500. print '<td>'.$langs->trans("DefaultPriceType").'</td>';
  501. print '<td class="right">';
  502. print $form->selectPriceBaseType($conf->global->PRODUCT_PRICE_BASE_TYPE, "price_base_type");
  503. print '</td>';
  504. print '</tr>';
  505. // Use conditionnement in buying
  506. if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
  507. print '<tr class="oddeven">';
  508. print '<td>'.$form->textwithpicto($langs->trans("UseProductSupplierPackaging"), $langs->trans("PackagingForThisProductDesc")).'</td>';
  509. print '<td align="right">';
  510. print ajax_constantonoff("PRODUCT_USE_SUPPLIER_PACKAGING", array(), $conf->entity, 0, 0, 0, 0);
  511. //print $form->selectyesno("activate_useProdSupplierPackaging", (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING) ? $conf->global->PRODUCT_USE_SUPPLIER_PACKAGING : 0), 1);
  512. print '</td>';
  513. print '</tr>';
  514. print '<tr class="oddeven">';
  515. print '<td>'.$langs->trans("UseProductFournDesc").'</td>';
  516. print '<td class="right">';
  517. print ajax_constantonoff("PRODUIT_FOURN_TEXTS", array(), $conf->entity, 0, 0, 0, 0);
  518. //print $form->selectyesno("activate_useProdFournDesc", (!empty($conf->global->PRODUIT_FOURN_TEXTS) ? $conf->global->PRODUIT_FOURN_TEXTS : 0), 1);
  519. print '</td>';
  520. print '</tr>';
  521. }
  522. print '</table>';
  523. print '</div>';
  524. print '<div class="center">';
  525. print '<input type="submit" class="button reposition" value="'.$langs->trans("Modify").'">';
  526. print '</div>';
  527. print load_fiche_titre($langs->trans("UserInterface"), '', '');
  528. print '<div class="div-table-responsive-no-min">';
  529. print '<table class="noborder centpercent">';
  530. print '<tr class="liste_titre">';
  531. print '<td>'.$langs->trans("Parameters").'</td>'."\n";
  532. print '<td class="right" width="60">'.$langs->trans("Value").'</td>'."\n";
  533. print '</tr>'."\n";
  534. // Use Ajax form to select a product
  535. print '<tr class="oddeven">';
  536. print '<td>'.$form->textwithpicto($langs->trans("UseSearchToSelectProduct"), $langs->trans('UseSearchToSelectProductTooltip'), 1).'</td>';
  537. if (empty($conf->use_javascript_ajax)) {
  538. print '<td class="nowrap right">';
  539. print $langs->trans("NotAvailableWhenAjaxDisabled");
  540. print '</td>';
  541. } else {
  542. print '<td class="right">';
  543. $arrval = array(
  544. '0'=>$langs->trans("No"),
  545. '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
  546. '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
  547. '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
  548. );
  549. print $form->selectarray("activate_usesearchtoselectproduct", $arrval, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT);
  550. print '</td>';
  551. }
  552. print '</tr>';
  553. if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) {
  554. print '<tr class="oddeven">';
  555. print '<td>'.$langs->trans("NumberOfProductShowInSelect").'</td>';
  556. print '<td class="right"><input size="3" type="text" class="flat" name="value_PRODUIT_LIMIT_SIZE" value="' . getDolGlobalString('PRODUIT_LIMIT_SIZE').'"></td>';
  557. print '</tr>';
  558. }
  559. // Do Not Add Product description on add lines
  560. print '<tr class="oddeven">';
  561. print '<td>'.$langs->trans("OnProductSelectAddProductDesc").'</td>';
  562. print '<td class="right">';
  563. print '<!-- PRODUIT_AUTOFILL_DESC -->';
  564. print $form->selectarray(
  565. "activate_FillProductDescAuto",
  566. array(0=>'DoNotAutofillButAutoConcat', 1=>'AutoFillFormFieldBeforeSubmit', 2=>'DoNotUseDescriptionOfProdut'),
  567. empty($conf->global->PRODUIT_AUTOFILL_DESC) ? 0 : $conf->global->PRODUIT_AUTOFILL_DESC,
  568. 0,
  569. 0,
  570. 0,
  571. '',
  572. 1,
  573. 0,
  574. 0,
  575. '',
  576. 'minwidth100imp maxwidth400',
  577. 1
  578. );
  579. print '</td>';
  580. print '</tr>';
  581. // Visualiser description produit dans les formulaires activation/desactivation
  582. print '<tr class="oddeven">';
  583. print '<td>'.$langs->trans("ViewProductDescInFormAbility").'</td>';
  584. print '<td class="right">';
  585. $arrayofchoices = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes").' ('.$langs->trans("DesktopsOnly").')', '2' => $langs->trans("Yes").' ('.$langs->trans("DesktopsAndSmartphones").')');
  586. print $form->selectarray("PRODUIT_DESC_IN_FORM", $arrayofchoices, getDolGlobalInt('PRODUIT_DESC_IN_FORM'), 0);
  587. print '</td>';
  588. print '</tr>';
  589. // Activate propal merge produt card
  590. /* Kept as hidden feature only. PRODUIT_PDF_MERGE_PROPAL can be added manually. Still did not understand how this feature works.
  591. print '<tr class="oddeven">';
  592. print '<td>'.$langs->trans("MergePropalProductCard").'</td>';
  593. print '<td class="right">';
  594. print $form->selectyesno("activate_mergePropalProductCard",$conf->global->PRODUIT_PDF_MERGE_PROPAL,1);
  595. print '</td>';
  596. print '</tr>';
  597. */
  598. // Use units
  599. /* 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
  600. print '<tr class="oddeven">';
  601. print '<td>'.$langs->trans("UseUnits").'</td>';
  602. print '<td class="right">';
  603. print $form->selectyesno("activate_units",$conf->global->PRODUCT_USE_UNITS,1);
  604. print '</td>';
  605. print '</tr>';
  606. */
  607. // View product description in thirdparty language
  608. if (getDolGlobalInt('MAIN_MULTILANGS')) {
  609. print '<tr class="oddeven">';
  610. print '<td>'.$langs->trans("ViewProductDescInThirdpartyLanguageAbility").'</td>';
  611. print '<td class="right">';
  612. print $form->selectyesno("activate_viewProdTextsInThirdpartyLanguage", (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) ? $conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE : 0), 1);
  613. print '</td>';
  614. print '</tr>';
  615. }
  616. if (!empty($conf->global->PRODUCT_CANVAS_ABILITY)) {
  617. // Add canvas feature
  618. $dir = DOL_DOCUMENT_ROOT."/product/canvas/";
  619. print '<tr class="liste_titre">';
  620. print '<td>'.$langs->trans("ProductSpecial").'</td>'."\n";
  621. print '<td class="right">'.$langs->trans("Value").'</td>'."\n";
  622. print '</tr>'."\n";
  623. if (is_dir($dir)) {
  624. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  625. $handle = opendir($dir);
  626. if (is_resource($handle)) {
  627. while (($file = readdir($handle)) !== false) {
  628. if (file_exists($dir.$file.'/product.'.$file.'.class.php')) {
  629. $classfile = $dir.$file.'/product.'.$file.'.class.php';
  630. $classname = 'Product'.ucfirst($file);
  631. require_once $classfile;
  632. $object = new $classname();
  633. $module = $object->module;
  634. if ($conf->$module->enabled) {
  635. print '<tr class="oddeven"><td>';
  636. print $object->description;
  637. print '</td><td class="right">';
  638. $const = "PRODUCT_SPECIAL_".strtoupper($file);
  639. if ($conf->global->$const) {
  640. print img_picto($langs->trans("Active"), 'tick');
  641. print '</td><td class="right">';
  642. print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&spe='.urlencode($file).'&value=0">'.$langs->trans("Disable").'</a>';
  643. } else {
  644. print '&nbsp;</td><td class="right">';
  645. print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&spe='.urlencode($file).'&value=1">'.$langs->trans("Activate").'</a>';
  646. }
  647. print '</td></tr>';
  648. }
  649. }
  650. }
  651. closedir($handle);
  652. }
  653. } else {
  654. setEventMessages($dir.' '.$langs->trans("IsNotADir"), null, 'errors');
  655. }
  656. }
  657. print '</table>';
  658. print '</div>';
  659. print '<div class="center">';
  660. print '<input type="submit" class="button reposition" value="'.$langs->trans("Modify").'">';
  661. print '</div>';
  662. print '</form>';
  663. // End of page
  664. llxFooter();
  665. $db->close();