Initial commit : GWM
This commit is contained in:
parent
2b27583c43
commit
be541de46f
59
.gitignore
vendored
59
.gitignore
vendored
@ -1,50 +1,21 @@
|
||||
# These are some examples of commonly ignored file patterns.
|
||||
# You should customize this list as applicable to your project.
|
||||
# Learn more about .gitignore:
|
||||
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
|
||||
|
||||
# Node artifact files
|
||||
node_modules/
|
||||
dist/
|
||||
# Ignore vendor folder
|
||||
/vendor/
|
||||
|
||||
# Compiled Java class files
|
||||
*.class
|
||||
# Ignore logs folder
|
||||
/writable/logs/
|
||||
/writable/debugbar/
|
||||
/writable/session/
|
||||
|
||||
# Compiled Python bytecode
|
||||
*.py[cod]
|
||||
# Ignore env File here
|
||||
.env
|
||||
|
||||
# Log files
|
||||
*.log
|
||||
# Ignore uploaded File here
|
||||
/writable/uploads/enquiry/previous_policy/*
|
||||
/writable/uploads/enquiry/id_proof/*
|
||||
/writable/uploads/enquiry/rc/*
|
||||
/writable/uploads/quotation/*
|
||||
/writable/uploads/policy/policy_pdf/*
|
||||
/writable/uploads/policy/policy_payment_receipt/*
|
||||
|
||||
# Package files
|
||||
*.jar
|
||||
|
||||
# Maven
|
||||
target/
|
||||
dist/
|
||||
|
||||
# JetBrains IDE
|
||||
.idea/
|
||||
|
||||
# Unit test reports
|
||||
TEST*.xml
|
||||
|
||||
# Generated by MacOS
|
||||
.DS_Store
|
||||
|
||||
# Generated by Windows
|
||||
Thumbs.db
|
||||
|
||||
# Applications
|
||||
*.app
|
||||
*.exe
|
||||
*.war
|
||||
|
||||
# Large media files
|
||||
*.mp4
|
||||
*.tiff
|
||||
*.avi
|
||||
*.flv
|
||||
*.mov
|
||||
*.wmv
|
||||
|
||||
|
||||
55
.htaccess
Executable file
55
.htaccess
Executable file
@ -0,0 +1,55 @@
|
||||
# Disable directory browsing
|
||||
Options -Indexes
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Rewrite engine
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
# Turning on the rewrite engine is necessary for the following rules and features.
|
||||
# FollowSymLinks must be enabled for this to work.
|
||||
<IfModule mod_rewrite.c>
|
||||
Options +FollowSymlinks
|
||||
RewriteEngine On
|
||||
|
||||
# If you installed CodeIgniter in a subfolder, you will need to
|
||||
# change the following line to match the subfolder you need.
|
||||
# http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
|
||||
# RewriteBase /
|
||||
|
||||
# Redirect Trailing Slashes...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_URI} (.+)/$
|
||||
RewriteRule ^ %1 [L,R=301]
|
||||
|
||||
# Rewrite "www.example.com -> example.com"
|
||||
RewriteCond %{HTTPS} !=on
|
||||
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
|
||||
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
|
||||
|
||||
# Checks to see if the user is attempting to access a valid file,
|
||||
# such as an image or css document, if this isn't true it sends the
|
||||
# request to the front controller, index.php
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]
|
||||
|
||||
# Ensure Authorization header is passed along
|
||||
RewriteCond %{HTTP:Authorization} .
|
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
</IfModule>
|
||||
|
||||
<IfModule !mod_rewrite.c>
|
||||
# If we don't have mod_rewrite installed, all 404's
|
||||
# can be sent to index.php, and everything works as normal.
|
||||
ErrorDocument 404 index.php
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_headers.c>
|
||||
Header set Access-Control-Allow-Origin "*"
|
||||
Header set Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE"
|
||||
Header set Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With"
|
||||
</IfModule>
|
||||
|
||||
# Disable server signature start
|
||||
ServerSignature Off
|
||||
# Disable server signature end
|
||||
22
LICENSE
Executable file
22
LICENSE
Executable file
@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2019 British Columbia Institute of Technology
|
||||
Copyright (c) 2019-present CodeIgniter Foundation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
60
README.md
Executable file
60
README.md
Executable file
@ -0,0 +1,60 @@
|
||||
# CodeIgniter 4 Framework
|
||||
|
||||
## What is CodeIgniter?
|
||||
|
||||
CodeIgniter is a PHP full-stack web framework that is light, fast, flexible and secure.
|
||||
More information can be found at the [official site](https://codeigniter.com).
|
||||
|
||||
This repository holds the distributable version of the framework.
|
||||
It has been built from the
|
||||
[development repository](https://github.com/codeigniter4/CodeIgniter4).
|
||||
|
||||
More information about the plans for version 4 can be found in [CodeIgniter 4](https://forum.codeigniter.com/forumdisplay.php?fid=28) on the forums.
|
||||
|
||||
You can read the [user guide](https://codeigniter.com/user_guide/)
|
||||
corresponding to the latest version of the framework.
|
||||
|
||||
## Important Change with index.php
|
||||
|
||||
`index.php` is no longer in the root of the project! It has been moved inside the *public* folder,
|
||||
for better security and separation of components.
|
||||
|
||||
This means that you should configure your web server to "point" to your project's *public* folder, and
|
||||
not to the project root. A better practice would be to configure a virtual host to point there. A poor practice would be to point your web server to the project root and expect to enter *public/...*, as the rest of your logic and the
|
||||
framework are exposed.
|
||||
|
||||
**Please** read the user guide for a better explanation of how CI4 works!
|
||||
|
||||
## Repository Management
|
||||
|
||||
We use GitHub issues, in our main repository, to track **BUGS** and to track approved **DEVELOPMENT** work packages.
|
||||
We use our [forum](http://forum.codeigniter.com) to provide SUPPORT and to discuss
|
||||
FEATURE REQUESTS.
|
||||
|
||||
This repository is a "distribution" one, built by our release preparation script.
|
||||
Problems with it can be raised on our forum, or as issues in the main repository.
|
||||
|
||||
## Contributing
|
||||
|
||||
We welcome contributions from the community.
|
||||
|
||||
Please read the [*Contributing to CodeIgniter*](https://github.com/codeigniter4/CodeIgniter4/blob/develop/CONTRIBUTING.md) section in the development repository.
|
||||
|
||||
## Server Requirements
|
||||
|
||||
PHP version 8.1 or higher is required, with the following extensions installed:
|
||||
|
||||
- [intl](http://php.net/manual/en/intl.requirements.php)
|
||||
- [mbstring](http://php.net/manual/en/mbstring.installation.php)
|
||||
|
||||
> [!WARNING]
|
||||
> - The end of life date for PHP 7.4 was November 28, 2022.
|
||||
> - The end of life date for PHP 8.0 was November 26, 2023.
|
||||
> - If you are still using PHP 7.4 or 8.0, you should upgrade immediately.
|
||||
> - The end of life date for PHP 8.1 will be December 31, 2025.
|
||||
|
||||
Additionally, make sure that the following extensions are enabled in your PHP:
|
||||
|
||||
- json (enabled by default - don't turn it off)
|
||||
- [mysqlnd](http://php.net/manual/en/mysqlnd.install.php) if you plan to use MySQL
|
||||
- [libcurl](http://php.net/manual/en/curl.requirements.php) if you plan to use the HTTP\CURLRequest library
|
||||
6
app/.htaccess
Executable file
6
app/.htaccess
Executable file
@ -0,0 +1,6 @@
|
||||
<IfModule authz_core_module>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
<IfModule !authz_core_module>
|
||||
Deny from all
|
||||
</IfModule>
|
||||
15
app/Common.php
Executable file
15
app/Common.php
Executable file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The goal of this file is to allow developers a location
|
||||
* where they can overwrite core procedural functions and
|
||||
* replace them with their own. This file is loaded during
|
||||
* the bootstrap process and is called during the framework's
|
||||
* execution.
|
||||
*
|
||||
* This can be looked at as a `master helper` file that is
|
||||
* loaded early on, and may also contain additional functions
|
||||
* that you'd like to use throughout your entire application
|
||||
*
|
||||
* @see: https://codeigniter.com/user_guide/extending/common.html
|
||||
*/
|
||||
202
app/Config/App.php
Executable file
202
app/Config/App.php
Executable file
@ -0,0 +1,202 @@
|
||||
<?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:8080/';
|
||||
|
||||
/**
|
||||
* 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';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Allowed URL Characters
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This lets you specify which characters are permitted within your URLs.
|
||||
| When someone tries to submit a URL with disallowed characters they will
|
||||
| get a warning message.
|
||||
|
|
||||
| As a security measure you are STRONGLY encouraged to restrict URLs to
|
||||
| as few characters as possible.
|
||||
|
|
||||
| By default, only these are allowed: `a-z 0-9~%.:_-`
|
||||
|
|
||||
| Set an empty string to allow all characters -- but only if you are insane.
|
||||
|
|
||||
| The configured value is actually a regular expression character group
|
||||
| and it will be used as: '/\A[<permittedURIChars>]+\z/iu'
|
||||
|
|
||||
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
||||
|
|
||||
*/
|
||||
public string $permittedURIChars = 'a-z 0-9~%.:_\-';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* 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;
|
||||
}
|
||||
94
app/Config/Autoload.php
Executable file
94
app/Config/Autoload.php
Executable file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\AutoloadConfig;
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* AUTOLOADER CONFIGURATION
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* This file defines the namespaces and class maps so the Autoloader
|
||||
* can find the files as needed.
|
||||
*
|
||||
* NOTE: If you use an identical key in $psr4 or $classmap, then
|
||||
* the values in this file will overwrite the framework's values.
|
||||
*
|
||||
* NOTE: This class is required prior to Autoloader instantiation,
|
||||
* and does not extend BaseConfig.
|
||||
*
|
||||
* @immutable
|
||||
*/
|
||||
class Autoload extends AutoloadConfig
|
||||
{
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Namespaces
|
||||
* -------------------------------------------------------------------
|
||||
* This maps the locations of any namespaces in your application to
|
||||
* their location on the file system. These are used by the autoloader
|
||||
* to locate files the first time they have been instantiated.
|
||||
*
|
||||
* The 'Config' (APPPATH . 'Config') and 'CodeIgniter' (SYSTEMPATH) are
|
||||
* already mapped for you.
|
||||
*
|
||||
* You may change the name of the 'App' namespace if you wish,
|
||||
* but this should be done prior to creating any namespaced classes,
|
||||
* else you will need to modify all of those classes for this to work.
|
||||
*
|
||||
* @var array<string, list<string>|string>
|
||||
*/
|
||||
public $psr4 = [
|
||||
APP_NAMESPACE => APPPATH,
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Class Map
|
||||
* -------------------------------------------------------------------
|
||||
* The class map provides a map of class names and their exact
|
||||
* location on the drive. Classes loaded in this manner will have
|
||||
* slightly faster performance because they will not have to be
|
||||
* searched for within one or more directories as they would if they
|
||||
* were being autoloaded through a namespace.
|
||||
*
|
||||
* Prototype:
|
||||
* $classmap = [
|
||||
* 'MyClass' => '/path/to/class/file.php'
|
||||
* ];
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public $classmap = [];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Files
|
||||
* -------------------------------------------------------------------
|
||||
* The files array provides a list of paths to __non-class__ files
|
||||
* that will be autoloaded. This can be useful for bootstrap operations
|
||||
* or for loading functions.
|
||||
*
|
||||
* Prototype:
|
||||
* $files = [
|
||||
* '/path/to/my/file.php',
|
||||
* ];
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public $files = [];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Helpers
|
||||
* -------------------------------------------------------------------
|
||||
* Prototype:
|
||||
* $helpers = [
|
||||
* 'form',
|
||||
* ];
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public $helpers = ['JwtHelper','common_helper','mail_helper','url_helper','status_helper'];
|
||||
}
|
||||
34
app/Config/Boot/development.php
Executable file
34
app/Config/Boot/development.php
Executable file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ERROR DISPLAY
|
||||
|--------------------------------------------------------------------------
|
||||
| In development, we want to show as many errors as possible to help
|
||||
| make sure they don't make it to production. And save us hours of
|
||||
| painful debugging.
|
||||
|
|
||||
| If you set 'display_errors' to '1', CI4's detailed error report will show.
|
||||
*/
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', '1');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG BACKTRACES
|
||||
|--------------------------------------------------------------------------
|
||||
| If true, this constant will tell the error screens to display debug
|
||||
| backtraces along with the other error information. If you would
|
||||
| prefer to not see this, set this value to false.
|
||||
*/
|
||||
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG MODE
|
||||
|--------------------------------------------------------------------------
|
||||
| Debug mode is an experimental flag that can allow changes throughout
|
||||
| the system. This will control whether Kint is loaded, and a few other
|
||||
| items. It can always be used within your own application too.
|
||||
*/
|
||||
defined('CI_DEBUG') || define('CI_DEBUG', true);
|
||||
25
app/Config/Boot/production.php
Executable file
25
app/Config/Boot/production.php
Executable file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ERROR DISPLAY
|
||||
|--------------------------------------------------------------------------
|
||||
| Don't show ANY in production environments. Instead, let the system catch
|
||||
| it and display a generic error message.
|
||||
|
|
||||
| If you set 'display_errors' to '1', CI4's detailed error report will show.
|
||||
*/
|
||||
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
// If you want to suppress more types of errors.
|
||||
// error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
|
||||
ini_set('display_errors', '0');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG MODE
|
||||
|--------------------------------------------------------------------------
|
||||
| Debug mode is an experimental flag that can allow changes throughout
|
||||
| the system. It's not widely used currently, and may not survive
|
||||
| release of the framework.
|
||||
*/
|
||||
defined('CI_DEBUG') || define('CI_DEBUG', false);
|
||||
38
app/Config/Boot/testing.php
Executable file
38
app/Config/Boot/testing.php
Executable file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The environment testing is reserved for PHPUnit testing. It has special
|
||||
* conditions built into the framework at various places to assist with that.
|
||||
* You can’t use it for your development.
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ERROR DISPLAY
|
||||
|--------------------------------------------------------------------------
|
||||
| In development, we want to show as many errors as possible to help
|
||||
| make sure they don't make it to production. And save us hours of
|
||||
| painful debugging.
|
||||
*/
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', '1');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG BACKTRACES
|
||||
|--------------------------------------------------------------------------
|
||||
| If true, this constant will tell the error screens to display debug
|
||||
| backtraces along with the other error information. If you would
|
||||
| prefer to not see this, set this value to false.
|
||||
*/
|
||||
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG MODE
|
||||
|--------------------------------------------------------------------------
|
||||
| Debug mode is an experimental flag that can allow changes throughout
|
||||
| the system. It's not widely used currently, and may not survive
|
||||
| release of the framework.
|
||||
*/
|
||||
defined('CI_DEBUG') || define('CI_DEBUG', true);
|
||||
20
app/Config/CURLRequest.php
Executable file
20
app/Config/CURLRequest.php
Executable file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class CURLRequest extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CURLRequest Share Options
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Whether share options between requests or not.
|
||||
*
|
||||
* If true, all the options won't be reset between requests.
|
||||
* It may cause an error request with unnecessary headers.
|
||||
*/
|
||||
public bool $shareOptions = false;
|
||||
}
|
||||
161
app/Config/Cache.php
Executable file
161
app/Config/Cache.php
Executable file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Cache\CacheInterface;
|
||||
use CodeIgniter\Cache\Handlers\DummyHandler;
|
||||
use CodeIgniter\Cache\Handlers\FileHandler;
|
||||
use CodeIgniter\Cache\Handlers\MemcachedHandler;
|
||||
use CodeIgniter\Cache\Handlers\PredisHandler;
|
||||
use CodeIgniter\Cache\Handlers\RedisHandler;
|
||||
use CodeIgniter\Cache\Handlers\WincacheHandler;
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Cache extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Primary Handler
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The name of the preferred handler that should be used. If for some reason
|
||||
* it is not available, the $backupHandler will be used in its place.
|
||||
*/
|
||||
public string $handler = 'file';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Backup Handler
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The name of the handler that will be used in case the first one is
|
||||
* unreachable. Often, 'file' is used here since the filesystem is
|
||||
* always available, though that's not always practical for the app.
|
||||
*/
|
||||
public string $backupHandler = 'dummy';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Key Prefix
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This string is added to all cache item names to help avoid collisions
|
||||
* if you run multiple applications with the same cache engine.
|
||||
*/
|
||||
public string $prefix = '';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Default TTL
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The default number of seconds to save items when none is specified.
|
||||
*
|
||||
* WARNING: This is not used by framework handlers where 60 seconds is
|
||||
* hard-coded, but may be useful to projects and modules. This will replace
|
||||
* the hard-coded value in a future release.
|
||||
*/
|
||||
public int $ttl = 60;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Reserved Characters
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* A string of reserved characters that will not be allowed in keys or tags.
|
||||
* Strings that violate this restriction will cause handlers to throw.
|
||||
* Default: {}()/\@:
|
||||
*
|
||||
* NOTE: The default set is required for PSR-6 compliance.
|
||||
*/
|
||||
public string $reservedCharacters = '{}()/\@:';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* File settings
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Your file storage preferences can be specified below, if you are using
|
||||
* the File driver.
|
||||
*
|
||||
* @var array<string, int|string|null>
|
||||
*/
|
||||
public array $file = [
|
||||
'storePath' => WRITEPATH . 'cache/',
|
||||
'mode' => 0640,
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Memcached settings
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Your Memcached servers can be specified below, if you are using
|
||||
* the Memcached drivers.
|
||||
*
|
||||
* @see https://codeigniter.com/user_guide/libraries/caching.html#memcached
|
||||
*
|
||||
* @var array<string, bool|int|string>
|
||||
*/
|
||||
public array $memcached = [
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 11211,
|
||||
'weight' => 1,
|
||||
'raw' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Redis settings
|
||||
* -------------------------------------------------------------------------
|
||||
* Your Redis server can be specified below, if you are using
|
||||
* the Redis or Predis drivers.
|
||||
*
|
||||
* @var array<string, int|string|null>
|
||||
*/
|
||||
public array $redis = [
|
||||
'host' => '127.0.0.1',
|
||||
'password' => null,
|
||||
'port' => 6379,
|
||||
'timeout' => 0,
|
||||
'database' => 0,
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Available Cache Handlers
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is an array of cache engine alias' and class names. Only engines
|
||||
* that are listed here are allowed to be used.
|
||||
*
|
||||
* @var array<string, class-string<CacheInterface>>
|
||||
*/
|
||||
public array $validHandlers = [
|
||||
'dummy' => DummyHandler::class,
|
||||
'file' => FileHandler::class,
|
||||
'memcached' => MemcachedHandler::class,
|
||||
'predis' => PredisHandler::class,
|
||||
'redis' => RedisHandler::class,
|
||||
'wincache' => WincacheHandler::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Web Page Caching: Cache Include Query String
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Whether to take the URL query string into consideration when generating
|
||||
* output cache files. Valid options are:
|
||||
*
|
||||
* false = Disabled
|
||||
* true = Enabled, take all query parameters into account.
|
||||
* Please be aware that this may result in numerous cache
|
||||
* files generated for the same page over and over again.
|
||||
* ['q'] = Enabled, but only take into account the specified list
|
||||
* of query parameters.
|
||||
*
|
||||
* @var bool|list<string>
|
||||
*/
|
||||
public $cacheQueryString = false;
|
||||
}
|
||||
79
app/Config/Constants.php
Executable file
79
app/Config/Constants.php
Executable file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
| --------------------------------------------------------------------
|
||||
| App Namespace
|
||||
| --------------------------------------------------------------------
|
||||
|
|
||||
| This defines the default Namespace that is used throughout
|
||||
| CodeIgniter to refer to the Application directory. Change
|
||||
| this constant to change the namespace that all application
|
||||
| classes should use.
|
||||
|
|
||||
| NOTE: changing this will require manually modifying the
|
||||
| existing namespaces of App\* namespaced-classes.
|
||||
*/
|
||||
defined('APP_NAMESPACE') || define('APP_NAMESPACE', 'App');
|
||||
|
||||
/*
|
||||
| --------------------------------------------------------------------------
|
||||
| Composer Path
|
||||
| --------------------------------------------------------------------------
|
||||
|
|
||||
| The path that Composer's autoload file is expected to live. By default,
|
||||
| the vendor folder is in the Root directory, but you can customize that here.
|
||||
*/
|
||||
defined('COMPOSER_PATH') || define('COMPOSER_PATH', ROOTPATH . 'vendor/autoload.php');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Timing Constants
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Provide simple ways to work with the myriad of PHP functions that
|
||||
| require information to be in seconds.
|
||||
*/
|
||||
defined('SECOND') || define('SECOND', 1);
|
||||
defined('MINUTE') || define('MINUTE', 60);
|
||||
defined('HOUR') || define('HOUR', 3600);
|
||||
defined('DAY') || define('DAY', 86400);
|
||||
defined('WEEK') || define('WEEK', 604800);
|
||||
defined('MONTH') || define('MONTH', 2_592_000);
|
||||
defined('YEAR') || define('YEAR', 31_536_000);
|
||||
defined('DECADE') || define('DECADE', 315_360_000);
|
||||
|
||||
/*
|
||||
| --------------------------------------------------------------------------
|
||||
| Exit Status Codes
|
||||
| --------------------------------------------------------------------------
|
||||
|
|
||||
| Used to indicate the conditions under which the script is exit()ing.
|
||||
| While there is no universal standard for error codes, there are some
|
||||
| broad conventions. Three such conventions are mentioned below, for
|
||||
| those who wish to make use of them. The CodeIgniter defaults were
|
||||
| chosen for the least overlap with these conventions, while still
|
||||
| leaving room for others to be defined in future versions and user
|
||||
| applications.
|
||||
|
|
||||
| The three main conventions used for determining exit status codes
|
||||
| are as follows:
|
||||
|
|
||||
| Standard C/C++ Library (stdlibc):
|
||||
| http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
|
||||
| (This link also contains other GNU-specific conventions)
|
||||
| BSD sysexits.h:
|
||||
| http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
|
||||
| Bash scripting:
|
||||
| http://tldp.org/LDP/abs/html/exitcodes.html
|
||||
|
|
||||
*/
|
||||
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
|
||||
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
|
||||
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error
|
||||
defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found
|
||||
defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class
|
||||
defined('EXIT_UNKNOWN_METHOD') || define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
|
||||
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input
|
||||
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error
|
||||
defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
|
||||
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code
|
||||
176
app/Config/ContentSecurityPolicy.php
Executable file
176
app/Config/ContentSecurityPolicy.php
Executable file
@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* Stores the default settings for the ContentSecurityPolicy, if you
|
||||
* choose to use it. The values here will be read in and set as defaults
|
||||
* for the site. If needed, they can be overridden on a page-by-page basis.
|
||||
*
|
||||
* Suggested reference for explanations:
|
||||
*
|
||||
* @see https://www.html5rocks.com/en/tutorials/security/content-security-policy/
|
||||
*/
|
||||
class ContentSecurityPolicy extends BaseConfig
|
||||
{
|
||||
// -------------------------------------------------------------------------
|
||||
// Broadbrush CSP management
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Default CSP report context
|
||||
*/
|
||||
public bool $reportOnly = false;
|
||||
|
||||
/**
|
||||
* Specifies a URL where a browser will send reports
|
||||
* when a content security policy is violated.
|
||||
*/
|
||||
public ?string $reportURI = null;
|
||||
|
||||
/**
|
||||
* Instructs user agents to rewrite URL schemes, changing
|
||||
* HTTP to HTTPS. This directive is for websites with
|
||||
* large numbers of old URLs that need to be rewritten.
|
||||
*/
|
||||
public bool $upgradeInsecureRequests = false;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Sources allowed
|
||||
// NOTE: once you set a policy to 'none', it cannot be further restricted
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Will default to self if not overridden
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $defaultSrc;
|
||||
|
||||
/**
|
||||
* Lists allowed scripts' URLs.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $scriptSrc = 'self';
|
||||
|
||||
/**
|
||||
* Lists allowed stylesheets' URLs.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $styleSrc = 'self';
|
||||
|
||||
/**
|
||||
* Defines the origins from which images can be loaded.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $imageSrc = 'self';
|
||||
|
||||
/**
|
||||
* Restricts the URLs that can appear in a page's `<base>` element.
|
||||
*
|
||||
* Will default to self if not overridden
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $baseURI;
|
||||
|
||||
/**
|
||||
* Lists the URLs for workers and embedded frame contents
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $childSrc = 'self';
|
||||
|
||||
/**
|
||||
* Limits the origins that you can connect to (via XHR,
|
||||
* WebSockets, and EventSource).
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $connectSrc = 'self';
|
||||
|
||||
/**
|
||||
* Specifies the origins that can serve web fonts.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $fontSrc;
|
||||
|
||||
/**
|
||||
* Lists valid endpoints for submission from `<form>` tags.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $formAction = 'self';
|
||||
|
||||
/**
|
||||
* Specifies the sources that can embed the current page.
|
||||
* This directive applies to `<frame>`, `<iframe>`, `<embed>`,
|
||||
* and `<applet>` tags. This directive can't be used in
|
||||
* `<meta>` tags and applies only to non-HTML resources.
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $frameAncestors;
|
||||
|
||||
/**
|
||||
* The frame-src directive restricts the URLs which may
|
||||
* be loaded into nested browsing contexts.
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $frameSrc;
|
||||
|
||||
/**
|
||||
* Restricts the origins allowed to deliver video and audio.
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $mediaSrc;
|
||||
|
||||
/**
|
||||
* Allows control over Flash and other plugins.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $objectSrc = 'self';
|
||||
|
||||
/**
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $manifestSrc;
|
||||
|
||||
/**
|
||||
* Limits the kinds of plugins a page may invoke.
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $pluginTypes;
|
||||
|
||||
/**
|
||||
* List of actions allowed.
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $sandbox;
|
||||
|
||||
/**
|
||||
* Nonce tag for style
|
||||
*/
|
||||
public string $styleNonceTag = '{csp-style-nonce}';
|
||||
|
||||
/**
|
||||
* Nonce tag for script
|
||||
*/
|
||||
public string $scriptNonceTag = '{csp-script-nonce}';
|
||||
|
||||
/**
|
||||
* Replace nonce tag automatically
|
||||
*/
|
||||
public bool $autoNonce = true;
|
||||
}
|
||||
107
app/Config/Cookie.php
Executable file
107
app/Config/Cookie.php
Executable file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use DateTimeInterface;
|
||||
|
||||
class Cookie extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Prefix
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Set a cookie name prefix if you need to avoid collisions.
|
||||
*/
|
||||
public string $prefix = '';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Expires Timestamp
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Default expires timestamp for cookies. Setting this to `0` will mean the
|
||||
* cookie will not have the `Expires` attribute and will behave as a session
|
||||
* cookie.
|
||||
*
|
||||
* @var DateTimeInterface|int|string
|
||||
*/
|
||||
public $expires = 0;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Path
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Typically will be a forward slash.
|
||||
*/
|
||||
public string $path = '/';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Domain
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Set to `.your-domain.com` for site-wide cookies.
|
||||
*/
|
||||
public string $domain = '';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Secure
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Cookie will only be set if a secure HTTPS connection exists.
|
||||
*/
|
||||
public bool $secure = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie HTTPOnly
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Cookie will only be accessible via HTTP(S) (no JavaScript).
|
||||
*/
|
||||
public bool $httponly = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie SameSite
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Configure cookie SameSite setting. Allowed values are:
|
||||
* - None
|
||||
* - Lax
|
||||
* - Strict
|
||||
* - ''
|
||||
*
|
||||
* Alternatively, you can use the constant names:
|
||||
* - `Cookie::SAMESITE_NONE`
|
||||
* - `Cookie::SAMESITE_LAX`
|
||||
* - `Cookie::SAMESITE_STRICT`
|
||||
*
|
||||
* Defaults to `Lax` for compatibility with modern browsers. Setting `''`
|
||||
* (empty string) means default SameSite attribute set by browsers (`Lax`)
|
||||
* will be set on cookies. If set to `None`, `$secure` must also be set.
|
||||
*
|
||||
* @phpstan-var 'None'|'Lax'|'Strict'|''
|
||||
*/
|
||||
public string $samesite = 'Lax';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Raw
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This flag allows setting a "raw" cookie, i.e., its name and value are
|
||||
* not URL encoded using `rawurlencode()`.
|
||||
*
|
||||
* If this is set to `true`, cookie names should be compliant of RFC 2616's
|
||||
* list of allowed characters.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes
|
||||
* @see https://tools.ietf.org/html/rfc2616#section-2.2
|
||||
*/
|
||||
public bool $raw = false;
|
||||
}
|
||||
105
app/Config/Cors.php
Executable file
105
app/Config/Cors.php
Executable file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* Cross-Origin Resource Sharing (CORS) Configuration
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
||||
*/
|
||||
class Cors extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* The default CORS configuration.
|
||||
*
|
||||
* @var array{
|
||||
* allowedOrigins: list<string>,
|
||||
* allowedOriginsPatterns: list<string>,
|
||||
* supportsCredentials: bool,
|
||||
* allowedHeaders: list<string>,
|
||||
* exposedHeaders: list<string>,
|
||||
* allowedMethods: list<string>,
|
||||
* maxAge: int,
|
||||
* }
|
||||
*/
|
||||
public array $default = [
|
||||
/**
|
||||
* Origins for the `Access-Control-Allow-Origin` header.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
|
||||
*
|
||||
* E.g.:
|
||||
* - ['http://localhost:8080']
|
||||
* - ['https://www.example.com']
|
||||
*/
|
||||
'allowedOrigins' => [],
|
||||
|
||||
/**
|
||||
* Origin regex patterns for the `Access-Control-Allow-Origin` header.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
|
||||
*
|
||||
* NOTE: A pattern specified here is part of a regular expression. It will
|
||||
* be actually `#\A<pattern>\z#`.
|
||||
*
|
||||
* E.g.:
|
||||
* - ['https://\w+\.example\.com']
|
||||
*/
|
||||
'allowedOriginsPatterns' => [],
|
||||
|
||||
/**
|
||||
* Weather to send the `Access-Control-Allow-Credentials` header.
|
||||
*
|
||||
* The Access-Control-Allow-Credentials response header tells browsers whether
|
||||
* the server allows cross-origin HTTP requests to include credentials.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
|
||||
*/
|
||||
'supportsCredentials' => false,
|
||||
|
||||
/**
|
||||
* Set headers to allow.
|
||||
*
|
||||
* The Access-Control-Allow-Headers response header is used in response to
|
||||
* a preflight request which includes the Access-Control-Request-Headers to
|
||||
* indicate which HTTP headers can be used during the actual request.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
|
||||
*/
|
||||
'allowedHeaders' => [],
|
||||
|
||||
/**
|
||||
* Set headers to expose.
|
||||
*
|
||||
* The Access-Control-Expose-Headers response header allows a server to
|
||||
* indicate which response headers should be made available to scripts running
|
||||
* in the browser, in response to a cross-origin request.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers
|
||||
*/
|
||||
'exposedHeaders' => [],
|
||||
|
||||
/**
|
||||
* Set methods to allow.
|
||||
*
|
||||
* The Access-Control-Allow-Methods response header specifies one or more
|
||||
* methods allowed when accessing a resource in response to a preflight
|
||||
* request.
|
||||
*
|
||||
* E.g.:
|
||||
* - ['GET', 'POST', 'PUT', 'DELETE']
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods
|
||||
*/
|
||||
'allowedMethods' => [],
|
||||
|
||||
/**
|
||||
* Set how many seconds the results of a preflight request can be cached.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
|
||||
*/
|
||||
'maxAge' => 7200,
|
||||
];
|
||||
}
|
||||
203
app/Config/Database.php
Executable file
203
app/Config/Database.php
Executable file
@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Database\Config;
|
||||
|
||||
/**
|
||||
* Database Configuration
|
||||
*/
|
||||
class Database extends Config
|
||||
{
|
||||
/**
|
||||
* The directory that holds the Migrations and Seeds directories.
|
||||
*/
|
||||
public string $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR;
|
||||
|
||||
/**
|
||||
* Lets you choose which connection group to use if no other is specified.
|
||||
*/
|
||||
public string $defaultGroup = 'default';
|
||||
|
||||
/**
|
||||
* The default database connection.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
public array $default = [
|
||||
'DSN' => '',
|
||||
'hostname' => 'localhost',
|
||||
'username' => '',
|
||||
'password' => '',
|
||||
'database' => '',
|
||||
'DBDriver' => 'MySQLi',
|
||||
'DBPrefix' => '',
|
||||
'pConnect' => false,
|
||||
'DBDebug' => true,
|
||||
'charset' => 'utf8mb4',
|
||||
'DBCollat' => 'utf8mb4_general_ci',
|
||||
'swapPre' => '',
|
||||
'encrypt' => false,
|
||||
'compress' => false,
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
'port' => 3306,
|
||||
'numberNative' => false,
|
||||
'foundRows' => false,
|
||||
'dateFormat' => [
|
||||
'date' => 'Y-m-d',
|
||||
'datetime' => 'Y-m-d H:i:s',
|
||||
'time' => 'H:i:s',
|
||||
],
|
||||
];
|
||||
|
||||
// /**
|
||||
// * Sample database connection for SQLite3.
|
||||
// *
|
||||
// * @var array<string, mixed>
|
||||
// */
|
||||
// public array $default = [
|
||||
// 'database' => 'database.db',
|
||||
// 'DBDriver' => 'SQLite3',
|
||||
// 'DBPrefix' => '',
|
||||
// 'DBDebug' => true,
|
||||
// 'swapPre' => '',
|
||||
// 'failover' => [],
|
||||
// 'foreignKeys' => true,
|
||||
// 'busyTimeout' => 1000,
|
||||
// 'synchronous' => null,
|
||||
// 'dateFormat' => [
|
||||
// 'date' => 'Y-m-d',
|
||||
// 'datetime' => 'Y-m-d H:i:s',
|
||||
// 'time' => 'H:i:s',
|
||||
// ],
|
||||
// ];
|
||||
|
||||
// /**
|
||||
// * Sample database connection for Postgre.
|
||||
// *
|
||||
// * @var array<string, mixed>
|
||||
// */
|
||||
// public array $default = [
|
||||
// 'DSN' => '',
|
||||
// 'hostname' => 'localhost',
|
||||
// 'username' => 'root',
|
||||
// 'password' => 'root',
|
||||
// 'database' => 'ci4',
|
||||
// 'schema' => 'public',
|
||||
// 'DBDriver' => 'Postgre',
|
||||
// 'DBPrefix' => '',
|
||||
// 'pConnect' => false,
|
||||
// 'DBDebug' => true,
|
||||
// 'charset' => 'utf8',
|
||||
// 'swapPre' => '',
|
||||
// 'failover' => [],
|
||||
// 'port' => 5432,
|
||||
// 'dateFormat' => [
|
||||
// 'date' => 'Y-m-d',
|
||||
// 'datetime' => 'Y-m-d H:i:s',
|
||||
// 'time' => 'H:i:s',
|
||||
// ],
|
||||
// ];
|
||||
|
||||
// /**
|
||||
// * Sample database connection for SQLSRV.
|
||||
// *
|
||||
// * @var array<string, mixed>
|
||||
// */
|
||||
// public array $default = [
|
||||
// 'DSN' => '',
|
||||
// 'hostname' => 'localhost',
|
||||
// 'username' => 'root',
|
||||
// 'password' => 'root',
|
||||
// 'database' => 'ci4',
|
||||
// 'schema' => 'dbo',
|
||||
// 'DBDriver' => 'SQLSRV',
|
||||
// 'DBPrefix' => '',
|
||||
// 'pConnect' => false,
|
||||
// 'DBDebug' => true,
|
||||
// 'charset' => 'utf8',
|
||||
// 'swapPre' => '',
|
||||
// 'encrypt' => false,
|
||||
// 'failover' => [],
|
||||
// 'port' => 1433,
|
||||
// 'dateFormat' => [
|
||||
// 'date' => 'Y-m-d',
|
||||
// 'datetime' => 'Y-m-d H:i:s',
|
||||
// 'time' => 'H:i:s',
|
||||
// ],
|
||||
// ];
|
||||
|
||||
// /**
|
||||
// * Sample database connection for OCI8.
|
||||
// *
|
||||
// * You may need the following environment variables:
|
||||
// * NLS_LANG = 'AMERICAN_AMERICA.UTF8'
|
||||
// * NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
|
||||
// * NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
|
||||
// * NLS_TIMESTAMP_TZ_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
|
||||
// *
|
||||
// * @var array<string, mixed>
|
||||
// */
|
||||
// public array $default = [
|
||||
// 'DSN' => 'localhost:1521/XEPDB1',
|
||||
// 'username' => 'root',
|
||||
// 'password' => 'root',
|
||||
// 'DBDriver' => 'OCI8',
|
||||
// 'DBPrefix' => '',
|
||||
// 'pConnect' => false,
|
||||
// 'DBDebug' => true,
|
||||
// 'charset' => 'AL32UTF8',
|
||||
// 'swapPre' => '',
|
||||
// 'failover' => [],
|
||||
// 'dateFormat' => [
|
||||
// 'date' => 'Y-m-d',
|
||||
// 'datetime' => 'Y-m-d H:i:s',
|
||||
// 'time' => 'H:i:s',
|
||||
// ],
|
||||
// ];
|
||||
|
||||
/**
|
||||
* This database connection is used when running PHPUnit database tests.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
public array $tests = [
|
||||
'DSN' => '',
|
||||
'hostname' => '127.0.0.1',
|
||||
'username' => '',
|
||||
'password' => '',
|
||||
'database' => ':memory:',
|
||||
'DBDriver' => 'SQLite3',
|
||||
'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
|
||||
'pConnect' => false,
|
||||
'DBDebug' => true,
|
||||
'charset' => 'utf8',
|
||||
'DBCollat' => '',
|
||||
'swapPre' => '',
|
||||
'encrypt' => false,
|
||||
'compress' => false,
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
'port' => 3306,
|
||||
'foreignKeys' => true,
|
||||
'busyTimeout' => 1000,
|
||||
'dateFormat' => [
|
||||
'date' => 'Y-m-d',
|
||||
'datetime' => 'Y-m-d H:i:s',
|
||||
'time' => 'H:i:s',
|
||||
],
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Ensure that we always set the database group to 'tests' if
|
||||
// we are currently running an automated test suite, so that
|
||||
// we don't overwrite live data on accident.
|
||||
if (ENVIRONMENT === 'testing') {
|
||||
$this->defaultGroup = 'tests';
|
||||
}
|
||||
}
|
||||
}
|
||||
46
app/Config/DocTypes.php
Executable file
46
app/Config/DocTypes.php
Executable file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* @immutable
|
||||
*/
|
||||
class DocTypes
|
||||
{
|
||||
/**
|
||||
* List of valid document types.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $list = [
|
||||
'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
|
||||
'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
|
||||
'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
|
||||
'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
|
||||
'xhtml-basic11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">',
|
||||
'html5' => '<!DOCTYPE html>',
|
||||
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
|
||||
'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
|
||||
'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
|
||||
'mathml1' => '<!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd">',
|
||||
'mathml2' => '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">',
|
||||
'svg10' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
|
||||
'svg11' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
|
||||
'svg11-basic' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">',
|
||||
'svg11-tiny' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">',
|
||||
'xhtml-math-svg-xh' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
|
||||
'xhtml-math-svg-sh' => '<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
|
||||
'xhtml-rdfa-1' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
|
||||
'xhtml-rdfa-2' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">',
|
||||
];
|
||||
|
||||
/**
|
||||
* Whether to remove the solidus (`/`) character for void HTML elements (e.g. `<input>`)
|
||||
* for HTML5 compatibility.
|
||||
*
|
||||
* Set to:
|
||||
* `true` - to be HTML5 compatible
|
||||
* `false` - to be XHTML compatible
|
||||
*/
|
||||
public bool $html5 = true;
|
||||
}
|
||||
121
app/Config/Email.php
Executable file
121
app/Config/Email.php
Executable file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Email extends BaseConfig
|
||||
{
|
||||
public string $fromEmail = '';
|
||||
public string $fromName = '';
|
||||
public string $recipients = '';
|
||||
|
||||
/**
|
||||
* The "user agent"
|
||||
*/
|
||||
public string $userAgent = 'CodeIgniter';
|
||||
|
||||
/**
|
||||
* The mail sending protocol: mail, sendmail, smtp
|
||||
*/
|
||||
public string $protocol = 'mail';
|
||||
|
||||
/**
|
||||
* The server path to Sendmail.
|
||||
*/
|
||||
public string $mailPath = '/usr/sbin/sendmail';
|
||||
|
||||
/**
|
||||
* SMTP Server Hostname
|
||||
*/
|
||||
public string $SMTPHost = '';
|
||||
|
||||
/**
|
||||
* SMTP Username
|
||||
*/
|
||||
public string $SMTPUser = '';
|
||||
|
||||
/**
|
||||
* SMTP Password
|
||||
*/
|
||||
public string $SMTPPass = '';
|
||||
|
||||
/**
|
||||
* SMTP Port
|
||||
*/
|
||||
public int $SMTPPort = 25;
|
||||
|
||||
/**
|
||||
* SMTP Timeout (in seconds)
|
||||
*/
|
||||
public int $SMTPTimeout = 5;
|
||||
|
||||
/**
|
||||
* Enable persistent SMTP connections
|
||||
*/
|
||||
public bool $SMTPKeepAlive = false;
|
||||
|
||||
/**
|
||||
* SMTP Encryption.
|
||||
*
|
||||
* @var string '', 'tls' or 'ssl'. 'tls' will issue a STARTTLS command
|
||||
* to the server. 'ssl' means implicit SSL. Connection on port
|
||||
* 465 should set this to ''.
|
||||
*/
|
||||
public string $SMTPCrypto = 'tls';
|
||||
|
||||
/**
|
||||
* Enable word-wrap
|
||||
*/
|
||||
public bool $wordWrap = true;
|
||||
|
||||
/**
|
||||
* Character count to wrap at
|
||||
*/
|
||||
public int $wrapChars = 76;
|
||||
|
||||
/**
|
||||
* Type of mail, either 'text' or 'html'
|
||||
*/
|
||||
public string $mailType = 'text';
|
||||
|
||||
/**
|
||||
* Character set (utf-8, iso-8859-1, etc.)
|
||||
*/
|
||||
public string $charset = 'UTF-8';
|
||||
|
||||
/**
|
||||
* Whether to validate the email address
|
||||
*/
|
||||
public bool $validate = false;
|
||||
|
||||
/**
|
||||
* Email Priority. 1 = highest. 5 = lowest. 3 = normal
|
||||
*/
|
||||
public int $priority = 3;
|
||||
|
||||
/**
|
||||
* Newline character. (Use “\r\n” to comply with RFC 822)
|
||||
*/
|
||||
public string $CRLF = "\r\n";
|
||||
|
||||
/**
|
||||
* Newline character. (Use “\r\n” to comply with RFC 822)
|
||||
*/
|
||||
public string $newline = "\r\n";
|
||||
|
||||
/**
|
||||
* Enable BCC Batch Mode.
|
||||
*/
|
||||
public bool $BCCBatchMode = false;
|
||||
|
||||
/**
|
||||
* Number of emails in each BCC batch
|
||||
*/
|
||||
public int $BCCBatchSize = 200;
|
||||
|
||||
/**
|
||||
* Enable notify message from server
|
||||
*/
|
||||
public bool $DSN = false;
|
||||
}
|
||||
92
app/Config/Encryption.php
Executable file
92
app/Config/Encryption.php
Executable file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* Encryption configuration.
|
||||
*
|
||||
* These are the settings used for encryption, if you don't pass a parameter
|
||||
* array to the encrypter for creation/initialization.
|
||||
*/
|
||||
class Encryption extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Encryption Key Starter
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If you use the Encryption class you must set an encryption key (seed).
|
||||
* You need to ensure it is long enough for the cipher and mode you plan to use.
|
||||
* See the user guide for more info.
|
||||
*/
|
||||
public string $key = '';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Encryption Driver to Use
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* One of the supported encryption drivers.
|
||||
*
|
||||
* Available drivers:
|
||||
* - OpenSSL
|
||||
* - Sodium
|
||||
*/
|
||||
public string $driver = 'OpenSSL';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* SodiumHandler's Padding Length in Bytes
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is the number of bytes that will be padded to the plaintext message
|
||||
* before it is encrypted. This value should be greater than zero.
|
||||
*
|
||||
* See the user guide for more information on padding.
|
||||
*/
|
||||
public int $blockSize = 16;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Encryption digest
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* HMAC digest to use, e.g. 'SHA512' or 'SHA256'. Default value is 'SHA512'.
|
||||
*/
|
||||
public string $digest = 'SHA512';
|
||||
|
||||
/**
|
||||
* Whether the cipher-text should be raw. If set to false, then it will be base64 encoded.
|
||||
* This setting is only used by OpenSSLHandler.
|
||||
*
|
||||
* Set to false for CI3 Encryption compatibility.
|
||||
*/
|
||||
public bool $rawData = true;
|
||||
|
||||
/**
|
||||
* Encryption key info.
|
||||
* This setting is only used by OpenSSLHandler.
|
||||
*
|
||||
* Set to 'encryption' for CI3 Encryption compatibility.
|
||||
*/
|
||||
public string $encryptKeyInfo = '';
|
||||
|
||||
/**
|
||||
* Authentication key info.
|
||||
* This setting is only used by OpenSSLHandler.
|
||||
*
|
||||
* Set to 'authentication' for CI3 Encryption compatibility.
|
||||
*/
|
||||
public string $authKeyInfo = '';
|
||||
|
||||
/**
|
||||
* Cipher to use.
|
||||
* This setting is only used by OpenSSLHandler.
|
||||
*
|
||||
* Set to 'AES-128-CBC' to decrypt encrypted data that encrypted
|
||||
* by CI3 Encryption default configuration.
|
||||
*/
|
||||
public string $cipher = 'AES-256-CTR';
|
||||
}
|
||||
55
app/Config/Events.php
Executable file
55
app/Config/Events.php
Executable file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Events\Events;
|
||||
use CodeIgniter\Exceptions\FrameworkException;
|
||||
use CodeIgniter\HotReloader\HotReloader;
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Application Events
|
||||
* --------------------------------------------------------------------
|
||||
* Events allow you to tap into the execution of the program without
|
||||
* modifying or extending core files. This file provides a central
|
||||
* location to define your events, though they can always be added
|
||||
* at run-time, also, if needed.
|
||||
*
|
||||
* You create code that can execute by subscribing to events with
|
||||
* the 'on()' method. This accepts any form of callable, including
|
||||
* Closures, that will be executed when the event is triggered.
|
||||
*
|
||||
* Example:
|
||||
* Events::on('create', [$myInstance, 'myMethod']);
|
||||
*/
|
||||
|
||||
Events::on('pre_system', static function (): void {
|
||||
if (ENVIRONMENT !== 'testing') {
|
||||
if (ini_get('zlib.output_compression')) {
|
||||
throw FrameworkException::forEnabledZlibOutputCompression();
|
||||
}
|
||||
|
||||
while (ob_get_level() > 0) {
|
||||
ob_end_flush();
|
||||
}
|
||||
|
||||
ob_start(static fn ($buffer) => $buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Debug Toolbar Listeners.
|
||||
* --------------------------------------------------------------------
|
||||
* If you delete, they will no longer be collected.
|
||||
*/
|
||||
if (CI_DEBUG && ! is_cli()) {
|
||||
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
|
||||
service('toolbar')->respond();
|
||||
// Hot Reload route - for framework use on the hot reloader.
|
||||
if (ENVIRONMENT === 'development') {
|
||||
service('routes')->get('__hot-reload', static function (): void {
|
||||
(new HotReloader())->run();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
106
app/Config/Exceptions.php
Executable file
106
app/Config/Exceptions.php
Executable file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Debug\ExceptionHandler;
|
||||
use CodeIgniter\Debug\ExceptionHandlerInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Setup how the exception handler works.
|
||||
*/
|
||||
class Exceptions extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* LOG EXCEPTIONS?
|
||||
* --------------------------------------------------------------------------
|
||||
* If true, then exceptions will be logged
|
||||
* through Services::Log.
|
||||
*
|
||||
* Default: true
|
||||
*/
|
||||
public bool $log = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* DO NOT LOG STATUS CODES
|
||||
* --------------------------------------------------------------------------
|
||||
* Any status codes here will NOT be logged if logging is turned on.
|
||||
* By default, only 404 (Page Not Found) exceptions are ignored.
|
||||
*
|
||||
* @var list<int>
|
||||
*/
|
||||
public array $ignoreCodes = [404];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Error Views Path
|
||||
* --------------------------------------------------------------------------
|
||||
* This is the path to the directory that contains the 'cli' and 'html'
|
||||
* directories that hold the views used to generate errors.
|
||||
*
|
||||
* Default: APPPATH.'Views/errors'
|
||||
*/
|
||||
public string $errorViewPath = APPPATH . 'Views/errors';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* HIDE FROM DEBUG TRACE
|
||||
* --------------------------------------------------------------------------
|
||||
* Any data that you would like to hide from the debug trace.
|
||||
* In order to specify 2 levels, use "/" to separate.
|
||||
* ex. ['server', 'setup/password', 'secret_token']
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $sensitiveDataInTrace = [];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* WHETHER TO THROW AN EXCEPTION ON DEPRECATED ERRORS
|
||||
* --------------------------------------------------------------------------
|
||||
* If set to `true`, DEPRECATED errors are only logged and no exceptions are
|
||||
* thrown. This option also works for user deprecations.
|
||||
*/
|
||||
public bool $logDeprecations = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* LOG LEVEL THRESHOLD FOR DEPRECATIONS
|
||||
* --------------------------------------------------------------------------
|
||||
* If `$logDeprecations` is set to `true`, this sets the log level
|
||||
* to which the deprecation will be logged. This should be one of the log
|
||||
* levels recognized by PSR-3.
|
||||
*
|
||||
* The related `Config\Logger::$threshold` should be adjusted, if needed,
|
||||
* to capture logging the deprecations.
|
||||
*/
|
||||
public string $deprecationLogLevel = LogLevel::WARNING;
|
||||
|
||||
/*
|
||||
* DEFINE THE HANDLERS USED
|
||||
* --------------------------------------------------------------------------
|
||||
* Given the HTTP status code, returns exception handler that
|
||||
* should be used to deal with this error. By default, it will run CodeIgniter's
|
||||
* default handler and display the error information in the expected format
|
||||
* for CLI, HTTP, or AJAX requests, as determined by is_cli() and the expected
|
||||
* response format.
|
||||
*
|
||||
* Custom handlers can be returned if you want to handle one or more specific
|
||||
* error codes yourself like:
|
||||
*
|
||||
* if (in_array($statusCode, [400, 404, 500])) {
|
||||
* return new \App\Libraries\MyExceptionHandler();
|
||||
* }
|
||||
* if ($exception instanceOf PageNotFoundException) {
|
||||
* return new \App\Libraries\MyExceptionHandler();
|
||||
* }
|
||||
*/
|
||||
public function handler(int $statusCode, Throwable $exception): ExceptionHandlerInterface
|
||||
{
|
||||
return new ExceptionHandler($this);
|
||||
}
|
||||
}
|
||||
37
app/Config/Feature.php
Executable file
37
app/Config/Feature.php
Executable file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* Enable/disable backward compatibility breaking features.
|
||||
*/
|
||||
class Feature extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* Use improved new auto routing instead of the legacy version.
|
||||
*/
|
||||
public bool $autoRoutesImproved = true;
|
||||
|
||||
/**
|
||||
* Use filter execution order in 4.4 or before.
|
||||
*/
|
||||
public bool $oldFilterOrder = false;
|
||||
|
||||
/**
|
||||
* The behavior of `limit(0)` in Query Builder.
|
||||
*
|
||||
* If true, `limit(0)` returns all records. (the behavior of 4.4.x or before in version 4.x.)
|
||||
* If false, `limit(0)` returns no records. (the behavior of 3.1.9 or later in version 3.x.)
|
||||
*/
|
||||
public bool $limitZeroAsAll = true;
|
||||
|
||||
/**
|
||||
* Use strict location negotiation.
|
||||
*
|
||||
* By default, the locale is selected based on a loose comparison of the language code (ISO 639-1)
|
||||
* Enabling strict comparison will also consider the region code (ISO 3166-1 alpha-2).
|
||||
*/
|
||||
public bool $strictLocaleNegotiation = false;
|
||||
}
|
||||
115
app/Config/Filters.php
Executable file
115
app/Config/Filters.php
Executable file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\Filters as BaseFilters;
|
||||
use CodeIgniter\Filters\Cors;
|
||||
use CodeIgniter\Filters\CSRF;
|
||||
use CodeIgniter\Filters\DebugToolbar;
|
||||
use CodeIgniter\Filters\ForceHTTPS;
|
||||
use CodeIgniter\Filters\Honeypot;
|
||||
use CodeIgniter\Filters\InvalidChars;
|
||||
use CodeIgniter\Filters\PageCache;
|
||||
use CodeIgniter\Filters\PerformanceMetrics;
|
||||
use CodeIgniter\Filters\SecureHeaders;
|
||||
use App\Filters\JwtAuthFilter;
|
||||
use App\Filters\VerifyAppSignature;
|
||||
class Filters extends BaseFilters
|
||||
{
|
||||
/**
|
||||
* Configures aliases for Filter classes to
|
||||
* make reading things nicer and simpler.
|
||||
*
|
||||
* @var array<string, class-string|list<class-string>>
|
||||
*
|
||||
* [filter_name => classname]
|
||||
* or [filter_name => [classname1, classname2, ...]]
|
||||
*/
|
||||
public array $aliases = [
|
||||
'csrf' => CSRF::class,
|
||||
'toolbar' => DebugToolbar::class,
|
||||
'honeypot' => Honeypot::class,
|
||||
'invalidchars' => InvalidChars::class,
|
||||
'secureheaders' => SecureHeaders::class,
|
||||
'cors' => Cors::class,
|
||||
'forcehttps' => ForceHTTPS::class,
|
||||
'pagecache' => PageCache::class,
|
||||
'performance' => PerformanceMetrics::class,
|
||||
'jwtAuth' => JwtAuthFilter::class,
|
||||
'appSignature' => VerifyAppSignature::class,
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* List of special required filters.
|
||||
*
|
||||
* The filters listed here are special. They are applied before and after
|
||||
* other kinds of filters, and always applied even if a route does not exist.
|
||||
*
|
||||
* Filters set by default provide framework functionality. If removed,
|
||||
* those functions will no longer work.
|
||||
*
|
||||
* @see https://codeigniter.com/user_guide/incoming/filters.html#provided-filters
|
||||
*
|
||||
* @var array{before: list<string>, after: list<string>}
|
||||
*/
|
||||
public array $required = [
|
||||
'before' => [
|
||||
'forcehttps', // Force Global Secure Requests
|
||||
'pagecache', // Web Page Caching
|
||||
],
|
||||
'after' => [
|
||||
'pagecache', // Web Page Caching
|
||||
'performance', // Performance Metrics
|
||||
'toolbar', // Debug Toolbar
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* List of filter aliases that are always
|
||||
* applied before and after every request.
|
||||
*
|
||||
* @var array<string, array<string, array<string, string>>>|array<string, list<string>>
|
||||
*/
|
||||
public array $globals = [
|
||||
'before' => [
|
||||
// 'honeypot',
|
||||
// 'csrf',
|
||||
// 'invalidchars',
|
||||
],
|
||||
'after' => [
|
||||
// 'honeypot',
|
||||
// 'secureheaders',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* List of filter aliases that works on a
|
||||
* particular HTTP method (GET, POST, etc.).
|
||||
*
|
||||
* Example:
|
||||
* 'POST' => ['foo', 'bar']
|
||||
*
|
||||
* If you use this, you should disable auto-routing because auto-routing
|
||||
* permits any HTTP method to access a controller. Accessing the controller
|
||||
* with a method you don't expect could bypass the filter.
|
||||
*
|
||||
* @var array<string, list<string>>
|
||||
*/
|
||||
public array $methods = [];
|
||||
|
||||
/**
|
||||
* List of filter aliases that should run on any
|
||||
* before or after URI patterns.
|
||||
*
|
||||
* Example:
|
||||
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
|
||||
*
|
||||
* @var array<string, array<string, list<string>>>
|
||||
*/
|
||||
public array $filters = [];
|
||||
}
|
||||
12
app/Config/ForeignCharacters.php
Executable file
12
app/Config/ForeignCharacters.php
Executable file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\ForeignCharacters as BaseForeignCharacters;
|
||||
|
||||
/**
|
||||
* @immutable
|
||||
*/
|
||||
class ForeignCharacters extends BaseForeignCharacters
|
||||
{
|
||||
}
|
||||
64
app/Config/Format.php
Executable file
64
app/Config/Format.php
Executable file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Format\JSONFormatter;
|
||||
use CodeIgniter\Format\XMLFormatter;
|
||||
|
||||
class Format extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Available Response Formats
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* When you perform content negotiation with the request, these are the
|
||||
* available formats that your application supports. This is currently
|
||||
* only used with the API\ResponseTrait. A valid Formatter must exist
|
||||
* for the specified format.
|
||||
*
|
||||
* These formats are only checked when the data passed to the respond()
|
||||
* method is an array.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $supportedResponseFormats = [
|
||||
'application/json',
|
||||
'application/xml', // machine-readable XML
|
||||
'text/xml', // human-readable XML
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Formatters
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Lists the class to use to format responses with of a particular type.
|
||||
* For each mime type, list the class that should be used. Formatters
|
||||
* can be retrieved through the getFormatter() method.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $formatters = [
|
||||
'application/json' => JSONFormatter::class,
|
||||
'application/xml' => XMLFormatter::class,
|
||||
'text/xml' => XMLFormatter::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Formatters Options
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Additional Options to adjust default formatters behaviour.
|
||||
* For each mime type, list the additional options that should be used.
|
||||
*
|
||||
* @var array<string, int>
|
||||
*/
|
||||
public array $formatterOptions = [
|
||||
'application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
|
||||
'application/xml' => 0,
|
||||
'text/xml' => 0,
|
||||
];
|
||||
}
|
||||
44
app/Config/Generators.php
Executable file
44
app/Config/Generators.php
Executable file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Generators extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Generator Commands' Views
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This array defines the mapping of generator commands to the view files
|
||||
* they are using. If you need to customize them for your own, copy these
|
||||
* view files in your own folder and indicate the location here.
|
||||
*
|
||||
* You will notice that the views have special placeholders enclosed in
|
||||
* curly braces `{...}`. These placeholders are used internally by the
|
||||
* generator commands in processing replacements, thus you are warned
|
||||
* not to delete them or modify the names. If you will do so, you may
|
||||
* end up disrupting the scaffolding process and throw errors.
|
||||
*
|
||||
* YOU HAVE BEEN WARNED!
|
||||
*
|
||||
* @var array<string, array<string, string>|string>
|
||||
*/
|
||||
public array $views = [
|
||||
'make:cell' => [
|
||||
'class' => 'CodeIgniter\Commands\Generators\Views\cell.tpl.php',
|
||||
'view' => 'CodeIgniter\Commands\Generators\Views\cell_view.tpl.php',
|
||||
],
|
||||
'make:command' => 'CodeIgniter\Commands\Generators\Views\command.tpl.php',
|
||||
'make:config' => 'CodeIgniter\Commands\Generators\Views\config.tpl.php',
|
||||
'make:controller' => 'CodeIgniter\Commands\Generators\Views\controller.tpl.php',
|
||||
'make:entity' => 'CodeIgniter\Commands\Generators\Views\entity.tpl.php',
|
||||
'make:filter' => 'CodeIgniter\Commands\Generators\Views\filter.tpl.php',
|
||||
'make:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
|
||||
'make:model' => 'CodeIgniter\Commands\Generators\Views\model.tpl.php',
|
||||
'make:seeder' => 'CodeIgniter\Commands\Generators\Views\seeder.tpl.php',
|
||||
'make:validation' => 'CodeIgniter\Commands\Generators\Views\validation.tpl.php',
|
||||
'session:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
|
||||
];
|
||||
}
|
||||
42
app/Config/Honeypot.php
Executable file
42
app/Config/Honeypot.php
Executable file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Honeypot extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* Makes Honeypot visible or not to human
|
||||
*/
|
||||
public bool $hidden = true;
|
||||
|
||||
/**
|
||||
* Honeypot Label Content
|
||||
*/
|
||||
public string $label = 'Fill This Field';
|
||||
|
||||
/**
|
||||
* Honeypot Field Name
|
||||
*/
|
||||
public string $name = 'honeypot';
|
||||
|
||||
/**
|
||||
* Honeypot HTML Template
|
||||
*/
|
||||
public string $template = '<label>{label}</label><input type="text" name="{name}" value="">';
|
||||
|
||||
/**
|
||||
* Honeypot container
|
||||
*
|
||||
* If you enabled CSP, you can remove `style="display:none"`.
|
||||
*/
|
||||
public string $container = '<div style="display:none">{template}</div>';
|
||||
|
||||
/**
|
||||
* The id attribute for Honeypot container tag
|
||||
*
|
||||
* Used when CSP is enabled.
|
||||
*/
|
||||
public string $containerId = 'hpc';
|
||||
}
|
||||
31
app/Config/Images.php
Executable file
31
app/Config/Images.php
Executable file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Images\Handlers\GDHandler;
|
||||
use CodeIgniter\Images\Handlers\ImageMagickHandler;
|
||||
|
||||
class Images extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* Default handler used if no other handler is specified.
|
||||
*/
|
||||
public string $defaultHandler = 'gd';
|
||||
|
||||
/**
|
||||
* The path to the image library.
|
||||
* Required for ImageMagick, GraphicsMagick, or NetPBM.
|
||||
*/
|
||||
public string $libraryPath = '/usr/local/bin/convert';
|
||||
|
||||
/**
|
||||
* The available handler classes.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $handlers = [
|
||||
'gd' => GDHandler::class,
|
||||
'imagick' => ImageMagickHandler::class,
|
||||
];
|
||||
}
|
||||
63
app/Config/Kint.php
Executable file
63
app/Config/Kint.php
Executable file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use Kint\Parser\ConstructablePluginInterface;
|
||||
use Kint\Renderer\Rich\TabPluginInterface;
|
||||
use Kint\Renderer\Rich\ValuePluginInterface;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Kint
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* We use Kint's `RichRenderer` and `CLIRenderer`. This area contains options
|
||||
* that you can set to customize how Kint works for you.
|
||||
*
|
||||
* @see https://kint-php.github.io/kint/ for details on these settings.
|
||||
*/
|
||||
class Kint
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global Settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var list<class-string<ConstructablePluginInterface>|ConstructablePluginInterface>|null
|
||||
*/
|
||||
public $plugins;
|
||||
|
||||
public int $maxDepth = 6;
|
||||
public bool $displayCalledFrom = true;
|
||||
public bool $expanded = false;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RichRenderer Settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public string $richTheme = 'aante-light.css';
|
||||
public bool $richFolder = false;
|
||||
|
||||
/**
|
||||
* @var array<string, class-string<ValuePluginInterface>>|null
|
||||
*/
|
||||
public $richObjectPlugins;
|
||||
|
||||
/**
|
||||
* @var array<string, class-string<TabPluginInterface>>|null
|
||||
*/
|
||||
public $richTabPlugins;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CLI Settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public bool $cliColors = true;
|
||||
public bool $cliForceUTF8 = false;
|
||||
public bool $cliDetectWidth = true;
|
||||
public int $cliMinWidth = 40;
|
||||
}
|
||||
150
app/Config/Logger.php
Executable file
150
app/Config/Logger.php
Executable file
@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Log\Handlers\FileHandler;
|
||||
|
||||
class Logger extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Error Logging Threshold
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* You can enable error logging by setting a threshold over zero. The
|
||||
* threshold determines what gets logged. Any values below or equal to the
|
||||
* threshold will be logged.
|
||||
*
|
||||
* Threshold options are:
|
||||
*
|
||||
* - 0 = Disables logging, Error logging TURNED OFF
|
||||
* - 1 = Emergency Messages - System is unusable
|
||||
* - 2 = Alert Messages - Action Must Be Taken Immediately
|
||||
* - 3 = Critical Messages - Application component unavailable, unexpected exception.
|
||||
* - 4 = Runtime Errors - Don't need immediate action, but should be monitored.
|
||||
* - 5 = Warnings - Exceptional occurrences that are not errors.
|
||||
* - 6 = Notices - Normal but significant events.
|
||||
* - 7 = Info - Interesting events, like user logging in, etc.
|
||||
* - 8 = Debug - Detailed debug information.
|
||||
* - 9 = All Messages
|
||||
*
|
||||
* You can also pass an array with threshold levels to show individual error types
|
||||
*
|
||||
* array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages
|
||||
*
|
||||
* For a live site you'll usually enable Critical or higher (3) to be logged otherwise
|
||||
* your log files will fill up very fast.
|
||||
*
|
||||
* @var int|list<int>
|
||||
*/
|
||||
public $threshold = (ENVIRONMENT === 'production') ? 4 : 9;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Date Format for Logs
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Each item that is logged has an associated date. You can use PHP date
|
||||
* codes to set your own date formatting
|
||||
*/
|
||||
public string $dateFormat = 'Y-m-d H:i:s';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Log Handlers
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The logging system supports multiple actions to be taken when something
|
||||
* is logged. This is done by allowing for multiple Handlers, special classes
|
||||
* designed to write the log to their chosen destinations, whether that is
|
||||
* a file on the getServer, a cloud-based service, or even taking actions such
|
||||
* as emailing the dev team.
|
||||
*
|
||||
* Each handler is defined by the class name used for that handler, and it
|
||||
* MUST implement the `CodeIgniter\Log\Handlers\HandlerInterface` interface.
|
||||
*
|
||||
* The value of each key is an array of configuration items that are sent
|
||||
* to the constructor of each handler. The only required configuration item
|
||||
* is the 'handles' element, which must be an array of integer log levels.
|
||||
* This is most easily handled by using the constants defined in the
|
||||
* `Psr\Log\LogLevel` class.
|
||||
*
|
||||
* Handlers are executed in the order defined in this array, starting with
|
||||
* the handler on top and continuing down.
|
||||
*
|
||||
* @var array<class-string, array<string, int|list<string>|string>>
|
||||
*/
|
||||
public array $handlers = [
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* File Handler
|
||||
* --------------------------------------------------------------------
|
||||
*/
|
||||
FileHandler::class => [
|
||||
// The log levels that this handler will handle.
|
||||
'handles' => [
|
||||
'critical',
|
||||
'alert',
|
||||
'emergency',
|
||||
'debug',
|
||||
'error',
|
||||
'info',
|
||||
'notice',
|
||||
'warning',
|
||||
],
|
||||
|
||||
/*
|
||||
* The default filename extension for log files.
|
||||
* An extension of 'php' allows for protecting the log files via basic
|
||||
* scripting, when they are to be stored under a publicly accessible directory.
|
||||
*
|
||||
* NOTE: Leaving it blank will default to 'log'.
|
||||
*/
|
||||
'fileExtension' => '',
|
||||
|
||||
/*
|
||||
* The file system permissions to be applied on newly created log files.
|
||||
*
|
||||
* IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
|
||||
* integer notation (i.e. 0700, 0644, etc.)
|
||||
*/
|
||||
'filePermissions' => 0644,
|
||||
|
||||
/*
|
||||
* Logging Directory Path
|
||||
*
|
||||
* By default, logs are written to WRITEPATH . 'logs/'
|
||||
* Specify a different destination here, if desired.
|
||||
*/
|
||||
'path' => '',
|
||||
],
|
||||
|
||||
/*
|
||||
* The ChromeLoggerHandler requires the use of the Chrome web browser
|
||||
* and the ChromeLogger extension. Uncomment this block to use it.
|
||||
*/
|
||||
// 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => [
|
||||
// /*
|
||||
// * The log levels that this handler will handle.
|
||||
// */
|
||||
// 'handles' => ['critical', 'alert', 'emergency', 'debug',
|
||||
// 'error', 'info', 'notice', 'warning'],
|
||||
// ],
|
||||
|
||||
/*
|
||||
* The ErrorlogHandler writes the logs to PHP's native `error_log()` function.
|
||||
* Uncomment this block to use it.
|
||||
*/
|
||||
// 'CodeIgniter\Log\Handlers\ErrorlogHandler' => [
|
||||
// /* The log levels this handler can handle. */
|
||||
// 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'],
|
||||
//
|
||||
// /*
|
||||
// * The message type where the error should go. Can be 0 or 4, or use the
|
||||
// * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4)
|
||||
// */
|
||||
// 'messageType' => 0,
|
||||
// ],
|
||||
];
|
||||
}
|
||||
50
app/Config/Migrations.php
Executable file
50
app/Config/Migrations.php
Executable file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Migrations extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Enable/Disable Migrations
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Migrations are enabled by default.
|
||||
*
|
||||
* You should enable migrations whenever you intend to do a schema migration
|
||||
* and disable it back when you're done.
|
||||
*/
|
||||
public bool $enabled = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Migrations Table
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is the name of the table that will store the current migrations state.
|
||||
* When migrations runs it will store in a database table which migration
|
||||
* files have already been run.
|
||||
*/
|
||||
public string $table = 'migrations';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Timestamp Format
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is the format that will be used when creating new migrations
|
||||
* using the CLI command:
|
||||
* > php spark make:migration
|
||||
*
|
||||
* NOTE: if you set an unsupported format, migration runner will not find
|
||||
* your migration files.
|
||||
*
|
||||
* Supported formats:
|
||||
* - YmdHis_
|
||||
* - Y-m-d-His_
|
||||
* - Y_m_d_His_
|
||||
*/
|
||||
public string $timestampFormat = 'Y-m-d-His_';
|
||||
}
|
||||
536
app/Config/Mimes.php
Executable file
536
app/Config/Mimes.php
Executable file
@ -0,0 +1,536 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* Mimes
|
||||
*
|
||||
* This file contains an array of mime types. It is used by the
|
||||
* Upload class to help identify allowed file types.
|
||||
*
|
||||
* When more than one variation for an extension exist (like jpg, jpeg, etc)
|
||||
* the most common one should be first in the array to aid the guess*
|
||||
* methods. The same applies when more than one mime-type exists for a
|
||||
* single extension.
|
||||
*
|
||||
* When working with mime types, please make sure you have the ´fileinfo´
|
||||
* extension enabled to reliably detect the media types.
|
||||
*
|
||||
* @immutable
|
||||
*/
|
||||
class Mimes
|
||||
{
|
||||
/**
|
||||
* Map of extensions to mime types.
|
||||
*
|
||||
* @var array<string, list<string>|string>
|
||||
*/
|
||||
public static array $mimes = [
|
||||
'hqx' => [
|
||||
'application/mac-binhex40',
|
||||
'application/mac-binhex',
|
||||
'application/x-binhex40',
|
||||
'application/x-mac-binhex40',
|
||||
],
|
||||
'cpt' => 'application/mac-compactpro',
|
||||
'csv' => [
|
||||
'text/csv',
|
||||
'text/x-comma-separated-values',
|
||||
'text/comma-separated-values',
|
||||
'application/vnd.ms-excel',
|
||||
'application/x-csv',
|
||||
'text/x-csv',
|
||||
'application/csv',
|
||||
'application/excel',
|
||||
'application/vnd.msexcel',
|
||||
'text/plain',
|
||||
],
|
||||
'bin' => [
|
||||
'application/macbinary',
|
||||
'application/mac-binary',
|
||||
'application/octet-stream',
|
||||
'application/x-binary',
|
||||
'application/x-macbinary',
|
||||
],
|
||||
'dms' => 'application/octet-stream',
|
||||
'lha' => 'application/octet-stream',
|
||||
'lzh' => 'application/octet-stream',
|
||||
'exe' => [
|
||||
'application/octet-stream',
|
||||
'application/vnd.microsoft.portable-executable',
|
||||
'application/x-dosexec',
|
||||
'application/x-msdownload',
|
||||
],
|
||||
'class' => 'application/octet-stream',
|
||||
'psd' => [
|
||||
'application/x-photoshop',
|
||||
'image/vnd.adobe.photoshop',
|
||||
],
|
||||
'so' => 'application/octet-stream',
|
||||
'sea' => 'application/octet-stream',
|
||||
'dll' => 'application/octet-stream',
|
||||
'oda' => 'application/oda',
|
||||
'pdf' => [
|
||||
'application/pdf',
|
||||
'application/force-download',
|
||||
'application/x-download',
|
||||
],
|
||||
'ai' => [
|
||||
'application/pdf',
|
||||
'application/postscript',
|
||||
],
|
||||
'eps' => 'application/postscript',
|
||||
'ps' => 'application/postscript',
|
||||
'smi' => 'application/smil',
|
||||
'smil' => 'application/smil',
|
||||
'mif' => 'application/vnd.mif',
|
||||
'xls' => [
|
||||
'application/vnd.ms-excel',
|
||||
'application/msexcel',
|
||||
'application/x-msexcel',
|
||||
'application/x-ms-excel',
|
||||
'application/x-excel',
|
||||
'application/x-dos_ms_excel',
|
||||
'application/xls',
|
||||
'application/x-xls',
|
||||
'application/excel',
|
||||
'application/download',
|
||||
'application/vnd.ms-office',
|
||||
'application/msword',
|
||||
],
|
||||
'ppt' => [
|
||||
'application/vnd.ms-powerpoint',
|
||||
'application/powerpoint',
|
||||
'application/vnd.ms-office',
|
||||
'application/msword',
|
||||
],
|
||||
'pptx' => [
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
],
|
||||
'wbxml' => 'application/wbxml',
|
||||
'wmlc' => 'application/wmlc',
|
||||
'dcr' => 'application/x-director',
|
||||
'dir' => 'application/x-director',
|
||||
'dxr' => 'application/x-director',
|
||||
'dvi' => 'application/x-dvi',
|
||||
'gtar' => 'application/x-gtar',
|
||||
'gz' => 'application/x-gzip',
|
||||
'gzip' => 'application/x-gzip',
|
||||
'php' => [
|
||||
'application/x-php',
|
||||
'application/x-httpd-php',
|
||||
'application/php',
|
||||
'text/php',
|
||||
'text/x-php',
|
||||
'application/x-httpd-php-source',
|
||||
],
|
||||
'php4' => 'application/x-httpd-php',
|
||||
'php3' => 'application/x-httpd-php',
|
||||
'phtml' => 'application/x-httpd-php',
|
||||
'phps' => 'application/x-httpd-php-source',
|
||||
'js' => [
|
||||
'application/x-javascript',
|
||||
'text/plain',
|
||||
],
|
||||
'swf' => 'application/x-shockwave-flash',
|
||||
'sit' => 'application/x-stuffit',
|
||||
'tar' => 'application/x-tar',
|
||||
'tgz' => [
|
||||
'application/x-tar',
|
||||
'application/x-gzip-compressed',
|
||||
],
|
||||
'z' => 'application/x-compress',
|
||||
'xhtml' => 'application/xhtml+xml',
|
||||
'xht' => 'application/xhtml+xml',
|
||||
'zip' => [
|
||||
'application/x-zip',
|
||||
'application/zip',
|
||||
'application/x-zip-compressed',
|
||||
'application/s-compressed',
|
||||
'multipart/x-zip',
|
||||
],
|
||||
'rar' => [
|
||||
'application/vnd.rar',
|
||||
'application/x-rar',
|
||||
'application/rar',
|
||||
'application/x-rar-compressed',
|
||||
],
|
||||
'mid' => 'audio/midi',
|
||||
'midi' => 'audio/midi',
|
||||
'mpga' => 'audio/mpeg',
|
||||
'mp2' => 'audio/mpeg',
|
||||
'mp3' => [
|
||||
'audio/mpeg',
|
||||
'audio/mpg',
|
||||
'audio/mpeg3',
|
||||
'audio/mp3',
|
||||
],
|
||||
'aif' => [
|
||||
'audio/x-aiff',
|
||||
'audio/aiff',
|
||||
],
|
||||
'aiff' => [
|
||||
'audio/x-aiff',
|
||||
'audio/aiff',
|
||||
],
|
||||
'aifc' => 'audio/x-aiff',
|
||||
'ram' => 'audio/x-pn-realaudio',
|
||||
'rm' => 'audio/x-pn-realaudio',
|
||||
'rpm' => 'audio/x-pn-realaudio-plugin',
|
||||
'ra' => 'audio/x-realaudio',
|
||||
'rv' => 'video/vnd.rn-realvideo',
|
||||
'wav' => [
|
||||
'audio/x-wav',
|
||||
'audio/wave',
|
||||
'audio/wav',
|
||||
],
|
||||
'bmp' => [
|
||||
'image/bmp',
|
||||
'image/x-bmp',
|
||||
'image/x-bitmap',
|
||||
'image/x-xbitmap',
|
||||
'image/x-win-bitmap',
|
||||
'image/x-windows-bmp',
|
||||
'image/ms-bmp',
|
||||
'image/x-ms-bmp',
|
||||
'application/bmp',
|
||||
'application/x-bmp',
|
||||
'application/x-win-bitmap',
|
||||
],
|
||||
'gif' => 'image/gif',
|
||||
'jpg' => [
|
||||
'image/jpeg',
|
||||
'image/pjpeg',
|
||||
],
|
||||
'jpeg' => [
|
||||
'image/jpeg',
|
||||
'image/pjpeg',
|
||||
],
|
||||
'jpe' => [
|
||||
'image/jpeg',
|
||||
'image/pjpeg',
|
||||
],
|
||||
'jp2' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'j2k' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'jpf' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'jpg2' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'jpx' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'jpm' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'mj2' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'mjp2' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'png' => [
|
||||
'image/png',
|
||||
'image/x-png',
|
||||
],
|
||||
'webp' => 'image/webp',
|
||||
'tif' => 'image/tiff',
|
||||
'tiff' => 'image/tiff',
|
||||
'css' => [
|
||||
'text/css',
|
||||
'text/plain',
|
||||
],
|
||||
'html' => [
|
||||
'text/html',
|
||||
'text/plain',
|
||||
],
|
||||
'htm' => [
|
||||
'text/html',
|
||||
'text/plain',
|
||||
],
|
||||
'shtml' => [
|
||||
'text/html',
|
||||
'text/plain',
|
||||
],
|
||||
'txt' => 'text/plain',
|
||||
'text' => 'text/plain',
|
||||
'log' => [
|
||||
'text/plain',
|
||||
'text/x-log',
|
||||
],
|
||||
'rtx' => 'text/richtext',
|
||||
'rtf' => 'text/rtf',
|
||||
'xml' => [
|
||||
'application/xml',
|
||||
'text/xml',
|
||||
'text/plain',
|
||||
],
|
||||
'xsl' => [
|
||||
'application/xml',
|
||||
'text/xsl',
|
||||
'text/xml',
|
||||
],
|
||||
'mpeg' => 'video/mpeg',
|
||||
'mpg' => 'video/mpeg',
|
||||
'mpe' => 'video/mpeg',
|
||||
'qt' => 'video/quicktime',
|
||||
'mov' => 'video/quicktime',
|
||||
'avi' => [
|
||||
'video/x-msvideo',
|
||||
'video/msvideo',
|
||||
'video/avi',
|
||||
'application/x-troff-msvideo',
|
||||
],
|
||||
'movie' => 'video/x-sgi-movie',
|
||||
'doc' => [
|
||||
'application/msword',
|
||||
'application/vnd.ms-office',
|
||||
],
|
||||
'docx' => [
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/zip',
|
||||
'application/msword',
|
||||
'application/x-zip',
|
||||
],
|
||||
'dot' => [
|
||||
'application/msword',
|
||||
'application/vnd.ms-office',
|
||||
],
|
||||
'dotx' => [
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/zip',
|
||||
'application/msword',
|
||||
],
|
||||
'xlsx' => [
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/zip',
|
||||
'application/vnd.ms-excel',
|
||||
'application/msword',
|
||||
'application/x-zip',
|
||||
],
|
||||
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
|
||||
'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
|
||||
'word' => [
|
||||
'application/msword',
|
||||
'application/octet-stream',
|
||||
],
|
||||
'xl' => 'application/excel',
|
||||
'eml' => 'message/rfc822',
|
||||
'json' => [
|
||||
'application/json',
|
||||
'text/json',
|
||||
],
|
||||
'pem' => [
|
||||
'application/x-x509-user-cert',
|
||||
'application/x-pem-file',
|
||||
'application/octet-stream',
|
||||
],
|
||||
'p10' => [
|
||||
'application/x-pkcs10',
|
||||
'application/pkcs10',
|
||||
],
|
||||
'p12' => 'application/x-pkcs12',
|
||||
'p7a' => 'application/x-pkcs7-signature',
|
||||
'p7c' => [
|
||||
'application/pkcs7-mime',
|
||||
'application/x-pkcs7-mime',
|
||||
],
|
||||
'p7m' => [
|
||||
'application/pkcs7-mime',
|
||||
'application/x-pkcs7-mime',
|
||||
],
|
||||
'p7r' => 'application/x-pkcs7-certreqresp',
|
||||
'p7s' => 'application/pkcs7-signature',
|
||||
'crt' => [
|
||||
'application/x-x509-ca-cert',
|
||||
'application/x-x509-user-cert',
|
||||
'application/pkix-cert',
|
||||
],
|
||||
'crl' => [
|
||||
'application/pkix-crl',
|
||||
'application/pkcs-crl',
|
||||
],
|
||||
'der' => 'application/x-x509-ca-cert',
|
||||
'kdb' => 'application/octet-stream',
|
||||
'pgp' => 'application/pgp',
|
||||
'gpg' => 'application/gpg-keys',
|
||||
'sst' => 'application/octet-stream',
|
||||
'csr' => 'application/octet-stream',
|
||||
'rsa' => 'application/x-pkcs7',
|
||||
'cer' => [
|
||||
'application/pkix-cert',
|
||||
'application/x-x509-ca-cert',
|
||||
],
|
||||
'3g2' => 'video/3gpp2',
|
||||
'3gp' => [
|
||||
'video/3gp',
|
||||
'video/3gpp',
|
||||
],
|
||||
'mp4' => 'video/mp4',
|
||||
'm4a' => 'audio/x-m4a',
|
||||
'f4v' => [
|
||||
'video/mp4',
|
||||
'video/x-f4v',
|
||||
],
|
||||
'flv' => 'video/x-flv',
|
||||
'webm' => 'video/webm',
|
||||
'aac' => 'audio/x-acc',
|
||||
'm4u' => 'application/vnd.mpegurl',
|
||||
'm3u' => 'text/plain',
|
||||
'xspf' => 'application/xspf+xml',
|
||||
'vlc' => 'application/videolan',
|
||||
'wmv' => [
|
||||
'video/x-ms-wmv',
|
||||
'video/x-ms-asf',
|
||||
],
|
||||
'au' => 'audio/x-au',
|
||||
'ac3' => 'audio/ac3',
|
||||
'flac' => 'audio/x-flac',
|
||||
'ogg' => [
|
||||
'audio/ogg',
|
||||
'video/ogg',
|
||||
'application/ogg',
|
||||
],
|
||||
'kmz' => [
|
||||
'application/vnd.google-earth.kmz',
|
||||
'application/zip',
|
||||
'application/x-zip',
|
||||
],
|
||||
'kml' => [
|
||||
'application/vnd.google-earth.kml+xml',
|
||||
'application/xml',
|
||||
'text/xml',
|
||||
],
|
||||
'ics' => 'text/calendar',
|
||||
'ical' => 'text/calendar',
|
||||
'zsh' => 'text/x-scriptzsh',
|
||||
'7zip' => [
|
||||
'application/x-compressed',
|
||||
'application/x-zip-compressed',
|
||||
'application/zip',
|
||||
'multipart/x-zip',
|
||||
],
|
||||
'cdr' => [
|
||||
'application/cdr',
|
||||
'application/coreldraw',
|
||||
'application/x-cdr',
|
||||
'application/x-coreldraw',
|
||||
'image/cdr',
|
||||
'image/x-cdr',
|
||||
'zz-application/zz-winassoc-cdr',
|
||||
],
|
||||
'wma' => [
|
||||
'audio/x-ms-wma',
|
||||
'video/x-ms-asf',
|
||||
],
|
||||
'jar' => [
|
||||
'application/java-archive',
|
||||
'application/x-java-application',
|
||||
'application/x-jar',
|
||||
'application/x-compressed',
|
||||
],
|
||||
'svg' => [
|
||||
'image/svg+xml',
|
||||
'image/svg',
|
||||
'application/xml',
|
||||
'text/xml',
|
||||
],
|
||||
'vcf' => 'text/x-vcard',
|
||||
'srt' => [
|
||||
'text/srt',
|
||||
'text/plain',
|
||||
],
|
||||
'vtt' => [
|
||||
'text/vtt',
|
||||
'text/plain',
|
||||
],
|
||||
'ico' => [
|
||||
'image/x-icon',
|
||||
'image/x-ico',
|
||||
'image/vnd.microsoft.icon',
|
||||
],
|
||||
'stl' => [
|
||||
'application/sla',
|
||||
'application/vnd.ms-pki.stl',
|
||||
'application/x-navistyle',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Attempts to determine the best mime type for the given file extension.
|
||||
*
|
||||
* @return string|null The mime type found, or none if unable to determine.
|
||||
*/
|
||||
public static function guessTypeFromExtension(string $extension)
|
||||
{
|
||||
$extension = trim(strtolower($extension), '. ');
|
||||
|
||||
if (! array_key_exists($extension, static::$mimes)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return is_array(static::$mimes[$extension]) ? static::$mimes[$extension][0] : static::$mimes[$extension];
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to determine the best file extension for a given mime type.
|
||||
*
|
||||
* @param string|null $proposedExtension - default extension (in case there is more than one with the same mime type)
|
||||
*
|
||||
* @return string|null The extension determined, or null if unable to match.
|
||||
*/
|
||||
public static function guessExtensionFromType(string $type, ?string $proposedExtension = null)
|
||||
{
|
||||
$type = trim(strtolower($type), '. ');
|
||||
|
||||
$proposedExtension = trim(strtolower($proposedExtension ?? ''));
|
||||
|
||||
if (
|
||||
$proposedExtension !== ''
|
||||
&& array_key_exists($proposedExtension, static::$mimes)
|
||||
&& in_array($type, (array) static::$mimes[$proposedExtension], true)
|
||||
) {
|
||||
// The detected mime type matches with the proposed extension.
|
||||
return $proposedExtension;
|
||||
}
|
||||
|
||||
// Reverse check the mime type list if no extension was proposed.
|
||||
// This search is order sensitive!
|
||||
foreach (static::$mimes as $ext => $types) {
|
||||
if (in_array($type, (array) $types, true)) {
|
||||
return $ext;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
84
app/Config/Modules.php
Executable file
84
app/Config/Modules.php
Executable file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Modules\Modules as BaseModules;
|
||||
|
||||
/**
|
||||
* Modules Configuration.
|
||||
*
|
||||
* NOTE: This class is required prior to Autoloader instantiation,
|
||||
* and does not extend BaseConfig.
|
||||
*
|
||||
* @immutable
|
||||
*/
|
||||
class Modules extends BaseModules
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Enable Auto-Discovery?
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If true, then auto-discovery will happen across all elements listed in
|
||||
* $aliases below. If false, no auto-discovery will happen at all,
|
||||
* giving a slight performance boost.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $enabled = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Enable Auto-Discovery Within Composer Packages?
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If true, then auto-discovery will happen across all namespaces loaded
|
||||
* by Composer, as well as the namespaces configured locally.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $discoverInComposer = true;
|
||||
|
||||
/**
|
||||
* The Composer package list for Auto-Discovery
|
||||
* This setting is optional.
|
||||
*
|
||||
* E.g.:
|
||||
* [
|
||||
* 'only' => [
|
||||
* // List up all packages to auto-discover
|
||||
* 'codeigniter4/shield',
|
||||
* ],
|
||||
* ]
|
||||
* or
|
||||
* [
|
||||
* 'exclude' => [
|
||||
* // List up packages to exclude.
|
||||
* 'pestphp/pest',
|
||||
* ],
|
||||
* ]
|
||||
*
|
||||
* @var array{only?: list<string>, exclude?: list<string>}
|
||||
*/
|
||||
public $composerPackages = [];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Auto-Discovery Rules
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Aliases list of all discovery classes that will be active and used during
|
||||
* the current application request.
|
||||
*
|
||||
* If it is not listed, only the base application elements will be used.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public $aliases = [
|
||||
'events',
|
||||
'filters',
|
||||
'registrars',
|
||||
'routes',
|
||||
'services',
|
||||
];
|
||||
}
|
||||
32
app/Config/Optimize.php
Executable file
32
app/Config/Optimize.php
Executable file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* Optimization Configuration.
|
||||
*
|
||||
* NOTE: This class does not extend BaseConfig for performance reasons.
|
||||
* So you cannot replace the property values with Environment Variables.
|
||||
*
|
||||
* @immutable
|
||||
*/
|
||||
class Optimize
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Config Caching
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* @see https://codeigniter.com/user_guide/concepts/factories.html#config-caching
|
||||
*/
|
||||
public bool $configCacheEnabled = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Config Caching
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* @see https://codeigniter.com/user_guide/concepts/autoloader.html#file-locator-caching
|
||||
*/
|
||||
public bool $locatorCacheEnabled = false;
|
||||
}
|
||||
37
app/Config/Pager.php
Executable file
37
app/Config/Pager.php
Executable file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Pager extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Templates
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pagination links are rendered out using views to configure their
|
||||
* appearance. This array contains aliases and the view names to
|
||||
* use when rendering the links.
|
||||
*
|
||||
* Within each view, the Pager object will be available as $pager,
|
||||
* and the desired group as $pagerGroup;
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $templates = [
|
||||
'default_full' => 'CodeIgniter\Pager\Views\default_full',
|
||||
'default_simple' => 'CodeIgniter\Pager\Views\default_simple',
|
||||
'default_head' => 'CodeIgniter\Pager\Views\default_head',
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Items Per Page
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The default number of results shown in a single page.
|
||||
*/
|
||||
public int $perPage = 20;
|
||||
}
|
||||
80
app/Config/Paths.php
Executable file
80
app/Config/Paths.php
Executable file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* Paths
|
||||
*
|
||||
* Holds the paths that are used by the system to
|
||||
* locate the main directories, app, system, etc.
|
||||
*
|
||||
* Modifying these allows you to restructure your application,
|
||||
* share a system folder between multiple applications, and more.
|
||||
*
|
||||
* All paths are relative to the project's root folder.
|
||||
*
|
||||
* NOTE: This class is required prior to Autoloader instantiation,
|
||||
* and does not extend BaseConfig.
|
||||
*
|
||||
* @immutable
|
||||
*/
|
||||
class Paths
|
||||
{
|
||||
/**
|
||||
* ---------------------------------------------------------------
|
||||
* SYSTEM FOLDER NAME
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This must contain the name of your "system" folder. Include
|
||||
* the path if the folder is not in the same directory as this file.
|
||||
*/
|
||||
public string $systemDirectory = __DIR__ . '/../../system';
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------------------
|
||||
* APPLICATION FOLDER NAME
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* If you want this front controller to use a different "app"
|
||||
* folder than the default one you can set its name here. The folder
|
||||
* can also be renamed or relocated anywhere on your server. If
|
||||
* you do, use a full server path.
|
||||
*
|
||||
* @see http://codeigniter.com/user_guide/general/managing_apps.html
|
||||
*/
|
||||
public string $appDirectory = __DIR__ . '/..';
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------------------
|
||||
* WRITABLE DIRECTORY NAME
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This variable must contain the name of your "writable" directory.
|
||||
* The writable directory allows you to group all directories that
|
||||
* need write permission to a single place that can be tucked away
|
||||
* for maximum security, keeping it out of the app and/or
|
||||
* system directories.
|
||||
*/
|
||||
public string $writableDirectory = __DIR__ . '/../../writable';
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------------------
|
||||
* TESTS DIRECTORY NAME
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This variable must contain the name of your "tests" directory.
|
||||
*/
|
||||
public string $testsDirectory = __DIR__ . '/../../tests';
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------------------
|
||||
* VIEW DIRECTORY NAME
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This variable must contain the name of the directory that
|
||||
* contains the view files used by your application. By
|
||||
* default this is in `app/Views`. This value
|
||||
* is used when no value is provided to `Services::renderer()`.
|
||||
*/
|
||||
public string $viewDirectory = __DIR__ . '/../Views';
|
||||
}
|
||||
28
app/Config/Publisher.php
Executable file
28
app/Config/Publisher.php
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\Publisher as BasePublisher;
|
||||
|
||||
/**
|
||||
* Publisher Configuration
|
||||
*
|
||||
* Defines basic security restrictions for the Publisher class
|
||||
* to prevent abuse by injecting malicious files into a project.
|
||||
*/
|
||||
class Publisher extends BasePublisher
|
||||
{
|
||||
/**
|
||||
* A list of allowed destinations with a (pseudo-)regex
|
||||
* of allowed files for each destination.
|
||||
* Attempts to publish to directories not in this list will
|
||||
* result in a PublisherException. Files that do no fit the
|
||||
* pattern will cause copy/merge to fail.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public $restrictions = [
|
||||
ROOTPATH => '*',
|
||||
FCPATH => '#\.(s?css|js|map|html?|xml|json|webmanifest|ttf|eot|woff2?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i',
|
||||
];
|
||||
}
|
||||
187
app/Config/Routes.php
Executable file
187
app/Config/Routes.php
Executable file
@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
use CodeIgniter\Router\RouteCollection;
|
||||
|
||||
/**
|
||||
* @var RouteCollection $routes
|
||||
*/
|
||||
$routes->get('swagger', 'SwaggerController::view');
|
||||
$routes->get('swagger/json', 'SwaggerController::generate');
|
||||
|
||||
//Auth
|
||||
$routes->group('api', ['filter' => 'appSignature'], function ($routes) {
|
||||
|
||||
// Agent Login api
|
||||
$routes->post('auth/verifyAgentWithMobileNumber', 'AgentAuthController::verifyAgentWithMobileNumber');
|
||||
$routes->post('auth/verifyAgentWithEmailId', 'AgentAuthController::verifyAgentWithEmailId');
|
||||
$routes->post('auth/getVerifiedAgentData', 'AgentAuthController::getVerifiedAgentData');
|
||||
|
||||
// Staff Login api
|
||||
$routes->post('auth/verifyStaffWithMobileNumber', 'StaffAuthController::verifyStaffWithMobileNumber');
|
||||
$routes->post('auth/verifyStaffWithEmailId', 'StaffAuthController::verifyStaffWithEmailId');
|
||||
$routes->post('auth/getVerifiedStaffData', 'StaffAuthController::getVerifiedStaffData');
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//api's with token
|
||||
$routes->group('api', ['filter' => ["jwtAuth","appSignature"] ], function ($routes) {
|
||||
|
||||
$routes->get('user/refreshUserToken', 'AuthController::refreshUserToken');
|
||||
|
||||
|
||||
//Organization
|
||||
$routes->get('organizations', 'OrganizationController::index');
|
||||
$routes->get('organizations/find/(:num)', 'OrganizationController::find/$1');
|
||||
$routes->post('organizations/create', 'OrganizationController::create');
|
||||
$routes->put('organizations/update/(:num)', 'OrganizationController::update/$1');
|
||||
$routes->put('organizations/org-status/(:num)', 'OrganizationController::updateOrganizationStatus/$1');
|
||||
$routes->post('organizations/testMail', 'OrganizationController::testMail');
|
||||
|
||||
//Service
|
||||
$routes->get('service', 'OrganizationController::getServices');
|
||||
|
||||
//Group
|
||||
$routes->get('groups', 'OrganizationController::getGroups');
|
||||
$routes->get('groups/find/(:num)', 'OrganizationController::findGroup/$1');
|
||||
$routes->post('groups/create', 'OrganizationController::createGroup');
|
||||
$routes->put('groups/update/(:num)', 'OrganizationController::updateGroup/$1');
|
||||
$routes->put('groups/group-status/(:num)', 'OrganizationController::updateGroupStatus/$1');
|
||||
|
||||
//Policy
|
||||
$routes->get('policy', 'OrganizationController::getPolicy');
|
||||
$routes->get('policy/find/(:num)', 'OrganizationController::findPolicy/$1');
|
||||
$routes->post('policy/createOrUpdate', 'OrganizationController::createOrUpdatePolicy');
|
||||
$routes->put('policy/policy-status/(:num)', 'OrganizationController::updatePolicyStatus/$1');
|
||||
|
||||
//User
|
||||
$routes->get('users', 'UserController::index');
|
||||
$routes->get('agentList', 'UserController::agentList');
|
||||
$routes->get('users/find/(:num)', 'UserController::find/$1');
|
||||
$routes->post('users/create', 'UserController::create');
|
||||
$routes->put('users/update/(:num)', 'UserController::update/$1');
|
||||
$routes->put('user/user-status/(:num)', 'UserController::updateUserStatus/$1');
|
||||
$routes->put('user/user-password/(:num)', 'UserController::changePassword/$1');
|
||||
$routes->get('checkDuplicate', 'UserController::checkDuplicate');
|
||||
$routes->post('user/userUpload','UserController::userUpload');
|
||||
$routes->get('user/userUploadTemplate','UserController::userUploadTemplate');
|
||||
|
||||
|
||||
//Traveller
|
||||
$routes->get('travellers', 'TravellerController::index');
|
||||
$routes->post('travellers/create', 'TravellerController::create');
|
||||
$routes->get('travellers/find', 'TravellerController::find');
|
||||
$routes->put('travellers/update/(:num)', 'TravellerController::update/$1');
|
||||
$routes->get('travellers/find/name/(:any)', 'TravellerController::findByName/$1');
|
||||
$routes->get('travellers/find/email/(:any)', 'TravellerController::findByEmail/$1');
|
||||
$routes->get('travellers/find/mobile/(:any)', 'TravellerController::findByMobile/$1');
|
||||
|
||||
|
||||
//Plan
|
||||
$routes->get('plans', 'PlanController::index');
|
||||
$routes->put('plans/find/(:num)', 'PlanController::find/$1');
|
||||
$routes->post('plans/createOrEditPlan', 'PlanController::createOrEditPlan');
|
||||
$routes->post('plans/getForexPerdiem', 'PlanController::getForexPerdiem');
|
||||
$routes->post('plans/approvePlan', 'PlanController::approvePlan');
|
||||
$routes->post('plans/rejectPlan', 'PlanController::rejectPlan');
|
||||
$routes->get('plans/statusDashboard', 'PlanController::statusDashboard');
|
||||
$routes->get('plans/download', 'PlanController::downloadPlan');
|
||||
$routes->get('plans/view', 'PlanController::viewPlan');
|
||||
$routes->get('plans/findApprovalList', 'PlanController::findApprovalList');
|
||||
$routes->get('plans/findTravelAgentPlanList', 'PlanController::findTravelAgentPlanList');
|
||||
$routes->post('plans/addOrEditPlanRemark', 'PlanController::addOrEditPlanRemark');
|
||||
$routes->get('plans/getRemarksByPlanId', 'PlanController::getRemarksByPlanId');
|
||||
$routes->get('plans/forexDownload', 'PlanController::forexDownload');
|
||||
$routes->get('plans/cancle_plan', 'PlanController::canclePlan');
|
||||
$routes->get('plans/get_plan_approval_status', 'PlanController::get_plan_approval_status');
|
||||
$routes->get('plans/plan_pdf', 'PlanController::plan_pdf');
|
||||
$routes->get('plans/plan_policy_action_status', 'PlanController::plan_policy_action_status');
|
||||
|
||||
//Master
|
||||
$routes->get('getDropdownMaster', 'MasterController::getDropdownMaster');
|
||||
$routes->get('getTravelStatusMaster', 'MasterController::getTravelStatusMaster');
|
||||
$routes->get('getcountryMaster', 'MasterController::getcountryMaster');
|
||||
$routes->get('getAirportCodeMaster', 'MasterController::getAirportCodeMaster');
|
||||
$routes->get('getAirlineMaster', 'MasterController::getAirlineMaster');
|
||||
$routes->get('getTrainCodeMaster', 'MasterController::getTrainCodeMaster');
|
||||
$routes->get('getFlightAndTrainClass', 'MasterController::getFlightAndTrainClass');
|
||||
// Costcenter
|
||||
$routes->get('getCostCenterMaster', 'MasterController::getCostCenterMaster');
|
||||
$routes->post('createCostCenter', 'MasterController::createCostCenter');
|
||||
$routes->get('findCostCenter', 'MasterController::findCostCenter');
|
||||
$routes->put('updateCostCenter/(:num)', 'MasterController::updateCostCenter/$1');
|
||||
// Department Master
|
||||
$routes->get('getDepartmentList', 'MasterController::getDepartmentList');
|
||||
$routes->post('createDepartment', 'MasterController::createDepartment');
|
||||
$routes->get('findDepartment', 'MasterController::findDepartment');
|
||||
$routes->put('updateDepartment/(:num)', 'MasterController::updateDepartment/$1');
|
||||
// Purpose of travel Master
|
||||
$routes->get('getPurposeOfTravelList', 'MasterController::getPurposeOfTravelList');
|
||||
$routes->post('createPurposeOfTravel', 'MasterController::createPurposeOfTravel');
|
||||
$routes->get('findPurposeOfTravel', 'MasterController::findPurposeOfTravel');
|
||||
$routes->put('updatePurposeOfTravel/(:num)', 'MasterController::updatePurposeOfTravel/$1');
|
||||
// Forex Master
|
||||
$routes->get('getForexPerdiemList', 'MasterController::getForexPerdiemList');
|
||||
$routes->post('createForexPerdiem', 'MasterController::createForexPerdiem');
|
||||
$routes->get('findForexPerdiem', 'MasterController::findForexPerdiem');
|
||||
$routes->put('updateForexPerdiem/(:num)', 'MasterController::updateForexPerdiem/$1');
|
||||
$routes->post('forex_signature_upload', 'MasterController::forex_signature_upload');
|
||||
$routes->get('getForexSignaturePath', 'MasterController::getForexSignaturePath');
|
||||
// Hotels Master
|
||||
$routes->get('getHotels', 'MasterController::getHotels');
|
||||
$routes->post('createHotels', 'MasterController::createHotels');
|
||||
$routes->get('findHotels', 'MasterController::findHotels');
|
||||
$routes->put('updateHotels/(:num)', 'MasterController::updateHotels/$1');
|
||||
|
||||
|
||||
//mail template
|
||||
$routes->get('template', 'EmailTemplateController::index');
|
||||
$routes->put('template/find/(:num)', 'EmailTemplateController::find/$1');
|
||||
$routes->post('template/create', 'EmailTemplateController::create');
|
||||
$routes->put('template/update/(:num)', 'EmailTemplateController::update/$1');
|
||||
$routes->get('getForexTemplate', 'EmailTemplateController::getForexTemplate');
|
||||
|
||||
$routes->get('getRoles', 'UserController::roleList');
|
||||
|
||||
|
||||
$routes->post('advancePurchaseReport', 'ReportsController::advancePurchaseReport');
|
||||
$routes->post('misServicesAnalysis', 'ReportsController::misServicesAnalysis');
|
||||
$routes->post('misAirReport', 'ReportsController::misAirReport');
|
||||
$routes->post('misHotelReport', 'ReportsController::misHotelReport');
|
||||
$routes->post('misForexReport', 'ReportsController::misForexReport');
|
||||
$routes->post('guestHouseReport', 'ReportsController::guestHouseReport');
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
// plan review related signed url
|
||||
$routes->post('approvePlan', 'PlanController::approvePlan');
|
||||
$routes->post('rejectPlan', 'PlanController::rejectPlan');
|
||||
$routes->get('review', 'PlanController::protectedPage', ['filter' => 'signedUrl']);
|
||||
$routes->get('url', 'PlanController::url');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
140
app/Config/Routing.php
Executable file
140
app/Config/Routing.php
Executable file
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of CodeIgniter 4 framework.
|
||||
*
|
||||
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\Routing as BaseRouting;
|
||||
|
||||
/**
|
||||
* Routing configuration
|
||||
*/
|
||||
class Routing extends BaseRouting
|
||||
{
|
||||
/**
|
||||
* For Defined Routes.
|
||||
* An array of files that contain route definitions.
|
||||
* Route files are read in order, with the first match
|
||||
* found taking precedence.
|
||||
*
|
||||
* Default: APPPATH . 'Config/Routes.php'
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $routeFiles = [
|
||||
APPPATH . 'Config/Routes.php',
|
||||
];
|
||||
|
||||
/**
|
||||
* For Defined Routes and Auto Routing.
|
||||
* The default namespace to use for Controllers when no other
|
||||
* namespace has been specified.
|
||||
*
|
||||
* Default: 'App\Controllers'
|
||||
*/
|
||||
public string $defaultNamespace = 'App\Controllers';
|
||||
|
||||
/**
|
||||
* For Auto Routing.
|
||||
* The default controller to use when no other controller has been
|
||||
* specified.
|
||||
*
|
||||
* Default: 'Home'
|
||||
*/
|
||||
public string $defaultController = 'Home';
|
||||
|
||||
/**
|
||||
* For Defined Routes and Auto Routing.
|
||||
* The default method to call on the controller when no other
|
||||
* method has been set in the route.
|
||||
*
|
||||
* Default: 'index'
|
||||
*/
|
||||
public string $defaultMethod = 'index';
|
||||
|
||||
/**
|
||||
* For Auto Routing.
|
||||
* Whether to translate dashes in URIs for controller/method to underscores.
|
||||
* Primarily useful when using the auto-routing.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
public bool $translateURIDashes = false;
|
||||
|
||||
/**
|
||||
* Sets the class/method that should be called if routing doesn't
|
||||
* find a match. It can be the controller/method name like: Users::index
|
||||
*
|
||||
* This setting is passed to the Router class and handled there.
|
||||
*
|
||||
* If you want to use a closure, you will have to set it in the
|
||||
* routes file by calling:
|
||||
*
|
||||
* $routes->set404Override(function() {
|
||||
* // Do something here
|
||||
* });
|
||||
*
|
||||
* Example:
|
||||
* public $override404 = 'App\Errors::show404';
|
||||
*/
|
||||
public ?string $override404 = null;
|
||||
|
||||
/**
|
||||
* If TRUE, the system will attempt to match the URI against
|
||||
* Controllers by matching each segment against folders/files
|
||||
* in APPPATH/Controllers, when a match wasn't found against
|
||||
* defined routes.
|
||||
*
|
||||
* If FALSE, will stop searching and do NO automatic routing.
|
||||
*/
|
||||
public bool $autoRoute = false;
|
||||
|
||||
/**
|
||||
* For Defined Routes.
|
||||
* If TRUE, will enable the use of the 'prioritize' option
|
||||
* when defining routes.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
public bool $prioritize = false;
|
||||
|
||||
/**
|
||||
* For Defined Routes.
|
||||
* If TRUE, matched multiple URI segments will be passed as one parameter.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
public bool $multipleSegmentsOneParam = false;
|
||||
|
||||
/**
|
||||
* For Auto Routing (Improved).
|
||||
* Map of URI segments and namespaces.
|
||||
*
|
||||
* The key is the first URI segment. The value is the controller namespace.
|
||||
* E.g.,
|
||||
* [
|
||||
* 'blog' => 'Acme\Blog\Controllers',
|
||||
* ]
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $moduleRoutes = [];
|
||||
|
||||
/**
|
||||
* For Auto Routing (Improved).
|
||||
* Whether to translate dashes in URIs for controller/method to CamelCase.
|
||||
* E.g., blog-controller -> BlogController
|
||||
*
|
||||
* If you enable this, $translateURIDashes is ignored.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
public bool $translateUriToCamelCase = true;
|
||||
}
|
||||
100
app/Config/SamlSettings.php
Executable file
100
app/Config/SamlSettings.php
Executable file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class SamlSettings extends BaseConfig
|
||||
{
|
||||
|
||||
// IdP (Identity Provider)
|
||||
public $idpEntityId;
|
||||
public $idpSSOUrl;
|
||||
public $idpSLOUrl;
|
||||
public $idpX509Cert;
|
||||
|
||||
// SP (Service Provider)
|
||||
public $spEntityId;
|
||||
public $spAssertionConsumerServiceUrl;
|
||||
public $spSingleLogoutServiceUrl;
|
||||
public $spCert;
|
||||
public $spPrivateKey;
|
||||
|
||||
public $strict = true; // Enable strict mode
|
||||
public $debug = true; // Enable debug mode for development
|
||||
|
||||
private $publicCertPath;
|
||||
private $privateKeyPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Define idp details
|
||||
$this->idpEntityId = env('IDP_EntityId');
|
||||
$this->idpSSOUrl = env('IDP_SSOUrl');
|
||||
$this->idpSLOUrl = env('IDP_SLOUrl');
|
||||
$this->idpX509Cert = env('IDP_X509Cert');
|
||||
|
||||
|
||||
// Define the public and private key file paths
|
||||
$this->publicCertPath = ROOTPATH . 'sp_cert.pem';
|
||||
$this->privateKeyPath = ROOTPATH . 'sp_private_key.pem';
|
||||
|
||||
// Set SP URLs
|
||||
$this->spEntityId = base_url();
|
||||
$this->spAssertionConsumerServiceUrl = base_url() . 'acs';
|
||||
$this->spSingleLogoutServiceUrl = base_url() . 'logout';
|
||||
|
||||
// Load the public certificate
|
||||
$this->spCert = $this->loadFile($this->publicCertPath);
|
||||
|
||||
// Load the private key
|
||||
$this->spPrivateKey = $this->loadPrivateKey($this->privateKeyPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a file and return its contents.
|
||||
*
|
||||
* @param string $filePath Path to the file.
|
||||
* @return string The file contents.
|
||||
*/
|
||||
private function loadFile($filePath)
|
||||
{
|
||||
$fileContents = file_get_contents($filePath);
|
||||
|
||||
if ($fileContents === false) {
|
||||
die("Failed to load the public certificate from {$filePath}");
|
||||
}
|
||||
|
||||
return $fileContents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load and validate a private key.
|
||||
*
|
||||
* @param string $filePath Path to the private key file.
|
||||
* @return string The private key contents.
|
||||
*/
|
||||
private function loadPrivateKey($filePath)
|
||||
{
|
||||
$privateKey = file_get_contents($filePath);
|
||||
|
||||
if ($privateKey === false) {
|
||||
die("Failed to read private key from {$filePath}");
|
||||
}
|
||||
|
||||
// Validate the private key
|
||||
if (openssl_pkey_get_private($privateKey) === false) {
|
||||
die("Invalid private key at {$filePath}");
|
||||
}
|
||||
|
||||
return $privateKey;
|
||||
}
|
||||
|
||||
}
|
||||
86
app/Config/Security.php
Executable file
86
app/Config/Security.php
Executable file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Security extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Protection Method
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Protection Method for Cross Site Request Forgery protection.
|
||||
*
|
||||
* @var string 'cookie' or 'session'
|
||||
*/
|
||||
public string $csrfProtection = 'cookie';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Token Randomization
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Randomize the CSRF Token for added security.
|
||||
*/
|
||||
public bool $tokenRandomize = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Token Name
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Token name for Cross Site Request Forgery protection.
|
||||
*/
|
||||
public string $tokenName = 'csrf_test_name';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Header Name
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Header name for Cross Site Request Forgery protection.
|
||||
*/
|
||||
public string $headerName = 'X-CSRF-TOKEN';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Cookie Name
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Cookie name for Cross Site Request Forgery protection.
|
||||
*/
|
||||
public string $cookieName = 'csrf_cookie_name';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Expires
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Expiration time for Cross Site Request Forgery protection cookie.
|
||||
*
|
||||
* Defaults to two hours (in seconds).
|
||||
*/
|
||||
public int $expires = 7200;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Regenerate
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Regenerate CSRF Token on every submission.
|
||||
*/
|
||||
public bool $regenerate = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Redirect
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Redirect to previous page with error on failure.
|
||||
*
|
||||
* @see https://codeigniter4.github.io/userguide/libraries/security.html#redirection-on-failure
|
||||
*/
|
||||
public bool $redirect = (ENVIRONMENT === 'production');
|
||||
}
|
||||
32
app/Config/Services.php
Executable file
32
app/Config/Services.php
Executable file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseService;
|
||||
|
||||
/**
|
||||
* Services Configuration file.
|
||||
*
|
||||
* Services are simply other classes/libraries that the system uses
|
||||
* to do its job. This is used by CodeIgniter to allow the core of the
|
||||
* framework to be swapped out easily without affecting the usage within
|
||||
* the rest of your application.
|
||||
*
|
||||
* This file holds any application-specific services, or service overrides
|
||||
* that you might need. An example has been included with the general
|
||||
* method format you should use for your service methods. For more examples,
|
||||
* see the core Services file at system/Config/Services.php.
|
||||
*/
|
||||
class Services extends BaseService
|
||||
{
|
||||
/*
|
||||
* public static function example($getShared = true)
|
||||
* {
|
||||
* if ($getShared) {
|
||||
* return static::getSharedInstance('example');
|
||||
* }
|
||||
*
|
||||
* return new \CodeIgniter\Example();
|
||||
* }
|
||||
*/
|
||||
}
|
||||
127
app/Config/Session.php
Executable file
127
app/Config/Session.php
Executable file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Session\Handlers\BaseHandler;
|
||||
use CodeIgniter\Session\Handlers\FileHandler;
|
||||
|
||||
class Session extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Driver
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The session storage driver to use:
|
||||
* - `CodeIgniter\Session\Handlers\FileHandler`
|
||||
* - `CodeIgniter\Session\Handlers\DatabaseHandler`
|
||||
* - `CodeIgniter\Session\Handlers\MemcachedHandler`
|
||||
* - `CodeIgniter\Session\Handlers\RedisHandler`
|
||||
*
|
||||
* @var class-string<BaseHandler>
|
||||
*/
|
||||
public string $driver = FileHandler::class;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Cookie Name
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The session cookie name, must contain only [0-9a-z_-] characters
|
||||
*/
|
||||
public string $cookieName = 'ci_session';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Expiration
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The number of SECONDS you want the session to last.
|
||||
* Setting to 0 (zero) means expire when the browser is closed.
|
||||
*/
|
||||
public int $expiration = 7200;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Save Path
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The location to save sessions to and is driver dependent.
|
||||
*
|
||||
* For the 'files' driver, it's a path to a writable directory.
|
||||
* WARNING: Only absolute paths are supported!
|
||||
*
|
||||
* For the 'database' driver, it's a table name.
|
||||
* Please read up the manual for the format with other session drivers.
|
||||
*
|
||||
* IMPORTANT: You are REQUIRED to set a valid save path!
|
||||
*/
|
||||
public string $savePath = WRITEPATH . 'session';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Match IP
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Whether to match the user's IP address when reading the session data.
|
||||
*
|
||||
* WARNING: If you're using the database driver, don't forget to update
|
||||
* your session table's PRIMARY KEY when changing this setting.
|
||||
*/
|
||||
public bool $matchIP = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Time to Update
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* How many seconds between CI regenerating the session ID.
|
||||
*/
|
||||
public int $timeToUpdate = 300;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Regenerate Destroy
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Whether to destroy session data associated with the old session ID
|
||||
* when auto-regenerating the session ID. When set to FALSE, the data
|
||||
* will be later deleted by the garbage collector.
|
||||
*/
|
||||
public bool $regenerateDestroy = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Database Group
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* DB Group for the database session.
|
||||
*/
|
||||
public ?string $DBGroup = null;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Lock Retry Interval (microseconds)
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is used for RedisHandler.
|
||||
*
|
||||
* Time (microseconds) to wait if lock cannot be acquired.
|
||||
* The default is 100,000 microseconds (= 0.1 seconds).
|
||||
*/
|
||||
public int $lockRetryInterval = 100_000;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Lock Max Retries
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is used for RedisHandler.
|
||||
*
|
||||
* Maximum number of lock acquisition attempts.
|
||||
* The default is 300 times. That is lock timeout is about 30 (0.1 * 300)
|
||||
* seconds.
|
||||
*/
|
||||
public int $lockMaxRetries = 300;
|
||||
}
|
||||
122
app/Config/Toolbar.php
Executable file
122
app/Config/Toolbar.php
Executable file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Database;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Events;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Files;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Logs;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Routes;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Timers;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Views;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Debug Toolbar
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The Debug Toolbar provides a way to see information about the performance
|
||||
* and state of your application during that page display. By default it will
|
||||
* NOT be displayed under production environments, and will only display if
|
||||
* `CI_DEBUG` is true, since if it's not, there's not much to display anyway.
|
||||
*/
|
||||
class Toolbar extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Toolbar Collectors
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* List of toolbar collectors that will be called when Debug Toolbar
|
||||
* fires up and collects data from.
|
||||
*
|
||||
* @var list<class-string>
|
||||
*/
|
||||
public array $collectors = [
|
||||
Timers::class,
|
||||
Database::class,
|
||||
Logs::class,
|
||||
Views::class,
|
||||
// \CodeIgniter\Debug\Toolbar\Collectors\Cache::class,
|
||||
Files::class,
|
||||
Routes::class,
|
||||
Events::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Collect Var Data
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If set to false var data from the views will not be collected. Useful to
|
||||
* avoid high memory usage when there are lots of data passed to the view.
|
||||
*/
|
||||
public bool $collectVarData = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Max History
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* `$maxHistory` sets a limit on the number of past requests that are stored,
|
||||
* helping to conserve file space used to store them. You can set it to
|
||||
* 0 (zero) to not have any history stored, or -1 for unlimited history.
|
||||
*/
|
||||
public int $maxHistory = 20;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Toolbar Views Path
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The full path to the the views that are used by the toolbar.
|
||||
* This MUST have a trailing slash.
|
||||
*/
|
||||
public string $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Max Queries
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If the Database Collector is enabled, it will log every query that the
|
||||
* the system generates so they can be displayed on the toolbar's timeline
|
||||
* and in the query log. This can lead to memory issues in some instances
|
||||
* with hundreds of queries.
|
||||
*
|
||||
* `$maxQueries` defines the maximum amount of queries that will be stored.
|
||||
*/
|
||||
public int $maxQueries = 100;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Watched Directories
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Contains an array of directories that will be watched for changes and
|
||||
* used to determine if the hot-reload feature should reload the page or not.
|
||||
* We restrict the values to keep performance as high as possible.
|
||||
*
|
||||
* NOTE: The ROOTPATH will be prepended to all values.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $watchedDirectories = [
|
||||
'app',
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Watched File Extensions
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Contains an array of file extensions that will be watched for changes and
|
||||
* used to determine if the hot-reload feature should reload the page or not.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $watchedExtensions = [
|
||||
'php', 'css', 'js', 'html', 'svg', 'json', 'env',
|
||||
];
|
||||
}
|
||||
252
app/Config/UserAgents.php
Executable file
252
app/Config/UserAgents.php
Executable file
@ -0,0 +1,252 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* User Agents
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* This file contains four arrays of user agent data. It is used by the
|
||||
* User Agent Class to help identify browser, platform, robot, and
|
||||
* mobile device data. The array keys are used to identify the device
|
||||
* and the array values are used to set the actual name of the item.
|
||||
*/
|
||||
class UserAgents extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* OS Platforms
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $platforms = [
|
||||
'windows nt 10.0' => 'Windows 10',
|
||||
'windows nt 6.3' => 'Windows 8.1',
|
||||
'windows nt 6.2' => 'Windows 8',
|
||||
'windows nt 6.1' => 'Windows 7',
|
||||
'windows nt 6.0' => 'Windows Vista',
|
||||
'windows nt 5.2' => 'Windows 2003',
|
||||
'windows nt 5.1' => 'Windows XP',
|
||||
'windows nt 5.0' => 'Windows 2000',
|
||||
'windows nt 4.0' => 'Windows NT 4.0',
|
||||
'winnt4.0' => 'Windows NT 4.0',
|
||||
'winnt 4.0' => 'Windows NT',
|
||||
'winnt' => 'Windows NT',
|
||||
'windows 98' => 'Windows 98',
|
||||
'win98' => 'Windows 98',
|
||||
'windows 95' => 'Windows 95',
|
||||
'win95' => 'Windows 95',
|
||||
'windows phone' => 'Windows Phone',
|
||||
'windows' => 'Unknown Windows OS',
|
||||
'android' => 'Android',
|
||||
'blackberry' => 'BlackBerry',
|
||||
'iphone' => 'iOS',
|
||||
'ipad' => 'iOS',
|
||||
'ipod' => 'iOS',
|
||||
'os x' => 'Mac OS X',
|
||||
'ppc mac' => 'Power PC Mac',
|
||||
'freebsd' => 'FreeBSD',
|
||||
'ppc' => 'Macintosh',
|
||||
'linux' => 'Linux',
|
||||
'debian' => 'Debian',
|
||||
'sunos' => 'Sun Solaris',
|
||||
'beos' => 'BeOS',
|
||||
'apachebench' => 'ApacheBench',
|
||||
'aix' => 'AIX',
|
||||
'irix' => 'Irix',
|
||||
'osf' => 'DEC OSF',
|
||||
'hp-ux' => 'HP-UX',
|
||||
'netbsd' => 'NetBSD',
|
||||
'bsdi' => 'BSDi',
|
||||
'openbsd' => 'OpenBSD',
|
||||
'gnu' => 'GNU/Linux',
|
||||
'unix' => 'Unknown Unix OS',
|
||||
'symbian' => 'Symbian OS',
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Browsers
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* The order of this array should NOT be changed. Many browsers return
|
||||
* multiple browser types so we want to identify the subtype first.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $browsers = [
|
||||
'OPR' => 'Opera',
|
||||
'Flock' => 'Flock',
|
||||
'Edge' => 'Spartan',
|
||||
'Edg' => 'Edge',
|
||||
'Chrome' => 'Chrome',
|
||||
// Opera 10+ always reports Opera/9.80 and appends Version/<real version> to the user agent string
|
||||
'Opera.*?Version' => 'Opera',
|
||||
'Opera' => 'Opera',
|
||||
'MSIE' => 'Internet Explorer',
|
||||
'Internet Explorer' => 'Internet Explorer',
|
||||
'Trident.* rv' => 'Internet Explorer',
|
||||
'Shiira' => 'Shiira',
|
||||
'Firefox' => 'Firefox',
|
||||
'Chimera' => 'Chimera',
|
||||
'Phoenix' => 'Phoenix',
|
||||
'Firebird' => 'Firebird',
|
||||
'Camino' => 'Camino',
|
||||
'Netscape' => 'Netscape',
|
||||
'OmniWeb' => 'OmniWeb',
|
||||
'Safari' => 'Safari',
|
||||
'Mozilla' => 'Mozilla',
|
||||
'Konqueror' => 'Konqueror',
|
||||
'icab' => 'iCab',
|
||||
'Lynx' => 'Lynx',
|
||||
'Links' => 'Links',
|
||||
'hotjava' => 'HotJava',
|
||||
'amaya' => 'Amaya',
|
||||
'IBrowse' => 'IBrowse',
|
||||
'Maxthon' => 'Maxthon',
|
||||
'Ubuntu' => 'Ubuntu Web Browser',
|
||||
'Vivaldi' => 'Vivaldi',
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Mobiles
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $mobiles = [
|
||||
// legacy array, old values commented out
|
||||
'mobileexplorer' => 'Mobile Explorer',
|
||||
// 'openwave' => 'Open Wave',
|
||||
// 'opera mini' => 'Opera Mini',
|
||||
// 'operamini' => 'Opera Mini',
|
||||
// 'elaine' => 'Palm',
|
||||
'palmsource' => 'Palm',
|
||||
// 'digital paths' => 'Palm',
|
||||
// 'avantgo' => 'Avantgo',
|
||||
// 'xiino' => 'Xiino',
|
||||
'palmscape' => 'Palmscape',
|
||||
// 'nokia' => 'Nokia',
|
||||
// 'ericsson' => 'Ericsson',
|
||||
// 'blackberry' => 'BlackBerry',
|
||||
// 'motorola' => 'Motorola'
|
||||
|
||||
// Phones and Manufacturers
|
||||
'motorola' => 'Motorola',
|
||||
'nokia' => 'Nokia',
|
||||
'palm' => 'Palm',
|
||||
'iphone' => 'Apple iPhone',
|
||||
'ipad' => 'iPad',
|
||||
'ipod' => 'Apple iPod Touch',
|
||||
'sony' => 'Sony Ericsson',
|
||||
'ericsson' => 'Sony Ericsson',
|
||||
'blackberry' => 'BlackBerry',
|
||||
'cocoon' => 'O2 Cocoon',
|
||||
'blazer' => 'Treo',
|
||||
'lg' => 'LG',
|
||||
'amoi' => 'Amoi',
|
||||
'xda' => 'XDA',
|
||||
'mda' => 'MDA',
|
||||
'vario' => 'Vario',
|
||||
'htc' => 'HTC',
|
||||
'samsung' => 'Samsung',
|
||||
'sharp' => 'Sharp',
|
||||
'sie-' => 'Siemens',
|
||||
'alcatel' => 'Alcatel',
|
||||
'benq' => 'BenQ',
|
||||
'ipaq' => 'HP iPaq',
|
||||
'mot-' => 'Motorola',
|
||||
'playstation portable' => 'PlayStation Portable',
|
||||
'playstation 3' => 'PlayStation 3',
|
||||
'playstation vita' => 'PlayStation Vita',
|
||||
'hiptop' => 'Danger Hiptop',
|
||||
'nec-' => 'NEC',
|
||||
'panasonic' => 'Panasonic',
|
||||
'philips' => 'Philips',
|
||||
'sagem' => 'Sagem',
|
||||
'sanyo' => 'Sanyo',
|
||||
'spv' => 'SPV',
|
||||
'zte' => 'ZTE',
|
||||
'sendo' => 'Sendo',
|
||||
'nintendo dsi' => 'Nintendo DSi',
|
||||
'nintendo ds' => 'Nintendo DS',
|
||||
'nintendo 3ds' => 'Nintendo 3DS',
|
||||
'wii' => 'Nintendo Wii',
|
||||
'open web' => 'Open Web',
|
||||
'openweb' => 'OpenWeb',
|
||||
|
||||
// Operating Systems
|
||||
'android' => 'Android',
|
||||
'symbian' => 'Symbian',
|
||||
'SymbianOS' => 'SymbianOS',
|
||||
'elaine' => 'Palm',
|
||||
'series60' => 'Symbian S60',
|
||||
'windows ce' => 'Windows CE',
|
||||
|
||||
// Browsers
|
||||
'obigo' => 'Obigo',
|
||||
'netfront' => 'Netfront Browser',
|
||||
'openwave' => 'Openwave Browser',
|
||||
'mobilexplorer' => 'Mobile Explorer',
|
||||
'operamini' => 'Opera Mini',
|
||||
'opera mini' => 'Opera Mini',
|
||||
'opera mobi' => 'Opera Mobile',
|
||||
'fennec' => 'Firefox Mobile',
|
||||
|
||||
// Other
|
||||
'digital paths' => 'Digital Paths',
|
||||
'avantgo' => 'AvantGo',
|
||||
'xiino' => 'Xiino',
|
||||
'novarra' => 'Novarra Transcoder',
|
||||
'vodafone' => 'Vodafone',
|
||||
'docomo' => 'NTT DoCoMo',
|
||||
'o2' => 'O2',
|
||||
|
||||
// Fallback
|
||||
'mobile' => 'Generic Mobile',
|
||||
'wireless' => 'Generic Mobile',
|
||||
'j2me' => 'Generic Mobile',
|
||||
'midp' => 'Generic Mobile',
|
||||
'cldc' => 'Generic Mobile',
|
||||
'up.link' => 'Generic Mobile',
|
||||
'up.browser' => 'Generic Mobile',
|
||||
'smartphone' => 'Generic Mobile',
|
||||
'cellphone' => 'Generic Mobile',
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Robots
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* There are hundred of bots but these are the most common.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $robots = [
|
||||
'googlebot' => 'Googlebot',
|
||||
'msnbot' => 'MSNBot',
|
||||
'baiduspider' => 'Baiduspider',
|
||||
'bingbot' => 'Bing',
|
||||
'slurp' => 'Inktomi Slurp',
|
||||
'yahoo' => 'Yahoo',
|
||||
'ask jeeves' => 'Ask Jeeves',
|
||||
'fastcrawler' => 'FastCrawler',
|
||||
'infoseek' => 'InfoSeek Robot 1.0',
|
||||
'lycos' => 'Lycos',
|
||||
'yandex' => 'YandexBot',
|
||||
'mediapartners-google' => 'MediaPartners Google',
|
||||
'CRAZYWEBCRAWLER' => 'Crazy Webcrawler',
|
||||
'adsbot-google' => 'AdsBot Google',
|
||||
'feedfetcher-google' => 'Feedfetcher Google',
|
||||
'curious george' => 'Curious George',
|
||||
'ia_archiver' => 'Alexa Crawler',
|
||||
'MJ12bot' => 'Majestic-12',
|
||||
'Uptimebot' => 'Uptimebot',
|
||||
];
|
||||
}
|
||||
44
app/Config/Validation.php
Executable file
44
app/Config/Validation.php
Executable file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Validation\StrictRules\CreditCardRules;
|
||||
use CodeIgniter\Validation\StrictRules\FileRules;
|
||||
use CodeIgniter\Validation\StrictRules\FormatRules;
|
||||
use CodeIgniter\Validation\StrictRules\Rules;
|
||||
|
||||
class Validation extends BaseConfig
|
||||
{
|
||||
// --------------------------------------------------------------------
|
||||
// Setup
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Stores the classes that contain the
|
||||
* rules that are available.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $ruleSets = [
|
||||
Rules::class,
|
||||
FormatRules::class,
|
||||
FileRules::class,
|
||||
CreditCardRules::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Specifies the views that are used to display the
|
||||
* errors.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $templates = [
|
||||
'list' => 'CodeIgniter\Validation\Views\list',
|
||||
'single' => 'CodeIgniter\Validation\Views\single',
|
||||
];
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Rules
|
||||
// --------------------------------------------------------------------
|
||||
}
|
||||
62
app/Config/View.php
Executable file
62
app/Config/View.php
Executable file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\View as BaseView;
|
||||
use CodeIgniter\View\ViewDecoratorInterface;
|
||||
|
||||
/**
|
||||
* @phpstan-type parser_callable (callable(mixed): mixed)
|
||||
* @phpstan-type parser_callable_string (callable(mixed): mixed)&string
|
||||
*/
|
||||
class View extends BaseView
|
||||
{
|
||||
/**
|
||||
* When false, the view method will clear the data between each
|
||||
* call. This keeps your data safe and ensures there is no accidental
|
||||
* leaking between calls, so you would need to explicitly pass the data
|
||||
* to each view. You might prefer to have the data stick around between
|
||||
* calls so that it is available to all views. If that is the case,
|
||||
* set $saveData to true.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $saveData = true;
|
||||
|
||||
/**
|
||||
* Parser Filters map a filter name with any PHP callable. When the
|
||||
* Parser prepares a variable for display, it will chain it
|
||||
* through the filters in the order defined, inserting any parameters.
|
||||
* To prevent potential abuse, all filters MUST be defined here
|
||||
* in order for them to be available for use within the Parser.
|
||||
*
|
||||
* Examples:
|
||||
* { title|esc(js) }
|
||||
* { created_on|date(Y-m-d)|esc(attr) }
|
||||
*
|
||||
* @var array<string, string>
|
||||
* @phpstan-var array<string, parser_callable_string>
|
||||
*/
|
||||
public $filters = [];
|
||||
|
||||
/**
|
||||
* Parser Plugins provide a way to extend the functionality provided
|
||||
* by the core Parser by creating aliases that will be replaced with
|
||||
* any callable. Can be single or tag pair.
|
||||
*
|
||||
* @var array<string, callable|list<string>|string>
|
||||
* @phpstan-var array<string, list<parser_callable_string>|parser_callable_string|parser_callable>
|
||||
*/
|
||||
public $plugins = [];
|
||||
|
||||
/**
|
||||
* View Decorators are class methods that will be run in sequence to
|
||||
* have a chance to alter the generated output just prior to caching
|
||||
* the results.
|
||||
*
|
||||
* All classes must implement CodeIgniter\View\ViewDecoratorInterface
|
||||
*
|
||||
* @var list<class-string<ViewDecoratorInterface>>
|
||||
*/
|
||||
public array $decorators = [];
|
||||
}
|
||||
136
app/Controllers/AgentAuthController.php
Normal file
136
app/Controllers/AgentAuthController.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
use CodeIgniter\RESTful\ResourceController;
|
||||
use App\Models\AgentModel;
|
||||
|
||||
class AgentAuthController extends ResourceController
|
||||
{
|
||||
protected $format = 'json';
|
||||
protected $myLogger;
|
||||
protected $AgentModel;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
helper('jwt_helper');
|
||||
helper('oauth_helper');
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
$this->AgentModel = new AgentModel();
|
||||
|
||||
}
|
||||
|
||||
public function verifyAgentWithMobileNumber()
|
||||
{
|
||||
try {
|
||||
|
||||
$mobile = $this->request->getJSON()->mobile;
|
||||
|
||||
$agentData = $this->AgentModel->where('mobile', $mobile)->where('is_active', 1)->first();
|
||||
|
||||
|
||||
if (isset($agentData['id']))
|
||||
{
|
||||
$result = ['agent_verification' => true ,'message' => "Verified Successfully"];
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
|
||||
} else {
|
||||
|
||||
$result = ['agent_verification' => false , 'message' => "Verification Failed"];
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
|
||||
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||
}
|
||||
}
|
||||
|
||||
public function verifyAgentWithEmailId()
|
||||
{
|
||||
try {
|
||||
|
||||
$email = $this->request->getJSON()->email;
|
||||
|
||||
$agentData = $this->AgentModel->where('email', $email)->where('is_active', 1)->first();
|
||||
|
||||
if (isset($agentData['id'])) {
|
||||
|
||||
$otp = random_int(100000, 999999);
|
||||
|
||||
$update = $this->AgentModel->where('email', $email)->where('is_active', 1)->set(['email_otp' => $otp])->update();
|
||||
|
||||
if ($update) {
|
||||
|
||||
$subject = 'Nhance user verification - OTP';
|
||||
$mail_content = $otp . ' is your verification code for Nhance.';
|
||||
|
||||
$EmailResult = send_login_otp( $email , $subject , $mail_content);
|
||||
|
||||
if ($EmailResult['status'] == 'success') {
|
||||
$result = ['agent_verification' => true, 'message' => "Verified Successfully"];
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200);
|
||||
} else {
|
||||
$result = ['agent_verification' => false, 'message' => "Mail sending failed , try again"];
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||
}
|
||||
} else {
|
||||
$result = ['agent_verification' => false, 'message' => "Verification failed , try again"];
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||
}
|
||||
|
||||
} else {
|
||||
$result = ['agent_verification' => false, 'message' => "User not found"];
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||
}
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $th], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getVerifiedAgentData()
|
||||
{
|
||||
try {
|
||||
|
||||
$otp_verification = isset($this->request->getJSON()->otp_verification) ? $this->request->getJSON()->otp_verification : null;
|
||||
$mobile = isset($this->request->getJSON()->mobile) ? $this->request->getJSON()->mobile : null;
|
||||
|
||||
$otp = isset($this->request->getJSON()->otp) ? $this->request->getJSON()->otp : null;
|
||||
$email = isset($this->request->getJSON()->email) ? $this->request->getJSON()->email : null;
|
||||
|
||||
|
||||
if (isset($mobile))
|
||||
{
|
||||
$agentData = $this->AgentModel->where('mobile', $mobile)->where('is_active', 1)->first();
|
||||
|
||||
} else {
|
||||
$agentData = $this->AgentModel->where('email', $email)->where('is_active', 1)->first();
|
||||
}
|
||||
|
||||
|
||||
if ($agentData && $otp_verification == true || $agentData && isset($this->request->getJSON()->otp) ) {
|
||||
|
||||
if(isset($this->request->getJSON()->otp)){
|
||||
$this->AgentModel->where('id', $agentData['id'])->where('otp', $otp)->where('is_active', 1)->set(['otp'=>null])->update();
|
||||
}
|
||||
|
||||
$result = generateJWT($agentData);
|
||||
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
|
||||
} else {
|
||||
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => []],200);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' =>[], 'error' => $e->getMessage()],500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
85
app/Controllers/AgentController.php
Normal file
85
app/Controllers/AgentController.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\AgentModel;
|
||||
|
||||
class PartnerAgentController extends BaseController
|
||||
{
|
||||
protected $AgentModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->AgentModel = new AgentModel();
|
||||
}
|
||||
|
||||
// =========================
|
||||
// 1. List all records
|
||||
// =========================
|
||||
public function list()
|
||||
{
|
||||
$data = $this->AgentModel->findAll();
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
|
||||
// =========================
|
||||
// 2. Find single record by ID
|
||||
// =========================
|
||||
public function find($id = null)
|
||||
{
|
||||
$record = $this->AgentModel->find($id);
|
||||
|
||||
if (!$record) {
|
||||
return $this->response->setJSON([
|
||||
'status' => 'error',
|
||||
'message' => 'Record not found'
|
||||
])->setStatusCode(404);
|
||||
}
|
||||
|
||||
return $this->response->setJSON($record);
|
||||
}
|
||||
|
||||
// =========================
|
||||
// 3. Create new record
|
||||
// =========================
|
||||
public function create()
|
||||
{
|
||||
$data = $this->request->getJSON(true); // get JSON body as array
|
||||
|
||||
if (!$this->AgentModel->insert($data)) {
|
||||
return $this->response->setJSON([
|
||||
'status' => 'error',
|
||||
'message' => 'Failed to insert',
|
||||
'errors' => $this->AgentModel->errors()
|
||||
])->setStatusCode(400);
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => 'success',
|
||||
'message' => 'Record created successfully',
|
||||
'id' => $this->AgentModel->getInsertID()
|
||||
]);
|
||||
}
|
||||
|
||||
// =========================
|
||||
// 4. Update record by ID
|
||||
// =========================
|
||||
public function update($id = null)
|
||||
{
|
||||
$data = $this->request->getJSON(true);
|
||||
|
||||
if (!$this->AgentModel->update($id, $data)) {
|
||||
return $this->response->setJSON([
|
||||
'status' => 'error',
|
||||
'message' => 'Failed to update',
|
||||
'errors' => $this->AgentModel->errors()
|
||||
])->setStatusCode(400);
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => 'success',
|
||||
'message' => 'Record updated successfully'
|
||||
]);
|
||||
}
|
||||
}
|
||||
58
app/Controllers/BaseController.php
Executable file
58
app/Controllers/BaseController.php
Executable file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\HTTP\CLIRequest;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Class BaseController
|
||||
*
|
||||
* BaseController provides a convenient place for loading components
|
||||
* and performing functions that are needed by all your controllers.
|
||||
* Extend this class in any new controllers:
|
||||
* class Home extends BaseController
|
||||
*
|
||||
* For security be sure to declare any new methods as protected or private.
|
||||
*/
|
||||
abstract class BaseController extends Controller
|
||||
{
|
||||
/**
|
||||
* Instance of the main Request object.
|
||||
*
|
||||
* @var CLIRequest|IncomingRequest
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* An array of helpers to be loaded automatically upon
|
||||
* class instantiation. These helpers will be available
|
||||
* to all other controllers that extend BaseController.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $helpers = [];
|
||||
|
||||
/**
|
||||
* Be sure to declare properties for any property fetch you initialized.
|
||||
* The creation of dynamic property is deprecated in PHP 8.2.
|
||||
*/
|
||||
// protected $session;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
// Do Not Edit This Line
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
// Preload any models, libraries, etc, here.
|
||||
|
||||
// E.g.: $this->session = service('session');
|
||||
}
|
||||
}
|
||||
11
app/Controllers/Home.php
Executable file
11
app/Controllers/Home.php
Executable file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
class Home extends BaseController
|
||||
{
|
||||
public function index(): string
|
||||
{
|
||||
return view('welcome_message');
|
||||
}
|
||||
}
|
||||
732
app/Controllers/MasterController.php
Normal file
732
app/Controllers/MasterController.php
Normal file
@ -0,0 +1,732 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\RESTful\ResourceController;
|
||||
use App\Models\DropdownModel;
|
||||
use App\Models\DepartmentModel;
|
||||
use App\Models\TravelStatusModel;
|
||||
use App\Models\CountryModel;
|
||||
use App\Models\AirportCodeModel;
|
||||
use App\Models\TrainStationsModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\OrganizationModel;
|
||||
use App\Models\GroupModel;
|
||||
use App\Models\PolicyModel;
|
||||
use App\Models\PolicyDetailsModel;
|
||||
use App\Models\ServiceModel;
|
||||
use App\Models\ForexPerdiemModel;
|
||||
use App\Models\HotelModel;
|
||||
use App\Models\CostCenterModel;
|
||||
use App\Models\AirlineModel;
|
||||
use App\Models\MailTemplateModel;
|
||||
|
||||
class MasterController extends ResourceController
|
||||
{
|
||||
protected $format = 'json';
|
||||
protected $myLogger;
|
||||
protected $dropdownModel;
|
||||
protected $departmentModel;
|
||||
protected $travelStatusModel;
|
||||
protected $countryModel;
|
||||
protected $airportCodeModel;
|
||||
protected $trainStationsModel;
|
||||
protected $userModel;
|
||||
protected $organizationModel;
|
||||
protected $groupModel;
|
||||
protected $policyModel;
|
||||
protected $policyDetailsModel;
|
||||
protected $serviceModel;
|
||||
protected $forexPerdiemModel;
|
||||
protected $hotelModel;
|
||||
protected $costCenterModel;
|
||||
protected $airlineModel;
|
||||
protected $mailTemplateModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
$this->dropdownModel = new DropdownModel();
|
||||
$this->departmentModel = new DepartmentModel();
|
||||
$this->travelStatusModel = new TravelStatusModel();
|
||||
$this->countryModel = new CountryModel();
|
||||
$this->airportCodeModel = new AirportCodeModel();
|
||||
$this->trainStationsModel = new TrainStationsModel();
|
||||
$this->userModel = new UserModel();
|
||||
$this->organizationModel = new OrganizationModel();
|
||||
$this->groupModel = new GroupModel();
|
||||
$this->policyModel = new PolicyModel();
|
||||
$this->policyDetailsModel = new PolicyDetailsModel();
|
||||
$this->serviceModel = new ServiceModel();
|
||||
$this->forexPerdiemModel = new ForexPerdiemModel();
|
||||
$this->hotelModel = new HotelModel();
|
||||
$this->costCenterModel = new CostCenterModel();
|
||||
$this->airlineModel = new AirlineModel();
|
||||
$this->mailTemplateModel = new MailTemplateModel();
|
||||
}
|
||||
|
||||
|
||||
public function getDropdownMaster()
|
||||
{
|
||||
$data = $this->dropdownModel->select('dropdown')->groupBy('dropdown')->findAll();
|
||||
|
||||
if (!$data) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
if ($data)
|
||||
{
|
||||
foreach ($data as &$val)
|
||||
{
|
||||
$temp[$val['dropdown']] = $this->dropdownModel->where('dropdown', $val['dropdown'])->where('is_active',1)->findAll();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 200,'message' => 'success','data' => $temp]);
|
||||
}
|
||||
|
||||
|
||||
public function getTravelStatusMaster()
|
||||
{
|
||||
$data = $this->travelStatusModel->where('is_active',1)->findAll();
|
||||
|
||||
if (!$data) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
|
||||
}
|
||||
|
||||
public function getcountryMaster()
|
||||
{
|
||||
$data = $this->countryModel->where('is_active',1)->findAll();
|
||||
|
||||
if (!$data) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
|
||||
}
|
||||
|
||||
public function getAirlineMaster()
|
||||
{
|
||||
$data = $this->airlineModel->findAll();
|
||||
|
||||
if (!$data) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
|
||||
}
|
||||
|
||||
|
||||
public function getAirportCodeMaster()
|
||||
{
|
||||
$type = $this->request->getGet('trip_type');
|
||||
|
||||
// Build the query
|
||||
$query = $this->airportCodeModel->where('is_active', 1);
|
||||
if ($type == 1) {
|
||||
$query->where('Country_Code', 'IN');
|
||||
}
|
||||
|
||||
// Execute the query and get the result
|
||||
$data = $query->findAll();
|
||||
|
||||
// Check if data exists
|
||||
if (empty($data)) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
// Return success response
|
||||
return $this->respond([
|
||||
'status' => 200,
|
||||
'message' => 'success',
|
||||
'data' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
public function getTrainCodeMaster()
|
||||
{
|
||||
$data = $this->trainStationsModel->where('is_active',1)->findAll();
|
||||
|
||||
if (!$data) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
|
||||
}
|
||||
|
||||
public function getFlightAndTrainClass()
|
||||
{
|
||||
|
||||
|
||||
$trip_type = $this->request->getGet('trip_type');
|
||||
$user_id = $this->request->getVar('user_id');
|
||||
|
||||
$user = $this->userModel->where('user_id', $user_id)->first();
|
||||
|
||||
$groupData = $this->groupModel->find($user['group_id']);
|
||||
|
||||
if($groupData)
|
||||
{
|
||||
if($trip_type == 1) { $policyId = $groupData['domestic_policy_id'];}else{ $policyId = $groupData['international_policy_id'];}
|
||||
dd($policyId);
|
||||
if($policyId != null)
|
||||
{
|
||||
$minFlightRow = $this->policyDetailsModel->where('policy_id', $policyId)->where('service_id', 1)->get()->getRow();
|
||||
|
||||
$minTrainRow = $this->policyDetailsModel->where('policy_id', $policyId)->where('service_id', 2)->get()->getRow();
|
||||
|
||||
$minHotelRow = $this->policyDetailsModel->where('policy_id', $policyId)->where('service_id', 5)->get()->getRow();
|
||||
|
||||
$minFlightClassKey = $minFlightRow ? $minFlightRow->class : null;
|
||||
$minTrainClassKey = $minTrainRow ? $minTrainRow->class : null;
|
||||
$minHotelClassKey = $minHotelRow ? $minHotelRow->class : null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//flight
|
||||
$allFlightClass = $this->dropdownModel->where('dropdown', 'flight_class')->orderBy('dropdown_key','ASC')->findAll();
|
||||
$minFlightClassKey = $minFlightClassKey ?? 0;
|
||||
$data['flight_class'] = [];
|
||||
foreach ($allFlightClass as $key => $value) {
|
||||
|
||||
if((int)$value['dropdown_key'] >= (int)$minFlightClassKey){
|
||||
$value['is_allowed'] = 'yes';
|
||||
array_push($data['flight_class'] , $value);
|
||||
}else{
|
||||
$value['is_allowed'] = 'No';
|
||||
array_push($data['flight_class'] , $value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//train
|
||||
$allTrainClass = $this->dropdownModel->where('dropdown', 'train_class')->orderBy('dropdown_key','ASC')->findAll();
|
||||
$minTrainClassKey = $minTrainClassKey ?? 0;
|
||||
$data['train_class'] = [];
|
||||
|
||||
foreach ($allTrainClass as $key => $value) {
|
||||
|
||||
if((int)$value['dropdown_key'] >= (int)$minTrainClassKey){
|
||||
$value['is_allowed'] = 'yes';
|
||||
array_push($data['train_class'] , $value);
|
||||
}else{
|
||||
$value['is_allowed'] = 'No';
|
||||
array_push($data['train_class'] , $value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//hotel
|
||||
$allHotelClass = $this->dropdownModel->where('dropdown', 'hotel_class')->orderBy('dropdown_key','ASC')->findAll();
|
||||
$minHotelClassKey = $minHotelClassKey ?? 0;
|
||||
$data['hotel_class'] = [];
|
||||
|
||||
foreach ($allHotelClass as $key => $value) {
|
||||
|
||||
if((int)$value['dropdown_key'] >= (int)$minHotelClassKey){
|
||||
$value['is_allowed'] = 'yes';
|
||||
array_push($data['hotel_class'] , $value);
|
||||
}else{
|
||||
$value['is_allowed'] = 'No';
|
||||
array_push($data['hotel_class'] , $value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!$data) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
|
||||
}
|
||||
|
||||
|
||||
// Department crud
|
||||
public function getDepartmentList()
|
||||
{
|
||||
$for = $this->request->getVar('for');
|
||||
|
||||
if (isset($for) && $for === 'table_view')
|
||||
{
|
||||
$data = $this->dropdownModel->where('dropdown','plan_functional_department')->findAll();
|
||||
} else {
|
||||
$data = $this->dropdownModel->where('dropdown','plan_functional_department')->where('is_active', 1)->findAll();
|
||||
}
|
||||
|
||||
if (!$data) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
|
||||
}
|
||||
|
||||
public function createDepartment()
|
||||
{
|
||||
$data = $this->request->getJSON(true);
|
||||
|
||||
$data['dropdown'] = 'plan_functional_department';
|
||||
$data['is_active'] = 1;
|
||||
$existData = $this->dropdownModel->where('dropdown','plan_functional_department')->findAll();
|
||||
$data['dropdown_key'] = count($existData) + 1;
|
||||
|
||||
if (!$this->dropdownModel->insert($data)) {
|
||||
return $this->failValidationErrors($this->dropdownModel->errors());
|
||||
}
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 201,
|
||||
'message' => 'Department created successfully'
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function findDepartment()
|
||||
{
|
||||
|
||||
$id = $this->request->getGet('id');
|
||||
|
||||
$data = $this->dropdownModel->where('id',$id)->find();
|
||||
|
||||
if (!$data) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
|
||||
}
|
||||
|
||||
public function updateDepartment($id = null)
|
||||
{
|
||||
$data = $this->request->getJSON(true);
|
||||
|
||||
if (!$this->dropdownModel->find($id)) {
|
||||
return $this->failNotFound('Department not found');
|
||||
}
|
||||
|
||||
if (!$this->dropdownModel->update($id, $data)) {
|
||||
return $this->failValidationErrors($this->dropdownModel->errors());
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 200,
|
||||
'message' => 'Department updated successfully'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// Purpose of travel crud
|
||||
public function getPurposeOfTravelList()
|
||||
{
|
||||
$for = $this->request->getVar('for');
|
||||
|
||||
if (isset($for) && $for === 'table_view')
|
||||
{
|
||||
$data = $this->dropdownModel->where('dropdown','plan_purpose_of_travel')->findAll();
|
||||
} else {
|
||||
$data = $this->dropdownModel->where('dropdown','plan_purpose_of_travel')->where('is_active', 1)->findAll();
|
||||
}
|
||||
|
||||
if (!$data) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
|
||||
}
|
||||
|
||||
public function createPurposeOfTravel()
|
||||
{
|
||||
$data = $this->request->getJSON(true);
|
||||
|
||||
$data['dropdown'] = 'plan_purpose_of_travel';
|
||||
$data['is_active'] = 1;
|
||||
$existData = $this->dropdownModel->where('dropdown','plan_purpose_of_travel')->findAll();
|
||||
$data['dropdown_key'] = count($existData) + 1;
|
||||
|
||||
if (!$this->dropdownModel->insert($data)) {
|
||||
return $this->failValidationErrors($this->dropdownModel->errors());
|
||||
}
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 201,
|
||||
'message' => 'Department created successfully'
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function findPurposeOfTravel()
|
||||
{
|
||||
|
||||
$id = $this->request->getGet('id');
|
||||
|
||||
$data = $this->dropdownModel->where('id',$id)->find();
|
||||
|
||||
if (!$data) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
|
||||
}
|
||||
|
||||
public function updatePurposeOfTravel($id = null)
|
||||
{
|
||||
$data = $this->request->getJSON(true);
|
||||
|
||||
if (!$this->dropdownModel->find($id)) {
|
||||
return $this->failNotFound('Department not found');
|
||||
}
|
||||
|
||||
if (!$this->dropdownModel->update($id, $data)) {
|
||||
return $this->failValidationErrors($this->dropdownModel->errors());
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 200,
|
||||
'message' => 'Department updated successfully'
|
||||
]);
|
||||
}
|
||||
|
||||
// Cost center crud
|
||||
public function getCostCenterMaster()
|
||||
{
|
||||
$for = $this->request->getVar('for');
|
||||
|
||||
if (isset($for) && $for === 'table_view')
|
||||
{
|
||||
$data = $this->costCenterModel->findAll();
|
||||
} else {
|
||||
$data = $this->costCenterModel->where('is_active', 1)->findAll();
|
||||
}
|
||||
|
||||
if (!$data) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
|
||||
}
|
||||
|
||||
public function createCostCenter()
|
||||
{
|
||||
$data = $this->request->getJSON(true);
|
||||
|
||||
if (!$this->costCenterModel->insert($data)) {
|
||||
return $this->failValidationErrors($this->costCenterModel->errors());
|
||||
}
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 201,
|
||||
'message' => 'Cost Center created successfully'
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function findCostCenter()
|
||||
{
|
||||
|
||||
$id = $this->request->getGet('cost_center_id');
|
||||
|
||||
$data = $this->costCenterModel->where('cost_center_id',$id)->find();
|
||||
|
||||
if (!$data) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
|
||||
}
|
||||
|
||||
public function updateCostCenter($id = null)
|
||||
{
|
||||
$data = $this->request->getJSON(true);
|
||||
|
||||
if (!$this->costCenterModel->find($id)) {
|
||||
return $this->failNotFound('Cost Center not found');
|
||||
}
|
||||
|
||||
if (!$this->costCenterModel->update($id, $data)) {
|
||||
return $this->failValidationErrors($this->costCenterModel->errors());
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 200,
|
||||
'message' => 'Cost Center updated successfully'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// Forex crud
|
||||
public function getForexPerdiemList()
|
||||
{
|
||||
|
||||
$for = $this->request->getVar('for');
|
||||
|
||||
if (isset($for) && $for === 'table_view')
|
||||
{
|
||||
$data = $this->forexPerdiemModel->findAll();
|
||||
} else {
|
||||
$data = $this->forexPerdiemModel->where('is_active', 1)->findAll();
|
||||
}
|
||||
|
||||
if (!$data) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
|
||||
}
|
||||
|
||||
public function createForexPerdiem()
|
||||
{
|
||||
|
||||
|
||||
try {
|
||||
|
||||
$data = $this->request->getJSON(true);
|
||||
|
||||
if (!$this->forexPerdiemModel->insert($data)) {
|
||||
return $this->failValidationErrors($this->forexPerdiemModel->errors());
|
||||
}
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 201,
|
||||
'message' => 'Forex Perdiem created successfully'
|
||||
]);
|
||||
} catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) {
|
||||
|
||||
if (strpos($e->getMessage(), 'Duplicate entry') !== false) {
|
||||
return $this->respond([
|
||||
'status' => 404,
|
||||
'message' => 'Duplicate entry'
|
||||
],404);
|
||||
}
|
||||
|
||||
// For other DB-related exceptions
|
||||
return $this->failServerError($e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function findForexPerdiem()
|
||||
{
|
||||
|
||||
$id = $this->request->getGet('forex_perdiem_id');
|
||||
|
||||
$data = $this->forexPerdiemModel->where('forex_perdiem_id',$id)->find();
|
||||
|
||||
if (!$data) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
|
||||
}
|
||||
|
||||
public function updateForexPerdiem($id = null)
|
||||
{
|
||||
try{
|
||||
|
||||
$data = $this->request->getJSON(true);
|
||||
|
||||
if (!$this->forexPerdiemModel->find($id)) {
|
||||
return $this->failNotFound('Forex Perdiem not found');
|
||||
}
|
||||
|
||||
|
||||
if (!$this->forexPerdiemModel->update($id, $data)) {
|
||||
return $this->failValidationErrors($this->forexPerdiemModel->errors());
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 200,
|
||||
'message' => 'Forex Perdiem updated successfully'
|
||||
]);
|
||||
|
||||
} catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) {
|
||||
|
||||
if (strpos($e->getMessage(), 'Duplicate entry') !== false) {
|
||||
return $this->respond([
|
||||
'status' => 404,
|
||||
'message' => 'Duplicate entry'
|
||||
]);
|
||||
}
|
||||
|
||||
// For other DB-related exceptions
|
||||
return $this->failServerError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Hotels crud
|
||||
public function getHotels()
|
||||
{
|
||||
|
||||
$for = $this->request->getVar('for');
|
||||
|
||||
if (isset($for) && $for === 'table_view')
|
||||
{
|
||||
$hotels = $this->hotelModel->select('m_hotels.* , C.country_name')
|
||||
->join('m_country C', 'C.country_code = m_hotels.country_code', 'left')
|
||||
->findAll();
|
||||
} else {
|
||||
$hotels = $this->hotelModel->select('m_hotels.* , C.country_name')
|
||||
->join('m_country C', 'C.country_code = m_hotels.country_code', 'left')
|
||||
->where('m_hotels.is_active', 1)
|
||||
->findAll();
|
||||
}
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => 200,
|
||||
'message' => 'Hotel list fetched successfully',
|
||||
'data' => $hotels
|
||||
]);
|
||||
}
|
||||
|
||||
public function createHotels()
|
||||
{
|
||||
$data = $this->request->getJSON(true);
|
||||
|
||||
if (!$this->hotelModel->insert($data)) {
|
||||
return $this->failValidationErrors($this->hotelModel->errors());
|
||||
}
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 201,
|
||||
'message' => 'Hotels created successfully'
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function findHotels()
|
||||
{
|
||||
|
||||
$id = $this->request->getGet('hotel_id');
|
||||
|
||||
$data = $this->hotelModel->where('hotel_id',$id)->find();
|
||||
|
||||
if (!$data) {
|
||||
return $this->failNotFound('No data found');
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
|
||||
}
|
||||
|
||||
public function updateHotels($id = null)
|
||||
{
|
||||
$data = $this->request->getJSON(true);
|
||||
|
||||
if (!$this->hotelModel->find($id)) {
|
||||
return $this->failNotFound('Hotels not found');
|
||||
}
|
||||
|
||||
if (!$this->hotelModel->update($id, $data)) {
|
||||
return $this->failValidationErrors($this->hotelModel->errors());
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 200,
|
||||
'message' => 'Hotels updated successfully'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function forex_signature_upload()
|
||||
{
|
||||
|
||||
$data = $this->request->getPost();
|
||||
|
||||
// Handle file upload
|
||||
$file = $this->request->getFile('signature');
|
||||
if ($file && $file->isValid() && !$file->hasMoved()) {
|
||||
$newName = $file->getRandomName(); // Generate a unique name
|
||||
// $uploadPath = WRITEPATH.'uploads/signature';
|
||||
$uploadPath = FCPATH.'public/assets/images/signature';
|
||||
|
||||
// print_r( $uploadPath); die;
|
||||
|
||||
// Move file to the specified directory
|
||||
$file->move($uploadPath, $newName);
|
||||
|
||||
// Save file path in database
|
||||
$path = $uploadPath . '/' . $newName;
|
||||
} else {
|
||||
return $this->failValidationErrors(['passport_document' => 'Invalid file upload']);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$this->mailTemplateModel->set(['image_location' => $newName])->where('template_name','forex')->update();
|
||||
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 201,
|
||||
'message' => 'organization created successfully',
|
||||
'data' => $data
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->failServerError('Failed to create organization: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// public function getForexSignaturePath()
|
||||
// {
|
||||
|
||||
// $data = $this->mailTemplateModel->where('template_name','forex')->first();
|
||||
|
||||
// return $this->respond([
|
||||
// 'status' => 200,
|
||||
// 'message' => 'success',
|
||||
// 'data' => $data
|
||||
|
||||
// ]);
|
||||
|
||||
// }
|
||||
|
||||
public function getForexSignaturePath()
|
||||
{
|
||||
$data = $this->mailTemplateModel->where('template_name', 'forex')->first();
|
||||
|
||||
if (!$data || empty($data['image_location'])) {
|
||||
return $this->respond([
|
||||
'status' => 404,
|
||||
'message' => 'Image not found',
|
||||
'url' => null
|
||||
]);
|
||||
}
|
||||
|
||||
// If the DB stores only the filename, adjust accordingly
|
||||
$fileName = basename($data['image_location']);
|
||||
|
||||
|
||||
$imageUrl = base_url('public/assets/images/signature/' . $fileName);
|
||||
|
||||
// Add both the URL and ready-made HTML tag
|
||||
$data['image_url'] = $imageUrl;
|
||||
$data['image_tag'] = '<img src="' . $imageUrl . '" alt="Signature" style="max-width:200px;">';
|
||||
|
||||
return $this->respond([
|
||||
'status' => 200,
|
||||
'message' => 'success',
|
||||
'url' => $imageUrl
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
136
app/Controllers/StaffAuthController.php
Normal file
136
app/Controllers/StaffAuthController.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
use CodeIgniter\RESTful\ResourceController;
|
||||
use App\Models\StaffModel;
|
||||
|
||||
class StaffAuthController extends ResourceController
|
||||
{
|
||||
protected $format = 'json';
|
||||
protected $myLogger;
|
||||
protected $StaffModel;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
helper('jwt_helper');
|
||||
helper('oauth_helper');
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
$this->StaffModel = new StaffModel();
|
||||
|
||||
}
|
||||
|
||||
public function verifyStaffWithMobileNumber()
|
||||
{
|
||||
try {
|
||||
|
||||
$mobile = $this->request->getJSON()->mobile;
|
||||
|
||||
$StaffData = $this->StaffModel->where('mobile', $mobile)->where('is_active', 1)->first();
|
||||
|
||||
|
||||
if (isset($StaffData['id']))
|
||||
{
|
||||
$result = ['Staff_verification' => true ,'message' => "Verified Successfully"];
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
|
||||
} else {
|
||||
|
||||
$result = ['Staff_verification' => false , 'message' => "Verification Failed"];
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
|
||||
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||
}
|
||||
}
|
||||
|
||||
public function verifyStaffWithEmailId()
|
||||
{
|
||||
try {
|
||||
|
||||
$email = $this->request->getJSON()->email;
|
||||
|
||||
$StaffData = $this->StaffModel->where('email', $email)->where('is_active', 1)->first();
|
||||
|
||||
if (isset($StaffData['id'])) {
|
||||
|
||||
$otp = random_int(100000, 999999);
|
||||
|
||||
$update = $this->StaffModel->where('email', $email)->where('is_active', 1)->set(['email_otp' => $otp])->update();
|
||||
|
||||
if ($update) {
|
||||
|
||||
$subject = 'Nhance user verification - OTP';
|
||||
$mail_content = $otp . ' is your verification code for Nhance.';
|
||||
|
||||
$EmailResult = send_login_otp( $email , $subject , $mail_content);
|
||||
|
||||
if ($EmailResult['status'] == 'success') {
|
||||
$result = ['Staff_verification' => true, 'message' => "Verified Successfully"];
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200);
|
||||
} else {
|
||||
$result = ['Staff_verification' => false, 'message' => "Mail sending failed , try again"];
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||
}
|
||||
} else {
|
||||
$result = ['Staff_verification' => false, 'message' => "Verification failed , try again"];
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||
}
|
||||
|
||||
} else {
|
||||
$result = ['Staff_verification' => false, 'message' => "User not found"];
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||
}
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $th], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getVerifiedStaffData()
|
||||
{
|
||||
try {
|
||||
|
||||
$otp_verification = isset($this->request->getJSON()->otp_verification) ? $this->request->getJSON()->otp_verification : null;
|
||||
$mobile = isset($this->request->getJSON()->mobile) ? $this->request->getJSON()->mobile : null;
|
||||
|
||||
$otp = isset($this->request->getJSON()->otp) ? $this->request->getJSON()->otp : null;
|
||||
$email = isset($this->request->getJSON()->email) ? $this->request->getJSON()->email : null;
|
||||
|
||||
|
||||
if (isset($mobile))
|
||||
{
|
||||
$StaffData = $this->StaffModel->where('mobile', $mobile)->where('is_active', 1)->first();
|
||||
|
||||
} else {
|
||||
$StaffData = $this->StaffModel->where('email', $email)->where('is_active', 1)->first();
|
||||
}
|
||||
|
||||
|
||||
if ($StaffData && $otp_verification == true || $StaffData && isset($this->request->getJSON()->otp) ) {
|
||||
|
||||
if(isset($this->request->getJSON()->otp)){
|
||||
$this->StaffModel->where('id', $StaffData['id'])->where('otp', $otp)->where('is_active', 1)->set(['otp'=>null])->update();
|
||||
}
|
||||
|
||||
$result = generateJWT($StaffData);
|
||||
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
|
||||
} else {
|
||||
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => []],200);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' =>[], 'error' => $e->getMessage()],500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
85
app/Controllers/StaffController.php
Normal file
85
app/Controllers/StaffController.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\StaffModel;
|
||||
|
||||
class StaffController extends BaseController
|
||||
{
|
||||
protected $StaffModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->StaffModel = new StaffModel();
|
||||
}
|
||||
|
||||
// =========================
|
||||
// 1. List all staff
|
||||
// =========================
|
||||
public function list()
|
||||
{
|
||||
$data = $this->StaffModel->findAll();
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
|
||||
// =========================
|
||||
// 2. Find single staff by ID
|
||||
// =========================
|
||||
public function find($id = null)
|
||||
{
|
||||
$record = $this->StaffModel->find($id);
|
||||
|
||||
if (!$record) {
|
||||
return $this->response->setJSON([
|
||||
'status' => 'error',
|
||||
'message' => 'Record not found'
|
||||
])->setStatusCode(404);
|
||||
}
|
||||
|
||||
return $this->response->setJSON($record);
|
||||
}
|
||||
|
||||
// =========================
|
||||
// 3. Create new staff
|
||||
// =========================
|
||||
public function create()
|
||||
{
|
||||
$data = $this->request->getJSON(true); // JSON body to array
|
||||
|
||||
if (!$this->StaffModel->insert($data)) {
|
||||
return $this->response->setJSON([
|
||||
'status' => 'error',
|
||||
'message' => 'Failed to insert',
|
||||
'errors' => $this->StaffModel->errors()
|
||||
])->setStatusCode(400);
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => 'success',
|
||||
'message' => 'Staff created successfully',
|
||||
'id' => $this->StaffModel->getInsertID()
|
||||
]);
|
||||
}
|
||||
|
||||
// =========================
|
||||
// 4. Update staff by ID
|
||||
// =========================
|
||||
public function update($id = null)
|
||||
{
|
||||
$data = $this->request->getJSON(true);
|
||||
|
||||
if (!$this->StaffModel->update($id, $data)) {
|
||||
return $this->response->setJSON([
|
||||
'status' => 'error',
|
||||
'message' => 'Failed to update',
|
||||
'errors' => $this->StaffModel->errors()
|
||||
])->setStatusCode(400);
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => 'success',
|
||||
'message' => 'Staff updated successfully'
|
||||
]);
|
||||
}
|
||||
}
|
||||
23
app/Controllers/SwaggerController.php
Normal file
23
app/Controllers/SwaggerController.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use OpenApi\Annotations as OA;
|
||||
use OpenApi\Generator;
|
||||
|
||||
class SwaggerController extends BaseController
|
||||
{
|
||||
public function view()
|
||||
{
|
||||
// echo 'Hai'; die;
|
||||
return view('swagger/index');
|
||||
}
|
||||
|
||||
public function generate()
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
$openapi = Generator::scan([APPPATH . 'Controllers', APPPATH . 'Models']);
|
||||
dd($openapi);
|
||||
echo $openapi->toJson();
|
||||
}
|
||||
}
|
||||
0
app/Database/Migrations/.gitkeep
Executable file
0
app/Database/Migrations/.gitkeep
Executable file
0
app/Database/Seeds/.gitkeep
Executable file
0
app/Database/Seeds/.gitkeep
Executable file
0
app/Filters/.gitkeep
Executable file
0
app/Filters/.gitkeep
Executable file
56
app/Filters/Cors.php
Normal file
56
app/Filters/Cors.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filters;
|
||||
|
||||
use CodeIgniter\Filters\FilterInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
||||
class Cors implements FilterInterface
|
||||
{
|
||||
/**
|
||||
* Do whatever processing this filter needs to do.
|
||||
* By default it should not return anything during
|
||||
* normal execution. However, when an abnormal state
|
||||
* is found, it should return an instance of
|
||||
* CodeIgniter\HTTP\Response. If it does, script
|
||||
* execution will end and that Response will be
|
||||
* sent back to the client, allowing for error pages,
|
||||
* redirects, etc.
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
* @param array|null $arguments
|
||||
*
|
||||
* @return RequestInterface|ResponseInterface|string|void
|
||||
*/
|
||||
public function before(RequestInterface $request, $arguments = null)
|
||||
{
|
||||
// Set CORS headers
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With");
|
||||
|
||||
// Handle preflight requests
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
header("HTTP/1.1 200 OK");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows After filters to inspect and modify the response
|
||||
* object as needed. This method does not allow any way
|
||||
* to stop execution of other after filters, short of
|
||||
* throwing an Exception or Error.
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
* @param ResponseInterface $response
|
||||
* @param array|null $arguments
|
||||
*
|
||||
* @return ResponseInterface|void
|
||||
*/
|
||||
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
|
||||
{
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
35
app/Filters/JwtAuthFilter.php
Normal file
35
app/Filters/JwtAuthFilter.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filters;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\Filters\FilterInterface;
|
||||
use Firebase\JWT\JWT;
|
||||
use Firebase\JWT\Key;
|
||||
|
||||
class JwtAuthFilter implements FilterInterface
|
||||
{
|
||||
public function before(RequestInterface $request, $arguments = null)
|
||||
{
|
||||
helper('jwt_helper');
|
||||
$header = $request->getHeaderLine('Authorization');
|
||||
|
||||
if (!$header || !preg_match('/Bearer\s(\S+)/', $header, $matches)) {
|
||||
return service('response')->setJSON(['status' => 401, 'message' => 'Token required'])->setStatusCode(401);
|
||||
}
|
||||
|
||||
$decodedToken = validateJWT($matches[1]);
|
||||
|
||||
if (!$decodedToken) {
|
||||
return service('response')->setJSON(['status' => 401, 'message' => 'Invalid or expired token'])->setStatusCode(401);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
|
||||
{
|
||||
// No action needed
|
||||
}
|
||||
}
|
||||
44
app/Filters/SignedUrlFilter.php
Executable file
44
app/Filters/SignedUrlFilter.php
Executable file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filters;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\Filters\FilterInterface;
|
||||
use Config\Services;
|
||||
class SignedUrlFilter implements FilterInterface
|
||||
{
|
||||
public function before(RequestInterface $request, $arguments = null)
|
||||
{
|
||||
$secretKey = 'your-secret-key'; // Change this to your secret key
|
||||
$expires = $request->getGet('expires');
|
||||
$signature = $request->getGet('signature');
|
||||
|
||||
if (!$expires || !$signature) {
|
||||
return Services::response()->setStatusCode(403)->setBody('Forbidden');
|
||||
}
|
||||
|
||||
if (time() > $expires) {
|
||||
$body = view('expired_link');
|
||||
return Services::response()->setStatusCode(403)->setBody($body);
|
||||
}
|
||||
|
||||
$queryParams = $request->getGet();
|
||||
unset($queryParams['signature']);
|
||||
$route = $request->getPath();
|
||||
$expectedSignature = hash_hmac('sha256', $route . '?' . http_build_query($queryParams), $secretKey);
|
||||
|
||||
if (!hash_equals($expectedSignature, $signature)) {
|
||||
return Services::response()->setStatusCode(403)->setBody('Invalid signature');
|
||||
}
|
||||
|
||||
return true; // Allow the request
|
||||
}
|
||||
|
||||
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
|
||||
{
|
||||
// Do nothing here
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
36
app/Filters/VerifyAppSignature.php
Normal file
36
app/Filters/VerifyAppSignature.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filters;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\Filters\FilterInterface;
|
||||
|
||||
class VerifyAppSignature implements FilterInterface
|
||||
{
|
||||
public function before(RequestInterface $request, $arguments = null)
|
||||
{
|
||||
// Get the header sent by the Flutter app
|
||||
$clientSignature = $request->getHeaderLine('App-Signature');
|
||||
|
||||
// Load the server's expected signature from the .env
|
||||
$validSignature = getenv('APP_SIGNATURE');
|
||||
|
||||
// Check if signature is valid
|
||||
if ($clientSignature !== $validSignature) {
|
||||
return service('response')
|
||||
->setStatusCode(403)
|
||||
->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Forbidden: Invalid App Signature',
|
||||
]);
|
||||
}
|
||||
|
||||
// allow request to proceed
|
||||
}
|
||||
|
||||
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
|
||||
{
|
||||
// nothing to do after response
|
||||
}
|
||||
}
|
||||
0
app/Helpers/.gitkeep
Executable file
0
app/Helpers/.gitkeep
Executable file
491
app/Helpers/common_helper.php
Normal file
491
app/Helpers/common_helper.php
Normal file
@ -0,0 +1,491 @@
|
||||
<?php
|
||||
|
||||
use App\Models\OrganizationModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\GroupModel;
|
||||
use App\Models\PolicyModel;
|
||||
use App\Models\PolicyDetailsModel;
|
||||
use App\Models\ServiceModel;
|
||||
use App\Models\PlanStatusModel;
|
||||
use App\Models\PlanModel;
|
||||
|
||||
if (!function_exists('getUserByEmail')) {
|
||||
function getUserByEmail($email)
|
||||
{
|
||||
$userModel = new UserModel();
|
||||
$user = $userModel->where('email', $email)->first();
|
||||
|
||||
return $user ? $user : false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('checkUserExist')) {
|
||||
function checkUserExist($first_name, $email)
|
||||
{
|
||||
$userModel = new UserModel();
|
||||
|
||||
// Check if email already exists
|
||||
$user = $userModel->where('email', $email)->first();
|
||||
if ($user) {
|
||||
return ['status' => true,'data' => $user ,'message' => 'User already exists'];
|
||||
}
|
||||
|
||||
// Insert new user
|
||||
$userId = $userModel->insert([
|
||||
'first_name' => $first_name,
|
||||
'email' => $email,
|
||||
'org_id' => env('ORG_id')
|
||||
]);
|
||||
|
||||
if($userId){
|
||||
$user = $userModel->where('user_id', $userId)->first();
|
||||
return ['status' => true,'data' => $user ,'message' => 'User created successfully'];
|
||||
}else{
|
||||
return ['status' => false, 'message' => 'Something wend wrong'];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('getUserPlanCreationRestrictionStatus')) {
|
||||
function getUserPlanCreationRestrictionStatus($user)
|
||||
{
|
||||
if($user['group_id'] != null)
|
||||
{
|
||||
$groupModel = new GroupModel();
|
||||
$groupData = $groupModel->find($user['group_id']);
|
||||
if($groupData)
|
||||
{
|
||||
$domesticPolicyId = $groupData['domestic_policy_id'];
|
||||
$internationalPolicyId = $groupData['international_policy_id'];
|
||||
$policyDetailsModel = new PolicyDetailsModel();
|
||||
|
||||
if($domesticPolicyId != null && $internationalPolicyId != null)
|
||||
{
|
||||
$domesticPolicy = $policyDetailsModel->where('policy_id',$domesticPolicyId)->where('service_id', 1)->find();
|
||||
$domesticCheck = checkApproverSetOrNotBasedOnPolicy($domesticPolicy,$user);
|
||||
$internationalPolicy = $policyDetailsModel->where('policy_id',$internationalPolicyId)->where('service_id', 1)->find();
|
||||
$internationalCheck = checkApproverSetOrNotBasedOnPolicy($internationalPolicy,$user);
|
||||
|
||||
if($domesticCheck == true && $internationalCheck == true)
|
||||
return 'Both Type Plan Creation Allowed';
|
||||
else
|
||||
return 'Plan Creation Not Allowed';
|
||||
|
||||
}
|
||||
else if($domesticPolicyId != null)
|
||||
{
|
||||
$domesticPolicy = $policyDetailsModel->where('policy_id',$domesticPolicyId)->where('service_id', 1)->find();
|
||||
$check = checkApproverSetOrNotBasedOnPolicy($domesticPolicy,$user);
|
||||
$internationalPolicy = $policyDetailsModel->where('policy_id',$domesticPolicyId)->where('service_id', 1)->find();
|
||||
$check = checkApproverSetOrNotBasedOnPolicy($internationalPolicy,$user);
|
||||
|
||||
if($check == true)
|
||||
return 'Only Domestic Plan Creation Allowed';
|
||||
else
|
||||
return 'Plan Creation Not Allowed';
|
||||
|
||||
}
|
||||
else if($internationalPolicyId != null)
|
||||
{
|
||||
|
||||
$internationalPolicy = $policyDetailsModel->where('policy_id',$internationalPolicyId)->where('service_id', 1)->find();
|
||||
$check = checkApproverSetOrNotBasedOnPolicy($internationalPolicy,$user);
|
||||
|
||||
if($check == true)
|
||||
return 'Only International Plan Creation Allowed';
|
||||
else
|
||||
return 'Plan Creation Not Allowed';
|
||||
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
return 'Plan Creation Not Allowed';
|
||||
}
|
||||
|
||||
}else{
|
||||
return 'Plan Creation Not Allowed';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function checkApproverSetOrNotBasedOnPolicy($Policy,$user)
|
||||
{
|
||||
// Step 1: Determine required approver levels (a1 to a4)
|
||||
$requiredApprovers = [];
|
||||
|
||||
foreach (['', '_exceptional', '_amendment'] as $type) {
|
||||
for ($i = 1; $i <= 4; $i++) {
|
||||
$key = "a{$i}{$type}_action";
|
||||
if (isset($Policy[0][$key]) && $Policy[0][$key] === 'Approval') {
|
||||
$requiredApprovers[] = $i; // add level (1 to 4)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicates (in case multiple types require same level)
|
||||
$requiredApprovers = array_unique($requiredApprovers);
|
||||
|
||||
// Step 2: Check user profile for each required approver level
|
||||
$missingApprovers = [];
|
||||
|
||||
foreach ($requiredApprovers as $level) {
|
||||
$profileKey = match ($level) {
|
||||
1 => 'first_approver',
|
||||
2 => 'second_approver',
|
||||
3 => 'third_approver',
|
||||
4 => 'fourth_approver',
|
||||
};
|
||||
|
||||
if (empty($user[$profileKey]) || $user[$profileKey] == 0) {
|
||||
$missingApprovers[] = $profileKey;
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3: Final check
|
||||
if (!empty($missingApprovers)) {
|
||||
// One or more approvers missing
|
||||
// echo "Missing approvers in user profile: " . implode(', ', $missingApprovers);
|
||||
return false;
|
||||
} else {
|
||||
// echo "All required approvers are set in user profile.";
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('isDataChanged')) {
|
||||
function isDataChanged($model, $id, array $newData): bool
|
||||
{
|
||||
// Step 1: Fetch old data from the model
|
||||
$oldData = $model->where('plan_id', $id)->where('is_active', 1)->findAll();
|
||||
|
||||
if (!$oldData) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Step 2: Define keys to exclude
|
||||
$excludeKeys = ['created_by', 'updated_by', 'created_on', 'updated_on'];
|
||||
|
||||
// Step 3: Clean both old and new data arrays
|
||||
$cleanOldData = array_map(function($item) use ($excludeKeys) {
|
||||
foreach ($excludeKeys as $key) {
|
||||
unset($item[$key]);
|
||||
}
|
||||
return $item;
|
||||
}, $oldData);
|
||||
|
||||
$cleanNewData = array_map(function($item) use ($excludeKeys) {
|
||||
foreach ($excludeKeys as $key) {
|
||||
unset($item[$key]);
|
||||
}
|
||||
return $item;
|
||||
}, $newData);
|
||||
|
||||
|
||||
// Step 4: Compare count
|
||||
if (count($cleanOldData) !== count($cleanNewData)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Step 5: Check if there's any difference
|
||||
return $cleanOldData !== $cleanNewData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('isFlightTripDataChanged')) {
|
||||
function isFlightTripDataChanged($model, $id, array $newData): bool
|
||||
{
|
||||
|
||||
$newTripData = [];
|
||||
$flightIds = array_column($newData, 'flight_id');
|
||||
foreach ($newData as $key1 => $value1) {
|
||||
foreach ($value1['trips'] as $key => $value) {
|
||||
array_push($newTripData , $value);
|
||||
}
|
||||
}
|
||||
|
||||
// Step 1: Fetch old data from the model
|
||||
if(!empty($flightIds))
|
||||
$oldData = $model->whereIn('flight_id', $flightIds)->where('is_active', 1)->findAll();
|
||||
else
|
||||
$oldData = [];
|
||||
|
||||
|
||||
if (!$oldData) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Step 2: Define keys to exclude
|
||||
$excludeKeys = ['created_by', 'updated_by', 'created_on', 'updated_on'];
|
||||
|
||||
// Step 3: Clean both old and new data arrays
|
||||
$cleanOldData = array_map(function($item) use ($excludeKeys) {
|
||||
foreach ($excludeKeys as $key) {
|
||||
unset($item[$key]);
|
||||
}
|
||||
return $item;
|
||||
}, $oldData);
|
||||
|
||||
$cleanNewData = array_map(function($item) use ($excludeKeys) {
|
||||
foreach ($excludeKeys as $key) {
|
||||
unset($item[$key]);
|
||||
}
|
||||
return $item;
|
||||
}, $newTripData);
|
||||
|
||||
|
||||
// Step 4: Compare count
|
||||
if (count($cleanOldData) !== count($cleanNewData)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Step 5: Check if there's any difference
|
||||
return $cleanOldData !== $cleanNewData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getDelegatedPlans($org_id, $id)
|
||||
{
|
||||
$userModel = new UserModel();
|
||||
$planModel = new PlanModel();
|
||||
$planStatusModel = new PlanStatusModel();
|
||||
$delegatedUsers = $userModel->where('delegated_to_user_id', $id)
|
||||
->where('is_active', 1)
|
||||
->where('delegation_start_date <=', date('Y-m-d'))
|
||||
->where('delegation_end_date >=', date('Y-m-d'))
|
||||
->findAll();
|
||||
$allPlanData = [];
|
||||
foreach ($delegatedUsers as $user) {
|
||||
|
||||
$userId = $user['user_id'];
|
||||
$startDate = $user['delegation_start_date'];
|
||||
$endDate = $user['delegation_end_date'];
|
||||
|
||||
$a1Data = $planStatusModel->select('plan_id,a1_id as user_id')
|
||||
->where('a1_id',$userId)
|
||||
->where('a1_action','Approval')
|
||||
->where('created_on >=', $startDate)
|
||||
->where('created_on <=', $endDate)
|
||||
->where('is_active',1)
|
||||
->findAll();
|
||||
|
||||
$a2Data = $planStatusModel->select('plan_id,a2_id as user_id')
|
||||
->where('a2_id',$userId)
|
||||
->where('a2_action','Approval')
|
||||
->where('created_on >=', $startDate)
|
||||
->where('created_on <=', $endDate)
|
||||
->where('is_active',1)
|
||||
->findAll();
|
||||
|
||||
$a3Data = $planStatusModel->select('plan_id,a3_id as user_id')
|
||||
->where('a3_id',$userId)
|
||||
->where('a3_action','Approval')
|
||||
->where('is_active',1)
|
||||
->where('created_on >=', $startDate)
|
||||
->where('created_on <=', $endDate)
|
||||
->findAll();
|
||||
|
||||
$a4Data = $planStatusModel->select('plan_id,a4_id as user_id')
|
||||
->where('a4_id',$userId)
|
||||
->where('a4_action','Approval')
|
||||
->where('is_active',1)
|
||||
->where('created_on >=', $startDate)
|
||||
->where('created_on <=', $endDate)
|
||||
->findAll();
|
||||
|
||||
// Merge results (each record has plan_id + user_id)
|
||||
$merged = array_merge($a1Data, $a2Data, $a3Data, $a4Data);
|
||||
|
||||
// Merge into final array
|
||||
$allPlanData = array_merge($allPlanData, $merged);
|
||||
|
||||
}
|
||||
|
||||
//get already approved data in delegated flow
|
||||
// $a1 = $planStatusModel->select('plan_id,a1_id as user_id')->where('a1_action_done_by',$id)->where('a1_action','Approval')->where('is_active',1)->findAll();
|
||||
// $a2 = $planStatusModel->select('plan_id,a2_id as user_id')->where('a2_action_done_by',$id)->where('a2_action','Approval')->where('is_active',1)->findAll();
|
||||
// $a3 = $planStatusModel->select('plan_id,a3_id as user_id')->where('a3_action_done_by',$id)->where('a3_action','Approval')->where('is_active',1)->findAll();
|
||||
|
||||
//need to discuss with sir
|
||||
// $mergedApprovedArray = array_merge($a1, $a2, $a3);
|
||||
$mergedApprovedArray = [];
|
||||
|
||||
// Merge into main list
|
||||
$allPlanData = array_merge($allPlanData, $mergedApprovedArray);
|
||||
|
||||
// Remove duplicate associative arrays
|
||||
$allPlanData = array_map('unserialize', array_unique(array_map('serialize', $allPlanData)));
|
||||
|
||||
$plansWithUser = [];
|
||||
|
||||
foreach ($allPlanData as $item) {
|
||||
$planId = $item['plan_id'];
|
||||
$userId = $item['user_id'];
|
||||
$userData = $userModel->where('user_id',$userId)->first();
|
||||
$userName = $userData['first_name'].' '.$userData['last_name'];
|
||||
|
||||
$planData = $planModel->getActivePlan($org_id, 'PLAN', null , $planId);
|
||||
|
||||
if ($planData) {
|
||||
$planData['approver_id'] = $userId;
|
||||
$planData['approver_name'] = $userName;
|
||||
$planData['delegater_id'] = $id;
|
||||
$planData['approver_status'] = getApproverCurrentAction( $planData['plan_id'], $userId );
|
||||
$plansWithUser[] = $planData;
|
||||
}
|
||||
}
|
||||
|
||||
return $plansWithUser;
|
||||
|
||||
}
|
||||
|
||||
function normalize_date(string $date): ?string
|
||||
{
|
||||
$date = trim($date);
|
||||
|
||||
// If already valid Y-m-d (e.g., 2025-03-20), return it as-is
|
||||
$yFormat = DateTime::createFromFormat('Y-m-d', $date);
|
||||
if ($yFormat && $yFormat->format('Y-m-d') === $date) {
|
||||
return $date;
|
||||
}
|
||||
|
||||
// Try to convert from d-m-Y (e.g., 20-03-2025)
|
||||
$dFormat = DateTime::createFromFormat('d-m-Y', $date);
|
||||
if ($dFormat) {
|
||||
return $dFormat->format('Y-m-d');
|
||||
}
|
||||
|
||||
// Try from d/m/Y (optional)
|
||||
$slashFormat = DateTime::createFromFormat('d/m/Y', $date);
|
||||
if ($slashFormat) {
|
||||
return $slashFormat->format('Y-m-d');
|
||||
}
|
||||
|
||||
// Unknown format
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!function_exists('format_date_for_client')) {
|
||||
/**
|
||||
* Converts a date from 'Y-m-d' to 'd-m-Y'.
|
||||
*
|
||||
* @param string $date
|
||||
* @return string|null
|
||||
*/
|
||||
function format_date_for_client(string $date): ?string
|
||||
{
|
||||
$dt = DateTime::createFromFormat('Y-m-d', $date);
|
||||
if ($dt) {
|
||||
return $dt->format('d-m-Y');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('isValidUploadedFile')) {
|
||||
function isValidUploadedFile($file): bool
|
||||
{
|
||||
return $file && $file->isValid();
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('isAllowedExtension')) {
|
||||
function isAllowedExtension($file, array $allowedExtensions = [] ): bool
|
||||
{
|
||||
$ext = strtolower($file->getClientExtension());
|
||||
|
||||
$result = in_array($ext, $allowedExtensions);
|
||||
|
||||
$result = empty($allowedExtensions) ? true : $result ;
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('isExcelNotEmpty')) {
|
||||
function isExcelNotEmpty(array $sheetData): bool
|
||||
{
|
||||
return !empty($sheetData) && count($sheetData) >= 2;
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('createDirectoryWith0777Permission')){
|
||||
|
||||
function createDirectoryWith0777Permission( $uploadDir)
|
||||
{
|
||||
if (!is_dir($uploadDir)) {
|
||||
mkdir($uploadDir, 0777, true); // recursive creation with full permission
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getAllowedClassForUser($trip_type,$user_id)
|
||||
{
|
||||
|
||||
$userModel = new UserModel();
|
||||
$groupModel = new GroupModel();
|
||||
$policyDetailsModel = new PolicyDetailsModel();
|
||||
$policyDetailsModel = new PolicyDetailsModel();
|
||||
|
||||
$user = $userModel->where('user_id', $user_id)->first();
|
||||
$groupData = $groupModel->find($user['group_id']);
|
||||
|
||||
if($groupData)
|
||||
{
|
||||
if($trip_type == 1) { $policyId = $groupData['domestic_policy_id'];}else{ $policyId = $groupData['international_policy_id'];}
|
||||
if($policyId != null)
|
||||
{
|
||||
$allowedFlightClass = $policyDetailsModel->select('c_policy_details.class, m_dropdown.dropdown_value as allowed_class')
|
||||
->join('m_dropdown', 'dropdown_key = c_policy_details.class AND dropdown = "flight_class"', 'left')
|
||||
->where('policy_id',$policyId)
|
||||
->where('service_id',1)
|
||||
->first();
|
||||
$data['flight'] = $allowedFlightClass['allowed_class'] ?? [];
|
||||
|
||||
$allowedTrainClass = $policyDetailsModel->select('c_policy_details.class, m_dropdown.dropdown_value as allowed_class')
|
||||
->join('m_dropdown', 'dropdown_key = c_policy_details.class AND dropdown = "train_class"', 'left')
|
||||
->where('policy_id',$policyId)
|
||||
->where('service_id',2)
|
||||
->first();
|
||||
$data['train'] = $allowedTrainClass['allowed_class'] ?? [];
|
||||
|
||||
$allowedHotelClass = $policyDetailsModel->select('c_policy_details.class, m_dropdown.dropdown_value as allowed_class')
|
||||
->join('m_dropdown', 'dropdown_key = c_policy_details.class AND dropdown = "hotel_class"', 'left')
|
||||
->where('policy_id',$policyId)
|
||||
->where('service_id',5)
|
||||
->first();
|
||||
$data['hotel'] = $allowedHotelClass['allowed_class'] ?? [];
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
37
app/Helpers/jwt_helper.php
Normal file
37
app/Helpers/jwt_helper.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Firebase\JWT\JWT;
|
||||
use Firebase\JWT\Key;
|
||||
|
||||
if (!function_exists('generateJWT')) {
|
||||
function generateJWT($userData)
|
||||
{
|
||||
$key = getenv('JWT_SECRET'); // Load secret from .env
|
||||
$issuedAt = time();
|
||||
$expire = $issuedAt + 14400; // Token valid for 4 hour
|
||||
|
||||
$payload = [
|
||||
'iss' => base_url(), // Issuer
|
||||
'iat' => $issuedAt, // Issued at
|
||||
'exp' => $expire, // Expiration time
|
||||
'sub' => $userData['user_id'], // Subject (User ID)
|
||||
'data' => $userData // Additional user data
|
||||
];
|
||||
|
||||
return JWT::encode($payload, $key, 'HS256');
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('validateJWT')) {
|
||||
function validateJWT($token)
|
||||
{
|
||||
$key = getenv('JWT_SECRET');
|
||||
|
||||
try {
|
||||
$decoded = JWT::decode($token, new Key($key, 'HS256'));
|
||||
return (array) $decoded;
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
67
app/Helpers/mail_helper.php
Normal file
67
app/Helpers/mail_helper.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
use App\Models\AgentModel;
|
||||
|
||||
|
||||
if (!function_exists('send_login_otp')) {
|
||||
function send_login_otp( $to_email , $subject , $message)
|
||||
{
|
||||
try {
|
||||
// Set up ZeptoMail API request
|
||||
$endpoint = "https://api.zeptomail.com/v1.1/email";
|
||||
$apiKey = env('ZOHO_API_KEY');
|
||||
$sender = env('ZOHO_SENDER_MAIL');
|
||||
|
||||
$payload = [
|
||||
"from" => [
|
||||
"address" => $sender,
|
||||
"name" => "Nhance-Partner"
|
||||
],
|
||||
"to" => [
|
||||
["email_address" => ["address" => $to_email]]
|
||||
],
|
||||
"subject" => $subject,
|
||||
"htmlbody" => $message,
|
||||
];
|
||||
|
||||
|
||||
|
||||
$headers = [
|
||||
"Content-Type: application/json",
|
||||
"Authorization: Zoho-enczapikey " . $apiKey
|
||||
];
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $endpoint);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
if (curl_errno($ch)) {
|
||||
$error_msg = curl_error($ch);
|
||||
log_message('error', "[EMAIL ERROR] Curl failed: {$error_msg}");
|
||||
return ['status' => 'failed', 'code' => 500, 'message' => 'Curl error', 'error' => $error_msg];
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
$resp = json_decode($response, true);
|
||||
|
||||
if ($httpCode === 200 && isset($resp['request_id'])) {
|
||||
log_message('debug', 'OTP Send Success to agent , email = ' . $to_email);
|
||||
return ['status' => 'success', 'code' => 200, 'message' => 'Send Success'];
|
||||
} else {
|
||||
log_message('error', "[OTP Send FAILED] , email = {$to_email}, HTTP: {$httpCode}, Response: {$response}");
|
||||
return ['status' => 'failed', 'code' => 500, 'message' => 'Curl error', 'error' => $response];
|
||||
}
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
log_message('debug', 'Exception occurred while sending email to agent: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
63
app/Helpers/oauth_helper.php
Executable file
63
app/Helpers/oauth_helper.php
Executable file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
// File: app/Helpers/oauth_helper.php
|
||||
|
||||
use Google\Client as GoogleClient;
|
||||
use Google\Service\Oauth2;
|
||||
|
||||
// Check if the function exists, to prevent redeclaration
|
||||
if (!function_exists('googleOauthLogin')) {
|
||||
|
||||
function googleOAuthLogin($oauthToken)
|
||||
{
|
||||
|
||||
// Retrieve configuration values from environment variables
|
||||
// $appName = "710416535204-q948ovmbgs74lpf7so5866qtk8bpjthm.apps.googleusercontent.com";
|
||||
// $clientID = "710416535204-q948ovmbgs74lpf7so5866qtk8bpjthm.apps.googleusercontent.com";
|
||||
// $clientSecret = "18GKZJcIChn1Nore25fLPoT52137";
|
||||
// $redirectUri = "http://localhost/ts_tat/googleoauth";
|
||||
// $scopes = ["https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"];
|
||||
|
||||
$clientID = '696241936560-m2mr272ge7vr2n4q36c22l3d2gdgi90l.apps.googleusercontent.com';
|
||||
$clientSecret = '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';
|
||||
$redirectUri = "http://localhost/ts_tat/googleoauth";
|
||||
$scopes = ["https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"];
|
||||
|
||||
|
||||
// Initialize a new Google client
|
||||
$client = new GoogleClient();
|
||||
$client->setClientId($clientID);
|
||||
$client->setClientSecret($clientSecret);
|
||||
$client->setRedirectUri($redirectUri);
|
||||
$client->addScope($scopes);
|
||||
// $client->setApprovalPrompt('force');
|
||||
$client->setPrompt('consent');
|
||||
$client->setAccessType('offline');
|
||||
|
||||
// Check if an OAuth token is provided
|
||||
if ($oauthToken) {
|
||||
try {
|
||||
// Attempt to fetch the access token with the provided OAuth token
|
||||
$token = $client->fetchAccessTokenWithAuthCode($oauthToken);
|
||||
$client->setAccessToken($token);
|
||||
|
||||
$oauth = new Oauth2($client);
|
||||
|
||||
// Get user information using the OAuth2 service
|
||||
$user_info = $oauth->userinfo->get();
|
||||
return $user_info;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Handle exceptions and return an error message
|
||||
return 'Error fetching access token: ' . $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
// If no OAuth token is provided, generate the authentication URL
|
||||
$url = $client->createAuthUrl();
|
||||
// Redirect the user to the authentication URL
|
||||
// return $url;
|
||||
return redirect()->to(filter_var($url, FILTER_SANITIZE_URL));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
908
app/Helpers/status_helper.php
Normal file
908
app/Helpers/status_helper.php
Normal file
@ -0,0 +1,908 @@
|
||||
<?php
|
||||
use App\Controllers\PlanController;
|
||||
use App\Models\OrganizationModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\GroupModel;
|
||||
use App\Models\PolicyModel;
|
||||
use App\Models\PolicyDetailsModel;
|
||||
use App\Models\ServiceModel;
|
||||
use App\Models\PlanStatusModel;
|
||||
use App\Models\PlanModel;
|
||||
|
||||
|
||||
if (!function_exists('palnStatusHandler')) {
|
||||
function palnStatusHandler($plan_id , $is_data_edited)
|
||||
{
|
||||
log_message('info', "palnStatusHandler() called for plan_id: {$plan_id}, is_data_edited: {$is_data_edited}");
|
||||
|
||||
$planModel = new PlanModel();
|
||||
$planStatusModel = new PlanStatusModel();
|
||||
$userModel = new UserModel();
|
||||
$groupModel = new GroupModel();
|
||||
$policyModel = new PolicyModel();
|
||||
$policyDetailsModel = new PolicyDetailsModel();
|
||||
$planController = new PlanController();
|
||||
|
||||
$planData = $planController->find($plan_id, 'internal');
|
||||
if (!$planData) {
|
||||
log_message('error', "No plan data found for plan_id: {$plan_id}");
|
||||
return false;
|
||||
}
|
||||
|
||||
$planServices = [];
|
||||
if (count($planData['flight'])) { array_push($planServices, 1); }
|
||||
if (count($planData['train'])) { array_push($planServices, 2); }
|
||||
if (count($planData['bus'])) { array_push($planServices, 3); }
|
||||
if (count($planData['taxi'])) { array_push($planServices, 4); }
|
||||
if (count($planData['accomodation'])) { array_push($planServices, 5); }
|
||||
if (count($planData['forex'])) { array_push($planServices, 6); }
|
||||
if (count($planData['insurance'])) { array_push($planServices, 7); }
|
||||
if (count($planData['visa'])) { array_push($planServices, 8); }
|
||||
if (count($planData['miscellaneous'])) { array_push($planServices, 9); }
|
||||
|
||||
log_message('debug', "Plan services found: " . json_encode($planServices));
|
||||
|
||||
$userId = $planData['user_id'] ?? $planData['traveller_id'];
|
||||
$userData = $userModel->where('user_id', $userId)->first();
|
||||
if (!$userData) {
|
||||
log_message('error', "User data not found for user_id: {$userId}");
|
||||
return false;
|
||||
}
|
||||
|
||||
$groupId = $userData['group_id'];
|
||||
$a1Id = $userData['first_approver'];
|
||||
$a2Id = $userData['second_approver'];
|
||||
$a3Id = $userData['third_approver'];
|
||||
$a4Id = $userData['fourth_approver'];
|
||||
|
||||
$groupData = $groupModel->where('group_id', $groupId)->first();
|
||||
if (!$groupData) {
|
||||
log_message('error', "Group data not found for group_id: {$groupId}");
|
||||
return false;
|
||||
}
|
||||
|
||||
$tripType = $planData['trip_type'];
|
||||
$policyId = ($tripType == 1) ? $groupData['domestic_policy_id'] : $groupData['international_policy_id'];
|
||||
|
||||
$policyData = $policyModel->where('policy_id', $policyId)->first();
|
||||
if (!$policyData) {
|
||||
log_message('error', "Policy data not found for policy_id: {$policyId}");
|
||||
return false;
|
||||
}
|
||||
|
||||
$priorityOrderOfService = json_decode($policyData['services_ids'], true);
|
||||
if (!is_array($priorityOrderOfService)) {
|
||||
log_message('error', "Invalid service priority list in policy_id: {$policyId}");
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($priorityOrderOfService as $key => &$value) {
|
||||
$value['priority'] = $key + 1;
|
||||
}
|
||||
unset($value);
|
||||
|
||||
log_message('debug', "Service priority list: " . json_encode($priorityOrderOfService));
|
||||
|
||||
// Step 1: Filter only services present in current plan
|
||||
$filtered = array_filter($priorityOrderOfService, function ($item) use ($planServices) {
|
||||
return in_array($item['service_id'], $planServices);
|
||||
});
|
||||
|
||||
// Step 2: Sort by priority
|
||||
usort($filtered, function ($a, $b) {
|
||||
return $a['priority'] <=> $b['priority'];
|
||||
});
|
||||
|
||||
$topPriorityService = reset($filtered);
|
||||
if (!$topPriorityService) {
|
||||
log_message('error', "No matching service found for plan_id: {$plan_id}");
|
||||
return false;
|
||||
}
|
||||
|
||||
log_message('info', "Top priority service identified: " . json_encode($topPriorityService));
|
||||
|
||||
$policyServiceDetails = $policyDetailsModel
|
||||
->where('policy_id', $policyId)
|
||||
->where('service_id', $topPriorityService['service_id'])
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
if (!$policyServiceDetails) {
|
||||
log_message('error', "Policy service details not found for service_id: {$topPriorityService['service_id']}, policy_id: {$policyId}");
|
||||
return false;
|
||||
}
|
||||
// dd($policyServiceDetails);
|
||||
|
||||
|
||||
$isExceptional = $planData['exceptional_plan_reason'] !== null && $planData['exceptional_plan_reason'] !== '';
|
||||
// dd($isExceptional);
|
||||
|
||||
if ($isExceptional) {
|
||||
$policyA1Action = $policyServiceDetails['a1_exceptional_action'];
|
||||
$policyA2Action = $policyServiceDetails['a2_exceptional_action'];
|
||||
$policyA3Action = $policyServiceDetails['a3_exceptional_action'];
|
||||
$policyA4Action = $policyServiceDetails['a4_exceptional_action'];
|
||||
$policyParallelAction = $policyServiceDetails['exceptional_parallel_process_from'];
|
||||
} else if ($is_data_edited) {
|
||||
$policyA1Action = $policyServiceDetails['a1_amendment_action'];
|
||||
$policyA2Action = $policyServiceDetails['a2_amendment_action'];
|
||||
$policyA3Action = $policyServiceDetails['a3_amendment_action'];
|
||||
$policyA4Action = $policyServiceDetails['a4_amendment_action'];
|
||||
$policyParallelAction = $policyServiceDetails['amendment_parallel_process_from'];
|
||||
} else {
|
||||
$policyA1Action = $policyServiceDetails['a1_action'];
|
||||
$policyA2Action = $policyServiceDetails['a2_action'];
|
||||
$policyA3Action = $policyServiceDetails['a3_action'];
|
||||
$policyA4Action = 'None';
|
||||
$policyParallelAction = $policyServiceDetails['parallel_process_from'];
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'plan_id' => $plan_id,
|
||||
'service_id' => $topPriorityService['service_id'],
|
||||
'a1_id' => $a1Id,
|
||||
'a1_action' => $policyA1Action,
|
||||
'is_a1_action_done' => ($policyA1Action == 'None') ? 1 : 0,
|
||||
'a2_id' => $a2Id,
|
||||
'a2_action' => $policyA2Action,
|
||||
'is_a2_action_done' => ($policyA2Action == 'None') ? 1 : 0,
|
||||
'a3_id' => $a3Id,
|
||||
'a3_action' => $policyA3Action,
|
||||
'is_a3_action_done' => ($policyA3Action == 'None') ? 1 : 0,
|
||||
'a4_id' => $a4Id,
|
||||
'a4_action' => $policyA4Action,
|
||||
'is_a4_action_done' => ($policyA4Action == 'None') ? 1 : 0,
|
||||
'parallel_process_from' => $policyParallelAction
|
||||
];
|
||||
|
||||
// dd($data);
|
||||
|
||||
if ($is_data_edited == false) {
|
||||
log_message('info', "Creating new plan status for plan_id: {$plan_id}");
|
||||
$planStatusModel->insert($data);
|
||||
} else {
|
||||
$oldStatusData = $planStatusModel->where('plan_id', $plan_id)->where('is_active', 1)->first();
|
||||
if ($oldStatusData) {
|
||||
if ($oldStatusData['service_id'] == $topPriorityService['service_id']) {
|
||||
log_message('info', "No status update needed; service_id unchanged for plan_id: {$plan_id}");
|
||||
} else {
|
||||
log_message('info', "Updating plan status for edited plan_id: {$plan_id}. New service_id: {$topPriorityService['service_id']}, Old service_id: {$oldStatusData['service_id']}");
|
||||
$planStatusModel->insert($data);
|
||||
$planStatusModel->set(['is_active' => 0])
|
||||
->where('plan_id', $plan_id)
|
||||
->where('service_id', $oldStatusData['service_id'])
|
||||
->update();
|
||||
}
|
||||
} else {
|
||||
log_message('warning', "Old status data not found for edited plan_id: {$plan_id}");
|
||||
$planStatusModel->insert($data);
|
||||
}
|
||||
}
|
||||
|
||||
log_message('info', "palnStatusHandler() completed for plan_id: {$plan_id}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if (!function_exists('palnStatusHandler')) {
|
||||
// function palnStatusHandler($plan_id , $is_data_edited)
|
||||
// {
|
||||
|
||||
// $planModel = new PlanModel();
|
||||
// $planStatusModel = new PlanStatusModel();
|
||||
// $userModel = new UserModel();
|
||||
// $groupModel = new GroupModel();
|
||||
// $policyModel = new PolicyModel();
|
||||
// $policyDetailsModel = new PolicyDetailsModel();
|
||||
// $planController = new PlanController();
|
||||
|
||||
// $planData = $planController->find($plan_id, 'internal');
|
||||
|
||||
// $planServices = [];
|
||||
// if($planData)
|
||||
// {
|
||||
// if(count($planData['flight'])){ array_push($planServices,1); }
|
||||
// if(count($planData['train'])){ array_push($planServices,2); }
|
||||
// if(count($planData['bus'])){ array_push($planServices,3); }
|
||||
// if(count($planData['taxi'])){ array_push($planServices,4); }
|
||||
// if(count($planData['accomodation'])){ array_push($planServices,5); }
|
||||
// if(count($planData['forex'])){ array_push($planServices,6); }
|
||||
// if(count($planData['insurance'])){ array_push($planServices,7); }
|
||||
// if(count($planData['visa'])){ array_push($planServices,8); }
|
||||
// if(count($planData['miscellaneous'])){ array_push($planServices,9); }
|
||||
|
||||
// }
|
||||
// echo '<pre>';
|
||||
// print_r($planServices);
|
||||
|
||||
|
||||
// // Fetch plan data
|
||||
// if (!$planData) { return false; }
|
||||
// $userId = $planData['user_id'] ?? $planData['traveller_id'];
|
||||
|
||||
// // Fetch user data
|
||||
// $userData = $userModel->where('user_id', $userId)->first();
|
||||
// if (!$userData) { return false; }
|
||||
// $groupId = $userData['group_id'];
|
||||
// $a1Id = $userData['first_approver'];
|
||||
// $a2Id = $userData['second_approver'];
|
||||
// $a3Id = $userData['third_approver'];
|
||||
|
||||
|
||||
// // Fetch group data
|
||||
// $groupData = $groupModel->where('group_id', $groupId)->first();
|
||||
// if (!$groupData) { return false; }
|
||||
// $policyId = ($planData['trip_type'] == 1) ? $groupData['domestic_policy_id'] : $groupData['international_policy_id'];
|
||||
|
||||
// // Fetch policy service data
|
||||
// $policyData = $policyModel->where('policy_id', $policyId)->first();
|
||||
// if (!$policyData) {return false; }
|
||||
|
||||
// $priorityOrderOfService = json_decode($policyData['services_ids'],true);
|
||||
// if (is_array($priorityOrderOfService)) {
|
||||
// foreach ($priorityOrderOfService as $key => &$value) {
|
||||
// $value['priority'] = $key + 1;
|
||||
// }
|
||||
// unset($value); // always break reference after loop
|
||||
// }
|
||||
// echo '<pre>';
|
||||
// print_r($priorityOrderOfService);
|
||||
|
||||
// // Step 1: Filter only services you currently have
|
||||
// $filtered = array_filter($priorityOrderOfService, function($item) use ($planServices) {
|
||||
// return in_array($item['service_id'], $planServices);
|
||||
// });
|
||||
|
||||
// // Step 2: Sort by priority ascending
|
||||
// usort($filtered, function($a, $b) {
|
||||
// return $a['priority'] <=> $b['priority'];
|
||||
// });
|
||||
|
||||
// // Step 3: Get the top priority service
|
||||
// $topPriorityService = reset($filtered);
|
||||
// echo '<pre>';
|
||||
// print_r($topPriorityService); die;
|
||||
|
||||
// $policyServiceDetails = $policyDetailsModel->where('policy_id',$policyId)->where('service_id',$topPriorityService['service_id'])->where('is_active',1)->first();
|
||||
// if (!$policyServiceDetails) { return false; }
|
||||
// $policyA1Action = $policyServiceDetails['a1_action'];
|
||||
// $policyA2Action = $policyServiceDetails['a2_action'];
|
||||
// $policyA3Action = $policyServiceDetails['a3_action'];
|
||||
// $policyParallelAction = $policyServiceDetails['parallel_process_from'];
|
||||
|
||||
|
||||
|
||||
|
||||
// if($is_data_edited == false)//plan Creation
|
||||
// {
|
||||
// $data['plan_id'] = $plan_id;
|
||||
// $data['service_id'] = $topPriorityService['service_id'];
|
||||
// $data['a1_id'] = $a1Id;
|
||||
// $data['a1_action'] = $policyA1Action;
|
||||
// $data['a2_id'] = $a2Id;
|
||||
// $data['a2_action'] = $policyA2Action;
|
||||
// $data['a3_id'] = $a3Id;
|
||||
// $data['a3_action'] = $policyA3Action;
|
||||
// $data['parallel_process_from'] = $policyParallelAction;
|
||||
// // Insert Status
|
||||
// $planStatusModel->insert($data);
|
||||
|
||||
// }else{
|
||||
|
||||
// $oldStatusData = $planStatusModel->where('plan_id',$plan_id)->where('is_active', 1)->first();
|
||||
|
||||
// if($oldStatusData['service_id'] == $topPriorityService['service_id']){ // skip the process
|
||||
|
||||
// }else{ // insert new data
|
||||
|
||||
// //insert new service data
|
||||
// $data['plan_id'] = $plan_id;
|
||||
// $data['service_id'] = $topPriorityService['service_id'];
|
||||
// $data['a1_id'] = $a1Id;
|
||||
// $data['a1_action'] = $policyA1Action;
|
||||
// $data['a2_id'] = $a2Id;
|
||||
// $data['a2_action'] = $policyA2Action;
|
||||
// $data['a3_id'] = $a3Id;
|
||||
// $data['a3_action'] = $policyA3Action;
|
||||
// $data['parallel_process_from'] = $policyParallelAction;
|
||||
// // Insert Status
|
||||
// $planStatusModel->insert($data);
|
||||
|
||||
// //update old service data is_active = 0
|
||||
// $planStatusModel->set(['is_active'=>0])->where('plan_id',$plan_id)->where('service_id',$oldStatusData['service_id'])->update();
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
if (!function_exists('updatePlanStatus')) {
|
||||
function updatePlanStatus($plan_id)
|
||||
{
|
||||
|
||||
$planStatusModel = new PlanStatusModel();
|
||||
$planModel = new PlanModel();
|
||||
|
||||
$a1 = $planStatusModel->where('plan_id',$plan_id)->where('a1_action','Approval')->where('is_active',1)->findAll();
|
||||
$a1ApproveSum = 0;
|
||||
$a1ApproveCount = 0;
|
||||
if(count($a1))
|
||||
{
|
||||
$a1ApproveSum = array_sum(array_column($a1, 'is_a1_action_done'));
|
||||
$a1ApproveCount = count($a1);
|
||||
}
|
||||
|
||||
$a2 = $planStatusModel->where('plan_id',$plan_id)->where('a2_action','Approval')->where('is_active',1)->findAll();
|
||||
$a2ApproveSum = 0;
|
||||
$a2ApproveCount = 0;
|
||||
if(count($a2))
|
||||
{
|
||||
$a2ApproveSum = array_sum(array_column($a2, 'is_a2_action_done'));
|
||||
$a2ApproveCount = count($a2);
|
||||
}
|
||||
|
||||
|
||||
$a3 = $planStatusModel->where('plan_id',$plan_id)->where('a3_action','Approval')->where('is_active',1)->findAll();
|
||||
$a3ApproveSum = 0;
|
||||
$a3ApproveCount = 0;
|
||||
if(count($a3))
|
||||
{
|
||||
$a3ApproveSum = array_sum(array_column($a3, 'is_a3_action_done'));
|
||||
$a3ApproveCount = count($a3);
|
||||
}
|
||||
|
||||
$a4 = $planStatusModel->where('plan_id',$plan_id)->where('a4_action','Approval')->where('is_active',1)->findAll();
|
||||
$a4ApproveSum = 0;
|
||||
$a4ApproveCount = 0;
|
||||
if(count($a4))
|
||||
{
|
||||
$a4ApproveSum = array_sum(array_column($a4, 'is_a4_action_done'));
|
||||
$a4ApproveCount = count($a4);
|
||||
}
|
||||
|
||||
|
||||
$count = ( $a1ApproveCount + $a2ApproveCount + $a3ApproveCount + $a4ApproveCount);
|
||||
$sum = ( $a1ApproveSum + $a2ApproveSum + $a3ApproveSum + $a4ApproveSum);
|
||||
|
||||
|
||||
if($count == $sum)
|
||||
{
|
||||
// Approved
|
||||
$planModel->set(['status'=>3])->where('plan_id',$plan_id)->update();
|
||||
|
||||
}else if($count != $sum && $sum > 0)
|
||||
{
|
||||
//Partially Approved
|
||||
$planModel->set(['status'=>2])->where('plan_id',$plan_id)->update();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('getCurrentPlanStatus')) {
|
||||
function getCurrentPlanStatus($plan_id)
|
||||
{
|
||||
|
||||
$planStatusModel = new PlanStatusModel();
|
||||
$userModel = new UserModel();
|
||||
$currentStatus = [];
|
||||
|
||||
$a1 = $planStatusModel->where('plan_id',$plan_id)->where('a1_action','Approval')->where('is_active',1)->findAll();
|
||||
|
||||
if(count($a1))
|
||||
{
|
||||
|
||||
$user1 = $userModel->where('user_id', $a1[0]['a1_action_done_by'])->first();
|
||||
if(!$user1){
|
||||
$user1 = $userModel->where('user_id', $a1[0]['a1_id'])->first();
|
||||
}
|
||||
|
||||
$hasRejectReason = !empty(array_filter($a1, fn($row) => !empty($row['a1_reject_reason'])));
|
||||
if($user1)
|
||||
{
|
||||
|
||||
$userId = $user1['user_id'];
|
||||
|
||||
$a1ApproveSum = array_sum(array_column($a1, 'is_a1_action_done'));
|
||||
$a1ApproveCount = count($a1);
|
||||
|
||||
$a1Status['a1_id'] = $userId;
|
||||
if($a1ApproveSum == $a1ApproveCount)
|
||||
{
|
||||
$a1Status['a1_status'] = 'Plan approved by '.$user1['first_name'].' '.$user1['last_name'];
|
||||
}else if($hasRejectReason){
|
||||
$a1Status['a1_status'] = 'Plan rejected by '.$user1['first_name'].' '.$user1['last_name'].', Reason-'.$a1[0]['a1_reject_reason'];
|
||||
}else{
|
||||
$a1Status['a1_status'] = 'Plan approval pending from '.$user1['first_name'].' '.$user1['last_name'];
|
||||
}
|
||||
array_push($currentStatus,$a1Status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$a2 = $planStatusModel->where('plan_id',$plan_id)->where('a2_action','Approval')->where('is_active',1)->findAll();
|
||||
if(count($a2))
|
||||
{
|
||||
$user2 = $userModel->where('user_id', $a2[0]['a2_action_done_by'])->first();
|
||||
if(!$user2){
|
||||
$user2 = $userModel->where('user_id', $a2[0]['a2_id'])->first();
|
||||
}
|
||||
$hasRejectReason = !empty(array_filter($a2, fn($row) => !empty($row['a2_reject_reason'])));
|
||||
if($user2)
|
||||
{
|
||||
$userId = $user2['user_id'];
|
||||
|
||||
$a2ApproveSum = array_sum(array_column($a2, 'is_a2_action_done'));
|
||||
$a2ApproveCount = count($a2);
|
||||
|
||||
$a2Status['a2_id'] = $userId;
|
||||
if($a2ApproveSum == $a2ApproveCount)
|
||||
{
|
||||
$a2Status['a2_status'] = 'Plan approved by '.$user2['first_name'].' '.$user2['last_name'];
|
||||
}else if($hasRejectReason){
|
||||
$a2Status['a2_status'] = 'Plan rejected by '.$user2['first_name'].' '.$user2['last_name'].', Reason-'.$a2[0]['a2_reject_reason'];
|
||||
}else{
|
||||
$a2Status['a2_status'] = 'Plan approval pending from '.$user2['first_name'].' '.$user2['last_name'];
|
||||
}
|
||||
array_push($currentStatus,$a2Status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$a3 = $planStatusModel->where('plan_id',$plan_id)->where('a3_action','Approval')->where('is_active',1)->findAll();
|
||||
if(count($a3))
|
||||
{
|
||||
$user3 = $userModel->where('user_id', $a3[0]['a3_action_done_by'])->first();
|
||||
if(!$user3){
|
||||
$user3 = $userModel->where('user_id', $a3[0]['a3_id'])->first();
|
||||
}
|
||||
$hasRejectReason = !empty(array_filter($a3, fn($row) => !empty($row['a3_reject_reason'])));
|
||||
if($user3)
|
||||
{
|
||||
$userId = $user3['user_id'];
|
||||
|
||||
$a3ApproveSum = array_sum(array_column($a3, 'is_a3_action_done'));
|
||||
$a3ApproveCount = count($a3);
|
||||
|
||||
$a3Status['a3_id'] = $userId;
|
||||
if($a3ApproveSum == $a3ApproveCount)
|
||||
{
|
||||
$a3Status['a3_status'] = 'Plan approved by '.$user3['first_name'].' '.$user3['last_name'];
|
||||
}else if($hasRejectReason){
|
||||
$a3Status['a3_status'] = 'Plan rejected by '.$user3['first_name'].' '.$user3['last_name'].', Reason-'.$a3[0]['a3_reject_reason'];
|
||||
}else{
|
||||
$a3Status['a3_status'] = 'Plan approval pending from '.$user3['first_name'].' '.$user3['last_name'];
|
||||
}
|
||||
array_push($currentStatus,$a3Status);
|
||||
}
|
||||
}
|
||||
|
||||
$a4 = $planStatusModel->where('plan_id',$plan_id)->where('a4_action','Approval')->where('is_active',1)->findAll();
|
||||
if(count($a4))
|
||||
{
|
||||
$user4 = $userModel->where('user_id', $a4[0]['a4_action_done_by'])->first();
|
||||
if(!$user4){
|
||||
$user4 = $userModel->where('user_id', $a4[0]['a4_id'])->first();
|
||||
}
|
||||
$hasRejectReason = !empty(array_filter($a4, fn($row) => !empty($row['a4_reject_reason'])));
|
||||
if($user4)
|
||||
{
|
||||
$userId = $user4['user_id'];
|
||||
|
||||
$a4ApproveSum = array_sum(array_column($a4, 'is_a4_action_done'));
|
||||
$a4ApproveCount = count($a4);
|
||||
|
||||
$a4Status['a4_id'] = $userId;
|
||||
if($a4ApproveSum == $a4ApproveCount)
|
||||
{
|
||||
$a4Status['a4_status'] = 'Plan approved by '.$user4['first_name'].' '.$user4['last_name'];
|
||||
}else if($hasRejectReason){
|
||||
$a4Status['a4_status'] = 'Plan rejected by '.$user4['first_name'].' '.$user4['last_name'].', Reason-'.$a4[0]['a4_reject_reason'];
|
||||
}else{
|
||||
$a4Status['a4_status'] = 'Plan approval pending from '.$user4['first_name'].' '.$user4['last_name'];
|
||||
}
|
||||
array_push($currentStatus,$a4Status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $currentStatus;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('getPlanApproverAction')) {
|
||||
// initially written code without parallel , sequential
|
||||
// function getPlanApproverAction($plan_id , )
|
||||
// {
|
||||
|
||||
// $planStatusModel = new PlanStatusModel();
|
||||
// $userModel = new UserModel();
|
||||
// $result['approver_data'] = [];
|
||||
// $serviceIds = [];
|
||||
|
||||
// $a1 = $planStatusModel->where('plan_id',$plan_id)->whereIn('a1_action',['Approval','Notification'])->where('is_active',1)->findAll();
|
||||
// if(count($a1))
|
||||
// {
|
||||
// $serviceId = array_column($a1, 'service_id');
|
||||
// $serviceIds = array_merge($serviceIds, $serviceId);
|
||||
// $user = $userModel->where('user_id', $a1[0]['a1_id'])->first();
|
||||
// if($user)
|
||||
// {
|
||||
// $approvalCount = 0;
|
||||
// $notificationCount = 0;
|
||||
|
||||
// foreach ($a1 as $item) {
|
||||
// if ($item['a1_action'] === 'Approval') {
|
||||
// $approvalCount++;
|
||||
// } elseif ($item['a1_action'] === 'Notification') {
|
||||
// $notificationCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if($approvalCount != 0)
|
||||
// {
|
||||
// array_push($result['approver_data'] , ['approver'=>1, 'user_id'=>$a1[0]['a1_id'], 'email'=> $user['email'], 'action'=>'Approval', 'is_action_done'=>$a1[0]['is_a1_action_done']] );
|
||||
// }else if($notificationCount != 0){
|
||||
// array_push($result['approver_data'] , ['approver'=>1, 'user_id'=>$a1[0]['a1_id'], 'email'=> $user['email'], 'action'=>'Notification', 'is_action_done'=>$a1[0]['is_a1_action_done']] );
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// $a2 = $planStatusModel->where('plan_id',$plan_id)->whereIn('a2_action',['Approval','Notification'])->where('is_active',1)->findAll();
|
||||
// if(count($a2))
|
||||
// {
|
||||
// $serviceId = array_column($a2, 'service_id');
|
||||
// $serviceIds = array_merge($serviceIds, $serviceId);
|
||||
// $user = $userModel->where('user_id', $a1[0]['a2_id'])->first();
|
||||
// if($user)
|
||||
// {
|
||||
// $approvalCount = 0;
|
||||
// $notificationCount = 0;
|
||||
|
||||
// foreach ($a1 as $item) {
|
||||
// if ($item['a2_action'] === 'Approval') {
|
||||
// $approvalCount++;
|
||||
// } elseif ($item['a2_action'] === 'Notification') {
|
||||
// $notificationCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if($approvalCount != 0)
|
||||
// {
|
||||
// array_push($result['approver_data'] , ['approver'=>2, 'user_id'=>$a1[0]['a2_id'], 'email'=> $user['email'], 'action'=>'Approval', 'is_action_done'=>$a2[0]['is_a2_action_done']] );
|
||||
// }else if($notificationCount != 0){
|
||||
// array_push($result['approver_data'] , ['approver'=>2, 'user_id'=>$a1[0]['a2_id'], 'email'=> $user['email'], 'action'=>'Notification', 'is_action_done'=>$a2[0]['is_a2_action_done']] );
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// $a3 = $planStatusModel->where('plan_id',$plan_id)->whereIn('a3_action',['Approval','Notification'])->where('is_active',1)->findAll();
|
||||
// if(count($a3))
|
||||
// {
|
||||
// $serviceId = array_column($a3, 'service_id');
|
||||
// $serviceIds = array_merge($serviceIds, $serviceId);
|
||||
// $user = $userModel->where('user_id', $a1[0]['a3_id'])->first();
|
||||
// if($user)
|
||||
// {
|
||||
// $approvalCount = 0;
|
||||
// $notificationCount = 0;
|
||||
|
||||
// foreach ($a1 as $item) {
|
||||
// if ($item['a3_action'] === 'Approval') {
|
||||
// $approvalCount++;
|
||||
// } elseif ($item['a3_action'] === 'Notification') {
|
||||
// $notificationCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if($approvalCount != 0)
|
||||
// {
|
||||
// array_push($result['approver_data'] , ['approver'=>3, 'user_id'=>$a1[0]['a3_id'], 'email'=> $user['email'], 'action'=>'Approval', 'is_action_done'=>$a3[0]['is_a3_action_done']] );
|
||||
// }else if($notificationCount != 0){
|
||||
// array_push($result['approver_data'] , ['approver'=>3, 'user_id'=>$a1[0]['a3_id'], 'email'=> $user['email'], 'action'=>'Notification', 'is_action_done'=>$a3[0]['is_a3_action_done']] );
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// $statusData = $planStatusModel->where('plan_id',$plan_id)->where('is_active',1)->first();
|
||||
// $result['parallel_process_from'] = $statusData['parallel_process_from'];
|
||||
|
||||
// return $result;
|
||||
|
||||
// }
|
||||
|
||||
// 3 level of parallel , sequential
|
||||
// function getPlanApproverAction($plan_id)
|
||||
// {
|
||||
// $planStatusModel = new PlanStatusModel();
|
||||
// $userModel = new UserModel();
|
||||
// $result = ['approver_data' => []];
|
||||
// $serviceIds = [];
|
||||
|
||||
// // A1, A2, A3 - handle all same way
|
||||
// $approverAction = [
|
||||
// ['key' => 'a1', 'approver' => 1],
|
||||
// ['key' => 'a2', 'approver' => 2],
|
||||
// ['key' => 'a3', 'approver' => 3],
|
||||
// ];
|
||||
|
||||
// foreach ($approverAction as $stage) {
|
||||
// $field = $stage['key'];
|
||||
// $approverNumber = $stage['approver'];
|
||||
// $actionField = "{$field}_action";
|
||||
// $idField = "{$field}_id";
|
||||
// $doneField = "is_{$field}_action_done";
|
||||
|
||||
// $record = $planStatusModel->where('plan_id', $plan_id)
|
||||
// ->whereIn($actionField, ['Approval', 'Notification', 'None'])
|
||||
// ->where('is_active', 1)
|
||||
// ->first();
|
||||
|
||||
// if ($record) {
|
||||
// $user = $userModel->where('user_id', $record[$idField])->first();
|
||||
// if ($user) {
|
||||
// $result['approver_data'][] = [
|
||||
// 'approver' => $approverNumber,
|
||||
// 'user_id' => $record[$idField],
|
||||
// 'email' => $user['email'],
|
||||
// 'action' => $record[$actionField],
|
||||
// 'is_action_done' => $record[$doneField],
|
||||
// 'where_key' => $idField,
|
||||
// 'action_key' => $actionField,
|
||||
// 'action_done_key' => $doneField,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Get parallel process value
|
||||
// $statusData = $planStatusModel->where('plan_id', $plan_id)->where('is_active', 1)->first();
|
||||
// $result['parallel_process_from'] = $statusData['parallel_process_from'] ?? null;
|
||||
|
||||
|
||||
// $parallelFrom = (int) $result['parallel_process_from'];
|
||||
|
||||
// foreach ($result['approver_data'] as $key => &$approver) {
|
||||
// $approver['status'] = 'pending'; // default
|
||||
|
||||
// if ($parallelFrom === 1) {
|
||||
// // All parallel
|
||||
// $approver['status'] = 'active';
|
||||
// } elseif ($parallelFrom === 2) {
|
||||
// if ($approver['approver'] === 1) {
|
||||
// $approver['status'] = 'active';
|
||||
// } elseif (in_array($approver['approver'], [2, 3])) {
|
||||
// // Check if approver 1 is done
|
||||
// $a1Done = false;
|
||||
// foreach ($result['approver_data'] as $a) {
|
||||
// if ($a['approver'] === 1 && $a['is_action_done']) {
|
||||
// $a1Done = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// $approver['status'] = $a1Done ? 'active' : 'waiting';
|
||||
// }
|
||||
// } elseif ($parallelFrom === 3) {
|
||||
// // Sequential: 1 -> 2 -> 3
|
||||
// $a1Done = false;
|
||||
// $a2Done = false;
|
||||
|
||||
// foreach ($result['approver_data'] as $a) {
|
||||
// if ($a['approver'] === 1 && $a['is_action_done']) $a1Done = true;
|
||||
// if ($a['approver'] === 2 && $a['is_action_done']) $a2Done = true;
|
||||
// }
|
||||
|
||||
// if ($approver['approver'] === 1) {
|
||||
// $approver['status'] = 'active';
|
||||
// } elseif ($approver['approver'] === 2) {
|
||||
// $approver['status'] = $a1Done ? 'active' : 'waiting';
|
||||
// } elseif ($approver['approver'] === 3) {
|
||||
// $approver['status'] = ($a1Done && $a2Done) ? 'active' : 'waiting';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// unset($approver); // best practice when using & reference in foreach
|
||||
|
||||
|
||||
// return $result;
|
||||
// }
|
||||
|
||||
|
||||
// latest 4 level of parallel , sequential
|
||||
function getPlanApproverAction($plan_id)
|
||||
{
|
||||
$planStatusModel = new PlanStatusModel();
|
||||
$userModel = new UserModel();
|
||||
$result = ['approver_data' => []];
|
||||
|
||||
$approverAction = [
|
||||
['key' => 'a1', 'approver' => 1],
|
||||
['key' => 'a2', 'approver' => 2],
|
||||
['key' => 'a3', 'approver' => 3],
|
||||
['key' => 'a4', 'approver' => 4],
|
||||
];
|
||||
|
||||
foreach ($approverAction as $stage) {
|
||||
$field = $stage['key'];
|
||||
$approverNumber = $stage['approver'];
|
||||
$actionField = "{$field}_action";
|
||||
$idField = "{$field}_id";
|
||||
$doneField = "is_{$field}_action_done";
|
||||
$mailField = "is_{$field}_mail_send";
|
||||
|
||||
$record = $planStatusModel->where('plan_id', $plan_id)
|
||||
->whereIn($actionField, ['Approval', 'Notification', 'None'])
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
if ($record) {
|
||||
$user = $userModel->where('user_id', $record[$idField])->first();
|
||||
if ($user) {
|
||||
$result['approver_data'][] = [
|
||||
'approver' => $approverNumber,
|
||||
'user_id' => $record[$idField],
|
||||
'email' => $user['email'],
|
||||
'action' => $record[$actionField],
|
||||
'is_action_done' => $record[$doneField],
|
||||
'where_key' => $idField,
|
||||
'action_key' => $actionField,
|
||||
'action_done_key' => $doneField,
|
||||
'mail_send_key' => $mailField,
|
||||
'is_mail_send' => $record[$mailField],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$statusData = $planStatusModel->where('plan_id', $plan_id)->where('is_active', 1)->first();
|
||||
$result['parallel_process_from'] = $statusData['parallel_process_from'] ?? null;
|
||||
|
||||
$parallelFrom = (int) $result['parallel_process_from'];
|
||||
|
||||
foreach ($result['approver_data'] as &$approver) {
|
||||
$approver['status'] = 'pending'; // default
|
||||
|
||||
// Flags
|
||||
$a1Done = $a2Done = $a3Done = false;
|
||||
foreach ($result['approver_data'] as $a) {
|
||||
if ($a['approver'] === 1 && $a['is_action_done']) $a1Done = true;
|
||||
if ($a['approver'] === 2 && $a['is_action_done']) $a2Done = true;
|
||||
if ($a['approver'] === 3 && $a['is_action_done']) $a3Done = true;
|
||||
}
|
||||
|
||||
if ($parallelFrom === 1) {
|
||||
// All approvers active
|
||||
$approver['status'] = 'active';
|
||||
|
||||
} elseif ($parallelFrom === 2) {
|
||||
if ($approver['approver'] === 1) {
|
||||
$approver['status'] = 'active';
|
||||
} elseif (in_array($approver['approver'], [2, 3, 4])) {
|
||||
$approver['status'] = $a1Done ? 'active' : 'waiting';
|
||||
}
|
||||
|
||||
} elseif ($parallelFrom === 3) {
|
||||
if ($approver['approver'] === 1) {
|
||||
$approver['status'] = 'active';
|
||||
} elseif ($approver['approver'] === 2) {
|
||||
$approver['status'] = $a1Done ? 'active' : 'waiting';
|
||||
} elseif (in_array($approver['approver'], [3, 4])) {
|
||||
$approver['status'] = ($a1Done && $a2Done) ? 'active' : 'waiting';
|
||||
}
|
||||
|
||||
} elseif ($parallelFrom === 4) {
|
||||
if ($approver['approver'] === 1) {
|
||||
$approver['status'] = 'active';
|
||||
} elseif ($approver['approver'] === 2) {
|
||||
$approver['status'] = $a1Done ? 'active' : 'waiting';
|
||||
} elseif ($approver['approver'] === 3) {
|
||||
$approver['status'] = ($a1Done && $a2Done) ? 'active' : 'waiting';
|
||||
} elseif ($approver['approver'] === 4) {
|
||||
$approver['status'] = ($a1Done && $a2Done && $a3Done) ? 'active' : 'waiting';
|
||||
}
|
||||
} else {
|
||||
$approver['status'] = 'pending'; // fallback
|
||||
}
|
||||
}
|
||||
unset($approver); // clean reference
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('getApproverCurrentAction')) {
|
||||
function getApproverCurrentAction($plan_id,$user_id)
|
||||
{
|
||||
|
||||
$planStatusModel = new PlanStatusModel();
|
||||
$userModel = new UserModel();
|
||||
|
||||
$a1 = $planStatusModel->where('plan_id',$plan_id)->where('a1_id',$user_id)->where('a1_action','Approval')->where('is_active',1)->findAll();
|
||||
if(count($a1))
|
||||
{
|
||||
$hasRejectReason = !empty(array_filter($a1, fn($row) => !empty($row['a1_reject_reason'])));
|
||||
$a1ApproveSum = array_sum(array_column($a1, 'is_a1_action_done'));
|
||||
$a1ApproveCount = count($a1);
|
||||
|
||||
if($a1ApproveSum == $a1ApproveCount)
|
||||
{
|
||||
return 'Approved';
|
||||
}else if($hasRejectReason){
|
||||
return 'Rejected';
|
||||
}else{
|
||||
return 'Approval pending';
|
||||
}
|
||||
}
|
||||
|
||||
$a2 = $planStatusModel->where('plan_id',$plan_id)->where('a2_id',$user_id)->where('a2_action','Approval')->where('is_active',1)->findAll();
|
||||
if(count($a2))
|
||||
{
|
||||
$hasRejectReason = !empty(array_filter($a2, fn($row) => !empty($row['a2_reject_reason'])));
|
||||
$a2ApproveSum = array_sum(array_column($a2, 'is_a2_action_done'));
|
||||
$a2ApproveCount = count($a2);
|
||||
|
||||
if($a2ApproveSum == $a2ApproveCount)
|
||||
{
|
||||
return 'Approved';
|
||||
}else if($hasRejectReason){
|
||||
return 'Rejected';
|
||||
}else{
|
||||
return 'Approval pending';
|
||||
}
|
||||
}
|
||||
|
||||
$a3 = $planStatusModel->where('plan_id',$plan_id)->where('a3_id',$user_id)->where('a3_action','Approval')->where('is_active',1)->findAll();
|
||||
if(count($a3))
|
||||
{
|
||||
$hasRejectReason = !empty(array_filter($a3, fn($row) => !empty($row['a3_reject_reason'])));
|
||||
$a3ApproveSum = array_sum(array_column($a3, 'is_a3_action_done'));
|
||||
$a3ApproveCount = count($a3);
|
||||
|
||||
if($a3ApproveSum == $a3ApproveCount)
|
||||
{
|
||||
return 'Approved';
|
||||
}else if($hasRejectReason){
|
||||
return 'Rejected';
|
||||
}else{
|
||||
return 'Approval pending';
|
||||
}
|
||||
}
|
||||
|
||||
$a4 = $planStatusModel->where('plan_id',$plan_id)->where('a4_id',$user_id)->where('a4_action','Approval')->where('is_active',1)->findAll();
|
||||
if(count($a4))
|
||||
{
|
||||
$hasRejectReason = !empty(array_filter($a4, fn($row) => !empty($row['a4_reject_reason'])));
|
||||
$a4ApproveSum = array_sum(array_column($a4, 'is_a4_action_done'));
|
||||
$a4ApproveCount = count($a4);
|
||||
|
||||
if($a4ApproveSum == $a4ApproveCount)
|
||||
{
|
||||
return 'Approved';
|
||||
}else if($hasRejectReason){
|
||||
return 'Rejected';
|
||||
}else{
|
||||
return 'Approval pending';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
28
app/Helpers/url_helper.php
Executable file
28
app/Helpers/url_helper.php
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Config\Services;
|
||||
|
||||
if (!function_exists('generate_signed_url')) {
|
||||
function generate_signed_url($route, $params = [], $expiresIn = 259200)
|
||||
{
|
||||
$secretKey = 'your-secret-key'; // Change this to your secret key
|
||||
$expiresAt = time() + $expiresIn;
|
||||
$params['expires'] = $expiresAt;
|
||||
$signature = hash_hmac('sha256', $route . '?' . http_build_query($params), $secretKey);
|
||||
$params['signature'] = $signature;
|
||||
return base_url($route . '?' . http_build_query($params));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('urlButton')) {
|
||||
function urlButton($planId, $userId , $delegationUserId = null )
|
||||
{
|
||||
|
||||
$url = generate_signed_url('review', ['plan_id'=> md5($planId),'user_id'=> $userId,'delegation_user_id'=> $delegationUserId], 259200);
|
||||
|
||||
return '<a href="' . $url . '" target="_blank">Click here to review the trip</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
0
app/Language/.gitkeep
Executable file
0
app/Language/.gitkeep
Executable file
4
app/Language/en/Validation.php
Executable file
4
app/Language/en/Validation.php
Executable file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
// override core en language system validation or define your own en language validation message
|
||||
return [];
|
||||
0
app/Libraries/.gitkeep
Executable file
0
app/Libraries/.gitkeep
Executable file
0
app/Models/.gitkeep
Executable file
0
app/Models/.gitkeep
Executable file
28
app/Models/AgentModel.php
Normal file
28
app/Models/AgentModel.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class AgentModel extends Model
|
||||
{
|
||||
protected $table = 'partner_agent';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
'name',
|
||||
'email',
|
||||
'mobile',
|
||||
'address',
|
||||
'certificate_file_name',
|
||||
'incentive_file_name',
|
||||
'email_otp',
|
||||
'firebase_device_token',
|
||||
'is_active',
|
||||
'created_by',
|
||||
'created_on',
|
||||
'updated_by',
|
||||
'updated_on'
|
||||
];
|
||||
|
||||
protected $useTimestamps = false; // we manually handle created_on & updated_on
|
||||
}
|
||||
26
app/Models/StaffModel.php
Normal file
26
app/Models/StaffModel.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class StaffModel extends Model
|
||||
{
|
||||
protected $table = 'partner_staff';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
'name',
|
||||
'email',
|
||||
'mobile',
|
||||
'emp_id',
|
||||
'role_id',
|
||||
'email_otp',
|
||||
'is_active',
|
||||
'created_by',
|
||||
'created_on',
|
||||
'updated_by',
|
||||
'updated_on'
|
||||
];
|
||||
|
||||
protected $useTimestamps = false; // we manually manage created_on / updated_on
|
||||
}
|
||||
0
app/ThirdParty/.gitkeep
vendored
Executable file
0
app/ThirdParty/.gitkeep
vendored
Executable file
BIN
app/Views/Quotation-S00060.png
Normal file
BIN
app/Views/Quotation-S00060.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
112
app/Views/dashboard.php
Normal file
112
app/Views/dashboard.php
Normal file
@ -0,0 +1,112 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>CRM Dashboard</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
.sidebar {
|
||||
height: 100vh;
|
||||
background: #343a40;
|
||||
color: #fff;
|
||||
}
|
||||
.sidebar a {
|
||||
color: #adb5bd;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
padding: 10px;
|
||||
}
|
||||
.sidebar a:hover {
|
||||
background: #495057;
|
||||
color: #fff;
|
||||
}
|
||||
.card {
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="d-flex">
|
||||
<!-- Sidebar -->
|
||||
<div class="sidebar p-3">
|
||||
<h4 class="text-white">CRM</h4>
|
||||
<a href="#">Dashboard</a>
|
||||
<a href="#">Customers</a>
|
||||
<a href="#">Sales</a>
|
||||
<a href="#">Reports</a>
|
||||
<a href="#">Settings</a>
|
||||
</div>
|
||||
|
||||
<!-- Main Content -->
|
||||
<div class="flex-grow-1">
|
||||
<!-- Navbar -->
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light px-4">
|
||||
<a class="navbar-brand" href="#">Dashboard</a>
|
||||
<div class="ms-auto">
|
||||
<button class="btn btn-primary">Logout</button>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Content -->
|
||||
<div class="container-fluid p-4">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-3">
|
||||
<div class="card text-white bg-primary">
|
||||
<div class="card-body">
|
||||
<h5>Total Leads</h5>
|
||||
<h3>1,204</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card text-white bg-success">
|
||||
<div class="card-body">
|
||||
<h5>Deals Closed</h5>
|
||||
<h3>315</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card text-white bg-warning">
|
||||
<div class="card-body">
|
||||
<h5>Pending Tasks</h5>
|
||||
<h3>48</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card text-white bg-danger">
|
||||
<div class="card-body">
|
||||
<h5>Issues</h5>
|
||||
<h3>5</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Chart Placeholder -->
|
||||
<div class="row mt-4">
|
||||
<div class="col-12">
|
||||
<div class="card bg-light">
|
||||
<div class="card-body">
|
||||
<h5>Sales Overview</h5>
|
||||
<div style="height: 300px; background: #f1f3f5; display: flex; justify-content: center; align-items: center;">
|
||||
<span class="text-muted">[Chart Placeholder]</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
7
app/Views/errors/cli/error_404.php
Executable file
7
app/Views/errors/cli/error_404.php
Executable file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
use CodeIgniter\CLI\CLI;
|
||||
|
||||
CLI::error('ERROR: ' . $code);
|
||||
CLI::write($message);
|
||||
CLI::newLine();
|
||||
65
app/Views/errors/cli/error_exception.php
Executable file
65
app/Views/errors/cli/error_exception.php
Executable file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
use CodeIgniter\CLI\CLI;
|
||||
|
||||
// The main Exception
|
||||
CLI::write('[' . $exception::class . ']', 'light_gray', 'red');
|
||||
CLI::write($message);
|
||||
CLI::write('at ' . CLI::color(clean_path($exception->getFile()) . ':' . $exception->getLine(), 'green'));
|
||||
CLI::newLine();
|
||||
|
||||
$last = $exception;
|
||||
|
||||
while ($prevException = $last->getPrevious()) {
|
||||
$last = $prevException;
|
||||
|
||||
CLI::write(' Caused by:');
|
||||
CLI::write(' [' . $prevException::class . ']', 'red');
|
||||
CLI::write(' ' . $prevException->getMessage());
|
||||
CLI::write(' at ' . CLI::color(clean_path($prevException->getFile()) . ':' . $prevException->getLine(), 'green'));
|
||||
CLI::newLine();
|
||||
}
|
||||
|
||||
// The backtrace
|
||||
if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) {
|
||||
$backtraces = $last->getTrace();
|
||||
|
||||
if ($backtraces) {
|
||||
CLI::write('Backtrace:', 'green');
|
||||
}
|
||||
|
||||
foreach ($backtraces as $i => $error) {
|
||||
$padFile = ' '; // 4 spaces
|
||||
$padClass = ' '; // 7 spaces
|
||||
$c = str_pad($i + 1, 3, ' ', STR_PAD_LEFT);
|
||||
|
||||
if (isset($error['file'])) {
|
||||
$filepath = clean_path($error['file']) . ':' . $error['line'];
|
||||
|
||||
CLI::write($c . $padFile . CLI::color($filepath, 'yellow'));
|
||||
} else {
|
||||
CLI::write($c . $padFile . CLI::color('[internal function]', 'yellow'));
|
||||
}
|
||||
|
||||
$function = '';
|
||||
|
||||
if (isset($error['class'])) {
|
||||
$type = ($error['type'] === '->') ? '()' . $error['type'] : $error['type'];
|
||||
$function .= $padClass . $error['class'] . $type . $error['function'];
|
||||
} elseif (! isset($error['class']) && isset($error['function'])) {
|
||||
$function .= $padClass . $error['function'];
|
||||
}
|
||||
|
||||
$args = implode(', ', array_map(static fn ($value): string => match (true) {
|
||||
is_object($value) => 'Object(' . $value::class . ')',
|
||||
is_array($value) => $value !== [] ? '[...]' : '[]',
|
||||
$value === null => 'null', // return the lowercased version
|
||||
default => var_export($value, true),
|
||||
}, array_values($error['args'] ?? [])));
|
||||
|
||||
$function .= '(' . $args . ')';
|
||||
|
||||
CLI::write($function);
|
||||
CLI::newLine();
|
||||
}
|
||||
}
|
||||
5
app/Views/errors/cli/production.php
Executable file
5
app/Views/errors/cli/production.php
Executable file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
// On the CLI, we still want errors in productions
|
||||
// so just use the exception template.
|
||||
include __DIR__ . '/error_exception.php';
|
||||
194
app/Views/errors/html/debug.css
Executable file
194
app/Views/errors/html/debug.css
Executable file
@ -0,0 +1,194 @@
|
||||
:root {
|
||||
--main-bg-color: #fff;
|
||||
--main-text-color: #555;
|
||||
--dark-text-color: #222;
|
||||
--light-text-color: #c7c7c7;
|
||||
--brand-primary-color: #E06E3F;
|
||||
--light-bg-color: #ededee;
|
||||
--dark-bg-color: #404040;
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
background: var(--main-bg-color);
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
|
||||
color: var(--main-text-color);
|
||||
font-weight: 300;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
h1 {
|
||||
font-weight: lighter;
|
||||
font-size: 3rem;
|
||||
color: var(--dark-text-color);
|
||||
margin: 0;
|
||||
}
|
||||
h1.headline {
|
||||
margin-top: 20%;
|
||||
font-size: 5rem;
|
||||
}
|
||||
.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
p.lead {
|
||||
font-size: 1.6rem;
|
||||
}
|
||||
.container {
|
||||
max-width: 75rem;
|
||||
margin: 0 auto;
|
||||
padding: 1rem;
|
||||
}
|
||||
.header {
|
||||
background: var(--light-bg-color);
|
||||
color: var(--dark-text-color);
|
||||
margin-top: 2.17rem;
|
||||
}
|
||||
.header .container {
|
||||
padding: 1rem;
|
||||
}
|
||||
.header h1 {
|
||||
font-size: 2.5rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
.header p {
|
||||
font-size: 1.2rem;
|
||||
margin: 0;
|
||||
line-height: 2.5;
|
||||
}
|
||||
.header a {
|
||||
color: var(--brand-primary-color);
|
||||
margin-left: 2rem;
|
||||
display: none;
|
||||
text-decoration: none;
|
||||
}
|
||||
.header:hover a {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.environment {
|
||||
background: var(--brand-primary-color);
|
||||
color: var(--main-bg-color);
|
||||
text-align: center;
|
||||
padding: calc(4px + 0.2083vw);
|
||||
width: 100%;
|
||||
margin-top: -2.14rem;
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
.source {
|
||||
background: #343434;
|
||||
color: var(--light-text-color);
|
||||
padding: 0.5em 1em;
|
||||
border-radius: 5px;
|
||||
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
|
||||
font-size: 0.85rem;
|
||||
margin: 0;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
.source span.line {
|
||||
line-height: 1.4;
|
||||
}
|
||||
.source span.line .number {
|
||||
color: #666;
|
||||
}
|
||||
.source .line .highlight {
|
||||
display: block;
|
||||
background: var(--dark-text-color);
|
||||
color: var(--light-text-color);
|
||||
}
|
||||
.source span.highlight .number {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
list-style: none;
|
||||
list-style-position: inside;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin-bottom: -1px;
|
||||
}
|
||||
.tabs li {
|
||||
display: inline;
|
||||
}
|
||||
.tabs a:link,
|
||||
.tabs a:visited {
|
||||
padding: 0 1rem;
|
||||
line-height: 2.7;
|
||||
text-decoration: none;
|
||||
color: var(--dark-text-color);
|
||||
background: var(--light-bg-color);
|
||||
border: 1px solid rgba(0,0,0,0.15);
|
||||
border-bottom: 0;
|
||||
border-top-left-radius: 5px;
|
||||
border-top-right-radius: 5px;
|
||||
display: inline-block;
|
||||
}
|
||||
.tabs a:hover {
|
||||
background: var(--light-bg-color);
|
||||
border-color: rgba(0,0,0,0.15);
|
||||
}
|
||||
.tabs a.active {
|
||||
background: var(--main-bg-color);
|
||||
color: var(--main-text-color);
|
||||
}
|
||||
.tab-content {
|
||||
background: var(--main-bg-color);
|
||||
border: 1px solid rgba(0,0,0,0.15);
|
||||
}
|
||||
.content {
|
||||
padding: 1rem;
|
||||
}
|
||||
.hide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.alert {
|
||||
margin-top: 2rem;
|
||||
display: block;
|
||||
text-align: center;
|
||||
line-height: 3.0;
|
||||
background: #d9edf7;
|
||||
border: 1px solid #bcdff1;
|
||||
border-radius: 5px;
|
||||
color: #31708f;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
th {
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #e7e7e7;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
td {
|
||||
padding: 0.2rem 0.5rem 0.2rem 0;
|
||||
}
|
||||
tr:hover td {
|
||||
background: #f1f1f1;
|
||||
}
|
||||
td pre {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.trace a {
|
||||
color: inherit;
|
||||
}
|
||||
.trace table {
|
||||
width: auto;
|
||||
}
|
||||
.trace tr td:first-child {
|
||||
min-width: 5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
.trace td {
|
||||
background: var(--light-bg-color);
|
||||
padding: 0 1rem;
|
||||
}
|
||||
.trace td pre {
|
||||
margin: 0;
|
||||
}
|
||||
.args {
|
||||
display: none;
|
||||
}
|
||||
116
app/Views/errors/html/debug.js
Executable file
116
app/Views/errors/html/debug.js
Executable file
@ -0,0 +1,116 @@
|
||||
var tabLinks = new Array();
|
||||
var contentDivs = new Array();
|
||||
|
||||
function init()
|
||||
{
|
||||
// Grab the tab links and content divs from the page
|
||||
var tabListItems = document.getElementById('tabs').childNodes;
|
||||
console.log(tabListItems);
|
||||
for (var i = 0; i < tabListItems.length; i ++)
|
||||
{
|
||||
if (tabListItems[i].nodeName == "LI")
|
||||
{
|
||||
var tabLink = getFirstChildWithTagName(tabListItems[i], 'A');
|
||||
var id = getHash(tabLink.getAttribute('href'));
|
||||
tabLinks[id] = tabLink;
|
||||
contentDivs[id] = document.getElementById(id);
|
||||
}
|
||||
}
|
||||
|
||||
// Assign onclick events to the tab links, and
|
||||
// highlight the first tab
|
||||
var i = 0;
|
||||
|
||||
for (var id in tabLinks)
|
||||
{
|
||||
tabLinks[id].onclick = showTab;
|
||||
tabLinks[id].onfocus = function () {
|
||||
this.blur()
|
||||
};
|
||||
if (i == 0)
|
||||
{
|
||||
tabLinks[id].className = 'active';
|
||||
}
|
||||
i ++;
|
||||
}
|
||||
|
||||
// Hide all content divs except the first
|
||||
var i = 0;
|
||||
|
||||
for (var id in contentDivs)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
console.log(contentDivs[id]);
|
||||
contentDivs[id].className = 'content hide';
|
||||
}
|
||||
i ++;
|
||||
}
|
||||
}
|
||||
|
||||
function showTab()
|
||||
{
|
||||
var selectedId = getHash(this.getAttribute('href'));
|
||||
|
||||
// Highlight the selected tab, and dim all others.
|
||||
// Also show the selected content div, and hide all others.
|
||||
for (var id in contentDivs)
|
||||
{
|
||||
if (id == selectedId)
|
||||
{
|
||||
tabLinks[id].className = 'active';
|
||||
contentDivs[id].className = 'content';
|
||||
}
|
||||
else
|
||||
{
|
||||
tabLinks[id].className = '';
|
||||
contentDivs[id].className = 'content hide';
|
||||
}
|
||||
}
|
||||
|
||||
// Stop the browser following the link
|
||||
return false;
|
||||
}
|
||||
|
||||
function getFirstChildWithTagName(element, tagName)
|
||||
{
|
||||
for (var i = 0; i < element.childNodes.length; i ++)
|
||||
{
|
||||
if (element.childNodes[i].nodeName == tagName)
|
||||
{
|
||||
return element.childNodes[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getHash(url)
|
||||
{
|
||||
var hashPos = url.lastIndexOf('#');
|
||||
return url.substring(hashPos + 1);
|
||||
}
|
||||
|
||||
function toggle(elem)
|
||||
{
|
||||
elem = document.getElementById(elem);
|
||||
|
||||
if (elem.style && elem.style['display'])
|
||||
{
|
||||
// Only works with the "style" attr
|
||||
var disp = elem.style['display'];
|
||||
}
|
||||
else if (elem.currentStyle)
|
||||
{
|
||||
// For MSIE, naturally
|
||||
var disp = elem.currentStyle['display'];
|
||||
}
|
||||
else if (window.getComputedStyle)
|
||||
{
|
||||
// For most other browsers
|
||||
var disp = document.defaultView.getComputedStyle(elem, null).getPropertyValue('display');
|
||||
}
|
||||
|
||||
// Toggle the state of the "display" style
|
||||
elem.style.display = disp == 'block' ? 'none' : 'block';
|
||||
|
||||
return false;
|
||||
}
|
||||
84
app/Views/errors/html/error_400.php
Executable file
84
app/Views/errors/html/error_400.php
Executable file
@ -0,0 +1,84 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><?= lang('Errors.badRequest') ?></title>
|
||||
|
||||
<style>
|
||||
div.logo {
|
||||
height: 200px;
|
||||
width: 155px;
|
||||
display: inline-block;
|
||||
opacity: 0.08;
|
||||
position: absolute;
|
||||
top: 2rem;
|
||||
left: 50%;
|
||||
margin-left: -73px;
|
||||
}
|
||||
body {
|
||||
height: 100%;
|
||||
background: #fafafa;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
color: #777;
|
||||
font-weight: 300;
|
||||
}
|
||||
h1 {
|
||||
font-weight: lighter;
|
||||
letter-spacing: normal;
|
||||
font-size: 3rem;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
color: #222;
|
||||
}
|
||||
.wrap {
|
||||
max-width: 1024px;
|
||||
margin: 5rem auto;
|
||||
padding: 2rem;
|
||||
background: #fff;
|
||||
text-align: center;
|
||||
border: 1px solid #efefef;
|
||||
border-radius: 0.5rem;
|
||||
position: relative;
|
||||
}
|
||||
pre {
|
||||
white-space: normal;
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
code {
|
||||
background: #fafafa;
|
||||
border: 1px solid #efefef;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 5px;
|
||||
display: block;
|
||||
}
|
||||
p {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
.footer {
|
||||
margin-top: 2rem;
|
||||
border-top: 1px solid #efefef;
|
||||
padding: 1em 2em 0 2em;
|
||||
font-size: 85%;
|
||||
color: #999;
|
||||
}
|
||||
a:active,
|
||||
a:link,
|
||||
a:visited {
|
||||
color: #dd4814;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<h1>400</h1>
|
||||
|
||||
<p>
|
||||
<?php if (ENVIRONMENT !== 'production') : ?>
|
||||
<?= nl2br(esc($message)) ?>
|
||||
<?php else : ?>
|
||||
<?= lang('Errors.sorryBadRequest') ?>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
84
app/Views/errors/html/error_404.php
Executable file
84
app/Views/errors/html/error_404.php
Executable file
@ -0,0 +1,84 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><?= lang('Errors.pageNotFound') ?></title>
|
||||
|
||||
<style>
|
||||
div.logo {
|
||||
height: 200px;
|
||||
width: 155px;
|
||||
display: inline-block;
|
||||
opacity: 0.08;
|
||||
position: absolute;
|
||||
top: 2rem;
|
||||
left: 50%;
|
||||
margin-left: -73px;
|
||||
}
|
||||
body {
|
||||
height: 100%;
|
||||
background: #fafafa;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
color: #777;
|
||||
font-weight: 300;
|
||||
}
|
||||
h1 {
|
||||
font-weight: lighter;
|
||||
letter-spacing: normal;
|
||||
font-size: 3rem;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
color: #222;
|
||||
}
|
||||
.wrap {
|
||||
max-width: 1024px;
|
||||
margin: 5rem auto;
|
||||
padding: 2rem;
|
||||
background: #fff;
|
||||
text-align: center;
|
||||
border: 1px solid #efefef;
|
||||
border-radius: 0.5rem;
|
||||
position: relative;
|
||||
}
|
||||
pre {
|
||||
white-space: normal;
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
code {
|
||||
background: #fafafa;
|
||||
border: 1px solid #efefef;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 5px;
|
||||
display: block;
|
||||
}
|
||||
p {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
.footer {
|
||||
margin-top: 2rem;
|
||||
border-top: 1px solid #efefef;
|
||||
padding: 1em 2em 0 2em;
|
||||
font-size: 85%;
|
||||
color: #999;
|
||||
}
|
||||
a:active,
|
||||
a:link,
|
||||
a:visited {
|
||||
color: #dd4814;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<h1>404</h1>
|
||||
|
||||
<p>
|
||||
<?php if (ENVIRONMENT !== 'production') : ?>
|
||||
<?= nl2br(esc($message)) ?>
|
||||
<?php else : ?>
|
||||
<?= lang('Errors.sorryCannotFind') ?>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
429
app/Views/errors/html/error_exception.php
Executable file
429
app/Views/errors/html/error_exception.php
Executable file
@ -0,0 +1,429 @@
|
||||
<?php
|
||||
use CodeIgniter\HTTP\Header;
|
||||
use CodeIgniter\CodeIgniter;
|
||||
|
||||
$errorId = uniqid('error', true);
|
||||
?>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="robots" content="noindex">
|
||||
|
||||
<title><?= esc($title) ?></title>
|
||||
<style>
|
||||
<?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.css')) ?>
|
||||
</style>
|
||||
|
||||
<script>
|
||||
<?= file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.js') ?>
|
||||
</script>
|
||||
</head>
|
||||
<body onload="init()">
|
||||
|
||||
<!-- Header -->
|
||||
<div class="header">
|
||||
<div class="environment">
|
||||
Displayed at <?= esc(date('H:i:sa')) ?> —
|
||||
PHP: <?= esc(PHP_VERSION) ?> —
|
||||
CodeIgniter: <?= esc(CodeIgniter::CI_VERSION) ?> --
|
||||
Environment: <?= ENVIRONMENT ?>
|
||||
</div>
|
||||
<div class="container">
|
||||
<h1><?= esc($title), esc($exception->getCode() ? ' #' . $exception->getCode() : '') ?></h1>
|
||||
<p>
|
||||
<?= nl2br(esc($exception->getMessage())) ?>
|
||||
<a href="https://www.duckduckgo.com/?q=<?= urlencode($title . ' ' . preg_replace('#\'.*\'|".*"#Us', '', $exception->getMessage())) ?>"
|
||||
rel="noreferrer" target="_blank">search →</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Source -->
|
||||
<div class="container">
|
||||
<p><b><?= esc(clean_path($file)) ?></b> at line <b><?= esc($line) ?></b></p>
|
||||
|
||||
<?php if (is_file($file)) : ?>
|
||||
<div class="source">
|
||||
<?= static::highlightFile($file, $line, 15); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<?php
|
||||
$last = $exception;
|
||||
|
||||
while ($prevException = $last->getPrevious()) {
|
||||
$last = $prevException;
|
||||
?>
|
||||
|
||||
<pre>
|
||||
Caused by:
|
||||
<?= esc($prevException::class), esc($prevException->getCode() ? ' #' . $prevException->getCode() : '') ?>
|
||||
|
||||
<?= nl2br(esc($prevException->getMessage())) ?>
|
||||
<a href="https://www.duckduckgo.com/?q=<?= urlencode($prevException::class . ' ' . preg_replace('#\'.*\'|".*"#Us', '', $prevException->getMessage())) ?>"
|
||||
rel="noreferrer" target="_blank">search →</a>
|
||||
<?= esc(clean_path($prevException->getFile()) . ':' . $prevException->getLine()) ?>
|
||||
</pre>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) : ?>
|
||||
<div class="container">
|
||||
|
||||
<ul class="tabs" id="tabs">
|
||||
<li><a href="#backtrace">Backtrace</a></li>
|
||||
<li><a href="#server">Server</a></li>
|
||||
<li><a href="#request">Request</a></li>
|
||||
<li><a href="#response">Response</a></li>
|
||||
<li><a href="#files">Files</a></li>
|
||||
<li><a href="#memory">Memory</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
|
||||
<!-- Backtrace -->
|
||||
<div class="content" id="backtrace">
|
||||
|
||||
<ol class="trace">
|
||||
<?php foreach ($trace as $index => $row) : ?>
|
||||
|
||||
<li>
|
||||
<p>
|
||||
<!-- Trace info -->
|
||||
<?php if (isset($row['file']) && is_file($row['file'])) : ?>
|
||||
<?php
|
||||
if (isset($row['function']) && in_array($row['function'], ['include', 'include_once', 'require', 'require_once'], true)) {
|
||||
echo esc($row['function'] . ' ' . clean_path($row['file']));
|
||||
} else {
|
||||
echo esc(clean_path($row['file']) . ' : ' . $row['line']);
|
||||
}
|
||||
?>
|
||||
<?php else: ?>
|
||||
{PHP internal code}
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Class/Method -->
|
||||
<?php if (isset($row['class'])) : ?>
|
||||
— <?= esc($row['class'] . $row['type'] . $row['function']) ?>
|
||||
<?php if (! empty($row['args'])) : ?>
|
||||
<?php $argsId = $errorId . 'args' . $index ?>
|
||||
( <a href="#" onclick="return toggle('<?= esc($argsId, 'attr') ?>');">arguments</a> )
|
||||
<div class="args" id="<?= esc($argsId, 'attr') ?>">
|
||||
<table cellspacing="0">
|
||||
|
||||
<?php
|
||||
$params = null;
|
||||
// Reflection by name is not available for closure function
|
||||
if (! str_ends_with($row['function'], '}')) {
|
||||
$mirror = isset($row['class']) ? new ReflectionMethod($row['class'], $row['function']) : new ReflectionFunction($row['function']);
|
||||
$params = $mirror->getParameters();
|
||||
}
|
||||
|
||||
foreach ($row['args'] as $key => $value) : ?>
|
||||
<tr>
|
||||
<td><code><?= esc(isset($params[$key]) ? '$' . $params[$key]->name : "#{$key}") ?></code></td>
|
||||
<td><pre><?= esc(print_r($value, true)) ?></pre></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
()
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (! isset($row['class']) && isset($row['function'])) : ?>
|
||||
— <?= esc($row['function']) ?>()
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
|
||||
<!-- Source? -->
|
||||
<?php if (isset($row['file']) && is_file($row['file']) && isset($row['class'])) : ?>
|
||||
<div class="source">
|
||||
<?= static::highlightFile($row['file'], $row['line']) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Server -->
|
||||
<div class="content" id="server">
|
||||
<?php foreach (['_SERVER', '_SESSION'] as $var) : ?>
|
||||
<?php
|
||||
if (empty($GLOBALS[$var]) || ! is_array($GLOBALS[$var])) {
|
||||
continue;
|
||||
} ?>
|
||||
|
||||
<h3>$<?= esc($var) ?></h3>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($GLOBALS[$var] as $key => $value) : ?>
|
||||
<tr>
|
||||
<td><?= esc($key) ?></td>
|
||||
<td>
|
||||
<?php if (is_string($value)) : ?>
|
||||
<?= esc($value) ?>
|
||||
<?php else: ?>
|
||||
<pre><?= esc(print_r($value, true)) ?></pre>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php endforeach ?>
|
||||
|
||||
<!-- Constants -->
|
||||
<?php $constants = get_defined_constants(true); ?>
|
||||
<?php if (! empty($constants['user'])) : ?>
|
||||
<h3>Constants</h3>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($constants['user'] as $key => $value) : ?>
|
||||
<tr>
|
||||
<td><?= esc($key) ?></td>
|
||||
<td>
|
||||
<?php if (is_string($value)) : ?>
|
||||
<?= esc($value) ?>
|
||||
<?php else: ?>
|
||||
<pre><?= esc(print_r($value, true)) ?></pre>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Request -->
|
||||
<div class="content" id="request">
|
||||
<?php $request = service('request'); ?>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 10em">Path</td>
|
||||
<td><?= esc($request->getUri()) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>HTTP Method</td>
|
||||
<td><?= esc($request->getMethod()) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>IP Address</td>
|
||||
<td><?= esc($request->getIPAddress()) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 10em">Is AJAX Request?</td>
|
||||
<td><?= $request->isAJAX() ? 'yes' : 'no' ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Is CLI Request?</td>
|
||||
<td><?= $request->isCLI() ? 'yes' : 'no' ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Is Secure Request?</td>
|
||||
<td><?= $request->isSecure() ? 'yes' : 'no' ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>User Agent</td>
|
||||
<td><?= esc($request->getUserAgent()->getAgentString()) ?></td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<?php $empty = true; ?>
|
||||
<?php foreach (['_GET', '_POST', '_COOKIE'] as $var) : ?>
|
||||
<?php
|
||||
if (empty($GLOBALS[$var]) || ! is_array($GLOBALS[$var])) {
|
||||
continue;
|
||||
} ?>
|
||||
|
||||
<?php $empty = false; ?>
|
||||
|
||||
<h3>$<?= esc($var) ?></h3>
|
||||
|
||||
<table style="width: 100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($GLOBALS[$var] as $key => $value) : ?>
|
||||
<tr>
|
||||
<td><?= esc($key) ?></td>
|
||||
<td>
|
||||
<?php if (is_string($value)) : ?>
|
||||
<?= esc($value) ?>
|
||||
<?php else: ?>
|
||||
<pre><?= esc(print_r($value, true)) ?></pre>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php endforeach ?>
|
||||
|
||||
<?php if ($empty) : ?>
|
||||
|
||||
<div class="alert">
|
||||
No $_GET, $_POST, or $_COOKIE Information to show.
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $headers = $request->headers(); ?>
|
||||
<?php if (! empty($headers)) : ?>
|
||||
|
||||
<h3>Headers</h3>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Header</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($headers as $name => $value) : ?>
|
||||
<tr>
|
||||
<td><?= esc($name, 'html') ?></td>
|
||||
<td>
|
||||
<?php
|
||||
if ($value instanceof Header) {
|
||||
echo esc($value->getValueLine(), 'html');
|
||||
} else {
|
||||
foreach ($value as $i => $header) {
|
||||
echo ' ('. $i+1 . ') ' . esc($header->getValueLine(), 'html');
|
||||
}
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Response -->
|
||||
<?php
|
||||
$response = service('response');
|
||||
$response->setStatusCode(http_response_code());
|
||||
?>
|
||||
<div class="content" id="response">
|
||||
<table>
|
||||
<tr>
|
||||
<td style="width: 15em">Response Status</td>
|
||||
<td><?= esc($response->getStatusCode() . ' - ' . $response->getReasonPhrase()) ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php $headers = $response->headers(); ?>
|
||||
<?php if (! empty($headers)) : ?>
|
||||
<h3>Headers</h3>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Header</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($headers as $name => $value) : ?>
|
||||
<tr>
|
||||
<td><?= esc($name, 'html') ?></td>
|
||||
<td>
|
||||
<?php
|
||||
if ($value instanceof Header) {
|
||||
echo esc($response->getHeaderLine($name), 'html');
|
||||
} else {
|
||||
foreach ($value as $i => $header) {
|
||||
echo ' ('. $i+1 . ') ' . esc($header->getValueLine(), 'html');
|
||||
}
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Files -->
|
||||
<div class="content" id="files">
|
||||
<?php $files = get_included_files(); ?>
|
||||
|
||||
<ol>
|
||||
<?php foreach ($files as $file) :?>
|
||||
<li><?= esc(clean_path($file)) ?></li>
|
||||
<?php endforeach ?>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<!-- Memory -->
|
||||
<div class="content" id="memory">
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Memory Usage</td>
|
||||
<td><?= esc(static::describeMemory(memory_get_usage(true))) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 12em">Peak Memory Usage:</td>
|
||||
<td><?= esc(static::describeMemory(memory_get_peak_usage(true))) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Memory Limit:</td>
|
||||
<td><?= esc(ini_get('memory_limit')) ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
</div> <!-- /tab-content -->
|
||||
|
||||
</div> <!-- /container -->
|
||||
<?php endif; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
25
app/Views/errors/html/production.php
Executable file
25
app/Views/errors/html/production.php
Executable file
@ -0,0 +1,25 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="robots" content="noindex">
|
||||
|
||||
<title><?= lang('Errors.whoops') ?></title>
|
||||
|
||||
<style>
|
||||
<?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.css')) ?>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container text-center">
|
||||
|
||||
<h1 class="headline"><?= lang('Errors.whoops') ?></h1>
|
||||
|
||||
<p class="lead"><?= lang('Errors.weHitASnag') ?></p>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
35
app/Views/expired_link.php
Executable file
35
app/Views/expired_link.php
Executable file
@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Link Expired</title>
|
||||
<style>
|
||||
body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
.container {
|
||||
text-align: center;
|
||||
}
|
||||
img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
.text{
|
||||
font-size: large;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
|
||||
<p class="text">Link expired</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
157
app/Views/forex.php
Normal file
157
app/Views/forex.php
Normal file
@ -0,0 +1,157 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 14px;
|
||||
|
||||
}
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed; /* Equal column width */
|
||||
}
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.table th {
|
||||
background-color: #f2f2f2;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
<!-- Define header -->
|
||||
<htmlpageheader name="myHeader">
|
||||
<div class="header" style="height: 100px;"> <!-- Fixed height for header -->
|
||||
<table class="header-table" style="width: 100%;">
|
||||
<tr class="header-section">
|
||||
<td class="header-logo" style="width: 120px;">
|
||||
<img src="<?= $org_data['logo'] ?>" alt="Logo" style="max-height: 80px; max-width: 100%; height: auto;" />
|
||||
</td>
|
||||
<td class="header-section-text" style="text-align: right; vertical-align: middle;">
|
||||
Trip ID #<?= $forexData['plan_id'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</htmlpageheader>
|
||||
|
||||
|
||||
<!-- Define footer -->
|
||||
<htmlpagefooter name="myFooter">
|
||||
<div class="footer">
|
||||
<table class="foooter-section">
|
||||
<tr class="footer-text">
|
||||
<td class="text-center">@<?= $org_data['name'] ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</htmlpagefooter>
|
||||
|
||||
<!-- Apply header/footer to all pages -->
|
||||
<sethtmlpageheader name="myHeader" value="on" show-this-page="1" />
|
||||
<sethtmlpagefooter name="myFooter" value="on" />
|
||||
|
||||
|
||||
<div style="text-align: center;"> Application cum Declaration Form for release of Foreign Exchange under Business Travel</div>
|
||||
<div style="text-align: center;"><br></div>
|
||||
<div style="text-align: right;"><span style="font-size: 0.875rem;">Date: <?= date('d, M Y', strtotime($forexData['date'])) ?></span></div>
|
||||
<p></p>
|
||||
<p>To,</p>
|
||||
<p>The Manager</p>
|
||||
<p>Ebixcash <span style="font-size: 0.875rem;">World Money Ltd
|
||||
</span></p>
|
||||
<p><span style="font-size: 0.875rem;"> We request you to release foreign exchange to our personnel for his/her business travel abroad as
|
||||
mentioned below</span></p>
|
||||
<p><span style="font-size: 0.875rem;"><br></span></p>
|
||||
<ol style="line-height: 25px;">
|
||||
<li><span style="font-size: 0.875rem;">Name of Person : <?= $forexData['first_name'] ?> <?= $forexData['last_name'] ?></span></li>
|
||||
<li><span style="font-size: 0.875rem;">Designation :</span></li>
|
||||
<li><span style="font-size: 0.875rem;">Mobile : <?= $forexData['mobile_no'] ?> </span></li>
|
||||
<li><span style="font-size: 0.875rem;">Email Id : <?= $forexData['email'] ?></span></li>
|
||||
<li><span style="font-size: 0.875rem;">Residential Address :</span> <?= $forexData['address'] ?></li>
|
||||
<li><span style="font-size: 0.875rem;">Residential Status :</span></li>
|
||||
<li><span style="font-size: 0.875rem;">PAN No :</span></li>
|
||||
<li><span style="font-size: 0.875rem;">Passport Details :</span>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Passport No </td>
|
||||
<td>Place of Issue </td>
|
||||
<td>Date of Issue</td>
|
||||
<td>Expiry Date</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <?= $forexData['passport_number'] ?></td>
|
||||
<td> <?= $forexData['place_of_issue'] ?></td>
|
||||
<td> <?= $forexData['date_of_issue'] ?></td>
|
||||
<td> <?= $forexData['date_of_expiry'] ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</li>
|
||||
<li><span style="font-size: 0.875rem;">Foreign Exchange Requirement: :</span>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Country/Countries to be Visited</td>
|
||||
<td>Purpose of Visit</td>
|
||||
<td>Duration of stayaboard (No. of days)</td>
|
||||
<td>Total Forex ExchangeRequired</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <?= $forexData['country_name'] ?></td>
|
||||
<td> <?= $forexData['purpose_of_visit'] ?></td>
|
||||
<td> <?= $forexData['duration'] ?></td>
|
||||
<td> <?= $forexData['deposit_on_card'] + $forexData['deposit_on_cash'] ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</li><br>
|
||||
<li><span style="font-size: 0.875rem;">Air ticket no:_______________________ Airlines:____________________<span style="font-size: 0.875rem;">___</span>_________<span style="font-size: 0.875rem;">_</span><span style="font-size: 0.875rem;">__ Date of Travel:_________________</span></span></li>
|
||||
</ol>
|
||||
<br>
|
||||
<p style="margin-bottom: 1rem;"><span style="font-size: 11px;">Declaration:</span></p>
|
||||
<p style="margin-bottom: 1rem;"><span style="font-size: 11px;"> It is certified that the expenses for the above trip are being borne by firm/company and we undertake that the same shall be utilized for the
|
||||
purpose stated above. It is hereby declared that the transaction, the details of which are mentioned above does not involve, and is not designedfor the purpose of or in contravention or evasion of any provision of the Foreign Exchange Management Act, 1999 or of any Rule, Regulation,
|
||||
Notification, Direction or Order issued / made thereunder. We also hereby agree and undertake to submit information/documents as will
|
||||
reasonably satisfy you about this transaction in terms of the above declaration. I/We further confirm that the foreign exchange released for the
|
||||
above mentioned purpose shall be used within 180 days of purchase. In case it is not possible to use the said foreign exchange within the period
|
||||
of 180 days, same shall be surrendered to an Authorized Person. We further declare that the undersigned has the authority to give this
|
||||
declaration on behalf of the firm/company. We also understand that if the complete details as required above in A to H and the required KYC
|
||||
documents are not furnished, Ebixcash World Money Ltd shall refuse in writing to undertake the transaction and shall, if it has reason to believe,
|
||||
may report the matter to Reserve Bank of India(RBI) / Financial Intelligence Unit(FIU). This application for release of foreign exchange as above is
|
||||
being made in accordance with the provision of RBI Master Circular on Miscellaneous Remittances from India – Facilities for Residents. We
|
||||
undertake that the foreign exchange released vide this application shall be utilized for the employees overseas travel only.</span></p>
|
||||
<p style="margin-bottom: 1rem;"><span style="font-size: 14px;"></span><span style="font-size: 0.875rem;">We enclose our Cheque / DD No._________________ dated _____________for Rs._____________</span></p>
|
||||
<p style="margin-bottom: 1rem;">Thanking you,
|
||||
</p>
|
||||
<p style="margin-bottom: 1rem;">Yours sincerely,
|
||||
</p>
|
||||
<p style="margin-bottom: 1rem;">For M/s Aujas Cybersecurity Limited</p>
|
||||
<p style="margin-bottom: 1rem;">Signature
|
||||
</p>
|
||||
<p style="margin-bottom: 1rem;">Name &Designation<span style="font-size: 0.875rem;"><br></span><span style="font-size: 11px;"><br></span><span style="font-size: 0.875rem;"></span></p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
88
app/Views/home.php
Normal file
88
app/Views/home.php
Normal file
@ -0,0 +1,88 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Trip Approval</title>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #eaeaea;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
}
|
||||
header {
|
||||
width: 100%;
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
padding: 10px 20px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
header h1 {
|
||||
margin: 7px;
|
||||
font-size: 24px;
|
||||
}
|
||||
.logout-button {
|
||||
padding: 8px 15px;
|
||||
font-size: 14px;
|
||||
color: #fff;
|
||||
background-color: #dc3545;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
text-transform: uppercase;
|
||||
margin: 7px;
|
||||
}
|
||||
.logout-button:hover {
|
||||
background-color: #b02a37;
|
||||
}
|
||||
.welcome-message {
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 24px;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Trip Approval</h1>
|
||||
<a class="logout-button" >Logout</a>
|
||||
</header>
|
||||
<div class="welcome-message">
|
||||
Welcome , <?= $userName ?> !
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
$(document).on('click', '.logout-button', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
$.ajax({
|
||||
url: '<?= base_url('logout'); ?>',
|
||||
type: 'POST',
|
||||
success: function (response) {
|
||||
// if (response.status === 'success') {
|
||||
|
||||
// window.location.href = '<?= base_url('login'); ?>'; // Redirect to login page
|
||||
// }
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error('Logout failed:', error);
|
||||
alert('Failed to logout. Please try again.');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
37
app/Views/landingpage.php
Normal file
37
app/Views/landingpage.php
Normal file
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Login Page</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background-color: #f0f0f0; /* You can change this color as needed */
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
.login-button {
|
||||
padding: 10px 20px;
|
||||
font-size: 18px;
|
||||
color: #fff;
|
||||
background-color: #007bff; /* Button color */
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
text-transform: uppercase;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.login-button:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a class="login-button" href="<?= base_url('login'); ?>">Login</a>
|
||||
</body>
|
||||
</html>
|
||||
BIN
app/Views/login-logo.png
Normal file
BIN
app/Views/login-logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
47
app/Views/mslogin.php
Normal file
47
app/Views/mslogin.php
Normal file
@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>Login</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
.login-box {
|
||||
background: white;
|
||||
padding: 40px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 20px rgba(0,0,0,0.2);
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
max-width: 350px;
|
||||
}
|
||||
.login-btn {
|
||||
background-color: #0078d4;
|
||||
border: none;
|
||||
color: white;
|
||||
padding: 12px 20px;
|
||||
border-radius: 6px;
|
||||
font-size: 16px;
|
||||
transition: background 0.3s;
|
||||
}
|
||||
.login-btn:hover {
|
||||
background-color: #005ea2;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-box">
|
||||
<h3 class="mb-4">Welcome to CRM</h3>
|
||||
<a href="<?= base_url('auth/mslogin') ?>" class="btn login-btn w-100 mb-2">Login with Microsoft</a>
|
||||
<a href="<?= base_url('auth/googlelogin') ?>" class="btn login-btn w-100">Login with Google</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
722
app/Views/pdf.php
Normal file
722
app/Views/pdf.php
Normal file
@ -0,0 +1,722 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<style>
|
||||
body{
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 14px;
|
||||
|
||||
}
|
||||
.header-table, .invoice-content-table, .invoice-table table, .invoice-table-design, .foooter-section{
|
||||
width: 100%;
|
||||
}
|
||||
.header-table, .invoice-content-table, .invoice-table, .invoice-table-design, .foooter-section{
|
||||
margin-top: 30px;
|
||||
}
|
||||
.header-table td, .invoice-content-table td{
|
||||
width:50%;
|
||||
}
|
||||
.header-table td.company-details, .invoice-table td.quotation-heading{
|
||||
text-align: right;
|
||||
font-size: xx-large;
|
||||
}
|
||||
.header-section-text{
|
||||
text-align: right;
|
||||
color:#0d79af;
|
||||
font-size: 25px;
|
||||
}
|
||||
.text-left{
|
||||
text-align: left;
|
||||
}
|
||||
.text-right{
|
||||
text-align: right;
|
||||
}
|
||||
.text-center{
|
||||
text-align: center;
|
||||
}
|
||||
.invoice-table{
|
||||
border:1px solid #a4aeb1;
|
||||
border-radius: 10px;
|
||||
background-color: #f7f8f9;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
.invoice-table-design{
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.invoice-table-design th{
|
||||
background: #0d79af;
|
||||
border: 1px solid #d8dadd;
|
||||
color: #ffffff;
|
||||
padding:8px;
|
||||
text-transform: uppercase;
|
||||
font-size: 14px;
|
||||
}
|
||||
.invoice-table-design td{
|
||||
border: 1px solid #dddddd;
|
||||
padding:10px;
|
||||
}
|
||||
|
||||
.invoice-table .qsub-heading{
|
||||
color: #6b7577;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.foooter-section{
|
||||
border-top: 1px solid #000000;
|
||||
padding-top: 10px;
|
||||
}
|
||||
.border-bottom-dotted td{
|
||||
border-bottom: 1px dotted #a4aeb1;
|
||||
}
|
||||
.quotation-heading .quo-heading1{
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
vertical-align: top;
|
||||
}
|
||||
.invoice-table.services{
|
||||
border-color:#0d79afeb;
|
||||
}
|
||||
.invoice-table.services th{
|
||||
font-weight: 500;
|
||||
padding-top:10px;
|
||||
padding-bottom:10px;
|
||||
font-size: 17px;
|
||||
border-bottom: 1px solid #82868af2;
|
||||
}
|
||||
.quotation-company span{
|
||||
font-size: 15px;
|
||||
}
|
||||
.quotation-company div{
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.quotation-code {
|
||||
text-align: right;
|
||||
}
|
||||
.icon{
|
||||
width:16px;
|
||||
height:16px;
|
||||
}
|
||||
.quotation-code .invoice-table{
|
||||
padding: 0;
|
||||
background-color: transparent;
|
||||
}
|
||||
.quotation-code table{
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.quotation-code td{
|
||||
|
||||
padding: 8px;
|
||||
|
||||
}
|
||||
|
||||
.user-name{
|
||||
font-size: 24px!important;
|
||||
}
|
||||
.user-email{
|
||||
font-size: 14px!important;
|
||||
}
|
||||
|
||||
/* .quotation-code td:first-child, .quotation-code td:last-child{
|
||||
border-bottom: 1px solid #d8d9dbf2;
|
||||
}
|
||||
.quotation-code td:last-child{
|
||||
border-left: 1px solid #d8d9dbf2;
|
||||
color: #615d5d;
|
||||
|
||||
} */
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php if($data['view'] == false){ ?>
|
||||
|
||||
<!-- Define header -->
|
||||
<htmlpageheader name="myHeader">
|
||||
<div class="header" style="height: 100px;"> <!-- Fixed height for header -->
|
||||
<table class="header-table" style="width: 100%;">
|
||||
<tr class="header-section">
|
||||
<td class="header-logo" style="width: 120px;">
|
||||
<?php if(isset($data['org_data']['logo'])) : if (!empty($data['org_data']['logo'])):
|
||||
$orgLogoFilename = basename($data['org_data']['logo']);
|
||||
$orgLogo = base_url("assets/images/logo/" . $orgLogoFilename);
|
||||
?>
|
||||
<img src="<?= $orgLogo ?>" alt="Logo" style="max-height: 80px; max-width: 100%; height: auto;" />
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="header-section-text" style="text-align: right; vertical-align: middle;">
|
||||
Trip ID #<?= $data['plan_id'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</htmlpageheader>
|
||||
|
||||
|
||||
<!-- Define footer -->
|
||||
<htmlpagefooter name="myFooter">
|
||||
<div class="footer">
|
||||
<table class="foooter-section">
|
||||
<tr class="footer-text">
|
||||
<td class="text-center"><?php if (isset($data['org_data']['name'])): ?> @<?= $data['org_data']['name'] ?> <?php endif; ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</htmlpagefooter>
|
||||
|
||||
<!-- Apply header/footer to all pages -->
|
||||
<sethtmlpageheader name="myHeader" value="on" show-this-page="1" />
|
||||
<sethtmlpagefooter name="myFooter" value="on" />
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<!--- user details --->
|
||||
|
||||
|
||||
|
||||
|
||||
<table class="invoice-content-table" >
|
||||
<tr class="invoice-section">
|
||||
<td class="quotation-company">
|
||||
<?php if (isset($data['logo']) && $data['view'] !== false):
|
||||
$logoFilename = basename($data['logo']);
|
||||
$logo = base_url("assets/images/logo/" . $logoFilename);
|
||||
?>
|
||||
<div class="org-logo" style="width: 120px;">
|
||||
<img src="<?= $logo ?>" alt="Logo" style="max-height: 80px; max-width: 100%; height: auto;" />
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div>
|
||||
<span class="user-name"><?= esc($data['user_data']['first_name']) ?> <?= esc($data['user_data']['last_name']) ?> <?php if($data['user_data']['employee_code']){ echo '- '.$data['user_data']['employee_code']; } ?> </span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="user-email" ><?= esc($data['user_data']['email']) ?></span>,
|
||||
<span class="user-email" ><?= esc($data['user_data']['mobile_no']) ?></span>.
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<?php if($data['trip_type_value'] == 'International'){ ?>
|
||||
<td class="quotation-code" style="border:1px solid #ddd; border-radius:10px;">
|
||||
<table style="width:100%;">
|
||||
<tr>
|
||||
<td style="text-align:left; border-bottom:1px solid #ddd; border-right:1px solid #ddd;">Passport No</td>
|
||||
<td style="text-align:left; border-bottom:1px solid #ddd; color:#6b6b6b; "><?= ($data['user_data']['passport_number']) ?? '' ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left; border-bottom:1px solid #ddd; border-right:1px solid #ddd;">Expiry Date</td>
|
||||
<td style="text-align:left; border-bottom:1px solid #ddd; color:#6b6b6b;"><?= $data['user_data']['date_of_expiry'] ? date('d, M y', strtotime($data['user_data']['date_of_expiry'])) : '' ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left; border-bottom:1px solid #ddd; border-right:1px solid #ddd;">Place Of Issue</td>
|
||||
<td style="text-align:left; border-bottom:1px solid #ddd; color:#6b6b6b;"><?= ($data['user_data']['place_of_issue']) ?? '' ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left; border-right:1px solid #ddd;">Forex Card Number</td>
|
||||
<td style="text-align:left; color:#6b6b6b;"><?= ($data['user_data']['forex_pre_paid_card_number']) ?? '' ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php if($data['trip_type_value'] == 'International'){ ?>
|
||||
<table class="invoice-content-table" >
|
||||
<tr class="invoice-section">
|
||||
|
||||
<td class="quotation-code" style="border:1px solid #ddd; border-radius:10px;">
|
||||
|
||||
<table style="width:100%;">
|
||||
<tr>
|
||||
<td style="text-align:left; border-bottom:1px solid #ddd;">Visa Details</td>
|
||||
</tr>
|
||||
<?php if (!empty($data['visa_data'])): ?>
|
||||
<?php foreach ($data['visa_data'] as $visa): ?>
|
||||
<tr>
|
||||
<td style="text-align:left; color:#6b6b6b;">
|
||||
<?= esc($visa['country_name']) ?> - <?= esc($visa['visa_type_value']) ?>
|
||||
(<?= date('d M Y', strtotime($visa['valid_from'])) ?> to <?= date('d M Y', strtotime($visa['valid_upto'])) ?>)
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td style="text-align:left; color:#6b6b6b;">No visa data available.</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
<?php if($data['exceptional_plan_reason'] != null && $data['exceptional_plan_reason'] != ''){ ?>
|
||||
|
||||
<table class="invoice-content-table" style="width:100%; border-collapse:collapse; font-family:Arial, sans-serif;">
|
||||
<tr>
|
||||
<td style="
|
||||
text-align:left;
|
||||
background-color:#ffdbdb;
|
||||
color:#960000;
|
||||
padding:7px 15px;
|
||||
font-weight:bold;
|
||||
border-top-left-radius:5px;
|
||||
border-top-right-radius:5px;
|
||||
border-bottom:1px solid #c65e56;
|
||||
">Reason for travel policy exception </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="
|
||||
text-align:left;
|
||||
background-color:#fff5f5;
|
||||
color:#960000ab;
|
||||
padding:10px 15px;
|
||||
border-bottom-left-radius:5px;
|
||||
border-bottom-right-radius:5px;
|
||||
">
|
||||
<?= esc($data['exceptional_plan_reason']) ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<!--- currect status --->
|
||||
<div class="invoice-table">
|
||||
<table>
|
||||
<tr class="quotation-heading">
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Trip Type</div>
|
||||
<div class="qsub-desc"><?= esc($data['trip_type_value']) ?><br/></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Requested Date </div>
|
||||
<div class="qsub-desc"><?= date('d, M y', strtotime($data['created_on'])) ?></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Trip Start Date </div>
|
||||
<div class="qsub-desc"><?= ($data['trip_start_date'] == '9999-12-31') ? '-' : date('d, M y', strtotime($data['trip_start_date'])) ?></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Current Status</div>
|
||||
<div class="qsub-desc"><?= esc($data['status_value']) ?></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<table class="invoice-table-design">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-left">Trip title</th>
|
||||
<th class="text-left">Cost center</th>
|
||||
<th class="text-left">Purpose of travel</th>
|
||||
<?php if($data['functional_department'] == 5){ ?>
|
||||
<th class="text-left">SO Number</th>
|
||||
<?php }else{ ?>
|
||||
<th class="text-left">Functional department</th>
|
||||
<?php } ?>
|
||||
<th class="text-left">Is Billable</h>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="text-left"><?= esc($data['trip_title']) ?></td>
|
||||
<td class="text-left"><?= esc($data['cost_center_value']) ?></td>
|
||||
<td class="text-left"><?= esc($data['purpose_of_travel_value']) ?></td>
|
||||
<?php if($data['functional_department'] == 5){ ?>
|
||||
<td class="text-left"><?= esc($data['so_number']) ?></td>
|
||||
<?php }else{ ?>
|
||||
<td class="text-left"><?= esc($data['functional_department_value']) ?></td>
|
||||
<?php } ?>
|
||||
|
||||
<td class="text-left"><?= esc($data['is_billable_value']) ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<?php if (count($data['status_details'])) {
|
||||
|
||||
$statusHtml = '<h4 style="margin-bottom: 10px;">Trip Status:</h4>';
|
||||
$statusHtml .= '<ul style="
|
||||
list-style: none;
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
background-color: #f9f9f9;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
">';
|
||||
|
||||
foreach ($data['status_details'] as $key => $value) {
|
||||
|
||||
if (isset($value['a1_status'])) {
|
||||
$statusHtml .= '<li style="margin-bottom: 8px;"><strong>Approver 1:</strong> ' . $value['a1_status'] . '</li>';
|
||||
}
|
||||
|
||||
if (isset($value['a2_status'])) {
|
||||
$statusHtml .= '<li style="margin-bottom: 8px;"><strong>Approver 2:</strong> ' . $value['a2_status'] . '</li>';
|
||||
}
|
||||
|
||||
if (isset($value['a3_status'])) {
|
||||
$statusHtml .= '<li style="margin-bottom: 8px;"><strong>Approver 3:</strong> ' . $value['a3_status'] . '</li>';
|
||||
}
|
||||
|
||||
if (isset($value['a4_status'])) {
|
||||
$statusHtml .= '<li style="margin-bottom: 8px;"><strong>Approver 4:</strong> ' . $value['a4_status'] . '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
$statusHtml .= '</ul>';
|
||||
|
||||
echo $statusHtml;
|
||||
} ?>
|
||||
|
||||
|
||||
|
||||
<!--- Flight --->
|
||||
|
||||
<?php if(count($data['flight'])){ foreach ($data['flight'] as $key => $value) { ?>
|
||||
<div class="invoice-table services">
|
||||
<table>
|
||||
<tr>
|
||||
<th class="text-left" colspan="5"><strong>Flight - </strong><?= esc($value['trip_type']) ?></th>
|
||||
</tr>
|
||||
<?php foreach ($value['trips'] as $tripskey => $tripsvalue) { ?>
|
||||
<tr class="quotation-heading <?php if(count($value['trips']) != $tripskey+1){ echo 'border-bottom-dotted'; } ?>">
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">From</div>
|
||||
<div class="qsub-desc"><?= esc($tripsvalue['from_place']).' ('.esc($tripsvalue['from_place_name']).')' ?><br/></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">To</div>
|
||||
<div class="qsub-desc"><?= esc($tripsvalue['to_place']).' ('.esc($tripsvalue['to_place_name']).')' ?></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Date</div>
|
||||
<div class="qsub-desc"><?= date('d, M y', strtotime($tripsvalue['date'])) ?> </div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Time</div>
|
||||
<div class="qsub-desc"> <?= date('h:i A', strtotime($tripsvalue['time'])) ?> </div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Class</div>
|
||||
<!-- <div class="qsub-desc"><?= esc($tripsvalue['flight_class']) ?></div> -->
|
||||
<span <?php if($tripsvalue['is_this_exceptional'] == 1){ ?> style="color: #960000;" <?php } ?> ><?= esc($tripsvalue['flight_class']) ?></span> <br/>
|
||||
<?php if($tripsvalue['is_this_exceptional'] == 1){ ?> <span style="font-size: 12px"> allowed for <?= $data['allowed_class']['flight'] ?> </span><?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</div>
|
||||
<?php } } ?>
|
||||
|
||||
|
||||
|
||||
<!--- Train --->
|
||||
<?php if(count($data['train'])){ ?>
|
||||
<div class="invoice-table services">
|
||||
<table>
|
||||
<tr>
|
||||
<th class="text-left" colspan="6"><strong>Train</strong></th>
|
||||
</tr>
|
||||
<?php foreach ($data['train'] as $trainkey => $trainvalue) { ?>
|
||||
<tr class="quotation-heading <?php if(count($data['train']) != $trainkey+1){ echo 'border-bottom-dotted'; } ?>">
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Train No</div>
|
||||
<div class="qsub-desc"><?= esc($trainvalue['train_no']) ?><br/></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">From</div>
|
||||
<div class="qsub-desc"><?= esc($trainvalue['from_station']) ?><br/></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">To</div>
|
||||
<div class="qsub-desc"><?= esc($trainvalue['to_station']) ?></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Date</div>
|
||||
<div class="qsub-desc"><?= date('d, M y', strtotime($trainvalue['date'])) ?> </div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Time</div>
|
||||
<div class="qsub-desc"><?= date('h:i A', strtotime($trainvalue['time'])) ?> </div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Class</div>
|
||||
<span <?php if($trainvalue['is_this_exceptional'] == 1){ ?> style="color: #960000;" <?php } ?> ><?= esc($trainvalue['train_class']) ?></span> <br/>
|
||||
<?php if($trainvalue['is_this_exceptional'] == 1){ ?> <span style="font-size: 12px"> allowed for <?= $data['allowed_class']['train'] ?> </span><?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table></div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
|
||||
<!--- Bus --->
|
||||
<?php if(count($data['bus'])){ ?>
|
||||
<div class="invoice-table services">
|
||||
<table>
|
||||
<tr>
|
||||
<th class="text-left" colspan="5"><strong>Bus</strong></th>
|
||||
</tr>
|
||||
<?php foreach ($data['bus'] as $buskey => $busvalue) { ?>
|
||||
<tr class="quotation-heading <?php if(count($data['bus']) != $buskey+1){ echo 'border-bottom-dotted'; } ?>">
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">From</div>
|
||||
<div class="qsub-desc"><?= esc($busvalue['from']) ?><br/></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">To</div>
|
||||
<div class="qsub-desc"><?= esc($busvalue['to']) ?></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Date</div>
|
||||
<div class="qsub-desc"><?= date('d, M y', strtotime($busvalue['date'])) ?> </div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Time</div>
|
||||
<div class="qsub-desc"> <?= date('h:i A', strtotime($busvalue['time'])) ?> </div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Comments</div>
|
||||
<div class="qsub-desc"><?= ($busvalue['comments']) ? esc($busvalue['comments']) : '-' ?></div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table></div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
|
||||
<!--- Taxi --->
|
||||
<?php if(count($data['taxi'])){ ?>
|
||||
<div class="invoice-table services">
|
||||
<table>
|
||||
<tr>
|
||||
<th class="text-left" colspan="6"><strong>Taxi</strong></th>
|
||||
</tr>
|
||||
<?php foreach ($data['taxi'] as $taxikey => $taxivalue) { ?>
|
||||
<tr class="quotation-heading <?php if(count($data['taxi']) != $taxikey+1){ echo 'border-bottom-dotted'; } ?>">
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Pickup</div>
|
||||
<div class="qsub-desc"><?= esc($taxivalue['location_of_pickup']) ?><br/></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Destination</div>
|
||||
<div class="qsub-desc"><?= esc($taxivalue['destination_city']) ?></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Date</div>
|
||||
<div class="qsub-desc"><?= date('d, M y', strtotime($taxivalue['date'])) ?> </div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Time</div>
|
||||
<div class="qsub-desc"> <?= date('h:i A', strtotime($taxivalue['time'])) ?> </div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Car Type</div>
|
||||
<div class="qsub-desc"><?= esc($taxivalue['car_type_value']) ?></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Required For</div>
|
||||
<div class="qsub-desc"><?= esc($taxivalue['car_required_for_value']) ?></div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table></div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
<!--- Accomodation --->
|
||||
<?php if(count($data['accomodation'])){ ?>
|
||||
<div class="invoice-table services">
|
||||
<table>
|
||||
<tr>
|
||||
<th class="text-left" colspan="5"><strong>Accomodation</strong></th>
|
||||
</tr>
|
||||
<?php foreach ($data['accomodation'] as $accomodationkey => $accomodationvalue) { ?>
|
||||
<tr class="quotation-heading <?php if(count($data['accomodation']) != $accomodationkey+1){ echo 'border-bottom-dotted'; } ?>">
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">City</div>
|
||||
<div class="qsub-desc"><?= esc($accomodationvalue['destination_city']) ?></div>
|
||||
</td>
|
||||
<td class="quo-heading1" width="25%">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Hotel Name</div>
|
||||
<div class="qsub-desc"><?= esc($accomodationvalue['hotel_name']) ?><br/></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Checkin Date & Time</div>
|
||||
<div class="qsub-desc"><?= date('d, M y', strtotime($accomodationvalue['checkin_date'])) ?> <?= date('h:i A', strtotime($accomodationvalue['checkin_time'])) ?> </div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Checkout Date & Time</div>
|
||||
<div class="qsub-desc"><?= date('d, M y', strtotime($accomodationvalue['checkout_date'])) ?> <?= date('h:i A', strtotime($accomodationvalue['checkout_time'])) ?> </div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;" >Category</div>
|
||||
<div class="qsub-desc" >
|
||||
<span <?php if($accomodationvalue['is_this_exceptional'] == 1){ ?> style="color: #960000;" <?php } ?> ><?= esc($accomodationvalue['hotel_class']) ?></span> <br/>
|
||||
<?php if($accomodationvalue['is_this_exceptional'] == 1){ ?> <span style="font-size: 12px"> allowed for <?= $data['allowed_class']['hotel'] ?> </span><?php } ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table></div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
<!--- Forex --->
|
||||
<?php if(count($data['forex'])){ ?>
|
||||
<div class="invoice-table services">
|
||||
<table>
|
||||
<tr>
|
||||
<th class="text-left" colspan="7"><strong>Forex</strong></th>
|
||||
</tr>
|
||||
<?php foreach ($data['forex'] as $forexkey => $forexvalue) { ?>
|
||||
<tr class="quotation-heading <?php if(count($data['forex']) != $forexkey+1){ echo 'border-bottom-dotted'; } ?>">
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Country</div>
|
||||
<div class="qsub-desc"><?= $forexvalue['country_name'].' - '.$forexvalue['currency'] ?></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Duration</div>
|
||||
<div class="qsub-desc"><?= esc($forexvalue['duration']).' Days' ?><br/></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Perdiem</div>
|
||||
<div class="qsub-desc"><?= esc($forexvalue['perdiem_amount']) ?><br/></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Others</div>
|
||||
<div class="qsub-desc"><?= ($forexvalue['transport'] + $forexvalue['accommodation'] + $forexvalue['telephone']) ?><br/></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Total</div>
|
||||
<div class="qsub-desc"><?= ($forexvalue['deposit_on_cash'] + $forexvalue['deposit_on_card']) ?><br/></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Cash</div>
|
||||
<div class="qsub-desc"><?= ($forexvalue['deposit_on_cash']) ?><br/></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Card</div>
|
||||
<div class="qsub-desc"><?= ($forexvalue['deposit_on_card']) ?><br/></div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table></div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
|
||||
<!--- Insurance --->
|
||||
<?php if(count($data['insurance'])){ ?>
|
||||
<div class="invoice-table services">
|
||||
<table>
|
||||
<tr>
|
||||
<th class="text-left" colspan="4"><strong>Insurance</strong></th>
|
||||
</tr>
|
||||
<?php foreach ($data['insurance'] as $insurancekey => $insurancevalue) { ?>
|
||||
<tr class="quotation-heading <?php if(count($data['insurance']) != $insurancekey+1){ echo 'border-bottom-dotted'; } ?>">
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Type</div>
|
||||
<div class="qsub-desc"><?= esc($insurancevalue['type_of_insurance_value']) ?></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Start Date</div>
|
||||
<div class="qsub-desc"><?= date('d, M y', strtotime($insurancevalue['start_date'])) ?> </div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">End Date</div>
|
||||
<div class="qsub-desc"><?= date('d, M y', strtotime($insurancevalue['end_date'])) ?> </div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Comments</div>
|
||||
<div class="qsub-desc"><?= ($insurancevalue['comments']) ? esc($insurancevalue['comments']) : '-' ?></div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table></div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
|
||||
<!--- Visa --->
|
||||
<?php if(count($data['visa'])){ ?>
|
||||
<div class="invoice-table services">
|
||||
<table>
|
||||
<tr>
|
||||
<th class="text-left" colspan="4"><strong>Visa</strong></th>
|
||||
</tr>
|
||||
<?php foreach ($data['visa'] as $visakey => $visavalue) { ?>
|
||||
<tr class="quotation-heading <?php if(count($data['visa']) != $visakey+1){ echo 'border-bottom-dotted'; } ?>">
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Country</div>
|
||||
<div class="qsub-desc"><?= esc($visavalue['country_name']) ?></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Type</div>
|
||||
<div class="qsub-desc"><?= esc($visavalue['visa_type_value']) ?> </div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Start Date</div>
|
||||
<div class="qsub-desc"><?= date('d, M y', strtotime($visavalue['start_date'])) ?> </div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Comments</div>
|
||||
<div class="qsub-desc"><?= ($visavalue['comments']) ? esc($visavalue['comments']) : '-' ?></div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table></div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
<!--- Miscellaneous --->
|
||||
<?php if(count($data['miscellaneous'])){ ?>
|
||||
<div class="invoice-table services">
|
||||
<table>
|
||||
<tr>
|
||||
<th class="text-left" colspan="2"><strong>Miscellaneous</strong></th>
|
||||
</tr>
|
||||
<?php foreach ($data['miscellaneous'] as $miscellaneouskey => $miscellaneousvalue) { ?>
|
||||
<tr class="quotation-heading <?php if(count($data['miscellaneous']) != $miscellaneouskey+1){ echo 'border-bottom-dotted'; } ?>">
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Special Request</div>
|
||||
<div class="qsub-desc"><?= esc($miscellaneousvalue['special_request_value']) ?></div>
|
||||
</td>
|
||||
<td class="quo-heading1">
|
||||
<div class="qsub-heading" style="color: #6b7577; margin-bottom: 5px;">Comments</div>
|
||||
<div class="qsub-desc"><?= ($miscellaneousvalue['comments']) ? esc($miscellaneousvalue['comments']) : '-' ?></div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table></div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
100
app/Views/plan_pdf.php
Normal file
100
app/Views/plan_pdf.php
Normal file
@ -0,0 +1,100 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Trip Plan Report</title>
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; font-size: 12px; }
|
||||
h2 { text-align: center; background-color: #e8b7b7; padding: 7px; color: white; border-radius: 5px;}
|
||||
table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
|
||||
th, td { border: 1px solid #aaaaaa; padding: 6px; text-align: left; }
|
||||
.section-title {
|
||||
margin:20px 0 20px 0;
|
||||
padding-bottom: 5px;
|
||||
border-bottom: 3px dotted #aaaaaa;
|
||||
position: relative;
|
||||
font-size: 20px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.child{ background-color: #f1d5d5; }
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Trip Plan Report</h2>
|
||||
|
||||
<!-- <div class="section-title">Basic Info</div> -->
|
||||
<table>
|
||||
<tr>
|
||||
<th>Trip Title</th><td colspan="3"><?= esc($data['trip_title']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Traveller</th><td><?= esc( $data['user_name'] ?? $data['traveller_name'] ) ?></td>
|
||||
<th>Department</th><td><?= esc( $data['functional_department_value'] ) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Trip Type</th><td><?= esc($data['trip_type_value']) ?></td>
|
||||
<th>Is Billable</th><td><?= esc($data['is_billable_value']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Cost Center</th><td><?= esc($data['cost_center_value']) ?></td>
|
||||
<th>Plan Status</th><td><?= esc($data['status_value']) ?></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<?php if (!empty($data['flight'])): ?>
|
||||
<div class="section-title">Flights</div>
|
||||
<?php foreach ($data['flight'] as $flight): ?>
|
||||
<table>
|
||||
<tr><th>Flight ID</th><td><?= esc($flight['flight_id']) ?></td></tr>
|
||||
<tr><th>Comments</th><td><?= esc($flight['comments']) ?></td></tr>
|
||||
</table>
|
||||
<table>
|
||||
<thead>
|
||||
<tr class="child">
|
||||
<th>From</th><th>To</th><th>Date</th><th>Time</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($flight['trips'] as $trip): ?>
|
||||
<tr>
|
||||
<td><?= esc($trip['from_place']) ?></td>
|
||||
<td><?= esc($trip['to_place']) ?></td>
|
||||
<td><?= esc($trip['date']) ?></td>
|
||||
<td><?= esc($trip['time']) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$sections = ['accomodation', 'bus', 'insurance', 'miscellaneous', 'taxi', 'train', 'visa'];
|
||||
foreach ($sections as $section) {
|
||||
if (!empty($data[$section])) {
|
||||
echo "<div class='section-title'>" . ucfirst($section) . "</div><table><thead><tr>";
|
||||
foreach (array_keys($data[$section][0]) as $key) {
|
||||
if (!in_array($key, ['created_on', 'created_by', 'updated_on', 'updated_by', 'is_active', 'plan_id'])) {
|
||||
echo "<th class='child'>" . ucfirst(str_replace('_', ' ', $key)) . "</th>";
|
||||
}
|
||||
}
|
||||
echo "</tr></thead><tbody>";
|
||||
foreach ($data[$section] as $item) {
|
||||
echo "<tr>";
|
||||
foreach ($item as $k => $v) {
|
||||
if (!in_array($k, ['created_on', 'created_by', 'updated_on', 'updated_by', 'is_active', 'plan_id'])) {
|
||||
echo "<td>" . esc($v) . "</td>";
|
||||
}
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</tbody></table>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
156
app/Views/protected_page.php
Normal file
156
app/Views/protected_page.php
Normal file
@ -0,0 +1,156 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Approval Page</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="row mt-4">
|
||||
<div class="col-2"></div>
|
||||
|
||||
<div class="col-12 col-md-8 mx-auto p-3">
|
||||
|
||||
<!-- Header with buttons -->
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h4>Trip Plan Approval</h4>
|
||||
<div>
|
||||
|
||||
<?php if ($status == "Approval pending"){ ?>
|
||||
<button class="btn btn-success me-2" data-bs-toggle="modal" data-bs-target="#approveModal">Approve</button>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($status == "Approval pending"){ ?>
|
||||
<button class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#rejectModal">Reject</button>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Main content -->
|
||||
<div class="card p-3">
|
||||
<?= $html; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-2"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Approve Modal -->
|
||||
<div class="modal fade" id="approveModal" tabindex="-1" aria-labelledby="approveModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Confirm Approval</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
Are you sure you want to approve this trip plan?
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">No</button>
|
||||
<button type="button" class="btn btn-success" id="confirmApprove">Yes, Approve</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Reject Modal -->
|
||||
<div class="modal fade" id="rejectModal" tabindex="-1" aria-labelledby="rejectModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<form id="rejectForm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Reject Reason</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<textarea class="form-control" name="reason" id="reason" rows="3" placeholder="Enter reason for rejection" required></textarea>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-danger">Submit Reason</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Approve AJAX
|
||||
$('#confirmApprove').on('click', function () {
|
||||
|
||||
const data = {
|
||||
plan_id: <?= $plan_id ?>,
|
||||
user_id: <?= $user_id ?>,
|
||||
delegation_user_id: <?= $delegation_user_id ?? 0 ?>
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: "<?= base_url('/approvePlan') ?>",
|
||||
method: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(data),
|
||||
beforeSend: function() {
|
||||
$('#loader').show();
|
||||
},
|
||||
success: function(response) {
|
||||
location.reload();
|
||||
},
|
||||
error: function(xhr) {
|
||||
$('#loader').hide();
|
||||
alert('Approval failed: ' + xhr.responseText);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Reject AJAX
|
||||
$('#rejectForm').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
const reason = $('#reason').val();
|
||||
if (!reason.trim()) {
|
||||
alert('Please enter a reason.');
|
||||
return;
|
||||
}
|
||||
data = {
|
||||
plan_id: <?= $plan_id ?>,
|
||||
user_id: <?= $user_id ?>,
|
||||
delegation_user_id: <?= $delegation_user_id ?? 0 ?>,
|
||||
reason : reason
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: "<?= base_url('/rejectPlan') ?>",
|
||||
method: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(data),
|
||||
beforeSend: function() {
|
||||
$('#loader').show();
|
||||
},
|
||||
success: function(response) {
|
||||
location.reload();
|
||||
},
|
||||
error: function(xhr) {
|
||||
$('#loader').hide();
|
||||
alert('Approval failed: ' + xhr.responseText);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
<!-- Loader Spinner -->
|
||||
<div id="loader" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
|
||||
background: rgba(255, 255, 255, 0.8); z-index: 9999; text-align: center; padding-top: 20%;">
|
||||
<div class="spinner-border text-primary" style="width: 3rem; height: 3rem;" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
60
app/Views/swagger/index.php
Executable file
60
app/Views/swagger/index.php
Executable file
@ -0,0 +1,60 @@
|
||||
<!-- HTML for static distribution bundle build -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Swagger UI</title>
|
||||
<link rel="stylesheet" type="text/css" href="<?= base_url('public/assets/swagger/swagger-ui.css') ?>">
|
||||
<link rel="icon" type="image/png" href="<?= base_url('public/assets/swagger/favicon-32x32.png') ?> sizes=" 32x32" />
|
||||
<link rel="icon" type="image/png" href="<?= base_url('public/assets/swagger/favicon-16x16.png') ?> sizes=" 16x16" />
|
||||
<style>
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
*,
|
||||
*:before,
|
||||
*:after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: #fafafa;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
|
||||
<script src="<?= base_url('public/assets/swagger/swagger-ui-bundle.js') ?>">console.log(base_url); </script>
|
||||
<script src="<?= base_url('public/assets/swagger/swagger-ui-standalone-preset.js') ?>"> </script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
// Begin Swagger UI call region
|
||||
const ui = SwaggerUIBundle({
|
||||
url: "<?= base_url('public/assets/api.yaml') ?>",
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
layout: "StandaloneLayout"
|
||||
})
|
||||
// End Swagger UI call region
|
||||
|
||||
window.ui = ui
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
331
app/Views/welcome_message.php
Executable file
331
app/Views/welcome_message.php
Executable file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user