function dashboard_system_messages_delete()
{
    cw_system_messages_delete($_GET['code']);
    cw_ajax_add_block(array('id' => 'system_message_' . $_GET['code'], 'action' => 'hide'));
}
function dashboard_section_awaiting($params, $return = null)
{
    global $config, $smarty, $tables, $customer_id;
    // Set the dashboard code name here
    $name = 'awaiting_actions';
    // If the section is disabled then skip it on dashboard
    if ($params['mode'] == 'dashboard' && $params['sections'][$name]['active'] === '0') {
        return $return;
    }
    // Define basic data for configuration
    $return[$name] = array('title' => 'Awaiting action(s)', 'description' => 'These actions await for admin attention', 'active' => 1, 'pos' => 50, 'size' => 'small', 'frame' => 1, 'header' => 1);
    if ($params['mode'] == 'setting') {
        return $return;
    }
    // Products approval counter
    $cnt = cw_query_first_cell("SELECT count(*) FROM {$tables['products']} WHERE status=2");
    if ($cnt == 0) {
        cw_system_messages_delete('product_approvals');
    } else {
        cw_system_messages_add('product_approvals', cw_get_langvar_by_name('lbl_product_approvals') . ' -
	<a href="index.php?target=products&mode=search&status[]=2">' . $cnt . '</a>', constant('SYSTEM_MESSAGE_AWAITING'));
    }
    // Reviews counter
    $cnt = cw_query_first_cell("SELECT count(*) FROM {$tables['products_reviews']} WHERE status=0");
    if ($cnt == 0) {
        cw_system_messages_delete('product_reviews');
    } else {
        cw_system_messages_add('product_reviews', cw_get_langvar_by_name('lbl_product_reviews') . ' -
	<a href="index.php?target=estore_reviews_management">' . $cnt . '</a>', constant('SYSTEM_MESSAGE_AWAITING'));
    }
    // Incoming messages
    $cnt = cw_query_first_cell("SELECT count(*) FROM {$tables['messages']} WHERE recipient_id='{$customer_id}' and read_status=0");
    if ($cnt == 0) {
        cw_system_messages_delete('incoming_messages');
    } else {
        cw_system_messages_add('incoming_messages', cw_get_langvar_by_name('lbl_incoming_messages') . ' -
	<a href="index.php?target=message_box&sort_field=read_status&sort_direction=1">' . $cnt . '</a>', constant('SYSTEM_MESSAGE_AWAITING'));
    }
    // Quotes counter
    $cnt = cw_query_first_cell("SELECT count(*) FROM {$tables['docs']} WHERE type='I' and status='Q'");
    if ($cnt == 0) {
        cw_system_messages_delete('quote_requests');
    } else {
        cw_system_messages_add('quote_requests', cw_get_langvar_by_name('lbl_quote_requests') . ' -
	<a href="index.php?target=docs_I&mode=search&data[status]=Q">' . $cnt . '</a>', constant('SYSTEM_MESSAGE_AWAITING'));
    }
    cw_event('on_dashboard_awaiting_actions');
    // Handlers must add lines via cw_system_messages_add (type = SYSTEM_MESSAGE_AWAITING)
    /*
     * GET SYSTEM MESSAGES
     */
    $system_messages = cw_system_messages(constant('SYSTEM_MESSAGE_AWAITING'), true);
    $smarty->assign('awaiting_actions', $system_messages);
    $return[$name]['template'] = 'addons/dashboard/admin/sections/awaiting_actions.tpl';
    if (empty($system_messages)) {
        unset($return[$name]);
    }
    return $return;
}
    foreach ($tasks as $task => $period) {
        if ($period == 'regular' || $executed == 0) {
            $log[$task] = cw_event($task, array($time, $last_run[$period]));
            if (empty($log[$task])) {
                $log[$task] = null;
            }
            unset($tasks[$task]);
        }
        if ($period != 'regular') {
            $executed++;
        }
    }
    $last_run['queue'] = $tasks;
    // Old fashion cron handlers are files in cron folder
    $targets = cw_func_call('cw_cron_get_targets', array('time' => $time_dump, 'hour' => $hour, 'minute' => $minute, 'manual_run' => $manual_run));
    foreach ($targets as $target) {
        $log['include:' . $target] = cw_include($area . '/' . $target . '.php');
    }
} else {
    $log[$manual_run] = cw_call($manual_run, array($time, $time));
    $log['include:' . $manual_run] = cw_include($area . '/' . $manual_run . '.php');
}
$last_run['flag'] = 0;
// Cron finished
db_query("REPLACE {$tables['config']} (name, config_category_id, value) values ('last_cron_run',1,'" . mysql_real_escape_string(serialize($last_run)) . "')");
cw_system_messages_delete('cron_not_finished');
$log['end'] = '#' . $counter . ': Cron ended at ' . date('H:i:s', time());
cw_log_add('cron', $log, false);
cw_call('cw_system_messages_delete', array('crontab_warning'));
exit(0);
// do not return back to display functions