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