dolibarr  20.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  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>.
24  *
25  * Need to have following variables defined:
26  * $object (invoice, order, ...)
27  * $conf
28  * $langs
29  * $dateSelector
30  * $forceall (0 by default, 1 for supplier invoices/orders)
31  * $element (used to test $user->rights->$element->creer)
32  * $permtoedit (used to replace test $user->rights->$element->creer)
33  * $senderissupplier (0 by default, 1 for supplier invoices/orders)
34  * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
35  * $outputalsopricetotalwithtax
36  * $usemargins (0 to disable all margins columns, 1 to show according to margin setup)
37  * $object_rights->creer initialized from = $object->getRights()
38  * $disableedit, $disablemove, $disableremove
39  *
40  * $text, $description, $line
41  */
42 // Protection to avoid direct call of template
43 if (empty($object) || !is_object($object)) {
44  print "Error, template page can't be called as URL";
45  exit(1);
46 }
47 
48 '@phan-var-force CommonObject $this
49  @phan-var-force CommonObject $object
50  @phan-var-force 0|1 $forceall
51 ';
52 
53 global $mysoc;
54 global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax;
55 
56 $usemargins = 0;
57 if (isModEnabled('margin') && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande'))) {
58  $usemargins = 1;
59 }
60 
61 if (empty($dateSelector)) {
62  $dateSelector = 0;
63 }
64 if (empty($forceall)) {
65  $forceall = 0;
66 }
67 if (empty($senderissupplier)) {
68  $senderissupplier = 0;
69 }
70 if (empty($inputalsopricewithtax)) {
71  $inputalsopricewithtax = 0;
72 }
73 if (empty($outputalsopricetotalwithtax)) {
74  $outputalsopricetotalwithtax = 0;
75 }
76 
77 // add html5 elements
78 $domData = ' data-element="'.$line->element.'"';
79 $domData .= ' data-id="'.$line->id.'"';
80 $domData .= ' data-qty="'.$line->qty.'"';
81 $domData .= ' data-product_type="'.$line->product_type.'"';
82 
83 $sign = 1;
84 // @phan-suppress-next-line PhanUndeclaredConstantOfClass
85 if (getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE_SCREEN') && in_array($object->element, array('facture', 'invoice_supplier')) && $object->type == $object::TYPE_CREDIT_NOTE) {
86  $sign = -1;
87 }
88 
89 
90 $coldisplay = 0;
91 ?>
92 <!-- BEGIN PHP TEMPLATE objectline_view.tpl.php -->
93 <tr id="row-<?php print $line->id?>" class="drag drop oddeven" <?php print $domData; ?> >
94 <?php if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) { ?>
95  <td class="linecolnum center"><span class="opacitymedium"><?php $coldisplay++; ?><?php print($i + 1); ?></span></td>
96 <?php } ?>
97  <td class="linecoldescription minwidth300imp"><?php $coldisplay++; ?><div id="line_<?php print $line->id; ?>"></div>
98 <?php
99 if (($line->info_bits & 2) == 2) {
100  print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$this->socid.'">';
101  $txt = '';
102  print img_object($langs->trans("ShowReduc"), 'reduc').' ';
103  if ($line->description == '(DEPOSIT)') {
104  $txt = $langs->trans("Deposit");
105  } elseif ($line->description == '(EXCESS RECEIVED)') {
106  $txt = $langs->trans("ExcessReceived");
107  } elseif ($line->description == '(EXCESS PAID)') {
108  $txt = $langs->trans("ExcessPaid");
109  }
110  //else $txt=$langs->trans("Discount");
111  print $txt;
112  print '</a>';
113  if ($line->description) {
114  if ($line->description == '(CREDIT_NOTE)' && $line->fk_remise_except > 0) {
115  include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
116  $discount = new DiscountAbsolute($this->db);
117  $discount->fetch($line->fk_remise_except);
118  print($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
119  } elseif ($line->description == '(DEPOSIT)' && $line->fk_remise_except > 0) {
120  include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
121  $discount = new DiscountAbsolute($this->db);
122  $discount->fetch($line->fk_remise_except);
123  print($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
124  // Add date of deposit
125  if (getDolGlobalString('INVOICE_ADD_DEPOSIT_DATE')) {
126  print ' ('.dol_print_date($discount->datec).')';
127  }
128  } elseif ($line->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) {
129  include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
130  $discount = new DiscountAbsolute($this->db);
131  $discount->fetch($line->fk_remise_except);
132  print($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0));
133  } elseif ($line->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) {
134  include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
135  $discount = new DiscountAbsolute($this->db);
136  $discount->fetch($line->fk_remise_except);
137  print($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0));
138  } else {
139  print($txt ? ' - ' : '').dol_htmlentitiesbr($line->description);
140  }
141  }
142 } else {
143  $format = (getDolGlobalString('MAIN_USE_HOURMIN_IN_DATE_RANGE') ? 'dayhour' : 'day');
144 
145  if ($line->fk_product > 0) {
146  if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
147  print (!empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : '') . $text;
148  if (!getDolGlobalInt('PRODUIT_DESC_IN_FORM')) {
149  print $form->textwithpicto('', $description);
150  }
151  } else {
152  print $form->textwithtooltip($text, $description, 3, 0, '', $i, 0, (!empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : ''));
153  }
154  } else {
155  $type = (!empty($line->product_type) ? $line->product_type : $line->fk_product_type);
156  if ($type == 1) {
157  $text = img_object($langs->trans('Service'), 'service');
158  } else {
159  $text = img_object($langs->trans('Product'), 'product');
160  }
161 
162  if (!empty($line->label)) {
163  $text .= ' <strong>'.$line->label.'</strong>';
164  print $form->textwithtooltip($text, dol_htmlentitiesbr($line->description), 3, 0, '', $i, 0, (!empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : ''));
165  } else {
166  if (!empty($line->fk_parent_line)) {
167  print img_picto('', 'rightarrow');
168  }
169  if (preg_match('/^\‍(DEPOSIT\‍)/', $line->description)) {
170  $newdesc = preg_replace('/^\‍(DEPOSIT\‍)/', $langs->trans("Deposit"), $line->description);
171  print $text.' '.dol_htmlentitiesbr($newdesc);
172  } else {
173  print $text.' '.dol_htmlentitiesbr($line->description);
174  }
175  }
176  }
177 
178  // Show date range
179  if ($line->element == 'facturedetrec' || $line->element == 'invoice_supplier_det_rec') {
180  if ($line->element == 'invoice_supplier_det_rec' && $line->product_type != Product::TYPE_PRODUCT) {
181  $line->date_start_fill = $line->date_start;
182  $line->date_end_fill = $line->date_end;
183  }
184  if ($line->date_start_fill || $line->date_end_fill) {
185  print '<div class="clearboth nowraponall daterangeofline-facturedetrec">';
186  }
187  if ($line->date_start_fill) {
188  print '<span class="opacitymedium" title="'.dol_escape_htmltag($langs->trans("AutoFillDateFrom")).'">'.$langs->trans('AutoFillDateFromShort').':</span> '.yn($line->date_start_fill);
189  }
190  if ($line->date_start_fill && $line->date_end_fill) {
191  print ' - ';
192  }
193  if ($line->date_end_fill) {
194  print '<span class="opacitymedium" title="'.dol_escape_htmltag($langs->trans("AutoFillDateTo")).'">'.$langs->trans('AutoFillDateToShort').':</span> '.yn($line->date_end_fill);
195  }
196  if ($line->date_start_fill || $line->date_end_fill) {
197  print '</div>';
198  }
199  } else {
200  if ($line->date_start || $line->date_end) {
201  print '<div class="clearboth nowraponall opacitymedium daterangeofline">'.get_date_range($line->date_start, $line->date_end, $format).'</div>';
202  }
203 
204  if (!$line->date_start || !$line->date_end) {
205  // show warning under line
206  // we need to fetch product associated to line for some test
207  if ($object->element == 'propal' || $object->element == 'order' || $object->element == 'facture' || $object->element == 'propal_supplier' || $object->element == 'supplier_proposal' || $object->element == 'commande') {
208  $res = $line->fetch_product();
209  if ($res > 0) {
210  if ($line->product->isService() && $line->product->isMandatoryPeriod()) {
211  print '<div><span class="clearboth nowraponall warning">'.$langs->trans("mandatoryPeriodNeedTobeSet").'</span></div>';
212  }
213  }
214  }
215  }
216 
217  // If we show the lines in a context to create a recurring sale invoice
218  if (basename($_SERVER["PHP_SELF"]) == 'card-rec.php') {
219  $default_start_fill = getDolGlobalInt('INVOICEREC_SET_AUTOFILL_DATE_START');
220  $default_end_fill = getDolGlobalInt('INVOICEREC_SET_AUTOFILL_DATE_END');
221  print '<div class="clearboth nowraponall daterangeofline-facturedetrec">';
222  print '<span class="opacitymedium" title="'.dol_escape_htmltag($langs->trans("AutoFillDateFrom")).'">'.$langs->trans('AutoFillDateFromShort').':</span> '.yn($default_start_fill);
223  print ' - ';
224  print '<span class="opacitymedium" title="'.dol_escape_htmltag($langs->trans("AutoFillDateTo")).'">'.$langs->trans('AutoFillDateToShort').':</span> '.yn($default_end_fill);
225  print '</div>';
226  }
227  }
228 
229  // Add description in form
230  if ($line->fk_product > 0 && getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) {
231  if ($line->element == 'facturedetrec') {
232  print (!empty($line->description) && $line->description != $line->product_label) ? (($line->date_start_fill || $line->date_end_fill) ? '' : '<br>').'<br>'.dol_htmlentitiesbr($line->description) : '';
233  } elseif ($line->element == 'invoice_supplier_det_rec') {
234  print (!empty($line->description) && $line->description != $line->label) ? (($line->date_start || $line->date_end) ? '' : '<br>').'<br>'.dol_htmlentitiesbr($line->description) : '';
235  } else {
236  print (!empty($line->description) && $line->description != $line->product_label) ? (($line->date_start || $line->date_end) ? '' : '<br>').'<br>'.dol_htmlentitiesbr($line->description) : '';
237  }
238  }
239 
240  // Line extrafield
241  if (!empty($extrafields)) {
242  $temps = $line->showOptionals($extrafields, 'view', array(), '', '', 1, 'line');
243  if (!empty($temps)) {
244  print '<div style="padding-top: 10px" id="extrafield_lines_area_'.$line->id.'" name="extrafield_lines_area_'.$line->id.'">';
245  print $temps;
246  print '</div>';
247  }
248  }
249 }
250 
251 if ($user->hasRight('fournisseur', 'lire') && isset($line->fk_fournprice) && $line->fk_fournprice > 0 && !getDolGlobalString('SUPPLIER_HIDE_SUPPLIER_OBJECTLINES')) {
252  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
253  $productfourn = new ProductFournisseur($this->db);
254  $productfourn->fetch_product_fournisseur_price($line->fk_fournprice);
255  print '<div class="clearboth"></div>';
256  print '<span class="opacitymedium">'.$langs->trans('Supplier').' : </span>'.$productfourn->getSocNomUrl(1, 'supplier').' - <span class="opacitymedium">'.$langs->trans('Ref').' : </span>';
257  // Supplier ref
258  if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { // change required right here
259  print $productfourn->getNomUrl();
260  } else {
261  print $productfourn->ref_supplier;
262  }
263 }
264 
265 if (isModEnabled('accounting') && !empty($line->fk_accounting_account) && $line->fk_accounting_account > 0) {
266  $accountingaccount = new AccountingAccount($this->db);
267  $accountingaccount->fetch($line->fk_accounting_account);
268  print '<div class="clearboth"></div><br><span class="opacitymedium">'.$langs->trans('AccountingAffectation').' : </span>'.$accountingaccount->getNomUrl(0, 1, 1);
269 }
270 
271 print '</td>';
272 // Vendor price ref
273 if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier' || $object->element == 'invoice_supplier_rec') { // We must have same test in printObjectLines
274  print '<td class="linecolrefsupplier">';
275  print($line->ref_fourn ? $line->ref_fourn : $line->ref_supplier);
276  print '</td>';
277 }
278 
279 $tooltiponprice = '';
280 $tooltiponpriceend = '';
281 if (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
282  $tooltiponprice = $langs->transcountry("TotalHT", $mysoc->country_code).'='.price($line->total_ht);
283  $tooltiponprice .= '<br>'.$langs->transcountry("TotalVAT", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->total_tva);
284  if (is_object($object->thirdparty)) {
285  if ($senderissupplier) {
286  $seller = $object->thirdparty;
287  $buyer = $mysoc;
288  } else {
289  $seller = $mysoc;
290  $buyer = $object->thirdparty;
291  }
292 
293  if ($mysoc->useLocalTax(1)) {
294  if (($seller->country_code == $buyer->country_code) || $line->total_localtax1 || $seller->useLocalTax(1)) {
295  $tooltiponprice .= '<br>'.$langs->transcountry("TotalLT1", $seller->country_code).'='.price($line->total_localtax1);
296  } else {
297  $tooltiponprice .= '<br>'.$langs->transcountry("TotalLT1", $seller->country_code).'=<span class="opacitymedium">'.$langs->trans($senderissupplier ? "NotUsedForThisVendor" : "NotUsedForThisCustomer").'</span>';
298  }
299  }
300  if ($mysoc->useLocalTax(2)) {
301  if ((isset($seller->country_code) && isset($buyer->thirdparty->country_code) && $seller->country_code == $buyer->thirdparty->country_code) || $line->total_localtax2 || $seller->useLocalTax(2)) {
302  $tooltiponprice .= '<br>'.$langs->transcountry("TotalLT2", $seller->country_code).'='.price($line->total_localtax2);
303  } else {
304  $tooltiponprice .= '<br>'.$langs->transcountry("TotalLT2", $seller->country_code).'=<span class="opacitymedium">'.$langs->trans($senderissupplier ? "NotUsedForThisVendor" : "NotUsedForThisCustomer").'</span>';
305  }
306  }
307  }
308  $tooltiponprice .= '<br>'.$langs->transcountry("TotalTTC", $mysoc->country_code).'='.price($line->total_ttc);
309 
310  $tooltiponprice = '<span class="classfortooltip" title="'.dol_escape_htmltag($tooltiponprice).'">';
311  $tooltiponpriceend = '</span>';
312 }
313 
314 // VAT Rate
315 print '<td class="linecolvat nowrap right">';
316 $coldisplay++;
317 $positiverates = '';
318 if (price2num($line->tva_tx)) {
319  $positiverates .= ($positiverates ? '/' : '').price2num($line->tva_tx);
320 }
321 if (price2num($line->total_localtax1)) {
322  $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax1_tx);
323 }
324 if (price2num($line->total_localtax2)) {
325  $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax2_tx);
326 }
327 if (empty($positiverates)) {
328  $positiverates = '0';
329 }
330 print $tooltiponprice;
331 print vatrate($positiverates.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), '%', $line->info_bits);
332 print $tooltiponpriceend;
333 ?></td>
334 
335  <td class="linecoluht nowraponall right"><?php $coldisplay++; ?><?php print price($sign * $line->subprice); ?></td>
336 
337 <?php if (isModEnabled("multicurrency") && $this->multicurrency_code != $conf->currency) { ?>
338  <td class="linecoluht_currency nowraponall right"><?php $coldisplay++; ?><?php print price($sign * $line->multicurrency_subprice); ?></td>
339 <?php }
340 
341 if (!empty($inputalsopricewithtax) && !getDolGlobalInt('MAIN_NO_INPUT_PRICE_WITH_TAX')) { ?>
342  <td class="linecoluttc nowraponall right"><?php $coldisplay++; ?><?php
343  $upinctax = isset($line->pu_ttc) ? $line->pu_ttc : null;
344  if (getDolGlobalInt('MAIN_UNIT_PRICE_WITH_TAX_IS_FOR_ALL_TAXES')) {
345  $upinctax = price2num($line->total_ttc / (float) $line->qty, 'MU');
346  }
347  print(isset($upinctax) ? price($sign * $upinctax) : price($sign * $line->subprice));
348  ?></td>
349 <?php } ?>
350 
351  <td class="linecolqty nowraponall right"><?php $coldisplay++; ?>
352 <?php
353 if ((($line->info_bits & 2) != 2) && $line->special_code != 3) {
354  // I comment this because it shows info even when not required
355  // 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
356  // must also not be output for most entities (proposal, intervention, ...)
357  //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." ";
358  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
359 } else {
360  print '&nbsp;';
361 }
362 print '</td>';
363 
364 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
365  print '<td class="linecoluseunit nowrap left">';
366  $label = $line->getLabelOfUnit('short');
367  if ($label !== '') {
368  print $langs->trans($label);
369  }
370  print '</td>';
371 }
372 if (!empty($line->remise_percent) && $line->special_code != 3) {
373  print '<td class="linecoldiscount right">';
374  $coldisplay++;
375  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
376  print dol_print_reduction($line->remise_percent, $langs);
377  print '</td>';
378 } else {
379  print '<td class="linecoldiscount">&nbsp;</td>';
380  $coldisplay++;
381 }
382 
383 // Fields for situation invoices
384 if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) {
385  include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
386  $coldisplay++;
387  print '<td class="linecolcycleref nowrap right">'.$line->situation_percent.'%</td>';
388  $coldisplay++;
389  $locataxes_array = getLocalTaxesFromRate($line->tva.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), 0, ($senderissupplier ? $mysoc : $object->thirdparty), ($senderissupplier ? $object->thirdparty : $mysoc));
390  $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);
391  print '<td align="right" class="linecolcycleref2 nowrap">'.price($sign * $tmp[0]).'</td>';
392 }
393 
394 if ($usemargins && isModEnabled('margin') && empty($user->socid)) {
395  if ($user->hasRight('margins', 'creer')) { ?>
396  <td class="linecolmargin1 nowrap margininfos right"><?php $coldisplay++; ?><?php print price($line->pa_ht); ?></td>
397  <?php }
398  if (getDolGlobalString('DISPLAY_MARGIN_RATES') && $user->hasRight('margins', 'liretous')) { ?>
399  <td class="linecolmargin2 nowrap margininfos right"><?php $coldisplay++; ?><?php print(($line->pa_ht == 0) ? 'n/a' : price(price2num($line->marge_tx, 'MT')).'%'); ?></td>
400  <?php }
401  if (getDolGlobalString('DISPLAY_MARK_RATES') && $user->hasRight('margins', 'liretous')) {?>
402  <td class="linecolmargin2 nowrap margininfos right"><?php $coldisplay++; ?><?php print price(price2num($line->marque_tx, 'MT')).'%'; ?></td>
403  <?php }
404 }
405 
406 // Price total without tax
407 if ($line->special_code == 3) {
408  $coldisplay++;
409  $colspanOptions = '';
410  if (!empty($conf->multicurrency->enabled) && $object->multicurrency_code != $conf->currency) {
411  $coldisplay++;
412  $colspanOptions = ' colspan="2"';
413  }
414  print '<td class="linecoloption nowrap right"'.$colspanOptions.'>'.$langs->trans('Option').'</td>';
415 } else {
416  print '<td class="linecolht nowrap right">';
417  $coldisplay++;
418  print $tooltiponprice;
419  print price($sign * $line->total_ht);
420  print $tooltiponpriceend;
421  print '</td>';
422  if (isModEnabled("multicurrency") && $this->multicurrency_code != $conf->currency) {
423  print '<td class="linecolutotalht_currency nowrap right">'.price($sign * $line->multicurrency_total_ht).'</td>';
424  $coldisplay++;
425  }
426 }
427 
428 // Price inc tax
429 if ($outputalsopricetotalwithtax) {
430  print '<td class="linecolht nowrap right">'.price($sign * $line->total_ttc).'</td>';
431  $coldisplay++;
432 }
433 
434 if ($this->status == 0 && !empty($object_rights->creer) && $action != 'selectlines') {
435  $situationinvoicelinewithparent = 0;
436  if (isset($line->fk_prev_id) && in_array($object->element, array('facture', 'facturedet'))) {
437  // @phan-suppress-next-line PhanUndeclaredConstantOfClass
438  if ($object->type == $object::TYPE_SITUATION) { // The constant TYPE_SITUATION exists only for object invoice
439  // Set constant to disallow editing during a situation cycle
440  $situationinvoicelinewithparent = 1;
441  }
442  }
443 
444  // Asset info
445  if (isModEnabled('asset') && $object->element == 'invoice_supplier') {
446  print '<td class="linecolasset center">';
447  $coldisplay++;
448  if (!empty($product_static->accountancy_code_buy) ||
449  !empty($product_static->accountancy_code_buy_intra) ||
450  !empty($product_static->accountancy_code_buy_export)
451  ) {
452  $accountancy_category_asset = getDolGlobalString('ASSET_ACCOUNTANCY_CATEGORY');
453  $filters = array();
454  if (!empty($product_static->accountancy_code_buy)) {
455  $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy) . "'";
456  }
457  if (!empty($product_static->accountancy_code_buy_intra)) {
458  $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_intra) . "'";
459  }
460  if (!empty($product_static->accountancy_code_buy_export)) {
461  $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_export) . "'";
462  }
463  $sql = "SELECT COUNT(*) AS found";
464  $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account";
465  $sql .= " WHERE pcg_type = '" . $this->db->escape($conf->global->ASSET_ACCOUNTANCY_CATEGORY) . "'";
466  $sql .= " AND (" . implode(' OR ', $filters). ")";
467  $resql_asset = $this->db->query($sql);
468  if (!$resql_asset) {
469  print 'Error SQL: ' . $this->db->lasterror();
470  } elseif ($obj = $this->db->fetch_object($resql_asset)) {
471  if (!empty($obj->found)) {
472  print '<a class="reposition" href="' . DOL_URL_ROOT . '/asset/card.php?action=create&token='.newToken().'&supplier_invoice_id='.$object->id.'">';
473  print img_edit_add() . '</a>';
474  }
475  }
476  }
477  print '</td>';
478  }
479 
480  // Edit picto
481  print '<td class="linecoledit center">';
482  $coldisplay++;
483  if (($line->info_bits & 2) == 2 || !empty($disableedit)) {
484  } else { ?>
485  <a class="editfielda reposition" href="<?php print $_SERVER["PHP_SELF"].'?id='.$this->id.'&action=editline&token='.newToken().'&lineid='.$line->id; ?>">
486  <?php print img_edit().'</a>';
487  }
488  print '</td>';
489 
490  // Delete picto
491  print '<td class="linecoldelete center">';
492  $coldisplay++;
493  if (!$situationinvoicelinewithparent && empty($disableremove)) { // For situation invoice, deletion is not possible if there is a parent company.
494  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=ask_deleteline&token='.newToken().'&lineid='.$line->id.'">';
495  print img_delete();
496  print '</a>';
497  }
498  print '</td>';
499 
500  // Move up-down picto
501  if ($num > 1 && $conf->browser->layout != 'phone' && ((property_exists($this, 'situation_counter') && $this->situation_counter == 1) || empty($this->situation_cycle_ref)) && empty($disablemove)) {
502  print '<td class="linecolmove tdlineupdown center">';
503  $coldisplay++;
504  if ($i > 0) { ?>
505  <a class="lineupdown" href="<?php print $_SERVER["PHP_SELF"].'?id='.$this->id.'&action=up&token='.newToken().'&rowid='.$line->id; ?>">
506  <?php print img_up('default', 0, 'imgupforline'); ?>
507  </a>
508  <?php }
509  if ($i < $num - 1) { ?>
510  <a class="lineupdown" href="<?php print $_SERVER["PHP_SELF"].'?id='.$this->id.'&action=down&token='.newToken().'&rowid='.$line->id; ?>">
511  <?php print img_down('default', 0, 'imgdownforline'); ?>
512  </a>
513  <?php }
514  print '</td>';
515  } else {
516  print '<td '.(($conf->browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'></td>';
517  $coldisplay++;
518  }
519 } else {
520  $colspan = 3;
521  if (isModEnabled('asset') && $object->element == 'invoice_supplier') {
522  $colspan++;
523  }
524  print '<td colspan="'.$colspan.'"></td>';
525  $coldisplay = $coldisplay + $colspan;
526 }
527 
528 if ($action == 'selectlines') { ?>
529  <td class="linecolcheck center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php print $i + 1; ?>]" value="<?php print $line->id; ?>" ></td>
530 <?php }
531 
532 print "</tr>\n";
533 
534 print "<!-- END PHP TEMPLATE objectline_view.tpl.php -->\n";
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition: card.php:58
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition: security.php:607
Class to manage accounting accounts.
Class to manage absolute discounts.
Class to manage predefined suppliers products.
const TYPE_PRODUCT
Regular product.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:745
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)
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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'.
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 dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
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:88
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:123
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:126