Skip to content

Commit

Permalink
Merge branch 'release/0.3.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeyers committed Feb 2, 2018
2 parents febff88 + 30300ef commit 5445caf
Show file tree
Hide file tree
Showing 23 changed files with 955 additions and 284 deletions.
4 changes: 3 additions & 1 deletion application/config/authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*/

$config['levels_and_roles'] = [
'99' =>'superadmin',
'1' => 'clerk',
'3' => 'nurse',
'6' => 'doctor',
Expand All @@ -46,7 +47,8 @@
'department' => 'doctor,nurse',
'facility' => 'clerk',
'managers'=> 'admin',
'employees' => 'doctor,admin'
'employees' => 'doctor,admin',
'superadmin'=>'superadmin'

];

Expand Down
2 changes: 1 addition & 1 deletion application/config/config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$config['version'] = '0.3.4';
$config['version'] = '0.3.5';
defined('BASEPATH') OR exit('No direct script access allowed');

/*
Expand Down
89 changes: 89 additions & 0 deletions application/controllers/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,95 @@ public function created_user()
echo $this->load->view('examples/page_footer', '', TRUE);
}

public function create_superadmin()
{
// Customize this array for your user
$user_data = [
'username' => 'surgitrack',
'passwd' => 'Passw0rd',
'first_name'=> 'Super ',
'last_name'=> 'Admin',
'email' => 'admin@surgitrack.co.za',
'auth_level' => '99', // 9 if you want to login @ examples/index.
];

$this->is_logged_in();

echo $this->load->view('examples/page_header', '', TRUE);

// Load resources
$this->load->helper('auth');
$this->load->model('Authorization/authorization_model');
$this->load->model('Authorization/validation_callables');
$this->load->library('form_validation');

$this->form_validation->set_data($user_data);

$validation_rules = [
[
'field' => 'username',
'label' => 'username',
'rules' => 'max_length[12]|is_unique[' . db_table('user_table') . '.username]',
'errors' => [
'is_unique' => 'Username already in use.'
]
],
[
'field' => 'passwd',
'label' => 'passwd',
'rules' => [
'trim',
'required',
[
'_check_password_strength',
[$this->validation_callables, '_check_password_strength']
]
],
'errors' => [
'required' => 'The password field is required.'
]
],
[
'field' => 'email',
'label' => 'email',
'rules' => 'trim|required|valid_email|is_unique[' . db_table('user_table') . '.email]',
'errors' => [
'is_unique' => 'Email address already in use.'
]
],
[
'field' => 'auth_level',
'label' => 'auth_level',
'rules' => 'required|integer|in_list[99,1,6,9]'
]
];

$this->form_validation->set_rules($validation_rules);

if ($this->form_validation->run()) {
$user_data['passwd'] = $this->authentication->hash_passwd($user_data['passwd']);
$user_data['user_id'] = $this->authorization_model->get_unused_id();
$user_data['created_at'] = date('Y-m-d H:i:s');

// If username is not used, it must be entered into the record as NULL
if (empty($user_data['username'])) {
$user_data['username'] = NULL;
}

$this->db->set($user_data)
->insert(db_table('user_table'));

if ($this->db->affected_rows() == 1)
echo '<h1>Congratulations</h1>' . '<p>User ' . $user_data['username'] . ' was created.</p>';


} else {
echo '<h1>User Creation Error(s)</h1>' . validation_errors();
}

echo $this->load->view('examples/page_footer', '', TRUE);
}

public function create_facility_user($userdata)
{ //username,passwd,email,first_name,last_name,facilityid,authlevel

Expand Down
10 changes: 8 additions & 2 deletions application/controllers/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function __construct()
$this->data['default_firm_color'] = '#000000';
}
//CHECK IF FACILITY IS SETUP
if (!$this->setup_model->is_setup_complete($this->auth_facilityid)) {
if (!$this->setup_model->is_setup_complete()) {

if ($this->usergroup == 'admin') {
redirect('setup/my_setup', 'refresh');
Expand Down Expand Up @@ -151,7 +151,13 @@ public function index($caseid = '')

$this->_smart_render('dashboard/calendar', $this->data, true, true);

} else {
} elseif($this->auth_level=='99'){
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->data['pagescripts'] = $this->pagescripts . $this->calendar . $this->dashboard . $this->general_tools;
$this->_smart_render('dashboard/superadmin', $this->data, true);
}

else {
$this->data['department_firms'] = $this->settings_model->get_all_firms_by_department();
$this->data['dashstats'] = $this->dashboard_model->dashstats();
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
Expand Down
32 changes: 28 additions & 4 deletions application/controllers/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -683,13 +683,24 @@ public function create_facility()

if ($id == 0) {
if ($this->form_validation->run() == true && $this->settings_model->facilities_insert($data)) {

$this->session->set_flashdata('message', "You have succesfully created a new Facility");
$this->session->set_flashdata('message', '<div class="alert alert-success fade in">
<button class="close" data-dismiss="alert">
×
</button>
<i class="fa-fw fa fa-times"></i>
<strong>Success!</strong> You have succesfully created a new Facility
</div');
}
} else {
if ($this->form_validation->run() == true && $this->settings_model->facilities_update($data, $id)) {

$this->session->set_flashdata('message', "you have succesfully Updated '" . $this->input->post('facility_name') . "' details");
$this->session->set_flashdata('message', '<div class="alert alert-success fade in">
<button class="close" data-dismiss="alert">
×
</button>
<i class="fa-fw fa fa-times"></i>
<strong>Success!</strong> You have succesfully Updated ' . $this->input->post('facility_name') . ' details.
</div');
}
}
redirect('settings/facilities');
Expand Down Expand Up @@ -724,9 +735,22 @@ public function delete_facilities()
{
$id = $this->uri->segment(3);
if ($this->settings_model->delete_facilities($id) == 1) {
$this->session->set_flashdata('message', "You cannot delete this Facility has theatres");
$this->session->set_flashdata('message', '<div class="alert alert-danger fade in">
<button class="close" data-dismiss="alert">
×
</button>
<i class="fa-fw fa fa-times"></i>
<strong>Success!</strong> You cannot delete this Facility has Patients registered under it
</div');
} else {
$this->settings_model->delete_facilities($id);
$this->session->set_flashdata('message', '<div class="alert alert-success fade in">
<button class="close" data-dismiss="alert">
×
</button>
<i class="fa-fw fa fa-times"></i>
<strong>Success!</strong> The facility has successfully been deleted.
</div');
}
redirect('settings/facilities');
}
Expand Down
67 changes: 67 additions & 0 deletions application/controllers/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ function __construct()

public function index()
{
if ($this->auth_level == '99') {
redirect('users/all', 'refresh');
}
$this->data['roles'] = config_item('levels_and_roles');
$id = $this->uri->segment(3);
if ($id != "" && is_numeric($id)) {
Expand All @@ -93,6 +96,21 @@ public function index()

}

public function all()
{
if ($this->auth_level != '99') {
redirect('users', 'refresh');
}
$this->data['roles'] = config_item('levels_and_roles');
$this->data['users'] = $this->setup_model->get_all_users();
$this->data['pagescripts'] = $this->pagescripts . $this->table_tools.$this->settings_tools;
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->_smart_render('users/all', $this->data, true);

}



public function create_user()
{
$this->load->helper('auth');
Expand Down Expand Up @@ -499,6 +517,21 @@ function delete_user()

}

function ban_user()
{
$id = $this->uri->segment(3);
if($this->user_model->ban_user($id)){
$this->session->set_flashdata('message', 'User was succesfully banned');
redirect("users/all");
}else{
$this->session->set_flashdata('message', 'User was not banned');
redirect("users/all");
}

}



function ajaxgetuser()
{
$id = $this->input->post('id');
Expand Down Expand Up @@ -609,6 +642,40 @@ public function usersmanage()
$this->_smart_render('users/user_manage', $this->data, true);
}

public function user_manage()
{
$id = $this->uri->segment(3);
$this->data['firms'] = $this->settings_model->get_firms_list($this->auth_facilityid);
$this->data['facilities'] = $this->settings_model->get_facilities_list($this->auth_facilityid);
$this->data['departments'] = $this->settings_model->get_departments_list($this->auth_facilityid);
$this->data['user'] = $this->user_model->get_Users($this->auth_facilityid);
$this->data['users'] = $this->user_model->get_user($id);
$this->data['roles'] = config_item('levels_and_roles');
$departments = $this->user_model->get_users_department($id);
if (!empty($departments)) {
$department_id = $departments->department_id;
$this->data['myfirms'] = $this->settings_model->get_mydefault_firms($id, $department_id);
} else {
$this->data['myfirms'] = array();
}
$this->data['myfacilities'] = $this->settings_model->get_myfacilities_list($id);
$this->data['mydepartments'] = $this->settings_model->get_mydepartments_list($id);

$this->data['pagescripts'] = $this->pagescripts . $this->table_tools . $this->general_tools;

$this->_smart_render('users/admin_usermanage', $this->data, true);
}

public function user_facility_unlink()
{
$id = $this->uri->segment(3);
redirect('users/all');
}





public function user_unassign_unit()
{
$userid = $this->input->post('userid');
Expand Down
8 changes: 4 additions & 4 deletions application/controllers/api/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ public function create_post()
$stmt = $this->api_model->admin_user_insert($user_data,$password, $admin['facility_id']);

if ($stmt) {
$this->writelog->writelog(0, 'Admin User '.$admin['email'].' details was created:' . date('Y-m-d H:i:s', strtotime('now'));
$this->response($stmt, 200);
$this->writelog->writelog(0, 'Admin User '.$admin['email'].' details was created:' . date('Y-m-d H:i:s', strtotime('now')),'Admin user account creation successfull');
$this->response($stmt, 200);
} else {
$this->writelog->writelog(0, 'Admin User '.$admin['email'].' details creation failed:' . date('Y-m-d H:i:s', strtotime('now'));
$this->response(array('error' => 'Admin User creation failed'), 404);
$this->writelog->writelog(0, 'Admin User '.$admin['email'].' details creation failed:' . date('Y-m-d H:i:s', strtotime('now')),'Admin User creation failed');
$this->response(array('error' => 'Admin User creation failed'), 404);
}
}

Expand Down
Loading

0 comments on commit 5445caf

Please sign in to comment.