public function actionPurchases()
 {
     //Check to see if we can get new data
     $groupMembers = $this->getTrackingGroupMembers(1);
     $transactionInterface = new APITransactions();
     if (!$transactionInterface->getCacheExpiration($groupMembers[0]->characterID)) {
         foreach ($groupMembers as $member) {
             $orders = $transactionInterface->getEveData($member->characterID);
             $character = Characters::Model()->findByPk($member->characterID);
             if ($character->walletEnabled) {
                 $transactionInterface->storeData($member->characterID);
             }
         }
     }
     //Get our tracking group members
     $members = $this->getMembersAsArray(1);
     $sqlarray = '(' . implode(',', $members) . ')';
     //Create our db criteria
     $criteria = new CDbCriteria();
     $criteria->condition = 'transactionType = "buy" AND characterID IN ' . $sqlarray;
     $criteria->order = 'transactionDateTime DESC';
     $criteria->limit = 30;
     //Grab our last 30 transactions
     $results = Wallet::model()->findAll($criteria);
     //Create a new XML object
     $xmlObject = new DOMDocument();
     $root = $xmlObject->appendChild($xmlObject->createElement('TransactionList'));
     //Iterate over the db results and construct the XML
     foreach ($results as $result) {
         //Create the parent tag for this transaction
         $trans = $root->appendChild($xmlObject->createElement('Transaction'));
         //Populate with the data
         $trans->appendChild($xmlObject->createElement('transactionDateTime', $result->transactionDateTime));
         $trans->appendChild($xmlObject->createElement('transactionTimestamp', strtotime($result->transactionDateTime)));
         $trans->appendChild($xmlObject->createElement('typeID', $result->typeID));
         $trans->appendChild($xmlObject->createElement('typeName', $result->typeName));
         $trans->appendChild($xmlObject->createElement('quantity', $result->quantity));
         $trans->appendChild($xmlObject->createElement('profit', $result->profit));
         $trans->appendChild($xmlObject->createElement('price', $result->price));
         $trans->appendChild($xmlObject->createElement('stationName', $result->stationName));
         $trans->appendChild($xmlObject->createElement('icon', $this->getIcon($result->typeID)));
     }
     //Render the XML
     $xmlObject->formatOutput = false;
     echo $xmlObject->saveXML();
     //$this->renderPartial('transactions',array('results'=>$results));
 }
Esempio n. 2
0
<?php

$transInterface = new APITransactions();
$group = $this->getDefaultTrackingGroup(Yii::app()->user->trackingGroupID);
$groupMembers = $this->getTrackingGroupMembers($group->trackingGroupID);
foreach ($groupMembers as $member) {
    $orders = $transInterface->getEveData($member->characterID);
    $character = Characters::Model()->findByPk($member->characterID);
    if ($character->walletEnabled) {
        $transInterface->storeData($member->characterID);
    }
}
echo "API Updated. Please refresh your page.";