$selected_product = CValue::get('selected_product'); $product = new CProduct(); $category = new CProductCategory(); $total = null; $count = null; $where_or = array(); $order = 'name, code'; //FIXME: changer en seek if ($keywords) { foreach ($product->getSeekables() as $field => $spec) { $where_or[] = "`{$field}` LIKE '%{$keywords}%'"; } $where = array(); $where[] = implode(' OR ', $where_or); $where[] = "cancelled IS NULL OR cancelled = '0'"; $list_products = $product->loadList($where, $order, 20); $total = $product->countList($where); } else { if ($category_id == 0) { $list_products = $product->loadList(null, $order); } else { if ($category_id == -1) { $list_products = array(); } else { $category->load($category_id); $list_products = $category->loadBackRefs("products", $order); $total = count($list_products); } } } $count = count($list_products);
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');
continue; } $old_code = $_product->code; $dioptrie_sign = $matches[1] === "+" ? "1" : "2"; $_product->code = "2808" . $dioptrie_sign . $matches[2] . $matches[3]; CAppUI::stepAjax(" Conversion: \"{$old_code}\" => \"{$_product->code}\""); if ($msg = $_product->store()) { CAppUI::stepAjax("Problème dans la conversion :" . $msg, UI_MSG_WARNING); $errors++; } } // Implants ALCON SN60WF /////////////// $where = array(); $where["code"] = "LIKE 'SN60WF +%'"; $product = new CProduct(); $list_product = $product->loadList($where); CAppUI::stepAjax(count($list_product) . " produit(s) à remplacer (ALCON SN60WF)"); $errors = 0; foreach ($list_product as $_product) { if (!preg_match('/(SN60WF)\\ \\+([0123]\\d)(?:\\.([05]))?/', $_product->code, $matches)) { continue; } $old_code = $_product->code; $_product->code = $matches[1] . "." . $matches[2] . (isset($matches[3]) ? $matches[3] : "0"); CAppUI::stepAjax(" Conversion: \"{$old_code}\" => \"{$_product->code}\""); if ($msg = $_product->store()) { CAppUI::stepAjax("Problème dans la conversion :" . $msg, UI_MSG_WARNING); $errors++; } } CAppUI::stepAjax("Fin de conversion avec " . $errors . " erreurs", $errors ? UI_MSG_WARNING : UI_MSG_OK);