$q .= " LIMIT " . strval(5 * $maxproducts);
 }
 $r = tep_db_query($q);
 while ($row = tep_db_fetch_array($r)) {
     $grab_article = false;
     $pid = $row['products_id'];
     $aid = $row['products_articles_id'];
     $is_best_product = $row['status'] == '1';
     $stock = $row['stock'] - $row['booking_active'];
     $stock_and_orders = $stock + $row['ordered'];
     if ($stock < 0) {
         $stock = 0;
     }
     if (!isset($p) || !is_object($p) || $p->id != $pid) {
         $p = new Product($pid);
         $is_in_ltf_col = $p->isLevellingProduct();
     }
     $image_html = $p->displayImage(IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1);
     $dioh = $p->getDIOH($aid, $stock);
     $dioh2 = $p->getDIOH($aid, $stock + $row['ordered']);
     $dioh_text = $p->displayDIOH($aid, $stock);
     $dioh2_text = $p->displayDIOH($aid, $stock_and_orders);
     $target = $p->getDIOHstockTarget($aid);
     $target_levelling = $p->getLevellingTarget($aid);
     $target_after_levelling = $p->getDIOHstockTargetAfterLevelling($aid);
     $missing = $target - $stock_and_orders;
     if ($missing < 0) {
         $missing = 0;
     }
     $missing_no_refill = $target - $stock;
     if ($missing_no_refill < 0) {