2004-10-20 22:06:49 +02:00
< ? php
2014-10-02 09:30:31 +02:00
/* Copyright ( C ) 2001 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2016-09-12 00:15:27 +02:00
* Copyright ( C ) 2004 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2014 Regis Houssin < regis . houssin @ inodbox . com >
2015-08-01 14:29:32 +02:00
* Copyright ( C ) 2015 Juanjo Menent < jmenent @ 2 byte . es >
2020-03-01 14:45:51 +01:00
* Copyright ( C ) 2020 Tobias Sekan < tobias . sekan @ startmail . com >
2004-07-21 18:16:25 +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
2004-07-21 18:16:25 +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 />.
2004-07-21 18:16:25 +02:00
*/
2005-01-09 18:55:45 +01:00
2005-03-28 20:50:47 +02:00
/**
2014-09-18 20:33:37 +02:00
* \file htdocs / product / stock / list . php
2010-03-22 15:40:04 +01:00
* \ingroup stock
2014-09-17 15:24:01 +02:00
* \brief Page with warehouse and stock value
2010-03-22 15:40:04 +01:00
*/
2005-01-09 18:55:45 +01:00
2012-08-22 23:24:21 +02:00
require '../../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php' ;
2020-03-01 14:45:51 +01:00
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> categorie -> enabled )) {
2020-04-12 13:30:02 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcategory.class.php' ;
2020-03-01 14:45:51 +01:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
}
2004-07-21 18:16:25 +02:00
2018-05-26 23:52:52 +02:00
// Load translation files required by the page
2019-11-12 09:46:08 +01:00
$langs -> loadLangs ( array ( " stocks " , " other " ));
$action = GETPOST ( 'action' , 'aZ09' ) ? GETPOST ( 'action' , 'aZ09' ) : 'view' ; // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST ( 'massaction' , 'alpha' ); // The bulk action (combo box choice into lists)
$show_files = GETPOST ( 'show_files' , 'int' ); // Show files area generated by bulk actions ?
$confirm = GETPOST ( 'confirm' , 'alpha' ); // Result of a confirmation
$cancel = GETPOST ( 'cancel' , 'alpha' ); // We click on a Cancel button
$toselect = GETPOST ( 'toselect' , 'array' ); // Array of ids of elements selected into a list
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'stocklist' ; // To manage different context of search
$backtopage = GETPOST ( 'backtopage' , 'alpha' ); // Go back to a dedicated page
$optioncss = GETPOST ( 'optioncss' , 'aZ' ); // Option for the css output (always '' except when 'print')
2020-12-24 00:58:21 +01:00
$toselect = GETPOST ( 'toselect' , 'array' );
2019-11-12 09:46:08 +01:00
$search_all = trim (( GETPOST ( 'search_all' , 'alphanohtml' ) != '' ) ? GETPOST ( 'search_all' , 'alphanohtml' ) : GETPOST ( 'sall' , 'alphanohtml' ));
$search_ref = GETPOST ( " sref " , " alpha " ) ? GETPOST ( " sref " , " alpha " ) : GETPOST ( " search_ref " , " alpha " );
$search_label = GETPOST ( " snom " , " alpha " ) ? GETPOST ( " snom " , " alpha " ) : GETPOST ( " search_label " , " alpha " );
$search_status = GETPOST ( " search_status " , " int " );
2004-07-21 18:16:25 +02:00
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> categorie -> enabled )) {
2020-03-01 14:45:51 +01:00
$search_category_list = GETPOST ( " search_category_ " . Categorie :: TYPE_WAREHOUSE . " _list " , " array " );
2020-02-28 16:03:35 +01:00
}
2019-10-16 03:17:53 +02:00
// Load variable for pagination
2019-11-12 09:46:08 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2020-09-18 17:13:01 +02:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
2020-09-17 14:31:25 +02:00
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2020-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2021-02-26 14:25:17 +01:00
if ( empty ( $page ) || $page == - 1 || GETPOST ( 'button_search' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' ) || ( empty ( $toselect ) && $massaction === '0' )) {
$page = 0 ;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
2019-10-16 03:17:53 +02:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2021-02-26 14:25:17 +01:00
if ( ! $sortfield ) {
$sortfield = " t.ref " ;
}
if ( ! $sortorder ) {
$sortorder = " ASC " ;
}
2019-10-16 03:17:53 +02:00
2019-06-03 15:44:17 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new Entrepot ( $db );
$extrafields = new ExtraFields ( $db );
2021-11-30 16:35:46 +01:00
$diroutputmassaction = $conf -> stock -> dir_output . '/temp/massgeneration/' . $user -> id ;
2019-10-16 03:17:53 +02:00
$hookmanager -> initHooks ( array ( 'stocklist' ));
2019-06-03 15:44:17 +02:00
2019-10-16 03:17:53 +02:00
// Fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2019-10-16 03:17:53 +02:00
2019-11-12 09:46:08 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $object -> table_element , '' , 'search_' );
2019-06-03 15:44:17 +02:00
2020-04-10 01:22:22 +02:00
// Initialize array of search criterias
2020-08-28 21:27:50 +02:00
$search_all = GETPOST ( " search_all " , 'alpha' );
2020-04-25 13:52:07 +02:00
$search = array ();
2021-02-26 14:25:17 +01:00
foreach ( $object -> fields as $key => $val ) {
2020-08-07 15:11:36 +02:00
$search_key = $key ;
2021-02-26 14:25:17 +01:00
if ( $search_key == 'statut' ) {
$search_key = 'status' ; // remove this after refactor entrepot.class property statut to status
}
if ( GETPOST ( 'search_' . $search_key , 'alpha' ) !== '' ) {
$search [ $search_key ] = GETPOST ( 'search_' . $search_key , 'alpha' );
}
2020-04-10 01:22:22 +02:00
}
2021-02-02 02:24:21 +01:00
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array ();
2021-02-26 14:25:17 +01:00
foreach ( $object -> fields as $key => $val ) {
2021-06-14 01:55:58 +02:00
if ( ! empty ( $val [ 'searchall' ])) {
2021-02-26 14:25:17 +01:00
$fieldstosearchall [ 't.' . $key ] = $val [ 'label' ];
}
2019-10-16 03:17:53 +02:00
}
2021-02-02 02:24:21 +01:00
// Definition of array of fields for columns
$arrayfields = array (
'stockqty' => array ( 'type' => 'float' , 'label' => 'PhysicalStock' , 'enabled' => 1 , 'visible' =>- 2 , 'checked' => 0 , 'position' => 170 ),
'estimatedvalue' => array ( 'type' => 'float' , 'label' => 'EstimatedStockValue' , 'enabled' => 1 , 'visible' => 1 , 'checked' => 1 , 'position' => 171 ),
'estimatedstockvaluesell' => array ( 'type' => 'float' , 'label' => 'EstimatedStockValueSell' , 'enabled' => 1 , 'checked' => 1 , 'visible' => 2 , 'position' => 172 ),
);
foreach ( $object -> fields as $key => $val ) {
// If $val['visible']==0, then we never show the field
if ( ! empty ( $val [ 'visible' ])) {
2022-03-01 16:38:06 +01:00
$visible = ( int ) dol_eval ( $val [ 'visible' ], 1 , 1 , '1' );
2021-02-02 02:24:21 +01:00
$arrayfields [ 't.' . $key ] = array (
'label' => $val [ 'label' ],
'checked' => (( $visible < 0 ) ? 0 : 1 ),
2022-03-01 16:38:06 +01:00
'enabled' => ( $visible != 3 && dol_eval ( $val [ 'enabled' ], 1 , 1 , '1' )),
2021-02-02 02:24:21 +01:00
'position' => $val [ 'position' ],
2021-07-05 14:51:34 +02:00
'help' => isset ( $val [ 'help' ]) ? $val [ 'help' ] : 'help'
2021-02-02 02:24:21 +01:00
);
2019-10-16 03:17:53 +02:00
}
2019-06-03 15:44:17 +02:00
}
2021-02-02 02:24:21 +01:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php' ;
2019-10-16 03:17:53 +02:00
$object -> fields = dol_sort_array ( $object -> fields , 'position' );
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
2019-06-03 15:44:17 +02:00
2021-06-24 09:54:30 +02:00
// Security check
$result = restrictedArea ( $user , 'stock' );
2019-06-03 15:44:17 +02:00
2016-09-12 00:15:27 +02:00
/*
* Actions
*/
2021-02-26 14:25:17 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) {
$action = 'list' ; $massaction = '' ;
}
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) {
$massaction = '' ;
}
2019-10-16 03:17:53 +02:00
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 14:25:17 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2016-09-12 00:15:27 +02:00
2021-02-26 14:25:17 +01:00
if ( empty ( $reshook )) {
2019-10-16 03:17:53 +02:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
2021-02-26 14:25:17 +01:00
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) { // All tests are required to be compatible with all browsers
foreach ( $object -> fields as $key => $val ) {
2020-04-10 01:22:22 +02:00
$search [ $key ] = '' ;
}
2020-12-24 00:58:21 +01:00
$toselect = array ();
2020-04-10 01:22:22 +02:00
$search_array_options = array ();
2021-06-24 09:54:30 +02:00
$search_category_list = array ();
2019-10-16 03:17:53 +02:00
}
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )
2021-02-26 14:25:17 +01:00
|| GETPOST ( 'button_search_x' , 'alpha' ) || GETPOST ( 'button_search.x' , 'alpha' ) || GETPOST ( 'button_search' , 'alpha' )) {
2019-11-12 09:46:08 +01:00
$massaction = '' ; // Protection to avoid mass action if we force a new search during a mass action confirmation
2019-10-16 03:17:53 +02:00
}
// Mass actions
2019-11-12 09:46:08 +01:00
$objectclass = 'Entrepot' ;
$objectlabel = 'Warehouse' ;
2019-11-04 15:33:49 +01:00
$permissiontoread = $user -> rights -> stock -> lire ;
$permissiontodelete = $user -> rights -> stock -> supprimer ;
2020-12-24 00:58:21 +01:00
$permissiontoadd = $user -> rights -> stock -> creer ;
2019-10-16 03:17:53 +02:00
$uploaddir = $conf -> stock -> dir_output ;
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
2016-09-12 00:15:27 +02:00
}
2014-09-17 15:24:01 +02:00
/*
* View
*/
2019-11-12 09:46:08 +01:00
$form = new Form ( $db );
$warehouse = new Entrepot ( $db );
2015-04-12 17:08:14 +02:00
2019-11-12 09:46:08 +01:00
$now = dol_now ();
2019-10-16 03:17:53 +02:00
2019-11-12 09:46:08 +01:00
$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks' ;
2019-10-16 03:17:53 +02:00
$title = $langs -> trans ( " ListOfWarehouses " );
2021-10-31 13:56:19 +01:00
$totalarray = array ();
2021-12-01 15:24:25 +01:00
$totalarray [ 'nbfield' ] = 0 ;
2019-10-16 03:17:53 +02:00
// Build and execute select
// --------------------------------------------------------------------
2020-04-10 01:22:22 +02:00
$sql = 'SELECT ' ;
2021-02-26 14:25:17 +01:00
foreach ( $object -> fields as $key => $val ) {
2021-08-27 22:42:04 +02:00
$sql .= " t. " . $key . " , " ;
2020-04-10 01:22:22 +02:00
}
2019-06-03 15:44:17 +02:00
// Add fields from extrafields
2019-11-12 09:46:08 +01:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-02-26 14:25:17 +01:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) {
2021-08-27 22:42:04 +02:00
$sql .= ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $key ] != 'separate' ? " ef. " . $key . " as options_ " . $key . ', ' : '' );
2021-02-26 14:25:17 +01:00
}
2019-10-02 22:59:13 +02:00
}
2021-04-27 10:51:15 +02:00
//For Multicompany PMP per entity
$separatedPMP = false ;
if ( ! empty ( $conf -> global -> MULTICOMPANY_PRODUCT_SHARING_ENABLED ) && ! empty ( $conf -> global -> MULTICOMPANY_PMP_PER_ENTITY_ENABLED )) {
$separatedPMP = true ;
$sql .= " SUM(pa.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty " ;
} else {
$sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty " ;
}
2019-08-26 23:54:15 +02:00
// Add fields from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters , $object ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
$sql = preg_replace ( '/,\s*$/' , '' , $sql );
2020-04-10 01:22:22 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . $object -> table_element . " as t " ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> categorie -> enabled )) {
2020-04-10 01:22:22 +02:00
$sql .= Categorie :: getFilterJoinQuery ( Categorie :: TYPE_WAREHOUSE , " t.rowid " );
2020-02-28 16:03:35 +01:00
}
2021-11-30 16:35:46 +01:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && is_array ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-02-26 14:25:17 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object -> table_element . " _extrafields as ef on (t.rowid = ef.fk_object) " ;
}
2020-04-10 01:22:22 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product_stock as ps ON t.rowid = ps.fk_entrepot " ;
2019-11-12 09:46:08 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product as p ON ps.fk_product = p.rowid " ;
2020-04-10 01:22:22 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_departements as c_dep ON c_dep.rowid = t.fk_departement " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_country as ccount ON ccount.rowid = t.fk_pays " ;
2021-04-27 10:51:15 +02:00
if ( $separatedPMP ) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product_perentity as pa ON pa.fk_product = p.rowid AND pa.fk_product = ps.fk_product AND pa.entity = " . ( int ) $conf -> entity ;
}
2020-04-10 01:22:22 +02:00
$sql .= " WHERE t.entity IN ( " . getEntity ( 'stock' ) . " ) " ;
2021-04-27 10:51:15 +02:00
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> categorie -> enabled )) {
2020-04-10 01:22:22 +02:00
$sql .= Categorie :: getFilterSelectQuery ( Categorie :: TYPE_WAREHOUSE , " t.rowid " , $search_category_list );
}
2021-02-26 14:25:17 +01:00
foreach ( $search as $key => $val ) {
2020-08-07 15:11:36 +02:00
$class_key = $key ;
2021-02-26 14:25:17 +01:00
if ( $class_key == 'status' ) {
2021-06-24 09:54:30 +02:00
$class_key = 'statut' ; // remove this after refactoring entrepot.class property statut to status
2021-02-26 14:25:17 +01:00
}
if (( $key == 'status' && $search [ $key ] == - 1 ) || $key == 'entity' ) {
continue ;
}
2020-04-10 01:22:22 +02:00
$mode_search = (( $object -> isInt ( $object -> fields [ $key ]) || $object -> isFloat ( $object -> fields [ $key ])) ? 1 : 0 );
if ( strpos ( $object -> fields [ $key ][ 'type' ], 'integer:' ) === 0 ) {
2021-02-26 14:25:17 +01:00
if ( $search [ $key ] == '-1' ) {
$search [ $key ] = '' ;
}
2020-04-10 01:22:22 +02:00
$mode_search = 2 ;
}
2021-02-26 14:25:17 +01:00
if ( $search [ $key ] != '' ) {
2021-08-28 03:09:18 +02:00
$sql .= natural_search ((( $key == " ref " ) ? " t.ref " : " t. " . $class_key ), $search [ $key ], (( $key == 'status' ) ? 2 : $mode_search ));
2021-02-26 14:25:17 +01:00
}
}
if ( $search_all ) {
$sql .= natural_search ( array_keys ( $fieldstosearchall ), $search_all );
2020-02-28 16:03:35 +01:00
}
2019-06-03 15:44:17 +02:00
// Add where from extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php' ;
2019-08-26 23:54:15 +02:00
// Add where from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters , $object ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2020-04-25 13:52:07 +02:00
$sql .= " GROUP BY " ;
2021-02-26 14:25:17 +01:00
foreach ( $object -> fields as $key => $val ) {
2021-08-27 22:42:04 +02:00
$sql .= " t. " . $key . " , " ;
2020-04-10 01:22:22 +02:00
}
// Add fields from extrafields
2020-04-25 13:52:07 +02:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-02-26 14:25:17 +01:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) {
$sql .= ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $key ] != 'separate' ? " ef. " . $key . ', ' : '' );
}
2020-04-10 01:22:22 +02:00
}
// Add where from hooks
2020-04-25 13:52:07 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListGroupBy' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
$sql = preg_replace ( '/,\s*$/' , '' , $sql );
2019-11-12 09:46:08 +01:00
$totalnboflines = 0 ;
2021-04-27 10:51:15 +02:00
2019-11-12 09:46:08 +01:00
$result = $db -> query ( $sql );
2021-02-26 14:25:17 +01:00
if ( $result ) {
2020-04-10 01:21:59 +02:00
$totalnboflines = $db -> num_rows ( $result );
2016-01-13 16:33:51 +01:00
// fetch totals
$line = $total = $totalsell = $totalStock = 0 ;
2021-02-26 14:25:17 +01:00
while ( $line < $totalnboflines ) {
2016-01-13 16:33:51 +01:00
$objp = $db -> fetch_object ( $result );
2021-03-27 13:17:56 +01:00
$total += $objp -> estimatedvalue ;
$totalsell += $objp -> sellvalue ;
2016-01-13 16:33:51 +01:00
$totalStock += $objp -> stockqty ;
$line ++ ;
}
2021-03-27 13:17:56 +01:00
$totalarray [ 'val' ][ 'stockqty' ] = price2num ( $totalStock , 'MS' );
$totalarray [ 'val' ][ 'estimatedvalue' ] = price2num ( $total , 'MT' );
$totalarray [ 'val' ][ 'estimatedstockvaluesell' ] = price2num ( $totalsell , 'MT' );
2015-12-28 00:20:48 +01:00
}
2019-11-12 09:46:08 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2015-08-01 14:29:32 +02:00
2019-10-16 03:17:53 +02:00
// Count total nb of records
$nbtotalofrecords = '' ;
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST )) {
2019-10-16 03:17:53 +02:00
$resql = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $resql );
2021-02-26 14:25:17 +01:00
if (( $page * $limit ) > $nbtotalofrecords ) { // if total of record found is smaller than page * limit, goto and load page 0
2019-10-16 03:17:53 +02:00
$page = 0 ;
$offset = 0 ;
}
}
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
2021-06-24 09:54:30 +02:00
if ( is_numeric ( $nbtotalofrecords ) && ( $limit > $nbtotalofrecords || empty ( $limit ))) {
2019-10-16 03:17:53 +02:00
$num = $nbtotalofrecords ;
2020-05-21 15:05:19 +02:00
} else {
2021-06-24 09:54:30 +02:00
if ( $limit ) {
$sql .= $db -> plimit ( $limit + 1 , $offset );
}
2004-07-21 18:16:25 +02:00
2019-11-12 09:46:08 +01:00
$resql = $db -> query ( $sql );
2021-02-26 14:25:17 +01:00
if ( ! $resql ) {
2019-10-16 03:17:53 +02:00
dol_print_error ( $db );
exit ;
}
2004-07-21 18:16:25 +02:00
2019-10-16 03:17:53 +02:00
$num = $db -> num_rows ( $resql );
}
// Direct jump if only one record found
2021-06-24 09:54:30 +02:00
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && $search_all && ! $page ) {
2019-10-16 03:17:53 +02:00
$obj = $db -> fetch_object ( $resql );
$id = $obj -> rowid ;
header ( " Location: " . DOL_URL_ROOT . '/product/stock/card.php?id=' . $id );
exit ;
}
2004-07-21 18:16:25 +02:00
2017-08-02 13:31:53 +02:00
2019-10-16 03:17:53 +02:00
// Output page
// --------------------------------------------------------------------
2019-06-03 15:44:17 +02:00
2019-10-16 03:17:53 +02:00
llxHeader ( '' , $title , $help_url );
2018-03-30 16:54:38 +02:00
2019-11-12 09:46:08 +01:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2017-08-02 13:31:53 +02:00
2019-11-12 09:46:08 +01:00
$param = '' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . urlencode ( $contextpage );
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
$param .= '&limit=' . urlencode ( $limit );
}
foreach ( $search as $key => $val ) {
if ( is_array ( $search [ $key ]) && count ( $search [ $key ])) {
foreach ( $search [ $key ] as $skey ) {
$param .= '&search_' . $key . '[]=' . urlencode ( $skey );
}
} else {
$param .= '&search_' . $key . '=' . urlencode ( $search [ $key ]);
}
}
if ( $optioncss != '' ) {
$param .= '&optioncss=' . urlencode ( $optioncss );
}
2019-10-16 03:17:53 +02:00
// Add $param from extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
2017-08-02 13:31:53 +02:00
2019-10-16 03:17:53 +02:00
// List of mass actions available
2019-11-12 09:46:08 +01:00
$arrayofmassactions = array (
2021-04-14 12:28:01 +02:00
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
2019-10-16 03:17:53 +02:00
);
2021-04-14 14:45:55 +02:00
//if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
2021-02-26 14:25:17 +01:00
if ( GETPOST ( 'nomassaction' , 'int' ) || in_array ( $massaction , array ( 'presend' , 'predelete' , 'preaffecttag' ))) {
$arrayofmassactions = array ();
}
2022-09-23 11:46:55 +02:00
if ( isModEnabled ( 'category' ) && $user -> rights -> stock -> creer ) {
2021-04-14 12:28:01 +02:00
$arrayofmassactions [ 'preaffecttag' ] = img_picto ( '' , 'label' , 'class="pictofixedwidth"' ) . $langs -> trans ( " AffectTag " );
2021-02-26 14:25:17 +01:00
}
2019-11-12 09:46:08 +01:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2019-10-16 03:17:53 +02:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" id="searchFormList" method="POST" name="formulaire">' ;
2021-02-26 14:25:17 +01:00
if ( $optioncss != '' ) {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
}
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-10-16 03:17:53 +02:00
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
$newcardbutton = dolGetButtonTitle ( $langs -> trans ( 'MenuNewWarehouse' ), '' , 'fa fa-plus-circle' , DOL_URL_ROOT . '/product/stock/card.php?action=create&backtopage=' . urlencode ( $_SERVER [ 'PHP_SELF' ]), '' , $user -> rights -> stock -> creer );
2020-04-20 15:57:15 +02:00
print_barre_liste ( $title , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'stock' , 0 , $newcardbutton , '' , $limit , 0 , 0 , 1 );
2019-10-16 03:17:53 +02:00
// Add code for pre mass action (confirmation or email presend form)
2019-11-12 09:46:08 +01:00
$topicmail = " Information " ;
$modelmail = " warehouse " ;
$objecttmp = new Entrepot ( $db );
$trackid = 'ware' . $object -> id ;
2019-10-16 03:17:53 +02:00
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
2017-08-02 13:31:53 +02:00
2016-09-09 13:58:41 +02:00
2021-02-26 14:25:17 +01:00
if ( $search_all ) {
foreach ( $fieldstosearchall as $key => $val ) {
$fieldstosearchall [ $key ] = $langs -> trans ( $val );
}
2019-11-12 09:46:08 +01:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $sall ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
2019-10-16 03:17:53 +02:00
}
2006-08-13 16:37:56 +02:00
2019-10-16 03:17:53 +02:00
$moreforfilter = '' ;
2020-02-28 16:03:35 +01:00
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> categorie -> enabled ) && $user -> rights -> categorie -> lire ) {
2020-04-12 13:30:02 +02:00
$formcategory = new FormCategory ( $db );
2020-04-10 01:22:22 +02:00
$moreforfilter .= $formcategory -> getFilterBox ( Categorie :: TYPE_WAREHOUSE , $search_category_list );
2020-02-28 16:03:35 +01:00
}
2019-10-16 03:17:53 +02:00
/* $moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= $langs -> trans ( 'MyFilter' ) . ': <input type="text" name="search_myfield" value="' . dol_escape_htmltag ( $search_myfield ) . '">' ;
$moreforfilter .= '</div>' ; */
2015-06-30 13:14:19 +02:00
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2021-02-26 14:25:17 +01:00
if ( empty ( $reshook )) {
$moreforfilter .= $hookmanager -> resPrint ;
} else {
$moreforfilter = $hookmanager -> resPrint ;
}
2019-10-16 03:17:53 +02:00
2021-02-26 14:25:17 +01:00
if ( ! empty ( $moreforfilter )) {
2019-10-16 03:17:53 +02:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
print '</div>' ;
}
2015-06-30 13:14:19 +02:00
2019-11-12 09:46:08 +01:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
$selectedfields .= ( count ( $arrayofmassactions ) ? $form -> showCheckAddButtons ( 'checkforselect' , 1 ) : '' );
2015-06-30 13:14:19 +02:00
2021-06-24 09:54:30 +02:00
print '<div class="div-table-responsive">' ;
2020-03-27 16:02:58 +01:00
print '<table class="tagtable nobottomiftotal liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2015-06-30 13:14:19 +02:00
2019-10-16 03:17:53 +02:00
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre_filter">' ;
2019-06-03 15:44:17 +02:00
2021-02-26 14:25:17 +01:00
foreach ( $object -> fields as $key => $val ) {
if ( $key == 'statut' ) {
continue ;
}
2021-06-24 09:54:30 +02:00
$cssforfield = ( empty ( $val [ 'csslist' ]) ? ( empty ( $val [ 'css' ]) ? '' : $val [ 'css' ]) : $val [ 'csslist' ]);
2021-02-26 14:25:17 +01:00
if ( $key == 'status' ) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'center' ;
} elseif ( in_array ( $val [ 'type' ], array ( 'date' , 'datetime' , 'timestamp' ))) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'center' ;
} elseif ( in_array ( $val [ 'type' ], array ( 'timestamp' ))) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'nowrap' ;
2021-06-24 09:54:30 +02:00
} elseif ( in_array ( $val [ 'type' ], array ( 'double(24,8)' , 'double(6,3)' , 'integer' , 'real' , 'price' )) && $val [ 'label' ] != 'TechnicalID' && empty ( $val [ 'arrayofkeyval' ])) {
2021-02-26 14:25:17 +01:00
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'right' ;
}
if ( ! empty ( $arrayfields [ 't.' . $key ][ 'checked' ])) {
2020-04-06 13:08:03 +02:00
print '<td class="liste_titre' . ( $cssforfield ? ' ' . $cssforfield : '' ) . '">' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $val [ 'arrayofkeyval' ]) && is_array ( $val [ 'arrayofkeyval' ])) {
print $form -> selectarray ( 'search_' . $key , $val [ 'arrayofkeyval' ], $search [ $key ], $val [ 'notnull' ], 0 , 0 , '' , 1 , 0 , 0 , '' , 'maxwidth100' , 1 );
2021-06-24 09:54:30 +02:00
} elseif (( strpos ( $val [ 'type' ], 'integer:' ) === 0 ) || ( strpos ( $val [ 'type' ], 'sellist:' ) === 0 )) {
print $object -> showInputField ( $val , $key , $search [ $key ], '' , '' , 'search_' , 'maxwidth125' , 1 );
2021-02-26 14:25:17 +01:00
} elseif ( ! preg_match ( '/^(date|timestamp)/' , $val [ 'type' ])) {
2021-11-30 16:35:46 +01:00
print '<input type="text" class="flat maxwidth75" name="search_' . $key . '" value="' . dol_escape_htmltag ( ! empty ( $search [ $key ]) ? $search [ $key ] : '' ) . '">' ;
2021-02-26 14:25:17 +01:00
}
2020-04-06 13:08:03 +02:00
print '</td>' ;
}
2020-03-18 00:03:26 +01:00
}
2015-06-30 13:14:19 +02:00
2020-04-06 13:08:03 +02:00
if ( ! empty ( $arrayfields [ " stockqty " ][ 'checked' ])) {
2020-02-26 14:37:36 +01:00
print '<td class="liste_titre"></td>' ;
}
2015-06-30 13:14:19 +02:00
2020-04-06 13:08:03 +02:00
if ( ! empty ( $arrayfields [ " estimatedvalue " ][ 'checked' ])) {
2020-02-26 14:37:36 +01:00
print '<td class="liste_titre"></td>' ;
}
2020-04-06 13:08:03 +02:00
if ( ! empty ( $arrayfields [ " estimatedstockvaluesell " ][ 'checked' ])) {
2020-02-26 14:37:36 +01:00
print '<td class="liste_titre"></td>' ;
}
2017-08-02 13:31:53 +02:00
2019-10-16 03:17:53 +02:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
2020-04-10 01:22:22 +02:00
2019-10-16 03:17:53 +02:00
// Fields from hook
2019-11-12 09:46:08 +01:00
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2019-10-16 03:17:53 +02:00
print $hookmanager -> resPrint ;
// Status
2020-04-10 01:22:22 +02:00
if ( ! empty ( $arrayfields [ 't.statut' ][ 'checked' ])) {
2020-08-19 01:59:03 +02:00
print '<td class="liste_titre center">' ;
2020-02-26 14:37:36 +01:00
print $form -> selectarray ( 'search_status' , $warehouse -> statuts , $search_status , 1 , 0 , 0 , '' , 1 );
print '</td>' ;
}
2019-10-16 03:17:53 +02:00
// Action column
print '<td class="liste_titre maxwidthsearch">' ;
2019-11-12 09:46:08 +01:00
$searchpicto = $form -> showFilterButtons ();
2019-10-16 03:17:53 +02:00
print $searchpicto ;
print '</td>' ;
print '</tr>' . " \n " ;
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">' ;
2020-02-26 14:37:36 +01:00
2021-02-26 14:25:17 +01:00
foreach ( $object -> fields as $key => $val ) {
if ( $key == 'statut' ) {
continue ;
}
2021-06-24 09:54:30 +02:00
$cssforfield = ( empty ( $val [ 'csslist' ]) ? ( empty ( $val [ 'css' ]) ? '' : $val [ 'css' ]) : $val [ 'csslist' ]);
2021-02-26 14:25:17 +01:00
if ( $key == 'status' ) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'center' ;
} elseif ( in_array ( $val [ 'type' ], array ( 'date' , 'datetime' , 'timestamp' ))) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'center' ;
} elseif ( in_array ( $val [ 'type' ], array ( 'timestamp' ))) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'nowrap' ;
2021-06-24 09:54:30 +02:00
} elseif ( in_array ( $val [ 'type' ], array ( 'double(24,8)' , 'double(6,3)' , 'integer' , 'real' , 'price' )) && $val [ 'label' ] != 'TechnicalID' && empty ( $val [ 'arrayofkeyval' ])) {
2021-02-26 14:25:17 +01:00
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'right' ;
}
if ( ! empty ( $arrayfields [ 't.' . $key ][ 'checked' ])) {
2020-04-10 01:22:22 +02:00
print getTitleFieldOfList ( $arrayfields [ 't.' . $key ][ 'label' ], 0 , $_SERVER [ 'PHP_SELF' ], 't.' . $key , '' , $param , ( $cssforfield ? 'class="' . $cssforfield . '"' : '' ), $sortfield , $sortorder , ( $cssforfield ? $cssforfield . ' ' : '' )) . " \n " ;
2020-04-06 13:08:03 +02:00
}
2020-03-18 00:03:26 +01:00
}
2020-04-06 13:08:03 +02:00
if ( ! empty ( $arrayfields [ " stockqty " ][ 'checked' ])) {
print_liste_field_titre ( " PhysicalStock " , $_SERVER [ " PHP_SELF " ], " stockqty " , '' , $param , '' , $sortfield , $sortorder , 'right ' );
2020-02-26 14:37:36 +01:00
}
2020-04-06 13:08:03 +02:00
if ( ! empty ( $arrayfields [ " estimatedvalue " ][ 'checked' ])) {
print_liste_field_titre ( " EstimatedStockValue " , $_SERVER [ " PHP_SELF " ], " estimatedvalue " , '' , $param , '' , $sortfield , $sortorder , 'right ' );
2020-02-26 14:37:36 +01:00
}
2020-04-06 13:08:03 +02:00
if ( ! empty ( $arrayfields [ " estimatedstockvaluesell " ][ 'checked' ])) {
print_liste_field_titre ( " EstimatedStockValueSell " , $_SERVER [ " PHP_SELF " ], " " , '' , $param , '' , $sortfield , $sortorder , 'right ' );
2020-02-26 14:37:36 +01:00
}
2019-10-16 03:17:53 +02:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
2020-02-26 14:37:36 +01:00
2019-10-16 03:17:53 +02:00
// Hook fields
2019-11-12 09:46:08 +01:00
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2019-10-16 03:17:53 +02:00
print $hookmanager -> resPrint ;
2020-02-26 14:37:36 +01:00
2020-04-10 01:22:22 +02:00
if ( ! empty ( $arrayfields [ 't.statut' ][ 'checked' ])) {
2020-08-19 01:59:03 +02:00
print_liste_field_titre ( $arrayfields [ 't.statut' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.statut " , '' , $param , '' , $sortfield , $sortorder , 'center ' );
2020-02-26 16:53:58 +01:00
}
2019-10-16 03:17:53 +02:00
// Action column
print getTitleFieldOfList ( $selectedfields , 0 , $_SERVER [ " PHP_SELF " ], '' , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' ) . " \n " ;
print '</tr>' . " \n " ;
// Loop on record
// --------------------------------------------------------------------
2019-11-12 09:46:08 +01:00
$i = 0 ;
2019-10-16 03:17:53 +02:00
2021-06-24 09:54:30 +02:00
$warehouse = new Entrepot ( $db );
2020-02-26 14:37:36 +01:00
2021-06-24 09:54:30 +02:00
while ( $i < min ( $num , $limit )) {
$obj = $db -> fetch_object ( $resql );
if ( empty ( $obj )) {
break ; // Should not happen
}
2020-02-26 14:37:36 +01:00
2021-06-24 09:54:30 +02:00
// Store properties in $object
$warehouse -> setVarsFromFetchObj ( $obj );
2020-02-26 14:37:36 +01:00
2021-06-24 09:54:30 +02:00
$warehouse -> label = $warehouse -> ref ;
2019-10-16 03:17:53 +02:00
2021-06-24 09:54:30 +02:00
// Show here line of result
print '<tr class="oddeven">' ;
2020-03-18 01:24:40 +01:00
2021-06-24 09:54:30 +02:00
foreach ( $warehouse -> fields as $key => $val ) {
if ( $key == 'statut' ) {
continue ;
}
$cssforfield = ( empty ( $val [ 'csslist' ]) ? ( empty ( $val [ 'css' ]) ? '' : $val [ 'css' ]) : $val [ 'csslist' ]);
if ( in_array ( $val [ 'type' ], array ( 'date' , 'datetime' , 'timestamp' ))) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'center' ;
} elseif ( $key == 'status' ) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'center' ;
2020-03-18 00:03:26 +01:00
}
2021-06-24 09:54:30 +02:00
if ( in_array ( $val [ 'type' ], array ( 'timestamp' ))) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'nowrap' ;
} elseif ( $key == 'ref' ) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'nowrap' ;
2020-02-26 14:37:36 +01:00
}
2019-10-16 03:17:53 +02:00
2021-06-24 09:54:30 +02:00
if ( in_array ( $val [ 'type' ], array ( 'double(24,8)' , 'double(6,3)' , 'integer' , 'real' , 'price' )) && $key != 'status' && empty ( $val [ 'arrayofkeyval' ])) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'right' ;
}
if ( in_array ( $key , array ( 'fk_soc' , 'fk_user' , 'fk_warehouse' ))) {
$cssforfield = 'tdoverflowmax100' ;
2020-02-26 14:37:36 +01:00
}
2019-10-16 03:17:53 +02:00
2021-06-24 09:54:30 +02:00
if ( ! empty ( $arrayfields [ 't.' . $key ][ 'checked' ])) {
print '<td' . ( $cssforfield ? ' class="' . $cssforfield . '"' : '' ) . '>' ;
if ( $key == 'statut' ) {
print $warehouse -> getLibStatut ( 5 );
}
if ( $key == 'phone' ) {
print dol_print_phone ( $obj -> phone , '' , 0 , $obj -> rowid , 'AC_TEL' );
} elseif ( $key == 'fax' ) {
print dol_print_phone ( $obj -> fax , '' , 0 , $obj -> rowid , 'AC_FAX' );
2021-02-26 14:25:17 +01:00
} else {
2021-06-24 09:54:30 +02:00
print $warehouse -> showOutputField ( $val , $key , $warehouse -> $key , '' );
2020-02-26 14:37:36 +01:00
}
print '</td>' ;
2021-02-26 14:25:17 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-10-19 16:26:43 +02:00
if ( ! empty ( $val [ 'isameasure' ]) && $val [ 'isameasure' ] == 1 ) {
2021-06-24 09:54:30 +02:00
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 't.' . $key ;
}
if ( ! isset ( $totalarray [ 'val' ])) {
$totalarray [ 'val' ] = array ();
}
if ( ! isset ( $totalarray [ 'val' ][ 't.' . $key ])) {
$totalarray [ 'val' ][ 't.' . $key ] = 0 ;
}
$totalarray [ 'val' ][ 't.' . $key ] += $warehouse -> $key ;
2021-02-26 14:25:17 +01:00
}
2019-10-16 03:17:53 +02:00
}
2021-06-24 09:54:30 +02:00
}
2019-10-16 03:17:53 +02:00
2021-06-24 09:54:30 +02:00
// Stock qty
if ( ! empty ( $arrayfields [ " stockqty " ][ 'checked' ])) {
print '<td class="right">' . price2num ( $obj -> stockqty , 5 ) . '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 'stockqty' ;
}
}
2019-10-16 03:17:53 +02:00
2021-06-24 09:54:30 +02:00
// PMP value
if ( ! empty ( $arrayfields [ " estimatedvalue " ][ 'checked' ])) {
print '<td class="right">' ;
if ( price2num ( $obj -> estimatedvalue , 'MT' )) {
print '<span class="amount">' . price ( price2num ( $obj -> estimatedvalue , 'MT' ), 1 ) . '</span>' ;
} else {
print '' ;
}
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 'estimatedvalue' ;
2020-02-26 14:37:36 +01:00
}
2021-06-24 09:54:30 +02:00
}
2019-10-16 03:17:53 +02:00
2021-06-24 09:54:30 +02:00
// Selling value
if ( ! empty ( $arrayfields [ " estimatedstockvaluesell " ][ 'checked' ])) {
print '<td class="right">' ;
if ( empty ( $conf -> global -> PRODUIT_MULTIPRICES )) {
if ( $obj -> sellvalue ) {
print '<span class="amount">' . price ( price2num ( $obj -> sellvalue , 'MT' ), 1 ) . '</span>' ;
2021-02-26 14:25:17 +01:00
}
2021-06-24 09:54:30 +02:00
} else {
$htmltext = $langs -> trans ( " OptionMULTIPRICESIsOn " );
2022-05-19 12:16:18 +02:00
print $form -> textwithtooltip ( '<span class="opacitymedium">' . $langs -> trans ( " Variable " ) . '</span>' , $htmltext );
2006-08-13 16:37:56 +02:00
}
2019-10-16 03:17:53 +02:00
print '</td>' ;
2021-02-26 14:25:17 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-06-24 09:54:30 +02:00
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 'estimatedstockvaluesell' ;
}
}
2019-10-16 03:17:53 +02:00
2021-06-24 09:54:30 +02:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields , 'object' => $object , 'obj' => $obj , 'i' => $i , 'totalarray' =>& $totalarray );
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters , $object ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2019-10-16 03:17:53 +02:00
2021-06-24 09:54:30 +02:00
// Status
if ( ! empty ( $arrayfields [ 't.statut' ][ 'checked' ])) {
print '<td class="center">' . $warehouse -> LibStatut ( $obj -> statut , 5 ) . '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
}
2019-10-16 03:17:53 +02:00
2021-06-24 09:54:30 +02:00
// Action column
print '<td class="nowrap center">' ;
if ( $massactionbutton || $massaction ) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0 ;
if ( in_array ( $obj -> rowid , $arrayofselected )) {
$selected = 1 ;
}
print '<input id="cb' . $obj -> rowid . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj -> rowid . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
}
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
2019-10-16 03:17:53 +02:00
}
2014-09-17 15:24:01 +02:00
2021-06-24 09:54:30 +02:00
print '</tr>' . " \n " ;
$i ++ ;
}
if ( $totalnboflines - $offset <= $limit ) {
// Show total line
include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php' ;
}
// If no record found
if ( $num == 0 ) {
$colspan = 1 ;
foreach ( $arrayfields as $key => $val ) {
if ( ! empty ( $val [ 'checked' ])) {
$colspan ++ ;
}
2006-08-13 16:37:56 +02:00
}
2021-06-24 09:54:30 +02:00
print '<tr><td colspan="' . $colspan . '" class="opacitymedium">' . $langs -> trans ( " NoRecordFound " ) . '</td></tr>' ;
2019-10-16 03:17:53 +02:00
}
2006-08-13 16:37:56 +02:00
2019-10-16 03:17:53 +02:00
$db -> free ( $resql );
2006-08-13 16:37:56 +02:00
2019-11-12 09:46:08 +01:00
$parameters = array ( 'arrayfields' => $arrayfields , 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2019-10-16 03:17:53 +02:00
print $hookmanager -> resPrint ;
2017-08-02 13:31:53 +02:00
2019-10-16 03:17:53 +02:00
print '</table>' . " \n " ;
print '</div>' . " \n " ;
print '</form>' . " \n " ;
2021-02-26 14:25:17 +01:00
if ( in_array ( 'builddoc' , $arrayofmassactions ) && ( $nbtotalofrecords === '' || $nbtotalofrecords )) {
2019-11-12 09:46:08 +01:00
$hidegeneratedfilelistifempty = 1 ;
2021-02-26 14:25:17 +01:00
if ( $massaction == 'builddoc' || $action == 'remove_file' || $show_files ) {
$hidegeneratedfilelistifempty = 0 ;
}
2019-10-16 03:17:53 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
$formfile = new FormFile ( $db );
// Show list of available documents
2019-11-12 09:46:08 +01:00
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?sortfield=' . $sortfield . '&sortorder=' . $sortorder ;
$urlsource .= str_replace ( '&' , '&' , $param );
2019-10-16 03:17:53 +02:00
2019-11-12 09:46:08 +01:00
$filedir = $diroutputmassaction ;
2020-07-30 21:10:06 +02:00
$genallowed = $user -> rights -> stock -> lire ;
$delallowed = $user -> rights -> stock -> creer ;
2019-10-16 03:17:53 +02:00
2020-08-02 16:06:51 +02:00
print $formfile -> showdocuments ( 'massfilesarea_stock' , '' , $filedir , $urlsource , 0 , $delallowed , '' , 1 , 1 , 0 , 48 , 1 , $param , $title , '' , '' , '' , null , $hidegeneratedfilelistifempty );
2004-07-21 18:16:25 +02:00
}
2018-08-15 12:48:13 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2014-09-17 15:24:01 +02:00
$db -> close ();