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();
$jng_sp_id = '5';
//NEW PROCESS WITH NEW CALC METHOD
use_class('jng_sp_orders');
$class_jo = new jng_sp_orders();
$orders_query = tep_db_query("SELECT jng_sp_orders_id FROM jng_sp_orders WHERE jng_sp_id={$jng_sp_id}");
$orders_count = 0;
while ($row = tep_db_fetch_array($orders_query)) {
    $orders_count++;
    $dataArray = $class_jo->calculateAnalysisData($row['jng_sp_orders_id']);
    $class_jo->saveAnalysisData($dataArray);
}
echo "{$orders_count} Order(s) are Processed";
echo '<br />';
//OLD PROCESS WITH OLD CALC METHOD
use_class('jng_sp_catalog');
$class_jc = new jng_sp_catalog();
$joi = array();
$joi_query = "SELECT joi.*";
$joi_query .= " FROM jng_sp_orders jo";
$joi_query .= " INNER JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_id=jo.jng_sp_orders_id";
$joi_query .= " WHERE jo.jng_sp_id={$jng_sp_id}";
$joi_result = tep_db_query($joi_query);
while ($row = tep_db_fetch_array($joi_result)) {
    if (!isset($joi[$row['products_id']])) {
        $joi[$row['products_id']] = array();