Пример #1
0
 public function getCurrencyCode()
 {
     if (!$this->get('currency_code')) {
         $this->set('currency_code', Main::app()->getConfig('CURRENCY'));
     }
     return $this->get('currency_code');
 }
Пример #2
0
 public function balanceReportChartDataAction()
 {
     $xhb = $this->getXhbSession()->getModel();
     $collFilters = array('period' => $this->getRequestQuery('period') ? $this->getRequestQuery('period') : Main::app()->getConfig('DEFAULT_OPERATIONS_PERIOD'));
     $accountCollection = $xhb->getAccountCollection()->addFieldToFilter('type', Constants::ACC_TYPE_BANK);
     $accountIds = $accountCollection->getAllIds();
     $chartData = Chart\Operation::getBalanceReportData($xhb, $collFilters, $accountIds, true);
     $this->setPageConfig(array('template' => 'data/json.phtml', 'mime' => 'application/json'));
     $this->getView()->setData('DATA', $chartData);
 }
Пример #3
0
 public function consumptionChartDataAction()
 {
     $xhb = $this->getXhbSession()->getModel();
     $periodCode = $this->getRequestQuery('period') ? $this->getRequestQuery('period') : Main::app()->getConfig('DEFAULT_VEHICLES_PERIOD');
     $period = $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);
     $fuelCostData = \app\helpers\whb\Chart\Vehiclecost::getConsumptionData($xhb, $period, $categoryIds);
     $this->setPageConfig(array('template' => 'data/json.phtml', 'mime' => 'application/json'));
     $this->getView()->setData('DATA', $fuelCostData);
 }
Пример #4
0
 /**
  * Generate a unique key based on the current configuration files.
  * Avoid using deprecated cache data when config is updated.
  *
  * This behavior can be turned off by setting a fixed value for app.CONFIG_CACHE_KEY inside configuration.
  *
  * @see $this->_configCacheKeySections for configuration sections used to calculate the key.
  *
  * @return string
  */
 protected function _getConfigCacheKey()
 {
     $fw = \Base::instance();
     if (!$this->_configCacheKey) {
         if ($key = Main::app()->getConfig('CONFIG_CACHE_KEY')) {
             $this->_configCacheKey = $key;
         } else {
             $key = array();
             foreach ($this->_configCacheKeySections as $section) {
                 $key[] = $fw->get($section);
             }
             $this->_configCacheKey = $fw->hash($fw->serialize($key));
         }
     }
     return $this->_configCacheKey;
 }
Пример #5
0
 public function doLoadAction()
 {
     $this->setPageConfig(array('template' => 'data/json.phtml', 'mime' => 'application/json'));
     try {
         $config = Main::app()->getConfig('XHB');
         $adapter = new XhbAdapter($this->_fw, $this->getXhbSession()->get('xhb_file'), $config);
         $xhb = $adapter->loadXhb(true);
         $this->getSession()->addMessage(I18n::instance()->tr('XHB imported to database successfully!'), Session::MESSAGE_INFO);
         $this->getView()->setData('DATA', array('status' => 'success', 'message' => ''));
     } catch (\Exception $e) {
         $response = array('status' => 'error', 'message' => $e->getMessage());
         if ($this->_fw->get('DEBUG') > 0) {
             $response['trace'] = $e->getTraceAsString();
         }
         $this->getView()->setData('DATA', $response);
     }
 }
Пример #6
0
 /**
  *
  * @return \app\models\whb\Session\Xhb
  */
 protected function getXhbSession()
 {
     return Main::app()->getSession('xhb');
 }
Пример #7
0
 /**
  * @return \app\controllers\Core\AbstractController
  */
 public function getCurrentController()
 {
     return Main::app()->getCurrentController();
 }
Пример #8
0
 public function getSession($code = 'xhb')
 {
     return Main::app()->getSession($code);
 }
Пример #9
0
 protected function _loadCache($key, $strictFullActionName = true)
 {
     if ($strictFullActionName) {
         $key = $this->getFullActionName() . '_' . $key;
     }
     return Main::app()->loadCache($key);
 }
Пример #10
0
 public function balanceReportChartDataAction()
 {
     $collFilters = array('period' => $this->getRequestQuery('period') ? $this->getRequestQuery('period') : Main::app()->getConfig('DEFAULT_OPERATIONS_PERIOD'));
     $chartData = Chart\Operation::getBalanceReportData($this->getXhbSession()->getModel(), $collFilters, array($this->getAccount()->getId()));
     $this->setPageConfig(array('template' => 'data/json.phtml', 'mime' => 'application/json'));
     $this->getView()->setData('DATA', $chartData);
 }
Пример #11
0
 public function setUp()
 {
     $session = Main::app()->getSession('xhb');
     $this->xhb = $session->getModel();
 }
Пример #12
0
 protected function _generateXhbId($xhbUniqueKey)
 {
     return sha1(Main::app()->getConfig('VERSION') . $xhbUniqueKey);
 }