12005 Hwy 64
Eads, TN 38028 USA

Services Trends

[insert_php] $authUser = FALSE;

$yourId = wp_get_current_user()->user_login;
$allowed_users = array( “[email protected]”, “[email protected]”, “[email protected]”, “balajivalmiki”, “nkoka”, “[email protected]”);

if ( (is_user_logged_in() && current_user_can(‘administrator’) ) ||
(is_user_logged_in() && in_array($yourId, $allowed_users) )
)
$authUser = TRUE;

if($authUser == FALSE)
{
wp_redirect( site_url() ); exit;
}
[/insert_php]

[insert_php] global $wpdb;

setlocale(LC_MONETARY, ‘en_US’);

$result = $wpdb->get_results ( ”

Select o.id, o.name,
Sum(Case When YEAR(receive_date) = YEAR(CURDATE())-4 Then total_amount Else 0 End) as prev_year4,
Sum(Case When YEAR(receive_date) = YEAR(CURDATE())-3 Then total_amount Else 0 End) as prev_year3,
Sum(Case When YEAR(receive_date) = YEAR(CURDATE())-2 Then total_amount Else 0 End) as prev_year2,
Sum(Case When YEAR(receive_date) = YEAR(CURDATE())-1 Then total_amount Else 0 End) as prev_year1,
Sum(Case When YEAR(receive_date) = YEAR(CURDATE()) Then total_amount Else 0 End) as currentYear
From civicrm_contribution c left outer join
civicrm_financial_type o on o.id = c.financial_type_id
Where o.id in( 5,6, 7, 8, 9, 10, 11, 12, 13, 14,15, 20, 22, 23, 24, 25, 26, 27, 28, 29, 31, 35, 36, 37, 38, 39, 40, 42, 44, 49, 60,70, 73, 74,79, 88,93, 101, 109, 110, 111, 112, 113,114,115,119,120,125,130,132,183,184,186,187,192,194,195,222,257, 265) and contribution_status_id=1
Group By o.id, o.name
Order by o.name

” );

$total_currentYear = 0;
$total_prev_year1 = 0;
$total_prev_year2 = 0;
$total_prev_year3 = 0;
$total_prev_year4 = 0;

foreach ( $result as $page )
{
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;

$total_currentYear += $page->currentYear;
$total_prev_year1 += $page->prev_year1;
$total_prev_year2 += $page->prev_year2;
$total_prev_year3 += $page->prev_year3;
$total_prev_year4 += $page->prev_year4;
}

echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;

[/insert_php]
Financial Type [insert_php]echo date(“Y”)-4;[/insert_php] [insert_php]echo date(“Y”)-3;[/insert_php] [insert_php]echo date(“Y”)-2;[/insert_php] [insert_php]echo date(“Y”)-1;[/insert_php] [insert_php]echo date(“Y”);[/insert_php]
” . str_replace(‘$’, ‘$ ‘, ($page->name)) . “ $ ” . number_format($page->prev_year4) . “ $ ” . number_format($page->prev_year3) . “ $ ” . number_format($page->prev_year2) . “ $ ” . number_format($page->prev_year1) . “ $ ” . number_format($page->currentYear) . “
Total $ ” . number_format($total_prev_year4) . “ $ ” . number_format($total_prev_year3) . “ $ ” . number_format($total_prev_year2) . “ $ ” . number_format($total_prev_year1) . “ $ ” . number_format($total_currentYear) . “