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