dolibarr 20.0.0
product.php
Go to the documentation of this file.
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 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <https://www.gnu.org/licenses/>.
26 */
27
34// Load Dolibarr environment
35require '../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php';
40
41// Load translation files required by the page
42$langs->loadLangs(array("admin", "products"));
43
44// Security check
45if (!$user->admin || (!isModEnabled("product") && !isModEnabled("service"))) {
47}
48
49$action = GETPOST('action', 'aZ09');
50$value = GETPOST('value', 'alpha');
51$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
52
53$label = GETPOST('label', 'alpha');
54$scandir = GETPOST('scan_dir', 'alpha');
55$type = 'product';
56
57// Pricing Rules
58$select_pricing_rules = array(
59 'PRODUCT_PRICE_UNIQ' => $langs->trans('PriceCatalogue'), // Unique price
60 'PRODUIT_MULTIPRICES' => $langs->trans('MultiPricesAbility'), // Several prices according to a customer level
61 'PRODUIT_CUSTOMER_PRICES' => $langs->trans('PriceByCustomer'), // Different price for each customer
62);
63$keyforparam = 'PRODUIT_CUSTOMER_PRICES_BY_QTY';
64if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1 || !empty($conf->global->$keyforparam)) {
65 $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
66}
67$keyforparam = 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES';
68if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2 || !empty($conf->global->$keyforparam)) {
69 $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'] = $langs->trans('MultiPricesAbility').'+'.$langs->trans('PriceByQuantity').' ('.$langs->trans("VersionExperimental").')';
70}
71
72// Clean param
73if (getDolGlobalString('PRODUIT_MULTIPRICES') && !getDolGlobalString('PRODUIT_MULTIPRICES_LIMIT')) {
74 dolibarr_set_const($db, 'PRODUIT_MULTIPRICES_LIMIT', 5, 'chaine', 0, '', $conf->entity);
75}
76
77$error = 0;
78
79
80/*
81 * Actions
82 */
83
84$nomessageinsetmoduleoptions = 1;
85include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
86
87if ($action == 'setcodeproduct') {
88 if (dolibarr_set_const($db, "PRODUCT_CODEPRODUCT_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) {
89 header("Location: ".$_SERVER["PHP_SELF"]);
90 exit;
91 } else {
92 dol_print_error($db);
93 }
94}
95
96if ($action == 'other' && GETPOST('value_PRODUIT_LIMIT_SIZE') >= 0) {
97 $res = dolibarr_set_const($db, "PRODUIT_LIMIT_SIZE", GETPOST('value_PRODUIT_LIMIT_SIZE'), 'chaine', 0, '', $conf->entity);
98 if (!($res > 0)) {
99 $error++;
100 }
101}
102if ($action == 'other' && GETPOST('value_PRODUIT_MULTIPRICES_LIMIT') > 0) {
103 $res = dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", GETPOST('value_PRODUIT_MULTIPRICES_LIMIT'), 'chaine', 0, '', $conf->entity);
104 if (!($res > 0)) {
105 $error++;
106 }
107}
108if ($action == 'other') {
109 $princingrules = GETPOST('princingrule', 'alpha');
110 foreach ($select_pricing_rules as $tmprule => $tmplabel) { // Loop on each possible mode
111 if ($tmprule == $princingrules) { // We are on selected rule, we enable it
112 if ($princingrules == 'PRODUCT_PRICE_UNIQ') { // For this case, we disable entries manually
113 $res = dolibarr_set_const($db, 'PRODUIT_MULTIPRICES', 0, 'chaine', 0, '', $conf->entity);
114 $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES_BY_QTY', 0, 'chaine', 0, '', $conf->entity);
115 $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES', 0, 'chaine', 0, '', $conf->entity);
116 dolibarr_set_const($db, 'PRODUCT_PRICE_UNIQ', 1, 'chaine', 0, '', $conf->entity);
117 } else {
118 $multirule = explode('&', $princingrules);
119 foreach ($multirule as $rulesselected) {
120 $res = dolibarr_set_const($db, $rulesselected, 1, 'chaine', 0, '', $conf->entity);
121 }
122 }
123 } else { // We clear this mode
124 if (strpos($tmprule, '&') === false) {
125 $res = dolibarr_set_const($db, $tmprule, 0, 'chaine', 0, '', $conf->entity);
126 }
127 }
128 }
129
130 $value = GETPOST('price_base_type', 'alpha');
131 $res = dolibarr_set_const($db, "PRODUCT_PRICE_BASE_TYPE", $value, 'chaine', 0, '', $conf->entity);
132
133 /*$value = GETPOST('PRODUIT_SOUSPRODUITS', 'alpha');
134 $res = dolibarr_set_const($db, "PRODUIT_SOUSPRODUITS", $value, 'chaine', 0, '', $conf->entity);*/
135
136 $value = GETPOST('PRODUIT_DESC_IN_FORM', 'alpha');
137 $res = dolibarr_set_const($db, "PRODUIT_DESC_IN_FORM", $value, 'chaine', 0, '', $conf->entity);
138
139 $value = GETPOST('activate_viewProdTextsInThirdpartyLanguage', 'alpha');
140 $res = dolibarr_set_const($db, "PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE", $value, 'chaine', 0, '', $conf->entity);
141
142 $value = GETPOST('activate_mergePropalProductCard', 'alpha');
143 $res = dolibarr_set_const($db, "PRODUIT_PDF_MERGE_PROPAL", $value, 'chaine', 0, '', $conf->entity);
144
145 $value = GETPOST('activate_usesearchtoselectproduct', 'alpha');
146 $res = dolibarr_set_const($db, "PRODUIT_USE_SEARCH_TO_SELECT", $value, 'chaine', 0, '', $conf->entity);
147
148 $value = GETPOST('activate_FillProductDescAuto', 'alpha');
149 $res = dolibarr_set_const($db, "PRODUIT_AUTOFILL_DESC", $value, 'chaine', 0, '', $conf->entity);
150
151 if (GETPOSTISSET('PRODUIT_FOURN_TEXTS')) {
152 $value = GETPOST('PRODUIT_FOURN_TEXTS', 'alpha');
153 $res = dolibarr_set_const($db, "PRODUIT_FOURN_TEXTS", $value, 'chaine', 0, '', $conf->entity);
154 }
155
156 if (GETPOSTISSET('PRODUCT_USE_SUPPLIER_PACKAGING')) {
157 $value = GETPOST('PRODUCT_USE_SUPPLIER_PACKAGING', 'alpha');
158 $res = dolibarr_set_const($db, "PRODUCT_USE_SUPPLIER_PACKAGING", $value, 'chaine', 0, '', $conf->entity);
159 }
160}
161
162
163if ($action == 'specimen') { // For products
164 $modele = GETPOST('module', 'alpha');
165
166 $product = new Product($db);
167 $product->initAsSpecimen();
168
169 // Search template files
170 $file = '';
171 $classname = '';
172 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
173 foreach ($dirmodels as $reldir) {
174 $file = dol_buildpath($reldir."core/modules/product/doc/pdf_".$modele.".modules.php", 0);
175 if (file_exists($file)) {
176 $classname = "pdf_".$modele;
177 break;
178 }
179 }
180
181 if ($classname !== '') {
182 require_once $file;
183
184 $module = new $classname($db);
185
186 if ($module->write_file($product, $langs, '') > 0) {
187 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=product&file=SPECIMEN.pdf");
188 return;
189 } else {
190 setEventMessages($obj->error, $obj->errors, 'errors');
191 dol_syslog($obj->error, LOG_ERR);
192 }
193 } else {
194 setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
195 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
196 }
197}
198
199// Activate a model
200if ($action == 'set') {
201 $ret = addDocumentModel($value, $type, $label, $scandir);
202}
203
204if ($action == 'del') {
205 $ret = delDocumentModel($value, $type);
206 if ($ret > 0) {
207 if (getDolGlobalString('PRODUCT_ADDON_PDF') == "$value") {
208 dolibarr_del_const($db, 'PRODUCT_ADDON_PDF', $conf->entity);
209 }
210 }
211}
212
213// Set default model
214if ($action == 'setdoc') {
215 if (dolibarr_set_const($db, "PRODUCT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
216 // La constante qui a ete lue en avant du nouveau set
217 // on passe donc par une variable pour avoir un affichage coherent
218 $conf->global->PRODUCT_ADDON_PDF = $value;
219 }
220
221 // On active le modele
222 $ret = delDocumentModel($value, $type);
223 if ($ret > 0) {
224 $ret = addDocumentModel($value, $type, $label, $scandir);
225 }
226}
227
228
229if ($action == 'set') {
230 $const = "PRODUCT_SPECIAL_".strtoupper(GETPOST('spe', 'alpha'));
231 $value = GETPOST('value');
232 if (GETPOST('value', 'alpha')) {
233 $res = dolibarr_set_const($db, $const, $value, 'chaine', 0, '', $conf->entity);
234 } else {
235 $res = dolibarr_del_const($db, $const, $conf->entity);
236 }
237 if (!($res > 0)) {
238 $error++;
239 }
240}
241
242// To enable a constant without javascript
243if (preg_match('/set_(.+)/', $action, $reg)) {
244 $keyforvar = $reg[1];
245 if ($keyforvar) {
246 $value = 1;
247 $res = dolibarr_set_const($db, $keyforvar, $value, 'chaine', 0, '', $conf->entity);
248 }
249}
250
251// To disable a constant without javascript
252if (preg_match('/del_(.+)/', $action, $reg)) {
253 $keyforvar = $reg[1];
254 if ($keyforvar) {
255 $res = dolibarr_del_const($db, $keyforvar, $conf->entity);
256 }
257}
258
259if ($action) {
260 if (!$error) {
261 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
262 } else {
263 setEventMessages($langs->trans("SetupNotError"), null, 'errors');
264 }
265}
266
267/*
268 * View
269 */
270
271$formbarcode = new FormBarCode($db);
272
273$title = $langs->trans('ProductServiceSetup');
274$tab = $langs->trans("ProductsAndServices");
275if (!isModEnabled("product")) {
276 $title = $langs->trans('ServiceSetup');
277 $tab = $langs->trans('Services');
278} elseif (!isModEnabled("service")) {
279 $title = $langs->trans('ProductSetup');
280 $tab = $langs->trans('Products');
281}
282
283llxHeader('', $title, '', '', 0, 0, '', '', '', 'mod-product page-admin_product');
284
285$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
286print load_fiche_titre($title, $linkback, 'title_setup');
287
289print dol_get_fiche_head($head, 'general', $tab, -1, 'product');
290
291$form = new Form($db);
292
293// Module to manage product / services code
294$dirproduct = array('/core/modules/product/');
295$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
296
297print load_fiche_titre($langs->trans("ProductCodeChecker"), '', '');
298
299print '<div class="div-table-responsive-no-min">';
300print '<table class="noborder centpercent">'."\n";
301print '<tr class="liste_titre">'."\n";
302print ' <td>'.$langs->trans("Name").'</td>';
303print ' <td>'.$langs->trans("Description").'</td>';
304print ' <td>'.$langs->trans("Example").'</td>';
305print ' <td class="center" width="80">'.$langs->trans("Status").'</td>';
306print ' <td class="center"></td>';
307print "</tr>\n";
308
309foreach ($dirproduct as $dirroot) {
310 $dir = dol_buildpath($dirroot, 0);
311
312 $handle = @opendir($dir);
313 if (is_resource($handle)) {
314 // Loop on each module find in opened directory
315 while (($file = readdir($handle)) !== false) {
316 if (substr($file, 0, 16) == 'mod_codeproduct_' && substr($file, -3) == 'php') {
317 $file = substr($file, 0, dol_strlen($file) - 4);
318
319 try {
320 dol_include_once($dirroot.$file.'.php');
321 } catch (Exception $e) {
322 dol_syslog($e->getMessage(), LOG_ERR);
323 }
324
325 $modCodeProduct = new $file();
326
327 // Show modules according to features level
328 if ($modCodeProduct->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
329 continue;
330 }
331 if ($modCodeProduct->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
332 continue;
333 }
334
335 print '<tr class="oddeven">'."\n";
336 print '<td width="140">'.$modCodeProduct->name.'</td>'."\n";
337 print '<td>'.$modCodeProduct->info($langs).'</td>'."\n";
338 print '<td class="nowrap"><span class="opacitymedium">'.$modCodeProduct->getExample($langs).'</span></td>'."\n";
339
340 if (getDolGlobalString('PRODUCT_CODEPRODUCT_ADDON') && $conf->global->PRODUCT_CODEPRODUCT_ADDON == $file) {
341 print '<td class="center">'."\n";
342 print img_picto($langs->trans("Activated"), 'switch_on');
343 print "</td>\n";
344 } else {
345 $disabled = false;
346 if (isModEnabled('multicompany') && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true) {
347 }
348 print '<td class="center">';
349 if (!$disabled) {
350 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeproduct&token='.newToken().'&value='.urlencode($file).'">';
351 }
352 print img_picto($langs->trans("Disabled"), 'switch_off');
353 if (!$disabled) {
354 print '</a>';
355 }
356 print '</td>';
357 }
358
359 print '<td class="center">';
360 $s = $modCodeProduct->getToolTip($langs, null, -1);
361 print $form->textwithpicto('', $s, 1);
362 print '</td>';
363
364 print '</tr>';
365 }
366 }
367 closedir($handle);
368 }
369}
370print '</table>';
371print '</div>';
372
373// Module to build doc
374$def = array();
375$sql = "SELECT nom";
376$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
377$sql .= " WHERE type = '".$db->escape($type)."'";
378$sql .= " AND entity = ".$conf->entity;
379$resql = $db->query($sql);
380if ($resql) {
381 $i = 0;
382 $num_rows = $db->num_rows($resql);
383 while ($i < $num_rows) {
384 $array = $db->fetch_array($resql);
385 if (is_array($array)) {
386 array_push($def, $array[0]);
387 }
388 $i++;
389 }
390} else {
391 dol_print_error($db);
392}
393
394print '<br>';
395
396print load_fiche_titre($langs->trans("ProductDocumentTemplates"), '', '');
397
398print '<div class="div-table-responsive-no-min">';
399print '<table class="noborder centpercent">';
400print '<tr class="liste_titre">';
401print '<td>'.$langs->trans("Name").'</td>';
402print '<td>'.$langs->trans("Description").'</td>';
403print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
404print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
405print '<td class="center"></td>';
406print '<td class="center" width="80">'.$langs->trans("Preview").'</td>';
407print "</tr>\n";
408
409clearstatcache();
410
411$filelist = array();
412foreach ($dirmodels as $reldir) {
413 foreach (array('', '/doc') as $valdir) {
414 $dir = dol_buildpath($reldir."core/modules/product".$valdir);
415 if (is_dir($dir)) {
416 $handle = opendir($dir);
417 if (is_resource($handle)) {
418 while (($file = readdir($handle)) !== false) {
419 $filelist[] = $file;
420 }
421 closedir($handle);
422 arsort($filelist);
423
424 foreach ($filelist as $file) {
425 if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
426 if (file_exists($dir.'/'.$file)) {
427 $name = substr($file, 4, dol_strlen($file) - 16);
428 $classname = substr($file, 0, dol_strlen($file) - 12);
429
430 require_once $dir.'/'.$file;
431 $module = new $classname($db);
432
433 $modulequalified = 1;
434 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
435 $modulequalified = 0;
436 }
437 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
438 $modulequalified = 0;
439 }
440
441 if ($modulequalified) {
442 print '<tr class="oddeven"><td width="100">';
443 print(empty($module->name) ? $name : $module->name);
444 print "</td><td>\n";
445 if (method_exists($module, 'info')) {
446 print $module->info($langs);
447 } else {
448 print $module->description;
449 }
450 print '</td>';
451
452 // Active
453 if (in_array($name, $def)) {
454 print '<td class="center">'."\n";
455 print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
456 print img_picto($langs->trans("Enabled"), 'switch_on');
457 print '</a>';
458 print '</td>';
459 } else {
460 print '<td class="center">'."\n";
461 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>';
462 print "</td>";
463 }
464
465 // Default
466 print '<td class="center">';
467 if (getDolGlobalString('PRODUCT_ADDON_PDF') == $name) {
468 print img_picto($langs->trans("Default"), 'on');
469 } else {
470 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>';
471 }
472 print '</td>';
473
474 // Info
475 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
476 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
477 if ($module->type == 'pdf') {
478 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
479 }
480 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
481 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
482 $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
483
484
485 print '<td class="center">';
486 print $form->textwithpicto('', $htmltooltip, 1, 0);
487 print '</td>';
488
489 // Preview
490 print '<td class="center">';
491 if ($module->type == 'pdf') {
492 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>';
493 } else {
494 print img_object($langs->trans("PreviewNotAvailable"), 'generic');
495 }
496 print '</td>';
497
498 print "</tr>\n";
499 }
500 }
501 }
502 }
503 }
504 }
505 }
506}
507
508print '</table>';
509print '</div>';
510
511print "<br>";
512
513/*
514 * Other conf
515 */
516
517print "<br>";
518
519
520print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
521print '<input type="hidden" name="token" value="'.newToken().'">';
522print '<input type="hidden" name="action" value="other">';
523print '<input type="hidden" name="page_y" value="">';
524
525
526print load_fiche_titre($langs->trans("ProductOtherConf"), '', '');
527
528
529print '<div class="div-table-responsive-no-min">';
530print '<table class="noborder centpercent">';
531print '<tr class="liste_titre">';
532print '<td>'.$langs->trans("Parameters").'</td>'."\n";
533print '<td class="right" width="60">'.$langs->trans("Value").'</td>'."\n";
534print '</tr>'."\n";
535
536
537// Enable kits (subproducts)
538
539print '<tr class="oddeven">';
540print '<td>'.$langs->trans("AssociatedProductsAbility").'</td>';
541print '<td class="right">';
542print ajax_constantonoff("PRODUIT_SOUSPRODUITS", array(), $conf->entity, 0, 0, 1, 0);
543//print $form->selectyesno("PRODUIT_SOUSPRODUITS", $conf->global->PRODUIT_SOUSPRODUITS, 1);
544print '</td>';
545print '</tr>';
546
547
548// Enable variants
549
550print '<tr class="oddeven">';
551print '<td>'.$langs->trans("VariantsAbility").'</td>';
552print '<td class="right">';
553//print ajax_constantonoff("PRODUIT_SOUSPRODUITS", array(), $conf->entity, 0, 0, 1, 0);
554//print $form->selectyesno("PRODUIT_SOUSPRODUITS", $conf->global->PRODUIT_SOUSPRODUITS, 1);
555if (!isModEnabled('variants')) {
556 print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabled", $langs->transnoentitiesnoconv("Module610Name")).'</span>';
557} else {
558 print yn(1).' <span class="opacitymedium">('.$langs->trans("ModuleIsEnabled", $langs->transnoentitiesnoconv("Module610Name")).')</span>';
559}
560print '</td>';
561print '</tr>';
562
563
564// Rule for price
565
566print '<tr class="oddeven">';
567if (!isModEnabled('multicompany')) {
568 print '<td>'.$langs->trans("PricingRule").'</td>';
569} else {
570 print '<td>'.$form->textwithpicto($langs->trans("PricingRule"), $langs->trans("SamePriceAlsoForSharedCompanies"), 1).'</td>';
571}
572print '<td class="right">';
573$current_rule = 'PRODUCT_PRICE_UNIQ';
574if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
575 $current_rule = 'PRODUIT_MULTIPRICES';
576}
577if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY')) {
578 $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY';
579}
580if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES')) {
581 $current_rule = 'PRODUIT_CUSTOMER_PRICES';
582}
583if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
584 $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES';
585}
586print $form->selectarray("princingrule", $select_pricing_rules, $current_rule, 0, 0, 0, '', 1, 0, 0, '', 'maxwidth400', 1);
587print '</td>';
588print '</tr>';
589
590
591// multiprix nombre de prix a proposer
592if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
593 print '<tr class="oddeven">';
594 print '<td>'.$langs->trans("MultiPricesNumPrices").'</td>';
595 print '<td class="right"><input size="3" type="text" class="flat right" name="value_PRODUIT_MULTIPRICES_LIMIT" value="' . getDolGlobalString('PRODUIT_MULTIPRICES_LIMIT').'"></td>';
596 print '</tr>';
597}
598
599// Default product price base type
600print '<tr class="oddeven">';
601print '<td>'.$langs->trans("DefaultPriceType").'</td>';
602print '<td class="right">';
603print $form->selectPriceBaseType($conf->global->PRODUCT_PRICE_BASE_TYPE, "price_base_type");
604print '</td>';
605print '</tr>';
606
607// Use conditionnement in buying
608if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
609 print '<tr class="oddeven">';
610 print '<td>'.$form->textwithpicto($langs->trans("UseProductSupplierPackaging"), $langs->trans("PackagingForThisProductDesc")).'</td>';
611 print '<td align="right">';
612 print ajax_constantonoff("PRODUCT_USE_SUPPLIER_PACKAGING", array(), $conf->entity, 0, 0, 0, 0);
613 //print $form->selectyesno("activate_useProdSupplierPackaging", (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING) ? $conf->global->PRODUCT_USE_SUPPLIER_PACKAGING : 0), 1);
614 print '</td>';
615 print '</tr>';
616
617 print '<tr class="oddeven">';
618 print '<td>'.$langs->trans("UseProductFournDesc").'</td>';
619 print '<td class="right">';
620 print ajax_constantonoff("PRODUIT_FOURN_TEXTS", array(), $conf->entity, 0, 0, 0, 0);
621 //print $form->selectyesno("activate_useProdFournDesc", (!empty($conf->global->PRODUIT_FOURN_TEXTS) ? $conf->global->PRODUIT_FOURN_TEXTS : 0), 1);
622 print '</td>';
623 print '</tr>';
624}
625
626print '</table>';
627print '</div>';
628
629print '<div class="center">';
630print '<input type="submit" class="button reposition" value="'.$langs->trans("Modify").'">';
631print '</div>';
632
633
634print load_fiche_titre($langs->trans("UserInterface"), '', '');
635
636
637print '<div class="div-table-responsive-no-min">';
638print '<table class="noborder centpercent">';
639print '<tr class="liste_titre">';
640print '<td>'.$langs->trans("Parameters").'</td>'."\n";
641print '<td class="right" width="60">'.$langs->trans("Value").'</td>'."\n";
642print '</tr>'."\n";
643
644// Use Ajax form to select a product
645
646print '<tr class="oddeven">';
647print '<td>'.$form->textwithpicto($langs->trans("UseSearchToSelectProduct"), $langs->trans('UseSearchToSelectProductTooltip'), 1).'</td>';
648if (empty($conf->use_javascript_ajax)) {
649 print '<td class="nowrap right">';
650 print $langs->trans("NotAvailableWhenAjaxDisabled");
651 print '</td>';
652} else {
653 print '<td class="right">';
654 $arrval = array(
655 '0' => $langs->trans("No"),
656 '1' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
657 '2' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
658 '3' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
659 );
660 print $form->selectarray("activate_usesearchtoselectproduct", $arrval, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT);
661 print '</td>';
662}
663print '</tr>';
664
665if (!getDolGlobalString('PRODUIT_USE_SEARCH_TO_SELECT')) {
666 print '<tr class="oddeven">';
667 print '<td>'.$langs->trans("NumberOfProductShowInSelect").'</td>';
668 print '<td class="right"><input size="3" type="text" class="flat" name="value_PRODUIT_LIMIT_SIZE" value="' . getDolGlobalString('PRODUIT_LIMIT_SIZE').'"></td>';
669 print '</tr>';
670}
671
672// Do Not Add Product description on add lines
673print '<tr class="oddeven">';
674print '<td>'.$langs->trans("OnProductSelectAddProductDesc").'</td>';
675print '<td class="right">';
676print '<!-- PRODUIT_AUTOFILL_DESC -->';
677print $form->selectarray(
678 "activate_FillProductDescAuto",
679 array(0 => 'DoNotAutofillButAutoConcat', 1 => 'AutoFillFormFieldBeforeSubmit', 2 => 'DoNotUseDescriptionOfProdut'),
680 !getDolGlobalString('PRODUIT_AUTOFILL_DESC') ? 0 : $conf->global->PRODUIT_AUTOFILL_DESC,
681 0,
682 0,
683 0,
684 '',
685 1,
686 0,
687 0,
688 '',
689 'minwidth100imp maxwidth400',
690 1
691);
692print '</td>';
693print '</tr>';
694
695// Visualiser description produit dans les formulaires activation/deactivation
696print '<tr class="oddeven">';
697print '<td>'.$langs->trans("ViewProductDescInFormAbility").'</td>';
698print '<td class="right">';
699$arrayofchoices = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes").' ('.$langs->trans("DesktopsOnly").')', '2' => $langs->trans("Yes").' ('.$langs->trans("DesktopsAndSmartphones").')');
700print $form->selectarray("PRODUIT_DESC_IN_FORM", $arrayofchoices, getDolGlobalInt('PRODUIT_DESC_IN_FORM'), 0);
701print '</td>';
702print '</tr>';
703
704// Activate propal merge produt card
705/* Kept as hidden feature only. PRODUIT_PDF_MERGE_PROPAL can be added manually. Still did not understand how this feature works.
706
707print '<tr class="oddeven">';
708print '<td>'.$langs->trans("MergePropalProductCard").'</td>';
709print '<td class="right">';
710print $form->selectyesno("activate_mergePropalProductCard",$conf->global->PRODUIT_PDF_MERGE_PROPAL,1);
711print '</td>';
712print '</tr>';
713*/
714
715// Use units
716/* 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
717
718print '<tr class="oddeven">';
719print '<td>'.$langs->trans("UseUnits").'</td>';
720print '<td class="right">';
721print $form->selectyesno("activate_units",$conf->global->PRODUCT_USE_UNITS,1);
722print '</td>';
723print '</tr>';
724*/
725
726// View product description in thirdparty language
727if (getDolGlobalInt('MAIN_MULTILANGS')) {
728 print '<tr class="oddeven">';
729 print '<td>'.$langs->trans("ViewProductDescInThirdpartyLanguageAbility").'</td>';
730 print '<td class="right">';
731 print $form->selectyesno("activate_viewProdTextsInThirdpartyLanguage", (getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE') ? $conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE : 0), 1);
732 print '</td>';
733 print '</tr>';
734}
735
736
737if (getDolGlobalString('PRODUCT_CANVAS_ABILITY')) {
738 // Add canvas feature
739 $dir = DOL_DOCUMENT_ROOT."/product/canvas/";
740
741 print '<tr class="liste_titre">';
742 print '<td>'.$langs->trans("ProductSpecial").'</td>'."\n";
743 print '<td class="right">'.$langs->trans("Value").'</td>'."\n";
744 print '</tr>'."\n";
745
746 if (is_dir($dir)) {
747 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
748
749 $handle = opendir($dir);
750 if (is_resource($handle)) {
751 while (($file = readdir($handle)) !== false) {
752 if (file_exists($dir.$file.'/product.'.$file.'.class.php')) {
753 $classfile = $dir.$file.'/product.'.$file.'.class.php';
754 $classname = 'Product'.ucfirst($file);
755
756 require_once $classfile;
757 $object = new $classname();
758
759 $module = $object->module;
760
761 if ($conf->$module->enabled) {
762 print '<tr class="oddeven"><td>';
763
764 print $object->description;
765
766 print '</td><td class="right">';
767
768 $const = "PRODUCT_SPECIAL_".strtoupper($file);
769
770 if (getDolGlobalString($const)) {
771 print img_picto($langs->trans("Active"), 'tick');
772 print '</td><td class="right">';
773 print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&spe='.urlencode($file).'&value=0">'.$langs->trans("Disable").'</a>';
774 } else {
775 print '&nbsp;</td><td class="right">';
776 print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&spe='.urlencode($file).'&value=1">'.$langs->trans("Activate").'</a>';
777 }
778
779 print '</td></tr>';
780 }
781 }
782 }
783 closedir($handle);
784 }
785 } else {
786 setEventMessages($dir.' '.$langs->trans("IsNotADir"), null, 'errors');
787 }
788}
789
790print '</table>';
791print '</div>';
792
793print '<div class="center">';
794print '<input type="submit" class="button reposition" value="'.$langs->trans("Modify").'">';
795print '</div>';
796
797print '</form>';
798
799// End of page
800llxFooter();
801$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
delDocumentModel($name, $type)
Delete document model used by doc generator.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage barcode HTML.
Class to manage generation of HTML components Only common components must be here.
Class to manage products or services.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
product_admin_prepare_head()
Return array head with list of tabs to view object information.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:142
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.