Merge branch 'main' of bitbucket.org:venbainformationtechnology/the_mechanic into main

This commit is contained in:
sriramv 2024-04-23 17:12:53 +05:30
commit c966c49d63
8 changed files with 665 additions and 144 deletions

179
App.php Normal file
View File

@ -0,0 +1,179 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class App extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Base Site URL
* --------------------------------------------------------------------------
*
* URL to your CodeIgniter root. Typically, this will be your base URL,
* WITH a trailing slash:
*
* E.g., http://example.com/
*/
public string $baseURL = 'http://localhost/the_mechanic/';
/**
* Allowed Hostnames in the Site URL other than the hostname in the baseURL.
* If you want to accept multiple Hostnames, set this.
*
* E.g.,
* When your site URL ($baseURL) is 'http://example.com/', and your site
* also accepts 'http://media.example.com/' and 'http://accounts.example.com/':
* ['media.example.com', 'accounts.example.com']
*
* @var list<string>
*/
public array $allowedHostnames = [];
/**
* --------------------------------------------------------------------------
* Index File
* --------------------------------------------------------------------------
*
* Typically, this will be your `index.php` file, unless you've renamed it to
* something else. If you have configured your web server to remove this file
* from your site URIs, set this variable to an empty string.
*/
public string $indexPage = 'index.php';
/**
* --------------------------------------------------------------------------
* URI PROTOCOL
* --------------------------------------------------------------------------
*
* This item determines which server global should be used to retrieve the
* URI string. The default setting of 'REQUEST_URI' works for most servers.
* If your links do not seem to work, try one of the other delicious flavors:
*
* 'REQUEST_URI': Uses $_SERVER['REQUEST_URI']
* 'QUERY_STRING': Uses $_SERVER['QUERY_STRING']
* 'PATH_INFO': Uses $_SERVER['PATH_INFO']
*
* WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
*/
// public string $uriProtocol = 'REQUEST_URI';
public string $uriProtocol = 'PATH_INFO';
/**
* --------------------------------------------------------------------------
* Default Locale
* --------------------------------------------------------------------------
*
* The Locale roughly represents the language and location that your visitor
* is viewing the site from. It affects the language strings and other
* strings (like currency markers, numbers, etc), that your program
* should run under for this request.
*/
public string $defaultLocale = 'en';
/**
* --------------------------------------------------------------------------
* Negotiate Locale
* --------------------------------------------------------------------------
*
* If true, the current Request object will automatically determine the
* language to use based on the value of the Accept-Language header.
*
* If false, no automatic detection will be performed.
*/
public bool $negotiateLocale = false;
/**
* --------------------------------------------------------------------------
* Supported Locales
* --------------------------------------------------------------------------
*
* If $negotiateLocale is true, this array lists the locales supported
* by the application in descending order of priority. If no match is
* found, the first locale will be used.
*
* IncomingRequest::setLocale() also uses this list.
*
* @var list<string>
*/
public array $supportedLocales = ['en'];
/**
* --------------------------------------------------------------------------
* Application Timezone
* --------------------------------------------------------------------------
*
* The default timezone that will be used in your application to display
* dates with the date helper, and can be retrieved through app_timezone()
*
* @see https://www.php.net/manual/en/timezones.php for list of timezones
* supported by PHP.
*/
public string $appTimezone = 'UTC';
/**
* --------------------------------------------------------------------------
* Default Character Set
* --------------------------------------------------------------------------
*
* This determines which character set is used by default in various methods
* that require a character set to be provided.
*
* @see http://php.net/htmlspecialchars for a list of supported charsets.
*/
public string $charset = 'UTF-8';
/**
* --------------------------------------------------------------------------
* Force Global Secure Requests
* --------------------------------------------------------------------------
*
* If true, this will force every request made to this application to be
* made via a secure connection (HTTPS). If the incoming request is not
* secure, the user will be redirected to a secure version of the page
* and the HTTP Strict Transport Security (HSTS) header will be set.
*/
public bool $forceGlobalSecureRequests = false;
/**
* --------------------------------------------------------------------------
* Reverse Proxy IPs
* --------------------------------------------------------------------------
*
* If your server is behind a reverse proxy, you must whitelist the proxy
* IP addresses from which CodeIgniter should trust headers such as
* X-Forwarded-For or Client-IP in order to properly identify
* the visitor's IP address.
*
* You need to set a proxy IP address or IP address with subnets and
* the HTTP header for the client IP address.
*
* Here are some examples:
* [
* '10.0.1.200' => 'X-Forwarded-For',
* '192.168.5.0/24' => 'X-Real-IP',
* ]
*
* @var array<string, string>
*/
public array $proxyIPs = [];
/**
* --------------------------------------------------------------------------
* Content Security Policy
* --------------------------------------------------------------------------
*
* Enables the Response's Content Secure Policy to restrict the sources that
* can be used for images, scripts, CSS files, audio, video, etc. If enabled,
* the Response object will populate default values for the policy from the
* `ContentSecurityPolicy.php` file. Controllers can always add to those
* restrictions at run time.
*
* For a better understanding of CSP, see these documents:
*
* @see http://www.html5rocks.com/en/tutorials/security/content-security-policy/
* @see http://www.w3.org/TR/CSP/
*/
public bool $CSPEnabled = false;
}

View File

@ -15,9 +15,11 @@ $routes->get('/', 'Login::index');
$routes->get('log_out', 'Login::index');
$routes->post("authenticate", "Login::authenticate");
$routes->get("edit_account/(:any)", "Users::edit_account/$1");
$routes->post("edit_mail/(:any)", "Users::edit_mail/$1");
$routes->post("change_password/(:any)", "Users::change_password/$1");
$routes->post("add_account", "Users::add_account");
// $routes->get("new_user/(:any)", "Users::new_user/$1");
// $routes->get("delete_user/(:any)", "Users::delete_user/$1");
// $routes->get("delete_user/(:any)", "Users::delete_user/$1");
//end Login//
//Users//
@ -40,8 +42,12 @@ $routes->get("delete_business/(:any)", "Business::delete_business/$1");
$routes->get('branch_index/(:any)', 'Branch::branch_index/$1');
$routes->post('add_branch/(:any)', 'Branch::new_branch/$1');
$routes->post('edit_branch/(:any)', 'Branch::edit_branch/$1');
$routes->post('edit_branch_form/(:any)', 'Branch::edit_branch_form/$1');
$routes->get("get_branch/(:any)", "Branch::get_branch/$1");
$routes->get("delete_branch/(:any)", "Branch::delete_branch/$1");
$routes->get('business_branches',"Branch::business_branches");
$routes->get('get_branch_edit_form/(:any)',"Branch::get_branch_edit_form/$1");
// end Branch//
// Products//

View File

@ -68,6 +68,7 @@ class Branch extends BaseController
}
public function edit_branch($branch_id)
{
if ($branch_id) {
@ -98,4 +99,33 @@ class Branch extends BaseController
return redirect()->to('branch_index/' . $existingBranch['business_id']);
}
public function get_branch_edit_form($branch_id){
if ($branch_id) {
$BranchModel = new BranchModel();
$branchs =$BranchModel->where('branch_id',$branch_id)->first();
$branch['page_name'] = "Edit Branch";
$branch['branch'] = $branchs;
return view('branch_edit_form',$branch);
}
}
public function edit_branch_form($branch_id)
{
if ($branch_id) {
$data = $this->request->getPost();
$BranchModel = new BranchModel();
// print_r($data);die;
$BranchModel->update($branch_id,$data);
return view('dashboard');
}
}
}

View File

@ -23,7 +23,9 @@ class Users extends BaseController
public function index()
{
$UsersModel = new UsersModel();
$users = $UsersModel->findAll();
$business_id =session()->get('logged_user_business_id');
$branch_id =session()->get('logged_user_branch_id');
$users = $UsersModel->where('business_id',$business_id)->where('branch_id',$branch_id)->findAll();
$data['users']=$users;
$roleModel = new RoleModel();
@ -58,22 +60,36 @@ class Users extends BaseController
$data['users'] = [];
$BusinessModel=new BusinessModel();
$BranchModel=new BranchModel();
$business=$BusinessModel->findAll();
$business_select = $BusinessModel->where('business_id',session()->get('logged_user_business_id'))->findAll();
$branch_list = $BranchModel->where('branch_id',session()->get('logged_user_branch_id'))->findAll();
// print_r($business);die;
$rolemodel = new RoleModel();
$roles =$rolemodel->getRoles();
$data['business'] = $business;
// $data['business'] = $business;
$data['business'] = $business_select;
$data['branch'] = $branch_list;
$data['roles'] = $roles;
} else if ($user_id !== '0') {
$UsersModel = new UsersModel();
$users=$UsersModel->getUserById($user_id);
$BusinessModel=new BusinessModel();
$BranchModel=new BranchModel();
$business=$BusinessModel->findAll();
$business_select = $BusinessModel->where('business_id',session()->get('logged_user_business_id'))->findAll();
$data['users']=$users;
$data['business'] = $business;
$branch = $BranchModel->where('branch_id',$users['branch_id'])->findAll();
$data['branch'] = $branch;
$data['business'] = $business_select;
$rolemodel = new RoleModel();
$roles =$rolemodel->getRoles();
@ -117,9 +133,11 @@ class Users extends BaseController
$data['branches'] = $branch;
$rolemodel = new RoleModel();
$role = $rolemodel->where('role_id',$users['role'])->first();
$roles =$rolemodel->getRoles();
$data['roles'] = $roles;
$data['role'] = $role;
}
$data['user_id'] = $user_id;
@ -256,4 +274,56 @@ class Users extends BaseController
}
public function edit_mail($user_id){
$UsersModel = new UsersModel();
$data = [
'email' => $this->request->getPost('email'),
];
$UsersModel->update($user_id, $data);
$user_mail =$UsersModel->where('user_id',$user_id)->first();
return json_encode($user_mail);
}
public function change_password($user_id){
$old_password =$this->request->getPost('old_password');
$new_password =$this->request->getPost('new_password');
$confirm_password =$this->request->getPost('confirm_password');
$UsersModel = new UsersModel();
$user = $UsersModel->where('user_id',$user_id)->first();
$data_old_password = $user['password'];
if (!password_verify($old_password, $data_old_password)) {
$response = array(
'status' => 'error',
'message' => 'Old Password Not Match...'
);
return json_encode($response);
}
if($new_password != $confirm_password){
$response = array(
'status' => 'error',
'message' => 'New Password And Confirm Password Not Match...'
);
return json_encode($response);
}
$hashedPassword = password_hash($new_password, PASSWORD_DEFAULT);
$data['password'] = $hashedPassword;
if ($UsersModel->update($user_id, $data)) {
$response = array(
'status' => 'success',
'message' => 'Password Change Succuessfully'
);
return json_encode($response);
}
}
}

View File

@ -0,0 +1,56 @@
<?php include('layout/header.php'); ?>
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title"><?php echo $page_name ?></h4>
<div class="page-title-right">
<ol class="breadcrumb m-0">
</ol>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<form action="<?= base_url() . "edit_branch_form/". session()->get('logged_user_branch_id'); ?>" method="post">
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputEmail4" class="col-form-label">Branch Name</label>
<input type="text" class="form-control" name="branch_name" placeholder="Name" value="<?= isset($branch['branch_name']) ? $branch['branch_name'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputAddress" class="col-form-label">Mobile</label>
<input type="text" class="form-control" name="mobile_no" placeholder="Mobile" value="<?= isset($branch['mobile_no']) ? $branch['mobile_no'] : '' ?>" required maxlength="10" minlength="10">
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Address</label>
<input type="text" class="form-control" name="address" placeholder="Address"value="<?= isset($branch['address']) ? $branch['address'] : '' ?>" required>
</div>
</div>
<input type="hidden" id="business_id" name="business_id" value="<?= isset($branch['business_id']) ? $branch['business_id'] : '' ?>">
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">City</label>
<input type="text" class="form-control" name="city" placeholder="City"value="<?= isset($branch['city']) ? $branch['city'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">State</label>
<input type="text" class="form-control" name="state" placeholder="State"value="<?= isset($branch['state']) ? $branch['state'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Postal Code</label>
<input type="text" class="form-control" name="postal_code" placeholder="Postal Code"value="<?= isset($branch['postal_code']) ? $branch['postal_code'] : '' ?>" required maxlength="6" minlength="6">
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>
</div>
<?php include('layout/footer.php'); ?>

View File

@ -1,113 +1,294 @@
<?php include('layout/header.php'); ?>
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Add User</h4>
<div class="page-title-right">
<ol class="breadcrumb m-0">
</li>
<!-- <li class="breadcrumb-item"><a href="javascript: void(0);">Tables</a></li>
<li class="breadcrumb-item active">Datatables</li> -->
</ol>
</div>
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Profile</h4>
<div class="page-title-right">
<ol class="breadcrumb m-0">
</ol>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<form action="<?= base_url() . "add_account"; ?>" method="post">
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputEmail4" class="col-form-label">Name</label>
<input type="text" class="form-control" name="name" placeholder="Name" value="<?= isset($users['name']) ? $users['name'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputEmail4" class="col-form-label">Email</label>
<input type="email" class="form-control" name="email" placeholder="Email" value="<?= isset($users['email']) ? $users['email'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Password</label>
<input type="password" class="form-control" name="password" placeholder="Password" required>
</div>
<div class="form-group col-md-6">
<label for="inputAddress" class="col-form-label">Mobile</label>
<input type="text" class="form-control" name="mobile" placeholder="Mobile" value="<?= isset($users['mobile_no']) ? $users['mobile_no'] : '' ?>" maxlength="10" minlength="10"required>
<div class="col-lg-4 col-xl-4">
<div class="card text-center">
<div class="card-body">
<h4 class="mt-3 mb-0"><?php echo $users['name']; ?></h4>
<p class="text-muted">@<?php echo $role['roles']; ?></p>
<div class="text-left mt-3" style=" margin-bottom: 16px;">
<div class="table-responsive">
<table class="table table-borderless table-sm">
<tbody>
<tr>
<th scope="row">Full Name :</th>
<td class="text-muted"><?php echo $users['name']; ?></td>
</tr>
<tr>
<th scope="row">Mobile :</th>
<td class="text-muted"><?php echo $users['mobile_no']; ?></td>
</tr>
<tr>
<th scope="row">Email :</th>
<td class="text-muted"><?php echo $users['email']; ?></td>
</tr>
</tbody>
</table>
</div>
</div>
<input type="hidden" id="user_id" name="user_id" value="<?= isset($users['user_id']) ? $users['user_id'] : '' ?>">
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputState" class="col-form-label">Role</label>
<select id="inputState" class="form-control" name="role" readonly required >
<option value="">Select Role</option>
<?php foreach ($roles as $role): ?>
<option value="<?= $role['role_id'] ?>" <?= isset($users['role']) && $users['role'] == $role['role_id'] ? 'selected' : '' ?>><?= $role['roles'] ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-6">
<label for="inputState" class="col-form-label">Business</label>
<select id="business" class="form-control" name="business" readonly required>
<option value="">Select Business</option>
<?php foreach ($business as $busin): ?>
<option value="<?= $busin['business_id'] ?>" <?= isset($users['business_id']) && $users['business_id'] == $busin['business_id'] ? 'selected' : '' ?>><?= $busin['business_name'] ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-6">
<label for="inputState" class="col-form-label">Branch</label>
<select id="branch" class="form-control" name="branch" readonly required>
<option value="">Select Branch</option>
<?php foreach ($branches as $branch): ?>
<option value="<?= $branch['branch_id'] ?>" <?= isset($users['branch_id']) && $users['branch_id'] == $branch['branch_id'] ? 'selected' : '' ?>><?= $branch['branch_name'] ?></option>
<?php endforeach; ?>
<!-- Branch options will be populated dynamically using JavaScript -->
</select>
</div>
</div>
</div>
</div> <!-- end card -->
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>
</div>
<div class="col-lg-8 col-xl-8">
<div class="card">
<div class="card-body">
<div class="tab-pane show active" id="settings">
<form>
<h5 class="mb-3 text-uppercase bg-light p-2"><i class="mdi mdi-account-circle mr-1"></i> Personal Info</h5>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" value="<?php echo $users['name']; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="mobile_no">Mobile Number</label>
<input type="text" class="form-control" id="mobile_no" value="<?php echo $users['mobile_no']; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input type="text" class="form-control" id="user_id" value="<?php echo $users['user_id']; ?>" hidden>
<label for="useremail">Email Address</label>
<input type="email" class="form-control" id="useremail" value="<?php echo $users['email']; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group" style="margin-top: 28px;">
<button type="button" class="btn btn-primary" style="float: inline-end;" onclick="submitPersonalInfo()">Update</button>
</div>
</div>
</div>
</form>
</div>
<!-- end settings content-->
</div>
</div>
</div>
<div class="col-lg-12 col-xl-12">
<div class="card text-center">
<div class="card-body">
<div class="text-left mt-3">
<h5 class="mb-3 text-uppercase bg-light p-2"><i class="mdi mdi-account-circle mr-1"></i> Change Password</h5>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="old_password">Old Password</label>
<div class="input-group">
<input type="password" class="form-control" id="old_password" required>
<div class="input-group-append">
<span class="input-group-text">
<i class="fa fa-eye" id="toggleOldPassword"></i>
</span>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="new_password">New Password</label>
<div class="input-group">
<input type="password" class="form-control" id="new_password" required>
<div class="input-group-append">
<span class="input-group-text">
<i class="fa fa-eye" id="toggleNewPassword"></i>
</span>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="confirm_password">Confirm Password</label>
<div class="input-group">
<input type="password" class="form-control" id="confirm_password" required>
<div class="input-group-append">
<span class="input-group-text">
<i class="fa fa-eye" id="toggleConfirmPassword"></i>
</span>
</div>
</div>
</div>
</div>
<div class="col-md-6" style="margin-top: 27px;">
<button type="submit" class="btn btn-primary" id="submit_password" style="float: inline-end;" onclick="changePassword(this)">Submit</button>
</div>
</div>
</div>
</div>
</div> <!-- end card -->
</div>
</div>
<?php include('layout/footer.php'); ?>
<script>
$(document).ready(function() {
$('#business').change(function() {
var businessId = $(this).val();
if (businessId !== '') {
$.ajax({
url: '<?php echo base_url(),"get_branch"?>', // Update 'your_controller' with the actual controller name
type: 'post',
data: {business_id: businessId},
dataType: 'json',
success:function(response) {
var len = response.length;
$("#branch").empty();
$("#branch").append("<option value=''>Select Branch</option>");
for( var i = 0; i<len; i++) {
var branchId = response[i]['branch_id'];
var branchName = response[i]['branch_name'];
$("#branch").append("<option value='"+branchId+"'>"+branchName+"</option>");
}
}
});
function submitPersonalInfo(params) {
var user_id = $('#user_id').val();
var formData = {
email: $('#useremail').val(),
mobile_no: $('#mobile_no').val(),
name: $('#name').val()
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."edit_mail/"?>' + user_id,
data: formData,
dataType: 'json',
success: function(response) {
console.log(response);
location.reload();
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
function changePassword(params) {
var user_id = $('#user_id').val();
var formData = {
old_password: $('#old_password').val(),
new_password: $('#new_password').val(),
confirm_password: $('#confirm_password').val()
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."change_password/"?>' + user_id,
data: formData,
dataType: 'json',
success: function(response) {
console.log(response);
if (response.status == 'error') {
toastr.warning(response.message, 'Warning');
}else{
toastr.success(response.message, 'Success');
$('#old_password').val('');
$('#new_password').val('');
$('#confirm_password').val('');
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
</script>
<script>
var oldPasswordField = document.getElementById("old_password");
var toggleOldPassword = document.getElementById("toggleOldPassword");
var newPasswordField = document.getElementById("new_password");
var toggleNewPassword = document.getElementById("toggleNewPassword");
var confirmField = document.getElementById("confirm_password");
var toggleConfirmPassword = document.getElementById("toggleConfirmPassword");
toggleOldPassword.addEventListener("click", function() {
togglePasswordVisibility(oldPasswordField, toggleOldPassword);
});
toggleNewPassword.addEventListener("click", function() {
togglePasswordVisibility(newPasswordField, toggleNewPassword);
});
toggleConfirmPassword.addEventListener("click", function() {
togglePasswordVisibility(confirmField, toggleConfirmPassword);
});
function togglePasswordVisibility(field, toggle) {
if (field.type === "password") {
field.type = "text";
toggle.className = "fa fa-eye-slash";
} else {
field.type = "password";
toggle.className = "fa fa-eye";
}
}
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
var newPasswordField = document.getElementById('new_password');
var confirmPasswordField = document.getElementById('confirm_password');
var submitButton = document.getElementById('submit_password');
// Add an event listener to the "Confirm Password" field
confirmPasswordField.addEventListener('input', function() {
// Check if the passwords match
if (newPasswordField.value === confirmPasswordField.value) {
// Enable the submit button
submitButton.disabled = false;
} else {
$("#branch").empty();
$("#branch").append("<option value=''>Select Branch</option>");
// Disable the submit button
submitButton.disabled = true;
}
});
});
</script>

View File

@ -181,24 +181,6 @@
</div>
</li>
<?php } ?>
<?php if(session()->get('logged_user_role') == 'Floor Manager' ) { ?>
<li>
<a href="<?php echo base_url('index') ?>">
@ -212,7 +194,11 @@
<?php if(session()->get('logged_user_role') == 'Administrator') { ?>
<li class="menu-title mt-2">Apps</li>
<li> <a href="<?php echo base_url('business_index') ?>"><i class="ri-layout-line"></i><span> Business </span></a></li>
<li>
<!-- <a href="<?php echo base_url('branch_index/'. session()->get('logged_user_business_id')) ?>"> -->
<!-- <i class="ri-layout-line"></i><span> Branches </span> -->
<!-- </a> -->
</li>
<li>
<a href="<?php echo base_url('index') ?>"><i class="fas fa-user"></i><span> Users</span></a></li>
<?php } ?>
@ -291,8 +277,19 @@
<span>My Account</span>
</a>
<?php if(session()->get('logged_user_role') == 'Administrator') { ?>
<a href="<?= base_url("new_business/". session()->get("logged_user_business_id")); ?>" class="dropdown-item notify-item">
<i class="ri-layout-line"></i>
<span>Business</span>
</a>
<a href="<?= base_url("get_branch_edit_form/".session()->get('logged_user_branch_id')); ?>" class="dropdown-item notify-item">
<i class="fas fa-code-branch"></i>
<span>Branches</span>
</a>
<?php } ?>
<div class="dropdown-divider"></div>
<!-- <div class="dropdown-divider"></div> -->
<!-- item-->
<a href="<?php echo base_url("log_out")?>" class="dropdown-item notify-item">

View File

@ -21,6 +21,35 @@
<form action="<?= base_url() . "add_user"; ?>" method="post">
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputState" class="col-form-label">Business</label>
<select id="business" class="form-control" name="business" required>
<!-- <option value="">Select Business</option> -->
<?php foreach ($business as $busin): ?>
<option value="<?= $busin['business_id'] ?>" <?= isset($users['business_id']) && $users['business_id'] == $busin['business_id'] ? 'selected' : '' ?>><?= $busin['business_name'] ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="inputState" class="col-form-label">Branch</label>
<select id="branch" class="form-control" name="branch" required>
<!-- <option value="">Select Branch</option> -->
<?php if (isset($branch) && (is_array($branch) || is_object($branch))) {
foreach ($branch as $branch): ?>
<option value="<?= $branch['business_id'] ?>" <?= isset($users['branch_id']) && $users['branch_id'] == $branch['branch_id'] ? 'selected' : '' ?> ><?= $branch['branch_name'] ?></option>
<?php endforeach; } ?>
<!-- Branch options will be populated dynamically using JavaScript -->
</select>
</div>
<div class="form-group col-md-4">
<label for="inputState" class="col-form-label">Role</label>
<select id="inputState" class="form-control" name="role" required>
<option value="">Select Role</option>
<?php foreach ($roles as $role): ?>
<option value="<?= $role['role_id'] ?>" <?= isset($users['role']) && $users['role'] == $role['role_id'] ? 'selected' : '' ?>><?= $role['roles'] ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-6">
<label for="inputEmail4" class="col-form-label">Name</label>
<input type="text" class="form-control" name="name" placeholder="Name" value="<?= isset($users['name']) ? $users['name'] : '' ?>" required>
@ -39,34 +68,7 @@
</div>
</div>
<input type="hidden" id="user_id" name="user_id" value="<?= isset($users['user_id']) ? $users['user_id'] : '' ?>">
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputState" class="col-form-label">Role</label>
<select id="inputState" class="form-control" name="role" required>
<option value="">Select Role</option>
<?php foreach ($roles as $role): ?>
<option value="<?= $role['role_id'] ?>" <?= isset($users['role']) && $users['role'] == $role['role_id'] ? 'selected' : '' ?>><?= $role['roles'] ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-6">
<label for="inputState" class="col-form-label">Business</label>
<select id="business" class="form-control" name="business" required>
<option value="">Select Business</option>
<?php foreach ($business as $busin): ?>
<option value="<?= $busin['business_id'] ?>" <?= isset($users['business_id']) && $users['business_id'] == $busin['business_id'] ? 'selected' : '' ?>><?= $busin['business_name'] ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-6">
<label for="inputState" class="col-form-label">Branch</label>
<select id="branch" class="form-control" name="branch" required>
<option value="">Select Branch</option>
<!-- Branch options will be populated dynamically using JavaScript -->
</select>
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>