/** * Конструктор класса * */ public function __construct() { // Название класса $className = get_class($this); // Подключаем объект CI $CI =& get_instance(); // Подключаем хелпер периодов дат $CI->load->helper('periods'); // Подготавливаем массив для чтения из поста даты $fields = array('from' => type_cast($CI->input->post('from'), 'date'), 'to' => type_cast($CI->input->post('to'), 'date'), 'period' => $CI->input->post('period'), 'mode' => $CI->input->post('mode')); if (false !== $fields['mode']) { // Устанавливаем период $period = data_range($fields); $this->setUnixRange($period['from'], $period['to']); // Сохраняем период period_save($className, $fields); } else { // Загружаем период $fields = period_load($className, 'select', 'today'); // Устанавливаем период $period = data_range($fields); $this->setUnixRange($period['from'], $period['to']); } $this->specifiedRange = false; }
/** * подготавливает данные статистики для периода времени по умолчанию, * callback-функция для библиотеки form * * @param integer $id не используется (обязательный параметр callback-функции) * @return array пустой массив (обязательное возвращаемое значение callback-функции) */ public function _load() { // Загружаем данные по класса Sppc_Dashboard_DateRange $className = get_class($this->range); if (!$this->range->isSpecifiedRange()) { $fields = period_load($className, $this->range->getUnixStartDate(), $this->range->getUnixEndDate()); } else { $fields = array('from' => $this->range->getUnixStartDate(), 'to' => $this->range->getUnixEndDate(), 'period' => '', 'mode' => 'range'); } return $fields; }
/** * подготавливает данные статистики для периода времени по умолчанию, * callback-функция для библиотеки form * * @param integer $id не используется (обязательный параметр callback-функции) * @return array пустой массив (обязательное возвращаемое значение callback-функции) */ public function _load($id) { $fields = period_load('advdashboard', 'select', 'today'); $this->_stat(data_range($fields)); return $fields; }
/** * подготавливает данные статистики для периода времени по умолчанию, * callback-функция для библиотеки form * * @return array пустой массив (обязательное возвращаемое значение callback-функции) */ public function _load() { $fields = period_load('manageadvertisers', 'select', 'today'); $fields['filt'] = $this->temporary['manageadvertisers_filt']; $fields['quicksearch'] = $this->temporary['manageadvertisers_quicksearch']; $this->range = data_range($fields); return $fields; }
/** * Callback-функция, устанавливает значения по умолчанию для фильтра таблицы * * @return array массив со значениями по умолчанию для фильтров */ public function _load() { $fields = period_load('manadsgroups', 'select', 'alltime'); $this->date_range = data_range($fields); $fields['filt'] = $this->temporary['manadsgroups_filt']; return $fields; }
/** * Отправляет ответ (HTML таблицу) на запрос списка сайтов выбранного канала * Канал указывается в GET-параметре id_channel */ public function get_sites($id_channel, $date_from = null, $date_to = null) { // Add plugins to hook $this->add_plugins('channel_sites'); $message = ''; if (is_null($date_from) || is_null($date_to)) { $fields = period_load('manage_sites_channels', 'select', 'alltime'); $this->date_range = data_range($fields); } else { $this->date_range = array('from' => $date_from, 'to' => $date_to); } $action = $this->input->post('manage_action'); if ($action) { $id_channel = $this->input->post('id_channel'); switch ($action) { case 'pause': $this->pause_channel_sites(); break; case 'resume': $this->resume_channel_sites(); break; case 'delete': $message = $this->delete_channel_sites(); break; } } $this->pagination_post->clear(); $this->pagination_post->set_form_name('manage_sites_channels_site_' . $id_channel); $total_params = array('channel_id_filter' => $id_channel, 'date_filter' => $this->date_range, 'revenue_field' => $this->revenue_field, 'id_entity' => $this->user_id); $total = $this->site->get_count($total_params); $this->pagination_post->set_total_records($total['count']); $this->pagination_post->read_variables('manage_sites_channels_site', 1, 10, FALSE, 'manage_sites_channels_site_' . $id_channel); //настройка параметров разбиения на страницы $pagination = $this->pagination_post->create_form(); $col_index = 0; $col_alias = array('chkboxes' => $col_index++, 'id' => $col_index++, 'url' => $col_index++, 'name' => $col_index++, 'status' => $col_index++, 'impressions' => $col_index++, 'alternative_impressions' => $col_index++, 'clicks' => $col_index++, 'ctr' => $col_index++, 'revenue' => $col_index++, 'action' => $col_index++); // add addtional columns to column map from plugins foreach ($this->_hooks as $hookObj) { $col_alias = $hookObj->extendColumnMap($col_alias); } $this->table_builder->clear(); $this->table_builder->init_sort_vars('manage_sites_channels_site', 'id', 'desc', FALSE, 'manage_sites_channels_site_' . $id_channel); $this->table_builder->sorted_column($col_alias['id'], 'id', 'ID', 'asc'); $this->table_builder->sorted_column($col_alias['name'], 'name', 'Title', 'asc'); $this->table_builder->sorted_column($col_alias['url'], 'url', 'Site URL', 'asc'); $this->table_builder->sorted_column($col_alias['status'], 'status', 'Status', 'asc'); $this->table_builder->sorted_column($col_alias['impressions'], 'impressions', 'Impressions', 'desc'); $this->table_builder->sorted_column($col_alias['alternative_impressions'], 'alternative_impressions', 'Alternative Impressions', 'desc'); $this->table_builder->sorted_column($col_alias['clicks'], 'clicks', 'Clicks', 'desc'); $this->table_builder->sorted_column($col_alias['ctr'], 'ctr', 'CTR', 'desc'); $this->table_builder->sorted_column($col_alias['revenue'], 'revenue', 'Revenue', 'desc'); //$this->table_builder->sorted_column(9,'creation_date','Creation Date','desc'); //добавление ячеек-заголовка $this->table_builder->set_cell_content(0, $col_alias['chkboxes'], array('name' => 'checkAll', 'extra' => 'onclick="return select_all(\'manage_sites_channels_site\', this)"'), 'checkbox'); $this->table_builder->set_cell_content(0, $col_alias['action'], __('Action')); // create additional columns from plugins foreach ($this->_hooks as $hookObj) { $hookObj->createColumns($col_alias, $this->table_builder); } $this->table_builder->cell(0, $col_alias['chkboxes'])->add_attribute('class', 'simpleTitle'); $this->table_builder->cell(0, $col_alias['action'])->add_attribute('class', 'simpleTitle'); //прописывание стилей для ячеек $this->table_builder->add_col_attribute($col_alias['chkboxes'], 'class', '"chkbox"'); $this->table_builder->add_col_attribute($col_alias['id'], 'class', 'w20'); //$this->table_builder->add_col_attribute(3, 'class', 'w150'); //$this->table_builder->add_col_attribute(3, 'class', '"w80 center"'); $this->table_builder->add_col_attribute($col_alias['status'], 'class', 'w80 center'); $this->table_builder->add_col_attribute($col_alias['impressions'], 'class', 'w80 right'); $this->table_builder->add_col_attribute($col_alias['alternative_impressions'], 'class', 'w80 right'); $this->table_builder->add_col_attribute($col_alias['clicks'], 'class', 'w50 right'); $this->table_builder->add_col_attribute($col_alias['ctr'], 'class', 'w50 right'); //$this->table_builder->add_col_attribute(8, 'class', '"w80 right"'); $this->table_builder->add_col_attribute($col_alias['revenue'], 'class', 'w100 center'); $this->table_builder->add_col_attribute($col_alias['action'], 'class', 'nowrap center'); // add styles for additional columns from plugins foreach ($this->_hooks as $hookObj) { $hookObj->defineColumnStyles($col_alias, $this->table_builder); } $this->table_builder->add_row_attribute(0, 'class', 'th'); //установка атрибутов таблицы $this->table_builder->add_attribute('class', 'xTable'); //or set style here $params = array('fields' => 'sites.id_site as id, ' . 'sites.url, site_channels.status, sites.name, SUM(impressions) as impressions, ' . 'SUM(alternative_impressions) as alternative_impressions, SUM(clicks) as clicks, ' . '(SUM(clicks)/SUM(impressions)*100) as ctr, UNIX_TIMESTAMP(sites.creation_date) as ' . 'creation_date, SUM(' . $this->revenue_field . ') as revenue, ' . 'e.id_entity AS pub_entity', 'order_by' => $this->table_builder->sort_field, 'order_direction' => $this->table_builder->sort_direction, 'channel_id_filter' => $id_channel, 'date_filter' => $this->date_range, 'id_entity' => $this->user_id, 'offset' => ($this->pagination_post->get_page() - 1) * $this->pagination_post->get_per_page(), 'limit' => $this->pagination_post->get_per_page()); // Add addtional fields to $params['fields'] foreach ($this->_hooks as $hookObj) { if (method_exists($hookObj, 'extendColumnQueryFields')) { $params = $hookObj->extendColumnQueryFields($params, 'stat_sites_channels'); } } $sites_array = $this->site->get_list($params); //echo $this->db->last_query(); if (is_null($sites_array)) { $sites_array = array(); } //$this->table_builder->add_from_array ($sites_array); $data_rows_conut = sizeof($sites_array); //модификация контента отдельных столбцов (ссылки, чекбоксы) $code_channel = type_to_str($id_channel, 'textcode'); $page_total = array('revenue' => 0, 'impressions' => 0, 'alternative_impressions' => 0, 'clicks' => 0); // register additional per page statistic fields foreach ($this->_hooks as $hookObj) { $page_total = $hookObj->registerPerPageStatisticFields($page_total); } $pub_entity = NULL; for ($i = 0; $i < $data_rows_conut; $i++) { $pub_entity = $sites_array[$i]['pub_entity']; $page_total['impressions'] += $sites_array[$i]['impressions']; $page_total['alternative_impressions'] += $sites_array[$i]['alternative_impressions']; $page_total['clicks'] += $sites_array[$i]['clicks']; $page_total['revenue'] += $sites_array[$i]['revenue']; // calculate per page statistic for additional columns from plugins foreach ($this->_hooks as $hookObj) { $page_total = $hookObj->calculatePerPageStatistic($page_total, $sites_array[$i]); } $code_site = type_to_str($sites_array[$i]['id'], 'textcode'); if ('deleted' == $sites_array[$i]['status']) { $this->table_builder->set_cell_content($i + 1, $col_alias['chkboxes'], ''); $this->table_builder->set_cell_content($i + 1, $col_alias['action'], ''); $this->table_builder->add_row_attribute($i + 1, 'class', 'deleted_row'); } else { if ($sites_array[$i]['pub_entity'] == $this->user_id) { $this->table_builder->set_cell_content($i + 1, $col_alias['chkboxes'], array('name' => 'id_site[]', 'value' => $sites_array[$i]['id'], 'extra' => 'id=chk' . $i . ' onclick="checktr(\'chk' . $i . '\',\'tr' . ($i + 1) . '\')"'), 'checkbox'); $this->table_builder->set_cell_content($i + 1, $col_alias['action'], array('name' => __('Edit'), 'href' => $this->site_url . $this->index_page . $this->role . '/edit_site/index/' . $sites_array[$i]['id'], 'extra' => 'jframe="no" class="guibutton floatl ico ico-edit" value="{@Edit@}" title="{@Edit@}" onclick="top.location=\'' . $this->site_url . $this->index_page . $this->role . '/edit_site/index/' . $sites_array[$i]['id'] . '\'" target="_top"'), 'link'); $this->table_builder->cell($i + 1, $col_alias['action'])->add_content(array('name' => __('Get code'), 'href' => '#get_code', 'extra' => 'jframe="no" class="guibutton floatl ico ico-puzzle2" value="{@Get code@}" title="{@Get code@}" onclick="top.get_channel_code(\'' . $sites_array[$i]['id'] . '\',\'' . $id_channel . '\')"'), 'link', ' '); $this->table_builder->cell($i + 1, $col_alias['action'])->add_content(array('name' => __('Layout'), 'href' => $this->site_url . $this->index_page . $this->role . '/edit_site_channel_layout/index/' . $sites_array[$i]['id'], 'extra' => 'jframe="no" class="guibutton floatl ico ico-site-layout" value="{@Layout@}" title="{@Layout@}" onclick="top.location=\'' . $this->site_url . $this->index_page . $this->role . '/edit_site_channel_layout/index/' . $sites_array[$i]['id'] . '\'" target="_top"'), 'link', ''); } else { $this->table_builder->set_cell_content($i + 1, $col_alias['chkboxes'], ''); $this->table_builder->set_cell_content($i + 1, $col_alias['action'], ''); } $this->table_builder->cell($i + 1, $col_alias['action'])->add_content(array('name' => __('View Ads'), 'href' => '#view_ads', 'extra' => 'jframe="no" class="guibutton floatl ico ico-viewads" value="' . __("View Ads") . '" title="' . __("View Ads") . '" onclick="top.view_ads(\'' . $code_site . '\',\'' . $code_channel . '\')"'), 'link', ' '); $this->table_builder->add_row_attribute($i + 1, 'id', 'tr' . ($i + 1)); if ('paused' == $sites_array[$i]['status']) { $this->table_builder->add_row_attribute($i + 1, 'class', 'blocked_row'); } } $this->table_builder->set_cell_content($i + 1, $col_alias['id'], $sites_array[$i]['id']); $this->table_builder->set_cell_content($i + 1, $col_alias['name'], limit_str_and_hint($sites_array[$i]['name'], 30)); $this->table_builder->set_cell_content($i + 1, $col_alias['url'], array('name' => $sites_array[$i]['url'], 'href' => 'http://' . $sites_array[$i]['url'], 'extra' => 'target="_blank"'), 'link'); $this->table_builder->set_cell_content($i + 1, $col_alias['status'], __('site_' . $sites_array[$i]['status'])); $this->table_builder->set_cell_content($i + 1, $col_alias['impressions'], type_to_str($sites_array[$i]['impressions'], 'integer')); $this->table_builder->set_cell_content($i + 1, $col_alias['alternative_impressions'], type_to_str($sites_array[$i]['alternative_impressions'], 'integer')); $this->table_builder->set_cell_content($i + 1, $col_alias['clicks'], type_to_str($sites_array[$i]['clicks'], 'integer')); $this->table_builder->set_cell_content($i + 1, $col_alias['ctr'], type_to_str($sites_array[$i]['ctr'], 'float') . ' %'); $this->table_builder->set_cell_content($i + 1, $col_alias['revenue'], type_to_str($sites_array[$i]['revenue'], 'money')); //$this->table_builder->set_cell_content ( $i + 1, 9, type_to_str($sites_array [$i]['creation_date'], 'date')); // render additional columns from plugins foreach ($this->_hooks as $hookObj) { $hookObj->renderRow($i + 1, $col_alias, $sites_array[$i], $this->table_builder); } } //end модификация контента отдельных столбцов (ссылки, чекбоксы) if (0 == $data_rows_conut) { $this->table_builder->insert_empty_cells = false; $this->table_builder->set_cell_content(1, 0, __('Records not found')); $this->table_builder->cell(1, 0)->add_attribute('colspan', count($col_alias)); $this->table_builder->cell(1, 0)->add_attribute('class', 'nodata'); $this->table_builder->remove_col_attribute_value(0, 'class', 'chkbox'); $this->table_builder->cell(0, 0)->add_attribute('class', 'chkbox'); } else { $row = $data_rows_conut + 1; $this->table_builder->set_cell_content($row, $col_alias['name'], __("Page total")); //$this->table_builder->cell($row, 2)->add_attribute('colspan', 2); $this->table_builder->set_cell_content($row, $col_alias['impressions'], type_to_str($page_total['impressions'], 'integer')); $this->table_builder->set_cell_content($row, $col_alias['alternative_impressions'], type_to_str($page_total['alternative_impressions'], 'integer')); $this->table_builder->set_cell_content($row, $col_alias['clicks'], type_to_str($page_total['clicks'], 'integer')); $this->table_builder->set_cell_content($row, $col_alias['revenue'], type_to_str($page_total['revenue'], 'money')); $ctr = $page_total['impressions'] ? $page_total['clicks'] / $page_total['impressions'] * 100 : 0; $this->table_builder->set_cell_content($row, $col_alias['ctr'], type_to_str($ctr, 'procent')); $this->table_builder->clear_row_attributes($row); $this->table_builder->add_row_attribute($row, 'class', 'pagetotal'); // render per page statistic for additional columns from plugins foreach ($this->_hooks as $hookObj) { $hookObj->renderPageStatisticRow($row, $col_alias, $page_total, $this->table_builder); } $row++; $this->table_builder->set_cell_content($row, $col_alias['name'], __("Total")); //$this->table_builder->cell($row, 2)->add_attribute('colspan', 2); $this->table_builder->set_cell_content($row, $col_alias['impressions'], type_to_str($total['impressions'], 'integer')); $this->table_builder->set_cell_content($row, $col_alias['alternative_impressions'], type_to_str($total['alternative_impressions'], 'integer')); $this->table_builder->set_cell_content($row, $col_alias['clicks'], type_to_str($total['clicks'], 'integer')); $this->table_builder->set_cell_content($row, $col_alias['revenue'], type_to_str($total['revenue'], 'money')); $ctr = $total['impressions'] ? $total['clicks'] / $total['impressions'] * 100 : 0; $this->table_builder->set_cell_content($row, $col_alias['ctr'], type_to_str($ctr, 'procent')); $this->table_builder->clear_row_attributes($row); $this->table_builder->add_row_attribute($row, 'class', 'alltotal'); // render summary statistic for additional columns from plugins foreach ($this->_hooks as $hookObj) { $hookObj->renderSummaryRow($row, $col_alias, $total, $this->table_builder); } } // Устанавливаем возможность выбора колонок $this->table_builder->use_select_columns(); $invariable_columns = array($col_alias['chkboxes'], $col_alias['id'], $col_alias['url'], $col_alias['action']); $this->table_builder->set_invariable_columns($invariable_columns); //$this->table_builder->add_attribute ( 'class', 'xTable' ); //or set style here $table = $this->table_builder->get_sort_html(); $content = $this->parser->parse($this->views_paths['iframe_sites_list'], array('MESSAGE' => json_encode(array('message' => __($message))), 'SITES_TABLE' => $table, 'COLUMNS' => $this->table_builder->get_columns_html(), 'PAGINATION' => $pagination, 'ID_CHANNEL' => $id_channel, 'JFRAME_ACTION' => '<%SITEURL%><%INDEXPAGE%>' . $this->role . '/manage_sites_channels/get_sites/' . $id_channel . '/' . $date_from . '/' . $date_to . '/all'), TRUE); if ($pub_entity != $this->user_id) { $content = preg_replace("/\\<a name=\"chan_buttons_begin\"\\>\\<\\/a\\>[\\s\\S]*?\\<a name=\"chan_buttons_end\"\\>\\<\\/a\\>/", '', $content); } //$this->template = "common/parent/iframe.html"; $this->template = "common/parent/jq_iframe.html"; $this->_set_content($content); $this->_display(); }
/** * Callback-функция, устанавливает значения по умолчанию для фильтра таблицы * * @return array массив со значениями по умолчанию для фильтров */ public function _load($id) { if ($id == 'ads') { $fields = period_load('manadsads', 'select', 'alltime'); $fields['filt'] = $this->temporary['manadsads_filt']; } elseif ($id == 'channels') { $fields = period_load('manadschannels', 'select', 'alltime'); $fields['filt'] = $this->temporary['manadschannels_filt']; } else { $fields = period_load('manadssummary', 'select', 'alltime'); } $this->date_range = data_range($fields); return $fields; }
/** * Callback-функция, устанавливает значения по умолчанию для фильтров таблиц * * @return array массив со значениями по умолчанию для фильтров */ public function _load($id) { $fields = period_load($this->form_prefix . '_reqreports', 'select', 'alltime'); $this->date_range = data_range($fields); $fields['type_filt'] = $this->temporary[$this->form_prefix . '_reqreports_type_filt']; return $fields; }