public function showMain()
 {
     $page = $this->node;
     $tree = Collector::get('root');
     $subTree = Tree::getSubTree($tree, $page);
     $blocks = null;
     if ($subTree) {
         $blocks = $subTree->children;
     }
     foreach ($blocks as $index => $block) {
         $blocks[$block->slug] = $block;
         unset($blocks[$index]);
     }
     $allRates = Cache::tags('rates')->rememberForever('rates_' . App::getLocale(), function () {
         return Rates::orderPriority()->get();
     });
     $rates = array();
     foreach ($allRates as $i => $rate) {
         if ($rate['type'] == 1) {
             $rates['departments'][] = $rate;
         } else {
             $rates['cards'][$rate['name_card']][] = $rate;
         }
     }
     $calculatorCredit = new CashCalculator();
     // fixme:
     //$calculatorCredit->setMonthlyIncome(Settings::get('monthly_income_default', 0));
     $calculatorCredit->setCreditAmount(Settings::get('credit_amount_default', 100000));
     $calculatorCredit->setTerm(Settings::get('term_default', 3));
     $calculationsCredit = $calculatorCredit->calculate();
     return View::make('index', compact('page', 'blocks', 'rates', 'calculationsCredit'));
 }
 public function doCashCalculation()
 {
     App::setLocale(Cookie::get('locale', 'ru'));
     $creditAmount = intval(trim(Input::get('credit_amount')));
     $term = intval(trim(Input::get('term')));
     if (!$creditAmount || !$term) {
         return Response::json(array('status' => false));
     }
     $calculator = new CashCalculator();
     $calculator->setCreditAmount($creditAmount);
     $calculator->setTerm($term);
     $calculationsCredit = $calculator->calculate();
     $html = View::make('partials.calculators.partials.cash_table', compact('calculationsCredit'))->render();
     return Response::json(array('status' => true, 'html' => $html));
 }
 public function showCreditsCash()
 {
     $page = $this->node;
     $tree = Collector::get('root');
     $subTree = Tree::getSubTree($tree, $page);
     $blocks = null;
     if ($subTree) {
         $blocks = $subTree->children;
     }
     $calculatorCredit = new CashCalculator();
     $calculatorCredit->setMonthlyIncome(0);
     $calculatorCredit->setCreditAmount(Settings::get('credit_amount_default', 100000));
     $calculatorCredit->setTerm(Settings::get('term_default', 3));
     $calculationsCredit = $calculatorCredit->calculate();
     return View::make('private-persons.credits.cash', compact('page', 'blocks', 'calculationsCredit'));
 }