Merge pull request #8673 from frederic34/variantonservice

NEW Module variant supported on services
This commit is contained in:
Laurent Destailleur 2018-04-27 10:01:28 +02:00 committed by GitHub
commit 19d15c79dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 15 deletions

View File

@ -97,7 +97,7 @@ function product_prepare_head($object)
$head[$h][2] = 'referers';
$h++;
if (!empty($conf->variants->enabled) && $object->isProduct()) {
if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) {
global $db;

View File

@ -1771,7 +1771,7 @@ else
}
//Parent product.
if (!empty($conf->variants->enabled) && $object->isProduct()) {
if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) {
$combination = new ProductCombination($db);

View File

@ -71,7 +71,7 @@ if ($cancel) {
unset($_SESSION['addvariant_'.$object->id]);
}
if (! $object->isProduct()) {
if (! $object->isProduct() && ! $object->isService()) {
header('Location: '.dol_buildpath('/product/card.php?id='.$object->id, 2));
exit();
}
@ -327,11 +327,31 @@ if (! empty($id) || ! empty($ref))
if ($action == 'add') {
$title = $langs->trans('NewProductCombination');
print dol_fiche_head();
$features = $_SESSION['addvariant_'.$object->id];
//First, sanitize
print '<div id="parttoaddvariant">';
if (! empty($features)) {
foreach ($features as $feature) {
$explode = explode(':', $feature);
if ($prodattr->fetch($explode[0]) < 0) {
continue;
}
if ($prodattr_val->fetch($explode[1]) < 0) {
continue;
}
print '<i>' . $prodattr->label . '</i>:'. $prodattr_val->value . ' ';
}
}
print '</div>';
print dol_fiche_end();
} else {
$title = $langs->trans('EditProductCombination');
}
print '<div id="parttoaddvariant"></div>';
print_fiche_titre($title);
if ($action == 'add') {
@ -346,8 +366,8 @@ if (! empty($id) || ! empty($ref))
foreach ($prodattr_all as $each) {
$prodattr_alljson[$each->id] = $each;
}
?>
?>
<script type="text/javascript">
@ -523,12 +543,13 @@ if (! empty($id) || ! empty($ref))
<td><input type="text" id="price_impact" name="price_impact" value="<?php echo price($price_impact) ?>">
<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></td>
</tr>
<tr>
<td><label for="weight_impact"><?php echo $langs->trans('WeightImpact') ?></label></td>
<td><input type="text" id="weight_impact" name="weight_impact" value="<?php echo price($weight_impact) ?>"></td>
</tr>
</table>
<?php
<?php if ($object->isProduct()) {
print '<tr>';
print '<td><label for="weight_impact">'.$langs->trans('WeightImpact').'</label></td>';
print '<td><input type="text" id="weight_impact" name="weight_impact" value="'.price($weight_impact).'"></td>';
print '</tr>';
}
print '</table>';
}
print dol_fiche_end();
@ -678,7 +699,7 @@ if (! empty($id) || ! empty($ref))
<td class="liste_titre"><?php echo $langs->trans('Product') ?></td>
<td class="liste_titre"><?php echo $langs->trans('Combination') ?></td>
<td class="liste_titre right"><?php echo $langs->trans('PriceImpact') ?></td>
<td class="liste_titre right"><?php echo $langs->trans('WeightImpact') ?></td>
<?php if ($object->isProduct()) print'<td class="liste_titre right">'.$langs->trans('WeightImpact').'</td>'; ?>
<td class="liste_titre center"><?php echo $langs->trans('OnSell') ?></td>
<td class="liste_titre center"><?php echo $langs->trans('OnBuy') ?></td>
<td class="liste_titre"></td>
@ -714,7 +735,7 @@ if (! empty($id) || ! empty($ref))
} ?>
</td>
<td class="right"><?php echo ($currcomb->variation_price >= 0 ? '+' : '').price($currcomb->variation_price).($currcomb->variation_price_percentage ? ' %' : '') ?></td>
<td class="right"><?php echo ($currcomb->variation_weight >= 0 ? '+' : '').price($currcomb->variation_weight).' '.measuring_units_string($prodstatic->weight_units, 'weight') ?></td>
<?php if ($object->isProduct()) print '<td class="right">'.($currcomb->variation_weight >= 0 ? '+' : '').price($currcomb->variation_weight).' '.measuring_units_string($prodstatic->weight_units, 'weight').'</td>'; ?>
<td style="text-align: center;"><?php echo $prodstatic->getLibStatut(2, 0) ?></td>
<td style="text-align: center;"><?php echo $prodstatic->getLibStatut(2, 1) ?></td>
<td class="right">