function auto_cron()
 {
     // make sure we're in wp-cron.php
     if (false !== strpos($_SERVER['REQUEST_URI'], '/wp-cron.php')) {
         // make sure a secret string is provided in the ur
         if (isset($_GET['action']) && $_GET['action'] == 'sendpress') {
             $time_start = microtime(true);
             $count = SendPress_Data::emails_in_queue();
             $bg = 0;
             if ($count > 0) {
                 SendPress_Queue::send_mail();
                 $count = SendPress_Data::emails_in_queue();
             } else {
                 SPNL()->log->prune_logs();
                 SendPress_Data::clean_queue_table();
                 //SendPress_Logging::prune_logs();
                 $bg = 1;
             }
             $attempted_count = SendPress_Option::get('autocron-per-call', 25);
             $pro = 0;
             if (defined('SENDPRESS_PRO_VERSION')) {
                 $pro = SENDPRESS_PRO_VERSION;
             }
             $stuck = SendPress_Data::emails_stuck_in_queue();
             $limit = SendPress_Manager::limit_reached();
             $emails_per_day = SendPress_Option::get('emails-per-day');
             $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");
             $limits = array('autocron' => $attempted_count, 'dl' => $emails_per_day, 'hl' => $emails_per_hour, 'ds' => $emails_so_far, 'hs' => $hourly_emails);
             $time_end = microtime(true);
             $time = $time_end - $time_start;
             echo json_encode(array("background" => $bg, "queue" => $count, "stuck" => $stuck, "version" => SENDPRESS_VERSION, "pro" => $pro, "limit" => $limit, 'info' => $limits, 'time' => number_format($time, 3)));
             die;
         }
     }
 }
 static function emails_allowed_to_send()
 {
     $emails_per_day = SendPress_Option::get('emails-per-day');
     $emails_per_hour = SendPress_Option::get('emails-per-hour');
     $count = SendPress_Data::emails_in_queue();
     $emails_this_hour = SendPress_Data::emails_sent_in_queue("hour");
     $emails_today = SendPress_Data::emails_sent_in_queue("day");
     $hour = $emails_per_hour - $emails_this_hour;
     $day = $emails_per_day - $emails_today;
     if ($count <= $hour && $count <= $day) {
         return $count;
     }
     if ($hour <= $day) {
         return $hour;
     }
     return $day;
 }
 /** ************************************************************************
  * REQUIRED! This is where you prepare your data for display. This method will
  * usually be used to query the database, sort and filter the data, and generally
  * get it ready to be displayed. At a minimum, we should set $this->items and
  * $this->set_pagination_args(), although the following properties and methods
  * are frequently interacted with here...
  * 
  * @uses $this->_column_headers
  * @uses $this->items
  * @uses $this->get_columns()
  * @uses $this->get_sortable_columns()
  * @uses $this->get_pagenum()
  * @uses $this->set_pagination_args()
  **************************************************************************/
 function prepare_items()
 {
     global $wpdb, $_wp_column_headers;
     $screen = get_current_screen();
     /*      
             select t1.* from `sp_sendpress_list_subscribers` as t1 , `sp_sendpress_subscribers` as t2
             where t1.subscriberID = t2.subscriberID and t1.listID = 2*/
     $query = "SELECT * FROM " . SendPress_Data::queue_table();
     /* -- Pagination parameters -- */
     //Number of elements in your table?
     $totalitems = SendPress_Data::emails_sent_in_queue('All');
     //$wpdb->query($query); //return the total number of affected rows
     //How many to display per page?
     // get the current user ID
     $user = get_current_user_id();
     // get the current admin screen
     $screen = get_current_screen();
     // retrieve the "per_page" option
     $per_page = 10;
     $screen_option = $screen->get_option('per_page', 'option');
     if (!empty($screen_option)) {
         // retrieve the value of the option stored for the current user
         $per_page = get_user_meta($user, $screen_option, true);
         if (empty($per_page) || $per_page < 1) {
             // get the default value if none is set
             $per_page = $screen->get_option('per_page', 'default');
         }
     }
     //Which page is this?
     $paged = !empty($_GET["paged"]) ? esc_sql($_GET["paged"]) : '';
     //Page Number
     if (empty($paged) || !is_numeric($paged) || $paged <= 0) {
         $paged = 1;
     }
     //How many pages do we have in total?
     $totalpages = ceil($totalitems / $per_page);
     $query .= ' WHERE success = 1 ';
     //$query.="AND ( date_sent = '0000-00-00 00:00:00' or date_sent < '".date_i18n('Y-m-d H:i:s')."') ";
     if (isset($_GET["listid"]) && $_GET["listid"] > 0) {
         $query .= ' AND listID = ' . $_GET["listid"];
     }
     if (isset($_GET["qs"])) {
         $query .= ' AND to_email LIKE "%' . $_GET["qs"] . '%"';
     }
     /* -- Ordering parameters -- */
     //Parameters that are going to be used to order the result
     $orderby = !empty($_GET["orderby"]) ? esc_sql($_GET["orderby"]) : '';
     $order = !empty($_GET["order"]) ? esc_sql($_GET["order"]) : 'ASC';
     if (!empty($orderby) & !empty($order)) {
         $query .= ' ORDER BY ' . $orderby . ' ' . $order;
     }
     if (empty($orderby)) {
         $query .= ' ORDER BY id DESC ';
     }
     //adjust the query to take pagination into account
     if (!empty($paged) && !empty($per_page)) {
         $offset = ($paged - 1) * $per_page;
         $query .= ' LIMIT ' . (int) $offset . ',' . (int) $per_page;
     }
     /* -- Register the pagination -- */
     $this->set_pagination_args(array("total_items" => $totalitems, "total_pages" => $totalpages, "per_page" => $per_page));
     //The pagination links are automatically built according to those parameters
     /* -- Register the Columns -- */
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     /* -- Fetch the items -- */
     $this->items = $wpdb->get_results($query);
 }
    function html()
    {
        global $sendpress_sender_factory;
        $senders = $sendpress_sender_factory->get_all_senders();
        ksort($senders);
        $method = SendPress_Option::get('sendmethod');
        $fe = __('From Email', 'sendpress');
        $fn = __('From Name', 'sendpress');
        ?>
<!--
<div style="float:right;" >
  <a href="" class="btn btn-large btn-default" ><i class="icon-remove"></i> <?php 
        _e('Cancel', 'sendpress');
        ?>
</a> <a href="#" id="save-update" class="btn btn-primary btn-large"><i class="icon-white icon-ok"></i> <?php 
        _e('Save', 'sendpress');
        ?>
</a>
</div>
-->


<form method="post" id="post">
	<br class="clear">
	<br class="clear">
	<div class="sp-row">
		<div class="sp-50 sp-first">
			<?php 
        $this->panel_start('<span class="glyphicon glyphicon-user"></span> ' . __('Sending Email', 'sendpress'));
        ?>
			<div class="form-group">
				<label for="fromname"><?php 
        _e('From Name', 'sendpress');
        ?>
</label>
				<input name="fromname" tabindex=1 type="text" id="fromname" value="<?php 
        echo SendPress_Option::get('fromname');
        ?>
" class="form-control">
			</div>
			<div class="form-group">
				<label for="fromemail"><?php 
        _e('From Email', 'sendpress');
        ?>
</label>
				<input name="fromemail" tabindex=2 type="text" id="fromemail" value="<?php 
        echo SendPress_Option::get('fromemail');
        ?>
" class="form-control">
			</div>

			<div class="form-group">
                <label for="bounceemail"><?php 
        _e('Email de Retorno', 'jaiminho');
        ?>
</label>
                <input name="bounceemail" tabindex=3 type="text" id="bounceemail" value="<?php 
        echo SendPress_Option::get('bounce_email');
        ?>
" class="form-control">
            </div>

			<?php 
        $this->panel_end();
        ?>
		</div >
		<div class="sp-50">
			<?php 
        $this->panel_start('<span class="glyphicon glyphicon-inbox"></span> ' . __('Test Email', 'sendpress'));
        ?>

			<div class="form-group">
				<label for="testemail"><?php 
        _e('Where to send Test Email', 'sendpress');
        ?>
</label>
				<input name="testemail" type="text" id="test-email-main" value="<?php 
        echo SendPress_Option::get('testemail');
        ?>
" class="form-control"/>
			</div>
			<div class="sp-row">
				<div class="sp-50 sp-first">
					<button class="btn btn-primary btn-block" value="test" name="test" type="submit"><?php 
        _e('Send Test!', 'sendpress');
        ?>
</button>
				</div>
				<div class="sp-50">
					<button class="btn btn-danger btn-block" data-toggle="modal" data-target="#debugModal" type="button"><?php 
        _e('Debug Info', 'sendpress');
        ?>
</button>
				</div>
			</div>
			<div class="sp-row">
				<br>
				<div class="panel-group" id="accordion">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h4 class="panel-title">
								<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
									<?php 
        _e('Click to View Last Error', 'sendpress');
        ?>
								</a>
							</h4>
						</div>
						<div id="collapseOne" class="panel-collapse collapse">
							<div class="panel-body">

								<?php 
        $logs = SPNL()->log->get_connected_logs(array('posts_per_page' => 1, 'log_type' => 'sending'));
        if (!empty($logs)) {
            foreach ($logs as $log) {
                echo "<strong>" . $log->post_date . "</strong>  " . $log->post_title;
                echo "<br>" . $log->post_content;
            }
        }
        ?>
							</div>
						</div>
					</div>
				</div>
				
			</div>
			<?php 
        $this->panel_end();
        ?>
		</div>
	</div>

	<div class="panel panel-default">
		<div class="panel-heading">
			<h3 class="panel-title"><?php 
        _e('Sending Account Setup', 'sendpress');
        ?>
</h3>
		</div>
		<div class="panel-body">

			<input type="hidden" name="action" value="account-setup" />
			<?php 
        $new = array();
        foreach ($senders as $key => $sender) {
            array_push($new, array($key, $sender->label()));
        }
        echo '<strong>Delivery Method: </strong>';
        $this->select('sendpress-sender', $method, $new);
        ?>
<br><br>
			<?php 
        if (count($senders) < 3) {
            $c = 0;
            foreach ($senders as $key => $sender) {
                $class = '';
                if ($c >= 1) {
                    $class = "margin-left: 4%";
                }
                echo "<div style=' float:left; width: 48%; {$class}' id='{$key}'>";
                ?>
					<!-- XXXX -->	
					<p>&nbsp;<!--<input name="sendpress-sender" type="radio"  <?php 
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    ?>
checked="checked"<?php 
                }
                ?>
 id="website" value="<?php 
                echo $key;
                ?>
" /> <?php 
                _e('Send Emails via', 'sendpress');
                ?>
 -->
						<?php 
                echo $sender->label();
                echo "</p><div class='well'>";
                echo $sender->settings();
                echo "</div></div>";
                $c++;
            }
        } else {
            ?>
				<div class="tabbable tabs-left">
					<ul class="nav nav-tabs">
						<?php 
            foreach ($senders as $key => $sender) {
                $class = '';
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    $class = "class='active'";
                }
                echo "<li {$class}><a href='#{$key}' data-toggle='tab'>";
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    echo '<span class="glyphicon glyphicon-ok-sign"></span> ';
                }
                echo $sender->label();
                echo "</a></li>";
            }
            ?>
					</ul>
					<div class="tab-content" style="display:block;">
						<?php 
            foreach ($senders as $key => $sender) {
                $class = '';
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    $class = "active";
                }
                echo "<div class='tab-pane {$class}' id='{$key}'>";
                ?>
							<!-- XXXX -->
							<!--<p>&nbsp;<input name="sendpress-sender" type="radio"  <?php 
                if ($key === 'SendPress_Sender_Website' && is_multisite()) {
                    echo 'style="display:none"';
                }
                ?>
 <?php 
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    ?>
checked="checked"<?php 
                }
                ?>
 id="website" value="<?php 
                echo $key;
                ?>
" /> <?php 
                _e('Activate', 'sendpress');
                ?>
-->
								<?php 
                //echo $sender->label();
                echo "</p><div class='well'>";
                echo $sender->settings();
                echo "</div></div>";
            }
            ?>

						</div>
					</div>


					<p > <span class="glyphicon glyphicon-ok-sign"></span> = <?php 
            _e('Currently Active', 'sendpress');
            ?>
</p>
					<?php 
        }
        ?>

				</div>
			</div>
			<br class="clear">
			<div class="panel panel-default">
				<div class="panel-heading">
					<h3 class="panel-title"><?php 
        _e('Advanced Sending Options', 'sendpress');
        ?>
</h3>
				</div>
				<div class="panel-body">
					<div class="boxer form-box">
						<div style="float: right; width: 45%;">
							<h2><?php 
        _e('Email Sending Limits', 'sendpress');
        ?>
</h2>

							<?php 
        $emails_per_day = SendPress_Option::get('emails-per-day');
        $emails_per_hour = SendPress_Option::get('emails-per-hour');
        $credits = SendPress_Option::get('emails-credits');
        //$hourly_emails = SendPress_Data::emails_sent_in_queue("hour");
        $emails_so_far = SendPress_Data::emails_sent_in_queue("day");
        $offset = get_option('gmt_offset') * 60 * 60;
        // Time offset in seconds
        $local_timestamp = wp_next_scheduled('sendpress_cron_action') + $offset;
        //print_r(wp_get_schedules());
        sprintf(__('You have sent <strong>%s</strong> emails so far today and you have <strong>%s</strong> credits remaining.', 'sendpress'), $emails_so_far, $credits);
        ?>
<br><br>
<input type="text" size="6" name="emails-per-day" value="<?php 
        echo $emails_per_day;
        ?>
" /> <?php 
        _e('Emails Per Day', 'sendpress');
        ?>
<br><br>
<input type="text" size="6" name="emails-per-hour" value="<?php 
        echo $emails_per_hour;
        ?>
" /> <?php 
        _e('Emails Per Hour', 'sendpress');
        ?>
<br><br>
<h2><?php 
        _e('Email Encoding', 'sendpress');
        ?>
</h2>
<?php 
        $charset = SendPress_Option::get('email-charset', 'UTF-8');
        ?>
Charset:
<select name="email-charset" id="">

	<?php 
        $charsete = SendPress_Data::get_charset_types();
        foreach ($charsete as $type) {
            $select = "";
            if ($type == $charset) {
                $select = " selected ";
            }
            echo "<option {$select} value={$type}>{$type}</option>";
        }
        ?>
</select><br>
<?php 
        _e('Squares or weird characters displaying in your emails select the charset for your language', 'sendpress');
        ?>
.
<br><br>
<?php 
        _e('Encoding', 'sendpress');
        ?>
: <select name="email-encoding" id="">
<?php 
        $charset = SendPress_Option::get('email-encoding', '8bit');
        $charsete = SendPress_Data::get_encoding_types();
        foreach ($charsete as $type) {
            $select = "";
            if ($type == $charset) {
                $select = " selected ";
            }
            echo "<option {$select} value={$type}>{$type}</option>";
        }
        ?>
</select>

<br class="clear">
</div>
</div>
</div>
</div>


<?php 
        //Page Nonce
        //wp_nonce_field(  basename(__FILE__) ,'_spnonce' );
        wp_nonce_field($this->_nonce_value);
        ?>
<input type="submit" class="btn btn-primary" value="Save"/> <a href="" class="btn btn-default"><i class="icon-remove"></i> <?php 
        _e('Cancel', 'sendpress');
        ?>
</a>
</form>
<form method="post" id="post-test" class="form-inline">
	<input type="hidden" name="action" value="send-test-email" />
	<input name="testemail" type="hidden" id="test-email-form" value="<?php 
        echo SendPress_Option::get('testemail');
        ?>
" class="form-control"/>

	<br class="clear">




	<?php 
        //Page Nonce
        //wp_nonce_field(  basename(__FILE__) ,'_spnonce' );
        //SendPress General Nonce
        wp_nonce_field($this->_nonce_value);
        ?>
</form>
<?php 
        $error = SendPress_Option::get('phpmailer_error');
        $hide = 'hide';
        if (!empty($error) && isset($_POST['testemail'])) {
            $hide = '';
            $phpmailer_error = '<pre>' . $error . '</pre>';
            ?>
	<script type="text/javascript">
		jQuery(document).ready(function($) {
			$('#debugModal').modal('show');
		});
	</script>

	<?php 
        }
        ?>


<div class="modal fade" id="debugModal" 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('SMTP Debug Info', 'sendpress');
        ?>
</h3>
			</div>
			<div class="modal-body">
				<?php 
        if (!empty($phpmailer_error)) {
            $server = "smtp.sendgrid.net";
            $port = "25";
            $port2 = "465";
            $port3 = "587";
            $timeout = "1";
            if ($server and $port and $timeout) {
                $port25 = @fsockopen("{$server}", $port, $errno, $errstr, $timeout);
                $port465 = @fsockopen("{$server}", $port2, $errno, $errstr, $timeout);
                $port587 = @fsockopen("{$server}", $port3, $errno, $errstr, $timeout);
            }
            if (!$port25) {
                echo '<div class="alert alert-error">';
                _e('Port 25 seems to be blocked.', 'sendpress');
                echo '</div>';
            }
            if (!$port465) {
                echo '<div class="alert alert-error">';
                _e('Port 465 seems to be blocked. Gmail may have trouble', 'sendpress');
                echo '</div>';
            }
            if (!$port587) {
                echo '<div class="alert alert-error">';
                _e('Port 587 seems to be blocked.', 'sendpress');
                echo '</div>';
            }
            echo $phpmailer_error;
        }
        ?>


				<pre>
					<?php 
        $whoops = SendPress_Option::get('last_test_debug');
        if (empty($whoops)) {
            _e('No Debug info saved.', 'sendpress');
        } else {
            echo $whoops;
        }
        ?>
				</pre>
			</div>
			<div class="modal-footer">
				<a href="#" class="btn" data-dismiss="modal"><?php 
        _e('Close', 'sendpress');
        ?>
</a>
			</div>
		</div>
	</div></div>
	<?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)
    {
        global $sendpress_sender_factory;
        $senders = $sendpress_sender_factory->get_all_senders();
        ksort($senders);
        $method = SendPress_Option::get('sendmethod');
        $fe = __('From Email', 'sendpress');
        $fn = __('From Name', 'sendpress');
        ?>
<!--
<div style="float:right;" >
  <a href="" class="btn btn-large btn-default" ><i class="icon-remove"></i> <?php 
        _e('Cancel', 'sendpress');
        ?>
</a> <a href="#" id="save-update" class="btn btn-primary btn-large"><i class="icon-white icon-ok"></i> <?php 
        _e('Save', 'sendpress');
        ?>
</a>
</div>
-->


<form method="post" id="post">
	<br class="clear">
	<br class="clear">
	<div class="sp-row">
		<div class="sp-50 sp-first">
			<?php 
        $this->panel_start('<span class="glyphicon glyphicon-user"></span> ' . __('Sending Email', 'sendpress'));
        ?>
			<div class="form-group">
				<label for="fromname"><?php 
        _e('From Name', 'sendpress');
        ?>
</label>
				<input name="fromname" tabindex=1 type="text" id="fromname" value="<?php 
        echo SendPress_Option::get('fromname');
        ?>
" class="form-control">
			</div>
			<div class="form-group">
				<label for="fromemail"><?php 
        _e('From Email', 'sendpress');
        ?>
</label>
				<input name="fromemail" tabindex=2 type="text" id="fromemail" value="<?php 
        echo SendPress_Option::get('fromemail');
        ?>
" class="form-control">
			</div>

			<?php 
        $this->panel_end();
        ?>
		</div >
		<div class="sp-50">
			<?php 
        $this->panel_start('<span class="glyphicon glyphicon-inbox"></span> ' . __('Test Email', 'sendpress'));
        ?>

			<div class="form-group">
				<label for="testemail"><?php 
        _e('Where to send Test Email', 'sendpress');
        ?>
</label>
				<input name="testemail" type="text" id="test-email-main" value="<?php 
        echo SendPress_Option::get('testemail');
        ?>
" class="form-control"/>
			</div>
			<div class="sp-row">
				<div class="sp-50 sp-first">
					<button class="btn btn-primary btn-block" value="test" name="test" type="submit"><?php 
        _e('Send Test!', 'sendpress');
        ?>
</button>
				</div>
				<div class="sp-50">
					<button class="btn btn-danger btn-block" data-toggle="modal" data-target="#debugModal" type="button"><?php 
        _e('Debug Info', 'sendpress');
        ?>
</button>
				</div>
			</div>
			<div class="sp-row">
				<br>
				<div class="panel-group" id="accordion">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h4 class="panel-title">
								<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
									<?php 
        _e('Click to View Last Error', 'sendpress');
        ?>
								</a>
							</h4>
						</div>
						<div id="collapseOne" class="panel-collapse collapse">
							<div class="panel-body">

								<?php 
        $logs = SPNL()->log->get_connected_logs(array('posts_per_page' => 1, 'log_type' => 'sending'));
        if (!empty($logs)) {
            foreach ($logs as $log) {
                echo "<strong>" . $log->post_date . "</strong>  " . $log->post_title;
                echo "<br>" . $log->post_content;
            }
        }
        ?>
							</div>
						</div>
					</div>
				</div>
				
			</div>
			<?php 
        $this->panel_end();
        ?>
		</div>
	</div>

	<div class="panel panel-default">
		<div class="panel-heading">
			<h3 class="panel-title"><?php 
        _e('Sending Account Setup', 'sendpress');
        ?>
</h3>
		</div>
		<div class="panel-body">

			<input type="hidden" name="action" value="account-setup" />
			
			<?php 
        if (count($senders) < 3) {
            $c = 0;
            foreach ($senders as $key => $sender) {
                $class = '';
                if ($c >= 1) {
                    $class = "margin-left: 4%";
                }
                echo "<div style=' float:left; width: 48%; {$class}' id='{$key}'>";
                ?>
					<p>&nbsp;<input name="sendpress-sender" type="radio"  <?php 
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    ?>
checked="checked"<?php 
                }
                ?>
 id="website" value="<?php 
                echo $key;
                ?>
" /> <?php 
                _e('Send Emails via', 'sendpress');
                ?>
						<?php 
                echo $sender->label();
                echo "</p><div class='well'>";
                echo $sender->settings();
                echo "</div></div>";
                $c++;
            }
        } else {
            ?>
				<div class="tabbable tabs-left">
					<ul class="nav nav-tabs">
						<?php 
            foreach ($senders as $key => $sender) {
                $class = '';
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    $class = "class='active'";
                }
                echo "<li {$class}><a href='#{$key}' data-toggle='tab'>";
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    echo '<span class="glyphicon glyphicon-ok-sign"></span> ';
                }
                echo $sender->label();
                echo "</a></li>";
            }
            ?>
					</ul>
					<div class="tab-content" style="display:block;">
						<?php 
            foreach ($senders as $key => $sender) {
                $class = '';
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    $class = "active";
                }
                echo "<div class='tab-pane {$class}' id='{$key}'>";
                ?>
							<p>&nbsp;<input name="sendpress-sender" type="radio"  <?php 
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    ?>
checked="checked"<?php 
                }
                ?>
 id="website" value="<?php 
                echo $key;
                ?>
" /> <?php 
                _e('Activate', 'sendpress');
                ?>
								<?php 
                echo $sender->label();
                echo "</p><div class='well'>";
                echo $sender->settings();
                echo "</div></div>";
            }
            ?>

						</div>
					</div>


					<p > <span class="glyphicon glyphicon-ok-sign"></span> = <?php 
            _e('Currently Active', 'sendpress');
            ?>
</p>
					<?php 
        }
        ?>

				</div>
			</div>
			<br class="clear">
			<div class="panel panel-default">
				<div class="panel-heading">
					<h3 class="panel-title"><?php 
        _e('Advanced Sending Options', 'sendpress');
        ?>
</h3>
				</div>
				<div class="panel-body">
					<div class="boxer form-box">
						<div style="float: right; width: 45%;">
							<h2><?php 
        _e('Email Sending Limits', 'sendpress');
        ?>
</h2>

							<?php 
        $emails_per_day = SendPress_Option::get('emails-per-day');
        $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");
        $offset = get_option('gmt_offset') * 60 * 60;
        // Time offset in seconds
        $local_timestamp = wp_next_scheduled('sendpress_cron_action') + $offset;
        //print_r(wp_get_schedules());
        printf(__('You have sent <strong>%d</strong> emails so far today.', 'sendpress'), $emails_so_far);
        ?>
.<br><br>
<input type="text" size="6" name="emails-per-day" value="<?php 
        echo $emails_per_day;
        ?>
" /> <?php 
        _e('Emails Per Day', 'sendpress');
        ?>
<br><br>
<input type="text" size="6" name="emails-per-hour" value="<?php 
        echo $emails_per_hour;
        ?>
" /> <?php 
        _e('Emails Per Hour', 'sendpress');
        ?>
<br><br>
<h2><?php 
        _e('Email Encoding', 'sendpress');
        ?>
</h2>
<?php 
        $charset = SendPress_Option::get('email-charset', 'UTF-8');
        ?>
Charset:
<select name="email-charset" id="">

	<?php 
        $charsete = SendPress_Data::get_charset_types();
        foreach ($charsete as $type) {
            $select = "";
            if ($type == $charset) {
                $select = " selected ";
            }
            echo "<option {$select} value={$type}>{$type}</option>";
        }
        ?>
</select><br>
<?php 
        _e('Squares or weird characters displaying in your emails select the charset for your language', 'sendpress');
        ?>
.
<br><br>
<?php 
        _e('Encoding', 'sendpress');
        ?>
: <select name="email-encoding" id="">
<?php 
        $charset = SendPress_Option::get('email-encoding', '8bit');
        $charsete = SendPress_Data::get_encoding_types();
        foreach ($charsete as $type) {
            $select = "";
            if ($type == $charset) {
                $select = " selected ";
            }
            echo "<option {$select} value={$type}>{$type}</option>";
        }
        ?>
</select><br>
<?php 
        _e('Older versions of SendPress used', 'sendpress');
        ?>
 "quoted-printable"
<br><br><br>
<h2><?php 
        _e('AutoCron Information', 'sendpress');
        ?>
</h2>
<?php 
        $api_info = json_decode(SendPress_Cron::get_info());
        $autocron = SendPress_Option::get('autocron', 'no');
        if ($autocron == 'yes') {
            ?>
<ul>
	<li>Last Check: <?php 
            echo $api_info->lastcheck;
            ?>
 UTC</li>
	<li>Errors: <?php 
            echo $api_info->errors;
            ?>
 </li>
	<li>Active: <?php 
            if ($api_info->active == 0) {
                echo "false";
            } else {
                echo "true";
            }
            ?>
 </li>
	
</ul>

<?php 
        } else {
            ?>
	<p>AutoCron is not enabled.</p>
<?php 
        }
        ?>

<br class="clear">
</div>
<div style="width: 45%; margin-right: 10%">
	<?php 
        $tl = SendPress_Option::get('autocron', 'no');
        ?>
	<h2><?php 
        _e('SendPress Pro Auto Cron', 'sendpress');
        ?>
</h2>
	<p>At least once every hour we visit your site, just like a "cron" job.<br>There's no setup involved. Easy and hassle free.</p>

	<button id="sp-enable-cron" <?php 
        if ($tl == 'yes') {
            echo "style='display:none;'";
        }
        ?>
 class="btn  btn-success">Enable Pro Auto Cron</button><button id="sp-disable-cron" <?php 
        if ($tl == 'no') {
            echo "style='display:none;'";
        }
        ?>
 class="btn  btn-danger">Disable Pro Auto Cron</button>
	<br><br>
	<strong>Enable AutoCron and receive a 20% discount code for SendPress Pro. Your discount code will be emailed to you.</strong>
	<br><br>
	<p class="well">
		<strong>Without SendPress Pro</strong><br>
		Auto Cron is limited to a max of <strong>3,000*</strong> emails per day at a max rate of <strong>125*</strong> emails per hour.
		<br><br>
		<strong>With SendPress Pro</strong><br>
		Auto Cron starts at a max of <strong>12,000*</strong> emails per day at a max rate of <strong>500*</strong> emails per hour. Sending of up to <strong>36,000*</strong> emails a day available provided your server can handle it. <br><br><br>
		<strong>*</strong>Auto Cron will not send faster then your <strong>Email Sending Limits</strong> to the right.<br><br>Please make sure you follow the rules of your hosting provider or upgrade to <strong><a href="http://sendpress.com">SendPress Pro</a></strong> to use a third-party service.
	</p>
	<small>Pro Auto Cron does collect some data about your website and usage of SendPress. It will not track any user details, so your security and privacy are safe with us.</small>



<!--
  WordPress Cron: Next run @ <?php 
        echo date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $local_timestamp);
        ?>
<br><br>-->

<br class="clear">
</div>
</div>
</div>
</div>


<?php 
        //Page Nonce
        //wp_nonce_field(  basename(__FILE__) ,'_spnonce' );
        wp_nonce_field($sp->_nonce_value);
        ?>
<input type="submit" class="btn btn-primary" value="Save"/> <a href="" class="btn btn-default"><i class="icon-remove"></i> <?php 
        _e('Cancel', 'sendpress');
        ?>
</a>
</form>
<form method="post" id="post-test" class="form-inline">
	<input type="hidden" name="action" value="send-test-email" />
	<input name="testemail" type="hidden" id="test-email-form" value="<?php 
        echo SendPress_Option::get('testemail');
        ?>
" class="form-control"/>

	<br class="clear">




	<?php 
        //Page Nonce
        //wp_nonce_field(  basename(__FILE__) ,'_spnonce' );
        //SendPress General Nonce
        wp_nonce_field($sp->_nonce_value);
        ?>
</form>
<?php 
        $error = SendPress_Option::get('phpmailer_error');
        $hide = 'hide';
        if (!empty($error)) {
            $hide = '';
            $phpmailer_error = '<pre>' . $error . '</pre>';
            ?>
	<script type="text/javascript">
		jQuery(document).ready(function($) {
			$('#debugModal').modal('show');
		});
	</script>

	<?php 
        }
        ?>


<div class="modal fade" id="debugModal" 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('SMTP Debug Info', 'sendpress');
        ?>
</h3>
			</div>
			<div class="modal-body">
				<?php 
        if (!empty($phpmailer_error)) {
            $server = "smtp.sendgrid.net";
            $port = "25";
            $port2 = "465";
            $port3 = "587";
            $timeout = "1";
            if ($server and $port and $timeout) {
                $port25 = @fsockopen("{$server}", $port, $errno, $errstr, $timeout);
                $port465 = @fsockopen("{$server}", $port2, $errno, $errstr, $timeout);
                $port587 = @fsockopen("{$server}", $port3, $errno, $errstr, $timeout);
            }
            if (!$port25) {
                echo '<div class="alert alert-error">';
                _e('Port 25 seems to be blocked.', 'sendpress');
                echo '</div>';
            }
            if (!$port465) {
                echo '<div class="alert alert-error">';
                _e('Port 465 seems to be blocked. Gmail may have trouble', 'sendpress');
                echo '</div>';
            }
            if (!$port587) {
                echo '<div class="alert alert-error">';
                _e('Port 587 seems to be blocked.', 'sendpress');
                echo '</div>';
            }
            echo $phpmailer_error;
        }
        ?>


				<pre>
					<?php 
        $whoops = SendPress_Option::get('last_test_debug');
        if (empty($whoops)) {
            _e('No Debug info saved.', 'sendpress');
        } else {
            echo $whoops;
        }
        ?>
				</pre>
			</div>
			<div class="modal-footer">
				<a href="#" class="btn" data-dismiss="modal"><?php 
        _e('Close', 'sendpress');
        ?>
</a>
			</div>
		</div>
	</div></div>
	<?php 
    }
 static function auto_cron()
 {
     // make sure we're in wp-cron.php
     if (false !== strpos($_SERVER['REQUEST_URI'], '/wp-cron.php')) {
         // make sure a secret string is provided in the ur
         if (isset($_GET['action']) && $_GET['action'] == 'sendpress') {
             //* Use cache
             static $cron_bg_run = null;
             static $cron_bg_run_weekly = null;
             $time_start = microtime(true);
             $count = SendPress_Data::emails_in_queue();
             $bg = 0;
             $bg_weekly = 0;
             $error = '';
             try {
                 if ($count > 0) {
                     SendPress_Queue::send_mail();
                     $count = SendPress_Data::emails_in_queue();
                 } else {
                     //* If cache is empty, pull transient
                     if (!$cron_bg_run) {
                         $cron_bg_run = get_transient('spnl-background-daily');
                     }
                     //* If transient has expired, do a fresh update check
                     if (!$cron_bg_run) {
                         //* If cache is empty, pull transient
                         if (!$cron_bg_run_weekly) {
                             $cron_bg_run_weekly = get_transient('spnl-background-weekly');
                         }
                         //* If transient has expired, do a fresh update check
                         if (!$cron_bg_run_weekly) {
                             SPNL()->log->prune_logs();
                             SendPress_Data::clean_queue_table();
                             SendPress_DB_Tables::repair_tables();
                             $cron_bg_run_weekly = array('runtime' => date("F j, Y, g:i a"));
                             set_transient('spnl-background-weekly', $cron_bg_run_weekly, 60 * 60 * 24 * 7);
                             $bg_weekly = 1;
                         }
                         //SendPress_Logging::prune_logs();
                         $bg = 1;
                         $cron_bg_run = array('runtime' => date("F j, Y, g:i a"));
                         set_transient('spnl-background-daily', $cron_bg_run, 60 * 60 * 24);
                     }
                 }
             } catch (Exception $e) {
                 $error = $e->getMessage();
                 SPNL()->log->add('Autocron', $error, 0, 'error');
             }
             $attempted_count = SendPress_Option::get('autocron-per-call', 25);
             $pro = 0;
             if (defined('SENDPRESS_PRO_VERSION')) {
                 $pro = SENDPRESS_PRO_VERSION;
             }
             $stuck = SendPress_Data::emails_stuck_in_queue();
             $limit = SendPress_Manager::limit_reached();
             $emails_per_day = SendPress_Option::get('emails-per-day');
             $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");
             $limits = array('autocron' => $attempted_count, 'dl' => $emails_per_day, 'hl' => $emails_per_hour, 'ds' => $emails_so_far, 'hs' => $hourly_emails);
             $time_end = microtime(true);
             $time = $time_end - $time_start;
             echo json_encode(array("error" => $error, "background" => $bg, "weekly" => $bg_weekly, "queue" => $count, "stuck" => $stuck, "version" => SENDPRESS_VERSION, "pro" => $pro, "limit" => $limit, 'info' => $limits, 'time' => number_format($time, 3)));
             die;
         }
     }
 }
    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 
    }