function testCountRecurringDonationsPastYear()
 {
     // donation will have recurring_donation_KEY set
     // SELECT COUNT(*) FROM donation WHERE supporter_KEY=### AND RESULT=0 AND Transaction_Date= recurring_donation_KEY IS NOT NULL
     // data__recurring_donations_past_year
     $s = new Supporter(array('supporter_KEY' => 58));
     $donations = array(array('supporter_KEY' => 58, 'donation_KEY' => 61, 'RESULT' => 0, 'recurring_donation_KEY' => 455, 'Transaction_Date' => date('Y-m-d H:i:s', strtotime('-7 months')), 'RESULT' => 0), array('supporter_KEY' => 58, 'donation_KEY' => 62, 'RESULT' => 0, 'recurring_donation_KEY' => 455, 'Transaction_Date' => date('Y-m-d H:i:s', strtotime('-13 months')), 'RESULT' => 0), array('supporter_KEY' => 58, 'donation_KEY' => 63, 'RESULT' => 1, 'recurring_donation_KEY' => 455), array('supporter_KEY' => 58, 'donation_KEY' => 64, 'RESULT' => 0), array('supporter_KEY' => 59, 'donation_KEY' => 65, 'RESULT' => 0, 'recurring_donation_KEY' => 455));
     foreach ($donations as $donation_data) {
         $d = new Donation($donation_data);
         $d->db_insert();
     }
     $s->updateDonationCounts();
     $this->assertEqual($s->data['data__recurring_donations_past_year'], 1);
 }
<?php

require '../../boot.php';
list($cmd, $supporter_KEY) = $argv;
#$supporter_KEY = 48965489;
$supporter_query = $db->query("SELECT * FROM supporter WHERE supporter_KEY=" . $supporter_KEY);
if ($supporter_query->num_rows > 0) {
    while ($supporter_arr = $supporter_query->fetch_assoc()) {
        $supporter = new Supporter($supporter_arr);
        $supporter->process();
        #$supporter->geovalidate();
        $supporter->updateDonationCounts();
        $supporter->updateActionCounts();
        $supporter->updateEmailCounts();
        $supporter->updateUnsubscribeInfo();
        $supporter->updateSupporterTypes();
        //$supporter->db_update();
        $supporter->data['key'] = $supporter->data['supporter_KEY'];
        //$dia->save('supporter', $supporter->data);
    }
}
echo '<pre>' . print_r($supporter) . '</pre>';
예제 #3
0
<?php

require '../boot.php';
$rs = $db->Execute("SELECT distinct supporter_KEY from donation where amount>0 ");
while ($supporter_arr = $rs->FetchRow()) {
    $supporter = new Supporter($supporter_arr);
    $supporter->updateDonationCounts(NULL);
    $d['gift_string__largest__low'] = $supporter->data['data__gift_string__largest__low'];
    $d['gift_string__largest__medium'] = $supporter->data['data__gift_string__largest__medium'];
    $d['gift_string__largest__high'] = $supporter->data['data__gift_string__largest__high'];
    $d['gift_string__avg__low'] = $supporter->data['data__gift_string__avg__low'];
    $d['gift_string__avg__medium'] = $supporter->data['data__gift_string__avg__medium'];
    $d['gift_string__avg__high'] = $supporter->data['data__gift_string__avg__high'];
    $d['gift_string__last__low'] = $supporter->data['data__gift_string__last__low'];
    $d['gift_string__last__medium'] = $supporter->data['data__gift_string__last__medium'];
    $d['gift_string__last__high'] = $supporter->data['data__gift_string__last__high'];
    $d['donation_history__count'] = $supporter->data['data__donation__count'];
    $d['donation_history__total'] = $supporter->data['data__donation__total'];
    $d['donation_history__average'] = $supporter->data['data__donation__average'];
    $d['donation_history__max'] = $supporter->data['data__donation__max'];
    $d['donation_history__min'] = $supporter->data['data__donation__min'];
    $d['donation_history__last'] = $supporter->data['data__donation__last_amount'];
    $d['key'] = $supporter->data['supporter_KEY'];
    $db->AutoExecute('supporter', $d, 'UPDATE', 'supporter_KEY =' . $supporter->data['supporter_KEY']);
    #    $DIA->save('supporter', $d);
    echo '<pre>';
    print_r($d);
    echo '</pre>';
}