Пример #1
0
 public function action_ajaxfindaccount()
 {
     // ajax only
     if (!\Input::is_ajax()) {
         \Response::redirect($this->getAndSetSubmitRedirection());
     }
     // check permission
     if (\Model_AccountLevelPermission::checkAdminPermission('acperm_perm', 'acperm_manage_user_perm') == false) {
         return null;
     }
     $output = array();
     // list account with search
     if (trim(\Input::get('term')) != null) {
         $option['search'] = trim(\Input::get('term'));
     }
     $option['list_for'] = 'admin';
     $list_account = \Model_Accounts::listAccounts($option);
     unset($option);
     // loop set result for search
     if (is_array($list_account) && !empty($list_account)) {
         $i = 0;
         foreach ($list_account['items'] as $row) {
             $output[$i]['value'] = $row->account_id;
             $output[$i]['label'] = $row->account_username;
             $i++;
         }
     }
     $response = new \Response();
     $response->set_header('Content-Type', 'application/json');
     $response->body(json_encode($output));
     return $response;
 }
Пример #2
0
 public function action_index()
 {
     // clear redirect referrer
     \Session::delete('submitted_redirect');
     // check permission
     if (\Model_AccountLevelPermission::checkAdminPermission('account_perm', 'account_viewusers_perm') == false) {
         \Session::set_flash('form_status', array('form_status' => 'error', 'form_status_message' => \Lang::get('admin_permission_denied', array('page' => \Uri::string()))));
         \Response::redirect(\Uri::create('admin'));
     }
     // load language
     \Lang::load('account');
     // read flash message for display errors.
     $form_status = \Session::get_flash('form_status');
     if (isset($form_status['form_status']) && isset($form_status['form_status_message'])) {
         $output['form_status'] = $form_status['form_status'];
         $output['form_status_message'] = $form_status['form_status_message'];
     }
     unset($form_status);
     // get levels to select
     $account_levels = \Model_AccountLevelGroup::listLevels(array('no_guest' => false));
     $select_lvls = array();
     if (!empty($account_levels['items']) && is_array($account_levels)) {
         foreach ($account_levels['items'] as $lvr) {
             $select_lvls[$lvr->level_group_id] = $lvr->level_name;
         }
     }
     $output['account_levels'] = $select_lvls;
     unset($account_levels, $select_lvls);
     // set sort variable for sortable in views.
     $sort = \Security::strip_tags(trim(\Input::get('sort')));
     if ($sort == null || $sort == 'ASC') {
         $next_sort = 'DESC';
     } else {
         $next_sort = 'ASC';
     }
     $output['next_sort'] = $next_sort;
     unset($next_sort, $sort);
     // search query
     $output['q'] = trim(\Input::get('q'));
     // filters
     $output['filter_account_id'] = trim(\Input::get('filter_account_id'));
     $output['filter_account_username'] = trim(\Input::get('filter_account_username'));
     $output['filter_account_email'] = trim(\Input::get('filter_account_email'));
     $output['filter_level_group_id'] = trim(\Input::get('filter_level_group_id'));
     $output['filter_account_create'] = trim(\Input::get('filter_account_create'));
     $output['filter_account_last_login'] = trim(\Input::get('filter_account_last_login'));
     $output['filter_account_status'] = trim(\Input::get('filter_account_status'));
     // list accounts --------------------------------------------------------------------------------------------------
     $option['limit'] = \Model_Config::getval('content_admin_items_perpage');
     $option['offset'] = trim(\Input::get('page')) != null ? ((int) \Input::get('page') - 1) * $option['limit'] : 0;
     if (trim(\Input::get('q')) != null) {
         $option['search'] = trim(\Input::get('q'));
     }
     if ($output['filter_account_id'] != null) {
         $option['filter_account_id'] = $output['filter_account_id'];
     }
     if ($output['filter_account_username'] != null) {
         $option['filter_account_username'] = $output['filter_account_username'];
     }
     if ($output['filter_account_email'] != null) {
         $option['filter_account_email'] = $output['filter_account_email'];
     }
     if ($output['filter_level_group_id'] != null) {
         $option['filter_level_group_id'] = $output['filter_level_group_id'];
     }
     if ($output['filter_account_create'] != null) {
         $option['filter_account_create'] = $output['filter_account_create'];
     }
     if ($output['filter_account_last_login'] != null) {
         $option['filter_account_last_login'] = $output['filter_account_last_login'];
     }
     if ($output['filter_account_status'] != null) {
         $option['filter_account_status'] = $output['filter_account_status'];
     }
     if (\Security::strip_tags(trim(\Input::get('orders'))) != null) {
         $option['orders'] = \Security::strip_tags(trim(\Input::get('orders')));
     }
     if (\Security::strip_tags(trim(\Input::get('sort'))) != null) {
         $option['sort'] = \Security::strip_tags(trim(\Input::get('sort')));
     }
     $list_accounts = \Model_Accounts::listAccounts($option);
     // pagination config
     $config['pagination_url'] = \Uri::main() . \Uri::getCurrentQuerystrings(true, true, false);
     $config['total_items'] = $list_accounts['total'];
     $config['per_page'] = $option['limit'];
     $config['uri_segment'] = 'page';
     $config['num_links'] = 3;
     $config['show_first'] = true;
     $config['show_last'] = true;
     $config['first-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>";
     $config['first-inactive-link'] = '<a href="#">{page}</a>';
     $config['first-marker'] = '&laquo;';
     $config['last-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>";
     $config['last-inactive-link'] = '<a href="#">{page}</a>';
     $config['last-marker'] = '&raquo;';
     $config['previous-marker'] = '&lsaquo;';
     $config['next-marker'] = '&rsaquo;';
     $pagination = \Pagination::forge('viewlogins_pagination', $config);
     $output['list_accounts'] = $list_accounts;
     $output['pagination'] = $pagination;
     unset($config, $list_accounts, $option, $pagination);
     // <head> output ----------------------------------------------------------------------------------------------
     $output['page_title'] = $this->generateTitle(\Lang::get('account_accounts'));
     $theme = \Theme::instance();
     $theme->asset->css('datepicker.css', array(), 'fuelstart');
     unset($theme);
     // <head> output ----------------------------------------------------------------------------------------------
     // breadcrumb -------------------------------------------------------------------------------------------------
     $page_breadcrumb = [];
     $page_breadcrumb[0] = ['name' => \Lang::get('admin_admin_home'), 'url' => \Uri::create('admin')];
     $page_breadcrumb[1] = ['name' => \Lang::get('account_accounts'), 'url' => \Uri::create('admin/account')];
     $output['page_breadcrumb'] = $page_breadcrumb;
     unset($page_breadcrumb);
     // breadcrumb -------------------------------------------------------------------------------------------------
     return $this->generatePage('admin/templates/account/index_v', $output, false);
 }