function wdm_get_data($auc_type, $tab_char)
 {
     $this->auction_type = $auc_type;
     if ($this->auction_type == "expired") {
         $args = array('posts_per_page' => -1, 'post_type' => 'ultimate-auction', 'auction-status' => 'expired', 'orderby' => 'meta_value', 'meta_key' => 'wdm_listing_ends', 'order' => 'DESC');
     } elseif ($this->auction_type == "scheduled") {
         $args = array('posts_per_page' => -1, 'post_type' => 'ultimate-auction', 'auction-status' => 'scheduled');
     } elseif ($this->auction_type == "pending") {
         $args = array('posts_per_page' => -1, 'post_type' => 'ultimate-auction', 'post_status' => 'pending');
     } else {
         $args = array('posts_per_page' => -1, 'post_type' => 'ultimate-auction', 'auction-status' => 'live');
     }
     $auction_item_array = get_posts($args);
     $data_array = array();
     $inv_arr = array();
     $results = array();
     //$tab_char = wdm_current_perm_char();
     foreach ($auction_item_array as $single_auction) {
         $authorID = $single_auction->post_author;
         $userID = get_current_user_id();
         $user_det = new WP_User($userID);
         $user_auth_det = new WP_User($authorID);
         $author_mail = $user_auth_det->user_email;
         if (!in_array('administrator', $user_det->roles) && $authorID == $userID || in_array('administrator', $user_det->roles) && in_array('administrator', $user_auth_det->roles)) {
             $act_term = wp_get_post_terms($single_auction->ID, 'auction-status', array("fields" => "names"));
             if (time() >= strtotime(get_post_meta($single_auction->ID, 'wdm_listing_ends', true))) {
                 if (!in_array('expired', $act_term)) {
                     $check_tm = term_exists('expired', 'auction-status');
                     wp_set_post_terms($single_auction->ID, $check_tm["term_id"], 'auction-status');
                 }
             }
             $listing_trans_amt = get_post_meta($single_auction->ID, 'wdm_auction_listing_amt', true);
             $listing_trans_id = get_post_meta($single_auction->ID, 'wdm_auction_listing_transaction', true);
             $row = array();
             $row['ID'] = $single_auction->ID;
             $row['title'] = '<input class="wdm_chk_auc_act" value=' . $single_auction->ID . ' type="checkbox" />' . prepare_single_auction_title($single_auction->ID, $single_auction->post_title);
             $row['payment_made'] = '';
             if (empty($listing_trans_amt) && empty($listing_trans_id)) {
                 $row['payment_made'] = __('Nil', 'wdm-ultimate-auction') . ' <br /><br />';
             } else {
                 if (!empty($listing_trans_amt)) {
                     $row['payment_made'] = $listing_trans_amt . '<br /><br />';
                 }
                 if (!empty($listing_trans_id)) {
                     $row['payment_made'] .= __('Transaction ID', 'wdm-ultimate-auction') . ': <br /><span class="wdm-mark-hover">' . $listing_trans_id . '</span>';
                 }
             }
             $end_date = get_post_meta($single_auction->ID, 'wdm_listing_ends', true);
             if ($this->auction_type == "scheduled") {
                 $dt_lbl = __('Starting Date', 'wdm-ultimate-auction');
             } else {
                 $dt_lbl = __('Creation Date', 'wdm-ultimate-auction');
             }
             $row['date_created'] = "<strong> " . $dt_lbl . ":</strong> <br />" . get_post_meta($single_auction->ID, 'wdm_creation_time', true) . " <br /><br /> <strong> " . __('Ending Date', 'wdm-ultimate-auction') . ":</strong> <br />" . $end_date;
             //$row['image_1']="<img src='".get_post_meta($single_auction->ID,'wdm_auction_thumb', true)."' width='90'";
             if ($this->auction_type == "live" || $this->auction_type == "scheduled" || $this->auction_type == "pending") {
                 $row['action'] = "<a class='wdm_ua_act_links' href='" . $tab_char . "dashboard=add-auction&edit_auction=" . $single_auction->ID . "'>" . __('Edit', 'wdm-ultimate-auction') . "</a>\n\t\t<span class='wdm_ua_act_links'> | </span><div id='wdm-delete-auction-" . $single_auction->ID . "' class='wdm_ua_act_links' style='color:red;cursor:pointer;'>" . __('Delete', 'wdm-ultimate-auction') . " <span class='auc-ajax-img'></span></div>";
             } else {
                 $row['action'] = "<div id='wdm-delete-auction-" . $single_auction->ID . "' class='wdm_ua_act_links' style='color:red;cursor:pointer;'>" . __('Delete', 'wdm-ultimate-auction') . " <span class='auc-ajax-img'></span></div>\n\t    <span class='wdm_ua_act_links'> | </span><a class='wdm_ua_act_links' href='" . $tab_char . "dashboard=add-auction&edit_auction=" . $single_auction->ID . "&reactivate'>" . __('Reactivate', 'wdm-ultimate-auction') . "</a>";
                 //if(get_post_meta($single_auction->ID,'auction_bought_status',true) === 'bought'){
                 //	require('ajax-actions/send-download-link.php');
                 //
                 //}
             }
             if ($this->auction_type == "live") {
                 $row['action'] .= "<span class='wdm_ua_act_links'> | </span><div id='wdm-end-auction-" . $single_auction->ID . "' class='wdm_ua_act_links' style='color:#21759B;cursor:pointer;'>" . __('End Auction', 'wdm-ultimate-auction') . "</div>";
                 require 'ajax-actions/end-auction.php';
             }
             //for bidding logic
             $row["bidders"] = "";
             $row_bidders = "";
             global $wpdb;
             $currency_code = substr(get_option('wdm_currency'), -3);
             $query = "SELECT * FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $single_auction->ID . " ORDER BY id DESC LIMIT 5";
             $results = $wpdb->get_results($query);
             $ship_amt = '';
             $ship_amt = get_post_meta($single_auction->ID, 'wdm_ua_shipping_amt', true);
             $sa = '';
             if (!empty($ship_amt)) {
                 $sa = "<br /><br />" . __('Shipping amount', 'wdm-ultimate-auction') . ": <br />" . $currency_code . " " . $ship_amt;
             }
             if (!empty($results)) {
                 $cnt_bidder = 0;
                 foreach ($results as $result) {
                     $row_bidders .= "<li class='fe_bids_placed_links'><strong><a href='#'>" . $result->name . "</a></strong> - " . $currency_code . " " . $result->bid . "</li>";
                     if ($cnt_bidder == 0) {
                         $bidder_id = $result->id;
                         $bidder_name = $result->name;
                     }
                     $cnt_bidder++;
                 }
                 if (!in_array('administrator', $user_det->roles) && ($this->auction_type != "live" && $this->auction_type != "scheduled")) {
                     if (get_post_meta($single_auction->ID, 'auction_bought_status', true) === 'bought') {
                         $cp = get_post_meta($single_auction->ID, 'wdm_buy_it_now', true);
                     } else {
                         $q = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $single_auction->ID;
                         $cp = $wpdb->get_var($q);
                     }
                     $commission = 0;
                     $commission = get_option('wdm_manage_cm_fees_data');
                     $cp = wdm_auction_commission_calculator($commission, $cp);
                     $final_paid_amt = get_post_meta($single_auction->ID, 'finally_paid_amount', true);
                     if (!empty($final_paid_amt)) {
                         $row["bidders"] = $final_paid_amt;
                     } else {
                         $row["bidders"] = $currency_code . " " . $cp;
                     }
                     $row["bidders"] .= $sa;
                 } else {
                     $row["bidders"] = "<div class='wdm-bidder-list-" . $single_auction->ID . "'><ul>" . $row_bidders . "</ul></div>";
                     $qry = "SELECT * FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $single_auction->ID . " ORDER BY id DESC";
                     $all_bids = $wpdb->get_results($qry);
                     if (count($all_bids) > 5) {
                         $row["bidders"] .= "<br />\n\t\t    <a href='#' class='see-more showing-top-5' rel='" . $single_auction->ID . "' >" . __('See more', 'wdm-ultimate-auction') . "</a>";
                     }
                 }
             } elseif (get_post_meta($single_auction->ID, 'auction_bought_status', true) === 'bought' && (!in_array('administrator', $user_det->roles) && ($this->auction_type != "live" && $this->auction_type != "scheduled"))) {
                 $cp = get_post_meta($single_auction->ID, 'wdm_buy_it_now', true);
                 $commission = 0;
                 $commission = get_option('wdm_manage_cm_fees_data');
                 $cp = wdm_auction_commission_calculator($commission, $cp);
                 $final_paid_amt = get_post_meta($single_auction->ID, 'finally_paid_amount', true);
                 if (!empty($final_paid_amt)) {
                     $row["bidders"] = $final_paid_amt;
                 } else {
                     $row["bidders"] = $currency_code . " " . $cp;
                 }
                 $row["bidders"] .= $sa;
             } else {
                 $row["bidders"] = __('No bids placed', 'wdm-ultimate-auction');
             }
             $start_price = get_post_meta($single_auction->ID, 'wdm_opening_bid', true);
             $buy_it_now_price = get_post_meta($single_auction->ID, 'wdm_buy_it_now', true);
             $row['current_price'] = "";
             $row['final_price'] = "";
             if (empty($start_price) && !empty($buy_it_now_price)) {
                 $row['current_price'] = "<strong>" . __('Buy Now Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $buy_it_now_price;
                 $row['final_price'] = "<strong>" . __('Buy Now Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $buy_it_now_price;
             } elseif (!empty($start_price)) {
                 $query = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $single_auction->ID;
                 $curr_price = $wpdb->get_var($query);
                 if (empty($curr_price)) {
                     $curr_price = $start_price;
                 }
                 $row['current_price'] = "<strong>" . __('Starting Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $start_price;
                 $row['current_price'] .= "<br /><br /> <strong>" . __('Current Price', 'wdm-ultimate-auction') . ":</strong><br /> " . $currency_code . " " . $curr_price;
                 $row['final_price'] = "<strong>" . __('Starting Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $start_price;
                 $row['final_price'] .= "<br /><br /> <strong>" . __('Final Price', 'wdm-ultimate-auction') . ":</strong><br /> " . $currency_code . " " . $curr_price;
             }
             if ($this->auction_type === "expired") {
                 $winner_email = "";
                 $buyer_id = "";
                 $buyer_id = get_post_meta($single_auction->ID, 'wdm_auction_buyer', true);
                 $row['email_payment'] = "";
                 $paid_to_seller = get_post_meta($single_auction->ID, 'ua_direct_pay_to_seller', true);
                 //$check_method = get_post_meta($single_auction->ID, 'wdm_payment_method', true);
                 if (get_post_meta($single_auction->ID, 'auction_bought_status', true) === 'bought' && $paid_to_seller != 'pay') {
                     if (empty($buyer_id)) {
                         $row['email_payment'] = "<div class='wdm-auction-bought wdm-mark-green'>" . __("Expired via Buy Now", "wdm-ultimate-auction") . "</div><div class='wdm-margin-bottom wdm-mark-green'>" . __("Price", "wdm-ultimate-auction") . "[" . $currency_code . " " . $buy_it_now_price . "]</div>";
                     } else {
                         $buyer = get_user_by('id', $buyer_id);
                         if (!empty($buyer) && in_array('administrator', $buyer->roles)) {
                             $row['email_payment'] = "<div class='wdm-auction-bought wdm-mark-green'>" . __("Bought by Administrator", "wdm-ultimate-auction") . "</div><div>" . apply_filters('ua_list_winner_info', $buyer->user_login, $buyer, $single_auction->ID, "e") . "</div><div class='wdm-margin-bottom wdm-mark-green'>" . __("Price", "wdm-ultimate-auction") . "[" . $currency_code . " " . $buy_it_now_price . "]</div>";
                         } else {
                             $row['email_payment'] = "<div class='wdm-auction-bought wdm-mark-green'>" . sprintf(__("Bought by %s", "wdm-ultimate-auction"), apply_filters('ua_list_winner_info', $buyer->user_login, $buyer, $single_auction->ID, "e")) . "</div><div class='wdm-margin-bottom wdm-mark-green'>" . __("Price", "wdm-ultimate-auction") . "[" . $currency_code . " " . $buy_it_now_price . "]</div>";
                         }
                     }
                 } else {
                     if (get_post_meta($single_auction->ID, 'wdm_auction_expired_by', true) == 'ua_best_offers') {
                         $bo_sender_data = get_post_meta($single_auction->ID, 'auction_winner_by_best_offer', true);
                         if (is_array($bo_sender_data)) {
                             reset($bo_sender_data);
                             $bo_sender_id = key($bo_sender_data);
                             $bo_sender = get_user_by('id', $bo_sender_id);
                             $best_offer_price_row = isset($bo_sender_data[$bo_sender_id]['offer_val']) ? "<div class='wdm-margin-bottom wdm-mark-green'>" . __("Price", "wdm-ultimate-auction") . "[" . $currency_code . " " . $bo_sender_data[$bo_sender_id]['offer_val'] . "]</div>" : "";
                             $row['email_payment'] = "<div class='wdm-auction-bought wdm-mark-green'>" . sprintf(__("Sold to %s", "wdm-ultimate-auction"), apply_filters('ua_best_offer_sender_info', $bo_sender->user_login, $bo_sender, $bo_sender_id, "e")) . "</div>" . $best_offer_price_row;
                         }
                     } else {
                         $reserve_price_met = 0;
                         $bid_qry = "";
                         $email_qry = "";
                         $winner_bid = 0;
                         $winner_name = "";
                         $winner = array();
                         $email_sent = "";
                         if (!empty($results)) {
                             $reserve_price_met = get_post_meta($single_auction->ID, 'wdm_lowest_bid', true);
                             $bid_qry = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $single_auction->ID;
                             $winner_bid = $wpdb->get_var($bid_qry);
                             if ($winner_bid >= $reserve_price_met) {
                                 $email_qry = "SELECT name FROM " . $wpdb->prefix . "wdm_bidders WHERE bid =" . $winner_bid . " AND auction_id =" . $single_auction->ID . " ORDER BY id DESC";
                                 $winner_name = $wpdb->get_var($email_qry);
                                 $winner = get_user_by('login', $winner_name);
                                 $winner_email = $winner->user_email;
                                 $email_sent = get_post_meta($single_auction->ID, 'auction_email_sent', true);
                                 if (!empty($winner) && in_array('administrator', $winner->roles)) {
                                     $row['email_payment'] = "<div class='wdm-margin-bottom wdm-mark-green'>" . __('Won by Administrator', 'wdm-ultimate-auction') . "</div><div>" . apply_filters('ua_list_winner_info', $winner->user_login, $winner, $single_auction->ID, "e") . "</div>";
                                     if ($authorID == $userID) {
                                         require 'ajax-actions/send-download-link.php';
                                     }
                                 } else {
                                     $row['email_payment'] = "<div class='wdm-margin-bottom wdm-mark-green'>" . sprintf(__('Won by %s', 'wdm-ultimate-auction'), apply_filters('ua_list_winner_info', $winner->user_login, $winner, $single_auction->ID, "e")) . "</div>";
                                     if ($authorID == $userID) {
                                         require 'ajax-actions/send-download-link.php';
                                     }
                                 }
                                 $row['email_payment'] .= "<strong>" . __('Email Status', 'wdm-ultimate-auction') . ": </strong>";
                                 if ($email_sent === 'sent') {
                                     $row['email_payment'] .= "<span class='wdm-mark-green'>" . __('Yes', 'wdm-ultimate-auction') . "</span>";
                                 } else {
                                     $row['email_payment'] .= "<span class='wdm-mark-red'>" . __('No', 'wdm-ultimate-auction') . "</span>";
                                 }
                                 $row['email_payment'] .= "<br/><br/> <a href='' id='auction-resend-" . $single_auction->ID . "'>" . __('Resend', 'wdm-ultimate-auction') . "</a>";
                                 require 'ajax-actions/resend-email.php';
                             } else {
                                 $row['email_payment'] = "<span class='wdm-mark-hover'>" . __('Expired without reaching its reserve price', 'wdm-ultimate-auction') . "</span>";
                             }
                         } else {
                             if (empty($start_price)) {
                                 $row['email_payment'] = "<span class='wdm-mark-red'>" . __('Expired without buying', 'wdm-ultimate-auction') . "</span>";
                             } else {
                                 if (get_post_meta($single_auction->ID, 'auction_bought_status', true) === 'bought') {
                                     if (empty($buyer_id)) {
                                         $row['email_payment'] = "<div class='wdm-auction-bought wdm-mark-green'>" . __("Expired via Buy Now", "wdm-ultimate-auction") . "</div><div class='wdm-margin-bottom wdm-mark-green'>" . __("Price", "wdm-ultimate-auction") . "[" . $currency_code . " " . $buy_it_now_price . "]</div>";
                                     } else {
                                         $buyer = get_user_by('id', $buyer_id);
                                         if (!empty($buyer) && in_array('administrator', $buyer->roles)) {
                                             $row['email_payment'] = "<div class='wdm-auction-bought wdm-mark-green'>" . __("Bought by Administrator", "wdm-ultimate-auction") . "</div><div>" . apply_filters('ua_list_winner_info', $buyer->user_login, $buyer, $single_auction->ID, "e") . "</div><div class='wdm-margin-bottom wdm-mark-green'>" . __("Price", "wdm-ultimate-auction") . "[" . $currency_code . " " . $buy_it_now_price . "]</div>";
                                         } else {
                                             $row['email_payment'] = "<div class='wdm-auction-bought wdm-mark-green'>" . sprintf(__("Bought by %s", "wdm-ultimate-auction"), apply_filters('ua_list_winner_info', $buyer->user_login, $buyer, $single_auction->ID, "e")) . "</div><div class='wdm-margin-bottom wdm-mark-green'>" . __("Price", "wdm-ultimate-auction") . "[" . $currency_code . " " . $buy_it_now_price . "]</div>";
                                         }
                                     }
                                 } else {
                                     $row['email_payment'] = "<span class='wdm-mark-red'>" . __('Expired without any bids', 'wdm-ultimate-auction') . "</span>";
                                 }
                             }
                         }
                     }
                 }
                 $row['invoice'] = "";
                 $pay_method = get_post_meta($single_auction->ID, 'auction_active_pay_method', true);
                 $invoiceStat = get_post_meta($single_auction->ID, 'auction_invoice_status', true);
                 $auctionID = $single_auction->ID;
                 if ($invoiceStat !== 'Paid') {
                     $inv_arr[] = $auctionID;
                 }
                 $invoiceStat = get_post_meta($single_auction->ID, 'auction_invoice_status', true);
                 //$admin_email = get_option('wdm_auction_email');
                 $payment_qry = get_post_meta($single_auction->ID, 'wdm_payment_method', true);
                 $payment_method = str_replace("method_", " ", $payment_qry);
                 $payment_method = str_replace("_", " ", $payment_method);
                 if ($payment_method == 'mailing') {
                     $payment_method = 'cheque';
                 }
                 $row['invoice'] = "<span>" . sprintf(__('Method : %s', 'wdm-ultimate-auction'), $payment_method) . "</span><br /><br />";
                 if (!empty($invoiceStat) || get_post_meta($single_auction->ID, 'auction_bought_status', true) === 'bought' || !empty($winner) && in_array('administrator', $winner->roles)) {
                     if ($invoiceStat === 'Paid' || $invoiceStat === 'MarkedAsPaid' || get_post_meta($single_auction->ID, 'auction_bought_status', true) === 'bought' || !empty($winner) && in_array('administrator', $winner->roles)) {
                         if (!empty($winner) && in_array('administrator', $winner->roles)) {
                             //$row['invoice'] .= "<div class='wdm-margin-bottom wdm-mark-green'>".__('Won by Administrator', 'wdm-ultimate-auction')."</div>".apply_filters('ua_list_winner_info', $winner->user_login, $winner, $single_auction->ID, "p");
                         } else {
                             if ($invoiceStat === 'Paid' || $invoiceStat === 'MarkedAsPaid') {
                                 $row['invoice'] .= "<a href='#wdm_ua_fe_single_" . $single_auction->ID . "' id='wdm_pay_inv_" . $single_auction->ID . "'>" . __('Invoice Details', 'wdm-ultimate-auction') . "</a><br /><br />";
                             }
                             if (!empty($winner)) {
                                 if (get_post_meta($single_auction->ID, 'auction_bought_status', true) !== 'bought') {
                                     $row['invoice'] .= "<div class='wdm-margin-bottom wdm-mark-green'>" . sprintf(__("Paid by %s", "wdm-ultimate-auction"), apply_filters('ua_list_winner_info', $winner->user_login, $winner, $single_auction->ID, "p")) . "</div>";
                                 }
                             }
                         }
                         $if_paid = get_post_meta($single_auction->ID, 'wdm_final_payment_to_user', true);
                         if ($if_paid === 'Paid' && $pay_method != 'adaptive') {
                             $row['invoice'] .= "<div class='wdm-margin-bottom wdm-mark-green'>" . __("Paid by Administrator", "wdm-ultimate-auction") . "</div>";
                         } else {
                             $userData = new WP_User($userID);
                             if (!in_array('administrator', $userData->roles)) {
                                 //$paid_to_seller = get_post_meta($single_auction->ID, 'ua_direct_pay_to_seller', true);
                                 if ($paid_to_seller == 'pay' && get_post_meta($single_auction->ID, 'auction_bought_status', true) === 'bought') {
                                     if (!empty($winner)) {
                                         $row['invoice'] .= "<div class='wdm-mark-green'>" . sprintf(__('Paid by %s', 'wdm-ultimate-auction'), apply_filters('ua_list_winner_info', $winner->user_login, $winner, $single_auction->ID, "p")) . "</div>";
                                     }
                                 } elseif ($pay_method == 'adaptive') {
                                     $row['invoice'] .= "";
                                 } else {
                                     if (get_post_meta($single_auction->ID, 'auction_bought_status', true) !== 'bought') {
                                         $row['invoice'] .= "<div class='wdm-margin-bottom wdm-mark-red'>" . __("Pending with Administrator", "wdm-ultimate-auction") . "</div>";
                                     }
                                 }
                             }
                         }
                     } elseif ($invoiceStat === 'Sent') {
                         $row['invoice'] .= "<a href='#wdm_ua_fe_single_" . $single_auction->ID . "' id='wdm_pay_inv_" . $single_auction->ID . "'>" . __('Invoice Details', 'wdm-ultimate-auction') . "</a>";
                         if (!empty($winner)) {
                             $row['invoice'] .= "<br /><br /><div class='wdm-margin-bottom wdm-mark-red'>" . sprintf(__("Pending with %s", "wdm-ultimate-auction"), apply_filters('ua_list_winner_info', $winner->user_login, $winner, $single_auction->ID, "p")) . "</div>";
                         }
                     } else {
                         $row['invoice'] .= "<a href='#wdm_ua_fe_single_" . $single_auction->ID . "' id='wdm_pay_inv_" . $single_auction->ID . "'>" . __('Invoice Details', 'wdm-ultimate-auction') . "</a>";
                         $row['invoice'] .= "<br /><br /><span style='color:#FF4D00;'>" . __("Invoice Status", "wdm-ultimate-auction") . " - " . $invoiceStat . "</span>";
                     }
                 } else {
                     $row['invoice'] .= "<span class='wdm-mark-hover'>" . __('No Invoice', 'wdm-ultimate-auction') . "</span>";
                     $sent_to_seller = get_post_meta($single_auction->ID, 'ua_direct_paymentlink_to_seller', true);
                     if ($sent_to_seller == 'sent') {
                         if (!empty($winner)) {
                             $row['invoice'] .= "<br /><br /><div class='wdm-margin-bottom wdm-mark-green'>" . sprintf(__("Email with payment details sent to %s", "wdm-ultimate-auction"), apply_filters('ua_list_winner_info', $winner->user_login, $winner, $single_auction->ID, "p")) . "</div>";
                         }
                     }
                 }
             }
             //best offers for live auctions only.
             if ($this->auction_type === "live") {
                 $auction_best_offers_arr = get_post_meta($single_auction->ID, 'auction_best_offers', true);
                 if (!is_array($auction_best_offers_arr) || empty($auction_best_offers_arr)) {
                     $auction_best_offers_arr = array();
                 }
                 $row['bidders'] .= "<br /><br />";
                 if (!empty($auction_best_offers_arr)) {
                     $row['bidders'] .= "<strong>" . __("Best Offers", "wdm-ultimate-auction") . ":</strong>";
                 }
                 $row['bidders'] .= "<div class='wdm-ua-bst-offrs-box' data-bst-offer-uaid='" . $single_auction->ID . "'>";
                 foreach ($auction_best_offers_arr as $offer_sender_id => $bst_offr_data) {
                     $offer_sender_name = "";
                     $offer_sender = new WP_User($offer_sender_id);
                     $offer_sender_name = $offer_sender->user_login;
                     $offer_sender_email = $offer_sender->user_email;
                     $row['bidders'] .= "<br/><div class='wdm-ua-best-offer-row'><div class='wdm-ua-offer-details'><a href='#'><span class='wdm-mark-bold'>" . $offer_sender_name . ": " . "</span></a><span>" . $currency_code . " " . $bst_offr_data['offer_val'] . " " . "</span></div><br/>\n\n                        <div class = 'wdm-ua-offer-approval'><span class='wdm-mark-green wdm-ua-bst-offr-accept' data-bst-offr-senderid='" . $offer_sender_id . "' data-bst-offr-sendername='" . $offer_sender_name . "' data-bst-offr-senderemail='" . $offer_sender_email . "' data-best-offer-val='" . $bst_offr_data['offer_val'] . "'>" . __("Accept", "wdm-ultimate-auction") . "</span> <span class='wdm-mark-red wdm-ua-bst-offr-reject' data-bst-offr-senderid='" . $offer_sender_id . "' data-bst-offr-senderemail='" . $offer_sender_email . "' data-best-offer-val='" . $bst_offr_data['offer_val'] . "'>" . __("Reject", "wdm-ultimate-auction") . "</span></div></div>";
                 }
                 $row['bidders'] .= "</div>";
             }
             $data_array[] = $row;
             require 'ajax-actions/delete-auction.php';
             require 'ajax-actions/show_single_inv.php';
             require_once 'ajax-actions/best-offers-accept-reject.php';
         }
     }
     if ($this->auction_type === "expired") {
         $auctionID = implode(",", $inv_arr);
         require_once 'ua-paypal-invoice/ajax-actions/get-invoice-details.php';
     }
     require_once 'ajax-actions/see-more-bidders.php';
     $this->allData = $data_array;
     return $data_array;
 }
Exemple #2
0
 function wdm_get_data()
 {
     $userID = get_current_user_id();
     $user_det = new WP_User($userID);
     //        if(in_array('administrator', $user_det->roles))
     //	    $auction_auth_email = get_option("wdm_auction_email");
     //	else
     $auction_auth = $user_det->user_login;
     global $wpdb;
     $qry = "SELECT id,auction_id,bid FROM " . $wpdb->prefix . "wdm_bidders WHERE name ='" . $auction_auth . "' ORDER BY date DESC";
     $bids_data = $wpdb->get_results($qry);
     $all_auctions = array();
     $won_bids_array = array();
     $not_won_bids_array = array();
     $active_bids_array = array();
     $bid_data = array();
     $inv_arr = array();
     foreach ($bids_data as $bdata) {
         $reserve_pric_met = get_post_meta($bdata->auction_id, 'wdm_lowest_bid', true);
         $bid_qr = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $bdata->auction_id;
         $winner_bid = $wpdb->get_var($bid_qr);
         $name_qr = "SELECT name FROM " . $wpdb->prefix . "wdm_bidders WHERE bid =" . $winner_bid . " AND auction_id =" . $bdata->auction_id;
         //$winner_email = $wpdb->get_var($email_qr);
         $winner_name = $wpdb->get_var($name_qr);
         $winner = get_user_by('login', $winner_name);
         $winner_email = $winner->user_email;
         $active_terms = wp_get_post_terms($bdata->auction_id, 'auction-status', array("fields" => "names"));
         if ($auction_auth == $winner_name && $bdata->bid == $winner_bid && $winner_bid >= $reserve_pric_met && in_array('expired', $active_terms)) {
             $won_bids_array[] = $bdata;
         } else {
             if (in_array('expired', $active_terms)) {
                 $not_won_bids_array[] = $bdata;
             } else {
                 $active_bids_array[] = $bdata;
             }
         }
     }
     if (isset($_GET["bid_type"]) && $_GET["bid_type"] == "active") {
         $all_auctions = $active_bids_array;
     } elseif (isset($_GET["bid_type"]) && $_GET["bid_type"] == "not-won") {
         $all_auctions = $not_won_bids_array;
     } else {
         $all_auctions = $won_bids_array;
     }
     $data_array = array();
     foreach ($all_auctions as $single_auction) {
         $currency_code = substr(get_option('wdm_currency'), -3);
         $auction_post = get_post($single_auction->auction_id);
         if ($auction_post) {
             $auction_post_author = $auction_post->post_author;
             $auction_post_author_data = new WP_User($auction_post_author);
             $row = array();
             $row['owner'] = $auction_post_author_data->user_login;
             if (in_array('administrator', $auction_post_author_data->roles)) {
                 $row['paypal_email'] = get_option('wdm_paypal_address');
             } else {
                 $row['paypal_email'] = get_user_meta($auction_post_author, 'auction_user_paypal_email', true);
             }
             $row['title'] = prepare_single_auction_title($single_auction->auction_id, get_the_title($single_auction->auction_id));
             $end_date = get_post_meta($single_auction->auction_id, 'wdm_listing_ends', true);
             $row['date_created'] = "<strong> " . __('Creation Date', 'wdm-ultimate-auction') . ":</strong> <br />" . get_post_meta($single_auction->auction_id, 'wdm_creation_time', true) . " <br /><br /> <strong> " . __('Ending Date', 'wdm-ultimate-auction') . ":</strong> <br />" . $end_date;
             $start_price = get_post_meta($single_auction->auction_id, 'wdm_opening_bid', true);
             $buy_it_now_price = get_post_meta($single_auction->auction_id, 'wdm_buy_it_now', true);
             $row['current_price'] = "";
             $row['final_price'] = "";
             if (empty($start_price) && !empty($buy_it_now_price)) {
                 $row['current_price'] = "<strong>" . __('Buy Now Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $buy_it_now_price;
                 $row['final_price'] = "<strong>" . __('Buy Now Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $buy_it_now_price;
             } elseif (!empty($start_price)) {
                 $query = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $single_auction->auction_id;
                 $curr_price = $wpdb->get_var($query);
                 if (empty($curr_price)) {
                     $curr_price = $start_price;
                 }
                 $row['current_price'] = "<strong>" . __('Starting Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $start_price;
                 $row['current_price'] .= "<br /><br /> <strong>" . __('Current Price', 'wdm-ultimate-auction') . ":</strong><br /> " . $currency_code . " " . $curr_price;
                 $row['final_price'] = "<strong>" . __('Starting Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $start_price;
                 $row['final_price'] .= "<br /><br /> <strong>" . __('Final Price', 'wdm-ultimate-auction') . ":</strong><br /> " . $currency_code . " " . $curr_price;
             }
             $row['payment'] = '';
             $invoiceStat = get_post_meta($single_auction->auction_id, 'auction_invoice_status', true);
             $auctionID = $single_auction->auction_id;
             if ($invoiceStat !== 'Paid') {
                 $inv_arr[] = $auctionID;
             }
             $invoiceStat = get_post_meta($single_auction->auction_id, 'auction_invoice_status', true);
             if (!empty($invoiceStat)) {
                 if ($invoiceStat === 'Paid' || $invoiceStat === 'MarkedAsPaid') {
                     $row['payment'] = "<span class='wdm-mark-green'>" . __('Paid', 'wdm-ultimate-auction') . "</span><br /><br />";
                 } elseif ($invoiceStat === 'Sent') {
                     $row['payment'] = "<span class='wdm-mark-red'>" . __('Pending', 'wdm-ultimate-auction') . "</span><br /><br />";
                 } else {
                     $row['payment'] = "<span class='wdm-mark-hover'>" . __('Invoice Status', 'wdm-ultimate-auction') . " - " . $invoiceStat . "</span><br /><br />";
                 }
                 $inv_url = get_post_meta($single_auction->auction_id, 'paypal_invoice_url', true);
                 $row['payment'] .= !empty($inv_url) ? '<a href="' . $inv_url . '" target="_blank"> ' . __("View Invoice", "wdm-ultimate-auction") . ' </a>' : '';
             } else {
                 $row['payment'] = "<span class='wdm-mark-hover'>" . __('No Invoice', 'wdm-ultimate-auction');
             }
             $row['amount'] = $currency_code . " " . $single_auction->bid;
             $bidder_id = $single_auction->id;
             $data_array[] = $row;
         }
     }
     if ($this->bid_type === "won") {
         $auctionID = implode(",", $inv_arr);
         require_once 'ua-paypal-invoice/ajax-actions/get-invoice-details.php';
     }
     $this->allData = $data_array;
     return $data_array;
 }
Exemple #3
0
    function wdm_get_data()
    {
        $watch_auctions = get_user_meta(get_current_user_id(), 'wdm_watch_auctions', true);
        if (isset($watch_auctions)) {
            $auction_ids = explode(" ", $watch_auctions);
            $arg_data = array('post__in' => $auction_ids, 'posts_per_page' => -1, 'post_type' => 'ultimate-auction', 'post_status' => 'publish', 'order' => 'DESC');
            global $wpdb;
            $wdm_auction_array = get_posts($arg_data);
            $data_array = array();
            foreach ($wdm_auction_array as $auction) {
                $row = array();
                $act_trm = wp_get_post_terms($auction->ID, 'auction-status', array("fields" => "names"));
                $query = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $auction->ID;
                $curr_price = $wpdb->get_var($query);
                $vid_arr = array('mpg', 'mpeg', 'avi', 'mov', 'wmv', 'wma', 'mp4', '3gp', 'ogm', 'mkv', 'flv');
                $auc_thumb = get_post_meta($auction->ID, 'wdm_auction_thumb', true);
                $imgMime = wdm_get_mime_type($auc_thumb);
                $img_ext = explode(".", $auc_thumb);
                $img_ext = end($img_ext);
                if (strpos($img_ext, '?') !== false) {
                    $img_ext = strtolower(strstr($img_ext, '?', true));
                }
                if (strstr($imgMime, "video/") || in_array($img_ext, $vid_arr) || strstr($auc_thumb, "youtube.com") || strstr($auc_thumb, "vimeo.com")) {
                    $auc_thumb = plugins_url('img/film.png', __FILE__);
                }
                if (empty($auc_thumb)) {
                    $auc_thumb = plugins_url('img/no-pic.jpg', __FILE__);
                }
                //$perma_type = get_option('permalink_structure');
                //
                //if(empty($perma_type))
                //  $set_char = "&";
                //else
                //  $set_char = "?";
                //$auc_url = get_option('wdm_auction_page_url');
                //if(!empty($auc_url)){
                $link_title = get_permalink($auction->ID);
                //}
                $row['image_1'] = "<input class='wdm_chk_auc_act' value=" . $auction->ID . " type='checkbox' style='margin: 0 5px 0 0;' />" . "<img src='" . $auc_thumb . "' width='90'";
                $row['title'] = prepare_single_auction_title($auction->ID, $auction->post_title);
                $cc = substr(get_option('wdm_currency'), -3);
                $ob = get_post_meta($auction->ID, 'wdm_opening_bid', true);
                $bnp = get_post_meta($auction->ID, 'wdm_buy_it_now', true);
                if (!in_array('expired', $act_trm)) {
                    if ((!empty($curr_price) || $curr_price > 0) && !empty($ob)) {
                        $row['current_price'] = $cc . " " . sprintf("%.2f", $curr_price);
                    } elseif (!empty($ob)) {
                        $row['current_price'] = $cc . " " . sprintf("%.2f", $ob);
                    } elseif (empty($ob) && !empty($bnp)) {
                        $row['current_price'] = sprintf(__('Buy at %s %.2f', 'wdm-ultimate-auction'), $cc, $bnp);
                    }
                } elseif (in_array('expired', $act_trm)) {
                    $bought = get_post_meta($auction->ID, 'auction_bought_status', true);
                    if ($bought === 'bought') {
                        $row['current_price'] = $cc . " " . sprintf("%.2f", $bnp);
                    } elseif ((!empty($curr_price) || $curr_price > 0) && !empty($ob)) {
                        $row['current_price'] = $cc . " " . sprintf("%.2f", $curr_price);
                    } elseif (!empty($ob)) {
                        $row['current_price'] = $cc . " " . sprintf("%.2f", $ob);
                    } elseif (empty($ob) && !empty($bnp)) {
                        $row['current_price'] = $cc . " " . sprintf("%.2f", $bnp);
                    }
                }
                $get_bids = "SELECT COUNT(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $auction->ID;
                $bids_placed = $wpdb->get_var($get_bids);
                $auc_bstat = get_post_meta($auction->ID, 'auction_bought_status', true);
                if (in_array('expired', $act_trm) && $auc_bstat === 'bought') {
                    $row['bids_placed'] = "<span class='wdm-bids-avail wdm-mark-normal'>" . __("Sold at 'Buy Now' price", 'wdm-ultimate-auction') . "</span>";
                } else {
                    if (!empty($bids_placed) || $bids_placed > 0) {
                        $row['bids_placed'] = "<span class='wdm-bids-avail'>" . $bids_placed . "</span>";
                    } else {
                        $row['bids_placed'] = "<span class='wdm-no-bids-avail'>" . __('No bids placed', 'wdm-ultimate-auction') . "</span>";
                    }
                }
                $now = time();
                $ending_date = strtotime(get_post_meta($auction->ID, 'wdm_listing_ends', true));
                $seconds = $ending_date - $now;
                if (in_array('expired', $act_trm)) {
                    $seconds = $now - $ending_date;
                    $ending_tm = '';
                    $ended_at = wdm_ending_time_calculator($seconds, $ending_tm);
                    $row['end_time'] = "<span class='wdm-mark-normal'>" . sprintf(__('%s ago', 'wdm-ultimate-auction'), $ended_at) . "</span>";
                } elseif ($seconds > 0 && !in_array('expired', $act_trm)) {
                    $ending_tm = '';
                    $ending_in = wdm_ending_time_calculator($seconds, $ending_tm);
                    $row['end_time'] = "<span class='wdm-mark-normal'>" . $ending_in . "</span>";
                } else {
                    $seconds = $now - $ending_date;
                    $ending_tm = '';
                    $ended_at = wdm_ending_time_calculator($seconds, $ending_tm);
                    $row['end_time'] = "<span class='wdm-mark-normal'>" . sprintf(__('%s ago', 'wdm-ultimate-auction'), $ended_at) . "</span>";
                }
                if (in_array('expired', $act_trm)) {
                    $row['place_bid'] = '<span class="wdm-mark-red">' . __("Expired", "wdm-ultimate-auction") . '</span>';
                } elseif (in_array('live', $act_trm)) {
                    $row['place_bid'] = '<a href="' . $link_title . '" target="_blank"><input class="wdm_bid_now_btn" type="button" value="' . __('Bid Now', 'wdm-ultimate-auction') . '" /></a>';
                }
                $row['remove'] = '<a id="wdm-rmv-frmwatch-' . $auction->ID . '" style="color:red;cursor:pointer;text-decoration:none;" href="#">' . __('Remove', 'wdm-ultimate-auction') . ' <span class="auc-ajax-img"></span></a>';
                ?>
	    <script type="text/javascript">
            jQuery(document).ready(function($){
		$('#wdm-rmv-frmwatch-<?php 
                echo $auction->ID;
                ?>
').click(function(e){
		e.preventDefault();
		var ajaxurl = '<?php 
                echo admin_url('admin-ajax.php');
                ?>
';
		var cnf = confirm('<?php 
                _e("Are you sure to remove this auction from your watchlist?", "wdm-ultimate-auction");
                ?>
');
		
		if(cnf == true){
		
		$(this).html("<?php 
                _e('Removing', 'wdm-ultimate-auction');
                echo ' ';
                ?>
 <img src='<?php 
                echo plugins_url('/img/ajax-loader.gif', __FILE__);
                ?>
' />");
		
		var data = {
			      action:'rmv_frm_watchlist',
			      rmv_id:'<?php 
                echo $auction->ID;
                ?>
',
			      usr_id:'<?php 
                echo get_current_user_id();
                ?>
',
			      auc_title: '<?php 
                echo esc_js($auction->post_title);
                ?>
',
			      force_del:'yes'
			    };
		
		$.post(ajaxurl, data, function(response) {
		    $('#wdm-rmv-frmwatch-<?php 
                echo $auction->ID;
                ?>
').html('<?php 
                _e("Remove", "wdm-ultimate-auction");
                ?>
');
		    alert(response);
		    window.location.reload();
		 });
		}
		return false;
	      });
	    });
            </script>
      <?php 
                $data_array[] = $row;
            }
        }
        $this->allData = $data_array;
        return $data_array;
    }
 function wdm_get_data()
 {
     if (isset($_GET["auction_type"]) && $_GET["auction_type"] == "expired") {
         $args = array('posts_per_page' => -1, 'post_type' => 'ultimate-auction', 'auction-status' => 'expired', 'orderby' => 'meta_value', 'meta_key' => 'wdm_listing_ends', 'order' => 'DESC');
     } else {
         $args = array('posts_per_page' => -1, 'post_type' => 'ultimate-auction', 'auction-status' => 'live');
     }
     $auction_item_array = get_posts($args);
     $data_array = array();
     foreach ($auction_item_array as $single_auction) {
         $act_term = wp_get_post_terms($single_auction->ID, 'auction-status', array("fields" => "names"));
         if (time() >= strtotime(get_post_meta($single_auction->ID, 'wdm_listing_ends', true))) {
             if (!in_array('expired', $act_term)) {
                 $check_tm = term_exists('expired', 'auction-status');
                 wp_set_post_terms($single_auction->ID, $check_tm["term_id"], 'auction-status');
             }
         }
         $row = array();
         $row['ID'] = $single_auction->ID;
         $row['title'] = prepare_single_auction_title($single_auction->ID, $single_auction->post_title);
         $end_date = get_post_meta($single_auction->ID, 'wdm_listing_ends', true);
         $row['date_created'] = "<strong> " . __('Creation Date', 'wdm-ultimate-auction') . ":</strong> <br />" . get_post_meta($single_auction->ID, 'wdm_creation_time', true) . " <br /><br /> <strong>  " . __('Ending Date', 'wdm-ultimate-auction') . ":</strong> <br />" . $end_date;
         $thumb_img = get_post_meta($single_auction->ID, 'wdm_auction_thumb', true);
         if (empty($thumb_img) || $thumb_img == null) {
             $thumb_img = plugins_url('img/no-pic.jpg', __FILE__);
         }
         $row['image_1'] = "<input class='wdm_chk_auc_act' value=" . $single_auction->ID . " type='checkbox' style='margin: 0 5px 0 0;' />" . "<img src='" . $thumb_img . "' width='90'";
         if ($this->auction_type == "live") {
             $row['action'] = "<a href='?page=add-new-auction&edit_auction=" . $single_auction->ID . "'>" . __('Edit', 'wdm-ultimate-auction') . "</a> <br /><br /> <div id='wdm-delete-auction-" . $single_auction->ID . "' style='color:red;cursor:pointer;'>" . __('Delete', 'wdm-ultimate-auction') . " <span class='auc-ajax-img'></span></div> <br /> <div id='wdm-end-auction-" . $single_auction->ID . "' style='color:#21759B;cursor:pointer;'>" . __('End Auction', 'wdm-ultimate-auction') . "</div>";
             require 'ajax-actions/end-auction.php';
         } else {
             $row['action'] = "<div id='wdm-delete-auction-" . $single_auction->ID . "' style='color:red;cursor:pointer;'>" . __('Delete', 'wdm-ultimate-auction') . " <span class='auc-ajax-img'></span></div><br /><a href='?page=add-new-auction&edit_auction=" . $single_auction->ID . "&reactivate'>" . __('Reactivate', 'wdm-ultimate-auction') . "</a>";
         }
         //for bidding logic
         $row['bidders'] = "";
         $row_bidders = "";
         global $wpdb;
         $currency_code = substr(get_option('wdm_currency'), -3);
         $query = "SELECT * FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $single_auction->ID . " ORDER BY id DESC LIMIT 5";
         $results = $wpdb->get_results($query);
         if (!empty($results)) {
             $cnt_bidder = 0;
             foreach ($results as $result) {
                 $row_bidders .= "<li><strong><a href='#'>" . $result->name . "</a></strong> - " . $currency_code . " " . $result->bid . "</li>";
                 if ($cnt_bidder == 0) {
                     $bidder_id = $result->id;
                     $bidder_name = $result->name;
                 }
                 $cnt_bidder++;
             }
             $row["bidders"] = "<div class='wdm-bidder-list-" . $single_auction->ID . "'><ul>" . $row_bidders . "</ul></div>";
             $row["bidders"] .= "<div id='wdm-cancel-bidder-" . $bidder_id . "' style='font-weight:bold;color:#21759B;cursor:pointer;'>" . __('Cancel Last Bid', 'wdm-ultimate-auction') . "</div>";
             $qry = "SELECT * FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $single_auction->ID . " ORDER BY id DESC";
             $all_bids = $wpdb->get_results($qry);
             if (count($all_bids) > 5) {
                 $row["bidders"] .= "<br />\n                <a href='#' class='see-more showing-top-5' rel='" . $single_auction->ID . "' >" . __('See more', 'wdm-ultimate-auction') . "</a>";
             }
             require 'ajax-actions/cancel-bidder.php';
         } else {
             $row["bidders"] = __('No bids placed', 'wdm-ultimate-auction');
         }
         $start_price = get_post_meta($single_auction->ID, 'wdm_opening_bid', true);
         $buy_it_now_price = get_post_meta($single_auction->ID, 'wdm_buy_it_now', true);
         $row['current_price'] = "";
         $row['final_price'] = "";
         if (empty($start_price) && !empty($buy_it_now_price)) {
             $row['current_price'] = "<strong>" . __('Buy Now Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $buy_it_now_price;
             $row['final_price'] = "<strong>" . __('Buy Now Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $buy_it_now_price;
         } elseif (!empty($start_price)) {
             $query = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $single_auction->ID . " ORDER BY id DESC";
             $curr_price = $wpdb->get_var($query);
             if (empty($curr_price)) {
                 $curr_price = $start_price;
             }
             $row['current_price'] = "<strong>" . __('Starting Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $start_price;
             $row['current_price'] .= "<br /><br /> <strong>" . __('Current Price', 'wdm-ultimate-auction') . ":</strong><br /> " . $currency_code . " " . $curr_price;
             $row['final_price'] = "<strong>" . __('Starting Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $start_price;
             $row['final_price'] .= "<br /><br /> <strong>" . __('Final Price', 'wdm-ultimate-auction') . ":</strong><br /> " . $currency_code . " " . $curr_price;
         }
         if ($this->auction_type === "expired") {
             $row['email_payment'] = "";
             $payment_qry = get_post_meta($single_auction->ID, 'wdm_payment_method', true);
             $payment_method = str_replace("method_", " ", $payment_qry);
             $payment_method = str_replace("_", " ", $payment_method);
             $buyer_id = get_post_meta($single_auction->ID, 'wdm_auction_buyer', true);
             if ($payment_method == 'mailing') {
                 $payment_method = 'cheque';
             }
             $row['email_payment'] = "<span>" . sprintf(__('Method : %s', 'wdm-ultimate-auction'), $payment_method) . "</span><br /><br />";
             $buyer = get_user_by('id', $buyer_id);
             if (get_post_meta($single_auction->ID, 'auction_bought_status', true) === 'bought') {
                 if (empty($buyer)) {
                     $row['email_payment'] .= "<span class='wdm-auction-bought'>" . __('Auction has been bought by paying Buy Now price', 'wdm-ultimate-auction') . " <br/> [" . $currency_code . " " . $buy_it_now_price . "] </span>";
                 } else {
                     $row['email_payment'] .= "<div class='wdm-auction-bought'>" . sprintf(__("Bought by %s", "wdm-ultimate-auction"), apply_filters('ua_list_winner_info', $buyer->user_login, $buyer, $single_auction->ID, "e")) . "</div><div class='wdm-margin-bottom wdm-mark-green'>" . __("Price", "wdm-ultimate-auction") . "[" . $currency_code . " " . $buy_it_now_price . "]</div>";
                 }
             } else {
                 if (!empty($results)) {
                     $reserve_price_met = get_post_meta($single_auction->ID, 'wdm_lowest_bid', true);
                     $bid_qry = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $single_auction->ID . " ORDER BY id DESC";
                     $winner_bid = $wpdb->get_var($bid_qry);
                     if ($winner_bid >= $reserve_price_met) {
                         $email_qry = "SELECT email FROM " . $wpdb->prefix . "wdm_bidders WHERE bid =" . $winner_bid . " AND auction_id =" . $single_auction->ID . " ORDER BY id DESC";
                         $winner_email = $wpdb->get_var($email_qry);
                         //$winner = get_user_by('email', $winner_email);
                         $name_qry = "SELECT name FROM " . $wpdb->prefix . "wdm_bidders WHERE bid =" . $winner_bid . " AND auction_id =" . $single_auction->ID . " AND email = '" . $winner_email . "' ORDER BY id DESC";
                         $winner_name = $wpdb->get_var($name_qry);
                         $row['email_payment'] .= "<div class='wdm-margin-bottom wdm-mark-green'>" . sprintf(__("Won by %s", "wdm-ultimate-auction"), $winner_name) . "</div>";
                         $email_sent = get_post_meta($single_auction->ID, 'auction_email_sent', true);
                         $row['email_payment'] .= "<strong>Status: </strong>";
                         if ($email_sent === 'sent') {
                             $row['email_payment'] .= "<span style='color:green'>" . __('Yes', 'wdm-ultimate-auction') . "</span>";
                         } else {
                             $row['email_payment'] .= "<span style='color:red'>" . __('No', 'wdm-ultimate-auction') . "</span>";
                         }
                         $row['email_payment'] .= "<br/><br/> <a href='' id='auction-resend-" . $single_auction->ID . "'>" . __('Resend', 'wdm-ultimate-auction') . "</a>";
                         require 'ajax-actions/resend-email.php';
                     } else {
                         $row['email_payment'] .= "<span style='color:#D64B00'>" . __('Auction has expired without reaching its reserve price', 'wdm-ultimate-auction') . "</span>";
                     }
                 }
             }
         }
         $data_array[] = $row;
         require 'ajax-actions/delete-auction.php';
     }
     require_once 'ajax-actions/multi-delete.php';
     $this->allData = $data_array;
     return $data_array;
 }
    function wdm_get_data()
    {
        if (isset($_GET["auction_type"]) && $_GET["auction_type"] == "expired") {
            $args = array('posts_per_page' => -1, 'post_type' => 'ultimate-auction', 'auction-status' => 'expired', 'orderby' => 'meta_value', 'meta_key' => 'wdm_listing_ends', 'order' => 'DESC');
        } elseif (isset($_GET["auction_type"]) && $_GET["auction_type"] == "scheduled") {
            $args = array('posts_per_page' => -1, 'post_type' => 'ultimate-auction', 'auction-status' => 'scheduled');
        } elseif (isset($_GET["auction_type"]) && $_GET["auction_type"] == "pending") {
            $args = array('posts_per_page' => -1, 'post_type' => 'ultimate-auction', 'post_status' => 'pending');
        } else {
            $args = array('posts_per_page' => -1, 'post_type' => 'ultimate-auction', 'auction-status' => 'live');
        }
        $auction_item_array = get_posts($args);
        $data_array = array();
        $inv_arr = array();
        $inv_arr1 = array();
        $results = array();
        $auction_user = get_option('wdm_usr_auctions_list');
        foreach ($auction_item_array as $single_auction) {
            $userID = $single_auction->post_author;
            $userData = new WP_User($userID);
            $author_mail = $userData->user_email;
            if (!empty($auction_user) && $auction_user == $userData->user_login || empty($auction_user) && !in_array('administrator', $userData->roles)) {
                $act_term = wp_get_post_terms($single_auction->ID, 'auction-status', array("fields" => "names"));
                if (time() >= strtotime(get_post_meta($single_auction->ID, 'wdm_listing_ends', true))) {
                    if (!in_array('expired', $act_term)) {
                        $check_tm = term_exists('expired', 'auction-status');
                        wp_set_post_terms($single_auction->ID, $check_tm["term_id"], 'auction-status');
                    }
                }
                $listing_trans_amt = get_post_meta($single_auction->ID, 'wdm_auction_listing_amt', true);
                $listing_trans_id = get_post_meta($single_auction->ID, 'wdm_auction_listing_transaction', true);
                $user_paypal_id = get_user_meta($userID, 'auction_user_paypal_email', true);
                $row = array();
                $row['user'] = "******" . $single_auction->ID . " type='checkbox' style='margin: 0 5px 0 0;' />" . $userData->user_login;
                $row['user'] .= "<br /><br /><a href='mailto:" . $userData->user_email . "'>" . $userData->user_email . "</a>";
                $row['payment_made'] = '';
                if (empty($listing_trans_amt) && empty($listing_trans_id)) {
                    $row['payment_made'] = __('Nil', 'wdm-ultimate-auction') . ' <br /><br />';
                } else {
                    if (!empty($listing_trans_amt)) {
                        $row['payment_made'] = $listing_trans_amt . '<br /><br />';
                    }
                    if (!empty($listing_trans_id)) {
                        $row['payment_made'] .= __('Transaction ID', 'wdm-ultimate-auction') . ': <br /><span class="wdm-mark-hover">' . $listing_trans_id . '</span>';
                    }
                }
                $row['ID'] = $single_auction->ID;
                $row['title'] = prepare_single_auction_title($single_auction->ID, $single_auction->post_title);
                $end_date = get_post_meta($single_auction->ID, 'wdm_listing_ends', true);
                if ($this->auction_type == "scheduled") {
                    $dt_lbl = __('Starting Date', 'wdm-ultimate-auction');
                } else {
                    $dt_lbl = __('Creation Date', 'wdm-ultimate-auction');
                }
                $row['date_created'] = "<strong> " . $dt_lbl . ":</strong> <br />" . get_post_meta($single_auction->ID, 'wdm_creation_time', true) . " <br /><br /> <strong> " . __('Ending Date', 'wdm-ultimate-auction') . ":</strong> <br />" . $end_date;
                $thumb_img = get_post_meta($single_auction->ID, 'wdm_auction_thumb', true);
                if (empty($thumb_img) || $thumb_img == null) {
                    $thumb_img = plugins_url('img/no-pic.jpg', __FILE__);
                }
                $row['image_1'] = "<img src='" . $thumb_img . "' width='90'";
                if ($this->auction_type == "live" || $this->auction_type == "scheduled" || $this->auction_type == "pending") {
                    $row['action'] = "<a href='?page=add-new-auction&edit_auction=" . $single_auction->ID . "'>" . __('Edit', 'wdm-ultimate-auction') . "</a> <br /><br />\n\t\t<div id='wdm-delete-auction-" . $single_auction->ID . "' style='color:red;cursor:pointer;'>" . __('Delete', 'wdm-ultimate-auction') . " <span class='auc-ajax-img'></span></div>";
                } else {
                    $row['action'] = "<div id='wdm-delete-auction-" . $single_auction->ID . "' style='color:red;cursor:pointer;'>" . __('Delete', 'wdm-ultimate-auction') . " <span class='auc-ajax-img'></span></div>\n\t\t\t\t<br /><a href='?page=add-new-auction&edit_auction=" . $single_auction->ID . "&reactivate'>" . __('Reactivate', 'wdm-ultimate-auction') . "</a>";
                    //if(get_post_meta($single_auction->ID,'auction_bought_status',true) === 'bought'){
                    //	require('ajax-actions/send-download-link.php');
                    //}
                }
                if ($this->auction_type == "live") {
                    $row['action'] .= "<br />\n\t\t<div id='wdm-end-auction-" . $single_auction->ID . "' style='color:#21759B;cursor:pointer;'>" . __('End Auction', 'wdm-ultimate-auction') . "</div>";
                    require 'ajax-actions/end-auction.php';
                }
                //for bidding logic
                $row['bidders'] = "";
                $row_bidders = "";
                global $wpdb;
                $currency_code = substr(get_option('wdm_currency'), -3);
                $query = "SELECT * FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $single_auction->ID . " ORDER BY id DESC LIMIT 5";
                $results = $wpdb->get_results($query);
                if (!empty($results)) {
                    $cnt_bidder = 0;
                    foreach ($results as $result) {
                        $row_bidders .= "<li><strong><a href='#'>" . $result->name . "</a></strong> - " . $currency_code . " " . $result->bid . "</li>";
                        if ($cnt_bidder == 0) {
                            $bidder_id = $result->id;
                            $bidder_name = $result->name;
                        }
                        $cnt_bidder++;
                    }
                    $row["bidders"] = "<div class='wdm-bidder-list-" . $single_auction->ID . "'><ul>" . $row_bidders . "</ul></div>";
                    if ($this->auction_type === "live") {
                        $row["bidders"] .= "<div id='wdm-cancel-bidder-" . $bidder_id . "' style='font-weight:bold;color:#21759B;cursor:pointer;'>" . __('Cancel Last Bid', 'wdm-ultimate-auction') . "</div>";
                        require 'ajax-actions/cancel-bid.php';
                    }
                    $qry = "SELECT * FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $single_auction->ID . " ORDER BY id DESC";
                    $all_bids = $wpdb->get_results($qry);
                    if (count($all_bids) > 5) {
                        $row["bidders"] .= "<br />\n                <a href='#' class='see-more showing-top-5' rel='" . $single_auction->ID . "' >" . __('See more', 'wdm-ultimate-auction') . "</a>";
                    }
                } else {
                    $row["bidders"] = __('No bids placed', 'wdm-ultimate-auction');
                }
                $start_price = get_post_meta($single_auction->ID, 'wdm_opening_bid', true);
                $buy_it_now_price = get_post_meta($single_auction->ID, 'wdm_buy_it_now', true);
                $row['current_price'] = "";
                $row['final_price'] = "";
                if (empty($start_price) && !empty($buy_it_now_price)) {
                    $row['current_price'] = "<strong>" . __('Buy Now Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $buy_it_now_price;
                    $row['final_price'] = "<strong>" . __('Buy Now Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $buy_it_now_price;
                } elseif (!empty($start_price)) {
                    $query = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $single_auction->ID;
                    $curr_price = $wpdb->get_var($query);
                    if (empty($curr_price)) {
                        $curr_price = $start_price;
                    }
                    $row['current_price'] = "<strong>" . __('Starting Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $start_price;
                    $row['current_price'] .= "<br /><br /> <strong>" . __('Current Price', 'wdm-ultimate-auction') . ":</strong><br /> " . $currency_code . " " . $curr_price;
                    $row['final_price'] = "<strong>" . __('Starting Price', 'wdm-ultimate-auction') . ":</strong> <br />" . $currency_code . " " . $start_price;
                    $row['final_price'] .= "<br /><br /> <strong>" . __('Final Price', 'wdm-ultimate-auction') . ":</strong><br /> " . $currency_code . " " . $curr_price;
                }
                if ($this->auction_type === "expired") {
                    $winner_email = "";
                    $buyer_id = "";
                    $buyer_id = get_post_meta($single_auction->ID, 'wdm_auction_buyer', true);
                    $row['email_payment'] = "";
                    $amt_pay_to_user = 0;
                    $paid_to_seller = get_post_meta($single_auction->ID, 'ua_direct_pay_to_seller', true);
                    //$check_method = get_post_meta($single_auction->ID, 'wdm_payment_method', true);
                    if (get_post_meta($single_auction->ID, 'auction_bought_status', true) === 'bought' && $paid_to_seller != 'pay') {
                        if (empty($buyer_id)) {
                            $row['email_payment'] = "<div class='wdm-auction-bought wdm-mark-green'>" . __("Expired via Buy Now", "wdm-ultimate-auction") . "</div><div class='wdm-margin-bottom wdm-mark-green'>" . __("Price", "wdm-ultimate-auction") . "[" . $currency_code . " " . $buy_it_now_price . "]</div>";
                        } else {
                            $buyer = get_user_by('id', $buyer_id);
                            if (!empty($buyer) && in_array('administrator', $buyer->roles)) {
                                $row['email_payment'] = "<div class='wdm-auction-bought wdm-mark-green'>" . __("Bought by Administrator", "wdm-ultimate-auction") . "</div><div>" . apply_filters('ua_list_winner_info', $buyer->user_login, $buyer, $single_auction->ID, "e") . "</div><div class='wdm-margin-bottom wdm-mark-green'>" . __("Price", "wdm-ultimate-auction") . "[" . $currency_code . " " . $buy_it_now_price . "]</div>";
                            } else {
                                $row['email_payment'] = "<div class='wdm-auction-bought wdm-mark-green'>" . sprintf(__("Bought by %s", "wdm-ultimate-auction"), apply_filters('ua_list_winner_info', $buyer->user_login, $buyer, $single_auction->ID, "e")) . "</div><div class='wdm-margin-bottom wdm-mark-green'>" . __("Price", "wdm-ultimate-auction") . "[" . $currency_code . " " . $buy_it_now_price . "]</div>";
                            }
                        }
                        $amt_pay_to_user = $buy_it_now_price;
                    } else {
                        if (get_post_meta($single_auction->ID, 'wdm_auction_expired_by', true) == 'ua_best_offers') {
                            $bo_sender_data = get_post_meta($single_auction->ID, 'auction_winner_by_best_offer', true);
                            if (is_array($bo_sender_data)) {
                                reset($bo_sender_data);
                                $bo_sender_id = key($bo_sender_data);
                                $bo_sender = get_user_by('id', $bo_sender_id);
                                $best_offer_price_row = isset($bo_sender_data[$bo_sender_id]['offer_val']) ? "<div class='wdm-margin-bottom wdm-mark-green'>" . __("Price", "wdm-ultimate-auction") . "[" . $currency_code . " " . $bo_sender_data[$bo_sender_id]['offer_val'] . "]</div>" : "";
                                $row['email_payment'] = "<div class='wdm-auction-bought wdm-mark-green'>" . sprintf(__("Sold to %s", "wdm-ultimate-auction"), apply_filters('ua_best_offer_sender_info', $bo_sender->user_login, $bo_sender, $bo_sender_id, "e")) . "</div>" . $best_offer_price_row;
                            }
                        } else {
                            $reserve_price_met = 0;
                            $bid_qry = "";
                            $email_qry = "";
                            $winner_bid = 0;
                            $winner_name = "";
                            $winner = array();
                            $email_sent = "";
                            if (!empty($results)) {
                                $reserve_price_met = get_post_meta($single_auction->ID, 'wdm_lowest_bid', true);
                                $bid_qry = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $single_auction->ID;
                                $winner_bid = $wpdb->get_var($bid_qry);
                                if ($winner_bid >= $reserve_price_met) {
                                    $amt_pay_to_user = $winner_bid;
                                    $email_qry = "SELECT name FROM " . $wpdb->prefix . "wdm_bidders WHERE bid =" . $winner_bid . " AND auction_id =" . $single_auction->ID . " ORDER BY id DESC";
                                    $winner_name = $wpdb->get_var($email_qry);
                                    $winner = get_user_by('login', $winner_name);
                                    $winner_email = $winner->user_email;
                                    $email_sent = get_post_meta($single_auction->ID, 'auction_email_sent', true);
                                    $current_user_ID = get_current_user_id();
                                    if (!empty($winner) && in_array('administrator', $winner->roles)) {
                                        $row['email_payment'] = "<div class='wdm-margin-bottom wdm-mark-green'>" . __('Won by Administrator', 'wdm-ultimate-auction') . "</div><div>" . apply_filters('ua_list_winner_info', $winner->user_login, $winner, $single_auction->ID, "e") . "</div>";
                                        if ($current_user_ID == $userID) {
                                            require 'ajax-actions/send-download-link.php';
                                        }
                                    } else {
                                        $row['email_payment'] = "<div class='wdm-margin-bottom wdm-mark-green'>" . sprintf(__('Won by %s', 'wdm-ultimate-auction'), apply_filters('ua_list_winner_info', $winner->user_login, $winner, $single_auction->ID, "e")) . "</div>";
                                        if ($current_user_ID == $userID) {
                                            require 'ajax-actions/send-download-link.php';
                                        }
                                    }
                                    $row['email_payment'] .= "<strong>" . __('Email Status', 'wdm-ultimate-auction') . ": </strong>";
                                    if ($email_sent === 'sent') {
                                        $row['email_payment'] .= "<span class='wdm-mark-green'>" . __('Yes', 'wdm-ultimate-auction') . "</span>";
                                    } else {
                                        $row['email_payment'] .= "<span class='wdm-mark-red'>" . __('No', 'wdm-ultimate-auction') . "</span>";
                                    }
                                    $row['email_payment'] .= "<br/><br/> <a href='' id='auction-resend-" . $single_auction->ID . "'>" . __('Resend', 'wdm-ultimate-auction') . "</a>";
                                    require 'ajax-actions/resend-email.php';
                                } else {
                                    $row['email_payment'] = "<span class='wdm-mark-hover'>" . __('Expired without reaching its reserve price', 'wdm-ultimate-auction') . "</span>";
                                }
                            } else {
                                if (empty($start_price)) {
                                    $row['email_payment'] = "<span class='wdm-mark-red'>" . __('Expired without buying', 'wdm-ultimate-auction') . "</span>";
                                } else {
                                    if (get_post_meta($single_auction->ID, 'auction_bought_status', true) === 'bought') {
                                        if (empty($buyer_id)) {
                                            $row['email_payment'] = "<div class='wdm-auction-bought wdm-mark-green'>" . __("Expired via Buy Now", "wdm-ultimate-auction") . "</div><div class='wdm-margin-bottom wdm-mark-green'>" . __("Price", "wdm-ultimate-auction") . "[" . $currency_code . " " . $buy_it_now_price . "]</div>";
                                        } else {
                                            $buyer = get_user_by('id', $buyer_id);
                                            if (!empty($buyer) && in_array('administrator', $buyer->roles)) {
                                                $row['email_payment'] = "<div class='wdm-auction-bought wdm-mark-green'>" . __("Bought by Administrator", "wdm-ultimate-auction") . "</div><div>" . apply_filters('ua_list_winner_info', $buyer->user_login, $buyer, $single_auction->ID, "e") . "</div><div class='wdm-margin-bottom wdm-mark-green'>" . __("Price", "wdm-ultimate-auction") . "[" . $currency_code . " " . $buy_it_now_price . "]</div>";
                                            } else {
                                                $row['email_payment'] = "<div class='wdm-auction-bought wdm-mark-green'>" . sprintf(__("Bought by %s", "wdm-ultimate-auction"), apply_filters('ua_list_winner_info', $buyer->user_login, $buyer, $single_auction->ID, "e")) . "</div><div class='wdm-margin-bottom wdm-mark-green'>" . __("Price", "wdm-ultimate-auction") . "[" . $currency_code . " " . $buy_it_now_price . "]</div>";
                                            }
                                        }
                                    } else {
                                        $row['email_payment'] = "<span class='wdm-mark-red'>" . __('Expired without any bids', 'wdm-ultimate-auction') . "</span>";
                                    }
                                }
                            }
                        }
                    }
                    $row['payment'] = "";
                    $pay_method = get_post_meta($single_auction->ID, 'auction_active_pay_method', true);
                    $invoiceStat = get_post_meta($single_auction->ID, 'auction_invoice_status', true);
                    $auctionID = $single_auction->ID;
                    if ($invoiceStat !== 'Paid') {
                        $pay_mthd = get_post_meta($single_auction->ID, 'auction_active_pay_method', true);
                        if ($pay_mthd == 'adaptive') {
                            $inv_arr1[] = $auctionID;
                        } else {
                            $inv_arr[] = $auctionID;
                        }
                    }
                    $invoiceStat = get_post_meta($single_auction->ID, 'auction_invoice_status', true);
                    //$admin_email = get_option('wdm_auction_email');
                    $payment_qry = get_post_meta($single_auction->ID, 'wdm_payment_method', true);
                    $payment_method = str_replace("method_", " ", $payment_qry);
                    $payment_method = str_replace("_", " ", $payment_method);
                    if ($payment_method == 'mailing') {
                        $payment_method = 'cheque';
                    }
                    $row['payment'] = "<span>" . sprintf(__('Method : %s', 'wdm-ultimate-auction'), $payment_method) . "</span><br /><br />";
                    if (!empty($invoiceStat) || get_post_meta($single_auction->ID, 'auction_bought_status', true) === 'bought' || !empty($winner) && in_array('administrator', $winner->roles)) {
                        if ($invoiceStat === 'Paid' || $invoiceStat === 'MarkedAsPaid' || get_post_meta($single_auction->ID, 'auction_bought_status', true) === 'bought' || !empty($winner) && in_array('administrator', $winner->roles)) {
                            if (!empty($winner) && in_array('administrator', $winner->roles)) {
                                //$row['payment'] .= "<div class='wdm-margin-bottom wdm-mark-green'>".__('Won by Administrator', 'wdm-ultimate-auction')."</div>".apply_filters('ua_list_winner_info', $winner->user_login, $winner, $single_auction->ID, "p");
                            } else {
                                if ($invoiceStat === 'Paid' || $invoiceStat === 'MarkedAsPaid') {
                                    $row['payment'] .= "<a href='" . admin_url("admin.php?page=invoices&payment_type=past&auction=") . $single_auction->ID . "' target='_blank'>" . __('Invoice Details', 'wdm-ultimate-auction') . "</a><br /><br />";
                                }
                                if (!empty($winner)) {
                                    if (get_post_meta($single_auction->ID, 'auction_bought_status', true) !== 'bought') {
                                        $row['payment'] .= "<div class='wdm-margin-bottom wdm-mark-green'>" . sprintf(__("Paid by %s", "wdm-ultimate-auction"), apply_filters('ua_list_winner_info', $winner->user_login, $winner, $single_auction->ID, "p")) . "</div>";
                                    }
                                }
                            }
                            //$commission = 0;
                            //$commission = get_option('wdm_manage_cm_fees_data');
                            //$amt_pay_to_user = wdm_auction_commission_calculator($commission, $amt_pay_to_user);
                            //if(isset($_GET["tx"]) && !empty($_GET["tx"])){
                            $auth = get_post_meta($single_auction->ID, 'wdm-auth-key', true);
                            if (isset($_GET["auc"]) && $_GET["auc"] === $auth) {
                                update_post_meta($single_auction->ID, 'wdm_final_payment_to_user', 'Paid');
                                update_post_meta($single_auction->ID, 'finally_paid_amount', $currency_code . " " . $amt_pay_to_user);
                                printf("<script type='text/javascript'>\n\t\t    var cur_url = window.location.href;\n\t\t    if(window.location.href.indexOf('ua_reloaded') == -1)\n\t\t    setTimeout(function() {alert('" . __("Payment done to %s successfully.", "wdm-ultimate-auction") . "');window.location.href=cur_url+'&ua_reloaded';}, 1000);\n\t\t    </script>", $userData->user_login);
                            }
                            //}
                            $if_paid = get_post_meta($single_auction->ID, 'wdm_final_payment_to_user', true);
                            if ($if_paid === 'Paid' && $pay_method != 'adaptive') {
                                $row['payment'] .= "<div class='wdm-mark-green'>" . sprintf(__('Paid to %s', 'wdm-ultimate-auction'), apply_filters('ua_list_winner_info', $userData->user_login, $userData, $single_auction->ID, "p")) . "</div>";
                            } else {
                                //disable pay to user if payment sent directly to auction owner
                                //$paid_to_seller = get_post_meta($single_auction->ID, 'ua_direct_pay_to_seller', true);
                                if ($paid_to_seller == 'pay' && get_post_meta($single_auction->ID, 'auction_bought_status', true) === 'bought') {
                                    $row['payment'] .= "<div class='wdm-mark-hover'>" . sprintf(__('Payment directly made to %s', 'wdm-ultimate-auction'), apply_filters('ua_list_winner_info', $userData->user_login, $userData, $single_auction->ID, "p")) . "</div>";
                                } else {
                                    $shipping_amt = '';
                                    $shipping_amt = get_post_meta($single_auction->ID, 'wdm_ua_shipping_amt', true);
                                    $mode = get_option('wdm_account_mode');
                                    $paypal_link = "";
                                    if ($mode == 'Sandbox') {
                                        $paypal_link = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick";
                                    } else {
                                        $paypal_link = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick";
                                    }
                                    $auth_key = get_post_meta($single_auction->ID, 'wdm-auth-key', true);
                                    $paypal_link .= "&business=" . urlencode($user_paypal_id);
                                    //$paypal_link .= "&lc=US";
                                    $paypal_link .= "&item_name=" . urlencode($single_auction->post_title);
                                    $paypal_link .= "&amount=" . urlencode($amt_pay_to_user);
                                    if (!empty($shipping_amt)) {
                                        $paypal_link .= "&shipping=" . urlencode($shipping_amt);
                                    }
                                    $paypal_link .= "&currency_code=" . urlencode($currency_code);
                                    $paypal_link .= "&return=" . urlencode(admin_url('admin.php?page=manage-user-auctions&auction_type=expired&auc=' . $auth_key));
                                    $paypal_link .= "&button_subtype=services";
                                    $paypal_link .= "&no_note=0";
                                    $paypal_link .= "&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHostedGuest";
                                    $payment_link = "";
                                    $comm_inv = get_option('wdm_manage_comm_invoice');
                                    if ($pay_method != 'adaptive') {
                                        //handle via adaptive payments only now
                                        $merchant_email = get_option('wdm_paypal_address');
                                        $auction_data = array('auc_id' => $single_auction->ID, 'auc_name' => $single_auction->post_title, 'auc_desc' => $single_auction->post_content, 'auc_bid' => $amt_pay_to_user, 'auc_seller' => $user_paypal_id, 'auc_payer' => $merchant_email, 'auc_currency' => $currency_code, 'auc_url' => admin_url('admin.php?page=manage-user-auctions&auction_type=expired&auc=' . $auth_key), 'pay_type' => 'simple');
                                        //$paypal_link = apply_filters('ua_adaptive_buy_now_link', $paypal_link, $auction_data);
                                        $btn_txt = sprintf(__('Pay %s to %s', 'wdm-ultimate-auction'), $currency_code . " " . $amt_pay_to_user, $userData->user_login);
                                        if (get_post_meta($single_auction->ID, 'auction_bought_status', true) !== 'bought' || get_post_meta($single_auction->ID, 'auction_bought_status', true) === 'bought' && $comm_inv === 'Yes' && $payment_qry === 'method_paypal') {
                                            //$payment_link .= $paypal_link;
                                            $payment_link = "<form class='adp_bin_frm' action='' method='post'>\n\t\t\t    <input class='wdm-make-payment-link button-secondary wdm-mark-hover' style='height:auto !important;white-space:normal;' name='adp_bin_btn' type='submit' value='" . $btn_txt . "' />";
                                            $payment_link .= "<input name='auc_data' class='adp_bin_btn_hdn' type='hidden' value='" . base64_encode(json_encode($auction_data)) . "' />";
                                            $payment_link .= "<span class='prog_img'></span></form><br />";
                                        }
                                    }
                                    if (!empty($shipping_amt)) {
                                        $payment_link .= "<span style='font-size: 11px;color: #E76709;'>" . __('Shipping amount', 'wdm-ultimate-auction') . ": " . $currency_code . " " . $shipping_amt . "</span><br />";
                                    }
                                    $row['payment'] .= $payment_link;
                                    $row['payment'] .= apply_filters('ua_list_winner_info', $userData->user_login, $userData, $single_auction->ID, "p");
                                }
                            }
                        } elseif ($invoiceStat === 'Sent') {
                            $row['payment'] .= "<a href='" . admin_url("admin.php?page=invoices&payment_type=outstanding&auction=") . $single_auction->ID . "' target='_blank'>" . __('Invoice Details', 'wdm-ultimate-auction') . "</a>";
                            if (!empty($winner)) {
                                $row['payment'] .= "<br /><br /><div class='wdm-margin-bottom wdm-mark-red'>" . sprintf(__("Pending with %s", "wdm-ultimate-auction"), apply_filters('ua_list_winner_info', $winner->user_login, $winner, $single_auction->ID, "p")) . "</div>";
                            }
                        } else {
                            $row['payment'] .= "<a href='" . admin_url("admin.php?page=invoices&payment_type=outstanding&auction=") . $single_auction->ID . "' target='_blank'>" . __('Invoice Details', 'wdm-ultimate-auction') . "</a>";
                            $row['payment'] .= "<br /><br /><span style='color:#FF4D00;'>" . __("Invoice Status", "wdm-ultimate-auction") . " - " . $invoiceStat . "</span>";
                        }
                    } else {
                        $row['payment'] .= "<span class='wdm-mark-hover'>" . __('No Invoice', 'wdm-ultimate-auction');
                        $sent_to_seller = get_post_meta($single_auction->ID, 'ua_direct_paymentlink_to_seller', true);
                        if ($sent_to_seller == 'sent') {
                            if (!empty($winner)) {
                                $row['payment'] .= "<br /><br /><div class='wdm-margin-bottom wdm-mark-green'>" . sprintf(__("Email with payment details sent to %s", "wdm-ultimate-auction"), apply_filters('ua_list_winner_info', $winner->user_login, $winner, $single_auction->ID, "p")) . "</div>";
                            }
                        }
                    }
                }
                if ($this->auction_type === "pending") {
                    if (isset($_GET['approve_auc']) && $_GET['approve_auc'] == $single_auction->ID) {
                        $p_auc = array();
                        $p_auc['ID'] = $single_auction->ID;
                        $p_auc['post_status'] = 'publish';
                        wp_update_post($p_auc);
                        ?>
	    <script type="text/javascript">
		jQuery(document).ready(function(){
		window.location.href = "<?php 
                        echo admin_url('admin.php?page=manage-user-auctions&auction_type=pending');
                        ?>
";
		});
	    </script>
	    <?php 
                    } else {
                        $row['action'] .= "<br /><a href='?page=manage-user-auctions&auction_type=pending&approve_auc=" . $single_auction->ID . " '>" . __('Approve', 'wdm-ultimate-auction') . "</a>";
                    }
                }
                $data_array[] = $row;
                require 'ajax-actions/delete-auction.php';
            }
        }
        if ($this->auction_type === "expired") {
            $auctionID = implode(",", $inv_arr);
            $auctionID1 = implode(",", $inv_arr1);
            require_once 'ua-paypal-invoice/ajax-actions/get-invoice-details.php';
        }
        require_once 'ajax-actions/see-more-bidders.php';
        require_once 'ajax-actions/multi-delete.php';
        require_once 'ajax-actions/buy-now-adaptive-admin.php';
        $this->allData = $data_array;
        return $data_array;
    }