Skip to content

Instantly share code, notes, and snippets.

@alur222
Last active February 16, 2024 10:57
Show Gist options
  • Save alur222/506fb6d233ec09986d6e1720a346b6b0 to your computer and use it in GitHub Desktop.
Save alur222/506fb6d233ec09986d6e1720a346b6b0 to your computer and use it in GitHub Desktop.
bonfire controller
<?php
if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
class Business extends Front_Controller {
public function __construct() {
parent::__construct();
// restrict access to User who have this permission
$this->auth->restrict('View.ReportsAndDashboard');
$this->load->library('session');
$this->load->library('users/auth');
$this->load->library('auth_ext/auth_ext');
$this->load->library('general/gen_lib');
$this->load->library('general/ui_lib');
$this->load->model('webuiuser_model');
$this->load->model('user_logging_model');
$this->load->model('general_model');
Assets::$asset_timestamp = true;
Assets::Add_css('css/app.css');
Assets::add_js('js/app.js');
Assets::add_js('js/handlebars-v1.3.0.js');
Assets::add_js('js/datatables/datatables.js');
Assets::add_css('js/datatables/datatables.css');
Template::set('ui_menu', $this->uilib->get_menu_elements());
}
public function index() {
// restrict access
$has_access = has_permission("BusinessReport");
// page specific dependencies
Assets::add_js('js/moment.js');
Assets::add_css('css/page.css');
Assets::add_js('js/page.js');
if ($has_access) {
$can_access_pii = has_permission("BusinessReportPIISection");
Template::set("has_pie_access", $can_access_pii);
Template::render();
} else {
Template::set_view("noaccess");
Template::render();
}
}
public function api_get_active_users() {
$response = array(
'success' => false,
'message' => 'General business reports error.',
'payload' => array()
);
if (has_permission('BusinessReportActiveUsers')) {
$this->load->model('business_dashboard_model');
$link = $this->sql_model->get_link();
$result = $this->business_dashboard_model->get_active_users($link, null, null);
$this->sql_model->close_link($link);
return $this->genlib->json_out($result);
}
return $this->genlib->json_out($response);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment