/**
  * Get a forecasting configuration value
  * @param type $config_key const CONFIG_KEY_* of this class 
  * @return type
  */
 public static function getForecastingConfig($config_key)
 {
     if (is_null(self::$forecasting_config)) {
         self::$forecasting_config = load_config('forecasting');
     }
     return self::$forecasting_config[$config_key];
 }
//$adf_sp = "jo.jng_sp_orders_id NOT IN (95488, 95489, 95490, 95491, 95492)"; //TODO: remove filter at 18.12.2011
//$adf_sp = "jo.jng_sp_orders_id NOT IN (54804, 64396, 64427, 26558, 55450)"; //TODO: remove filter at 07.04.2012
//SET "" TO USE NO FILTER / REMOVE FILTER:
$adf_sp = "";
$adf_jg = "";
$products_per_sp = array();
$articles = array();
$topa_sold_week = $class_pm->querySoldSalesAndReturnsHistory(7, $adf_sp, $adf_jg);
//LAST 1 WEEK    (7 DAYS) SOLD
$topa_sold_monthly_1 = $class_pm->querySoldSalesAndReturnsHistory(30, $adf_sp, $adf_jg);
//LAST 1 MONTH  (30 DAYS) SOLD
$topa_sold_monthly_2 = $class_pm->querySoldSalesAndReturnsHistory(60, $adf_sp, $adf_jg);
//LAST 2 MONTHS (60 DAYS) SOLD
$topa_sold_monthly_3 = $class_pm->querySoldSalesAndReturnsHistory(90, $adf_sp, $adf_jg);
//LAST 3 MONTHS (90 DAYS) SOLD
$fc = new forecasting();
$fc_start = 'yesterday';
$fc_total_days = 30;
$fc_last_sold_daily_avg = product::retrieveDailyAverageSoldExcludingPromotionOrdersQuery($fc_start, $fc_total_days);
$fc_last_factors_daily_avg = $fc->calcFactorAverage($fc_start, $fc_total_days);
foreach ($topa_sold_week as $p) {
    $pid = $p['products_id'];
    $aid = $p['products_articles_id'];
    $akey = $pid . '-' . $aid;
    if (!isset($products[$pid])) {
        $products[$pid] = array('products_id' => $pid);
    }
    if (!isset($articles[$akey])) {
        $articles[$akey]['products_id'] = $pid;
        $articles[$akey]['products_articles_id'] = $aid;
    }
use_class('elements_preorder');
use_class('elements_order');
use_class('forecasting');
element::loadDIOHsettings();
$forecasting_conf = load_config('forecasting');
$elements_id = tep_db_prepare_input($_GET['id']);
$year = date('Y');
$kw_now = date('W');
$log_base_data = element::DIOH_BASENUMBER_COLUMN_NAME;
$log_base_info = element::DIOH_BASENUMBER_DESCRIPTION;
$e = new element($elements_id);
$monthly_usage = intval($e->log[$log_base_data]);
$daily_usage = round($monthly_usage / 30, 1);
$last_week_usage = $daily_usage * 7;
$last_week_usage = $last_week_usage > 0 && $last_week_usage < 1 ? 1 : round($last_week_usage, 0);
$fc = new forecasting($year, $forecasting_conf['elements-sourcing-projection']);
$weekly_usage = $e->retrieveWeeklyUsage($year);
$box_style = 'height:100px;padding:5px;';
$content .= '<div class="float-box w450 ui-corner-all" style="' . $box_style . 'margin-right:20px;">';
$content .= '<h3>Chart Legend</h3>';
$content .= '<div><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 ' . $log_base_info . '</td></tr>';
$content .= '<tr><td class="red">Red Line</td><td class="red">=</td><td class="red">Real weekly elements usage</td></tr>';
$content .= '</table></div>';
$content .= '</div>';
$content .= '<div class="float-box w400 ui-corner-all" style="' . $box_style . '">';
$content .= '<h3>Forecast Details</h3>';
$content .= '<div><table border="0" cellspacing="0" cellpadding="0">';
$content .= '<tr><td>Today</td><td>=</td><td class="w080">KW ' . $kw_now . '</td></tr>';
$content .= '<tr><td>L30D usage</td><td>=</td><td>' . $monthly_usage . '</td></tr>';
Beispiel #4
0
 /**
  * Get forecasting object of current year
  * @return forecasting
  */
 private function getForecastingObject()
 {
     if (is_null(self::$forecasting)) {
         $fc = new forecasting();
         $fc->calcForecastLevelling();
         self::$forecasting = $fc;
     }
     return self::$forecasting;
 }
ini_set('memory_limit', '512M');
global $db;
require_once '../confy.php';
require_once '../functions.php';
require_once '../functions-2.php';
require_once DIR_WS_FUNCTIONS . 'html_output.php';
tep_db_connect();
use_class('depot_orders');
use_class('forecasting');
use_class('Product');
$class_do = new depot_orders();
$segments_id = tep_db_prepare_input($_POST['segmentid']);
$keywords = tep_db_prepare_input($_POST['pids']);
$fc_year = date('Y');
$current_month = date('m');
$fc = new forecasting($fc_year);
$fc->calcForecastLevelling();
$target_is_overlap = $fc->isLevellingTargetOverlap();
$list = $class_do->recommendationList($segments_id, $keywords);
$header = array();
$header['a'] = 'No';
$header['b'] = 'Image';
$header['c'] = 'Info';
$header['d'] = 'Size';
$header['e'] = 'EAN';
$header['f'] = 'L30D Sold No Promo';
$header['g'] = 'L30D Sold';
$header['h'] = 'Stock Available';
$header['i'] = 'Stock Target';
$header['j'] = 'Refill Ordered';
$header['k'] = 'Missing Quantity';
     $fc = new forecasting($kw_year, $forecasting_conf['elements-sourcing-projection']);
     echo utf8_encode(drawDataGraph($fc, $kw_year));
     exit;
 } elseif ($_POST['me_action'] == 'SAVELTFSETTINGS') {
     $input_name = tep_db_prepare_input($_POST['varname']);
     $input_value = tep_db_prepare_input($_POST['varvalue']);
     $forecasting_conf[$input_name] = $input_value;
     save_config('forecasting', $forecasting_conf);
     $ajaxResult = array();
     $ajaxResult['inputname'] = $input_name;
     $ajaxResult['inputvalue'] = $input_value;
     ajaxReturn($ajaxResult);
     exit;
 } elseif ($_POST['me_action'] == 'LOADLTF') {
     $kw_year = tep_db_prepare_input($_POST['kw_year']);
     $fc = new forecasting($kw_year, $forecasting_conf['elements-sourcing-projection']);
     for ($m = 1; $m <= 12; $m++) {
         $month = str_pad($m, 2, '0', STR_PAD_LEFT);
         $periods[$month] = date('M', strtotime("{$kw_year}-{$month}-01"));
     }
     $result = '<h2>LONG TERM FORECASTING (LTF) / Levelling</h2>';
     $result .= '<div class="draw-table">';
     $result .= '<table border="0" cellpadding="0" cellspacing="0">';
     $result .= '<tr><th class="w200">Period</th>';
     foreach ($periods as $p) {
         $result .= '<th class="w080">' . $p . '</th>';
     }
     $result .= '</tr>';
     $result .= '<tr class="o"><td class="bold">Period Target</td>';
     $target_period = array('11', '12');
     foreach ($periods as $pk => $p) {
<?php

use_class('Product');
use_class('depot_orders');
$class_do = new depot_orders();
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'LOADOVERVIEW') {
        $pids = explode(',', $_POST['pids']);
        $year = date('Y');
        $month_now = date('n');
        $months = array();
        for ($m = 1; $m <= 12; $m++) {
            $mp = str_pad($m, 2, '0', STR_PAD_LEFT);
            $months[$mp] = date('M-y', strtotime("{$year}-{$mp}-01"));
        }
        $fc = new forecasting($year);
        $fc->calcForecastLevelling();
        $sales_real = array();
        $sales_forecast = array();
        $levelling_split = array();
        $levelling_orders_real = array();
        $levelling_orders_real_out = array();
        $levelling_orders_real_ptb = array();
        $levelling_orders_real_out_open = array();
        $levelling_orders_forecast = array();
        $levelling_target_forecast = array();
        $no_values = '<span class="notice">-</span>';
        //set default value per month
        foreach ($months as $mp => $mtext) {
            $mp_value = intval($mp);
            $sales_real[$mp] = 0;
 */
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>';
use_class('forecasting');
use_class('php-ofc-library/open-flash-chart');
$data = explode('|||', $_GET['data']);
$year = $data[0];
$data_max = 1;
$kw_daterange = array();
$kw_today = date('W');
$year_today = date('Y');
$title = new title('Calendar Week ' . $year);
$title->set_style("{font-size:14px; font-weight:bold; padding:10px;}");
$data_1_color = '#000099';
$data_1 = explode('|', $data[1]);
foreach ($data_1 as $k => $v) {
    $kw = $k + 1;
    $v = floatval($v);
    $da = forecasting::getDatesOfCalendarWeek($year, $kw, 'd.m');
    $d = $da[0] . '-' . $da[6];
    $kw_daterange[$kw] = $d;
    $lv = new hollow_dot($v);
    $lv->colour($data_1_color)->size(3)->halo_size(0);
    $lv->tooltip('#x_label#<br>' . $d . '<br>Value: #val#');
    $data_1[$k] = $lv;
    if ($v > $data_max) {
        $data_max = ceil($v);
    }
}
$line_1 = new line();
$line_1->set_values($data_1);
$line_1->set_colour($data_1_color);
$line_1->set_width(4);
$data_2_color = '#990000';
Beispiel #10
0
 function getDIOH($articles_id, $current_stock)
 {
     //old method using old function
     //return calculateDIOH($current_stock, $this->log_articles[$articles_id][self::DIOH_BASENUMBER_COLUMN_NAME]);
     //new method using forecasting
     $fc = new forecasting();
     return $fc->calculateDIOH($current_stock, $this->log_articles[$articles_id][self::FORECAST_DAILY_COLUMN_NAME]);
 }