From 855aaaffd8f2a6df7e93019b6fa2ad68ca777a0e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Feb 2019 11:44:10 +0100 Subject: [PATCH] Better fix for type of discount --- htdocs/comm/card.php | 63 +++++++++++++++++++++++------------------- htdocs/comm/remise.php | 31 +++++++++++---------- 2 files changed, 51 insertions(+), 43 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 2cf3c120af6..be60c4fa574 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -377,38 +377,43 @@ if ($object->id > 0) print ''; } - // Relative discounts (Discounts-Drawbacks-Rebates) - print ''; - print '
'; - print $langs->trans("CustomerRelativeDiscountShort"); - print ''; - if ($user->rights->societe->creer && !$user->societe_id > 0) - { - print ''.img_edit($langs->trans("Modify")).''; - } - print '
'; - print ''.($object->remise_percent?''.$object->remise_percent.'%':'').''; - print ''; + $isCustomer = ($object->client == 1 || $object->client == 3); - // Absolute discounts (Discounts-Drawbacks-Rebates) - print ''; - print ''; - print ''; + print ''; + + // Absolute discounts (Discounts-Drawbacks-Rebates) + print ''; + print ''; + print ''; } - print '
'; - print $langs->trans("CustomerAbsoluteDiscountShort"); - print ''; - if ($user->rights->societe->creer && !$user->societe_id > 0) + // Relative discounts (Discounts-Drawbacks-Rebates) + if ($isCustomer) { - print ''.img_edit($langs->trans("Modify")).''; + print '
'; + print '
'; + print $langs->trans("CustomerRelativeDiscountShort"); + print ''; + if ($user->rights->societe->creer && !$user->societe_id > 0) + { + print ''.img_edit($langs->trans("Modify")).''; + } + print '
'; + print '
'.($object->remise_percent?''.$object->remise_percent.'%':'').'
'; + print ''; + print '
'; + print $langs->trans("CustomerAbsoluteDiscountShort"); + print ''; + if ($user->rights->societe->creer && !$user->societe_id > 0) + { + print ''.img_edit($langs->trans("Modify")).''; + } + print '
'; + print '
'; + $amount_discount=$object->getAvailableDiscounts(); + if ($amount_discount < 0) dol_print_error($db,$object->error); + if ($amount_discount > 0) print ''.price($amount_discount,1,$langs,1,-1,-1,$conf->currency).''; + //else print $langs->trans("DiscountNone"); + print '
'; - print ''; - print ''; - $amount_discount=$object->getAvailableDiscounts(); - if ($amount_discount < 0) dol_print_error($db,$object->error); - if ($amount_discount > 0) print ''.price($amount_discount,1,$langs,1,-1,-1,$conf->currency).''; - //else print $langs->trans("DiscountNone"); - print ''; - print ''; // Max outstanding bill if ($object->client) diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 7cc675b1816..13e4f13ec3d 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -106,7 +106,7 @@ if ($socid > 0) $head = societe_prepare_head($object); - $isCustomer = $object->client == 1 || $object->client == 3; + $isCustomer = ($object->client == 1 || $object->client == 3); $isSupplier = $object->fournisseur == 1; print '
'; @@ -122,7 +122,7 @@ if ($socid > 0) print '
'; - if(! $isCustomer && ! $isSupplier) { + if (! $isCustomer && ! $isSupplier) { print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; dol_fiche_end(); @@ -136,13 +136,13 @@ if ($socid > 0) print ''; - if($isCustomer) { + if ($isCustomer) { // Customer discount print '"; } - if($isSupplier) { + if ($isSupplier) { // Supplier discount print '"; @@ -155,24 +155,27 @@ if ($socid > 0) print '
'; - if($isCustomer && ! $isSupplier) { - print ''; - } - - if(! $isCustomer && $isSupplier) { - print ''; - } + /*if (! ($isCustomer && $isSupplier)) + { + if ($isCustomer && ! $isSupplier) { + print ''; + } + if (! $isCustomer && $isSupplier) { + print ''; + } + }*/ print '
'; print $langs->trans("CustomerRelativeDiscount").''.price2num($object->remise_percent)."%
'; print $langs->trans("SupplierRelativeDiscount").''.price2num($object->remise_supplier_percent)."%
'; - if($isCustomer || $isSupplier) { + if ($isCustomer || $isSupplier) + { // Discount type print ''; }
'.$langs->trans('DiscountType').''; if ($isCustomer) { - print ' '; + print ' '; } if ($isSupplier) { - print ' '; + print ' '; } print '