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