<?php

require_once(MH_DIR_FS_CATALOG . MH_ROOT_PATH . 'common/functions/compatibility.php');

mh_define('MH_BYPASS_TEMPLATE', TRUE);

mh_session_write_close();

$dashboard_module = mh_get('dashboard_module');

$refresh = false;
if (mh_get('dashboard_action')) {

    switch (mh_get('dashboard_action')) {
        case 'refresh':
        case 'load':
            $refresh = true;
            break;
        default:
            break;
    }
}

$class = $dashboard_module;

if (!class_exists($class)) {

    mh_load_modules_language_files(MH_DIR_DASHBOARD, $class);

    if (file_exists(MH_DIR_DASHBOARD . $class . MH_FILE_EXTENSION)) {
        include_once(MH_DIR_DASHBOARD . $class . MH_FILE_EXTENSION);
    } else {
    }
}

if (class_exists($class)) {
    $dashboard_module = new $class;
    //$widgetContent = $dashboard_module->getOutputAjax($_GET['dashboard_action'] == 'refresh');
    $widgetContent = $dashboard_module->getOutputAjax($refresh); // refresh
} else {
    $widgetContent = $dashboard_module . ' not found';

}
$json_data = json_encode((object)array('widgetContent' => mh_force_utf8($widgetContent)));
echo $json_data;
