public function storeData($walletID) { $attributes = $this->apiAttributes(); //Retrieve the XML dataset $orders = $this->getEVEData($walletID); $character = Characters::Model()->findByPk($walletID); Orders::Model()->deleteAll('charID=:charID', array(':charID' => $character->characterID)); foreach ($orders->result->rowset->row as $row) { $exist = Orders::Model()->exists('orderID=:orderID', array(':orderID' => $row->attributes()->orderID)); if (!$exist) { //echo "ORDERID: {$row->attributes()->orderID} <br>"; $orderRow = new Orders(); $orderRow->orderID = $row->attributes()->orderID; $orderRow->charID = $row->attributes()->charID; $orderRow->stationID = $row->attributes()->stationID; $orderRow->volEntered = $row->attributes()->volEntered; $orderRow->volRemaining = $row->attributes()->volRemaining; $orderRow->minVolume = $row->attributes()->minVolume; $orderRow->orderState = $row->attributes()->orderState; $orderRow->typeID = $row->attributes()->typeID; $orderRow->range = $row->attributes()->range; $orderRow->accountKey = $row->attributes()->accountKey; $orderRow->duration = $row->attributes()->duration; $orderRow->escrow = $row->attributes()->escrow; $orderRow->price = $row->attributes()->price; $orderRow->bid = $row->attributes()->bid; $orderRow->issued = $row->attributes()->issued; $orderRow->save(); //print_r($orderRow->getErrors()); } else { //echo "ORDERID: {$row->attributes()->orderID} <br>"; $orderRow = Orders::Model()->findByPk($row->attributes()->orderID); $orderRow->orderID = $row->attributes()->orderID; $orderRow->charID = $row->attributes()->charID; $orderRow->stationID = $row->attributes()->stationID; $orderRow->volEntered = $row->attributes()->volEntered; $orderRow->volRemaining = $row->attributes()->volRemaining; $orderRow->minVolume = $row->attributes()->minVolume; $orderRow->orderState = $row->attributes()->orderState; $orderRow->typeID = $row->attributes()->typeID; $orderRow->range = $row->attributes()->range; $orderRow->accountKey = $row->attributes()->accountKey; $orderRow->duration = $row->attributes()->duration; $orderRow->escrow = $row->attributes()->escrow; $orderRow->price = $row->attributes()->price; $orderRow->bid = $row->attributes()->bid; $orderRow->issued = $row->attributes()->issued; $orderRow->save(); //print_r($orderRow->getErrors()); } } }
<?php $topTenItems = $this->getTopTenByProfit(); foreach ($topTenItems as $item) { $i++; if ($i % 2) { echo "<tr class='odd'>"; } else { echo "<tr>"; } $name = $item['typeName']; $volume = $item['totalVolume']; $profit = $item['totalProfit']; $typeID = $item['typeID']; $icon = $this->getIcon($typeID); //get order data $orders = Orders::Model()->find('typeID=:typeID AND orderState = 0 AND charID IN (' . implode(',', $this->getMembersAsCharIDArray(Yii::app()->user->trackingGroupID)) . ')', array(':typeID' => $typeID)); if (empty($orders)) { $orderText = "No Orders"; } else { $orderText = number_format($orders->volRemaining) . "/" . number_format($orders->volEntered) . " (" . floor($orders->volRemaining / $orders->volEntered * 100) . "%)"; } echo '<td><div class="textCenter"><img height="16" width="16" src="./images/items/' . $icon . '"><a href="index.php?r=wallet/item&id=' . $typeID . '">' . $name . '</a></div></td>'; echo "<td>{$orderText}</td>"; echo '<td style="text-align: right;"><font color="green">+' . number_format($profit, 0) . '</font></td>'; echo "</tr>"; } ?> </table> </div> </div>
public function getOrderTotal($characterID) { //Get the character information from the db $character = Characters::model()->findByPk($characterID); $criteria = new CDbCriteria(); $criteria->condition = 'charID=:characterID AND orderState=0 AND bid=0'; $criteria->params = array(':characterID' => $character->characterID); $orders = Orders::Model()->findAll($criteria); foreach ($orders as $order) { $orderTotal = $orderTotal + $order->price * $order->volRemaining; } return $orderTotal; }
echo "</tr>\n"; $names++; $j = 0; //Loop through the items foreach ($group as $item) { $i++; $j++; if ($j % 2) { echo "<tr class='odd'>\n"; } else { echo "<tr>\n"; } //Get the item details $itemDetails = Invtypes::Model()->findByPk($item); //Get some order information $orders = Orders::Model()->find('typeID=:typeID AND orderState = 0', array(':typeID' => $item)); if (empty($orders)) { $orderText = "<font color='#FFA824'>No Orders</font>"; } else { $orderText = number_format($orders->volRemaining) . "/" . number_format($orders->volEntered) . " (" . floor($orders->volRemaining / $orders->volEntered * 100) . "%)"; } //Get profit, volume, and icon information $details = $this->getProfitDetails($item); $detailsRow = $details->read(); $profit = number_format($detailsRow['totalProfit']); $volume = number_format($detailsRow['totalVolume']); $perUnit = number_format($detailsRow['totalProfit'] / $detailsRow['totalVolume'], 0); $color = $this->numToColor($profit); $icon = $this->getIcon($itemDetails->typeID); echo "<td><div class='textCenter'><img height='16' width='16' src='http://image.eveonline.com/Type/{$icon}'> <a href='index.php?r=wallet/item&id={$itemDetails->typeID}'>{$itemDetails->typeName}</a></div></td>\n"; #echo "<td><div class='textCenter'><img height='16' width='16' src='images/items/$icon'>$itemDetails->typeName</div></td>\n";