46print
'<!-- BEGIN object_discounts.tpl.php -->'.
"\n";
49@phan-var-force Propal|Commande|CommandeFournisseur|Facture|FactureFournisseur $object
50@phan-var-force Societe $thirdparty
51@phan-var-force string $backtopage
52@phan-var-force string $filtercreditnote
53@phan-var-force string $filterabsolutediscount
54@phan-var-force int<0,1> $discount_type
55@phan-var-force int $resteapayer
58$objclassname = get_class(
$object);
59$isInvoice = in_array(
$object->element, array(
'facture',
'invoice',
'facture_fourn',
'invoice_supplier'));
63if (empty($absolute_discount)) {
64 $absolute_discount = 0;
66if (empty($absolute_creditnote)) {
67 $absolute_creditnote = 0;
69if (empty($nb_creditnote_notyetavailable)) {
70 $nb_creditnote_notyetavailable = 0;
75$addrelativediscount =
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.((int) $thirdparty->id).
'&backtopage='.urlencode($backtopage).
'&action=create&token='.
newToken().(!empty($discount_type) ?
'&discount_type=1' :
'').
'">'.img_edit($langs->trans(
"EditRelativeDiscount")).
'</a>';
76$addabsolutediscount =
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.((int) $thirdparty->id).
'&backtopage='.urlencode($backtopage).
'&action=create&token='.
newToken().
'">'.img_edit($langs->trans(
"EditGlobalDiscounts")).
'</a>';
77$viewabsolutediscount =
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.((int) $thirdparty->id).
'&backtopage='.urlencode($backtopage).
'">'.$langs->trans(
"ViewAvailableGlobalDiscounts").
'</a>';
79$fixedDiscount = $thirdparty->remise_percent;
80if (!empty($discount_type)) {
81 $fixedDiscount = $thirdparty->remise_supplier_percent;
84if ($fixedDiscount > 0) {
85 $translationKey = (empty($discount_type)) ?
'CompanyHasRelativeDiscount' :
'HasRelativeDiscountFromSupplier';
86 print $langs->trans($translationKey, $fixedDiscount);
88 if (
$conf->dol_optimize_smallscreen) {
89 $translationKey =
'RelativeDiscount';
91 $translationKey = (empty($discount_type)) ?
'CompanyHasNoRelativeDiscount' :
'HasNoRelativeDiscountFromSupplier';
93 print
'<span class="opacitymedium">'.$langs->trans($translationKey).
'</span>';
96print
' '.$addrelativediscount;
100if ($absolute_discount > 0) {
101 print
'<!-- absolute_discount -->';
102 if (!empty($cannotApplyDiscount) || !$isInvoice || $isNewObject ||
$object->statut > $objclassname::STATUS_DRAFT ||
$object->type == $objclassname::TYPE_CREDIT_NOTE ||
$object->type == $objclassname::TYPE_DEPOSIT) {
103 $translationKey = empty($discount_type) ?
'CompanyHasDownPaymentOrCommercialDiscount' :
'HasDownPaymentOrCommercialDiscountFromSupplier';
104 $text = $langs->trans($translationKey,
price($absolute_discount, 0, $langs, 1, -1, -1,
$conf->currency));
106 if ($isInvoice && !$isNewObject &&
$object->statut > $objclassname::STATUS_DRAFT &&
$object->type != $objclassname::TYPE_CREDIT_NOTE &&
$object->type != $objclassname::TYPE_DEPOSIT) {
107 $text = $form->textwithpicto($text, $langs->trans(
'AbsoluteDiscountUse'));
110 $text .=
' '.$addabsolutediscount;
116 print
'<div class="inline-block clearboth">'.$text.
'</div>';
120 $more = $addabsolutediscount;
121 $filter = $filterabsolutediscount;
124 $form->form_remise_dispo($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id,
GETPOSTINT(
'discountid'),
'remise_id', $thirdparty->id, $absolute_discount, $filter, 0, $more, 0, $discount_type, 1);
130if ($absolute_creditnote > 0) {
131 print
'<!-- absolute_creditnote -->';
133 if (!empty($cannotApplyDiscount) || !$isInvoice || $isNewObject ||
$object->statut != $objclassname::STATUS_VALIDATED ||
$object->type == $objclassname::TYPE_CREDIT_NOTE) {
134 $translationKey = empty($discount_type) ?
'CompanyHasCreditNote' :
'HasCreditNoteFromSupplier';
135 $text = $langs->trans($translationKey,
price($absolute_creditnote, 0, $langs, 1, -1, -1,
$conf->currency));
137 if ($isInvoice && !$isNewObject &&
$object->statut == $objclassname::STATUS_DRAFT &&
$object->type != $objclassname::TYPE_DEPOSIT) {
138 $text = $form->textwithpicto($text, $langs->trans(
'CreditNoteDepositUse'));
141 if ($absolute_discount <= 0 || $isNewObject) {
142 $text .=
' '.$addabsolutediscount;
148 print
'<div class="inline-block clearboth">'.$text.
'</div>';
152 $more = $isInvoice && !$isNewObject ?
' ('.$viewabsolutediscount.
')' :
'';
153 $filter = $filtercreditnote;
154 $form->form_remise_dispo($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id, 0,
'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filter, 0, $more, 0, $discount_type, 0, 1);
158if ($absolute_discount <= 0 && $absolute_creditnote <= 0) {
159 if (
$conf->dol_optimize_smallscreen) {
160 $translationKey =
'AbsoluteDiscount';
162 $translationKey = !empty($discount_type) ?
'HasNoAbsoluteDiscountFromSupplier' :
'CompanyHasNoAbsoluteDiscount';
164 print
'<br><span class="opacitymedium">'.$langs->trans($translationKey).
'</span>';
166 if ($isInvoice &&
$object->statut == $objclassname::STATUS_DRAFT &&
$object->type != $objclassname::TYPE_CREDIT_NOTE &&
$object->type != $objclassname::TYPE_DEPOSIT) {
167 print
' '.$addabsolutediscount;
171if ($nb_creditnote_notyetavailable > 0) {
172 print
'<!-- absolute_creditnote not yet converted -->';
173 $translationKey =
'SomeNotConvertedCreditNoteExists';
174 print
'<br><span class="opacitymedium">'.$langs->trans($translationKey, $nb_creditnote_notyetavailable).
'</span>';
177print
'<!-- END template -->';
if(! $sortfield) if(! $sortorder) $object
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.