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';
31$langs->loadLangs(array(
"products",
"other"));
38$reference =
GETPOST(
'reference',
'alpha');
41$price_impact_percent = (bool)
GETPOST(
'price_impact_percent');
45$level_price_impact =
GETPOST(
'level_price_impact',
'array');
46$level_price_impact = array_map(
'price2num', $level_price_impact);
47$level_price_impact = array_map(
'floatval', $level_price_impact);
48$level_price_impact_percent =
GETPOST(
'level_price_impact_percent',
'array');
49$level_price_impact_percent = array_map(
'boolval', $level_price_impact_percent);
53$action =
GETPOST(
'action',
'aZ09');
54$massaction =
GETPOST(
'massaction',
'alpha');
56$confirm =
GETPOST(
'confirm',
'alpha');
57$toselect =
GETPOST(
'toselect',
'array');
58$cancel =
GETPOST(
'cancel',
'alpha');
59$delete_product =
GETPOST(
'delete_product',
'alpha');
60$subaction =
GETPOST(
'subaction',
'aZ09');
61$backtopage =
GETPOST(
'backtopage',
'alpha');
62$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
63$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
66$fieldvalue =
$id ?: $ref;
67$fieldtype = !empty($ref) ?
'ref' :
'rowid';
78$selectedvariant = isset($_SESSION[
'addvariant_'.
$object->id]) ? $_SESSION[
'addvariant_'.$object->id] : array();
81if (!isModEnabled(
'variants')) {
84if ($user->socid > 0) {
96 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
98$usercanread = ((
$object->isProduct() && $user->hasRight(
'produit',
'lire')) || (
$object->isService() && $user->hasRight(
'service',
'lire')));
99$usercancreate = ((
$object->isProduct() && $user->hasRight(
'produit',
'creer')) || (
$object->isService() && $user->hasRight(
'service',
'creer')));
100$usercandelete = ((
$object->isProduct() && $user->hasRight(
'produit',
'supprimer')) || (
$object->isService() && $user->hasRight(
'service',
'supprimer')));
110 unset($_SESSION[
'addvariant_'.
$object->id]);
117if ($action ==
'add') {
118 unset($selectedvariant);
119 unset($_SESSION[
'addvariant_'.
$object->id]);
121if ($action ==
'create' &&
GETPOST(
'selectvariant',
'alpha') && $usercancreate) {
125 if ($attribute_id > 0 && $attribute_value_id > 0) {
126 $feature = $attribute_id .
'-' . $attribute_value_id;
127 $selectedvariant[$feature] = $feature;
128 $_SESSION[
'addvariant_'.$object->id] = $selectedvariant;
131if ($action ==
'create' && $subaction ==
'delete' && $usercancreate) {
133 $feature =
GETPOST(
'feature',
'intcomma');
134 if (isset($selectedvariant[$feature])) {
135 unset($selectedvariant[$feature]);
136 $_SESSION[
'addvariant_'.$object->id] = $selectedvariant;
144$productCombination2ValuePairs1 = array();
146if (($action ==
'add' || $action ==
'create') && $usercancreate && empty($massaction) && !
GETPOST(
'selectvariant',
'alpha') && empty($subaction)) {
148 $features = !empty($_SESSION[
'addvariant_'.
$object->id]) ? $_SESSION[
'addvariant_'.$object->id] : array();
151 if ($action ==
'create') {
155 $reference = trim($reference);
156 if (empty($reference)) {
159 $weight_impact =
price2num($weight_impact);
160 $price_impact =
price2num($price_impact);
163 $level_price_impact = array(1 => $price_impact);
164 $level_price_impact_percent = array(1 => $price_impact_percent);
167 $sanit_features = array();
170 foreach ($features as $feature) {
171 $explode = explode(
'-', $feature);
172 if ($prodattr->fetch($explode[0]) <= 0 || $prodattr_val->fetch($explode[1]) <= 0) {
177 $sanit_features[(int) $explode[0]] = (
int) $explode[1];
180 $tmp->fk_prod_attr = (int) $explode[0];
181 $tmp->fk_prod_attr_val = (int) $explode[1];
183 $productCombination2ValuePairs1[] = $tmp;
190 if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) {
191 $result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $level_price_impact_percent, $level_price_impact, $weight_impact, $reference);
194 unset($_SESSION[
'addvariant_'.
$object->id]);
197 header(
'Location: '.
dol_buildpath(
'/variants/combinations.php?id='.$id, 2));
200 $langs->load(
"errors");
204 setEventMessages($langs->trans(
'ErrorRecordAlreadyExists'),
null,
'errors');
209} elseif (!empty($massaction)) {
210 $bulkaction = $massaction;
215 foreach ($toselect as $prodid) {
217 $prodstatic =
new Product($db);
218 if ($prodstatic->fetch($prodid) < 0) {
222 if ($bulkaction ==
'on_sell') {
223 $prodstatic->status = 1;
224 $res = $prodstatic->update($prodstatic->id, $user);
230 } elseif ($bulkaction ==
'on_buy') {
231 $prodstatic->status_buy = 1;
232 $res = $prodstatic->update($prodstatic->id, $user);
238 } elseif ($bulkaction ==
'not_sell') {
239 $prodstatic->status = 0;
240 $res = $prodstatic->update($prodstatic->id, $user);
246 } elseif ($bulkaction ==
'not_buy') {
247 $prodstatic->status_buy = 0;
248 $res = $prodstatic->update($prodstatic->id, $user);
254 } elseif ($bulkaction ==
'delete') {
255 $res = $prodstatic->delete($user, $prodstatic->id);
268 if (empty($prodstatic->error)) {
275} elseif ($action ===
'update' && $combination_id > 0 && $usercancreate) {
276 if ($prodcomb->fetch($combination_id) < 0) {
281 $prodcomb->variation_weight = (float)
price2num($weight_impact);
285 $prodcomb->variation_price = $level_price_impact[1];
286 $prodcomb->variation_price_percentage = $level_price_impact_percent[1];
288 $level_price_impact = array(1 => $price_impact);
289 $level_price_impact_percent = array(1 => $price_impact_percent);
291 $prodcomb->variation_price = $price_impact;
292 $prodcomb->variation_price_percentage = $price_impact_percent;
296 $prodcomb->combination_price_levels = array();
297 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
299 $productCombinationLevel->fk_product_attribute_combination = $prodcomb->id;
300 $productCombinationLevel->fk_price_level = $i;
301 $productCombinationLevel->variation_price = (float) $level_price_impact[$i];
302 $productCombinationLevel->variation_price_percentage = (bool) $level_price_impact_percent[$i];
303 $prodcomb->combination_price_levels[$i] = $productCombinationLevel;
311 $product_child =
new Product($db);
312 $product_child->fetch($prodcomb->fk_product_child);
313 $product_child->oldcopy = clone $product_child;
314 $product_child->ref = $reference;
316 $result = $product_child->update($product_child->id, $user);
324 $result = $prodcomb->update($user);
334 header(
'Location: ' .
dol_buildpath(
'/variants/combinations.php?id=' . $id, 2));
343$productCombinations = $prodcomb->fetchAllByFkProductParent(
$object->id,
true);
345if ($action ===
'confirm_deletecombination' && $usercancreate) {
346 if ($prodcomb->fetch($combination_id) > 0) {
349 if ($prodcomb->delete($user) > 0 && (empty($delete_product) || ($delete_product ==
'on' && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0))) {
357 setEventMessages($langs->trans(
'ProductCombinationAlreadyUsed'),
null,
'errors');
360} elseif ($action ===
'edit' && $usercancreate) {
361 if ($prodcomb->fetch($combination_id) < 0) {
366 $product_child =
new Product($db);
367 $product_child->fetch($prodcomb->fk_product_child);
368 $reference = $product_child->ref;
369 $weight_impact = $prodcomb->variation_weight;
370 $price_impact = $prodcomb->variation_price;
371 $price_impact_percent = $prodcomb->variation_price_percentage;
373 $productCombination2ValuePairs1 = $prodcomb2val->fetchByFkCombination($combination_id);
374} elseif ($action ===
'confirm_copycombination' && $usercancreate) {
376 $dest_product =
GETPOST(
'dest_product');
378 if ($prodstatic->fetch(0, $dest_product) > 0) {
380 if ($prodstatic->ref !=
$object->ref) {
381 if ($prodcomb->copyAll($user,
$object->id, $prodstatic) > 0) {
382 header(
'Location: '.
dol_buildpath(
'/variants/combinations.php?id='.$prodstatic->id, 2));
385 setEventMessages($langs->trans(
'ErrorCopyProductCombinations'),
null,
'errors');
389 setEventMessages($langs->trans(
'ErrorDestinationProductNotFound'),
null,
'errors');
399$form =
new Form($db);
401$title = $langs->trans(
"Variant");
406if (!empty($id) || !empty($ref)) {
407 $showbarcode = isModEnabled(
'barcode');
408 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
413 $titre = $langs->trans(
"CardProduct".
$object->type);
414 $picto =
$object->isService() ?
'service' :
'product';
418 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?type='.((int)
$object->type).
'">'.$langs->trans(
"BackToList").
'</a>';
419 $object->next_prev_filter =
"fk_product_type = ".((int)
$object->type);
421 dol_banner_tab($object,
'ref', $linkback, ($user->socid ? 0 : 1),
'ref',
'',
'',
'', 0,
'',
'');
423 print
'<div class="fichecenter">';
425 print
'<div class="underbanner clearboth"></div>';
426 print
'<table class="border centpercent tableforfield">';
429 if (isModEnabled(
"product") && isModEnabled(
"service")) {
430 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
431 print
'<tr><td class="titlefieldcreate">';
432 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type',
$object->type, $object, $usercancreate, $typeformat) : $langs->trans(
'Type');
434 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, $usercancreate, $typeformat);
439 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
446 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
449 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
451 if (empty($positiverates)) {
452 $positiverates =
'0';
454 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr);
464 print
'<tr><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
465 if (
$object->price_base_type ==
'TTC') {
473 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td>';
474 if (
$object->price_base_type ==
'TTC') {
482 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
488 print
"</td></tr>\n";
493 print
'<div class="clearboth"></div>';
497 $listofvariantselected =
'';
500 if ($action ==
'add' || ($action ==
'edit')) {
501 if ($action ==
'add') {
502 $title = $langs->trans(
'NewProductCombination');
504 $features = !empty($_SESSION[
'addvariant_'.
$object->id]) ? $_SESSION[
'addvariant_'.$object->id] : array();
506 $listofvariantselected =
'<div id="parttoaddvariant">';
507 if (!empty($features)) {
509 foreach ($features as $feature) {
510 $explode = explode(
'-', $feature);
511 if ($prodattr->fetch($explode[0]) <= 0 || $prodattr_val->fetch($explode[1]) <= 0) {
514 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #ddd;">' . $prodattr->label.
' : '.$prodattr_val->value .
515 ' <a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=create&subaction=delete&feature='.urlencode($feature).
'">' .
img_delete() .
'</a></li>';
517 $listofvariantselected .=
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
519 $listofvariantselected .=
'</div>';
522 $title = $langs->trans(
'EditProductCombination');
525 if ($action ==
'add') {
526 $prodattr_all = $prodattr->fetchAll();
529 $selected = $prodattr_all[key($prodattr_all)]->id;
532 $prodattr_alljson = array();
534 foreach ($prodattr_all as $each) {
535 $prodattr_alljson[$each->id] = $each;
538 <script
type=
"text/javascript">
540 variants_available = <?php echo json_encode($prodattr_alljson, JSON_PARTIAL_OUTPUT_ON_ERROR); ?>;
541 variants_selected = {
547 foreach ($productCombination2ValuePairs1 as $pc2v) {
548 $prodattr_val->fetch($pc2v->fk_prod_attr_val); ?>
549 variants_selected.index.push(<?php echo $pc2v->fk_prod_attr ?>);
550 variants_selected.info[<?php echo $pc2v->fk_prod_attr ?>] = {
551 attribute: variants_available[<?php echo $pc2v->fk_prod_attr ?>],
553 id: <?php echo $pc2v->fk_prod_attr_val ?>,
554 label:
'<?php echo $prodattr_val->value ?>'
560 restoreAttributes =
function() {
561 jQuery(
"select[name=attribute]").empty().append(
'<option value="-1"> </option>');
563 jQuery.each(variants_available,
function (key, val) {
564 if (jQuery.inArray(val.id, variants_selected.index) == -1) {
565 jQuery(
"select[name=attribute]").append(
'<option value="' + val.id +
'">' + val.label +
'</option>');
571 jQuery(document).ready(
function() {
572 jQuery(
"select#attribute").change(
function () {
573 console.log(
"Change of field variant attribute");
574 var select = jQuery(
"select#value");
576 if (!jQuery(
this).val().length || jQuery(
this).val() ==
'-1') {
578 select.append(
'<option value="-1"> </option>');
582 select.empty().append(
'<option value="">Loading...</option>');
584 jQuery.getJSON(
"ajax/get_attribute_values.php", {
585 id: jQuery(
this).val()
589 select.append(
'<option value="-1"> </option>');
590 return alert(data.error);
594 select.append(
'<option value="-1"> </option>');
596 jQuery(data).each(
function (key, val) {
597 keyforoption = val.id
598 valforoption = val.value
599 select.append(
'<option value="' + keyforoption +
'">' + valforoption +
'</option>');
613 print
'<form method="post" id="combinationform" action="'.$_SERVER[
"PHP_SELF"] .
'?id='.
$object->id.
'">'.
"\n";
614 print
'<input type="hidden" name="token" value="'.newToken().
'">';
615 print
'<input type="hidden" name="action" value="'.(($combination_id > 0) ?
"update" :
"create").
'">'.
"\n";
616 if ($combination_id > 0) {
617 print
'<input type="hidden" name="combination_id" value="'.$combination_id.
'">'.
"\n";
623 if ($action ==
'add') {
624 print
'<table class="border" style="width: 100%">';
625 print
"<!-- Variant -->\n";
627 print
'<td class="titlefieldcreate fieldrequired"><label for="attribute">'.$langs->trans(
'ProductAttribute').
'</label></td>';
629 if (is_array($prodattr_all)) {
630 print
'<select class="flat minwidth100" id="attribute" name="attribute">';
631 print
'<option value="-1"> </option>';
632 foreach ($prodattr_all as $attr) {
634 print
'<option value="'.$attr->id.
'">'.$attr->label.
'</option>';
639 $htmltext = $langs->trans(
"GoOnMenuToCreateVairants", $langs->transnoentities(
"Product"), $langs->transnoentities(
"VariantAttributes"));
640 print $form->textwithpicto(
'', $htmltext);
649 <td
class=
"fieldrequired"><label
for=
"value"><?php echo $langs->trans(
'Value') ?></label></td>
651 <select
class=
"flat minwidth100" id=
"value" name=
"value">
652 <option value=
"-1"> </option>
655 $htmltext = $langs->trans(
"GoOnMenuToCreateVairants", $langs->transnoentities(
"Product"), $langs->transnoentities(
"VariantAttributes"));
656 print $form->textwithpicto(
'', $htmltext);
666 <input
type=
"submit" class=
"button" name=
"selectvariant" id=
"selectvariant" value=
"<?php echo dol_escape_htmltag($langs->trans("SelectCombination
")); ?>">
670 print
'<tr><td></td><td>';
671 print $listofvariantselected;
679 if (is_array($productCombination2ValuePairs1)) {
680 print
'<table class="border" style="width: 100%">';
683 if (is_array($productCombination2ValuePairs1) && count($productCombination2ValuePairs1)) {
686 <td
class=
"titlefieldcreate tdtop"><label
for=
"features"><?php echo $langs->trans(
'Attributes') ?></label></td>
688 <div
class=
"inline-block valignmiddle quatrevingtpercent">
690 foreach ($productCombination2ValuePairs1 as $pc2v) {
691 $result1 = $prodattr->fetch($pc2v->fk_prod_attr);
692 $result2 = $prodattr_val->fetch($pc2v->fk_prod_attr_val);
693 if ($result1 > 0 && $result2 > 0) {
694 print $prodattr->label.
' : '.$prodattr_val->value.
'<br>';
699 <!-- <div
class=
"inline-block valignmiddle">
700 <a href=
"#" class=
"inline-block valignmiddle button" id=
"delfeature"><?php echo
img_edit_remove() ?></a>
709 <td><label
for=
"reference"><?php echo $langs->trans(
'Reference') ?></label></td>
710 <td><input
type=
"text" id=
"reference" name=
"reference" value=
"<?php echo trim($reference) ?>"></td>
716 <td><label
for=
"price_impact"><?php echo $langs->trans(
'PriceImpact') ?></label></td>
717 <td><input
type=
"text" id=
"price_impact" name=
"price_impact" value=
"<?php echo price($price_impact) ?>">
718 <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>
723 $prodcomb->fetchCombinationPriceLevels();
725 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
726 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
727 $text = $langs->trans(
'ImpactOnPriceLevel', $i).
' - '.
getDolGlobalString($keyforlabel);
729 print
'<td><label for="level_price_impact_'.$i.
'">'.$text.
'</label>';
731 print
'<br/><a id="apply-price-impact-to-all-level" class="classfortooltip" href="#" title="'.$langs->trans(
'ApplyToAllPriceImpactLevelHelp').
'">('.$langs->trans(
'ApplyToAllPriceImpactLevel').
')</a>';
734 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).
'">';
735 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>';
744 print
'<td><label for="weight_impact">'.$langs->trans(
'WeightImpact').
'</label></td>';
745 print
'<td><input type="text" id="weight_impact" name="weight_impact" value="'.price($weight_impact).
'"></td>';
755 $(document).ready(
function() {
757 $(
'body').on(
'click',
'#apply-price-impact-to-all-level',
function(e) {
759 let priceImpact = $(
"#level_price_impact_1" ).val();
760 let priceImpactPrecent = $(
"#level_price_impact_percent_1" ).prop(
"checked");
762 var multipricelimit = <?php print intval($conf->global->PRODUIT_MULTIPRICES_LIMIT); ?>
764 for (let i = 2; i <= multipricelimit; i++) {
765 $(
"#level_price_impact_" + i ).val(priceImpact);
766 $(
"#level_price_impact_percent_" + i ).prop(
"checked", priceImpactPrecent);
776 <div style=
"text-align: center">
777 <input
type=
"submit" name=
"create" <?php
if (!is_array($productCombination2ValuePairs1)) {
778 print
' disabled="disabled"';
779 } ?> value=
"<?php echo $action == 'add' ? $langs->trans('Create') : $langs->trans("Save
") ?>" class=
"button button-save">
781 <input
type=
"submit" name=
"cancel" value=
"<?php echo $langs->trans("Cancel
"); ?>" class=
"button button-cancel">
788 if ($action ===
'delete') {
789 if ($prodcomb->fetch($combination_id) > 0) {
790 $prodstatic->fetch($prodcomb->fk_product_child);
792 print $form->formconfirm(
793 "combinations.php?id=".urlencode((
string) ($id)).
"&combination_id=".urlencode((
string) ($combination_id)),
794 $langs->trans(
'Delete'),
795 $langs->trans(
'ProductCombinationDeleteDialog', $prodstatic->ref),
796 "confirm_deletecombination",
797 array(array(
'label' => $langs->trans(
'DeleteLinkedProduct'),
'type' =>
'checkbox',
'name' =>
'delete_product',
'value' =>
false)),
802 } elseif ($action ===
'copy') {
803 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);
808 if ($productCombinations) {
811 <script
type=
"text/javascript">
812 jQuery(document).ready(
function() {
814 jQuery(
'input[name="select_all"]').click(
function() {
816 if (jQuery(
this).prop(
'checked')) {
822 jQuery(
'table.liste input[type="checkbox"]').prop(
'checked', checked);
825 jQuery(
'input[name^="select["]').click(
function() {
826 jQuery(
'input[name="select_all"]').prop(
'checked',
false);
836 print
'<div class="tabsAction">';
838 print
' <div class="inline-block divButAction">';
840 print
'<a href="combinations.php?id='.$object->id.
'&action=add&token='.
newToken().
'" class="butAction">'.$langs->trans(
'NewProductCombination').
'</a>';
842 if ($productCombinations) {
843 print
'<a href="combinations.php?id='.$object->id.
'&action=copy&token='.
newToken().
'" class="butAction">'.$langs->trans(
'PropagateVariant').
'</a>';
852 $arrayofselected = is_array($toselect) ? $toselect : array();
856 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"] .
'?id='.
$object->id.
'">';
857 print
'<input type="hidden" name="token" value="'.newToken().
'">';
858 print
'<input type="hidden" name="action" value="massaction">';
859 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
864 if (count($productCombinations)) {
865 $aaa =
'<select id="bulk_action" name="massaction" class="flat">';
866 $aaa .=
' <option value="nothing"> </option>';
867 $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>';
868 $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>';
869 $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>';
870 $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>';
871 $aaa .=
' <option value="delete" data-html="'.dol_escape_htmltag(
img_picto($langs->trans(
"Delete"),
'delete',
'class="pictofixedwidth"').$langs->trans(
'Delete')).
'">'.$langs->trans(
'Delete').
'</option>';
874 $aaa .=
'<input type="submit" value="'.dol_escape_htmltag($langs->trans(
"Apply")).
'" class="button small">';
876 $massactionbutton = $aaa;
878 $title = $langs->trans(
"ProductCombinations");
880 print_barre_liste($title, 0, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder, $aaa, 0);
882 print
'<div class="div-table-responsive">'; ?>
883 <
table class=
"liste">
884 <tr
class=
"liste_titre">
888 print
'<td class="liste_titre center">';
889 $searchpicto = $form->showCheckAddButtons(
'checkforselect', 1);
893 <td
class=
"liste_titre"><?php echo $langs->trans(
'Product') ?></td>
894 <td
class=
"liste_titre"><?php echo $langs->trans(
'Attributes') ?></td>
895 <td
class=
"liste_titre right"><?php echo $langs->trans(
'PriceImpact') ?></td>
896 <?php
if (
$object->isProduct()) {
897 print
'<td class="liste_titre right">'.$langs->trans(
'WeightImpact').
'</td>';
899 <td
class=
"liste_titre center"><?php echo $langs->trans(
'OnSell') ?></td>
900 <td
class=
"liste_titre center"><?php echo $langs->trans(
'OnBuy') ?></td>
901 <td
class=
"liste_titre"></td>
905 print
'<td class="liste_titre center">';
906 $searchpicto = $form->showCheckAddButtons(
'checkforselect', 1);
913 if (count($productCombinations)) {
914 foreach ($productCombinations as $currcomb) {
915 $prodstatic->fetch($currcomb->fk_product_child);
916 print
'<tr class="oddeven">';
920 print
'<td class="nowrap center">';
921 if (!empty($productCombinations) || $massactionbutton || $massaction) {
923 if (in_array($prodstatic->id, $arrayofselected)) {
926 print
'<input id="cb'.$prodstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$prodstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
931 print
'<td>'.$prodstatic->getNomUrl(1).
'</td>';
933 foreach ($comb2val->fetchByFkCombination($currcomb->id) as $pc2v) {
937 print
'<td class="right">'.($currcomb->variation_price >= 0 ?
'+' :
'').
price($currcomb->variation_price).($currcomb->variation_price_percentage ?
' %' :
'').
'</td>';
939 print
'<td class="right">'.($currcomb->variation_weight >= 0 ?
'+' :
'').
price($currcomb->variation_weight).
' '.
measuringUnitString(0,
'weight', $prodstatic->weight_units).
'</td>';
941 print
'<td class="center">'.$prodstatic->getLibStatut(2, 0).
'</td>';
942 print
'<td class="center">'.$prodstatic->getLibStatut(2, 1).
'</td>';
944 print
'<td class="right">';
945 print
'<a class="paddingleft paddingright editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&action=edit&token='.
newToken().
'&combination_id='.$currcomb->id.
'">'.
img_edit().
'</a>';
946 print
'<a class="paddingleft paddingright" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&action=delete&token='.
newToken().
'&combination_id='.$currcomb->id.
'">'.
img_delete().
'</a>';
951 print
'<td class="nowrap center">';
952 if (!empty($productCombinations) || $massactionbutton || $massaction) {
954 if (in_array($prodstatic->id, $arrayofselected)) {
957 print
'<input id="cb'.$prodstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$prodstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
965 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.
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.
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.
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.
print_barre_liste($title, $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.
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($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.