use_class('Product');
use_class('forecasting');
Product::loadDIOHsettings();
$forecasting_conf = load_config('forecasting');
$products_id = tep_db_prepare_input($_GET['products_id']);
$articles_id = isset($_GET['articles_id']) ? tep_db_prepare_input($_GET['articles_id']) : '*';
$year = date('Y');
$kw_now = date('W');
$log_base_data = 'sold_monthly_1';
$log_base_info = 'last 30 days sold';
$p = new Product($products_id);
$daily_sold = $p->log[Product::FORECAST_DAILY_COLUMN_NAME];
$last_week_sold = $daily_sold * 7;
$last_week_sold = $last_week_sold > 0 && $last_week_sold < 1 ? 1 : round($last_week_sold, 0);
$fc = new forecasting($year);
$weekly_sold_real_nopromo = $p->retrieveWeeklySoldByShippingWindowExcludingPromotionOrders($year);
$box_style = 'height:150px;padding:5px;';
$content .= '<div class="float-box w400 ui-corner-all" style="' . $box_style . 'margin-right:20px;">';
$content .= '<h3>Chart Legend</h3>';
$content .= '<table border="0" cellspacing="0" cellpadding="0">';
$content .= '<tr style="background:#efccef;"><td class="w080">Purple Block</td><td>=</td><td>Current Calendar Week</td></tr>';
$content .= '<tr><td class="blue">Blue Line</td><td class="blue">=</td><td class="blue">Forecasting based on weekly average of L30D sold and excluding <em class="help" title="' . $forecasting_conf['promotion-orders-desc'] . '">promotion orders</em></td></tr>';
$content .= '<tr><td class="red">Red Line</td><td class="red">=</td><td class="red">Real weekly sold based on shipping window open and excluding <em class="help" title="' . $forecasting_conf['promotion-orders-desc'] . '">promotion orders</em></td></tr>';
$content .= '</table>';
$content .= '</div>';
$content .= '<div class="float-box w400 ui-corner-all" style="' . $box_style . '">';
$content .= '<h3 style="margin-bottom:0;">Product Sold Forecast</h3>';
$content .= '<div class="notice smallText">' . $forecasting_conf['promotion-orders-desc'] . '</div>';
$content .= '<div style="margin-top:5px;"><table border="0" cellspacing="0" cellpadding="0">';
$content .= '<tr><td>L30D Daily average</td><td>=</td><td>' . $daily_sold . '</td></tr>';
$content .= '<tr><td>L30D Weekly average</td><td>=</td><td>' . $last_week_sold . '</td></tr>';