28print 
'<!-- BEGIN object_discounts.tpl.php -->'.
"\n";
 
   30$objclassname = get_class($object);
 
   31$isInvoice = in_array($object->element, array(
'facture', 
'invoice', 
'facture_fourn', 
'invoice_supplier'));
 
   32$isNewObject = empty($object->id) && empty($object->rowid);
 
   35if (!isset($absolute_discount)) {
 
   36  $absolute_discount = 0;
 
   38if (!isset($absolute_creditnote)) {
 
   39  $absolute_creditnote = 0;
 
   43$addrelativediscount = 
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.((int) $thirdparty->id).
'&backtopage='.urlencode($backtopage).
'&action=create&token='.newToken().
'">'.$langs->trans(
"EditRelativeDiscount").
'</a>';
 
   44$addabsolutediscount = 
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.((int) $thirdparty->id).
'&backtopage='.urlencode($backtopage).
'&action=create&token='.newToken().
'">'.$langs->trans(
"EditGlobalDiscounts").
'</a>';
 
   45$viewabsolutediscount = 
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.((int) $thirdparty->id).
'&backtopage='.urlencode($backtopage).
'">'.$langs->trans(
"ViewAvailableGlobalDiscounts").
'</a>';
 
   47$fixedDiscount = $thirdparty->remise_percent;
 
   48if (!empty($discount_type)) {
 
   49  $fixedDiscount = $thirdparty->remise_supplier_percent;
 
   52if ($fixedDiscount > 0) {
 
   53  $translationKey = (!empty($discount_type)) ? 
'HasRelativeDiscountFromSupplier' : 
'CompanyHasRelativeDiscount';
 
   54  print $langs->trans($translationKey, $fixedDiscount).
'.';
 
   56  $translationKey = (!empty($discount_type)) ? 
'HasNoRelativeDiscountFromSupplier' : 
'CompanyHasNoRelativeDiscount';
 
   57  print 
'<span class="opacitymedium hideonsmartphone">'.$langs->trans($translationKey).
'.</span>';
 
   60  print 
' ('.$addrelativediscount.
')';
 
   64if ($absolute_discount > 0) {
 
   65  if (!empty($cannotApplyDiscount) || !$isInvoice || $isNewObject || $object->statut > $objclassname::STATUS_DRAFT || $object->type == $objclassname::TYPE_CREDIT_NOTE || $object->type == $objclassname::TYPE_DEPOSIT) {
 
   66    $translationKey = !empty($discount_type) ? 
'HasAbsoluteDiscountFromSupplier' : 
'CompanyHasAbsoluteDiscount';
 
   67    $text = $langs->trans($translationKey, 
price($absolute_discount), $langs->transnoentities(
"Currency".$conf->currency)).
'.';
 
   69    if ($isInvoice && !$isNewObject && $object->statut > $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) {
 
   70      $text = $form->textwithpicto($text, $langs->trans(
'AbsoluteDiscountUse'));
 
   74      $text .= 
' ('.$addabsolutediscount.
')';
 
   80      print 
'<div class="inline-block clearboth">'.$text.
'</div>';
 
   84    $more = 
'('.$addabsolutediscount.
')';
 
   85    $form->form_remise_dispo($_SERVER[
"PHP_SELF"].
'?facid='.$object->id, 
GETPOST(
'discountid'), 
'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type);
 
   90if ($absolute_creditnote > 0) {
 
   92  if (!empty($cannotApplyDiscount) || !$isInvoice || $isNewObject || $object->statut != $objclassname::STATUS_VALIDATED || $object->type == $objclassname::TYPE_CREDIT_NOTE) {
 
   93    $translationKey = !empty($discount_type) ? 
'HasCreditNoteFromSupplier' : 
'CompanyHasCreditNote';
 
   94    $text = $langs->trans($translationKey, 
price($absolute_creditnote), $langs->transnoentities(
"Currency".$conf->currency)).
'.';
 
   96    if ($isInvoice && !$isNewObject && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_DEPOSIT) {
 
   97      $text = $form->textwithpicto($text, $langs->trans(
'CreditNoteDepositUse'));
 
  100    if ($absolute_discount <= 0 || $isNewObject) {
 
  101      $text .= 
' ('.$addabsolutediscount.
')';
 
  107      print 
'<div class="inline-block clearboth">'.$text.
'</div>';
 
  111    $more = $isInvoice && !$isNewObject ? 
' ('.$viewabsolutediscount.
')' : 
'';
 
  112    $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); 
 
  116if ($absolute_discount <= 0 && $absolute_creditnote <= 0) {
 
  117  $translationKey = !empty($discount_type) ? 
'HasNoAbsoluteDiscountFromSupplier' : 
'CompanyHasNoAbsoluteDiscount';
 
  118  print 
'<br class="hideonsmartphone"><span class="opacitymedium hideonsmartphone">'.$langs->trans($translationKey).
'.</span>';
 
  120  if ($isInvoice && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) {
 
  121    print 
' ('.$addabsolutediscount.
')';
 
  125print 
'<!-- END template -->';
 
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.