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