/**
 * Add a dashboard widget
 */
function alo_em_dashboard_widget_function()
{
    global $wpdb;
    echo "<h4>" . __("Newsletters scheduled for sending", "alo-easymail") . ": " . alo_em_count_newsletters_by_status('sendable') . "</h4>";
    $newsletter = alo_em_get_newsletters_in_queue(1);
    if ($newsletter) {
        echo "<p>";
        echo '<img src="' . ALO_EM_PLUGIN_URL . '/images/16-email-forward.png" title="' . __("now sending", "alo-easymail") . '" alt="" style="vertical-align:text-bottom" />';
        echo " <strong>" . stripslashes(alo_em___($newsletter[0]->post_title)) . "</strong><br />";
        echo __("Progress", "alo-easymail") . ": " . alo_em_newsletter_recipients_percentuage_already_sent($newsletter[0]->ID) . " %<br />";
        echo "<em>" . __("Added on", "alo-easymail") . " " . date_i18n(__('j M Y @ G:i', "alo-easymail"), strtotime($newsletter[0]->post_date)) . "  - ";
        echo __("Scheduled by", "alo-easymail") . " " . get_user_meta($newsletter[0]->post_author, 'nickname', true) . "</em>";
        echo "</p>";
    } else {
        echo "<p>" . __("There are no newsletters in queue", "alo-easymail") . ".</p>";
    }
    echo "<h4 style='margin-top:1.2em'>" . __("Subscribers", "alo-easymail") . "</h4>";
    list($total, $active, $noactive) = alo_em_count_subscribers();
    if ($total) {
        echo "<p>" . sprintf(__("There are %d subscribers: %d activated, %d not activated", "alo-easymail"), $total, $active, $noactive) . ".</p>";
    } else {
        echo "<p>" . __("No subscribers", "alo-easymail") . ".</p>";
    }
    if (current_user_can('administrator')) {
        echo "<h5 style='margin-bottom:0.4em'>" . __("Updates from plugin developer", "alo-easymail") . "</h5>";
        $rss = fetch_feed('http://www.eventualo.net/blog/category/alo-easymail-newsletter/feed/');
        if (!is_wp_error($rss)) {
            $maxitems = $rss->get_item_quantity(3);
            $rss_items = $rss->get_items(0, $maxitems);
            echo "<ul style='padding-top: 0.5em'>";
            if ($maxitems == 0) {
                echo '<li>No items.</li>';
            } else {
                // Loop through each feed item and display each item as a hyperlink.
                foreach ($rss_items as $item) {
                    $content = $item->get_content();
                    $content = esc_attr(wp_html_excerpt($content, 350)) . ' [...]';
                    ?>
				<li>
					<a href='<?php 
                    echo $item->get_permalink();
                    ?>
'
					title='<?php 
                    echo $content;
                    ?>
'>
					<?php 
                    echo $item->get_title();
                    ?>
</a>
					<?php 
                    echo date_i18n(__('j F Y', "alo-easymail"), strtotime($item->get_date()));
                    ?>
 
				</li>
				<?php 
                }
            }
            echo "</ul>";
        } else {
            echo '<p>';
            printf(__('<strong>RSS Error</strong>: %s'), $rss->get_error_message());
            echo '</p>';
        }
    }
}