protected function loadNavBar()
    {
        $this->breadcrumb->add((new BreadcrumbItem('Budget'))
            ->setIcon('money')
            ->setUri('#'));

        $bankMapper = new BankMapper(Database::get('money'));
        $banks      = $bankMapper->select();

        $accountUserMapper = new AccountUserMapper(Database::get('money'));
        $userAccounts      = $accountUserMapper->findByUserId((int) Session::getInstance()->get('id'));

        $accounts = array();
        foreach ($userAccounts as $userAccount) {
            $account = $userAccount->getAccount();

            if ($account->isVirtual()) {
                continue;
            }

            if (!isset($accounts[$account->getBankId()])) {
                $accounts[$account->getBankId()] = array();
            }

            $accounts[$account->getBankId()][] = $account;
        }

        $this->dataCollection->add('banks', $banks);
        $this->dataCollection->add('accounts', $accounts);

        $params = $this->route->getParameterCollection();
        $get    = Get::getInstance();

        try {
            $dateStart = new \DateTimeImmutable($get->get('date_start', date('Y-m-01')));
        } catch(\Exception $exception) {
            $dateStart = new \DateTimeImmutable();
        }

        $this->navForm->setParams(array(
            'banks'            => $banks,
            'accounts'         => $accounts,
            'currentAccountId' => ($params->hasByName('id') ? (int) $params->getByName('id')->getValue() : 0),
            'dateStart'        => $dateStart,
            'date'             => new \DateTimeImmutable(date('Y-m-01')),
        ));

        $this->navForm->setTemplate($this->appTplPath . '/Partial/NavbarForm');
    }
protected function loadNavBar()
    {
        $this->breadcrumb->add((new BreadcrumbItem('Budget'))
            ->setIcon('money')
            ->setUri('#'));

        $bankMapper = new BankMapper(Database::get('money'));
        $banks      = $bankMapper->select();

        $accountUserMapper = new AccountUserMapper(Database::get('money'));
        $userAccounts      = $accountUserMapper->findByUserId((int) Session::getInstance()->get('id'));

        $accounts = array();
        foreach ($userAccounts as $userAccount) {
            $account = $userAccount->getAccount();

            if ($account->isVirtual()) {
                continue;
            }

            if (!isset($accounts[$account->getBankId()])) {
                $accounts[$account->getBankId()] = array();
            }

            $accounts[$account->getBankId()][] = $account;
        }

        $this->dataCollection->add('banks', $banks);
        $this->dataCollection->add('accounts', $accounts);

        $params = $this->route->getParameterCollection();
        $get    = Get::getInstance();

        try {
            $dateStart = new \DateTimeImmutable($get->get('date_start', date('Y-m-01')));
        } catch(\Exception $exception) {
            $dateStart = new \DateTimeImmutable();
        }

        $this->navForm->setParams(array(
            'banks'            => $banks,
            'accounts'         => $accounts,
            'currentAccountId' => ($params->hasByName('id') ? (int) $params->getByName('id')->getValue() : 0),
            'dateStart'        => $dateStart,
            'date'             => new \DateTimeImmutable(date('Y-m-01')),
        ));

        $this->navForm->setTemplate($this->appTplPath . '/Partial/NavbarForm');
    }
protected function loadNavBar ( ) { $ this -> breadcrumb -> add ( ( new BreadcrumbItem ( 'Budget' ) ) -> setIcon ( 'money' ) -> setUri ( '#' ) ) ; $ bankMapper = new BankMapper ( Database :: get ( 'money' ) ) ; $ banks = $ bankMapper -> select ( ) ; $ accountUserMapper = new AccountUserMapper ( Database :: get ( 'money' ) ) ; $ userAccounts = $ accountUserMapper -> findByUserId ( ( int ) Session :: getInstance ( ) -> get ( 'id' ) ) ; $ accounts = array ( ) ; foreach ( $ userAccounts as $ userAccount ) { $ account = $ userAccount -> getAccount ( ) ; if ( $ account -> isVirtual ( ) ) { continue ; } if ( ! isset ( $ accounts [ $ account -> getBankId ( ) ] ) ) { $ accounts [ $ account -> getBankId ( ) ] = array ( ) ; } $ accounts [ $ account -> getBankId ( ) ] [ ] = $ account ; } $ this -> dataCollection -> add ( 'banks' , $ banks ) ; $ this -> dataCollection -> add ( 'accounts' , $ accounts ) ; $ params = $ this -> route -> getParameterCollection ( ) ; $ get = Get :: getInstance ( ) ; try { $ dateStart = new \ DateTimeImmutable ( $ get -> get ( 'date_start' , date ( 'Y-m-01' ) ) ) ; } catch ( \ Exception $ exception ) { $ dateStart = new \ DateTimeImmutable ( ) ; } $ this -> navForm -> setParams ( array ( 'banks' => $ banks , 'accounts' => $ accounts , 'currentAccountId' => ( $ params -> hasByName ( 'id' ) ? ( int ) $ params -> getByName ( 'id' ) -> getValue ( ) : 0 ) , 'dateStart' => $ dateStart , 'date' => new \ DateTimeImmutable ( date ( 'Y-m-01' ) ) , ) ) ; $ this -> navForm -> setTemplate ( $ this -> appTplPath . '/Partial/NavbarForm' ) ; }
Load navbar for budgets pages
@return void
@throws \Exception
Load navbar for budgets pages