CValue::setSession("show_all", $show_all);
$where = array();
$where["name"] = $letter === "#" ? "RLIKE '^[^A-Z]'" : "LIKE '{$letter}%'";
if ($category_id) {
    $where['category_id'] = " = '{$category_id}'";
}
if ($societe_id) {
    $where['societe_id'] = " = '{$societe_id}'";
}
if ($keywords) {
    $where[] = "`code` LIKE '%{$keywords}%' OR \r\n              `name` LIKE '%{$keywords}%' OR \r\n              `classe_comptable` LIKE '%{$keywords}%' OR \r\n              `description` LIKE '%{$keywords}%'";
}
if (!$show_all) {
    $where[] = "cancelled = '0' OR cancelled IS NULL";
}
$orderby = 'name, code';
$product = new CProduct();
$total = $product->countList($where);
$list_products = $product->loadList($where, $orderby, intval($start) . "," . CAppUI::conf("dPstock CProduct pagination_size"));
foreach ($list_products as $prod) {
    $prod->loadRefs();
    $prod->getPendingOrderItems(false);
}
// Smarty template
$smarty = new CSmartyDP();
$smarty->assign('list_products', $list_products);
$smarty->assign('product_id', $product_id);
$smarty->assign('total', $total);
$smarty->assign('start', $start);
$smarty->assign('letter', $letter);
$smarty->display('inc_products_list.tpl');