Exemple #1
0
 public function display($tpl = null)
 {
     $_session = JFactory::getSession();
     $model_account = KSSystem::getModel('account');
     $controller = KSSystem::getController('account');
     $this->title = JText::_('KM_CATALOG_YA_MARKET');
     $model = $this->getModel('yamarket');
     $app = JFactory::getApplication();
     $this->document->addScript(JURI::base() . 'components/com_ksenmart/js/yamarket.js');
     $this->document->addStyleSheet(JURI::base() . 'components/com_ksenmart/css/yamarket.css');
     if (!$model_account->checkAuthorize()) {
         $app->redirect('index.php?option=com_ksenmart&view=account&layout=default_login');
     } else {
         $uid = $model_account->getUserId();
         if (!empty($uid) && $uid > 0) {
             $layout = $this->getLayout();
             $params = $model->getUserParams($uid);
             if (empty($params->ya_site_id)) {
                 $app->redirect('index.php?option=com_ksenmart', 'KM_YA_MARKET_ACCESS_DENIED');
                 exit;
             }
             $shop_info = $model->getUserShopInfo($params->ya_site_id);
             switch ($layout) {
                 case 'stat-placement':
                     $jinput = $app->input;
                     $fromDate = $jinput->get('fromDate', date('Y-m-d'), 'string');
                     $toDate = $jinput->get('toDate', date('Y-m-d'), 'string');
                     $groupBy = $jinput->get('groupBy', 'daily', 'string');
                     $this->path->addItem(JText::_('KM_YA_MARKET'), 'index.php?option=com_ksenmart&view=yamarket');
                     $this->path->addItem(JText::_('KM_YA_HITS_FOR_PLACEMENTS'));
                     $statistic = $model->getShopStatisticByPlacesFull($fromDate, $toDate, $groupBy);
                     $groupByList = JHTML::_('select.genericlist', array('daily' => 'дням', 'weekly' => 'неделям', 'monthly' => 'месяцам'), 'groupBy', 'class="inputbox"', 'value', 'text', $groupBy);
                     $this->assignRef('statistic', $statistic);
                     $this->assignRef('fromDate', $fromDate);
                     $this->assignRef('toDate', $toDate);
                     $this->assignRef('groupByList', $groupByList);
                     break;
                 case 'clicks-report-search':
                     $jinput = $app->input;
                     $groupBy = $jinput->get('groupBy', '-1', 'string');
                     $this->path->addItem(JText::_('KM_YA_MARKET'), 'index.php?option=com_ksenmart&view=yamarket');
                     $this->path->addItem(JText::_('KM_YA_CLICKS_REPORT_SEARCH'));
                     $offersStatistic = $model->getShopOffersStatistic($groupBy, true);
                     $groupByList = JHTML::_('select.genericlist', array('-1' => 'вчера', '-7' => '7 дней', '-30' => '30 дней'), 'groupBy', 'class="inputbox"', 'value', 'text', $groupBy);
                     $this->assignRef('offersStatistic', $offersStatistic);
                     $this->assignRef('groupByList', $groupByList);
                     break;
                 default:
                     $offers = $this->get('ShopOffers');
                     $balance = $this->get('ShopBalance');
                     $statistic = $this->get('ShopStatistic');
                     $statisticByPlaces = $this->get('ShopStatisticByPlaces');
                     $offersStatistic = $this->get('ShopOffersStatistic');
                     /*$test    = $this->get('Test');
                       print_r($test);*/
                     $this->assignRef('params', $params);
                     $this->assignRef('offers', $offers);
                     $this->assignRef('balance', $balance);
                     $this->assignRef('statistic', $statistic);
                     $this->assignRef('statisticByPlaces', $statisticByPlaces);
                     $this->assignRef('offersStatistic', $offersStatistic);
                     $this->assignRef('shop_info', $shop_info);
                     break;
             }
         }
     }
     parent::display($tpl);
 }