objectline_view.tpl.php 23 KB

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