Пример #1
0
 public function BillingHistory()
 {
     $billingHistory = new ArrayList();
     $orders = Order::get()->filter(array('MemberID' => Member::currentUserID(), 'OrderStatus' => 'c'))->sort('Created');
     foreach ($orders as $order) {
         $productId = $order->ProductID;
         if (($productId == 1 || $productId == 2 || $productId == 3) && $order->IsTrial == 1) {
             $productDesc = 'First Month Trial';
         } else {
             $product = Product::get()->byID($productId);
             $productDesc = $product->Name;
         }
         $creditCard = $order->CreditCard();
         $ccNumber = 'XXXX-XXXX-XXXX-' . substr($creditCard->CreditCardNumber, -4);
         $orderDetails = array('Date' => $order->Created, 'Description' => $productDesc, 'CCType' => strtoupper($creditCard->CreditCardType), 'CCNumber' => $ccNumber, 'Amount' => $order->Amount);
         $billingHistory->push(new ArrayData($orderDetails));
     }
     $memBillHistory = MemberBillingHistory::get()->filter('MemberID', Member::currentUserID())->sort('Created');
     foreach ($memBillHistory as $history) {
         $creditCard = $history->CreditCard();
         $ccNumber = 'XXXX-XXXX-XXXX-' . substr($creditCard->CreditCardNumber, -4);
         $details = array('Date' => $history->Created, 'Description' => $history->Product()->Name, 'CCType' => strtoupper($creditCard->CreditCardType), 'CCNumber' => $ccNumber, 'Amount' => $history->Product()->RecurringPrice);
         $billingHistory->push(new ArrayData($details));
     }
     $sortedBillingHistory = $billingHistory->sort('Date');
     return $sortedBillingHistory;
 }
Пример #2
0
 public function moveHistoryFromJoomlaToSS()
 {
     die('test3');
     error_reporting(E_ALL);
     ini_set('display_errors', 1);
     ini_set('max_execution_time', 0);
     ini_set('memory_limit', '-1');
     $mysqli = $this->getDbConnection();
     $result = $mysqli->query("SELECT * FROM jos_users u\n\t\tINNER JOIN jos_osemsc_mem_history mh ON u.id = mh.member_id");
     $count = 0;
     while ($obj = $result->fetch_object()) {
         $ssMember = $this->getSSMember($obj->email);
         if (!$ssMember) {
             continue;
         }
         if ($obj->date == '0000-00-00 00:00:00') {
             $transDate = $obj->expired_date;
         } else {
             $transDate = $obj->date;
         }
         $billingHistory = new MemberBillingHistory();
         $billingHistory->Created = $transDate;
         $billingHistory->LastEdited = $transDate;
         $billingHistory->MemberID = $ssMember->ID;
         $creditCardId = $this->getSSCreditCardId($obj->member_id, $ssMember->ID, $transDate);
         if ($creditCardId) {
             $billingHistory->CreditCardID = $creditCardId;
         }
         $subscriptionId = $this->getSSSubscriptionId($ssMember->ID, $obj->msc_id, $transDate);
         if ($subscriptionId) {
             $billingHistory->SubscriptionID = $subscriptionId;
         }
         $billingHistory->ProductID = $obj->msc_id;
         $billingHistory->write();
         $count++;
     }
     $mysqli->close();
     echo "Total history moved: {$count}";
 }