if ($a['length'] > 4.6 && $a['length'] < 6.0) {
             $row[] = $p->getSKU($aid);
         } else {
             continue;
         }
     } else {
         $row[] = $p->getSKU(0);
     }
 } else {
     $row[] = $p->getSKU($aid);
 }
 //Quantity
 if ($category_top_id == '1') {
     if ($category_id == '29') {
         if ($a['length'] > 4.6 && $a['length'] < 6.0) {
             $row[] = $p->retrieveStockQuantity($aid);
         }
     } else {
         $row[] = $p->retrieveStockQuantity(0);
     }
 } else {
     $row[] = $p->retrieveStockQuantity($aid);
 }
 //Price
 $price = $p->getPriceSelling($jng_sp_id);
 $price_old = $p->getPriceSellingOld($jng_sp_id);
 if ($price_old <= $price) {
     $row[] = $price;
 } else {
     $row[] = $price_old;
 }
$content .= '<tr><td>L30D Weekly average</td><td>=</td><td>' . $last_week_sold . '</td></tr>';
$content .= '<tr><td>Today</td><td>=</td><td class="w080">KW ' . $kw_now . '</td></tr>';
$content .= '<tr><td colspan="3" class="bold">Graph is using product level forecasting (not article level)</td></tr>';
$content .= '</table></div>';
$content .= '</div>';
$content .= '<div style="clear:both;padding-top:20px;">';
$content .= '<h2>Depot Refill using Forecast';
if ($articles_id != '*' && count($p->articles) > 0) {
    $content .= ' <span id="txt-show-all-articles" class="pointer blue smallText">&laquo;show all articles&raquo;</span>';
}
$content .= '</h2>';
foreach ($p->articles as $aid => $a) {
    $a_title = $a['length'] > 0 ? textLength($a['length']) : '<span class="notice">No Length</span>';
    $daily_sold = $p->log_articles[$aid][Product::FORECAST_DAILY_COLUMN_NAME];
    $stock_target = $p->getDIOHstockTarget($aid);
    $stock_available = $p->retrieveStockQuantity($aid);
    $stock_available_dioh = $p->displayDIOH($aid, $stock_available);
    $refill_ordered = $p->retrieveRefillQuantity($aid);
    $missing_qty = $stock_target - ($stock_available + $refill_ordered);
    if ($missing_qty < 0) {
        $missing_qty = 0;
    }
    $show_box = $articles_id == '*' || $articles_id == $aid ? '' : 'display:none;';
    $content .= '<div class="float-box w300 ui-corner-all" style="padding:5px;margin:0 10px 10px 0;' . $show_box . '"><table border="0" cellspacing="0" cellpadding="0">';
    $content .= '<tr><td colspan="3" class="bold">EAN ' . $a['products_ean'] . ' - ' . $a_title . '</td></tr>';
    $content .= '<tr><td>Daily Average <span class="red" title="' . $forecasting_conf['promotion-orders-desc'] . '">(!)</span></td><td>=</td><td>' . $daily_sold . '</td></tr>';
    $content .= '<tr><td title="Stock Target based on DIOH Target Settings">Stock Target (' . Product::$diohStopLevel[$p->stars] . ' days)</td><td>=</td><td>' . $stock_target . '</td></tr>';
    $content .= '<tr><td>Stock Available</td><td>=</td><td>' . $stock_available . '&nbsp;<span class="notice">(' . $stock_available_dioh . ')</span></td></tr>';
    $content .= '<tr><td>Refill Ordered</td><td>=</td><td>' . $refill_ordered . '</td></tr>';
    $content .= '<tr><td class="bold">Missing Quantity</td><td class="bold">=</td><td class="bold">' . $missing_qty . '</td></tr>';
    $content .= '</table></div>';
/**
 * Get cell value for Matahari catalog cell
 * @global Int $jng_sp_id
 * @global Array $sp_detail
 * @param String $column_key
 * @param Product $product
 * @param Int $aid
 * @return String
 */
function getMatahariCatalogCellValue($column_key, $product, $aid)
{
    global $class_pb, $jng_sp_id, $sp_detail, $sp_values_brand, $sp_values_colors, $sp_values_navcat, $sp_values_navsubcat, $category_top_id;
    $lid = $sp_detail['languages_id'];
    if (!isset($sp_values_brand[$product->brand_id])) {
        $sp_brands = $class_pb->getSPbrands($product->brand_id);
        $sp_values_brand[$product->brand_id] = $sp_brands[$jng_sp_id];
    }
    $product_old_function = $product->getOldProductFunction()->retrieveDetail($product->id, 'p,pd,pd2,pc,pnc,cat,pei,pci');
    if ($category_top_id == '1') {
        if ($product_old_function['pci']['products_clear_image'] != '') {
            $main_image = substr($product_old_function['pci']['products_clear_image'], 23);
        } else {
            $main_image = substr($product_old_function['p']['products_image'], 23);
        }
    } else {
        $main_image = substr($product_old_function['p']['products_image'], 23);
    }
    $additional_images = array_values($product_old_function['pei']);
    $category_id = $product->category_id;
    $selling_points = $product->getSellingPointsAsArray($lid);
    switch ($column_key) {
        case 'Title*':
            if ($category_top_id == '1') {
                //JEWELRY
                $value = ucwords(strtolower($sp_values_brand[$product->brand_id])) . ' ' . $product_old_function['pd'][3]['products_name'] . ' ' . $product->getColors($lid);
                //                $value = 'VON LORENZ' . ' ' .
                //                    $product_old_function['pd'][3]['products_name'] . ' ' . $product->getColors($lid);
            } else {
                $value = ucwords(strtolower($sp_values_brand[$product->brand_id])) . ' ' . $product->getName($lid) . ' ' . $product->getColors($lid);
            }
            break;
        case 'Brand':
            $value = $sp_values_brand[$product->brand_id];
            //            $value = 'VON LORENZ';
            break;
        case 'Model':
            $value = '';
            break;
        case 'Color*':
            $value = $product->getColors($lid);
            break;
        case 'Sale Price (Amount)*':
            $price = $product->getPriceSelling($jng_sp_id);
            $price_old = $product->getPriceSellingOld($jng_sp_id);
            if ($price_old <= $price) {
                //show blank if its not discounted
                $price = '';
            }
            $value = $price;
            break;
        case 'Price (Amount)*':
            $price = $product->getPriceSelling($jng_sp_id);
            $price_old = $product->getPriceSellingOld($jng_sp_id);
            if ($price_old <= $price) {
                $price_old = $price;
            }
            $value = $price_old;
            break;
        case 'SKU*':
            $value = $product->getSKU($aid);
            break;
        case 'Size':
            //todo: translate ring sizes
            if ($category_top_id == '1') {
                if ($category_id == '29') {
                    $value = $product->convertRingSizeToJapaneseSize($product->getLengthOrSizeAsText($aid));
                } else {
                    $value = 'One Size';
                }
            } else {
                $value = $product->getLengthOrSizeAsText($aid);
            }
            break;
        case 'Model Number':
            $value = $product->getEAN($aid);
            break;
        case 'Stock':
            $value = $product->retrieveStockQuantity($aid);
            break;
        case 'Product Line':
            $value = 'Wanita';
            break;
        case 'Normal Price (Amount)*':
            $value = $product->getPriceDefault();
            break;
        case 'Normal Price (Currency)*':
            $value = 'IDR';
            break;
        case 'Main Material':
            $value = '';
            break;
        case 'Description*':
            $value = $product->getDescription($lid);
            break;
        case 'Youtube URL':
            $value = '';
            break;
        case 'Highlight 1':
            $value = $selling_points[0];
            break;
        case 'Highlight 2':
            $value = $selling_points[1];
            break;
        case 'Highlight 3':
            $value = $selling_points[2];
            break;
        case 'Highlight 4':
            $value = $selling_points[3];
            break;
        case 'Highlight 5':
            $value = $selling_points[4];
            break;
        case 'Highlight 6':
            $value = '';
            break;
        case 'Highlight 7':
            $value = '';
            break;
        case 'Highlight 8':
            $value = '';
            break;
        case 'Highlight 9':
            $value = '';
            break;
        case 'Highlight 10':
            $value = '';
            break;
        case 'Highlight 11':
            $value = '';
            break;
        case 'Highlight 12':
            $value = '';
            break;
        case 'Insurance option':
            $value = '1';
            break;
        case 'Handling fee (IDR)':
            $value = '0';
            break;
        case 'Product Dimension':
            //Measurements is from Zalora Template
            $value = $product->displayMeasurement($lid);
            break;
        case 'Product Weight':
            $value = $product->displayWeight($lid);
            break;
        case 'Package Dimension (L x W x H cm)':
            //todo: use dynamic data
            $value = '40 x 35 x 3 cm';
            break;
        case 'Certification':
            $value = '';
            break;
        case 'Product Country':
            $value = ProductAttribute::displayAttributeName($product->id, ProductAttribute::GROUP_ID_ORIGIN, $lid);
            break;
        case 'Item Condition*':
            $value = 'new';
            break;
        case 'Product Waranty':
            $value = '';
            break;
        case 'Image 1*':
            //Currently Kristel will copy the link to this field manually.
            $value = $main_image;
            break;
        case 'Image 2':
            $value = $additional_images[0] == '' ? '' : substr($additional_images[0], 23);
            break;
        case 'Image 3':
            $value = $additional_images[1] == '' ? '' : substr($additional_images[1], 23);
            break;
        case 'Image 4':
            $value = $additional_images[2] == '' ? '' : substr($additional_images[2], 23);
            break;
        case 'Image 5':
            $value = $additional_images[3] == '' ? '' : substr($additional_images[3], 23);
            break;
        case 'Product Line':
            $value = ucfirst($product->getProductGender('1'));
            break;
        case 'Price (Currency)*':
            $value = 'IDR';
            break;
        case 'Type':
            $value = '';
            break;
        case 'Package Weight (Kg)':
            $value = 0.4;
            break;
        case 'product_id(MUST BE DELETED BEFORE UPLOAD)':
            $value = $product->id;
            break;
        default:
            $value = '';
    }
    return $value;
}