public function actionOverview() { $incomeToday = $this->income(1); $incomeWeek = $this->income(7); $incomeMonth = $this->income(30); $profitArray = $this->getProfitData(30); $revProfit = array_reverse($profitArray); $i = 0; $todaysProfit = 0; $sevenDayProfit = 0; $thirtyDaysProfit = 0; foreach ($revProfit as $row) { $i++; if ($i <= 1) { $todaysProfit = $row[1]; } if ($i <= 7) { $sevenDayProfit = $sevenDayProfit + $row[1]; } $thirtyDayProfit = $thirtyDayProfit + $row[1]; } //Get our current group characters $members = $this->getMembersAsCharIDArray(1); $sqlarray = '(' . implode(',', $members) . ')'; $characters = Characters::Model()->findAll('characterID IN ' . $sqlarray); $balance = 0; foreach ($characters as $character) { $criteria = new CDbCriteria(); $criteria->condition = 'characterID = :characterID'; $criteria->params = array(':characterID' => $character->characterID); $criteria->order = 'balanceDateTime DESC'; $balance += Balances::model()->find($criteria)->balance; } //Create a new XML object $xmlObject = new DOMDocument(); $root = $xmlObject->appendChild($xmlObject->createElement('Overview')); $root->appendChild($xmlObject->createElement('IncomeToday', $incomeToday)); $root->appendChild($xmlObject->createElement('IncomeWeek', $incomeWeek)); $root->appendChild($xmlObject->createElement('IncomeMonth', $incomeMonth)); $root->appendChild($xmlObject->createElement('ProfitToday', $todaysProfit)); $root->appendChild($xmlObject->createElement('ProfitWeek', $sevenDayProfit)); $root->appendChild($xmlObject->createElement('ProfitMonth', $thirtyDayProfit)); $root->appendChild($xmlObject->createElement('Balance', number_format($balance, 2))); //Render the XML $xmlObject->formatOutput = false; echo $xmlObject->saveXML(); }