2004-10-20 22:06:49 +02:00
< ? php
2006-12-04 18:54:07 +01:00
/* Copyright ( C ) 2001 - 2006 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2011-04-18 10:38:51 +02:00
* Copyright ( C ) 2004 - 2011 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-12-30 15:13:49 +01:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
2013-12-15 18:44:53 +01:00
* Copyright ( C ) 2012 - 2013 Marcos García < marcosgdf @ gmail . com >
2013-02-22 08:57:28 +01:00
* Copyright ( C ) 2013 Juanjo Menent < jmenent @ 2 byte . es >
2013-03-15 15:33:49 +01:00
* Copyright ( C ) 2013 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
2013-05-24 22:39:28 +02:00
* Copyright ( C ) 2013 Jean Heimburger < jean @ tiaris . info >
2013-06-03 15:34:12 +02:00
* Copyright ( C ) 2013 Cédric Salvador < csalvador @ gpcsolutions . fr >
2013-12-24 16:28:27 +01:00
* Copyright ( C ) 2013 Florian Henry < florian . henry @ open - concept . pro >
* Copyright ( C ) 2013 Adolfo segura < adolfo . segura @ gmail . com >
2015-04-18 21:28:55 +02:00
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
2003-09-04 11:59: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
2003-09-04 11:59: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
2011-08-01 01:19:04 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2003-09-04 11:59:59 +02:00
*/
2004-10-23 01:34:25 +02:00
2005-01-19 22:40:03 +01:00
/**
2014-09-18 20:33:37 +02:00
* \file htdocs / product / list . php
2008-11-17 19:59:02 +01:00
* \ingroup produit
* \brief Page to list products and services
*/
2004-10-23 01:34:25 +02: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/class/product.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2012-07-24 17:52:46 +02:00
if ( ! empty ( $conf -> categorie -> enabled ))
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2003-09-04 11:59:59 +02:00
2010-05-02 19:05:07 +02:00
$langs -> load ( " products " );
2010-05-07 21:22:34 +02:00
$langs -> load ( " stocks " );
2013-06-19 09:26:20 +02:00
$langs -> load ( " suppliers " );
2004-08-13 23:25:54 +02:00
2011-08-23 00:07:09 +02:00
$action = GETPOST ( 'action' );
2010-11-10 20:47:03 +01:00
$sref = GETPOST ( " sref " );
$sbarcode = GETPOST ( " sbarcode " );
$snom = GETPOST ( " snom " );
$sall = GETPOST ( " sall " );
2010-11-10 21:16:31 +01:00
$type = GETPOST ( " type " , " int " );
2011-04-06 18:40:11 +02:00
$search_sale = GETPOST ( " search_sale " );
2011-08-21 12:12:18 +02:00
$search_categ = GETPOST ( " search_categ " , 'int' );
2011-04-18 10:38:51 +02:00
$tosell = GETPOST ( " tosell " );
$tobuy = GETPOST ( " tobuy " );
2011-08-21 12:12:18 +02:00
$fourn_id = GETPOST ( " fourn_id " , 'int' );
2012-07-24 17:52:46 +02:00
$catid = GETPOST ( 'catid' , 'int' );
2010-06-13 23:05:57 +02:00
2010-11-20 14:08:44 +01:00
$sortfield = GETPOST ( " sortfield " , 'alpha' );
$sortorder = GETPOST ( " sortorder " , 'alpha' );
$page = GETPOST ( " page " , 'int' );
if ( $page == - 1 ) { $page = 0 ; }
$offset = $conf -> liste_limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2005-08-24 23:06:25 +02:00
if ( ! $sortfield ) $sortfield = " p.ref " ;
2006-09-12 00:33:07 +02:00
if ( ! $sortorder ) $sortorder = " ASC " ;
2010-11-20 14:08:44 +01:00
2003-09-04 11:59:59 +02:00
$limit = $conf -> liste_limit ;
2004-10-31 17:02:47 +01:00
2010-02-27 18:30:17 +01:00
2011-04-06 18:40:11 +02:00
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
2012-07-24 17:52:46 +02:00
$canvas = GETPOST ( " canvas " );
2014-11-15 16:20:03 +01:00
$objcanvas = null ;
2011-04-06 18:40:11 +02:00
if ( ! empty ( $canvas ))
{
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php' ;
2011-04-06 18:40:11 +02:00
$objcanvas = new Canvas ( $db , $action );
2011-09-06 21:58:42 +02:00
$objcanvas -> getCanvas ( 'product' , 'list' , $canvas );
2011-04-06 18:40:11 +02:00
}
2010-03-16 21:05:44 +01:00
2011-09-13 14:00:37 +02:00
// Security check
if ( $type == '0' ) $result = restrictedArea ( $user , 'produit' , '' , '' , '' , '' , '' , $objcanvas );
else if ( $type == '1' ) $result = restrictedArea ( $user , 'service' , '' , '' , '' , '' , '' , $objcanvas );
else $result = restrictedArea ( $user , 'produit|service' , '' , '' , '' , '' , '' , $objcanvas );
2009-08-12 15:07:49 +02:00
2009-03-09 22:59:29 +01:00
/*
* Actions
*/
2014-11-22 15:52:08 +01:00
if ( GETPOST ( " button_removefilter_x " ) || GETPOST ( " button_removefilter " )) // Both test are required to be compatible with all browsers
2005-08-24 23:06:25 +02:00
{
2009-03-09 22:59:29 +01:00
$sref = " " ;
$sbarcode = " " ;
$snom = " " ;
2012-04-19 19:10:21 +02:00
$search_categ = 0 ;
2014-11-17 23:53:01 +01:00
$tosell = " " ;
$tobuy = " " ;
2004-10-31 17:02:47 +01:00
}
2009-08-12 15:07:49 +02:00
2004-08-13 23:25:54 +02:00
/*
2009-08-12 15:07:49 +02:00
* View
2004-08-13 23:25:54 +02:00
*/
2010-03-16 21:05:44 +01:00
$htmlother = new FormOther ( $db );
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2010-03-16 21:05:44 +01:00
2011-09-10 20:51:39 +02:00
if ( is_object ( $objcanvas ) && $objcanvas -> displayCanvasExists ( $action ))
2006-12-09 12:37:36 +01:00
{
2011-09-10 20:51:39 +02:00
$objcanvas -> assign_values ( 'list' ); // This must contains code to load data (must call LoadListDatas($limit, $offset, $sortfield, $sortorder))
$objcanvas -> display_canvas ( 'list' ); // This is code to show template
2006-12-09 12:37:36 +01:00
}
else
{
2009-03-09 22:59:29 +01:00
$title = $langs -> trans ( " ProductsAndServices " );
2006-12-09 12:37:36 +01:00
2012-07-24 17:52:46 +02:00
if ( isset ( $type ))
2009-03-09 22:59:29 +01:00
{
2010-03-22 17:58:14 +01:00
if ( $type == 1 )
{
$texte = $langs -> trans ( " Services " );
}
2010-05-02 19:05:07 +02:00
else
2010-03-22 17:58:14 +01:00
{
$texte = $langs -> trans ( " Products " );
}
}
else
{
2009-03-09 22:59:29 +01:00
$texte = $langs -> trans ( " ProductsAndServices " );
}
2014-11-23 01:20:02 +01:00
// Add what we are searching for
if ( ! empty ( $sall )) $texte .= " - " . $sall ;
2005-11-27 22:41:30 +01:00
2011-09-10 20:51:39 +02:00
$sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,' ;
$sql .= ' p.fk_product_type, p.tms as datem,' ;
2014-11-15 11:59:02 +01:00
$sql .= ' p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,' ;
2011-09-10 20:51:39 +02:00
$sql .= ' MIN(pfp.unitprice) as minsellprice' ;
2012-07-18 00:20:33 +02:00
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'product as p' ;
2012-07-24 17:52:46 +02:00
if ( ! empty ( $search_categ ) || ! empty ( $catid )) $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . " categorie_product as cp ON p.rowid = cp.fk_product " ; // We'll need this table joined to the select in order to filter by categ
2012-03-01 09:40:05 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product_fournisseur_price as pfp ON p.rowid = pfp.fk_product " ;
2013-12-24 16:28:27 +01:00
// multilang
2014-11-15 11:59:02 +01:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = ' " . $langs -> getDefaultLang () . " ' " ;
2013-09-10 16:43:06 +02:00
$sql .= ' WHERE p.entity IN (' . getEntity ( 'product' , 1 ) . ')' ;
2013-12-24 16:28:27 +01:00
if ( $sall )
{
2013-09-10 16:43:06 +02:00
// For natural search
$params = array ( 'p.ref' , 'p.label' , 'p.description' , 'p.note' );
2013-05-24 22:39:28 +02:00
// multilang
2014-11-15 11:59:02 +01:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS ))
2013-05-24 22:39:28 +02:00
{
2014-11-15 11:59:02 +01:00
$params [] = 'pl.label' ;
2013-09-10 16:43:06 +02:00
$params [] = 'pl.description' ;
$params [] = 'pl.note' ;
2013-05-24 22:39:28 +02:00
}
2013-09-10 16:43:06 +02:00
if ( ! empty ( $conf -> barcode -> enabled )) {
$params [] = 'p.barcode' ;
}
$sql .= natural_search ( $params , $sall );
}
2011-09-20 12:30:56 +02:00
// if the type is not 1, we show all products (type = 0,2,3)
2011-09-10 20:51:39 +02:00
if ( dol_strlen ( $type ))
{
if ( $type == 1 ) $sql .= " AND p.fk_product_type = '1' " ;
else $sql .= " AND p.fk_product_type <> '1' " ;
}
2013-12-24 16:28:27 +01:00
if ( $sref ) $sql .= natural_search ( 'p.ref' , $sref );
if ( $sbarcode ) $sql .= natural_search ( 'p.barcode' , $sbarcode );
2013-05-24 22:39:28 +02:00
if ( $snom )
{
2013-09-10 16:43:06 +02:00
$params = array ( 'p.label' );
2013-05-24 22:39:28 +02:00
// multilang
2014-11-15 11:59:02 +01:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS ))
2013-09-10 16:43:06 +02:00
{
$params [] = 'pl.label' ;
2013-05-24 22:39:28 +02:00
}
2013-09-10 16:43:06 +02:00
$sql .= natural_search ( $params , $snom );
}
2013-11-17 17:25:14 +01:00
if ( isset ( $tosell ) && dol_strlen ( $tosell ) > 0 && $tosell !=- 1 ) $sql .= " AND p.tosell = " . $db -> escape ( $tosell );
if ( isset ( $tobuy ) && dol_strlen ( $tobuy ) > 0 && $tobuy !=- 1 ) $sql .= " AND p.tobuy = " . $db -> escape ( $tobuy );
2012-07-18 00:20:33 +02:00
if ( dol_strlen ( $canvas ) > 0 ) $sql .= " AND p.canvas = ' " . $db -> escape ( $canvas ) . " ' " ;
if ( $catid > 0 ) $sql .= " AND cp.fk_categorie = " . $catid ;
2012-07-24 17:52:46 +02:00
if ( $catid == - 2 ) $sql .= " AND cp.fk_categorie IS NULL " ;
2012-07-18 00:20:33 +02:00
if ( $search_categ > 0 ) $sql .= " AND cp.fk_categorie = " . $search_categ ;
if ( $search_categ == - 2 ) $sql .= " AND cp.fk_categorie IS NULL " ;
2011-10-04 01:26:07 +02:00
if ( $fourn_id > 0 ) $sql .= " AND pfp.fk_soc = " . $fourn_id ;
2011-09-10 20:51:39 +02:00
$sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, " ;
$sql .= " p.fk_product_type, p.tms, " ;
$sql .= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte " ;
2013-05-31 11:13:16 +02:00
$sql .= ', p.desiredstock' ;
2011-09-10 20:51:39 +02:00
//if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte"; // Not used yet
2014-05-14 12:25:30 +02:00
2014-05-12 11:00:58 +02:00
$nbtotalofrecords = 0 ;
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST ))
{
$result = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $result );
}
2014-05-14 12:25:30 +02:00
2011-09-10 20:51:39 +02:00
$sql .= $db -> order ( $sortfield , $sortorder );
2012-01-22 21:17:02 +01:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2011-09-10 20:51:39 +02:00
2011-09-20 15:32:16 +02:00
$resql = $db -> query ( $sql );
2011-09-10 20:51:39 +02:00
if ( $resql )
{
$num = $db -> num_rows ( $resql );
$i = 0 ;
if ( $num == 1 && ( $sall || $snom || $sref || $sbarcode ) && $action != 'list' )
{
$objp = $db -> fetch_object ( $resql );
2014-09-18 21:18:25 +02:00
header ( " Location: card.php?id= " . $objp -> rowid );
2011-09-10 20:51:39 +02:00
exit ;
}
$helpurl = '' ;
2012-07-24 17:52:46 +02:00
if ( isset ( $type ))
2011-09-10 20:51:39 +02:00
{
2012-07-24 17:52:46 +02:00
if ( $type == 0 )
{
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos' ;
}
else if ( $type == 1 )
{
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios' ;
}
2011-09-10 20:51:39 +02:00
}
llxHeader ( '' , $title , $helpurl , '' );
// Displays product removal confirmation
2014-07-20 02:32:13 +02:00
if ( GETPOST ( 'delprod' )) {
setEventMessage ( $langs -> trans ( " ProductDeleted " , GETPOST ( 'delprod' )));
}
2011-09-10 20:51:39 +02:00
$param = " &sref= " . $sref . ( $sbarcode ? " &sbarcode= " . $sbarcode : " " ) . " &snom= " . $snom . " &sall= " . $sall . " &tosell= " . $tosell . " &tobuy= " . $tobuy ;
$param .= ( $fourn_id ? " &fourn_id= " . $fourn_id : " " );
2012-04-19 19:10:21 +02:00
$param .= ( $search_categ ? " &search_categ= " . $search_categ : " " );
2011-09-10 20:51:39 +02:00
$param .= isset ( $type ) ? " &type= " . $type : " " ;
2014-05-14 12:25:30 +02:00
2015-04-18 20:33:18 +02:00
print_barre_liste ( $texte , $page , " list.php " , $param , $sortfield , $sortorder , '' , $num , $nbtotalofrecords , 'title_products.png' );
2011-09-10 20:51:39 +02:00
2012-07-24 17:52:46 +02:00
if ( ! empty ( $catid ))
2011-09-10 20:51:39 +02:00
{
print " <div id='ways'> " ;
2012-07-24 17:52:46 +02:00
$c = new Categorie ( $db );
2014-09-18 20:33:37 +02:00
$ways = $c -> print_all_ways ( ' > ' , 'product/list.php' );
2011-09-10 20:51:39 +02:00
print " > " . $ways [ 0 ] . " <br> \n " ;
print " </div><br> " ;
}
2012-07-24 17:52:46 +02:00
if ( ! empty ( $canvas ) && file_exists ( DOL_DOCUMENT_ROOT . '/product/canvas/' . $canvas . '/actions_card_' . $canvas . '.class.php' ))
2011-09-10 20:51:39 +02:00
{
$fieldlist = $object -> field_list ;
$datas = $object -> list_datas ;
$picto = 'title.png' ;
$title_picto = img_picto ( '' , $picto );
$title_text = $title ;
// Default templates directory
2012-07-24 17:52:46 +02:00
$template_dir = DOL_DOCUMENT_ROOT . '/product/canvas/' . $canvas . '/tpl/' ;
2011-09-10 20:51:39 +02:00
// Check if a custom template is present
2012-07-24 17:52:46 +02:00
if ( file_exists ( DOL_DOCUMENT_ROOT . '/theme/' . $conf -> theme . '/tpl/product/' . $canvas . '/list.tpl.php' ))
2011-09-10 20:51:39 +02:00
{
2012-07-24 17:52:46 +02:00
$template_dir = DOL_DOCUMENT_ROOT . '/theme/' . $conf -> theme . '/tpl/product/' . $canvas . '/' ;
2011-09-10 20:51:39 +02:00
}
2012-08-23 02:04:35 +02:00
include $template_dir . 'list.tpl.php' ; // Include native PHP templates
2011-09-10 20:51:39 +02:00
}
else
{
2014-03-05 11:22:01 +01:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="post" name="formulaire">' ;
2011-09-10 20:51:39 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
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="type" value="' . $type . '">' ;
print '<table class="liste" width="100%">' ;
// Filter on categories
$moreforfilter = '' ;
2013-11-22 11:45:42 +01:00
$colspan = 6 ;
if ( ! empty ( $conf -> barcode -> enabled )) $colspan ++ ;
if ( ! empty ( $conf -> service -> enabled ) && $type != 0 ) $colspan ++ ;
if ( empty ( $conf -> global -> PRODUIT_MULTIPRICES )) $colspan ++ ;
if ( $user -> rights -> fournisseur -> lire ) $colspan ++ ;
if ( ! empty ( $conf -> stock -> enabled ) && $user -> rights -> stock -> lire && $type != 1 ) $colspan += 2 ;
2014-03-05 11:22:01 +01:00
2012-07-24 17:52:46 +02:00
if ( ! empty ( $conf -> categorie -> enabled ))
2011-09-10 20:51:39 +02:00
{
$moreforfilter .= $langs -> trans ( 'Categories' ) . ': ' ;
2012-07-18 00:20:33 +02:00
$moreforfilter .= $htmlother -> select_categories ( 0 , $search_categ , 'search_categ' , 1 );
2011-09-10 20:51:39 +02:00
$moreforfilter .= ' ' ;
}
if ( $moreforfilter )
{
print '<tr class="liste_titre">' ;
2013-11-22 11:45:42 +01:00
print '<td class="liste_titre" colspan="' . $colspan . '">' ;
2011-09-10 20:51:39 +02:00
print $moreforfilter ;
print '</td></tr>' ;
}
// Lignes des titres
2013-11-22 11:45:42 +01:00
print '<tr class="liste_titre">' ;
2011-09-10 20:51:39 +02:00
print_liste_field_titre ( $langs -> trans ( " Ref " ), $_SERVER [ " PHP_SELF " ], " p.ref " , $param , " " , " " , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " Label " ), $_SERVER [ " PHP_SELF " ], " p.label " , $param , " " , " " , $sortfield , $sortorder );
2012-07-24 17:52:46 +02:00
if ( ! empty ( $conf -> barcode -> enabled )) print_liste_field_titre ( $langs -> trans ( " BarCode " ), $_SERVER [ " PHP_SELF " ], " p.barcode " , $param , '' , '' , $sortfield , $sortorder );
2011-09-10 20:51:39 +02:00
print_liste_field_titre ( $langs -> trans ( " DateModification " ), $_SERVER [ " PHP_SELF " ], " p.tms " , $param , " " , 'align="center"' , $sortfield , $sortorder );
2012-07-24 17:52:46 +02:00
if ( ! empty ( $conf -> service -> enabled ) && $type != 0 ) print_liste_field_titre ( $langs -> trans ( " Duration " ), $_SERVER [ " PHP_SELF " ], " p.duration " , $param , " " , 'align="center"' , $sortfield , $sortorder );
2011-09-10 20:51:39 +02:00
if ( empty ( $conf -> global -> PRODUIT_MULTIPRICES )) print_liste_field_titre ( $langs -> trans ( " SellingPrice " ), $_SERVER [ " PHP_SELF " ], " p.price " , $param , " " , 'align="right"' , $sortfield , $sortorder );
2013-11-22 11:45:42 +01:00
if ( $user -> rights -> fournisseur -> lire ) print '<td class="liste_titre" align="right">' . $langs -> trans ( " BuyingPriceMinShort " ) . '</td>' ;
2013-05-31 11:13:16 +02:00
if ( ! empty ( $conf -> stock -> enabled ) && $user -> rights -> stock -> lire && $type != 1 ) print '<td class="liste_titre" align="right">' . $langs -> trans ( " DesiredStock " ) . '</td>' ;
2012-07-24 17:52:46 +02:00
if ( ! empty ( $conf -> stock -> enabled ) && $user -> rights -> stock -> lire && $type != 1 ) print '<td class="liste_titre" align="right">' . $langs -> trans ( " PhysicalStock " ) . '</td>' ;
2013-11-17 17:25:14 +01:00
print_liste_field_titre ( $langs -> trans ( " Sell " ), $_SERVER [ " PHP_SELF " ], " p.tosell " , $param , " " , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " Buy " ), $_SERVER [ " PHP_SELF " ], " p.tobuy " , $param , " " , 'align="center"' , $sortfield , $sortorder );
print '<td width="1%"> </td>' ;
2011-09-10 20:51:39 +02:00
print " </tr> \n " ;
// Lignes des champs de filtre
print '<tr class="liste_titre">' ;
print '<td class="liste_titre" align="left">' ;
print '<input class="flat" type="text" name="sref" size="8" value="' . $sref . '">' ;
print '</td>' ;
print '<td class="liste_titre" align="left">' ;
print '<input class="flat" type="text" name="snom" size="12" value="' . $snom . '">' ;
print '</td>' ;
2014-09-09 14:51:29 +02:00
// Barcode
2012-07-24 17:52:46 +02:00
if ( ! empty ( $conf -> barcode -> enabled ))
2011-09-10 20:51:39 +02:00
{
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="sbarcode" size="6" value="' . $sbarcode . '">' ;
print '</td>' ;
}
2014-09-09 14:51:29 +02:00
// Date modification
2011-09-10 20:51:39 +02:00
print '<td class="liste_titre">' ;
print ' ' ;
print '</td>' ;
2006-12-09 11:11:31 +01:00
2011-09-10 20:51:39 +02:00
// Duration
2012-07-24 17:52:46 +02:00
if ( ! empty ( $conf -> service -> enabled ) && $type != 0 )
2011-09-10 20:51:39 +02:00
{
print '<td class="liste_titre">' ;
print ' ' ;
print '</td>' ;
}
2008-05-31 19:44:38 +02:00
2011-09-10 20:51:39 +02:00
// Sell price
if ( empty ( $conf -> global -> PRODUIT_MULTIPRICES ))
{
print '<td class="liste_titre">' ;
print ' ' ;
print '</td>' ;
}
2006-12-09 12:01:22 +01:00
2011-09-10 20:51:39 +02:00
// Minimum buying Price
2013-11-22 11:45:42 +01:00
if ( $user -> rights -> fournisseur -> lire ) {
2013-09-06 10:49:18 +02:00
print '<td class="liste_titre">' ;
print ' ' ;
print '</td>' ;
}
2008-03-12 22:36:54 +01:00
2011-09-10 20:51:39 +02:00
// Stock
2012-07-24 17:52:46 +02:00
if ( ! empty ( $conf -> stock -> enabled ) && $user -> rights -> stock -> lire && $type != 1 )
2011-09-10 20:51:39 +02:00
{
print '<td class="liste_titre">' ;
print ' ' ;
print '</td>' ;
2013-05-31 11:13:16 +02:00
//desiredstock
print '<td class="liste_titre">' ;
print ' ' ;
print '</td>' ;
2011-09-10 20:51:39 +02:00
}
2010-05-07 21:22:34 +02:00
2014-03-05 11:22:01 +01:00
print '<td align="center">' ;
2013-11-17 17:25:14 +01:00
print $form -> selectarray ( 'tosell' , array ( '0' => $langs -> trans ( 'ProductStatusNotOnSellShort' ), '1' => $langs -> trans ( 'ProductStatusOnSellShort' )), $tosell , 1 );
print '</td >' ;
2014-03-05 11:22:01 +01:00
2013-11-17 17:25:14 +01:00
print '<td align="center">' ;
print $form -> selectarray ( 'tobuy' , array ( '0' => $langs -> trans ( 'ProductStatusNotOnBuyShort' ), '1' => $langs -> trans ( 'ProductStatusOnBuyShort' )), $tobuy , 1 );
2011-09-10 20:51:39 +02:00
print '</td>' ;
2011-09-10 19:52:21 +02:00
2014-09-09 14:51:29 +02:00
print '<td class="liste_titre nowrap" align="right">' ;
2014-01-13 10:15:07 +01:00
print '<input type="image" class="liste_titre" name="button_search" src="' . img_picto ( $langs -> trans ( " Search " ), 'search.png' , '' , '' , 1 ) . '" value="' . dol_escape_htmltag ( $langs -> trans ( " Search " )) . '" title="' . dol_escape_htmltag ( $langs -> trans ( " Search " )) . '">' ;
2014-11-17 23:53:01 +01:00
print '<input type="image" class="liste_titre" name="button_removefilter" src="' . img_picto ( $langs -> trans ( " RemoveFilter " ), 'searchclear.png' , '' , '' , 1 ) . '" value="' . dol_escape_htmltag ( $langs -> trans ( " RemoveFilter " )) . '" title="' . dol_escape_htmltag ( $langs -> trans ( " RemoveFilter " )) . '">' ;
2011-09-10 20:51:39 +02:00
print '</td>' ;
print '</tr>' ;
2011-09-10 19:52:21 +02:00
2010-03-16 21:05:44 +01:00
2011-09-10 20:51:39 +02:00
$product_static = new Product ( $db );
$product_fourn = new ProductFournisseur ( $db );
2011-05-14 00:04:52 +02:00
2011-09-10 20:51:39 +02:00
$var = true ;
while ( $i < min ( $num , $limit ))
{
$objp = $db -> fetch_object ( $resql );
2011-05-14 00:04:52 +02:00
2011-09-10 20:51:39 +02:00
// Multilangs
2012-07-24 17:52:46 +02:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) // si l'option est active
2011-09-10 20:51:39 +02:00
{
$sql = " SELECT label " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " product_lang " ;
$sql .= " WHERE fk_product= " . $objp -> rowid ;
$sql .= " AND lang=' " . $langs -> getDefaultLang () . " ' " ;
$sql .= " LIMIT 1 " ;
$result = $db -> query ( $sql );
if ( $result )
{
$objtp = $db -> fetch_object ( $result );
2012-07-24 17:52:46 +02:00
if ( ! empty ( $objtp -> label )) $objp -> label = $objtp -> label ;
2011-09-10 20:51:39 +02:00
}
}
2011-05-14 00:04:52 +02:00
2011-09-10 20:51:39 +02:00
$var =! $var ;
print '<tr ' . $bc [ $var ] . '>' ;
2011-08-21 02:26:31 +02:00
2011-09-10 20:51:39 +02:00
// Ref
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2011-09-10 20:51:39 +02:00
$product_static -> id = $objp -> rowid ;
$product_static -> ref = $objp -> ref ;
2015-01-24 15:36:47 +01:00
$product_static -> label = $objp -> label ;
2011-09-10 20:51:39 +02:00
$product_static -> type = $objp -> fk_product_type ;
print $product_static -> getNomUrl ( 1 , '' , 24 );
print " </td> \n " ;
2011-05-14 00:04:52 +02:00
2011-09-10 20:51:39 +02:00
// Label
print '<td>' . dol_trunc ( $objp -> label , 40 ) . '</td>' ;
2011-05-14 00:04:52 +02:00
2011-09-10 20:51:39 +02:00
// Barcode
2012-07-24 17:52:46 +02:00
if ( ! empty ( $conf -> barcode -> enabled ))
2011-09-10 20:51:39 +02:00
{
2011-10-01 12:48:31 +02:00
print '<td>' . $objp -> barcode . '</td>' ;
2011-09-10 20:51:39 +02:00
}
2009-03-09 22:59:29 +01:00
2014-05-25 04:34:04 +02:00
// Modification Date
2011-09-10 20:51:39 +02:00
print '<td align="center">' . dol_print_date ( $db -> jdate ( $objp -> datem ), 'day' ) . " </td> \n " ;
2009-03-09 22:59:29 +01:00
2011-09-10 20:51:39 +02:00
// Duration
2012-07-24 17:52:46 +02:00
if ( ! empty ( $conf -> service -> enabled ) && $type != 0 )
2011-09-10 20:51:39 +02:00
{
print '<td align="center">' ;
2014-05-26 01:14:15 +02:00
if ( preg_match ( '/([0-9]+)[a-z]/i' , $objp -> duration ))
{
if ( preg_match ( '/([0-9]+)y/i' , $objp -> duration , $regs )) print $regs [ 1 ] . ' ' . $langs -> trans ( " DurationYear " );
elseif ( preg_match ( '/([0-9]+)m/i' , $objp -> duration , $regs )) print $regs [ 1 ] . ' ' . $langs -> trans ( " DurationMonth " );
elseif ( preg_match ( '/([0-9]+)w/i' , $objp -> duration , $regs )) print $regs [ 1 ] . ' ' . $langs -> trans ( " DurationWeek " );
elseif ( preg_match ( '/([0-9]+)d/i' , $objp -> duration , $regs )) print $regs [ 1 ] . ' ' . $langs -> trans ( " DurationDay " );
//elseif (preg_match('/([0-9]+)h/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationHour");
else print $objp -> duration ;
}
2011-09-10 20:51:39 +02:00
print '</td>' ;
}
2009-03-09 22:59:29 +01:00
2011-09-10 20:51:39 +02:00
// Sell price
if ( empty ( $conf -> global -> PRODUIT_MULTIPRICES ))
{
print '<td align="right">' ;
2015-02-23 23:15:41 +01:00
if ( $objp -> tosell )
{
if ( $objp -> price_base_type == 'TTC' ) print price ( $objp -> price_ttc ) . ' ' . $langs -> trans ( " TTC " );
else print price ( $objp -> price ) . ' ' . $langs -> trans ( " HT " );
}
2011-09-10 20:51:39 +02:00
print '</td>' ;
}
2008-11-17 19:59:02 +01:00
2011-09-10 20:51:39 +02:00
// Better buy price
2014-10-15 15:24:31 +02:00
if ( $user -> rights -> fournisseur -> lire )
2014-05-25 04:34:04 +02:00
{
2013-09-06 10:49:18 +02:00
print '<td align="right">' ;
2015-02-23 23:15:41 +01:00
if ( $objp -> tobuy && $objp -> minsellprice != '' )
2013-09-06 10:49:18 +02:00
{
//print price($objp->minsellprice).' '.$langs->trans("HT");
if ( $product_fourn -> find_min_price_product_fournisseur ( $objp -> rowid ) > 0 )
{
if ( $product_fourn -> product_fourn_price_id > 0 )
{
2015-04-08 12:44:11 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && $user -> rights -> fournisseur -> lire )
{
$htmltext = $product_fourn -> display_price_product_fournisseur ( 1 , 1 , 0 , 1 );
print $form -> textwithpicto ( price ( $product_fourn -> fourn_unitprice ) . ' ' . $langs -> trans ( " HT " ), $htmltext );
}
2013-09-06 10:49:18 +02:00
else print price ( $product_fourn -> fourn_unitprice ) . ' ' . $langs -> trans ( " HT " );
}
}
}
print '</td>' ;
}
2011-09-10 20:51:39 +02:00
// Show stock
2012-07-24 17:52:46 +02:00
if ( ! empty ( $conf -> stock -> enabled ) && $user -> rights -> stock -> lire && $type != 1 )
2011-08-21 12:12:18 +02:00
{
2011-09-10 20:51:39 +02:00
if ( $objp -> fk_product_type != 1 )
{
$product_static -> id = $objp -> rowid ;
$product_static -> load_stock ();
2013-05-31 11:13:16 +02:00
print '<td align="right">' ;
print $objp -> desiredstock ;
print '</td>' ;
2011-09-10 20:51:39 +02:00
print '<td align="right">' ;
if ( $product_static -> stock_reel < $objp -> seuil_stock_alerte ) print img_warning ( $langs -> trans ( " StockTooLow " )) . ' ' ;
print $product_static -> stock_reel ;
print '</td>' ;
}
else
{
2014-05-25 04:34:04 +02:00
print '<td>' ;
print ' ' ;
print '</td>' ;
print '<td>' ;
print ' ' ;
print '</td>' ;
2011-09-10 20:51:39 +02:00
}
2011-08-21 12:12:18 +02:00
}
2011-08-21 02:26:31 +02:00
2014-10-18 16:36:28 +02:00
$product_static -> status_buy = $objp -> tobuy ;
$product_static -> status = $objp -> tosell ;
2011-09-10 20:51:39 +02:00
// Status (to sell)
2014-11-06 20:04:51 +01:00
print '<td align="center" nowrap="nowrap">' ;
2014-11-24 01:16:26 +01:00
if ( ! empty ( $conf -> use_javascript_ajax ) && $user -> rights -> produit -> creer && ! empty ( $conf -> global -> MAIN_DIRECT_STATUS_UPDATE )) {
2014-10-18 22:51:24 +02:00
print ajax_object_onoff ( $product_static , 'status' , 'tosell' , 'ProductStatusOnSell' , 'ProductStatusNotOnSell' );
2014-10-18 16:36:28 +02:00
} else {
print $product_static -> LibStatut ( $objp -> tosell , 5 , 0 );
}
print '</td>' ;
// Status (to buy)
2014-11-06 20:04:51 +01:00
print '<td align="center" nowrap="nowrap">' ;
2014-11-24 01:16:26 +01:00
if ( ! empty ( $conf -> use_javascript_ajax ) && $user -> rights -> produit -> creer && ! empty ( $conf -> global -> MAIN_DIRECT_STATUS_UPDATE )) {
2014-10-18 22:51:24 +02:00
print ajax_object_onoff ( $product_static , 'status_buy' , 'tobuy' , 'ProductStatusOnBuy' , 'ProductStatusNotOnBuy' );
2014-10-18 16:36:28 +02:00
} else {
print $product_static -> LibStatut ( $objp -> tobuy , 5 , 1 );
}
print '</td>' ;
2009-03-09 22:59:29 +01:00
2013-11-17 17:25:14 +01:00
print '<td> </td>' ;
2014-03-05 11:22:01 +01:00
2011-09-10 20:51:39 +02:00
print " </tr> \n " ;
$i ++ ;
}
2009-03-09 22:59:29 +01:00
2013-02-21 14:29:06 +01:00
$param = " &sref= " . $sref . ( $sbarcode ? " &sbarcode= " . $sbarcode : " " ) . " &snom= " . $snom . " &sall= " . $sall . " &tosell= " . $tosell . " &tobuy= " . $tobuy ;
$param .= ( $fourn_id ? " &fourn_id= " . $fourn_id : " " );
$param .= ( $search_categ ? " &search_categ= " . $search_categ : " " );
$param .= isset ( $type ) ? " &type= " . $type : " " ;
2014-09-18 20:33:37 +02:00
print_barre_liste ( '' , $page , " list.php " , $param , $sortfield , $sortorder , '' , $num , $nbtotalofrecords );
2013-05-29 01:30:36 +02:00
2011-09-10 20:51:39 +02:00
$db -> free ( $resql );
print " </table> " ;
print '</form>' ;
}
}
else
{
dol_print_error ( $db );
}
2005-11-27 22:41:30 +01:00
}
2003-09-04 11:59:59 +02:00
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-07-24 17:52:46 +02:00
$db -> close ();