12005 Hwy 64
Eads, TN 38028 USA

Sponsors Report View

[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]

$fiTypes = “”;
$years = “”;

foreach ($_POST as $key => $value)
{
if (strpos($key, ‘fyId’) !== false) {
$fiTypes = $value . “, ” . $fiTypes;
}
elseif (strpos($key, ‘yr’) !== false) {
$years = $value . “, ” . $years;
}
}
[/insert_php]

  Include Gothram & Family Details  Download

Payments paid during [insert_php] echo $years;[/insert_php]

[insert_php]

global $wpdb;

$query = ”
select
(select CONCAT( first_name , ‘ ‘ , last_name) from civicrm_contact c where b.contact_id = c.id) as Name,
(select email from civicrm_email e where b.contact_id = e.contact_id and e.is_primary=1) as Email,
(select `phone` from civicrm_phone p where b.contact_id = p.contact_id and p.is_primary=1) as Phone, name as Sponsorship,
CONCAT(‘$’, FORMAT((total_amount),0)) as Paid, total_amount,
DATE_FORMAT(receive_date, ‘%m/%d/%y’) as ReceiptDate
from civicrm_contribution b, civicrm_financial_type f
where f.id=b.financial_type_id and
b.financial_type_id in (” .$fiTypes. ” 999999) and
YEAR(b.receive_date) in (” .$years. ” 9999)
order by receive_date desc, b.contact_id
“;
//echo $query;

$results = $wpdb->get_results( $query );

$cnt=1;
$grand_total_paid = 0;

foreach ( $results as $page )
{
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;

$grand_total_paid += $page->total_amount;
}

[/insert_php]
# Name Email Phone Sponsorship Type Paid Date
” . ($cnt++) . “ ” . ($page->Name) . “ ” . $page->Email . “ ” . $page->Phone . “ ” . str_replace(‘$’, ‘$ ‘, ($page->Sponsorship)) . “ ” . str_replace(‘$’, ‘$ ‘, ($page->Paid)) . “ ” . $page->ReceiptDate . “
Total: $ [insert_php]echo number_format($grand_total_paid); [/insert_php]

[insert_php]

$query = ”
select
(select CONCAT( first_name , ‘ ‘ , last_name) from civicrm_contact c where b.contact_id = c.id) as Name,
(select email from civicrm_email e where b.contact_id = e.contact_id and e.is_primary=1) as Email,
(select `phone` from civicrm_phone p where b.contact_id = p.contact_id and p.is_primary=1) as Phone, name as Sponsorship,
CONCAT(‘$’, FORMAT((total_amount),0)) as Paid,
DATE_FORMAT(receive_date, ‘%m/%d/%y’) as ReceiptDate
from civicrm_contribution b, civicrm_financial_type f
where f.id=b.financial_type_id and
b.financial_type_id in (” .$fiTypes. ” 999999) and
YEAR(b.receive_date) in (” .$years. ” 9999)
order by receive_date desc, b.contact_id
“;
$_SESSION[“sponsors_query”] = $query;

$query = ”

select
(select Gothram_1 from civicrm_value_gothram_1 g where b.contact_id = g.entity_id ) as Gothram,
(select CONCAT( first_name , ‘ ‘ , last_name) from civicrm_contact c where b.contact_id = c.id) as Name,
(select Spouse_9 e from civicrm_value_family_information_3 fm where b.contact_id = fm.entity_id ) as Spouse,
(select concat(Family_Member_1_10, ‘, ‘ ,Family_Member_2_11,’, ‘,Family_Member_3_12, ‘, ‘,Family_Member_4_13, ‘, ‘, Family_Member_5_14, ‘, ‘,Family_Member_6_15) from civicrm_value_family_information_3 fm where b.contact_id = fm.entity_id ) as FamilyMembers,
name as Sponsorship,
(select email from civicrm_email e where b.contact_id = e.contact_id and e.is_primary=1) as Email,
(select `phone` from civicrm_phone p where b.contact_id = p.contact_id and p.is_primary=1) as Phone
from civicrm_contribution b, civicrm_financial_type f
where f.id=b.financial_type_id and
b.financial_type_id in (” .$fiTypes. ” 999999) and
YEAR(b.receive_date) in (” .$years. ” 9999)
group by b.contact_id, b.financial_type_id
order by b.financial_type_id, Name

“;
$_SESSION[“sponsors_query_family”] = $query;

[/insert_php]