dolibarr 21.0.0-beta
objectline_view.tpl.php
1<?php
2/* Copyright (C) 2010-2013 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
5 * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
6 * Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
7 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
8 * Copyright (C) 2017 Juanjo Menent <jmenent@2byte.es>
9 * Copyright (C) 2022 OpenDSI <support@open-dsi.fr>
10 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
11 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
12 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <https://www.gnu.org/licenses/>.
26 *
27 * Need to have the following variables defined:
28 * $object (invoice, order, ...)
29 * $conf
30 * $langs
31 * $dateSelector
32 * $forceall (0 by default, 1 for supplier invoices/orders)
33 * $element (used to test $user->rights->$element->creer)
34 * $permtoedit (used to replace test $user->rights->$element->creer)
35 * $senderissupplier (0 by default, 1 for supplier invoices/orders)
36 * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
37 * $outputalsopricetotalwithtax
38 * $usemargins (0 to disable all margins columns, 1 to show according to margin setup)
39 * $disableedit, $disablemove, $disableremove
40 *
41 * $text, $description, $line
42 */
63// Protection to avoid direct call of template
64if (empty($object) || !is_object($object)) {
65 print "Error, template page can't be called as URL";
66 exit(1);
67}
68
69'
70@phan-var-force PropaleLigne|ContratLigne|CommonObjectLine|CommonInvoiceLine|CommonOrderLine|ExpeditionLigne|DeliveryLine|FactureFournisseurLigneRec|SupplierInvoiceLine|SupplierProposalLine $line
71@phan-var-force CommonObject $this
72@phan-var-force Propal|Contrat|Commande|Facture|Expedition|Delivery|FactureFournisseur|FactureFournisseur|SupplierProposal $object
73@phan-var-force 0|1 $forceall
74@phan-var-force int $num
75@phan-var-force ?Product $product_static
76@phan-var-force string $text
77@phan-var-force string $description
78';
79
80global $mysoc;
81global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax;
82
83$usemargins = 0;
84if (isModEnabled('margin') && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande'))) {
85 $usemargins = 1;
86}
87
88if (empty($dateSelector)) {
89 $dateSelector = 0;
90}
91if (empty($forceall)) {
92 $forceall = 0;
93}
94if (empty($senderissupplier)) {
95 $senderissupplier = 0;
96}
97if (empty($inputalsopricewithtax)) {
98 $inputalsopricewithtax = 0;
99}
100if (empty($outputalsopricetotalwithtax)) {
101 $outputalsopricetotalwithtax = 0;
102}
103
104// add html5 elements
105$domData = ' data-element="'.$line->element.'"';
106$domData .= ' data-id="'.$line->id.'"';
107$domData .= ' data-qty="'.$line->qty.'"';
108$domData .= ' data-product_type="'.$line->product_type.'"';
109
110$sign = 1;
111if (getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE_SCREEN') && in_array($object->element, array('facture', 'invoice_supplier'))) {
113 // @phan-suppress-next-line PhanUndeclaredConstantOfClass
114 if ($object->type == $object::TYPE_CREDIT_NOTE) {
115 $sign = -1;
116 }
117}
118
119
120$coldisplay = 0;
121?>
122<!-- BEGIN PHP TEMPLATE objectline_view.tpl.php -->
123<tr id="row-<?php print $line->id?>" class="drag drop oddeven" <?php print $domData; ?> >
124<?php if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) { ?>
125 <td class="linecolnum center"><span class="opacitymedium"><?php $coldisplay++; ?><?php print($i + 1); ?></span></td>
126<?php } ?>
127 <td class="linecoldescription minwidth300imp"><?php $coldisplay++; ?><div id="line_<?php print $line->id; ?>"></div>
128<?php
129if (($line->info_bits & 2) == 2) {
130 print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$this->socid.'">';
131 $txt = '';
132 print img_object($langs->trans("ShowReduc"), 'reduc').' ';
133 if ($line->description == '(DEPOSIT)') {
134 $txt = $langs->trans("Deposit");
135 } elseif ($line->description == '(EXCESS RECEIVED)') {
136 $txt = $langs->trans("ExcessReceived");
137 } elseif ($line->description == '(EXCESS PAID)') {
138 $txt = $langs->trans("ExcessPaid");
139 }
140 //else $txt=$langs->trans("Discount");
141 print $txt;
142 print '</a>';
143 if ($line->description) {
144 if ($line->description == '(CREDIT_NOTE)' && $line->fk_remise_except > 0) {
145 include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
146 $discount = new DiscountAbsolute($this->db);
147 $discount->fetch($line->fk_remise_except);
148 print($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
149 } elseif ($line->description == '(DEPOSIT)' && $line->fk_remise_except > 0) {
150 include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
151 $discount = new DiscountAbsolute($this->db);
152 $discount->fetch($line->fk_remise_except);
153 print($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
154 // Add date of deposit
155 if (getDolGlobalString('INVOICE_ADD_DEPOSIT_DATE')) {
156 print ' ('.dol_print_date($discount->datec).')';
157 }
158 } elseif ($line->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) {
159 include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
160 $discount = new DiscountAbsolute($this->db);
161 $discount->fetch($line->fk_remise_except);
162 print($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0));
163 } elseif ($line->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) {
164 include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
165 $discount = new DiscountAbsolute($this->db);
166 $discount->fetch($line->fk_remise_except);
167 print($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0));
168 } else {
169 print($txt ? ' - ' : '').dol_htmlentitiesbr($line->description);
170 }
171 }
172} else {
173 $format = (getDolGlobalString('MAIN_USE_HOURMIN_IN_DATE_RANGE') ? 'dayhour' : 'day');
174
175 if ($line->fk_product > 0) {
176 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
177 print (!empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : '') . $text;
178 if (!getDolGlobalInt('PRODUIT_DESC_IN_FORM')) {
179 print $form->textwithpicto('', $description);
180 }
181 } else {
182 print $form->textwithtooltip($text, $description, 3, 0, '', $i, 0, (!empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : ''));
183 }
184 } else {
185 $type = (!empty($line->product_type) ? $line->product_type : $line->fk_product_type);
186 if ($type == 1) {
187 $text = img_object($langs->trans('Service'), 'service');
188 } else {
189 $text = img_object($langs->trans('Product'), 'product');
190 }
191
192 if (!empty($line->label)) {
193 $text .= ' <strong>'.$line->label.'</strong>';
194 print $form->textwithtooltip($text, dol_htmlentitiesbr($line->description), 3, 0, '', $i, 0, (!empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : ''));
195 } else {
196 if (!empty($line->fk_parent_line)) {
197 print img_picto('', 'rightarrow');
198 }
199 if (preg_match('/^\‍(DEPOSIT\‍)/', $line->description)) {
200 $newdesc = preg_replace('/^\‍(DEPOSIT\‍)/', $langs->trans("Deposit"), $line->description);
201 print $text.' '.dol_htmlentitiesbr($newdesc);
202 } else {
203 print $text.' '.dol_htmlentitiesbr($line->description);
204 }
205 }
206 }
207
208 // Show date range
209 if ($line->element == 'facturedetrec' || $line->element == 'invoice_supplier_det_rec') {
210 if ($line->element == 'invoice_supplier_det_rec' && $line->product_type != Product::TYPE_PRODUCT) {
211 $line->date_start_fill = $line->date_start;
212 $line->date_end_fill = $line->date_end;
213 }
214 if ($line->date_start_fill || $line->date_end_fill) {
215 print '<div class="clearboth nowraponall daterangeofline-facturedetrec">';
216 }
217 if ($line->date_start_fill) {
218 print '<span class="opacitymedium" title="'.dol_escape_htmltag($langs->trans("AutoFillDateFrom")).'">'.$langs->trans('AutoFillDateFromShort').':</span> '.yn($line->date_start_fill);
219 }
220 if ($line->date_start_fill && $line->date_end_fill) {
221 print ' - ';
222 }
223 if ($line->date_end_fill) {
224 print '<span class="opacitymedium" title="'.dol_escape_htmltag($langs->trans("AutoFillDateTo")).'">'.$langs->trans('AutoFillDateToShort').':</span> '.yn($line->date_end_fill);
225 }
226 if ($line->date_start_fill || $line->date_end_fill) {
227 print '</div>';
228 }
229 } else {
230 if ($line->date_start || $line->date_end) {
231 print '<div class="clearboth nowraponall opacitymedium daterangeofline">'.get_date_range($line->date_start, $line->date_end, $format).'</div>';
232 }
233
234 if (!$line->date_start || !$line->date_end) {
235 // show warning under line
236 // we need to fetch product associated to line for some test
237 if ($object->element == 'propal' || $object->element == 'order' || $object->element == 'facture' || $object->element == 'propal_supplier' || $object->element == 'supplier_proposal' || $object->element == 'commande') {
238 $res = $line->fetch_product();
239 if ($res > 0) {
240 if ($line->product->isService() && $line->product->isMandatoryPeriod()) {
241 print '<div><span class="clearboth nowraponall warning">'.$langs->trans("mandatoryPeriodNeedTobeSet").'</span></div>';
242 }
243 }
244 }
245 }
246
247 // If we show the lines in a context to create a recurring sale invoice
248 if (basename($_SERVER["PHP_SELF"]) == 'card-rec.php') {
249 $default_start_fill = getDolGlobalInt('INVOICEREC_SET_AUTOFILL_DATE_START');
250 $default_end_fill = getDolGlobalInt('INVOICEREC_SET_AUTOFILL_DATE_END');
251 print '<div class="clearboth nowraponall daterangeofline-facturedetrec">';
252 print '<span class="opacitymedium" title="'.dol_escape_htmltag($langs->trans("AutoFillDateFrom")).'">'.$langs->trans('AutoFillDateFromShort').':</span> '.yn($default_start_fill);
253 print ' - ';
254 print '<span class="opacitymedium" title="'.dol_escape_htmltag($langs->trans("AutoFillDateTo")).'">'.$langs->trans('AutoFillDateToShort').':</span> '.yn($default_end_fill);
255 print '</div>';
256 }
257 }
258
259 // Add description in form
260 if ($line->fk_product > 0 && getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) {
261 if ($line->element == 'facturedetrec') {
262 print (!empty($line->description) && $line->description != $line->product_label) ? (($line->date_start_fill || $line->date_end_fill) ? '' : '<br>').'<br>'.dol_htmlentitiesbr($line->description) : '';
263 } elseif ($line->element == 'invoice_supplier_det_rec') {
264 print (!empty($line->description) && $line->description != $line->label) ? (($line->date_start || $line->date_end) ? '' : '<br>').'<br>'.dol_htmlentitiesbr($line->description) : '';
265 } else {
266 print (!empty($line->description) && $line->description != $line->product_label) ? (($line->date_start || $line->date_end) ? '' : '<br>').'<br>'.dol_htmlentitiesbr($line->description) : '';
267 }
268 }
269
270 // Line extrafield
271 if (!empty($extrafields)) {
272 $temps = $line->showOptionals($extrafields, 'view', array(), '', '', 1, 'line');
273 if (!empty($temps)) {
274 print '<div style="padding-top: 10px" id="extrafield_lines_area_'.$line->id.'" name="extrafield_lines_area_'.$line->id.'">';
275 print $temps;
276 print '</div>';
277 }
278 }
279}
280
281if ($user->hasRight('fournisseur', 'lire') && isset($line->fk_fournprice) && $line->fk_fournprice > 0 && !getDolGlobalString('SUPPLIER_HIDE_SUPPLIER_OBJECTLINES')) {
282 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
283 $productfourn = new ProductFournisseur($this->db);
284 $productfourn->fetch_product_fournisseur_price($line->fk_fournprice);
285 print '<div class="clearboth"></div>';
286 print '<span class="opacitymedium">'.$langs->trans('Supplier').' : </span>'.$productfourn->getSocNomUrl(1, 'supplier').' - <span class="opacitymedium">'.$langs->trans('Ref').' : </span>';
287 // Supplier ref
288 if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { // change required right here
289 print $productfourn->getNomUrl();
290 } else {
291 print $productfourn->ref_supplier;
292 }
293}
294
295if (isModEnabled('accounting') && !empty($line->fk_accounting_account) && $line->fk_accounting_account > 0) {
296 $accountingaccount = new AccountingAccount($this->db);
297 $accountingaccount->fetch($line->fk_accounting_account);
298 print '<div class="clearboth"></div><br><span class="opacitymedium">'.$langs->trans('AccountingAffectation').' : </span>'.$accountingaccount->getNomUrl(0, 1, 1);
299}
300
301print '</td>';
302
303// Vendor price ref
304if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier' || $object->element == 'invoice_supplier_rec') { // We must have same test in printObjectLines
305 print '<td class="linecolrefsupplier">';
306 print($line->ref_fourn ? $line->ref_fourn : $line->ref_supplier);
307 print '</td>';
308}
309
310// Set the text for tooltip.
311// The value of maount must be shown with price(..., 0, '', 0, 0) so value will be visible exactly like it is into database.
312$tooltiponprice = '';
313$tooltiponpricemultiprice = '';
314$tooltiponpriceend = '';
315$tooltiponpriceendmultiprice = '';
316if (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
317 $tooltiponprice .= $langs->transcountry("TotalHT", $mysoc->country_code).'='.price($line->total_ht, 0, '', 0, 0);
318 $tooltiponpricemultiprice .= $langs->transcountry("TotalHT", $mysoc->country_code).'='.price($line->multicurrency_total_ht, 0, '', 0, 0);
319 $tooltiponprice .= '<br>'.$langs->transcountry("TotalVAT", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->total_tva, 0, '', 0, 0);
320 $tooltiponpricemultiprice .= '<br>'.$langs->transcountry("TotalVAT", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->multicurrency_total_tva, 0, '', 0, 0);
321 if (is_object($object->thirdparty)) {
322 if ($senderissupplier) {
323 $seller = $object->thirdparty;
324 $buyer = $mysoc;
325 } else {
326 $seller = $mysoc;
327 $buyer = $object->thirdparty;
328 }
329
330 if ($mysoc->useLocalTax(1)) {
331 if (($seller->country_code == $buyer->country_code) || $line->total_localtax1 || $seller->useLocalTax(1)) {
332 $tooltiponprice .= '<br>'.$langs->transcountry("TotalLT1", $seller->country_code).'='.price($line->total_localtax1, 0, '', 0, 0);
333 $tooltiponpricemultiprice .= '<br>'.$langs->transcountry("TotalLT1", $seller->country_code).'='.price($line->multicurrency_total_localtax1, 0, '', 0, 0);
334 } else {
335 $tooltiponprice .= '<br>'.$langs->transcountry("TotalLT1", $seller->country_code).'=<span class="opacitymedium">'.$langs->trans($senderissupplier ? "NotUsedForThisVendor" : "NotUsedForThisCustomer").'</span>';
336 $tooltiponpricemultiprice .= '<br>'.$langs->transcountry("TotalLT1", $seller->country_code).'=<span class="opacitymedium">'.$langs->trans($senderissupplier ? "NotUsedForThisVendor" : "NotUsedForThisCustomer").'</span>';
337 }
338 }
339 if ($mysoc->useLocalTax(2)) {
340 if ((isset($seller->country_code) && isset($buyer->thirdparty->country_code) && $seller->country_code == $buyer->thirdparty->country_code) || $line->total_localtax2 || $seller->useLocalTax(2)) {
341 $tooltiponprice .= '<br>'.$langs->transcountry("TotalLT2", $seller->country_code).'='.price($line->total_localtax2, 0, '', 0, 0);
342 $tooltiponpricemultiprice .= '<br>'.$langs->transcountry("TotalLT2", $seller->country_code).'='.price($line->multicurrency_total_localtax2, 0, '', 0, 0);
343 } else {
344 $tooltiponprice .= '<br>'.$langs->transcountry("TotalLT2", $seller->country_code).'=<span class="opacitymedium">'.$langs->trans($senderissupplier ? "NotUsedForThisVendor" : "NotUsedForThisCustomer").'</span>';
345 $tooltiponpricemultiprice .= '<br>'.$langs->transcountry("TotalLT2", $seller->country_code).'=<span class="opacitymedium">'.$langs->trans($senderissupplier ? "NotUsedForThisVendor" : "NotUsedForThisCustomer").'</span>';
346 }
347 }
348 }
349 $tooltiponprice .= '<br>'.$langs->transcountry("TotalTTC", $mysoc->country_code).'='.price($line->total_ttc, 0, '', 0, 0);
350 $tooltiponpricemultiprice .= '<br>'.$langs->transcountry("TotalTTC", $mysoc->country_code).'='.price($line->multicurrency_total_ttc, 0, '', 0, 0);
351
352 if (!empty($line->special_code) || $line->product_type == 9) {
353 $tooltiponprice .= '<br>';
354 $tooltiponpricemultiprice .= '<br>';
355 if (!empty($line->special_code)) {
356 $tooltiponprice .= '<br>'.$langs->trans("SpecialLine").' : '.getLabelSpecialCode($line->special_code);
357 $tooltiponpricemultiprice .= '<br>'.$langs->trans("SpecialLine").' : '.getLabelSpecialCode($line->special_code);
358 }
359 if ($line->product_type == 9) {
360 $tooltiponprice .= '<br>'.$langs->trans("SpecialLine").' : '.$langs->trans("GroupingLine");
361 $tooltiponpricemultiprice .= '<br>'.$langs->trans("SpecialLine").' : '.$langs->trans("GroupingLine");
362 }
363 }
364
365 $tooltiponprice = '<span class="classfortooltip" title="'.dol_escape_htmltag($tooltiponprice).'">';
366 $tooltiponpricemultiprice = '<span class="classfortooltip" title="'.dol_escape_htmltag($tooltiponpricemultiprice).'">';
367
368 $tooltiponpriceend = '</span>';
369 $tooltiponpriceendmultiprice = '</span>';
370}
371
372// VAT Rate
373print '<td class="linecolvat nowrap right">';
374$coldisplay++;
375$positiverates = '';
376if (price2num($line->tva_tx)) {
377 $positiverates .= ($positiverates ? '/' : '').price2num($line->tva_tx);
378}
379if (price2num($line->total_localtax1)) {
380 $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax1_tx);
381}
382if (price2num($line->total_localtax2)) {
383 $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax2_tx);
384}
385if (empty($positiverates)) {
386 $positiverates = '0';
387}
388print $tooltiponprice;
389print vatrate($positiverates.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), true, $line->info_bits);
390print $tooltiponpriceend;
391?></td>
392
393 <td class="linecoluht nowraponall right"><?php $coldisplay++; ?><?php print price($sign * $line->subprice); ?></td>
394
395<?php if (isModEnabled("multicurrency") && $this->multicurrency_code != $conf->currency) { ?>
396 <td class="linecoluht_currency nowraponall right"><?php $coldisplay++; ?><?php print price($sign * $line->multicurrency_subprice); ?></td>
397<?php }
398
399if (!empty($inputalsopricewithtax) && !getDolGlobalInt('MAIN_NO_INPUT_PRICE_WITH_TAX')) { ?>
400 <td class="linecoluttc nowraponall right"><?php $coldisplay++; ?><?php
401 $upinctax = isset($line->pu_ttc) ? $line->pu_ttc : null;
402 if (getDolGlobalInt('MAIN_UNIT_PRICE_WITH_TAX_IS_FOR_ALL_TAXES')) {
403 $upinctax = price2num($line->total_ttc / (float) $line->qty, 'MU');
404 }
405 print(isset($upinctax) ? price($sign * $upinctax) : price($sign * $line->subprice));
406 ?></td>
407<?php } ?>
408
409 <td class="linecolqty nowraponall right"><?php $coldisplay++; ?>
410<?php
411if ((($line->info_bits & 2) != 2) && $line->special_code != 3) {
412 // I comment this because it shows info even when not required
413 // for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated
414 // must also not be output for most entities (proposal, intervention, ...)
415 //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." ";
416 print price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formatting role of function price
417} else {
418 print '&nbsp;';
419}
420print '</td>';
421
422if (getDolGlobalString('PRODUCT_USE_UNITS')) {
423 print '<td class="linecoluseunit nowrap left">';
424 $label = $line->getLabelOfUnit('short');
425 if ($label !== '') {
426 print $langs->trans($label);
427 }
428 print '</td>';
429}
430if (!empty($line->remise_percent) && $line->special_code != 3) {
431 print '<td class="linecoldiscount right">';
432 $coldisplay++;
433 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
434 print dol_print_reduction((float) $line->remise_percent, $langs);
435 print '</td>';
436} else {
437 print '<td class="linecoldiscount">&nbsp;</td>';
438 $coldisplay++;
439}
440
441// Fields for situation invoices
442if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) {
443 include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
444 $coldisplay++;
445 if (getDolGlobalInt('INVOICE_USE_SITUATION') == 2) {
446 $previous_progress = $line->getAllPrevProgress($object->id);
447 $current_progress = $previous_progress + floatval($line->situation_percent);
448 print '<td class="linecolcycleref nowrap right">'.$current_progress.'%</td>';
449 $coldisplay++;
450 print '<td class="nowrap right">'.$line->situation_percent.'%</td>';
451 $coldisplay++;
452 $locataxes_array = getLocalTaxesFromRate($line->tva.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), 0, ($senderissupplier ? $mysoc : $object->thirdparty), ($senderissupplier ? $object->thirdparty : $mysoc));
453 $tmp = calcul_price_total($line->qty, $line->pu, $line->remise_percent, $line->txtva, -1, -1, 0, 'HT', $line->info_bits, $line->type, ($senderissupplier ? $object->thirdparty : $mysoc), $locataxes_array, 100, $object->multicurrency_tx, $line->multicurrency_subprice);
454 print '<td class="linecolcycleref2 right nowrap">'.price($sign * (float) $tmp[0]).'</td>';
455 } else {
456 print '<td class="linecolcycleref nowrap right">'.$line->situation_percent.'%</td>';
457 $coldisplay++;
458 $locataxes_array = getLocalTaxesFromRate($line->tva.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), 0, ($senderissupplier ? $mysoc : $object->thirdparty), ($senderissupplier ? $object->thirdparty : $mysoc));
459 $tmp = calcul_price_total($line->qty, $line->pu, $line->remise_percent, $line->txtva, -1, -1, 0, 'HT', $line->info_bits, $line->type, ($senderissupplier ? $object->thirdparty : $mysoc), $locataxes_array, 100, $object->multicurrency_tx, $line->multicurrency_subprice);
460 print '<td class="linecolcycleref2 right nowrap">'.price($sign * (float) $tmp[0]).'</td>';
461 }
462}
463
464if ($usemargins && isModEnabled('margin') && empty($user->socid)) {
465 if ($user->hasRight('margins', 'creer')) { ?>
466 <td class="linecolmargin1 nowrap margininfos right"><?php $coldisplay++; ?><?php print price($line->pa_ht); ?></td>
467 <?php }
468 if (getDolGlobalString('DISPLAY_MARGIN_RATES') && $user->hasRight('margins', 'liretous')) { ?>
469 <td class="linecolmargin2 nowrap margininfos right"><?php $coldisplay++; ?><?php print(($line->pa_ht == 0) ? 'n/a' : price(price2num($line->marge_tx, 'MT')).'%'); ?></td>
470 <?php }
471 if (getDolGlobalString('DISPLAY_MARK_RATES') && $user->hasRight('margins', 'liretous')) {?>
472 <td class="linecolmark1 nowrap margininfos right"><?php $coldisplay++; ?><?php print price(price2num($line->marque_tx, 'MT')).'%'; ?></td>
473 <?php }
474}
475
476// Price total without tax
477if ($line->special_code == 3) {
478 $coldisplay++;
479 $colspanOptions = '';
480 if (isModEnabled('multicurrency') && $object->multicurrency_code != $conf->currency) {
481 $coldisplay++;
482 $colspanOptions = ' colspan="2"';
483 }
484 print '<td class="linecoloption nowrap right"'.$colspanOptions.'>'.$langs->trans('Option').'</td>';
485} else {
486 print '<td class="linecolht nowrap right">';
487 $coldisplay++;
488 print $tooltiponprice;
489 print price($sign * $line->total_ht);
490 print $tooltiponpriceend;
491 print '</td>';
492 if (isModEnabled("multicurrency") && $this->multicurrency_code != $conf->currency) {
493 print '<td class="linecolutotalht_currency nowrap right">';
494 print $tooltiponpricemultiprice;
495 print price($sign * $line->multicurrency_total_ht);
496 print $tooltiponpriceendmultiprice;
497 print '</td>';
498 $coldisplay++;
499 }
500}
501
502// Price inc tax
503if ($outputalsopricetotalwithtax) {
504 print '<td class="linecolht nowrap right">'.price($sign * $line->total_ttc).'</td>';
505 $coldisplay++;
506}
507
508// TODO Replace this with $permissiontoedit ?
509$objectRights = $this->getRights();
510$tmppermtoedit = $objectRights->creer;
511
512if ($this->status == 0 && $tmppermtoedit && $action != 'selectlines') {
513 $situationinvoicelinewithparent = 0;
514 if (isset($line->fk_prev_id) && in_array($object->element, array('facture', 'facturedet'))) {
516 // @phan-suppress-next-line PhanUndeclaredConstantOfClass
517 if ($object->type == $object::TYPE_SITUATION) { // The constant TYPE_SITUATION exists only for object invoice
518 // Set constant to disallow editing during a situation cycle
519 $situationinvoicelinewithparent = 1;
520 }
521 }
522
523 // Asset info
524 if (isModEnabled('asset') && $object->element == 'invoice_supplier') {
525 print '<td class="linecolasset center">';
526 $coldisplay++;
527 if (
528 $product_static !== null
529 &&
530 (
531 !empty($product_static->accountancy_code_buy) ||
532 !empty($product_static->accountancy_code_buy_intra) ||
533 !empty($product_static->accountancy_code_buy_export)
534 )
535 ) {
536 $accountancy_category_asset = getDolGlobalString('ASSET_ACCOUNTANCY_CATEGORY');
537 $filters = array();
538 if (!empty($product_static->accountancy_code_buy)) {
539 $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy) . "'";
540 }
541 if (!empty($product_static->accountancy_code_buy_intra)) {
542 $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_intra) . "'";
543 }
544 if (!empty($product_static->accountancy_code_buy_export)) {
545 $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_export) . "'";
546 }
547 $sql = "SELECT COUNT(*) AS found";
548 $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account";
549 $sql .= " WHERE pcg_type = '" . $this->db->escape($conf->global->ASSET_ACCOUNTANCY_CATEGORY) . "'";
550 $sql .= " AND (" . implode(' OR ', $filters). ")";
551 $resql_asset = $this->db->query($sql);
552 if (!$resql_asset) {
553 print 'Error SQL: ' . $this->db->lasterror();
554 } elseif ($obj = $this->db->fetch_object($resql_asset)) {
555 if (!empty($obj->found)) {
556 print '<a class="reposition" href="' . DOL_URL_ROOT . '/asset/card.php?action=create&token='.newToken().'&supplier_invoice_id='.$object->id.'">';
557 print img_edit_add() . '</a>';
558 }
559 }
560 }
561 print '</td>';
562 }
563
564 // Edit picto
565 print '<td class="linecoledit center">';
566 $coldisplay++;
567 if (($line->info_bits & 2) == 2 || !empty($disableedit)) {
568 } else { ?>
569 <a class="editfielda reposition" href="<?php print $_SERVER["PHP_SELF"].'?id='.$this->id.'&action=editline&token='.newToken().'&lineid='.$line->id; ?>">
570 <?php print img_edit().'</a>';
571 }
572 print '</td>';
573
574 // Delete picto
575 print '<td class="linecoldelete center">';
576 $coldisplay++;
577 if (!$situationinvoicelinewithparent && empty($disableremove)) { // For situation invoice, deletion is not possible if there is a parent company.
578 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=ask_deleteline&token='.newToken().'&lineid='.$line->id.'">';
579 print img_delete();
580 print '</a>';
581 }
582 print '</td>';
583
584 // Move up-down picto
585 if ($num > 1 && $conf->browser->layout != 'phone' && ((property_exists($this, 'situation_counter') && $this->situation_counter == 1) || empty($this->situation_cycle_ref)) && empty($disablemove)) {
586 print '<td class="linecolmove tdlineupdown center">';
587 $coldisplay++;
588 if ($i > 0) { ?>
589 <a class="lineupdown" href="<?php print $_SERVER["PHP_SELF"].'?id='.$this->id.'&action=up&token='.newToken().'&rowid='.$line->id; ?>">
590 <?php print img_up('default', 0, 'imgupforline'); ?>
591 </a>
592 <?php }
593 if ($i < $num - 1) { ?>
594 <a class="lineupdown" href="<?php print $_SERVER["PHP_SELF"].'?id='.$this->id.'&action=down&token='.newToken().'&rowid='.$line->id; ?>">
595 <?php print img_down('default', 0, 'imgdownforline'); ?>
596 </a>
597 <?php }
598 print '</td>';
599 } else {
600 print '<td '.(($conf->browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'></td>';
601 $coldisplay++;
602 }
603} else {
604 $colspan = 3;
605 if (isModEnabled('asset') && $object->element == 'invoice_supplier') {
606 $colspan++;
607 }
608 print '<td colspan="'.$colspan.'"></td>';
609 $coldisplay += $colspan;
610}
611
612if ($action == 'selectlines') { ?>
613 <td class="linecolcheck center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php print $i + 1; ?>]" value="<?php print $line->id; ?>" ></td>
614<?php }
615
616print "</tr>\n";
617
618print "<!-- END PHP TEMPLATE objectline_view.tpl.php -->\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
Class to manage accounting accounts.
Class to manage absolute discounts.
Class to manage predefined suppliers products.
const TYPE_PRODUCT
Regular product.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:171
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_print_reduction($reduction, $langs)
Returns formatted reduction.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
getLabelSpecialCode($idcode)
Make content of an input box selected when we click into input field.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
img_edit_add($titlealt='default', $other='')
Show logo +.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller='', $localtaxes_array=[], $progress=100, $multicurrency_tx=1, $pu_devise=0, $multicurrency_code='')
Calculate totals (net, vat, ...) of a line.
Definition price.lib.php:90
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:149
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:152