\n";
$stmtStockArticles = getStmtStockArticles ($stkIdCurrent, "1", "at.at_id ='" . $tmpAtId . "'", "stkat.stkat_itemquantity DESC") ;
$result = $db->query($stmtStockArticles);
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
// Only if the current article has to go out of the stock then split per stocks and check for quantities !!!
$tmpCount = 0; // Count number of stock areas the current article will be found
if ($outgoing) :
// Iterate all stocks having this current article of the whole bundle
// $tmpAtLeastOneStockHasEnoughQuantityOfRequestedQuantity = false;
// $tmpSumOfStkatItemQuantity = 0;
$tmpStockArticleArray = array();
while ($row = $result->fetch_assoc()):
$tmpStockArticleArray["stk_id"][$tmpCount] = $row["stk_id"];
$tmpStockArticleArray["stk_name"][$tmpCount] = $row["stk_name"];
$tmpStockArticleArray["stkat_itemquantity"][$tmpCount] = $row["stkat_itemquantity"];
// $tmpSumOfStkatItemQuantity += $row["stkat_itemquantity"];
// if (!$tmpAtLeastOneStockHasEnoughQuantityOfRequestedQuantity && $row["stkat_itemquantity"] >= $tmpQuantity) :
// $tmpAtLeastOneStockHasEnoughQuantityOfRequestedQuantity = true;
// endif;
$tmpCount++;
endwhile;
$result->free();
endif;
if ($incoming) :
// Get the free places of the target stock according to the current article
$stkQuantityFree = getFreeStkQuantity ($f_mv_stk_to, $tmpAtId, 0, "1");
// Number of articles matching number of stock areas
$atStkItemQuantity = getFieldValueFromId("article", "at_id", $tmpAtId, "at_stk_itemquantity");
$atStkAreaQuantity = getFieldValueFromId("article", "at_id", $tmpAtId, "at_stk_areaquantity");
endif;
// Iterate until the whole requested quantity can be disposed
$restOfItemQuantity = $tmpQuantity;
$count2 = max($count2, $tmpCount);
for ($j = 0; $j <= $tmpCount; $j++) :
$tmpStockFromForDispose = $f_mv_stk_from;
if ($outgoing) :
$tmpStockFromForDispose = $tmpStockArticleArray["stk_id"][$j];
endif;
$out .= "
\n";
$out .= " ";
$out .= " ";
$out .= " ";
// $out .= " ";
$out .= " ";
$quantityToBeDisposed = $tmpQuantity;
if ($outgoing):
$quantityToBeDisposed = $tmpStockArticleArray["stkat_itemquantity"][$j];
if ($j < $tmpCount):
$quantityToBeDisposed = min($restOfItemQuantity, $tmpStockArticleArray["stkat_itemquantity"][$j]);
endif;
endif;
if ($incoming) :
// Get the free places of the target stock according to the current article
$stkItemQuantityFree = getFreeStkQuantity($f_mv_stk_to, $tmpAtId, $quantityToBeDisposed, "2");
$stkQuantityNeeded = ceil(($quantityToBeDisposed * $atStkAreaQuantity) / $atStkItemQuantity);
// Sum up all quantities
$quantityStockSumNeeded += $stkQuantityNeeded;
if ($stkQuantityFree < $quantityStockSumNeeded) :
$quantityToBeDisposed = 0;
$displayBacklog = true;
endif;
endif;
if ($quantityToBeDisposed == "") : $quantityToBeDisposed = 0; endif;
$out .= " ";
$restOfItemQuantity = $restOfItemQuantity - $tmpStockArticleArray["stkat_itemquantity"][$j];
// If stock movement is an outgoing transaction then display available quantity (sum of stocks)
if ($outgoing && $j == $tmpCount) :
if ($restOfItemQuantity > 0) :
$out .= "" . getLngt("nicht verfügbar:") . " " . $restOfItemQuantity . " ";
$out .= "" . getLngt("von:") . " " . $tmpQuantity . " ";
$out .= "(" . $tmpQuantityOneBundle . " x " . $f_mv_stk_itemquantity . ") ";
endif;
endif;
if ($incoming && $displayBacklog) :
$out .= "" . getLngt("Überhang auf dem Ziellager:") . " " . abs($stkQuantityFree - $quantityStockSumNeeded) . " " . getLngt("Stellplätze") . " ";
endif;
$out .= "