" . "stkIdRoot: " . $stkIdRoot . "
" . "stkIdCurrent: " . $stkIdCurrent . "
"; echo "stkNameCurrent: " . $stkNameCurrent . "
" . "stkPathCurrent: " . $stkPathCurrent . "
" . "nameStock: " . $nameStock . "

"; echo "Date range: " . $fromDateRange . " - " . $toDateRange . "
"; echo "f_act: " . $f_act . "
"; */ if (true) : // Only it is possible to enable/disable the stock area planning for the whole tree $f_stk_planning = getFieldValueFromId("stock","stk_id",$stkIdRoot,"stk_planning"); // *** Save the stock article movement (Begin) *** if ($f_act == "moveArticle") : if ($f_count > 0 && $f_count2 >= 0) : TA("B"); $currentTime = getDateTime("0"); $statusMessage = ""; for ($i = 0; $i <= $f_count; $i++) : for ($j = 0; $j <= $f_count2; $j++) : getSecHttpVars("1",array("f_mv_stk_from_" . $i . "_" . $j, "f_mv_at_id_" . $i . "_" . $j, "f_mv_stk_itemquantity_" . $i . "_" . $j, "f_mv_stk_to_" . $i . "_" . $j, "f_mv_tan_" . $i . "_" . $j, "f_mv_remark_" . $i . "_" . $j, "f_mv_serialno_" . $i . "_" . $j, "f_mv_jb_id_" . $i . "_" . $j)); $tmpQuantity = ${("f_mv_stk_itemquantity_" . $i . "_" . $j)}; if ($tmpQuantity > 0) : $tmpStkFrom = ${("f_mv_stk_from_" . $i . "_" . $j)}; $tmpAtId = ${("f_mv_at_id_" . $i . "_" . $j)}; $tmpStkTo = ${("f_mv_stk_to_" . $i . "_" . $j)}; $tmpTan = ${("f_mv_tan_" . $i . "_" . $j)}; $tmpRemark = ${("f_mv_remark_" . $i . "_" . $j)}; $tmpSerialNo = ${("f_mv_serialno_" . $i . "_" . $j)}; $tmpJbId = ${("f_mv_jb_id_" . $i . "_" . $j)}; $moveResult = stockMoveTA ($tmpStkFrom, $tmpStkTo, $tmpAtId, $tmpQuantity, $tmpTan, $tmpRemark, $tmpSerialNo, $tmpJbId, $usr_id, $f_mv_at, $currentTime); if ($moveResult[0]) : // TA executed $f_mv_stk_itemquantity = 0; // Reset quantity value (only for display) $f_mv_tan = ""; $f_mv_remark = ""; $f_mv_serialno = ""; endif; if (trim($moveResult[1]) != "") : $tmpAtEid = getFieldValueFromId("article","at_id",$tmpAtId,"at_eid"); if ($statusMessage != "") : $statusMessage .= " / "; endif; $statusMessage .= $tmpAtEid . ": " . $moveResult[1] . " "; endif; endif; endfor; endfor; $autoClose = "1"; TA("C"); TA("E"); endif; endif; // *** Save the stock article movement (End) *** if ($autoClose == "0") : // ************************************************** // * Get all articles of the current bundle article * // ************************************************** // Get all articles by top-down recursion getTreeOfBundledArticles($f_mv_at, 0, 1); // --- DEBUG START -------------------------------------------------------------------------------- if (false) : echo "
"; echo "recurseCount: " . $recurseCount . "

"; echo "atArray:
"; $keys = array_keys($atArray); $keysLen = count($keys); for ($i = 0; $i < $keysLen; $i++) : $tmpAtId = $keys[$i]; echo $tmpAtId . " : " . $atArray[$tmpAtId] . "
"; endfor; echo "----------------
"; endif; // --- DEBUG END ----------------------------------------------------------------------------------- // Iterate all item articles beeing in the bundle $stockArticles = array(); $out = ""; $count = 0; $count2 = 0; $quantityStockSumNeeded = 0; $displayBacklog = false; $keys = array_keys($atArray); $keysLen = count($keys); for ($i = 0; $i < $keysLen; $i++) : $tmpAtId = $keys[$i]; $tmpQuantityOneBundle = $atArray[$tmpAtId]; // ATTENTION: Multiply quantity of 1 bundled article by quantity of the whole bundle $tmpQuantity = $tmpQuantityOneBundle * $f_mv_stk_itemquantity; $atEid = getFieldValueFromId("article","at_id",$tmpAtId,"at_eid"); $atName = getFieldValueFromId("article","at_id",$tmpAtId,"at_name"); $tmpStockArticles = showStockArticles($stkIdCurrent, "1", "at.at_id = '" . $tmpAtId . "'", "stkat.stkat_itemquantity DESC"); $stockArticles[] = $tmpStockArticles; $out .= "
\n"; $out .= $tmpStockArticles; $out .= "
\n"; $out .= "
"; $out .= "
\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 .= "
\n"; $out .= "
"; if ($restOfItemQuantity <= 0) : break; endif; endfor; $out .= "
"; $count++; endfor; endif; // $autoClose == "0" endif; ?> <?php echo $pageTitel ?>