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