dolibarr 23.0.4
combinations.php
1<?php
2/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
3 * Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2022 Open-Dsi <support@open-dsi.fr>
6 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2025 William Mead <william@m34d.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23// Load Dolibarr environment
24require '../main.inc.php';
25require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
26require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
27require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php';
28require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttributeValue.class.php';
29require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
30require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination2ValuePair.class.php';
31
40$langs->loadLangs(array("products", "other"));
41
42$id = GETPOSTINT('id'); // ID of the parent Product
43$ref = GETPOST('ref', 'alpha');
44
45$combination_id = GETPOSTINT('combination_id'); // ID of the combination
46
47$reference = GETPOST('reference', 'alpha'); // Reference of the variant Product
48
49$weight_impact = GETPOSTFLOAT('weight_impact', 2);
50$price_impact_percent = (bool) GETPOST('price_impact_percent');
51$price_impact = $price_impact_percent ? GETPOSTFLOAT('price_impact', 2) : GETPOSTFLOAT('price_impact', 'MU');
52
53// for PRODUIT_MULTIPRICES
54$level_price_impact = GETPOST('level_price_impact', 'array');
55$level_price_impact = array_map('price2num', $level_price_impact);
56$level_price_impact = array_map('floatval', $level_price_impact);
57$level_price_impact_percent = GETPOST('level_price_impact_percent', 'array');
58$level_price_impact_percent = array_map('boolval', $level_price_impact_percent);
59$clone_categories = (bool) GETPOST('clone_categories');
60
61$form = new Form($db);
62
63$action = GETPOST('action', 'aZ09');
64$massaction = GETPOST('massaction', 'alpha');
65$show_files = GETPOSTINT('show_files');
66$confirm = GETPOST('confirm', 'alpha');
67$toselect = GETPOST('toselect', 'array:int');
68$cancel = GETPOST('cancel', 'alpha');
69$delete_product = GETPOST('delete_product', 'alpha');
70$subaction = GETPOST('subaction', 'aZ09');
71$backtopage = GETPOST('backtopage', 'alpha');
72$sortfield = GETPOST('sortfield', 'aZ09comma');
73$sortorder = GETPOST('sortorder', 'aZ09comma');
74
75// Security check
76$fieldvalue = $id ?: $ref;
77$fieldtype = !empty($ref) ? 'ref' : 'rowid';
78
79$prodstatic = new Product($db);
80$prodattr = new ProductAttribute($db);
81$prodattr_val = new ProductAttributeValue($db);
82
83$object = new Product($db);
84if ($id > 0 || $ref) {
85 $object->fetch($id, $ref);
86}
87
88$selectedvariant = isset($_SESSION['addvariant_'.$object->id]) ? $_SESSION['addvariant_'.$object->id] : array();
89$selected = '';
90// Security check
91if (!isModEnabled('variants')) {
92 accessforbidden('Module not enabled');
93}
94if ($user->socid > 0) { // Protection if external user
96}
97
98if ($object->id > 0) {
99 if ($object->isProduct()) {
100 restrictedArea($user, 'produit', $object->id, 'product&product', '', '');
101 }
102 if ($object->isService()) {
103 restrictedArea($user, 'service', $object->id, 'product&product', '', '');
104 }
105} else {
106 restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
107}
108$usercanread = (($object->isProduct() && $user->hasRight('produit', 'lire')) || ($object->isService() && $user->hasRight('service', 'lire')));
109$usercancreate = (($object->isProduct() && $user->hasRight('produit', 'creer')) || ($object->isService() && $user->hasRight('service', 'creer')));
110$usercandelete = (($object->isProduct() && $user->hasRight('produit', 'supprimer')) || ($object->isService() && $user->hasRight('service', 'supprimer')));
111
112
113/*
114 * Actions
115 */
116
117if ($cancel) {
118 $action = '';
119 $massaction = '';
120 unset($_SESSION['addvariant_'.$object->id]);
121}
122
123if (!$object->isProduct() && !$object->isService()) {
124 header('Location: '.dol_buildpath('/product/card.php?id='.$object->id, 2));
125 exit();
126}
127if ($action == 'add') { // Test on permission not required
128 unset($selectedvariant);
129 unset($_SESSION['addvariant_'.$object->id]);
130}
131if ($action == 'create' && GETPOST('selectvariant', 'alpha') && $usercancreate) { // We click on select combination
132 $action = 'add';
133 $attribute_id = GETPOSTINT('attribute');
134 $attribute_value_id = GETPOSTINT('value');
135 if ($attribute_id > 0 && $attribute_value_id > 0) {
136 $feature = $attribute_id . '-' . $attribute_value_id;
137 $selectedvariant[$feature] = $feature;
138 $_SESSION['addvariant_'.$object->id] = $selectedvariant;
139 }
140}
141if ($action == 'create' && $subaction == 'delete' && $usercancreate) { // We click on select combination
142 $action = 'add';
143 $feature = GETPOST('feature', 'intcomma');
144 if (isset($selectedvariant[$feature])) {
145 unset($selectedvariant[$feature]);
146 $_SESSION['addvariant_'.$object->id] = $selectedvariant;
147 }
148}
149
150
151$prodcomb = new ProductCombination($db);
152$prodcomb2val = new ProductCombination2ValuePair($db);
153
154// The combination to edit or delete must be a variant of the product shown
155if ($combination_id > 0) {
156 $tmpcomb = new ProductCombination($db);
157 if ($tmpcomb->fetch($combination_id) <= 0 || $tmpcomb->fk_product_parent != $object->id) {
158 setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors');
159 $combination_id = 0;
160 $action = '';
161 }
162}
163
164$productCombination2ValuePairs1 = array();
165
166if (($action == 'add' || $action == 'create') && $usercancreate && empty($massaction) && !GETPOST('selectvariant', 'alpha') && empty($subaction)) { // We click on Create all defined combinations
167 //$features = GETPOST('features', 'array');
168 $features = !empty($_SESSION['addvariant_'.$object->id]) ? $_SESSION['addvariant_'.$object->id] : array();
169
170 if (!$features) {
171 if ($action == 'create') { // Test on permission already done
172 setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors');
173 }
174 } else {
175 $reference = trim($reference);
176 if (empty($reference)) {
177 $reference = false;
178 }
179 $weight_impact = price2num($weight_impact);
180 $price_impact = price2num($price_impact);
181
182 if (!getDolGlobalString('PRODUIT_MULTIPRICES') && !getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
183 $level_price_impact = array(1 => $price_impact);
184 $level_price_impact_percent = array(1 => $price_impact_percent);
185 }
186
187 $sanit_features = array();
188
189 //First, sanitize
190 foreach ($features as $feature) {
191 $explode = explode('-', $feature);
192 if ($prodattr->fetch((int) $explode[0]) <= 0 || $prodattr_val->fetch((int) $explode[1]) <= 0) {
193 continue;
194 }
195
196 // Valuepair
197 $sanit_features[(int) $explode[0]] = (int) $explode[1];
198
199 $tmp = new ProductCombination2ValuePair($db);
200 $tmp->fk_prod_attr = (int) $explode[0];
201 $tmp->fk_prod_attr_val = (int) $explode[1];
202
203 $productCombination2ValuePairs1[] = $tmp;
204 }
205
206 $db->begin();
207
208 // sanit_feature is an array with 1 (and only 1) value per attribute.
209 // For example: Color->blue, Size->Small, Option->2
210 if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) {
211 $result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $level_price_impact_percent, $level_price_impact, (float) $weight_impact, $reference, '', $clone_categories);
212 if ($result > 0) {
213 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
214 unset($_SESSION['addvariant_'.$object->id]);
215
216 $db->commit();
217 header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2));
218 exit();
219 } else {
220 $langs->load("errors");
221 setEventMessages($prodcomb->error, $prodcomb->errors, 'errors');
222 }
223 } else {
224 setEventMessages($langs->trans('ErrorRecordAlreadyExists'), null, 'errors');
225 }
226
227 $db->rollback();
228 }
229} elseif (!empty($massaction) && ($massaction == 'delete' ? $usercandelete : $usercancreate)) {
230 $bulkaction = $massaction;
231 $error = 0;
232
233 // The mass action can only target the variants of this product
234 $childids = array();
235 $tmpcombinations = $prodcomb->fetchAllByFkProductParent($object->id);
236 if (is_array($tmpcombinations)) {
237 foreach ($tmpcombinations as $tmpcombination) {
238 $childids[] = (int) $tmpcombination->fk_product_child;
239 }
240 }
241
242 $db->begin();
243
244 foreach ($toselect as $prodid) {
245 if (!in_array((int) $prodid, $childids)) {
246 continue;
247 }
248 // need create new of Product to prevent rename dir behavior
249 $prodstatic = new Product($db);
250 if ($prodstatic->fetch($prodid) < 0) {
251 continue;
252 }
253
254 if ($bulkaction == 'on_sell') {
255 $prodstatic->status = 1;
256 $res = $prodstatic->update($prodstatic->id, $user);
257 if ($res <= 0) {
258 setEventMessages($prodstatic->error, $prodstatic->errors, 'errors');
259 $error++;
260 break;
261 }
262 } elseif ($bulkaction == 'on_buy') {
263 $prodstatic->status_buy = 1;
264 $res = $prodstatic->update($prodstatic->id, $user);
265 if ($res <= 0) {
266 setEventMessages($prodstatic->error, $prodstatic->errors, 'errors');
267 $error++;
268 break;
269 }
270 } elseif ($bulkaction == 'not_sell') {
271 $prodstatic->status = 0;
272 $res = $prodstatic->update($prodstatic->id, $user);
273 if ($res <= 0) {
274 setEventMessages($prodstatic->error, $prodstatic->errors, 'errors');
275 $error++;
276 break;
277 }
278 } elseif ($bulkaction == 'not_buy') {
279 $prodstatic->status_buy = 0;
280 $res = $prodstatic->update($prodstatic->id, $user);
281 if ($res <= 0) {
282 setEventMessages($prodstatic->error, $prodstatic->errors, 'errors');
283 $error++;
284 break;
285 }
286 } elseif ($bulkaction == 'delete') {
287 $res = $prodstatic->delete($user, $prodstatic->id);
288 if ($res <= 0) {
289 setEventMessages($prodstatic->error, $prodstatic->errors, 'errors');
290 $error++;
291 break;
292 }
293 } else {
294 break;
295 }
296 }
297
298 if ($error) {
299 $db->rollback();
300 if (empty($prodstatic->error)) {
301 setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
302 }
303 } else {
304 $db->commit();
305 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
306 }
307} elseif ($action === 'update' && $combination_id > 0 && $usercancreate) {
308 if ($prodcomb->fetch($combination_id) < 0) {
309 dol_print_error($db, $langs->trans('ErrorRecordNotFound'));
310 exit();
311 }
312
313 $prodcomb->variation_weight = (float) price2num($weight_impact);
314
315 // for conf PRODUIT_MULTIPRICES
316 if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
317 $prodcomb->variation_price = $level_price_impact[1];
318 $prodcomb->variation_price_percentage = $level_price_impact_percent[1];
319 } else {
320 $level_price_impact = array(1 => $price_impact);
321 $level_price_impact_percent = array(1 => $price_impact_percent);
322
323 $prodcomb->variation_price = $price_impact;
324 $prodcomb->variation_price_percentage = $price_impact_percent;
325 }
326
327 if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
328 $prodcomb->combination_price_levels = array();
329 $maxi = getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT');
330 for ($i = 1; $i <= $maxi; $i++) {
331 $productCombinationLevel = new ProductCombinationLevel($db);
332 $productCombinationLevel->fk_product_attribute_combination = $prodcomb->id;
333 $productCombinationLevel->fk_price_level = $i;
334 $productCombinationLevel->variation_price = (float) $level_price_impact[$i];
335 $productCombinationLevel->variation_price_percentage = (bool) $level_price_impact_percent[$i];
336 $prodcomb->combination_price_levels[$i] = $productCombinationLevel;
337 }
338 }
339
340 $error = 0;
341 $db->begin();
342
343 // Update product variant ref
344 $product_child = new Product($db);
345 $product_child->fetch($prodcomb->fk_product_child);
346 $product_child->oldcopy = clone $product_child; // @phan-suppress-current-line PhanTypeMismatchProperty
347 $product_child->ref = $reference;
348
349 $result = $product_child->update($product_child->id, $user);
350 if ($result < 0) {
351 setEventMessages($product_child->error, $product_child->errors, 'errors');
352 $error++;
353 }
354
355 if (!$error) {
356 // Update product variant infos
357 $result = $prodcomb->update($user);
358 if ($result < 0) {
359 setEventMessages($prodcomb->error, $prodcomb->errors, 'errors');
360 $error++;
361 }
362 }
363
364 if (!$error) {
365 $db->commit();
366 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
367 header('Location: ' . dol_buildpath('/variants/combinations.php?id=' . $id, 2));
368 exit();
369 } else {
370 $db->rollback();
371 }
372}
373
374
375// Reload variants
376$productCombinations = $prodcomb->fetchAllByFkProductParent($object->id, true);
377
378if ($action === 'confirm_deletecombination' && $usercancreate) {
379 if ($prodcomb->fetch($combination_id) > 0) {
380 $db->begin();
381
382 if ($prodcomb->delete($user) > 0 && (empty($delete_product) || ($delete_product == 'on' && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0))) {
383 $db->commit();
384 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
385 header('Location: '.dol_buildpath('/variants/combinations.php?id='.$object->id, 2));
386 exit();
387 }
388
389 $db->rollback();
390 setEventMessages($langs->trans('ProductCombinationAlreadyUsed'), null, 'errors');
391 $action = '';
392 }
393} elseif ($action === 'edit' && $usercancreate) {
394 if ($prodcomb->fetch($combination_id) < 0) {
395 dol_print_error($db, $langs->trans('ErrorRecordNotFound'));
396 exit();
397 }
398
399 $product_child = new Product($db);
400 $product_child->fetch($prodcomb->fk_product_child);
401 $reference = (string) $product_child->ref;
402 $weight_impact = $prodcomb->variation_weight;
403 $price_impact = $prodcomb->variation_price;
404 $price_impact_percent = $prodcomb->variation_price_percentage;
405
406 $productCombination2ValuePairs1 = $prodcomb2val->fetchByFkCombination($combination_id);
407} elseif ($action === 'confirm_copycombination' && $usercancreate) {
408 //Check destination product
409 $dest_product = GETPOST('dest_product');
410
411 if ($prodstatic->fetch(0, $dest_product) > 0) {
412 //To prevent from copying to the same product
413 if ($prodstatic->ref != $object->ref) {
414 if ($prodcomb->copyAll($user, $object->id, $prodstatic) > 0) {
415 header('Location: '.dol_buildpath('/variants/combinations.php?id='.$prodstatic->id, 2));
416 exit();
417 } else {
418 setEventMessages($langs->trans('ErrorCopyProductCombinations'), null, 'errors');
419 }
420 }
421 } else {
422 setEventMessages($langs->trans('ErrorDestinationProductNotFound'), null, 'errors');
423 }
424}
425
426
427
428/*
429 * View
430 */
431
432$form = new Form($db);
433
434$title = $langs->trans("Variant");
435
436llxHeader("", $title);
437
438
439if (!empty($id) || !empty($ref)) {
440 $showbarcode = isModEnabled('barcode');
441 if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('barcode', 'lire_advance')) {
442 $showbarcode = 0;
443 }
444
445 $head = product_prepare_head($object);
446 $titre = $langs->trans("CardProduct".$object->type);
447 $picto = $object->isService() ? 'service' : 'product';
448
449 print dol_get_fiche_head($head, 'combinations', $titre, -1, $picto);
450
451 $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?type='.((int) $object->type).'">'.$langs->trans("BackToList").'</a>';
452 $object->next_prev_filter = "(te.fk_product_type:=:".((int) $object->type).")";
453
454 dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', '', '', '', 0, '', '');
455
456 print '<div class="fichecenter">';
457
458 print '<div class="underbanner clearboth"></div>';
459 print '<table class="border centpercent tableforfield">';
460
461 // Type
462 if (isModEnabled("product") && isModEnabled("service")) {
463 $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service");
464 print '<tr><td class="titlefieldcreate">';
465 print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', (string) $object->type, $object, 0, $typeformat) : $langs->trans('Type');
466 print '</td><td>';
467 print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat);
468 print '</td></tr>';
469 }
470
471 // TVA
472 print '<tr><td class="titlefieldcreate">'.$langs->trans("DefaultTaxRate").'</td><td>';
473
474 $positiverates = '';
475 if (price2num($object->tva_tx)) {
476 $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx);
477 }
478 if (price2num($object->localtax1_type)) {
479 $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx);
480 }
481 if (price2num($object->localtax2_type)) {
482 $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx);
483 }
484 if (empty($positiverates)) {
485 $positiverates = '0';
486 }
487 echo vatrate($positiverates.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), true, $object->tva_npr);
488 /*
489 if ($object->default_vat_code)
490 {
491 print vatrate($object->tva_tx, true) . ' ('.$object->default_vat_code.')';
492 }
493 else print vatrate($object->tva_tx, true, $object->tva_npr, true);*/
494 print '</td></tr>';
495
496 // Price
497 print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>';
498 if ($object->price_base_type == 'TTC') {
499 print price($object->price_ttc).' '.$langs->trans($object->price_base_type);
500 } else {
501 print price($object->price).' '.$langs->trans($object->price_base_type);
502 }
503 print '</td></tr>';
504
505 // Price minimum
506 print '<tr><td>'.$langs->trans("MinPrice").'</td><td>';
507 if ($object->price_base_type == 'TTC') {
508 print price($object->price_min_ttc).' '.$langs->trans($object->price_base_type);
509 } else {
510 print price($object->price_min).' '.$langs->trans($object->price_base_type);
511 }
512 print '</td></tr>';
513
514 // Weight
515 print '<tr><td>'.$langs->trans("Weight").'</td><td>';
516 if ($object->weight != '') {
517 print $object->weight." ".measuringUnitString(0, "weight", $object->weight_units);
518 } else {
519 print '&nbsp;';
520 }
521 print "</td></tr>\n";
522
523 print "</table>\n";
524
525 print '</div>';
526 print '<div class="clearboth"></div>';
527
528 print dol_get_fiche_end();
529
530 $listofvariantselected = '';
531
532 // Create or edit a variant
533 if ($action == 'add' || ($action == 'edit')) {
534 if ($action == 'add') {
535 $title = $langs->trans('NewProductCombination');
536 // print dol_get_fiche_head();
537 $features = !empty($_SESSION['addvariant_'.$object->id]) ? $_SESSION['addvariant_'.$object->id] : array();
538 //First, sanitize
539 $listofvariantselected = '<div id="parttoaddvariant">';
540 if (!empty($features)) {
541 $toprint = array();
542 foreach ($features as $feature) {
543 $explode = explode('-', $feature);
544 if ($prodattr->fetch((int) $explode[0]) <= 0 || $prodattr_val->fetch((int) $explode[1]) <= 0) {
545 continue;
546 }
547 $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #ddd;">' . $prodattr->label.' : '.$prodattr_val->value .
548 ' <a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=create&subaction=delete&feature='.urlencode($feature).'">' . img_delete() . '</a></li>';
549 }
550 $listofvariantselected .= '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
551 }
552 $listofvariantselected .= '</div>';
553 //print dol_get_fiche_end();
554 } else {
555 $title = $langs->trans('EditProductCombination');
556 }
557
558 $prodattr_alljson = null;
559 $prodattr_all = null;
560 if ($action == 'add') {
561 $prodattr_all = $prodattr->fetchAll();
562
563 if (!$selected && !empty($prodattr_all)) {
564 $selected = $prodattr_all[key($prodattr_all)]->id;
565 }
566
567 $prodattr_alljson = array();
568
569 foreach ($prodattr_all as $each) {
570 $prodattr_alljson[$each->id] = $each;
571 } ?>
572
573 <script type="text/javascript">
574
575 variants_available = <?php echo json_encode($prodattr_alljson, JSON_PARTIAL_OUTPUT_ON_ERROR); ?>;
576 variants_selected = {
577 index: [],
578 info: []
579 };
580
581 <?php
582 foreach ($productCombination2ValuePairs1 as $pc2v) {
583 $prodattr_val->fetch($pc2v->fk_prod_attr_val); ?>
584 variants_selected.index.push(<?php echo $pc2v->fk_prod_attr ?>);
585 variants_selected.info[<?php echo $pc2v->fk_prod_attr ?>] = {
586 attribute: variants_available[<?php echo $pc2v->fk_prod_attr ?>],
587 value: {
588 id: <?php echo $pc2v->fk_prod_attr_val ?>,
589 label: '<?php echo $prodattr_val->value ?>'
590 }
591 };
592 <?php
593 } ?>
594
595 restoreAttributes = function() {
596 jQuery("select[name=attribute]").empty().append('<option value="-1">&nbsp;</option>');
597
598 jQuery.each(variants_available, function (key, val) {
599 if (jQuery.inArray(val.id, variants_selected.index) == -1) {
600 jQuery("select[name=attribute]").append('<option value="' + val.id + '">' + val.label + '</option>');
601 }
602 });
603 };
604
605
606 jQuery(document).ready(function() {
607 jQuery("select#attribute").change(function () {
608 console.log("Change of field variant attribute");
609 var select = jQuery("select#value");
610
611 if (!jQuery(this).val().length || jQuery(this).val() == '-1') {
612 select.empty();
613 select.append('<option value="-1">&nbsp;</option>');
614 return;
615 }
616
617 select.empty().append('<option value="">Loading...</option>');
618
619 jQuery.getJSON("ajax/get_attribute_values.php", {
620 id: jQuery(this).val()
621 }, function(data) {
622 if (data.error) {
623 select.empty();
624 select.append('<option value="-1">&nbsp;</option>');
625 return alert(data.error);
626 }
627
628 select.empty();
629 select.append('<option value="-1">&nbsp;</option>');
630
631 jQuery(data).each(function (key, val) {
632 keyforoption = val.id
633 valforoption = val.value
634 select.append('<option value="' + keyforoption + '">' + valforoption + '</option>');
635 });
636 });
637 });
638 });
639 </script>
640
641 <?php
642 }
643
644 print '<br>';
645
646 print load_fiche_titre($title);
647
648 print '<form method="post" id="combinationform" action="'.$_SERVER["PHP_SELF"] .'?id='.$object->id.'">'."\n";
649 print '<input type="hidden" name="token" value="'.newToken().'">';
650 print '<input type="hidden" name="action" value="'.(($combination_id > 0) ? "update" : "create").'">'."\n";
651 if ($combination_id > 0) {
652 print '<input type="hidden" name="combination_id" value="'.$combination_id.'">'."\n";
653 }
654
655 print dol_get_fiche_head();
656
657
658 if ($action == 'add') {
659 print '<table class="border" style="width: 100%">';
660 print "<!-- Variant -->\n";
661 print '<tr>';
662 print '<td class="titlefieldcreate fieldrequired"><label for="attribute">'.$langs->trans('ProductAttribute').'</label></td>';
663 print '<td>';
664 if (is_array($prodattr_all)) {
665 print '<select class="flat minwidth100" id="attribute" name="attribute">';
666 print '<option value="-1">&nbsp;</option>';
667 foreach ($prodattr_all as $attr) {
668 //print '<option value="'.$attr->id.'"'.($attr->id == GETPOST('attribute', 'int') ? ' selected="selected"' : '').'>'.$attr->label.'</option>';
669 print '<option value="'.$attr->id.'">'.$attr->label.'</option>';
670 }
671 print '</select>';
672 }
673
674 $htmltext = $langs->trans("GoOnMenuToCreateVairants", $langs->transnoentities("Product"), $langs->transnoentities("VariantAttributes"));
675 print $form->textwithpicto('', $htmltext);
676 /*print ' &nbsp; &nbsp; <a href="'.DOL_URL_ROOT.'/variants/create.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=add&token='.newToken().'&id='.$object->id).'">';
677 print $langs->trans("Create");
678 print '</a>';*/
679
680 print '</td>';
681 print '</tr>'; ?>
682 <!-- Value -->
683 <tr>
684 <td class="fieldrequired"><label for="value"><?php echo $langs->trans('Value') ?></label></td>
685 <td>
686 <select class="flat minwidth100" id="value" name="value">
687 <option value="-1">&nbsp;</option>
688 </select>
689 <?php
690 $htmltext = $langs->trans("GoOnMenuToCreateVairants", $langs->transnoentities("Product"), $langs->transnoentities("VariantAttributes"));
691 print $form->textwithpicto('', $htmltext);
692 /*
693 print ' &nbsp; &nbsp; <a href="'.DOL_URL_ROOT.'/variants/create.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=add&token='.newToken().'&id='.$object->id).'">';
694 print $langs->trans("Create");
695 print '</a>';
696 */ ?>
697 </td>
698 </tr>
699 <tr>
700 <td></td><td>
701 <input type="submit" class="button" name="selectvariant" id="selectvariant" value="<?php echo dol_escape_htmltag($langs->trans("SelectCombination")); ?>">
702 </td>
703 </tr>
704 <?php
705 print '<tr><td></td><td>';
706 print $listofvariantselected;
707 print '</td>';
708 print '</tr>';
709
710 print '</table>';
711 print '<hr>';
712 }
713
714 if (is_array($productCombination2ValuePairs1)) {
715 print '<table class="border" style="width: 100%">';
716
717 // When in edit mode
718 if (is_array($productCombination2ValuePairs1) && count($productCombination2ValuePairs1)) {
719 ?>
720 <tr>
721 <td class="titlefieldcreate tdtop"><label for="features"><?php echo $langs->trans('Attributes') ?></label></td>
722 <td class="tdtop">
723 <div class="inline-block valignmiddle quatrevingtpercent">
724 <?php
725 foreach ($productCombination2ValuePairs1 as $pc2v) {
726 $result1 = $prodattr->fetch($pc2v->fk_prod_attr);
727 $result2 = $prodattr_val->fetch($pc2v->fk_prod_attr_val);
728 if ($result1 > 0 && $result2 > 0) {
729 print $prodattr->label.' : '.$prodattr_val->value.'<br>';
730 // TODO Add delete link
731 }
732 } ?>
733 </div>
734 <!-- <div class="inline-block valignmiddle">
735 <a href="#" class="inline-block valignmiddle button" id="delfeature"><?php echo img_edit_remove() ?></a>
736 </div>-->
737 </td>
738 <td>
739 </td>
740 </tr>
741 <?php
742 } ?>
743 <tr>
744 <td><label for="reference"><?php echo $langs->trans('Reference') ?></label></td>
745 <td><input type="text" id="reference" name="reference" value="<?php echo trim($reference) ?>" spellcheck="false"></td>
746 </tr>
747 <?php
748 if (!getDolGlobalString('PRODUIT_MULTIPRICES') && !getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
749 ?>
750 <tr>
751 <td><label for="price_impact"><?php echo $langs->trans('PriceImpact') ?></label></td>
752 <td><input type="text" id="price_impact" name="price_impact" value="<?php echo price($price_impact) ?>">
753
754 <input type="checkbox" id="price_impact_percent" name="price_impact_percent" <?php echo ($price_impact_percent ? ' checked' : '') ?>> <label for="price_impact_percent"><?php echo $langs->trans('PercentageVariation') ?></label>
755 </td>
756 </tr>
757 <?php
758 } else {
759 $prodcomb->fetchCombinationPriceLevels();
760
761 $maxi = getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT');
762 for ($i = 1; $i <= $maxi; $i++) {
763 $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i;
764 $text = $langs->trans('ImpactOnPriceLevel', $i).' - '.getDolGlobalString($keyforlabel);
765 print '<tr>';
766 print '<td><label for="level_price_impact_'.$i.'">'.$text.'</label>';
767 if ($i === 1) {
768 print '<br/><a id="apply-price-impact-to-all-level" class="classfortooltip" href="#" title="'.$langs->trans('ApplyToAllPriceImpactLevelHelp').'">('.$langs->trans('ApplyToAllPriceImpactLevel').')</a>';
769 }
770 print '</td>';
771 print '<td><input type="text" class="level_price_impact" id="level_price_impact_'.$i.'" name="level_price_impact['.$i.']" value="'.price($prodcomb->combination_price_levels[$i]->variation_price).'">';
772 print '<span class="paddingleft"></span>';
773 print '<input type="checkbox" class="level_price_impact_percent" id="level_price_impact_percent_'.$i.'" name="level_price_impact_percent['.$i.']" '.($prodcomb->combination_price_levels[$i]->variation_price_percentage ? ' checked' : '').'> <label for="level_price_impact_percent_'.$i.'">'.$langs->trans('PercentageVariation').'</label>';
774
775 print '</td>';
776 print '</tr>';
777 }
778 }
779
780 if ($object->isProduct()) {
781 print '<tr>';
782 print '<td><label for="weight_impact">'.$langs->trans('WeightImpact').'</label></td>';
783 print '<td><input type="text" id="weight_impact" name="weight_impact" value="'.price($weight_impact).'"></td>';
784 print '</tr>';
785 }
786
787 print '<tr>';
788 print '<td><label for="clone_categories">'.$langs->trans('CloneCategoriesProduct').'</label></td>';
789 print '<td><input type="checkbox" id="clone_categories" name="clone_categories"></td>';
790 print '</tr>';
791
792 print '</table>';
793 }
794
795 if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
796 ?>
797 <script>
798 $(document).ready(function() {
799 // Apply level 1 impact to all prices impact levels
800 $('body').on('click', '#apply-price-impact-to-all-level', function(e) {
801 e.preventDefault();
802 let priceImpact = $( "#level_price_impact_1" ).val();
803 let priceImpactPrecent = $( "#level_price_impact_percent_1" ).prop("checked");
804
805 let multipricelimit = <?php print getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT'); ?>
806
807 for (let i = 2; i <= multipricelimit; i++) {
808 $( "#level_price_impact_" + i ).val(priceImpact);
809 $( "#level_price_impact_percent_" + i ).prop("checked", priceImpactPrecent);
810 }
811 });
812 });
813 </script>
814 <?php
815 }
816
817 print dol_get_fiche_end(); ?>
818
819 <div style="text-align: center">
820 <input type="submit" name="create" <?php if (!is_array($productCombination2ValuePairs1)) {
821 print ' disabled="disabled"';
822 } ?> value="<?php echo $action == 'add' ? $langs->trans('Create') : $langs->trans("Save") ?>" class="button button-save">
823 &nbsp;
824 <input type="submit" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>" class="button button-cancel">
825 </div>
826
827 <?php
828
829 print '</form>';
830 } else {
831 if ($action === 'delete') {
832 if ($prodcomb->fetch($combination_id) > 0) {
833 $prodstatic->fetch($prodcomb->fk_product_child);
834
835 print $form->formconfirm(
836 "combinations.php?id=".urlencode((string) ($id))."&combination_id=".urlencode((string) ($combination_id)),
837 $langs->trans('Delete'),
838 $langs->trans('ProductCombinationDeleteDialog', $prodstatic->ref),
839 "confirm_deletecombination",
840 array(array('label' => $langs->trans('DeleteLinkedProduct'), 'type' => 'checkbox', 'name' => 'delete_product', 'value' => false)),
841 0,
842 1
843 );
844 }
845 } elseif ($action === 'copy') {
846 print $form->formconfirm('combinations.php?id='.$id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneProductCombinations'), 'confirm_copycombination', array(array('type' => 'text', 'label' => $langs->trans('CloneDestinationReference'), 'name' => 'dest_product')), 0, 1);
847 }
848
849 $comb2val = new ProductCombination2ValuePair($db);
850
851 if ($productCombinations) {
852 ?>
853
854 <script type="text/javascript">
855 jQuery(document).ready(function() {
856
857 jQuery('input[name="select_all"]').click(function() {
858
859 if (jQuery(this).prop('checked')) {
860 var checked = true;
861 } else {
862 var checked = false;
863 }
864
865 jQuery('table.liste input[type="checkbox"]').prop('checked', checked);
866 });
867
868 jQuery('input[name^="select["]').click(function() {
869 jQuery('input[name="select_all"]').prop('checked', false);
870 });
871
872 });
873 </script>
874
875 <?php
876 }
877
878 // Buttons
879 print '<div class="tabsAction">';
880
881 print ' <div class="inline-block divButAction">';
882
883 print '<a href="combinations.php?id='.$object->id.'&action=add&token='.newToken().'" class="butAction">'.$langs->trans('NewProductCombination').'</a>'; // NewVariant
884
885 if ($productCombinations) {
886 print '<a href="combinations.php?id='.$object->id.'&action=copy&token='.newToken().'" class="butAction">'.$langs->trans('PropagateVariant').'</a>';
887 }
888
889 print ' </div>';
890
891 print '</div>';
892
893
894
895 $arrayofselected = is_array($toselect) ? $toselect : array();
896
897
898 // List of variants
899 print '<form method="POST" action="'.$_SERVER["PHP_SELF"] .'?id='.$object->id.'">';
900 print '<input type="hidden" name="token" value="'.newToken().'">';
901 print '<input type="hidden" name="action" value="massaction">';
902 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
903
904 // List of mass actions available
905
906 $aaa = '';
907 if (count($productCombinations)) {
908 $aaa = '<select id="bulk_action" name="massaction" class="minwidth250">';
909 $aaa .= ' <option value="nothing">&nbsp;</option>';
910 $aaa .= ' <option value="not_buy" data-html="'.dol_escape_htmltag(img_picto($langs->trans("SetToStatus"), 'stop-circle', 'class="pictofixedwidth"').$langs->trans('SetToStatus', $langs->transnoentitiesnoconv('ProductStatusNotOnBuy'))).'">'.$langs->trans('ProductStatusNotOnBuy').'</option>';
911 $aaa .= ' <option value="not_sell" data-html="'.dol_escape_htmltag(img_picto($langs->trans("SetToStatus"), 'stop-circle', 'class="pictofixedwidth"').$langs->trans('SetToStatus', $langs->transnoentitiesnoconv('ProductStatusNotOnSell'))).'">'.$langs->trans('ProductStatusNotOnSell').'</option>';
912 $aaa .= ' <option value="on_buy" data-html="'.dol_escape_htmltag(img_picto($langs->trans("SetToStatus"), 'stop-circle', 'class="pictofixedwidth"').$langs->trans('SetToStatus', $langs->transnoentitiesnoconv('ProductStatusOnBuy'))).'">'.$langs->trans('ProductStatusOnBuy').'</option>';
913 $aaa .= ' <option value="on_sell" data-html="'.dol_escape_htmltag(img_picto($langs->trans("SetToStatus"), 'stop-circle', 'class="pictofixedwidth"').$langs->trans('SetToStatus', $langs->transnoentitiesnoconv('ProductStatusOnSell'))).'">'.$langs->trans('ProductStatusOnSell').'</option>';
914 $aaa .= ' <option value="delete" data-html="'.dol_escape_htmltag(img_picto($langs->trans("Delete"), 'delete', 'class="pictofixedwidth"').$langs->trans('Delete')).'">'.$langs->trans('Delete').'</option>';
915 $aaa .= '</select>';
916 $aaa .= ajax_combobox("bulk_action");
917 $aaa .= '<input type="submit" value="'.dol_escape_htmltag($langs->trans("Apply")).'" class="button small">';
918 }
919 $massactionbutton = $aaa;
920
921 $title = $langs->trans("ProductCombinations");
922
923 print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $aaa, 0);
924
925 print '<div class="div-table-responsive">'; ?>
926 <table class="liste">
927 <tr class="liste_titre">
928 <?php
929 // Action column
930 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
931 print '<td class="liste_titre center">';
932 $searchpicto = $form->showCheckAddButtons('checkforselect', 1);
933 print $searchpicto;
934 print '</td>';
935 } ?>
936 <td class="liste_titre"><?php echo $langs->trans('Product') ?></td>
937 <td class="liste_titre"><?php echo $langs->trans('Attributes') ?></td>
938 <td class="liste_titre right"><?php echo $langs->trans('PriceImpact') ?></td>
939 <?php if ($object->isProduct()) {
940 print'<td class="liste_titre right">'.$langs->trans('WeightImpact').'</td>';
941 } ?>
942 <td class="liste_titre center"><?php echo $langs->trans('OnSell') ?></td>
943 <td class="liste_titre center"><?php echo $langs->trans('OnBuy') ?></td>
944 <td class="liste_titre"></td>
945 <?php
946 // Action column
947 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
948 print '<td class="liste_titre center">';
949 $searchpicto = $form->showCheckAddButtons('checkforselect', 1);
950 print $searchpicto;
951 print '</td>';
952 } ?>
953 </tr>
954 <?php
955
956 if (count($productCombinations)) {
957 foreach ($productCombinations as $currcomb) {
958 $prodstatic->fetch($currcomb->fk_product_child);
959 print '<tr class="oddeven">';
960
961 // Action column
962 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
963 print '<td class="nowrap center">';
964 if (!empty($productCombinations) || $massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
965 $selected = 0;
966 if (in_array($prodstatic->id, $arrayofselected)) {
967 $selected = 1;
968 }
969 print '<input id="cb'.$prodstatic->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$prodstatic->id.'"'.($selected ? ' checked="checked"' : '').'>';
970 }
971 print '</td>';
972 }
973
974 print '<td>'.$prodstatic->getNomUrl(1).'</td>';
975 print '<td>';
976 foreach ($comb2val->fetchByFkCombination($currcomb->id) as $pc2v) {
977 print dol_htmlentities($pc2v).'<br>';
978 }
979 print '</td>';
980 print '<td class="right">'.($currcomb->variation_price >= 0 ? '+' : '').price($currcomb->variation_price).($currcomb->variation_price_percentage ? ' %' : '').'</td>';
981 if ($object->isProduct()) {
982 print '<td class="right">'.($currcomb->variation_weight >= 0 ? '+' : '').price($currcomb->variation_weight).' '.measuringUnitString(0, 'weight', $prodstatic->weight_units).'</td>';
983 }
984 print '<td class="center">'.$prodstatic->getLibStatut(2, 0).'</td>';
985 print '<td class="center">'.$prodstatic->getLibStatut(2, 1).'</td>';
986
987 print '<td class="right">';
988 print '<a class="paddingleft paddingright editfielda" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=edit&token='.newToken().'&combination_id='.$currcomb->id.'">'.img_edit().'</a>';
989 print '<a class="paddingleft paddingright" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=delete&token='.newToken().'&combination_id='.$currcomb->id.'">'.img_delete().'</a>';
990 print '</td>';
991
992 // Action column
993 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
994 print '<td class="nowrap center">';
995 if (!empty($productCombinations) || $massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
996 $selected = 0;
997 if (in_array($prodstatic->id, $arrayofselected)) {
998 $selected = 1;
999 }
1000 print '<input id="cb'.$prodstatic->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$prodstatic->id.'"'.($selected ? ' checked="checked"' : '').'>';
1001 }
1002 print '</td>';
1003 }
1004
1005 print '</tr>';
1006 }
1007 } else {
1008 print '<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
1009 }
1010 print '</table>';
1011 print '</div>';
1012 print '</form>';
1013 }
1014}
1015
1016// End of page
1017llxFooter();
1018$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition ajax.lib.php:475
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage generation of HTML components Only common components must be here.
Class ProductAttribute Used to represent a Product attribute Examples:
Class ProductAttributeValue Used to represent a product attribute value.
Class ProductCombination2ValuePair Used to represent the relation between a variant and its attribute...
Class ProductCombination Used to represent the relation between a product and one of its variants.
Class ProductCombinationLevel Used to represent a product combination Level.
Class to manage products or services.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
img_edit_remove($titlealt='default', $other='')
Show logo "-".
treeview li table
No Email.
measuringUnitString($unitid, $measuring_style='', $unitscale=null, $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
product_prepare_head($object)
Prepare array with list of tabs.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:132
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:135
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.