NEW: supplier credit notes: factorized discount block (+ correct translations for supplier discounts)
This commit is contained in:
parent
e07177fec2
commit
451d943927
@ -1458,17 +1458,13 @@ if ($action == 'create')
|
|||||||
|
|
||||||
// Ligne info remises tiers
|
// Ligne info remises tiers
|
||||||
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
||||||
if ($soc->remise_percent)
|
|
||||||
print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent);
|
|
||||||
else
|
|
||||||
print $langs->trans("CompanyHasNoRelativeDiscount");
|
|
||||||
$absolute_discount = $soc->getAvailableDiscounts();
|
$absolute_discount = $soc->getAvailableDiscounts();
|
||||||
print '. ';
|
|
||||||
if ($absolute_discount)
|
$thirdparty = $soc;
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount, 0, $langs, 1, -1, -1, $conf->currency));
|
$discount_type = 0;
|
||||||
else
|
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?socid=' . $thirdparty->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid'));
|
||||||
print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
|
||||||
print '.';
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1884,29 +1880,17 @@ if ($action == 'create')
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
|
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
|
||||||
if ($soc->remise_percent)
|
|
||||||
print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent);
|
|
||||||
else
|
|
||||||
print $langs->trans("CompanyHasNoRelativeDiscount");
|
|
||||||
print '. ';
|
|
||||||
$absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount);
|
$absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount);
|
||||||
$absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote);
|
$absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote);
|
||||||
$absolute_discount = price2num($absolute_discount, 'MT');
|
$absolute_discount = price2num($absolute_discount, 'MT');
|
||||||
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
|
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
|
||||||
if ($absolute_discount) {
|
|
||||||
if ($object->statut > Propal::STATUS_DRAFT) {
|
$thirdparty = $soc;
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount, 0, $langs, 0, 0, -1, $conf->currency));
|
$discount_type = 0;
|
||||||
} else {
|
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id);
|
||||||
// Remise dispo de type non avoir
|
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
|
||||||
print '<br>';
|
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount, 0, '', 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($absolute_creditnote) {
|
|
||||||
print $langs->trans("CompanyHasCreditNote", price($absolute_creditnote, 0, $langs, 0, 0, -1, $conf->currency)) . '. ';
|
|
||||||
}
|
|
||||||
if (! $absolute_discount && ! $absolute_creditnote)
|
|
||||||
print $langs->trans("CompanyHasNoAbsoluteDiscount") . '.';
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Date of proposal
|
// Date of proposal
|
||||||
|
|||||||
@ -1558,17 +1558,14 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
|
|
||||||
// Ligne info remises tiers
|
// Ligne info remises tiers
|
||||||
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
||||||
if ($soc->remise_percent)
|
|
||||||
print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent);
|
|
||||||
else
|
|
||||||
print $langs->trans("CompanyHasNoRelativeDiscount");
|
|
||||||
print '. ';
|
|
||||||
$absolute_discount = $soc->getAvailableDiscounts();
|
$absolute_discount = $soc->getAvailableDiscounts();
|
||||||
if ($absolute_discount)
|
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency" . $conf->currency));
|
$thirdparty = $soc;
|
||||||
else
|
$discount_type = 0;
|
||||||
print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?socid=' . $thirdparty->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid'));
|
||||||
print '.';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
|
||||||
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
// Date
|
// Date
|
||||||
@ -2052,29 +2049,17 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
$addcreditnote = '<a href="' . DOL_URL_ROOT . '/compta/facture/card.php?action=create&socid=' . $soc->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>';
|
$addcreditnote = '<a href="' . DOL_URL_ROOT . '/compta/facture/card.php?action=create&socid=' . $soc->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>';
|
||||||
|
|
||||||
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
|
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
|
||||||
if ($soc->remise_percent)
|
|
||||||
print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent);
|
|
||||||
else
|
|
||||||
print $langs->trans("CompanyHasNoRelativeDiscount");
|
|
||||||
print '. ';
|
|
||||||
$absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount);
|
$absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount);
|
||||||
$absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote);
|
$absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote);
|
||||||
$absolute_discount = price2num($absolute_discount, 'MT');
|
$absolute_discount = price2num($absolute_discount, 'MT');
|
||||||
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
|
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
|
||||||
if ($absolute_discount) {
|
|
||||||
if ($object->statut > Commande::STATUS_DRAFT) {
|
$thirdparty = $soc;
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
$discount_type = 0;
|
||||||
} else {
|
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id);
|
||||||
// Remise dispo de type remise fixe (not credit note)
|
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
|
||||||
print '<br>';
|
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount, 0, '', 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($absolute_creditnote) {
|
|
||||||
print $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '. ';
|
|
||||||
}
|
|
||||||
if (! $absolute_discount && ! $absolute_creditnote)
|
|
||||||
print $langs->trans("CompanyHasNoAbsoluteDiscount") . '.';
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Date
|
// Date
|
||||||
|
|||||||
@ -2699,19 +2699,12 @@ if ($action == 'create')
|
|||||||
{
|
{
|
||||||
// Discounts for third party
|
// Discounts for third party
|
||||||
print '<tr><td>' . $langs->trans('Discounts') . '</td><td colspan="2">';
|
print '<tr><td>' . $langs->trans('Discounts') . '</td><td colspan="2">';
|
||||||
if ($soc->remise_percent)
|
|
||||||
print $langs->trans("CompanyHasRelativeDiscount", '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . $soc->remise_percent . '</a>');
|
$thirdparty = $soc;
|
||||||
else
|
$discount_type = 0;
|
||||||
print $langs->trans("CompanyHasNoRelativeDiscount");
|
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?socid=' . $thirdparty->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid'));
|
||||||
print ' <a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditRelativeDiscount") . ')</a>';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
|
||||||
print '. ';
|
|
||||||
print '<br>';
|
|
||||||
if ($absolute_discount)
|
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . price($absolute_discount) . '</a>', $langs->trans("Currency" . $conf->currency));
|
|
||||||
else
|
|
||||||
print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
|
||||||
print ' <a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditGlobalDiscounts") . ')</a>';
|
|
||||||
print '.';
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3363,84 +3356,14 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Relative and absolute discounts
|
// Relative and absolute discounts
|
||||||
$addrelativediscount = '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditRelativeDiscounts") . '</a>';
|
|
||||||
$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditGlobalDiscounts") . '</a>';
|
|
||||||
$addcreditnote = '<a href="' . DOL_URL_ROOT . '/compta/facture/card.php?action=create&socid=' . $soc->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>';
|
|
||||||
$viewabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("ViewAvailableGlobalDiscounts") . '</a>';
|
|
||||||
|
|
||||||
print '<!-- Discounts --><tr><td>' . $langs->trans('Discounts');
|
print '<!-- Discounts --><tr><td>' . $langs->trans('Discounts');
|
||||||
print '</td><td>';
|
|
||||||
if ($soc->remise_percent)
|
|
||||||
print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent);
|
|
||||||
else
|
|
||||||
print $langs->trans("CompanyHasNoRelativeDiscount");
|
|
||||||
// print ' ('.$addrelativediscount.')';
|
|
||||||
|
|
||||||
// Is there is commercial discount or down payment available ?
|
print '</td><td>';
|
||||||
if ($absolute_discount > 0) {
|
$thirdparty = $soc;
|
||||||
print '. ';
|
$discount_type = 0;
|
||||||
if ($object->statut > 0 || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) {
|
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?facid=' . $object->id);
|
||||||
if ($object->statut == 0) {
|
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
|
||||||
print '. ';
|
|
||||||
} else {
|
|
||||||
if ($object->statut < 1 || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) {
|
|
||||||
$text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
|
||||||
print '<br>' . $text . '.<br>';
|
|
||||||
} else {
|
|
||||||
$text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
|
||||||
$text2 = $langs->trans("AbsoluteDiscountUse");
|
|
||||||
print $form->textwithpicto($text, $text2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Discount available of type fixed amount (not credit note)
|
|
||||||
print '<br>';
|
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount, $resteapayer, ' (' . $addabsolutediscount . ')');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($absolute_creditnote > 0) // If not, link will be added later
|
|
||||||
{
|
|
||||||
if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT)
|
|
||||||
print ' (' . $addabsolutediscount . ')<br>';
|
|
||||||
else
|
|
||||||
print '. ';
|
|
||||||
} else
|
|
||||||
print '. ';
|
|
||||||
}
|
|
||||||
// Is there credit notes availables ?
|
|
||||||
if ($absolute_creditnote > 0)
|
|
||||||
{
|
|
||||||
// If validated, we show link "add credit note to payment"
|
|
||||||
if ($object->statut != Facture::STATUS_VALIDATED || $object->type == Facture::TYPE_CREDIT_NOTE) {
|
|
||||||
if ($object->statut == 0 && $object->type != Facture::TYPE_DEPOSIT) {
|
|
||||||
$text = $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency));
|
|
||||||
print $form->textwithpicto($text, $langs->trans("CreditNoteDepositUse"));
|
|
||||||
} else {
|
|
||||||
print $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '.';
|
|
||||||
}
|
|
||||||
} else { // We can add a credit note on a down payment or standard invoice or situation invoice
|
|
||||||
// There is credit notes discounts available
|
|
||||||
if (! $absolute_discount) print '<br>';
|
|
||||||
// $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer);
|
|
||||||
$more=' ('.$addcreditnote. (($addcreditnote && $viewabsolutediscount) ? ' - ' : '') . $viewabsolutediscount . ')';
|
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, 0, $more); // We allow credit note even if amount is higher
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (! $absolute_discount && ! $absolute_creditnote) {
|
|
||||||
print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
|
||||||
if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT)
|
|
||||||
print ' (' . $addabsolutediscount . ')<br>';
|
|
||||||
else
|
|
||||||
print '. ';
|
|
||||||
}
|
|
||||||
// if ($object->statut == 0 && $object->type != 2 && $object->type != 3)
|
|
||||||
// {
|
|
||||||
// if (! $absolute_discount && ! $absolute_creditnote) print '<br>';
|
|
||||||
// print ' - ';
|
|
||||||
// print $addabsolutediscount;
|
|
||||||
// print ' - '.$addcreditnote; // We disbale link to credit note
|
|
||||||
// }
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Date invoice
|
// Date invoice
|
||||||
|
|||||||
@ -261,59 +261,13 @@ if ($object->id > 0)
|
|||||||
|
|
||||||
// Discounts
|
// Discounts
|
||||||
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
|
||||||
if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent);
|
|
||||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
$thirdparty = $object->thirdparty;
|
||||||
print '. ';
|
$discount_type = 0;
|
||||||
if ($absolute_discount > 0)
|
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?facid=' . $object->id);
|
||||||
{
|
$cannotApplyDiscount = 1;
|
||||||
if ($object->statut > Facture::STATUS_DRAFT || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT)
|
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
|
||||||
{
|
|
||||||
if ($object->statut == Facture::STATUS_DRAFT)
|
|
||||||
{
|
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)).'. ';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($object->statut < Facture::STATUS_VALIDATED || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT)
|
|
||||||
{
|
|
||||||
$text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
|
|
||||||
print '<br>'.$text.'.<br>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
|
|
||||||
$text2=$langs->trans("AbsoluteDiscountUse");
|
|
||||||
print $form->textwithpicto($text,$text2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Remise dispo de type non avoir
|
|
||||||
print '<br>';
|
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id',$object->thirdparty->id,$absolute_discount,$filterabsolutediscount,$resteapayer,'',1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($absolute_creditnote > 0)
|
|
||||||
{
|
|
||||||
// If validated, we show link "add credit note to payment"
|
|
||||||
if ($object->statut != Facture::STATUS_VALIDATED || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_CREDIT_NOTE)
|
|
||||||
{
|
|
||||||
if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_DEPOSIT)
|
|
||||||
{
|
|
||||||
$text=$langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency));
|
|
||||||
print $form->textwithpicto($text,$langs->trans("CreditNoteDepositUse"));
|
|
||||||
}
|
|
||||||
else print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)).'.';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Remise dispo de type avoir
|
|
||||||
if (! $absolute_discount) print '<br>';
|
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id_for_payment',$object->thirdparty->id,$absolute_creditnote,$filtercreditnote,$resteapayer,'',1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Date invoice
|
// Date invoice
|
||||||
|
|||||||
@ -4239,26 +4239,27 @@ class Form
|
|||||||
if(! empty($discount_type)) {
|
if(! empty($discount_type)) {
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
|
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
|
||||||
{
|
{
|
||||||
if (! $filter || $filter=="fk_invoice_supplier_source IS NULL") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)); // If we want deposit to be substracted to payments only and not to total of final invoice
|
if (! $filter || $filter=="fk_invoice_supplier_source IS NULL") $translationKey = 'HasAbsoluteDiscountFromSupplier'; // If we want deposit to be substracted to payments only and not to total of final invoice
|
||||||
else print $langs->trans("CompanyHasCreditNote",price($amount,0,$langs,0,0,-1,$conf->currency));
|
else $translationKey = 'HasCreditNoteFromSupplier';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (! $filter || $filter=="fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency));
|
if (! $filter || $filter=="fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") $translationKey = 'HasAbsoluteDiscountFromSupplier';
|
||||||
else print $langs->trans("CompanyHasCreditNote",price($amount,0,$langs,0,0,-1,$conf->currency));
|
else $translationKey = 'HasCreditNoteFromSupplier';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
|
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
|
||||||
{
|
{
|
||||||
if (! $filter || $filter=="fk_facture_source IS NULL") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)); // If we want deposit to be substracted to payments only and not to total of final invoice
|
if (! $filter || $filter=="fk_facture_source IS NULL") $translationKey = 'CompanyHasAbsoluteDiscount'; // If we want deposit to be substracted to payments only and not to total of final invoice
|
||||||
else print $langs->trans("CompanyHasCreditNote",price($amount,0,$langs,0,0,-1,$conf->currency));
|
else $translationKey = 'CompanyHasCreditNote';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (! $filter || $filter=="fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency));
|
if (! $filter || $filter=="fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") $translationKey = 'CompanyHasAbsoluteDiscount';
|
||||||
else print $langs->trans("CompanyHasCreditNote",price($amount,0,$langs,0,0,-1,$conf->currency));
|
else $translationKey = 'CompanyHasCreditNote';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
print $langs->trans($translationKey,price($amount,0,$langs,0,0,-1,$conf->currency));
|
||||||
if (empty($hidelist)) print ': ';
|
if (empty($hidelist)) print ': ';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
if (empty($hidelist))
|
if (empty($hidelist))
|
||||||
|
|||||||
104
htdocs/core/tpl/object_discounts.tpl.php
Normal file
104
htdocs/core/tpl/object_discounts.tpl.php
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2018 ATM Consulting <support@atm-consulting.fr>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Needs the following variables defined:
|
||||||
|
* $object Proposal, order, invoice (including supplier versions)
|
||||||
|
* $thirdparty Thirdparty of object
|
||||||
|
* $absolute_discount Amount of fixed discounts available
|
||||||
|
* $absolute_creditnote Amount of credit notes available
|
||||||
|
* $discount_type 0 => Customer discounts, 1 => Supplier discounts
|
||||||
|
* $cannotApplyDiscount Set it to prevent form to apply discount
|
||||||
|
* $backtopage URL to come back to from discount modification pages
|
||||||
|
*/
|
||||||
|
|
||||||
|
$classname = get_class($object);
|
||||||
|
$isInvoice = in_array($object->element, array('facture', 'invoice', 'facture_fourn', 'invoice_supplier'));
|
||||||
|
$isNewObject = empty($object->id) && empty($object->rowid);
|
||||||
|
|
||||||
|
// Relative and absolute discounts
|
||||||
|
$addrelativediscount = '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $thirdparty->id . '&backtopage=' . $backtopage . '">' . $langs->trans("EditRelativeDiscount") . '</a>';
|
||||||
|
$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $thirdparty->id . '&backtopage=' . $backtopage . '">' . $langs->trans("EditGlobalDiscounts") . '</a>';
|
||||||
|
$viewabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $thirdparty->id . '&backtopage=' . $backtopage . '">' . $langs->trans("ViewAvailableGlobalDiscounts") . '</a>';
|
||||||
|
|
||||||
|
$fixedDiscount = $thirdparty->remise_percent;
|
||||||
|
|
||||||
|
if(! empty($discount_type)) {
|
||||||
|
$fixedDiscount = $thirdparty->remise_supplier_percent;
|
||||||
|
}
|
||||||
|
|
||||||
|
$translationKey = ! empty($discount_type) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount';
|
||||||
|
if ($fixedDiscount > 0)
|
||||||
|
print $langs->trans($translationKey, $fixedDiscount).'.';
|
||||||
|
else
|
||||||
|
print $langs->trans($translationKey).'.';
|
||||||
|
if($isNewObject) print ' ('.$addrelativediscount.')';
|
||||||
|
|
||||||
|
// Is there is commercial discount or down payment available ?
|
||||||
|
if ($absolute_discount > 0) {
|
||||||
|
|
||||||
|
if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut > $classname::STATUS_DRAFT || $object->type == $classname::TYPE_CREDIT_NOTE || $object->type == $classname::TYPE_DEPOSIT) {
|
||||||
|
$translationKey = ! empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount';
|
||||||
|
$text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)).'.';
|
||||||
|
|
||||||
|
if ($isInvoice && ! $isNewObject && $object->statut > $classname::STATUS_DRAFT && $object->type != $classname::TYPE_CREDIT_NOTE && $object->type != $classname::TYPE_DEPOSIT) {
|
||||||
|
$text = $form->textwithpicto($text, $langs->trans('AbsoluteDiscountUse'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isNewObject) {
|
||||||
|
$text.= ' ('.$addabsolutediscount.')';
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<br>'.$text;
|
||||||
|
} else {
|
||||||
|
// Discount available of type fixed amount (not credit note)
|
||||||
|
$more = '(' . $addabsolutediscount . ')';
|
||||||
|
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is there credit notes availables ?
|
||||||
|
if ($absolute_creditnote > 0) {
|
||||||
|
|
||||||
|
// If validated, we show link "add credit note to payment"
|
||||||
|
if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut != $classname::STATUS_VALIDATED || $object->type == $classname::TYPE_CREDIT_NOTE) {
|
||||||
|
$translationKey = ! empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote';
|
||||||
|
$text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '.';
|
||||||
|
|
||||||
|
if ($isInvoice && ! $isNewObject && $object->statut == $classname::STATUS_DRAFT && $object->type != $classname::TYPE_DEPOSIT) {
|
||||||
|
$text = $form->textwithpicto($text, $langs->trans('CreditNoteDepositUse'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($absolute_discount <= 0 || $isNewObject) {
|
||||||
|
$text.= '('.$addabsolutediscount.')';
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<br>'.$text;
|
||||||
|
} else { // We can add a credit note on a down payment or standard invoice or situation invoice
|
||||||
|
// There is credit notes discounts available
|
||||||
|
$more = $isInvoice && ! $isNewObject ? ' (' . $viewabsolutediscount . ')' : '';
|
||||||
|
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, $discount_type); // We allow credit note even if amount is higher
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($absolute_discount <= 0 && $absolute_creditnote <= 0) {
|
||||||
|
$translationKey = ! empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount';
|
||||||
|
print '<br>'.$langs->trans($translationKey).'.';
|
||||||
|
|
||||||
|
if ($isInvoice && $object->statut == $classname::STATUS_DRAFT && $object->type != $classname::TYPE_CREDIT_NOTE && $object->type != $classname::TYPE_DEPOSIT) {
|
||||||
|
print ' (' . $addabsolutediscount . ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -340,31 +340,17 @@ if ($id > 0 || ! empty($ref))
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '<tr><td class="titlefield">'.$langs->trans('Discounts').'</td><td colspan="3">';
|
print '<tr><td class="titlefield">'.$langs->trans('Discounts').'</td><td colspan="3">';
|
||||||
if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_percent);
|
|
||||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
|
||||||
print '. ';
|
|
||||||
$absolute_discount=$soc->getAvailableDiscounts('',$filterabsolutediscount);
|
$absolute_discount=$soc->getAvailableDiscounts('',$filterabsolutediscount);
|
||||||
$absolute_creditnote=$soc->getAvailableDiscounts('',$filtercreditnote);
|
$absolute_creditnote=$soc->getAvailableDiscounts('',$filtercreditnote);
|
||||||
$absolute_discount=price2num($absolute_discount,'MT');
|
$absolute_discount=price2num($absolute_discount,'MT');
|
||||||
$absolute_creditnote=price2num($absolute_creditnote,'MT');
|
$absolute_creditnote=price2num($absolute_creditnote,'MT');
|
||||||
if ($absolute_discount)
|
|
||||||
{
|
$thirdparty = $soc;
|
||||||
if ($object->statut > Commande::STATUS_DRAFT)
|
$discount_type = 0;
|
||||||
{
|
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id);
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
|
$cannotApplyDiscount = 1;
|
||||||
}
|
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
|
||||||
else
|
|
||||||
{
|
|
||||||
// Remise dispo de type non avoir
|
|
||||||
print '<br>';
|
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id',$soc->id,$absolute_discount,$filterabsolutediscount, 0, '', 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($absolute_creditnote)
|
|
||||||
{
|
|
||||||
print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)).'. ';
|
|
||||||
}
|
|
||||||
if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Date
|
// Date
|
||||||
|
|||||||
@ -1483,22 +1483,14 @@ if ($action=='create')
|
|||||||
{
|
{
|
||||||
// Discounts for third party
|
// Discounts for third party
|
||||||
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
||||||
if ($societe->remise_supplier_percent)
|
|
||||||
print $langs->trans("HasRelativeDiscountFromSupplier", '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . $societe->remise_supplier_percent . '</a>');
|
|
||||||
else
|
|
||||||
print $langs->trans("HasNoRelativeDiscountFromSupplier");
|
|
||||||
print ' <a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditRelativeDiscount") . ')</a>';
|
|
||||||
print '. ';
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
$absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1);
|
$absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1);
|
||||||
|
|
||||||
if ($absolute_discount)
|
$thirdparty = $societe;
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . price($absolute_discount) . '</a>', $langs->trans("Currency" . $conf->currency));
|
$discount_type = 1;
|
||||||
else
|
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?socid=' . $thirdparty->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid'));
|
||||||
print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
|
||||||
print ' <a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditGlobalDiscounts") . ')</a>';
|
|
||||||
print '.';
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1893,36 +1885,18 @@ elseif (! empty($object->id))
|
|||||||
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
|
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
|
||||||
}
|
}
|
||||||
|
|
||||||
$addrelativediscount = '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditRelativeDiscounts") . '</a>';
|
|
||||||
$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditGlobalDiscounts") . '</a>';
|
|
||||||
$addcreditnote = '<a href="' . DOL_URL_ROOT . '/fourn/facture/card.php?action=create&socid=' . $societe->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>';
|
|
||||||
|
|
||||||
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
|
|
||||||
|
|
||||||
if ($societe->remise_supplier_percent)
|
|
||||||
print $langs->trans("HasRelativeDiscountFromSupplier", $societe->remise_supplier_percent);
|
|
||||||
else
|
|
||||||
print $langs->trans("HasNoRelativeDiscountFromSupplier");
|
|
||||||
print '. ';
|
|
||||||
|
|
||||||
$absolute_discount = $societe->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
|
$absolute_discount = $societe->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
|
||||||
$absolute_creditnote = $societe->getAvailableDiscounts('', $filtercreditnote, 0, 1);
|
$absolute_creditnote = $societe->getAvailableDiscounts('', $filtercreditnote, 0, 1);
|
||||||
$absolute_discount = price2num($absolute_discount, 'MT');
|
$absolute_discount = price2num($absolute_discount, 'MT');
|
||||||
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
|
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
|
||||||
if ($absolute_discount) {
|
|
||||||
if ($object->statut > CommandeFournisseur::STATUS_DRAFT) {
|
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
|
||||||
} else {
|
$thirdparty = $societe;
|
||||||
// Remise dispo de type remise fixe (not credit note)
|
$discount_type = 1;
|
||||||
print '<br>';
|
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id);
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $societe->id, $absolute_discount, $filterabsolutediscount, 0, '', 1, 1);
|
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($absolute_creditnote) {
|
|
||||||
print $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '. ';
|
|
||||||
}
|
|
||||||
if (! $absolute_discount && ! $absolute_creditnote)
|
|
||||||
print $langs->trans("CompanyHasNoAbsoluteDiscount") . '.';
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1920,20 +1920,11 @@ if ($action == 'create')
|
|||||||
// Discounts for third party
|
// Discounts for third party
|
||||||
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
||||||
|
|
||||||
if ($societe->remise_supplier_percent)
|
$thirdparty = $societe;
|
||||||
print $langs->trans("HasRelativeDiscountFromSupplier", '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . $societe->remise_supplier_percent . '</a>');
|
$discount_type = 1;
|
||||||
else
|
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid'));
|
||||||
print $langs->trans("HasNoRelativeDiscountFromSupplier");
|
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
|
||||||
print ' <a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditRelativeDiscount") . ')</a>';
|
|
||||||
print '. ';
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
if ($absolute_discount)
|
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . price($absolute_discount) . '</a>', $langs->trans("Currency" . $conf->currency));
|
|
||||||
else
|
|
||||||
print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
|
||||||
print ' <a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditGlobalDiscounts") . ')</a>';
|
|
||||||
print '.';
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2421,89 +2412,15 @@ else
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
if ($conf->global->MAIN_FEATURES_LEVEL > 0) {
|
if ($conf->global->MAIN_FEATURES_LEVEL > 0) {
|
||||||
|
|
||||||
// Relative and absolute discounts
|
// Relative and absolute discounts
|
||||||
$addrelativediscount = '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditRelativeDiscounts") . '</a>';
|
|
||||||
$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditGlobalDiscounts") . '</a>';
|
|
||||||
$addcreditnote = '<a href="' . DOL_URL_ROOT . '/fourn/facture/card.php?action=create&socid=' . $societe->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>';
|
|
||||||
$viewabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("ViewAvailableGlobalDiscounts") . '</a>';
|
|
||||||
|
|
||||||
print '<!-- Discounts --><tr><td>' . $langs->trans('Discounts');
|
print '<!-- Discounts --><tr><td>' . $langs->trans('Discounts');
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
|
|
||||||
if ($societe->remise_supplier_percent)
|
$thirdparty = $societe;
|
||||||
print $langs->trans("HasRelativeDiscountFromSupplier", $societe->remise_supplier_percent);
|
$discount_type = 1;
|
||||||
else
|
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?facid=' . $object->id);
|
||||||
print $langs->trans("HasNoRelativeDiscountFromSupplier");
|
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
|
||||||
// print ' ('.$addrelativediscount.')';
|
|
||||||
|
|
||||||
|
|
||||||
// Is there is commercial discount or down payment available ?
|
|
||||||
if ($absolute_discount > 0) {
|
|
||||||
print '. ';
|
|
||||||
if ($object->statut > 0 || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) {
|
|
||||||
if ($object->statut == 0) {
|
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
|
||||||
print '. ';
|
|
||||||
} else {
|
|
||||||
if ($object->statut < 1 || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) {
|
|
||||||
$text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
|
||||||
print '<br>' . $text . '.<br>';
|
|
||||||
} else {
|
|
||||||
$text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
|
||||||
$text2 = $langs->trans("AbsoluteDiscountUse");
|
|
||||||
print $form->textwithpicto($text, $text2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Discount available of type fixed amount (not credit note)
|
|
||||||
print '<br>';
|
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $societe->id, $absolute_discount, $filterabsolutediscount, $resteapayer, ' (' . $addabsolutediscount . ')', 0, 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($absolute_creditnote > 0) // If not, link will be added later
|
|
||||||
{
|
|
||||||
if ($object->statut == FactureFournisseur::STATUS_DRAFT && $object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->type != FactureFournisseur::TYPE_DEPOSIT)
|
|
||||||
print ' (' . $addabsolutediscount . ')<br>';
|
|
||||||
else
|
|
||||||
print '. ';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
print '. ';
|
|
||||||
}
|
|
||||||
// Is there credit notes availables ?
|
|
||||||
if ($absolute_creditnote > 0)
|
|
||||||
{
|
|
||||||
// If validated, we show link "add credit note to payment"
|
|
||||||
if ($object->statut != FactureFournisseur::STATUS_VALIDATED || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
|
|
||||||
if ($object->statut == 0 && $object->type != FactureFournisseur::TYPE_DEPOSIT) {
|
|
||||||
$text = $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency));
|
|
||||||
print $form->textwithpicto($text, $langs->trans("CreditNoteDepositUse"));
|
|
||||||
} else {
|
|
||||||
print $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '.';
|
|
||||||
}
|
|
||||||
} else { // We can add a credit note on a down payment or standard invoice or situation invoice
|
|
||||||
// There is credit notes discounts available
|
|
||||||
if (! $absolute_discount) print '<br>';
|
|
||||||
// $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $societe->id, $absolute_creditnote, $filtercreditnote, $resteapayer, '', 0, 1);
|
|
||||||
$more=' ('.$addcreditnote. (($addcreditnote && $viewabsolutediscount) ? ' - ' : '') . $viewabsolutediscount . ')';
|
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $societe->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, 1); // We allow credit note even if amount is higher
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (! $absolute_discount && ! $absolute_creditnote) {
|
|
||||||
print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
|
||||||
if ($object->statut == FactureFournisseur::STATUS_DRAFT && $object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->type != FactureFournisseur::TYPE_DEPOSIT)
|
|
||||||
print ' (' . $addabsolutediscount . ')<br>';
|
|
||||||
else
|
|
||||||
print '. ';
|
|
||||||
}
|
|
||||||
// if ($object->statut == 0 && $object->type != 2 && $object->type != 3)
|
|
||||||
// {
|
|
||||||
// if (! $absolute_discount && ! $absolute_creditnote) print '<br>';
|
|
||||||
// print ' - ';
|
|
||||||
// print $addabsolutediscount;
|
|
||||||
// print ' - '.$addcreditnote; // We disbale link to credit note
|
|
||||||
// }
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -273,6 +273,10 @@ HasNoRelativeDiscountFromSupplier=You have no default relative discount from thi
|
|||||||
CompanyHasAbsoluteDiscount=This customer has discount available (credits notes or down payments) for <b>%s</b> %s
|
CompanyHasAbsoluteDiscount=This customer has discount available (credits notes or down payments) for <b>%s</b> %s
|
||||||
CompanyHasDownPaymentOrCommercialDiscount=This customer has discount available (commercial, down payments) for <b>%s</b> %s
|
CompanyHasDownPaymentOrCommercialDiscount=This customer has discount available (commercial, down payments) for <b>%s</b> %s
|
||||||
CompanyHasCreditNote=This customer still has credit notes for <b>%s</b> %s
|
CompanyHasCreditNote=This customer still has credit notes for <b>%s</b> %s
|
||||||
|
HasNoAbsoluteDiscountFromSupplier=You have no discount credit available from this supplier
|
||||||
|
HasAbsoluteDiscountFromSupplier=You have discounts available (credits notes or down payments) for <b>%s</b> %s from this supplier
|
||||||
|
HasDownPaymentOrCommercialDiscountFromSupplier=You have discounts available (commercial, down payments) for <b>%s</b> %s from this supplier
|
||||||
|
HasCreditNoteFromSupplier=You have credit notes for <b>%s</b> %s from this supplier
|
||||||
CompanyHasNoAbsoluteDiscount=This customer has no discount credit available
|
CompanyHasNoAbsoluteDiscount=This customer has no discount credit available
|
||||||
CustomerAbsoluteDiscountAllUsers=Absolute customer discounts (granted by all users)
|
CustomerAbsoluteDiscountAllUsers=Absolute customer discounts (granted by all users)
|
||||||
CustomerAbsoluteDiscountMy=Absolute customer discounts (granted by yourself)
|
CustomerAbsoluteDiscountMy=Absolute customer discounts (granted by yourself)
|
||||||
|
|||||||
@ -1055,22 +1055,13 @@ if ($action == 'create')
|
|||||||
// Discounts for third party
|
// Discounts for third party
|
||||||
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
||||||
|
|
||||||
if ($soc->remise_supplier_percent)
|
|
||||||
print $langs->trans("HasRelativeDiscountFromSupplier", '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . $soc->remise_supplier_percent . '</a>');
|
|
||||||
else
|
|
||||||
print $langs->trans("HasNoRelativeDiscountFromSupplier");
|
|
||||||
print ' <a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditRelativeDiscount") . ')</a>';
|
|
||||||
print '. ';
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
$absolute_discount = $soc->getAvailableDiscounts('', '', 0, 1);
|
$absolute_discount = $soc->getAvailableDiscounts('', '', 0, 1);
|
||||||
|
|
||||||
if ($absolute_discount)
|
$thirdparty = $soc;
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . price($absolute_discount) . '</a>', $langs->trans("Currency" . $conf->currency));
|
$discount_type = 1;
|
||||||
else
|
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?socid=' . $thirdparty->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid'));
|
||||||
print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
|
||||||
print ' <a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditGlobalDiscounts") . ')</a>';
|
|
||||||
print '.';
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1424,36 +1415,18 @@ if ($action == 'create')
|
|||||||
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
|
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
|
||||||
}
|
}
|
||||||
|
|
||||||
$addrelativediscount = '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditRelativeDiscounts") . '</a>';
|
|
||||||
$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditGlobalDiscounts") . '</a>';
|
|
||||||
$addcreditnote = '<a href="' . DOL_URL_ROOT . '/fourn/facture/card.php?action=create&socid=' . $soc->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>';
|
|
||||||
|
|
||||||
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
|
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
|
||||||
|
|
||||||
if ($soc->remise_supplier_percent)
|
|
||||||
print $langs->trans("HasRelativeDiscountFromSupplier", $soc->remise_supplier_percent);
|
|
||||||
else
|
|
||||||
print $langs->trans("HasNoRelativeDiscountFromSupplier");
|
|
||||||
print '. ';
|
|
||||||
|
|
||||||
$absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
|
$absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
|
||||||
$absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote, 0, 1);
|
$absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote, 0, 1);
|
||||||
$absolute_discount = price2num($absolute_discount, 'MT');
|
$absolute_discount = price2num($absolute_discount, 'MT');
|
||||||
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
|
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
|
||||||
if ($absolute_discount) {
|
|
||||||
if ($object->statut > SupplierProposal::STATUS_DRAFT) {
|
$thirdparty = $soc;
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
$discount_type = 1;
|
||||||
} else {
|
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id);
|
||||||
// Remise dispo de type remise fixe (not credit note)
|
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
|
||||||
print '<br>';
|
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount, 0, '', 1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($absolute_creditnote) {
|
|
||||||
print $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '. ';
|
|
||||||
}
|
|
||||||
if (! $absolute_discount && ! $absolute_creditnote)
|
|
||||||
print $langs->trans("CompanyHasNoAbsoluteDiscount") . '.';
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user