}
            $total_products[$jng_warehouses_id][$products_id][$articles_id] += $row['order_quantity'];
        }
    }
}
foreach ($total_products as $jng_warehouses_id => $products) {
    foreach ($products as $products_id => $articles) {
        foreach ($articles as $aid => $add_amount) {
            $class_pm->stockAdd($jng_warehouses_id, $products_id, $add_amount, $aid);
            $class_ms->products_state($jng_warehouses_id, $products_id, $period, true);
        }
    }
}
//ELEMENTS
$jng_warehouses_id = 1;
$stocks = $class_es->retrieveAll($jng_warehouses_id);
foreach ($stocks as $eid => $stock) {
    $class_ms->elements_state($jng_warehouses_id, $eid, $period, true);
}
//FG Bali
$jng_warehouses_id = 7;
$stocks = $class_pm->stockRetrieveList($jng_warehouses_id);
foreach ($stocks as $s) {
    if ($s['stock'] > 0) {
        var_dump($s);
        echo '<br />';
        $class_ms->products_state($jng_warehouses_id, $s['products_id'], $period, true);
    }
}
echo 'Data is Processed!';
tep_db_close();