function html()
        {
            SendPress_Tracking::event('Emails Tab');
            //SendPress_Template_Manager::update_template_content();
            //Create an instance of our package class...
            $testListTable = new Jaiminho_Email_Local_Table();
            //Fetch, prepare, sort, and filter our data...
            $testListTable->prepare_items();
            ?>
	
	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form id="email-filter" method="get">
		<div id="taskbar" class="lists-dashboard rounded group"> 

		<h2><?php 
            _e('Templates', 'sendpress');
            ?>
</h2>
		<small><?php 
            _e('Help', 'sendpress');
            ?>
: <a target="_blank" href="http://docs.sendpress.com/article/58-setting-up-a-newsletter-template/"><?php 
            _e('Getting Started with Templates', 'sendpress');
            ?>
</a></small>
	</div>
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	    <input type="hidden" name="page" value="<?php 
            echo SPNL()->validate->page();
            ?>
" />
	    <!-- Now we can render the completed list table -->
	    <?php 
            $testListTable->display();
            ?>
	    <?php 
            wp_nonce_field($this->_nonce_value);
            ?>
	</form><br>
	<!--a href="<?php 
            echo SendPress_Admin::link('Emails_Temp', array('action' => 'install'));
            ?>
" class="btn btn-primary">Install Starter Templates</a-->
	<a href="<?php 
            echo SendPress_Admin::link('Emails_Temp', array('action' => 'install'));
            ?>
" class="btn btn-primary">Install Starter Templates</a>
	<?php 
        }
    function html($sp)
    {
        SendPress_Tracking::event('Reports Tab');
        //Create an instance of our package class...
        $sp_reports_table = new SendPress_Reports_Table();
        //Fetch, prepare, sort, and filter our data...
        $sp_reports_table->prepare_items();
        ?>
		<br>
		<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
		<form id="email-filter" method="get">
			<!-- For plugins, we also need to ensure that the form posts back to our current page -->
		    <input type="hidden" name="page" value="<?php 
        echo SPNL()->validate->page($_REQUEST['page']);
        ?>
" />
		    <!-- Now we can render the completed list table -->
		    <?php 
        $sp_reports_table->display();
        ?>
		    <?php 
        wp_nonce_field($this->_nonce_value);
        ?>
		</form>
		<h3><?php 
        _e('Information', 'sendpress');
        ?>
</h3>
		<div class='well'>
		<span class="label label-success"><?php 
        _e('Unique', 'sendpress');
        ?>
</span> <?php 
        _e('The total number of different recipients that have clicked on a link or opened an email.', 'sendpress');
        ?>
<br><br>

		<span class="label label-info"><?php 
        _e('Total', 'sendpress');
        ?>
</span> <?php 
        _e('The total number of clicks or opens that have happened. Regardless of who clicked or opened the email.', 'sendpress');
        ?>
		</div>
		<?php 
    }
    function html($sp)
    {
        SendPress_Tracking::event('Emails Tab');
        //Create an instance of our package class...
        $testListTable = new SendPress_System_Email_Table();
        //Fetch, prepare, sort, and filter our data...
        $testListTable->prepare_items();
        ?>

	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form id="email-filter" method="get">
		<div id="taskbar" class="lists-dashboard rounded group">
		<?php 
        $form_types = SendPress_Data::get_system_email_types();
        if ($form_types) {
            ?>
				<div id="button-area">
					<a class="btn btn-primary btn-large" href="?page=<?php 
            echo $_REQUEST['page'];
            ?>
&view=systememailcreate"><?php 
            _e('Create System E-mail', 'sendpress');
            ?>
</a>
				</div>
			<?php 
        }
        ?>

	</div>
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	    <input type="hidden" name="page" value="<?php 
        echo $_REQUEST['page'];
        ?>
" />
	    <!-- Now we can render the completed list table -->
	    <?php 
        $testListTable->display();
        ?>
	    <?php 
        wp_nonce_field($this->_nonce_value);
        ?>
	</form>
	<?php 
    }
    function html($sp)
    {
        SendPress_Tracking::event('Queue Tab');
        $testListTable = new SendPress_Queue_Errors_Table();
        $testListTable->prepare_items();
        SendPress_Option::set('no_cron_send', 'false');
        $sp->cron_start();
        $open_info = array("id" => 13, "report" => 10, "view" => "open");
        ?>

	<h2><?php 
        _e('Error history for the last 2 Weeks', 'sendpress');
        ?>
.</h2>

	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form id="email-filter" action="<?php 
        echo SendPress_Admin::link('Queue_Errors');
        ?>
" method="get">
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	     <input type="hidden" name="page" value="<?php 
        echo SPNL()->validate->page($_REQUEST['page']);
        ?>
" /> 
	    <!-- Now we can render the completed list table -->
	    <?php 
        $testListTable->display();
        ?>
	    <?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>
	<br>
	
<?php 
    }
        function html($sp)
        {
            SendPress_Tracking::event('Overview Tab');
            global $wp_version;
            $classes = 'sp-welcome-panel';
            $option = get_user_meta(get_current_user_id(), 'show_sp_welcome_panel', true);
            // 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner
            $hide = 0 == $option || 2 == $option && wp_get_current_user()->user_email != get_option('admin_email');
            list($display_version) = explode('-', $wp_version);
            ?>
<br>



<div class="sp-row ">

  <div class="sp-block sp-25 sp-first"> 
    <h2 class="nomargin nopadding"><?php 
            echo SendPress_Data::bd_nice_number(SendPress_Data::get_total_subscribers());
            ?>
</h2> <p class="fwb"><?php 
            _e('Subscribers', 'sendpress');
            ?>
</p>  
  </div>
  <div class="sp-block sp-25">
    <h2 class="nomargin nopadding"><?php 
            $report = SendPress_Data::get_last_report();
            echo SendPress_Data::emails_active_in_queue();
            ?>
</h2> <p class="fwb"><?php 
            _e('Emails Actively Sending', 'sendpress');
            ?>
</small></p>
  </div>
  <div class="sp-block sp-25">
    <h2 class="nomargin nopadding"><?php 
            echo SendPress_Data::emails_maxed_in_queue();
            ?>
</h2> <p class="fwb"><?php 
            _e('Emails Stuck in Queue', 'sendpress');
            ?>
</p>
  </div>
  <div class="sp-block sp-25">
    <h2 class="nomargin nopadding"><?php 
            _e('Autocron last check', 'sendpress');
            ?>
</h2> <p class="fwb">  <?php 
            $autocron = SendPress_Option::get('autocron', 'no');
            //print_r(SendPress_Data::emails_stuck_in_queue());
            if ($autocron == 'yes') {
                $api_info = json_decode(SendPress_Cron::get_info());
                if (isset($api_info->lastcheck)) {
                    echo $api_info->lastcheck . " UTC";
                } else {
                    echo "No Data";
                }
            } else {
                echo "Not Enabled";
            }
            ?>
</p>
  </div>

</div>
<?php 
            if ($report) {
                $rec = get_post_meta($report->ID, '_send_last_count', true);
                $this->panel_start($report->post_title . " <small style='color:#333;'>" . __('This email had', 'sendpress') . " " . $rec . " " . __('Recipients', 'sendpress') . "</small>");
                $stat_type = get_post_meta($report->ID, '_stat_type', true);
                $clicks = SPNL()->db("Subscribers_Url")->clicks_email_id($report->ID);
                $clicks_total = SPNL()->db("Subscribers_Url")->clicks_total_email_id($report->ID);
                ?>

<div class="sp-row">
  <div class="sp-50 sp-first">
    <h4 style="text-align:center;"><?php 
                _e('Opens', 'sendpress');
                ?>
</h4>
      <?php 
                $this->panel_start();
                $open = 0;
                $rec = get_post_meta($report->ID, '_send_last_count', true);
                if ($report) {
                    if ($stat_type == 'new') {
                        $open = SPNL()->db("Subscribers_Tracker")->get_opens_total($report->ID);
                    } else {
                        $open = SendPress_Data::get_opens($report->ID);
                    }
                    $p = $open / $rec * 100;
                }
                ?>
        <div class="sp-row">
        <div class="sp-50 sp-first">
          <div style="float:left;">
          <div id="myStat" class="chartid" data-dimension="150" data-text="<?php 
                echo floor($p);
                ?>
%" data-info="Total Opens" data-width="15" data-fontsize="30" data-percent="<?php 
                echo floor($p);
                ?>
" data-fgcolor="#61a9dc" data-bgcolor="#eee" data-fill="#ddd" data-total="<?php 
                echo $rec;
                ?>
" data-part="<?php 
                echo $open;
                ?>
" data-icon="long-arrow-up" data-icon-size="28" data-icon-color="#fff"></div>
         </div>
         <div style="text-align:center;">
         <h5>Total</h5>
         <?php 
                echo $open;
                ?>
        </div>
        </div>
        <div class="sp-50">
        <?php 
                $ou = 0;
                if ($stat_type == 'new') {
                    $ou = SPNL()->db("Subscribers_Tracker")->get_opens($report->ID);
                } else {
                    $ou = SendPress_Data::get_opens_unique_total($report->ID);
                }
                $px = $ou / $rec * 100;
                ?>
        <div style="float:left;">
          <div id="myStat" class="chartid" data-dimension="150" data-text="<?php 
                echo floor($px);
                ?>
%" data-info="Unique Opens" data-width="15" data-fontsize="30" data-percent="35" data-fgcolor="#85d002" data-bgcolor="#eee" data-fill="#ddd" data-total="<?php 
                echo $rec;
                ?>
" data-part="<?php 
                echo $ou;
                ?>
" data-icon="long-arrow-up" data-icon-size="28" data-icon-color="#fff"></div>
        </div>
          <div style="text-align:center;">
          <h5>Unique</h5>
          <?php 
                echo $ou;
                ?>
          </div>
       </div>
       </div>
        
      <?php 
                $this->panel_end();
                ?>
  </div>
  <div class="sp-50">
  <h4 style="text-align:center;"><?php 
                _e('Clicks', 'sendpress');
                ?>
</h4>
    <?php 
                $this->panel_start();
                $click = 0;
                $rec = get_post_meta($report->ID, '_send_last_count', true);
                if ($report) {
                    if ($stat_type == 'new') {
                        $click = SPNL()->db("Subscribers_Url")->clicks_email_id($report->ID);
                    } else {
                        $click = SendPress_Data::get_clicks($report->ID);
                    }
                    $p = $click / $rec * 100;
                }
                ?>
     <div class="sp-row">
        <div class="sp-50 sp-first">
          <div style="float:left;">
          <div id="myStat" class="chartid" data-dimension="150" data-text="<?php 
                echo floor($p);
                ?>
%" data-info="Total Opens" data-width="15" data-fontsize="30" data-percent="<?php 
                echo floor($p);
                ?>
" data-fgcolor="#61a9dc" data-bgcolor="#eee" data-fill="#ddd" data-total="<?php 
                echo $rec;
                ?>
" data-part="<?php 
                echo $click;
                ?>
" data-icon="long-arrow-up" data-icon-size="28" data-icon-color="#fff"></div>
         </div>
         <div style="text-align:center;">
         <h5><?php 
                _e('Total', 'sendpress');
                ?>
</h5>
         <?php 
                echo $click;
                ?>
         </div>
        </div>
        <div class="sp-50">
        <?php 
                $ou = 0;
                if ($stat_type == 'new') {
                    $ou = SPNL()->db("Subscribers_Url")->clicks_total_email_id($report->ID);
                } else {
                    $ou = SendPress_Data::get_clicks_unique_total($report->ID);
                }
                $px = $ou / $rec * 100;
                ?>
        <div style="float:left;">
          <div id="myStat" class="chartid" data-dimension="150" data-text="<?php 
                echo floor($px);
                ?>
%" data-info="Unique Opens" data-width="15" data-fontsize="30" data-percent="35" data-fgcolor="#85d002" data-bgcolor="#eee" data-fill="#ddd" data-total="<?php 
                echo $rec;
                ?>
" data-part="<?php 
                echo $ou;
                ?>
" data-icon="long-arrow-up" data-icon-size="28" data-icon-color="#fff"></div>
        </div>
        <div style="text-align:center;">
          <h5><?php 
                _e('Unique', 'sendpress');
                ?>
</h5>
          <?php 
                echo $ou;
                ?>
         </div>
       </div>
       </div>
        
     <?php 
                $this->panel_end();
                ?>
  </div>
</div>
<?php 
                $this->panel_end();
            }
            ?>




<div class="sp-row">
<div class="sp-33 sp-first">
<div class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title"><?php 
            _e('Recent Subscribers', 'sendpress');
            ?>
</h3>
  </div>
  <div class="panel-body">
  	<table class="table table-striped table-condensed">
    <tr>
    <th>Date</th>
    <th>List</th>
    <th><div style="text-align:right;">Email</div></th>
    </tr>
  	<?php 
            $recent = SendPress_Data::get_recent_subscribers();
            foreach ($recent as $item) {
                echo "<tr>";
                echo "<td>";
                if (property_exists($item, 'subscriberID')) {
                    $d = SendPress_Data::get_subscriber($item->subscriberID);
                    if (property_exists($item, 'updated')) {
                        echo date_i18n("m.d.y", strtotime($item->updated));
                    }
                    echo "</td>";
                    echo "<td >";
                    if (property_exists($item, 'listID')) {
                        echo get_the_title($item->listID);
                    }
                    echo "</td>";
                    echo "<td align='right'>";
                    if (is_object($d)) {
                        echo $d->email . "<br>";
                    }
                    echo "</td>";
                    echo "</tr>";
                }
            }
            ?>
  </table>
  </div>
</div>
</div>
<div class="sp-33">
	<div class="panel panel-default">
	  <div class="panel-heading">
	    <h3 class="panel-title"><?php 
            _e('Most Active Subscribers', 'sendpress');
            ?>
</h3>
	  </div>
	  <div class="panel-body">
	  	<ul>
	  	<?php 
            $recent = SPNL()->db("Subscribers_Tracker")->get_most_active();
            // SendPress_Data::get_most_active_subscriber();
            foreach ($recent as $item) {
                if (property_exists($item, 'subscriber_id')) {
                    echo "<li>";
                    $d = SendPress_Data::get_subscriber($item->subscriber_id);
                    if (is_object($d)) {
                        echo $d->email;
                    }
                    echo "</li>";
                }
            }
            ?>
	  	</ul>
	  </div>
	</div>
</div>
<div class="sp-33">
  <?php 
            if (!defined('SENDPRESS_PRO_VERSION')) {
                ?>
	<div class="panel panel-default">
	  <div class="panel-heading">
	    <h3 class="panel-title"><?php 
                _e('Go Pro!', 'sendpress');
                ?>
</h3>
	  </div>
	  <div class="panel-body">
	  	<ul>
	  		<li><a href="http://sendpress.com/purchase-pricing/"><?php 
                _e('Advanced Reports', 'sendpress');
                ?>
</a></li>
	  		<li><a href="http://sendpress.com/purchase-pricing/"><?php 
                _e('Check Spam Scores', 'sendpress');
                ?>
</a></li>
	  		<li><a href="http://sendpress.com/purchase-pricing/"><?php 
                _e('Post Notifications', 'sendpress');
                ?>
</a></li>
	  	</ul>
   
	  </div>
	</div>
  <?php 
            }
            ?>
</div>
</div>

<script>
jQuery( document ).ready(function($) {
        $('.chartid').circliful();
    });
</script>
<!--
<div class="panel panel-default">
  <div class="panel-body">
   <h2>Welcome to SendPress</h2>
  </div>
</div>

-->
<?php 
            if (SendPress_Option::get('feedback') == 'yes' || SendPress_Option::get('allow_tracking') == 'yes') {
                SendPress_Tracking::data();
            }
        }
    function html($sp)
    {
        //SendPress_Option::set('pro_plugins','');
        SendPress_Tracking::event('Pro Tab');
        ?>
        <div class="pro-header" >
            <form method="post" id="post" style="float:right;">
            <?php 
        $sppro = new SendPress_Module_Pro();
        $sppro->buttons('sendpress-pro/sendpress-pro.php');
        ?>
 
            <input type="hidden" name="plugin_path" value="sendpress-pro/sendpress-pro.php" />
            <input class="action" type="hidden" name="action" value="module-activate-sendpress-pro" />
            <?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
        </form>
    <h1 style="font-size:35px;">SendPress Pro
    <?php 
        if (defined('SENDPRESS_PRO_VERSION')) {
            echo "<small>v" . SENDPRESS_PRO_VERSION . "</small>";
        }
        ?>
    </h1>
    <?php 
        if (is_plugin_active('sendpress-pro/sendpress-pro.php')) {
            ?>
        <p class="lead">Thanks for using <b>SendPress Pro</b>.</p>
    <?php 
        } else {
            ?>
 
        <p class="lead">Take your emails to the next level. <b>SendPress Pro</b> allows you to build an email marketing system tailored to your needs. All within WordPress with no need for an external system.</p>
    <?php 
        }
        ?>
    </div>
                <?php 
        $modules = apply_filters('sendpress_pro_modules', array('sendgrid', 'mailjet', 'customsmtp', 'amazonses', 'mandrill', 'elastic', 'empty', 'empty', 'empty'));
        echo '<div class="sendpress-addons">';
        $p = new SendPress_Module_Pro();
        $p->index(0);
        $p->render($this);
        $i = 1;
        echo "<h2 class='clear' style='padding-left: 18px; padding-top: 30px; padding-bottom: 10px;'>Sending Options</h2>";
        foreach ($modules as $mod) {
            $mod_class = $this->get_module_class($mod);
            if ($mod_class) {
                $mod_class = new $mod_class();
                $mod_class->index($i);
                $mod_class->render($this);
                $i++;
            }
        }
        echo '<br class="clear"><br></div>';
        ?>
        <!--
        <h2 class="clear" style="padding-left: 18px; padding-top: 30px; padding-bottom: 10px;">Addons</h2>
        <div class="sendpress-module  mod-first"><div class="inner-module">
        <h4>WordPress Emails</h4>
            <form method="post" id="post">
            <div class="description">
                Wrap WordPress system emails in a SendPress template and send them via your sending settings.
                <br><br>
                
            </div>
            <?php 
        $d = get_option('sendpress_wp_mail', false);
        $sp = is_plugin_active('sendpress-pro/sendpress-pro.php');
        ?>


            <div class="inline-buttons">
            <?php 
        if ($sp) {
            if ($d === false) {
                ?>
                    <a class=" btn-success btn-activate btn" href="<?php 
                echo SendPress_Admin::link('Pro', array('action' => 'wp-mail', 'enable' => true));
                ?>
">Activate</a>
                <?php 
            } else {
                ?>
                    <a class="btn btn-default " href="<?php 
                echo SendPress_Admin::link('Pro', array('action' => 'wp-mail', 'enable' => false));
                ?>
">Deactivate</a>&nbsp;<a class="btn btn-default module-deactivate-plugin" href="#">Settings</a>
                <?php 
            }
            ?>
            <?php 
        } else {
            ?>
                <a class="btn disabled btn-default btn-activate" href="#">Activate</a>
            <?php 
        }
        ?>
            </div>         
            
            </div>
        </div>
        -->
          <br class="clear">
        <br><br>

        <?php 
    }
    function display_forms()
    {
        SendPress_Tracking::event('Emails Tab');
        //Create an instance of our package class...
        $testListTable = new SendPress_Settings_Forms_Table();
        //Fetch, prepare, sort, and filter our data...
        $testListTable->prepare_items();
        ?>
		
		<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
		<form id="forms-filter" method="get">
			<div id="taskbar" class="lists-dashboard rounded group"> 
				<div id="button-area">  
					<a class="btn btn-primary btn-large" href="?page=<?php 
        echo SPNL()->validate->page($_REQUEST['page']);
        ?>
&view=widgets&create=1"><?php 
        _e('Create Form', 'sendpress');
        ?>
</a>
				</div>
				<h2><?php 
        _e('Forms', 'sendpress');
        ?>
</h2>
			</div>
			<!-- For plugins, we also need to ensure that the form posts back to our current page -->
		    <input type="hidden" name="page" value="<?php 
        echo SPNL()->validate->page($_REQUEST['page']);
        ?>
" />
		    <!-- Now we can render the completed list table -->
		    <?php 
        $testListTable->display();
        ?>
		    <?php 
        wp_nonce_field($this->_nonce_value);
        ?>
		</form>
		<?php 
    }
    function html($sp)
    {
        SendPress_Tracking::event('Queue Tab');
        if (isset($_GET['cron'])) {
            $sp->fetch_mail_from_queue();
        }
        //Create an instance of our package class...
        $testListTable = new SendPress_Queue_Table();
        //Fetch, prepare, sort, and filter our data...
        $testListTable->prepare_items();
        SendPress_Option::set('no_cron_send', 'false');
        //$sp->fetch_mail_from_queue();
        $sp->cron_start();
        //echo $sp->get_key(). "<br>";
        $open_info = array("id" => 13, "report" => 10, "view" => "open");
        /*
        		$x = $sp->encrypt_data($open_info);
        
        	echo $x."<br>";
        	$x = $sp->decrypt_data($x);
        
        	print_r($x);
        		echo "<br>";
        
        	$d = $_GET['t'];
        	$x = $sp->decrypt_data($d);
        
        	print_r($x->id);
        		echo "<br>";
        	
        	
        	//echo wp_get_schedule('sendpress_cron_action_run');
        	//
        	$time_delay =  SendPress_Option::get('time-delay');
        	echo $time_delay;
        	echo date('l jS \of F Y H:i:s A',$time_delay );
        	echo "<br>";
        	$time = date('H:i:s');
        
        echo $time;//11:09
        	$time = date('H:i:s', $time_delay);
        
        echo $time;//11:09
        */
        $autocron = SendPress_Option::get('autocron', 'no');
        if ($autocron == 'yes') {
            $api_info = json_decode(SendPress_Cron::get_info());
            if (isset($api_info->active) && $api_info->active === 0) {
                echo "<p class='alert alert-danger'><strong>Oh no!</strong> It looks like AutoCron disconnected itself. To get max send speed please re-enable it <a href='" . SendPress_Admin::link('Settings_Account') . "'>here</a>.</p>";
                delete_transient('sendpress_autocron_cache');
                SendPress_Option::set('autocron', 'no');
            } else {
                if (isset($api_info->lastcheck)) {
                    echo "<p class='alert alert-success'><strong>Looking good!</strong> Autocron is running and last checked your site at:&nbsp;" . $api_info->lastcheck . " UTC</p>";
                }
            }
        } else {
            echo "<p class='alert alert-info'><strong>Howdy.</strong> It looks like AutoCron was not enabled or it disconnected itself. To get max send speed please re-enable it <a href='" . SendPress_Admin::link('Settings_Account') . "'>here</a>.</p>";
        }
        ?>

<br>
	<div id="taskbar" class="lists-dashboard rounded group"> 

	<div id="button-area">  
	<?php 
        $pause_sending = SendPress_Option::get('pause-sending', 'no');
        $txt = __('Pause Sending', 'sendpress');
        //Stop Sending for now
        if ($pause_sending == 'yes') {
            $txt = __('Resume Sending', 'sendpress');
        }
        ?>
	<div class="btn-group">
	<a class="btn btn-large btn-default " href="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
&action=pause-queue" ><i class="icon-repeat icon-white "></i> <?php 
        echo $txt;
        ?>
</a>

	<a id="send-now" class="btn btn-primary btn-large " data-toggle="modal" href="#sendpress-sending"   ><i class="icon-white icon-refresh"></i> <?php 
        _e('Send Emails Now', 'sendpress');
        ?>
</a>
	</div>
	</div>
	<?php 
        $emails_per_day = SendPress_Option::get('emails-per-day');
        if ($emails_per_day == 0) {
            $emails_per_day = __('Unlimited', 'sendpress');
        }
        $emails_per_hour = SendPress_Option::get('emails-per-hour');
        $hourly_emails = SendPress_Data::emails_sent_in_queue("hour");
        $emails_so_far = SendPress_Data::emails_sent_in_queue("day");
        //print_r(SendPress_Data::emails_stuck_in_queue());
        ?>

		
		<h2><strong><?php 
        echo $emails_so_far;
        ?>
</strong> <?php 
        _e('of a possible', 'sendpress');
        ?>
 <strong><?php 
        echo $emails_per_day;
        ?>
</strong> <?php 
        _e('emails sent in the last 24 hours', 'sendpress');
        ?>
.</h2>
		<h2><strong><?php 
        echo $hourly_emails;
        ?>
</strong> <?php 
        _e('of a possible', 'sendpress');
        ?>
 <strong><?php 
        echo $emails_per_hour;
        ?>
</strong> <?php 
        _e('emails sent in the last hour', 'sendpress');
        ?>
.</h2>
		<small><?php 
        _e('You can adjust these settings here', 'sendpress');
        ?>
: <a href="<?php 
        echo SendPress_Admin::link('Settings_Account');
        ?>
"><?php 
        _e('Settings', 'sendpress');
        ?>
 > <?php 
        _e('Sending Account', 'sendpress');
        ?>
</a>.</small>
 		<?php 
        if ($autocron == 'no') {
            $offset = get_option('gmt_offset') * 60 * 60;
            // Time offset in seconds
            $local_timestamp = wp_next_scheduled('sendpress_cron_action') + $offset;
            ?>
<br><small><?php 
            _e('The cron will run again around', 'sendpress');
            ?>
: <?php 
            echo date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $local_timestamp);
            ?>
</small>
<?php 
        }
        ?>
 		<br><br>
		</div>
	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form id="email-filter" action="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
" method="get">
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	     <input type="hidden" name="page" value="<?php 
        echo SPNL()->validate->page($_REQUEST['page']);
        ?>
" /> 
	    <!-- Now we can render the completed list table -->
	    <?php 
        $testListTable->display();
        ?>
	    <?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>
	<br>
	<!--
		<a class="btn btn-large btn-success " href="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
&action=reset-queue" ><i class="icon-repeat icon-white "></i> <?php 
        _e('Re-queue All Emails', 'sendpress');
        ?>
</a><br><br>
	-->
	<form  method='get'>
		<input type='hidden' value="<?php 
        echo SPNL()->validate->page($_GET['page']);
        ?>
" name="page" />
		
		<input type='hidden' value="empty-queue" name="action" />
		<a class="btn btn-large  btn-danger" data-toggle="modal" href="#sendpress-empty-queue" ><i class="icon-warning-sign "></i> <?php 
        _e('Delete All Emails in the Queue', 'sendpress');
        ?>
</a>
		<?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>
<div class="modal fade" id="sendpress-empty-queue" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
  	<div class="modal-content">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal">×</button>
		<h3><?php 
        _e('Really? Delete All Emails in the Queue.', 'sendpress');
        ?>
</h3>
	</div>
	<div class="modal-body">
		<p><?php 
        _e('This will remove all emails from the queue without attempting to send them', 'sendpress');
        ?>
.</p>
	</div>
	<div class="modal-footer">
	<a href="#" class="btn btn-primary" data-dismiss="modal"><?php 
        _e('No! I was Joking', 'sendpress');
        ?>
</a><a href="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
&action=empty-queue" id="confirm-delete" class="btn btn-danger" ><?php 
        _e('Yes! Delete All Emails', 'sendpress');
        ?>
</a>
	</div>
</div></div>
</div>

<div class="modal fade" id="sendpress-sending" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
	<div class="modal-content">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">×</button>
    <h3><?php 
        _e('Sending Emails', 'sendpress');
        ?>
</h3>
  </div>
  <div class="modal-body">
    <div id="sendbar" class="progress progress-striped
     active">
  <div id="sendbar-inner" class="progress-bar"
       style="width: 40%;"></div>
</div>
	<span id="queue-sent">-</span> <?php 
        _e('of', 'sendpress');
        ?>
 <span id="queue-total">-</span> <?php 
        _e('emails left to send', 'sendpress');
        ?>
.<br>
	<br>
	<?php 
        _e('You are also limited to', 'sendpress');
        ?>
 <?php 
        echo $hour;
        ?>
 <?php 
        _e('emails per hour', 'sendpress');
        ?>
.<br>
	<?php 
        _e('To change these settings go to', 'sendpress');
        ?>
 <a href="<?php 
        echo SendPress_Admin::link('Settings_Account');
        ?>
"> <?php 
        _e('Settings', 'sendpress');
        ?>
 > <?php 
        _e('Sending Account', 'sendpress');
        ?>
</a>.
  </div>
  <div class="modal-footer">
   <?php 
        _e('If you close this window sending will stop. ', 'sendpress');
        ?>
<a href="#" class="btn btn-primary" data-dismiss="modal"><?php 
        _e('Close', 'sendpress');
        ?>
</a>
  </div>
</div>
</div></div>
<?php 
    }
    function html($sp)
    {
        SendPress_Tracking::event('Help Tab');
        global $wp_version;
        $screen = get_current_screen();
        $class = 'columns-2';
        //. get_current_screen()->get_columns();
        ?>
<div id="dashboard-widgets" class="metabox-holder clearfix <?php 
        echo $class;
        ?>
">
	<div id='postbox-container-1' class='postbox-container'>
	<?php 
        do_meta_boxes($screen->id, 'normal', '');
        ?>
	</div>
	<div id='postbox-container-2' class='postbox-container'>
	<?php 
        do_meta_boxes($screen->id, 'side', '');
        ?>
	</div>
	<div id='postbox-container-3' class='postbox-container'>
	<?php 
        do_meta_boxes($screen->id, 'column3', '');
        ?>
	</div>
	<div id='postbox-container-4' class='postbox-container'>
	<?php 
        do_meta_boxes($screen->id, 'column4', '');
        ?>
	</div>
</div>

<?php 
        wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
        wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
    }
    function sub_menu($sp = false)
    {
        SendPress_Tracking::event('Settings Tab');
        ?>

	<div class="navbar navbar-default" >

		<div class="pull-right  top-action-buttons navbar-right btn-group">
			<?php 
        $this->view_buttons();
        ?>
		</div>
		<div class="navbar-header">

		<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
		 <span class="sr-only"><?php 
        _e('Toggle navigation', 'sendpress');
        ?>
</span>
		<span class="icon-bar"></span>
		<span class="icon-bar"></span>
		<span class="icon-bar"></span>

		</button>
		<a class="navbar-brand" href="#"><?php 
        _e('Settings', 'sendpress');
        ?>
</a>
		</div>
		 <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
		<ul class="nav navbar-nav">
			<!--
		  <li <?php 
        if ($sp->_current_view == '') {
            ?>
class="active"<?php 
        }
        ?>
 ><a href="<?php 
        echo SendPress_Admin::link('Settings');
        ?>
"><i class="icon-envelope"></i> <?php 
        _e('Basic Setup', 'sendpress');
        ?>
</a></li>
		 -->
		  <!--
		   <li <?php 
        if ($sp->_current_view == 'shared') {
            ?>
class="active"<?php 
        }
        ?>
 >
		    <a href="<?php 
        echo SendPress_Admin::link('Settings_Shared');
        ?>
"><i class="icon-pencil "></i> <?php 
        _e('Shared Content', 'sendpress');
        ?>
</a>
		  </li>
		  -->
		<li <?php 
        if ($sp->_current_view == 'account') {
            ?>
class="active"<?php 
        }
        ?>
 ><a href="<?php 
        echo SendPress_Admin::link('Settings_Account');
        ?>
"><i class="icon-envelope "></i> <?php 
        _e('Sending', 'sendpress');
        ?>
</a></li>
		<li <?php 
        if ($sp->_current_view == 'activation') {
            ?>
class="active"<?php 
        }
        ?>
 ><a <?php 
        if ($sp->_current_view == 'activation') {
            ?>
class="wp-ui-primary"<?php 
        }
        ?>
  href="<?php 
        echo SendPress_Admin::link('Settings_Activation');
        ?>
"><i class=" icon-bullhorn"></i> <?php 
        _e('Confirmation', 'sendpress');
        ?>
</a></li>
		<!--
		<li <?php 
        if (strpos($sp->_current_view, 'systememail') !== false) {
            ?>
class="active"<?php 
        }
        ?>
 ><a <?php 
        if (strpos($sp->_current_view, 'systememail') !== false) {
            ?>
class="wp-ui-primary"<?php 
        }
        ?>
  href="<?php 
        echo SendPress_Admin::link('Settings_Systememail');
        ?>
"><i class=" icon-bullhorn"></i> <?php 
        _e('System Email', 'sendpress');
        ?>
</a></li>
		-->
		<li <?php 
        if ($sp->_current_view == 'access') {
            ?>
class="active"<?php 
        }
        ?>
 ><a href="<?php 
        echo SendPress_Admin::link('Settings_Access');
        ?>
"><i class="icon-user "></i> <?php 
        _e('Permissions', 'sendpress');
        ?>
</a></li>
		<li <?php 
        if ($sp->_current_view == 'notifications') {
            ?>
class="active"<?php 
        }
        ?>
 ><a href="<?php 
        echo SendPress_Admin::link('Settings_Notifications');
        ?>
"><i class="icon-bell"></i> <?php 
        _e('Notifications', 'sendpress');
        ?>
</a></li>
		<li <?php 
        if ($sp->_current_view == 'widgets') {
            ?>
class="active"<?php 
        }
        ?>
 ><a href="<?php 
        echo SendPress_Admin::link('Settings_Widgets');
        ?>
"><i class=" icon-wrench "></i> <?php 
        _e('Forms', 'sendpress');
        ?>
</a></li>
		<li <?php 
        if ($sp->_current_view == 'advanced') {
            ?>
class="active"<?php 
        }
        ?>
 ><a href="<?php 
        echo SendPress_Admin::link('Settings_Advanced');
        ?>
"><i class=" icon-wrench "></i> <?php 
        _e('Advanced', 'sendpress');
        ?>
</a></li>
		<li <?php 
        if ($sp->_current_view == 'styles') {
            ?>
class="active wp-ui-primary"<?php 
        }
        ?>
 >
		    <a href="<?php 
        echo SendPress_Admin::link('Settings_Styles');
        ?>
"><i class="icon-pencil "></i> <?php 
        _e('Styles', 'sendpress');
        ?>
</a>
		 </li>
		 
		<?php 
        do_action('sendpress_view_settings_menu', $sp->_current_view);
        ?>

		</ul>

	</div>
</div>
	<?php 
    }
    function html()
    {
        SendPress_Tracking::event('Queue Tab');
        if (SPNL()->validate->_isset('cron')) {
            SPNL()->fetch_mail_from_queue();
        }
        //Create an instance of our package class...
        $testListTable = new SendPress_Queue_Table();
        //Fetch, prepare, sort, and filter our data...
        $testListTable->prepare_items();
        SendPress_Option::set('no_cron_send', 'false');
        SPNL()->cron_start();
        $open_info = array("id" => 13, "report" => 10, "view" => "open");
        $autocron = SendPress_Option::get('autocron', 'no');
        ?>

<br>
	<div id="taskbar" class="lists-dashboard rounded group"> 

	<div id="button-area">  
	<?php 
        $pause_sending = SendPress_Option::get('pause-sending', 'no');
        $txt = __('Pause Sending', 'sendpress');
        //Stop Sending for now
        if ($pause_sending == 'yes') {
            $txt = __('Resume Sending', 'sendpress');
        }
        ?>
	<div class="btn-group">

       <?php 
        if (SendPress_Option::get('emails-credits') && SendPress_Option::get('sendmethod') === 'Jaiminho_Sender_NetWork' || SendPress_Option::get('sendmethod') != 'Jaiminho_Sender_NetWork') {
            SendPress_Option::set('pause-sending', 'no');
            ?>
          <a class="btn btn-large btn-default " href="<?php 
            echo SendPress_Admin::link('Queue');
            ?>
&action=pause-queue" ><i class="icon-repeat icon-white "></i> <?php 
            echo $txt;
            ?>
</a>
          <a id="send-now" class="btn btn-primary btn-large " data-toggle="modal" href="#sendpress-sending"   ><i class="icon-white icon-refresh"></i> <?php 
            _e('Send Emails Now', 'sendpress');
            ?>
</a>
	</div>
	</div>
	<?php 
        } else {
            SendPress_Option::set('pause-sending', 'yes');
        }
        $emails_per_day = SendPress_Option::get('emails-per-day');
        if ($emails_per_day == 0) {
            $emails_per_day = __('Unlimited', 'sendpress');
        }
        $emails_per_hour = SendPress_Option::get('emails-per-hour');
        $hourly_emails = SendPress_Data::emails_sent_in_queue("hour");
        $emails_so_far = SendPress_Data::emails_sent_in_queue("day");
        $credits = SendPress_Option::get('emails-credits');
        //print_r(SendPress_Data::emails_stuck_in_queue());
        global $wpdb;
        $table = SendPress_Data::queue_table();
        $date = getdate();
        // Maurilio TODO: fazer com os créditos sejam contados a partir da 00:00:00 do primeiro dia do mês atual
        $hour_ago = strtotime('-' . $date["mday"] . ' day');
        $time = date('Y-m-d H:i:s', $hour_ago);
        $query = $wpdb->prepare("SELECT COUNT(*) FROM {$table} where last_attempt > %s and success = %d", $time, 1);
        $credits_so_far = $wpdb->get_var($query);
        $result_credits = $credits - $credits_so_far;
        if ($credits <= 0) {
            echo "<p class='alert alert-danger' style='width:70%;'>" . __("Vixe! Você não tem créditos. Para enviar emails em sua fila ou enviar novos emails, você precisa obter mais créditos.", "jaiminho") . "</p>";
        } else {
            ?>
        <h2><?php 
            echo $credits ? __('Você tem', 'jaiminho') : "";
            ?>
        <strong><?php 
            echo $result_credits ? $result_credits : "";
            ?>
</strong> <?php 
            echo $credits ? __('créditos', 'jaiminho') : "";
            ?>
.
        </h2>
        <?php 
        }
        ?>
       
      <h2><strong><?php 
        echo $emails_so_far;
        ?>
</strong> <?php 
        _e('of a possible', 'sendpress');
        ?>
 <strong><?php 
        echo $emails_per_day;
        ?>
</strong> <?php 
        _e('emails sent in the last 24 hours', 'sendpress');
        ?>
.</h2>
      <h2><strong><?php 
        echo $hourly_emails;
        ?>
</strong> <?php 
        _e('of a possible', 'sendpress');
        ?>
 <strong><?php 
        echo $emails_per_hour;
        ?>
</strong> <?php 
        _e('emails sent in the last hour', 'sendpress');
        ?>
.</h2>
      <?php 
        if (is_multisite() && is_super_admin() || !is_multisite()) {
            ?>
      <small><?php 
            _e('You can adjust these settings here', 'sendpress');
            ?>
: <a href="<?php 
            echo SendPress_Admin::link('Settings_Account');
            ?>
"><?php 
            _e('Settings', 'sendpress');
            ?>
 > <?php 
            _e('Sending Account', 'sendpress');
            ?>
</a>.</small>
                 <?php 
        }
        ?>
 		<?php 
        if ($autocron == 'no') {
            $offset = get_option('gmt_offset') * 60 * 60;
            // Time offset in seconds
            $local_timestamp = wp_next_scheduled('sendpress_cron_action') + $offset;
            ?>
<br><small><?php 
            _e('The cron will run again around', 'sendpress');
            ?>
: <?php 
            echo date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $local_timestamp);
            ?>
</small>
<?php 
        }
        ?>
 		<br><br>
		</div>
	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form id="email-filter" action="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
" method="get">
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	     <input type="hidden" name="page" value="<?php 
        echo SPNL()->validate->page();
        ?>
" /> 
	    <!-- Now we can render the completed list table -->
	    <?php 
        $testListTable->display();
        ?>
	    <?php 
        wp_nonce_field($this->_nonce_value);
        ?>
	</form>
	<br>
	<!--
		<a class="btn btn-large btn-success " href="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
&action=reset-queue" ><i class="icon-repeat icon-white "></i> <?php 
        _e('Re-queue All Emails', 'sendpress');
        ?>
</a><br><br>
	-->
	<form  method='get'>
		<input type='hidden' value="<?php 
        echo SPNL()->validate->page();
        ?>
" name="page" />
		
		<input type='hidden' value="empty-queue" name="action" />
		<a class="btn btn-large  btn-danger" data-toggle="modal" href="#sendpress-empty-queue" ><i class="icon-warning-sign "></i> <?php 
        _e('Delete All Emails in the Queue', 'sendpress');
        ?>
</a>
		<?php 
        wp_nonce_field($this->_nonce_value);
        ?>
	</form>
<div class="modal fade" id="sendpress-empty-queue" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
  	<div class="modal-content">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal">×</button>
		<h3><?php 
        _e('Really? Delete All Emails in the Queue.', 'sendpress');
        ?>
</h3>
	</div>
	<div class="modal-body">
		<p><?php 
        _e('This will remove all emails from the queue without attempting to send them', 'sendpress');
        ?>
.</p>
	</div>
	<div class="modal-footer">
	<a href="#" class="btn btn-primary" data-dismiss="modal"><?php 
        _e('No! I was Joking', 'sendpress');
        ?>
</a><a href="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
&action=empty-queue" id="confirm-delete" class="btn btn-danger" ><?php 
        _e('Yes! Delete All Emails', 'sendpress');
        ?>
</a>
	</div>
</div></div>
</div>

<div class="modal fade" id="sendpress-sending" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
	<div class="modal-content">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">×</button>
    <h3><?php 
        _e('Sending Emails', 'sendpress');
        ?>
</h3>
  </div>
  <div class="modal-body">
    <div id="sendbar" class="progress progress-striped
     active">
  <div id="sendbar-inner" class="progress-bar"
       style="width: 40%;"></div>
</div>
	<span id="queue-sent">-</span> <?php 
        _e('of', 'sendpress');
        ?>
 <span id="queue-total">-</span> <?php 
        _e('emails left to send', 'sendpress');
        ?>
.<br>
	<br>
	<?php 
        _e('You are also limited to', 'sendpress');
        ?>
 <?php 
        echo $emails_per_hour;
        ?>
 <?php 
        _e('emails per hour', 'sendpress');
        ?>
.<br>
	<?php 
        _e('To change these settings go to', 'sendpress');
        ?>
 <a href="<?php 
        echo SendPress_Admin::link('Settings_Account');
        ?>
"> <?php 
        _e('Settings', 'sendpress');
        ?>
 > <?php 
        _e('Sending Account', 'sendpress');
        ?>
</a>.
  </div>
  <div class="modal-footer">
   <?php 
        _e('If you close this window sending will stop. ', 'sendpress');
        ?>
<a href="#" class="btn btn-primary" data-dismiss="modal"><?php 
        _e('Close', 'sendpress');
        ?>
</a>
  </div>
</div>
</div></div>
<?php 
    }
    function html($sp)
    {
        SendPress_Tracking::event('Lists Tab');
        //Create an instance of our package class...
        $testListTable = new SendPress_Lists_Table();
        //Fetch, prepare, sort, and filter our data...
        $testListTable->prepare_items();
        ?>
		<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
		<div id="button-area">  
			<a class="btn btn-primary btn-large" href="?page=<?php 
        echo $_REQUEST['page'];
        ?>
&view=listcreate"><?php 
        _e('Create List', 'sendpress');
        ?>
</a>
		</div>
		<h2><?php 
        _e('Lists', 'sendpress');
        ?>
</h2>
		<form id="sendpress-lists" method="get">
			<!-- For plugins, we also need to ensure that the form posts back to our current page -->
		    <input type="hidden" name="page" value="<?php 
        echo $_REQUEST['page'];
        ?>
" />
		    <!-- Now we can render the completed list table -->
		    <?php 
        $testListTable->display();
        ?>
		    <?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
		</form>
	<?php 
    }
    function html($sp)
    {
        SendPress_Tracking::event('Queue Tab');
        if (isset($_GET['cron'])) {
            $sp->fetch_mail_from_queue();
        }
        //Create an instance of our package class...
        $testListTable = new SendPress_Queue_All_Table();
        //Fetch, prepare, sort, and filter our data...
        $testListTable->prepare_items();
        SendPress_Option::set('no_cron_send', 'false');
        //$sp->fetch_mail_from_queue();
        $sp->cron_start();
        //echo $sp->get_key(). "<br>";
        $open_info = array("id" => 13, "report" => 10, "view" => "open");
        /*
        		$x = $sp->encrypt_data($open_info);
        
        	echo $x."<br>";
        	$x = $sp->decrypt_data($x);
        
        	print_r($x);
        		echo "<br>";
        
        	$d = $_GET['t'];
        	$x = $sp->decrypt_data($d);
        
        	print_r($x->id);
        		echo "<br>";
        	
        	
        	//echo wp_get_schedule('sendpress_cron_action_run');
        	//
        	$time_delay =  SendPress_Option::get('time-delay');
        	echo $time_delay;
        	echo date('l jS \of F Y H:i:s A',$time_delay );
        	echo "<br>";
        	$time = date('H:i:s');
        
        echo $time;//11:09
        	$time = date('H:i:s', $time_delay);
        
        echo $time;//11:09
        */
        ?>
<h2><?php 
        _e('Queue history for the last ', 'sendpress');
        ?>
 <strong><?php 
        echo SendPress_Option::get('queue-history', 7);
        ?>
</strong> <?php 
        _e('Days', 'sendpress');
        ?>
.</h2>
		<small><?php 
        _e('You can adjust these settings here', 'sendpress');
        ?>
: <a href="<?php 
        echo SendPress_Admin::link('Settings_Advanced');
        ?>
"><?php 
        _e('Settings', 'sendpress');
        ?>
 > <?php 
        _e('Advanced', 'sendpress');
        ?>
</a>.</small>
 		<br><br>
	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form id="email-filter" action="<?php 
        echo SendPress_Admin::link('Queue_All');
        ?>
" method="get">
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	     <input type="hidden" name="page" value="<?php 
        echo $_REQUEST['page'];
        ?>
" /> 
	       <?php 
        if (isset($_GET['listID']) && $_GET['listID'] > 0) {
            ?>
	    <input type="hidden" name="listID" value="<?php 
            echo $_GET['listID'];
            ?>
" />
	    <?php 
        }
        ?>
	    <input type="hidden" name="view" value="<?php 
        echo $_GET['view'];
        ?>
" />
	    <!-- Now we can render the completed list table -->
	    <?php 
        $testListTable->display();
        ?>
	    <?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>
	<br>
	
	<form  method='get'>
		<input type='hidden' value="<?php 
        echo $_GET['page'];
        ?>
" name="page" />
		
		
		<?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>

<?php 
    }
    function html($sp)
    {
        SendPress_Tracking::event('Queue Tab');
        //Create an instance of our package class...
        $testListTable = new SendPress_Queue_All_Table();
        //Fetch, prepare, sort, and filter our data...
        $testListTable->prepare_items();
        SendPress_Option::set('no_cron_send', 'false');
        $sp->cron_start();
        //echo $sp->get_key(). "<br>";
        $open_info = array("id" => 13, "report" => 10, "view" => "open");
        ?>
<h2><?php 
        _e('Queue history for the last ', 'sendpress');
        ?>
 <strong><?php 
        echo SendPress_Option::get('queue-history', 7);
        ?>
</strong> <?php 
        _e('Days', 'sendpress');
        ?>
.</h2>
		<small><?php 
        _e('You can adjust these settings here', 'sendpress');
        ?>
: <a href="<?php 
        echo SendPress_Admin::link('Settings_Advanced');
        ?>
"><?php 
        _e('Settings', 'sendpress');
        ?>
 > <?php 
        _e('Advanced', 'sendpress');
        ?>
</a>.</small>
 		<br><br>
	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form id="email-filter" action="<?php 
        echo SendPress_Admin::link('Queue_All');
        ?>
" method="get">
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	     <input type="hidden" name="page" value="<?php 
        echo SPNL()->validate->page($_REQUEST['page']);
        ?>
" /> 
	       <?php 
        if (isset($_GET['listID']) && $_GET['listID'] > 0) {
            ?>
	    <input type="hidden" name="listID" value="<?php 
            echo SPNL()->validate->int($_POST['listID']);
            ?>
" />
	    <?php 
        }
        ?>
	    <input type="hidden" name="view" value="<?php 
        echo esc_html($_GET['view']);
        ?>
" />
	    <!-- Now we can render the completed list table -->
	    <?php 
        $testListTable->display();
        ?>
	    <?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>
	<br>
	
	<form  method='get'>
		<input type='hidden' value="<?php 
        echo SPNL()->validate->page($_GET['page']);
        ?>
" name="page" />
		
		
		<?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>

<?php 
    }
 function html($sp)
 {
     SendPress_Tracking::event('Emails Tab');
 }
        function html($sp)
        {
            //SendPress_Template_Manager::update_template_content();
            SendPress_Tracking::event('Overview Tab');
            //print_r( SendPress_Data::get_subcribers_by_meta('test','test') );
            //echo wp_next_scheduled('wysija_cron_queue') . 'asdf';
            //SPNL()->db->subscribers_tracker->add( array('subscriber_id'=> 101, 'email_id'=> 20 ) );
            //SPNL()->db->subscribers_url->add_update( array('subscriber_id'=> 101, 'email_id'=> 20 , 'url_id' => 123 ) );
            //SPNL()->log->add(  'Email Skiped' , 'Email test',' did not have any Text.', 'sending');
            //print_r(_get_cron_array());
            global $wp_version;
            $classes = 'sp-welcome-panel';
            $option = get_user_meta(get_current_user_id(), 'show_sp_welcome_panel', true);
            // 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner
            $hide = 0 == $option || 2 == $option && wp_get_current_user()->user_email != get_option('admin_email');
            //if ( $hide )
            //	$classes .= ' hidden';
            /*
            $args = array( 'post_type' => 'sendpress_list','numberposts'     => -1,
            	    'offset'          => 0,
            	    'orderby'         => 'post_title',
            	    'order'           => 'DESC', );
            		$lists = get_posts( $args );
            $sp->send_optin(1,array('1','2','3'),$lists);
            */
            list($display_version) = explode('-', $wp_version);
            //SendPress_Template_Manager::update_template_content();
            /*
            
            
            
            echo spnl_do_email_tags( 'here is some {subscriber_list} content that should run tags' , 0 , 0 );
            
            
            SPNL()->log->add('Bad Email','This email can not be sent');
            echo "<pre>";
            print_r( SPNL()->log->get_logs() );
            echo "</pre>";
            */
            ?>
<br>



<div class="sp-row ">

  <div class="sp-block sp-25 sp-first"> 
    <h2 class="nomargin nopadding"><?php 
            echo SendPress_Data::bd_nice_number(SendPress_Data::get_total_subscribers());
            ?>
</h2> <p class="fwb"><?php 
            _e('Subscribers', 'sendpress');
            ?>
</p>  
  </div>
  <div class="sp-block sp-25">
    <h2 class="nomargin nopadding"><?php 
            $report = SendPress_Data::get_last_report();
            echo SendPress_Data::emails_active_in_queue();
            ?>
</h2> <p class="fwb"><?php 
            _e('Emails Actively Sending', 'sendpress');
            ?>
</small></p>
  </div>
  <div class="sp-block sp-25">
    <h2 class="nomargin nopadding"><?php 
            echo SendPress_Data::emails_maxed_in_queue();
            ?>
</h2> <p class="fwb"><?php 
            _e('Emails Stuck in Queue', 'sendpress');
            ?>
</p>
  </div>
  <div class="sp-block sp-25">
    <h2 class="nomargin nopadding"><?php 
            _e('Autocron last check', 'sendpress');
            ?>
</h2> <p class="fwb">  <?php 
            $autocron = SendPress_Option::get('autocron', 'no');
            //print_r(SendPress_Data::emails_stuck_in_queue());
            if ($autocron == 'yes') {
                $api_info = json_decode(SendPress_Cron::get_info());
                if (isset($api_info->lastcheck)) {
                    echo $api_info->lastcheck . " UTC";
                } else {
                    echo "No Data";
                }
            } else {
                echo "Not Enabled";
            }
            ?>
</p>
  </div>

</div>
<?php 
            if ($report) {
                $rec = get_post_meta($report->ID, '_send_last_count', true);
                $this->panel_start($report->post_title . " <small style='color:#333;'>" . __('This email had', 'sendpress') . " " . $rec . " " . __('Recipients', 'sendpress') . "</small>");
                $stat_type = get_post_meta($report->ID, '_stat_type', true);
                $clicks = SPNL()->db->subscribers_url->clicks_email_id($report->ID);
                $clicks_total = SPNL()->db->subscribers_url->clicks_total_email_id($report->ID);
                ?>

<div class="sp-row">
  <div class="sp-50 sp-first">
    <h4 style="text-align:center;"><?php 
                _e('Opens', 'sendpress');
                ?>
</h4>
      <?php 
                $this->panel_start();
                $open = 0;
                $rec = get_post_meta($report->ID, '_send_last_count', true);
                if ($report) {
                    if ($stat_type == 'new') {
                        $open = SPNL()->db->subscribers_tracker->get_opens_total($report->ID);
                    } else {
                        $open = SendPress_Data::get_opens($report->ID);
                    }
                    $p = $open / $rec * 100;
                }
                ?>
        <div class="sp-row">
        <div class="sp-50 sp-first">
          <div style="float:left;">
          <div id="myStat" class="chartid" data-dimension="150" data-text="<?php 
                echo floor($p);
                ?>
%" data-info="Total Opens" data-width="15" data-fontsize="30" data-percent="<?php 
                echo floor($p);
                ?>
" data-fgcolor="#61a9dc" data-bgcolor="#eee" data-fill="#ddd" data-total="<?php 
                echo $rec;
                ?>
" data-part="<?php 
                echo $open;
                ?>
" data-icon="long-arrow-up" data-icon-size="28" data-icon-color="#fff"></div>
         </div>
         <div style="text-align:center;">
         <h5>Total</h5>
         <?php 
                echo $open;
                ?>
        </div>
        </div>
        <div class="sp-50">
        <?php 
                $ou = 0;
                if ($stat_type == 'new') {
                    $ou = SPNL()->db->subscribers_tracker->get_opens($report->ID);
                } else {
                    $ou = SendPress_Data::get_opens_unique_total($report->ID);
                }
                $px = $ou / $rec * 100;
                ?>
        <div style="float:left;">
          <div id="myStat" class="chartid" data-dimension="150" data-text="<?php 
                echo floor($px);
                ?>
%" data-info="Unique Opens" data-width="15" data-fontsize="30" data-percent="35" data-fgcolor="#85d002" data-bgcolor="#eee" data-fill="#ddd" data-total="<?php 
                echo $rec;
                ?>
" data-part="<?php 
                echo $ou;
                ?>
" data-icon="long-arrow-up" data-icon-size="28" data-icon-color="#fff"></div>
        </div>
          <div style="text-align:center;">
          <h5>Unique</h5>
          <?php 
                echo $ou;
                ?>
          </div>
       </div>
       </div>
        
      <?php 
                $this->panel_end();
                ?>
  </div>
  <div class="sp-50">
  <h4 style="text-align:center;"><?php 
                _e('Clicks', 'sendpress');
                ?>
</h4>
    <?php 
                $this->panel_start();
                $click = 0;
                $rec = get_post_meta($report->ID, '_send_last_count', true);
                if ($report) {
                    if ($stat_type == 'new') {
                        $click = SPNL()->db->subscribers_url->clicks_email_id($report->ID);
                    } else {
                        $click = SendPress_Data::get_clicks($report->ID);
                    }
                    $p = $click / $rec * 100;
                }
                ?>
     <div class="sp-row">
        <div class="sp-50 sp-first">
          <div style="float:left;">
          <div id="myStat" class="chartid" data-dimension="150" data-text="<?php 
                echo floor($p);
                ?>
%" data-info="Total Opens" data-width="15" data-fontsize="30" data-percent="<?php 
                echo floor($p);
                ?>
" data-fgcolor="#61a9dc" data-bgcolor="#eee" data-fill="#ddd" data-total="<?php 
                echo $rec;
                ?>
" data-part="<?php 
                echo $click;
                ?>
" data-icon="long-arrow-up" data-icon-size="28" data-icon-color="#fff"></div>
         </div>
         <div style="text-align:center;">
         <h5><?php 
                _e('Total', 'sendpress');
                ?>
</h5>
         <?php 
                echo $click;
                ?>
         </div>
        </div>
        <div class="sp-50">
        <?php 
                $ou = 0;
                if ($stat_type == 'new') {
                    $ou = SPNL()->db->subscribers_url->clicks_total_email_id($report->ID);
                } else {
                    $ou = SendPress_Data::get_clicks_unique_total($report->ID);
                }
                $px = $ou / $rec * 100;
                ?>
        <div style="float:left;">
          <div id="myStat" class="chartid" data-dimension="150" data-text="<?php 
                echo floor($px);
                ?>
%" data-info="Unique Opens" data-width="15" data-fontsize="30" data-percent="35" data-fgcolor="#85d002" data-bgcolor="#eee" data-fill="#ddd" data-total="<?php 
                echo $rec;
                ?>
" data-part="<?php 
                echo $ou;
                ?>
" data-icon="long-arrow-up" data-icon-size="28" data-icon-color="#fff"></div>
        </div>
        <div style="text-align:center;">
          <h5><?php 
                _e('Unique', 'sendpress');
                ?>
</h5>
          <?php 
                echo $ou;
                ?>
         </div>
       </div>
       </div>
        
     <?php 
                $this->panel_end();
                ?>
  </div>
</div>
<?php 
                $this->panel_end();
            }
            ?>




<div class="sp-row">
<div class="sp-33 sp-first">
<div class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title"><?php 
            _e('Recent Subscribers', 'sendpress');
            ?>
</h3>
  </div>
  <div class="panel-body">
  	<table class="table table-striped table-condensed">
    <tr>
    <th>Date</th>
    <th>List</th>
    <th><div style="text-align:right;">Email</div></th>
    </tr>
  	<?php 
            $recent = SendPress_Data::get_subscribed_events();
            foreach ($recent as $item) {
                echo "<tr>";
                echo "<td>";
                if (property_exists($item, 'subscriberID')) {
                    $d = SendPress_Data::get_subscriber($item->subscriberID);
                    if (property_exists($item, 'eventdate')) {
                        echo date_i18n("m.d.y", strtotime($item->eventdate));
                    }
                    echo "</td>";
                    echo "<td >";
                    if (property_exists($item, 'listID')) {
                        echo get_the_title($item->listID);
                    }
                    echo "</td>";
                    echo "<td align='right'>";
                    if (is_object($d)) {
                        echo $d->email . "<br>";
                    }
                    echo "</td>";
                    echo "</tr>";
                }
            }
            ?>
  </table>
  </div>
</div>
</div>
<div class="sp-33">
	<div class="panel panel-default">
	  <div class="panel-heading">
	    <h3 class="panel-title"><?php 
            _e('Most Active Subscribers', 'sendpress');
            ?>
</h3>
	  </div>
	  <div class="panel-body">
	  	<ul>
	  	<?php 
            $recent = SendPress_Data::get_most_active_subscriber();
            foreach ($recent as $item) {
                if (property_exists($item, 'subscriberID')) {
                    echo "<li>";
                    $d = SendPress_Data::get_subscriber($item->subscriberID);
                    if (is_object($d)) {
                        echo $d->email;
                    }
                    echo "</li>";
                }
            }
            ?>
	  	</ul>
	  </div>
	</div>
</div>
<div class="sp-33">
	<div class="panel panel-default">
	  <div class="panel-heading">
	    <h3 class="panel-title"><?php 
            _e('Go Pro!', 'sendpress');
            ?>
</h3>
	  </div>
	  <div class="panel-body">
	  	<ul>
	  		<li><a href="http://sendpress.com/purchase-pricing/"><?php 
            _e('Advanced Reports', 'sendpress');
            ?>
</a></li>
	  		<li><a href="http://sendpress.com/purchase-pricing/"><?php 
            _e('Check Spam Scores', 'sendpress');
            ?>
</a></li>
	  		<li><a href="http://sendpress.com/purchase-pricing/"><?php 
            _e('Post Notifications', 'sendpress');
            ?>
</a></li>
	  	</ul>
   
	  </div>
	</div>
</div>
</div>

<script>
jQuery( document ).ready(function($) {
        $('.chartid').circliful();
    });
</script>
<!--
<div class="panel panel-default">
  <div class="panel-body">
   <h2>Welcome to SendPress</h2>
  </div>
</div>

-->
<?php 
            if (SendPress_Option::get('feedback') == 'yes' || SendPress_Option::get('allow_tracking') == 'yes') {
                SendPress_Tracking::data();
            }
        }