Better fix for type of discount

This commit is contained in:
Laurent Destailleur 2019-02-28 11:44:10 +01:00
parent 92259810c1
commit 855aaaffd8
2 changed files with 51 additions and 43 deletions

View File

@ -377,7 +377,11 @@ if ($object->id > 0)
print '</tr>'; print '</tr>';
} }
$isCustomer = ($object->client == 1 || $object->client == 3);
// Relative discounts (Discounts-Drawbacks-Rebates) // Relative discounts (Discounts-Drawbacks-Rebates)
if ($isCustomer)
{
print '<tr><td class="nowrap">'; print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans("CustomerRelativeDiscountShort"); print $langs->trans("CustomerRelativeDiscountShort");
@ -409,6 +413,7 @@ if ($object->id > 0)
//else print $langs->trans("DiscountNone"); //else print $langs->trans("DiscountNone");
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
}
// Max outstanding bill // Max outstanding bill
if ($object->client) if ($object->client)

View File

@ -106,7 +106,7 @@ if ($socid > 0)
$head = societe_prepare_head($object); $head = societe_prepare_head($object);
$isCustomer = $object->client == 1 || $object->client == 3; $isCustomer = ($object->client == 1 || $object->client == 3);
$isSupplier = $object->fournisseur == 1; $isSupplier = $object->fournisseur == 1;
print '<form method="POST" action="remise.php?id='.$object->id.'">'; print '<form method="POST" action="remise.php?id='.$object->id.'">';
@ -122,7 +122,7 @@ if ($socid > 0)
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
if(! $isCustomer && ! $isSupplier) { if (! $isCustomer && ! $isSupplier) {
print '<p class="opacitymedium">'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'</p>'; print '<p class="opacitymedium">'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'</p>';
dol_fiche_end(); dol_fiche_end();
@ -136,13 +136,13 @@ if ($socid > 0)
print '<table class="border centpercent">'; print '<table class="border centpercent">';
if($isCustomer) { if ($isCustomer) {
// Customer discount // Customer discount
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans("CustomerRelativeDiscount").'</td><td>'.price2num($object->remise_percent)."%</td></tr>"; print $langs->trans("CustomerRelativeDiscount").'</td><td>'.price2num($object->remise_percent)."%</td></tr>";
} }
if($isSupplier) { if ($isSupplier) {
// Supplier discount // Supplier discount
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans("SupplierRelativeDiscount").'</td><td>'.price2num($object->remise_supplier_percent)."%</td></tr>"; print $langs->trans("SupplierRelativeDiscount").'</td><td>'.price2num($object->remise_supplier_percent)."%</td></tr>";
@ -155,24 +155,27 @@ if ($socid > 0)
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
if($isCustomer && ! $isSupplier) { /*if (! ($isCustomer && $isSupplier))
{
if ($isCustomer && ! $isSupplier) {
print '<input type="hidden" name="discount_type" value="0" />'; print '<input type="hidden" name="discount_type" value="0" />';
} }
if (! $isCustomer && $isSupplier) {
if(! $isCustomer && $isSupplier) {
print '<input type="hidden" name="discount_type" value="1" />'; print '<input type="hidden" name="discount_type" value="1" />';
} }
}*/
print '<table class="border centpercent">'; print '<table class="border centpercent">';
if($isCustomer || $isSupplier) { if ($isCustomer || $isSupplier)
{
// Discount type // Discount type
print '<tr><td class="titlefield fieldrequired">'.$langs->trans('DiscountType').'</td><td>'; print '<tr><td class="titlefield fieldrequired">'.$langs->trans('DiscountType').'</td><td>';
if ($isCustomer) { if ($isCustomer) {
print '<input type="radio" name="discount_type" id="discount_type_0" selected value="0"/> <label for="discount_type_0">'.$langs->trans('Customer').'</label>'; print '<input type="radio" name="discount_type" id="discount_type_0" checked value="0"/> <label for="discount_type_0">'.$langs->trans('Customer').'</label>';
} }
if ($isSupplier) { if ($isSupplier) {
print ' <input type="radio" name="discount_type" id="discount_type_1" selected value="1"/> <label for="discount_type_1">'.$langs->trans('Supplier').'</label>'; print ' <input type="radio" name="discount_type" id="discount_type_1"'.($isCustomer?'':' checked').' value="1"/> <label for="discount_type_1">'.$langs->trans('Supplier').'</label>';
} }
print '</td></tr>'; print '</td></tr>';
} }