/** * Get all the entries in the excludes list * * @param null $fields * @param array $filter * @param int $page * @return array */ public function get_excludes_report($fields = null, $filter = array(), $page = 1) { $args = array('type' => 'excludes', 'page' => $page, 'limit' => !empty($filter['limit']) ? absint($filter['limit']) : get_option('posts_per_page')); $exclude_reports = FUE_Reports::get_reports($args); $exclude_data = array(); $total_rows = Follow_Up_Emails::instance()->wpdb->get_var("SELECT FOUND_ROWS()"); foreach ($exclude_reports as $report) { $exclude_data[] = array('email_name' => $report->email_name, 'email_address' => $report->email, 'date' => $this->server->format_datetime($report->date_added, true)); } // set the pagination data $query = array('page' => $page, 'single' => count($exclude_data) == 1, 'total' => $total_rows, 'total_pages' => ceil($total_rows / $args['limit'])); $this->server->add_pagination_headers($query); return array('optouts' => apply_filters('fue_api_report_response', $exclude_data, $exclude_reports, $fields, $this->server)); }
public function report_section_div() { // coupons sorting $sort['sortby'] = 'date_sent'; $sort['sort'] = 'desc'; if (isset($_GET['sortby']) && !empty($_GET['sortby'])) { $valid = array('date_sent', 'email_address', 'coupon_used'); if (in_array($_GET['sortby'], $valid)) { $sort['sortby'] = $_GET['sortby']; $sort['sort'] = isset($_GET['sort']) && $_GET['sort'] == 'asc' ? 'asc' : 'desc'; } } $coupon_reports = FUE_Reports::get_reports(array('type' => 'coupons', 'sort' => $sort)); $email_address_class = $sort['sortby'] != 'email_address' ? 'sortable' : 'sorted'; $email_address_sort = $email_address_class == 'sorted' ? $sort['sort'] : 'asc'; $email_address_dir = $email_address_sort == 'asc' ? 'desc' : 'asc'; $used_class = $sort['sortby'] != 'coupon_used' ? 'sortable' : 'sorted'; $used_sort = $used_class == 'sorted' ? $sort['sort'] : 'asc'; $used_dir = $used_sort == 'asc' ? 'desc' : 'asc'; $sent_class = $sort['sortby'] != 'date_sent' ? 'sortable' : 'sorted'; $sent_sort = $sent_class == 'sorted' ? $sort['sort'] : 'asc'; $sent_dir = $sent_sort == 'asc' ? 'desc' : 'asc'; ?> <div class="section" id="coupons"> <h3><?php _e('Coupons', 'follow_up_emails'); ?> </h3> <table class="wp-list-table widefat fixed posts"> <thead> <tr> <th scope="col" id="coupon_name" class="manage-column column-type" style=""><?php _e('Coupon Name', 'follow_up_emails'); ?> </th> <th scope="col" id="email_address" class="manage-column column-usage_count <?php echo $email_address_class . ' ' . $email_address_sort; ?> " style=""> <a href="admin.php?page=followup-emails-reports&tab=reports&sortby=email_address&sort=<?php echo $email_address_dir; ?> &v=coupons"> <span><?php _e('Email Address', 'follow_up_emails'); ?> </span> <span class="sorting-indicator"></span> </a> </th> <th scope="col" id="coupon_code" class="manage-column column-usage_count" style=""><?php _e('Coupon Code', 'follow_up_emails'); ?> <img class="help_tip" width="16" height="16" title="<?php _e('This is the unique coupon code generated by the follow-up email for this specific email address', 'follow_up_emails'); ?> " src="<?php echo FUE_TEMPLATES_URL; ?> /images/help.png" /></th> <th scope="col" id="email_name" class="manage-column column-usage_count" style=""><?php _e('Email Name', 'follow_up_emails'); ?> <img class="help_tip" width="16" height="16" title="<?php _e('This is the name of the follow-up email that generated the coupon that was sent to this specific email address', 'follow_up_emails'); ?> " src="<?php echo FUE_TEMPLATES_URL; ?> /images/help.png" /></th> <th scope="col" id="used" class="manage-column column-used <?php echo $used_class . ' ' . $used_sort; ?> " style=""> <a href="admin.php?page=followup-emails-reports&tab=reports&sortby=coupon_used&sort=<?php echo $used_dir; ?> &v=coupons"> <span><?php _e('Used', 'follow_up_emails'); ?> <img class="help_tip" width="16" height="16" title="<?php _e('This tells you if this specific coupon code generated and sent via follow-up emails has been used, and if it has, it includes the date and time', 'follow_up_emails'); ?> " src="<?php echo FUE_TEMPLATES_URL; ?> /images/help.png" /></span> <span class="sorting-indicator"></span> </a> </th> <th scope="col" id="date_sent" class="manage-column column-date_sent <?php echo $sent_class . ' ' . $sent_sort; ?> " style=""> <a href="admin.php?page=followup-emails-reports&tab=reports&sortby=date_sent&sort=<?php echo $sent_dir; ?> &v=coupons"> <span><?php _e('Date Sent', 'follow_up_emails'); ?> <img class="help_tip" width="16" height="16" title="<?php _e('This is the date and time that this specific coupon code was sent to this email address', 'follow_up_emails'); ?> " src="<?php echo FUE_TEMPLATES_URL; ?> /images/help.png" /></span> <span class="sorting-indicator"></span> </a> </th> </tr> </thead> <tbody id="the_list"> <?php if (empty($coupon_reports)) { echo ' <tr scope="row"> <th colspan="6">' . __('No reports available', 'follow_up_emails') . '</th> </tr>'; } else { foreach ($coupon_reports as $report) { $used = __('No', 'follow_up_emails'); if ($report->coupon_used == 1) { $date = date(get_option('date_format') . ' ' . get_option('time_format'), strtotime($report->date_used)); $used = sprintf(__('Yes (%s)', 'follow_up_emails'), $date); } echo ' <tr scope="row"> <td class="post-title column-title"> <strong>' . stripslashes($report->coupon_name) . '</strong> </td> <td>' . esc_html($report->email_address) . '</td> <td>' . esc_html($report->coupon_code) . '</td> <td>' . esc_html($report->email_name) . '</td> <td>' . $used . '</td> <td>' . date(get_option('date_format') . ' ' . get_option('time_format'), strtotime($report->date_sent)) . '</td> </tr> '; } } ?> </tbody> </table> </div> <?php }
public static function user_view_html() { $email = urldecode($_GET['email']); $reports = FUE_Reports::get_reports(array('email' => $email, 'type' => 'users')); $block = ''; //echo '<pre>'. print_r($reports,true) .'</pre>'; if (empty($reports)) { $block = ' <tr scope="row"> <th colspan="2">' . __('No reports available', 'follow_up_emails') . '</th> </tr>'; } else { foreach ($reports as $report) { $block .= ' <tr scope="row"> <td class="post-title column-title">'; if ($report->user_id != 0) { $block .= '<strong><a href="edit.php?post_status=all&post_type=shop_order&_customer_user='******'">' . stripslashes($report->customer_name) . '</a></strong>'; } else { $block .= '<strong>' . stripslashes($report->customer_name) . '</strong>'; } $block .= ' </td> <td>' . stripslashes($report->email_address) . '</td> <td>'; if ($report->product_id != 0) { $block .= '<a href="' . get_permalink($report->product_id) . '">' . get_the_title($report->product_id) . '</a>'; } $block .= ' </td> <td>' . $report->email_name . '</td> <td>' . $report->email_trigger . '</td>'; $block .= ' <td>' . date(get_option('date_format') . ' ' . get_option('time_format'), strtotime($report->date_sent)) . '</td> '; if ($report->order_id != 0) { $block .= '<td><a href="post.php?post=' . $report->order_id . '&action=edit">View Order</a></td>'; } else { $block .= '<td>-</td>'; } $block .= '</tr>'; } } $html = ' <h3>' . sprintf(__('Report for %s (%s)', 'wc_folloup_emails'), $report->customer_name, $report->email_address) . '</h3> <table class="wp-list-table widefat fixed posts"> <thead> <tr> <th scope="col" id="type" class="manage-column column-type" style="">' . __('Customer Name', 'follow_up_emails') . '</th> <th scope="col" id="user_email" class="manage-column column-user_email" style="">' . __('Customer Email', 'follow_up_emails') . '</th> <th scope="col" id="product" class="manage-column column-product" style="">' . __('Product', 'wc_folloup_emails') . '</th> <th scope="col" id="email_name" class="manage-column column-email_name" style="">' . __('Email', 'wc_folloup_emails') . '</th> <th scope="col" id="trigger" class="manage-column column-trigger" style="">' . __('Trigger', 'wc_folloup_emails') . '</th> <th scope="col" id="date_sent" class="manage-column column-date_sent" style="">' . __('Date Sent', 'follow_up_emails') . '</th> <th scope="col" id="order" class="manage-column column-order" style=""> </th> </tr> </thead> <tbody id="the_list"> ' . $block . ' </tbody> </table> '; return $html; }
/** * View report for a customer */ public static function user_view_html() { global $wpdb; $email = $_GET['email']; $reports = FUE_Reports::get_reports(array('email' => $email, 'type' => 'users')); $user_id = !empty($_GET['user_id']) ? $_GET['user_id'] : 0; if ($user_id == 0) { $fue_user = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}followup_customers WHERE email_address = %s", $email)); if ($fue_user) { $user_id = $fue_user->user_id; } } $user_email = get_user_meta($user_id, 'billing_email', true); $sql = $wpdb->prepare("SELECT * FROM {$wpdb->prefix}followup_email_excludes WHERE email = %s", $user_email); $excludes = $wpdb->get_results($sql); $queue = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT * FROM {$wpdb->prefix}followup_email_orders WHERE is_sent = 0 AND user_email = %s ORDER BY send_on ASC", $email)); include FUE_TEMPLATES_DIR . '/reports/user_view.php'; return; }