dolibarr 21.0.0-beta
doc.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
4 * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
5 * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
8 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 * or see https://www.gnu.org/
23 */
24
42function doc_getlinedesc($line, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
43{
44 global $db, $conf, $langs;
45
46 $idprod = $line->fk_product;
47 $label = (!empty($line->label) ? $line->label : (!empty($line->libelle) ? $line->libelle : ''));
48 $desc = (!empty($line->desc) ? $line->desc : (!empty($line->description) ? $line->description : ''));
49 $ref_supplier = (!empty($line->ref_supplier) ? $line->ref_supplier : (!empty($line->ref_fourn) ? $line->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders
50 $note = (!empty($line->note) ? $line->note : '');
51
52 if ($issupplierline) {
53 $prodser = new ProductFournisseur($db);
54 } else {
55 $prodser = new Product($db);
56 }
57
58 if ($idprod) {
59 $prodser->fetch($idprod);
60 // If a predefined product and multilang and on other lang, we renamed label with label translated
61 if (getDolGlobalInt('MAIN_MULTILANGS') && ($outputlangs->defaultlang != $langs->defaultlang)) {
62 if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) {
63 $label = $prodser->multilangs[$outputlangs->defaultlang]["label"];
64 }
65 if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && $desc == $prodser->description) {
66 $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"];
67 }
68 if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) {
69 $note = $prodser->multilangs[$outputlangs->defaultlang]["note"];
70 }
71 }
72 }
73
74 // Description short of product line
75 $libelleproduitservice = $label;
76
77 // Description long of product line
78 if ($desc && ($desc != $label)) {
79 if ($desc == '(CREDIT_NOTE)' && $line->fk_remise_except) {
80 $discount = new DiscountAbsolute($db);
81 $discount->fetch($line->fk_remise_except);
82 $sourceref = !empty($discount->discount_type) ? $discount->ref_invoice_supplier_source : $discount->ref_facture_source;
83 $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref);
84 } elseif ($desc == '(DEPOSIT)' && $line->fk_remise_except) {
85 $discount = new DiscountAbsolute($db);
86 $discount->fetch($line->fk_remise_except);
87 $sourceref = !empty($discount->discount_type) ? $discount->ref_invoice_supplier_source : $discount->ref_facture_source;
88 $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref);
89 // Add date of deposit
90 if (getDolGlobalString('INVOICE_ADD_DEPOSIT_DATE')) {
91 $libelleproduitservice .= ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')';
92 }
93 } elseif ($desc == '(EXCESS RECEIVED)' && $line->fk_remise_except) {
94 $discount = new DiscountAbsolute($db);
95 $discount->fetch($line->fk_remise_except);
96 $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source);
97 } elseif ($desc == '(EXCESS PAID)' && $line->fk_remise_except) {
98 $discount = new DiscountAbsolute($db);
99 $discount->fetch($line->fk_remise_except);
100 $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source);
101 } else {
102 if ($idprod) {
103 if (empty($hidedesc)) {
104 $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc);
105 }
106 } else {
107 $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc);
108 }
109 }
110 }
111
112 // If line linked to a product
113 if ($idprod) {
114 // On ajoute la ref
115 if ($prodser->ref) {
116 $prefix_prodserv = "";
117 $ref_prodserv = "";
118 if (getDolGlobalString('PRODUCT_ADD_TYPE_IN_DOCUMENTS')) { // In standard mode, we do not show this
119 if ($prodser->isService()) {
120 $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." ";
121 } else {
122 $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." ";
123 }
124 }
125
126 if (empty($hideref)) {
127 if ($issupplierline) {
128 $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref
129 } else {
130 $ref_prodserv = $prodser->ref; // Show local ref only
131 }
132 }
133
134 $libelleproduitservice = $prefix_prodserv.$ref_prodserv.($libelleproduitservice ? " - " : "").$libelleproduitservice;
135 }
136 }
137
138 if (!empty($line->date_start) || !empty($line->date_end)) {
139 $format = 'day';
140 $period = '';
141 // Show duration if exists
142 if ($line->date_start && $line->date_end) {
143 $period = '('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($line->date_start, $format, false, $outputlangs), dol_print_date($line->date_end, $format, false, $outputlangs)).')';
144 }
145 if ($line->date_start && !$line->date_end) {
146 $period = '('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($line->date_start, $format, false, $outputlangs)).')';
147 }
148 if (!$line->date_start && $line->date_end) {
149 $period = '('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($line->date_end, $format, false, $outputlangs)).')';
150 }
151 //print '>'.$outputlangs->charset_output.','.$period;
152 $libelleproduitservice = dol_concatdesc($libelleproduitservice, $period);
153 //print $libelleproduitservice;
154 }
155
156 return $libelleproduitservice;
157}
Class to manage absolute discounts.
Class to manage predefined suppliers products.
Class to manage products or services.
doc_getlinedesc($line, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
Return line description translated in outputlangs and encoded into UTF8.
Definition doc.lib.php:42
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79