Exemplo n.º 1
0
 /**
  * @param \Base $fw
  */
 public function indexAction()
 {
     $xhb = $this->getXhbSession()->getModel();
     $gridDataCacheKey = 'gridData_' . $xhb->getUniqueKey();
     $totalDataCacheKey = 'totalData_' . $xhb->getUniqueKey();
     if (!($gridData = $this->_loadCache($gridDataCacheKey)) || !($totalData = $this->_loadCache($totalDataCacheKey))) {
         $gridData = array();
         $totalData = array();
         /* @var $account \Xhb\Model\Account */
         foreach ($xhb->getAccountCollection() as $account) {
             $type = $account->getType(true);
             $accountData = array('account' => $account, 'balances' => array(Constants::BALANCE_TYPE_BANK => $account->getBankBalance(), Constants::BALANCE_TYPE_TODAY => $account->getTodayBalance(), Constants::BALANCE_TYPE_FUTURE => $account->getFutureBalance()));
             $gridData[$type][] = $accountData;
             if (!isset($totalData[$type])) {
                 $totalData[$type] = array(Constants::BALANCE_TYPE_BANK => 0, Constants::BALANCE_TYPE_TODAY => 0, Constants::BALANCE_TYPE_FUTURE => 0);
             }
             if (!isset($totalData['grand_total'])) {
                 $totalData['grand_total'] = array(Constants::BALANCE_TYPE_BANK => 0, Constants::BALANCE_TYPE_TODAY => 0, Constants::BALANCE_TYPE_FUTURE => 0);
             }
             $totalData[$type][Constants::BALANCE_TYPE_BANK] += $accountData['balances'][Constants::BALANCE_TYPE_BANK];
             $totalData[$type][Constants::BALANCE_TYPE_TODAY] += $accountData['balances'][Constants::BALANCE_TYPE_TODAY];
             $totalData[$type][Constants::BALANCE_TYPE_FUTURE] += $accountData['balances'][Constants::BALANCE_TYPE_FUTURE];
             $totalData['grand_total'][Constants::BALANCE_TYPE_BANK] += $accountData['balances'][Constants::BALANCE_TYPE_BANK];
             $totalData['grand_total'][Constants::BALANCE_TYPE_TODAY] += $accountData['balances'][Constants::BALANCE_TYPE_TODAY];
             $totalData['grand_total'][Constants::BALANCE_TYPE_FUTURE] += $accountData['balances'][Constants::BALANCE_TYPE_FUTURE];
         }
         $this->_saveCache($gridDataCacheKey, $gridData)->_saveCache($totalDataCacheKey, $totalData);
     }
     Design::instance()->addJs('chartjs/Chart.min.js')->addJs('chartjs/Chart.Scatter.js');
     //FIXME Scale is buggy with minified JS
     $this->getView()->setBlockTemplate('charts', 'account/index/charts.phtml')->setData('GRID_DATA', $gridData)->setData('TOTAL_DATA', $totalData)->setData('TOP_SPENDING_CHART', new Donut(array('id' => 'topSpendingChart', 'title' => 'Where your money goes', 'data_url' => $this->getUrl('*/topSpendingChartData'), 'filters' => array(new PeriodFilter($xhb, array('name' => 'period', 'value' => Main::app()->getConfig('DEFAULT_OPERATIONS_PERIOD')))), 'class' => 'toolbar-right')))->setData('BALANCE_REPORT_CHART', new Scatter(array('id' => 'balanceReportChart', 'title' => 'General Balance Report', 'data_url' => $this->getUrl('*/balanceReportChartData'), 'filters' => array(new PeriodFilter($xhb, array('name' => 'period', 'value' => Main::app()->getConfig('DEFAULT_OPERATIONS_PERIOD')))), 'class' => 'toolbar-top-right', 'show_legend' => false, 'footer_note' => $this->__('Only bank accounts are shown here.'), 'axis_type' => Scatter::AXIS_TYPE_DATE_CURRENCY)));
 }
Exemplo n.º 2
0
 protected function _beforeRoute($fw, $args = null)
 {
     AbstractController::_beforeRoute($fw, $args);
     $this->_viewInstance = View::instance();
     $this->setPageTitle($this->__('WebHomeBank'));
     Design::instance()->addJs('jquery/jquery-2.1.4.min.js', 'header', -100)->addJs('whb/i18n.js')->addInlineJs("var LANGUAGE='{$fw->get('LANGUAGE')}';\nvar CURRENCY='{$this->getXhbSession()->getCurrencyCode()}';\nvar i18n = new I18n(LANGUAGE, CURRENCY);");
     $this->canCacheOutput(false);
     $this->_setupLayoutBlocks();
 }
Exemplo n.º 3
0
 protected function _beforeRoute($fw, $args = null)
 {
     parent::_beforeRoute($fw, $args);
     $this->_viewInstance = View::instance();
     if (!$this->getXhbSession()->isModelLoaded()) {
         $this->_reroute('/init/load');
         return false;
     }
     $xhb = $this->getXhbSession()->getModel();
     $this->setPageTitle($xhb->getTitle());
     Design::instance()->addJs('jquery/jquery-2.1.4.min.js', 'header', -100)->addJs('whb/i18n.js')->addInlineJs("var LANGUAGE='{$fw->get('LANGUAGE')}';\nvar CURRENCY='{$this->getXhbSession()->getCurrencyCode()}';\nvar i18n = new I18n(LANGUAGE, CURRENCY);");
     $this->_setupLayoutBlocks();
 }
Exemplo n.º 4
0
 public function indexAction()
 {
     $xhb = $this->getXhbSession()->getModel();
     $vehicleCostReport = new \Xhb\Model\Report\VehicleCost($xhb);
     $periodCode = $this->getRequestQuery('period') ? $this->getRequestQuery('period') : Main::app()->getConfig('DEFAULT_VEHICLES_PERIOD');
     $periodObject = $xhb->getDateHelper()->getPeriodFromConstant($periodCode);
     $category = $this->getRequestQuery('category') ? $this->getRequestQuery('category') : $xhb->getCarCategory();
     /* @var $category Category */
     $childrenIds = $xhb->getCategory($category)->getChildrenCategories()->getAllIds();
     $categoryIds = array_merge(array($category), $childrenIds);
     $consumptionSummaryData = $vehicleCostReport->getPeriodConsumptionSummaryData($periodObject, $categoryIds);
     $consumptionData = $vehicleCostReport->getPeriodConsumptionData($periodObject, $categoryIds);
     $filters = array();
     $categoryFilter = new CategoryFilter($xhb, array('name' => 'category', 'id' => 'filter-category', 'value' => $category, 'class' => 'filter-input'));
     $filters['category'] = $categoryFilter;
     $periodFilter = new PeriodFilter($xhb, array('name' => 'period', 'id' => 'filter-period', 'value' => $periodCode, 'class' => 'filter-input'));
     $filters['period'] = $periodFilter;
     Design::instance()->addJs('chartjs/Chart.min.js')->addJs('chartjs/Chart.Scatter.js');
     //FIXME Scale is buggy with minified JS
     $this->getView()->setBlockTemplate('toolbar', 'common/toolbar.phtml')->setBlockTemplate('summary', 'report/vehiclecost/index/summary.phtml')->setBlockTemplate('charts', 'report/vehiclecost/index/charts.phtml')->setData('FILTER_FORM_ACTION', $this->getUrl('*/*'))->setData('FILTERS', $filters)->setData('RESET_FILTERS_URL', $this->getUrl('*/*'))->setData('CONSUMPTION_SUMMARY_DATA', $consumptionSummaryData)->setData('CONSUMPTION_DATA', $consumptionData)->setData('CONSUMPTION_CHART', new Scatter(array('id' => 'consumptionRatioChart', 'title' => 'Consumption', 'data_url' => $this->getUrl('*/consumptionChartData', array('_query' => '*')), 'class' => 'toolbar-top-right', 'show_legend' => false)))->setData('FUEL_PRICE_EVOLUTION_CHART', new Scatter(array('id' => 'fuelPriceChart', 'title' => 'Fuel Price Evolution', 'data_url' => $this->getUrl('*/fuelPriceChartData', array('_query' => '*')), 'class' => 'toolbar-top-right', 'show_legend' => false, 'axis_type' => Scatter::AXIS_TYPE_DATE_CURRENCY)))->setData('DISTANCE_TRAVELED_CHART', new Scatter(array('id' => 'distanceTraveledChart', 'title' => 'Distance Traveled', 'data_url' => $this->getUrl('*/distanceTraveledChartData', array('_query' => '*')), 'class' => 'toolbar-top-right', 'show_legend' => false)));
 }
Exemplo n.º 5
0
 protected function _setup()
 {
     ini_set('max_execution_time', 60);
     if ($this->_fw->get('DEBUG')) {
         ini_set('display_errors', 1);
     }
     // Setup i18n
     $i18n = I18n::instance();
     $i18n->setLocale($this->getSession()->getLocale());
     $i18n->setCurrencyCode($this->getSession('xhb')->getCurrencyCode());
     // Set HTML lang according to defined locale
     $this->_fw->set('HTML_LANG', $i18n->getLocaleCountryCodeISO2());
     // Load XHB
     $this->getSession('xhb')->set('xhb_file', $this->_xhbFile);
     // Avoid decimal separator issues when casting double and float values to strings
     setlocale(LC_NUMERIC, 'C');
     if ($theme = $this->getSession()->getTheme()) {
         Design::instance()->setTheme($theme);
     }
     Design::instance()->init();
     if ($this->_xhbFile == 'data/example.xhb') {
         $this->getSession()->addMessage($i18n->tr("It seems you're using the default <span class=\"mono\">example.xhb</span> file. " . "You may want to change it by editing <span class=\"mono\">etc/local.ini</span>."), Session::MESSAGE_INFO, array('no_escape' => true));
     }
 }
Exemplo n.º 6
0
<?php

\app\models\core\Design::instance()->addCss(array('base.css', 'theme.css', 'app.css', 'dropdown.css'));
Exemplo n.º 7
0
 protected function _addBodyClass()
 {
     $class = preg_replace('/[^a-z-]/i', '-', $this->_controller);
     Design::instance()->addBodyClass($class);
     $class = preg_replace('/[^a-z-]/i', '-', $this->getFullActionName());
     Design::instance()->addBodyClass($class);
 }
Exemplo n.º 8
0
<?php

\app\models\core\Design::instance()->addCss(array('app.css'))->addJs(array('foundation/foundation.js', 'foundation/foundation.topbar.js'), 'footer')->addInlineJs("jQuery(document).foundation();", 'footer', 1000);
Exemplo n.º 9
0
 public function indexAction()
 {
     $xhb = $this->getXhbSession()->getModel();
     $order = $this->getRequestQuery('order');
     $dir = $this->getRequestQuery('dir');
     if (!$order) {
         $order = 'date';
         $dir = SORT_ASC;
     }
     if (!$dir) {
         $dir = SORT_ASC;
     }
     $currentOrder = array($order => $dir);
     $coll = $this->getAccount()->getOperationCollection()->orderBy($order, $dir);
     $query = $this->getRequestQuery();
     if (!isset($query['period'])) {
         $query['period'] = Main::app()->getConfig('DEFAULT_OPERATIONS_PERIOD');
     }
     $filters = AccountOperation::applyFiltersOnCollection($coll, $query);
     // Speed up collection loading by not setting aggregated fields if not needed
     if (empty($filters['search'])) {
         $coll->setFlag('skip_aggregated_fields');
     }
     $filters = array();
     $periodFilter = new PeriodFilter($xhb, array('name' => 'period', 'id' => 'filter-period', 'value' => $query['period'], 'class' => 'filter-input'));
     $filters['period'] = $periodFilter;
     $typeFilter = new TypeFilter($xhb, array('name' => 'type', 'id' => 'filter-type', 'value' => isset($query['type']) ? $query['type'] : null, 'class' => 'filter-input'));
     $filters['type'] = $typeFilter;
     $statusFilter = new StatusFilter($xhb, array('name' => 'status', 'id' => 'filter-status', 'value' => isset($query['status']) ? $query['status'] : null, 'class' => 'filter-input'));
     $filters['status'] = $statusFilter;
     $searchFilter = new SearchFilter($xhb, array('name' => 'search', 'id' => 'filter-search', 'value' => isset($query['search']) ? $query['search'] : null, 'class' => 'filter-input'));
     $filters['search'] = $searchFilter;
     Design::instance()->addJs('chartjs/Chart.min.js')->addJs('chartjs/Chart.Scatter.js');
     //FIXME Scale is buggy with minified JS
     $this->getView()->setBlockTemplate('operation_toolbar', 'common/toolbar.phtml')->setBlockTemplate('account_summary', 'account/operation/index/summary.phtml')->setBlockTemplate('charts', 'account/operation/index/charts.phtml')->setData('OPERATION_COLLECTION', $coll)->setData('FILTER_FORM_ACTION', $this->getUrl('*/*/*'))->setData('RESET_FILTERS_URL', $this->getUrl('*/*/*'))->setData('FILTERS', $filters)->setData('CURRENT_ORDER', $currentOrder)->setData('BALANCE_REPORT_CHART', new Scatter(array('id' => 'balanceReportChart', 'title' => 'Balance Report', 'data_url' => $this->getUrl('*/balanceReportChartData/*', array('_query' => '*')), 'class' => 'toolbar-top-right', 'show_legend' => false, 'axis_type' => Scatter::AXIS_TYPE_DATE_CURRENCY)));
 }