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';
40$langs->loadLangs(array(
"products",
"other"));
47$reference =
GETPOST(
'reference',
'alpha');
50$price_impact_percent = (bool)
GETPOST(
'price_impact_percent');
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');
63$action =
GETPOST(
'action',
'aZ09');
64$massaction =
GETPOST(
'massaction',
'alpha');
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');
76$fieldvalue =
$id ?: $ref;
77$fieldtype = !empty($ref) ?
'ref' :
'rowid';
88$selectedvariant = isset($_SESSION[
'addvariant_'.
$object->id]) ? $_SESSION[
'addvariant_'.$object->id] : array();
94if ($user->socid > 0) {
106 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
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')));
120 unset($_SESSION[
'addvariant_'.
$object->id]);
127if ($action ==
'add') {
128 unset($selectedvariant);
129 unset($_SESSION[
'addvariant_'.
$object->id]);
131if ($action ==
'create' &&
GETPOST(
'selectvariant',
'alpha') && $usercancreate) {
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;
141if ($action ==
'create' && $subaction ==
'delete' && $usercancreate) {
143 $feature =
GETPOST(
'feature',
'intcomma');
144 if (isset($selectedvariant[$feature])) {
145 unset($selectedvariant[$feature]);
146 $_SESSION[
'addvariant_'.$object->id] = $selectedvariant;
154$productCombination2ValuePairs1 = array();
156if (($action ==
'add' || $action ==
'create') && $usercancreate && empty($massaction) && !
GETPOST(
'selectvariant',
'alpha') && empty($subaction)) {
158 $features = !empty($_SESSION[
'addvariant_'.
$object->id]) ? $_SESSION[
'addvariant_'.$object->id] : array();
161 if ($action ==
'create') {
165 $reference = trim($reference);
166 if (empty($reference)) {
169 $weight_impact =
price2num($weight_impact);
170 $price_impact =
price2num($price_impact);
173 $level_price_impact = array(1 => $price_impact);
174 $level_price_impact_percent = array(1 => $price_impact_percent);
177 $sanit_features = array();
180 foreach ($features as $feature) {
181 $explode = explode(
'-', $feature);
182 if ($prodattr->fetch((
int) $explode[0]) <= 0 || $prodattr_val->fetch((
int) $explode[1]) <= 0) {
187 $sanit_features[(int) $explode[0]] = (
int) $explode[1];
190 $tmp->fk_prod_attr = (int) $explode[0];
191 $tmp->fk_prod_attr_val = (int) $explode[1];
193 $productCombination2ValuePairs1[] = $tmp;
200 if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) {
201 $result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $level_price_impact_percent, $level_price_impact, (float) $weight_impact, $reference,
'', $clone_categories);
204 unset($_SESSION[
'addvariant_'.
$object->id]);
207 header(
'Location: '.
dol_buildpath(
'/variants/combinations.php?id='.$id, 2));
210 $langs->load(
"errors");
214 setEventMessages($langs->trans(
'ErrorRecordAlreadyExists'),
null,
'errors');
219} elseif (!empty($massaction)) {
220 $bulkaction = $massaction;
225 foreach ($toselect as $prodid) {
227 $prodstatic =
new Product($db);
228 if ($prodstatic->fetch($prodid) < 0) {
232 if ($bulkaction ==
'on_sell') {
233 $prodstatic->status = 1;
234 $res = $prodstatic->update($prodstatic->id, $user);
240 } elseif ($bulkaction ==
'on_buy') {
241 $prodstatic->status_buy = 1;
242 $res = $prodstatic->update($prodstatic->id, $user);
248 } elseif ($bulkaction ==
'not_sell') {
249 $prodstatic->status = 0;
250 $res = $prodstatic->update($prodstatic->id, $user);
256 } elseif ($bulkaction ==
'not_buy') {
257 $prodstatic->status_buy = 0;
258 $res = $prodstatic->update($prodstatic->id, $user);
264 } elseif ($bulkaction ==
'delete') {
265 $res = $prodstatic->delete($user, $prodstatic->id);
278 if (empty($prodstatic->error)) {
285} elseif ($action ===
'update' && $combination_id > 0 && $usercancreate) {
286 if ($prodcomb->fetch($combination_id) < 0) {
291 $prodcomb->variation_weight = (float)
price2num($weight_impact);
295 $prodcomb->variation_price = $level_price_impact[1];
296 $prodcomb->variation_price_percentage = $level_price_impact_percent[1];
298 $level_price_impact = array(1 => $price_impact);
299 $level_price_impact_percent = array(1 => $price_impact_percent);
301 $prodcomb->variation_price = $price_impact;
302 $prodcomb->variation_price_percentage = $price_impact_percent;
306 $prodcomb->combination_price_levels = array();
308 for ($i = 1; $i <= $maxi; $i++) {
310 $productCombinationLevel->fk_product_attribute_combination = $prodcomb->id;
311 $productCombinationLevel->fk_price_level = $i;
312 $productCombinationLevel->variation_price = (float) $level_price_impact[$i];
313 $productCombinationLevel->variation_price_percentage = (bool) $level_price_impact_percent[$i];
314 $prodcomb->combination_price_levels[$i] = $productCombinationLevel;
322 $product_child =
new Product($db);
323 $product_child->fetch($prodcomb->fk_product_child);
324 $product_child->oldcopy = clone $product_child;
325 $product_child->ref = $reference;
327 $result = $product_child->update($product_child->id, $user);
335 $result = $prodcomb->update($user);
345 header(
'Location: ' .
dol_buildpath(
'/variants/combinations.php?id=' . $id, 2));
354$productCombinations = $prodcomb->fetchAllByFkProductParent(
$object->id,
true);
356if ($action ===
'confirm_deletecombination' && $usercancreate) {
357 if ($prodcomb->fetch($combination_id) > 0) {
360 if ($prodcomb->delete($user) > 0 && (empty($delete_product) || ($delete_product ==
'on' && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0))) {
368 setEventMessages($langs->trans(
'ProductCombinationAlreadyUsed'),
null,
'errors');
371} elseif ($action ===
'edit' && $usercancreate) {
372 if ($prodcomb->fetch($combination_id) < 0) {
377 $product_child =
new Product($db);
378 $product_child->fetch($prodcomb->fk_product_child);
379 $reference = (string) $product_child->ref;
380 $weight_impact = $prodcomb->variation_weight;
381 $price_impact = $prodcomb->variation_price;
382 $price_impact_percent = $prodcomb->variation_price_percentage;
384 $productCombination2ValuePairs1 = $prodcomb2val->fetchByFkCombination($combination_id);
385} elseif ($action ===
'confirm_copycombination' && $usercancreate) {
387 $dest_product =
GETPOST(
'dest_product');
389 if ($prodstatic->fetch(0, $dest_product) > 0) {
391 if ($prodstatic->ref !=
$object->ref) {
392 if ($prodcomb->copyAll($user,
$object->id, $prodstatic) > 0) {
393 header(
'Location: '.
dol_buildpath(
'/variants/combinations.php?id='.$prodstatic->id, 2));
396 setEventMessages($langs->trans(
'ErrorCopyProductCombinations'),
null,
'errors');
400 setEventMessages($langs->trans(
'ErrorDestinationProductNotFound'),
null,
'errors');
410$form =
new Form($db);
412$title = $langs->trans(
"Variant");
417if (!empty($id) || !empty($ref)) {
419 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
424 $titre = $langs->trans(
"CardProduct".
$object->type);
425 $picto =
$object->isService() ?
'service' :
'product';
429 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?type='.((int)
$object->type).
'">'.$langs->trans(
"BackToList").
'</a>';
430 $object->next_prev_filter =
"(te.fk_product_type:=:".((int)
$object->type).
")";
432 dol_banner_tab($object,
'ref', $linkback, ($user->socid ? 0 : 1),
'ref',
'',
'',
'', 0,
'',
'');
434 print
'<div class="fichecenter">';
436 print
'<div class="underbanner clearboth"></div>';
437 print
'<table class="border centpercent tableforfield">';
441 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
442 print
'<tr><td class="titlefieldcreate">';
443 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', (
string)
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
445 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
450 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
457 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
460 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
462 if (empty($positiverates)) {
463 $positiverates =
'0';
465 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr);
475 print
'<tr><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
476 if (
$object->price_base_type ==
'TTC') {
484 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td>';
485 if (
$object->price_base_type ==
'TTC') {
493 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
499 print
"</td></tr>\n";
504 print
'<div class="clearboth"></div>';
508 $listofvariantselected =
'';
511 if ($action ==
'add' || ($action ==
'edit')) {
512 if ($action ==
'add') {
513 $title = $langs->trans(
'NewProductCombination');
515 $features = !empty($_SESSION[
'addvariant_'.
$object->id]) ? $_SESSION[
'addvariant_'.$object->id] : array();
517 $listofvariantselected =
'<div id="parttoaddvariant">';
518 if (!empty($features)) {
520 foreach ($features as $feature) {
521 $explode = explode(
'-', $feature);
522 if ($prodattr->fetch((
int) $explode[0]) <= 0 || $prodattr_val->fetch((
int) $explode[1]) <= 0) {
525 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #ddd;">' . $prodattr->label.
' : '.$prodattr_val->value .
526 ' <a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=create&subaction=delete&feature='.urlencode($feature).
'">' .
img_delete() .
'</a></li>';
528 $listofvariantselected .=
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
530 $listofvariantselected .=
'</div>';
533 $title = $langs->trans(
'EditProductCombination');
536 $prodattr_alljson =
null;
537 $prodattr_all =
null;
538 if ($action ==
'add') {
539 $prodattr_all = $prodattr->fetchAll();
541 if (!$selected && !empty($prodattr_all)) {
542 $selected = $prodattr_all[key($prodattr_all)]->id;
545 $prodattr_alljson = array();
547 foreach ($prodattr_all as $each) {
548 $prodattr_alljson[$each->id] = $each;
551 <script
type=
"text/javascript">
553 variants_available = <?php echo json_encode($prodattr_alljson, JSON_PARTIAL_OUTPUT_ON_ERROR); ?>;
554 variants_selected = {
560 foreach ($productCombination2ValuePairs1 as $pc2v) {
561 $prodattr_val->fetch($pc2v->fk_prod_attr_val); ?>
562 variants_selected.index.push(<?php echo $pc2v->fk_prod_attr ?>);
563 variants_selected.info[<?php echo $pc2v->fk_prod_attr ?>] = {
564 attribute: variants_available[<?php echo $pc2v->fk_prod_attr ?>],
566 id: <?php echo $pc2v->fk_prod_attr_val ?>,
567 label:
'<?php echo $prodattr_val->value ?>'
573 restoreAttributes =
function() {
574 jQuery(
"select[name=attribute]").empty().append(
'<option value="-1"> </option>');
576 jQuery.each(variants_available,
function (key, val) {
577 if (jQuery.inArray(val.id, variants_selected.index) == -1) {
578 jQuery(
"select[name=attribute]").append(
'<option value="' + val.id +
'">' + val.label +
'</option>');
584 jQuery(document).ready(
function() {
585 jQuery(
"select#attribute").change(
function () {
586 console.log(
"Change of field variant attribute");
587 var select = jQuery(
"select#value");
589 if (!jQuery(
this).val().length || jQuery(
this).val() ==
'-1') {
591 select.append(
'<option value="-1"> </option>');
595 select.empty().append(
'<option value="">Loading...</option>');
597 jQuery.getJSON(
"ajax/get_attribute_values.php", {
598 id: jQuery(
this).val()
602 select.append(
'<option value="-1"> </option>');
603 return alert(data.error);
607 select.append(
'<option value="-1"> </option>');
609 jQuery(data).each(
function (key, val) {
610 keyforoption = val.id
611 valforoption = val.value
612 select.append(
'<option value="' + keyforoption +
'">' + valforoption +
'</option>');
626 print
'<form method="post" id="combinationform" action="'.$_SERVER[
"PHP_SELF"] .
'?id='.
$object->id.
'">'.
"\n";
627 print
'<input type="hidden" name="token" value="'.newToken().
'">';
628 print
'<input type="hidden" name="action" value="'.(($combination_id > 0) ?
"update" :
"create").
'">'.
"\n";
629 if ($combination_id > 0) {
630 print
'<input type="hidden" name="combination_id" value="'.$combination_id.
'">'.
"\n";
636 if ($action ==
'add') {
637 print
'<table class="border" style="width: 100%">';
638 print
"<!-- Variant -->\n";
640 print
'<td class="titlefieldcreate fieldrequired"><label for="attribute">'.$langs->trans(
'ProductAttribute').
'</label></td>';
642 if (is_array($prodattr_all)) {
643 print
'<select class="flat minwidth100" id="attribute" name="attribute">';
644 print
'<option value="-1"> </option>';
645 foreach ($prodattr_all as $attr) {
647 print
'<option value="'.$attr->id.
'">'.$attr->label.
'</option>';
652 $htmltext = $langs->trans(
"GoOnMenuToCreateVairants", $langs->transnoentities(
"Product"), $langs->transnoentities(
"VariantAttributes"));
653 print $form->textwithpicto(
'', $htmltext);
662 <td
class=
"fieldrequired"><label
for=
"value"><?php echo $langs->trans(
'Value') ?></label></td>
664 <select
class=
"flat minwidth100" id=
"value" name=
"value">
665 <option value=
"-1"> </option>
668 $htmltext = $langs->trans(
"GoOnMenuToCreateVairants", $langs->transnoentities(
"Product"), $langs->transnoentities(
"VariantAttributes"));
669 print $form->textwithpicto(
'', $htmltext);
679 <input
type=
"submit" class=
"button" name=
"selectvariant" id=
"selectvariant" value=
"<?php echo dol_escape_htmltag($langs->trans("SelectCombination
")); ?>">
683 print
'<tr><td></td><td>';
684 print $listofvariantselected;
692 if (is_array($productCombination2ValuePairs1)) {
693 print
'<table class="border" style="width: 100%">';
696 if (is_array($productCombination2ValuePairs1) && count($productCombination2ValuePairs1)) {
699 <td
class=
"titlefieldcreate tdtop"><label
for=
"features"><?php echo $langs->trans(
'Attributes') ?></label></td>
701 <div
class=
"inline-block valignmiddle quatrevingtpercent">
703 foreach ($productCombination2ValuePairs1 as $pc2v) {
704 $result1 = $prodattr->fetch($pc2v->fk_prod_attr);
705 $result2 = $prodattr_val->fetch($pc2v->fk_prod_attr_val);
706 if ($result1 > 0 && $result2 > 0) {
707 print $prodattr->label.
' : '.$prodattr_val->value.
'<br>';
712 <!-- <div
class=
"inline-block valignmiddle">
713 <a href=
"#" class=
"inline-block valignmiddle button" id=
"delfeature"><?php echo
img_edit_remove() ?></a>
722 <td><label
for=
"reference"><?php echo $langs->trans(
'Reference') ?></label></td>
723 <td><input
type=
"text" id=
"reference" name=
"reference" value=
"<?php echo trim($reference) ?>" spellcheck=
"false"></td>
729 <td><label
for=
"price_impact"><?php echo $langs->trans(
'PriceImpact') ?></label></td>
730 <td><input
type=
"text" id=
"price_impact" name=
"price_impact" value=
"<?php echo price($price_impact) ?>">
732 <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>
737 $prodcomb->fetchCombinationPriceLevels();
740 for ($i = 1; $i <= $maxi; $i++) {
741 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
742 $text = $langs->trans(
'ImpactOnPriceLevel', $i).
' - '.
getDolGlobalString($keyforlabel);
744 print
'<td><label for="level_price_impact_'.$i.
'">'.$text.
'</label>';
746 print
'<br/><a id="apply-price-impact-to-all-level" class="classfortooltip" href="#" title="'.$langs->trans(
'ApplyToAllPriceImpactLevelHelp').
'">('.$langs->trans(
'ApplyToAllPriceImpactLevel').
')</a>';
749 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).
'">';
750 print
'<span class="paddingleft"></span>';
751 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>';
760 print
'<td><label for="weight_impact">'.$langs->trans(
'WeightImpact').
'</label></td>';
761 print
'<td><input type="text" id="weight_impact" name="weight_impact" value="'.price($weight_impact).
'"></td>';
766 print
'<td><label for="clone_categories">'.$langs->trans(
'CloneCategoriesProduct').
'</label></td>';
767 print
'<td><input type="checkbox" id="clone_categories" name="clone_categories"></td>';
776 $(document).ready(
function() {
778 $(
'body').on(
'click',
'#apply-price-impact-to-all-level',
function(e) {
780 let priceImpact = $(
"#level_price_impact_1" ).val();
781 let priceImpactPrecent = $(
"#level_price_impact_percent_1" ).prop(
"checked");
783 let multipricelimit = <?php print
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT'); ?>
785 for (let i = 2; i <= multipricelimit; i++) {
786 $(
"#level_price_impact_" + i ).val(priceImpact);
787 $(
"#level_price_impact_percent_" + i ).prop(
"checked", priceImpactPrecent);
797 <div style=
"text-align: center">
798 <input
type=
"submit" name=
"create" <?php
if (!is_array($productCombination2ValuePairs1)) {
799 print
' disabled="disabled"';
800 } ?> value=
"<?php echo $action == 'add' ? $langs->trans('Create') : $langs->trans("Save
") ?>" class=
"button button-save">
802 <input
type=
"submit" name=
"cancel" value=
"<?php echo $langs->trans("Cancel
"); ?>" class=
"button button-cancel">
809 if ($action ===
'delete') {
810 if ($prodcomb->fetch($combination_id) > 0) {
811 $prodstatic->fetch($prodcomb->fk_product_child);
813 print $form->formconfirm(
814 "combinations.php?id=".urlencode((
string) ($id)).
"&combination_id=".urlencode((
string) ($combination_id)),
815 $langs->trans(
'Delete'),
816 $langs->trans(
'ProductCombinationDeleteDialog', $prodstatic->ref),
817 "confirm_deletecombination",
818 array(array(
'label' => $langs->trans(
'DeleteLinkedProduct'),
'type' =>
'checkbox',
'name' =>
'delete_product',
'value' =>
false)),
823 } elseif ($action ===
'copy') {
824 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);
829 if ($productCombinations) {
832 <script
type=
"text/javascript">
833 jQuery(document).ready(
function() {
835 jQuery(
'input[name="select_all"]').click(
function() {
837 if (jQuery(
this).prop(
'checked')) {
843 jQuery(
'table.liste input[type="checkbox"]').prop(
'checked', checked);
846 jQuery(
'input[name^="select["]').click(
function() {
847 jQuery(
'input[name="select_all"]').prop(
'checked',
false);
857 print
'<div class="tabsAction">';
859 print
' <div class="inline-block divButAction">';
861 print
'<a href="combinations.php?id='.$object->id.
'&action=add&token='.
newToken().
'" class="butAction">'.$langs->trans(
'NewProductCombination').
'</a>';
863 if ($productCombinations) {
864 print
'<a href="combinations.php?id='.$object->id.
'&action=copy&token='.
newToken().
'" class="butAction">'.$langs->trans(
'PropagateVariant').
'</a>';
873 $arrayofselected = is_array($toselect) ? $toselect : array();
877 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"] .
'?id='.
$object->id.
'">';
878 print
'<input type="hidden" name="token" value="'.newToken().
'">';
879 print
'<input type="hidden" name="action" value="massaction">';
880 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
885 if (count($productCombinations)) {
886 $aaa =
'<select id="bulk_action" name="massaction" class="minwidth250">';
887 $aaa .=
' <option value="nothing"> </option>';
888 $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>';
889 $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>';
890 $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>';
891 $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>';
892 $aaa .=
' <option value="delete" data-html="'.dol_escape_htmltag(
img_picto($langs->trans(
"Delete"),
'delete',
'class="pictofixedwidth"').$langs->trans(
'Delete')).
'">'.$langs->trans(
'Delete').
'</option>';
895 $aaa .=
'<input type="submit" value="'.dol_escape_htmltag($langs->trans(
"Apply")).
'" class="button small">';
897 $massactionbutton = $aaa;
899 $title = $langs->trans(
"ProductCombinations");
901 print_barre_liste($title, 0, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder, $aaa, 0);
903 print
'<div class="div-table-responsive">'; ?>
904 <
table class=
"liste">
905 <tr
class=
"liste_titre">
909 print
'<td class="liste_titre center">';
910 $searchpicto = $form->showCheckAddButtons(
'checkforselect', 1);
914 <td
class=
"liste_titre"><?php echo $langs->trans(
'Product') ?></td>
915 <td
class=
"liste_titre"><?php echo $langs->trans(
'Attributes') ?></td>
916 <td
class=
"liste_titre right"><?php echo $langs->trans(
'PriceImpact') ?></td>
917 <?php
if (
$object->isProduct()) {
918 print
'<td class="liste_titre right">'.$langs->trans(
'WeightImpact').
'</td>';
920 <td
class=
"liste_titre center"><?php echo $langs->trans(
'OnSell') ?></td>
921 <td
class=
"liste_titre center"><?php echo $langs->trans(
'OnBuy') ?></td>
922 <td
class=
"liste_titre"></td>
926 print
'<td class="liste_titre center">';
927 $searchpicto = $form->showCheckAddButtons(
'checkforselect', 1);
934 if (count($productCombinations)) {
935 foreach ($productCombinations as $currcomb) {
936 $prodstatic->fetch($currcomb->fk_product_child);
937 print
'<tr class="oddeven">';
941 print
'<td class="nowrap center">';
942 if (!empty($productCombinations) || $massactionbutton || $massaction) {
944 if (in_array($prodstatic->id, $arrayofselected)) {
947 print
'<input id="cb'.$prodstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$prodstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
952 print
'<td>'.$prodstatic->getNomUrl(1).
'</td>';
954 foreach ($comb2val->fetchByFkCombination($currcomb->id) as $pc2v) {
958 print
'<td class="right">'.($currcomb->variation_price >= 0 ?
'+' :
'').
price($currcomb->variation_price).($currcomb->variation_price_percentage ?
' %' :
'').
'</td>';
960 print
'<td class="right">'.($currcomb->variation_weight >= 0 ?
'+' :
'').
price($currcomb->variation_weight).
' '.
measuringUnitString(0,
'weight', $prodstatic->weight_units).
'</td>';
962 print
'<td class="center">'.$prodstatic->getLibStatut(2, 0).
'</td>';
963 print
'<td class="center">'.$prodstatic->getLibStatut(2, 1).
'</td>';
965 print
'<td class="right">';
966 print
'<a class="paddingleft paddingright editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&action=edit&token='.
newToken().
'&combination_id='.$currcomb->id.
'">'.
img_edit().
'</a>';
967 print
'<a class="paddingleft paddingright" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&action=delete&token='.
newToken().
'&combination_id='.$currcomb->id.
'">'.
img_delete().
'</a>';
972 print
'<td class="nowrap center">';
973 if (!empty($productCombinations) || $massactionbutton || $massaction) {
975 if (in_array($prodstatic->id, $arrayofselected)) {
978 print
'<input id="cb'.$prodstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$prodstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
986 print
'<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
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]]]',...
$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.