if ($convert->total_bids == 0) { _e('0 <span class="text-normal">bids</span>', ET_DOMAIN); } elseif ($convert->total_bids == 1) { _e('1 <span class="text-normal">bid</span>', ET_DOMAIN); } else { printf(__('%s <span class="text-normal">bids</span>', ET_DOMAIN), $convert->total_bids); } ?> </span> </li> <li> <span class="number-blue"> <?php $avg = 0; if ($convert->total_bids > 0) { $avg = get_total_cost_bids($convert->ID) / $convert->total_bids; } echo fre_price_format($avg); ?> </span> <span class="text-normal"> <?php printf(__("Avg Bid (%s)", ET_DOMAIN), $currency['code']); ?> </span> </li> <li> <?php if ($post->post_status == 'publish') { ?> <span class="number-blue">
function fre_delete_bid($bid_id) { //$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->posts WHERE post_id = %d AND post_type = %s ", $bid_id, BID ) ); // current bid status = trash. $project_id = get_post_field('post_parent', $bid_id); $bid_budget = (double) get_post_meta($bid_id, 'bid_budget', true); $total_bids = (int) get_post_meta($project_id, 'total_bids', true) - 1; $total_bids = max($total_bids, 0); wp_delete_post($bid_id, true); $new_avg = 0; if ($total_bids > 0) { $total_cost_bid = (double) get_total_cost_bids($project_id) / $total_bids; $new_avg = $total_cost_bid / $total_bids; } // update avg and total bid; update_post_meta($project_id, 'total_bids', $total_bids); update_post_meta($project_id, 'bid_average', number_format($new_avg, 2)); wp_delete_post($bid_id, true); $this->mail->bid_cancel_mail($project_id); wp_send_json(array('success' => true, 'msg' => __('Bid has been deleted successful', ET_DOMAIN))); }
<ul class="info-item"> <li> <?php if ($total_bids > 1 || $total_bids == 0) { printf(__('<span class="number-blue">%d</span> Bids', 'user-bid-item'), $total_bids); } else { printf(__('<span class="number-blue">%d</span> Bid', 'user-bid-item'), $total_bids); } ?> </li> <li> <span class="number-blue"> <?php $avg = 0; if ($project->total_bids > 0) { $avg = get_total_cost_bids($project->ID) / $project->total_bids; } echo fre_number_format($avg); ?> </span><?php printf(__('Avg Bid (%s)', 'user-bid-item'), $currency['code']); ?> </li> <li> <span class="number-blue"> <?php echo $status_text; ?> </span> </li>
function fre_delete_bid($bid_id) { global $wpdb; //$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->posts WHERE post_id = %d AND post_type = %s ", $bid_id, BID ) ); // current bid status = trash. $project_id = get_post_field('post_parent', $bid_id); $result = $wpdb->get_results("SELECT ID FROM `wp_posts` WHERE `post_content` LIKE '%bid=" . $bid_id . "%'"); $bid_budget = (double) get_post_meta($bid_id, 'bid_budget', true); $total_bids = (int) get_post_meta($project_id, 'total_bids', true) - 1; $total_bids = max($total_bids, 0); $new_avg = 0; if ($total_bids > 0) { $total_cost_bid = (double) get_total_cost_bids($project_id) / $total_bids; $new_avg = $total_cost_bid / $total_bids; } // update avg and total bid; update_post_meta($project_id, 'total_bids', $total_bids); update_post_meta($project_id, 'bid_average', number_format($new_avg, 2)); wp_delete_post($bid_id, true); wp_delete_post($result[0]->ID, true); //delete empty notify wp_send_json(array('success' => true, 'msg' => __('Bid has been deleted successful', 'bids-backend'))); }
/** *Convert project * * */ function ae_convert_project($result) { global $user_ID; $result->et_avatar = get_avatar($result->post_author, 35); $result->author_url = get_author_posts_url($result->post_author); $result->author_name = get_the_author_meta('display_name', $result->post_author); $result->budget = fre_price_format($result->et_budget); $result->bid_budget_text = fre_price_format(get_post_meta($result->accepted, 'bid_budget', true)); $result->rating_score = (double) get_post_meta($result->ID, 'rating_score', true); $comment = get_comments(array('post_id' => $result->ID, 'type' => 'fre_review')); if ($comment) { $result->project_comment = $comment['0']->comment_content; } else { $result->project_comment = ''; } // project is disputing if ($result->post_status == 'disputing') { $result->status_text = __("DISPUTE", ET_DOMAIN); } // project completed text status if ($result->post_status == 'complete') { $result->status_text = __("COMPLETED", ET_DOMAIN); } // project close for working when accepted a bids if ($result->post_status == 'close') { $result->status_text = __("HIRED", ET_DOMAIN); if ($user_ID == $result->post_author) { $result->workspace_link = add_query_arg(array('workspace' => 1), $result->permalink); } } $avg = 0; if ($result->total_bids > 0) { $avg = get_total_cost_bids($result->ID) / $result->total_bids; } $result->bid_average = $avg; /** * return carousels */ if (current_user_can('manage_options') || $result->post_author == $user_ID) { $children = get_children(array('numberposts' => 15, 'order' => 'ASC', 'post_parent' => $result->ID, 'post_type' => 'attachment')); $result->et_carousels = array(); foreach ($children as $key => $value) { $result->et_carousels[] = $key; } /** * set post thumbnail in one of carousel if the post thumbnail doesnot exists */ if (has_post_thumbnail($result->ID)) { $thumbnail_id = get_post_thumbnail_id($result->ID); if (!in_array($thumbnail_id, $result->et_carousels)) { $result->et_carousels[] = $thumbnail_id; } } } $result->posted_by = sprintf(__("Posted by %s", ET_DOMAIN), $result->author_name); return $result; }