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