21 require
'../main.inc.php';
22 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
23 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
24 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttribute.class.php';
25 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttributeValue.class.php';
26 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination2ValuePair.class.php';
29 $langs->loadLangs(array(
"products",
"other"));
32 $valueid =
GETPOST(
'valueid',
'int');
35 $price_impact_percent = (bool)
GETPOST(
'price_impact_percent');
36 if ($price_impact_percent) {
41 $level_price_impact =
GETPOST(
'level_price_impact',
'array');
42 $level_price_impact_percent =
GETPOST(
'level_price_impact_percent',
'array');
44 $reference =
GETPOST(
'reference',
'alpha');
47 $action =
GETPOST(
'action',
'aZ09');
48 $massaction =
GETPOST(
'massaction',
'alpha');
49 $show_files =
GETPOST(
'show_files',
'int');
50 $confirm =
GETPOST(
'confirm',
'alpha');
51 $toselect =
GETPOST(
'toselect',
'array');
52 $cancel =
GETPOST(
'cancel',
'alpha');
53 $delete_product =
GETPOST(
'delete_product',
'alpha');
54 $subaction =
GETPOST(
'subaction',
'aZ09');
55 $backtopage =
GETPOST(
'backtopage',
'alpha');
56 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
57 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
60 $fieldvalue = (!empty($id) ? $id : $ref);
61 $fieldtype = (!empty($ref) ?
'ref' :
'rowid');
68 if ($id > 0 || $ref) {
69 $object->fetch($id, $ref);
72 $selectedvariant = !empty($_SESSION[
'addvariant_'.$object->id]) ? $_SESSION[
'addvariant_'.$object->id] : array();
75 if (empty($conf->variants->enabled)) {
78 if ($user->socid > 0) {
82 if ($object->id > 0) {
83 if ($object->type == $object::TYPE_PRODUCT) {
84 restrictedArea($user,
'produit', $object->id,
'product&product',
'',
'');
86 if ($object->type == $object::TYPE_SERVICE) {
87 restrictedArea($user,
'service', $object->id,
'product&product',
'',
'');
90 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
104 unset($_SESSION[
'addvariant_'.$object->id]);
107 if (!$object->isProduct() && !$object->isService()) {
108 header(
'Location: '.
dol_buildpath(
'/product/card.php?id='.$object->id, 2));
111 if ($action ==
'add') {
112 unset($selectedvariant);
113 unset($_SESSION[
'addvariant_'.$object->id]);
115 if ($action ==
'create' &&
GETPOST(
'selectvariant',
'alpha')) {
117 $attribute_id =
GETPOST(
'attribute',
'int');
118 $attribute_value_id =
GETPOST(
'value',
'int');
119 if ($attribute_id> 0 && $attribute_value_id > 0) {
120 $feature = $attribute_id .
'-' . $attribute_value_id;
121 $selectedvariant[$feature] = $feature;
122 $_SESSION[
'addvariant_'.$object->id] = $selectedvariant;
125 if ($action ==
'create' && $subaction ==
'delete') {
127 $feature =
GETPOST(
'feature',
'intcomma');
128 if (isset($selectedvariant[$feature])) {
129 unset($selectedvariant[$feature]);
130 $_SESSION[
'addvariant_'.$object->id] = $selectedvariant;
138 $productCombination2ValuePairs1 = array();
140 if (($action ==
'add' || $action ==
'create') && empty($massaction) && !
GETPOST(
'selectvariant',
'alpha') && empty($subaction)) {
142 $features = $_SESSION[
'addvariant_'.$object->id];
145 if ($action ==
'create') {
149 $reference = trim($reference);
150 if (empty($reference)) {
153 $weight_impact =
price2num($weight_impact);
154 $price_impact =
price2num($price_impact);
157 if ($conf->global->PRODUIT_MULTIPRICES) {
158 $level_price_impact = array_map(
'price2num', $level_price_impact);
160 $level_price_impact = array(1 => $price_impact);
161 $level_price_impact_percent = array(1 => $price_impact_percent);
164 $sanit_features = array();
167 foreach ($features as $feature) {
168 $explode = explode(
'-', $feature);
169 if ($prodattr->fetch($explode[0]) <= 0 || $prodattr_val->fetch($explode[1]) <= 0) {
174 $sanit_features[$explode[0]] = $explode[1];
177 $tmp->fk_prod_attr = $explode[0];
178 $tmp->fk_prod_attr_val = $explode[1];
180 $productCombination2ValuePairs1[] = $tmp;
188 if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) {
189 $result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $level_price_impact_percent, $level_price_impact, $weight_impact, $reference);
192 unset($_SESSION[
'addvariant_'.$object->id]);
195 header(
'Location: '.
dol_buildpath(
'/variants/combinations.php?id='.$id, 2));
198 $langs->load(
"errors");
202 setEventMessages($langs->trans(
'ErrorRecordAlreadyExists'), null,
'errors');
207 } elseif (!empty($massaction)) {
208 $bulkaction = $massaction;
213 foreach ($toselect as $prodid) {
215 $prodstatic =
new Product($db);
216 if ($prodstatic->fetch($prodid) < 0) {
220 if ($bulkaction ==
'on_sell') {
221 $prodstatic->status = 1;
222 $res = $prodstatic->update($prodstatic->id, $user);
228 } elseif ($bulkaction ==
'on_buy') {
229 $prodstatic->status_buy = 1;
230 $res = $prodstatic->update($prodstatic->id, $user);
236 } elseif ($bulkaction ==
'not_sell') {
237 $prodstatic->status = 0;
238 $res = $prodstatic->update($prodstatic->id, $user);
244 } elseif ($bulkaction ==
'not_buy') {
245 $prodstatic->status_buy = 0;
246 $res = $prodstatic->update($prodstatic->id, $user);
252 } elseif ($bulkaction ==
'delete') {
253 $res = $prodstatic->delete($user, $prodstatic->id);
266 if (empty($prodstatic->error)) {
273 } elseif ($action ===
'update' && $valueid > 0) {
274 if ($prodcomb->fetch($valueid) < 0) {
279 $prodcomb->variation_weight =
price2num($weight_impact);
282 if ($conf->global->PRODUIT_MULTIPRICES) {
283 $level_price_impact = array_map(
'price2num', $level_price_impact);
285 $prodcomb->variation_price = $level_price_impact[1];
286 $prodcomb->variation_price_percentage = (bool) $level_price_impact_percent[1];
288 $level_price_impact = array(1 => $price_impact);
289 $level_price_impact_percent = array(1 => $price_impact_percent);
291 $prodcomb->variation_price = $price_impact;
292 $prodcomb->variation_price_percentage = $price_impact_percent;
295 if ($conf->global->PRODUIT_MULTIPRICES) {
296 $prodcomb->combination_price_levels = array();
297 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
299 $productCombinationLevel->fk_product_attribute_combination = $prodcomb->id;
300 $productCombinationLevel->fk_price_level = $i;
301 $productCombinationLevel->variation_price = $level_price_impact[$i];
302 $productCombinationLevel->variation_price_percentage = (bool) $level_price_impact_percent[$i];
303 $prodcomb->combination_price_levels[$i] = $productCombinationLevel;
307 if ($prodcomb->update($user) > 0) {
309 header(
'Location: '.
dol_buildpath(
'/variants/combinations.php?id='.$id, 2));
318 $productCombinations = $prodcomb->fetchAllByFkProductParent($object->id);
320 if ($action ===
'confirm_deletecombination') {
321 if ($prodcomb->fetch($valueid) > 0) {
324 if ($prodcomb->delete($user) > 0 && (empty($delete_product) || ($delete_product ==
'on' && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0))) {
327 header(
'Location: '.
dol_buildpath(
'/variants/combinations.php?id='.$object->id, 2));
332 setEventMessages($langs->trans(
'ProductCombinationAlreadyUsed'), null,
'errors');
335 } elseif ($action ===
'edit') {
336 if ($prodcomb->fetch($valueid) < 0) {
341 $weight_impact = $prodcomb->variation_weight;
342 $price_impact = $prodcomb->variation_price;
343 $price_impact_percent = $prodcomb->variation_price_percentage;
345 $productCombination2ValuePairs1 = $prodcomb2val->fetchByFkCombination($valueid);
346 } elseif ($action ===
'confirm_copycombination') {
348 $dest_product =
GETPOST(
'dest_product');
350 if ($prodstatic->fetch(
'', $dest_product) > 0) {
352 if ($prodstatic->ref != $object->ref) {
353 if ($prodcomb->copyAll($user, $object->id, $prodstatic) > 0) {
354 header(
'Location: '.
dol_buildpath(
'/variants/combinations.php?id='.$prodstatic->id, 2));
357 setEventMessages($langs->trans(
'ErrorCopyProductCombinations'), null,
'errors');
361 setEventMessages($langs->trans(
'ErrorDestinationProductNotFound'), null,
'errors');
373 if (!empty($id) || !empty($ref)) {
374 llxHeader(
"",
"", $langs->trans(
"CardProduct".$object->type));
376 $showbarcode = empty($conf->barcode->enabled) ? 0 : 1;
377 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
382 $titre = $langs->trans(
"CardProduct".$object->type);
387 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?type='.$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
388 $object->next_prev_filter =
" fk_product_type = ".$object->type;
390 dol_banner_tab($object,
'ref', $linkback, ($user->socid ? 0 : 1),
'ref',
'',
'',
'', 0,
'',
'');
392 print
'<div class="fichecenter">';
394 print
'<div class="underbanner clearboth"></div>';
395 print
'<table class="border centpercent tableforfield">';
398 if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) {
399 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
400 print
'<tr><td class="titlefieldcreate">';
401 print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ?
$form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans(
'Type');
403 print
$form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, $usercancreate, $typeformat);
408 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
412 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->tva_tx);
414 if (
price2num($object->localtax1_type)) {
415 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax1_tx);
417 if (
price2num($object->localtax2_type)) {
418 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax2_tx);
420 if (empty($positiverates)) {
421 $positiverates =
'0';
423 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
433 print
'<tr><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
434 if ($object->price_base_type ==
'TTC') {
435 print
price($object->price_ttc).
' '.$langs->trans($object->price_base_type);
437 print
price($object->price).
' '.$langs->trans($object->price_base_type);
442 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td>';
443 if ($object->price_base_type ==
'TTC') {
444 print
price($object->price_min_ttc).
' '.$langs->trans($object->price_base_type);
446 print
price($object->price_min).
' '.$langs->trans($object->price_base_type);
451 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
452 if ($object->weight !=
'') {
457 print
"</td></tr>\n";
462 print
'<div style="clear:both"></div>';
466 $listofvariantselected =
'';
469 if ($action ==
'add' || ($action ==
'edit')) {
470 if ($action ==
'add') {
471 $title = $langs->trans(
'NewProductCombination');
473 $features = $_SESSION[
'addvariant_'.$object->id];
475 $listofvariantselected =
'<div id="parttoaddvariant">';
476 if (!empty($features)) {
478 foreach ($features as $feature) {
479 $explode = explode(
'-', $feature);
480 if ($prodattr->fetch($explode[0]) <= 0 || $prodattr_val->fetch($explode[1]) <= 0) {
483 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #ddd;">' . $prodattr->label.
' : '.$prodattr_val->value .
484 ' <a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=create&subaction=delete&feature='.urlencode($feature).
'">' .
img_delete() .
'</a></li>';
486 $listofvariantselected .=
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
488 $listofvariantselected .=
'</div>';
491 $title = $langs->trans(
'EditProductCombination');
494 if ($action ==
'add') {
495 $prodattr_all = $prodattr->fetchAll();
498 $selected = $prodattr_all[key($prodattr_all)]->id;
501 $prodattr_alljson = array();
503 foreach ($prodattr_all as $each) {
504 $prodattr_alljson[$each->id] = $each;
509 <script
type=
"text/javascript">
511 variants_available = <?php echo json_encode($prodattr_alljson); ?>;
512 variants_selected = {
518 foreach ($productCombination2ValuePairs1 as $pc2v) {
519 $prodattr_val->fetch($pc2v->fk_prod_attr_val);
521 variants_selected.index.push(<?php echo $pc2v->fk_prod_attr ?>);
522 variants_selected.info[<?php echo $pc2v->fk_prod_attr ?>] = {
523 attribute: variants_available[<?php echo $pc2v->fk_prod_attr ?>],
525 id: <?php echo $pc2v->fk_prod_attr_val ?>,
526 label:
'<?php echo $prodattr_val->value ?>'
533 restoreAttributes =
function() {
534 jQuery(
"select[name=attribute]").empty().append(
'<option value="-1"> </option>');
536 jQuery.each(variants_available,
function (key, val) {
537 if (jQuery.inArray(val.id, variants_selected.index) == -1) {
538 jQuery(
"select[name=attribute]").append(
'<option value="' + val.id +
'">' + val.label +
'</option>');
544 jQuery(document).ready(
function() {
545 jQuery(
"select#attribute").change(
function () {
546 console.log(
"Change of field variant attribute");
547 var select = jQuery(
"select#value");
549 if (!jQuery(
this).val().length || jQuery(
this).val() ==
'-1') {
551 select.append(
'<option value="-1"> </option>');
555 select.empty().append(
'<option value="">Loading...</option>');
557 jQuery.getJSON(
"ajax/get_attribute_values.php", {
558 id: jQuery(
this).val()
562 select.append(
'<option value="-1"> </option>');
563 return alert(data.error);
567 select.append(
'<option value="-1"> </option>');
569 jQuery(data).each(
function (key, val) {
570 keyforoption = val.id
571 valforoption = val.value
572 select.append(
'<option value="' + keyforoption +
'">' + valforoption +
'</option>');
586 print
'<form method="post" id="combinationform" action="'.$_SERVER[
"PHP_SELF"] .
'?id='.$object->id.
'">'.
"\n";
587 print
'<input type="hidden" name="token" value="'.newToken().
'">';
588 print
'<input type="hidden" name="action" value="'.(($valueid > 0) ?
"update" :
"create").
'">'.
"\n";
590 print
'<input type="hidden" name="valueid" value="'.$valueid.
'">'.
"\n";
596 if ($action ==
'add') {
597 print
'<table class="border" style="width: 100%">';
598 print
"<!-- Variant -->\n";
600 print
'<td class="titlefieldcreate fieldrequired"><label for="attribute">'.$langs->trans(
'ProductAttribute').
'</label></td>';
602 if (is_array($prodattr_all)) {
603 print
'<select class="flat minwidth100" id="attribute" name="attribute">';
604 print
'<option value="-1"> </option>';
605 foreach ($prodattr_all as $attr) {
607 print
'<option value="'.$attr->id.
'">'.$attr->label.
'</option>';
612 $htmltext = $langs->trans(
"GoOnMenuToCreateVairants", $langs->transnoentities(
"Product"), $langs->transnoentities(
"VariantAttributes"));
613 print
$form->textwithpicto(
'', $htmltext);
623 <td
class=
"fieldrequired"><label
for=
"value"><?php echo $langs->trans(
'Value') ?></label></td>
625 <select
class=
"flat minwidth100" id=
"value" name=
"value">
626 <option value=
"-1"> </option>
629 $htmltext = $langs->trans(
"GoOnMenuToCreateVairants", $langs->transnoentities(
"Product"), $langs->transnoentities(
"VariantAttributes"));
630 print
$form->textwithpicto(
'', $htmltext);
641 <input type=
"submit" class=
"button" name=
"selectvariant" id=
"selectvariant" value=
"<?php echo dol_escape_htmltag($langs->trans("SelectCombination
")); ?>">
645 print
'<tr><td></td><td>';
646 print $listofvariantselected;
654 if (is_array($productCombination2ValuePairs1)) {
655 print
'<table class="border" style="width: 100%">';
658 if (is_array($productCombination2ValuePairs1) && count($productCombination2ValuePairs1)) {
661 <td
class=
"titlefieldcreate tdtop"><label
for=
"features"><?php echo $langs->trans(
'Combination') ?></label></td>
663 <div
class=
"inline-block valignmiddle quatrevingtpercent">
665 foreach ($productCombination2ValuePairs1 as $key => $val) {
666 $result1 = $prodattr->fetch($val->fk_prod_attr);
667 $result2 = $prodattr_val->fetch($val->fk_prod_attr_val);
669 if ($result1 > 0 && $result2 > 0) {
670 print $prodattr->label.
' - '.$prodattr_val->value.
'<br>';
676 <!-- <div
class=
"inline-block valignmiddle">
677 <a href=
"#" class=
"inline-block valignmiddle button" id=
"delfeature"><?php echo
img_edit_remove() ?></a>
687 <td><label
for=
"reference"><?php echo $langs->trans(
'Reference') ?></label></td>
688 <td><input type=
"text" id=
"reference" name=
"reference" value=
"<?php echo trim($reference) ?>"></td>
691 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
694 <td><label
for=
"price_impact"><?php echo $langs->trans(
'PriceImpact') ?></label></td>
695 <td><input type=
"text" id=
"price_impact" name=
"price_impact" value=
"<?php echo price($price_impact) ?>">
696 <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>
701 $prodcomb->fetchCombinationPriceLevels();
703 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
705 print
'<td><label for="level_price_impact_'.$i.
'">'.$langs->trans(
'ImpactOnPriceLevel', $i).
'</label>';
707 print
' <a id="apply-price-impact-to-all-level" class="classfortooltip" href="#" title="'.$langs->trans(
'ApplyToAllPriceImpactLevelHelp').
'">('.$langs->trans(
'ApplyToAllPriceImpactLevel').
')</a>';
710 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).
'">';
711 print
'<input type="checkbox" class="level_price_impact_percent" id="level_price_impact_percent_'.$i.
'" name="level_price_impact_percent['.$i.
']" '.(!empty($prodcomb->combination_price_levels[$i]->variation_price_percentage) ?
' checked' :
'').
'> <label for="level_price_impact_percent_'.$i.
'">'.$langs->trans(
'PercentageVariation').
'</label>';
718 if ($object->isProduct()) {
720 print
'<td><label for="weight_impact">'.$langs->trans(
'WeightImpact').
'</label></td>';
721 print
'<td><input type="text" id="weight_impact" name="weight_impact" value="'.price($weight_impact).
'"></td>';
728 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
731 $(document).ready(
function() {
733 $(
'body').on(
'click',
'#apply-price-impact-to-all-level',
function(e) {
735 let priceImpact = $(
"#level_price_impact_1" ).val();
736 let priceImpactPrecent = $(
"#level_price_impact_percent_1" ).prop(
"checked");
738 var multipricelimit = <?php print intval($conf->global->PRODUIT_MULTIPRICES_LIMIT); ?>
740 for (let i = 2; i <= multipricelimit; i++) {
741 $(
"#level_price_impact_" + i ).val(priceImpact);
742 $(
"#level_price_impact_percent_" + i ).prop(
"checked", priceImpactPrecent);
753 <div style=
"text-align: center">
754 <input type=
"submit" name=
"create" <?php
if (!is_array($productCombination2ValuePairs1)) {
755 print
' disabled="disabled"';
756 } ?> value=
"<?php echo $action == 'add' ? $langs->trans('Create') : $langs->trans("Save
") ?>" class=
"button button-save">
758 <input type=
"submit" name=
"cancel" value=
"<?php echo $langs->trans("Cancel
"); ?>" class=
"button button-cancel">
765 if ($action ===
'delete') {
766 if ($prodcomb->fetch($valueid) > 0) {
767 $prodstatic->fetch($prodcomb->fk_product_child);
769 print
$form->formconfirm(
770 "combinations.php?id=".urlencode($id).
"&valueid=".urlencode($valueid),
771 $langs->trans(
'Delete'),
772 $langs->trans(
'ProductCombinationDeleteDialog', $prodstatic->ref),
773 "confirm_deletecombination",
774 array(array(
'label'=> $langs->trans(
'DeleteLinkedProduct'),
'type'=>
'checkbox',
'name' =>
'delete_product',
'value' =>
false)),
779 } elseif ($action ===
'copy') {
780 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);
785 if ($productCombinations) {
788 <script type=
"text/javascript">
789 jQuery(document).ready(
function() {
791 jQuery(
'input[name="select_all"]').click(
function() {
793 if (jQuery(
this).prop(
'checked')) {
799 jQuery(
'table.liste input[type="checkbox"]').prop(
'checked', checked);
802 jQuery(
'input[name^="select["]').click(
function() {
803 jQuery(
'input[name="select_all"]').prop(
'checked',
false);
813 print
'<div class="tabsAction">';
815 print
' <div class="inline-block divButAction">';
817 print
'<a href="combinations.php?id='.$object->id.
'&action=add&token='.
newToken().
'" class="butAction">'.$langs->trans(
'NewProductCombination').
'</a>';
819 if ($productCombinations) {
820 print
'<a href="combinations.php?id='.$object->id.
'&action=copy&token='.
newToken().
'" class="butAction">'.$langs->trans(
'PropagateVariant').
'</a>';
829 $arrayofselected = is_array($toselect) ? $toselect : array();
833 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"] .
'?id='.$object->id.
'">';
834 print
'<input type="hidden" name="token" value="'.newToken().
'">';
835 print
'<input type="hidden" name="action" value="massaction">';
836 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
850 if (count($productCombinations)) {
851 $aaa =
'<label for="massaction">'.$langs->trans(
'BulkActions').
'</label>';
852 $aaa .=
'<select id="bulk_action" name="massaction" class="flat">';
853 $aaa .=
' <option value="nothing"> </option>';
854 $aaa .=
' <option value="not_buy">'.$langs->trans(
'ProductStatusNotOnBuy').
'</option>';
855 $aaa .=
' <option value="not_sell">'.$langs->trans(
'ProductStatusNotOnSell').
'</option>';
856 $aaa .=
' <option value="on_buy">'.$langs->trans(
'ProductStatusOnBuy').
'</option>';
857 $aaa .=
' <option value="on_sell">'.$langs->trans(
'ProductStatusOnSell').
'</option>';
858 $aaa .=
' <option value="delete">'.$langs->trans(
'Delete').
'</option>';
860 $aaa .=
'<input type="submit" value="'.dol_escape_htmltag($langs->trans(
"Apply")).
'" class="button small">';
862 $massactionbutton = $aaa;
864 $title = $langs->trans(
"ProductCombinations");
866 print_barre_liste($title, 0, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder, $aaa, 0);
868 print
'<div class="div-table-responsive">';
870 <table
class=
"liste">
871 <tr
class=
"liste_titre">
872 <td
class=
"liste_titre"><?php echo $langs->trans(
'Product') ?></td>
873 <td
class=
"liste_titre"><?php echo $langs->trans(
'Combination') ?></td>
874 <td
class=
"liste_titre right"><?php echo $langs->trans(
'PriceImpact') ?></td>
875 <?php
if ($object->isProduct()) {
876 print
'<td class="liste_titre right">'.$langs->trans(
'WeightImpact').
'</td>';
878 <td
class=
"liste_titre center"><?php echo $langs->trans(
'OnSell') ?></td>
879 <td
class=
"liste_titre center"><?php echo $langs->trans(
'OnBuy') ?></td>
880 <td
class=
"liste_titre"></td>
882 print
'<td class="liste_titre center">';
883 $searchpicto =
$form->showCheckAddButtons(
'checkforselect', 1);
890 if (count($productCombinations)) {
891 foreach ($productCombinations as $currcomb) {
892 $prodstatic->fetch($currcomb->fk_product_child);
893 print
'<tr class="oddeven">';
894 print
'<td>'.$prodstatic->getNomUrl(1).
'</td>';
897 $productCombination2ValuePairs = $comb2val->fetchByFkCombination($currcomb->id);
898 $iMax = count($productCombination2ValuePairs);
900 for ($i = 0; $i < $iMax; $i++) {
902 if ($i !== ($iMax - 1)) {
907 print
'<td class="right">'.($currcomb->variation_price >= 0 ?
'+' :
'').
price($currcomb->variation_price).($currcomb->variation_price_percentage ?
' %' :
'').
'</td>';
908 if ($object->isProduct()) {
909 print
'<td class="right">'.($currcomb->variation_weight >= 0 ?
'+' :
'').
price($currcomb->variation_weight).
' '.
measuringUnitString(0,
'weight', $prodstatic->weight_units).
'</td>';
911 print
'<td class="center">'.$prodstatic->getLibStatut(2, 0).
'</td>';
912 print
'<td class="center">'.$prodstatic->getLibStatut(2, 1).
'</td>';
913 print
'<td class="right">';
914 print
'<a class="paddingleft paddingright editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=edit&token='.
newToken().
'&valueid='.$currcomb->id.
'">'.
img_edit().
'</a>';
915 print
'<a class="paddingleft paddingright" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=delete&token='.
newToken().
'&valueid='.$currcomb->id.
'">'.
img_delete().
'</a>';
917 print
'<td class="nowrap center">';
918 if (!empty($productCombinations) || $massactionbutton || $massaction) {
920 if (in_array($prodstatic->id, $arrayofselected)) {
923 print
'<input id="cb'.$prodstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$prodstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
929 print
'<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
Class to manage products or services.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
const TYPE_SERVICE
Service.
const TYPE_PRODUCT
Regular product.
Class ProductAttributeValue Used to represent a product attribute value.
$conf db name
Only used if Module[ID]Name translation string is not found.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Class ProductAttribute Used to represent a product attribute.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
Class ProductCombinationLevel Used to represent a product combination Level.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class ProductCombination Used to represent a product combination.
restrictedArea($user, $features, $objectid=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.
img_edit_remove($titlealt= 'default', $other= '')
Show logo -.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
Class ProductCombination2ValuePair Used to represent the relation between a product combination...
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
product_prepare_head($object)
Prepare array with list of tabs.
measuringUnitString($unit, $measuring_style= '', $scale= '', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...