2019-05-22 20:28:24 +02:00
< ? php
/* Copyright ( C ) 2010 - 2013 Regis Houssin < regis . houssin @ inodbox . com >
* Copyright ( C ) 2010 - 2011 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2012 - 2013 Christophe Battarel < christophe . battarel @ altairis . fr >
* Copyright ( C ) 2012 Cédric Salvador < csalvador @ gpcsolutions . fr >
* Copyright ( C ) 2012 - 2014 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
* Copyright ( C ) 2013 Florian Henry < florian . henry @ open - concept . pro >
* Copyright ( C ) 2017 Juanjo Menent < jmenent @ 2 byte . es >
*
* 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
* the Free Software Foundation ; either version 3 of the License , or
* ( 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 />.
2019-05-22 20:28:24 +02:00
*
* Need to have following variables defined :
* $object ( invoice , order , ... )
* $conf
* $langs
* $forceall ( 0 by default , 1 for supplier invoices / orders )
* $element ( used to test $user -> rights -> $element -> creer )
* $permtoedit ( used to replace test $user -> rights -> $element -> creer )
* $inputalsopricewithtax ( 0 by default , 1 to also show column with unit price including tax )
* $object_rights -> creer initialized from = $object -> getRights ()
* $disableedit , $disablemove , $disableremove
*
* $type , $text , $description , $line
*/
// Protection to avoid direct call of template
2019-11-13 19:34:37 +01:00
if ( empty ( $object ) || ! is_object ( $object ))
2019-05-22 20:28:24 +02:00
{
print " Error, template page can't be called as URL " ;
exit ;
}
global $forceall , $senderissupplier , $inputalsopricewithtax , $outputalsopricetotalwithtax ;
2019-11-13 19:34:37 +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 ;
2019-05-22 20:28:24 +02: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 . '"' ;
2019-06-03 19:29:49 +02:00
// Lines for extrafield
2019-06-03 22:07:34 +02:00
$objectline = new BOMLine ( $object -> db );
2019-05-22 20:28:24 +02:00
2019-11-13 19:34:37 +01:00
$coldisplay = 0 ;
2019-10-20 11:17:54 +02:00
print " <!-- BEGIN PHP TEMPLATE objectline_view.tpl.php --> \n " ;
print '<tr id="row-' . $line -> id . '" class="drag drop oddeven" ' . $domData . ' >' ;
2019-11-13 19:34:37 +01:00
if ( ! empty ( $conf -> global -> MAIN_VIEW_LINE_NUMBER )) {
print '<td class="linecolnum center">' . ( $i + 1 ) . '</td>' ;
2019-10-20 11:17:54 +02:00
$coldisplay ++ ;
}
print '<td class="linecoldescription minwidth300imp">' ;
print '<div id="line_' . $line -> id . '"></div>' ;
$coldisplay ++ ;
$tmpproduct = new Product ( $object -> db );
$tmpproduct -> fetch ( $line -> fk_product );
print $tmpproduct -> getNomUrl ( 1 );
2019-12-01 17:45:01 +01:00
print ' - ' . $tmpproduct -> label ;
2019-10-20 11:17:54 +02:00
print '</td>' ;
print '<td class="linecolqty nowrap right">' ;
$coldisplay ++ ;
2019-11-13 19:34:37 +01:00
echo price ( $line -> qty , 0 , '' , 0 , 0 ); // Yes, it is a quantity, not a price, but we just want the formating role of function price
2019-10-20 11:17:54 +02:00
print '</td>' ;
2019-05-22 20:28:24 +02:00
2019-11-13 19:34:37 +01:00
if ( $conf -> global -> PRODUCT_USE_UNITS )
2019-10-20 11:17:54 +02:00
{
print '<td class="linecoluseunit nowrap left">' ;
$label = $line -> getLabelOfUnit ( 'short' );
if ( $label !== '' ) {
print $langs -> trans ( $label );
2019-05-22 20:28:24 +02:00
}
2019-10-20 11:17:54 +02:00
print '</td>' ;
}
2019-10-27 01:49:31 +02:00
print '<td class="linecolqtyfrozen nowrap right">' ;
$coldisplay ++ ;
echo $line -> qty_frozen ? yn ( $line -> qty_frozen ) : '' ;
print '</td>' ;
print '<td class="linecoldisablestockchange nowrap right">' ;
$coldisplay ++ ;
2020-04-10 10:59:32 +02:00
echo $line -> disable_stock_change ? yn ( $line -> disable_stock_change ) : '' ; // Yes, it is a quantity, not a price, but we just want the formating role of function price
2019-10-27 01:49:31 +02:00
print '</td>' ;
2020-02-28 16:12:42 +01:00
print '<td class="linecolefficiency nowrap right">' ;
$coldisplay ++ ;
echo $line -> efficiency ;
print '</td>' ;
2019-05-22 20:28:24 +02:00
2020-03-24 10:32:31 +01:00
print '<td class="linecolcost nowrap right">' ;
$coldisplay ++ ;
echo price ( $line -> total_cost );
print '</td>' ;
2020-04-10 10:59:32 +02:00
if ( $this -> status == 0 && ( $object_rights -> write ) && $action != 'selectlines' ) {
2019-10-21 15:02:06 +02:00
print '<td class="linecoledit center">' ;
$coldisplay ++ ;
2020-04-10 10:59:32 +02:00
if (( $line -> info_bits & 2 ) == 2 || ! empty ( $disableedit )) {
2019-05-22 20:28:24 +02:00
} else {
2020-07-09 16:25:51 +02:00
print '<a class="editfielda reposition" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $this -> id . '&action=editline&lineid=' . $line -> id . '">' . img_edit () . '</a>' ;
2019-05-22 20:28:24 +02:00
}
2019-10-20 11:17:54 +02:00
print '</td>' ;
2019-05-22 20:28:24 +02:00
2019-10-20 11:17:54 +02:00
print '<td class="linecoldelete center">' ;
$coldisplay ++ ;
2019-11-13 19:34:37 +01:00
if (( $line -> fk_prev_id == null ) && empty ( $disableremove )) {
2019-10-20 11:17:54 +02:00
//La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation
2020-03-31 17:45:45 +02:00
print '<a class="reposition" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $this -> id . '&action=deleteline&lineid=' . $line -> id . '">' ;
2019-10-20 11:17:54 +02:00
print img_delete ();
print '</a>' ;
}
print '</td>' ;
2019-05-22 20:28:24 +02:00
2019-10-20 11:17:54 +02:00
if ( $num > 1 && $conf -> browser -> layout != 'phone' && empty ( $disablemove )) {
print '<td class="linecolmove tdlineupdown center">' ;
$coldisplay ++ ;
if ( $i > 0 ) {
print '<a class="lineupdown" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $this -> id . '&action=up&rowid=' . $line -> id . '">' ;
echo img_up ( 'default' , 0 , 'imgupforline' );
print '</a>' ;
}
2019-11-13 19:34:37 +01:00
if ( $i < $num - 1 ) {
2019-10-20 11:17:54 +02:00
print '<a class="lineupdown" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $this -> id . '&action=down&rowid=' . $line -> id . '">' ;
echo img_down ( 'default' , 0 , 'imgdownforline' );
print '</a>' ;
}
print '</td>' ;
} else {
2019-11-13 19:34:37 +01:00
print '<td ' . (( $conf -> browser -> layout != 'phone' && empty ( $disablemove )) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"' ) . '></td>' ;
2019-10-20 11:17:54 +02:00
$coldisplay ++ ;
}
} else {
print '<td colspan="3"></td>' ;
2019-11-13 19:34:37 +01:00
$coldisplay = $coldisplay + 3 ;
2019-10-20 11:17:54 +02:00
}
if ( $action == 'selectlines' ) {
print '<td class="linecolcheck center">' ;
2019-11-13 19:34:37 +01:00
print '<input type="checkbox" class="linecheckbox" name="line_checkbox[' . ( $i + 1 ) . ']" value="' . $line -> id . '" >' ;
2019-10-20 11:17:54 +02:00
print '</td>' ;
}
print '</tr>' ;
2019-05-22 20:28:24 +02:00
//Line extrafield
2019-10-06 14:41:52 +02:00
if ( ! empty ( $extrafields ))
2019-05-22 20:28:24 +02:00
{
2020-02-21 14:32:23 +01:00
print $line -> showOptionals ( $extrafields , 'view' , array ( 'style' => 'class="drag drop oddeven"' , 'colspan' => $coldisplay ), '' , '' , 1 );
2019-05-22 20:28:24 +02:00
}
2019-10-20 11:17:54 +02:00
print " <!-- END PHP TEMPLATE objectline_view.tpl.php --> \n " ;