Merge pull request #9150 from frederic34/variant

code cleaning
This commit is contained in:
Laurent Destailleur 2018-08-21 13:21:11 +02:00 committed by GitHub
commit 5effcd222f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 23 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -62,9 +62,9 @@ print '<tr class="oddeven"><td>'.$langs->trans('HideProductCombinations').'</td>
print $form->selectyesno("PRODUIT_ATTRIBUTES_HIDECHILD",$conf->global->PRODUIT_ATTRIBUTES_HIDECHILD,1).'</td></tr>'; print $form->selectyesno("PRODUIT_ATTRIBUTES_HIDECHILD",$conf->global->PRODUIT_ATTRIBUTES_HIDECHILD,1).'</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans('CombinationsSeparator').'</td>'; print '<tr class="oddeven"><td>'.$langs->trans('CombinationsSeparator').'</td>';
if(isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) { if(isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) {
$separator = $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR; $separator = $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR;
} else { } else {
$separator = "_"; $separator = "_";
} }
print '<td align="right"><input size="3" type="text" class="flat" name="PRODUIT_ATTRIBUTES_SEPARATOR" value="'.$separator.'"></td></tr>'; print '<td align="right"><input size="3" type="text" class="flat" name="PRODUIT_ATTRIBUTES_SEPARATOR" value="'.$separator.'"></td></tr>';
print '</table>'; print '</table>';
@ -74,4 +74,3 @@ print '</form>';
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com> /* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -50,7 +51,7 @@ if ($_POST) {
$object->label = $label; $object->label = $label;
if ($object->update($user) < 1) { if ($object->update($user) < 1) {
setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); setEventMessages($langs->trans('CoreErrorMessage'), $object->errors, 'errors');
} else { } else {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
header('Location: '.dol_buildpath('/variants/card.php?id='.$id, 2)); header('Location: '.dol_buildpath('/variants/card.php?id='.$id, 2));
@ -79,7 +80,7 @@ if ($_POST) {
if ($objectval->update($user) > 0) { if ($objectval->update($user) > 0) {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} else { } else {
setEventMessage($langs->trans('CoreErrorMessage'), null, 'errors'); setEventMessage($langs->trans('CoreErrorMessage'), $objectval->errors, 'errors');
} }
} }
} }
@ -99,7 +100,7 @@ if ($confirm == 'yes') {
if ($res < 1 || ($object->delete() < 1)) { if ($res < 1 || ($object->delete() < 1)) {
$db->rollback(); $db->rollback();
setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); setEventMessages($langs->trans('CoreErrorMessage'), $object->errors, 'errors');
header('Location: '.dol_buildpath('/variants/card.php?id='.$object->id, 2)); header('Location: '.dol_buildpath('/variants/card.php?id='.$object->id, 2));
} else { } else {
$db->commit(); $db->commit();
@ -113,7 +114,7 @@ if ($confirm == 'yes') {
if ($objectval->fetch($valueid) > 0) { if ($objectval->fetch($valueid) > 0) {
if ($objectval->delete() < 1) { if ($objectval->delete() < 1) {
setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); setEventMessages($langs->trans('CoreErrorMessage'), $objectval->errors, 'errors');
} else { } else {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com> /* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -449,7 +450,7 @@ if (! empty($id) || ! empty($ref))
if($valueid > 0) { if($valueid > 0) {
print '<input type="hidden" name="valueid" value="' . $valueid .'">'."\n"; print '<input type="hidden" name="valueid" value="' . $valueid .'">'."\n";
} }
print dol_fiche_head(); print dol_fiche_head();
?> ?>

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com> /* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -49,7 +50,7 @@ if ($_POST) {
} }
exit; exit;
} else { } else {
setEventMessage($langs->trans('ErrorRecordAlreadyExists'), 'errors'); setEventMessages($langs->trans('ErrorRecordAlreadyExists'), $prodattr->errors, 'errors');
} }
} }
} }

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com> /* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -70,7 +71,7 @@ if ($action == 'add')
header('Location: '.DOL_URL_ROOT.'/variants/card.php?id='.$object->id); header('Location: '.DOL_URL_ROOT.'/variants/card.php?id='.$object->id);
exit(); exit();
} else { } else {
setEventMessages($langs->trans('ErrorCreatingProductAttributeValue'), null, 'errors'); setEventMessages($langs->trans('ErrorCreatingProductAttributeValue'), $objectval->errors, 'errors');
} }
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -103,7 +103,7 @@ if ($_POST) {
$res = 1; $res = 1;
foreach (cartesianArray($adapted_values) as $currcomb) foreach (cartesianArray($adapted_values) as $currcomb)
{ {
$res = $combination->createProductCombination($product, $currcomb, $sanitized_values, $price_var_percent); $res = $combination->createProductCombination($product, $currcomb, $sanitized_values, $price_var_percent);
if ($res < 0) { if ($res < 0) {
@ -146,17 +146,17 @@ if (! empty($id) || ! empty($ref)) {
{ {
$showbarcode=empty($conf->barcode->enabled)?0:1; $showbarcode=empty($conf->barcode->enabled)?0:1;
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0;
$head=product_prepare_head($object); $head=product_prepare_head($object);
$titre=$langs->trans("CardProduct".$object->type); $titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type== Product::TYPE_SERVICE?'service':'product'); $picto=($object->type== Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'combinations', $titre, 0, $picto); dol_fiche_head($head, 'combinations', $titre, 0, $picto);
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?type='.$object->type.'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
$object->next_prev_filter=" fk_product_type = ".$object->type; $object->next_prev_filter=" fk_product_type = ".$object->type;
dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', '', '', '', 0, '', '', 1); dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', '', '', '', 0, '', '', 1);
dol_fiche_end(); dol_fiche_end();
} }