/** * Returns all fields in an array. * * The result has the following form: * array ( * array ( * 'field name 0' => 'value of field 0', * 'field name 1' => 'value of field 1' * ) * ); * * The inner array is repeated for each row. * The fields need to be in the order returned by @link getFieldNames(). * * @return array A list of all fields. */ public function getAll() { global $badgerDb; $us = new UserSettings($badgerDb); $tpl = new TemplateEngine($us, BADGER_ROOT); $widgets = new WidgetEngine($tpl); $currentLanguage = $us->getProperty('badgerLanguage'); $result = array(); switch ($this->type) { case 'transaction': $this->fetchTransactions(); $sum = new Amount(); foreach ($this->finishedTransactions as $currentTransaction) { $sum->add($currentTransaction->getAmount()); $result[] = array('transactionId' => $currentTransaction->getId(), 'type' => $widgets->addImage($currentTransaction->getType() == 'FinishedTransaction' ? 'Account/finished_transaction.png' : 'Account/planned_transaction.png', 'title="' . getBadgerTranslation2('Account', $currentTransaction->getType()) . '"'), 'title' => $currentTransaction->getTitle(), 'description' => $currentTransaction->getDescription(), 'valutaDate' => ($tmp = $currentTransaction->getValutaDate()) ? $tmp->getFormatted() : '', 'amount' => $currentTransaction->getAmount()->getFormatted(), 'outsideCapital' => is_null($tmp = $currentTransaction->getOutsideCapital()) ? '' : $tmp, 'transactionPartner' => $currentTransaction->getTransactionPartner(), 'categoryId' => ($tmp = $currentTransaction->getCategory()) ? $tmp->getId() : '', 'categoryTitle' => ($tmp = $currentTransaction->getCategory()) ? $tmp->getTitle() : '', 'sum' => $sum->getFormatted()); } break; case 'finished': while ($this->fetchNextFinishedTransaction()) { } foreach ($this->finishedTransactions as $currentTransaction) { $result[] = array('finishedTransactionId' => $currentTransaction->getId(), 'title' => $currentTransaction->getTitle(), 'description' => $currentTransaction->getDescription(), 'valutaDate' => ($tmp = $currentTransaction->getValutaDate()) ? $tmp->getFormatted() : '', 'amount' => $currentTransaction->getAmount()->getFormatted(), 'outsideCapital' => is_null($tmp = $currentTransaction->getOutsideCapital()) ? '' : $tmp, 'transactionPartner' => $currentTransaction->getTransactionPartner(), 'categoryId' => ($tmp = $currentTransaction->getCategory()) ? $tmp->getId() : '', 'categoryTitle' => ($tmp = $currentTransaction->getCategory()) ? $tmp->getTitle() : '', 'exceptional' => is_null($tmp = $currentTransaction->getExceptional()) ? '' : $tmp, 'periodical' => is_null($tmp = $currentTransaction->getPeriodical()) ? '' : $tmp); } break; case 'planned': while ($this->fetchNextPlannedTransaction()) { } foreach ($this->plannedTransactions as $currentTransaction) { $result[] = array('plannedTransactionId' => 'p' . $currentTransaction->getId() . '_X', 'title' => $currentTransaction->getTitle(), 'description' => $currentTransaction->getDescription(), 'amount' => $currentTransaction->getAmount()->getFormatted(), 'outsideCapital' => is_null($tmp = $currentTransaction->getOutsideCapital()) ? '' : $tmp, 'transactionPartner' => $currentTransaction->getTransactionPartner(), 'beginDate' => $currentTransaction->getBeginDate()->getFormatted(), 'endDate' => ($tmp = $currentTransaction->getEndDate()) ? $tmp->getFormatted() : '', 'repeatUnit' => getBadgerTranslation2('Account', $currentTransaction->getRepeatUnit()), 'repeatFrequency' => $currentTransaction->getRepeatFrequency(), 'categoryId' => ($tmp = $currentTransaction->getCategory()) ? $tmp->getId() : '', 'categoryTitle' => ($tmp = $currentTransaction->getCategory()) ? $tmp->getTitle() : ''); } break; } return $result; }
function yAxisCallback($number) { global $us; $amount = new Amount($number); list($whole, $fraction) = explode($us->getProperty('badgerDecimalSeparator'), $amount->getFormatted()); if (floor($number) == $number) { return $whole; } else { return $amount->getFormatted(); } }
$pocketMoney2EndValue = $val3->sub($PocketMoney2Loop->mul($day))->get(); } $day++; } //foreach($totals as $key => $val) { echo '<forecastData>'; $insertChart = urlencode($insertChart); echo "<insertChart>{$insertChart}</insertChart>"; if ($showSavingTarget == 1) { $dailyPocketMoneyValue = $dailyPocketMoney->getFormatted(); echo "<dailyPocketMoneyValue>{$dailyPocketMoneyValue}</dailyPocketMoneyValue>"; } if ($pocketMoney1EndValue) { $printedPocketMoney1EndValue = new Amount($pocketMoney1EndValue); $balancedEndDate1 = $printedPocketMoney1EndValue->getFormatted(); echo "<balancedEndDate1>{$balancedEndDate1}</balancedEndDate1>"; } if ($pocketMoney2EndValue) { $printedPocketMoney2EndValue = new Amount($pocketMoney2EndValue); $balancedEndDate2 = $printedPocketMoney2EndValue->getFormatted(); echo "<balancedEndDate2>{$balancedEndDate2}</balancedEndDate2>"; } echo "<accountCurrency>{$accountCurrency}</accountCurrency>"; echo '</forecastData>'; } } else { //if ($today->compare($today, $selectedDate)!=1){ $noFutureDates = getBadgerTranslation2("forecast", "onlyFutureDates"); echo "<errors><error>{$noFutureDates}</error></errors>"; } require_once BADGER_ROOT . "/includes/fileFooter.php";
function getAllTransactions(&$finishedTransactions, $selectedFields, $order, $upperLimit, $lowerLimit) { $result = array(); $currResultIndex = 0; $sum = new Amount(); $now = new Date(); $now->setHour(0); $now->setMinute(0); $now->setSecond(0); if (isset($order[0]) && $order[0]['key'] == 'valutaDate') { $firstOrderValutaDate = true; $orderCompareNumber = $order[0]['dir'] == 'asc' ? -1 : 1; } else { $firstOrderValutaDate = false; } $todayMarkerSet = false; foreach ($finishedTransactions as $currentTransaction) { $sum->add($currentTransaction->getAmount()); $classAmount = $currentTransaction->getAmount()->compare(0) >= 0 ? 'dgPositiveAmount' : 'dgNegativeAmount'; if ($sum->compare(0) >= 0) { if ($upperLimit && $sum->compare($upperLimit) > 0) { $classSum = 'dgOverMaxAmount'; } else { $classSum = 'dgPositiveAmount'; } } else { if ($lowerLimit && $sum->compare($lowerLimit) < 0) { $classSum = 'dgUnderMinAmount'; } else { $classSum = 'dgNegativeAmount'; } } $balance = $currentTransaction->getBalance(); if ($balance->compare(0) >= 0) { if ($upperLimit && $balance->compare($upperLimit) > 0) { $classBalance = 'dgOverMaxAmount'; } else { $classBalance = 'dgPositiveAmount'; } } else { if ($lowerLimit && $balance->compare($lowerLimit) < 0) { $classBalance = 'dgUnderMinAmount'; } else { $classBalance = 'dgNegativeAmount'; } } $category = $currentTransaction->getCategory(); if (!is_null($category)) { $parentCategory = $category->getParent(); } else { $parentCategory = null; } if ($parentCategory) { $concatCategoryTitle = $parentCategory->getTitle() . ' - '; } else { $concatCategoryTitle = ''; } if ($category) { $concatCategoryTitle .= $category->getTitle(); } if ($currentTransaction->getType() == 'FinishedTransaction' || $currentTransaction->getType() == 'FinishedTransferalTransaction') { $id = $currentTransaction->getId(); } else { $id = 'p' . $currentTransaction->getPlannedTransaction()->getId() . '_' . $currentTransaction->getId(); } switch ($currentTransaction->getType()) { case 'FinishedTransaction': $typeImg = 'Account/finished_transaction.png'; $typeText = getBadgerTranslation2('Account', 'FinishedTransaction'); break; case 'FinishedTransferalTransaction': if ($currentTransaction->getTransferalSource()) { $typeImg = 'Account/finished_transferal_source_transaction.png'; $typeText = getBadgerTranslation2('Account', 'FinishedTransferalSourceTransaction'); } else { $typeImg = 'Account/finished_transferal_target_transaction.png'; $typeText = getBadgerTranslation2('Account', 'FinishedTransferalTargetTransaction'); } break; case 'PlannedTransaction': $typeImg = 'Account/planned_transaction.png'; $typeText = getBadgerTranslation2('Account', 'PlannedTransaction'); break; case 'PlannedTransferalTransaction': if ($currentTransaction->getTransferalSource()) { $typeImg = 'Account/planned_transferal_source_transaction.png'; $typeText = getBadgerTranslation2('Account', 'PlannedTransferalSourceTransaction'); } else { $typeImg = 'Account/planned_transferal_target_transaction.png'; $typeText = getBadgerTranslation2('Account', 'PlannedTransferalTargetTransaction'); } break; } $result[$currResultIndex] = array(); if ($firstOrderValutaDate && $todayMarkerSet === false && !is_null($currentTransaction->getValutaDate()) && Date::compare($now, $currentTransaction->getValutaDate()) == $orderCompareNumber) { $result[$currResultIndex]['transactionId'] = array('marker' => 'today', 'content' => $id); $todayMarkerSet = true; } else { $result[$currResultIndex]['transactionId'] = $id; } foreach ($selectedFields as $selectedField) { switch ($selectedField) { case 'type': $result[$currResultIndex]['type'] = array('img' => getRelativeTplPath($typeImg), 'title' => $typeText); break; case 'title': $result[$currResultIndex]['title'] = $currentTransaction->getTitle(); break; case 'description': $result[$currResultIndex]['description'] = $currentTransaction->getDescription(); break; case 'valutaDate': $result[$currResultIndex]['valutaDate'] = ($tmp = $currentTransaction->getValutaDate()) ? $tmp->getFormatted() : ''; break; case 'amount': $result[$currResultIndex]['amount'] = array('class' => $classAmount, 'content' => $currentTransaction->getAmount()->getFormatted()); break; case 'outsideCapital': $result[$currResultIndex]['outsideCapital'] = is_null($tmp = $currentTransaction->getOutsideCapital()) ? '' : $tmp; break; case 'transactionPartner': $result[$currResultIndex]['transactionPartner'] = $currentTransaction->getTransactionPartner(); break; case 'categoryId': $result[$currResultIndex]['categoryId'] = $category ? $category->getId() : ''; break; case 'categoryTitle': $result[$currResultIndex]['categoryTitle'] = $category ? $category->getTitle() : ''; break; case 'parentCategoryId': $result[$currResultIndex]['parentCategoryId'] = $parentCategory ? $parentCategory->getId() : ''; break; case 'parentCategoryTitle': $result[$currResultIndex]['parentCategoryTitle'] = $parentCategory ? $parentCategory->getTitle() : ''; break; case 'concatCategoryTitle': $result[$currResultIndex]['concatCategoryTitle'] = $concatCategoryTitle; break; case 'sum': $result[$currResultIndex]['sum'] = array('class' => $classSum, 'content' => $sum->getFormatted()); break; case 'balance': $result[$currResultIndex]['balance'] = array('class' => $classBalance, 'content' => $currentTransaction->getBalance()->getFormatted()); break; case 'plannedTransactionId': $result[$currResultIndex]['plannedTransactionId'] = is_null($tmp = $currentTransaction->getPlannedTransaction()) ? '' : $tmp->getId(); break; case 'exceptional': $result[$currResultIndex]['exceptional'] = is_null($tmp = $currentTransaction->getExceptional()) ? '' : $tmp; break; case 'periodical': $result[$currResultIndex]['periodical'] = is_null($tmp = $currentTransaction->getPeriodical()) ? '' : $tmp; break; case 'accountTitle': $result[$currResultIndex]['accountTitle'] = $currentTransaction->getAccount()->getTitle(); break; } //switch } //foreach selectedFields $currResultIndex++; } //foreach finishedTransactions return $result; }