23require
'../main.inc.php';
24require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
25require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
26require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttribute.class.php';
27require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttributeValue.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination2ValuePair.class.php';
39$langs->loadLangs(array(
"products",
"other"));
46$reference =
GETPOST(
'reference',
'alpha');
49$price_impact_percent = (bool)
GETPOST(
'price_impact_percent');
53$level_price_impact =
GETPOST(
'level_price_impact',
'array');
54$level_price_impact = array_map(
'price2num', $level_price_impact);
55$level_price_impact = array_map(
'floatval', $level_price_impact);
56$level_price_impact_percent =
GETPOST(
'level_price_impact_percent',
'array');
57$level_price_impact_percent = array_map(
'boolval', $level_price_impact_percent);
61$action =
GETPOST(
'action',
'aZ09');
62$massaction =
GETPOST(
'massaction',
'alpha');
64$confirm =
GETPOST(
'confirm',
'alpha');
65$toselect =
GETPOST(
'toselect',
'array');
66$cancel =
GETPOST(
'cancel',
'alpha');
67$delete_product =
GETPOST(
'delete_product',
'alpha');
68$subaction =
GETPOST(
'subaction',
'aZ09');
69$backtopage =
GETPOST(
'backtopage',
'alpha');
70$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
71$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
74$fieldvalue =
$id ?: $ref;
75$fieldtype = !empty($ref) ?
'ref' :
'rowid';
86$selectedvariant = isset($_SESSION[
'addvariant_'.
$object->id]) ? $_SESSION[
'addvariant_'.$object->id] : array();
89if (!isModEnabled(
'variants')) {
92if ($user->socid > 0) {
104 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
106$usercanread = ((
$object->isProduct() && $user->hasRight(
'produit',
'lire')) || (
$object->isService() && $user->hasRight(
'service',
'lire')));
107$usercancreate = ((
$object->isProduct() && $user->hasRight(
'produit',
'creer')) || (
$object->isService() && $user->hasRight(
'service',
'creer')));
108$usercandelete = ((
$object->isProduct() && $user->hasRight(
'produit',
'supprimer')) || (
$object->isService() && $user->hasRight(
'service',
'supprimer')));
118 unset($_SESSION[
'addvariant_'.
$object->id]);
125if ($action ==
'add') {
126 unset($selectedvariant);
127 unset($_SESSION[
'addvariant_'.
$object->id]);
129if ($action ==
'create' &&
GETPOST(
'selectvariant',
'alpha') && $usercancreate) {
133 if ($attribute_id > 0 && $attribute_value_id > 0) {
134 $feature = $attribute_id .
'-' . $attribute_value_id;
135 $selectedvariant[$feature] = $feature;
136 $_SESSION[
'addvariant_'.$object->id] = $selectedvariant;
139if ($action ==
'create' && $subaction ==
'delete' && $usercancreate) {
141 $feature =
GETPOST(
'feature',
'intcomma');
142 if (isset($selectedvariant[$feature])) {
143 unset($selectedvariant[$feature]);
144 $_SESSION[
'addvariant_'.$object->id] = $selectedvariant;
152$productCombination2ValuePairs1 = array();
154if (($action ==
'add' || $action ==
'create') && $usercancreate && empty($massaction) && !
GETPOST(
'selectvariant',
'alpha') && empty($subaction)) {
156 $features = !empty($_SESSION[
'addvariant_'.
$object->id]) ? $_SESSION[
'addvariant_'.$object->id] : array();
159 if ($action ==
'create') {
163 $reference = trim($reference);
164 if (empty($reference)) {
167 $weight_impact =
price2num($weight_impact);
168 $price_impact =
price2num($price_impact);
171 $level_price_impact = array(1 => $price_impact);
172 $level_price_impact_percent = array(1 => $price_impact_percent);
175 $sanit_features = array();
178 foreach ($features as $feature) {
179 $explode = explode(
'-', $feature);
180 if ($prodattr->fetch($explode[0]) <= 0 || $prodattr_val->fetch($explode[1]) <= 0) {
185 $sanit_features[(int) $explode[0]] = (
int) $explode[1];
188 $tmp->fk_prod_attr = (int) $explode[0];
189 $tmp->fk_prod_attr_val = (int) $explode[1];
191 $productCombination2ValuePairs1[] = $tmp;
198 if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) {
199 $result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $level_price_impact_percent, $level_price_impact, $weight_impact, $reference);
202 unset($_SESSION[
'addvariant_'.
$object->id]);
205 header(
'Location: '.
dol_buildpath(
'/variants/combinations.php?id='.$id, 2));
208 $langs->load(
"errors");
212 setEventMessages($langs->trans(
'ErrorRecordAlreadyExists'),
null,
'errors');
217} elseif (!empty($massaction)) {
218 $bulkaction = $massaction;
223 foreach ($toselect as $prodid) {
225 $prodstatic =
new Product($db);
226 if ($prodstatic->fetch($prodid) < 0) {
230 if ($bulkaction ==
'on_sell') {
231 $prodstatic->status = 1;
232 $res = $prodstatic->update($prodstatic->id, $user);
238 } elseif ($bulkaction ==
'on_buy') {
239 $prodstatic->status_buy = 1;
240 $res = $prodstatic->update($prodstatic->id, $user);
246 } elseif ($bulkaction ==
'not_sell') {
247 $prodstatic->status = 0;
248 $res = $prodstatic->update($prodstatic->id, $user);
254 } elseif ($bulkaction ==
'not_buy') {
255 $prodstatic->status_buy = 0;
256 $res = $prodstatic->update($prodstatic->id, $user);
262 } elseif ($bulkaction ==
'delete') {
263 $res = $prodstatic->delete($user, $prodstatic->id);
276 if (empty($prodstatic->error)) {
283} elseif ($action ===
'update' && $combination_id > 0 && $usercancreate) {
284 if ($prodcomb->fetch($combination_id) < 0) {
289 $prodcomb->variation_weight = (float)
price2num($weight_impact);
293 $prodcomb->variation_price = $level_price_impact[1];
294 $prodcomb->variation_price_percentage = $level_price_impact_percent[1];
296 $level_price_impact = array(1 => $price_impact);
297 $level_price_impact_percent = array(1 => $price_impact_percent);
299 $prodcomb->variation_price = $price_impact;
300 $prodcomb->variation_price_percentage = $price_impact_percent;
304 $prodcomb->combination_price_levels = array();
306 for ($i = 1; $i <= $maxi; $i++) {
308 $productCombinationLevel->fk_product_attribute_combination = $prodcomb->id;
309 $productCombinationLevel->fk_price_level = $i;
310 $productCombinationLevel->variation_price = (float) $level_price_impact[$i];
311 $productCombinationLevel->variation_price_percentage = (bool) $level_price_impact_percent[$i];
312 $prodcomb->combination_price_levels[$i] = $productCombinationLevel;
320 $product_child =
new Product($db);
321 $product_child->fetch($prodcomb->fk_product_child);
322 $product_child->oldcopy = clone $product_child;
323 $product_child->ref = $reference;
325 $result = $product_child->update($product_child->id, $user);
333 $result = $prodcomb->update($user);
343 header(
'Location: ' .
dol_buildpath(
'/variants/combinations.php?id=' . $id, 2));
352$productCombinations = $prodcomb->fetchAllByFkProductParent(
$object->id,
true);
354if ($action ===
'confirm_deletecombination' && $usercancreate) {
355 if ($prodcomb->fetch($combination_id) > 0) {
358 if ($prodcomb->delete($user) > 0 && (empty($delete_product) || ($delete_product ==
'on' && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0))) {
366 setEventMessages($langs->trans(
'ProductCombinationAlreadyUsed'),
null,
'errors');
369} elseif ($action ===
'edit' && $usercancreate) {
370 if ($prodcomb->fetch($combination_id) < 0) {
375 $product_child =
new Product($db);
376 $product_child->fetch($prodcomb->fk_product_child);
377 $reference = $product_child->ref;
378 $weight_impact = $prodcomb->variation_weight;
379 $price_impact = $prodcomb->variation_price;
380 $price_impact_percent = $prodcomb->variation_price_percentage;
382 $productCombination2ValuePairs1 = $prodcomb2val->fetchByFkCombination($combination_id);
383} elseif ($action ===
'confirm_copycombination' && $usercancreate) {
385 $dest_product =
GETPOST(
'dest_product');
387 if ($prodstatic->fetch(0, $dest_product) > 0) {
389 if ($prodstatic->ref !=
$object->ref) {
390 if ($prodcomb->copyAll($user,
$object->id, $prodstatic) > 0) {
391 header(
'Location: '.
dol_buildpath(
'/variants/combinations.php?id='.$prodstatic->id, 2));
394 setEventMessages($langs->trans(
'ErrorCopyProductCombinations'),
null,
'errors');
398 setEventMessages($langs->trans(
'ErrorDestinationProductNotFound'),
null,
'errors');
408$form =
new Form($db);
410$title = $langs->trans(
"Variant");
415if (!empty($id) || !empty($ref)) {
416 $showbarcode = isModEnabled(
'barcode');
417 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
422 $titre = $langs->trans(
"CardProduct".
$object->type);
423 $picto =
$object->isService() ?
'service' :
'product';
427 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?type='.((int)
$object->type).
'">'.$langs->trans(
"BackToList").
'</a>';
428 $object->next_prev_filter =
"fk_product_type:=:".((int)
$object->type);
430 dol_banner_tab($object,
'ref', $linkback, ($user->socid ? 0 : 1),
'ref',
'',
'',
'', 0,
'',
'');
432 print
'<div class="fichecenter">';
434 print
'<div class="underbanner clearboth"></div>';
435 print
'<table class="border centpercent tableforfield">';
438 if (isModEnabled(
"product") && isModEnabled(
"service")) {
439 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
440 print
'<tr><td class="titlefieldcreate">';
441 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type',
$object->type, $object, $usercancreate, $typeformat) : $langs->trans(
'Type');
443 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, $usercancreate, $typeformat);
448 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
455 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
458 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
460 if (empty($positiverates)) {
461 $positiverates =
'0';
463 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr);
473 print
'<tr><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
474 if (
$object->price_base_type ==
'TTC') {
482 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td>';
483 if (
$object->price_base_type ==
'TTC') {
491 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
497 print
"</td></tr>\n";
502 print
'<div class="clearboth"></div>';
506 $listofvariantselected =
'';
509 if ($action ==
'add' || ($action ==
'edit')) {
510 if ($action ==
'add') {
511 $title = $langs->trans(
'NewProductCombination');
513 $features = !empty($_SESSION[
'addvariant_'.
$object->id]) ? $_SESSION[
'addvariant_'.$object->id] : array();
515 $listofvariantselected =
'<div id="parttoaddvariant">';
516 if (!empty($features)) {
518 foreach ($features as $feature) {
519 $explode = explode(
'-', $feature);
520 if ($prodattr->fetch($explode[0]) <= 0 || $prodattr_val->fetch($explode[1]) <= 0) {
523 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #ddd;">' . $prodattr->label.
' : '.$prodattr_val->value .
524 ' <a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=create&subaction=delete&feature='.urlencode($feature).
'">' .
img_delete() .
'</a></li>';
526 $listofvariantselected .=
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
528 $listofvariantselected .=
'</div>';
531 $title = $langs->trans(
'EditProductCombination');
534 if ($action ==
'add') {
535 $prodattr_all = $prodattr->fetchAll();
538 $selected = $prodattr_all[key($prodattr_all)]->id;
541 $prodattr_alljson = array();
543 foreach ($prodattr_all as $each) {
544 $prodattr_alljson[$each->id] = $each;
547 <script
type=
"text/javascript">
549 variants_available = <?php echo json_encode($prodattr_alljson, JSON_PARTIAL_OUTPUT_ON_ERROR); ?>;
550 variants_selected = {
556 foreach ($productCombination2ValuePairs1 as $pc2v) {
557 $prodattr_val->fetch($pc2v->fk_prod_attr_val); ?>
558 variants_selected.index.push(<?php echo $pc2v->fk_prod_attr ?>);
559 variants_selected.info[<?php echo $pc2v->fk_prod_attr ?>] = {
560 attribute: variants_available[<?php echo $pc2v->fk_prod_attr ?>],
562 id: <?php echo $pc2v->fk_prod_attr_val ?>,
563 label:
'<?php echo $prodattr_val->value ?>'
569 restoreAttributes =
function() {
570 jQuery(
"select[name=attribute]").empty().append(
'<option value="-1"> </option>');
572 jQuery.each(variants_available,
function (key, val) {
573 if (jQuery.inArray(val.id, variants_selected.index) == -1) {
574 jQuery(
"select[name=attribute]").append(
'<option value="' + val.id +
'">' + val.label +
'</option>');
580 jQuery(document).ready(
function() {
581 jQuery(
"select#attribute").change(
function () {
582 console.log(
"Change of field variant attribute");
583 var select = jQuery(
"select#value");
585 if (!jQuery(
this).val().length || jQuery(
this).val() ==
'-1') {
587 select.append(
'<option value="-1"> </option>');
591 select.empty().append(
'<option value="">Loading...</option>');
593 jQuery.getJSON(
"ajax/get_attribute_values.php", {
594 id: jQuery(
this).val()
598 select.append(
'<option value="-1"> </option>');
599 return alert(data.error);
603 select.append(
'<option value="-1"> </option>');
605 jQuery(data).each(
function (key, val) {
606 keyforoption = val.id
607 valforoption = val.value
608 select.append(
'<option value="' + keyforoption +
'">' + valforoption +
'</option>');
622 print
'<form method="post" id="combinationform" action="'.$_SERVER[
"PHP_SELF"] .
'?id='.
$object->id.
'">'.
"\n";
623 print
'<input type="hidden" name="token" value="'.newToken().
'">';
624 print
'<input type="hidden" name="action" value="'.(($combination_id > 0) ?
"update" :
"create").
'">'.
"\n";
625 if ($combination_id > 0) {
626 print
'<input type="hidden" name="combination_id" value="'.$combination_id.
'">'.
"\n";
632 if ($action ==
'add') {
633 print
'<table class="border" style="width: 100%">';
634 print
"<!-- Variant -->\n";
636 print
'<td class="titlefieldcreate fieldrequired"><label for="attribute">'.$langs->trans(
'ProductAttribute').
'</label></td>';
638 if (is_array($prodattr_all)) {
639 print
'<select class="flat minwidth100" id="attribute" name="attribute">';
640 print
'<option value="-1"> </option>';
641 foreach ($prodattr_all as $attr) {
643 print
'<option value="'.$attr->id.
'">'.$attr->label.
'</option>';
648 $htmltext = $langs->trans(
"GoOnMenuToCreateVairants", $langs->transnoentities(
"Product"), $langs->transnoentities(
"VariantAttributes"));
649 print $form->textwithpicto(
'', $htmltext);
658 <td
class=
"fieldrequired"><label
for=
"value"><?php echo $langs->trans(
'Value') ?></label></td>
660 <select
class=
"flat minwidth100" id=
"value" name=
"value">
661 <option value=
"-1"> </option>
664 $htmltext = $langs->trans(
"GoOnMenuToCreateVairants", $langs->transnoentities(
"Product"), $langs->transnoentities(
"VariantAttributes"));
665 print $form->textwithpicto(
'', $htmltext);
675 <input
type=
"submit" class=
"button" name=
"selectvariant" id=
"selectvariant" value=
"<?php echo dol_escape_htmltag($langs->trans("SelectCombination
")); ?>">
679 print
'<tr><td></td><td>';
680 print $listofvariantselected;
688 if (is_array($productCombination2ValuePairs1)) {
689 print
'<table class="border" style="width: 100%">';
692 if (is_array($productCombination2ValuePairs1) && count($productCombination2ValuePairs1)) {
695 <td
class=
"titlefieldcreate tdtop"><label
for=
"features"><?php echo $langs->trans(
'Attributes') ?></label></td>
697 <div
class=
"inline-block valignmiddle quatrevingtpercent">
699 foreach ($productCombination2ValuePairs1 as $pc2v) {
700 $result1 = $prodattr->fetch($pc2v->fk_prod_attr);
701 $result2 = $prodattr_val->fetch($pc2v->fk_prod_attr_val);
702 if ($result1 > 0 && $result2 > 0) {
703 print $prodattr->label.
' : '.$prodattr_val->value.
'<br>';
708 <!-- <div
class=
"inline-block valignmiddle">
709 <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>
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) ?>">
728 <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>
733 $prodcomb->fetchCombinationPriceLevels();
736 for ($i = 1; $i <= $maxi; $i++) {
737 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
738 $text = $langs->trans(
'ImpactOnPriceLevel', $i).
' - '.
getDolGlobalString($keyforlabel);
740 print
'<td><label for="level_price_impact_'.$i.
'">'.$text.
'</label>';
742 print
'<br/><a id="apply-price-impact-to-all-level" class="classfortooltip" href="#" title="'.$langs->trans(
'ApplyToAllPriceImpactLevelHelp').
'">('.$langs->trans(
'ApplyToAllPriceImpactLevel').
')</a>';
745 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).
'">';
746 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>';
755 print
'<td><label for="weight_impact">'.$langs->trans(
'WeightImpact').
'</label></td>';
756 print
'<td><input type="text" id="weight_impact" name="weight_impact" value="'.price($weight_impact).
'"></td>';
766 $(document).ready(
function() {
768 $(
'body').on(
'click',
'#apply-price-impact-to-all-level',
function(e) {
770 let priceImpact = $(
"#level_price_impact_1" ).val();
771 let priceImpactPrecent = $(
"#level_price_impact_percent_1" ).prop(
"checked");
773 let multipricelimit = <?php print
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT'); ?>
775 for (let i = 2; i <= multipricelimit; i++) {
776 $(
"#level_price_impact_" + i ).val(priceImpact);
777 $(
"#level_price_impact_percent_" + i ).prop(
"checked", priceImpactPrecent);
787 <div style=
"text-align: center">
788 <input
type=
"submit" name=
"create" <?php
if (!is_array($productCombination2ValuePairs1)) {
789 print
' disabled="disabled"';
790 } ?> value=
"<?php echo $action == 'add' ? $langs->trans('Create') : $langs->trans("Save
") ?>" class=
"button button-save">
792 <input
type=
"submit" name=
"cancel" value=
"<?php echo $langs->trans("Cancel
"); ?>" class=
"button button-cancel">
799 if ($action ===
'delete') {
800 if ($prodcomb->fetch($combination_id) > 0) {
801 $prodstatic->fetch($prodcomb->fk_product_child);
803 print $form->formconfirm(
804 "combinations.php?id=".urlencode((
string) ($id)).
"&combination_id=".urlencode((
string) ($combination_id)),
805 $langs->trans(
'Delete'),
806 $langs->trans(
'ProductCombinationDeleteDialog', $prodstatic->ref),
807 "confirm_deletecombination",
808 array(array(
'label' => $langs->trans(
'DeleteLinkedProduct'),
'type' =>
'checkbox',
'name' =>
'delete_product',
'value' =>
false)),
813 } elseif ($action ===
'copy') {
814 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);
819 if ($productCombinations) {
822 <script
type=
"text/javascript">
823 jQuery(document).ready(
function() {
825 jQuery(
'input[name="select_all"]').click(
function() {
827 if (jQuery(
this).prop(
'checked')) {
833 jQuery(
'table.liste input[type="checkbox"]').prop(
'checked', checked);
836 jQuery(
'input[name^="select["]').click(
function() {
837 jQuery(
'input[name="select_all"]').prop(
'checked',
false);
847 print
'<div class="tabsAction">';
849 print
' <div class="inline-block divButAction">';
851 print
'<a href="combinations.php?id='.$object->id.
'&action=add&token='.
newToken().
'" class="butAction">'.$langs->trans(
'NewProductCombination').
'</a>';
853 if ($productCombinations) {
854 print
'<a href="combinations.php?id='.$object->id.
'&action=copy&token='.
newToken().
'" class="butAction">'.$langs->trans(
'PropagateVariant').
'</a>';
863 $arrayofselected = is_array($toselect) ? $toselect : array();
867 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"] .
'?id='.
$object->id.
'">';
868 print
'<input type="hidden" name="token" value="'.newToken().
'">';
869 print
'<input type="hidden" name="action" value="massaction">';
870 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
875 if (count($productCombinations)) {
876 $aaa =
'<select id="bulk_action" name="massaction" class="flat">';
877 $aaa .=
' <option value="nothing"> </option>';
878 $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>';
879 $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>';
880 $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>';
881 $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>';
882 $aaa .=
' <option value="delete" data-html="'.dol_escape_htmltag(
img_picto($langs->trans(
"Delete"),
'delete',
'class="pictofixedwidth"').$langs->trans(
'Delete')).
'">'.$langs->trans(
'Delete').
'</option>';
885 $aaa .=
'<input type="submit" value="'.dol_escape_htmltag($langs->trans(
"Apply")).
'" class="button small">';
887 $massactionbutton = $aaa;
889 $title = $langs->trans(
"ProductCombinations");
891 print_barre_liste($title, 0, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder, $aaa, 0);
893 print
'<div class="div-table-responsive">'; ?>
894 <
table class=
"liste">
895 <tr
class=
"liste_titre">
899 print
'<td class="liste_titre center">';
900 $searchpicto = $form->showCheckAddButtons(
'checkforselect', 1);
904 <td
class=
"liste_titre"><?php echo $langs->trans(
'Product') ?></td>
905 <td
class=
"liste_titre"><?php echo $langs->trans(
'Attributes') ?></td>
906 <td
class=
"liste_titre right"><?php echo $langs->trans(
'PriceImpact') ?></td>
907 <?php
if (
$object->isProduct()) {
908 print
'<td class="liste_titre right">'.$langs->trans(
'WeightImpact').
'</td>';
910 <td
class=
"liste_titre center"><?php echo $langs->trans(
'OnSell') ?></td>
911 <td
class=
"liste_titre center"><?php echo $langs->trans(
'OnBuy') ?></td>
912 <td
class=
"liste_titre"></td>
916 print
'<td class="liste_titre center">';
917 $searchpicto = $form->showCheckAddButtons(
'checkforselect', 1);
924 if (count($productCombinations)) {
925 foreach ($productCombinations as $currcomb) {
926 $prodstatic->fetch($currcomb->fk_product_child);
927 print
'<tr class="oddeven">';
931 print
'<td class="nowrap center">';
932 if (!empty($productCombinations) || $massactionbutton || $massaction) {
934 if (in_array($prodstatic->id, $arrayofselected)) {
937 print
'<input id="cb'.$prodstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$prodstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
942 print
'<td>'.$prodstatic->getNomUrl(1).
'</td>';
944 foreach ($comb2val->fetchByFkCombination($currcomb->id) as $pc2v) {
948 print
'<td class="right">'.($currcomb->variation_price >= 0 ?
'+' :
'').
price($currcomb->variation_price).($currcomb->variation_price_percentage ?
' %' :
'').
'</td>';
950 print
'<td class="right">'.($currcomb->variation_weight >= 0 ?
'+' :
'').
price($currcomb->variation_weight).
' '.
measuringUnitString(0,
'weight', $prodstatic->weight_units).
'</td>';
952 print
'<td class="center">'.$prodstatic->getLibStatut(2, 0).
'</td>';
953 print
'<td class="center">'.$prodstatic->getLibStatut(2, 1).
'</td>';
955 print
'<td class="right">';
956 print
'<a class="paddingleft paddingright editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&action=edit&token='.
newToken().
'&combination_id='.$currcomb->id.
'">'.
img_edit().
'</a>';
957 print
'<a class="paddingleft paddingright" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&action=delete&token='.
newToken().
'&combination_id='.$currcomb->id.
'">'.
img_delete().
'</a>';
962 print
'<td class="nowrap center">';
963 if (!empty($productCombinations) || $massactionbutton || $massaction) {
965 if (in_array($prodstatic->id, $arrayofselected)) {
968 print
'<input id="cb'.$prodstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$prodstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
976 print
'<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
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'.
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.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.
product_prepare_head($object)
Prepare array with list of tabs.
measuringUnitString($unitid, $measuring_style='', $unitscale='', $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.