function bepro_listings_custom_columns($column) { global $post; switch ($column) { case "description": the_excerpt(); break; case "lat_lon": global $wpdb; $custom = $wpdb->get_row("SELECT lat, lon FROM " . $wpdb->prefix . BEPRO_LISTINGS_TABLE_NAME . " WHERE post_id =" . $post->ID); echo !empty($custom->lat) && !empty($custom->lon) ? "Yes" : "No"; break; case "cost": global $wpdb; $custom = $wpdb->get_row("SELECT cost FROM " . $wpdb->prefix . BEPRO_LISTINGS_TABLE_NAME . " WHERE post_id =" . $post->ID); echo $custom->cost; break; case "notices": global $wpdb; $data = get_option("bepro_listings"); $notice = "None"; $cost = 0; $item = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . BEPRO_LISTINGS_TABLE_NAME . " WHERE post_id =" . $post->ID); $status = $post->post_status == "publish" ? "Published" : "Pending"; if (!empty($data["require_payment"]) && $status == "Published") { $notice = "Expires: " . (empty($item->expires) || $item->expires == "0000-00-00 00:00:00" ? "Never" : date("M, d Y", strtotime($item->expires))); } else { if (!empty($data["require_payment"]) && $status == "Pending") { if (is_numeric($item->bepro_cart_id)) { $notice = "Paid: Processing"; } else { if ($data["require_payment"] == 1) { //category option $cost = bepro_get_total_cat_cost($item->post_id); } else { if ($data["require_payment"] == 2) { $cost = get_post_meta($item->post_id, "fee", true); if (!$cost) { $notice = "Package: Required"; } } } } if (@$cost && $cost > 0) { $notice = __("Pay", "bepro-listings") . ": " . $data["currency_sign"] . $cost; } } } echo $notice; break; case "listing_types": echo get_the_term_list($post->ID, 'bepro_listing_types', '', ', ', ''); break; } }
function bl_show_user_missing_payments() { global $wpdb; $data = get_option("bepro_listings"); if ($data["require_payment"] != 1 && $data["require_payment"] != 2) { return; } $packages = get_posts(array("post_type" => "bpl_packages")); //if no packages, then warn user and exit if ($data["require_payment"] == 2 && empty($packages)) { echo "<p class='bl_fail_message'>" . __("NOTICE: Notify admin to create payment packaged in wp-admin!", "bepro-listings") . "</p>"; return; } echo "<h3>" . __("ORDERS", "bepro-listings") . "</h3>"; $user_id = get_current_user_id(); $active = $wpdb->get_results("SELECT * FROM " . BEPRO_LISTINGS_ORDERS_TABLE_NAME . " WHERE cust_user_id = " . $user_id . " AND status = 1 AND (feature_type = 1 OR feature_type = 2) AND expires > NOW()"); $expired = $wpdb->get_results("SELECT * FROM " . BEPRO_LISTINGS_ORDERS_TABLE_NAME . " WHERE cust_user_id = " . $user_id . " AND status = 1 AND (feature_type = 1 OR feature_type = 2) AND expires < NOW()"); $pending = $wpdb->get_results("SELECT * FROM " . BEPRO_LISTINGS_ORDERS_TABLE_NAME . " WHERE cust_user_id = " . $user_id . " AND status != 1 AND (feature_type = 1 OR feature_type = 2)"); ?> <div id="bepro_listings_package_tabs"> <ul> <li><a href="#tabs-1"><?php _e("Pending", "bepro-listings"); ?> </a></li> <li><a href="#tabs-2"><?php _e("Create", "bepro-listings"); ?> </a></li> <li><a href="#tabs-3"><?php _e("Active", "bepro-listings"); ?> </a></li> <li><a href="#tabs-4"><?php _e("Expired", "bepro-listings"); ?> </a></li> </ul> <div id="tabs-1"> <?php echo '<h4>' . __("Payment Required", "bepro-listings") . '</h4>'; if (sizeof($pending) > 0) { echo "<table class='bl_payment_required_table'>\n\t\t\t\t\t\t<tr><td>" . __("Name", "bepro-listings") . "</td><td>" . __("Cost", "bepro-listings") . "</td><td>" . __("Action", "bepro-listings") . "</td></tr>"; foreach ($pending as $pay_this) { $feature = get_post($pay_this->feature_id); $bl_order_id = $pay_this->bl_order_id; if ($data["require_payment"] == 1) { $cost = bepro_get_total_cat_cost($pay_this->feature_id); } else { $cost = get_post_meta($pay_this->feature_id, "package_cost", true); } echo "<tr><td>" . $feature->post_title . "</td><td>" . $data["currency_sign"] . $cost . "</td><td>" . do_shortcode("[bepro_cart_button item_number='" . $bl_order_id . "' name='" . $feature->post_title . "' price='" . $cost . "']") . "</td></tr>"; } echo "</table>"; } else { echo "<p>" . __("No Records Found.", "bepro-listings") . "</p>"; } ?> </div> <div id="tabs-2"> <?php echo '<h4>' . __("Available Options", "bepro-listings") . '</h4>'; if ($packages) { echo "<table class='bl_package_options_table'>\n\t\t\t\t\t\t<tr><td>" . __("Name", "bepro-listings") . "</td><td>" . __("Description", "bepro-listings") . "</td><td># " . __("Listings", "bepro-listings") . "</td><td># " . __("Days", "bepro-listings") . "</td><td>" . __("Cost", "bepro-listings") . "</td><td>" . __("Action", "bepro-listings") . "</td></tr>"; foreach ($packages as $package) { $num_listings = get_post_meta($package->ID, "num_package_listings", true); $duration = get_post_meta($package->ID, "package_duration", true); $cost = get_post_meta($package->ID, "package_cost", true); echo "<tr><td>" . $package->post_title . "</td><td>" . $package->post_content . "</td><td>" . $num_listings . "</td><td>" . $duration . "</td><td>" . $data["currency_sign"] . $cost . "</td><td>" . do_shortcode("[bepro_cart_button item_number='BPL_PACKAGE-" . $package->ID . "' name='" . $package->post_title . "' price='" . $cost . "']") . "</td></tr>"; } echo "</table>"; } else { echo "<p>" . __("No Records Found.", "bepro-listings") . "</p>"; } ?> </div> <div id="tabs-3"> <?php echo '<h4>' . __("Paid Orders", "bepro-listings") . '</h4>'; if (sizeof($active) > 0) { echo "<table class='bl_payment_required_table'>\n\t\t\t\t\t<tr><td>" . __("Name", "bepro-listings") . "</td><td># " . __("Attached Listings", "bepro-listings") . "</td><td>" . __("Expires", "bepro-listings") . "</td></tr>"; foreach ($active as $pay_this) { $feature = get_post($pay_this->feature_id); $related = $wpdb->get_row("SELECT COUNT(*) as num_listings FROM " . $wpdb->prefix . BEPRO_LISTINGS_TABLE_BASE . " WHERE bl_order_id = " . $pay_this->bl_order_id); echo "<tr><td>" . $feature->post_title . "</td><td>" . (@$related->num_listings ? $related->num_listings : 0) . "</td><td>" . date("M, dS Y", strtotime($pay_this->expires)) . "</td></tr>"; } echo "</table>"; } else { echo "<p>" . __("No Records Found.", "bepro-listings") . "</p>"; } ?> </div> <div id="tabs-4"> <?php echo '<h4>' . __("Expired Orders", "bepro-listings") . '</h4>'; if (sizeof($expired) > 0) { echo "<table class='bl_payment_required_table'>\n\t\t\t\t\t\t<tr><td>" . __("Name", "bepro-listings") . "</td><td>" . __("Cost", "bepro-listings") . "</td><td>" . __("Date", "bepro-listings") . "</td><td>" . __("Action", "bepro-listings") . "</td></tr>"; foreach ($expired as $pay_this) { $feature = get_post($pay_this->feature_id); $bl_order_id = $pay_this->bl_order_id; if ($data["require_payment"] == 1) { $cost = bepro_get_total_cat_cost($pay_this->feature_id); } else { $cost = get_post_meta($pay_this->feature_id, "package_cost", true); } echo "<tr><td>" . $feature->post_title . "</td><td>" . $data["currency_sign"] . $cost . "</td><td>" . date("M, dS Y", strtotime($pay_this->expires)) . "</td><td>" . do_shortcode("[bepro_cart_button item_number='" . $bl_order_id . "' name='" . $feature->post_title . "' price='" . $cost . "']") . "</td></tr>"; } echo "</table>"; } else { echo "<p>" . __("No Records Found.", "bepro-listings") . "</p>"; } ?> </div> </div> <?php }