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