$value .= '<br />' . $pid;
             break;
         case $hn_article:
             $value = implode('<br />', $alist);
             break;
         case $hn_custock:
             $tempvalue = array();
             foreach ($alist as $aid => $length) {
                 $tempvalue[] = $adata[$aid]['stock'];
             }
             $value = implode('<br />', $tempvalue);
             break;
         case $hn_cbooked:
             $tempvalue = array();
             foreach ($alist as $aid => $length) {
                 $tempvalue[] = stock_booking::getBookedQuantity($adata[$aid]['products_stock_id']);
             }
             $value = implode('<br />', $tempvalue);
             break;
         case $hn_cbohere:
             $tempvalue = array();
             foreach ($alist as $aid => $length) {
                 $tempvalue[] = intval($booking->items[$adata[$aid]['products_stock_id']]);
             }
             $value = implode('<br />', $tempvalue);
             break;
         default:
             $value = '&nbsp;';
     }
     $content .= '<td class="' . $k . '">' . $value . '</td>';
 }
$content .= '<input type="submit" value="Go" />';
$content .= '<input id="search-form-cancel" type="button" value="Cancel" style="display:none;" />';
$content .= '</form>';
$content .= '</div>';
//#search-form
if (isset($_GET['psid'])) {
    $psid = tep_db_prepare_input($_GET['psid']);
    $stock = $class_pm->stockRetrieveDetailByPSID($psid);
    $pid = $stock['products_id'];
    $aid = $stock['articles_id'];
    if ($stock['jng_warehouses_id'] != $fg_whid) {
        $ps = $class_pm->stockRetrieveDetail($fg_whid, $pid, $aid);
        openStockDetail($ps['products_stock_id']);
    }
    $bin = $class_bin->getBinProductStock($psid);
    $bookmanual = stock_booking::getBookedQuantity($psid);
    $stock_database = $stock['stock'];
    $stock_on_and_bookedbyrealorder = $class_pm->productsBookedCount($fg_whid, $pid, $aid);
    $stock_on_and_bookedmanually = $bookmanual > $stock_database ? $stock_database : $bookmanual;
    $stock_available = $stock_database - $stock_on_and_bookedmanually;
    $stock_on_total = $stock_database + $stock_on_and_bookedbyrealorder;
    $stock_off_and_bookedmanually = $bookmanual > $stock_database ? $bookmanual - $stock_database : 0;
    $content .= '<div id="stock-detail">';
    $content .= '<div style="float:left;width:350px;">';
    $content .= '<div>' . drawProductInfo($pid, $aid) . '</div>';
    $content .= '<div style="clear:both;padding-top:30px;">' . drawBinAction($bin) . '</div>';
    $content .= '<div style="margin-top:30px;">';
    $content .= '<h2>Stock Information</h2>';
    $content .= '<table border="0" cellpadding="0" cellspacing="0">';
    $content .= '<tr class="notice"><td style="width:250px;">On Stock in Database<br />(Available + Booked Manually)</td><td class="tar" style="width:50px;">' . $stock_database . '</td></tr>';
    $content .= '<tr><td colspan="2"><hr /></td></tr>';
function prepareArticle($pid, $product, $amazon_ek, $amazon_ek_old, $article = null)
{
    global $class_pm, $header, $hn, $report_cogs_lastyear, $report_cogs_thisyear;
    if (is_null($article)) {
        $aid = '0';
        $ean = $product['p']['products_ean'];
        $length = $product['pnc']['products_length'];
    } else {
        $aid = $article['products_articles_id'];
        $ean = $article['products_ean'];
        $length = $article['length'];
    }
    $stock = $class_pm->stockRetrieveDetail(WAREHOUSE_ID_PRODUCTS_HAMBURG, $pid, $aid);
    $td = array();
    foreach ($header as $k => $v) {
        $value = '';
        switch ($v) {
            case $hn['image']:
                $value = webImage($product['p']['products_image'], '80', '80', 'Products ' . $pid);
                break;
            case $hn['ean']:
                $value = $ean;
                break;
            case $hn['pid']:
                $value = $pid;
                break;
            case $hn['aid']:
                $value = $aid;
                break;
            case $hn['length']:
                $value = $length > 0 ? textLength($length) : '-';
                break;
            case $hn['price_old']:
                $value = displayCurrency('EUR', $product['p']['products_price_old'], false);
                break;
            case $hn['price']:
                $value = displayCurrency('EUR', $product['p']['products_price'], false);
                break;
            case $hn['price_amazon_ek']:
                $value = displayCurrency('EUR', $amazon_ek, false);
                break;
            case $hn['price_amazon_ek_old']:
                $value = displayCurrency('EUR', $amazon_ek_old, false);
                break;
            case $hn['stock']:
                $value = strval(intval($stock['stock']));
                break;
            case $hn['booked']:
                $value = strval(intval(stock_booking::getBookedQuantity($stock['products_stock_id'])));
                break;
            case $hn['matexp']:
                $value = displayCurrency('EUR', $product['p']['material_expenses'], false);
                break;
            case $hn['lastyear_qty']:
                $value = strval(intval($report_cogs_lastyear[$ean]['total_quantity']));
                break;
            case $hn['lastyear_netsales']:
                $value = displayCurrency('EUR', $report_cogs_lastyear[$ean]['total_net_sales'], false);
                break;
            case $hn['lastyear_cogs']:
                $value = displayCurrency('EUR', $report_cogs_lastyear[$ean]['total_cogs'], false);
                break;
            case $hn['lastyear_grossprofit']:
                $value = displayCurrency('EUR', $report_cogs_lastyear[$ean]['total_gross_profit'], false);
                break;
            case $hn['thisyear_qty']:
                $value = strval(intval($report_cogs_thisyear[$ean]['total_quantity']));
                break;
            case $hn['thisyear_cogs']:
                $value = displayCurrency('EUR', $report_cogs_thisyear[$ean]['total_cogs'], false);
                break;
        }
        $td[$k] = '<div style="padding:2px;">' . $value . '</div>';
    }
    return $td;
}