45print
'<!-- BEGIN object_discounts.tpl.php -->'.
"\n";
48@phan-var-force Propal|Commande|CommandeFournisseur|Facture|FactureFournisseur $object
49@phan-var-force Societe $thirdparty
50@phan-var-force string $backtopage
51@phan-var-force string $filtercreditnote
52@phan-var-force string $filterabsolutediscount
53@phan-var-force int<0,1> $discount_type
54@phan-var-force int $resteapayer
57$objclassname = get_class(
$object);
58$isInvoice = in_array(
$object->element, array(
'facture',
'invoice',
'facture_fourn',
'invoice_supplier'));
62if (empty($absolute_discount)) {
63 $absolute_discount = 0;
65if (empty($absolute_creditnote)) {
66 $absolute_creditnote = 0;
68if (empty($nb_creditnote_notyetavailable)) {
69 $nb_creditnote_notyetavailable = 0;
74$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>';
75$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>';
76$viewabsolutediscount =
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.((int) $thirdparty->id).
'&backtopage='.urlencode($backtopage).
'">'.$langs->trans(
"ViewAvailableGlobalDiscounts").
'</a>';
78$fixedDiscount = $thirdparty->remise_percent;
79if (!empty($discount_type)) {
80 $fixedDiscount = $thirdparty->remise_supplier_percent;
83if ($fixedDiscount > 0) {
84 $translationKey = (empty($discount_type)) ?
'CompanyHasRelativeDiscount' :
'HasRelativeDiscountFromSupplier';
85 print $langs->trans($translationKey, $fixedDiscount);
87 if ($conf->dol_optimize_smallscreen) {
88 $translationKey =
'RelativeDiscount';
90 $translationKey = (empty($discount_type)) ?
'CompanyHasNoRelativeDiscount' :
'HasNoRelativeDiscountFromSupplier';
92 print
'<span class="opacitymedium">'.$langs->trans($translationKey).
'</span>';
95print
' '.$addrelativediscount;
99if ($absolute_discount > 0) {
100 print
'<!-- absolute_discount -->';
101 if (!empty($cannotApplyDiscount) || !$isInvoice || $isNewObject ||
$object->statut > $objclassname::STATUS_DRAFT ||
$object->type == $objclassname::TYPE_CREDIT_NOTE ||
$object->type == $objclassname::TYPE_DEPOSIT) {
102 $translationKey = empty($discount_type) ?
'CompanyHasDownPaymentOrCommercialDiscount' :
'HasDownPaymentOrCommercialDiscountFromSupplier';
103 $text = $langs->trans($translationKey,
price($absolute_discount, 0, $langs, 1, -1, -1, $conf->currency));
105 if ($isInvoice && !$isNewObject &&
$object->statut > $objclassname::STATUS_DRAFT &&
$object->type != $objclassname::TYPE_CREDIT_NOTE &&
$object->type != $objclassname::TYPE_DEPOSIT) {
106 $text = $form->textwithpicto($text, $langs->trans(
'AbsoluteDiscountUse'));
109 $text .=
' '.$addabsolutediscount;
115 print
'<div class="inline-block clearboth">'.$text.
'</div>';
119 $more = $addabsolutediscount;
121 $form->form_remise_dispo($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id,
GETPOSTINT(
'discountid'),
'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type);
127if ($absolute_creditnote > 0) {
128 print
'<!-- absolute_creditnote -->';
130 if (!empty($cannotApplyDiscount) || !$isInvoice || $isNewObject ||
$object->statut != $objclassname::STATUS_VALIDATED ||
$object->type == $objclassname::TYPE_CREDIT_NOTE) {
131 $translationKey = empty($discount_type) ?
'CompanyHasCreditNote' :
'HasCreditNoteFromSupplier';
132 $text = $langs->trans($translationKey,
price($absolute_creditnote, 0, $langs, 1, -1, -1, $conf->currency));
134 if ($isInvoice && !$isNewObject &&
$object->statut == $objclassname::STATUS_DRAFT &&
$object->type != $objclassname::TYPE_DEPOSIT) {
135 $text = $form->textwithpicto($text, $langs->trans(
'CreditNoteDepositUse'));
138 if ($absolute_discount <= 0 || $isNewObject) {
139 $text .=
' '.$addabsolutediscount;
145 print
'<div class="inline-block clearboth">'.$text.
'</div>';
149 $more = $isInvoice && !$isNewObject ?
' ('.$viewabsolutediscount.
')' :
'';
150 $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);
154if ($absolute_discount <= 0 && $absolute_creditnote <= 0) {
155 if ($conf->dol_optimize_smallscreen) {
156 $translationKey =
'AbsoluteDiscount';
158 $translationKey = !empty($discount_type) ?
'HasNoAbsoluteDiscountFromSupplier' :
'CompanyHasNoAbsoluteDiscount';
160 print
'<br><span class="opacitymedium">'.$langs->trans($translationKey).
'</span>';
162 if ($isInvoice &&
$object->statut == $objclassname::STATUS_DRAFT &&
$object->type != $objclassname::TYPE_CREDIT_NOTE &&
$object->type != $objclassname::TYPE_DEPOSIT) {
163 print
' '.$addabsolutediscount;
167if ($nb_creditnote_notyetavailable > 0) {
168 print
'<!-- absolute_creditnote not yet converted -->';
169 $translationKey =
'SomeNotConvertedCreditNoteExists';
170 print
'<br><span class="opacitymedium">'.$langs->trans($translationKey, $nb_creditnote_notyetavailable).
'</span>';
173print
'<!-- END template -->';
if(! $sortfield) if(! $sortorder) $object
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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'.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.