is_action('country')) { $module->country(); $controls->messages = $module->country_result; } if ($controls->is_action('import')) { $wpdb->query("insert ignore into " . $wpdb->prefix . "newsletter_sent (user_id, email_id, time) select user_id, email_id, UNIX_TIMESTAMP(created) from " . NEWSLETTER_STATS_TABLE); $controls->messages = 'Done!'; } $types = $wpdb->get_results("select distinct type from " . NEWSLETTER_EMAILS_TABLE); $type_options = array(); foreach ($types as $type) { if ($type->type == 'followup') continue; if ($type->type == 'message') { $type_options[$type->type] = 'Standard Newsletter'; } else if ($type->type == 'feed') { $type_options[$type->type] = 'Feed by Mail'; } else if (strpos($type->type, 'automated') === 0) { list($a, $id) = explode('_', $type->type); $type_options[$type->type] = 'Automated Channel ' . $id; } else { $type_options[$type->type] = $type->type; } } if (empty($controls->data['type'])) { $emails = $wpdb->get_results("select send_on, id, subject, total, status, type, track, sent, subject from " . NEWSLETTER_EMAILS_TABLE . " where status='sent' order by send_on desc limit 20"); } else { $emails = $wpdb->get_results($wpdb->prepare("select send_on, id, subject, total, type from " . NEWSLETTER_EMAILS_TABLE . " where status='sent' and type=%s order by send_on desc limit 20", $controls->data['type'])); } $overview_labels = array(); $overview_titles = array(); $overview_open_rate = array(); $overview_click_rate = array(); $total_sent = 0; $open_count_total = 0; $click_count_total = 0; foreach ($emails as $email) { $entry = array(); // Skip newsletters which has no sent records $total = $module->get_total_count($email); if (empty($total)) { continue; } $total_sent += $total; //$entry[0] = $email->subject . ' [' . date('Y-m-d', $email->send_on) . ', ' . $email->type . ']'; $entry[0] = date('Y-m-d', $email->send_on); $open_count = $module->get_open_count($email); $open_count_total += $open_count; $entry[1] = $open_count / $total * 100; $entry[1] = round($entry[1], 2); $entry[2] = $email->subject; // . ' (' . percent($open_count, $email->sent) . ')'; $click_count = $module->get_click_count($email); $click_count_total += $click_count; $entry[3] = $click_count / $total * 100; $entry[3] = round($entry[3], 2); $overview_labels[] = strftime('%a, %e %b', $email->send_on); $overview_open_rate[] = $entry[1]; $overview_click_rate[] = $entry[3]; $overview_titles[] = $entry[2]; } $overview_labels = array_reverse($overview_labels); $overview_open_rate = array_reverse($overview_open_rate); $overview_click_rate = array_reverse($overview_click_rate); ?>