public function get_payment_terms() { global $wpdb; if (!awpcp_payments_api()->payments_enabled()) { return array($this->get_free_payment_term()); } $order = get_awpcp_option('fee-order'); $direction = get_awpcp_option('fee-order-direction'); switch ($order) { case 1: $orderby = array('adterm_name', $direction); break; case 2: $orderby = array("amount {$direction}, adterm_name", $direction); break; case 3: $orderby = array("imagesallowed {$direction}, adterm_name", $direction); break; case 5: $orderby = array("_duration_interval {$direction}, rec_period {$direction}, adterm_name", $direction); break; } if (awpcp_current_user_is_admin()) { $args = array('orderby' => $orderby[0], 'order' => $orderby[1]); } else { $args = array('where' => 'private = 0', 'orderby' => $orderby[0], 'order' => $orderby[1]); } return AWPCP_Fee::query($args); }
public function prepare_items() { $query = $this->parse_query(); $total_items = AWPCP_Fee::query(array_merge(array('fields' => 'count'), $query)); $this->items = AWPCP_Fee::query(array_merge(array('fields' => '*'), $query)); $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $this->items_per_page)); $this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns()); }
public function delete() { $id = awpcp_request_param('id', 0); $fee = AWPCP_Fee::find_by_id($id); if (is_null($fee)) { awpcp_flash(__("The specified Fee doesn't exists.", 'AWPCP'), 'error'); return $this->index(); } $errors = array(); if (AWPCP_Fee::delete($fee->id, $errors)) { awpcp_flash(__('The Fee was successfully deleted.', 'AWPCP')); } else { $where = sprintf("adterm_id = %d AND payment_term_type = 'fee'", $fee->id); $ads = AWPCP_Ad::find($where); if (empty($ads)) { foreach ($errors as $error) { awpcp_flash($error, 'error'); } } else { $fees = AWPCP_Fee::query(); if (count($fees) > 1) { $message = __("The Fee couldn't be deleted because there are active Ads in the system that are associated with the Fee ID. You need to switch the Ads to a different Fee before you can delete the plan.", "AWPCP"); awpcp_flash($message, 'error'); $params = array('fee' => $fee, 'fees' => $fees); $template = AWPCP_DIR . '/admin/templates/admin-panel-fees-delete.tpl.php'; echo $this->render($template, $params); return; } else { $message = __("The Fee couldn't be deleted because there are active Ads in the system that are associated with the Fee ID. Please create a new Fee and try the delete operation again. AWPCP will help you to switch existing Ads to the new fee.", "AWPCP"); awpcp_flash($message, 'error'); } } } return $this->index(); }
public function all() { return AWPCP_Fee::query(); }