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