12005 Hwy 64
Eads, TN 38028 USA

Yagnam 2018

[insert_php]

if ( !is_user_logged_in() && (!current_user_can(‘administrator’) || !current_user_can(‘shop_manager’) ) ){
wp_redirect( site_url() ); exit;
}

[/insert_php]



 

Yagnam 2018 Account Receivables Report

 [insert_php]echo date(“F j, Y”);[/insert_php]

[insert_php]

global $wpdb;

$result = $wpdb->get_results ( ”

select
(select last_name from civicrm_contact c where p.contact_id = c.id) as LastName,
(select first_name from civicrm_contact c where p.contact_id = c.id) as FirstName,
(select email from civicrm_email e where p.contact_id = e.contact_id and e.is_primary=1) as Email,
(select phone from civicrm_phone ph where p.contact_id = ph.contact_id and ph.is_primary=1) as Phone,
p.amount as Pledged,
(select sum(total_amount) from civicrm_contribution b where p.contact_id = b.contact_id and financial_type_id=p.financial_type_id and contribution_status_id=1) as Paid,
(select p.amount – (select sum(total_amount) from civicrm_contribution b where p.contact_id = b.contact_id and financial_type_id=p.financial_type_id and contribution_status_id=1)) as Balance
from civicrm_pledge p
where financial_type_id=265
order by pledged desc,lastname,firstname

” );

$grand_total_pledge_count = 0;
$grand_total_pledged = 0;
$grand_total_paid = 0;
$grand_total_balance = 0;

foreach ( $result as $page )
{
$paid = 0;
$balance = $page->Pledged;
if($page->Paid >=0) $paid = $page->Paid;
if($page->Balance >=0) $balance = $page->Balance;

echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;

$grand_total_pledge_count += $page->count;
$grand_total_pledged += $page->Pledged;
$grand_total_paid += $paid;
$grand_total_balance += ($page->Pledged- $paid);

}

echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;

[/insert_php]
Last, First Phone/Email Pledged Paid Balance
” . str_replace(‘$’, ‘$ ‘, ($page->LastName)) . “, ” . str_replace(‘$’, ‘$ ‘, ($page->FirstName)) . “ ” . ($page->Phone) . “
“. ($page->Email) . “
$ ” . number_format($page->Pledged) . “ $ ” . number_format( $paid) . “ $ ” . number_format( $page->Pledged- $paid ) . “
Totals ” . $grand_total_pledge_count . “ $ ” . number_format($grand_total_pledged) . “ $ ” . number_format( $grand_total_paid ) . “ $ ” . number_format( $grand_total_balance ) . “

[insert_php] $query = ”

select
(select last_name from civicrm_contact c where p.contact_id = c.id) as LastName,
(select first_name from civicrm_contact c where p.contact_id = c.id) as FirstName,
(select email from civicrm_email e where p.contact_id = e.contact_id and e.is_primary=1) as Email,
(select phone from civicrm_phone ph where p.contact_id = ph.contact_id and ph.is_primary=1) as Phone,
p.amount as Pledged,
(select sum(total_amount) from civicrm_contribution b where p.contact_id = b.contact_id and financial_type_id=p.financial_type_id and contribution_status_id=1) as Paid,
(select p.amount – (select sum(total_amount) from civicrm_contribution b where p.contact_id = b.contact_id and financial_type_id=p.financial_type_id and contribution_status_id=1)) as Balance
from civicrm_pledge p
where financial_type_id=265
order by pledged desc,lastname,firstname

“;
$_SESSION[“sponsors_query”] = $query;
[/insert_php]

Facebook4k
YouTube2k
YouTube
WhatsApp