22require
'../main.inc.php';
23require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
24require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
25require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttribute.class.php';
26require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttributeValue.class.php';
27require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination2ValuePair.class.php';
30$langs->loadLangs(array(
"products",
"other"));
33$valueid =
GETPOST(
'valueid',
'int');
36$price_impact_percent = (bool)
GETPOST(
'price_impact_percent');
37if ($price_impact_percent) {
42$level_price_impact =
GETPOST(
'level_price_impact',
'array');
43$level_price_impact_percent =
GETPOST(
'level_price_impact_percent',
'array');
45$reference =
GETPOST(
'reference',
'alpha');
48$action =
GETPOST(
'action',
'aZ09');
49$massaction =
GETPOST(
'massaction',
'alpha');
50$show_files =
GETPOST(
'show_files',
'int');
51$confirm =
GETPOST(
'confirm',
'alpha');
52$toselect =
GETPOST(
'toselect',
'array');
53$cancel =
GETPOST(
'cancel',
'alpha');
54$delete_product =
GETPOST(
'delete_product',
'alpha');
55$subaction =
GETPOST(
'subaction',
'aZ09');
56$backtopage =
GETPOST(
'backtopage',
'alpha');
57$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
58$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
61$fieldvalue = (!empty($id) ? $id : $ref);
62$fieldtype = (!empty($ref) ?
'ref' :
'rowid');
70 $object->fetch($id, $ref);
73$selectedvariant = !empty($_SESSION[
'addvariant_'.$object->id]) ? $_SESSION[
'addvariant_'.$object->id] : array();
76if (!isModEnabled(
'variants')) {
79if ($user->socid > 0) {
84 if ($object->type == $object::TYPE_PRODUCT) {
85 restrictedArea($user,
'produit', $object->id,
'product&product',
'',
'');
87 if ($object->type == $object::TYPE_SERVICE) {
88 restrictedArea($user,
'service', $object->id,
'product&product',
'',
'');
91 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
105 unset($_SESSION[
'addvariant_'.$object->id]);
108if (!$object->isProduct() && !$object->isService()) {
109 header(
'Location: '.
dol_buildpath(
'/product/card.php?id='.$object->id, 2));
112if ($action ==
'add') {
113 unset($selectedvariant);
114 unset($_SESSION[
'addvariant_'.$object->id]);
116if ($action ==
'create' &&
GETPOST(
'selectvariant',
'alpha')) {
118 $attribute_id =
GETPOST(
'attribute',
'int');
119 $attribute_value_id =
GETPOST(
'value',
'int');
120 if ($attribute_id> 0 && $attribute_value_id > 0) {
121 $feature = $attribute_id .
'-' . $attribute_value_id;
122 $selectedvariant[$feature] = $feature;
123 $_SESSION[
'addvariant_'.$object->id] = $selectedvariant;
126if ($action ==
'create' && $subaction ==
'delete') {
128 $feature =
GETPOST(
'feature',
'intcomma');
129 if (isset($selectedvariant[$feature])) {
130 unset($selectedvariant[$feature]);
131 $_SESSION[
'addvariant_'.$object->id] = $selectedvariant;
139$productCombination2ValuePairs1 = array();
141if (($action ==
'add' || $action ==
'create') && empty($massaction) && !
GETPOST(
'selectvariant',
'alpha') && empty($subaction)) {
143 $features = !empty($_SESSION[
'addvariant_'.$object->id]) ? $_SESSION[
'addvariant_'.$object->id] : array();
146 if ($action ==
'create') {
150 $reference = trim($reference);
151 if (empty($reference)) {
154 $weight_impact =
price2num($weight_impact);
155 $price_impact =
price2num($price_impact);
158 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
159 $level_price_impact = array_map(
'price2num', $level_price_impact);
161 $level_price_impact = array(1 => $price_impact);
162 $level_price_impact_percent = array(1 => $price_impact_percent);
165 $sanit_features = array();
168 foreach ($features as $feature) {
169 $explode = explode(
'-', $feature);
170 if ($prodattr->fetch($explode[0]) <= 0 || $prodattr_val->fetch($explode[1]) <= 0) {
175 $sanit_features[$explode[0]] = $explode[1];
178 $tmp->fk_prod_attr = (int) $explode[0];
179 $tmp->fk_prod_attr_val = (int) $explode[1];
181 $productCombination2ValuePairs1[] = $tmp;
189 if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) {
190 $result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $level_price_impact_percent, $level_price_impact, $weight_impact, $reference);
193 unset($_SESSION[
'addvariant_'.$object->id]);
196 header(
'Location: '.
dol_buildpath(
'/variants/combinations.php?id='.$id, 2));
199 $langs->load(
"errors");
203 setEventMessages($langs->trans(
'ErrorRecordAlreadyExists'),
null,
'errors');
208} elseif (!empty($massaction)) {
209 $bulkaction = $massaction;
214 foreach ($toselect as $prodid) {
216 $prodstatic =
new Product($db);
217 if ($prodstatic->fetch($prodid) < 0) {
221 if ($bulkaction ==
'on_sell') {
222 $prodstatic->status = 1;
223 $res = $prodstatic->update($prodstatic->id, $user);
229 } elseif ($bulkaction ==
'on_buy') {
230 $prodstatic->status_buy = 1;
231 $res = $prodstatic->update($prodstatic->id, $user);
237 } elseif ($bulkaction ==
'not_sell') {
238 $prodstatic->status = 0;
239 $res = $prodstatic->update($prodstatic->id, $user);
245 } elseif ($bulkaction ==
'not_buy') {
246 $prodstatic->status_buy = 0;
247 $res = $prodstatic->update($prodstatic->id, $user);
253 } elseif ($bulkaction ==
'delete') {
254 $res = $prodstatic->delete($user, $prodstatic->id);
267 if (empty($prodstatic->error)) {
274} elseif ($action ===
'update' && $valueid > 0) {
275 if ($prodcomb->fetch($valueid) < 0) {
280 $prodcomb->variation_weight =
price2num($weight_impact);
283 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
284 $level_price_impact = array_map(
'price2num', $level_price_impact);
286 $prodcomb->variation_price = $level_price_impact[1];
287 $prodcomb->variation_price_percentage = (bool) $level_price_impact_percent[1];
289 $level_price_impact = array(1 => $price_impact);
290 $level_price_impact_percent = array(1 => $price_impact_percent);
292 $prodcomb->variation_price = $price_impact;
293 $prodcomb->variation_price_percentage = $price_impact_percent;
296 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
297 $prodcomb->combination_price_levels = array();
298 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
300 $productCombinationLevel->fk_product_attribute_combination = $prodcomb->id;
301 $productCombinationLevel->fk_price_level = $i;
302 $productCombinationLevel->variation_price = $level_price_impact[$i];
303 $productCombinationLevel->variation_price_percentage = (bool) $level_price_impact_percent[$i];
304 $prodcomb->combination_price_levels[$i] = $productCombinationLevel;
312 $product_child =
new Product($db);
313 $product_child->fetch($prodcomb->fk_product_child);
314 $product_child->oldcopy = clone $product_child;
315 $product_child->ref = $reference;
317 $result = $product_child->update($product_child->id, $user);
325 $result = $prodcomb->update($user);
335 header(
'Location: ' .
dol_buildpath(
'/variants/combinations.php?id=' . $id, 2));
344$productCombinations = $prodcomb->fetchAllByFkProductParent($object->id);
346if ($action ===
'confirm_deletecombination') {
347 if ($prodcomb->fetch($valueid) > 0) {
350 if ($prodcomb->delete($user) > 0 && (empty($delete_product) || ($delete_product ==
'on' && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0))) {
353 header(
'Location: '.
dol_buildpath(
'/variants/combinations.php?id='.$object->id, 2));
358 setEventMessages($langs->trans(
'ProductCombinationAlreadyUsed'),
null,
'errors');
361} elseif ($action ===
'edit') {
362 if ($prodcomb->fetch($valueid) < 0) {
367 $product_child =
new Product($db);
368 $product_child->fetch($prodcomb->fk_product_child);
369 $reference = $product_child->ref;
370 $weight_impact = $prodcomb->variation_weight;
371 $price_impact = $prodcomb->variation_price;
372 $price_impact_percent = $prodcomb->variation_price_percentage;
374 $productCombination2ValuePairs1 = $prodcomb2val->fetchByFkCombination($valueid);
375} elseif ($action ===
'confirm_copycombination') {
377 $dest_product =
GETPOST(
'dest_product');
379 if ($prodstatic->fetch(
'', $dest_product) > 0) {
381 if ($prodstatic->ref != $object->ref) {
382 if ($prodcomb->copyAll($user, $object->id, $prodstatic) > 0) {
383 header(
'Location: '.
dol_buildpath(
'/variants/combinations.php?id='.$prodstatic->id, 2));
386 setEventMessages($langs->trans(
'ErrorCopyProductCombinations'),
null,
'errors');
390 setEventMessages($langs->trans(
'ErrorDestinationProductNotFound'),
null,
'errors');
400$form =
new Form($db);
402$title = $langs->trans(
"Variant");
407if (!empty($id) || !empty($ref)) {
408 $showbarcode = isModEnabled(
'barcode');
409 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
414 $titre = $langs->trans(
"CardProduct".$object->type);
419 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?type='.((int) $object->type).
'">'.$langs->trans(
"BackToList").
'</a>';
420 $object->next_prev_filter =
"fk_product_type = ".((int) $object->type);
422 dol_banner_tab($object,
'ref', $linkback, ($user->socid ? 0 : 1),
'ref',
'',
'',
'', 0,
'',
'');
424 print
'<div class="fichecenter">';
426 print
'<div class="underbanner clearboth"></div>';
427 print
'<table class="border centpercent tableforfield">';
430 if (isModEnabled(
"product") && isModEnabled(
"service")) {
431 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
432 print
'<tr><td class="titlefieldcreate">';
433 print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans(
'Type');
435 print $form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, $usercancreate, $typeformat);
440 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
444 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->tva_tx);
446 if (
price2num($object->localtax1_type)) {
447 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax1_tx);
449 if (
price2num($object->localtax2_type)) {
450 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax2_tx);
452 if (empty($positiverates)) {
453 $positiverates =
'0';
455 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
465 print
'<tr><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
466 if ($object->price_base_type ==
'TTC') {
467 print
price($object->price_ttc).
' '.$langs->trans($object->price_base_type);
469 print
price($object->price).
' '.$langs->trans($object->price_base_type);
474 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td>';
475 if ($object->price_base_type ==
'TTC') {
476 print
price($object->price_min_ttc).
' '.$langs->trans($object->price_base_type);
478 print
price($object->price_min).
' '.$langs->trans($object->price_base_type);
483 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
484 if ($object->weight !=
'') {
489 print
"</td></tr>\n";
494 print
'<div class="clearboth"></div>';
498 $listofvariantselected =
'';
501 if ($action ==
'add' || ($action ==
'edit')) {
502 if ($action ==
'add') {
503 $title = $langs->trans(
'NewProductCombination');
505 $features = !empty($_SESSION[
'addvariant_'.$object->id]) ? $_SESSION[
'addvariant_'.$object->id] : array();
507 $listofvariantselected =
'<div id="parttoaddvariant">';
508 if (!empty($features)) {
510 foreach ($features as $feature) {
511 $explode = explode(
'-', $feature);
512 if ($prodattr->fetch($explode[0]) <= 0 || $prodattr_val->fetch($explode[1]) <= 0) {
515 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #ddd;">' . $prodattr->label.
' : '.$prodattr_val->value .
516 ' <a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=create&subaction=delete&feature='.urlencode($feature).
'">' .
img_delete() .
'</a></li>';
518 $listofvariantselected .=
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
520 $listofvariantselected .=
'</div>';
523 $title = $langs->trans(
'EditProductCombination');
526 if ($action ==
'add') {
527 $prodattr_all = $prodattr->fetchAll();
530 $selected = $prodattr_all[key($prodattr_all)]->id;
533 $prodattr_alljson = array();
535 foreach ($prodattr_all as $each) {
536 $prodattr_alljson[$each->id] = $each;
540 <script
type=
"text/javascript">
542 variants_available = <?php echo json_encode($prodattr_alljson, JSON_PARTIAL_OUTPUT_ON_ERROR); ?>;
543 variants_selected = {
549 foreach ($productCombination2ValuePairs1 as $pc2v) {
550 $prodattr_val->fetch($pc2v->fk_prod_attr_val);
552 variants_selected.index.push(<?php echo $pc2v->fk_prod_attr ?>);
553 variants_selected.info[<?php echo $pc2v->fk_prod_attr ?>] = {
554 attribute: variants_available[<?php echo $pc2v->fk_prod_attr ?>],
556 id: <?php echo $pc2v->fk_prod_attr_val ?>,
557 label:
'<?php echo $prodattr_val->value ?>'
564 restoreAttributes =
function() {
565 jQuery(
"select[name=attribute]").empty().append(
'<option value="-1"> </option>');
567 jQuery.each(variants_available,
function (key, val) {
568 if (jQuery.inArray(val.id, variants_selected.index) == -1) {
569 jQuery(
"select[name=attribute]").append(
'<option value="' + val.id +
'">' + val.label +
'</option>');
575 jQuery(document).ready(
function() {
576 jQuery(
"select#attribute").change(
function () {
577 console.log(
"Change of field variant attribute");
578 var select = jQuery(
"select#value");
580 if (!jQuery(
this).val().length || jQuery(
this).val() ==
'-1') {
582 select.append(
'<option value="-1"> </option>');
586 select.empty().append(
'<option value="">Loading...</option>');
588 jQuery.getJSON(
"ajax/get_attribute_values.php", {
589 id: jQuery(
this).val()
593 select.append(
'<option value="-1"> </option>');
594 return alert(data.error);
598 select.append(
'<option value="-1"> </option>');
600 jQuery(data).each(
function (key, val) {
601 keyforoption = val.id
602 valforoption = val.value
603 select.append(
'<option value="' + keyforoption +
'">' + valforoption +
'</option>');
617 print
'<form method="post" id="combinationform" action="'.$_SERVER[
"PHP_SELF"] .
'?id='.$object->id.
'">'.
"\n";
618 print
'<input type="hidden" name="token" value="'.newToken().
'">';
619 print
'<input type="hidden" name="action" value="'.(($valueid > 0) ?
"update" :
"create").
'">'.
"\n";
621 print
'<input type="hidden" name="valueid" value="'.$valueid.
'">'.
"\n";
627 if ($action ==
'add') {
628 print
'<table class="border" style="width: 100%">';
629 print
"<!-- Variant -->\n";
631 print
'<td class="titlefieldcreate fieldrequired"><label for="attribute">'.$langs->trans(
'ProductAttribute').
'</label></td>';
633 if (is_array($prodattr_all)) {
634 print
'<select class="flat minwidth100" id="attribute" name="attribute">';
635 print
'<option value="-1"> </option>';
636 foreach ($prodattr_all as $attr) {
638 print
'<option value="'.$attr->id.
'">'.$attr->label.
'</option>';
643 $htmltext = $langs->trans(
"GoOnMenuToCreateVairants", $langs->transnoentities(
"Product"), $langs->transnoentities(
"VariantAttributes"));
644 print $form->textwithpicto(
'', $htmltext);
654 <td
class=
"fieldrequired"><label
for=
"value"><?php echo $langs->trans(
'Value') ?></label></td>
656 <select
class=
"flat minwidth100" id=
"value" name=
"value">
657 <option value=
"-1"> </option>
660 $htmltext = $langs->trans(
"GoOnMenuToCreateVairants", $langs->transnoentities(
"Product"), $langs->transnoentities(
"VariantAttributes"));
661 print $form->textwithpicto(
'', $htmltext);
672 <input
type=
"submit" class=
"button" name=
"selectvariant" id=
"selectvariant" value=
"<?php echo dol_escape_htmltag($langs->trans("SelectCombination
")); ?>">
676 print
'<tr><td></td><td>';
677 print $listofvariantselected;
685 if (is_array($productCombination2ValuePairs1)) {
686 print
'<table class="border" style="width: 100%">';
689 if (is_array($productCombination2ValuePairs1) && count($productCombination2ValuePairs1)) {
692 <td
class=
"titlefieldcreate tdtop"><label
for=
"features"><?php echo $langs->trans(
'Attributes') ?></label></td>
694 <div
class=
"inline-block valignmiddle quatrevingtpercent">
696 foreach ($productCombination2ValuePairs1 as $key => $val) {
697 $result1 = $prodattr->fetch($val->fk_prod_attr);
698 $result2 = $prodattr_val->fetch($val->fk_prod_attr_val);
700 if ($result1 > 0 && $result2 > 0) {
701 print $prodattr->label.
' : '.$prodattr_val->value.
'<br>';
707 <!-- <div
class=
"inline-block valignmiddle">
708 <a href=
"#" class=
"inline-block valignmiddle button" id=
"delfeature"><?php echo
img_edit_remove() ?></a>
718 <td><label
for=
"reference"><?php echo $langs->trans(
'Reference') ?></label></td>
719 <td><input
type=
"text" id=
"reference" name=
"reference" value=
"<?php echo trim($reference) ?>"></td>
722 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
725 <td><label
for=
"price_impact"><?php echo $langs->trans(
'PriceImpact') ?></label></td>
726 <td><input
type=
"text" id=
"price_impact" name=
"price_impact" value=
"<?php echo price($price_impact) ?>">
727 <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>
732 $prodcomb->fetchCombinationPriceLevels();
734 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
736 print
'<td><label for="level_price_impact_'.$i.
'">'.$langs->trans(
'ImpactOnPriceLevel', $i).
'</label>';
738 print
' <a id="apply-price-impact-to-all-level" class="classfortooltip" href="#" title="'.$langs->trans(
'ApplyToAllPriceImpactLevelHelp').
'">('.$langs->trans(
'ApplyToAllPriceImpactLevel').
')</a>';
741 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).
'">';
742 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>';
749 if ($object->isProduct()) {
751 print
'<td><label for="weight_impact">'.$langs->trans(
'WeightImpact').
'</label></td>';
752 print
'<td><input type="text" id="weight_impact" name="weight_impact" value="'.price($weight_impact).
'"></td>';
759 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
762 $(document).ready(
function() {
764 $(
'body').on(
'click',
'#apply-price-impact-to-all-level',
function(e) {
766 let priceImpact = $(
"#level_price_impact_1" ).val();
767 let priceImpactPrecent = $(
"#level_price_impact_percent_1" ).prop(
"checked");
769 var multipricelimit = <?php print intval($conf->global->PRODUIT_MULTIPRICES_LIMIT); ?>
771 for (let i = 2; i <= multipricelimit; i++) {
772 $(
"#level_price_impact_" + i ).val(priceImpact);
773 $(
"#level_price_impact_percent_" + i ).prop(
"checked", priceImpactPrecent);
784 <div style=
"text-align: center">
785 <input
type=
"submit" name=
"create" <?php
if (!is_array($productCombination2ValuePairs1)) {
786 print
' disabled="disabled"';
787 } ?> value=
"<?php echo $action == 'add' ? $langs->trans('Create') : $langs->trans("Save
") ?>" class=
"button button-save">
789 <input
type=
"submit" name=
"cancel" value=
"<?php echo $langs->trans("Cancel
"); ?>" class=
"button button-cancel">
796 if ($action ===
'delete') {
797 if ($prodcomb->fetch($valueid) > 0) {
798 $prodstatic->fetch($prodcomb->fk_product_child);
800 print $form->formconfirm(
801 "combinations.php?id=".urlencode($id).
"&valueid=".urlencode($valueid),
802 $langs->trans(
'Delete'),
803 $langs->trans(
'ProductCombinationDeleteDialog', $prodstatic->ref),
804 "confirm_deletecombination",
805 array(array(
'label'=> $langs->trans(
'DeleteLinkedProduct'),
'type'=>
'checkbox',
'name' =>
'delete_product',
'value' =>
false)),
810 } elseif ($action ===
'copy') {
811 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);
816 if ($productCombinations) {
819 <script
type=
"text/javascript">
820 jQuery(document).ready(
function() {
822 jQuery(
'input[name="select_all"]').click(
function() {
824 if (jQuery(
this).prop(
'checked')) {
830 jQuery(
'table.liste input[type="checkbox"]').prop(
'checked', checked);
833 jQuery(
'input[name^="select["]').click(
function() {
834 jQuery(
'input[name="select_all"]').prop(
'checked',
false);
844 print
'<div class="tabsAction">';
846 print
' <div class="inline-block divButAction">';
848 print
'<a href="combinations.php?id='.$object->id.
'&action=add&token='.newToken().
'" class="butAction">'.$langs->trans(
'NewProductCombination').
'</a>';
850 if ($productCombinations) {
851 print
'<a href="combinations.php?id='.$object->id.
'&action=copy&token='.newToken().
'" class="butAction">'.$langs->trans(
'PropagateVariant').
'</a>';
860 $arrayofselected = is_array($toselect) ? $toselect : array();
864 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"] .
'?id='.$object->id.
'">';
865 print
'<input type="hidden" name="token" value="'.newToken().
'">';
866 print
'<input type="hidden" name="action" value="massaction">';
867 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
881 if (count($productCombinations)) {
882 $aaa =
'<select id="bulk_action" name="massaction" class="flat">';
883 $aaa .=
' <option value="nothing"> </option>';
884 $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>';
885 $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>';
886 $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>';
887 $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>';
888 $aaa .=
' <option value="delete" data-html="'.dol_escape_htmltag(
img_picto($langs->trans(
"Delete"),
'delete',
'class="pictofixedwidth"').$langs->trans(
'Delete')).
'">'.$langs->trans(
'Delete').
'</option>';
891 $aaa .=
'<input type="submit" value="'.dol_escape_htmltag($langs->trans(
"Apply")).
'" class="button small">';
893 $massactionbutton = $aaa;
895 $title = $langs->trans(
"ProductCombinations");
897 print_barre_liste($title, 0, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder, $aaa, 0);
899 print
'<div class="div-table-responsive">';
901 <table
class=
"liste">
902 <tr
class=
"liste_titre">
906 print
'<td class="liste_titre center">';
907 $searchpicto = $form->showCheckAddButtons(
'checkforselect', 1);
912 <td
class=
"liste_titre"><?php echo $langs->trans(
'Product') ?></td>
913 <td
class=
"liste_titre"><?php echo $langs->trans(
'Attributes') ?></td>
914 <td
class=
"liste_titre right"><?php echo $langs->trans(
'PriceImpact') ?></td>
915 <?php
if ($object->isProduct()) {
916 print
'<td class="liste_titre right">'.$langs->trans(
'WeightImpact').
'</td>';
918 <td
class=
"liste_titre center"><?php echo $langs->trans(
'OnSell') ?></td>
919 <td
class=
"liste_titre center"><?php echo $langs->trans(
'OnBuy') ?></td>
920 <td
class=
"liste_titre"></td>
924 print
'<td class="liste_titre center">';
925 $searchpicto = $form->showCheckAddButtons(
'checkforselect', 1);
933 if (count($productCombinations)) {
934 foreach ($productCombinations as $currcomb) {
935 $prodstatic->fetch($currcomb->fk_product_child);
936 print
'<tr class="oddeven">';
940 print
'<td class="nowrap center">';
941 if (!empty($productCombinations) || $massactionbutton || $massaction) {
943 if (in_array($prodstatic->id, $arrayofselected)) {
946 print
'<input id="cb'.$prodstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$prodstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
951 print
'<td>'.$prodstatic->getNomUrl(1).
'</td>';
953 $productCombination2ValuePairs = $comb2val->fetchByFkCombination($currcomb->id);
954 $iMax = count($productCombination2ValuePairs);
956 for ($i = 0; $i < $iMax; $i++) {
958 if ($i !== ($iMax - 1)) {
963 print
'<td class="right">'.($currcomb->variation_price >= 0 ?
'+' :
'').
price($currcomb->variation_price).($currcomb->variation_price_percentage ?
' %' :
'').
'</td>';
964 if ($object->isProduct()) {
965 print
'<td class="right">'.($currcomb->variation_weight >= 0 ?
'+' :
'').
price($currcomb->variation_weight).
' '.
measuringUnitString(0,
'weight', $prodstatic->weight_units).
'</td>';
967 print
'<td class="center">'.$prodstatic->getLibStatut(2, 0).
'</td>';
968 print
'<td class="center">'.$prodstatic->getLibStatut(2, 1).
'</td>';
970 print
'<td class="right">';
971 print
'<a class="paddingleft paddingright editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=edit&token='.newToken().
'&valueid='.$currcomb->id.
'">'.
img_edit().
'</a>';
972 print
'<a class="paddingleft paddingright" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'&action=delete&token='.newToken().
'&valueid='.$currcomb->id.
'">'.
img_delete().
'</a>';
977 print
'<td class="nowrap center">';
978 if (!empty($productCombinations) || $massactionbutton || $massaction) {
980 if (in_array($prodstatic->id, $arrayofselected)) {
983 print
'<input id="cb'.$prodstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$prodstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
991 print
'<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class ProductAttribute Used to represent a product attribute.
Class ProductAttributeValue Used to represent a product attribute value.
Class ProductCombination2ValuePair Used to represent the relation between a product combination,...
Class ProductCombination Used to represent a product combination.
Class ProductCombinationLevel Used to represent a product combination Level.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
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.
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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
img_edit_remove($titlealt='default', $other='')
Show logo -.
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.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
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.