' . __('Resend DL', 'yak-admin') . ''; } } if (!function_exists('yak_resenddl_options')) { function yak_resenddl_options() { ?>




' . $count . '

'; $rows = yak_resenddl_get_details(); foreach ($rows as $row) { echo $row->email_address . '
'; } echo '

'; } ?>
prepare("select distinct a.email_address, max(o.id) as order_id from $order_table o, $address_table a where o.shipping_address_id = a.id and o.status in ('STOCK SENT', 'PAYMENT PROCESSED') and exists (select 1 from wp_yak_order_detail od where od.post_id = %d and od.cat_id = %d and od.id = o.id) group by a.email_address", $prod[0], $prod[1]); if (defined('YAK_DEBUG')) { yak_log("SQL: " . $sql); } return $wpdb->get_results($sql); } } if (!function_exists('yak_resenddl_update_options')) { function yak_resenddl_update_options() { global $wpdb, $order_table, $address_table, $order_dl_table; $action = $_REQUEST['options_update_resenddl']; $prod = explode(',', $_REQUEST['product']); $subject = $_REQUEST['subject']; $email = $_REQUEST['email']; $emails = array(); if (!empty($action)) { $sql = $wpdb->prepare("select * from wp_yak_product_detail where post_id = %d and cat_id = %d", $prod[0], $prod[1]); $row = $wpdb->get_row($sql); $dl_file = $row->dl_file; $rows = yak_resenddl_get_details(); if ($action != 'Check') { foreach ($rows as $row) { $sql = "insert into $order_dl_table (order_id, dl_file, download_attempts) values (" . $row->order_id . ", '$dl_file', 0)"; $wpdb->query($sql); yak_send_dl_email($row->order_id, $row->email_address, stripslashes($subject), stripslashes($email)); } $_REQUEST['email_count'] = __y('Sending email to %s purchaser(s):', 'yak-admin', count($rows)); } else { $_REQUEST['email_count'] = __y('%s purchaser(s) will receive the update mail:', 'yak-admin', count($rows)); } } } } add_action('yak-misc-options-link', 'yak_resenddl_options_link'); add_action('yak-misc-options', 'yak_resenddl_options'); add_action('yak-update-options-resenddl', 'yak_resenddl_update_options'); ?>