Example #1
0
 /**
  * @see Sppc_Dashboard_Block_Interface::getContent
  *
  * @param Sppc_Dashboard_DateRange $range
  * @return string
  */
 public function getContent(Sppc_Dashboard_DateRange $range)
 {
     // Сохраняем range для callback функций
     $this->range = $range;
     // Подключаем библиотеку для работы с формами
     $this->CI->load->library('form');
     /* @var $formBuilder Form */
     $formBuilder =& $this->CI->form;
     // Название
     $className = get_class($this);
     // Строим массив данных для отображения через Form
     $form = array('name' => $className . '_form', 'view' => 'common/dashboard/datepicker.html', 'no_errors' => 'true', 'vars' => array('CLASS_NAME' => $className, 'DATEFILTER' => period_html($className)));
     // Добавляем в данные для отображения поля для DatePicker
     data_range_fields($form, $range->getUnixStartDate(), $range->getUnixEndDate());
     return $formBuilder->get_form_content('modify', $form, $this->CI->input, $this);
 }
Example #2
0
 /**
  * создание и вывод HTML-кода дашборда адвертайзера
  *
  * @return ничего не возвращает
  */
 public function index()
 {
     $this->load->model('advertisers', '', TRUE);
     $this->_set_title(__('Advertiser') . ' - ' . __('Dashboard'));
     $this->_set_help_index("advertiser_dashboard");
     $this->load->library("form");
     $this->load->helper('periods');
     $form = array('name' => 'advdashboard_form', 'view' => 'advertiser/dashboard/form.html', 'no_errors' => 'true', 'vars' => array('DATEFILTER' => period_html('advdashboard')));
     data_range_fields($form, 'select', 'today');
     $this->dashboard = array('BALLANCE' => type_to_str($this->entity->ballance($this->user_id), 'money'), 'TOTALSPENT' => '-', 'TOTALIMPRESSIONS' => '-', 'TOTALCLICKS' => '-', 'CTR' => '-', 'BONUS' => '', 'USE_BONUS' => array(), 'ADDITIONAL_PERFORMANCE_FIELDS' => array());
     $this->dashboard['FORM'] = $this->form->get_form_content('modify', $form, $this->input, $this);
     $this->dashboard['TABS'] = $this->_tabs();
     $this->dashboard['CAMPAIGNS'] = $this->_top_campaigns();
     $this->sppc_range = new Sppc_Dashboard_DateRange();
     $this->_set_content($this->parser->parse('advertiser/dashboard/template.html', $this->dashboard));
     $this->_display();
 }
 /**
  * создание и вывод HTML-кода для управления рекламодателями
  *
  * @return ничего не возвращает
  */
 public function index()
 {
     $this->_set_title(implode(self::TITLE_SEP, array(__('Admin'), __('Manage Advertisers'))));
     $this->_set_help_index("manage_advertisers");
     $this->load->library("form");
     $this->load->helper('periods');
     $form = array('name' => 'manageadvertisers_form', 'view' => 'admin/manage_advertisers/template.html', 'no_errors' => 'true', 'vars' => array('DATEFILTER' => period_html('manageadvertisers')), 'fields' => array('filt' => array('id_field_type' => 'string', 'form_field_type' => 'select', 'options' => array('all' => __('all'), 'active' => __('pl_active'), 'blocked' => __('pl_blocked'), 'deleted' => __('pl_deleted'), 'activation' => __('pl_unapproved'))), 'quicksearch' => array('id_field_type' => 'string', 'form_field_type' => 'text')));
     $this->load->library("Plugins", array('path' => array('admin', 'manage_advertisers_global'), 'interface' => 'Sppc_Admin_ManageAdvertisers_GlobalHandlerInterface'));
     $form['vars']['PLUGIN_JS_FUNCTIONS'] = implode($this->plugins->run('get_js_functions_html', $this));
     data_range_fields($form, 'select', 'today');
     $html = $this->form->get_form_content('modify', $form, $this->input, $this);
     $this->load->model('advertisers');
     $this->_actions($this->input->post('manageadvertisers_action'));
     $this->load->library('Table_Builder');
     $this->table_builder->clear();
     $this->table_builder->insert_empty_cells = true;
     $this->table_builder->init_sort_vars('manageadvertisers', 'id', 'asc');
     $this->load->model('pagination_post');
     $this->pagination_post->set_form_name('manageadvertisers');
     // All pages total
     $total = $this->advertisers->total($this->temporary['manageadvertisers_filt'], $this->range, $this->temporary['manageadvertisers_quicksearch']);
     $this->pagination_post->set_total_records($total['cnt']);
     $this->pagination_post->read_variables('manageadvertisers', 1, $this->global_variables->get('AdvertisersPerPage'));
     $list = $this->advertisers->get($this->temporary['manageadvertisers_page'], $this->temporary['manageadvertisers_per_page'], $this->table_builder->sort_field, $this->table_builder->sort_direction, $this->temporary['manageadvertisers_filt'], $this->range, $this->temporary['manageadvertisers_quicksearch']);
     $col_index = 0;
     $col_alias = array('checkAll' => $col_index++);
     $col_alias['id'] = $col_index++;
     $col_alias['name'] = $col_index++;
     $col_alias['e_mail'] = $col_index++;
     $col_alias['creation_date'] = $col_index++;
     $col_alias['status'] = $col_index++;
     $col_alias['ballance'] = $col_index++;
     $col_alias['impressions'] = $col_index++;
     $col_alias['clicks'] = $col_index++;
     $col_alias['ctr'] = $col_index++;
     $col_alias['spent'] = $col_index++;
     $col_alias['action'] = $col_index++;
     $this->load->library("Plugins", array('path' => array('admin', 'manage_advertisers'), 'interface' => 'Sppc_Admin_ManageAdvertisers_Interface'), 'coupons_plugin');
     $this->coupons_plugin->run('getAdditionalColumns', $col_alias);
     // register additional columns from plugins
     foreach ($this->_hooks as $hookObj) {
         $col_alias = $hookObj->extendColumnMap($col_alias);
     }
     $this->table_builder->set_cell_content(0, $col_alias['checkAll'], array('name' => 'checkAll', 'extra' => 'onclick="return select_all(\'manageadvertisers\', this)"'), 'checkbox');
     $this->table_builder->sorted_column($col_alias['id'], "id", "ID", "asc");
     $this->table_builder->sorted_column($col_alias['name'], "name", "Full Name", "asc");
     $this->table_builder->sorted_column($col_alias['e_mail'], "e_mail", "E-Mail", "asc");
     $this->table_builder->sorted_column($col_alias['creation_date'], "creation_date", "Join Date", "desc");
     $this->table_builder->sorted_column($col_alias['status'], "status", "Status", "asc");
     $this->table_builder->sorted_column($col_alias['ballance'], "ballance", "Ballance", "desc");
     $this->table_builder->sorted_column($col_alias['impressions'], "impressions", "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['spent'], "spent", "Spent", "desc");
     $this->table_builder->set_cell_content(0, $col_alias['action'], __("Action"));
     $this->table_builder->add_row_attribute(0, 'class', 'th');
     $this->coupons_plugin->run('getAdditionalFields', $this->table_builder);
     // create additional columns from plugins
     foreach ($this->_hooks as $hookObj) {
         $hookObj->createColumns($col_alias, $this->table_builder);
     }
     //прописывание стилей для ячеек
     $this->table_builder->add_col_attribute($col_alias['checkAll'], 'class', '"chkbox"');
     $this->table_builder->add_col_attribute($col_alias['id'], 'class', '"w20 chkbox"');
     $this->table_builder->add_col_attribute($col_alias['creation_date'], 'class', '"w100 center"');
     $this->table_builder->add_col_attribute($col_alias['status'], 'class', '"w100 center"');
     $this->table_builder->add_col_attribute($col_alias['ballance'], 'class', '"right"');
     $this->table_builder->add_col_attribute($col_alias['impressions'], 'class', '"right w100"');
     $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($col_alias['spent'], 'class', '"w50 right"');
     $this->table_builder->add_col_attribute($col_alias['action'], 'class', '"center nowrap"');
     // add styles for additional columns from plugins
     foreach ($this->_hooks as $hookObj) {
         $hookObj->defineColumnStyles($col_alias, $this->table_builder);
     }
     $this->table_builder->add_attribute('class', 'xTable');
     $this->coupons_plugin->run('setAdditionalStyle', $this->table_builder);
     // Page Total
     $page_total = array('balance' => 0, 'impressions' => 0, 'clicks' => 0, 'spent' => 0, 'bonus' => 0);
     // register additional per page statistic fields
     foreach ($this->_hooks as $hookObj) {
         $page_total = $hookObj->registerPerPageStatisticFields($page_total);
     }
     $row = 1;
     foreach ($list as $id_entity => $entity) {
         $code = type_to_str($id_entity, 'textcode');
         // Calc total values
         $page_total['balance'] += $entity['ballance'];
         $page_total['impressions'] += $entity['impressions'];
         $page_total['clicks'] += $entity['clicks'];
         $page_total['spent'] += $entity['spent'];
         $page_total['bonus'] += $entity['bonus'];
         // calculate per page statistic for additional columns from plugins
         foreach ($this->_hooks as $hookObj) {
             $page_total = $hookObj->calculatePerPageStatistic($page_total, $entity);
         }
         // checkbox
         $this->table_builder->set_cell_content($row, $col_alias['checkAll'], array('name' => 'id_entity[]', 'value' => $code, 'extra' => "id=chk{$row} onclick=\"checktr('chk{$row}','tr{$row}')\""), 'checkbox');
         // email
         $this->table_builder->set_cell_content($row, $col_alias['e_mail'], "{$entity['email']}");
         if ('deleted' != $entity['status']) {
             // actions
             $this->table_builder->set_cell_content($row, $col_alias['action'], array('name' => __('Edit'), 'href' => "#edit", 'extra' => "value=\"" . __('Edit') . "\" title=\"" . __('Edit') . "\" class='guibutton floatl mr3 ico ico-edit' onclick='edit(\"{$code}\");'"), 'link');
             $this->table_builder->cell($row, $col_alias['action'])->add_content(array('name' => __('Change Balance'), 'href' => "#balance", 'extra' => "value=\"" . __('Change Balance') . "\" title=\"" . __('Change Balance') . "\" class='guibutton floatl ico ico-money' onclick='balance(\"{$code}\");'"), 'link', ' ');
         }
         switch ($entity['status']) {
             case 'deleted':
                 $this->table_builder->add_row_attribute($row, 'class', "deleted_row");
                 break;
             case 'blocked':
                 $this->table_builder->add_row_attribute($row, 'class', "blocked_row");
                 break;
         }
         // id
         $this->table_builder->set_cell_content($row, $col_alias['id'], $id_entity);
         // name
         $this->table_builder->set_cell_content($row, $col_alias['name'], type_to_str($entity['name'], 'encode'));
         // registration date
         $this->table_builder->set_cell_content($row, $col_alias['creation_date'], type_to_str($entity['join_date'], 'date'));
         // status
         $this->table_builder->set_cell_content($row, $col_alias['status'], __('adv_' . $entity['status']));
         // ballance
         $this->table_builder->set_cell_content($row, $col_alias['ballance'], type_to_str($entity['ballance'], 'money'));
         // impressions
         $this->table_builder->set_cell_content($row, $col_alias['impressions'], type_to_str($entity['impressions'], 'integer'));
         // clicks
         $this->table_builder->set_cell_content($row, $col_alias['clicks'], type_to_str($entity['clicks'], 'integer'));
         // ctr
         $this->table_builder->set_cell_content($row, $col_alias['ctr'], type_to_str($entity['ctr'], 'float') . ' %');
         // spent
         $this->table_builder->set_cell_content($row, $col_alias['spent'], type_to_str($entity['spent'], 'money'));
         // render addtional columns from simple plugins
         $this->coupons_plugin->run('getAdditionalCellsContent', array('table' => &$this->table_builder, 'row' => $row, 'content' => type_to_str($entity['bonus'], 'money')));
         // render additional columns from plugins
         foreach ($this->_hooks as $hookObj) {
             $hookObj->renderRow($row, $col_alias, $entity, $this->table_builder);
         }
         $this->table_builder->add_row_attribute($row, 'id', "tr{$row}");
         $row++;
     }
     if (0 == count($list)) {
         $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 {
         // Display page total
         $this->table_builder->set_cell_content($row, $col_alias['name'], __("Page total"));
         $this->table_builder->set_cell_content($row, $col_alias['ballance'], type_to_str($page_total['balance'], 'money'));
         $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['clicks'], type_to_str($page_total['clicks'], 'integer'));
         $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, 'float') . ' %');
         $this->table_builder->set_cell_content($row, $col_alias['spent'], type_to_str($page_total['spent'], 'money'));
         $this->table_builder->clear_row_attributes($row);
         $this->table_builder->add_row_attribute($row, 'class', 'pagetotal');
         // render additional columns from simple plugins
         $this->coupons_plugin->run('getAdditionalCellsContent', array('table' => &$this->table_builder, 'row' => $row, 'content' => type_to_str($page_total['bonus'], 'money')));
         // 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++;
         // Display all pages total
         $this->table_builder->set_cell_content($row, $col_alias['name'], __("Total"));
         $this->table_builder->set_cell_content($row, $col_alias['ballance'], type_to_str($total['balance'], 'money'));
         $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['clicks'], type_to_str($total['clicks'], 'integer'));
         $ctr = $total['impressions'] ? $total['clicks'] / $total['impressions'] * 100 : 0;
         $this->table_builder->set_cell_content($row, $col_alias['ctr'], type_to_str($ctr, 'float') . ' %');
         $this->table_builder->set_cell_content($row, $col_alias['spent'], type_to_str($total['spent'], 'money'));
         $this->table_builder->clear_row_attributes($row);
         $this->table_builder->add_row_attribute($row, 'class', 'alltotal');
         // render additional columns from simple plugins
         $this->coupons_plugin->run('getAdditionalCellsContent', array('table' => &$this->table_builder, 'row' => $row, 'content' => type_to_str($total['bonus'], 'money')));
         // 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['id'], $col_alias['name'], $col_alias['e_mail'], $col_alias['action']);
     $this->table_builder->set_invariable_columns($invariable_columns);
     $html = str_replace('<%ADVERTISERS%>', $this->table_builder->get_sort_html(), $html);
     $html = str_replace('<%PAGINATION%>', $this->pagination_post->create_form(), $html);
     $buttons = $this->load->view('admin/manage_advertisers/buttons.html', '', TRUE);
     $html = str_replace('<%BUTTONST%>', str_replace('<%ID%>', 'top_', $buttons), $html);
     $html = str_replace('<%BUTTONSB%>', str_replace('<%ID%>', 'bottom_', $buttons), $html);
     $html = str_replace('<%COLUMNS%>', $this->table_builder->get_columns_html(), $html);
     $this->_set_content($html);
     $this->_display();
 }
 /**
  * функция вызываемая по умолчанию, выводит таблицу кампаний
  *
  * @param integer $id_campaign уникальный код кампании, содержащей группы объявлений
  * @return ничего не возвращает
  */
 public function index($code_campaign)
 {
     $this->id_campaign = type_cast($code_campaign, 'textcode');
     $this->load->library('form');
     $this->load->helper('periods');
     $form = array('id' => 'groups', 'name' => 'manadsgroups_form', 'view' => 'advertiser/manage_ads/groups/table.html', 'redirect' => 'advertiser/manage_ads', 'no_errors' => 'true', 'vars' => array('DATEFILTER' => period_html('manadsgroups')), 'fields' => array('filt' => array('id_field_type' => 'string', 'form_field_type' => 'select', 'options' => array('all' => __('all'), 'active' => __('pl_active'), 'paused' => __('pl_paused')))));
     data_range_fields($form, 'select', 'alltime');
     $html = $this->form->get_form_content('modify', $form, $this->input, $this);
     $this->load->model('groups');
     $this->_actions($this->input->post('manadsgroups_action'));
     $this->load->library('Table_Builder');
     $this->table_builder->clear();
     $this->table_builder->insert_empty_cells = true;
     $this->table_builder->init_sort_vars('manadsgroups', 'id_campaign', 'asc');
     $this->load->model('pagination_post');
     $this->pagination_post->set_form_name('manadsgroups');
     $total_function = 'total';
     $total = $this->groups->{$total_function}($this->id_campaign, $this->temporary['manadsgroups_filt'], $this->date_range);
     $this->pagination_post->set_total_records($total['cnt']);
     $this->pagination_post->read_variables('manadsgroups', 1, $this->global_variables->get('GroupsPerPage'));
     $select_function = 'select';
     $groups = $this->groups->{$select_function}($this->id_campaign, $this->temporary['manadsgroups_page'], $this->temporary['manadsgroups_per_page'], $this->table_builder->sort_field, $this->table_builder->sort_direction, $this->temporary['manadsgroups_filt'], $this->date_range);
     $row = 0;
     //build column map
     $colIndex = 0;
     $colMap = array('chkbox' => $colIndex++, 'id' => $colIndex++, 'name' => $colIndex++, 'status' => $colIndex++, 'ads' => $colIndex++, 'siteChannels' => $colIndex++, 'spent' => $colIndex++, 'impressions' => $colIndex++, 'clicks' => $colIndex++, 'ctr' => $colIndex++, 'action' => $colIndex++);
     // register additional columns from plugins
     foreach ($this->_hooks as $hookObj) {
         $colMap = $hookObj->extendColumnMap($colMap);
     }
     // create columns
     $this->table_builder->set_cell_content($row, $colMap['chkbox'], array('name' => 'checkAll', 'extra' => 'onclick="return select_all(\'manadsgroups\', this)"'), 'checkbox');
     $this->table_builder->sorted_column($colMap['id'], "id_group", "ID", "asc");
     $this->table_builder->sorted_column($colMap['name'], "name", "Group Name", "asc");
     $this->table_builder->sorted_column($colMap['status'], "status", "Current Status", "asc");
     $this->table_builder->sorted_column($colMap['ads'], "ads", "Ads", "desc");
     $col_name = "Sites/Channels";
     $this->table_builder->sorted_column($colMap['siteChannels'], "site_channels", $col_name, "desc");
     $this->table_builder->set_cell_content($row, $colMap['spent'], __("Spent"));
     $this->table_builder->set_cell_content($row, $colMap['impressions'], __("Impressions"));
     $this->table_builder->set_cell_content($row, $colMap['clicks'], __("Clicks"));
     $this->table_builder->set_cell_content($row, $colMap['ctr'], __("CTR"));
     $this->table_builder->set_cell_content($row, $colMap['action'], __('Action'));
     // create additional columns from plugins
     foreach ($this->_hooks as $hookObj) {
         $hookObj->createColumns($colMap, $this->table_builder);
     }
     $this->table_builder->add_row_attribute($row, 'class', 'th');
     //прописывание стилей для ячеек
     $this->table_builder->add_col_attribute($colMap['chkbox'], 'class', '"chkbox"');
     $this->table_builder->add_col_attribute($colMap['id'], 'class', '"w20"');
     $this->table_builder->add_col_attribute($colMap['status'], 'class', '"w100  center"');
     $this->table_builder->add_col_attribute($colMap['ads'], 'class', '"w50   right"');
     $this->table_builder->add_col_attribute($colMap['siteChannels'], 'class', '"w100   right"');
     $this->table_builder->add_col_attribute($colMap['spent'], 'class', '"w100  right"');
     $this->table_builder->add_col_attribute($colMap['impressions'], 'class', '"w100   right"');
     $this->table_builder->add_col_attribute($colMap['clicks'], 'class', '"w50   right"');
     $this->table_builder->add_col_attribute($colMap['ctr'], 'class', '"w50   right"');
     $this->table_builder->add_col_attribute($colMap['action'], 'class', '"nowrap center"');
     // add styles for additional columns from plugins
     foreach ($this->_hooks as $hookObj) {
         $hookObj->defineColumnStyles($colMap, $this->table_builder);
     }
     $this->table_builder->add_attribute('class', 'xTable');
     $clone_icon = __('Edit');
     $row++;
     $page_total = array('ads' => 0, 'sites_channels' => 0, 'spent' => 0, 'impressions' => 0, 'clicks' => 0);
     // register additional per page statistic fields
     foreach ($this->_hooks as $hookObj) {
         $page_total = $hookObj->registerPerPageStatisticFields($page_total);
     }
     foreach ($groups as $id_group => $group) {
         // calculate per page statistic
         $page_total['ads'] += $group['ads'];
         $page_total['sites_channels'] += $group['site_channels'];
         $page_total['spent'] += $group['spent'];
         $page_total['impressions'] += $group['impressions'];
         $page_total['clicks'] += $group['clicks'];
         // calculate per page statistic for additional columns from plugins
         foreach ($this->_hooks as $hookObj) {
             $page_total = $hookObj->calculatePerPageStatistic($page_total, $group);
         }
         $code = type_to_str($id_group, 'textcode');
         // checkbox
         $this->table_builder->set_cell_content($row, $colMap['chkbox'], array('name' => 'id_groups[]', 'value' => $code, 'extra' => "id=chk{$row} onclick=\"checktr('chk{$row}','tr{$row}')\""), 'checkbox');
         // id
         $this->table_builder->set_cell_content($row, $colMap['id'], $id_group);
         // name
         $this->table_builder->set_cell_content($row, $colMap['name'], array('name' => limit_str_and_hint($group['name'], 30), 'href' => "#select_group", 'extra' => "jframe='no' onclick='return top.show_ads(\"{$code}\",\"\");'"), 'link');
         // status
         $this->table_builder->set_cell_content($row, $colMap['status'], __('grp_' . $group['status']));
         // ads
         $this->table_builder->set_cell_content($row, $colMap['ads'], array('name' => type_to_str($group['ads'], 'integer'), 'href' => "#select_ads", 'extra' => "jframe='no' onclick='return top.show_ads(\"{$code}\", \"ads\");'"), 'link');
         // site/channels
         $this->table_builder->set_cell_content($row, $colMap['siteChannels'], array('name' => type_to_str($group['site_channels'], 'integer'), 'href' => "#select_sitechannels", 'extra' => "jframe='no' onclick='return top.show_ads(\"{$code}\", \"channels\");'"), 'link');
         // spent
         $this->table_builder->set_cell_content($row, $colMap['spent'], type_to_str($group['spent'], 'money'));
         // impressions
         $this->table_builder->set_cell_content($row, $colMap['impressions'], type_to_str($group['impressions'], 'integer'));
         // clicks
         $this->table_builder->set_cell_content($row, $colMap['clicks'], type_to_str($group['clicks'], 'integer'));
         // ctr
         $this->table_builder->set_cell_content($row, $colMap['ctr'], type_to_str($group['ctr'], 'procent'));
         // action
         $this->table_builder->set_cell_content($row, $colMap['action'], array('name' => $clone_icon, 'href' => "#edit_group", 'extra' => "jframe='no' class='guibutton floatl ico ico-edit' value='{$clone_icon}' title='{$clone_icon}' onclick='top.editGroup(\"{$code_campaign}\",\"{$code}\");'"), 'link');
         // render additional columns from plugins
         foreach ($this->_hooks as $hookObj) {
             $hookObj->renderRow($row, $colMap, $group, $this->table_builder);
         }
         // add id attribute to the table row
         $this->table_builder->add_row_attribute($row, 'id', "tr{$row}");
         $row++;
     }
     if (0 == count($groups)) {
         $this->table_builder->insert_empty_cells = false;
         $this->table_builder->set_cell_content($row, 0, '&nbsp;&nbsp;' . __('Records not found'));
         $this->table_builder->cell($row, 0)->add_attribute('class', 'nodata');
         $this->table_builder->cell($row, 0)->add_attribute('colspan', count($colMap));
     } else {
         // render per page statistic row
         $this->table_builder->set_cell_content($row, $colMap['name'], __("Page total"));
         $this->table_builder->set_cell_content($row, $colMap['ads'], type_to_str($page_total['ads'], 'integer'));
         $this->table_builder->set_cell_content($row, $colMap['siteChannels'], type_to_str($page_total['sites_channels'], 'integer'));
         $this->table_builder->set_cell_content($row, $colMap['spent'], type_to_str($page_total['spent'], 'money'));
         $this->table_builder->set_cell_content($row, $colMap['impressions'], type_to_str($page_total['impressions'], 'integer'));
         $this->table_builder->set_cell_content($row, $colMap['clicks'], type_to_str($page_total['clicks'], 'integer'));
         $ctr = $page_total['impressions'] ? $page_total['clicks'] / $page_total['impressions'] * 100 : 0;
         $this->table_builder->set_cell_content($row, $colMap['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, $colMap, $page_total, $this->table_builder);
         }
         // render summary statistic row
         $row++;
         $this->table_builder->set_cell_content($row, $colMap['name'], __("Total"));
         $this->table_builder->set_cell_content($row, $colMap['ads'], type_to_str($total['ads'], 'integer'));
         $this->table_builder->set_cell_content($row, $colMap['siteChannels'], type_to_str($total['site_channels'], 'integer'));
         $this->table_builder->set_cell_content($row, $colMap['spent'], type_to_str($total['spent'], 'money'));
         $this->table_builder->set_cell_content($row, $colMap['impressions'], type_to_str($total['impressions'], 'integer'));
         $this->table_builder->set_cell_content($row, $colMap['clicks'], type_to_str($total['clicks'], 'integer'));
         $ctr = $total['impressions'] ? $total['clicks'] / $total['impressions'] * 100 : 0;
         $this->table_builder->set_cell_content($row, $colMap['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, $colMap, $total, $this->table_builder);
         }
     }
     // Устанавливаем возможность выбора колонок
     $this->table_builder->use_select_columns();
     $invariable_columns = array($colMap['id'], $colMap['name'], $colMap['action']);
     $this->table_builder->set_invariable_columns($invariable_columns);
     $html = str_replace('<%GROUPS%>', $this->table_builder->get_sort_html(), $html);
     $html = str_replace('<%PAGINATION%>', $this->pagination_post->create_form(), $html);
     $buttons = $this->load->view('advertiser/manage_ads/groups/buttons.html', '', TRUE);
     $buttons = str_replace('<%CAMPAIGN%>', $code_campaign, $buttons);
     $html = str_replace('<%BUTTONST%>', str_replace('<%ID%>', 'top_', $buttons), $html);
     $html = str_replace('<%BUTTONSB%>', str_replace('<%ID%>', 'bottom_', $buttons), $html);
     $html = str_replace('<%COLUMNS%>', $this->table_builder->get_columns_html(), $html);
     $this->_set_content($html);
     $this->_display();
 }
 protected function show_list($active_tab)
 {
     // Add plugins to hook
     $this->add_plugins($active_tab);
     $pluginsConfig = Zend_Registry::getInstance()->get('pluginsConfig');
     $hookObjects = array();
     if (isset($pluginsConfig->common->manage_site_channels)) {
         foreach ($pluginsConfig->common->manage_site_channels as $hookClass) {
             $hookObject = new $hookClass();
             if ($hookObject instanceof Sppc_Common_ManageSiteChannels_Interface) {
                 $hookObjects[] = $hookObject;
             }
         }
     }
     $additionalButtons = '';
     $additionalJSSiteButtons = '';
     foreach ($hookObjects as $hookObject) {
         $additionalButtons .= $hookObject->registerAdditionalButtons();
         $additionalJSSiteButtons .= $hookObject->registerJSSiteButtons(array($this, $this->role));
     }
     //режим фильтрации по статусу сайта/канала
     $status_filter = $this->input->post('status_filter');
     if (!$status_filter) {
         $status_filter = $this->temporary['manage_sites_channels_status_filter'];
     }
     $this->temporary['manage_sites_channels_status_filter'] = $status_filter;
     $quicksearch = $this->input->post('quicksearch');
     if (false === $quicksearch) {
         $quicksearch = $this->temporary['manage_sites_channels_quicksearch'];
     }
     $this->temporary['manage_sites_channels_quicksearch'] = $quicksearch;
     $form = array('id' => 'sites_channels', 'view' => $this->views_paths['body'], 'redirect' => $this->role . '/manage_sites_channels', 'vars' => array('DATEFILTER' => period_html('manage_sites_channels'), 'ADDITIONAL_BUTTONS' => $additionalButtons, 'ADDITIONAL_JS_SITE_BUTTONS' => $additionalJSSiteButtons, 'QUICK_SEARCH_FIELDS' => ''), 'fields' => array('status_filter' => array('id_field_type' => 'string', 'form_field_type' => 'select', 'options' => array('all' => __('all'), 'active' => __('pl_active'), 'paused' => __('pl_blocked'), 'deleted' => __('pl_deleted')), 'default' => $status_filter), 'quicksearch' => array('id_field_type' => 'string', 'form_field_type' => 'text', 'default' => $quicksearch)));
     if ($this->role == 'publisher') {
         $form['kill'] = array('owner');
     }
     data_range_fields($form, $this->temporary['manage_sites_channels_from'], $this->temporary['manage_sites_channels_to']);
     /*switch ($active_tab) {
       	case 'sites_to_channels': //Вкладка сайтов:
       */
     $quickSearchFields = array(__('ID'), __('Title'), __('Site URL'));
     $form['vars']['QUICK_SEARCH_FIELDS'] = implode(', ', $quickSearchFields);
     $form['vars']['TYPE'] = 'sites';
     $form['name'] = 'manage_sites_form';
     $html = $this->form->get_form_content('modify', $form, $this->input, $this);
     $this->pagination_post->clear();
     $this->pagination_post->set_form_name('manage_sites');
     $total_params = array('status' => $status_filter, 'date_filter' => $this->date_range, 'revenue_field' => $this->revenue_field, 'id_entity' => $this->user_id, 'quicksearch' => $quicksearch);
     $total = $this->site->get_count($total_params);
     $this->pagination_post->set_total_records($total['count']);
     $this->pagination_post->read_variables('manage_sites', 1, 10);
     //настройка параметров разбиения на страницы
     $pagination = $this->pagination_post->create_form();
     $col_index = 0;
     $col_alias = array('chkboxes' => $col_index++, 'togglers' => $col_index++, 'id' => $col_index++);
     $col_alias['url'] = $col_index++;
     $col_alias['name'] = $col_index++;
     $col_alias['status'] = $col_index++;
     $col_alias['impressions'] = $col_index++;
     $col_alias['alternative_impressions'] = $col_index++;
     $col_alias['clicks'] = $col_index++;
     $col_alias['ctr'] = $col_index++;
     $col_alias['revenue'] = $col_index++;
     $col_alias['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', 'id', 'desc');
     $this->table_builder->sorted_column($col_alias['id'], 'id', 'ID', 'asc');
     $this->table_builder->sorted_column($col_alias['name'], 'sites.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->set_cell_content(0, $col_alias['chkboxes'], array('name' => 'checkAll', 'extra' => 'onclick="return select_all(\'manage_sites_channels\', this)"'), 'checkbox');
     $this->table_builder->set_cell_content(0, $col_alias['togglers'], '&nbsp');
     $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['togglers'])->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['togglers'], 'class', '"chkbox"');
     $this->table_builder->add_col_attribute($col_alias['id'], 'class', '"w20"');
     $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 nowrap"');
     $this->table_builder->add_col_attribute($col_alias['revenue'], 'class', '"w100 center"');
     $this->table_builder->add_col_attribute($col_alias['action'], 'class', '"center nowrap"');
     // 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
     // Устанавливаем возможность выбора колонок
     $this->table_builder->use_select_columns();
     $invariable_columns = array($col_alias['togglers'], $col_alias['id'], $col_alias['url'], $col_alias['action']);
     $this->table_builder->set_invariable_columns($invariable_columns);
     //$periods = period_load('manage_sites_channels', 'select', 'alltime');
     $params = array('fields' => 'sites.id_site as id, sites.name, ' . 'sites.url, sites.status, SUM(stat_sites.impressions) as impressions, ' . 'SUM(stat_sites.alternative_impressions) as alternative_impressions, ' . 'SUM(stat_sites.clicks) as clicks, (SUM(stat_sites.clicks)/SUM(stat_sites.impressions)*100) ' . 'as ctr, SUM(' . $this->revenue_field . ') as revenue, UNIX_TIMESTAMP(sites.creation_date) ' . 'as creation_date, e.name AS pub_name, e.e_mail, e.id_entity AS pub_entity', 'order_by' => $this->table_builder->sort_field, 'order_direction' => $this->table_builder->sort_direction, 'status' => $status_filter, 'offset' => ($this->pagination_post->get_page() - 1) * $this->pagination_post->get_per_page(), 'limit' => $this->pagination_post->get_per_page(), 'date_filter' => $this->date_range, 'id_entity' => $this->user_id, 'quicksearch' => $quicksearch);
     // Add addtional fields to $params['fields']
     foreach ($this->_hooks as $hookObj) {
         if (method_exists($hookObj, 'extendColumnQueryFields')) {
             $params = $hookObj->extendColumnQueryFields($params);
         }
     }
     $sites_array = $this->site->get_list($params);
     if (is_null($sites_array)) {
         $sites_array = array();
     }
     //$this->table_builder->add_from_array ($sites_array);
     $data_rows_conut = sizeof($sites_array);
     $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);
     }
     //модификация контента отдельных столбцов (ссылки, чекбоксы)
     for ($i = 0; $i < $data_rows_conut; $i++) {
         $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]);
         }
         $this->table_builder->set_cell_content($i + 1, $col_alias['id'], $sites_array[$i]['id']);
         $code = type_to_str($sites_array[$i]['pub_entity'], 'textcode');
         $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');
         if ($sites_array[$i]['status'] == 'unapproved' && $sites_array[$i]['pub_entity'] == $this->user_id) {
             $this->table_builder->set_cell_content($i + 1, $col_alias['status'], array('name' => __('site_' . $sites_array[$i]['status']), 'extra' => ' class="red" value="' . __('site_' . $sites_array[$i]['status']) . '" title="' . __('Verify') . '" onclick="top.location=\'' . $this->site_url . $this->index_page . $this->role . '/approve_site/index/' . $sites_array[$i]['id'] . '\';"', 'href' => $this->site_url . $this->index_page . $this->role . '/approve_site/index/' . $sites_array[$i]['id']), 'link', '');
         } else {
             $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'], 'procent'));
         $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, 10, type_to_str($sites_array [$i] ['creation_date'], 'date'));
         if ('deleted' == $sites_array[$i]['status']) {
             $this->table_builder->set_cell_content($i + 1, $col_alias['action'], '');
             $this->table_builder->set_cell_content($i + 1, $col_alias['chkboxes'], '');
             $this->table_builder->set_cell_content($i + 1, $col_alias['togglers'], '');
             $this->table_builder->add_row_attribute($i + 1, 'class', 'deleted_row');
         } else {
             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['togglers'], array('src' => $this->site_url . 'images/pixel.gif', 'onclick' => 'ShowChannelsBySite(' . $sites_array[$i]['id'] . ',this)', 'extra' => 'class="plus"'), 'image');
             if ($sites_array[$i]['pub_entity'] == $this->user_id) {
                 $this->table_builder->set_cell_content($i + 1, $col_alias['action'], array('name' => '{@Create Channel@}', 'extra' => ' class="guibutton floatl mr3 mb3 ico ico-plusgreen" value="{@Create Channel@}" title="{@Create Channel@}" onclick="top.create_channel_for_site(' . $sites_array[$i]['id'] . ');" ', 'href' => '#'), 'link');
                 foreach ($hookObjects as $hookObject) {
                     $hookObject->registerAdditionalSiteButtons($this->table_builder->cell($i + 1, $col_alias['action']), $sites_array[$i]['id']);
                 }
                 $this->table_builder->cell($i + 1, $col_alias['action'])->add_content(array('name' => '{@Edit@}', 'extra' => ' class="guibutton floatl mr3 mb3 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'] . '\'" ', 'href' => $this->site_url . $this->index_page . $this->role . '/edit_site/index/' . $sites_array[$i]['id']), 'link', ' ');
                 $this->table_builder->cell($i + 1, $col_alias['action'])->add_content(array('name' => '{@Layout@}', 'extra' => ' class="guibutton floatl mr3 mb3 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'] . '\'" ', 'href' => $this->site_url . $this->index_page . $this->role . '/edit_site_channel_layout/index/' . $sites_array[$i]['id']), 'link', ' ');
             } else {
                 $this->table_builder->set_cell_content($i + 1, $col_alias['action'], array('name' => __('Login As'), 'href' => "#login_as", 'extra' => "value=\"" . __('Login As') . "\" title=\"" . __('Login As') . "\" class='guibutton floatl ico ico-user' onclick='loginAs(\"{$code}\");'"), 'link', ' ');
             }
             $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->add_row_attribute($i + 1, 'id', 'tr' . ($i + 1));
         // render additional columns from plugins
         foreach ($this->_hooks as $hookObj) {
             $hookObj->renderRow($i + 1, $col_alias, $sites_array[$i], $this->table_builder);
         }
     }
     // for($i = 0; $i < $data_rows_conut; $i ++), модификация контента отдельных столбцов (ссылки, чекбоксы)
     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->remove_col_attribute_value(0, 'class', 'chkbox');
         $this->table_builder->cell(0, 0)->add_attribute('class', 'chkbox');
         $this->table_builder->cell(1, 0)->add_attribute('class', 'nodata');
     } else {
         $row = $data_rows_conut + 1;
         $this->table_builder->set_cell_content($row, $col_alias['url'], __("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['url'], __("Total"));
         $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);
         }
     }
     $table = $this->table_builder->get_sort_html();
     $columns = $this->table_builder->get_columns_html();
     $tab_content = $this->parser->parse($this->views_paths['sites_list'], array('PAGINATION' => $pagination, 'SITES_TABLE' => $table, 'COLUMNS' => $columns), TRUE);
     /*	break;
        }*/
     $html = str_replace('<%SITES_TAB_SELECTED%>', $active_tab == 'sites_to_channels' ? 'class="sel"' : '', $html);
     $html = str_replace('<%TABS%>', $tab_content, $html);
     $html = str_replace('<%PERIOD_BEGIN%>', $this->date_range['from'], $html);
     $html = str_replace('<%PERIOD_END%>', $this->date_range['to'], $html);
     $this->_set_content($html);
     $this->_display();
 }
 /**
  * выводит итоговую таблицу
  *
  * @return string HTML-код тоговой таблицы
  */
 public function summary()
 {
     $this->load->library('form');
     $this->load->helper('periods');
     $additionalButtons = '';
     $form = array('id' => 'summary', 'name' => 'manadssummary_form', 'view' => 'advertiser/manage_ads/ads/summary.html', 'redirect' => 'advertiser/manage_ads', 'no_errors' => 'true', 'action' => $this->site_url . $this->index_page . "advertiser/manage_ads_ads/index/" . type_to_str($this->id_group, 'textcode'), 'vars' => array('DATEFILTER' => period_html('manadssummary'), 'EDITNAME' => __('Manage Channels'), 'EDITFUNCTION' => 'editChannels', 'CPCBIDS' => '', 'ADDITIONAL_BUTTONS' => $additionalButtons));
     data_range_fields($form, 'select', 'alltime');
     $html = $this->form->get_form_content('modify', $form, $this->input, $this);
     $this->load->model('groups');
     $this->load->library('Table_Builder');
     $this->table_builder->clear();
     $summary = $this->groups->summary($this->id_group, $this->date_range);
     $col = 0;
     $cols['type'] = array('index' => $col++, 'name' => '');
     $cols['ads'] = array('index' => $col++, 'name' => 'Ads', 'class' => '"w100 right"');
     $col_name = __('Sites/Channels');
     $cols['sites'] = array('index' => $col++, 'name' => $col_name, 'class' => '"w100 right"');
     $cols['spent'] = array('index' => $col++, 'name' => 'Spent', 'class' => '"w100 right"');
     $cols['clicks'] = array('index' => $col++, 'name' => 'Clicks', 'class' => '"w100 right"');
     $cols['impressions'] = array('index' => $col++, 'name' => 'Impressions', 'class' => '"w100 right"');
     $cols['ctr'] = array('index' => $col++, 'name' => 'CTR', 'class' => '"w100 right"');
     foreach ($cols as $data) {
         $this->table_builder->set_cell_content(0, $data['index'], __($data['name']));
         if (isset($data['class'])) {
             $this->table_builder->add_col_attribute($data['index'], 'class', $data['class']);
         }
     }
     $this->table_builder->add_row_attribute(0, 'class', 'th');
     $this->table_builder->add_attribute('class', 'xTable');
     $row = 1;
     $sites_text = type_to_str($summary['site_channels'], 'integer') . ' ' . __('Selected Sites');
     $summary_other = array();
     $this->table_builder->set_cell_content($row, $cols['type']['index'], __('Total'));
     $this->table_builder->set_cell_content($row, $cols['ads']['index'], array('name' => type_to_str($summary['ads'], 'integer'), 'href' => "#select_ads", 'extra' => "jframe='no' onclick='\$(\"#tab_ads\").click(); return false;'"), 'link');
     $this->table_builder->set_cell_content($row, $cols['sites']['index'], array('name' => type_to_str($summary['site_channels'], 'integer'), 'href' => "#select_channels", 'extra' => "jframe='no' onclick='\$(\"#tab_channels\").click(); return false;'"), 'link');
     $this->table_builder->set_cell_content($row, $cols['spent']['index'], type_to_str($summary['spent'], 'money'));
     $this->table_builder->set_cell_content($row, $cols['clicks']['index'], type_to_str($summary['clicks'], 'integer'));
     $this->table_builder->set_cell_content($row, $cols['impressions']['index'], type_to_str($summary['impressions'], 'integer'));
     $this->table_builder->set_cell_content($row, $cols['ctr']['index'], type_to_str($summary['ctr'], 'procent'));
     $html = str_replace('<%GROUP%>', "'" . type_to_str($this->id_group, 'textcode') . "'", $html);
     return str_replace('<%SUMMARY%>', $this->table_builder->get_html(), $html);
 }
 /**
  * возвращает HTML-код таблицы со списком запрошенных отчетов
  *
  * @return string HTML-код таблицы со списком запрошенных отчетов
  */
 protected function _report_table()
 {
     $form = array('id' => 'reports', 'name' => $this->form_prefix . '_reqreports_form', 'view' => 'common/reports_center/table.html', 'redirect' => $this->after_create_controller, 'no_errors' => 'true', 'vars' => array('DATEFILTER' => period_html($this->form_prefix . '_reqreports'), 'VIEW_REPORT_CONTROLLER' => $this->site_url . $this->index_page . $this->view_report_controller, 'VIEW_FROM_CONTROLLER' => $this->view_report_from_controller, 'MENUITEM' => $this->menu_item, 'FORM_PREFIX' => $this->form_prefix), 'fields' => array('type_filt' => array('id_field_type' => 'string', 'form_field_type' => 'select', 'options' => 'report_types', 'params' => array('group' => $this->report_group, 'role' => $this->role, 'all' => TRUE))));
     data_range_fields($form, 'select', 'alltime');
     $html = $this->form->get_form_content('modify', $form, $this->input, $this);
     $this->load->model('report_types');
     $this->_action_reports($this->input->post($this->form_prefix . '_reqreports_action'));
     $this->load->library('Table_Builder');
     $this->table_builder->clear();
     $this->table_builder->insert_empty_cells = false;
     $this->table_builder->init_sort_vars($this->form_prefix . '_reqreports', 'request_date', 'desc');
     $this->load->model('pagination_post');
     $this->pagination_post->set_form_name($this->form_prefix . '_reqreports');
     $this->pagination_post->set_total_records($this->report_types->total($this->user_id, $this->date_range, $this->role, $this->temporary[$this->form_prefix . '_reqreports_type_filt'], $this->report_group));
     $this->pagination_post->read_variables($this->form_prefix . '_reqreports', 1, $this->global_variables->get('ReportsPerPage'));
     $reports = $this->report_types->get_reports($this->user_id, $this->temporary[$this->form_prefix . '_reqreports_page'], $this->temporary[$this->form_prefix . '_reqreports_per_page'], $this->table_builder->sort_field, $this->table_builder->sort_direction, $this->date_range, $this->role, $this->temporary[$this->form_prefix . '_reqreports_type_filt'], $this->report_group);
     $col_index = 0;
     $col_alias = array('checkboxes' => $col_index++, 'id_report' => $col_index++, 'custom_title' => $col_index++, 'title' => $col_index++);
     $col_alias['date'] = $col_index++;
     if ($this->display_actions_in_table) {
         $col_alias['action'] = $col_index++;
     }
     $this->table_builder->set_cell_content(0, $col_alias['checkboxes'], array('name' => 'checkAll', 'extra' => 'onclick="return select_all(\'' . $this->form_prefix . '_reqreports\', this)"'), 'checkbox');
     $this->table_builder->sorted_column($col_alias['id_report'], "id_requested_report", "ID", "asc");
     $this->table_builder->sorted_column($col_alias['custom_title'], "custom_title", "Report Name", "asc");
     $this->table_builder->sorted_column($col_alias['title'], "title", "Report Type", "asc");
     $this->table_builder->sorted_column($col_alias['date'], "request_date", "Created", "desc");
     if ($this->display_actions_in_table) {
         $this->table_builder->set_cell_content(0, $col_alias['action'], __('Action'));
     }
     $this->table_builder->add_row_attribute(0, 'class', 'th');
     //прописывание стилей для ячеек
     $this->table_builder->add_col_attribute($col_alias['checkboxes'], 'class', '"chkbox"');
     $this->table_builder->add_col_attribute($col_alias['id_report'], 'class', '"w20"');
     $this->table_builder->add_col_attribute($col_alias['date'], 'class', '"center w100"');
     if ($this->display_actions_in_table) {
         $this->table_builder->add_col_attribute($col_alias['action'], 'class', '"center nowrap"');
     }
     // Устанавливаем возможность выбора колонок
     $this->table_builder->use_select_columns();
     $invariable_columns = array($col_alias['id_report'], $col_alias['custom_title']);
     if ($this->display_actions_in_table) {
         $invariable_columns[] = $col_alias['action'];
     }
     $this->table_builder->set_invariable_columns($invariable_columns);
     $this->table_builder->add_attribute('class', 'xTable');
     $clone_icon = __('Clone');
     $row = 1;
     foreach ($reports as $id_report => $report) {
         $code = type_to_str($id_report, 'textcode');
         $this->table_builder->set_cell_content($row, $col_alias['checkboxes'], array('name' => 'id_report[]', 'value' => $code, 'extra' => "id=chk{$row} onclick=\"checktr('chk{$row}','tr{$row}')\""), 'checkbox');
         $this->table_builder->set_cell_content($row, $col_alias['id_report'], $id_report);
         $this->table_builder->set_cell_content($row, $col_alias['custom_title'], array('name' => type_to_str($report['title'], 'encode'), 'href' => "#view_report", 'extra' => "onclick='viewReport(\"{$code}\"); return false;'"), 'link');
         $this->table_builder->set_cell_content($row, $col_alias['title'], $report['type']);
         $this->table_builder->set_cell_content($row, $col_alias['date'], $report['date']);
         if ($this->display_actions_in_table) {
             $this->table_builder->set_cell_content($row, $col_alias['action'], array('name' => $clone_icon, 'href' => "#create_report", 'extra' => "class='guibutton floatl ico ico-copy' value=\"{$clone_icon}\"  title=\"{$clone_icon}\" onclick='cloneReport(\"{$code}\");'"), 'link');
         }
         $this->table_builder->add_row_attribute($row, 'id', "tr{$row}");
         $this->table_builder->add_row_attribute($row, 'id_report', type_to_str($id_report, 'textcode'));
         $row++;
     }
     if (0 == count($reports)) {
         $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');
     }
     $html = str_replace('<%REPORTS%>', $this->table_builder->get_sort_html(), $html);
     $html = str_replace('<%PAGINATION%>', $this->pagination_post->create_form(), $html);
     $buttons = $this->parser->parse($this->req_report_buttons_template, array('FORM_PREFIX' => $this->form_prefix));
     $html = str_replace('<%BUTTONST%>', str_replace('<%ID%>', 'top_', $buttons), $html);
     $html = str_replace('<%BUTTONSB%>', str_replace('<%ID%>', 'bottom_', $buttons), $html);
     $html = str_replace('<%COLUMNS%>', $this->table_builder->get_columns_html(), $html);
     return $html;
 }