2010-09-08 18:09:59 +02:00
< ? php
2018-10-27 14:43:12 +02:00
/* Copyright ( C ) 2010 - 2013 Regis Houssin < regis . houssin @ inodbox . com >
2012-08-23 13:45:51 +02:00
* Copyright ( C ) 2010 - 2011 Laurent Destailleur < eldy @ users . sourceforge . net >
2013-10-30 18:17:37 +01:00
* Copyright ( C ) 2012 - 2013 Christophe Battarel < christophe . battarel @ altairis . fr >
2014-11-14 16:43:49 +01:00
* Copyright ( C ) 2012 Cédric Salvador < csalvador @ gpcsolutions . fr >
* Copyright ( C ) 2012 - 2014 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
2013-06-10 16:05:41 +02:00
* Copyright ( C ) 2013 Florian Henry < florian . henry @ open - concept . pro >
2017-08-30 14:36:00 +02:00
* Copyright ( C ) 2017 Juanjo Menent < jmenent @ 2 byte . es >
2022-02-14 04:52:39 +01:00
* Copyright ( C ) 2022 OpenDSI < support @ open - dsi . fr >
2010-09-08 18:09:59 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2010-09-08 18:09:59 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2010-09-08 18:09:59 +02:00
*
2014-08-30 20:36:53 +02:00
* Need to have following variables defined :
* $object ( invoice , order , ... )
* $conf
* $langs
* $dateSelector
* $forceall ( 0 by default , 1 for supplier invoices / orders )
2015-02-28 03:11:15 +01:00
* $element ( used to test $user -> rights -> $element -> creer )
* $permtoedit ( used to replace test $user -> rights -> $element -> creer )
2014-08-30 20:36:53 +02:00
* $senderissupplier ( 0 by default , 1 for supplier invoices / orders )
* $inputalsopricewithtax ( 0 by default , 1 to also show column with unit price including tax )
2019-06-11 21:02:41 +02:00
* $outputalsopricetotalwithtax
2015-02-27 18:05:12 +01:00
* $usemargins ( 0 to disable all margins columns , 1 to show according to margin setup )
2016-04-24 18:55:19 +02:00
* $object_rights -> creer initialized from = $object -> getRights ()
2016-04-26 22:00:41 +02:00
* $disableedit , $disablemove , $disableremove
2017-08-29 20:40:51 +02:00
*
2020-03-19 10:15:34 +01:00
* $text , $description , $line
2010-09-08 18:09:59 +02:00
*/
2014-08-30 20:36:53 +02:00
2017-12-21 13:32:16 +01:00
// Protection to avoid direct call of template
2021-02-23 22:03:23 +01:00
if ( empty ( $object ) || ! is_object ( $object )) {
2017-12-21 13:32:16 +01:00
print " Error, template page can't be called as URL " ;
exit ;
}
2020-04-21 14:14:49 +02:00
global $mysoc ;
2017-02-15 01:11:25 +01:00
global $forceall , $senderissupplier , $inputalsopricewithtax , $outputalsopricetotalwithtax ;
2015-03-04 17:54:43 +01:00
2019-11-13 19:35:39 +01:00
$usemargins = 0 ;
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> margin -> enabled ) && ! empty ( $object -> element ) && in_array ( $object -> element , array ( 'facture' , 'facturerec' , 'propal' , 'commande' ))) {
$usemargins = 1 ;
}
2014-08-30 20:36:53 +02:00
2021-02-23 22:03:23 +01:00
if ( empty ( $dateSelector )) {
$dateSelector = 0 ;
}
if ( empty ( $forceall )) {
$forceall = 0 ;
}
if ( empty ( $senderissupplier )) {
$senderissupplier = 0 ;
}
if ( empty ( $inputalsopricewithtax )) {
$inputalsopricewithtax = 0 ;
}
if ( empty ( $outputalsopricetotalwithtax )) {
$outputalsopricetotalwithtax = 0 ;
}
2017-02-15 01:11:25 +01:00
2018-02-20 17:46:32 +01:00
// add html5 elements
$domData = ' data-element="' . $line -> element . '"' ;
$domData .= ' data-id="' . $line -> id . '"' ;
$domData .= ' data-qty="' . $line -> qty . '"' ;
$domData .= ' data-product_type="' . $line -> product_type . '"' ;
2020-09-15 11:18:21 +02:00
$sign = 1 ;
2020-09-16 02:50:18 +02:00
if ( ! empty ( $conf -> global -> INVOICE_POSITIVE_CREDIT_NOTE_SCREEN ) && in_array ( $object -> element , array ( 'facture' , 'invoice_supplier' )) && $object -> type == $object :: TYPE_CREDIT_NOTE ) {
2020-09-15 11:18:21 +02:00
$sign = - 1 ;
}
2018-02-20 17:46:32 +01:00
2021-08-30 21:22:00 +02:00
2020-09-15 11:18:21 +02:00
$coldisplay = 0 ;
?>
2012-08-23 13:45:51 +02:00
<!-- BEGIN PHP TEMPLATE objectline_view . tpl . php -->
2020-01-20 12:25:25 +01:00
< tr id = " row-<?php print $line->id ?> " class = " drag drop oddeven " < ? php print $domData ; ?> >
2019-12-16 13:06:25 +01:00
< ? php if ( ! empty ( $conf -> global -> MAIN_VIEW_LINE_NUMBER )) { ?>
2020-11-30 18:28:04 +01:00
< td class = " linecolnum center " >< span class = " opacitymedium " >< ? php $coldisplay ++ ; ?> <?php print ($i + 1); ?></span></td>
2019-10-27 17:01:23 +01:00
< ? php } ?>
2020-01-20 12:25:25 +01:00
< td class = " linecoldescription minwidth300imp " >< ? php $coldisplay ++ ; ?> <div id="line_<?php print $line->id; ?>"></div>
2019-10-27 17:01:23 +01:00
< ? php
if (( $line -> info_bits & 2 ) == 2 ) {
2020-10-31 14:32:18 +01:00
print '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $this -> socid . '">' ;
2019-12-16 13:06:25 +01:00
$txt = '' ;
2019-10-27 17:01:23 +01:00
print img_object ( $langs -> trans ( " ShowReduc " ), 'reduc' ) . ' ' ;
2021-02-23 22:03:23 +01:00
if ( $line -> description == '(DEPOSIT)' ) {
$txt = $langs -> trans ( " Deposit " );
} elseif ( $line -> description == '(EXCESS RECEIVED)' ) {
$txt = $langs -> trans ( " ExcessReceived " );
} elseif ( $line -> description == '(EXCESS PAID)' ) {
$txt = $langs -> trans ( " ExcessPaid " );
}
2019-10-27 17:01:23 +01:00
//else $txt=$langs->trans("Discount");
print $txt ;
print '</a>' ;
2021-02-23 22:03:23 +01:00
if ( $line -> description ) {
if ( $line -> description == '(CREDIT_NOTE)' && $line -> fk_remise_except > 0 ) {
2021-03-03 22:46:25 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php' ;
2019-12-16 13:06:25 +01:00
$discount = new DiscountAbsolute ( $this -> db );
2019-10-27 17:01:23 +01:00
$discount -> fetch ( $line -> fk_remise_except );
2020-01-20 12:25:25 +01:00
print ( $txt ? ' - ' : '' ) . $langs -> transnoentities ( " DiscountFromCreditNote " , $discount -> getNomUrl ( 0 ));
2021-03-03 22:46:25 +01:00
} elseif ( $line -> description == '(DEPOSIT)' && $line -> fk_remise_except > 0 ) {
include_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php' ;
2019-12-16 13:06:25 +01:00
$discount = new DiscountAbsolute ( $this -> db );
2019-10-27 17:01:23 +01:00
$discount -> fetch ( $line -> fk_remise_except );
2020-01-20 12:25:25 +01:00
print ( $txt ? ' - ' : '' ) . $langs -> transnoentities ( " DiscountFromDeposit " , $discount -> getNomUrl ( 0 ));
2019-10-27 17:01:23 +01:00
// Add date of deposit
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> INVOICE_ADD_DEPOSIT_DATE )) {
2020-10-31 14:32:18 +01:00
print ' (' . dol_print_date ( $discount -> datec ) . ')' ;
2021-02-23 22:03:23 +01:00
}
2021-03-03 22:46:25 +01:00
} elseif ( $line -> description == '(EXCESS RECEIVED)' && $objp -> fk_remise_except > 0 ) {
include_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php' ;
2019-12-16 13:06:25 +01:00
$discount = new DiscountAbsolute ( $this -> db );
2019-10-27 17:01:23 +01:00
$discount -> fetch ( $line -> fk_remise_except );
2020-01-20 12:25:25 +01:00
print ( $txt ? ' - ' : '' ) . $langs -> transnoentities ( " DiscountFromExcessReceived " , $discount -> getNomUrl ( 0 ));
2021-02-23 22:03:23 +01:00
} elseif ( $line -> description == '(EXCESS PAID)' && $objp -> fk_remise_except > 0 ) {
2021-03-03 22:46:25 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php' ;
2019-12-16 13:06:25 +01:00
$discount = new DiscountAbsolute ( $this -> db );
2019-10-27 17:01:23 +01:00
$discount -> fetch ( $line -> fk_remise_except );
2020-01-20 12:25:25 +01:00
print ( $txt ? ' - ' : '' ) . $langs -> transnoentities ( " DiscountFromExcessPaid " , $discount -> getNomUrl ( 0 ));
2020-05-21 15:05:19 +02:00
} else {
2020-01-20 12:25:25 +01:00
print ( $txt ? ' - ' : '' ) . dol_htmlentitiesbr ( $line -> description );
2011-11-16 18:58:11 +01:00
}
2013-03-22 17:10:17 +01:00
}
2020-05-21 15:05:19 +02:00
} else {
2021-06-29 19:16:29 +02:00
$format = ( ! empty ( $conf -> global -> MAIN_USE_HOURMIN_IN_DATE_RANGE ) ? 'dayhour' : 'day' );
2019-10-06 14:41:52 +02:00
2021-01-07 12:39:51 +01:00
if ( $line -> fk_product > 0 ) {
2021-07-08 13:59:04 +02:00
print $form -> textwithtooltip ( $text , $description , 3 , 0 , '' , $i , 0 , ( ! empty ( $line -> fk_parent_line ) ? img_picto ( '' , 'rightarrow' ) : '' ));
2020-05-21 15:05:19 +02:00
} else {
2020-03-19 10:15:34 +01:00
$type = ( ! empty ( $line -> product_type ) ? $line -> product_type : $line -> fk_product_type );
2021-02-23 22:03:23 +01:00
if ( $type == 1 ) {
$text = img_object ( $langs -> trans ( 'Service' ), 'service' );
} else {
$text = img_object ( $langs -> trans ( 'Product' ), 'product' );
}
2019-10-27 17:01:23 +01:00
2019-12-16 13:06:25 +01:00
if ( ! empty ( $line -> label )) {
$text .= ' <strong>' . $line -> label . '</strong>' ;
2021-07-08 13:59:04 +02:00
print $form -> textwithtooltip ( $text , dol_htmlentitiesbr ( $line -> description ), 3 , 0 , '' , $i , 0 , ( ! empty ( $line -> fk_parent_line ) ? img_picto ( '' , 'rightarrow' ) : '' ));
2019-10-27 17:01:23 +01:00
} else {
2021-02-23 22:03:23 +01:00
if ( ! empty ( $line -> fk_parent_line )) {
print img_picto ( '' , 'rightarrow' );
}
2020-01-16 02:48:24 +01:00
if ( preg_match ( '/^\(DEPOSIT\)/' , $line -> description )) {
$newdesc = preg_replace ( '/^\(DEPOSIT\)/' , $langs -> trans ( " Deposit " ), $line -> description );
2020-01-20 12:25:25 +01:00
print $text . ' ' . dol_htmlentitiesbr ( $newdesc );
2020-05-21 15:05:19 +02:00
} else {
2020-01-20 12:25:25 +01:00
print $text . ' ' . dol_htmlentitiesbr ( $line -> description );
2020-01-16 02:48:24 +01:00
}
2019-10-27 17:01:23 +01:00
}
}
// Show date range
2022-02-07 14:34:27 +01:00
if ( $line -> element == 'facturedetrec' || $line -> element == 'invoice_supplier_det_rec' ) {
if ( $line -> element == 'invoice_supplier_det_rec' && $line -> product_type != Product :: TYPE_PRODUCT ) {
$line -> date_start_fill = $line -> date_start ;
$line -> date_end_fill = $line -> date_end ;
}
2021-02-23 22:03:23 +01:00
if ( $line -> date_start_fill || $line -> date_end_fill ) {
2021-09-19 19:25:38 +02:00
print '<div class="clearboth nowraponall daterangeofline-facturedetrec">' ;
2021-02-23 22:03:23 +01:00
}
if ( $line -> date_start_fill ) {
2022-03-22 11:47:25 +01:00
print '<span class="opacitymedium" title="' . dol_escape_htmltag ( $langs -> trans ( " AutoFillDateFrom " )) . '">' . $langs -> trans ( 'AutoFillDateFromShort' ) . ':</span> ' . yn ( $line -> date_start_fill );
2021-02-23 22:03:23 +01:00
}
if ( $line -> date_start_fill && $line -> date_end_fill ) {
print ' - ' ;
}
if ( $line -> date_end_fill ) {
2022-03-22 11:47:25 +01:00
print '<span class="opacitymedium" title="' . dol_escape_htmltag ( $langs -> trans ( " AutoFillDateTo " )) . '">' . $langs -> trans ( 'AutoFillDateToShort' ) . ':</span> ' . yn ( $line -> date_end_fill );
2021-02-23 22:03:23 +01:00
}
if ( $line -> date_start_fill || $line -> date_end_fill ) {
print '</div>' ;
}
2020-05-21 15:05:19 +02:00
} else {
2021-02-23 22:03:23 +01:00
if ( $line -> date_start || $line -> date_end ) {
2021-09-19 19:25:38 +02:00
print '<div class="clearboth nowraponall opacitymedium daterangeofline">' . get_date_range ( $line -> date_start , $line -> date_end , $format ) . '</div>' ;
2021-02-23 22:03:23 +01:00
}
2023-02-22 12:19:36 +01:00
2021-07-20 15:35:10 +02:00
if ( ! $line -> date_start || ! $line -> date_end ) {
2021-07-20 11:23:35 +02:00
// show warning under line
// we need to fetch product associated to line for some test
2023-02-22 12:19:36 +01:00
if ( $object -> element == 'propal' || $object -> element == 'order' || $object -> element == 'facture' || $object -> element == 'propal_supplier' || $object -> element == 'supplier_proposal' || $object -> element == 'commande' ) {
2021-07-21 08:31:07 +02:00
$res = $line -> fetch_product ();
if ( $res > 0 ) {
if ( $line -> product -> isService () && $line -> product -> isMandatoryPeriod ()) {
print '<div><span class="clearboth nowraponall warning">' . $langs -> trans ( " mandatoryPeriodNeedTobeSet " ) . '</span></div>' ;
}
2021-07-20 11:23:35 +02:00
}
}
2021-02-23 22:03:23 +01:00
}
2021-07-20 11:23:35 +02:00
2022-03-22 11:47:25 +01:00
// If we show the lines in a context to create a recurring sale invoice
if ( basename ( $_SERVER [ " PHP_SELF " ]) == 'card-rec.php' ) {
$default_start_fill = getDolGlobalInt ( 'INVOICEREC_SET_AUTOFILL_DATE_START' );
$default_end_fill = getDolGlobalInt ( 'INVOICEREC_SET_AUTOFILL_DATE_END' );
print '<div class="clearboth nowraponall daterangeofline-facturedetrec">' ;
print '<span class="opacitymedium" title="' . dol_escape_htmltag ( $langs -> trans ( " AutoFillDateFrom " )) . '">' . $langs -> trans ( 'AutoFillDateFromShort' ) . ':</span> ' . yn ( $default_start_fill );
print ' - ' ;
print '<span class="opacitymedium" title="' . dol_escape_htmltag ( $langs -> trans ( " AutoFillDateTo " )) . '">' . $langs -> trans ( 'AutoFillDateToShort' ) . ':</span> ' . yn ( $default_end_fill );
print '</div>' ;
}
2019-08-11 13:08:17 +02:00
}
2018-03-19 12:30:48 +01:00
2019-10-27 17:01:23 +01:00
// Add description in form
2021-02-23 22:03:23 +01:00
if ( $line -> fk_product > 0 && ! empty ( $conf -> global -> PRODUIT_DESC_IN_FORM )) {
2021-10-05 12:09:03 +02:00
if ( $line -> element == 'facturedetrec' ) {
print ( ! empty ( $line -> description ) && $line -> description != $line -> product_label ) ? (( $line -> date_start_fill || $line -> date_end_fill ) ? '' : '<br>' ) . '<br>' . dol_htmlentitiesbr ( $line -> description ) : '' ;
2022-02-07 14:34:27 +01:00
} elseif ( $line -> element == 'invoice_supplier_det_rec' ) {
print ( ! empty ( $line -> description ) && $line -> description != $line -> label ) ? (( $line -> date_start || $line -> date_end ) ? '' : '<br>' ) . '<br>' . dol_htmlentitiesbr ( $line -> description ) : '' ;
2021-10-05 12:09:03 +02:00
} else {
print ( ! empty ( $line -> description ) && $line -> description != $line -> product_label ) ? (( $line -> date_start || $line -> date_end ) ? '' : '<br>' ) . '<br>' . dol_htmlentitiesbr ( $line -> description ) : '' ;
}
2018-03-19 12:13:18 +01:00
}
2021-08-30 21:22:00 +02:00
// Line extrafield
2021-02-23 22:03:23 +01:00
if ( ! empty ( $extrafields )) {
2021-01-16 14:10:37 +01:00
$temps = $line -> showOptionals ( $extrafields , 'view' , array (), '' , '' , 1 , 'line' );
if ( ! empty ( $temps )) {
print '<div style="padding-top: 10px" id="extrafield_lines_area_' . $line -> id . '" name="extrafield_lines_area_' . $line -> id . '">' ;
print $temps ;
print '</div>' ;
}
2020-12-22 12:52:01 +01:00
}
2019-10-27 17:01:23 +01:00
}
2018-03-19 12:30:48 +01:00
2021-02-23 22:03:23 +01:00
if ( $user -> rights -> fournisseur -> lire && $line -> fk_fournprice > 0 && empty ( $conf -> global -> SUPPLIER_HIDE_SUPPLIER_OBJECTLINES )) {
2020-10-31 14:32:18 +01:00
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php' ;
2019-10-27 17:01:23 +01:00
$productfourn = new ProductFournisseur ( $this -> db );
$productfourn -> fetch_product_fournisseur_price ( $line -> fk_fournprice );
2020-01-20 12:25:25 +01:00
print '<div class="clearboth"></div>' ;
print '<span class="opacitymedium">' . $langs -> trans ( 'Supplier' ) . ' : </span>' . $productfourn -> getSocNomUrl ( 1 , 'supplier' ) . ' - <span class="opacitymedium">' . $langs -> trans ( 'Ref' ) . ' : </span>' ;
2019-10-27 17:01:23 +01:00
// Supplier ref
2021-02-23 22:03:23 +01:00
if ( $user -> rights -> produit -> creer || $user -> rights -> service -> creer ) { // change required right here
2020-01-20 12:25:25 +01:00
print $productfourn -> getNomUrl ();
2020-05-21 15:05:19 +02:00
} else {
2020-01-20 12:25:25 +01:00
print $productfourn -> ref_supplier ;
2019-10-27 17:01:23 +01:00
}
}
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> accounting -> enabled ) && $line -> fk_accounting_account > 0 ) {
2019-12-16 13:06:25 +01:00
$accountingaccount = new AccountingAccount ( $this -> db );
2019-10-27 17:01:23 +01:00
$accountingaccount -> fetch ( $line -> fk_accounting_account );
2020-01-20 12:25:25 +01:00
print '<div class="clearboth"></div><br><span class="opacitymedium">' . $langs -> trans ( 'AccountingAffectation' ) . ' : </span>' . $accountingaccount -> getNomUrl ( 0 , 1 , 1 );
2019-10-27 17:01:23 +01:00
}
print '</td>' ;
2023-01-06 12:08:40 +01:00
// Vendor price ref
2022-02-07 14:34:27 +01:00
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
2019-10-27 17:01:23 +01:00
print '<td class="linecolrefsupplier">' ;
2020-01-20 12:25:25 +01:00
print ( $line -> ref_fourn ? $line -> ref_fourn : $line -> ref_supplier );
2019-10-27 17:01:23 +01:00
print '</td>' ;
}
2023-01-06 12:08:40 +01:00
$tooltiponprice = '' ;
$tooltiponpriceend = '' ;
if ( empty ( $conf -> global -> MAIN_OPTIMIZEFORTEXTBROWSER )) {
$tooltiponprice = $langs -> transcountry ( " TotalHT " , $mysoc -> country_code ) . '=' . price ( $line -> total_ht );
$tooltiponprice .= '<br>' . $langs -> transcountry ( " TotalVAT " , ( $senderissupplier ? $object -> thirdparty -> country_code : $mysoc -> country_code )) . '=' . price ( $line -> total_tva );
$seller = ( $senderissupplier ? ( is_object ( $object -> thirdparty ) ? $object -> thirdparty : null ) : $mysoc );
if ( $seller ) {
if ( $seller -> useLocalTax ( 1 )) {
if (( $mysoc -> country_code == $object -> thirdparty -> country_code ) || $seller -> useLocalTax ( 1 )) {
$tooltiponprice .= '<br>' . $langs -> transcountry ( " TotalLT1 " , ( $senderissupplier ? $object -> thirdparty -> country_code : $mysoc -> country_code )) . '=' . price ( $line -> total_localtax1 );
} else {
$tooltiponprice .= '<br>' . $langs -> transcountry ( " TotalLT1 " , ( $senderissupplier ? $object -> thirdparty -> country_code : $mysoc -> country_code )) . '=<span class="opacitymedium">' . $langs -> trans ( " NotUsedForThis " . ( $senderissupplier ? " Vendor " : " Customer " )) . '</span>' ;
}
}
if ( $seller -> useLocalTax ( 2 )) {
if (( $mysoc -> country_code == $object -> thirdparty -> country_code ) || $seller -> useLocalTax ( 2 )) {
$tooltiponprice .= '<br>' . $langs -> transcountry ( " TotalLT2 " , ( $senderissupplier ? $object -> thirdparty -> country_code : $mysoc -> country_code )) . '=' . price ( $line -> total_localtax2 );
} else {
$tooltiponprice .= '<br>' . $langs -> transcountry ( " TotalLT2 " , ( $senderissupplier ? $object -> thirdparty -> country_code : $mysoc -> country_code )) . '=<span class="opacitymedium">' . $langs -> trans ( " NotUsedForThis " . ( $senderissupplier ? " Vendor " : " Customer " )) . '</span>' ;
}
}
}
$tooltiponprice .= '<br>' . $langs -> transcountry ( " TotalTTC " , $mysoc -> country_code ) . '=' . price ( $line -> total_ttc );
$tooltiponprice = '<span class="classfortooltip" title="' . dol_escape_htmltag ( $tooltiponprice ) . '">' ;
$tooltiponpriceend = '</span>' ;
}
2019-10-27 17:01:23 +01:00
// VAT Rate
print '<td class="linecolvat nowrap right">' ;
$coldisplay ++ ;
2019-12-16 13:06:25 +01:00
$positiverates = '' ;
2021-02-23 22:03:23 +01:00
if ( price2num ( $line -> tva_tx )) {
$positiverates .= ( $positiverates ? '/' : '' ) . price2num ( $line -> tva_tx );
}
if ( price2num ( $line -> total_localtax1 )) {
$positiverates .= ( $positiverates ? '/' : '' ) . price2num ( $line -> localtax1_tx );
}
if ( price2num ( $line -> total_localtax2 )) {
$positiverates .= ( $positiverates ? '/' : '' ) . price2num ( $line -> localtax2_tx );
}
if ( empty ( $positiverates )) {
$positiverates = '0' ;
}
2023-01-06 12:08:40 +01:00
print $tooltiponprice ;
2020-01-20 12:25:25 +01:00
print vatrate ( $positiverates . ( $line -> vat_src_code ? ' (' . $line -> vat_src_code . ')' : '' ), '%' , $line -> info_bits );
2023-01-06 12:08:40 +01:00
print $tooltiponpriceend ;
2019-10-27 17:01:23 +01:00
?> </td>
2010-09-18 16:44:57 +02:00
2020-09-15 11:18:21 +02:00
< td class = " linecoluht nowrap right " >< ? php $coldisplay ++ ; ?> <?php print price($sign * $line->subprice); ?></td>
2017-08-29 20:40:51 +02:00
2019-10-27 17:01:23 +01:00
< ? php if ( ! empty ( $conf -> multicurrency -> enabled ) && $this -> multicurrency_code != $conf -> currency ) { ?>
2020-09-15 11:18:21 +02:00
< td class = " linecoluht_currency nowrap right " >< ? php $coldisplay ++ ; ?> <?php print price($sign * $line->multicurrency_subprice); ?></td>
2019-10-27 17:01:23 +01:00
< ? php }
2017-08-29 20:40:51 +02:00
2019-10-27 17:01:23 +01:00
if ( $inputalsopricewithtax ) { ?>
2020-09-15 11:18:21 +02:00
< td class = " linecoluttc nowrap right " >< ? php $coldisplay ++ ; ?> <?php print (isset($line->pu_ttc) ? price($sign * $line->pu_ttc) : price($sign * $line->subprice)); ?></td>
2019-10-27 17:01:23 +01:00
< ? php } ?>
2012-08-22 17:42:40 +02:00
2019-01-20 23:36:39 +01:00
< td class = " linecolqty nowrap right " >< ? php $coldisplay ++ ; ?>
2019-10-27 17:01:23 +01:00
< ? php
if ((( $line -> info_bits & 2 ) != 2 ) && $line -> special_code != 3 ) {
// I comment this because it shows info even when not required
// 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
// must also not be output for most entities (proposal, intervention, ...)
//if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." ";
2020-01-20 12:25:25 +01:00
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
2021-02-23 22:03:23 +01:00
} else {
print ' ' ;
}
2019-10-27 17:01:23 +01:00
print '</td>' ;
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
2019-10-27 17:01:23 +01:00
print '<td class="linecoluseunit nowrap left">' ;
$label = $line -> getLabelOfUnit ( 'short' );
if ( $label !== '' ) {
print $langs -> trans ( $label );
2015-02-26 14:15:33 +01:00
}
2019-10-27 17:01:23 +01:00
print '</td>' ;
}
if ( ! empty ( $line -> remise_percent ) && $line -> special_code != 3 ) {
print '<td class="linecoldiscount right">' ;
$coldisplay ++ ;
include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
2020-01-20 12:25:25 +01:00
print dol_print_reduction ( $line -> remise_percent , $langs );
2019-10-27 17:01:23 +01:00
print '</td>' ;
} else {
print '<td class="linecoldiscount"> </td>' ;
$coldisplay ++ ;
}
2015-02-26 14:15:33 +01:00
2019-10-27 17:01:23 +01:00
// Fields for situation invoices
2021-06-29 16:37:07 +02:00
if ( isset ( $this -> situation_cycle_ref ) && $this -> situation_cycle_ref ) {
2020-10-31 14:32:18 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php' ;
2019-10-27 17:01:23 +01:00
$coldisplay ++ ;
2019-12-16 13:06:25 +01:00
print '<td class="linecolcycleref nowrap right">' . $line -> situation_percent . '%</td>' ;
2019-10-27 17:01:23 +01:00
$coldisplay ++ ;
2019-12-16 13:06:25 +01:00
$locataxes_array = getLocalTaxesFromRate ( $line -> tva . ( $line -> vat_src_code ? ' (' . $line -> vat_src_code . ')' : '' ), 0 , ( $senderissupplier ? $mysoc : $object -> thirdparty ), ( $senderissupplier ? $object -> thirdparty : $mysoc ));
$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 );
2020-09-15 11:18:21 +02:00
print '<td align="right" class="linecolcycleref2 nowrap">' . price ( $sign * $tmp [ 0 ]) . '</td>' ;
2019-10-27 17:01:23 +01:00
}
2019-04-30 18:11:35 +02:00
2021-02-23 22:03:23 +01:00
if ( $usemargins && ! empty ( $conf -> margin -> enabled ) && empty ( $user -> socid )) {
2019-10-27 17:01:23 +01:00
if ( ! empty ( $user -> rights -> margins -> creer )) { ?>
2020-01-20 12:25:25 +01:00
< td class = " linecolmargin1 nowrap margininfos right " >< ? php $coldisplay ++ ; ?> <?php print price($line->pa_ht); ?></td>
2019-10-27 17:01:23 +01:00
< ? php }
2019-12-16 13:06:25 +01:00
if ( ! empty ( $conf -> global -> DISPLAY_MARGIN_RATES ) && $user -> rights -> margins -> liretous ) { ?>
2020-01-20 12:25:25 +01:00
< td class = " linecolmargin2 nowrap margininfos right " >< ? php $coldisplay ++ ; ?> <?php print (($line->pa_ht == 0) ? 'n/a' : price(price2num($line->marge_tx, 'MT')).'%'); ?></td>
2019-10-27 17:01:23 +01:00
< ? php }
2020-10-31 14:32:18 +01:00
if ( ! empty ( $conf -> global -> DISPLAY_MARK_RATES ) && $user -> rights -> margins -> liretous ) { ?>
2021-02-23 22:03:23 +01:00
< td class = " linecolmargin2 nowrap margininfos right " >< ? php $coldisplay ++ ; ?> <?php print price(price2num($line->marque_tx, 'MT')).'%'; ?></td>
< ? php }
2019-10-27 17:01:23 +01:00
}
2023-01-06 12:08:40 +01:00
2020-09-15 11:18:21 +02:00
// Price total without tax
2019-12-16 13:06:25 +01:00
if ( $line -> special_code == 3 ) { ?>
2020-01-20 12:25:25 +01:00
< td class = " linecoloption nowrap right " >< ? php $coldisplay ++ ; ?> <?php print $langs->trans('Option'); ?></td>
2019-10-27 17:01:23 +01:00
< ? php } else {
print '<td class="linecolht nowrap right">' ;
$coldisplay ++ ;
2023-01-06 12:08:40 +01:00
print $tooltiponprice ;
2020-09-15 11:18:21 +02:00
print price ( $sign * $line -> total_ht );
2023-01-06 12:08:40 +01:00
print $tooltiponpriceend ;
2019-10-27 17:01:23 +01:00
print '</td>' ;
if ( ! empty ( $conf -> multicurrency -> enabled ) && $this -> multicurrency_code != $conf -> currency ) {
2020-09-15 11:18:21 +02:00
print '<td class="linecolutotalht_currency nowrap right">' . price ( $sign * $line -> multicurrency_total_ht ) . '</td>' ;
2019-04-30 18:11:35 +02:00
$coldisplay ++ ;
2014-11-14 16:43:49 +01:00
}
2019-10-27 17:01:23 +01:00
}
2023-01-06 12:08:40 +01:00
// Price inc tax
2019-10-27 17:01:23 +01:00
if ( $outputalsopricetotalwithtax ) {
2020-09-15 11:18:21 +02:00
print '<td class="linecolht nowrap right">' . price ( $sign * $line -> total_ttc ) . '</td>' ;
2019-10-27 17:01:23 +01:00
$coldisplay ++ ;
}
2014-11-14 16:43:49 +01:00
2021-07-05 17:08:10 +02:00
if ( $this -> statut == 0 && ! empty ( $object_rights -> creer ) && $action != 'selectlines' ) {
2021-07-01 13:36:04 +02:00
$situationinvoicelinewithparent = 0 ;
if ( $line -> fk_prev_id != null && in_array ( $object -> element , array ( 'facture' , 'facturedet' ))) {
if ( $object -> type == $object :: TYPE_SITUATION ) { // The constant TYPE_SITUATION exists only for object invoice
// Set constant to disallow editing during a situation cycle
$situationinvoicelinewithparent = 1 ;
}
}
2023-01-06 12:08:40 +01:00
// Asset info
2022-02-14 04:52:39 +01:00
if ( ! empty ( $conf -> asset -> enabled ) && $object -> element == 'invoice_supplier' ) {
print '<td class="linecolasset center">' ;
$coldisplay ++ ;
if ( ! empty ( $product_static -> accountancy_code_buy ) ||
! empty ( $product_static -> accountancy_code_buy_intra ) ||
! empty ( $product_static -> accountancy_code_buy_export )
) {
$accountancy_category_asset = $conf -> global -> ASSET_ACCOUNTANCY_CATEGORY ;
$filters = array ();
if ( ! empty ( $product_static -> accountancy_code_buy )) $filters [] = " account_number = ' " . $this -> db -> escape ( $product_static -> accountancy_code_buy ) . " ' " ;
if ( ! empty ( $product_static -> accountancy_code_buy_intra )) $filters [] = " account_number = ' " . $this -> db -> escape ( $product_static -> accountancy_code_buy_intra ) . " ' " ;
if ( ! empty ( $product_static -> accountancy_code_buy_export )) $filters [] = " account_number = ' " . $this -> db -> escape ( $product_static -> accountancy_code_buy_export ) . " ' " ;
$sql = " SELECT COUNT(*) AS found " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " accounting_account " ;
$sql .= " WHERE pcg_type = ' " . $this -> db -> escape ( $conf -> global -> ASSET_ACCOUNTANCY_CATEGORY ) . " ' " ;
$sql .= " AND ( " . implode ( ' OR ' , $filters ) . " ) " ;
$resql_asset = $this -> db -> query ( $sql );
if ( ! $resql_asset ) {
print 'Error SQL: ' . $this -> db -> lasterror ();
} elseif ( $obj = $this -> db -> fetch_object ( $resql_asset )) {
if ( ! empty ( $obj -> found )) {
print '<a class="reposition" href="' . DOL_URL_ROOT . '/asset/card.php?action=create&supplier_invoice_id=' . $object -> id . '&token=' . newToken () . '">' ;
print img_edit_add () . '</a>' ;
}
}
}
2022-02-14 04:56:45 +01:00
print '</td>' ;
2022-02-14 04:52:39 +01:00
}
2023-01-06 12:08:40 +01:00
// Edit picto
2019-10-27 17:01:23 +01:00
print '<td class="linecoledit center">' ;
$coldisplay ++ ;
2019-12-16 13:06:25 +01:00
if (( $line -> info_bits & 2 ) == 2 || ! empty ( $disableedit )) {
2019-10-27 17:01:23 +01:00
} else { ?>
2021-09-27 12:24:01 +02:00
< a class = " editfielda reposition " href = " <?php print $_SERVER["PHP_SELF"] .'?id='. $this->id .'&action=editline&token='.newToken().'&lineid='. $line->id .'#line_'. $line->id ; ?> " >
2020-01-20 12:25:25 +01:00
< ? php print img_edit () . '</a>' ;
2019-05-20 14:41:47 +02:00
}
2019-10-27 17:01:23 +01:00
print '</td>' ;
2023-01-06 12:08:40 +01:00
// Delete picto
2019-10-27 17:01:23 +01:00
print '<td class="linecoldelete center">' ;
$coldisplay ++ ;
2021-07-01 13:36:04 +02:00
if ( ! $situationinvoicelinewithparent && empty ( $disableremove )) { // For situation invoice, deletion is not possible if there is a parent company.
2021-09-27 12:24:01 +02:00
print '<a class="reposition" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $this -> id . '&action=ask_deleteline&token=' . newToken () . '&lineid=' . $line -> id . '">' ;
2019-10-27 17:01:23 +01:00
print img_delete ();
print '</a>' ;
}
print '</td>' ;
2010-09-18 16:44:57 +02:00
2023-01-06 12:08:40 +01:00
// Move up-down picto
2019-10-27 17:01:23 +01:00
if ( $num > 1 && $conf -> browser -> layout != 'phone' && ( $this -> situation_counter == 1 || ! $this -> situation_cycle_ref ) && empty ( $disablemove )) {
print '<td class="linecolmove tdlineupdown center">' ;
$coldisplay ++ ;
if ( $i > 0 ) { ?>
2021-09-27 12:24:01 +02:00
< a class = " lineupdown " href = " <?php print $_SERVER["PHP_SELF"] .'?id='. $this->id .'&action=up&token='.newToken().'&rowid='. $line->id ; ?> " >
2020-01-20 12:25:25 +01:00
< ? php print img_up ( 'default' , 0 , 'imgupforline' ); ?>
2019-05-20 14:41:47 +02:00
</ a >
2019-10-27 17:01:23 +01:00
< ? php }
2019-12-16 13:06:25 +01:00
if ( $i < $num - 1 ) { ?>
2021-09-27 12:24:01 +02:00
< a class = " lineupdown " href = " <?php print $_SERVER["PHP_SELF"] .'?id='. $this->id .'&action=down&token='.newToken().'&rowid='. $line->id ; ?> " >
2020-01-20 12:25:25 +01:00
< ? php print img_down ( 'default' , 0 , 'imgdownforline' ); ?>
2019-05-20 14:41:47 +02:00
</ a >
2019-10-27 17:01:23 +01:00
< ? php }
print '</td>' ;
2020-10-31 14:32:18 +01:00
} else {
2019-12-16 13:06:25 +01:00
print '<td ' . (( $conf -> browser -> layout != 'phone' && empty ( $disablemove )) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"' ) . '></td>' ;
2019-10-27 17:01:23 +01:00
$coldisplay ++ ;
}
} else {
print '<td colspan="3"></td>' ;
2019-12-16 13:06:25 +01:00
$coldisplay = $coldisplay + 3 ;
2019-10-27 17:01:23 +01:00
}
2019-05-20 14:41:47 +02:00
2019-10-27 17:01:23 +01:00
if ( $action == 'selectlines' ) { ?>
2020-01-20 12:25:25 +01:00
< td class = " linecolcheck center " >< input type = " checkbox " class = " linecheckbox " name = " line_checkbox[<?php print $i + 1; ?>] " value = " <?php print $line->id ; ?> " ></ td >
2019-10-27 17:01:23 +01:00
< ? php }
2010-09-08 18:09:59 +02:00
2019-10-27 17:01:23 +01:00
print " </tr> \n " ;
2018-03-20 10:10:21 +01:00
2019-10-27 17:01:23 +01:00
print " <!-- END PHP TEMPLATE objectline_view.tpl.php --> \n " ;