set_view_args( $args ); $template->render(); } return $template; } /** * Fetches a list of Campaigns * * @since 1.0.0 * * @return Charitable Campaigns list title and id */ function get_charitable_campaigns_title_id() { $args = array( 'post_type' => 'campaign'); $loop = new WP_Query( $args ); $campaigns = array(); $count=0; while ( $loop->have_posts() ) : $loop->the_post(); $campaigns[$count]['id'] = get_the_id(); $campaigns[$count]['title'] = get_the_title(); $count++; endwhile; return $campaigns; } /** * Return the database table helper object. * * @since 1.0.0 * * @param string $table The table key. * @return mixed|null A child class of Charitable_DB if table exists. null otherwise. */ function charitable_admin_expenses_get_table( $table ) { return charitable_admin_expenses()->get_db_table( $table ); } /** * Get all Admin Expenses */ function get_admin_expenses() { $results = charitable_admin_expenses_get_table( 'campaign_admin_expenses' )->get_expenses(); return $results; } /** * */ function get_charitable_campaigns_and_expenses_total() { $args = array( 'post_type' => 'campaign'); $loop = new WP_Query( $args ); $campaign_stats = array(); $count = 0; $expenses = get_utilized_amount(); $expense_array = array(); foreach($expenses as $expense) { $expense_array[$expense->campaign_id] = $expense->Total; } while ( $loop->have_posts() ) : $loop->the_post(); $campaign_stats[$count]['campaign_id'] = get_the_id(); $campaign_stats[$count]['campaign_title'] = get_the_title(); $campaign = charitable_get_campaign( get_the_id() ); $campaign_stats[$count]['donated'] = charitable_format_money( $campaign->get_donated_amount() ); $campaign_stats[$count]['utilized'] = charitable_format_money( isset($expense_array[get_the_id()]) ? $expense_array[get_the_id()] : 0 ); $count++; endwhile; return $campaign_stats; } /** * */ function get_utilized_amount() { $results = charitable_admin_expenses_get_table( 'campaign_admin_expenses' )->get_expenses_total(); return $results; }