$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) {
     $missing_no_refill = 0;
 }
 $missing_after_levelling = $target_after_levelling - $stock_and_orders;
 if ($missing_after_levelling < 0) {
     $missing_after_levelling = 0;
 }
 $missing_after_levelling_no_refill = $target_after_levelling - $stock;
 if ($missing_after_levelling_no_refill < 0) {