diff --git a/App.php b/App.php new file mode 100644 index 0000000..e41c2cb --- /dev/null +++ b/App.php @@ -0,0 +1,179 @@ + + */ + 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 + */ + 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 + */ + 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; +} diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 0c59776..8ee9346 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -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// diff --git a/app/Controllers/Branch.php b/app/Controllers/Branch.php index e06f5a7..c34cf07 100644 --- a/app/Controllers/Branch.php +++ b/app/Controllers/Branch.php @@ -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'); + } + } + + } \ No newline at end of file diff --git a/app/Controllers/Users.php b/app/Controllers/Users.php index f3ad5a1..8b719c4 100644 --- a/app/Controllers/Users.php +++ b/app/Controllers/Users.php @@ -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); + } + } } \ No newline at end of file diff --git a/app/Views/branch_edit_form.php b/app/Views/branch_edit_form.php new file mode 100644 index 0000000..ab2b1ad --- /dev/null +++ b/app/Views/branch_edit_form.php @@ -0,0 +1,56 @@ + +
+
+
+

+
+ +
+
+
+
+
+
+
+
+ +
get('logged_user_branch_id'); ?>" method="post"> +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+ diff --git a/app/Views/edit_account_form.php b/app/Views/edit_account_form.php index 7812080..b0ff460 100644 --- a/app/Views/edit_account_form.php +++ b/app/Views/edit_account_form.php @@ -1,113 +1,294 @@
-
-
-

Add User

-
- -
+
+
+

Profile

+
+
+
+ + + +
-
-
-
- -
" method="post"> -
-
- - -
-
- - -
-
- - -
-
- - +
+
+
+

+

@

+ + +
+
+ + + + + + + + + + + + + + + + +
Full Name :
Mobile :
Email :
+ -
-
- - -
- -
- - -
-
- - -
-
+ + +
+
- - -
-
-
+
+
+
+
+
+
Personal Info
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + + +
+
+
+
+ +
+
+
+ +
+
+ + +
+
+ +
+
+
+
+
+ +
Change Password
+ +
+
+
+ +
+ +
+ + + +
+
+
+
+ +
+
+ +
+ +
+ + + +
+
+
+
+ +
+
+ +
+ +
+ + + +
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + - - diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 026aec4..337383a 100644 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -181,24 +181,6 @@
- - - - - - - - - - - - - - - - - - get('logged_user_role') == 'Floor Manager' ) { ?>
  • @@ -212,7 +194,11 @@ get('logged_user_role') == 'Administrator') { ?>
  • -
  • Business
  • +
  • + + + +
  • Users
  • @@ -291,8 +277,19 @@ My Account + + get('logged_user_role') == 'Administrator') { ?> + get("logged_user_business_id")); ?>" class="dropdown-item notify-item"> + + Business + + get('logged_user_branch_id')); ?>" class="dropdown-item notify-item"> + + Branches + + - + " class="dropdown-item notify-item"> diff --git a/app/Views/user_form.php b/app/Views/user_form.php index 2a267ce..2f32d03 100644 --- a/app/Views/user_form.php +++ b/app/Views/user_form.php @@ -21,6 +21,35 @@
    " method="post">
    +
    + + +
    +
    + + +
    +
    + + +
    @@ -39,34 +68,7 @@
    -
    -
    - - -
    - -
    - - -
    -
    - - -
    -
    +