Exemplo n.º 1
0
 /**
  * Executes matrix action
  *
  * @param sfRequest $request A request object
  */
 public function executeMatrix(sfWebRequest $request)
 {
     $dateFrom = $request->getGetParameter('dateFrom', date('Y-m-01'));
     $dateTo = $request->getGetParameter('dateTo', date('Y-m-01'));
     $currency = $request->getGetParameter('currency', 1);
     $account = $request->getGetParameter('account', null);
     $type = $request->getGetParameter('type', null);
     $dateFrom = new DateTime(preg_replace("/(\\d{2}).(\\d{2}).(\\d{4})/", "\$3-\$2-\$1", $dateFrom));
     $dateTo = new DateTime(preg_replace("/(\\d{2}).(\\d{2}).(\\d{4})/", "\$3-\$2-\$1", $dateTo));
     $currency = Doctrine::getTable('Currency')->findOneById($currency);
     $user = $this->getUser()->getUserRecord();
     $account = $account ? Doctrine::getTable('Account')->findOneById($account) : null;
     $report = new myReportMatrix($currency);
     $report->buildReport($user, $account, $dateFrom, $dateTo, $type);
     $result = array('headerLeft' => $report->getHeaderLeft(), 'headerTop' => $report->getHeaderTop(), 'matrix' => $report->getMatrix());
     return $this->renderJson($result);
 }
 /**
  * Тест итогов на одной операции
  */
 public function testTotal()
 {
     $user = Doctrine::getTable('User')->findOneByLogin('tester');
     $dateStart = new DateTime('2010-08-01');
     $dateEnd = new DateTime('2010-12-01');
     $currency = $user->getCurrency();
     $report = new myReportMatrix($currency);
     $report->buildReport($user, null, $dateStart, $dateEnd, Operation::TYPE_PROFIT);
     $headerLeft = $report->getHeaderLeft();
     $matrix = $report->getMatrix();
     $this->assertEquals(400, $matrix[$headerLeft[0]->flatIndex]['tag_foo'], 'Сумма в доходной категории по тэгу tag_foo');
     $this->assertEquals(400, $matrix[$headerLeft[1]->flatIndex]['tag_foo'], 'Сумма в тэге tag_foo по категориям');
 }