chore: repo-wide normalization + rules test coverage
Normalize formatting/line endings across configs, controllers, models, tests, and OpenAPI specs. Update rule expression/rule engine implementation and remove obsolete RuleAction controller/model. Add unit tests for rule expression syntax and multi-action behavior, and include docs updates.
This commit is contained in:
parent
c01786bb93
commit
2bcdf09b55
252
.gitignore
vendored
252
.gitignore
vendored
@ -1,127 +1,127 @@
|
|||||||
#-------------------------
|
#-------------------------
|
||||||
# Operating Specific Junk Files
|
# Operating Specific Junk Files
|
||||||
#-------------------------
|
#-------------------------
|
||||||
|
|
||||||
# OS X
|
# OS X
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.AppleDouble
|
.AppleDouble
|
||||||
.LSOverride
|
.LSOverride
|
||||||
|
|
||||||
# OS X Thumbnails
|
# OS X Thumbnails
|
||||||
._*
|
._*
|
||||||
|
|
||||||
# Windows image file caches
|
# Windows image file caches
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
ehthumbs.db
|
ehthumbs.db
|
||||||
Desktop.ini
|
Desktop.ini
|
||||||
|
|
||||||
# Recycle Bin used on file shares
|
# Recycle Bin used on file shares
|
||||||
$RECYCLE.BIN/
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
# Windows Installer files
|
# Windows Installer files
|
||||||
*.cab
|
*.cab
|
||||||
*.msi
|
*.msi
|
||||||
*.msm
|
*.msm
|
||||||
*.msp
|
*.msp
|
||||||
|
|
||||||
# Windows shortcuts
|
# Windows shortcuts
|
||||||
*.lnk
|
*.lnk
|
||||||
|
|
||||||
# Linux
|
# Linux
|
||||||
*~
|
*~
|
||||||
|
|
||||||
# KDE directory preferences
|
# KDE directory preferences
|
||||||
.directory
|
.directory
|
||||||
|
|
||||||
# Linux trash folder which might appear on any partition or disk
|
# Linux trash folder which might appear on any partition or disk
|
||||||
.Trash-*
|
.Trash-*
|
||||||
|
|
||||||
#-------------------------
|
#-------------------------
|
||||||
# Environment Files
|
# Environment Files
|
||||||
#-------------------------
|
#-------------------------
|
||||||
# These should never be under version control,
|
# These should never be under version control,
|
||||||
# as it poses a security risk.
|
# as it poses a security risk.
|
||||||
.env
|
.env
|
||||||
.vagrant
|
.vagrant
|
||||||
Vagrantfile
|
Vagrantfile
|
||||||
|
|
||||||
#-------------------------
|
#-------------------------
|
||||||
# Temporary Files
|
# Temporary Files
|
||||||
#-------------------------
|
#-------------------------
|
||||||
writable/cache/*
|
writable/cache/*
|
||||||
!writable/cache/index.html
|
!writable/cache/index.html
|
||||||
|
|
||||||
writable/logs/*
|
writable/logs/*
|
||||||
!writable/logs/index.html
|
!writable/logs/index.html
|
||||||
|
|
||||||
writable/session/*
|
writable/session/*
|
||||||
!writable/session/index.html
|
!writable/session/index.html
|
||||||
|
|
||||||
writable/uploads/*
|
writable/uploads/*
|
||||||
!writable/uploads/index.html
|
!writable/uploads/index.html
|
||||||
|
|
||||||
writable/debugbar/*
|
writable/debugbar/*
|
||||||
!writable/debugbar/.gitkeep
|
!writable/debugbar/.gitkeep
|
||||||
|
|
||||||
php_errors.log
|
php_errors.log
|
||||||
|
|
||||||
#-------------------------
|
#-------------------------
|
||||||
# User Guide Temp Files
|
# User Guide Temp Files
|
||||||
#-------------------------
|
#-------------------------
|
||||||
user_guide_src/build/*
|
user_guide_src/build/*
|
||||||
user_guide_src/cilexer/build/*
|
user_guide_src/cilexer/build/*
|
||||||
user_guide_src/cilexer/dist/*
|
user_guide_src/cilexer/dist/*
|
||||||
user_guide_src/cilexer/pycilexer.egg-info/*
|
user_guide_src/cilexer/pycilexer.egg-info/*
|
||||||
|
|
||||||
#-------------------------
|
#-------------------------
|
||||||
# Test Files
|
# Test Files
|
||||||
#-------------------------
|
#-------------------------
|
||||||
tests/coverage*
|
tests/coverage*
|
||||||
|
|
||||||
# Don't save phpunit under version control.
|
# Don't save phpunit under version control.
|
||||||
phpunit
|
phpunit
|
||||||
|
|
||||||
#-------------------------
|
#-------------------------
|
||||||
# Composer
|
# Composer
|
||||||
#-------------------------
|
#-------------------------
|
||||||
vendor/
|
vendor/
|
||||||
|
|
||||||
#-------------------------
|
#-------------------------
|
||||||
# IDE / Development Files
|
# IDE / Development Files
|
||||||
#-------------------------
|
#-------------------------
|
||||||
|
|
||||||
# Modules Testing
|
# Modules Testing
|
||||||
_modules/*
|
_modules/*
|
||||||
|
|
||||||
# phpenv local config
|
# phpenv local config
|
||||||
.php-version
|
.php-version
|
||||||
|
|
||||||
# Jetbrains editors (PHPStorm, etc)
|
# Jetbrains editors (PHPStorm, etc)
|
||||||
.idea/
|
.idea/
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
# NetBeans
|
# NetBeans
|
||||||
/nbproject/
|
/nbproject/
|
||||||
/build/
|
/build/
|
||||||
/nbbuild/
|
/nbbuild/
|
||||||
/dist/
|
/dist/
|
||||||
/nbdist/
|
/nbdist/
|
||||||
/nbactions.xml
|
/nbactions.xml
|
||||||
/nb-configuration.xml
|
/nb-configuration.xml
|
||||||
/.nb-gradle/
|
/.nb-gradle/
|
||||||
|
|
||||||
# Sublime Text
|
# Sublime Text
|
||||||
*.tmlanguage.cache
|
*.tmlanguage.cache
|
||||||
*.tmPreferences.cache
|
*.tmPreferences.cache
|
||||||
*.stTheme.cache
|
*.stTheme.cache
|
||||||
*.sublime-workspace
|
*.sublime-workspace
|
||||||
*.sublime-project
|
*.sublime-project
|
||||||
.phpintel
|
.phpintel
|
||||||
/api/
|
/api/
|
||||||
|
|
||||||
# Visual Studio Code
|
# Visual Studio Code
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
/results/
|
/results/
|
||||||
/phpunit*.xml
|
/phpunit*.xml
|
||||||
/public/.htaccess
|
/public/.htaccess
|
||||||
4
.serena/.gitignore
vendored
4
.serena/.gitignore
vendored
@ -1,2 +1,2 @@
|
|||||||
/cache
|
/cache
|
||||||
/project.local.yml
|
/project.local.yml
|
||||||
|
|||||||
@ -1,32 +1,32 @@
|
|||||||
# CLQMS Project Overview
|
# CLQMS Project Overview
|
||||||
- **Name:** CLQMS (Clinical Laboratory Quality Management System)
|
- **Name:** CLQMS (Clinical Laboratory Quality Management System)
|
||||||
- **Type:** Headless REST API backend (no view layer for product UX)
|
- **Type:** Headless REST API backend (no view layer for product UX)
|
||||||
- **Purpose:** Manage clinical laboratory workflows (patients, orders, specimens, results, value sets, edge/instrument integration) via JSON APIs.
|
- **Purpose:** Manage clinical laboratory workflows (patients, orders, specimens, results, value sets, edge/instrument integration) via JSON APIs.
|
||||||
- **Framework/Runtime:** CodeIgniter 4 on PHP 8.1+
|
- **Framework/Runtime:** CodeIgniter 4 on PHP 8.1+
|
||||||
- **Database:** MySQL (legacy PascalCase column naming in many tables)
|
- **Database:** MySQL (legacy PascalCase column naming in many tables)
|
||||||
- **Auth:** JWT (firebase/php-jwt), typically required for protected `/api/*` endpoints.
|
- **Auth:** JWT (firebase/php-jwt), typically required for protected `/api/*` endpoints.
|
||||||
|
|
||||||
## Architecture Notes
|
## Architecture Notes
|
||||||
- API-first and frontend-agnostic; clients consume REST JSON endpoints.
|
- API-first and frontend-agnostic; clients consume REST JSON endpoints.
|
||||||
- Controllers delegate business logic to models/services; avoid direct DB query logic in controllers.
|
- Controllers delegate business logic to models/services; avoid direct DB query logic in controllers.
|
||||||
- Standardized response format with `status`, `message`, `data`.
|
- Standardized response format with `status`, `message`, `data`.
|
||||||
- ValueSet/Lookups system supports static lookup data and API-managed lookup definitions.
|
- ValueSet/Lookups system supports static lookup data and API-managed lookup definitions.
|
||||||
- OpenAPI docs live under `public/api-docs.yaml`, `public/paths/*.yaml`, `public/components/schemas/*.yaml` and are bundled into `public/api-docs.bundled.yaml`.
|
- OpenAPI docs live under `public/api-docs.yaml`, `public/paths/*.yaml`, `public/components/schemas/*.yaml` and are bundled into `public/api-docs.bundled.yaml`.
|
||||||
|
|
||||||
## High-Level Structure
|
## High-Level Structure
|
||||||
- `app/Config` - framework and app configuration (routes, filters, etc.)
|
- `app/Config` - framework and app configuration (routes, filters, etc.)
|
||||||
- `app/Controllers` - REST controllers
|
- `app/Controllers` - REST controllers
|
||||||
- `app/Models` - data access and DB logic
|
- `app/Models` - data access and DB logic
|
||||||
- `app/Services` - service-layer logic
|
- `app/Services` - service-layer logic
|
||||||
- `app/Filters` - auth/request filters
|
- `app/Filters` - auth/request filters
|
||||||
- `app/Helpers` - helper functions (including UTC handling per conventions)
|
- `app/Helpers` - helper functions (including UTC handling per conventions)
|
||||||
- `app/Libraries` - shared libraries (lookups/valuesets, etc.)
|
- `app/Libraries` - shared libraries (lookups/valuesets, etc.)
|
||||||
- `app/Traits` - reusable traits (including response behavior)
|
- `app/Traits` - reusable traits (including response behavior)
|
||||||
- `tests/feature`, `tests/unit` - PHPUnit test suites
|
- `tests/feature`, `tests/unit` - PHPUnit test suites
|
||||||
- `public/paths`, `public/components/schemas` - modular OpenAPI source files
|
- `public/paths`, `public/components/schemas` - modular OpenAPI source files
|
||||||
|
|
||||||
## Key Dependencies
|
## Key Dependencies
|
||||||
- `codeigniter4/framework`
|
- `codeigniter4/framework`
|
||||||
- `firebase/php-jwt`
|
- `firebase/php-jwt`
|
||||||
- `mossadal/math-parser`
|
- `mossadal/math-parser`
|
||||||
- Dev: `phpunit/phpunit`, `fakerphp/faker`
|
- Dev: `phpunit/phpunit`, `fakerphp/faker`
|
||||||
@ -1,43 +1,43 @@
|
|||||||
# CLQMS Style and Conventions
|
# CLQMS Style and Conventions
|
||||||
## PHP and Naming
|
## PHP and Naming
|
||||||
- PHP 8.1+, PSR-4 autoloading (`App\\` => `app/`, `Config\\` => `app/Config/`).
|
- PHP 8.1+, PSR-4 autoloading (`App\\` => `app/`, `Config\\` => `app/Config/`).
|
||||||
- Follow PSR-12 where applicable.
|
- Follow PSR-12 where applicable.
|
||||||
- Class names: PascalCase.
|
- Class names: PascalCase.
|
||||||
- Method names: camelCase.
|
- Method names: camelCase.
|
||||||
- Properties: legacy snake_case and newer camelCase coexist.
|
- Properties: legacy snake_case and newer camelCase coexist.
|
||||||
- Constants: UPPER_SNAKE_CASE.
|
- Constants: UPPER_SNAKE_CASE.
|
||||||
- DB tables: snake_case; many DB columns are legacy PascalCase.
|
- DB tables: snake_case; many DB columns are legacy PascalCase.
|
||||||
- JSON fields in API responses often use PascalCase for domain fields.
|
- JSON fields in API responses often use PascalCase for domain fields.
|
||||||
|
|
||||||
## Controller Pattern
|
## Controller Pattern
|
||||||
- Controllers should handle HTTP concerns and delegate to model/service logic.
|
- Controllers should handle HTTP concerns and delegate to model/service logic.
|
||||||
- Avoid embedding DB query logic directly inside controllers.
|
- Avoid embedding DB query logic directly inside controllers.
|
||||||
- Use `ResponseTrait` and consistent JSON envelope responses.
|
- Use `ResponseTrait` and consistent JSON envelope responses.
|
||||||
|
|
||||||
## Response Pattern
|
## Response Pattern
|
||||||
- Success: `status=success`, plus message/data.
|
- Success: `status=success`, plus message/data.
|
||||||
- Error: structured error response with proper HTTP status codes.
|
- Error: structured error response with proper HTTP status codes.
|
||||||
- Empty strings may be normalized to `null` by custom response behavior.
|
- Empty strings may be normalized to `null` by custom response behavior.
|
||||||
|
|
||||||
## DB and Data Handling
|
## DB and Data Handling
|
||||||
- Prefer CodeIgniter Model/Query Builder usage.
|
- Prefer CodeIgniter Model/Query Builder usage.
|
||||||
- Use UTC helper conventions for datetime handling.
|
- Use UTC helper conventions for datetime handling.
|
||||||
- Multi-table writes should be wrapped in transactions.
|
- Multi-table writes should be wrapped in transactions.
|
||||||
- For nested entities/arrays, extract and handle nested payloads carefully before filtering and persistence.
|
- For nested entities/arrays, extract and handle nested payloads carefully before filtering and persistence.
|
||||||
|
|
||||||
## Error Handling
|
## Error Handling
|
||||||
- Use try/catch for JWT and external operations.
|
- Use try/catch for JWT and external operations.
|
||||||
- Log errors with `log_message('error', ...)`.
|
- Log errors with `log_message('error', ...)`.
|
||||||
- Return structured API errors with correct status codes.
|
- Return structured API errors with correct status codes.
|
||||||
|
|
||||||
## Testing Convention
|
## Testing Convention
|
||||||
- PHPUnit tests in `tests/`.
|
- PHPUnit tests in `tests/`.
|
||||||
- Test naming: `test<Action><Scenario><ExpectedResult>`.
|
- Test naming: `test<Action><Scenario><ExpectedResult>`.
|
||||||
- Typical status expectation: 200 (GET/PATCH), 201 (POST), 400/401/404/500 as appropriate.
|
- Typical status expectation: 200 (GET/PATCH), 201 (POST), 400/401/404/500 as appropriate.
|
||||||
|
|
||||||
## API Docs Rule (Critical)
|
## API Docs Rule (Critical)
|
||||||
- Any controller/API contract change must update corresponding OpenAPI YAML files under:
|
- Any controller/API contract change must update corresponding OpenAPI YAML files under:
|
||||||
- `public/paths/*.yaml`
|
- `public/paths/*.yaml`
|
||||||
- `public/components/schemas/*.yaml`
|
- `public/components/schemas/*.yaml`
|
||||||
- optionally `public/api-docs.yaml` if references/tags change
|
- optionally `public/api-docs.yaml` if references/tags change
|
||||||
- Rebuild docs bundle after YAML updates.
|
- Rebuild docs bundle after YAML updates.
|
||||||
@ -1,32 +1,32 @@
|
|||||||
# Suggested Commands (Windows)
|
# Suggested Commands (Windows)
|
||||||
## Core Project Commands
|
## Core Project Commands
|
||||||
- Install dependencies: `composer install`
|
- Install dependencies: `composer install`
|
||||||
- Run all tests: `./vendor/bin/phpunit`
|
- Run all tests: `./vendor/bin/phpunit`
|
||||||
- Run one test file: `./vendor/bin/phpunit tests/feature/Patients/PatientCreateTest.php`
|
- Run one test file: `./vendor/bin/phpunit tests/feature/Patients/PatientCreateTest.php`
|
||||||
- Run one test method: `./vendor/bin/phpunit --filter testCreatePatientSuccess tests/feature/Patients/PatientCreateTest.php`
|
- Run one test method: `./vendor/bin/phpunit --filter testCreatePatientSuccess tests/feature/Patients/PatientCreateTest.php`
|
||||||
- Run test suite: `./vendor/bin/phpunit --testsuite App`
|
- Run test suite: `./vendor/bin/phpunit --testsuite App`
|
||||||
- Run with coverage: `./vendor/bin/phpunit --coverage-html build/logs/html`
|
- Run with coverage: `./vendor/bin/phpunit --coverage-html build/logs/html`
|
||||||
|
|
||||||
## CodeIgniter/Spark Commands
|
## CodeIgniter/Spark Commands
|
||||||
- Create migration: `php spark make:migration <name>`
|
- Create migration: `php spark make:migration <name>`
|
||||||
- Create model: `php spark make:model <name>`
|
- Create model: `php spark make:model <name>`
|
||||||
- Create controller: `php spark make:controller <name>`
|
- Create controller: `php spark make:controller <name>`
|
||||||
- Apply migrations: `php spark migrate`
|
- Apply migrations: `php spark migrate`
|
||||||
- Rollback migrations: `php spark migrate:rollback`
|
- Rollback migrations: `php spark migrate:rollback`
|
||||||
- Run local app: `php spark serve`
|
- Run local app: `php spark serve`
|
||||||
|
|
||||||
## OpenAPI Docs Commands
|
## OpenAPI Docs Commands
|
||||||
- Rebundle API docs after YAML changes: `node public/bundle-api-docs.js`
|
- Rebundle API docs after YAML changes: `node public/bundle-api-docs.js`
|
||||||
|
|
||||||
## Git and Shell Utilities (Windows)
|
## Git and Shell Utilities (Windows)
|
||||||
- Git status: `git status`
|
- Git status: `git status`
|
||||||
- Diff changes: `git diff`
|
- Diff changes: `git diff`
|
||||||
- Show staged diff: `git diff --cached`
|
- Show staged diff: `git diff --cached`
|
||||||
- Recent commits: `git log --oneline -n 10`
|
- Recent commits: `git log --oneline -n 10`
|
||||||
- List files (PowerShell): `Get-ChildItem`
|
- List files (PowerShell): `Get-ChildItem`
|
||||||
- Recursive file search (PowerShell): `Get-ChildItem -Recurse -File`
|
- Recursive file search (PowerShell): `Get-ChildItem -Recurse -File`
|
||||||
- Text search (PowerShell): `Select-String -Path .\* -Pattern "<text>" -Recurse`
|
- Text search (PowerShell): `Select-String -Path .\* -Pattern "<text>" -Recurse`
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
- Testing DB values in `phpunit.xml.dist` are environment-specific; verify before running tests.
|
- Testing DB values in `phpunit.xml.dist` are environment-specific; verify before running tests.
|
||||||
- API docs bundle output file: `public/api-docs.bundled.yaml`.
|
- API docs bundle output file: `public/api-docs.bundled.yaml`.
|
||||||
@ -1,9 +1,9 @@
|
|||||||
# Task Completion Checklist
|
# Task Completion Checklist
|
||||||
When finishing a coding change in CLQMS:
|
When finishing a coding change in CLQMS:
|
||||||
|
|
||||||
1. Run targeted tests first (file/method-level), then broader PHPUnit suite if scope warrants it.
|
1. Run targeted tests first (file/method-level), then broader PHPUnit suite if scope warrants it.
|
||||||
2. Verify API response structure consistency (`status`, `message`, `data`) and proper HTTP status codes.
|
2. Verify API response structure consistency (`status`, `message`, `data`) and proper HTTP status codes.
|
||||||
3. If controllers or API contracts changed, update OpenAPI YAML files in `public/paths` and/or `public/components/schemas`.
|
3. If controllers or API contracts changed, update OpenAPI YAML files in `public/paths` and/or `public/components/schemas`.
|
||||||
4. Rebundle OpenAPI docs with `node public/bundle-api-docs.js` after YAML updates.
|
4. Rebundle OpenAPI docs with `node public/bundle-api-docs.js` after YAML updates.
|
||||||
5. Confirm no secrets/credentials were introduced in tracked files.
|
5. Confirm no secrets/credentials were introduced in tracked files.
|
||||||
6. Review diff for legacy field naming compatibility (PascalCase DB columns/JSON domain fields where expected).
|
6. Review diff for legacy field naming compatibility (PascalCase DB columns/JSON domain fields where expected).
|
||||||
@ -1,135 +1,135 @@
|
|||||||
# the name by which the project can be referenced within Serena
|
# the name by which the project can be referenced within Serena
|
||||||
project_name: "clqms01-be"
|
project_name: "clqms01-be"
|
||||||
|
|
||||||
|
|
||||||
# list of languages for which language servers are started; choose from:
|
# list of languages for which language servers are started; choose from:
|
||||||
# al bash clojure cpp csharp
|
# al bash clojure cpp csharp
|
||||||
# csharp_omnisharp dart elixir elm erlang
|
# csharp_omnisharp dart elixir elm erlang
|
||||||
# fortran fsharp go groovy haskell
|
# fortran fsharp go groovy haskell
|
||||||
# java julia kotlin lua markdown
|
# java julia kotlin lua markdown
|
||||||
# matlab nix pascal perl php
|
# matlab nix pascal perl php
|
||||||
# php_phpactor powershell python python_jedi r
|
# php_phpactor powershell python python_jedi r
|
||||||
# rego ruby ruby_solargraph rust scala
|
# rego ruby ruby_solargraph rust scala
|
||||||
# swift terraform toml typescript typescript_vts
|
# swift terraform toml typescript typescript_vts
|
||||||
# vue yaml zig
|
# vue yaml zig
|
||||||
# (This list may be outdated. For the current list, see values of Language enum here:
|
# (This list may be outdated. For the current list, see values of Language enum here:
|
||||||
# https://github.com/oraios/serena/blob/main/src/solidlsp/ls_config.py
|
# https://github.com/oraios/serena/blob/main/src/solidlsp/ls_config.py
|
||||||
# For some languages, there are alternative language servers, e.g. csharp_omnisharp, ruby_solargraph.)
|
# For some languages, there are alternative language servers, e.g. csharp_omnisharp, ruby_solargraph.)
|
||||||
# Note:
|
# Note:
|
||||||
# - For C, use cpp
|
# - For C, use cpp
|
||||||
# - For JavaScript, use typescript
|
# - For JavaScript, use typescript
|
||||||
# - For Free Pascal/Lazarus, use pascal
|
# - For Free Pascal/Lazarus, use pascal
|
||||||
# Special requirements:
|
# Special requirements:
|
||||||
# Some languages require additional setup/installations.
|
# Some languages require additional setup/installations.
|
||||||
# See here for details: https://oraios.github.io/serena/01-about/020_programming-languages.html#language-servers
|
# See here for details: https://oraios.github.io/serena/01-about/020_programming-languages.html#language-servers
|
||||||
# When using multiple languages, the first language server that supports a given file will be used for that file.
|
# When using multiple languages, the first language server that supports a given file will be used for that file.
|
||||||
# The first language is the default language and the respective language server will be used as a fallback.
|
# The first language is the default language and the respective language server will be used as a fallback.
|
||||||
# Note that when using the JetBrains backend, language servers are not used and this list is correspondingly ignored.
|
# Note that when using the JetBrains backend, language servers are not used and this list is correspondingly ignored.
|
||||||
languages:
|
languages:
|
||||||
- php
|
- php
|
||||||
|
|
||||||
# the encoding used by text files in the project
|
# the encoding used by text files in the project
|
||||||
# For a list of possible encodings, see https://docs.python.org/3.11/library/codecs.html#standard-encodings
|
# For a list of possible encodings, see https://docs.python.org/3.11/library/codecs.html#standard-encodings
|
||||||
encoding: "utf-8"
|
encoding: "utf-8"
|
||||||
|
|
||||||
# line ending convention to use when writing source files.
|
# line ending convention to use when writing source files.
|
||||||
# Possible values: unset (use global setting), "lf", "crlf", or "native" (platform default)
|
# Possible values: unset (use global setting), "lf", "crlf", or "native" (platform default)
|
||||||
# This does not affect Serena's own files (e.g. memories and configuration files), which always use native line endings.
|
# This does not affect Serena's own files (e.g. memories and configuration files), which always use native line endings.
|
||||||
line_ending:
|
line_ending:
|
||||||
|
|
||||||
# The language backend to use for this project.
|
# The language backend to use for this project.
|
||||||
# If not set, the global setting from serena_config.yml is used.
|
# If not set, the global setting from serena_config.yml is used.
|
||||||
# Valid values: LSP, JetBrains
|
# Valid values: LSP, JetBrains
|
||||||
# Note: the backend is fixed at startup. If a project with a different backend
|
# Note: the backend is fixed at startup. If a project with a different backend
|
||||||
# is activated post-init, an error will be returned.
|
# is activated post-init, an error will be returned.
|
||||||
language_backend:
|
language_backend:
|
||||||
|
|
||||||
# whether to use project's .gitignore files to ignore files
|
# whether to use project's .gitignore files to ignore files
|
||||||
ignore_all_files_in_gitignore: true
|
ignore_all_files_in_gitignore: true
|
||||||
|
|
||||||
# list of additional paths to ignore in this project.
|
# list of additional paths to ignore in this project.
|
||||||
# Same syntax as gitignore, so you can use * and **.
|
# Same syntax as gitignore, so you can use * and **.
|
||||||
# Note: global ignored_paths from serena_config.yml are also applied additively.
|
# Note: global ignored_paths from serena_config.yml are also applied additively.
|
||||||
ignored_paths: []
|
ignored_paths: []
|
||||||
|
|
||||||
# whether the project is in read-only mode
|
# whether the project is in read-only mode
|
||||||
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
|
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
|
||||||
# Added on 2025-04-18
|
# Added on 2025-04-18
|
||||||
read_only: false
|
read_only: false
|
||||||
|
|
||||||
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
|
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
|
||||||
# Below is the complete list of tools for convenience.
|
# Below is the complete list of tools for convenience.
|
||||||
# To make sure you have the latest list of tools, and to view their descriptions,
|
# To make sure you have the latest list of tools, and to view their descriptions,
|
||||||
# execute `uv run scripts/print_tool_overview.py`.
|
# execute `uv run scripts/print_tool_overview.py`.
|
||||||
#
|
#
|
||||||
# * `activate_project`: Activates a project by name.
|
# * `activate_project`: Activates a project by name.
|
||||||
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
|
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
|
||||||
# * `create_text_file`: Creates/overwrites a file in the project directory.
|
# * `create_text_file`: Creates/overwrites a file in the project directory.
|
||||||
# * `delete_lines`: Deletes a range of lines within a file.
|
# * `delete_lines`: Deletes a range of lines within a file.
|
||||||
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
|
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
|
||||||
# * `execute_shell_command`: Executes a shell command.
|
# * `execute_shell_command`: Executes a shell command.
|
||||||
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
|
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
|
||||||
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
|
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
|
||||||
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
|
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
|
||||||
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
|
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
|
||||||
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
|
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
|
||||||
# * `initial_instructions`: Gets the initial instructions for the current project.
|
# * `initial_instructions`: Gets the initial instructions for the current project.
|
||||||
# Should only be used in settings where the system prompt cannot be set,
|
# Should only be used in settings where the system prompt cannot be set,
|
||||||
# e.g. in clients you have no control over, like Claude Desktop.
|
# e.g. in clients you have no control over, like Claude Desktop.
|
||||||
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
|
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
|
||||||
# * `insert_at_line`: Inserts content at a given line in a file.
|
# * `insert_at_line`: Inserts content at a given line in a file.
|
||||||
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
|
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
|
||||||
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
|
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
|
||||||
# * `list_memories`: Lists memories in Serena's project-specific memory store.
|
# * `list_memories`: Lists memories in Serena's project-specific memory store.
|
||||||
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
|
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
|
||||||
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
|
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
|
||||||
# * `read_file`: Reads a file within the project directory.
|
# * `read_file`: Reads a file within the project directory.
|
||||||
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
|
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
|
||||||
# * `remove_project`: Removes a project from the Serena configuration.
|
# * `remove_project`: Removes a project from the Serena configuration.
|
||||||
# * `replace_lines`: Replaces a range of lines within a file with new content.
|
# * `replace_lines`: Replaces a range of lines within a file with new content.
|
||||||
# * `replace_symbol_body`: Replaces the full definition of a symbol.
|
# * `replace_symbol_body`: Replaces the full definition of a symbol.
|
||||||
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
|
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
|
||||||
# * `search_for_pattern`: Performs a search for a pattern in the project.
|
# * `search_for_pattern`: Performs a search for a pattern in the project.
|
||||||
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
|
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
|
||||||
# * `switch_modes`: Activates modes by providing a list of their names
|
# * `switch_modes`: Activates modes by providing a list of their names
|
||||||
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
|
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
|
||||||
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
|
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
|
||||||
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
|
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
|
||||||
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
|
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
|
||||||
excluded_tools: []
|
excluded_tools: []
|
||||||
|
|
||||||
# list of tools to include that would otherwise be disabled (particularly optional tools that are disabled by default)
|
# list of tools to include that would otherwise be disabled (particularly optional tools that are disabled by default)
|
||||||
included_optional_tools: []
|
included_optional_tools: []
|
||||||
|
|
||||||
# fixed set of tools to use as the base tool set (if non-empty), replacing Serena's default set of tools.
|
# fixed set of tools to use as the base tool set (if non-empty), replacing Serena's default set of tools.
|
||||||
# This cannot be combined with non-empty excluded_tools or included_optional_tools.
|
# This cannot be combined with non-empty excluded_tools or included_optional_tools.
|
||||||
fixed_tools: []
|
fixed_tools: []
|
||||||
|
|
||||||
# list of mode names to that are always to be included in the set of active modes
|
# list of mode names to that are always to be included in the set of active modes
|
||||||
# The full set of modes to be activated is base_modes + default_modes.
|
# The full set of modes to be activated is base_modes + default_modes.
|
||||||
# If the setting is undefined, the base_modes from the global configuration (serena_config.yml) apply.
|
# If the setting is undefined, the base_modes from the global configuration (serena_config.yml) apply.
|
||||||
# Otherwise, this setting overrides the global configuration.
|
# Otherwise, this setting overrides the global configuration.
|
||||||
# Set this to [] to disable base modes for this project.
|
# Set this to [] to disable base modes for this project.
|
||||||
# Set this to a list of mode names to always include the respective modes for this project.
|
# Set this to a list of mode names to always include the respective modes for this project.
|
||||||
base_modes:
|
base_modes:
|
||||||
|
|
||||||
# list of mode names that are to be activated by default.
|
# list of mode names that are to be activated by default.
|
||||||
# The full set of modes to be activated is base_modes + default_modes.
|
# The full set of modes to be activated is base_modes + default_modes.
|
||||||
# If the setting is undefined, the default_modes from the global configuration (serena_config.yml) apply.
|
# If the setting is undefined, the default_modes from the global configuration (serena_config.yml) apply.
|
||||||
# Otherwise, this overrides the setting from the global configuration (serena_config.yml).
|
# Otherwise, this overrides the setting from the global configuration (serena_config.yml).
|
||||||
# This setting can, in turn, be overridden by CLI parameters (--mode).
|
# This setting can, in turn, be overridden by CLI parameters (--mode).
|
||||||
default_modes:
|
default_modes:
|
||||||
|
|
||||||
# initial prompt for the project. It will always be given to the LLM upon activating the project
|
# initial prompt for the project. It will always be given to the LLM upon activating the project
|
||||||
# (contrary to the memories, which are loaded on demand).
|
# (contrary to the memories, which are loaded on demand).
|
||||||
initial_prompt: ""
|
initial_prompt: ""
|
||||||
|
|
||||||
# time budget (seconds) per tool call for the retrieval of additional symbol information
|
# time budget (seconds) per tool call for the retrieval of additional symbol information
|
||||||
# such as docstrings or parameter information.
|
# such as docstrings or parameter information.
|
||||||
# This overrides the corresponding setting in the global configuration; see the documentation there.
|
# This overrides the corresponding setting in the global configuration; see the documentation there.
|
||||||
# If null or missing, use the setting from the global configuration.
|
# If null or missing, use the setting from the global configuration.
|
||||||
symbol_info_budget:
|
symbol_info_budget:
|
||||||
|
|
||||||
# list of regex patterns which, when matched, mark a memory entry as read‑only.
|
# list of regex patterns which, when matched, mark a memory entry as read‑only.
|
||||||
# Extends the list from the global configuration, merging the two lists.
|
# Extends the list from the global configuration, merging the two lists.
|
||||||
read_only_memory_patterns: []
|
read_only_memory_patterns: []
|
||||||
|
|||||||
632
AGENTS.md
632
AGENTS.md
@ -1,316 +1,316 @@
|
|||||||
# AGENTS.md - Code Guidelines for CLQMS
|
# AGENTS.md - Code Guidelines for CLQMS
|
||||||
|
|
||||||
> **CLQMS (Clinical Laboratory Quality Management System)** - A headless REST API backend for clinical laboratory workflows built with CodeIgniter 4.
|
> **CLQMS (Clinical Laboratory Quality Management System)** - A headless REST API backend for clinical laboratory workflows built with CodeIgniter 4.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Build, Test & Lint Commands
|
## Build, Test & Lint Commands
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Run all tests
|
# Run all tests
|
||||||
./vendor/bin/phpunit
|
./vendor/bin/phpunit
|
||||||
|
|
||||||
# Run a specific test file
|
# Run a specific test file
|
||||||
./vendor/bin/phpunit tests/feature/Patients/PatientCreateTest.php
|
./vendor/bin/phpunit tests/feature/Patients/PatientCreateTest.php
|
||||||
|
|
||||||
# Run a specific test method
|
# Run a specific test method
|
||||||
./vendor/bin/phpunit --filter testCreatePatientSuccess tests/feature/Patients/PatientCreateTest.php
|
./vendor/bin/phpunit --filter testCreatePatientSuccess tests/feature/Patients/PatientCreateTest.php
|
||||||
|
|
||||||
# Run tests with coverage
|
# Run tests with coverage
|
||||||
./vendor/bin/phpunit --coverage-html build/logs/html
|
./vendor/bin/phpunit --coverage-html build/logs/html
|
||||||
|
|
||||||
# Run tests by suite
|
# Run tests by suite
|
||||||
./vendor/bin/phpunit --testsuite App
|
./vendor/bin/phpunit --testsuite App
|
||||||
|
|
||||||
# Generate scaffolding
|
# Generate scaffolding
|
||||||
php spark make:migration <name>
|
php spark make:migration <name>
|
||||||
php spark make:model <name>
|
php spark make:model <name>
|
||||||
php spark make:controller <name>
|
php spark make:controller <name>
|
||||||
|
|
||||||
# Database migrations
|
# Database migrations
|
||||||
php spark migrate
|
php spark migrate
|
||||||
php spark migrate:rollback
|
php spark migrate:rollback
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Code Style Guidelines
|
## Code Style Guidelines
|
||||||
|
|
||||||
### PHP Standards
|
### PHP Standards
|
||||||
- **PHP Version**: 8.1+
|
- **PHP Version**: 8.1+
|
||||||
- **PSR-4 Autoloading**: `App\` maps to `app/`, `Config\` maps to `app/Config/`
|
- **PSR-4 Autoloading**: `App\` maps to `app/`, `Config\` maps to `app/Config/`
|
||||||
- **PSR-12 Coding Style** (follow where applicable)
|
- **PSR-12 Coding Style** (follow where applicable)
|
||||||
|
|
||||||
### Naming Conventions
|
### Naming Conventions
|
||||||
|
|
||||||
| Element | Convention | Example |
|
| Element | Convention | Example |
|
||||||
|---------|-----------|---------|
|
|---------|-----------|---------|
|
||||||
| Classes | PascalCase | `PatientController` |
|
| Classes | PascalCase | `PatientController` |
|
||||||
| Methods | camelCase | `createPatient()` |
|
| Methods | camelCase | `createPatient()` |
|
||||||
| Properties | snake_case (legacy) / camelCase (new) | `$patient_id` / `$patientId` |
|
| Properties | snake_case (legacy) / camelCase (new) | `$patient_id` / `$patientId` |
|
||||||
| Constants | UPPER_SNAKE_CASE | `MAX_RETRY_COUNT` |
|
| Constants | UPPER_SNAKE_CASE | `MAX_RETRY_COUNT` |
|
||||||
| Tables | snake_case | `patient_visits` |
|
| Tables | snake_case | `patient_visits` |
|
||||||
| Columns | PascalCase (legacy) | `PatientID`, `NameFirst` |
|
| Columns | PascalCase (legacy) | `PatientID`, `NameFirst` |
|
||||||
| JSON fields | PascalCase | `"PatientID": "123"` |
|
| JSON fields | PascalCase | `"PatientID": "123"` |
|
||||||
|
|
||||||
### Imports & Namespaces
|
### Imports & Namespaces
|
||||||
- Fully qualified namespaces at the top
|
- Fully qualified namespaces at the top
|
||||||
- Group imports: Framework first, then App, then external
|
- Group imports: Framework first, then App, then external
|
||||||
- Alphabetical order within groups
|
- Alphabetical order within groups
|
||||||
|
|
||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use Firebase\JWT\JWT;
|
use Firebase\JWT\JWT;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Controller Structure
|
### Controller Structure
|
||||||
Controllers handle HTTP requests and delegate business logic to Models. They should NOT contain database queries.
|
Controllers handle HTTP requests and delegate business logic to Models. They should NOT contain database queries.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
|
|
||||||
class ExampleController extends Controller
|
class ExampleController extends Controller
|
||||||
{
|
{
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->model = new \App\Models\ExampleModel();
|
$this->model = new \App\Models\ExampleModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$data = $this->model->findAll();
|
$data = $this->model->findAll();
|
||||||
return $this->respond(['status' => 'success', 'data' => $data], 200);
|
return $this->respond(['status' => 'success', 'data' => $data], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$data = $this->request->getJSON(true);
|
$data = $this->request->getJSON(true);
|
||||||
$result = $this->model->createWithRelations($data);
|
$result = $this->model->createWithRelations($data);
|
||||||
return $this->respond(['status' => 'success', 'data' => $result], 201);
|
return $this->respond(['status' => 'success', 'data' => $result], 201);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Response Format
|
### Response Format
|
||||||
All API responses use standardized format:
|
All API responses use standardized format:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// Success
|
// Success
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Operation completed',
|
'message' => 'Operation completed',
|
||||||
'data' => $data
|
'data' => $data
|
||||||
], 200);
|
], 200);
|
||||||
|
|
||||||
// Error
|
// Error
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Error description',
|
'message' => 'Error description',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 400);
|
], 400);
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note**: Custom `ResponseTrait` automatically converts empty strings to `null`.
|
**Note**: Custom `ResponseTrait` automatically converts empty strings to `null`.
|
||||||
|
|
||||||
### Error Handling
|
### Error Handling
|
||||||
- Use try-catch for JWT and external calls
|
- Use try-catch for JWT and external calls
|
||||||
- Log errors: `log_message('error', $message)`
|
- Log errors: `log_message('error', $message)`
|
||||||
- Return structured error responses with appropriate HTTP status codes
|
- Return structured error responses with appropriate HTTP status codes
|
||||||
|
|
||||||
```php
|
```php
|
||||||
try {
|
try {
|
||||||
$decoded = JWT::decode($token, new Key($key, 'HS256'));
|
$decoded = JWT::decode($token, new Key($key, 'HS256'));
|
||||||
} catch (\Firebase\JWT\ExpiredException $e) {
|
} catch (\Firebase\JWT\ExpiredException $e) {
|
||||||
return $this->respond(['status' => 'failed', 'message' => 'Token expired'], 401);
|
return $this->respond(['status' => 'failed', 'message' => 'Token expired'], 401);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->respond(['status' => 'failed', 'message' => 'Invalid token'], 401);
|
return $this->respond(['status' => 'failed', 'message' => 'Invalid token'], 401);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Database Operations
|
### Database Operations
|
||||||
- Use CodeIgniter Query Builder or Model methods
|
- Use CodeIgniter Query Builder or Model methods
|
||||||
- Use `helper('utc')` for UTC date conversion
|
- Use `helper('utc')` for UTC date conversion
|
||||||
- Wrap multi-table operations in transactions
|
- Wrap multi-table operations in transactions
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$this->db->transStart();
|
$this->db->transStart();
|
||||||
// ... database operations
|
// ... database operations
|
||||||
$this->db->transComplete();
|
$this->db->transComplete();
|
||||||
|
|
||||||
if ($this->db->transStatus() === false) {
|
if ($this->db->transStatus() === false) {
|
||||||
return $this->respond(['status' => 'error', 'message' => 'Transaction failed'], 500);
|
return $this->respond(['status' => 'error', 'message' => 'Transaction failed'], 500);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Model Patterns
|
### Model Patterns
|
||||||
- Extend `BaseModel` for automatic UTC date handling
|
- Extend `BaseModel` for automatic UTC date handling
|
||||||
- Use `checkDbError()` for database error detection
|
- Use `checkDbError()` for database error detection
|
||||||
|
|
||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
class PatientModel extends BaseModel
|
class PatientModel extends BaseModel
|
||||||
{
|
{
|
||||||
protected $table = 'patients';
|
protected $table = 'patients';
|
||||||
protected $primaryKey = 'PatientID';
|
protected $primaryKey = 'PatientID';
|
||||||
protected $allowedFields = ['NameFirst', 'NameLast', ...];
|
protected $allowedFields = ['NameFirst', 'NameLast', ...];
|
||||||
|
|
||||||
private function checkDbError($db, string $context) {
|
private function checkDbError($db, string $context) {
|
||||||
$error = $db->error();
|
$error = $db->error();
|
||||||
if (!empty($error['code'])) {
|
if (!empty($error['code'])) {
|
||||||
throw new \Exception("{$context} failed: {$error['code']} - {$error['message']}");
|
throw new \Exception("{$context} failed: {$error['code']} - {$error['message']}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Testing Guidelines
|
### Testing Guidelines
|
||||||
|
|
||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tests\Feature\Patients;
|
namespace Tests\Feature\Patients;
|
||||||
|
|
||||||
use CodeIgniter\Test\FeatureTestTrait;
|
use CodeIgniter\Test\FeatureTestTrait;
|
||||||
use CodeIgniter\Test\CIUnitTestCase;
|
use CodeIgniter\Test\CIUnitTestCase;
|
||||||
use Faker\Factory;
|
use Faker\Factory;
|
||||||
|
|
||||||
class PatientCreateTest extends CIUnitTestCase
|
class PatientCreateTest extends CIUnitTestCase
|
||||||
{
|
{
|
||||||
use FeatureTestTrait;
|
use FeatureTestTrait;
|
||||||
|
|
||||||
protected $endpoint = 'api/patient';
|
protected $endpoint = 'api/patient';
|
||||||
|
|
||||||
public function testCreatePatientSuccess()
|
public function testCreatePatientSuccess()
|
||||||
{
|
{
|
||||||
$faker = Factory::create('id_ID');
|
$faker = Factory::create('id_ID');
|
||||||
$payload = [...];
|
$payload = [...];
|
||||||
$result = $this->withBodyFormat('json')->post($this->endpoint, $payload);
|
$result = $this->withBodyFormat('json')->post($this->endpoint, $payload);
|
||||||
$result->assertStatus(201);
|
$result->assertStatus(201);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Test Naming**: `test<Action><Scenario><ExpectedResult>` (e.g., `testCreatePatientValidationFail`)
|
**Test Naming**: `test<Action><Scenario><ExpectedResult>` (e.g., `testCreatePatientValidationFail`)
|
||||||
|
|
||||||
**Test Status Codes**: 200 (GET/PATCH), 201 (POST), 400 (Validation), 401 (Unauthorized), 404 (Not Found), 500 (Server Error)
|
**Test Status Codes**: 200 (GET/PATCH), 201 (POST), 400 (Validation), 401 (Unauthorized), 404 (Not Found), 500 (Server Error)
|
||||||
|
|
||||||
### API Design
|
### API Design
|
||||||
- **Base URL**: `/api/`
|
- **Base URL**: `/api/`
|
||||||
- **Authentication**: JWT token via HttpOnly cookie
|
- **Authentication**: JWT token via HttpOnly cookie
|
||||||
- **Content-Type**: `application/json`
|
- **Content-Type**: `application/json`
|
||||||
- **Methods**: GET (read), POST (create), PATCH (partial update), DELETE (delete)
|
- **Methods**: GET (read), POST (create), PATCH (partial update), DELETE (delete)
|
||||||
|
|
||||||
### Routes Pattern
|
### Routes Pattern
|
||||||
```php
|
```php
|
||||||
$routes->group('api/patient', function ($routes) {
|
$routes->group('api/patient', function ($routes) {
|
||||||
$routes->get('/', 'Patient\PatientController::index');
|
$routes->get('/', 'Patient\PatientController::index');
|
||||||
$routes->post('/', 'Patient\PatientController::create');
|
$routes->post('/', 'Patient\PatientController::create');
|
||||||
$routes->get('(:num)', 'Patient\PatientController::show/$1');
|
$routes->get('(:num)', 'Patient\PatientController::show/$1');
|
||||||
$routes->patch('/', 'Patient\PatientController::update');
|
$routes->patch('/', 'Patient\PatientController::update');
|
||||||
$routes->delete('/', 'Patient\PatientController::delete');
|
$routes->delete('/', 'Patient\PatientController::delete');
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
- Use `auth` filter for protected routes
|
- Use `auth` filter for protected routes
|
||||||
- Sanitize user inputs
|
- Sanitize user inputs
|
||||||
- Use parameterized queries
|
- Use parameterized queries
|
||||||
- Store secrets in `.env`, never commit
|
- Store secrets in `.env`, never commit
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Project-Specific Conventions
|
## Project-Specific Conventions
|
||||||
|
|
||||||
### API Documentation Sync
|
### API Documentation Sync
|
||||||
**CRITICAL**: When updating any controller, you MUST also update the corresponding OpenAPI YAML documentation:
|
**CRITICAL**: When updating any controller, you MUST also update the corresponding OpenAPI YAML documentation:
|
||||||
|
|
||||||
- **Paths**: `public/paths/<resource>.yaml` (e.g., `patients.yaml`, `orders.yaml`)
|
- **Paths**: `public/paths/<resource>.yaml` (e.g., `patients.yaml`, `orders.yaml`)
|
||||||
- **Schemas**: `public/components/schemas/<resource>.yaml`
|
- **Schemas**: `public/components/schemas/<resource>.yaml`
|
||||||
- **Main file**: `public/api-docs.yaml` (for tags and schema references)
|
- **Main file**: `public/api-docs.yaml` (for tags and schema references)
|
||||||
|
|
||||||
**After updating YAML files**, regenerate the bundled documentation:
|
**After updating YAML files**, regenerate the bundled documentation:
|
||||||
```bash
|
```bash
|
||||||
node public/bundle-api-docs.js
|
node public/bundle-api-docs.js
|
||||||
```
|
```
|
||||||
|
|
||||||
This produces `public/api-docs.bundled.yaml` which is used by Swagger UI/Redoc.
|
This produces `public/api-docs.bundled.yaml` which is used by Swagger UI/Redoc.
|
||||||
|
|
||||||
### Controller-to-YAML Mapping
|
### Controller-to-YAML Mapping
|
||||||
| Controller | YAML Path File | YAML Schema File |
|
| Controller | YAML Path File | YAML Schema File |
|
||||||
|-----------|----------------|------------------|
|
|-----------|----------------|------------------|
|
||||||
| `PatientController` | `paths/patients.yaml` | `components/schemas/patient.yaml` |
|
| `PatientController` | `paths/patients.yaml` | `components/schemas/patient.yaml` |
|
||||||
| `PatVisitController` | `paths/patient-visits.yaml` | `components/schemas/patient-visit.yaml` |
|
| `PatVisitController` | `paths/patient-visits.yaml` | `components/schemas/patient-visit.yaml` |
|
||||||
| `OrderTestController` | `paths/orders.yaml` | `components/schemas/orders.yaml` |
|
| `OrderTestController` | `paths/orders.yaml` | `components/schemas/orders.yaml` |
|
||||||
| `SpecimenController` | `paths/specimen.yaml` | `components/schemas/specimen.yaml` |
|
| `SpecimenController` | `paths/specimen.yaml` | `components/schemas/specimen.yaml` |
|
||||||
| `TestsController` | `paths/tests.yaml` | `components/schemas/tests.yaml` |
|
| `TestsController` | `paths/tests.yaml` | `components/schemas/tests.yaml` |
|
||||||
| `AuthController` | `paths/authentication.yaml` | `components/schemas/authentication.yaml` |
|
| `AuthController` | `paths/authentication.yaml` | `components/schemas/authentication.yaml` |
|
||||||
| `ResultController` | `paths/results.yaml` | `components/schemas/*.yaml` |
|
| `ResultController` | `paths/results.yaml` | `components/schemas/*.yaml` |
|
||||||
| `EdgeController` | `paths/edge-api.yaml` | `components/schemas/edge-api.yaml` |
|
| `EdgeController` | `paths/edge-api.yaml` | `components/schemas/edge-api.yaml` |
|
||||||
| `LocationController` | `paths/locations.yaml` | `components/schemas/master-data.yaml` |
|
| `LocationController` | `paths/locations.yaml` | `components/schemas/master-data.yaml` |
|
||||||
| `ValueSetController` | `paths/valuesets.yaml` | `components/schemas/valuesets.yaml` |
|
| `ValueSetController` | `paths/valuesets.yaml` | `components/schemas/valuesets.yaml` |
|
||||||
| `ContactController` | `paths/contact.yaml` | (inline schemas) |
|
| `ContactController` | `paths/contact.yaml` | (inline schemas) |
|
||||||
|
|
||||||
### Legacy Field Naming
|
### Legacy Field Naming
|
||||||
Database uses PascalCase columns: `PatientID`, `NameFirst`, `Birthdate`, `CreatedAt`, `UpdatedAt`
|
Database uses PascalCase columns: `PatientID`, `NameFirst`, `Birthdate`, `CreatedAt`, `UpdatedAt`
|
||||||
|
|
||||||
### ValueSet System
|
### ValueSet System
|
||||||
```php
|
```php
|
||||||
use App\Libraries\Lookups;
|
use App\Libraries\Lookups;
|
||||||
|
|
||||||
$genders = Lookups::get('gender');
|
$genders = Lookups::get('gender');
|
||||||
$label = Lookups::getLabel('gender', '1'); // Returns 'Female'
|
$label = Lookups::getLabel('gender', '1'); // Returns 'Female'
|
||||||
$options = Lookups::getOptions('gender');
|
$options = Lookups::getOptions('gender');
|
||||||
$labeled = Lookups::transformLabels($data, ['Sex' => 'gender']);
|
$labeled = Lookups::transformLabels($data, ['Sex' => 'gender']);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Nested Data Handling
|
### Nested Data Handling
|
||||||
For entities with nested data (PatIdt, PatCom, PatAtt):
|
For entities with nested data (PatIdt, PatCom, PatAtt):
|
||||||
- Extract nested arrays before filtering
|
- Extract nested arrays before filtering
|
||||||
- Use transactions for multi-table operations
|
- Use transactions for multi-table operations
|
||||||
- Handle empty/null arrays appropriately
|
- Handle empty/null arrays appropriately
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Environment Configuration
|
## Environment Configuration
|
||||||
|
|
||||||
### Database (`.env`)
|
### Database (`.env`)
|
||||||
```ini
|
```ini
|
||||||
database.default.hostname = localhost
|
database.default.hostname = localhost
|
||||||
database.default.database = clqms01
|
database.default.database = clqms01
|
||||||
database.default.username = root
|
database.default.username = root
|
||||||
database.default.password = adminsakti
|
database.default.password = adminsakti
|
||||||
database.default.DBDriver = MySQLi
|
database.default.DBDriver = MySQLi
|
||||||
```
|
```
|
||||||
|
|
||||||
### JWT Secret (`.env`)
|
### JWT Secret (`.env`)
|
||||||
```ini
|
```ini
|
||||||
JWT_SECRET = '5pandaNdutNdut'
|
JWT_SECRET = '5pandaNdutNdut'
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Additional Notes
|
## Additional Notes
|
||||||
|
|
||||||
- **API-Only**: No view layer - headless REST API
|
- **API-Only**: No view layer - headless REST API
|
||||||
- **Frontend Agnostic**: Any client can consume these APIs
|
- **Frontend Agnostic**: Any client can consume these APIs
|
||||||
- **Stateless**: JWT-based authentication per request
|
- **Stateless**: JWT-based authentication per request
|
||||||
- **UTC Dates**: All dates stored in UTC, converted for display
|
- **UTC Dates**: All dates stored in UTC, converted for display
|
||||||
|
|
||||||
*© 2025 5Panda Team. Engineering Precision in Clinical Diagnostics.*
|
*© 2025 5Panda Team. Engineering Precision in Clinical Diagnostics.*
|
||||||
|
|||||||
44
LICENSE
44
LICENSE
@ -1,22 +1,22 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2014-2019 British Columbia Institute of Technology
|
Copyright (c) 2014-2019 British Columbia Institute of Technology
|
||||||
Copyright (c) 2019-present CodeIgniter Foundation
|
Copyright (c) 2019-present CodeIgniter Foundation
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<IfModule authz_core_module>
|
<IfModule authz_core_module>
|
||||||
Require all denied
|
Require all denied
|
||||||
</IfModule>
|
</IfModule>
|
||||||
<IfModule !authz_core_module>
|
<IfModule !authz_core_module>
|
||||||
Deny from all
|
Deny from all
|
||||||
</IfModule>
|
</IfModule>
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The goal of this file is to allow developers a location
|
* The goal of this file is to allow developers a location
|
||||||
* where they can overwrite core procedural functions and
|
* where they can overwrite core procedural functions and
|
||||||
* replace them with their own. This file is loaded during
|
* replace them with their own. This file is loaded during
|
||||||
* the bootstrap process and is called during the framework's
|
* the bootstrap process and is called during the framework's
|
||||||
* execution.
|
* execution.
|
||||||
*
|
*
|
||||||
* This can be looked at as a `master helper` file that is
|
* This can be looked at as a `master helper` file that is
|
||||||
* loaded early on, and may also contain additional functions
|
* loaded early on, and may also contain additional functions
|
||||||
* that you'd like to use throughout your entire application
|
* that you'd like to use throughout your entire application
|
||||||
*
|
*
|
||||||
* @see: https://codeigniter.com/user_guide/extending/common.html
|
* @see: https://codeigniter.com/user_guide/extending/common.html
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,203 +1,203 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
class App extends BaseConfig
|
class App extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Base Site URL
|
* Base Site URL
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* URL to your CodeIgniter root. Typically, this will be your base URL,
|
* URL to your CodeIgniter root. Typically, this will be your base URL,
|
||||||
* WITH a trailing slash:
|
* WITH a trailing slash:
|
||||||
*
|
*
|
||||||
* E.g., http://example.com/
|
* E.g., http://example.com/
|
||||||
*/
|
*/
|
||||||
public string $baseURL = '';
|
public string $baseURL = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allowed Hostnames in the Site URL other than the hostname in the baseURL.
|
* Allowed Hostnames in the Site URL other than the hostname in the baseURL.
|
||||||
* If you want to accept multiple Hostnames, set this.
|
* If you want to accept multiple Hostnames, set this.
|
||||||
*
|
*
|
||||||
* E.g.,
|
* E.g.,
|
||||||
* When your site URL ($baseURL) is 'http://example.com/', and your site
|
* When your site URL ($baseURL) is 'http://example.com/', and your site
|
||||||
* also accepts 'http://media.example.com/' and 'http://accounts.example.com/':
|
* also accepts 'http://media.example.com/' and 'http://accounts.example.com/':
|
||||||
* ['media.example.com', 'accounts.example.com']
|
* ['media.example.com', 'accounts.example.com']
|
||||||
*
|
*
|
||||||
* @var list<string>
|
* @var list<string>
|
||||||
*/
|
*/
|
||||||
public array $allowedHostnames = [];
|
public array $allowedHostnames = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Index File
|
* Index File
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Typically, this will be your `index.php` file, unless you've renamed it to
|
* 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
|
* something else. If you have configured your web server to remove this file
|
||||||
* from your site URIs, set this variable to an empty string.
|
* from your site URIs, set this variable to an empty string.
|
||||||
*/
|
*/
|
||||||
#public string $indexPage = 'index.php';
|
#public string $indexPage = 'index.php';
|
||||||
public string $indexPage = '';
|
public string $indexPage = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* URI PROTOCOL
|
* URI PROTOCOL
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This item determines which server global should be used to retrieve the
|
* This item determines which server global should be used to retrieve the
|
||||||
* URI string. The default setting of 'REQUEST_URI' works for most servers.
|
* 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:
|
* If your links do not seem to work, try one of the other delicious flavors:
|
||||||
*
|
*
|
||||||
* 'REQUEST_URI': Uses $_SERVER['REQUEST_URI']
|
* 'REQUEST_URI': Uses $_SERVER['REQUEST_URI']
|
||||||
* 'QUERY_STRING': Uses $_SERVER['QUERY_STRING']
|
* 'QUERY_STRING': Uses $_SERVER['QUERY_STRING']
|
||||||
* 'PATH_INFO': Uses $_SERVER['PATH_INFO']
|
* 'PATH_INFO': Uses $_SERVER['PATH_INFO']
|
||||||
*
|
*
|
||||||
* WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
|
* WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
|
||||||
*/
|
*/
|
||||||
public string $uriProtocol = 'REQUEST_URI';
|
public string $uriProtocol = 'REQUEST_URI';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Allowed URL Characters
|
| Allowed URL Characters
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| This lets you specify which characters are permitted within your URLs.
|
| This lets you specify which characters are permitted within your URLs.
|
||||||
| When someone tries to submit a URL with disallowed characters they will
|
| When someone tries to submit a URL with disallowed characters they will
|
||||||
| get a warning message.
|
| get a warning message.
|
||||||
|
|
|
|
||||||
| As a security measure you are STRONGLY encouraged to restrict URLs to
|
| As a security measure you are STRONGLY encouraged to restrict URLs to
|
||||||
| as few characters as possible.
|
| as few characters as possible.
|
||||||
|
|
|
|
||||||
| By default, only these are allowed: `a-z 0-9~%.:_-`
|
| By default, only these are allowed: `a-z 0-9~%.:_-`
|
||||||
|
|
|
|
||||||
| Set an empty string to allow all characters -- but only if you are insane.
|
| Set an empty string to allow all characters -- but only if you are insane.
|
||||||
|
|
|
|
||||||
| The configured value is actually a regular expression character group
|
| The configured value is actually a regular expression character group
|
||||||
| and it will be used as: '/\A[<permittedURIChars>]+\z/iu'
|
| and it will be used as: '/\A[<permittedURIChars>]+\z/iu'
|
||||||
|
|
|
|
||||||
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
public string $permittedURIChars = 'a-z 0-9~%.:_\-';
|
public string $permittedURIChars = 'a-z 0-9~%.:_\-';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Default Locale
|
* Default Locale
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* The Locale roughly represents the language and location that your visitor
|
* The Locale roughly represents the language and location that your visitor
|
||||||
* is viewing the site from. It affects the language strings and other
|
* is viewing the site from. It affects the language strings and other
|
||||||
* strings (like currency markers, numbers, etc), that your program
|
* strings (like currency markers, numbers, etc), that your program
|
||||||
* should run under for this request.
|
* should run under for this request.
|
||||||
*/
|
*/
|
||||||
public string $defaultLocale = 'en';
|
public string $defaultLocale = 'en';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Negotiate Locale
|
* Negotiate Locale
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* If true, the current Request object will automatically determine the
|
* If true, the current Request object will automatically determine the
|
||||||
* language to use based on the value of the Accept-Language header.
|
* language to use based on the value of the Accept-Language header.
|
||||||
*
|
*
|
||||||
* If false, no automatic detection will be performed.
|
* If false, no automatic detection will be performed.
|
||||||
*/
|
*/
|
||||||
public bool $negotiateLocale = false;
|
public bool $negotiateLocale = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Supported Locales
|
* Supported Locales
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* If $negotiateLocale is true, this array lists the locales supported
|
* If $negotiateLocale is true, this array lists the locales supported
|
||||||
* by the application in descending order of priority. If no match is
|
* by the application in descending order of priority. If no match is
|
||||||
* found, the first locale will be used.
|
* found, the first locale will be used.
|
||||||
*
|
*
|
||||||
* IncomingRequest::setLocale() also uses this list.
|
* IncomingRequest::setLocale() also uses this list.
|
||||||
*
|
*
|
||||||
* @var list<string>
|
* @var list<string>
|
||||||
*/
|
*/
|
||||||
public array $supportedLocales = ['en'];
|
public array $supportedLocales = ['en'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Application Timezone
|
* Application Timezone
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* The default timezone that will be used in your application to display
|
* The default timezone that will be used in your application to display
|
||||||
* dates with the date helper, and can be retrieved through app_timezone()
|
* 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
|
* @see https://www.php.net/manual/en/timezones.php for list of timezones
|
||||||
* supported by PHP.
|
* supported by PHP.
|
||||||
*/
|
*/
|
||||||
public string $appTimezone = 'UTC';
|
public string $appTimezone = 'UTC';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Default Character Set
|
* Default Character Set
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This determines which character set is used by default in various methods
|
* This determines which character set is used by default in various methods
|
||||||
* that require a character set to be provided.
|
* that require a character set to be provided.
|
||||||
*
|
*
|
||||||
* @see http://php.net/htmlspecialchars for a list of supported charsets.
|
* @see http://php.net/htmlspecialchars for a list of supported charsets.
|
||||||
*/
|
*/
|
||||||
public string $charset = 'UTF-8';
|
public string $charset = 'UTF-8';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Force Global Secure Requests
|
* Force Global Secure Requests
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* If true, this will force every request made to this application to be
|
* 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
|
* 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
|
* secure, the user will be redirected to a secure version of the page
|
||||||
* and the HTTP Strict Transport Security (HSTS) header will be set.
|
* and the HTTP Strict Transport Security (HSTS) header will be set.
|
||||||
*/
|
*/
|
||||||
public bool $forceGlobalSecureRequests = false;
|
public bool $forceGlobalSecureRequests = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Reverse Proxy IPs
|
* Reverse Proxy IPs
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* If your server is behind a reverse proxy, you must whitelist the proxy
|
* If your server is behind a reverse proxy, you must whitelist the proxy
|
||||||
* IP addresses from which CodeIgniter should trust headers such as
|
* IP addresses from which CodeIgniter should trust headers such as
|
||||||
* X-Forwarded-For or Client-IP in order to properly identify
|
* X-Forwarded-For or Client-IP in order to properly identify
|
||||||
* the visitor's IP address.
|
* the visitor's IP address.
|
||||||
*
|
*
|
||||||
* You need to set a proxy IP address or IP address with subnets and
|
* You need to set a proxy IP address or IP address with subnets and
|
||||||
* the HTTP header for the client IP address.
|
* the HTTP header for the client IP address.
|
||||||
*
|
*
|
||||||
* Here are some examples:
|
* Here are some examples:
|
||||||
* [
|
* [
|
||||||
* '10.0.1.200' => 'X-Forwarded-For',
|
* '10.0.1.200' => 'X-Forwarded-For',
|
||||||
* '192.168.5.0/24' => 'X-Real-IP',
|
* '192.168.5.0/24' => 'X-Real-IP',
|
||||||
* ]
|
* ]
|
||||||
*
|
*
|
||||||
* @var array<string, string>
|
* @var array<string, string>
|
||||||
*/
|
*/
|
||||||
public array $proxyIPs = [];
|
public array $proxyIPs = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Content Security Policy
|
* Content Security Policy
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Enables the Response's Content Secure Policy to restrict the sources that
|
* 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,
|
* 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
|
* the Response object will populate default values for the policy from the
|
||||||
* `ContentSecurityPolicy.php` file. Controllers can always add to those
|
* `ContentSecurityPolicy.php` file. Controllers can always add to those
|
||||||
* restrictions at run time.
|
* restrictions at run time.
|
||||||
*
|
*
|
||||||
* For a better understanding of CSP, see these documents:
|
* For a better understanding of CSP, see these documents:
|
||||||
*
|
*
|
||||||
* @see http://www.html5rocks.com/en/tutorials/security/content-security-policy/
|
* @see http://www.html5rocks.com/en/tutorials/security/content-security-policy/
|
||||||
* @see http://www.w3.org/TR/CSP/
|
* @see http://www.w3.org/TR/CSP/
|
||||||
*/
|
*/
|
||||||
public bool $CSPEnabled = false;
|
public bool $CSPEnabled = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,92 +1,92 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\AutoloadConfig;
|
use CodeIgniter\Config\AutoloadConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
* AUTOLOADER CONFIGURATION
|
* AUTOLOADER CONFIGURATION
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This file defines the namespaces and class maps so the Autoloader
|
* This file defines the namespaces and class maps so the Autoloader
|
||||||
* can find the files as needed.
|
* can find the files as needed.
|
||||||
*
|
*
|
||||||
* NOTE: If you use an identical key in $psr4 or $classmap, then
|
* NOTE: If you use an identical key in $psr4 or $classmap, then
|
||||||
* the values in this file will overwrite the framework's values.
|
* the values in this file will overwrite the framework's values.
|
||||||
*
|
*
|
||||||
* NOTE: This class is required prior to Autoloader instantiation,
|
* NOTE: This class is required prior to Autoloader instantiation,
|
||||||
* and does not extend BaseConfig.
|
* and does not extend BaseConfig.
|
||||||
*/
|
*/
|
||||||
class Autoload extends AutoloadConfig
|
class Autoload extends AutoloadConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
* Namespaces
|
* Namespaces
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
* This maps the locations of any namespaces in your application to
|
* This maps the locations of any namespaces in your application to
|
||||||
* their location on the file system. These are used by the autoloader
|
* their location on the file system. These are used by the autoloader
|
||||||
* to locate files the first time they have been instantiated.
|
* to locate files the first time they have been instantiated.
|
||||||
*
|
*
|
||||||
* The 'Config' (APPPATH . 'Config') and 'CodeIgniter' (SYSTEMPATH) are
|
* The 'Config' (APPPATH . 'Config') and 'CodeIgniter' (SYSTEMPATH) are
|
||||||
* already mapped for you.
|
* already mapped for you.
|
||||||
*
|
*
|
||||||
* You may change the name of the 'App' namespace if you wish,
|
* You may change the name of the 'App' namespace if you wish,
|
||||||
* but this should be done prior to creating any namespaced classes,
|
* 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.
|
* else you will need to modify all of those classes for this to work.
|
||||||
*
|
*
|
||||||
* @var array<string, list<string>|string>
|
* @var array<string, list<string>|string>
|
||||||
*/
|
*/
|
||||||
public $psr4 = [
|
public $psr4 = [
|
||||||
APP_NAMESPACE => APPPATH,
|
APP_NAMESPACE => APPPATH,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
* Class Map
|
* Class Map
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
* The class map provides a map of class names and their exact
|
* The class map provides a map of class names and their exact
|
||||||
* location on the drive. Classes loaded in this manner will have
|
* location on the drive. Classes loaded in this manner will have
|
||||||
* slightly faster performance because they will not have to be
|
* slightly faster performance because they will not have to be
|
||||||
* searched for within one or more directories as they would if they
|
* searched for within one or more directories as they would if they
|
||||||
* were being autoloaded through a namespace.
|
* were being autoloaded through a namespace.
|
||||||
*
|
*
|
||||||
* Prototype:
|
* Prototype:
|
||||||
* $classmap = [
|
* $classmap = [
|
||||||
* 'MyClass' => '/path/to/class/file.php'
|
* 'MyClass' => '/path/to/class/file.php'
|
||||||
* ];
|
* ];
|
||||||
*
|
*
|
||||||
* @var array<string, string>
|
* @var array<string, string>
|
||||||
*/
|
*/
|
||||||
public $classmap = [];
|
public $classmap = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
* Files
|
* Files
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
* The files array provides a list of paths to __non-class__ files
|
* The files array provides a list of paths to __non-class__ files
|
||||||
* that will be autoloaded. This can be useful for bootstrap operations
|
* that will be autoloaded. This can be useful for bootstrap operations
|
||||||
* or for loading functions.
|
* or for loading functions.
|
||||||
*
|
*
|
||||||
* Prototype:
|
* Prototype:
|
||||||
* $files = [
|
* $files = [
|
||||||
* '/path/to/my/file.php',
|
* '/path/to/my/file.php',
|
||||||
* ];
|
* ];
|
||||||
*
|
*
|
||||||
* @var list<string>
|
* @var list<string>
|
||||||
*/
|
*/
|
||||||
public $files = [];
|
public $files = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
* Helpers
|
* Helpers
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
* Prototype:
|
* Prototype:
|
||||||
* $helpers = [
|
* $helpers = [
|
||||||
* 'form',
|
* 'form',
|
||||||
* ];
|
* ];
|
||||||
*
|
*
|
||||||
* @var list<string>
|
* @var list<string>
|
||||||
*/
|
*/
|
||||||
public $helpers = [];
|
public $helpers = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,34 +1,34 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| ERROR DISPLAY
|
| ERROR DISPLAY
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| In development, we want to show as many errors as possible to help
|
| 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
|
| make sure they don't make it to production. And save us hours of
|
||||||
| painful debugging.
|
| painful debugging.
|
||||||
|
|
|
|
||||||
| If you set 'display_errors' to '1', CI4's detailed error report will show.
|
| If you set 'display_errors' to '1', CI4's detailed error report will show.
|
||||||
*/
|
*/
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
ini_set('display_errors', '1');
|
ini_set('display_errors', '1');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| DEBUG BACKTRACES
|
| DEBUG BACKTRACES
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| If true, this constant will tell the error screens to display debug
|
| If true, this constant will tell the error screens to display debug
|
||||||
| backtraces along with the other error information. If you would
|
| backtraces along with the other error information. If you would
|
||||||
| prefer to not see this, set this value to false.
|
| prefer to not see this, set this value to false.
|
||||||
*/
|
*/
|
||||||
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
|
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| DEBUG MODE
|
| DEBUG MODE
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Debug mode is an experimental flag that can allow changes throughout
|
| Debug mode is an experimental flag that can allow changes throughout
|
||||||
| the system. This will control whether Kint is loaded, and a few other
|
| the system. This will control whether Kint is loaded, and a few other
|
||||||
| items. It can always be used within your own application too.
|
| items. It can always be used within your own application too.
|
||||||
*/
|
*/
|
||||||
defined('CI_DEBUG') || define('CI_DEBUG', true);
|
defined('CI_DEBUG') || define('CI_DEBUG', true);
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| ERROR DISPLAY
|
| ERROR DISPLAY
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Don't show ANY in production environments. Instead, let the system catch
|
| Don't show ANY in production environments. Instead, let the system catch
|
||||||
| it and display a generic error message.
|
| it and display a generic error message.
|
||||||
|
|
|
|
||||||
| If you set 'display_errors' to '1', CI4's detailed error report will show.
|
| If you set 'display_errors' to '1', CI4's detailed error report will show.
|
||||||
*/
|
*/
|
||||||
error_reporting(E_ALL & ~E_DEPRECATED);
|
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||||
// If you want to suppress more types of errors.
|
// 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);
|
// error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
|
||||||
ini_set('display_errors', '0');
|
ini_set('display_errors', '0');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| DEBUG MODE
|
| DEBUG MODE
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Debug mode is an experimental flag that can allow changes throughout
|
| Debug mode is an experimental flag that can allow changes throughout
|
||||||
| the system. It's not widely used currently, and may not survive
|
| the system. It's not widely used currently, and may not survive
|
||||||
| release of the framework.
|
| release of the framework.
|
||||||
*/
|
*/
|
||||||
defined('CI_DEBUG') || define('CI_DEBUG', false);
|
defined('CI_DEBUG') || define('CI_DEBUG', false);
|
||||||
|
|||||||
@ -1,38 +1,38 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The environment testing is reserved for PHPUnit testing. It has special
|
* The environment testing is reserved for PHPUnit testing. It has special
|
||||||
* conditions built into the framework at various places to assist with that.
|
* conditions built into the framework at various places to assist with that.
|
||||||
* You can’t use it for your development.
|
* You can’t use it for your development.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| ERROR DISPLAY
|
| ERROR DISPLAY
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| In development, we want to show as many errors as possible to help
|
| 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
|
| make sure they don't make it to production. And save us hours of
|
||||||
| painful debugging.
|
| painful debugging.
|
||||||
*/
|
*/
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
ini_set('display_errors', '1');
|
ini_set('display_errors', '1');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| DEBUG BACKTRACES
|
| DEBUG BACKTRACES
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| If true, this constant will tell the error screens to display debug
|
| If true, this constant will tell the error screens to display debug
|
||||||
| backtraces along with the other error information. If you would
|
| backtraces along with the other error information. If you would
|
||||||
| prefer to not see this, set this value to false.
|
| prefer to not see this, set this value to false.
|
||||||
*/
|
*/
|
||||||
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
|
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| DEBUG MODE
|
| DEBUG MODE
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Debug mode is an experimental flag that can allow changes throughout
|
| Debug mode is an experimental flag that can allow changes throughout
|
||||||
| the system. It's not widely used currently, and may not survive
|
| the system. It's not widely used currently, and may not survive
|
||||||
| release of the framework.
|
| release of the framework.
|
||||||
*/
|
*/
|
||||||
defined('CI_DEBUG') || define('CI_DEBUG', true);
|
defined('CI_DEBUG') || define('CI_DEBUG', true);
|
||||||
|
|||||||
@ -1,20 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
class CURLRequest extends BaseConfig
|
class CURLRequest extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* CURLRequest Share Options
|
* CURLRequest Share Options
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Whether share options between requests or not.
|
* Whether share options between requests or not.
|
||||||
*
|
*
|
||||||
* If true, all the options won't be reset between requests.
|
* If true, all the options won't be reset between requests.
|
||||||
* It may cause an error request with unnecessary headers.
|
* It may cause an error request with unnecessary headers.
|
||||||
*/
|
*/
|
||||||
public bool $shareOptions = false;
|
public bool $shareOptions = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,162 +1,162 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Cache\CacheInterface;
|
use CodeIgniter\Cache\CacheInterface;
|
||||||
use CodeIgniter\Cache\Handlers\DummyHandler;
|
use CodeIgniter\Cache\Handlers\DummyHandler;
|
||||||
use CodeIgniter\Cache\Handlers\FileHandler;
|
use CodeIgniter\Cache\Handlers\FileHandler;
|
||||||
use CodeIgniter\Cache\Handlers\MemcachedHandler;
|
use CodeIgniter\Cache\Handlers\MemcachedHandler;
|
||||||
use CodeIgniter\Cache\Handlers\PredisHandler;
|
use CodeIgniter\Cache\Handlers\PredisHandler;
|
||||||
use CodeIgniter\Cache\Handlers\RedisHandler;
|
use CodeIgniter\Cache\Handlers\RedisHandler;
|
||||||
use CodeIgniter\Cache\Handlers\WincacheHandler;
|
use CodeIgniter\Cache\Handlers\WincacheHandler;
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
class Cache extends BaseConfig
|
class Cache extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Primary Handler
|
* Primary Handler
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* The name of the preferred handler that should be used. If for some reason
|
* 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.
|
* it is not available, the $backupHandler will be used in its place.
|
||||||
*/
|
*/
|
||||||
public string $handler = 'file';
|
public string $handler = 'file';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Backup Handler
|
* Backup Handler
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* The name of the handler that will be used in case the first one is
|
* 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
|
* unreachable. Often, 'file' is used here since the filesystem is
|
||||||
* always available, though that's not always practical for the app.
|
* always available, though that's not always practical for the app.
|
||||||
*/
|
*/
|
||||||
public string $backupHandler = 'dummy';
|
public string $backupHandler = 'dummy';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Key Prefix
|
* Key Prefix
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This string is added to all cache item names to help avoid collisions
|
* This string is added to all cache item names to help avoid collisions
|
||||||
* if you run multiple applications with the same cache engine.
|
* if you run multiple applications with the same cache engine.
|
||||||
*/
|
*/
|
||||||
public string $prefix = '';
|
public string $prefix = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Default TTL
|
* Default TTL
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* The default number of seconds to save items when none is specified.
|
* The default number of seconds to save items when none is specified.
|
||||||
*
|
*
|
||||||
* WARNING: This is not used by framework handlers where 60 seconds is
|
* 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
|
* hard-coded, but may be useful to projects and modules. This will replace
|
||||||
* the hard-coded value in a future release.
|
* the hard-coded value in a future release.
|
||||||
*/
|
*/
|
||||||
public int $ttl = 60;
|
public int $ttl = 60;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Reserved Characters
|
* Reserved Characters
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* A string of reserved characters that will not be allowed in keys or tags.
|
* A string of reserved characters that will not be allowed in keys or tags.
|
||||||
* Strings that violate this restriction will cause handlers to throw.
|
* Strings that violate this restriction will cause handlers to throw.
|
||||||
* Default: {}()/\@:
|
* Default: {}()/\@:
|
||||||
*
|
*
|
||||||
* NOTE: The default set is required for PSR-6 compliance.
|
* NOTE: The default set is required for PSR-6 compliance.
|
||||||
*/
|
*/
|
||||||
public string $reservedCharacters = '{}()/\@:';
|
public string $reservedCharacters = '{}()/\@:';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* File settings
|
* File settings
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Your file storage preferences can be specified below, if you are using
|
* Your file storage preferences can be specified below, if you are using
|
||||||
* the File driver.
|
* the File driver.
|
||||||
*
|
*
|
||||||
* @var array<string, int|string|null>
|
* @var array<string, int|string|null>
|
||||||
*/
|
*/
|
||||||
public array $file = [
|
public array $file = [
|
||||||
'storePath' => WRITEPATH . 'cache/',
|
'storePath' => WRITEPATH . 'cache/',
|
||||||
'mode' => 0640,
|
'mode' => 0640,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
* Memcached settings
|
* Memcached settings
|
||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Your Memcached servers can be specified below, if you are using
|
* Your Memcached servers can be specified below, if you are using
|
||||||
* the Memcached drivers.
|
* the Memcached drivers.
|
||||||
*
|
*
|
||||||
* @see https://codeigniter.com/user_guide/libraries/caching.html#memcached
|
* @see https://codeigniter.com/user_guide/libraries/caching.html#memcached
|
||||||
*
|
*
|
||||||
* @var array<string, bool|int|string>
|
* @var array<string, bool|int|string>
|
||||||
*/
|
*/
|
||||||
public array $memcached = [
|
public array $memcached = [
|
||||||
'host' => '127.0.0.1',
|
'host' => '127.0.0.1',
|
||||||
'port' => 11211,
|
'port' => 11211,
|
||||||
'weight' => 1,
|
'weight' => 1,
|
||||||
'raw' => false,
|
'raw' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
* Redis settings
|
* Redis settings
|
||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Your Redis server can be specified below, if you are using
|
* Your Redis server can be specified below, if you are using
|
||||||
* the Redis or Predis drivers.
|
* the Redis or Predis drivers.
|
||||||
*
|
*
|
||||||
* @var array<string, int|string|null>
|
* @var array<string, int|string|null>
|
||||||
*/
|
*/
|
||||||
public array $redis = [
|
public array $redis = [
|
||||||
'host' => '127.0.0.1',
|
'host' => '127.0.0.1',
|
||||||
'password' => null,
|
'password' => null,
|
||||||
'port' => 6379,
|
'port' => 6379,
|
||||||
'timeout' => 0,
|
'timeout' => 0,
|
||||||
'database' => 0,
|
'database' => 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Available Cache Handlers
|
* Available Cache Handlers
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This is an array of cache engine alias' and class names. Only engines
|
* This is an array of cache engine alias' and class names. Only engines
|
||||||
* that are listed here are allowed to be used.
|
* that are listed here are allowed to be used.
|
||||||
*
|
*
|
||||||
* @var array<string, class-string<CacheInterface>>
|
* @var array<string, class-string<CacheInterface>>
|
||||||
*/
|
*/
|
||||||
public array $validHandlers = [
|
public array $validHandlers = [
|
||||||
'dummy' => DummyHandler::class,
|
'dummy' => DummyHandler::class,
|
||||||
'file' => FileHandler::class,
|
'file' => FileHandler::class,
|
||||||
'memcached' => MemcachedHandler::class,
|
'memcached' => MemcachedHandler::class,
|
||||||
'predis' => PredisHandler::class,
|
'predis' => PredisHandler::class,
|
||||||
'redis' => RedisHandler::class,
|
'redis' => RedisHandler::class,
|
||||||
'wincache' => WincacheHandler::class,
|
'wincache' => WincacheHandler::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Web Page Caching: Cache Include Query String
|
* Web Page Caching: Cache Include Query String
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Whether to take the URL query string into consideration when generating
|
* Whether to take the URL query string into consideration when generating
|
||||||
* output cache files. Valid options are:
|
* output cache files. Valid options are:
|
||||||
*
|
*
|
||||||
* false = Disabled
|
* false = Disabled
|
||||||
* true = Enabled, take all query parameters into account.
|
* true = Enabled, take all query parameters into account.
|
||||||
* Please be aware that this may result in numerous cache
|
* Please be aware that this may result in numerous cache
|
||||||
* files generated for the same page over and over again.
|
* files generated for the same page over and over again.
|
||||||
* ['q'] = Enabled, but only take into account the specified list
|
* ['q'] = Enabled, but only take into account the specified list
|
||||||
* of query parameters.
|
* of query parameters.
|
||||||
*
|
*
|
||||||
* @var bool|list<string>
|
* @var bool|list<string>
|
||||||
*/
|
*/
|
||||||
public $cacheQueryString = false;
|
public $cacheQueryString = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,79 +1,79 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
| --------------------------------------------------------------------
|
| --------------------------------------------------------------------
|
||||||
| App Namespace
|
| App Namespace
|
||||||
| --------------------------------------------------------------------
|
| --------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| This defines the default Namespace that is used throughout
|
| This defines the default Namespace that is used throughout
|
||||||
| CodeIgniter to refer to the Application directory. Change
|
| CodeIgniter to refer to the Application directory. Change
|
||||||
| this constant to change the namespace that all application
|
| this constant to change the namespace that all application
|
||||||
| classes should use.
|
| classes should use.
|
||||||
|
|
|
|
||||||
| NOTE: changing this will require manually modifying the
|
| NOTE: changing this will require manually modifying the
|
||||||
| existing namespaces of App\* namespaced-classes.
|
| existing namespaces of App\* namespaced-classes.
|
||||||
*/
|
*/
|
||||||
defined('APP_NAMESPACE') || define('APP_NAMESPACE', 'App');
|
defined('APP_NAMESPACE') || define('APP_NAMESPACE', 'App');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
| --------------------------------------------------------------------------
|
| --------------------------------------------------------------------------
|
||||||
| Composer Path
|
| Composer Path
|
||||||
| --------------------------------------------------------------------------
|
| --------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| The path that Composer's autoload file is expected to live. By default,
|
| 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.
|
| the vendor folder is in the Root directory, but you can customize that here.
|
||||||
*/
|
*/
|
||||||
defined('COMPOSER_PATH') || define('COMPOSER_PATH', ROOTPATH . 'vendor/autoload.php');
|
defined('COMPOSER_PATH') || define('COMPOSER_PATH', ROOTPATH . 'vendor/autoload.php');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Timing Constants
|
| Timing Constants
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| Provide simple ways to work with the myriad of PHP functions that
|
| Provide simple ways to work with the myriad of PHP functions that
|
||||||
| require information to be in seconds.
|
| require information to be in seconds.
|
||||||
*/
|
*/
|
||||||
defined('SECOND') || define('SECOND', 1);
|
defined('SECOND') || define('SECOND', 1);
|
||||||
defined('MINUTE') || define('MINUTE', 60);
|
defined('MINUTE') || define('MINUTE', 60);
|
||||||
defined('HOUR') || define('HOUR', 3600);
|
defined('HOUR') || define('HOUR', 3600);
|
||||||
defined('DAY') || define('DAY', 86400);
|
defined('DAY') || define('DAY', 86400);
|
||||||
defined('WEEK') || define('WEEK', 604800);
|
defined('WEEK') || define('WEEK', 604800);
|
||||||
defined('MONTH') || define('MONTH', 2_592_000);
|
defined('MONTH') || define('MONTH', 2_592_000);
|
||||||
defined('YEAR') || define('YEAR', 31_536_000);
|
defined('YEAR') || define('YEAR', 31_536_000);
|
||||||
defined('DECADE') || define('DECADE', 315_360_000);
|
defined('DECADE') || define('DECADE', 315_360_000);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
| --------------------------------------------------------------------------
|
| --------------------------------------------------------------------------
|
||||||
| Exit Status Codes
|
| Exit Status Codes
|
||||||
| --------------------------------------------------------------------------
|
| --------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| Used to indicate the conditions under which the script is exit()ing.
|
| Used to indicate the conditions under which the script is exit()ing.
|
||||||
| While there is no universal standard for error codes, there are some
|
| While there is no universal standard for error codes, there are some
|
||||||
| broad conventions. Three such conventions are mentioned below, for
|
| broad conventions. Three such conventions are mentioned below, for
|
||||||
| those who wish to make use of them. The CodeIgniter defaults were
|
| those who wish to make use of them. The CodeIgniter defaults were
|
||||||
| chosen for the least overlap with these conventions, while still
|
| chosen for the least overlap with these conventions, while still
|
||||||
| leaving room for others to be defined in future versions and user
|
| leaving room for others to be defined in future versions and user
|
||||||
| applications.
|
| applications.
|
||||||
|
|
|
|
||||||
| The three main conventions used for determining exit status codes
|
| The three main conventions used for determining exit status codes
|
||||||
| are as follows:
|
| are as follows:
|
||||||
|
|
|
|
||||||
| Standard C/C++ Library (stdlibc):
|
| Standard C/C++ Library (stdlibc):
|
||||||
| http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
|
| http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
|
||||||
| (This link also contains other GNU-specific conventions)
|
| (This link also contains other GNU-specific conventions)
|
||||||
| BSD sysexits.h:
|
| BSD sysexits.h:
|
||||||
| http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
|
| http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
|
||||||
| Bash scripting:
|
| Bash scripting:
|
||||||
| http://tldp.org/LDP/abs/html/exitcodes.html
|
| http://tldp.org/LDP/abs/html/exitcodes.html
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
|
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
|
||||||
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
|
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
|
||||||
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration 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_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found
|
||||||
defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class
|
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_UNKNOWN_METHOD') || define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
|
||||||
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input
|
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input
|
||||||
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error
|
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_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
|
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code
|
||||||
|
|||||||
@ -1,176 +1,176 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the default settings for the ContentSecurityPolicy, if you
|
* Stores the default settings for the ContentSecurityPolicy, if you
|
||||||
* choose to use it. The values here will be read in and set as defaults
|
* 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.
|
* for the site. If needed, they can be overridden on a page-by-page basis.
|
||||||
*
|
*
|
||||||
* Suggested reference for explanations:
|
* Suggested reference for explanations:
|
||||||
*
|
*
|
||||||
* @see https://www.html5rocks.com/en/tutorials/security/content-security-policy/
|
* @see https://www.html5rocks.com/en/tutorials/security/content-security-policy/
|
||||||
*/
|
*/
|
||||||
class ContentSecurityPolicy extends BaseConfig
|
class ContentSecurityPolicy extends BaseConfig
|
||||||
{
|
{
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Broadbrush CSP management
|
// Broadbrush CSP management
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default CSP report context
|
* Default CSP report context
|
||||||
*/
|
*/
|
||||||
public bool $reportOnly = false;
|
public bool $reportOnly = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies a URL where a browser will send reports
|
* Specifies a URL where a browser will send reports
|
||||||
* when a content security policy is violated.
|
* when a content security policy is violated.
|
||||||
*/
|
*/
|
||||||
public ?string $reportURI = null;
|
public ?string $reportURI = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instructs user agents to rewrite URL schemes, changing
|
* Instructs user agents to rewrite URL schemes, changing
|
||||||
* HTTP to HTTPS. This directive is for websites with
|
* HTTP to HTTPS. This directive is for websites with
|
||||||
* large numbers of old URLs that need to be rewritten.
|
* large numbers of old URLs that need to be rewritten.
|
||||||
*/
|
*/
|
||||||
public bool $upgradeInsecureRequests = false;
|
public bool $upgradeInsecureRequests = false;
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Sources allowed
|
// Sources allowed
|
||||||
// NOTE: once you set a policy to 'none', it cannot be further restricted
|
// NOTE: once you set a policy to 'none', it cannot be further restricted
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will default to self if not overridden
|
* Will default to self if not overridden
|
||||||
*
|
*
|
||||||
* @var list<string>|string|null
|
* @var list<string>|string|null
|
||||||
*/
|
*/
|
||||||
public $defaultSrc;
|
public $defaultSrc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists allowed scripts' URLs.
|
* Lists allowed scripts' URLs.
|
||||||
*
|
*
|
||||||
* @var list<string>|string
|
* @var list<string>|string
|
||||||
*/
|
*/
|
||||||
public $scriptSrc = 'self';
|
public $scriptSrc = 'self';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists allowed stylesheets' URLs.
|
* Lists allowed stylesheets' URLs.
|
||||||
*
|
*
|
||||||
* @var list<string>|string
|
* @var list<string>|string
|
||||||
*/
|
*/
|
||||||
public $styleSrc = 'self';
|
public $styleSrc = 'self';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the origins from which images can be loaded.
|
* Defines the origins from which images can be loaded.
|
||||||
*
|
*
|
||||||
* @var list<string>|string
|
* @var list<string>|string
|
||||||
*/
|
*/
|
||||||
public $imageSrc = 'self';
|
public $imageSrc = 'self';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restricts the URLs that can appear in a page's `<base>` element.
|
* Restricts the URLs that can appear in a page's `<base>` element.
|
||||||
*
|
*
|
||||||
* Will default to self if not overridden
|
* Will default to self if not overridden
|
||||||
*
|
*
|
||||||
* @var list<string>|string|null
|
* @var list<string>|string|null
|
||||||
*/
|
*/
|
||||||
public $baseURI;
|
public $baseURI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists the URLs for workers and embedded frame contents
|
* Lists the URLs for workers and embedded frame contents
|
||||||
*
|
*
|
||||||
* @var list<string>|string
|
* @var list<string>|string
|
||||||
*/
|
*/
|
||||||
public $childSrc = 'self';
|
public $childSrc = 'self';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Limits the origins that you can connect to (via XHR,
|
* Limits the origins that you can connect to (via XHR,
|
||||||
* WebSockets, and EventSource).
|
* WebSockets, and EventSource).
|
||||||
*
|
*
|
||||||
* @var list<string>|string
|
* @var list<string>|string
|
||||||
*/
|
*/
|
||||||
public $connectSrc = 'self';
|
public $connectSrc = 'self';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the origins that can serve web fonts.
|
* Specifies the origins that can serve web fonts.
|
||||||
*
|
*
|
||||||
* @var list<string>|string
|
* @var list<string>|string
|
||||||
*/
|
*/
|
||||||
public $fontSrc;
|
public $fontSrc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists valid endpoints for submission from `<form>` tags.
|
* Lists valid endpoints for submission from `<form>` tags.
|
||||||
*
|
*
|
||||||
* @var list<string>|string
|
* @var list<string>|string
|
||||||
*/
|
*/
|
||||||
public $formAction = 'self';
|
public $formAction = 'self';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the sources that can embed the current page.
|
* Specifies the sources that can embed the current page.
|
||||||
* This directive applies to `<frame>`, `<iframe>`, `<embed>`,
|
* This directive applies to `<frame>`, `<iframe>`, `<embed>`,
|
||||||
* and `<applet>` tags. This directive can't be used in
|
* and `<applet>` tags. This directive can't be used in
|
||||||
* `<meta>` tags and applies only to non-HTML resources.
|
* `<meta>` tags and applies only to non-HTML resources.
|
||||||
*
|
*
|
||||||
* @var list<string>|string|null
|
* @var list<string>|string|null
|
||||||
*/
|
*/
|
||||||
public $frameAncestors;
|
public $frameAncestors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The frame-src directive restricts the URLs which may
|
* The frame-src directive restricts the URLs which may
|
||||||
* be loaded into nested browsing contexts.
|
* be loaded into nested browsing contexts.
|
||||||
*
|
*
|
||||||
* @var list<string>|string|null
|
* @var list<string>|string|null
|
||||||
*/
|
*/
|
||||||
public $frameSrc;
|
public $frameSrc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restricts the origins allowed to deliver video and audio.
|
* Restricts the origins allowed to deliver video and audio.
|
||||||
*
|
*
|
||||||
* @var list<string>|string|null
|
* @var list<string>|string|null
|
||||||
*/
|
*/
|
||||||
public $mediaSrc;
|
public $mediaSrc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows control over Flash and other plugins.
|
* Allows control over Flash and other plugins.
|
||||||
*
|
*
|
||||||
* @var list<string>|string
|
* @var list<string>|string
|
||||||
*/
|
*/
|
||||||
public $objectSrc = 'self';
|
public $objectSrc = 'self';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var list<string>|string|null
|
* @var list<string>|string|null
|
||||||
*/
|
*/
|
||||||
public $manifestSrc;
|
public $manifestSrc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Limits the kinds of plugins a page may invoke.
|
* Limits the kinds of plugins a page may invoke.
|
||||||
*
|
*
|
||||||
* @var list<string>|string|null
|
* @var list<string>|string|null
|
||||||
*/
|
*/
|
||||||
public $pluginTypes;
|
public $pluginTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of actions allowed.
|
* List of actions allowed.
|
||||||
*
|
*
|
||||||
* @var list<string>|string|null
|
* @var list<string>|string|null
|
||||||
*/
|
*/
|
||||||
public $sandbox;
|
public $sandbox;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nonce tag for style
|
* Nonce tag for style
|
||||||
*/
|
*/
|
||||||
public string $styleNonceTag = '{csp-style-nonce}';
|
public string $styleNonceTag = '{csp-style-nonce}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nonce tag for script
|
* Nonce tag for script
|
||||||
*/
|
*/
|
||||||
public string $scriptNonceTag = '{csp-script-nonce}';
|
public string $scriptNonceTag = '{csp-script-nonce}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace nonce tag automatically
|
* Replace nonce tag automatically
|
||||||
*/
|
*/
|
||||||
public bool $autoNonce = true;
|
public bool $autoNonce = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,107 +1,107 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
|
||||||
class Cookie extends BaseConfig
|
class Cookie extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Cookie Prefix
|
* Cookie Prefix
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Set a cookie name prefix if you need to avoid collisions.
|
* Set a cookie name prefix if you need to avoid collisions.
|
||||||
*/
|
*/
|
||||||
public string $prefix = '';
|
public string $prefix = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Cookie Expires Timestamp
|
* Cookie Expires Timestamp
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Default expires timestamp for cookies. Setting this to `0` will mean the
|
* 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 will not have the `Expires` attribute and will behave as a session
|
||||||
* cookie.
|
* cookie.
|
||||||
*
|
*
|
||||||
* @var DateTimeInterface|int|string
|
* @var DateTimeInterface|int|string
|
||||||
*/
|
*/
|
||||||
public $expires = 0;
|
public $expires = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Cookie Path
|
* Cookie Path
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Typically will be a forward slash.
|
* Typically will be a forward slash.
|
||||||
*/
|
*/
|
||||||
public string $path = '/';
|
public string $path = '/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Cookie Domain
|
* Cookie Domain
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Set to `.your-domain.com` for site-wide cookies.
|
* Set to `.your-domain.com` for site-wide cookies.
|
||||||
*/
|
*/
|
||||||
public string $domain = '';
|
public string $domain = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Cookie Secure
|
* Cookie Secure
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Cookie will only be set if a secure HTTPS connection exists.
|
* Cookie will only be set if a secure HTTPS connection exists.
|
||||||
*/
|
*/
|
||||||
public bool $secure = false;
|
public bool $secure = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Cookie HTTPOnly
|
* Cookie HTTPOnly
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Cookie will only be accessible via HTTP(S) (no JavaScript).
|
* Cookie will only be accessible via HTTP(S) (no JavaScript).
|
||||||
*/
|
*/
|
||||||
public bool $httponly = true;
|
public bool $httponly = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Cookie SameSite
|
* Cookie SameSite
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Configure cookie SameSite setting. Allowed values are:
|
* Configure cookie SameSite setting. Allowed values are:
|
||||||
* - None
|
* - None
|
||||||
* - Lax
|
* - Lax
|
||||||
* - Strict
|
* - Strict
|
||||||
* - ''
|
* - ''
|
||||||
*
|
*
|
||||||
* Alternatively, you can use the constant names:
|
* Alternatively, you can use the constant names:
|
||||||
* - `Cookie::SAMESITE_NONE`
|
* - `Cookie::SAMESITE_NONE`
|
||||||
* - `Cookie::SAMESITE_LAX`
|
* - `Cookie::SAMESITE_LAX`
|
||||||
* - `Cookie::SAMESITE_STRICT`
|
* - `Cookie::SAMESITE_STRICT`
|
||||||
*
|
*
|
||||||
* Defaults to `Lax` for compatibility with modern browsers. Setting `''`
|
* Defaults to `Lax` for compatibility with modern browsers. Setting `''`
|
||||||
* (empty string) means default SameSite attribute set by browsers (`Lax`)
|
* (empty string) means default SameSite attribute set by browsers (`Lax`)
|
||||||
* will be set on cookies. If set to `None`, `$secure` must also be set.
|
* will be set on cookies. If set to `None`, `$secure` must also be set.
|
||||||
*
|
*
|
||||||
* @phpstan-var 'None'|'Lax'|'Strict'|''
|
* @phpstan-var 'None'|'Lax'|'Strict'|''
|
||||||
*/
|
*/
|
||||||
public string $samesite = 'Lax';
|
public string $samesite = 'Lax';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Cookie Raw
|
* Cookie Raw
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This flag allows setting a "raw" cookie, i.e., its name and value are
|
* This flag allows setting a "raw" cookie, i.e., its name and value are
|
||||||
* not URL encoded using `rawurlencode()`.
|
* not URL encoded using `rawurlencode()`.
|
||||||
*
|
*
|
||||||
* If this is set to `true`, cookie names should be compliant of RFC 2616's
|
* If this is set to `true`, cookie names should be compliant of RFC 2616's
|
||||||
* list of allowed characters.
|
* list of allowed characters.
|
||||||
*
|
*
|
||||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes
|
||||||
* @see https://tools.ietf.org/html/rfc2616#section-2.2
|
* @see https://tools.ietf.org/html/rfc2616#section-2.2
|
||||||
*/
|
*/
|
||||||
public bool $raw = false;
|
public bool $raw = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,105 +1,105 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cross-Origin Resource Sharing (CORS) Configuration
|
* Cross-Origin Resource Sharing (CORS) Configuration
|
||||||
*
|
*
|
||||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
||||||
*/
|
*/
|
||||||
class Cors extends BaseConfig
|
class Cors extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The default CORS configuration.
|
* The default CORS configuration.
|
||||||
*
|
*
|
||||||
* @var array{
|
* @var array{
|
||||||
* allowedOrigins: list<string>,
|
* allowedOrigins: list<string>,
|
||||||
* allowedOriginsPatterns: list<string>,
|
* allowedOriginsPatterns: list<string>,
|
||||||
* supportsCredentials: bool,
|
* supportsCredentials: bool,
|
||||||
* allowedHeaders: list<string>,
|
* allowedHeaders: list<string>,
|
||||||
* exposedHeaders: list<string>,
|
* exposedHeaders: list<string>,
|
||||||
* allowedMethods: list<string>,
|
* allowedMethods: list<string>,
|
||||||
* maxAge: int,
|
* maxAge: int,
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
public array $default = [
|
public array $default = [
|
||||||
/**
|
/**
|
||||||
* Origins for the `Access-Control-Allow-Origin` header.
|
* Origins for the `Access-Control-Allow-Origin` header.
|
||||||
*
|
*
|
||||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
|
||||||
*
|
*
|
||||||
* E.g.:
|
* E.g.:
|
||||||
* - ['http://localhost:8080']
|
* - ['http://localhost:8080']
|
||||||
* - ['https://www.example.com']
|
* - ['https://www.example.com']
|
||||||
*/
|
*/
|
||||||
'allowedOrigins' => ['http://localhost:5173', 'https://clqms01.services-summit.my.id'],
|
'allowedOrigins' => ['http://localhost:5173', 'https://clqms01.services-summit.my.id'],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Origin regex patterns for the `Access-Control-Allow-Origin` header.
|
* 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
|
* @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
|
* NOTE: A pattern specified here is part of a regular expression. It will
|
||||||
* be actually `#\A<pattern>\z#`.
|
* be actually `#\A<pattern>\z#`.
|
||||||
*
|
*
|
||||||
* E.g.:
|
* E.g.:
|
||||||
* - ['https://\w+\.example\.com']
|
* - ['https://\w+\.example\.com']
|
||||||
*/
|
*/
|
||||||
'allowedOriginsPatterns' => [],
|
'allowedOriginsPatterns' => [],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Weather to send the `Access-Control-Allow-Credentials` header.
|
* Weather to send the `Access-Control-Allow-Credentials` header.
|
||||||
*
|
*
|
||||||
* The Access-Control-Allow-Credentials response header tells browsers whether
|
* The Access-Control-Allow-Credentials response header tells browsers whether
|
||||||
* the server allows cross-origin HTTP requests to include credentials.
|
* 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
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
|
||||||
*/
|
*/
|
||||||
'supportsCredentials' => true,
|
'supportsCredentials' => true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set headers to allow.
|
* Set headers to allow.
|
||||||
*
|
*
|
||||||
* The Access-Control-Allow-Headers response header is used in response to
|
* The Access-Control-Allow-Headers response header is used in response to
|
||||||
* a preflight request which includes the Access-Control-Request-Headers to
|
* a preflight request which includes the Access-Control-Request-Headers to
|
||||||
* indicate which HTTP headers can be used during the actual request.
|
* 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
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
|
||||||
*/
|
*/
|
||||||
'allowedHeaders' => ['Content-Type', 'Authorization', 'X-Requested-With'],
|
'allowedHeaders' => ['Content-Type', 'Authorization', 'X-Requested-With'],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set headers to expose.
|
* Set headers to expose.
|
||||||
*
|
*
|
||||||
* The Access-Control-Expose-Headers response header allows a server to
|
* The Access-Control-Expose-Headers response header allows a server to
|
||||||
* indicate which response headers should be made available to scripts running
|
* indicate which response headers should be made available to scripts running
|
||||||
* in the browser, in response to a cross-origin request.
|
* 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
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers
|
||||||
*/
|
*/
|
||||||
'exposedHeaders' => [],
|
'exposedHeaders' => [],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set methods to allow.
|
* Set methods to allow.
|
||||||
*
|
*
|
||||||
* The Access-Control-Allow-Methods response header specifies one or more
|
* The Access-Control-Allow-Methods response header specifies one or more
|
||||||
* methods allowed when accessing a resource in response to a preflight
|
* methods allowed when accessing a resource in response to a preflight
|
||||||
* request.
|
* request.
|
||||||
*
|
*
|
||||||
* E.g.:
|
* E.g.:
|
||||||
* - ['GET', 'POST', 'PUT', 'DELETE']
|
* - ['GET', 'POST', 'PUT', 'DELETE']
|
||||||
*
|
*
|
||||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods
|
||||||
*/
|
*/
|
||||||
'allowedMethods' => ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
'allowedMethods' => ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set how many seconds the results of a preflight request can be cached.
|
* 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
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
|
||||||
*/
|
*/
|
||||||
'maxAge' => 7200,
|
'maxAge' => 7200,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,210 +1,210 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Database\Config;
|
use CodeIgniter\Database\Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database Configuration
|
* Database Configuration
|
||||||
*/
|
*/
|
||||||
class Database extends Config
|
class Database extends Config
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The directory that holds the Migrations and Seeds directories.
|
* The directory that holds the Migrations and Seeds directories.
|
||||||
*/
|
*/
|
||||||
public string $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR;
|
public string $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lets you choose which connection group to use if no other is specified.
|
* Lets you choose which connection group to use if no other is specified.
|
||||||
*/
|
*/
|
||||||
public string $defaultGroup = 'default';
|
public string $defaultGroup = 'default';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default database connection.
|
* The default database connection.
|
||||||
*
|
*
|
||||||
* @var array<string, mixed>
|
* @var array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public array $default = [
|
public array $default = [
|
||||||
'DSN' => '',
|
'DSN' => '',
|
||||||
'hostname' => 'localhost',
|
'hostname' => 'localhost',
|
||||||
'username' => 'root',
|
'username' => 'root',
|
||||||
'password' => 'adminsakti',
|
'password' => 'adminsakti',
|
||||||
'database' => 'clqms01',
|
'database' => 'clqms01',
|
||||||
'DBDriver' => 'MySQLi',
|
'DBDriver' => 'MySQLi',
|
||||||
'DBPrefix' => '',
|
'DBPrefix' => '',
|
||||||
'pConnect' => false,
|
'pConnect' => false,
|
||||||
'DBDebug' => true,
|
'DBDebug' => true,
|
||||||
'charset' => 'utf8mb4',
|
'charset' => 'utf8mb4',
|
||||||
'DBCollat' => 'utf8mb4_general_ci',
|
'DBCollat' => 'utf8mb4_general_ci',
|
||||||
'swapPre' => '',
|
'swapPre' => '',
|
||||||
'encrypt' => false,
|
'encrypt' => false,
|
||||||
'compress' => false,
|
'compress' => false,
|
||||||
'strictOn' => false,
|
'strictOn' => false,
|
||||||
'failover' => [],
|
'failover' => [],
|
||||||
'port' => 3306,
|
'port' => 3306,
|
||||||
'numberNative' => false,
|
'numberNative' => false,
|
||||||
'foundRows' => false,
|
'foundRows' => false,
|
||||||
'dateFormat' => [
|
'dateFormat' => [
|
||||||
'date' => 'Y-m-d',
|
'date' => 'Y-m-d',
|
||||||
'datetime' => 'Y-m-d H:i:s',
|
'datetime' => 'Y-m-d H:i:s',
|
||||||
'time' => 'H:i:s',
|
'time' => 'H:i:s',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Sample database connection for SQLite3.
|
// * Sample database connection for SQLite3.
|
||||||
// *
|
// *
|
||||||
// * @var array<string, mixed>
|
// * @var array<string, mixed>
|
||||||
// */
|
// */
|
||||||
// public array $default = [
|
// public array $default = [
|
||||||
// 'database' => 'database.db',
|
// 'database' => 'database.db',
|
||||||
// 'DBDriver' => 'SQLite3',
|
// 'DBDriver' => 'SQLite3',
|
||||||
// 'DBPrefix' => '',
|
// 'DBPrefix' => '',
|
||||||
// 'DBDebug' => true,
|
// 'DBDebug' => true,
|
||||||
// 'swapPre' => '',
|
// 'swapPre' => '',
|
||||||
// 'failover' => [],
|
// 'failover' => [],
|
||||||
// 'foreignKeys' => true,
|
// 'foreignKeys' => true,
|
||||||
// 'busyTimeout' => 1000,
|
// 'busyTimeout' => 1000,
|
||||||
// 'synchronous' => null,
|
// 'synchronous' => null,
|
||||||
// 'dateFormat' => [
|
// 'dateFormat' => [
|
||||||
// 'date' => 'Y-m-d',
|
// 'date' => 'Y-m-d',
|
||||||
// 'datetime' => 'Y-m-d H:i:s',
|
// 'datetime' => 'Y-m-d H:i:s',
|
||||||
// 'time' => 'H:i:s',
|
// 'time' => 'H:i:s',
|
||||||
// ],
|
// ],
|
||||||
// ];
|
// ];
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Sample database connection for Postgre.
|
// * Sample database connection for Postgre.
|
||||||
// *
|
// *
|
||||||
// * @var array<string, mixed>
|
// * @var array<string, mixed>
|
||||||
// */
|
// */
|
||||||
// public array $default = [
|
// public array $default = [
|
||||||
// 'DSN' => '',
|
// 'DSN' => '',
|
||||||
// 'hostname' => 'localhost',
|
// 'hostname' => 'localhost',
|
||||||
// 'username' => 'root',
|
// 'username' => 'root',
|
||||||
// 'password' => 'root',
|
// 'password' => 'root',
|
||||||
// 'database' => 'ci4',
|
// 'database' => 'ci4',
|
||||||
// 'schema' => 'public',
|
// 'schema' => 'public',
|
||||||
// 'DBDriver' => 'Postgre',
|
// 'DBDriver' => 'Postgre',
|
||||||
// 'DBPrefix' => '',
|
// 'DBPrefix' => '',
|
||||||
// 'pConnect' => false,
|
// 'pConnect' => false,
|
||||||
// 'DBDebug' => true,
|
// 'DBDebug' => true,
|
||||||
// 'charset' => 'utf8',
|
// 'charset' => 'utf8',
|
||||||
// 'swapPre' => '',
|
// 'swapPre' => '',
|
||||||
// 'failover' => [],
|
// 'failover' => [],
|
||||||
// 'port' => 5432,
|
// 'port' => 5432,
|
||||||
// 'dateFormat' => [
|
// 'dateFormat' => [
|
||||||
// 'date' => 'Y-m-d',
|
// 'date' => 'Y-m-d',
|
||||||
// 'datetime' => 'Y-m-d H:i:s',
|
// 'datetime' => 'Y-m-d H:i:s',
|
||||||
// 'time' => 'H:i:s',
|
// 'time' => 'H:i:s',
|
||||||
// ],
|
// ],
|
||||||
// ];
|
// ];
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Sample database connection for SQLSRV.
|
// * Sample database connection for SQLSRV.
|
||||||
// *
|
// *
|
||||||
// * @var array<string, mixed>
|
// * @var array<string, mixed>
|
||||||
// */
|
// */
|
||||||
// public array $default = [
|
// public array $default = [
|
||||||
// 'DSN' => '',
|
// 'DSN' => '',
|
||||||
// 'hostname' => 'localhost',
|
// 'hostname' => 'localhost',
|
||||||
// 'username' => 'root',
|
// 'username' => 'root',
|
||||||
// 'password' => 'root',
|
// 'password' => 'root',
|
||||||
// 'database' => 'ci4',
|
// 'database' => 'ci4',
|
||||||
// 'schema' => 'dbo',
|
// 'schema' => 'dbo',
|
||||||
// 'DBDriver' => 'SQLSRV',
|
// 'DBDriver' => 'SQLSRV',
|
||||||
// 'DBPrefix' => '',
|
// 'DBPrefix' => '',
|
||||||
// 'pConnect' => false,
|
// 'pConnect' => false,
|
||||||
// 'DBDebug' => true,
|
// 'DBDebug' => true,
|
||||||
// 'charset' => 'utf8',
|
// 'charset' => 'utf8',
|
||||||
// 'swapPre' => '',
|
// 'swapPre' => '',
|
||||||
// 'encrypt' => false,
|
// 'encrypt' => false,
|
||||||
// 'failover' => [],
|
// 'failover' => [],
|
||||||
// 'port' => 1433,
|
// 'port' => 1433,
|
||||||
// 'dateFormat' => [
|
// 'dateFormat' => [
|
||||||
// 'date' => 'Y-m-d',
|
// 'date' => 'Y-m-d',
|
||||||
// 'datetime' => 'Y-m-d H:i:s',
|
// 'datetime' => 'Y-m-d H:i:s',
|
||||||
// 'time' => 'H:i:s',
|
// 'time' => 'H:i:s',
|
||||||
// ],
|
// ],
|
||||||
// ];
|
// ];
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Sample database connection for OCI8.
|
// * Sample database connection for OCI8.
|
||||||
// *
|
// *
|
||||||
// * You may need the following environment variables:
|
// * You may need the following environment variables:
|
||||||
// * NLS_LANG = 'AMERICAN_AMERICA.UTF8'
|
// * NLS_LANG = 'AMERICAN_AMERICA.UTF8'
|
||||||
// * NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
|
// * NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
|
||||||
// * NLS_TIMESTAMP_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'
|
// * NLS_TIMESTAMP_TZ_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
|
||||||
// *
|
// *
|
||||||
// * @var array<string, mixed>
|
// * @var array<string, mixed>
|
||||||
// */
|
// */
|
||||||
// public array $default = [
|
// public array $default = [
|
||||||
// 'DSN' => 'localhost:1521/XEPDB1',
|
// 'DSN' => 'localhost:1521/XEPDB1',
|
||||||
// 'username' => 'root',
|
// 'username' => 'root',
|
||||||
// 'password' => 'root',
|
// 'password' => 'root',
|
||||||
// 'DBDriver' => 'OCI8',
|
// 'DBDriver' => 'OCI8',
|
||||||
// 'DBPrefix' => '',
|
// 'DBPrefix' => '',
|
||||||
// 'pConnect' => false,
|
// 'pConnect' => false,
|
||||||
// 'DBDebug' => true,
|
// 'DBDebug' => true,
|
||||||
// 'charset' => 'AL32UTF8',
|
// 'charset' => 'AL32UTF8',
|
||||||
// 'swapPre' => '',
|
// 'swapPre' => '',
|
||||||
// 'failover' => [],
|
// 'failover' => [],
|
||||||
// 'dateFormat' => [
|
// 'dateFormat' => [
|
||||||
// 'date' => 'Y-m-d',
|
// 'date' => 'Y-m-d',
|
||||||
// 'datetime' => 'Y-m-d H:i:s',
|
// 'datetime' => 'Y-m-d H:i:s',
|
||||||
// 'time' => 'H:i:s',
|
// 'time' => 'H:i:s',
|
||||||
// ],
|
// ],
|
||||||
// ];
|
// ];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This database connection is used when running PHPUnit database tests.
|
* This database connection is used when running PHPUnit database tests.
|
||||||
*
|
*
|
||||||
* These values can be overridden in phpunit.xml.dist or .env file using:
|
* These values can be overridden in phpunit.xml.dist or .env file using:
|
||||||
* - database.tests.hostname
|
* - database.tests.hostname
|
||||||
* - database.tests.database
|
* - database.tests.database
|
||||||
* - database.tests.username
|
* - database.tests.username
|
||||||
* - database.tests.password
|
* - database.tests.password
|
||||||
* - database.tests.DBDriver
|
* - database.tests.DBDriver
|
||||||
*
|
*
|
||||||
* @var array<string, mixed>
|
* @var array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public array $tests = [
|
public array $tests = [
|
||||||
'DSN' => '',
|
'DSN' => '',
|
||||||
'hostname' => 'localhost',
|
'hostname' => 'localhost',
|
||||||
'username' => 'root',
|
'username' => 'root',
|
||||||
'password' => 'adminsakti',
|
'password' => 'adminsakti',
|
||||||
'database' => 'clqms01',
|
'database' => 'clqms01',
|
||||||
'DBDriver' => 'MySQLi',
|
'DBDriver' => 'MySQLi',
|
||||||
'DBPrefix' => '', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
|
'DBPrefix' => '', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
|
||||||
'pConnect' => false,
|
'pConnect' => false,
|
||||||
'DBDebug' => true,
|
'DBDebug' => true,
|
||||||
'charset' => 'utf8mb4',
|
'charset' => 'utf8mb4',
|
||||||
'DBCollat' => 'utf8mb4_general_ci',
|
'DBCollat' => 'utf8mb4_general_ci',
|
||||||
'swapPre' => '',
|
'swapPre' => '',
|
||||||
'encrypt' => false,
|
'encrypt' => false,
|
||||||
'compress' => false,
|
'compress' => false,
|
||||||
'strictOn' => false,
|
'strictOn' => false,
|
||||||
'failover' => [],
|
'failover' => [],
|
||||||
'port' => 3306,
|
'port' => 3306,
|
||||||
'foreignKeys' => true,
|
'foreignKeys' => true,
|
||||||
'busyTimeout' => 1000,
|
'busyTimeout' => 1000,
|
||||||
'dateFormat' => [
|
'dateFormat' => [
|
||||||
'date' => 'Y-m-d',
|
'date' => 'Y-m-d',
|
||||||
'datetime' => 'Y-m-d H:i:s',
|
'datetime' => 'Y-m-d H:i:s',
|
||||||
'time' => 'H:i:s',
|
'time' => 'H:i:s',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
// Ensure that we always set the database group to 'tests' if
|
// Ensure that we always set the database group to 'tests' if
|
||||||
// we are currently running an automated test suite, so that
|
// we are currently running an automated test suite, so that
|
||||||
// we don't overwrite live data on accident.
|
// we don't overwrite live data on accident.
|
||||||
if (ENVIRONMENT === 'testing') {
|
if (ENVIRONMENT === 'testing') {
|
||||||
$this->defaultGroup = 'tests';
|
$this->defaultGroup = 'tests';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,43 +1,43 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
class DocTypes
|
class DocTypes
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* List of valid document types.
|
* List of valid document types.
|
||||||
*
|
*
|
||||||
* @var array<string, string>
|
* @var array<string, string>
|
||||||
*/
|
*/
|
||||||
public array $list = [
|
public array $list = [
|
||||||
'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
|
'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-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-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">',
|
'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">',
|
'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>',
|
'html5' => '<!DOCTYPE html>',
|
||||||
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
|
'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-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">',
|
'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">',
|
'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">',
|
'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">',
|
'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' => '<!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-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">',
|
'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-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-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-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">',
|
'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>`)
|
* Whether to remove the solidus (`/`) character for void HTML elements (e.g. `<input>`)
|
||||||
* for HTML5 compatibility.
|
* for HTML5 compatibility.
|
||||||
*
|
*
|
||||||
* Set to:
|
* Set to:
|
||||||
* `true` - to be HTML5 compatible
|
* `true` - to be HTML5 compatible
|
||||||
* `false` - to be XHTML compatible
|
* `false` - to be XHTML compatible
|
||||||
*/
|
*/
|
||||||
public bool $html5 = true;
|
public bool $html5 = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,121 +1,121 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
class Email extends BaseConfig
|
class Email extends BaseConfig
|
||||||
{
|
{
|
||||||
public string $fromEmail = '';
|
public string $fromEmail = '';
|
||||||
public string $fromName = '';
|
public string $fromName = '';
|
||||||
public string $recipients = '';
|
public string $recipients = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "user agent"
|
* The "user agent"
|
||||||
*/
|
*/
|
||||||
public string $userAgent = 'CodeIgniter';
|
public string $userAgent = 'CodeIgniter';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The mail sending protocol: mail, sendmail, smtp
|
* The mail sending protocol: mail, sendmail, smtp
|
||||||
*/
|
*/
|
||||||
public string $protocol = 'mail';
|
public string $protocol = 'mail';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The server path to Sendmail.
|
* The server path to Sendmail.
|
||||||
*/
|
*/
|
||||||
public string $mailPath = '/usr/sbin/sendmail';
|
public string $mailPath = '/usr/sbin/sendmail';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMTP Server Hostname
|
* SMTP Server Hostname
|
||||||
*/
|
*/
|
||||||
public string $SMTPHost = '';
|
public string $SMTPHost = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMTP Username
|
* SMTP Username
|
||||||
*/
|
*/
|
||||||
public string $SMTPUser = '';
|
public string $SMTPUser = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMTP Password
|
* SMTP Password
|
||||||
*/
|
*/
|
||||||
public string $SMTPPass = '';
|
public string $SMTPPass = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMTP Port
|
* SMTP Port
|
||||||
*/
|
*/
|
||||||
public int $SMTPPort = 25;
|
public int $SMTPPort = 25;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMTP Timeout (in seconds)
|
* SMTP Timeout (in seconds)
|
||||||
*/
|
*/
|
||||||
public int $SMTPTimeout = 5;
|
public int $SMTPTimeout = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable persistent SMTP connections
|
* Enable persistent SMTP connections
|
||||||
*/
|
*/
|
||||||
public bool $SMTPKeepAlive = false;
|
public bool $SMTPKeepAlive = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMTP Encryption.
|
* SMTP Encryption.
|
||||||
*
|
*
|
||||||
* @var string '', 'tls' or 'ssl'. 'tls' will issue a STARTTLS command
|
* @var string '', 'tls' or 'ssl'. 'tls' will issue a STARTTLS command
|
||||||
* to the server. 'ssl' means implicit SSL. Connection on port
|
* to the server. 'ssl' means implicit SSL. Connection on port
|
||||||
* 465 should set this to ''.
|
* 465 should set this to ''.
|
||||||
*/
|
*/
|
||||||
public string $SMTPCrypto = 'tls';
|
public string $SMTPCrypto = 'tls';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable word-wrap
|
* Enable word-wrap
|
||||||
*/
|
*/
|
||||||
public bool $wordWrap = true;
|
public bool $wordWrap = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Character count to wrap at
|
* Character count to wrap at
|
||||||
*/
|
*/
|
||||||
public int $wrapChars = 76;
|
public int $wrapChars = 76;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of mail, either 'text' or 'html'
|
* Type of mail, either 'text' or 'html'
|
||||||
*/
|
*/
|
||||||
public string $mailType = 'text';
|
public string $mailType = 'text';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Character set (utf-8, iso-8859-1, etc.)
|
* Character set (utf-8, iso-8859-1, etc.)
|
||||||
*/
|
*/
|
||||||
public string $charset = 'UTF-8';
|
public string $charset = 'UTF-8';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to validate the email address
|
* Whether to validate the email address
|
||||||
*/
|
*/
|
||||||
public bool $validate = false;
|
public bool $validate = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Email Priority. 1 = highest. 5 = lowest. 3 = normal
|
* Email Priority. 1 = highest. 5 = lowest. 3 = normal
|
||||||
*/
|
*/
|
||||||
public int $priority = 3;
|
public int $priority = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Newline character. (Use “\r\n” to comply with RFC 822)
|
* Newline character. (Use “\r\n” to comply with RFC 822)
|
||||||
*/
|
*/
|
||||||
public string $CRLF = "\r\n";
|
public string $CRLF = "\r\n";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Newline character. (Use “\r\n” to comply with RFC 822)
|
* Newline character. (Use “\r\n” to comply with RFC 822)
|
||||||
*/
|
*/
|
||||||
public string $newline = "\r\n";
|
public string $newline = "\r\n";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable BCC Batch Mode.
|
* Enable BCC Batch Mode.
|
||||||
*/
|
*/
|
||||||
public bool $BCCBatchMode = false;
|
public bool $BCCBatchMode = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of emails in each BCC batch
|
* Number of emails in each BCC batch
|
||||||
*/
|
*/
|
||||||
public int $BCCBatchSize = 200;
|
public int $BCCBatchSize = 200;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable notify message from server
|
* Enable notify message from server
|
||||||
*/
|
*/
|
||||||
public bool $DSN = false;
|
public bool $DSN = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,92 +1,92 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encryption configuration.
|
* Encryption configuration.
|
||||||
*
|
*
|
||||||
* These are the settings used for encryption, if you don't pass a parameter
|
* These are the settings used for encryption, if you don't pass a parameter
|
||||||
* array to the encrypter for creation/initialization.
|
* array to the encrypter for creation/initialization.
|
||||||
*/
|
*/
|
||||||
class Encryption extends BaseConfig
|
class Encryption extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Encryption Key Starter
|
* Encryption Key Starter
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* If you use the Encryption class you must set an encryption key (seed).
|
* 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.
|
* You need to ensure it is long enough for the cipher and mode you plan to use.
|
||||||
* See the user guide for more info.
|
* See the user guide for more info.
|
||||||
*/
|
*/
|
||||||
public string $key = '';
|
public string $key = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Encryption Driver to Use
|
* Encryption Driver to Use
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* One of the supported encryption drivers.
|
* One of the supported encryption drivers.
|
||||||
*
|
*
|
||||||
* Available drivers:
|
* Available drivers:
|
||||||
* - OpenSSL
|
* - OpenSSL
|
||||||
* - Sodium
|
* - Sodium
|
||||||
*/
|
*/
|
||||||
public string $driver = 'OpenSSL';
|
public string $driver = 'OpenSSL';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* SodiumHandler's Padding Length in Bytes
|
* SodiumHandler's Padding Length in Bytes
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This is the number of bytes that will be padded to the plaintext message
|
* 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.
|
* before it is encrypted. This value should be greater than zero.
|
||||||
*
|
*
|
||||||
* See the user guide for more information on padding.
|
* See the user guide for more information on padding.
|
||||||
*/
|
*/
|
||||||
public int $blockSize = 16;
|
public int $blockSize = 16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Encryption digest
|
* Encryption digest
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* HMAC digest to use, e.g. 'SHA512' or 'SHA256'. Default value is 'SHA512'.
|
* HMAC digest to use, e.g. 'SHA512' or 'SHA256'. Default value is 'SHA512'.
|
||||||
*/
|
*/
|
||||||
public string $digest = 'SHA512';
|
public string $digest = 'SHA512';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the cipher-text should be raw. If set to false, then it will be base64 encoded.
|
* Whether the cipher-text should be raw. If set to false, then it will be base64 encoded.
|
||||||
* This setting is only used by OpenSSLHandler.
|
* This setting is only used by OpenSSLHandler.
|
||||||
*
|
*
|
||||||
* Set to false for CI3 Encryption compatibility.
|
* Set to false for CI3 Encryption compatibility.
|
||||||
*/
|
*/
|
||||||
public bool $rawData = true;
|
public bool $rawData = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encryption key info.
|
* Encryption key info.
|
||||||
* This setting is only used by OpenSSLHandler.
|
* This setting is only used by OpenSSLHandler.
|
||||||
*
|
*
|
||||||
* Set to 'encryption' for CI3 Encryption compatibility.
|
* Set to 'encryption' for CI3 Encryption compatibility.
|
||||||
*/
|
*/
|
||||||
public string $encryptKeyInfo = '';
|
public string $encryptKeyInfo = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authentication key info.
|
* Authentication key info.
|
||||||
* This setting is only used by OpenSSLHandler.
|
* This setting is only used by OpenSSLHandler.
|
||||||
*
|
*
|
||||||
* Set to 'authentication' for CI3 Encryption compatibility.
|
* Set to 'authentication' for CI3 Encryption compatibility.
|
||||||
*/
|
*/
|
||||||
public string $authKeyInfo = '';
|
public string $authKeyInfo = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cipher to use.
|
* Cipher to use.
|
||||||
* This setting is only used by OpenSSLHandler.
|
* This setting is only used by OpenSSLHandler.
|
||||||
*
|
*
|
||||||
* Set to 'AES-128-CBC' to decrypt encrypted data that encrypted
|
* Set to 'AES-128-CBC' to decrypt encrypted data that encrypted
|
||||||
* by CI3 Encryption default configuration.
|
* by CI3 Encryption default configuration.
|
||||||
*/
|
*/
|
||||||
public string $cipher = 'AES-256-CTR';
|
public string $cipher = 'AES-256-CTR';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,55 +1,55 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Events\Events;
|
use CodeIgniter\Events\Events;
|
||||||
use CodeIgniter\Exceptions\FrameworkException;
|
use CodeIgniter\Exceptions\FrameworkException;
|
||||||
use CodeIgniter\HotReloader\HotReloader;
|
use CodeIgniter\HotReloader\HotReloader;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
* Application Events
|
* Application Events
|
||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
* Events allow you to tap into the execution of the program without
|
* Events allow you to tap into the execution of the program without
|
||||||
* modifying or extending core files. This file provides a central
|
* modifying or extending core files. This file provides a central
|
||||||
* location to define your events, though they can always be added
|
* location to define your events, though they can always be added
|
||||||
* at run-time, also, if needed.
|
* at run-time, also, if needed.
|
||||||
*
|
*
|
||||||
* You create code that can execute by subscribing to events with
|
* You create code that can execute by subscribing to events with
|
||||||
* the 'on()' method. This accepts any form of callable, including
|
* the 'on()' method. This accepts any form of callable, including
|
||||||
* Closures, that will be executed when the event is triggered.
|
* Closures, that will be executed when the event is triggered.
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* Events::on('create', [$myInstance, 'myMethod']);
|
* Events::on('create', [$myInstance, 'myMethod']);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Events::on('pre_system', static function (): void {
|
Events::on('pre_system', static function (): void {
|
||||||
if (ENVIRONMENT !== 'testing') {
|
if (ENVIRONMENT !== 'testing') {
|
||||||
if (ini_get('zlib.output_compression')) {
|
if (ini_get('zlib.output_compression')) {
|
||||||
throw FrameworkException::forEnabledZlibOutputCompression();
|
throw FrameworkException::forEnabledZlibOutputCompression();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ob_get_level() > 0) {
|
while (ob_get_level() > 0) {
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_start(static fn ($buffer) => $buffer);
|
ob_start(static fn ($buffer) => $buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
* Debug Toolbar Listeners.
|
* Debug Toolbar Listeners.
|
||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
* If you delete, they will no longer be collected.
|
* If you delete, they will no longer be collected.
|
||||||
*/
|
*/
|
||||||
if (CI_DEBUG && ! is_cli()) {
|
if (CI_DEBUG && ! is_cli()) {
|
||||||
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
|
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
|
||||||
service('toolbar')->respond();
|
service('toolbar')->respond();
|
||||||
// Hot Reload route - for framework use on the hot reloader.
|
// Hot Reload route - for framework use on the hot reloader.
|
||||||
if (ENVIRONMENT === 'development') {
|
if (ENVIRONMENT === 'development') {
|
||||||
service('routes')->get('__hot-reload', static function (): void {
|
service('routes')->get('__hot-reload', static function (): void {
|
||||||
(new HotReloader())->run();
|
(new HotReloader())->run();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,106 +1,106 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
use CodeIgniter\Debug\ExceptionHandler;
|
use CodeIgniter\Debug\ExceptionHandler;
|
||||||
use CodeIgniter\Debug\ExceptionHandlerInterface;
|
use CodeIgniter\Debug\ExceptionHandlerInterface;
|
||||||
use Psr\Log\LogLevel;
|
use Psr\Log\LogLevel;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup how the exception handler works.
|
* Setup how the exception handler works.
|
||||||
*/
|
*/
|
||||||
class Exceptions extends BaseConfig
|
class Exceptions extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* LOG EXCEPTIONS?
|
* LOG EXCEPTIONS?
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* If true, then exceptions will be logged
|
* If true, then exceptions will be logged
|
||||||
* through Services::Log.
|
* through Services::Log.
|
||||||
*
|
*
|
||||||
* Default: true
|
* Default: true
|
||||||
*/
|
*/
|
||||||
public bool $log = true;
|
public bool $log = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* DO NOT LOG STATUS CODES
|
* DO NOT LOG STATUS CODES
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Any status codes here will NOT be logged if logging is turned on.
|
* Any status codes here will NOT be logged if logging is turned on.
|
||||||
* By default, only 404 (Page Not Found) exceptions are ignored.
|
* By default, only 404 (Page Not Found) exceptions are ignored.
|
||||||
*
|
*
|
||||||
* @var list<int>
|
* @var list<int>
|
||||||
*/
|
*/
|
||||||
public array $ignoreCodes = [404];
|
public array $ignoreCodes = [404];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Error Views Path
|
* Error Views Path
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* This is the path to the directory that contains the 'cli' and 'html'
|
* This is the path to the directory that contains the 'cli' and 'html'
|
||||||
* directories that hold the views used to generate errors.
|
* directories that hold the views used to generate errors.
|
||||||
*
|
*
|
||||||
* Default: APPPATH.'Views/errors'
|
* Default: APPPATH.'Views/errors'
|
||||||
*/
|
*/
|
||||||
public string $errorViewPath = __DIR__ . '/../Views/errors';
|
public string $errorViewPath = __DIR__ . '/../Views/errors';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* HIDE FROM DEBUG TRACE
|
* HIDE FROM DEBUG TRACE
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Any data that you would like to hide from the debug trace.
|
* Any data that you would like to hide from the debug trace.
|
||||||
* In order to specify 2 levels, use "/" to separate.
|
* In order to specify 2 levels, use "/" to separate.
|
||||||
* ex. ['server', 'setup/password', 'secret_token']
|
* ex. ['server', 'setup/password', 'secret_token']
|
||||||
*
|
*
|
||||||
* @var list<string>
|
* @var list<string>
|
||||||
*/
|
*/
|
||||||
public array $sensitiveDataInTrace = [];
|
public array $sensitiveDataInTrace = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* WHETHER TO THROW AN EXCEPTION ON DEPRECATED ERRORS
|
* WHETHER TO THROW AN EXCEPTION ON DEPRECATED ERRORS
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* If set to `true`, DEPRECATED errors are only logged and no exceptions are
|
* If set to `true`, DEPRECATED errors are only logged and no exceptions are
|
||||||
* thrown. This option also works for user deprecations.
|
* thrown. This option also works for user deprecations.
|
||||||
*/
|
*/
|
||||||
public bool $logDeprecations = true;
|
public bool $logDeprecations = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* LOG LEVEL THRESHOLD FOR DEPRECATIONS
|
* LOG LEVEL THRESHOLD FOR DEPRECATIONS
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* If `$logDeprecations` is set to `true`, this sets the log level
|
* 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
|
* to which the deprecation will be logged. This should be one of the log
|
||||||
* levels recognized by PSR-3.
|
* levels recognized by PSR-3.
|
||||||
*
|
*
|
||||||
* The related `Config\Logger::$threshold` should be adjusted, if needed,
|
* The related `Config\Logger::$threshold` should be adjusted, if needed,
|
||||||
* to capture logging the deprecations.
|
* to capture logging the deprecations.
|
||||||
*/
|
*/
|
||||||
public string $deprecationLogLevel = LogLevel::WARNING;
|
public string $deprecationLogLevel = LogLevel::WARNING;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DEFINE THE HANDLERS USED
|
* DEFINE THE HANDLERS USED
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Given the HTTP status code, returns exception handler that
|
* Given the HTTP status code, returns exception handler that
|
||||||
* should be used to deal with this error. By default, it will run CodeIgniter's
|
* 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
|
* 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
|
* for CLI, HTTP, or AJAX requests, as determined by is_cli() and the expected
|
||||||
* response format.
|
* response format.
|
||||||
*
|
*
|
||||||
* Custom handlers can be returned if you want to handle one or more specific
|
* Custom handlers can be returned if you want to handle one or more specific
|
||||||
* error codes yourself like:
|
* error codes yourself like:
|
||||||
*
|
*
|
||||||
* if (in_array($statusCode, [400, 404, 500])) {
|
* if (in_array($statusCode, [400, 404, 500])) {
|
||||||
* return new \App\Libraries\MyExceptionHandler();
|
* return new \App\Libraries\MyExceptionHandler();
|
||||||
* }
|
* }
|
||||||
* if ($exception instanceOf PageNotFoundException) {
|
* if ($exception instanceOf PageNotFoundException) {
|
||||||
* return new \App\Libraries\MyExceptionHandler();
|
* return new \App\Libraries\MyExceptionHandler();
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
public function handler(int $statusCode, Throwable $exception): ExceptionHandlerInterface
|
public function handler(int $statusCode, Throwable $exception): ExceptionHandlerInterface
|
||||||
{
|
{
|
||||||
return new ExceptionHandler($this);
|
return new ExceptionHandler($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,37 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable/disable backward compatibility breaking features.
|
* Enable/disable backward compatibility breaking features.
|
||||||
*/
|
*/
|
||||||
class Feature extends BaseConfig
|
class Feature extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Use improved new auto routing instead of the legacy version.
|
* Use improved new auto routing instead of the legacy version.
|
||||||
*/
|
*/
|
||||||
public bool $autoRoutesImproved = true;
|
public bool $autoRoutesImproved = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use filter execution order in 4.4 or before.
|
* Use filter execution order in 4.4 or before.
|
||||||
*/
|
*/
|
||||||
public bool $oldFilterOrder = false;
|
public bool $oldFilterOrder = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The behavior of `limit(0)` in Query Builder.
|
* 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 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.)
|
* If false, `limit(0)` returns no records. (the behavior of 3.1.9 or later in version 3.x.)
|
||||||
*/
|
*/
|
||||||
public bool $limitZeroAsAll = true;
|
public bool $limitZeroAsAll = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use strict location negotiation.
|
* Use strict location negotiation.
|
||||||
*
|
*
|
||||||
* By default, the locale is selected based on a loose comparison of the language code (ISO 639-1)
|
* 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).
|
* Enabling strict comparison will also consider the region code (ISO 3166-1 alpha-2).
|
||||||
*/
|
*/
|
||||||
public bool $strictLocaleNegotiation = false;
|
public bool $strictLocaleNegotiation = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,110 +1,110 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\Filters as BaseFilters;
|
use CodeIgniter\Config\Filters as BaseFilters;
|
||||||
// use CodeIgniter\Filters\Cors;
|
// use CodeIgniter\Filters\Cors;
|
||||||
use CodeIgniter\Filters\CSRF;
|
use CodeIgniter\Filters\CSRF;
|
||||||
use CodeIgniter\Filters\DebugToolbar;
|
use CodeIgniter\Filters\DebugToolbar;
|
||||||
use CodeIgniter\Filters\ForceHTTPS;
|
use CodeIgniter\Filters\ForceHTTPS;
|
||||||
use CodeIgniter\Filters\Honeypot;
|
use CodeIgniter\Filters\Honeypot;
|
||||||
use CodeIgniter\Filters\InvalidChars;
|
use CodeIgniter\Filters\InvalidChars;
|
||||||
use CodeIgniter\Filters\PageCache;
|
use CodeIgniter\Filters\PageCache;
|
||||||
use CodeIgniter\Filters\PerformanceMetrics;
|
use CodeIgniter\Filters\PerformanceMetrics;
|
||||||
use CodeIgniter\Filters\SecureHeaders;
|
use CodeIgniter\Filters\SecureHeaders;
|
||||||
|
|
||||||
class Filters extends BaseFilters
|
class Filters extends BaseFilters
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Configures aliases for Filter classes to
|
* Configures aliases for Filter classes to
|
||||||
* make reading things nicer and simpler.
|
* make reading things nicer and simpler.
|
||||||
*
|
*
|
||||||
* @var array<string, class-string|list<class-string>>
|
* @var array<string, class-string|list<class-string>>
|
||||||
*
|
*
|
||||||
* [filter_name => classname]
|
* [filter_name => classname]
|
||||||
* or [filter_name => [classname1, classname2, ...]]
|
* or [filter_name => [classname1, classname2, ...]]
|
||||||
*/
|
*/
|
||||||
public array $aliases = [
|
public array $aliases = [
|
||||||
'csrf' => CSRF::class,
|
'csrf' => CSRF::class,
|
||||||
'toolbar' => DebugToolbar::class,
|
'toolbar' => DebugToolbar::class,
|
||||||
'honeypot' => Honeypot::class,
|
'honeypot' => Honeypot::class,
|
||||||
'invalidchars' => InvalidChars::class,
|
'invalidchars' => InvalidChars::class,
|
||||||
'secureheaders' => SecureHeaders::class,
|
'secureheaders' => SecureHeaders::class,
|
||||||
// 'cors' => Cors::class,
|
// 'cors' => Cors::class,
|
||||||
'cors' => \App\Filters\Cors::class,
|
'cors' => \App\Filters\Cors::class,
|
||||||
'forcehttps' => ForceHTTPS::class,
|
'forcehttps' => ForceHTTPS::class,
|
||||||
'pagecache' => PageCache::class,
|
'pagecache' => PageCache::class,
|
||||||
'performance' => PerformanceMetrics::class,
|
'performance' => PerformanceMetrics::class,
|
||||||
'auth' => \App\Filters\AuthFilter::class,
|
'auth' => \App\Filters\AuthFilter::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of special required filters.
|
* List of special required filters.
|
||||||
*
|
*
|
||||||
* The filters listed here are special. They are applied before and after
|
* 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.
|
* other kinds of filters, and always applied even if a route does not exist.
|
||||||
*
|
*
|
||||||
* Filters set by default provide framework functionality. If removed,
|
* Filters set by default provide framework functionality. If removed,
|
||||||
* those functions will no longer work.
|
* those functions will no longer work.
|
||||||
*
|
*
|
||||||
* @see https://codeigniter.com/user_guide/incoming/filters.html#provided-filters
|
* @see https://codeigniter.com/user_guide/incoming/filters.html#provided-filters
|
||||||
*
|
*
|
||||||
* @var array{before: list<string>, after: list<string>}
|
* @var array{before: list<string>, after: list<string>}
|
||||||
*/
|
*/
|
||||||
public array $required = [
|
public array $required = [
|
||||||
'before' => [
|
'before' => [
|
||||||
// 'forcehttps', // Force Global Secure Requests - disabled for localhost
|
// 'forcehttps', // Force Global Secure Requests - disabled for localhost
|
||||||
'pagecache', // Web Page Caching
|
'pagecache', // Web Page Caching
|
||||||
],
|
],
|
||||||
'after' => [
|
'after' => [
|
||||||
'pagecache', // Web Page Caching
|
'pagecache', // Web Page Caching
|
||||||
'performance', // Performance Metrics
|
'performance', // Performance Metrics
|
||||||
'toolbar', // Debug Toolbar
|
'toolbar', // Debug Toolbar
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of filter aliases that are always
|
* List of filter aliases that are always
|
||||||
* applied before and after every request.
|
* applied before and after every request.
|
||||||
*
|
*
|
||||||
* @var array<string, array<string, array<string, string>>>|array<string, list<string>>
|
* @var array<string, array<string, array<string, string>>>|array<string, list<string>>
|
||||||
*/
|
*/
|
||||||
public array $globals = [
|
public array $globals = [
|
||||||
'before' => [
|
'before' => [
|
||||||
'cors',
|
'cors',
|
||||||
// 'honeypot',
|
// 'honeypot',
|
||||||
// 'csrf',
|
// 'csrf',
|
||||||
// 'invalidchars',
|
// 'invalidchars',
|
||||||
],
|
],
|
||||||
'after' => [
|
'after' => [
|
||||||
// 'honeypot',
|
// 'honeypot',
|
||||||
// 'secureheaders',
|
// 'secureheaders',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of filter aliases that works on a
|
* List of filter aliases that works on a
|
||||||
* particular HTTP method (GET, POST, etc.).
|
* particular HTTP method (GET, POST, etc.).
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* 'POST' => ['foo', 'bar']
|
* 'POST' => ['foo', 'bar']
|
||||||
*
|
*
|
||||||
* If you use this, you should disable auto-routing because auto-routing
|
* If you use this, you should disable auto-routing because auto-routing
|
||||||
* permits any HTTP method to access a controller. Accessing the controller
|
* permits any HTTP method to access a controller. Accessing the controller
|
||||||
* with a method you don't expect could bypass the filter.
|
* with a method you don't expect could bypass the filter.
|
||||||
*
|
*
|
||||||
* @var array<string, list<string>>
|
* @var array<string, list<string>>
|
||||||
*/
|
*/
|
||||||
public array $methods = [];
|
public array $methods = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of filter aliases that should run on any
|
* List of filter aliases that should run on any
|
||||||
* before or after URI patterns.
|
* before or after URI patterns.
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
|
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
|
||||||
*
|
*
|
||||||
* @var array<string, array<string, list<string>>>
|
* @var array<string, array<string, list<string>>>
|
||||||
*/
|
*/
|
||||||
public array $filters = [];
|
public array $filters = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\ForeignCharacters as BaseForeignCharacters;
|
use CodeIgniter\Config\ForeignCharacters as BaseForeignCharacters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class ForeignCharacters extends BaseForeignCharacters
|
class ForeignCharacters extends BaseForeignCharacters
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,64 +1,64 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
use CodeIgniter\Format\JSONFormatter;
|
use CodeIgniter\Format\JSONFormatter;
|
||||||
use CodeIgniter\Format\XMLFormatter;
|
use CodeIgniter\Format\XMLFormatter;
|
||||||
|
|
||||||
class Format extends BaseConfig
|
class Format extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Available Response Formats
|
* Available Response Formats
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* When you perform content negotiation with the request, these are the
|
* When you perform content negotiation with the request, these are the
|
||||||
* available formats that your application supports. This is currently
|
* available formats that your application supports. This is currently
|
||||||
* only used with the API\ResponseTrait. A valid Formatter must exist
|
* only used with the API\ResponseTrait. A valid Formatter must exist
|
||||||
* for the specified format.
|
* for the specified format.
|
||||||
*
|
*
|
||||||
* These formats are only checked when the data passed to the respond()
|
* These formats are only checked when the data passed to the respond()
|
||||||
* method is an array.
|
* method is an array.
|
||||||
*
|
*
|
||||||
* @var list<string>
|
* @var list<string>
|
||||||
*/
|
*/
|
||||||
public array $supportedResponseFormats = [
|
public array $supportedResponseFormats = [
|
||||||
'application/json',
|
'application/json',
|
||||||
'application/xml', // machine-readable XML
|
'application/xml', // machine-readable XML
|
||||||
'text/xml', // human-readable XML
|
'text/xml', // human-readable XML
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Formatters
|
* Formatters
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Lists the class to use to format responses with of a particular type.
|
* 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
|
* For each mime type, list the class that should be used. Formatters
|
||||||
* can be retrieved through the getFormatter() method.
|
* can be retrieved through the getFormatter() method.
|
||||||
*
|
*
|
||||||
* @var array<string, string>
|
* @var array<string, string>
|
||||||
*/
|
*/
|
||||||
public array $formatters = [
|
public array $formatters = [
|
||||||
'application/json' => JSONFormatter::class,
|
'application/json' => JSONFormatter::class,
|
||||||
'application/xml' => XMLFormatter::class,
|
'application/xml' => XMLFormatter::class,
|
||||||
'text/xml' => XMLFormatter::class,
|
'text/xml' => XMLFormatter::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Formatters Options
|
* Formatters Options
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Additional Options to adjust default formatters behaviour.
|
* Additional Options to adjust default formatters behaviour.
|
||||||
* For each mime type, list the additional options that should be used.
|
* For each mime type, list the additional options that should be used.
|
||||||
*
|
*
|
||||||
* @var array<string, int>
|
* @var array<string, int>
|
||||||
*/
|
*/
|
||||||
public array $formatterOptions = [
|
public array $formatterOptions = [
|
||||||
'application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
|
'application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
|
||||||
'application/xml' => 0,
|
'application/xml' => 0,
|
||||||
'text/xml' => 0,
|
'text/xml' => 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,44 +1,44 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
class Generators extends BaseConfig
|
class Generators extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Generator Commands' Views
|
* Generator Commands' Views
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This array defines the mapping of generator commands to the view files
|
* 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
|
* 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.
|
* view files in your own folder and indicate the location here.
|
||||||
*
|
*
|
||||||
* You will notice that the views have special placeholders enclosed in
|
* You will notice that the views have special placeholders enclosed in
|
||||||
* curly braces `{...}`. These placeholders are used internally by the
|
* curly braces `{...}`. These placeholders are used internally by the
|
||||||
* generator commands in processing replacements, thus you are warned
|
* generator commands in processing replacements, thus you are warned
|
||||||
* not to delete them or modify the names. If you will do so, you may
|
* not to delete them or modify the names. If you will do so, you may
|
||||||
* end up disrupting the scaffolding process and throw errors.
|
* end up disrupting the scaffolding process and throw errors.
|
||||||
*
|
*
|
||||||
* YOU HAVE BEEN WARNED!
|
* YOU HAVE BEEN WARNED!
|
||||||
*
|
*
|
||||||
* @var array<string, array<string, string>|string>
|
* @var array<string, array<string, string>|string>
|
||||||
*/
|
*/
|
||||||
public array $views = [
|
public array $views = [
|
||||||
'make:cell' => [
|
'make:cell' => [
|
||||||
'class' => 'CodeIgniter\Commands\Generators\Views\cell.tpl.php',
|
'class' => 'CodeIgniter\Commands\Generators\Views\cell.tpl.php',
|
||||||
'view' => 'CodeIgniter\Commands\Generators\Views\cell_view.tpl.php',
|
'view' => 'CodeIgniter\Commands\Generators\Views\cell_view.tpl.php',
|
||||||
],
|
],
|
||||||
'make:command' => 'CodeIgniter\Commands\Generators\Views\command.tpl.php',
|
'make:command' => 'CodeIgniter\Commands\Generators\Views\command.tpl.php',
|
||||||
'make:config' => 'CodeIgniter\Commands\Generators\Views\config.tpl.php',
|
'make:config' => 'CodeIgniter\Commands\Generators\Views\config.tpl.php',
|
||||||
'make:controller' => 'CodeIgniter\Commands\Generators\Views\controller.tpl.php',
|
'make:controller' => 'CodeIgniter\Commands\Generators\Views\controller.tpl.php',
|
||||||
'make:entity' => 'CodeIgniter\Commands\Generators\Views\entity.tpl.php',
|
'make:entity' => 'CodeIgniter\Commands\Generators\Views\entity.tpl.php',
|
||||||
'make:filter' => 'CodeIgniter\Commands\Generators\Views\filter.tpl.php',
|
'make:filter' => 'CodeIgniter\Commands\Generators\Views\filter.tpl.php',
|
||||||
'make:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
|
'make:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
|
||||||
'make:model' => 'CodeIgniter\Commands\Generators\Views\model.tpl.php',
|
'make:model' => 'CodeIgniter\Commands\Generators\Views\model.tpl.php',
|
||||||
'make:seeder' => 'CodeIgniter\Commands\Generators\Views\seeder.tpl.php',
|
'make:seeder' => 'CodeIgniter\Commands\Generators\Views\seeder.tpl.php',
|
||||||
'make:validation' => 'CodeIgniter\Commands\Generators\Views\validation.tpl.php',
|
'make:validation' => 'CodeIgniter\Commands\Generators\Views\validation.tpl.php',
|
||||||
'session:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
|
'session:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,42 +1,42 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
class Honeypot extends BaseConfig
|
class Honeypot extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Makes Honeypot visible or not to human
|
* Makes Honeypot visible or not to human
|
||||||
*/
|
*/
|
||||||
public bool $hidden = true;
|
public bool $hidden = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Honeypot Label Content
|
* Honeypot Label Content
|
||||||
*/
|
*/
|
||||||
public string $label = 'Fill This Field';
|
public string $label = 'Fill This Field';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Honeypot Field Name
|
* Honeypot Field Name
|
||||||
*/
|
*/
|
||||||
public string $name = 'honeypot';
|
public string $name = 'honeypot';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Honeypot HTML Template
|
* Honeypot HTML Template
|
||||||
*/
|
*/
|
||||||
public string $template = '<label>{label}</label><input type="text" name="{name}" value="">';
|
public string $template = '<label>{label}</label><input type="text" name="{name}" value="">';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Honeypot container
|
* Honeypot container
|
||||||
*
|
*
|
||||||
* If you enabled CSP, you can remove `style="display:none"`.
|
* If you enabled CSP, you can remove `style="display:none"`.
|
||||||
*/
|
*/
|
||||||
public string $container = '<div style="display:none">{template}</div>';
|
public string $container = '<div style="display:none">{template}</div>';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id attribute for Honeypot container tag
|
* The id attribute for Honeypot container tag
|
||||||
*
|
*
|
||||||
* Used when CSP is enabled.
|
* Used when CSP is enabled.
|
||||||
*/
|
*/
|
||||||
public string $containerId = 'hpc';
|
public string $containerId = 'hpc';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,31 +1,31 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
use CodeIgniter\Images\Handlers\GDHandler;
|
use CodeIgniter\Images\Handlers\GDHandler;
|
||||||
use CodeIgniter\Images\Handlers\ImageMagickHandler;
|
use CodeIgniter\Images\Handlers\ImageMagickHandler;
|
||||||
|
|
||||||
class Images extends BaseConfig
|
class Images extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Default handler used if no other handler is specified.
|
* Default handler used if no other handler is specified.
|
||||||
*/
|
*/
|
||||||
public string $defaultHandler = 'gd';
|
public string $defaultHandler = 'gd';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The path to the image library.
|
* The path to the image library.
|
||||||
* Required for ImageMagick, GraphicsMagick, or NetPBM.
|
* Required for ImageMagick, GraphicsMagick, or NetPBM.
|
||||||
*/
|
*/
|
||||||
public string $libraryPath = '/usr/local/bin/convert';
|
public string $libraryPath = '/usr/local/bin/convert';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The available handler classes.
|
* The available handler classes.
|
||||||
*
|
*
|
||||||
* @var array<string, string>
|
* @var array<string, string>
|
||||||
*/
|
*/
|
||||||
public array $handlers = [
|
public array $handlers = [
|
||||||
'gd' => GDHandler::class,
|
'gd' => GDHandler::class,
|
||||||
'imagick' => ImageMagickHandler::class,
|
'imagick' => ImageMagickHandler::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,63 +1,63 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use Kint\Parser\ConstructablePluginInterface;
|
use Kint\Parser\ConstructablePluginInterface;
|
||||||
use Kint\Renderer\Rich\TabPluginInterface;
|
use Kint\Renderer\Rich\TabPluginInterface;
|
||||||
use Kint\Renderer\Rich\ValuePluginInterface;
|
use Kint\Renderer\Rich\ValuePluginInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Kint
|
* Kint
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* We use Kint's `RichRenderer` and `CLIRenderer`. This area contains options
|
* We use Kint's `RichRenderer` and `CLIRenderer`. This area contains options
|
||||||
* that you can set to customize how Kint works for you.
|
* that you can set to customize how Kint works for you.
|
||||||
*
|
*
|
||||||
* @see https://kint-php.github.io/kint/ for details on these settings.
|
* @see https://kint-php.github.io/kint/ for details on these settings.
|
||||||
*/
|
*/
|
||||||
class Kint
|
class Kint
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Global Settings
|
| Global Settings
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var list<class-string<ConstructablePluginInterface>|ConstructablePluginInterface>|null
|
* @var list<class-string<ConstructablePluginInterface>|ConstructablePluginInterface>|null
|
||||||
*/
|
*/
|
||||||
public $plugins;
|
public $plugins;
|
||||||
|
|
||||||
public int $maxDepth = 6;
|
public int $maxDepth = 6;
|
||||||
public bool $displayCalledFrom = true;
|
public bool $displayCalledFrom = true;
|
||||||
public bool $expanded = false;
|
public bool $expanded = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| RichRenderer Settings
|
| RichRenderer Settings
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
public string $richTheme = 'aante-light.css';
|
public string $richTheme = 'aante-light.css';
|
||||||
public bool $richFolder = false;
|
public bool $richFolder = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array<string, class-string<ValuePluginInterface>>|null
|
* @var array<string, class-string<ValuePluginInterface>>|null
|
||||||
*/
|
*/
|
||||||
public $richObjectPlugins;
|
public $richObjectPlugins;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array<string, class-string<TabPluginInterface>>|null
|
* @var array<string, class-string<TabPluginInterface>>|null
|
||||||
*/
|
*/
|
||||||
public $richTabPlugins;
|
public $richTabPlugins;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| CLI Settings
|
| CLI Settings
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
public bool $cliColors = true;
|
public bool $cliColors = true;
|
||||||
public bool $cliForceUTF8 = false;
|
public bool $cliForceUTF8 = false;
|
||||||
public bool $cliDetectWidth = true;
|
public bool $cliDetectWidth = true;
|
||||||
public int $cliMinWidth = 40;
|
public int $cliMinWidth = 40;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,150 +1,150 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
use CodeIgniter\Log\Handlers\FileHandler;
|
use CodeIgniter\Log\Handlers\FileHandler;
|
||||||
|
|
||||||
class Logger extends BaseConfig
|
class Logger extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Error Logging Threshold
|
* Error Logging Threshold
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* You can enable error logging by setting a threshold over zero. The
|
* 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 determines what gets logged. Any values below or equal to the
|
||||||
* threshold will be logged.
|
* threshold will be logged.
|
||||||
*
|
*
|
||||||
* Threshold options are:
|
* Threshold options are:
|
||||||
*
|
*
|
||||||
* - 0 = Disables logging, Error logging TURNED OFF
|
* - 0 = Disables logging, Error logging TURNED OFF
|
||||||
* - 1 = Emergency Messages - System is unusable
|
* - 1 = Emergency Messages - System is unusable
|
||||||
* - 2 = Alert Messages - Action Must Be Taken Immediately
|
* - 2 = Alert Messages - Action Must Be Taken Immediately
|
||||||
* - 3 = Critical Messages - Application component unavailable, unexpected exception.
|
* - 3 = Critical Messages - Application component unavailable, unexpected exception.
|
||||||
* - 4 = Runtime Errors - Don't need immediate action, but should be monitored.
|
* - 4 = Runtime Errors - Don't need immediate action, but should be monitored.
|
||||||
* - 5 = Warnings - Exceptional occurrences that are not errors.
|
* - 5 = Warnings - Exceptional occurrences that are not errors.
|
||||||
* - 6 = Notices - Normal but significant events.
|
* - 6 = Notices - Normal but significant events.
|
||||||
* - 7 = Info - Interesting events, like user logging in, etc.
|
* - 7 = Info - Interesting events, like user logging in, etc.
|
||||||
* - 8 = Debug - Detailed debug information.
|
* - 8 = Debug - Detailed debug information.
|
||||||
* - 9 = All Messages
|
* - 9 = All Messages
|
||||||
*
|
*
|
||||||
* You can also pass an array with threshold levels to show individual error types
|
* 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
|
* 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
|
* For a live site you'll usually enable Critical or higher (3) to be logged otherwise
|
||||||
* your log files will fill up very fast.
|
* your log files will fill up very fast.
|
||||||
*
|
*
|
||||||
* @var int|list<int>
|
* @var int|list<int>
|
||||||
*/
|
*/
|
||||||
public $threshold = (ENVIRONMENT === 'production') ? 4 : 9;
|
public $threshold = (ENVIRONMENT === 'production') ? 4 : 9;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Date Format for Logs
|
* Date Format for Logs
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Each item that is logged has an associated date. You can use PHP date
|
* Each item that is logged has an associated date. You can use PHP date
|
||||||
* codes to set your own date formatting
|
* codes to set your own date formatting
|
||||||
*/
|
*/
|
||||||
public string $dateFormat = 'Y-m-d H:i:s';
|
public string $dateFormat = 'Y-m-d H:i:s';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Log Handlers
|
* Log Handlers
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* The logging system supports multiple actions to be taken when something
|
* The logging system supports multiple actions to be taken when something
|
||||||
* is logged. This is done by allowing for multiple Handlers, special classes
|
* is logged. This is done by allowing for multiple Handlers, special classes
|
||||||
* designed to write the log to their chosen destinations, whether that is
|
* 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
|
* a file on the getServer, a cloud-based service, or even taking actions such
|
||||||
* as emailing the dev team.
|
* as emailing the dev team.
|
||||||
*
|
*
|
||||||
* Each handler is defined by the class name used for that handler, and it
|
* Each handler is defined by the class name used for that handler, and it
|
||||||
* MUST implement the `CodeIgniter\Log\Handlers\HandlerInterface` interface.
|
* MUST implement the `CodeIgniter\Log\Handlers\HandlerInterface` interface.
|
||||||
*
|
*
|
||||||
* The value of each key is an array of configuration items that are sent
|
* 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
|
* to the constructor of each handler. The only required configuration item
|
||||||
* is the 'handles' element, which must be an array of integer log levels.
|
* 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
|
* This is most easily handled by using the constants defined in the
|
||||||
* `Psr\Log\LogLevel` class.
|
* `Psr\Log\LogLevel` class.
|
||||||
*
|
*
|
||||||
* Handlers are executed in the order defined in this array, starting with
|
* Handlers are executed in the order defined in this array, starting with
|
||||||
* the handler on top and continuing down.
|
* the handler on top and continuing down.
|
||||||
*
|
*
|
||||||
* @var array<class-string, array<string, int|list<string>|string>>
|
* @var array<class-string, array<string, int|list<string>|string>>
|
||||||
*/
|
*/
|
||||||
public array $handlers = [
|
public array $handlers = [
|
||||||
/*
|
/*
|
||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
* File Handler
|
* File Handler
|
||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
FileHandler::class => [
|
FileHandler::class => [
|
||||||
// The log levels that this handler will handle.
|
// The log levels that this handler will handle.
|
||||||
'handles' => [
|
'handles' => [
|
||||||
'critical',
|
'critical',
|
||||||
'alert',
|
'alert',
|
||||||
'emergency',
|
'emergency',
|
||||||
'debug',
|
'debug',
|
||||||
'error',
|
'error',
|
||||||
'info',
|
'info',
|
||||||
'notice',
|
'notice',
|
||||||
'warning',
|
'warning',
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The default filename extension for log files.
|
* The default filename extension for log files.
|
||||||
* An extension of 'php' allows for protecting the log files via basic
|
* An extension of 'php' allows for protecting the log files via basic
|
||||||
* scripting, when they are to be stored under a publicly accessible directory.
|
* scripting, when they are to be stored under a publicly accessible directory.
|
||||||
*
|
*
|
||||||
* NOTE: Leaving it blank will default to 'log'.
|
* NOTE: Leaving it blank will default to 'log'.
|
||||||
*/
|
*/
|
||||||
'fileExtension' => '',
|
'fileExtension' => '',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The file system permissions to be applied on newly created log files.
|
* 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
|
* IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
|
||||||
* integer notation (i.e. 0700, 0644, etc.)
|
* integer notation (i.e. 0700, 0644, etc.)
|
||||||
*/
|
*/
|
||||||
'filePermissions' => 0644,
|
'filePermissions' => 0644,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Logging Directory Path
|
* Logging Directory Path
|
||||||
*
|
*
|
||||||
* By default, logs are written to WRITEPATH . 'logs/'
|
* By default, logs are written to WRITEPATH . 'logs/'
|
||||||
* Specify a different destination here, if desired.
|
* Specify a different destination here, if desired.
|
||||||
*/
|
*/
|
||||||
'path' => '',
|
'path' => '',
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The ChromeLoggerHandler requires the use of the Chrome web browser
|
* The ChromeLoggerHandler requires the use of the Chrome web browser
|
||||||
* and the ChromeLogger extension. Uncomment this block to use it.
|
* and the ChromeLogger extension. Uncomment this block to use it.
|
||||||
*/
|
*/
|
||||||
// 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => [
|
// 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => [
|
||||||
// /*
|
// /*
|
||||||
// * The log levels that this handler will handle.
|
// * The log levels that this handler will handle.
|
||||||
// */
|
// */
|
||||||
// 'handles' => ['critical', 'alert', 'emergency', 'debug',
|
// 'handles' => ['critical', 'alert', 'emergency', 'debug',
|
||||||
// 'error', 'info', 'notice', 'warning'],
|
// 'error', 'info', 'notice', 'warning'],
|
||||||
// ],
|
// ],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The ErrorlogHandler writes the logs to PHP's native `error_log()` function.
|
* The ErrorlogHandler writes the logs to PHP's native `error_log()` function.
|
||||||
* Uncomment this block to use it.
|
* Uncomment this block to use it.
|
||||||
*/
|
*/
|
||||||
// 'CodeIgniter\Log\Handlers\ErrorlogHandler' => [
|
// 'CodeIgniter\Log\Handlers\ErrorlogHandler' => [
|
||||||
// /* The log levels this handler can handle. */
|
// /* The log levels this handler can handle. */
|
||||||
// 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'],
|
// '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
|
// * 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)
|
// * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4)
|
||||||
// */
|
// */
|
||||||
// 'messageType' => 0,
|
// 'messageType' => 0,
|
||||||
// ],
|
// ],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,50 +1,50 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
class Migrations extends BaseConfig
|
class Migrations extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Enable/Disable Migrations
|
* Enable/Disable Migrations
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Migrations are enabled by default.
|
* Migrations are enabled by default.
|
||||||
*
|
*
|
||||||
* You should enable migrations whenever you intend to do a schema migration
|
* You should enable migrations whenever you intend to do a schema migration
|
||||||
* and disable it back when you're done.
|
* and disable it back when you're done.
|
||||||
*/
|
*/
|
||||||
public bool $enabled = true;
|
public bool $enabled = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Migrations Table
|
* Migrations Table
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This is the name of the table that will store the current migrations state.
|
* 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
|
* When migrations runs it will store in a database table which migration
|
||||||
* files have already been run.
|
* files have already been run.
|
||||||
*/
|
*/
|
||||||
public string $table = 'migrations';
|
public string $table = 'migrations';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Timestamp Format
|
* Timestamp Format
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This is the format that will be used when creating new migrations
|
* This is the format that will be used when creating new migrations
|
||||||
* using the CLI command:
|
* using the CLI command:
|
||||||
* > php spark make:migration
|
* > php spark make:migration
|
||||||
*
|
*
|
||||||
* NOTE: if you set an unsupported format, migration runner will not find
|
* NOTE: if you set an unsupported format, migration runner will not find
|
||||||
* your migration files.
|
* your migration files.
|
||||||
*
|
*
|
||||||
* Supported formats:
|
* Supported formats:
|
||||||
* - YmdHis_
|
* - YmdHis_
|
||||||
* - Y-m-d-His_
|
* - Y-m-d-His_
|
||||||
* - Y_m_d_His_
|
* - Y_m_d_His_
|
||||||
*/
|
*/
|
||||||
public string $timestampFormat = 'Y-m-d-His_';
|
public string $timestampFormat = 'Y-m-d-His_';
|
||||||
}
|
}
|
||||||
|
|||||||
1068
app/Config/Mimes.php
1068
app/Config/Mimes.php
File diff suppressed because it is too large
Load Diff
@ -1,82 +1,82 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Modules\Modules as BaseModules;
|
use CodeIgniter\Modules\Modules as BaseModules;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modules Configuration.
|
* Modules Configuration.
|
||||||
*
|
*
|
||||||
* NOTE: This class is required prior to Autoloader instantiation,
|
* NOTE: This class is required prior to Autoloader instantiation,
|
||||||
* and does not extend BaseConfig.
|
* and does not extend BaseConfig.
|
||||||
*/
|
*/
|
||||||
class Modules extends BaseModules
|
class Modules extends BaseModules
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Enable Auto-Discovery?
|
* Enable Auto-Discovery?
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* If true, then auto-discovery will happen across all elements listed in
|
* If true, then auto-discovery will happen across all elements listed in
|
||||||
* $aliases below. If false, no auto-discovery will happen at all,
|
* $aliases below. If false, no auto-discovery will happen at all,
|
||||||
* giving a slight performance boost.
|
* giving a slight performance boost.
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public $enabled = true;
|
public $enabled = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Enable Auto-Discovery Within Composer Packages?
|
* Enable Auto-Discovery Within Composer Packages?
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* If true, then auto-discovery will happen across all namespaces loaded
|
* If true, then auto-discovery will happen across all namespaces loaded
|
||||||
* by Composer, as well as the namespaces configured locally.
|
* by Composer, as well as the namespaces configured locally.
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public $discoverInComposer = true;
|
public $discoverInComposer = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Composer package list for Auto-Discovery
|
* The Composer package list for Auto-Discovery
|
||||||
* This setting is optional.
|
* This setting is optional.
|
||||||
*
|
*
|
||||||
* E.g.:
|
* E.g.:
|
||||||
* [
|
* [
|
||||||
* 'only' => [
|
* 'only' => [
|
||||||
* // List up all packages to auto-discover
|
* // List up all packages to auto-discover
|
||||||
* 'codeigniter4/shield',
|
* 'codeigniter4/shield',
|
||||||
* ],
|
* ],
|
||||||
* ]
|
* ]
|
||||||
* or
|
* or
|
||||||
* [
|
* [
|
||||||
* 'exclude' => [
|
* 'exclude' => [
|
||||||
* // List up packages to exclude.
|
* // List up packages to exclude.
|
||||||
* 'pestphp/pest',
|
* 'pestphp/pest',
|
||||||
* ],
|
* ],
|
||||||
* ]
|
* ]
|
||||||
*
|
*
|
||||||
* @var array{only?: list<string>, exclude?: list<string>}
|
* @var array{only?: list<string>, exclude?: list<string>}
|
||||||
*/
|
*/
|
||||||
public $composerPackages = [];
|
public $composerPackages = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Auto-Discovery Rules
|
* Auto-Discovery Rules
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Aliases list of all discovery classes that will be active and used during
|
* Aliases list of all discovery classes that will be active and used during
|
||||||
* the current application request.
|
* the current application request.
|
||||||
*
|
*
|
||||||
* If it is not listed, only the base application elements will be used.
|
* If it is not listed, only the base application elements will be used.
|
||||||
*
|
*
|
||||||
* @var list<string>
|
* @var list<string>
|
||||||
*/
|
*/
|
||||||
public $aliases = [
|
public $aliases = [
|
||||||
'events',
|
'events',
|
||||||
'filters',
|
'filters',
|
||||||
'registrars',
|
'registrars',
|
||||||
'routes',
|
'routes',
|
||||||
'services',
|
'services',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,30 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optimization Configuration.
|
* Optimization Configuration.
|
||||||
*
|
*
|
||||||
* NOTE: This class does not extend BaseConfig for performance reasons.
|
* NOTE: This class does not extend BaseConfig for performance reasons.
|
||||||
* So you cannot replace the property values with Environment Variables.
|
* So you cannot replace the property values with Environment Variables.
|
||||||
*/
|
*/
|
||||||
class Optimize
|
class Optimize
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Config Caching
|
* Config Caching
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* @see https://codeigniter.com/user_guide/concepts/factories.html#config-caching
|
* @see https://codeigniter.com/user_guide/concepts/factories.html#config-caching
|
||||||
*/
|
*/
|
||||||
public bool $configCacheEnabled = false;
|
public bool $configCacheEnabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Config Caching
|
* Config Caching
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* @see https://codeigniter.com/user_guide/concepts/autoloader.html#file-locator-caching
|
* @see https://codeigniter.com/user_guide/concepts/autoloader.html#file-locator-caching
|
||||||
*/
|
*/
|
||||||
public bool $locatorCacheEnabled = false;
|
public bool $locatorCacheEnabled = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,37 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
class Pager extends BaseConfig
|
class Pager extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Templates
|
* Templates
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Pagination links are rendered out using views to configure their
|
* Pagination links are rendered out using views to configure their
|
||||||
* appearance. This array contains aliases and the view names to
|
* appearance. This array contains aliases and the view names to
|
||||||
* use when rendering the links.
|
* use when rendering the links.
|
||||||
*
|
*
|
||||||
* Within each view, the Pager object will be available as $pager,
|
* Within each view, the Pager object will be available as $pager,
|
||||||
* and the desired group as $pagerGroup;
|
* and the desired group as $pagerGroup;
|
||||||
*
|
*
|
||||||
* @var array<string, string>
|
* @var array<string, string>
|
||||||
*/
|
*/
|
||||||
public array $templates = [
|
public array $templates = [
|
||||||
'default_full' => 'CodeIgniter\Pager\Views\default_full',
|
'default_full' => 'CodeIgniter\Pager\Views\default_full',
|
||||||
'default_simple' => 'CodeIgniter\Pager\Views\default_simple',
|
'default_simple' => 'CodeIgniter\Pager\Views\default_simple',
|
||||||
'default_head' => 'CodeIgniter\Pager\Views\default_head',
|
'default_head' => 'CodeIgniter\Pager\Views\default_head',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Items Per Page
|
* Items Per Page
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* The default number of results shown in a single page.
|
* The default number of results shown in a single page.
|
||||||
*/
|
*/
|
||||||
public int $perPage = 20;
|
public int $perPage = 20;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,75 +1,75 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paths
|
* Paths
|
||||||
*
|
*
|
||||||
* Holds the paths that are used by the system to
|
* Holds the paths that are used by the system to
|
||||||
* locate the main directories, app, system, etc.
|
* locate the main directories, app, system, etc.
|
||||||
*
|
*
|
||||||
* Modifying these allows you to restructure your application,
|
* Modifying these allows you to restructure your application,
|
||||||
* share a system folder between multiple applications, and more.
|
* share a system folder between multiple applications, and more.
|
||||||
*
|
*
|
||||||
* All paths are relative to the project's root folder.
|
* All paths are relative to the project's root folder.
|
||||||
*/
|
*/
|
||||||
class Paths
|
class Paths
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
* SYSTEM FOLDER NAME
|
* SYSTEM FOLDER NAME
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This must contain the name of your "system" folder. Include
|
* This must contain the name of your "system" folder. Include
|
||||||
* the path if the folder is not in the same directory as this file.
|
* the path if the folder is not in the same directory as this file.
|
||||||
*/
|
*/
|
||||||
public string $systemDirectory = __DIR__ . '/../../vendor/codeigniter4/framework/system';
|
public string $systemDirectory = __DIR__ . '/../../vendor/codeigniter4/framework/system';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
* APPLICATION FOLDER NAME
|
* APPLICATION FOLDER NAME
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* If you want this front controller to use a different "app"
|
* If you want this front controller to use a different "app"
|
||||||
* folder than the default one you can set its name here. The folder
|
* folder than the default one you can set its name here. The folder
|
||||||
* can also be renamed or relocated anywhere on your server. If
|
* can also be renamed or relocated anywhere on your server. If
|
||||||
* you do, use a full server path.
|
* you do, use a full server path.
|
||||||
*
|
*
|
||||||
* @see http://codeigniter.com/user_guide/general/managing_apps.html
|
* @see http://codeigniter.com/user_guide/general/managing_apps.html
|
||||||
*/
|
*/
|
||||||
public string $appDirectory = __DIR__ . '/..';
|
public string $appDirectory = __DIR__ . '/..';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
* WRITABLE DIRECTORY NAME
|
* WRITABLE DIRECTORY NAME
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This variable must contain the name of your "writable" directory.
|
* This variable must contain the name of your "writable" directory.
|
||||||
* The writable directory allows you to group all directories that
|
* The writable directory allows you to group all directories that
|
||||||
* need write permission to a single place that can be tucked away
|
* need write permission to a single place that can be tucked away
|
||||||
* for maximum security, keeping it out of the app and/or
|
* for maximum security, keeping it out of the app and/or
|
||||||
* system directories.
|
* system directories.
|
||||||
*/
|
*/
|
||||||
public string $writableDirectory = __DIR__ . '/../../writable';
|
public string $writableDirectory = __DIR__ . '/../../writable';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
* TESTS DIRECTORY NAME
|
* TESTS DIRECTORY NAME
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This variable must contain the name of your "tests" directory.
|
* This variable must contain the name of your "tests" directory.
|
||||||
*/
|
*/
|
||||||
public string $testsDirectory = __DIR__ . '/../../tests';
|
public string $testsDirectory = __DIR__ . '/../../tests';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
* VIEW DIRECTORY NAME
|
* VIEW DIRECTORY NAME
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This variable must contain the name of the directory that
|
* This variable must contain the name of the directory that
|
||||||
* contains the view files used by your application. By
|
* contains the view files used by your application. By
|
||||||
* default this is in `app/Views`. This value
|
* default this is in `app/Views`. This value
|
||||||
* is used when no value is provided to `Services::renderer()`.
|
* is used when no value is provided to `Services::renderer()`.
|
||||||
*/
|
*/
|
||||||
public string $viewDirectory = __DIR__ . '/../Views';
|
public string $viewDirectory = __DIR__ . '/../Views';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,28 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\Publisher as BasePublisher;
|
use CodeIgniter\Config\Publisher as BasePublisher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publisher Configuration
|
* Publisher Configuration
|
||||||
*
|
*
|
||||||
* Defines basic security restrictions for the Publisher class
|
* Defines basic security restrictions for the Publisher class
|
||||||
* to prevent abuse by injecting malicious files into a project.
|
* to prevent abuse by injecting malicious files into a project.
|
||||||
*/
|
*/
|
||||||
class Publisher extends BasePublisher
|
class Publisher extends BasePublisher
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* A list of allowed destinations with a (pseudo-)regex
|
* A list of allowed destinations with a (pseudo-)regex
|
||||||
* of allowed files for each destination.
|
* of allowed files for each destination.
|
||||||
* Attempts to publish to directories not in this list will
|
* Attempts to publish to directories not in this list will
|
||||||
* result in a PublisherException. Files that do no fit the
|
* result in a PublisherException. Files that do no fit the
|
||||||
* pattern will cause copy/merge to fail.
|
* pattern will cause copy/merge to fail.
|
||||||
*
|
*
|
||||||
* @var array<string, string>
|
* @var array<string, string>
|
||||||
*/
|
*/
|
||||||
public $restrictions = [
|
public $restrictions = [
|
||||||
ROOTPATH => '*',
|
ROOTPATH => '*',
|
||||||
FCPATH => '#\.(s?css|js|map|html?|xml|json|webmanifest|ttf|eot|woff2?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i',
|
FCPATH => '#\.(s?css|js|map|html?|xml|json|webmanifest|ttf|eot|woff2?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,389 +1,384 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use CodeIgniter\Router\RouteCollection;
|
use CodeIgniter\Router\RouteCollection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var RouteCollection $routes
|
* @var RouteCollection $routes
|
||||||
*/
|
*/
|
||||||
$routes->get('/', function () {
|
$routes->get('/', function () {
|
||||||
return "Backend Running";
|
return "Backend Running";
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->options('(:any)', function () {
|
$routes->options('(:any)', function () {
|
||||||
return '';
|
return '';
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group('api', ['filter' => 'auth'], function ($routes) {
|
$routes->group('api', ['filter' => 'auth'], function ($routes) {
|
||||||
$routes->get('dashboard', 'DashboardController::index');
|
$routes->get('dashboard', 'DashboardController::index');
|
||||||
$routes->get('sample', 'SampleController::index');
|
$routes->get('sample', 'SampleController::index');
|
||||||
|
|
||||||
// Results CRUD
|
// Results CRUD
|
||||||
$routes->group('results', function ($routes) {
|
$routes->group('results', function ($routes) {
|
||||||
$routes->get('/', 'ResultController::index');
|
$routes->get('/', 'ResultController::index');
|
||||||
$routes->get('(:num)', 'ResultController::show/$1');
|
$routes->get('(:num)', 'ResultController::show/$1');
|
||||||
$routes->patch('(:num)', 'ResultController::update/$1');
|
$routes->patch('(:num)', 'ResultController::update/$1');
|
||||||
$routes->delete('(:num)', 'ResultController::delete/$1');
|
$routes->delete('(:num)', 'ResultController::delete/$1');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reports
|
// Reports
|
||||||
$routes->get('reports/(:num)', 'ReportController::view/$1');
|
$routes->get('reports/(:num)', 'ReportController::view/$1');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// V2 Auth API Routes (public - no auth required)
|
// V2 Auth API Routes (public - no auth required)
|
||||||
$routes->group('v2/auth', function ($routes) {
|
$routes->group('v2/auth', function ($routes) {
|
||||||
$routes->post('login', 'AuthV2Controller::login');
|
$routes->post('login', 'AuthV2Controller::login');
|
||||||
$routes->post('register', 'AuthV2Controller::register');
|
$routes->post('register', 'AuthV2Controller::register');
|
||||||
$routes->get('check', 'AuthV2Controller::checkAuth');
|
$routes->get('check', 'AuthV2Controller::checkAuth');
|
||||||
$routes->post('logout', 'AuthV2Controller::logout');
|
$routes->post('logout', 'AuthV2Controller::logout');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Faker
|
// Faker
|
||||||
$routes->get('faker/faker-patient/(:num)', 'faker\FakerPatient::sendMany/$1');
|
$routes->get('faker/faker-patient/(:num)', 'faker\FakerPatient::sendMany/$1');
|
||||||
|
|
||||||
$routes->group('api', function ($routes) {
|
$routes->group('api', function ($routes) {
|
||||||
// Auth
|
// Auth
|
||||||
$routes->group('auth', function ($routes) {
|
$routes->group('auth', function ($routes) {
|
||||||
$routes->post('login', 'AuthController::login');
|
$routes->post('login', 'AuthController::login');
|
||||||
$routes->post('change_pass', 'AuthController::change_pass');
|
$routes->post('change_pass', 'AuthController::change_pass');
|
||||||
$routes->post('register', 'AuthController::register');
|
$routes->post('register', 'AuthController::register');
|
||||||
$routes->get('check', 'AuthController::checkAuth');
|
$routes->get('check', 'AuthController::checkAuth');
|
||||||
$routes->post('logout', 'AuthController::logout');
|
$routes->post('logout', 'AuthController::logout');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Patient
|
// Patient
|
||||||
$routes->group('patient', function ($routes) {
|
$routes->group('patient', function ($routes) {
|
||||||
$routes->get('/', 'Patient\PatientController::index');
|
$routes->get('/', 'Patient\PatientController::index');
|
||||||
$routes->post('/', 'Patient\PatientController::create');
|
$routes->post('/', 'Patient\PatientController::create');
|
||||||
$routes->get('(:num)', 'Patient\PatientController::show/$1');
|
$routes->get('(:num)', 'Patient\PatientController::show/$1');
|
||||||
$routes->delete('/', 'Patient\PatientController::delete');
|
$routes->delete('/', 'Patient\PatientController::delete');
|
||||||
$routes->patch('/', 'Patient\PatientController::update');
|
$routes->patch('/', 'Patient\PatientController::update');
|
||||||
$routes->get('check', 'Patient\PatientController::patientCheck');
|
$routes->get('check', 'Patient\PatientController::patientCheck');
|
||||||
});
|
});
|
||||||
|
|
||||||
// PatVisit
|
// PatVisit
|
||||||
$routes->group('patvisit', function ($routes) {
|
$routes->group('patvisit', function ($routes) {
|
||||||
$routes->get('/', 'PatVisitController::index');
|
$routes->get('/', 'PatVisitController::index');
|
||||||
$routes->post('/', 'PatVisitController::create');
|
$routes->post('/', 'PatVisitController::create');
|
||||||
$routes->get('patient/(:num)', 'PatVisitController::showByPatient/$1');
|
$routes->get('patient/(:num)', 'PatVisitController::showByPatient/$1');
|
||||||
$routes->get('(:any)', 'PatVisitController::show/$1');
|
$routes->get('(:any)', 'PatVisitController::show/$1');
|
||||||
$routes->delete('/', 'PatVisitController::delete');
|
$routes->delete('/', 'PatVisitController::delete');
|
||||||
$routes->patch('/', 'PatVisitController::update');
|
$routes->patch('/', 'PatVisitController::update');
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group('patvisitadt', function ($routes) {
|
$routes->group('patvisitadt', function ($routes) {
|
||||||
$routes->get('visit/(:num)', 'PatVisitController::getADTByVisit/$1');
|
$routes->get('visit/(:num)', 'PatVisitController::getADTByVisit/$1');
|
||||||
$routes->get('(:num)', 'PatVisitController::showADT/$1');
|
$routes->get('(:num)', 'PatVisitController::showADT/$1');
|
||||||
$routes->post('/', 'PatVisitController::createADT');
|
$routes->post('/', 'PatVisitController::createADT');
|
||||||
$routes->patch('/', 'PatVisitController::updateADT');
|
$routes->patch('/', 'PatVisitController::updateADT');
|
||||||
$routes->delete('/', 'PatVisitController::deleteADT');
|
$routes->delete('/', 'PatVisitController::deleteADT');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Master Data
|
// Master Data
|
||||||
|
|
||||||
// Location
|
// Location
|
||||||
$routes->group('location', function ($routes) {
|
$routes->group('location', function ($routes) {
|
||||||
$routes->get('/', 'LocationController::index');
|
$routes->get('/', 'LocationController::index');
|
||||||
$routes->get('(:num)', 'LocationController::show/$1');
|
$routes->get('(:num)', 'LocationController::show/$1');
|
||||||
$routes->post('/', 'LocationController::create');
|
$routes->post('/', 'LocationController::create');
|
||||||
$routes->patch('/', 'LocationController::update');
|
$routes->patch('/', 'LocationController::update');
|
||||||
$routes->delete('/', 'LocationController::delete');
|
$routes->delete('/', 'LocationController::delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Contact
|
// Contact
|
||||||
$routes->group('contact', function ($routes) {
|
$routes->group('contact', function ($routes) {
|
||||||
$routes->get('/', 'Contact\ContactController::index');
|
$routes->get('/', 'Contact\ContactController::index');
|
||||||
$routes->get('(:num)', 'Contact\ContactController::show/$1');
|
$routes->get('(:num)', 'Contact\ContactController::show/$1');
|
||||||
$routes->post('/', 'Contact\ContactController::create');
|
$routes->post('/', 'Contact\ContactController::create');
|
||||||
$routes->patch('/', 'Contact\ContactController::update');
|
$routes->patch('/', 'Contact\ContactController::update');
|
||||||
$routes->delete('/', 'Contact\ContactController::delete');
|
$routes->delete('/', 'Contact\ContactController::delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group('occupation', function ($routes) {
|
$routes->group('occupation', function ($routes) {
|
||||||
$routes->get('/', 'Contact\OccupationController::index');
|
$routes->get('/', 'Contact\OccupationController::index');
|
||||||
$routes->get('(:num)', 'Contact\OccupationController::show/$1');
|
$routes->get('(:num)', 'Contact\OccupationController::show/$1');
|
||||||
$routes->post('/', 'Contact\OccupationController::create');
|
$routes->post('/', 'Contact\OccupationController::create');
|
||||||
$routes->patch('/', 'Contact\OccupationController::update');
|
$routes->patch('/', 'Contact\OccupationController::update');
|
||||||
//$routes->delete('/', 'Contact\OccupationController::delete');
|
//$routes->delete('/', 'Contact\OccupationController::delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group('medicalspecialty', function ($routes) {
|
$routes->group('medicalspecialty', function ($routes) {
|
||||||
$routes->get('/', 'Contact\MedicalSpecialtyController::index');
|
$routes->get('/', 'Contact\MedicalSpecialtyController::index');
|
||||||
$routes->get('(:num)', 'Contact\MedicalSpecialtyController::show/$1');
|
$routes->get('(:num)', 'Contact\MedicalSpecialtyController::show/$1');
|
||||||
$routes->post('/', 'Contact\MedicalSpecialtyController::create');
|
$routes->post('/', 'Contact\MedicalSpecialtyController::create');
|
||||||
$routes->patch('/', 'Contact\MedicalSpecialtyController::update');
|
$routes->patch('/', 'Contact\MedicalSpecialtyController::update');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Lib ValueSet (file-based)
|
// Lib ValueSet (file-based)
|
||||||
$routes->group('valueset', function ($routes) {
|
$routes->group('valueset', function ($routes) {
|
||||||
$routes->get('/', 'ValueSetController::index');
|
$routes->get('/', 'ValueSetController::index');
|
||||||
$routes->get('(:any)', 'ValueSetController::index/$1');
|
$routes->get('(:any)', 'ValueSetController::index/$1');
|
||||||
$routes->post('refresh', 'ValueSetController::refresh');
|
$routes->post('refresh', 'ValueSetController::refresh');
|
||||||
|
|
||||||
// User ValueSet (database-based)
|
// User ValueSet (database-based)
|
||||||
$routes->group('user', function ($routes) {
|
$routes->group('user', function ($routes) {
|
||||||
$routes->group('items', function ($routes) {
|
$routes->group('items', function ($routes) {
|
||||||
$routes->get('/', 'ValueSetController::items');
|
$routes->get('/', 'ValueSetController::items');
|
||||||
$routes->get('(:num)', 'ValueSetController::showItem/$1');
|
$routes->get('(:num)', 'ValueSetController::showItem/$1');
|
||||||
$routes->post('/', 'ValueSetController::createItem');
|
$routes->post('/', 'ValueSetController::createItem');
|
||||||
$routes->put('(:num)', 'ValueSetController::updateItem/$1');
|
$routes->put('(:num)', 'ValueSetController::updateItem/$1');
|
||||||
$routes->delete('(:num)', 'ValueSetController::deleteItem/$1');
|
$routes->delete('(:num)', 'ValueSetController::deleteItem/$1');
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group('def', function ($routes) {
|
$routes->group('def', function ($routes) {
|
||||||
$routes->get('/', 'ValueSetDefController::index');
|
$routes->get('/', 'ValueSetDefController::index');
|
||||||
$routes->get('(:num)', 'ValueSetDefController::show/$1');
|
$routes->get('(:num)', 'ValueSetDefController::show/$1');
|
||||||
$routes->post('/', 'ValueSetDefController::create');
|
$routes->post('/', 'ValueSetDefController::create');
|
||||||
$routes->put('(:num)', 'ValueSetDefController::update/$1');
|
$routes->put('(:num)', 'ValueSetDefController::update/$1');
|
||||||
$routes->delete('(:num)', 'ValueSetDefController::delete/$1');
|
$routes->delete('(:num)', 'ValueSetDefController::delete/$1');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Result ValueSet
|
// Result ValueSet
|
||||||
$routes->group('result', function ($routes) {
|
$routes->group('result', function ($routes) {
|
||||||
$routes->group('valueset', function ($routes) {
|
$routes->group('valueset', function ($routes) {
|
||||||
$routes->get('/', 'Result\ResultValueSetController::index');
|
$routes->get('/', 'Result\ResultValueSetController::index');
|
||||||
$routes->get('(:num)', 'Result\ResultValueSetController::show/$1');
|
$routes->get('(:num)', 'Result\ResultValueSetController::show/$1');
|
||||||
$routes->post('/', 'Result\ResultValueSetController::create');
|
$routes->post('/', 'Result\ResultValueSetController::create');
|
||||||
$routes->put('(:num)', 'Result\ResultValueSetController::update/$1');
|
$routes->put('(:num)', 'Result\ResultValueSetController::update/$1');
|
||||||
$routes->delete('(:num)', 'Result\ResultValueSetController::delete/$1');
|
$routes->delete('(:num)', 'Result\ResultValueSetController::delete/$1');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->post('calc/(:any)', 'CalculatorController::calculateByCodeOrName/$1');
|
$routes->post('calc/(:any)', 'CalculatorController::calculateByCodeOrName/$1');
|
||||||
|
|
||||||
// Counter
|
// Counter
|
||||||
$routes->group('counter', function ($routes) {
|
$routes->group('counter', function ($routes) {
|
||||||
$routes->get('/', 'CounterController::index');
|
$routes->get('/', 'CounterController::index');
|
||||||
$routes->get('(:num)', 'CounterController::show/$1');
|
$routes->get('(:num)', 'CounterController::show/$1');
|
||||||
$routes->post('/', 'CounterController::create');
|
$routes->post('/', 'CounterController::create');
|
||||||
$routes->patch('/', 'CounterController::update');
|
$routes->patch('/', 'CounterController::update');
|
||||||
$routes->delete('/', 'CounterController::delete');
|
$routes->delete('/', 'CounterController::delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
// AreaGeo
|
// AreaGeo
|
||||||
$routes->group('areageo', function ($routes) {
|
$routes->group('areageo', function ($routes) {
|
||||||
$routes->get('/', 'AreaGeoController::index');
|
$routes->get('/', 'AreaGeoController::index');
|
||||||
$routes->get('provinces', 'AreaGeoController::getProvinces');
|
$routes->get('provinces', 'AreaGeoController::getProvinces');
|
||||||
$routes->get('cities', 'AreaGeoController::getCities');
|
$routes->get('cities', 'AreaGeoController::getCities');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Organization
|
// Organization
|
||||||
$routes->group('organization', function ($routes) {
|
$routes->group('organization', function ($routes) {
|
||||||
// Account
|
// Account
|
||||||
$routes->group('account', function ($routes) {
|
$routes->group('account', function ($routes) {
|
||||||
$routes->get('/', 'Organization\AccountController::index');
|
$routes->get('/', 'Organization\AccountController::index');
|
||||||
$routes->get('(:num)', 'Organization\AccountController::show/$1');
|
$routes->get('(:num)', 'Organization\AccountController::show/$1');
|
||||||
$routes->post('/', 'Organization\AccountController::create');
|
$routes->post('/', 'Organization\AccountController::create');
|
||||||
$routes->patch('/', 'Organization\AccountController::update');
|
$routes->patch('/', 'Organization\AccountController::update');
|
||||||
$routes->delete('/', 'Organization\AccountController::delete');
|
$routes->delete('/', 'Organization\AccountController::delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Site
|
// Site
|
||||||
$routes->group('site', function ($routes) {
|
$routes->group('site', function ($routes) {
|
||||||
$routes->get('/', 'Organization\SiteController::index');
|
$routes->get('/', 'Organization\SiteController::index');
|
||||||
$routes->get('(:num)', 'Organization\SiteController::show/$1');
|
$routes->get('(:num)', 'Organization\SiteController::show/$1');
|
||||||
$routes->post('/', 'Organization\SiteController::create');
|
$routes->post('/', 'Organization\SiteController::create');
|
||||||
$routes->patch('/', 'Organization\SiteController::update');
|
$routes->patch('/', 'Organization\SiteController::update');
|
||||||
$routes->delete('/', 'Organization\SiteController::delete');
|
$routes->delete('/', 'Organization\SiteController::delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Discipline
|
// Discipline
|
||||||
$routes->group('discipline', function ($routes) {
|
$routes->group('discipline', function ($routes) {
|
||||||
$routes->get('/', 'Organization\DisciplineController::index');
|
$routes->get('/', 'Organization\DisciplineController::index');
|
||||||
$routes->get('(:num)', 'Organization\DisciplineController::show/$1');
|
$routes->get('(:num)', 'Organization\DisciplineController::show/$1');
|
||||||
$routes->post('/', 'Organization\DisciplineController::create');
|
$routes->post('/', 'Organization\DisciplineController::create');
|
||||||
$routes->patch('/', 'Organization\DisciplineController::update');
|
$routes->patch('/', 'Organization\DisciplineController::update');
|
||||||
$routes->delete('/', 'Organization\DisciplineController::delete');
|
$routes->delete('/', 'Organization\DisciplineController::delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Department
|
// Department
|
||||||
$routes->group('department', function ($routes) {
|
$routes->group('department', function ($routes) {
|
||||||
$routes->get('/', 'Organization\DepartmentController::index');
|
$routes->get('/', 'Organization\DepartmentController::index');
|
||||||
$routes->get('(:num)', 'Organization\DepartmentController::show/$1');
|
$routes->get('(:num)', 'Organization\DepartmentController::show/$1');
|
||||||
$routes->post('/', 'Organization\DepartmentController::create');
|
$routes->post('/', 'Organization\DepartmentController::create');
|
||||||
$routes->patch('/', 'Organization\DepartmentController::update');
|
$routes->patch('/', 'Organization\DepartmentController::update');
|
||||||
$routes->delete('/', 'Organization\DepartmentController::delete');
|
$routes->delete('/', 'Organization\DepartmentController::delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Workstation
|
// Workstation
|
||||||
$routes->group('workstation', function ($routes) {
|
$routes->group('workstation', function ($routes) {
|
||||||
$routes->get('/', 'Organization\WorkstationController::index');
|
$routes->get('/', 'Organization\WorkstationController::index');
|
||||||
$routes->get('(:num)', 'Organization\WorkstationController::show/$1');
|
$routes->get('(:num)', 'Organization\WorkstationController::show/$1');
|
||||||
$routes->post('/', 'Organization\WorkstationController::create');
|
$routes->post('/', 'Organization\WorkstationController::create');
|
||||||
$routes->patch('/', 'Organization\WorkstationController::update');
|
$routes->patch('/', 'Organization\WorkstationController::update');
|
||||||
$routes->delete('/', 'Organization\WorkstationController::delete');
|
$routes->delete('/', 'Organization\WorkstationController::delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
// HostApp
|
// HostApp
|
||||||
$routes->group('hostapp', function ($routes) {
|
$routes->group('hostapp', function ($routes) {
|
||||||
$routes->get('/', 'Organization\HostAppController::index');
|
$routes->get('/', 'Organization\HostAppController::index');
|
||||||
$routes->get('(:any)', 'Organization\HostAppController::show/$1');
|
$routes->get('(:any)', 'Organization\HostAppController::show/$1');
|
||||||
$routes->post('/', 'Organization\HostAppController::create');
|
$routes->post('/', 'Organization\HostAppController::create');
|
||||||
$routes->patch('/', 'Organization\HostAppController::update');
|
$routes->patch('/', 'Organization\HostAppController::update');
|
||||||
$routes->delete('/', 'Organization\HostAppController::delete');
|
$routes->delete('/', 'Organization\HostAppController::delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
// HostComPara
|
// HostComPara
|
||||||
$routes->group('hostcompara', function ($routes) {
|
$routes->group('hostcompara', function ($routes) {
|
||||||
$routes->get('/', 'Organization\HostComParaController::index');
|
$routes->get('/', 'Organization\HostComParaController::index');
|
||||||
$routes->get('(:any)', 'Organization\HostComParaController::show/$1');
|
$routes->get('(:any)', 'Organization\HostComParaController::show/$1');
|
||||||
$routes->post('/', 'Organization\HostComParaController::create');
|
$routes->post('/', 'Organization\HostComParaController::create');
|
||||||
$routes->patch('/', 'Organization\HostComParaController::update');
|
$routes->patch('/', 'Organization\HostComParaController::update');
|
||||||
$routes->delete('/', 'Organization\HostComParaController::delete');
|
$routes->delete('/', 'Organization\HostComParaController::delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
// CodingSys
|
// CodingSys
|
||||||
$routes->group('codingsys', function ($routes) {
|
$routes->group('codingsys', function ($routes) {
|
||||||
$routes->get('/', 'Organization\CodingSysController::index');
|
$routes->get('/', 'Organization\CodingSysController::index');
|
||||||
$routes->get('(:num)', 'Organization\CodingSysController::show/$1');
|
$routes->get('(:num)', 'Organization\CodingSysController::show/$1');
|
||||||
$routes->post('/', 'Organization\CodingSysController::create');
|
$routes->post('/', 'Organization\CodingSysController::create');
|
||||||
$routes->patch('/', 'Organization\CodingSysController::update');
|
$routes->patch('/', 'Organization\CodingSysController::update');
|
||||||
$routes->delete('/', 'Organization\CodingSysController::delete');
|
$routes->delete('/', 'Organization\CodingSysController::delete');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Infrastructure
|
// Infrastructure
|
||||||
$routes->group('equipmentlist', function ($routes) {
|
$routes->group('equipmentlist', function ($routes) {
|
||||||
$routes->get('/', 'Infrastructure\EquipmentListController::index');
|
$routes->get('/', 'Infrastructure\EquipmentListController::index');
|
||||||
$routes->get('(:num)', 'Infrastructure\EquipmentListController::show/$1');
|
$routes->get('(:num)', 'Infrastructure\EquipmentListController::show/$1');
|
||||||
$routes->post('/', 'Infrastructure\EquipmentListController::create');
|
$routes->post('/', 'Infrastructure\EquipmentListController::create');
|
||||||
$routes->patch('/', 'Infrastructure\EquipmentListController::update');
|
$routes->patch('/', 'Infrastructure\EquipmentListController::update');
|
||||||
$routes->delete('/', 'Infrastructure\EquipmentListController::delete');
|
$routes->delete('/', 'Infrastructure\EquipmentListController::delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Users
|
// Users
|
||||||
$routes->group('users', function ($routes) {
|
$routes->group('users', function ($routes) {
|
||||||
$routes->get('/', 'User\UserController::index');
|
$routes->get('/', 'User\UserController::index');
|
||||||
$routes->get('(:num)', 'User\UserController::show/$1');
|
$routes->get('(:num)', 'User\UserController::show/$1');
|
||||||
$routes->post('/', 'User\UserController::create');
|
$routes->post('/', 'User\UserController::create');
|
||||||
$routes->patch('/', 'User\UserController::update');
|
$routes->patch('/', 'User\UserController::update');
|
||||||
$routes->delete('(:num)', 'User\UserController::delete/$1');
|
$routes->delete('(:num)', 'User\UserController::delete/$1');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Specimen
|
// Specimen
|
||||||
$routes->group('specimen', function ($routes) {
|
$routes->group('specimen', function ($routes) {
|
||||||
// Container aliases - 'container' and 'containerdef' both point to ContainerDefController
|
// Container aliases - 'container' and 'containerdef' both point to ContainerDefController
|
||||||
$routes->group('container', function ($routes) {
|
$routes->group('container', function ($routes) {
|
||||||
$routes->get('/', 'Specimen\ContainerDefController::index');
|
$routes->get('/', 'Specimen\ContainerDefController::index');
|
||||||
$routes->get('(:num)', 'Specimen\ContainerDefController::show/$1');
|
$routes->get('(:num)', 'Specimen\ContainerDefController::show/$1');
|
||||||
$routes->post('/', 'Specimen\ContainerDefController::create');
|
$routes->post('/', 'Specimen\ContainerDefController::create');
|
||||||
$routes->patch('/', 'Specimen\ContainerDefController::update');
|
$routes->patch('/', 'Specimen\ContainerDefController::update');
|
||||||
});
|
});
|
||||||
$routes->group('containerdef', function ($routes) {
|
$routes->group('containerdef', function ($routes) {
|
||||||
$routes->get('/', 'Specimen\ContainerDefController::index');
|
$routes->get('/', 'Specimen\ContainerDefController::index');
|
||||||
$routes->get('(:num)', 'Specimen\ContainerDefController::show/$1');
|
$routes->get('(:num)', 'Specimen\ContainerDefController::show/$1');
|
||||||
$routes->post('/', 'Specimen\ContainerDefController::create');
|
$routes->post('/', 'Specimen\ContainerDefController::create');
|
||||||
$routes->patch('/', 'Specimen\ContainerDefController::update');
|
$routes->patch('/', 'Specimen\ContainerDefController::update');
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group('prep', function ($routes) {
|
$routes->group('prep', function ($routes) {
|
||||||
$routes->get('/', 'Specimen\SpecimenPrepController::index');
|
$routes->get('/', 'Specimen\SpecimenPrepController::index');
|
||||||
$routes->get('(:num)', 'Specimen\SpecimenPrepController::show/$1');
|
$routes->get('(:num)', 'Specimen\SpecimenPrepController::show/$1');
|
||||||
$routes->post('/', 'Specimen\SpecimenPrepController::create');
|
$routes->post('/', 'Specimen\SpecimenPrepController::create');
|
||||||
$routes->patch('/', 'Specimen\SpecimenPrepController::update');
|
$routes->patch('/', 'Specimen\SpecimenPrepController::update');
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group('status', function ($routes) {
|
$routes->group('status', function ($routes) {
|
||||||
$routes->get('/', 'Specimen\SpecimenStatusController::index');
|
$routes->get('/', 'Specimen\SpecimenStatusController::index');
|
||||||
$routes->get('(:num)', 'Specimen\SpecimenStatusController::show/$1');
|
$routes->get('(:num)', 'Specimen\SpecimenStatusController::show/$1');
|
||||||
$routes->post('/', 'Specimen\SpecimenStatusController::create');
|
$routes->post('/', 'Specimen\SpecimenStatusController::create');
|
||||||
$routes->patch('/', 'Specimen\SpecimenStatusController::update');
|
$routes->patch('/', 'Specimen\SpecimenStatusController::update');
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group('collection', function ($routes) {
|
$routes->group('collection', function ($routes) {
|
||||||
$routes->get('/', 'Specimen\SpecimenCollectionController::index');
|
$routes->get('/', 'Specimen\SpecimenCollectionController::index');
|
||||||
$routes->get('(:num)', 'Specimen\SpecimenCollectionController::show/$1');
|
$routes->get('(:num)', 'Specimen\SpecimenCollectionController::show/$1');
|
||||||
$routes->post('/', 'Specimen\SpecimenCollectionController::create');
|
$routes->post('/', 'Specimen\SpecimenCollectionController::create');
|
||||||
$routes->patch('/', 'Specimen\SpecimenCollectionController::update');
|
$routes->patch('/', 'Specimen\SpecimenCollectionController::update');
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->get('/', 'Specimen\SpecimenController::index');
|
$routes->get('/', 'Specimen\SpecimenController::index');
|
||||||
$routes->get('(:num)', 'Specimen\SpecimenController::show/$1');
|
$routes->get('(:num)', 'Specimen\SpecimenController::show/$1');
|
||||||
$routes->post('/', 'Specimen\SpecimenController::create');
|
$routes->post('/', 'Specimen\SpecimenController::create');
|
||||||
$routes->patch('/', 'Specimen\SpecimenController::update');
|
$routes->patch('/', 'Specimen\SpecimenController::update');
|
||||||
$routes->delete('(:num)', 'Specimen\SpecimenController::delete/$1');
|
$routes->delete('(:num)', 'Specimen\SpecimenController::delete/$1');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test Mapping
|
// Test Mapping
|
||||||
$routes->group('test', function ($routes) {
|
$routes->group('test', function ($routes) {
|
||||||
$routes->get('/', 'Test\TestsController::index');
|
$routes->get('/', 'Test\TestsController::index');
|
||||||
$routes->get('(:num)', 'Test\TestsController::show/$1');
|
$routes->get('(:num)', 'Test\TestsController::show/$1');
|
||||||
$routes->post('/', 'Test\TestsController::create');
|
$routes->post('/', 'Test\TestsController::create');
|
||||||
$routes->patch('/', 'Test\TestsController::update');
|
$routes->patch('/', 'Test\TestsController::update');
|
||||||
$routes->group('testmap', function ($routes) {
|
$routes->group('testmap', function ($routes) {
|
||||||
$routes->get('/', 'Test\TestMapController::index');
|
$routes->get('/', 'Test\TestMapController::index');
|
||||||
$routes->get('(:num)', 'Test\TestMapController::show/$1');
|
$routes->get('(:num)', 'Test\TestMapController::show/$1');
|
||||||
$routes->post('/', 'Test\TestMapController::create');
|
$routes->post('/', 'Test\TestMapController::create');
|
||||||
$routes->patch('/', 'Test\TestMapController::update');
|
$routes->patch('/', 'Test\TestMapController::update');
|
||||||
$routes->delete('/', 'Test\TestMapController::delete');
|
$routes->delete('/', 'Test\TestMapController::delete');
|
||||||
|
|
||||||
// Filter routes
|
// Filter routes
|
||||||
$routes->get('by-testcode/(:any)', 'Test\TestMapController::showByTestCode/$1');
|
$routes->get('by-testcode/(:any)', 'Test\TestMapController::showByTestCode/$1');
|
||||||
|
|
||||||
// TestMapDetail nested routes
|
// TestMapDetail nested routes
|
||||||
$routes->group('detail', function ($routes) {
|
$routes->group('detail', function ($routes) {
|
||||||
$routes->get('/', 'Test\TestMapDetailController::index');
|
$routes->get('/', 'Test\TestMapDetailController::index');
|
||||||
$routes->get('(:num)', 'Test\TestMapDetailController::show/$1');
|
$routes->get('(:num)', 'Test\TestMapDetailController::show/$1');
|
||||||
$routes->post('/', 'Test\TestMapDetailController::create');
|
$routes->post('/', 'Test\TestMapDetailController::create');
|
||||||
$routes->patch('/', 'Test\TestMapDetailController::update');
|
$routes->patch('/', 'Test\TestMapDetailController::update');
|
||||||
$routes->delete('/', 'Test\TestMapDetailController::delete');
|
$routes->delete('/', 'Test\TestMapDetailController::delete');
|
||||||
$routes->get('by-testmap/(:num)', 'Test\TestMapDetailController::showByTestMap/$1');
|
$routes->get('by-testmap/(:num)', 'Test\TestMapDetailController::showByTestMap/$1');
|
||||||
$routes->post('batch', 'Test\TestMapDetailController::batchCreate');
|
$routes->post('batch', 'Test\TestMapDetailController::batchCreate');
|
||||||
$routes->patch('batch', 'Test\TestMapDetailController::batchUpdate');
|
$routes->patch('batch', 'Test\TestMapDetailController::batchUpdate');
|
||||||
$routes->delete('batch', 'Test\TestMapDetailController::batchDelete');
|
$routes->delete('batch', 'Test\TestMapDetailController::batchDelete');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Orders
|
// Orders
|
||||||
$routes->group('ordertest', function ($routes) {
|
$routes->group('ordertest', function ($routes) {
|
||||||
$routes->get('/', 'OrderTestController::index');
|
$routes->get('/', 'OrderTestController::index');
|
||||||
$routes->get('(:any)', 'OrderTestController::show/$1');
|
$routes->get('(:any)', 'OrderTestController::show/$1');
|
||||||
$routes->post('/', 'OrderTestController::create');
|
$routes->post('/', 'OrderTestController::create');
|
||||||
$routes->patch('/', 'OrderTestController::update');
|
$routes->patch('/', 'OrderTestController::update');
|
||||||
$routes->delete('/', 'OrderTestController::delete');
|
$routes->delete('/', 'OrderTestController::delete');
|
||||||
$routes->post('status', 'OrderTestController::updateStatus');
|
$routes->post('status', 'OrderTestController::updateStatus');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Rules
|
// Rules
|
||||||
$routes->group('rules', function ($routes) {
|
$routes->group('rules', function ($routes) {
|
||||||
$routes->get('/', 'Rule\RuleController::index');
|
$routes->get('/', 'Rule\RuleController::index');
|
||||||
$routes->get('(:num)', 'Rule\RuleController::show/$1');
|
$routes->get('(:num)', 'Rule\RuleController::show/$1');
|
||||||
$routes->post('/', 'Rule\RuleController::create');
|
$routes->post('/', 'Rule\RuleController::create');
|
||||||
$routes->patch('(:num)', 'Rule\RuleController::update/$1');
|
$routes->patch('(:num)', 'Rule\RuleController::update/$1');
|
||||||
$routes->delete('(:num)', 'Rule\RuleController::delete/$1');
|
$routes->delete('(:num)', 'Rule\RuleController::delete/$1');
|
||||||
$routes->post('validate', 'Rule\RuleController::validateExpr');
|
$routes->post('validate', 'Rule\RuleController::validateExpr');
|
||||||
$routes->post('compile', 'Rule\RuleController::compile');
|
$routes->post('compile', 'Rule\RuleController::compile');
|
||||||
|
|
||||||
$routes->get('(:num)/actions', 'Rule\RuleActionController::index/$1');
|
|
||||||
$routes->post('(:num)/actions', 'Rule\RuleActionController::create/$1');
|
|
||||||
$routes->patch('(:num)/actions/(:num)', 'Rule\RuleActionController::update/$1/$2');
|
|
||||||
$routes->delete('(:num)/actions/(:num)', 'Rule\RuleActionController::delete/$1/$2');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Demo/Test Routes (No Auth)
|
// Demo/Test Routes (No Auth)
|
||||||
$routes->group('api/demo', function ($routes) {
|
$routes->group('api/demo', function ($routes) {
|
||||||
$routes->post('order', 'Test\DemoOrderController::createDemoOrder');
|
$routes->post('order', 'Test\DemoOrderController::createDemoOrder');
|
||||||
$routes->get('orders', 'Test\DemoOrderController::listDemoOrders');
|
$routes->get('orders', 'Test\DemoOrderController::listDemoOrders');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Edge API - Integration with tiny-edge
|
// Edge API - Integration with tiny-edge
|
||||||
$routes->group('edge', function ($routes) {
|
$routes->group('edge', function ($routes) {
|
||||||
$routes->post('results', 'EdgeController::results');
|
$routes->post('results', 'EdgeController::results');
|
||||||
$routes->get('orders', 'EdgeController::orders');
|
$routes->get('orders', 'EdgeController::orders');
|
||||||
$routes->post('orders/(:num)/ack', 'EdgeController::ack/$1');
|
$routes->post('orders/(:num)/ack', 'EdgeController::ack/$1');
|
||||||
$routes->post('status', 'EdgeController::status');
|
$routes->post('status', 'EdgeController::status');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Khusus
|
// Khusus
|
||||||
/*
|
/*
|
||||||
$routes->get('/api/zones', 'Zones::index');
|
$routes->get('/api/zones', 'Zones::index');
|
||||||
$routes->get('/api/zones/synchronize', 'Zones::synchronize');
|
$routes->get('/api/zones/synchronize', 'Zones::synchronize');
|
||||||
$routes->get('/api/zones/provinces', 'Zones::getProvinces');
|
$routes->get('/api/zones/provinces', 'Zones::getProvinces');
|
||||||
$routes->get('/api/zones/cities', 'Zones::getCities');
|
$routes->get('/api/zones/cities', 'Zones::getCities');
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@ -1,140 +1,140 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of CodeIgniter 4 framework.
|
* This file is part of CodeIgniter 4 framework.
|
||||||
*
|
*
|
||||||
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\Routing as BaseRouting;
|
use CodeIgniter\Config\Routing as BaseRouting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Routing configuration
|
* Routing configuration
|
||||||
*/
|
*/
|
||||||
class Routing extends BaseRouting
|
class Routing extends BaseRouting
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* For Defined Routes.
|
* For Defined Routes.
|
||||||
* An array of files that contain route definitions.
|
* An array of files that contain route definitions.
|
||||||
* Route files are read in order, with the first match
|
* Route files are read in order, with the first match
|
||||||
* found taking precedence.
|
* found taking precedence.
|
||||||
*
|
*
|
||||||
* Default: APPPATH . 'Config/Routes.php'
|
* Default: APPPATH . 'Config/Routes.php'
|
||||||
*
|
*
|
||||||
* @var list<string>
|
* @var list<string>
|
||||||
*/
|
*/
|
||||||
public array $routeFiles = [
|
public array $routeFiles = [
|
||||||
APPPATH . 'Config/Routes.php',
|
APPPATH . 'Config/Routes.php',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For Defined Routes and Auto Routing.
|
* For Defined Routes and Auto Routing.
|
||||||
* The default namespace to use for Controllers when no other
|
* The default namespace to use for Controllers when no other
|
||||||
* namespace has been specified.
|
* namespace has been specified.
|
||||||
*
|
*
|
||||||
* Default: 'App\Controllers'
|
* Default: 'App\Controllers'
|
||||||
*/
|
*/
|
||||||
public string $defaultNamespace = 'App\Controllers';
|
public string $defaultNamespace = 'App\Controllers';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For Auto Routing.
|
* For Auto Routing.
|
||||||
* The default controller to use when no other controller has been
|
* The default controller to use when no other controller has been
|
||||||
* specified.
|
* specified.
|
||||||
*
|
*
|
||||||
* Default: 'Home'
|
* Default: 'Home'
|
||||||
*/
|
*/
|
||||||
public string $defaultController = 'Home';
|
public string $defaultController = 'Home';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For Defined Routes and Auto Routing.
|
* For Defined Routes and Auto Routing.
|
||||||
* The default method to call on the controller when no other
|
* The default method to call on the controller when no other
|
||||||
* method has been set in the route.
|
* method has been set in the route.
|
||||||
*
|
*
|
||||||
* Default: 'index'
|
* Default: 'index'
|
||||||
*/
|
*/
|
||||||
public string $defaultMethod = 'index';
|
public string $defaultMethod = 'index';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For Auto Routing.
|
* For Auto Routing.
|
||||||
* Whether to translate dashes in URIs for controller/method to underscores.
|
* Whether to translate dashes in URIs for controller/method to underscores.
|
||||||
* Primarily useful when using the auto-routing.
|
* Primarily useful when using the auto-routing.
|
||||||
*
|
*
|
||||||
* Default: false
|
* Default: false
|
||||||
*/
|
*/
|
||||||
public bool $translateURIDashes = false;
|
public bool $translateURIDashes = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the class/method that should be called if routing doesn't
|
* 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
|
* find a match. It can be the controller/method name like: Users::index
|
||||||
*
|
*
|
||||||
* This setting is passed to the Router class and handled there.
|
* 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
|
* If you want to use a closure, you will have to set it in the
|
||||||
* routes file by calling:
|
* routes file by calling:
|
||||||
*
|
*
|
||||||
* $routes->set404Override(function() {
|
* $routes->set404Override(function() {
|
||||||
* // Do something here
|
* // Do something here
|
||||||
* });
|
* });
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* public $override404 = 'App\Errors::show404';
|
* public $override404 = 'App\Errors::show404';
|
||||||
*/
|
*/
|
||||||
public ?string $override404 = null;
|
public ?string $override404 = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If TRUE, the system will attempt to match the URI against
|
* If TRUE, the system will attempt to match the URI against
|
||||||
* Controllers by matching each segment against folders/files
|
* Controllers by matching each segment against folders/files
|
||||||
* in APPPATH/Controllers, when a match wasn't found against
|
* in APPPATH/Controllers, when a match wasn't found against
|
||||||
* defined routes.
|
* defined routes.
|
||||||
*
|
*
|
||||||
* If FALSE, will stop searching and do NO automatic routing.
|
* If FALSE, will stop searching and do NO automatic routing.
|
||||||
*/
|
*/
|
||||||
public bool $autoRoute = false;
|
public bool $autoRoute = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For Defined Routes.
|
* For Defined Routes.
|
||||||
* If TRUE, will enable the use of the 'prioritize' option
|
* If TRUE, will enable the use of the 'prioritize' option
|
||||||
* when defining routes.
|
* when defining routes.
|
||||||
*
|
*
|
||||||
* Default: false
|
* Default: false
|
||||||
*/
|
*/
|
||||||
public bool $prioritize = false;
|
public bool $prioritize = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For Defined Routes.
|
* For Defined Routes.
|
||||||
* If TRUE, matched multiple URI segments will be passed as one parameter.
|
* If TRUE, matched multiple URI segments will be passed as one parameter.
|
||||||
*
|
*
|
||||||
* Default: false
|
* Default: false
|
||||||
*/
|
*/
|
||||||
public bool $multipleSegmentsOneParam = false;
|
public bool $multipleSegmentsOneParam = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For Auto Routing (Improved).
|
* For Auto Routing (Improved).
|
||||||
* Map of URI segments and namespaces.
|
* Map of URI segments and namespaces.
|
||||||
*
|
*
|
||||||
* The key is the first URI segment. The value is the controller namespace.
|
* The key is the first URI segment. The value is the controller namespace.
|
||||||
* E.g.,
|
* E.g.,
|
||||||
* [
|
* [
|
||||||
* 'blog' => 'Acme\Blog\Controllers',
|
* 'blog' => 'Acme\Blog\Controllers',
|
||||||
* ]
|
* ]
|
||||||
*
|
*
|
||||||
* @var array<string, string>
|
* @var array<string, string>
|
||||||
*/
|
*/
|
||||||
public array $moduleRoutes = [];
|
public array $moduleRoutes = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For Auto Routing (Improved).
|
* For Auto Routing (Improved).
|
||||||
* Whether to translate dashes in URIs for controller/method to CamelCase.
|
* Whether to translate dashes in URIs for controller/method to CamelCase.
|
||||||
* E.g., blog-controller -> BlogController
|
* E.g., blog-controller -> BlogController
|
||||||
*
|
*
|
||||||
* If you enable this, $translateURIDashes is ignored.
|
* If you enable this, $translateURIDashes is ignored.
|
||||||
*
|
*
|
||||||
* Default: false
|
* Default: false
|
||||||
*/
|
*/
|
||||||
public bool $translateUriToCamelCase = true;
|
public bool $translateUriToCamelCase = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,86 +1,86 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
class Security extends BaseConfig
|
class Security extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* CSRF Protection Method
|
* CSRF Protection Method
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Protection Method for Cross Site Request Forgery protection.
|
* Protection Method for Cross Site Request Forgery protection.
|
||||||
*
|
*
|
||||||
* @var string 'cookie' or 'session'
|
* @var string 'cookie' or 'session'
|
||||||
*/
|
*/
|
||||||
public string $csrfProtection = 'cookie';
|
public string $csrfProtection = 'cookie';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* CSRF Token Randomization
|
* CSRF Token Randomization
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Randomize the CSRF Token for added security.
|
* Randomize the CSRF Token for added security.
|
||||||
*/
|
*/
|
||||||
public bool $tokenRandomize = false;
|
public bool $tokenRandomize = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* CSRF Token Name
|
* CSRF Token Name
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Token name for Cross Site Request Forgery protection.
|
* Token name for Cross Site Request Forgery protection.
|
||||||
*/
|
*/
|
||||||
public string $tokenName = 'csrf_test_name';
|
public string $tokenName = 'csrf_test_name';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* CSRF Header Name
|
* CSRF Header Name
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Header name for Cross Site Request Forgery protection.
|
* Header name for Cross Site Request Forgery protection.
|
||||||
*/
|
*/
|
||||||
public string $headerName = 'X-CSRF-TOKEN';
|
public string $headerName = 'X-CSRF-TOKEN';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* CSRF Cookie Name
|
* CSRF Cookie Name
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Cookie name for Cross Site Request Forgery protection.
|
* Cookie name for Cross Site Request Forgery protection.
|
||||||
*/
|
*/
|
||||||
public string $cookieName = 'csrf_cookie_name';
|
public string $cookieName = 'csrf_cookie_name';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* CSRF Expires
|
* CSRF Expires
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Expiration time for Cross Site Request Forgery protection cookie.
|
* Expiration time for Cross Site Request Forgery protection cookie.
|
||||||
*
|
*
|
||||||
* Defaults to two hours (in seconds).
|
* Defaults to two hours (in seconds).
|
||||||
*/
|
*/
|
||||||
public int $expires = 7200;
|
public int $expires = 7200;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* CSRF Regenerate
|
* CSRF Regenerate
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Regenerate CSRF Token on every submission.
|
* Regenerate CSRF Token on every submission.
|
||||||
*/
|
*/
|
||||||
public bool $regenerate = true;
|
public bool $regenerate = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* CSRF Redirect
|
* CSRF Redirect
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Redirect to previous page with error on failure.
|
* Redirect to previous page with error on failure.
|
||||||
*
|
*
|
||||||
* @see https://codeigniter4.github.io/userguide/libraries/security.html#redirection-on-failure
|
* @see https://codeigniter4.github.io/userguide/libraries/security.html#redirection-on-failure
|
||||||
*/
|
*/
|
||||||
public bool $redirect = (ENVIRONMENT === 'production');
|
public bool $redirect = (ENVIRONMENT === 'production');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,32 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseService;
|
use CodeIgniter\Config\BaseService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Services Configuration file.
|
* Services Configuration file.
|
||||||
*
|
*
|
||||||
* Services are simply other classes/libraries that the system uses
|
* 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
|
* 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
|
* framework to be swapped out easily without affecting the usage within
|
||||||
* the rest of your application.
|
* the rest of your application.
|
||||||
*
|
*
|
||||||
* This file holds any application-specific services, or service overrides
|
* This file holds any application-specific services, or service overrides
|
||||||
* that you might need. An example has been included with the general
|
* that you might need. An example has been included with the general
|
||||||
* method format you should use for your service methods. For more examples,
|
* method format you should use for your service methods. For more examples,
|
||||||
* see the core Services file at system/Config/Services.php.
|
* see the core Services file at system/Config/Services.php.
|
||||||
*/
|
*/
|
||||||
class Services extends BaseService
|
class Services extends BaseService
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* public static function example($getShared = true)
|
* public static function example($getShared = true)
|
||||||
* {
|
* {
|
||||||
* if ($getShared) {
|
* if ($getShared) {
|
||||||
* return static::getSharedInstance('example');
|
* return static::getSharedInstance('example');
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* return new \CodeIgniter\Example();
|
* return new \CodeIgniter\Example();
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,127 +1,127 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
use CodeIgniter\Session\Handlers\BaseHandler;
|
use CodeIgniter\Session\Handlers\BaseHandler;
|
||||||
use CodeIgniter\Session\Handlers\FileHandler;
|
use CodeIgniter\Session\Handlers\FileHandler;
|
||||||
|
|
||||||
class Session extends BaseConfig
|
class Session extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Session Driver
|
* Session Driver
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* The session storage driver to use:
|
* The session storage driver to use:
|
||||||
* - `CodeIgniter\Session\Handlers\FileHandler`
|
* - `CodeIgniter\Session\Handlers\FileHandler`
|
||||||
* - `CodeIgniter\Session\Handlers\DatabaseHandler`
|
* - `CodeIgniter\Session\Handlers\DatabaseHandler`
|
||||||
* - `CodeIgniter\Session\Handlers\MemcachedHandler`
|
* - `CodeIgniter\Session\Handlers\MemcachedHandler`
|
||||||
* - `CodeIgniter\Session\Handlers\RedisHandler`
|
* - `CodeIgniter\Session\Handlers\RedisHandler`
|
||||||
*
|
*
|
||||||
* @var class-string<BaseHandler>
|
* @var class-string<BaseHandler>
|
||||||
*/
|
*/
|
||||||
public string $driver = FileHandler::class;
|
public string $driver = FileHandler::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Session Cookie Name
|
* Session Cookie Name
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* The session cookie name, must contain only [0-9a-z_-] characters
|
* The session cookie name, must contain only [0-9a-z_-] characters
|
||||||
*/
|
*/
|
||||||
public string $cookieName = 'ci_session';
|
public string $cookieName = 'ci_session';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Session Expiration
|
* Session Expiration
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* The number of SECONDS you want the session to last.
|
* The number of SECONDS you want the session to last.
|
||||||
* Setting to 0 (zero) means expire when the browser is closed.
|
* Setting to 0 (zero) means expire when the browser is closed.
|
||||||
*/
|
*/
|
||||||
public int $expiration = 7200;
|
public int $expiration = 7200;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Session Save Path
|
* Session Save Path
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* The location to save sessions to and is driver dependent.
|
* The location to save sessions to and is driver dependent.
|
||||||
*
|
*
|
||||||
* For the 'files' driver, it's a path to a writable directory.
|
* For the 'files' driver, it's a path to a writable directory.
|
||||||
* WARNING: Only absolute paths are supported!
|
* WARNING: Only absolute paths are supported!
|
||||||
*
|
*
|
||||||
* For the 'database' driver, it's a table name.
|
* For the 'database' driver, it's a table name.
|
||||||
* Please read up the manual for the format with other session drivers.
|
* Please read up the manual for the format with other session drivers.
|
||||||
*
|
*
|
||||||
* IMPORTANT: You are REQUIRED to set a valid save path!
|
* IMPORTANT: You are REQUIRED to set a valid save path!
|
||||||
*/
|
*/
|
||||||
public string $savePath = WRITEPATH . 'session';
|
public string $savePath = WRITEPATH . 'session';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Session Match IP
|
* Session Match IP
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Whether to match the user's IP address when reading the session data.
|
* 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
|
* WARNING: If you're using the database driver, don't forget to update
|
||||||
* your session table's PRIMARY KEY when changing this setting.
|
* your session table's PRIMARY KEY when changing this setting.
|
||||||
*/
|
*/
|
||||||
public bool $matchIP = false;
|
public bool $matchIP = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Session Time to Update
|
* Session Time to Update
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* How many seconds between CI regenerating the session ID.
|
* How many seconds between CI regenerating the session ID.
|
||||||
*/
|
*/
|
||||||
public int $timeToUpdate = 300;
|
public int $timeToUpdate = 300;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Session Regenerate Destroy
|
* Session Regenerate Destroy
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Whether to destroy session data associated with the old session ID
|
* Whether to destroy session data associated with the old session ID
|
||||||
* when auto-regenerating the session ID. When set to FALSE, the data
|
* when auto-regenerating the session ID. When set to FALSE, the data
|
||||||
* will be later deleted by the garbage collector.
|
* will be later deleted by the garbage collector.
|
||||||
*/
|
*/
|
||||||
public bool $regenerateDestroy = false;
|
public bool $regenerateDestroy = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Session Database Group
|
* Session Database Group
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* DB Group for the database session.
|
* DB Group for the database session.
|
||||||
*/
|
*/
|
||||||
public ?string $DBGroup = null;
|
public ?string $DBGroup = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Lock Retry Interval (microseconds)
|
* Lock Retry Interval (microseconds)
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This is used for RedisHandler.
|
* This is used for RedisHandler.
|
||||||
*
|
*
|
||||||
* Time (microseconds) to wait if lock cannot be acquired.
|
* Time (microseconds) to wait if lock cannot be acquired.
|
||||||
* The default is 100,000 microseconds (= 0.1 seconds).
|
* The default is 100,000 microseconds (= 0.1 seconds).
|
||||||
*/
|
*/
|
||||||
public int $lockRetryInterval = 100_000;
|
public int $lockRetryInterval = 100_000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Lock Max Retries
|
* Lock Max Retries
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This is used for RedisHandler.
|
* This is used for RedisHandler.
|
||||||
*
|
*
|
||||||
* Maximum number of lock acquisition attempts.
|
* Maximum number of lock acquisition attempts.
|
||||||
* The default is 300 times. That is lock timeout is about 30 (0.1 * 300)
|
* The default is 300 times. That is lock timeout is about 30 (0.1 * 300)
|
||||||
* seconds.
|
* seconds.
|
||||||
*/
|
*/
|
||||||
public int $lockMaxRetries = 300;
|
public int $lockMaxRetries = 300;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,122 +1,122 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
use CodeIgniter\Debug\Toolbar\Collectors\Database;
|
use CodeIgniter\Debug\Toolbar\Collectors\Database;
|
||||||
use CodeIgniter\Debug\Toolbar\Collectors\Events;
|
use CodeIgniter\Debug\Toolbar\Collectors\Events;
|
||||||
use CodeIgniter\Debug\Toolbar\Collectors\Files;
|
use CodeIgniter\Debug\Toolbar\Collectors\Files;
|
||||||
use CodeIgniter\Debug\Toolbar\Collectors\Logs;
|
use CodeIgniter\Debug\Toolbar\Collectors\Logs;
|
||||||
use CodeIgniter\Debug\Toolbar\Collectors\Routes;
|
use CodeIgniter\Debug\Toolbar\Collectors\Routes;
|
||||||
use CodeIgniter\Debug\Toolbar\Collectors\Timers;
|
use CodeIgniter\Debug\Toolbar\Collectors\Timers;
|
||||||
use CodeIgniter\Debug\Toolbar\Collectors\Views;
|
use CodeIgniter\Debug\Toolbar\Collectors\Views;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Debug Toolbar
|
* Debug Toolbar
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* The Debug Toolbar provides a way to see information about the performance
|
* 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
|
* and state of your application during that page display. By default it will
|
||||||
* NOT be displayed under production environments, and will only display if
|
* 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.
|
* `CI_DEBUG` is true, since if it's not, there's not much to display anyway.
|
||||||
*/
|
*/
|
||||||
class Toolbar extends BaseConfig
|
class Toolbar extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Toolbar Collectors
|
* Toolbar Collectors
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* List of toolbar collectors that will be called when Debug Toolbar
|
* List of toolbar collectors that will be called when Debug Toolbar
|
||||||
* fires up and collects data from.
|
* fires up and collects data from.
|
||||||
*
|
*
|
||||||
* @var list<class-string>
|
* @var list<class-string>
|
||||||
*/
|
*/
|
||||||
public array $collectors = [
|
public array $collectors = [
|
||||||
Timers::class,
|
Timers::class,
|
||||||
Database::class,
|
Database::class,
|
||||||
Logs::class,
|
Logs::class,
|
||||||
Views::class,
|
Views::class,
|
||||||
// \CodeIgniter\Debug\Toolbar\Collectors\Cache::class,
|
// \CodeIgniter\Debug\Toolbar\Collectors\Cache::class,
|
||||||
Files::class,
|
Files::class,
|
||||||
Routes::class,
|
Routes::class,
|
||||||
Events::class,
|
Events::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Collect Var Data
|
* Collect Var Data
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* If set to false var data from the views will not be collected. Useful to
|
* 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.
|
* avoid high memory usage when there are lots of data passed to the view.
|
||||||
*/
|
*/
|
||||||
public bool $collectVarData = true;
|
public bool $collectVarData = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Max History
|
* Max History
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* `$maxHistory` sets a limit on the number of past requests that are stored,
|
* `$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
|
* 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.
|
* 0 (zero) to not have any history stored, or -1 for unlimited history.
|
||||||
*/
|
*/
|
||||||
public int $maxHistory = 20;
|
public int $maxHistory = 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Toolbar Views Path
|
* Toolbar Views Path
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* The full path to the the views that are used by the toolbar.
|
* The full path to the the views that are used by the toolbar.
|
||||||
* This MUST have a trailing slash.
|
* This MUST have a trailing slash.
|
||||||
*/
|
*/
|
||||||
public string $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/';
|
public string $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Max Queries
|
* Max Queries
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* If the Database Collector is enabled, it will log every query that the
|
* 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
|
* 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
|
* and in the query log. This can lead to memory issues in some instances
|
||||||
* with hundreds of queries.
|
* with hundreds of queries.
|
||||||
*
|
*
|
||||||
* `$maxQueries` defines the maximum amount of queries that will be stored.
|
* `$maxQueries` defines the maximum amount of queries that will be stored.
|
||||||
*/
|
*/
|
||||||
public int $maxQueries = 100;
|
public int $maxQueries = 100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Watched Directories
|
* Watched Directories
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Contains an array of directories that will be watched for changes and
|
* 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.
|
* 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.
|
* We restrict the values to keep performance as high as possible.
|
||||||
*
|
*
|
||||||
* NOTE: The ROOTPATH will be prepended to all values.
|
* NOTE: The ROOTPATH will be prepended to all values.
|
||||||
*
|
*
|
||||||
* @var list<string>
|
* @var list<string>
|
||||||
*/
|
*/
|
||||||
public array $watchedDirectories = [
|
public array $watchedDirectories = [
|
||||||
'app',
|
'app',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Watched File Extensions
|
* Watched File Extensions
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Contains an array of file extensions that will be watched for changes and
|
* 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.
|
* used to determine if the hot-reload feature should reload the page or not.
|
||||||
*
|
*
|
||||||
* @var list<string>
|
* @var list<string>
|
||||||
*/
|
*/
|
||||||
public array $watchedExtensions = [
|
public array $watchedExtensions = [
|
||||||
'php', 'css', 'js', 'html', 'svg', 'json', 'env',
|
'php', 'css', 'js', 'html', 'svg', 'json', 'env',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,252 +1,252 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
* User Agents
|
* User Agents
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* This file contains four arrays of user agent data. It is used by the
|
* This file contains four arrays of user agent data. It is used by the
|
||||||
* User Agent Class to help identify browser, platform, robot, and
|
* User Agent Class to help identify browser, platform, robot, and
|
||||||
* mobile device data. The array keys are used to identify the device
|
* 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.
|
* and the array values are used to set the actual name of the item.
|
||||||
*/
|
*/
|
||||||
class UserAgents extends BaseConfig
|
class UserAgents extends BaseConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
* OS Platforms
|
* OS Platforms
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* @var array<string, string>
|
* @var array<string, string>
|
||||||
*/
|
*/
|
||||||
public array $platforms = [
|
public array $platforms = [
|
||||||
'windows nt 10.0' => 'Windows 10',
|
'windows nt 10.0' => 'Windows 10',
|
||||||
'windows nt 6.3' => 'Windows 8.1',
|
'windows nt 6.3' => 'Windows 8.1',
|
||||||
'windows nt 6.2' => 'Windows 8',
|
'windows nt 6.2' => 'Windows 8',
|
||||||
'windows nt 6.1' => 'Windows 7',
|
'windows nt 6.1' => 'Windows 7',
|
||||||
'windows nt 6.0' => 'Windows Vista',
|
'windows nt 6.0' => 'Windows Vista',
|
||||||
'windows nt 5.2' => 'Windows 2003',
|
'windows nt 5.2' => 'Windows 2003',
|
||||||
'windows nt 5.1' => 'Windows XP',
|
'windows nt 5.1' => 'Windows XP',
|
||||||
'windows nt 5.0' => 'Windows 2000',
|
'windows nt 5.0' => 'Windows 2000',
|
||||||
'windows nt 4.0' => 'Windows NT 4.0',
|
'windows nt 4.0' => 'Windows NT 4.0',
|
||||||
'winnt4.0' => 'Windows NT 4.0',
|
'winnt4.0' => 'Windows NT 4.0',
|
||||||
'winnt 4.0' => 'Windows NT',
|
'winnt 4.0' => 'Windows NT',
|
||||||
'winnt' => 'Windows NT',
|
'winnt' => 'Windows NT',
|
||||||
'windows 98' => 'Windows 98',
|
'windows 98' => 'Windows 98',
|
||||||
'win98' => 'Windows 98',
|
'win98' => 'Windows 98',
|
||||||
'windows 95' => 'Windows 95',
|
'windows 95' => 'Windows 95',
|
||||||
'win95' => 'Windows 95',
|
'win95' => 'Windows 95',
|
||||||
'windows phone' => 'Windows Phone',
|
'windows phone' => 'Windows Phone',
|
||||||
'windows' => 'Unknown Windows OS',
|
'windows' => 'Unknown Windows OS',
|
||||||
'android' => 'Android',
|
'android' => 'Android',
|
||||||
'blackberry' => 'BlackBerry',
|
'blackberry' => 'BlackBerry',
|
||||||
'iphone' => 'iOS',
|
'iphone' => 'iOS',
|
||||||
'ipad' => 'iOS',
|
'ipad' => 'iOS',
|
||||||
'ipod' => 'iOS',
|
'ipod' => 'iOS',
|
||||||
'os x' => 'Mac OS X',
|
'os x' => 'Mac OS X',
|
||||||
'ppc mac' => 'Power PC Mac',
|
'ppc mac' => 'Power PC Mac',
|
||||||
'freebsd' => 'FreeBSD',
|
'freebsd' => 'FreeBSD',
|
||||||
'ppc' => 'Macintosh',
|
'ppc' => 'Macintosh',
|
||||||
'linux' => 'Linux',
|
'linux' => 'Linux',
|
||||||
'debian' => 'Debian',
|
'debian' => 'Debian',
|
||||||
'sunos' => 'Sun Solaris',
|
'sunos' => 'Sun Solaris',
|
||||||
'beos' => 'BeOS',
|
'beos' => 'BeOS',
|
||||||
'apachebench' => 'ApacheBench',
|
'apachebench' => 'ApacheBench',
|
||||||
'aix' => 'AIX',
|
'aix' => 'AIX',
|
||||||
'irix' => 'Irix',
|
'irix' => 'Irix',
|
||||||
'osf' => 'DEC OSF',
|
'osf' => 'DEC OSF',
|
||||||
'hp-ux' => 'HP-UX',
|
'hp-ux' => 'HP-UX',
|
||||||
'netbsd' => 'NetBSD',
|
'netbsd' => 'NetBSD',
|
||||||
'bsdi' => 'BSDi',
|
'bsdi' => 'BSDi',
|
||||||
'openbsd' => 'OpenBSD',
|
'openbsd' => 'OpenBSD',
|
||||||
'gnu' => 'GNU/Linux',
|
'gnu' => 'GNU/Linux',
|
||||||
'unix' => 'Unknown Unix OS',
|
'unix' => 'Unknown Unix OS',
|
||||||
'symbian' => 'Symbian OS',
|
'symbian' => 'Symbian OS',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
* Browsers
|
* Browsers
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* The order of this array should NOT be changed. Many browsers return
|
* The order of this array should NOT be changed. Many browsers return
|
||||||
* multiple browser types so we want to identify the subtype first.
|
* multiple browser types so we want to identify the subtype first.
|
||||||
*
|
*
|
||||||
* @var array<string, string>
|
* @var array<string, string>
|
||||||
*/
|
*/
|
||||||
public array $browsers = [
|
public array $browsers = [
|
||||||
'OPR' => 'Opera',
|
'OPR' => 'Opera',
|
||||||
'Flock' => 'Flock',
|
'Flock' => 'Flock',
|
||||||
'Edge' => 'Spartan',
|
'Edge' => 'Spartan',
|
||||||
'Edg' => 'Edge',
|
'Edg' => 'Edge',
|
||||||
'Chrome' => 'Chrome',
|
'Chrome' => 'Chrome',
|
||||||
// Opera 10+ always reports Opera/9.80 and appends Version/<real version> to the user agent string
|
// Opera 10+ always reports Opera/9.80 and appends Version/<real version> to the user agent string
|
||||||
'Opera.*?Version' => 'Opera',
|
'Opera.*?Version' => 'Opera',
|
||||||
'Opera' => 'Opera',
|
'Opera' => 'Opera',
|
||||||
'MSIE' => 'Internet Explorer',
|
'MSIE' => 'Internet Explorer',
|
||||||
'Internet Explorer' => 'Internet Explorer',
|
'Internet Explorer' => 'Internet Explorer',
|
||||||
'Trident.* rv' => 'Internet Explorer',
|
'Trident.* rv' => 'Internet Explorer',
|
||||||
'Shiira' => 'Shiira',
|
'Shiira' => 'Shiira',
|
||||||
'Firefox' => 'Firefox',
|
'Firefox' => 'Firefox',
|
||||||
'Chimera' => 'Chimera',
|
'Chimera' => 'Chimera',
|
||||||
'Phoenix' => 'Phoenix',
|
'Phoenix' => 'Phoenix',
|
||||||
'Firebird' => 'Firebird',
|
'Firebird' => 'Firebird',
|
||||||
'Camino' => 'Camino',
|
'Camino' => 'Camino',
|
||||||
'Netscape' => 'Netscape',
|
'Netscape' => 'Netscape',
|
||||||
'OmniWeb' => 'OmniWeb',
|
'OmniWeb' => 'OmniWeb',
|
||||||
'Safari' => 'Safari',
|
'Safari' => 'Safari',
|
||||||
'Mozilla' => 'Mozilla',
|
'Mozilla' => 'Mozilla',
|
||||||
'Konqueror' => 'Konqueror',
|
'Konqueror' => 'Konqueror',
|
||||||
'icab' => 'iCab',
|
'icab' => 'iCab',
|
||||||
'Lynx' => 'Lynx',
|
'Lynx' => 'Lynx',
|
||||||
'Links' => 'Links',
|
'Links' => 'Links',
|
||||||
'hotjava' => 'HotJava',
|
'hotjava' => 'HotJava',
|
||||||
'amaya' => 'Amaya',
|
'amaya' => 'Amaya',
|
||||||
'IBrowse' => 'IBrowse',
|
'IBrowse' => 'IBrowse',
|
||||||
'Maxthon' => 'Maxthon',
|
'Maxthon' => 'Maxthon',
|
||||||
'Ubuntu' => 'Ubuntu Web Browser',
|
'Ubuntu' => 'Ubuntu Web Browser',
|
||||||
'Vivaldi' => 'Vivaldi',
|
'Vivaldi' => 'Vivaldi',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
* Mobiles
|
* Mobiles
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* @var array<string, string>
|
* @var array<string, string>
|
||||||
*/
|
*/
|
||||||
public array $mobiles = [
|
public array $mobiles = [
|
||||||
// legacy array, old values commented out
|
// legacy array, old values commented out
|
||||||
'mobileexplorer' => 'Mobile Explorer',
|
'mobileexplorer' => 'Mobile Explorer',
|
||||||
// 'openwave' => 'Open Wave',
|
// 'openwave' => 'Open Wave',
|
||||||
// 'opera mini' => 'Opera Mini',
|
// 'opera mini' => 'Opera Mini',
|
||||||
// 'operamini' => 'Opera Mini',
|
// 'operamini' => 'Opera Mini',
|
||||||
// 'elaine' => 'Palm',
|
// 'elaine' => 'Palm',
|
||||||
'palmsource' => 'Palm',
|
'palmsource' => 'Palm',
|
||||||
// 'digital paths' => 'Palm',
|
// 'digital paths' => 'Palm',
|
||||||
// 'avantgo' => 'Avantgo',
|
// 'avantgo' => 'Avantgo',
|
||||||
// 'xiino' => 'Xiino',
|
// 'xiino' => 'Xiino',
|
||||||
'palmscape' => 'Palmscape',
|
'palmscape' => 'Palmscape',
|
||||||
// 'nokia' => 'Nokia',
|
// 'nokia' => 'Nokia',
|
||||||
// 'ericsson' => 'Ericsson',
|
// 'ericsson' => 'Ericsson',
|
||||||
// 'blackberry' => 'BlackBerry',
|
// 'blackberry' => 'BlackBerry',
|
||||||
// 'motorola' => 'Motorola'
|
// 'motorola' => 'Motorola'
|
||||||
|
|
||||||
// Phones and Manufacturers
|
// Phones and Manufacturers
|
||||||
'motorola' => 'Motorola',
|
'motorola' => 'Motorola',
|
||||||
'nokia' => 'Nokia',
|
'nokia' => 'Nokia',
|
||||||
'palm' => 'Palm',
|
'palm' => 'Palm',
|
||||||
'iphone' => 'Apple iPhone',
|
'iphone' => 'Apple iPhone',
|
||||||
'ipad' => 'iPad',
|
'ipad' => 'iPad',
|
||||||
'ipod' => 'Apple iPod Touch',
|
'ipod' => 'Apple iPod Touch',
|
||||||
'sony' => 'Sony Ericsson',
|
'sony' => 'Sony Ericsson',
|
||||||
'ericsson' => 'Sony Ericsson',
|
'ericsson' => 'Sony Ericsson',
|
||||||
'blackberry' => 'BlackBerry',
|
'blackberry' => 'BlackBerry',
|
||||||
'cocoon' => 'O2 Cocoon',
|
'cocoon' => 'O2 Cocoon',
|
||||||
'blazer' => 'Treo',
|
'blazer' => 'Treo',
|
||||||
'lg' => 'LG',
|
'lg' => 'LG',
|
||||||
'amoi' => 'Amoi',
|
'amoi' => 'Amoi',
|
||||||
'xda' => 'XDA',
|
'xda' => 'XDA',
|
||||||
'mda' => 'MDA',
|
'mda' => 'MDA',
|
||||||
'vario' => 'Vario',
|
'vario' => 'Vario',
|
||||||
'htc' => 'HTC',
|
'htc' => 'HTC',
|
||||||
'samsung' => 'Samsung',
|
'samsung' => 'Samsung',
|
||||||
'sharp' => 'Sharp',
|
'sharp' => 'Sharp',
|
||||||
'sie-' => 'Siemens',
|
'sie-' => 'Siemens',
|
||||||
'alcatel' => 'Alcatel',
|
'alcatel' => 'Alcatel',
|
||||||
'benq' => 'BenQ',
|
'benq' => 'BenQ',
|
||||||
'ipaq' => 'HP iPaq',
|
'ipaq' => 'HP iPaq',
|
||||||
'mot-' => 'Motorola',
|
'mot-' => 'Motorola',
|
||||||
'playstation portable' => 'PlayStation Portable',
|
'playstation portable' => 'PlayStation Portable',
|
||||||
'playstation 3' => 'PlayStation 3',
|
'playstation 3' => 'PlayStation 3',
|
||||||
'playstation vita' => 'PlayStation Vita',
|
'playstation vita' => 'PlayStation Vita',
|
||||||
'hiptop' => 'Danger Hiptop',
|
'hiptop' => 'Danger Hiptop',
|
||||||
'nec-' => 'NEC',
|
'nec-' => 'NEC',
|
||||||
'panasonic' => 'Panasonic',
|
'panasonic' => 'Panasonic',
|
||||||
'philips' => 'Philips',
|
'philips' => 'Philips',
|
||||||
'sagem' => 'Sagem',
|
'sagem' => 'Sagem',
|
||||||
'sanyo' => 'Sanyo',
|
'sanyo' => 'Sanyo',
|
||||||
'spv' => 'SPV',
|
'spv' => 'SPV',
|
||||||
'zte' => 'ZTE',
|
'zte' => 'ZTE',
|
||||||
'sendo' => 'Sendo',
|
'sendo' => 'Sendo',
|
||||||
'nintendo dsi' => 'Nintendo DSi',
|
'nintendo dsi' => 'Nintendo DSi',
|
||||||
'nintendo ds' => 'Nintendo DS',
|
'nintendo ds' => 'Nintendo DS',
|
||||||
'nintendo 3ds' => 'Nintendo 3DS',
|
'nintendo 3ds' => 'Nintendo 3DS',
|
||||||
'wii' => 'Nintendo Wii',
|
'wii' => 'Nintendo Wii',
|
||||||
'open web' => 'Open Web',
|
'open web' => 'Open Web',
|
||||||
'openweb' => 'OpenWeb',
|
'openweb' => 'OpenWeb',
|
||||||
|
|
||||||
// Operating Systems
|
// Operating Systems
|
||||||
'android' => 'Android',
|
'android' => 'Android',
|
||||||
'symbian' => 'Symbian',
|
'symbian' => 'Symbian',
|
||||||
'SymbianOS' => 'SymbianOS',
|
'SymbianOS' => 'SymbianOS',
|
||||||
'elaine' => 'Palm',
|
'elaine' => 'Palm',
|
||||||
'series60' => 'Symbian S60',
|
'series60' => 'Symbian S60',
|
||||||
'windows ce' => 'Windows CE',
|
'windows ce' => 'Windows CE',
|
||||||
|
|
||||||
// Browsers
|
// Browsers
|
||||||
'obigo' => 'Obigo',
|
'obigo' => 'Obigo',
|
||||||
'netfront' => 'Netfront Browser',
|
'netfront' => 'Netfront Browser',
|
||||||
'openwave' => 'Openwave Browser',
|
'openwave' => 'Openwave Browser',
|
||||||
'mobilexplorer' => 'Mobile Explorer',
|
'mobilexplorer' => 'Mobile Explorer',
|
||||||
'operamini' => 'Opera Mini',
|
'operamini' => 'Opera Mini',
|
||||||
'opera mini' => 'Opera Mini',
|
'opera mini' => 'Opera Mini',
|
||||||
'opera mobi' => 'Opera Mobile',
|
'opera mobi' => 'Opera Mobile',
|
||||||
'fennec' => 'Firefox Mobile',
|
'fennec' => 'Firefox Mobile',
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
'digital paths' => 'Digital Paths',
|
'digital paths' => 'Digital Paths',
|
||||||
'avantgo' => 'AvantGo',
|
'avantgo' => 'AvantGo',
|
||||||
'xiino' => 'Xiino',
|
'xiino' => 'Xiino',
|
||||||
'novarra' => 'Novarra Transcoder',
|
'novarra' => 'Novarra Transcoder',
|
||||||
'vodafone' => 'Vodafone',
|
'vodafone' => 'Vodafone',
|
||||||
'docomo' => 'NTT DoCoMo',
|
'docomo' => 'NTT DoCoMo',
|
||||||
'o2' => 'O2',
|
'o2' => 'O2',
|
||||||
|
|
||||||
// Fallback
|
// Fallback
|
||||||
'mobile' => 'Generic Mobile',
|
'mobile' => 'Generic Mobile',
|
||||||
'wireless' => 'Generic Mobile',
|
'wireless' => 'Generic Mobile',
|
||||||
'j2me' => 'Generic Mobile',
|
'j2me' => 'Generic Mobile',
|
||||||
'midp' => 'Generic Mobile',
|
'midp' => 'Generic Mobile',
|
||||||
'cldc' => 'Generic Mobile',
|
'cldc' => 'Generic Mobile',
|
||||||
'up.link' => 'Generic Mobile',
|
'up.link' => 'Generic Mobile',
|
||||||
'up.browser' => 'Generic Mobile',
|
'up.browser' => 'Generic Mobile',
|
||||||
'smartphone' => 'Generic Mobile',
|
'smartphone' => 'Generic Mobile',
|
||||||
'cellphone' => 'Generic Mobile',
|
'cellphone' => 'Generic Mobile',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
* Robots
|
* Robots
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* There are hundred of bots but these are the most common.
|
* There are hundred of bots but these are the most common.
|
||||||
*
|
*
|
||||||
* @var array<string, string>
|
* @var array<string, string>
|
||||||
*/
|
*/
|
||||||
public array $robots = [
|
public array $robots = [
|
||||||
'googlebot' => 'Googlebot',
|
'googlebot' => 'Googlebot',
|
||||||
'msnbot' => 'MSNBot',
|
'msnbot' => 'MSNBot',
|
||||||
'baiduspider' => 'Baiduspider',
|
'baiduspider' => 'Baiduspider',
|
||||||
'bingbot' => 'Bing',
|
'bingbot' => 'Bing',
|
||||||
'slurp' => 'Inktomi Slurp',
|
'slurp' => 'Inktomi Slurp',
|
||||||
'yahoo' => 'Yahoo',
|
'yahoo' => 'Yahoo',
|
||||||
'ask jeeves' => 'Ask Jeeves',
|
'ask jeeves' => 'Ask Jeeves',
|
||||||
'fastcrawler' => 'FastCrawler',
|
'fastcrawler' => 'FastCrawler',
|
||||||
'infoseek' => 'InfoSeek Robot 1.0',
|
'infoseek' => 'InfoSeek Robot 1.0',
|
||||||
'lycos' => 'Lycos',
|
'lycos' => 'Lycos',
|
||||||
'yandex' => 'YandexBot',
|
'yandex' => 'YandexBot',
|
||||||
'mediapartners-google' => 'MediaPartners Google',
|
'mediapartners-google' => 'MediaPartners Google',
|
||||||
'CRAZYWEBCRAWLER' => 'Crazy Webcrawler',
|
'CRAZYWEBCRAWLER' => 'Crazy Webcrawler',
|
||||||
'adsbot-google' => 'AdsBot Google',
|
'adsbot-google' => 'AdsBot Google',
|
||||||
'feedfetcher-google' => 'Feedfetcher Google',
|
'feedfetcher-google' => 'Feedfetcher Google',
|
||||||
'curious george' => 'Curious George',
|
'curious george' => 'Curious George',
|
||||||
'ia_archiver' => 'Alexa Crawler',
|
'ia_archiver' => 'Alexa Crawler',
|
||||||
'MJ12bot' => 'Majestic-12',
|
'MJ12bot' => 'Majestic-12',
|
||||||
'Uptimebot' => 'Uptimebot',
|
'Uptimebot' => 'Uptimebot',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,44 +1,44 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
use CodeIgniter\Validation\StrictRules\CreditCardRules;
|
use CodeIgniter\Validation\StrictRules\CreditCardRules;
|
||||||
use CodeIgniter\Validation\StrictRules\FileRules;
|
use CodeIgniter\Validation\StrictRules\FileRules;
|
||||||
use CodeIgniter\Validation\StrictRules\FormatRules;
|
use CodeIgniter\Validation\StrictRules\FormatRules;
|
||||||
use CodeIgniter\Validation\StrictRules\Rules;
|
use CodeIgniter\Validation\StrictRules\Rules;
|
||||||
|
|
||||||
class Validation extends BaseConfig
|
class Validation extends BaseConfig
|
||||||
{
|
{
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// Setup
|
// Setup
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the classes that contain the
|
* Stores the classes that contain the
|
||||||
* rules that are available.
|
* rules that are available.
|
||||||
*
|
*
|
||||||
* @var list<string>
|
* @var list<string>
|
||||||
*/
|
*/
|
||||||
public array $ruleSets = [
|
public array $ruleSets = [
|
||||||
Rules::class,
|
Rules::class,
|
||||||
FormatRules::class,
|
FormatRules::class,
|
||||||
FileRules::class,
|
FileRules::class,
|
||||||
CreditCardRules::class,
|
CreditCardRules::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the views that are used to display the
|
* Specifies the views that are used to display the
|
||||||
* errors.
|
* errors.
|
||||||
*
|
*
|
||||||
* @var array<string, string>
|
* @var array<string, string>
|
||||||
*/
|
*/
|
||||||
public array $templates = [
|
public array $templates = [
|
||||||
'list' => 'CodeIgniter\Validation\Views\list',
|
'list' => 'CodeIgniter\Validation\Views\list',
|
||||||
'single' => 'CodeIgniter\Validation\Views\single',
|
'single' => 'CodeIgniter\Validation\Views\single',
|
||||||
];
|
];
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// Rules
|
// Rules
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,62 +1,62 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use CodeIgniter\Config\View as BaseView;
|
use CodeIgniter\Config\View as BaseView;
|
||||||
use CodeIgniter\View\ViewDecoratorInterface;
|
use CodeIgniter\View\ViewDecoratorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @phpstan-type parser_callable (callable(mixed): mixed)
|
* @phpstan-type parser_callable (callable(mixed): mixed)
|
||||||
* @phpstan-type parser_callable_string (callable(mixed): mixed)&string
|
* @phpstan-type parser_callable_string (callable(mixed): mixed)&string
|
||||||
*/
|
*/
|
||||||
class View extends BaseView
|
class View extends BaseView
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* When false, the view method will clear the data between each
|
* When false, the view method will clear the data between each
|
||||||
* call. This keeps your data safe and ensures there is no accidental
|
* call. This keeps your data safe and ensures there is no accidental
|
||||||
* leaking between calls, so you would need to explicitly pass the data
|
* 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
|
* 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,
|
* calls so that it is available to all views. If that is the case,
|
||||||
* set $saveData to true.
|
* set $saveData to true.
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public $saveData = true;
|
public $saveData = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parser Filters map a filter name with any PHP callable. When the
|
* Parser Filters map a filter name with any PHP callable. When the
|
||||||
* Parser prepares a variable for display, it will chain it
|
* Parser prepares a variable for display, it will chain it
|
||||||
* through the filters in the order defined, inserting any parameters.
|
* through the filters in the order defined, inserting any parameters.
|
||||||
* To prevent potential abuse, all filters MUST be defined here
|
* To prevent potential abuse, all filters MUST be defined here
|
||||||
* in order for them to be available for use within the Parser.
|
* in order for them to be available for use within the Parser.
|
||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
* { title|esc(js) }
|
* { title|esc(js) }
|
||||||
* { created_on|date(Y-m-d)|esc(attr) }
|
* { created_on|date(Y-m-d)|esc(attr) }
|
||||||
*
|
*
|
||||||
* @var array<string, string>
|
* @var array<string, string>
|
||||||
* @phpstan-var array<string, parser_callable_string>
|
* @phpstan-var array<string, parser_callable_string>
|
||||||
*/
|
*/
|
||||||
public $filters = [];
|
public $filters = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parser Plugins provide a way to extend the functionality provided
|
* Parser Plugins provide a way to extend the functionality provided
|
||||||
* by the core Parser by creating aliases that will be replaced with
|
* by the core Parser by creating aliases that will be replaced with
|
||||||
* any callable. Can be single or tag pair.
|
* any callable. Can be single or tag pair.
|
||||||
*
|
*
|
||||||
* @var array<string, callable|list<string>|string>
|
* @var array<string, callable|list<string>|string>
|
||||||
* @phpstan-var array<string, list<parser_callable_string>|parser_callable_string|parser_callable>
|
* @phpstan-var array<string, list<parser_callable_string>|parser_callable_string|parser_callable>
|
||||||
*/
|
*/
|
||||||
public $plugins = [];
|
public $plugins = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View Decorators are class methods that will be run in sequence to
|
* View Decorators are class methods that will be run in sequence to
|
||||||
* have a chance to alter the generated output just prior to caching
|
* have a chance to alter the generated output just prior to caching
|
||||||
* the results.
|
* the results.
|
||||||
*
|
*
|
||||||
* All classes must implement CodeIgniter\View\ViewDecoratorInterface
|
* All classes must implement CodeIgniter\View\ViewDecoratorInterface
|
||||||
*
|
*
|
||||||
* @var list<class-string<ViewDecoratorInterface>>
|
* @var list<class-string<ViewDecoratorInterface>>
|
||||||
*/
|
*/
|
||||||
public array $decorators = [];
|
public array $decorators = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,52 +1,52 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Models\AreaGeoModel;
|
use App\Models\AreaGeoModel;
|
||||||
|
|
||||||
class AreaGeoController extends BaseController {
|
class AreaGeoController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->model = new AreaGeoModel();
|
$this->model = new AreaGeoModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
try {
|
try {
|
||||||
$filters = [
|
$filters = [
|
||||||
'AreaGeoID' => $this->request->getVar('AreaGeoID') ?? null,
|
'AreaGeoID' => $this->request->getVar('AreaGeoID') ?? null,
|
||||||
'AreaName' => $this->request->getVar('AreaName') ?? null
|
'AreaName' => $this->request->getVar('AreaName') ?? null
|
||||||
];
|
];
|
||||||
$rows = $this->model->getAreaGeos( $filters );
|
$rows = $this->model->getAreaGeos( $filters );
|
||||||
|
|
||||||
if(empty($rows)){return $this->respond(['status'=>'success', 'message'=>"no data found.", 'data'=>$rows], 200);}
|
if(empty($rows)){return $this->respond(['status'=>'success', 'message'=>"no data found.", 'data'=>$rows], 200);}
|
||||||
return $this->respond(['status'=>'success', 'message'=>"data fetched successfully", 'data'=>$rows], 200);
|
return $this->respond(['status'=>'success', 'message'=>"data fetched successfully", 'data'=>$rows], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->respond([ 'status' => 'error', 'message' => $e->getMessage() ], 200);
|
return $this->respond([ 'status' => 'error', 'message' => $e->getMessage() ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProvinces() {
|
public function getProvinces() {
|
||||||
$rows = $this->model->getProvinces();
|
$rows = $this->model->getProvinces();
|
||||||
$transformed = array_map(function($row) {
|
$transformed = array_map(function($row) {
|
||||||
return ['value' => $row['AreaGeoID'], 'label' => $row['AreaName']];
|
return ['value' => $row['AreaGeoID'], 'label' => $row['AreaName']];
|
||||||
}, $rows);
|
}, $rows);
|
||||||
if (empty($transformed)) { return $this->respond([ 'status' => 'success', 'data' => [] ], 200); }
|
if (empty($transformed)) { return $this->respond([ 'status' => 'success', 'data' => [] ], 200); }
|
||||||
return $this->respond([ 'status' => 'success', 'data' => $transformed ], 200);
|
return $this->respond([ 'status' => 'success', 'data' => $transformed ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCities() {
|
public function getCities() {
|
||||||
$filter = [ 'Parent' => $this->request->getVar('ProvinceID') ?? null ];
|
$filter = [ 'Parent' => $this->request->getVar('ProvinceID') ?? null ];
|
||||||
$rows = $this->model->getCities($filter);
|
$rows = $this->model->getCities($filter);
|
||||||
$transformed = array_map(function($row) {
|
$transformed = array_map(function($row) {
|
||||||
return ['value' => $row['AreaGeoID'], 'label' => $row['AreaName']];
|
return ['value' => $row['AreaGeoID'], 'label' => $row['AreaName']];
|
||||||
}, $rows);
|
}, $rows);
|
||||||
if (empty($transformed)) { return $this->respond([ 'status' => 'success', 'data' => [] ], 200); }
|
if (empty($transformed)) { return $this->respond([ 'status' => 'success', 'data' => [] ], 200); }
|
||||||
return $this->respond([ 'status' => 'success', 'data' => $transformed ], 200);
|
return $this->respond([ 'status' => 'success', 'data' => $transformed ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,329 +1,329 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
|
|
||||||
use Firebase\JWT\JWT;
|
use Firebase\JWT\JWT;
|
||||||
use Firebase\JWT\Key;
|
use Firebase\JWT\Key;
|
||||||
use Firebase\JWT\ExpiredException;
|
use Firebase\JWT\ExpiredException;
|
||||||
use Firebase\JWT\SignatureInvalidException;
|
use Firebase\JWT\SignatureInvalidException;
|
||||||
use Firebase\JWT\BeforeValidException;
|
use Firebase\JWT\BeforeValidException;
|
||||||
use CodeIgniter\Cookie\Cookie;
|
use CodeIgniter\Cookie\Cookie;
|
||||||
|
|
||||||
class AuthController extends Controller
|
class AuthController extends Controller
|
||||||
{
|
{
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
public function checkAuth()
|
public function checkAuth()
|
||||||
{
|
{
|
||||||
$token = $this->request->getCookie('token');
|
$token = $this->request->getCookie('token');
|
||||||
$key = getenv('JWT_SECRET');
|
$key = getenv('JWT_SECRET');
|
||||||
|
|
||||||
// Jika token FE tidak ada langsung kabarkan failed
|
// Jika token FE tidak ada langsung kabarkan failed
|
||||||
if (!$token) {
|
if (!$token) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'No token found'
|
'message' => 'No token found'
|
||||||
], 401);
|
], 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Decode Token dengan Key yg ada di .env
|
// Decode Token dengan Key yg ada di .env
|
||||||
$decodedPayload = JWT::decode($token, new Key($key, 'HS256'));
|
$decodedPayload = JWT::decode($token, new Key($key, 'HS256'));
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Authenticated',
|
'message' => 'Authenticated',
|
||||||
'data' => $decodedPayload
|
'data' => $decodedPayload
|
||||||
], 200);
|
], 200);
|
||||||
|
|
||||||
} catch (ExpiredException $e) {
|
} catch (ExpiredException $e) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Token expired',
|
'message' => 'Token expired',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 401);
|
], 401);
|
||||||
|
|
||||||
} catch (SignatureInvalidException $e) {
|
} catch (SignatureInvalidException $e) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Invalid token signature',
|
'message' => 'Invalid token signature',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 401);
|
], 401);
|
||||||
|
|
||||||
} catch (BeforeValidException $e) {
|
} catch (BeforeValidException $e) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Token not valid yet',
|
'message' => 'Token not valid yet',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 401);
|
], 401);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Invalid token: ' . $e->getMessage(),
|
'message' => 'Invalid token: ' . $e->getMessage(),
|
||||||
'data' => []
|
'data' => []
|
||||||
], 401);
|
], 401);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
// public function login() {
|
// public function login() {
|
||||||
|
|
||||||
// // Ambil dari JSON Form dan Key .env
|
// // Ambil dari JSON Form dan Key .env
|
||||||
// $username = $this->request->getVar('username');
|
// $username = $this->request->getVar('username');
|
||||||
// $password = $this->request->getVar('password');
|
// $password = $this->request->getVar('password');
|
||||||
// $key = getenv('JWT_SECRET');
|
// $key = getenv('JWT_SECRET');
|
||||||
|
|
||||||
// if (!$username) {
|
// if (!$username) {
|
||||||
// return $this->fail('Username required.', 400);
|
// return $this->fail('Username required.', 400);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// $sql = "SELECT * FROM users WHERE username=" . $this->db->escape($username);
|
// $sql = "SELECT * FROM users WHERE username=" . $this->db->escape($username);
|
||||||
// $query = $this->db->query($sql);
|
// $query = $this->db->query($sql);
|
||||||
// $row = $query->getResultArray();
|
// $row = $query->getResultArray();
|
||||||
|
|
||||||
// if (!$row) { return $this->fail('User not found.', 401); }
|
// if (!$row) { return $this->fail('User not found.', 401); }
|
||||||
// $row = $row[0];
|
// $row = $row[0];
|
||||||
// if (!password_verify($password, $row['password'])) {
|
// if (!password_verify($password, $row['password'])) {
|
||||||
// return $this->fail('Invalid password.', 401);
|
// return $this->fail('Invalid password.', 401);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// // Buat JWT payload
|
// // Buat JWT payload
|
||||||
// $exp = time() + 864000;
|
// $exp = time() + 864000;
|
||||||
// $payload = [
|
// $payload = [
|
||||||
// 'userid' => $row['id'],
|
// 'userid' => $row['id'],
|
||||||
// 'roleid' => $row['role_id'],
|
// 'roleid' => $row['role_id'],
|
||||||
// 'username' => $row['username'],
|
// 'username' => $row['username'],
|
||||||
// 'exp' => $exp
|
// 'exp' => $exp
|
||||||
// ];
|
// ];
|
||||||
|
|
||||||
// try {
|
// try {
|
||||||
// // Melakukan Hash terhadap Payload dengan Kunci .env menggunakan Algortima HMAC + SHA-256
|
// // Melakukan Hash terhadap Payload dengan Kunci .env menggunakan Algortima HMAC + SHA-256
|
||||||
// $jwt = JWT::encode($payload, $key, 'HS256');
|
// $jwt = JWT::encode($payload, $key, 'HS256');
|
||||||
// } catch (Exception $e) {
|
// } catch (Exception $e) {
|
||||||
// return $this->fail('Error generating JWT: ' . $e->getMessage(), 500);
|
// return $this->fail('Error generating JWT: ' . $e->getMessage(), 500);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// // Kirim Respon ke HttpOnly yg akan disimpan di browser dan tidak akan dapat diakses oleh siapapun
|
// // Kirim Respon ke HttpOnly yg akan disimpan di browser dan tidak akan dapat diakses oleh siapapun
|
||||||
// // $isSecure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
|
// // $isSecure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
|
||||||
// $this->response->setCookie([
|
// $this->response->setCookie([
|
||||||
// // 'name' => 'token', // nama token
|
// // 'name' => 'token', // nama token
|
||||||
// // 'value' => $jwt, // value dari jwt yg sudah di hash
|
// // 'value' => $jwt, // value dari jwt yg sudah di hash
|
||||||
// // 'expire' => 864000, // 10 hari
|
// // 'expire' => 864000, // 10 hari
|
||||||
// // 'path' => '/', // valid untuk semua path
|
// // 'path' => '/', // valid untuk semua path
|
||||||
// // 'secure' => $isSecure, // true for HTTPS, false for HTTP (localhost)
|
// // 'secure' => $isSecure, // true for HTTPS, false for HTTP (localhost)
|
||||||
// // 'httponly' => true, // dipakai agar cookie berikut tidak dapat diakses oleh javascript
|
// // 'httponly' => true, // dipakai agar cookie berikut tidak dapat diakses oleh javascript
|
||||||
// // 'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
// // 'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
||||||
// ]);
|
// ]);
|
||||||
|
|
||||||
|
|
||||||
// // Response tanpa token di body
|
// // Response tanpa token di body
|
||||||
// return $this->respond([
|
// return $this->respond([
|
||||||
// 'status' => 'success',
|
// 'status' => 'success',
|
||||||
// 'code' => 200,
|
// 'code' => 200,
|
||||||
// 'message' => 'Login successful'
|
// 'message' => 'Login successful'
|
||||||
// ], 200);
|
// ], 200);
|
||||||
// }
|
// }
|
||||||
public function login()
|
public function login()
|
||||||
{
|
{
|
||||||
|
|
||||||
// Ambil dari JSON Form dan Key .env
|
// Ambil dari JSON Form dan Key .env
|
||||||
$username = $this->request->getVar('username');
|
$username = $this->request->getVar('username');
|
||||||
$password = $this->request->getVar('password');
|
$password = $this->request->getVar('password');
|
||||||
$key = getenv('JWT_SECRET');
|
$key = getenv('JWT_SECRET');
|
||||||
|
|
||||||
if (!$username) {
|
if (!$username) {
|
||||||
return $this->fail('Username required.', 400);
|
return $this->fail('Username required.', 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM users WHERE username=" . $this->db->escape($username);
|
$sql = "SELECT * FROM users WHERE username=" . $this->db->escape($username);
|
||||||
$query = $this->db->query($sql);
|
$query = $this->db->query($sql);
|
||||||
$row = $query->getResultArray();
|
$row = $query->getResultArray();
|
||||||
|
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
return $this->fail('User not found.', 401);
|
return $this->fail('User not found.', 401);
|
||||||
}
|
}
|
||||||
$row = $row[0];
|
$row = $row[0];
|
||||||
if (!password_verify($password, $row['password'])) {
|
if (!password_verify($password, $row['password'])) {
|
||||||
return $this->fail('Invalid password.', 401);
|
return $this->fail('Invalid password.', 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Buat JWT payload
|
// Buat JWT payload
|
||||||
$exp = time() + 864000;
|
$exp = time() + 864000;
|
||||||
$payload = [
|
$payload = [
|
||||||
'userid' => $row['id'],
|
'userid' => $row['id'],
|
||||||
'roleid' => $row['role_id'],
|
'roleid' => $row['role_id'],
|
||||||
'username' => $row['username'],
|
'username' => $row['username'],
|
||||||
'exp' => $exp
|
'exp' => $exp
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Melakukan Hash terhadap Payload dengan Kunci .env menggunakan Algortima HMAC + SHA-256
|
// Melakukan Hash terhadap Payload dengan Kunci .env menggunakan Algortima HMAC + SHA-256
|
||||||
$jwt = JWT::encode($payload, $key, 'HS256');
|
$jwt = JWT::encode($payload, $key, 'HS256');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->fail('Error generating JWT: ' . $e->getMessage(), 500);
|
return $this->fail('Error generating JWT: ' . $e->getMessage(), 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect if HTTPS is being used
|
// Detect if HTTPS is being used
|
||||||
$isSecure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
|
$isSecure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
|
||||||
|
|
||||||
// Kirim Respon ke HttpOnly yg akan disimpan di browser dan tidak akan dapat diakses oleh siapapun
|
// Kirim Respon ke HttpOnly yg akan disimpan di browser dan tidak akan dapat diakses oleh siapapun
|
||||||
$this->response->setCookie([
|
$this->response->setCookie([
|
||||||
'name' => 'token', // nama token
|
'name' => 'token', // nama token
|
||||||
'value' => $jwt, // value dari jwt yg sudah di hash
|
'value' => $jwt, // value dari jwt yg sudah di hash
|
||||||
'expire' => 864000, // 10 hari
|
'expire' => 864000, // 10 hari
|
||||||
'path' => '/', // valid untuk semua path
|
'path' => '/', // valid untuk semua path
|
||||||
'secure' => $isSecure,
|
'secure' => $isSecure,
|
||||||
'httponly' => true, // dipakai agar cookie berikut tidak dapat diakses oleh javascript
|
'httponly' => true, // dipakai agar cookie berikut tidak dapat diakses oleh javascript
|
||||||
'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Response tanpa token di body
|
// Response tanpa token di body
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'code' => 200,
|
'code' => 200,
|
||||||
'message' => 'Login successful'
|
'message' => 'Login successful'
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
// public function logout() {
|
// public function logout() {
|
||||||
// // Definisikan ini pada cookies browser, harus sama dengan cookies login
|
// // Definisikan ini pada cookies browser, harus sama dengan cookies login
|
||||||
// // $isSecure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
|
// // $isSecure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
|
||||||
// return $this->response->setCookie([
|
// return $this->response->setCookie([
|
||||||
// 'name' => 'token',
|
// 'name' => 'token',
|
||||||
// 'value' => '',
|
// 'value' => '',
|
||||||
// 'expire' => time() - 3600,
|
// 'expire' => time() - 3600,
|
||||||
// 'path' => '/',
|
// 'path' => '/',
|
||||||
// 'secure' => $isSecure,
|
// 'secure' => $isSecure,
|
||||||
// 'httponly' => true,
|
// 'httponly' => true,
|
||||||
// 'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
// 'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
||||||
|
|
||||||
// ])->setJSON([
|
// ])->setJSON([
|
||||||
// 'status' => 'success',
|
// 'status' => 'success',
|
||||||
// 'code' => 200,
|
// 'code' => 200,
|
||||||
// 'message' => 'Logout successful'
|
// 'message' => 'Logout successful'
|
||||||
// ], 200);
|
// ], 200);
|
||||||
// }
|
// }
|
||||||
public function logout()
|
public function logout()
|
||||||
{
|
{
|
||||||
// Detect if HTTPS is being used
|
// Detect if HTTPS is being used
|
||||||
$isSecure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
|
$isSecure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
|
||||||
|
|
||||||
// Definisikan ini pada cookies browser, harus sama dengan cookies login
|
// Definisikan ini pada cookies browser, harus sama dengan cookies login
|
||||||
return $this->response->setCookie([
|
return $this->response->setCookie([
|
||||||
'name' => 'token',
|
'name' => 'token',
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'expire' => time() - 3600,
|
'expire' => time() - 3600,
|
||||||
'path' => '/',
|
'path' => '/',
|
||||||
'secure' => $isSecure,
|
'secure' => $isSecure,
|
||||||
'httponly' => true,
|
'httponly' => true,
|
||||||
'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
||||||
|
|
||||||
])->setJSON([
|
])->setJSON([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'code' => 200,
|
'code' => 200,
|
||||||
'message' => 'Logout successful'
|
'message' => 'Logout successful'
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
|
|
||||||
$username = strtolower($this->request->getJsonVar('username'));
|
$username = strtolower($this->request->getJsonVar('username'));
|
||||||
$password = $this->request->getJsonVar('password');
|
$password = $this->request->getJsonVar('password');
|
||||||
|
|
||||||
// Validasi Awal Dari BE
|
// Validasi Awal Dari BE
|
||||||
if (empty($username) || empty($password)) {
|
if (empty($username) || empty($password)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'code' => 400,
|
'code' => 400,
|
||||||
'message' => 'Username and password are required'
|
'message' => 'Username and password are required'
|
||||||
], 400); // Gunakan 400 Bad Request
|
], 400); // Gunakan 400 Bad Request
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cek Duplikasi Username
|
// Cek Duplikasi Username
|
||||||
$exists = $this->db->query("SELECT id FROM users WHERE username = ?", [$username])->getRow();
|
$exists = $this->db->query("SELECT id FROM users WHERE username = ?", [$username])->getRow();
|
||||||
if ($exists) {
|
if ($exists) {
|
||||||
return $this->respond(['status' => 'failed', 'code' => 409, 'message' => 'Username already exists'], 409);
|
return $this->respond(['status' => 'failed', 'code' => 409, 'message' => 'Username already exists'], 409);
|
||||||
}
|
}
|
||||||
|
|
||||||
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
|
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
// Mulai transaksi Insert
|
// Mulai transaksi Insert
|
||||||
$this->db->transStart();
|
$this->db->transStart();
|
||||||
$this->db->query(
|
$this->db->query(
|
||||||
"INSERT INTO users(username, password, role_id) VALUES(?, ?, ?)",
|
"INSERT INTO users(username, password, role_id) VALUES(?, ?, ?)",
|
||||||
[$username, $hashedPassword, 1]
|
[$username, $hashedPassword, 1]
|
||||||
);
|
);
|
||||||
$this->db->transComplete();
|
$this->db->transComplete();
|
||||||
|
|
||||||
// Cek status transaksi
|
// Cek status transaksi
|
||||||
if ($this->db->transStatus() === false) {
|
if ($this->db->transStatus() === false) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'code' => 500,
|
'code' => 500,
|
||||||
'message' => 'Failed to create user. Please try again later.'
|
'message' => 'Failed to create user. Please try again later.'
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Respon sukses jika kueri berhasil
|
// Respon sukses jika kueri berhasil
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'code' => 201,
|
'code' => 201,
|
||||||
'message' => 'User ' . $username . ' successfully created.'
|
'message' => 'User ' . $username . ' successfully created.'
|
||||||
], 201);
|
], 201);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function change_pass() {
|
// public function change_pass() {
|
||||||
// $db = \Config\Database::connect();
|
// $db = \Config\Database::connect();
|
||||||
// $username = $this->request->getJsonVar('username');
|
// $username = $this->request->getJsonVar('username');
|
||||||
// $password = $this->request->getJsonVar('password');
|
// $password = $this->request->getJsonVar('password');
|
||||||
// $password = password_hash($password, PASSWORD_DEFAULT);
|
// $password = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
// $master = $this->request->getJsonVar('master');
|
// $master = $this->request->getJsonVar('master');
|
||||||
// $masterkey = getenv('masterkey');
|
// $masterkey = getenv('masterkey');
|
||||||
|
|
||||||
// if($master != $masterkey) {
|
// if($master != $masterkey) {
|
||||||
// return $this->fail('Invalid master key.', 401);
|
// return $this->fail('Invalid master key.', 401);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// $sql = "update users set password='$password' where username='$username'";
|
// $sql = "update users set password='$password' where username='$username'";
|
||||||
// $query = $db->query($sql);
|
// $query = $db->query($sql);
|
||||||
// $response = [
|
// $response = [
|
||||||
// 'message' => "Password Changed for $username"
|
// 'message' => "Password Changed for $username"
|
||||||
// ];
|
// ];
|
||||||
// return $this->respond($response);
|
// return $this->respond($response);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public function coba()
|
public function coba()
|
||||||
{
|
{
|
||||||
|
|
||||||
$token = $this->request->getCookie('token');
|
$token = $this->request->getCookie('token');
|
||||||
$key = getenv('JWT_SECRET');
|
$key = getenv('JWT_SECRET');
|
||||||
|
|
||||||
// Decode Token dengan Key yg ada di .env
|
// Decode Token dengan Key yg ada di .env
|
||||||
$decodedPayload = JWT::decode($token, new Key($key, 'HS256'));
|
$decodedPayload = JWT::decode($token, new Key($key, 'HS256'));
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Authenticated',
|
'message' => 'Authenticated',
|
||||||
'data' => $decodedPayload
|
'data' => $decodedPayload
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,238 +1,238 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
|
|
||||||
use Firebase\JWT\JWT;
|
use Firebase\JWT\JWT;
|
||||||
use Firebase\JWT\Key;
|
use Firebase\JWT\Key;
|
||||||
use Firebase\JWT\ExpiredException;
|
use Firebase\JWT\ExpiredException;
|
||||||
use Firebase\JWT\SignatureInvalidException;
|
use Firebase\JWT\SignatureInvalidException;
|
||||||
use Firebase\JWT\BeforeValidException;
|
use Firebase\JWT\BeforeValidException;
|
||||||
use CodeIgniter\Cookie\Cookie;
|
use CodeIgniter\Cookie\Cookie;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AuthV2 Controller
|
* AuthV2 Controller
|
||||||
*
|
*
|
||||||
* Handles authentication for V2 UI
|
* Handles authentication for V2 UI
|
||||||
* Separate from the main Auth controller to avoid conflicts
|
* Separate from the main Auth controller to avoid conflicts
|
||||||
*/
|
*/
|
||||||
class AuthV2Controller extends Controller
|
class AuthV2Controller extends Controller
|
||||||
{
|
{
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check authentication status
|
* Check authentication status
|
||||||
* GET /v2/auth/check
|
* GET /v2/auth/check
|
||||||
*/
|
*/
|
||||||
public function checkAuth()
|
public function checkAuth()
|
||||||
{
|
{
|
||||||
$token = $this->request->getCookie('token');
|
$token = $this->request->getCookie('token');
|
||||||
$key = getenv('JWT_SECRET');
|
$key = getenv('JWT_SECRET');
|
||||||
|
|
||||||
if (!$token) {
|
if (!$token) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'No token found'
|
'message' => 'No token found'
|
||||||
], 401);
|
], 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$decodedPayload = JWT::decode($token, new Key($key, 'HS256'));
|
$decodedPayload = JWT::decode($token, new Key($key, 'HS256'));
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Authenticated',
|
'message' => 'Authenticated',
|
||||||
'data' => $decodedPayload
|
'data' => $decodedPayload
|
||||||
], 200);
|
], 200);
|
||||||
|
|
||||||
} catch (ExpiredException $e) {
|
} catch (ExpiredException $e) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Token expired'
|
'message' => 'Token expired'
|
||||||
], 401);
|
], 401);
|
||||||
|
|
||||||
} catch (SignatureInvalidException $e) {
|
} catch (SignatureInvalidException $e) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Invalid token signature'
|
'message' => 'Invalid token signature'
|
||||||
], 401);
|
], 401);
|
||||||
|
|
||||||
} catch (BeforeValidException $e) {
|
} catch (BeforeValidException $e) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Token not valid yet'
|
'message' => 'Token not valid yet'
|
||||||
], 401);
|
], 401);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Invalid token: ' . $e->getMessage()
|
'message' => 'Invalid token: ' . $e->getMessage()
|
||||||
], 401);
|
], 401);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Login user
|
* Login user
|
||||||
* POST /v2/auth/login
|
* POST /v2/auth/login
|
||||||
*/
|
*/
|
||||||
public function login()
|
public function login()
|
||||||
{
|
{
|
||||||
$username = $this->request->getVar('username');
|
$username = $this->request->getVar('username');
|
||||||
$password = $this->request->getVar('password');
|
$password = $this->request->getVar('password');
|
||||||
$key = getenv('JWT_SECRET');
|
$key = getenv('JWT_SECRET');
|
||||||
|
|
||||||
// Validate username
|
// Validate username
|
||||||
if (!$username) {
|
if (!$username) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Username is required'
|
'message' => 'Username is required'
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find user
|
// Find user
|
||||||
$sql = "SELECT * FROM users WHERE username = " . $this->db->escape($username);
|
$sql = "SELECT * FROM users WHERE username = " . $this->db->escape($username);
|
||||||
$query = $this->db->query($sql);
|
$query = $this->db->query($sql);
|
||||||
$row = $query->getResultArray();
|
$row = $query->getResultArray();
|
||||||
|
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'User not found'
|
'message' => 'User not found'
|
||||||
], 401);
|
], 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = $row[0];
|
$row = $row[0];
|
||||||
|
|
||||||
// Verify password
|
// Verify password
|
||||||
if (!password_verify($password, $row['password'])) {
|
if (!password_verify($password, $row['password'])) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Invalid password'
|
'message' => 'Invalid password'
|
||||||
], 401);
|
], 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create JWT payload
|
// Create JWT payload
|
||||||
$exp = time() + 864000; // 10 days
|
$exp = time() + 864000; // 10 days
|
||||||
$payload = [
|
$payload = [
|
||||||
'userid' => $row['id'],
|
'userid' => $row['id'],
|
||||||
'roleid' => $row['role_id'],
|
'roleid' => $row['role_id'],
|
||||||
'username' => $row['username'],
|
'username' => $row['username'],
|
||||||
'exp' => $exp
|
'exp' => $exp
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$jwt = JWT::encode($payload, $key, 'HS256');
|
$jwt = JWT::encode($payload, $key, 'HS256');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Error generating JWT: ' . $e->getMessage()
|
'message' => 'Error generating JWT: ' . $e->getMessage()
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect if HTTPS is being used
|
// Detect if HTTPS is being used
|
||||||
$isSecure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
|
$isSecure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
|
||||||
|
|
||||||
// Set HTTP-only cookie
|
// Set HTTP-only cookie
|
||||||
$this->response->setCookie([
|
$this->response->setCookie([
|
||||||
'name' => 'token',
|
'name' => 'token',
|
||||||
'value' => $jwt,
|
'value' => $jwt,
|
||||||
'expire' => 864000,
|
'expire' => 864000,
|
||||||
'path' => '/',
|
'path' => '/',
|
||||||
'secure' => $isSecure, // false for localhost HTTP
|
'secure' => $isSecure, // false for localhost HTTP
|
||||||
'httponly' => true,
|
'httponly' => true,
|
||||||
'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Login successful',
|
'message' => 'Login successful',
|
||||||
'data' => [
|
'data' => [
|
||||||
'username' => $row['username'],
|
'username' => $row['username'],
|
||||||
'role_id' => $row['role_id']
|
'role_id' => $row['role_id']
|
||||||
]
|
]
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logout user
|
* Logout user
|
||||||
* POST /v2/auth/logout
|
* POST /v2/auth/logout
|
||||||
*/
|
*/
|
||||||
public function logout()
|
public function logout()
|
||||||
{
|
{
|
||||||
// Detect if HTTPS is being used
|
// Detect if HTTPS is being used
|
||||||
$isSecure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
|
$isSecure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
|
||||||
|
|
||||||
// Clear the token cookie
|
// Clear the token cookie
|
||||||
return $this->response->setCookie([
|
return $this->response->setCookie([
|
||||||
'name' => 'token',
|
'name' => 'token',
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'expire' => time() - 3600,
|
'expire' => time() - 3600,
|
||||||
'path' => '/',
|
'path' => '/',
|
||||||
'secure' => $isSecure,
|
'secure' => $isSecure,
|
||||||
'httponly' => true,
|
'httponly' => true,
|
||||||
'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
||||||
])->setJSON([
|
])->setJSON([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Logout successful'
|
'message' => 'Logout successful'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register new user
|
* Register new user
|
||||||
* POST /v2/auth/register
|
* POST /v2/auth/register
|
||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
$username = strtolower($this->request->getJsonVar('username'));
|
$username = strtolower($this->request->getJsonVar('username'));
|
||||||
$password = $this->request->getJsonVar('password');
|
$password = $this->request->getJsonVar('password');
|
||||||
|
|
||||||
// Validate input
|
// Validate input
|
||||||
if (empty($username) || empty($password)) {
|
if (empty($username) || empty($password)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Username and password are required'
|
'message' => 'Username and password are required'
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for existing username
|
// Check for existing username
|
||||||
$exists = $this->db->query("SELECT id FROM users WHERE username = ?", [$username])->getRow();
|
$exists = $this->db->query("SELECT id FROM users WHERE username = ?", [$username])->getRow();
|
||||||
if ($exists) {
|
if ($exists) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Username already exists'
|
'message' => 'Username already exists'
|
||||||
], 409);
|
], 409);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hash password
|
// Hash password
|
||||||
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
|
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
// Insert user
|
// Insert user
|
||||||
$this->db->transStart();
|
$this->db->transStart();
|
||||||
$this->db->query(
|
$this->db->query(
|
||||||
"INSERT INTO users(username, password, role_id) VALUES(?, ?, ?)",
|
"INSERT INTO users(username, password, role_id) VALUES(?, ?, ?)",
|
||||||
[$username, $hashedPassword, 1]
|
[$username, $hashedPassword, 1]
|
||||||
);
|
);
|
||||||
$this->db->transComplete();
|
$this->db->transComplete();
|
||||||
|
|
||||||
if ($this->db->transStatus() === false) {
|
if ($this->db->transStatus() === false) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Failed to create user'
|
'message' => 'Failed to create user'
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'User ' . $username . ' successfully created'
|
'message' => 'User ' . $username . ' successfully created'
|
||||||
], 201);
|
], 201);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,58 +1,58 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
use CodeIgniter\HTTP\CLIRequest;
|
use CodeIgniter\HTTP\CLIRequest;
|
||||||
use CodeIgniter\HTTP\IncomingRequest;
|
use CodeIgniter\HTTP\IncomingRequest;
|
||||||
use CodeIgniter\HTTP\RequestInterface;
|
use CodeIgniter\HTTP\RequestInterface;
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BaseController
|
* Class BaseController
|
||||||
*
|
*
|
||||||
* BaseController provides a convenient place for loading components
|
* BaseController provides a convenient place for loading components
|
||||||
* and performing functions that are needed by all your controllers.
|
* and performing functions that are needed by all your controllers.
|
||||||
* Extend this class in any new controllers:
|
* Extend this class in any new controllers:
|
||||||
* class Home extends BaseController
|
* class Home extends BaseController
|
||||||
*
|
*
|
||||||
* For security be sure to declare any new methods as protected or private.
|
* For security be sure to declare any new methods as protected or private.
|
||||||
*/
|
*/
|
||||||
abstract class BaseController extends Controller
|
abstract class BaseController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Instance of the main Request object.
|
* Instance of the main Request object.
|
||||||
*
|
*
|
||||||
* @var CLIRequest|IncomingRequest
|
* @var CLIRequest|IncomingRequest
|
||||||
*/
|
*/
|
||||||
protected $request;
|
protected $request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of helpers to be loaded automatically upon
|
* An array of helpers to be loaded automatically upon
|
||||||
* class instantiation. These will be available
|
* class instantiation. These will be available
|
||||||
* to all other controllers that extend BaseController.
|
* to all other controllers that extend BaseController.
|
||||||
*
|
*
|
||||||
* @var list<string>
|
* @var list<string>
|
||||||
*/
|
*/
|
||||||
protected $helpers = ['json'];
|
protected $helpers = ['json'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Be sure to declare properties for any property fetch you initialized.
|
* Be sure to declare properties for any property fetch you initialized.
|
||||||
* The creation of dynamic property is deprecated in PHP 8.2.
|
* The creation of dynamic property is deprecated in PHP 8.2.
|
||||||
*/
|
*/
|
||||||
// protected $session;
|
// protected $session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||||
{
|
{
|
||||||
// Do Not Edit This Line
|
// Do Not Edit This Line
|
||||||
parent::initController($request, $response, $logger);
|
parent::initController($request, $response, $logger);
|
||||||
|
|
||||||
// Preload any models, libraries, etc, here.
|
// Preload any models, libraries, etc, here.
|
||||||
|
|
||||||
// E.g.: $this->session = service('session');
|
// E.g.: $this->session = service('session');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,183 +1,183 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Services\CalculatorService;
|
use App\Services\CalculatorService;
|
||||||
use App\Models\Test\TestDefCalModel;
|
use App\Models\Test\TestDefCalModel;
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
|
|
||||||
class CalculatorController extends Controller
|
class CalculatorController extends Controller
|
||||||
{
|
{
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected CalculatorService $calculator;
|
protected CalculatorService $calculator;
|
||||||
protected TestDefCalModel $calcModel;
|
protected TestDefCalModel $calcModel;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->calculator = new CalculatorService();
|
$this->calculator = new CalculatorService();
|
||||||
$this->calcModel = new TestDefCalModel();
|
$this->calcModel = new TestDefCalModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST api/calculate
|
* POST api/calculate
|
||||||
* Calculate a formula with provided variables
|
* Calculate a formula with provided variables
|
||||||
*
|
*
|
||||||
* Request: {
|
* Request: {
|
||||||
* "formula": "{result} * {factor} + {gender}",
|
* "formula": "{result} * {factor} + {gender}",
|
||||||
* "variables": {
|
* "variables": {
|
||||||
* "result": 100,
|
* "result": 100,
|
||||||
* "factor": 0.5,
|
* "factor": 0.5,
|
||||||
* "gender": "female"
|
* "gender": "female"
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
public function calculate(): ResponseInterface
|
public function calculate(): ResponseInterface
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$data = $this->request->getJSON(true);
|
$data = $this->request->getJSON(true);
|
||||||
|
|
||||||
if (empty($data['formula'])) {
|
if (empty($data['formula'])) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Formula is required'
|
'message' => 'Formula is required'
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->calculator->calculate(
|
$result = $this->calculator->calculate(
|
||||||
$data['formula'],
|
$data['formula'],
|
||||||
$data['variables'] ?? []
|
$data['variables'] ?? []
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'data' => [
|
'data' => [
|
||||||
'result' => $result,
|
'result' => $result,
|
||||||
'formula' => $data['formula'],
|
'formula' => $data['formula'],
|
||||||
'variables' => $data['variables'] ?? []
|
'variables' => $data['variables'] ?? []
|
||||||
]
|
]
|
||||||
], 200);
|
], 200);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => $e->getMessage()
|
'message' => $e->getMessage()
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST api/calculate/validate
|
* POST api/calculate/validate
|
||||||
* Validate a formula syntax
|
* Validate a formula syntax
|
||||||
*
|
*
|
||||||
* Request: {
|
* Request: {
|
||||||
* "formula": "{result} * 2 + 5"
|
* "formula": "{result} * 2 + 5"
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
public function validateFormula(): ResponseInterface
|
public function validateFormula(): ResponseInterface
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$data = $this->request->getJSON(true);
|
$data = $this->request->getJSON(true);
|
||||||
|
|
||||||
if (empty($data['formula'])) {
|
if (empty($data['formula'])) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Formula is required'
|
'message' => 'Formula is required'
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$validation = $this->calculator->validate($data['formula']);
|
$validation = $this->calculator->validate($data['formula']);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => $validation['valid'] ? 'success' : 'failed',
|
'status' => $validation['valid'] ? 'success' : 'failed',
|
||||||
'data' => [
|
'data' => [
|
||||||
'valid' => $validation['valid'],
|
'valid' => $validation['valid'],
|
||||||
'error' => $validation['error'],
|
'error' => $validation['error'],
|
||||||
'variables' => $this->calculator->extractVariables($data['formula'])
|
'variables' => $this->calculator->extractVariables($data['formula'])
|
||||||
]
|
]
|
||||||
], 200);
|
], 200);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => $e->getMessage()
|
'message' => $e->getMessage()
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST api/calculate/test-site/{testSiteID}
|
* POST api/calculate/test-site/{testSiteID}
|
||||||
* Calculate using TestDefCal definition
|
* Calculate using TestDefCal definition
|
||||||
*
|
*
|
||||||
* Request: {
|
* Request: {
|
||||||
* "result": 85,
|
* "result": 85,
|
||||||
* "gender": "female",
|
* "gender": "female",
|
||||||
* "age": 30
|
* "age": 30
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
public function calculateByTestSite($testSiteID): ResponseInterface
|
public function calculateByTestSite($testSiteID): ResponseInterface
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$calcDef = $this->calcModel->existsByTestSiteID($testSiteID);
|
$calcDef = $this->calcModel->existsByTestSiteID($testSiteID);
|
||||||
|
|
||||||
if (!$calcDef) {
|
if (!$calcDef) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'No calculation defined for this test site'
|
'message' => 'No calculation defined for this test site'
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$testValues = $this->request->getJSON(true);
|
$testValues = $this->request->getJSON(true);
|
||||||
$result = $this->calculator->calculateFromDefinition($calcDef, $testValues);
|
$result = $this->calculator->calculateFromDefinition($calcDef, $testValues);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'data' => [
|
'data' => [
|
||||||
'result' => $result,
|
'result' => $result,
|
||||||
'testSiteID' => $testSiteID,
|
'testSiteID' => $testSiteID,
|
||||||
'formula' => $calcDef['FormulaCode'],
|
'formula' => $calcDef['FormulaCode'],
|
||||||
'variables' => $testValues
|
'variables' => $testValues
|
||||||
]
|
]
|
||||||
], 200);
|
], 200);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => $e->getMessage()
|
'message' => $e->getMessage()
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST api/calc/{codeOrName}
|
* POST api/calc/{codeOrName}
|
||||||
* Evaluate a configured calculation by its code or name and return only the result map.
|
* Evaluate a configured calculation by its code or name and return only the result map.
|
||||||
*/
|
*/
|
||||||
public function calculateByCodeOrName($codeOrName): ResponseInterface
|
public function calculateByCodeOrName($codeOrName): ResponseInterface
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$calcDef = $this->calcModel->findActiveByCodeOrName($codeOrName);
|
$calcDef = $this->calcModel->findActiveByCodeOrName($codeOrName);
|
||||||
|
|
||||||
if (!$calcDef || empty($calcDef['FormulaCode'])) {
|
if (!$calcDef || empty($calcDef['FormulaCode'])) {
|
||||||
return $this->response->setJSON(new \stdClass());
|
return $this->response->setJSON(new \stdClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$variables = is_array($input) ? $input : [];
|
$variables = is_array($input) ? $input : [];
|
||||||
|
|
||||||
$result = $this->calculator->calculate($calcDef['FormulaCode'], $variables);
|
$result = $this->calculator->calculate($calcDef['FormulaCode'], $variables);
|
||||||
|
|
||||||
if ($result === null) {
|
if ($result === null) {
|
||||||
return $this->response->setJSON(new \stdClass());
|
return $this->response->setJSON(new \stdClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
$responseKey = $calcDef['TestSiteCode'] ?? strtoupper($codeOrName);
|
$responseKey = $calcDef['TestSiteCode'] ?? strtoupper($codeOrName);
|
||||||
|
|
||||||
return $this->response->setJSON([ $responseKey => $result ]);
|
return $this->response->setJSON([ $responseKey => $result ]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
log_message('error', "Calc lookup failed for {$codeOrName}: " . $e->getMessage());
|
log_message('error', "Calc lookup failed for {$codeOrName}: " . $e->getMessage());
|
||||||
return $this->response->setJSON(new \stdClass());
|
return $this->response->setJSON(new \stdClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,89 +1,89 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers\Contact;
|
namespace App\Controllers\Contact;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Libraries\ValueSet;
|
use App\Libraries\ValueSet;
|
||||||
use App\Models\Contact\ContactModel;
|
use App\Models\Contact\ContactModel;
|
||||||
|
|
||||||
class ContactController extends BaseController {
|
class ContactController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $model;
|
protected $model;
|
||||||
protected $rules;
|
protected $rules;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new ContactModel();
|
$this->model = new ContactModel();
|
||||||
$this->rules = [ 'NameFirst' => 'required' ];
|
$this->rules = [ 'NameFirst' => 'required' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$ContactName = $this->request->getVar('ContactName');
|
$ContactName = $this->request->getVar('ContactName');
|
||||||
$Specialty = $this->request->getVar('Specialty');
|
$Specialty = $this->request->getVar('Specialty');
|
||||||
$rows = $this->model->getContacts($ContactName, $Specialty);
|
$rows = $this->model->getContacts($ContactName, $Specialty);
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = ValueSet::transformLabels($rows, [
|
$rows = ValueSet::transformLabels($rows, [
|
||||||
'Specialty' => 'specialty',
|
'Specialty' => 'specialty',
|
||||||
'Occupation' => 'occupation',
|
'Occupation' => 'occupation',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($ContactID = null) {
|
public function show($ContactID = null) {
|
||||||
$model = new ContactModel();
|
$model = new ContactModel();
|
||||||
$row = $model->getContactWithDetail($ContactID);
|
$row = $model->getContactWithDetail($ContactID);
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = ValueSet::transformLabels([$row], [
|
$row = ValueSet::transformLabels([$row], [
|
||||||
'Specialty' => 'specialty',
|
'Specialty' => 'specialty',
|
||||||
'Occupation' => 'occupation',
|
'Occupation' => 'occupation',
|
||||||
])[0];
|
])[0];
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
try {
|
try {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$ContactID = $input["ContactID"];
|
$ContactID = $input["ContactID"];
|
||||||
if (!$ContactID) { return $this->failValidationErrors('ContactID is required.'); }
|
if (!$ContactID) { return $this->failValidationErrors('ContactID is required.'); }
|
||||||
$this->model->delete($ContactID);
|
$this->model->delete($ContactID);
|
||||||
return $this->respondDeleted([ 'status' => 'success', 'message' => "Contact with {$ContactID} deleted successfully."]);
|
return $this->respondDeleted([ 'status' => 'success', 'message' => "Contact with {$ContactID} deleted successfully."]);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$id = $this->model->saveContact($input,true);
|
$id = $this->model->saveContact($input,true);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$this->model->saveContact($input);
|
$this->model->saveContact($input);
|
||||||
$id = $input['ContactID'];
|
$id = $input['ContactID'];
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,64 +1,64 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers\Contact;
|
namespace App\Controllers\Contact;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Models\Contact\MedicalSpecialtyModel;
|
use App\Models\Contact\MedicalSpecialtyModel;
|
||||||
|
|
||||||
class MedicalSpecialtyController extends BaseController {
|
class MedicalSpecialtyController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $model;
|
protected $model;
|
||||||
protected $rules;
|
protected $rules;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new MedicalSpecialtyModel();
|
$this->model = new MedicalSpecialtyModel();
|
||||||
$this->rules = [ 'SpecialtyText' => 'required' ];
|
$this->rules = [ 'SpecialtyText' => 'required' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$Parent = $this->request->getVar('Parent');
|
$Parent = $this->request->getVar('Parent');
|
||||||
$SpecialtyText = $this->request->getVar('SpecialtyText');
|
$SpecialtyText = $this->request->getVar('SpecialtyText');
|
||||||
$rows = $this->model->getOccupations($Parent,$SpecialtyText);
|
$rows = $this->model->getOccupations($Parent,$SpecialtyText);
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data."], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data."], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($SpecialtyID = null) {
|
public function show($SpecialtyID = null) {
|
||||||
$model = new MedicalSpecialtyModel();
|
$model = new MedicalSpecialtyModel();
|
||||||
$row = $model->find($SpecialtyID);
|
$row = $model->find($SpecialtyID);
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null], 200);
|
||||||
}
|
}
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$this->model->insert($input);
|
$this->model->insert($input);
|
||||||
$id = $this->model->getInsertID();
|
$id = $this->model->getInsertID();
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$this->db->transRollback();
|
$this->db->transRollback();
|
||||||
return $this->failServerError('Exception : ' . $e->getMessage());
|
return $this->failServerError('Exception : ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$this->model->update($input['SpecialtyID'], $input);
|
$this->model->update($input['SpecialtyID'], $input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'Data updated successfully', 'data' => $input['SpecialtyID'] ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'Data updated successfully', 'data' => $input['SpecialtyID'] ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Exception : ' . $e->getMessage());
|
return $this->failServerError('Exception : ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,64 +1,64 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers\Contact;
|
namespace App\Controllers\Contact;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Models\Contact\OccupationModel;
|
use App\Models\Contact\OccupationModel;
|
||||||
|
|
||||||
class OccupationController extends BaseController {
|
class OccupationController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $model;
|
protected $model;
|
||||||
protected $rules;
|
protected $rules;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new OccupationModel();
|
$this->model = new OccupationModel();
|
||||||
$this->rules = [ 'OccCode' => 'required','OccText' => 'required' ];
|
$this->rules = [ 'OccCode' => 'required','OccText' => 'required' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$OccCode = $this->request->getVar('OccCode');
|
$OccCode = $this->request->getVar('OccCode');
|
||||||
$OccText = $this->request->getVar('OccText');
|
$OccText = $this->request->getVar('OccText');
|
||||||
$rows = $this->model->getOccupations($OccCode,$OccText);
|
$rows = $this->model->getOccupations($OccCode,$OccText);
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data."], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data."], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($OccupationID = null) {
|
public function show($OccupationID = null) {
|
||||||
$model = new OccupationModel();
|
$model = new OccupationModel();
|
||||||
$row = $model->find($OccupationID);
|
$row = $model->find($OccupationID);
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
||||||
}
|
}
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$this->model->insert($input);
|
$this->model->insert($input);
|
||||||
$id = $this->model->getInsertID();
|
$id = $this->model->getInsertID();
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$this->db->transRollback();
|
$this->db->transRollback();
|
||||||
return $this->failServerError('Exception : ' . $e->getMessage());
|
return $this->failServerError('Exception : ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$this->model->update($input['OccupationID'], $input);
|
$this->model->update($input['OccupationID'], $input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'Data updated successfully', 'data' => $input['OccupationID'] ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'Data updated successfully', 'data' => $input['OccupationID'] ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Exception : ' . $e->getMessage());
|
return $this->failServerError('Exception : ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,65 +1,65 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Models\CounterModel;
|
use App\Models\CounterModel;
|
||||||
|
|
||||||
class CounterController extends BaseController {
|
class CounterController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $model;
|
protected $model;
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->model = new CounterModel();
|
$this->model = new CounterModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$rows = $this->model->findAll();
|
$rows = $this->model->findAll();
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "No Data.", 'data' => [] ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "No Data.", 'data' => [] ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($CounterID = null) {
|
public function show($CounterID = null) {
|
||||||
$row = $this->model->find($CounterID);
|
$row = $this->model->find($CounterID);
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "No Data.", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "No Data.", 'data' => null ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $row ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$id = $this->model->insert($input,true);
|
$id = $this->model->insert($input,true);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'Data created successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'Data created successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$this->model->update($input['CounterID'], $input);
|
$this->model->update($input['CounterID'], $input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'Data updated successfully', 'data' => $input['CounterID'] ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'Data updated successfully', 'data' => $input['CounterID'] ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$this->model->delete($input['CounterID'], $input);
|
$this->model->delete($input['CounterID'], $input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'Data deleted successfully', 'data' => $input['CounterID'] ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'Data deleted successfully', 'data' => $input['CounterID'] ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,36 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
|
|
||||||
use Firebase\JWT\JWT;
|
use Firebase\JWT\JWT;
|
||||||
use Firebase\JWT\Key;
|
use Firebase\JWT\Key;
|
||||||
use Firebase\JWT\ExpiredException;
|
use Firebase\JWT\ExpiredException;
|
||||||
use Firebase\JWT\SignatureInvalidException;
|
use Firebase\JWT\SignatureInvalidException;
|
||||||
use Firebase\JWT\BeforeValidException;
|
use Firebase\JWT\BeforeValidException;
|
||||||
use CodeIgniter\Cookie\Cookie;
|
use CodeIgniter\Cookie\Cookie;
|
||||||
|
|
||||||
class DashboardController extends Controller
|
class DashboardController extends Controller
|
||||||
{
|
{
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
|
||||||
$token = $this->request->getCookie('token');
|
$token = $this->request->getCookie('token');
|
||||||
$key = getenv('JWT_SECRET');
|
$key = getenv('JWT_SECRET');
|
||||||
|
|
||||||
// Decode Token dengan Key yg ada di .env
|
// Decode Token dengan Key yg ada di .env
|
||||||
$decodedPayload = JWT::decode($token, new Key($key, 'HS256'));
|
$decodedPayload = JWT::decode($token, new Key($key, 'HS256'));
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'code' => 200,
|
'code' => 200,
|
||||||
'message' => 'Authenticated',
|
'message' => 'Authenticated',
|
||||||
'data' => $decodedPayload
|
'data' => $decodedPayload
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,169 +1,169 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
|
|
||||||
class EdgeController extends Controller
|
class EdgeController extends Controller
|
||||||
{
|
{
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $edgeResModel;
|
protected $edgeResModel;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->edgeResModel = new \App\Models\EdgeResModel();
|
$this->edgeResModel = new \App\Models\EdgeResModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /api/edge/results
|
* POST /api/edge/results
|
||||||
* Receive results from tiny-edge
|
* Receive results from tiny-edge
|
||||||
*/
|
*/
|
||||||
public function results()
|
public function results()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
|
|
||||||
if (empty($input)) {
|
if (empty($input)) {
|
||||||
return $this->failValidationErrors('Invalid JSON payload');
|
return $this->failValidationErrors('Invalid JSON payload');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract key fields from payload
|
// Extract key fields from payload
|
||||||
$sampleId = $input['sample_id'] ?? null;
|
$sampleId = $input['sample_id'] ?? null;
|
||||||
$instrumentId = $input['instrument_id'] ?? null;
|
$instrumentId = $input['instrument_id'] ?? null;
|
||||||
$patientId = $input['patient_id'] ?? null;
|
$patientId = $input['patient_id'] ?? null;
|
||||||
|
|
||||||
// Store in edgeres table
|
// Store in edgeres table
|
||||||
$data = [
|
$data = [
|
||||||
'SiteID' => 1, // Default site, can be configured
|
'SiteID' => 1, // Default site, can be configured
|
||||||
'InstrumentID' => $instrumentId,
|
'InstrumentID' => $instrumentId,
|
||||||
'SampleID' => $sampleId,
|
'SampleID' => $sampleId,
|
||||||
'PatientID' => $patientId,
|
'PatientID' => $patientId,
|
||||||
'Payload' => json_encode($input),
|
'Payload' => json_encode($input),
|
||||||
'Status' => 'pending',
|
'Status' => 'pending',
|
||||||
'AutoProcess' => 0, // Default to manual processing
|
'AutoProcess' => 0, // Default to manual processing
|
||||||
'CreateDate' => date('Y-m-d H:i:s')
|
'CreateDate' => date('Y-m-d H:i:s')
|
||||||
];
|
];
|
||||||
|
|
||||||
$id = $this->edgeResModel->insert($data);
|
$id = $this->edgeResModel->insert($data);
|
||||||
|
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
return $this->failServerError('Failed to save result');
|
return $this->failServerError('Failed to save result');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respondCreated([
|
return $this->respondCreated([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Result received and queued',
|
'message' => 'Result received and queued',
|
||||||
'data' => [
|
'data' => [
|
||||||
'edge_res_id' => $id,
|
'edge_res_id' => $id,
|
||||||
'sample_id' => $sampleId,
|
'sample_id' => $sampleId,
|
||||||
'instrument_id' => $instrumentId
|
'instrument_id' => $instrumentId
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Error processing result: ' . $e->getMessage());
|
return $this->failServerError('Error processing result: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /api/edge/orders
|
* GET /api/edge/orders
|
||||||
* Return pending orders for an instrument
|
* Return pending orders for an instrument
|
||||||
*/
|
*/
|
||||||
public function orders()
|
public function orders()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$instrumentId = $this->request->getGet('instrument');
|
$instrumentId = $this->request->getGet('instrument');
|
||||||
|
|
||||||
if (!$instrumentId) {
|
if (!$instrumentId) {
|
||||||
return $this->failValidationErrors('instrument parameter is required');
|
return $this->failValidationErrors('instrument parameter is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement order fetching logic
|
// TODO: Implement order fetching logic
|
||||||
// For now, return empty array
|
// For now, return empty array
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Orders fetched',
|
'message' => 'Orders fetched',
|
||||||
'data' => []
|
'data' => []
|
||||||
]);
|
]);
|
||||||
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Error fetching orders: ' . $e->getMessage());
|
return $this->failServerError('Error fetching orders: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /api/edge/orders/:id/ack
|
* POST /api/edge/orders/:id/ack
|
||||||
* Acknowledge order delivery
|
* Acknowledge order delivery
|
||||||
*/
|
*/
|
||||||
public function ack($orderId = null)
|
public function ack($orderId = null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (!$orderId) {
|
if (!$orderId) {
|
||||||
return $this->failValidationErrors('Order ID is required');
|
return $this->failValidationErrors('Order ID is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$instrumentId = $input['instrument_id'] ?? null;
|
$instrumentId = $input['instrument_id'] ?? null;
|
||||||
|
|
||||||
// Log acknowledgment
|
// Log acknowledgment
|
||||||
$this->db->table('edgeack')->insert([
|
$this->db->table('edgeack')->insert([
|
||||||
'OrderID' => $orderId,
|
'OrderID' => $orderId,
|
||||||
'InstrumentID' => $instrumentId,
|
'InstrumentID' => $instrumentId,
|
||||||
'AckDate' => date('Y-m-d H:i:s'),
|
'AckDate' => date('Y-m-d H:i:s'),
|
||||||
'CreateDate' => date('Y-m-d H:i:s')
|
'CreateDate' => date('Y-m-d H:i:s')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Order acknowledged',
|
'message' => 'Order acknowledged',
|
||||||
'data' => [
|
'data' => [
|
||||||
'order_id' => $orderId
|
'order_id' => $orderId
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Error acknowledging order: ' . $e->getMessage());
|
return $this->failServerError('Error acknowledging order: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /api/edge/status
|
* POST /api/edge/status
|
||||||
* Log instrument status
|
* Log instrument status
|
||||||
*/
|
*/
|
||||||
public function status()
|
public function status()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
|
|
||||||
$instrumentId = $input['instrument_id'] ?? null;
|
$instrumentId = $input['instrument_id'] ?? null;
|
||||||
$status = $input['status'] ?? null;
|
$status = $input['status'] ?? null;
|
||||||
$lastActivity = $input['last_activity'] ?? null;
|
$lastActivity = $input['last_activity'] ?? null;
|
||||||
$timestamp = $input['timestamp'] ?? date('Y-m-d H:i:s');
|
$timestamp = $input['timestamp'] ?? date('Y-m-d H:i:s');
|
||||||
|
|
||||||
if (!$instrumentId || !$status) {
|
if (!$instrumentId || !$status) {
|
||||||
return $this->failValidationErrors('instrument_id and status are required');
|
return $this->failValidationErrors('instrument_id and status are required');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store status log
|
// Store status log
|
||||||
$this->db->table('edgestatus')->insert([
|
$this->db->table('edgestatus')->insert([
|
||||||
'InstrumentID' => $instrumentId,
|
'InstrumentID' => $instrumentId,
|
||||||
'Status' => $status,
|
'Status' => $status,
|
||||||
'LastActivity' => $lastActivity,
|
'LastActivity' => $lastActivity,
|
||||||
'Timestamp' => $timestamp,
|
'Timestamp' => $timestamp,
|
||||||
'CreateDate' => date('Y-m-d H:i:s')
|
'CreateDate' => date('Y-m-d H:i:s')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Status logged'
|
'message' => 'Status logged'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Error logging status: ' . $e->getMessage());
|
return $this->failServerError('Error logging status: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,33 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
|
|
||||||
use Firebase\JWT\JWT;
|
use Firebase\JWT\JWT;
|
||||||
use Firebase\JWT\Key;
|
use Firebase\JWT\Key;
|
||||||
use Firebase\JWT\ExpiredException;
|
use Firebase\JWT\ExpiredException;
|
||||||
use Firebase\JWT\SignatureInvalidException;
|
use Firebase\JWT\SignatureInvalidException;
|
||||||
use Firebase\JWT\BeforeValidException;
|
use Firebase\JWT\BeforeValidException;
|
||||||
use CodeIgniter\Cookie\Cookie;
|
use CodeIgniter\Cookie\Cookie;
|
||||||
|
|
||||||
class HomeController extends Controller {
|
class HomeController extends Controller {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
|
|
||||||
// $token = $this->request->getCookie('token');
|
// $token = $this->request->getCookie('token');
|
||||||
// $key = getenv('JWT_SECRET');
|
// $key = getenv('JWT_SECRET');
|
||||||
|
|
||||||
// // Decode Token dengan Key yg ada di .env
|
// // Decode Token dengan Key yg ada di .env
|
||||||
// $decodedPayload = JWT::decode($token, new Key($key, 'HS256'));
|
// $decodedPayload = JWT::decode($token, new Key($key, 'HS256'));
|
||||||
|
|
||||||
// return $this->respond([
|
// return $this->respond([
|
||||||
// 'status' => 'success',
|
// 'status' => 'success',
|
||||||
// 'code' => 200,
|
// 'code' => 200,
|
||||||
// 'message' => 'Authenticated',
|
// 'message' => 'Authenticated',
|
||||||
// 'data' => $decodedPayload
|
// 'data' => $decodedPayload
|
||||||
// ], 200);
|
// ], 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,113 +1,113 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers\Infrastructure;
|
namespace App\Controllers\Infrastructure;
|
||||||
|
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Models\Infrastructure\EquipmentListModel;
|
use App\Models\Infrastructure\EquipmentListModel;
|
||||||
|
|
||||||
class EquipmentListController extends BaseController {
|
class EquipmentListController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new EquipmentListModel();
|
$this->model = new EquipmentListModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$filter = [
|
$filter = [
|
||||||
'IEID' => $this->request->getVar('IEID'),
|
'IEID' => $this->request->getVar('IEID'),
|
||||||
'InstrumentName' => $this->request->getVar('InstrumentName'),
|
'InstrumentName' => $this->request->getVar('InstrumentName'),
|
||||||
'DepartmentID' => $this->request->getVar('DepartmentID'),
|
'DepartmentID' => $this->request->getVar('DepartmentID'),
|
||||||
'WorkstationID' => $this->request->getVar('WorkstationID'),
|
'WorkstationID' => $this->request->getVar('WorkstationID'),
|
||||||
'Enable' => $this->request->getVar('Enable'),
|
'Enable' => $this->request->getVar('Enable'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$rows = $this->model->getEquipmentLists($filter);
|
$rows = $this->model->getEquipmentLists($filter);
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'no Data.',
|
'message' => 'no Data.',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'fetch success',
|
'message' => 'fetch success',
|
||||||
'data' => $rows
|
'data' => $rows
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($EID = null) {
|
public function show($EID = null) {
|
||||||
$row = $this->model->getEquipmentList($EID);
|
$row = $this->model->getEquipmentList($EID);
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'no Data.',
|
'message' => 'no Data.',
|
||||||
'data' => null
|
'data' => null
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'fetch success',
|
'message' => 'fetch success',
|
||||||
'data' => $row
|
'data' => $row
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$EID = $this->model->insert($input, true);
|
$EID = $this->model->insert($input, true);
|
||||||
return $this->respondCreated([
|
return $this->respondCreated([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'data created successfully',
|
'message' => 'data created successfully',
|
||||||
'data' => $EID
|
'data' => $EID
|
||||||
], 201);
|
], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$EID = $input['EID'];
|
$EID = $input['EID'];
|
||||||
$this->model->update($EID, $input);
|
$this->model->update($EID, $input);
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'data updated successfully',
|
'message' => 'data updated successfully',
|
||||||
'data' => $EID
|
'data' => $EID
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
try {
|
try {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$EID = $input['EID'];
|
$EID = $input['EID'];
|
||||||
|
|
||||||
if (!$EID) {
|
if (!$EID) {
|
||||||
return $this->failValidationErrors('EID is required.');
|
return $this->failValidationErrors('EID is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->model->delete($EID);
|
$this->model->delete($EID);
|
||||||
return $this->respondDeleted([
|
return $this->respondDeleted([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => "{$EID} deleted successfully."
|
'message' => "{$EID} deleted successfully."
|
||||||
]);
|
]);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,75 +1,75 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Models\Location\LocationModel;
|
use App\Models\Location\LocationModel;
|
||||||
|
|
||||||
class LocationController extends BaseController {
|
class LocationController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $model;
|
protected $model;
|
||||||
protected $rules;
|
protected $rules;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->model = new LocationModel();
|
$this->model = new LocationModel();
|
||||||
$this->rules = [
|
$this->rules = [
|
||||||
'LocCode' => 'required|max_length[6]',
|
'LocCode' => 'required|max_length[6]',
|
||||||
'LocFull' => 'required',
|
'LocFull' => 'required',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$LocName = $this->request->getVar('LocName');
|
$LocName = $this->request->getVar('LocName');
|
||||||
$LocCode = $this->request->getVar('LocCode');
|
$LocCode = $this->request->getVar('LocCode');
|
||||||
$rows = $this->model->getLocations($LocCode,$LocName);
|
$rows = $this->model->getLocations($LocCode,$LocName);
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($LocationID = null) {
|
public function show($LocationID = null) {
|
||||||
$row = $this->model->getLocation($LocationID);
|
$row = $this->model->getLocation($LocationID);
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$result = $this->model->saveLocation($input);
|
$result = $this->model->saveLocation($input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $result ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $result ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors( $this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors( $this->validator->getErrors()); }
|
||||||
$result = $this->model->saveLocation($input, true);
|
$result = $this->model->saveLocation($input, true);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $result ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $result ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$LocationID = $input["LocationID"];
|
$LocationID = $input["LocationID"];
|
||||||
$this->model->deleteLocation($LocationID);
|
$this->model->deleteLocation($LocationID);
|
||||||
return $this->respondDeleted([ 'status' => 'success', 'message' => "Location with {$LocationID} deleted successfully." ]);
|
return $this->respondDeleted([ 'status' => 'success', 'message' => "Location with {$LocationID} deleted successfully." ]);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,304 +1,290 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
use App\Libraries\ValueSet;
|
use App\Libraries\ValueSet;
|
||||||
use App\Models\OrderTest\OrderTestModel;
|
use App\Models\OrderTest\OrderTestModel;
|
||||||
use App\Models\Patient\PatientModel;
|
use App\Models\Patient\PatientModel;
|
||||||
use App\Models\PatVisit\PatVisitModel;
|
use App\Models\PatVisit\PatVisitModel;
|
||||||
use App\Services\RuleEngineService;
|
|
||||||
|
class OrderTestController extends Controller {
|
||||||
class OrderTestController extends Controller {
|
use ResponseTrait;
|
||||||
use ResponseTrait;
|
|
||||||
|
protected $db;
|
||||||
protected $db;
|
protected $model;
|
||||||
protected $model;
|
protected $patientModel;
|
||||||
protected $patientModel;
|
protected $visitModel;
|
||||||
protected $visitModel;
|
protected $rules;
|
||||||
protected $rules;
|
|
||||||
|
public function __construct() {
|
||||||
public function __construct() {
|
$this->db = \Config\Database::connect();
|
||||||
$this->db = \Config\Database::connect();
|
$this->model = new OrderTestModel();
|
||||||
$this->model = new OrderTestModel();
|
$this->patientModel = new PatientModel();
|
||||||
$this->patientModel = new PatientModel();
|
$this->visitModel = new PatVisitModel();
|
||||||
$this->visitModel = new PatVisitModel();
|
$this->rules = [
|
||||||
$this->rules = [
|
'InternalPID' => 'required|is_natural'
|
||||||
'InternalPID' => 'required|is_natural'
|
];
|
||||||
];
|
}
|
||||||
}
|
|
||||||
|
public function index() {
|
||||||
public function index() {
|
$internalPID = $this->request->getVar('InternalPID');
|
||||||
$internalPID = $this->request->getVar('InternalPID');
|
$includeDetails = $this->request->getVar('include') === 'details';
|
||||||
$includeDetails = $this->request->getVar('include') === 'details';
|
|
||||||
|
try {
|
||||||
try {
|
if ($internalPID) {
|
||||||
if ($internalPID) {
|
$rows = $this->model->getOrdersByPatient($internalPID);
|
||||||
$rows = $this->model->getOrdersByPatient($internalPID);
|
} else {
|
||||||
} else {
|
$rows = $this->db->table('ordertest')
|
||||||
$rows = $this->db->table('ordertest')
|
->where('DelDate', null)
|
||||||
->where('DelDate', null)
|
->orderBy('TrnDate', 'DESC')
|
||||||
->orderBy('TrnDate', 'DESC')
|
->get()
|
||||||
->get()
|
->getResultArray();
|
||||||
->getResultArray();
|
}
|
||||||
}
|
|
||||||
|
$rows = ValueSet::transformLabels($rows, [
|
||||||
$rows = ValueSet::transformLabels($rows, [
|
'Priority' => 'order_priority',
|
||||||
'Priority' => 'order_priority',
|
'OrderStatus' => 'order_status',
|
||||||
'OrderStatus' => 'order_status',
|
]);
|
||||||
]);
|
|
||||||
|
if ($includeDetails && !empty($rows)) {
|
||||||
if ($includeDetails && !empty($rows)) {
|
foreach ($rows as &$row) {
|
||||||
foreach ($rows as &$row) {
|
$row['Specimens'] = $this->getOrderSpecimens($row['InternalOID']);
|
||||||
$row['Specimens'] = $this->getOrderSpecimens($row['InternalOID']);
|
$row['Tests'] = $this->getOrderTests($row['InternalOID']);
|
||||||
$row['Tests'] = $this->getOrderTests($row['InternalOID']);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return $this->respond([
|
||||||
return $this->respond([
|
'status' => 'success',
|
||||||
'status' => 'success',
|
'message' => 'Data fetched successfully',
|
||||||
'message' => 'Data fetched successfully',
|
'data' => $rows
|
||||||
'data' => $rows
|
], 200);
|
||||||
], 200);
|
} catch (\Exception $e) {
|
||||||
} catch (\Exception $e) {
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public function show($orderID = null) {
|
||||||
public function show($orderID = null) {
|
try {
|
||||||
try {
|
$row = $this->model->getOrder($orderID);
|
||||||
$row = $this->model->getOrder($orderID);
|
if (empty($row)) {
|
||||||
if (empty($row)) {
|
return $this->respond([
|
||||||
return $this->respond([
|
'status' => 'success',
|
||||||
'status' => 'success',
|
'message' => 'Data not found.',
|
||||||
'message' => 'Data not found.',
|
'data' => null
|
||||||
'data' => null
|
], 200);
|
||||||
], 200);
|
}
|
||||||
}
|
|
||||||
|
$row = ValueSet::transformLabels([$row], [
|
||||||
$row = ValueSet::transformLabels([$row], [
|
'Priority' => 'order_priority',
|
||||||
'Priority' => 'order_priority',
|
'OrderStatus' => 'order_status',
|
||||||
'OrderStatus' => 'order_status',
|
])[0];
|
||||||
])[0];
|
|
||||||
|
// Include specimens and tests
|
||||||
// Include specimens and tests
|
$row['Specimens'] = $this->getOrderSpecimens($row['InternalOID']);
|
||||||
$row['Specimens'] = $this->getOrderSpecimens($row['InternalOID']);
|
$row['Tests'] = $this->getOrderTests($row['InternalOID']);
|
||||||
$row['Tests'] = $this->getOrderTests($row['InternalOID']);
|
|
||||||
|
return $this->respond([
|
||||||
return $this->respond([
|
'status' => 'success',
|
||||||
'status' => 'success',
|
'message' => 'Data fetched successfully',
|
||||||
'message' => 'Data fetched successfully',
|
'data' => $row
|
||||||
'data' => $row
|
], 200);
|
||||||
], 200);
|
} catch (\Exception $e) {
|
||||||
} catch (\Exception $e) {
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private function getOrderSpecimens($internalOID) {
|
||||||
private function getOrderSpecimens($internalOID) {
|
$specimens = $this->db->table('specimen s')
|
||||||
$specimens = $this->db->table('specimen s')
|
->select('s.*, cd.ConCode, cd.ConName')
|
||||||
->select('s.*, cd.ConCode, cd.ConName')
|
->join('containerdef cd', 'cd.ConDefID = s.ConDefID', 'left')
|
||||||
->join('containerdef cd', 'cd.ConDefID = s.ConDefID', 'left')
|
->where('s.OrderID', $internalOID)
|
||||||
->where('s.OrderID', $internalOID)
|
->where('s.EndDate IS NULL')
|
||||||
->where('s.EndDate IS NULL')
|
->get()
|
||||||
->get()
|
->getResultArray();
|
||||||
->getResultArray();
|
|
||||||
|
// Get status for each specimen
|
||||||
// Get status for each specimen
|
foreach ($specimens as &$specimen) {
|
||||||
foreach ($specimens as &$specimen) {
|
$status = $this->db->table('specimenstatus')
|
||||||
$status = $this->db->table('specimenstatus')
|
->where('SID', $specimen['SID'])
|
||||||
->where('SID', $specimen['SID'])
|
->where('EndDate IS NULL')
|
||||||
->where('EndDate IS NULL')
|
->orderBy('CreateDate', 'DESC')
|
||||||
->orderBy('CreateDate', 'DESC')
|
->get()
|
||||||
->get()
|
->getRowArray();
|
||||||
->getRowArray();
|
$specimen['Status'] = $status['SpcStatus'] ?? 'PENDING';
|
||||||
$specimen['Status'] = $status['SpcStatus'] ?? 'PENDING';
|
}
|
||||||
}
|
|
||||||
|
return $specimens;
|
||||||
return $specimens;
|
}
|
||||||
}
|
|
||||||
|
private function getOrderTests($internalOID) {
|
||||||
private function getOrderTests($internalOID) {
|
$tests = $this->db->table('patres pr')
|
||||||
$tests = $this->db->table('patres pr')
|
->select('pr.*, tds.TestSiteCode, tds.TestSiteName, tds.TestType, tds.SeqScr AS TestSeqScr, tds.SeqRpt AS TestSeqRpt, tds.DisciplineID, d.DisciplineCode, d.DisciplineName, d.SeqScr AS DisciplineSeqScr, d.SeqRpt AS DisciplineSeqRpt')
|
||||||
->select('pr.*, tds.TestSiteCode, tds.TestSiteName, tds.TestType, tds.SeqScr AS TestSeqScr, tds.SeqRpt AS TestSeqRpt, tds.DisciplineID, d.DisciplineCode, d.DisciplineName, d.SeqScr AS DisciplineSeqScr, d.SeqRpt AS DisciplineSeqRpt')
|
->join('testdefsite tds', 'tds.TestSiteID = pr.TestSiteID', 'left')
|
||||||
->join('testdefsite tds', 'tds.TestSiteID = pr.TestSiteID', 'left')
|
->join('discipline d', 'd.DisciplineID = tds.DisciplineID', 'left')
|
||||||
->join('discipline d', 'd.DisciplineID = tds.DisciplineID', 'left')
|
->where('pr.OrderID', $internalOID)
|
||||||
->where('pr.OrderID', $internalOID)
|
->where('pr.DelDate IS NULL')
|
||||||
->where('pr.DelDate IS NULL')
|
->orderBy('COALESCE(d.SeqScr, 999999) ASC')
|
||||||
->orderBy('COALESCE(d.SeqScr, 999999) ASC')
|
->orderBy('COALESCE(d.SeqRpt, 999999) ASC')
|
||||||
->orderBy('COALESCE(d.SeqRpt, 999999) ASC')
|
->orderBy('COALESCE(tds.SeqScr, 999999) ASC')
|
||||||
->orderBy('COALESCE(tds.SeqScr, 999999) ASC')
|
->orderBy('COALESCE(tds.SeqRpt, 999999) ASC')
|
||||||
->orderBy('COALESCE(tds.SeqRpt, 999999) ASC')
|
->orderBy('pr.ResultID ASC')
|
||||||
->orderBy('pr.ResultID ASC')
|
->get()
|
||||||
->get()
|
->getResultArray();
|
||||||
->getResultArray();
|
|
||||||
|
foreach ($tests as &$test) {
|
||||||
foreach ($tests as &$test) {
|
$discipline = [
|
||||||
$discipline = [
|
'DisciplineID' => $test['DisciplineID'] ?? null,
|
||||||
'DisciplineID' => $test['DisciplineID'] ?? null,
|
'DisciplineCode' => $test['DisciplineCode'] ?? null,
|
||||||
'DisciplineCode' => $test['DisciplineCode'] ?? null,
|
'DisciplineName' => $test['DisciplineName'] ?? null,
|
||||||
'DisciplineName' => $test['DisciplineName'] ?? null,
|
'SeqScr' => $test['DisciplineSeqScr'] ?? null,
|
||||||
'SeqScr' => $test['DisciplineSeqScr'] ?? null,
|
'SeqRpt' => $test['DisciplineSeqRpt'] ?? null,
|
||||||
'SeqRpt' => $test['DisciplineSeqRpt'] ?? null,
|
];
|
||||||
];
|
|
||||||
|
$test['Discipline'] = $discipline;
|
||||||
$test['Discipline'] = $discipline;
|
$test['SeqScr'] = $test['TestSeqScr'] ?? null;
|
||||||
$test['SeqScr'] = $test['TestSeqScr'] ?? null;
|
$test['SeqRpt'] = $test['TestSeqRpt'] ?? null;
|
||||||
$test['SeqRpt'] = $test['TestSeqRpt'] ?? null;
|
$test['DisciplineID'] = $discipline['DisciplineID'];
|
||||||
$test['DisciplineID'] = $discipline['DisciplineID'];
|
|
||||||
|
unset($test['DisciplineCode'], $test['DisciplineName'], $test['DisciplineSeqScr'], $test['DisciplineSeqRpt'], $test['TestSeqScr'], $test['TestSeqRpt']);
|
||||||
unset($test['DisciplineCode'], $test['DisciplineName'], $test['DisciplineSeqScr'], $test['DisciplineSeqRpt'], $test['TestSeqScr'], $test['TestSeqRpt']);
|
}
|
||||||
}
|
unset($test);
|
||||||
unset($test);
|
|
||||||
|
return $tests;
|
||||||
return $tests;
|
}
|
||||||
}
|
|
||||||
|
public function create() {
|
||||||
public function create() {
|
$input = $this->request->getJSON(true);
|
||||||
$input = $this->request->getJSON(true);
|
|
||||||
|
if (!$this->validateData($input, $this->rules)) {
|
||||||
if (!$this->validateData($input, $this->rules)) {
|
return $this->failValidationErrors($this->validator->getErrors());
|
||||||
return $this->failValidationErrors($this->validator->getErrors());
|
}
|
||||||
}
|
|
||||||
|
try {
|
||||||
try {
|
if (!$this->patientModel->find($input['InternalPID'])) {
|
||||||
if (!$this->patientModel->find($input['InternalPID'])) {
|
return $this->failValidationErrors(['InternalPID' => 'Patient not found']);
|
||||||
return $this->failValidationErrors(['InternalPID' => 'Patient not found']);
|
}
|
||||||
}
|
|
||||||
|
if (!empty($input['PatVisitID'])) {
|
||||||
if (!empty($input['PatVisitID'])) {
|
$visit = $this->visitModel->find($input['PatVisitID']);
|
||||||
$visit = $this->visitModel->find($input['PatVisitID']);
|
if (!$visit) {
|
||||||
if (!$visit) {
|
return $this->failValidationErrors(['PatVisitID' => 'Visit not found']);
|
||||||
return $this->failValidationErrors(['PatVisitID' => 'Visit not found']);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
$orderID = $this->model->createOrder($input);
|
||||||
$orderID = $this->model->createOrder($input);
|
|
||||||
|
// Fetch complete order details
|
||||||
// Fetch complete order details
|
$order = $this->model->getOrder($orderID);
|
||||||
$order = $this->model->getOrder($orderID);
|
$order['Specimens'] = $this->getOrderSpecimens($order['InternalOID']);
|
||||||
$order['Specimens'] = $this->getOrderSpecimens($order['InternalOID']);
|
$order['Tests'] = $this->getOrderTests($order['InternalOID']);
|
||||||
$order['Tests'] = $this->getOrderTests($order['InternalOID']);
|
|
||||||
|
// Rule engine triggers are fired at the test/result level (test_created, result_updated)
|
||||||
// Run common rules for ORDER_CREATED (non-blocking)
|
|
||||||
try {
|
|
||||||
$ruleEngine = new RuleEngineService();
|
|
||||||
$ruleEngine->run('ORDER_CREATED', [
|
|
||||||
'order' => $order,
|
|
||||||
'tests' => $order['Tests'],
|
|
||||||
'input' => $input,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Refresh tests in case rules updated results
|
|
||||||
$order['Tests'] = $this->getOrderTests($order['InternalOID']);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
log_message('error', 'OrderTestController::create rule engine error: ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->respondCreated([
|
return $this->respondCreated([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Order created successfully',
|
'message' => 'Order created successfully',
|
||||||
'data' => $order
|
'data' => $order
|
||||||
], 201);
|
], 201);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
|
|
||||||
if (empty($input['OrderID'])) {
|
if (empty($input['OrderID'])) {
|
||||||
return $this->failValidationErrors(['OrderID' => 'OrderID is required']);
|
return $this->failValidationErrors(['OrderID' => 'OrderID is required']);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$order = $this->model->getOrder($input['OrderID']);
|
$order = $this->model->getOrder($input['OrderID']);
|
||||||
if (!$order) {
|
if (!$order) {
|
||||||
return $this->failNotFound('Order not found');
|
return $this->failNotFound('Order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$updateData = [];
|
$updateData = [];
|
||||||
if (isset($input['Priority'])) $updateData['Priority'] = $input['Priority'];
|
if (isset($input['Priority'])) $updateData['Priority'] = $input['Priority'];
|
||||||
if (isset($input['OrderStatus'])) $updateData['OrderStatus'] = $input['OrderStatus'];
|
if (isset($input['OrderStatus'])) $updateData['OrderStatus'] = $input['OrderStatus'];
|
||||||
if (isset($input['OrderingProvider'])) $updateData['OrderingProvider'] = $input['OrderingProvider'];
|
if (isset($input['OrderingProvider'])) $updateData['OrderingProvider'] = $input['OrderingProvider'];
|
||||||
if (isset($input['DepartmentID'])) $updateData['DepartmentID'] = $input['DepartmentID'];
|
if (isset($input['DepartmentID'])) $updateData['DepartmentID'] = $input['DepartmentID'];
|
||||||
if (isset($input['WorkstationID'])) $updateData['WorkstationID'] = $input['WorkstationID'];
|
if (isset($input['WorkstationID'])) $updateData['WorkstationID'] = $input['WorkstationID'];
|
||||||
|
|
||||||
if (!empty($updateData)) {
|
if (!empty($updateData)) {
|
||||||
$this->model->update($order['InternalOID'], $updateData);
|
$this->model->update($order['InternalOID'], $updateData);
|
||||||
}
|
}
|
||||||
|
|
||||||
$updatedOrder = $this->model->getOrder($input['OrderID']);
|
$updatedOrder = $this->model->getOrder($input['OrderID']);
|
||||||
$updatedOrder['Specimens'] = $this->getOrderSpecimens($updatedOrder['InternalOID']);
|
$updatedOrder['Specimens'] = $this->getOrderSpecimens($updatedOrder['InternalOID']);
|
||||||
$updatedOrder['Tests'] = $this->getOrderTests($updatedOrder['InternalOID']);
|
$updatedOrder['Tests'] = $this->getOrderTests($updatedOrder['InternalOID']);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Order updated successfully',
|
'message' => 'Order updated successfully',
|
||||||
'data' => $updatedOrder
|
'data' => $updatedOrder
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$orderID = $input['OrderID'] ?? null;
|
$orderID = $input['OrderID'] ?? null;
|
||||||
|
|
||||||
if (empty($orderID)) {
|
if (empty($orderID)) {
|
||||||
return $this->failValidationErrors(['OrderID' => 'OrderID is required']);
|
return $this->failValidationErrors(['OrderID' => 'OrderID is required']);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$order = $this->model->getOrder($orderID);
|
$order = $this->model->getOrder($orderID);
|
||||||
if (!$order) {
|
if (!$order) {
|
||||||
return $this->failNotFound('Order not found');
|
return $this->failNotFound('Order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->model->softDelete($orderID);
|
$this->model->softDelete($orderID);
|
||||||
|
|
||||||
return $this->respondDeleted([
|
return $this->respondDeleted([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Order deleted successfully'
|
'message' => 'Order deleted successfully'
|
||||||
]);
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateStatus() {
|
public function updateStatus() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
|
|
||||||
if (empty($input['OrderID']) || empty($input['OrderStatus'])) {
|
if (empty($input['OrderID']) || empty($input['OrderStatus'])) {
|
||||||
return $this->failValidationErrors(['error' => 'OrderID and OrderStatus are required']);
|
return $this->failValidationErrors(['error' => 'OrderID and OrderStatus are required']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$validStatuses = ['ORD', 'SCH', 'ANA', 'VER', 'REV', 'REP'];
|
$validStatuses = ['ORD', 'SCH', 'ANA', 'VER', 'REV', 'REP'];
|
||||||
if (!in_array($input['OrderStatus'], $validStatuses)) {
|
if (!in_array($input['OrderStatus'], $validStatuses)) {
|
||||||
return $this->failValidationErrors(['OrderStatus' => 'Invalid status. Valid: ' . implode(', ', $validStatuses)]);
|
return $this->failValidationErrors(['OrderStatus' => 'Invalid status. Valid: ' . implode(', ', $validStatuses)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$order = $this->model->getOrder($input['OrderID']);
|
$order = $this->model->getOrder($input['OrderID']);
|
||||||
if (!$order) {
|
if (!$order) {
|
||||||
return $this->failNotFound('Order not found');
|
return $this->failNotFound('Order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->model->updateStatus($input['OrderID'], $input['OrderStatus']);
|
$this->model->updateStatus($input['OrderID'], $input['OrderStatus']);
|
||||||
|
|
||||||
$updatedOrder = $this->model->getOrder($input['OrderID']);
|
$updatedOrder = $this->model->getOrder($input['OrderID']);
|
||||||
$updatedOrder['Specimens'] = $this->getOrderSpecimens($updatedOrder['InternalOID']);
|
$updatedOrder['Specimens'] = $this->getOrderSpecimens($updatedOrder['InternalOID']);
|
||||||
$updatedOrder['Tests'] = $this->getOrderTests($updatedOrder['InternalOID']);
|
$updatedOrder['Tests'] = $this->getOrderTests($updatedOrder['InternalOID']);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Order status updated successfully',
|
'message' => 'Order status updated successfully',
|
||||||
'data' => $updatedOrder
|
'data' => $updatedOrder
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,79 +1,79 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers\Organization;
|
namespace App\Controllers\Organization;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
|
|
||||||
use App\Models\Organization\AccountModel;
|
use App\Models\Organization\AccountModel;
|
||||||
|
|
||||||
class AccountController extends BaseController {
|
class AccountController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new AccountModel();
|
$this->model = new AccountModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$filter = [
|
$filter = [
|
||||||
'Parent' => $this->request->getVar('Parent'),
|
'Parent' => $this->request->getVar('Parent'),
|
||||||
'AccountName' => $this->request->getVar('AccountName'),
|
'AccountName' => $this->request->getVar('AccountName'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$rows = $this->model->getAccounts($filter);
|
$rows = $this->model->getAccounts($filter);
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($AccountID = null) {
|
public function show($AccountID = null) {
|
||||||
//$rows = $this->model->where('AccountID', $AccountID)->findAll();
|
//$rows = $this->model->where('AccountID', $AccountID)->findAll();
|
||||||
$row = $this->model->getAccount($AccountID);
|
$row = $this->model->getAccount($AccountID);
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
try {
|
try {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$id = $input["AccountID"];
|
$id = $input["AccountID"];
|
||||||
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
||||||
$this->model->delete($id);
|
$this->model->delete($id);
|
||||||
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$id = $this->model->insert($input,true);
|
$id = $this->model->insert($input,true);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$id = $input['AccountID'];
|
$id = $input['AccountID'];
|
||||||
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
||||||
$this->model->update($id, $input);
|
$this->model->update($id, $input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,75 +1,75 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers\Organization;
|
namespace App\Controllers\Organization;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
|
|
||||||
use App\Models\Organization\DepartmentModel;
|
use App\Models\Organization\DepartmentModel;
|
||||||
|
|
||||||
class DepartmentController extends BaseController {
|
class DepartmentController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new DepartmentModel();
|
$this->model = new DepartmentModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$filter = [
|
$filter = [
|
||||||
'DepartmentCode' => $this->request->getVar('DepartmentCode'),
|
'DepartmentCode' => $this->request->getVar('DepartmentCode'),
|
||||||
'DepartmentName' => $this->request->getVar('DepartmentName'),
|
'DepartmentName' => $this->request->getVar('DepartmentName'),
|
||||||
];
|
];
|
||||||
$rows = $this->model->getDepartments($filter);
|
$rows = $this->model->getDepartments($filter);
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($DepartmentID = null) {
|
public function show($DepartmentID = null) {
|
||||||
$row = $this->model->getDepartment($DepartmentID);
|
$row = $this->model->getDepartment($DepartmentID);
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
try {
|
try {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$id = $input["DepartmentID"];
|
$id = $input["DepartmentID"];
|
||||||
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
||||||
$this->model->delete($id);
|
$this->model->delete($id);
|
||||||
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$id = $this->model->insert($input,true);
|
$id = $this->model->insert($input,true);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$id = $input['DepartmentID'];
|
$id = $input['DepartmentID'];
|
||||||
$this->model->update($id, $input);
|
$this->model->update($id, $input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,82 +1,82 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers\Organization;
|
namespace App\Controllers\Organization;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
|
|
||||||
use App\Models\Organization\DisciplineModel;
|
use App\Models\Organization\DisciplineModel;
|
||||||
|
|
||||||
class DisciplineController extends BaseController {
|
class DisciplineController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new DisciplineModel();
|
$this->model = new DisciplineModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$filter = [
|
$filter = [
|
||||||
'DisciplineCode' => $this->request->getVar('DisciplineCode'),
|
'DisciplineCode' => $this->request->getVar('DisciplineCode'),
|
||||||
'DisciplineName' => $this->request->getVar('DisciplineName'),
|
'DisciplineName' => $this->request->getVar('DisciplineName'),
|
||||||
];
|
];
|
||||||
$rows = $this->model->getDisciplines($filter);
|
$rows = $this->model->getDisciplines($filter);
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($DisciplineID = null) {
|
public function show($DisciplineID = null) {
|
||||||
$row = $this->model->where('DisciplineID', $DisciplineID)->first();
|
$row = $this->model->where('DisciplineID', $DisciplineID)->first();
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
try {
|
try {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$id = $input["DisciplineID"];
|
$id = $input["DisciplineID"];
|
||||||
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
||||||
$this->model->delete($id);
|
$this->model->delete($id);
|
||||||
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$id = $this->model->insert($input,true);
|
$id = $this->model->insert($input,true);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$id = $input['DisciplineID'];
|
$id = $input['DisciplineID'];
|
||||||
$this->model->update($id, $input);
|
$this->model->update($id, $input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
||||||
/*
|
/*
|
||||||
try {
|
try {
|
||||||
$id = $input['DisciplineID'];
|
$id = $input['DisciplineID'];
|
||||||
$this->model->where('DisciplineID', $id)->update();
|
$this->model->where('DisciplineID', $id)->update();
|
||||||
echo $this->model->getLastQuery();
|
echo $this->model->getLastQuery();
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage() );
|
return $this->failServerError('Something went wrong: ' . $e->getMessage() );
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,102 +1,102 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers\Organization;
|
namespace App\Controllers\Organization;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
|
|
||||||
use App\Models\Organization\SiteModel;
|
use App\Models\Organization\SiteModel;
|
||||||
|
|
||||||
class SiteController extends BaseController {
|
class SiteController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new SiteModel();
|
$this->model = new SiteModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$filter = [
|
$filter = [
|
||||||
'SiteCode' => $this->request->getVar('SiteCode'),
|
'SiteCode' => $this->request->getVar('SiteCode'),
|
||||||
'SiteName' => $this->request->getVar('SiteName'),
|
'SiteName' => $this->request->getVar('SiteName'),
|
||||||
];
|
];
|
||||||
$rows = $this->model->getSites($filter);
|
$rows = $this->model->getSites($filter);
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||||
}
|
}
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function show($SiteID = null) {
|
public function show($SiteID = null) {
|
||||||
//$rows = $this->model->where('SiteID', $SiteID)->findAll();
|
//$rows = $this->model->where('SiteID', $SiteID)->findAll();
|
||||||
$row = $this->model->getSite($SiteID);
|
$row = $this->model->getSite($SiteID);
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
try {
|
try {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$id = $input["SiteID"];
|
$id = $input["SiteID"];
|
||||||
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
||||||
$this->model->delete($id);
|
$this->model->delete($id);
|
||||||
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
|
|
||||||
$validation = service('validation');
|
$validation = service('validation');
|
||||||
$validation->setRules([
|
$validation->setRules([
|
||||||
'SiteCode' => 'required|regex_match[/^[A-Z0-9]{2}$/]',
|
'SiteCode' => 'required|regex_match[/^[A-Z0-9]{2}$/]',
|
||||||
'SiteName' => 'required',
|
'SiteName' => 'required',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!$validation->run($input)) {
|
if (!$validation->run($input)) {
|
||||||
return $this->failValidationErrors($validation->getErrors());
|
return $this->failValidationErrors($validation->getErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$id = $this->model->insert($input,true);
|
$id = $this->model->insert($input,true);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
|
|
||||||
$id = $input['SiteID'];
|
$id = $input['SiteID'];
|
||||||
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
||||||
|
|
||||||
if (!empty($input['SiteCode'])) {
|
if (!empty($input['SiteCode'])) {
|
||||||
$validation = service('validation');
|
$validation = service('validation');
|
||||||
$validation->setRules([
|
$validation->setRules([
|
||||||
'SiteCode' => 'regex_match[/^[A-Z0-9]{2}$/]',
|
'SiteCode' => 'regex_match[/^[A-Z0-9]{2}$/]',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!$validation->run($input)) {
|
if (!$validation->run($input)) {
|
||||||
return $this->failValidationErrors($validation->getErrors());
|
return $this->failValidationErrors($validation->getErrors());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->model->update($id, $input);
|
$this->model->update($id, $input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,76 +1,76 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers\Organization;
|
namespace App\Controllers\Organization;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
|
|
||||||
use App\Models\Organization\WorkstationModel;
|
use App\Models\Organization\WorkstationModel;
|
||||||
|
|
||||||
class WorkstationController extends BaseController {
|
class WorkstationController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new WorkstationModel();
|
$this->model = new WorkstationModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$filter = [
|
$filter = [
|
||||||
'WorkstationCode' => $this->request->getVar('WorkstationCode'),
|
'WorkstationCode' => $this->request->getVar('WorkstationCode'),
|
||||||
'WorkstationName' => $this->request->getVar('WorkstationName'),
|
'WorkstationName' => $this->request->getVar('WorkstationName'),
|
||||||
];
|
];
|
||||||
$rows = $this->model->getWorkstations($filter);
|
$rows = $this->model->getWorkstations($filter);
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($WorkstationID = null) {
|
public function show($WorkstationID = null) {
|
||||||
$row = $this->model->getWorkstation($WorkstationID);
|
$row = $this->model->getWorkstation($WorkstationID);
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
try {
|
try {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$id = $input["WorkstationID"];
|
$id = $input["WorkstationID"];
|
||||||
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
||||||
$this->model->delete($id);
|
$this->model->delete($id);
|
||||||
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$id = $this->model->insert($input,true);
|
$id = $this->model->insert($input,true);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
$id = $input['WorkstationID'];
|
$id = $input['WorkstationID'];
|
||||||
$this->model->update($id, $input);
|
$this->model->update($id, $input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PagesController - Serves view pages
|
* PagesController - Serves view pages
|
||||||
*
|
*
|
||||||
* This controller only returns views. No business logic.
|
* This controller only returns views. No business logic.
|
||||||
* All data is fetched via API calls from the frontend.
|
* All data is fetched via API calls from the frontend.
|
||||||
*/
|
*/
|
||||||
class PagesController extends BaseController
|
class PagesController extends BaseController
|
||||||
{
|
{
|
||||||
// Add page methods here as needed
|
// Add page methods here as needed
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,276 +1,276 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Models\PatVisit\PatVisitModel;
|
use App\Models\PatVisit\PatVisitModel;
|
||||||
use App\Models\PatVisit\PatVisitADTModel;
|
use App\Models\PatVisit\PatVisitADTModel;
|
||||||
use App\Models\Patient\PatientModel;
|
use App\Models\Patient\PatientModel;
|
||||||
|
|
||||||
class PatVisitController extends BaseController {
|
class PatVisitController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->model = new PatVisitModel();
|
$this->model = new PatVisitModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
try {
|
try {
|
||||||
$InternalPID = $this->request->getVar('InternalPID');
|
$InternalPID = $this->request->getVar('InternalPID');
|
||||||
$PVID = $this->request->getVar('PVID');
|
$PVID = $this->request->getVar('PVID');
|
||||||
$PatientID = $this->request->getVar('PatientID');
|
$PatientID = $this->request->getVar('PatientID');
|
||||||
$PatientName = $this->request->getVar('PatientName');
|
$PatientName = $this->request->getVar('PatientName');
|
||||||
$CreateDateFrom = $this->request->getVar('CreateDateFrom');
|
$CreateDateFrom = $this->request->getVar('CreateDateFrom');
|
||||||
$CreateDateTo = $this->request->getVar('CreateDateTo');
|
$CreateDateTo = $this->request->getVar('CreateDateTo');
|
||||||
|
|
||||||
$builder = $this->model->select('patvisit.*, patient.NameFirst, patient.NameLast, patient.PatientID, location.LocFull as LastLocation')
|
$builder = $this->model->select('patvisit.*, patient.NameFirst, patient.NameLast, patient.PatientID, location.LocFull as LastLocation')
|
||||||
->join('patient', 'patient.InternalPID=patvisit.InternalPID', 'left')
|
->join('patient', 'patient.InternalPID=patvisit.InternalPID', 'left')
|
||||||
->join('(SELECT a1.*
|
->join('(SELECT a1.*
|
||||||
FROM patvisitadt a1
|
FROM patvisitadt a1
|
||||||
INNER JOIN (
|
INNER JOIN (
|
||||||
SELECT InternalPVID, MAX(PVADTID) AS MaxID
|
SELECT InternalPVID, MAX(PVADTID) AS MaxID
|
||||||
FROM patvisitadt
|
FROM patvisitadt
|
||||||
GROUP BY InternalPVID
|
GROUP BY InternalPVID
|
||||||
) a2 ON a1.InternalPVID = a2.InternalPVID AND a1.PVADTID = a2.MaxID
|
) a2 ON a1.InternalPVID = a2.InternalPVID AND a1.PVADTID = a2.MaxID
|
||||||
) AS latest_patvisitadt', 'latest_patvisitadt.InternalPVID = patvisit.InternalPVID', 'left')
|
) AS latest_patvisitadt', 'latest_patvisitadt.InternalPVID = patvisit.InternalPVID', 'left')
|
||||||
->join('location', 'location.LocationID = latest_patvisitadt.LocationID', 'left');
|
->join('location', 'location.LocationID = latest_patvisitadt.LocationID', 'left');
|
||||||
|
|
||||||
if ($InternalPID) {
|
if ($InternalPID) {
|
||||||
$builder->where('patvisit.InternalPID', $InternalPID);
|
$builder->where('patvisit.InternalPID', $InternalPID);
|
||||||
}
|
}
|
||||||
if ($PVID) {
|
if ($PVID) {
|
||||||
$builder->like('patvisit.PVID', $PVID, 'both');
|
$builder->like('patvisit.PVID', $PVID, 'both');
|
||||||
}
|
}
|
||||||
if ($PatientID) {
|
if ($PatientID) {
|
||||||
$builder->like('patient.PatientID', $PatientID, 'both');
|
$builder->like('patient.PatientID', $PatientID, 'both');
|
||||||
}
|
}
|
||||||
if ($PatientName) {
|
if ($PatientName) {
|
||||||
$builder->groupStart()
|
$builder->groupStart()
|
||||||
->like('patient.NameFirst', $PatientName, 'both')
|
->like('patient.NameFirst', $PatientName, 'both')
|
||||||
->orLike('patient.NameLast', $PatientName, 'both')
|
->orLike('patient.NameLast', $PatientName, 'both')
|
||||||
->groupEnd();
|
->groupEnd();
|
||||||
}
|
}
|
||||||
if ($CreateDateFrom) {
|
if ($CreateDateFrom) {
|
||||||
$builder->where('patvisit.CreateDate >=', $CreateDateFrom);
|
$builder->where('patvisit.CreateDate >=', $CreateDateFrom);
|
||||||
}
|
}
|
||||||
if ($CreateDateTo) {
|
if ($CreateDateTo) {
|
||||||
$builder->where('patvisit.CreateDate <=', $CreateDateTo);
|
$builder->where('patvisit.CreateDate <=', $CreateDateTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = $builder->orderBy('patvisit.CreateDate', 'DESC')->findAll();
|
$rows = $builder->orderBy('patvisit.CreateDate', 'DESC')->findAll();
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond(['status' => 'success', 'message' => 'data not found', 'data' => []], 200);
|
return $this->respond(['status' => 'success', 'message' => 'data not found', 'data' => []], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond(['status' => 'success', 'message' => 'data found', 'data' => $rows], 200);
|
return $this->respond(['status' => 'success', 'message' => 'data found', 'data' => $rows], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($PVID = null) {
|
public function show($PVID = null) {
|
||||||
try {
|
try {
|
||||||
$row = $this->model->show($PVID);
|
$row = $this->model->show($PVID);
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => [] ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => [] ], 200);
|
||||||
}
|
}
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data found", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data found", 'data' => $row ], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong '.$e->getMessage());
|
return $this->failServerError('Something went wrong '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showByPatient($InternalPID = null) {
|
public function showByPatient($InternalPID = null) {
|
||||||
try {
|
try {
|
||||||
$rows = $this->model->showByPatient($InternalPID);
|
$rows = $this->model->showByPatient($InternalPID);
|
||||||
if($rows == []) { $message = "data not found"; }
|
if($rows == []) { $message = "data not found"; }
|
||||||
else { $message = "data found"; }
|
else { $message = "data found"; }
|
||||||
return $this->respond(['status' => 'success', 'message'=> $message, 'data' => $rows ], 200);
|
return $this->respond(['status' => 'success', 'message'=> $message, 'data' => $rows ], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong '.$e->getMessage());
|
return $this->failServerError('Something went wrong '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
if (!isset($input["InternalPVID"]) || !is_numeric($input["InternalPVID"])) {
|
if (!isset($input["InternalPVID"]) || !is_numeric($input["InternalPVID"])) {
|
||||||
return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400);
|
return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if visit exists
|
// Check if visit exists
|
||||||
$visit = $this->model->find($input["InternalPVID"]);
|
$visit = $this->model->find($input["InternalPVID"]);
|
||||||
if (!$visit) {
|
if (!$visit) {
|
||||||
return $this->respond(['status' => 'error', 'message' => 'Visit not found'], 404);
|
return $this->respond(['status' => 'error', 'message' => 'Visit not found'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->model->updatePatVisit($input);
|
$data = $this->model->updatePatVisit($input);
|
||||||
return $this->respond(['status' => 'success', 'message' => 'Data updated successfully', 'data' => $data], 200);
|
return $this->respond(['status' => 'success', 'message' => 'Data updated successfully', 'data' => $data], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
// Validate required fields
|
// Validate required fields
|
||||||
if (!isset($input['InternalPID']) || !is_numeric($input['InternalPID'])) {
|
if (!isset($input['InternalPID']) || !is_numeric($input['InternalPID'])) {
|
||||||
return $this->respond(['status' => 'error', 'message' => 'InternalPID is required and must be numeric'], 400);
|
return $this->respond(['status' => 'error', 'message' => 'InternalPID is required and must be numeric'], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if patient exists
|
// Check if patient exists
|
||||||
$patientModel = new PatientModel();
|
$patientModel = new PatientModel();
|
||||||
$patient = $patientModel->find($input['InternalPID']);
|
$patient = $patientModel->find($input['InternalPID']);
|
||||||
if (!$patient) {
|
if (!$patient) {
|
||||||
return $this->respond(['status' => 'error', 'message' => 'Patient not found'], 404);
|
return $this->respond(['status' => 'error', 'message' => 'Patient not found'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->model->createPatVisit($input);
|
$data = $this->model->createPatVisit($input);
|
||||||
return $this->respond(['status' => 'success', 'message' => 'Data created successfully', 'data' => $data], 201);
|
return $this->respond(['status' => 'success', 'message' => 'Data created successfully', 'data' => $data], 201);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
if (!isset($input["InternalPVID"]) || !is_numeric($input["InternalPVID"])) {
|
if (!isset($input["InternalPVID"]) || !is_numeric($input["InternalPVID"])) {
|
||||||
return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400);
|
return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if visit exists
|
// Check if visit exists
|
||||||
$visit = $this->model->find($input["InternalPVID"]);
|
$visit = $this->model->find($input["InternalPVID"]);
|
||||||
if (!$visit) {
|
if (!$visit) {
|
||||||
return $this->respond(['status' => 'error', 'message' => 'Visit not found'], 404);
|
return $this->respond(['status' => 'error', 'message' => 'Visit not found'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Soft delete using EndDate (configured in model)
|
// Soft delete using EndDate (configured in model)
|
||||||
$result = $this->model->delete($input["InternalPVID"]);
|
$result = $this->model->delete($input["InternalPVID"]);
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
return $this->respond(['status' => 'success', 'message' => 'Data deleted successfully'], 200);
|
return $this->respond(['status' => 'success', 'message' => 'Data deleted successfully'], 200);
|
||||||
} else {
|
} else {
|
||||||
return $this->respond(['status' => 'error', 'message' => 'Failed to delete data'], 500);
|
return $this->respond(['status' => 'error', 'message' => 'Failed to delete data'], 500);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createADT() {
|
public function createADT() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$input["InternalPVID"] || !is_numeric($input["InternalPVID"])) { return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400); }
|
if (!$input["InternalPVID"] || !is_numeric($input["InternalPVID"])) { return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400); }
|
||||||
$modelPVA = new PatVisitADTModel();
|
$modelPVA = new PatVisitADTModel();
|
||||||
try {
|
try {
|
||||||
$data = $modelPVA->insert($input, true);
|
$data = $modelPVA->insert($input, true);
|
||||||
return $this->respond(['status' => 'success', 'message' => 'Data created successfully', 'data' => $data], 201);
|
return $this->respond(['status' => 'success', 'message' => 'Data created successfully', 'data' => $data], 201);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateADT() {
|
public function updateADT() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$input["PVADTID"] || !is_numeric($input["PVADTID"])) { return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400); }
|
if (!$input["PVADTID"] || !is_numeric($input["PVADTID"])) { return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400); }
|
||||||
$modelPVA = new PatVisitADTModel();
|
$modelPVA = new PatVisitADTModel();
|
||||||
try {
|
try {
|
||||||
$data = $modelPVA->update($input['PVADTID'], $input);
|
$data = $modelPVA->update($input['PVADTID'], $input);
|
||||||
return $this->respond(['status' => 'success', 'message' => 'Data updated successfully', 'data' => $data], 200);
|
return $this->respond(['status' => 'success', 'message' => 'Data updated successfully', 'data' => $data], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getADTByVisit($InternalPVID = null) {
|
public function getADTByVisit($InternalPVID = null) {
|
||||||
try {
|
try {
|
||||||
if (!$InternalPVID || !is_numeric($InternalPVID)) {
|
if (!$InternalPVID || !is_numeric($InternalPVID)) {
|
||||||
return $this->respond(['status' => 'error', 'message' => 'Invalid or missing InternalPVID'], 400);
|
return $this->respond(['status' => 'error', 'message' => 'Invalid or missing InternalPVID'], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$modelPVA = new PatVisitADTModel();
|
$modelPVA = new PatVisitADTModel();
|
||||||
$rows = $modelPVA->select('patvisitadt.*, location.LocFull as LocationName,
|
$rows = $modelPVA->select('patvisitadt.*, location.LocFull as LocationName,
|
||||||
attDoc.NameFirst as AttDocFirstName, attDoc.NameLast as AttDocLastName,
|
attDoc.NameFirst as AttDocFirstName, attDoc.NameLast as AttDocLastName,
|
||||||
refDoc.NameFirst as RefDocFirstName, refDoc.NameLast as RefDocLastName,
|
refDoc.NameFirst as RefDocFirstName, refDoc.NameLast as RefDocLastName,
|
||||||
admDoc.NameFirst as AdmDocFirstName, admDoc.NameLast as AdmDocLastName,
|
admDoc.NameFirst as AdmDocFirstName, admDoc.NameLast as AdmDocLastName,
|
||||||
cnsDoc.NameFirst as CnsDocFirstName, cnsDoc.NameLast as CnsDocLastName')
|
cnsDoc.NameFirst as CnsDocFirstName, cnsDoc.NameLast as CnsDocLastName')
|
||||||
->join('location', 'location.LocationID = patvisitadt.LocationID', 'left')
|
->join('location', 'location.LocationID = patvisitadt.LocationID', 'left')
|
||||||
->join('contact attDoc', 'attDoc.ContactID = patvisitadt.AttDoc', 'left')
|
->join('contact attDoc', 'attDoc.ContactID = patvisitadt.AttDoc', 'left')
|
||||||
->join('contact refDoc', 'refDoc.ContactID = patvisitadt.RefDoc', 'left')
|
->join('contact refDoc', 'refDoc.ContactID = patvisitadt.RefDoc', 'left')
|
||||||
->join('contact admDoc', 'admDoc.ContactID = patvisitadt.AdmDoc', 'left')
|
->join('contact admDoc', 'admDoc.ContactID = patvisitadt.AdmDoc', 'left')
|
||||||
->join('contact cnsDoc', 'cnsDoc.ContactID = patvisitadt.CnsDoc', 'left')
|
->join('contact cnsDoc', 'cnsDoc.ContactID = patvisitadt.CnsDoc', 'left')
|
||||||
->where('patvisitadt.InternalPVID', $InternalPVID)
|
->where('patvisitadt.InternalPVID', $InternalPVID)
|
||||||
->where('patvisitadt.DelDate', null)
|
->where('patvisitadt.DelDate', null)
|
||||||
->orderBy('patvisitadt.CreateDate', 'ASC')
|
->orderBy('patvisitadt.CreateDate', 'ASC')
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond(['status' => 'success', 'message' => 'No ADT history found', 'data' => []], 200);
|
return $this->respond(['status' => 'success', 'message' => 'No ADT history found', 'data' => []], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond(['status' => 'success', 'message' => 'ADT history retrieved', 'data' => $rows], 200);
|
return $this->respond(['status' => 'success', 'message' => 'ADT history retrieved', 'data' => $rows], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showADT($PVADTID = null) {
|
public function showADT($PVADTID = null) {
|
||||||
try {
|
try {
|
||||||
if (!$PVADTID || !is_numeric($PVADTID)) {
|
if (!$PVADTID || !is_numeric($PVADTID)) {
|
||||||
return $this->respond(['status' => 'error', 'message' => 'Invalid or missing PVADTID'], 400);
|
return $this->respond(['status' => 'error', 'message' => 'Invalid or missing PVADTID'], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$modelPVA = new PatVisitADTModel();
|
$modelPVA = new PatVisitADTModel();
|
||||||
$row = $modelPVA->select('patvisitadt.*, location.LocFull as LocationName,
|
$row = $modelPVA->select('patvisitadt.*, location.LocFull as LocationName,
|
||||||
attDoc.NameFirst as AttDocFirstName, attDoc.NameLast as AttDocLastName,
|
attDoc.NameFirst as AttDocFirstName, attDoc.NameLast as AttDocLastName,
|
||||||
refDoc.NameFirst as RefDocFirstName, refDoc.NameLast as RefDocLastName,
|
refDoc.NameFirst as RefDocFirstName, refDoc.NameLast as RefDocLastName,
|
||||||
admDoc.NameFirst as AdmDocFirstName, admDoc.NameLast as AdmDocLastName,
|
admDoc.NameFirst as AdmDocFirstName, admDoc.NameLast as AdmDocLastName,
|
||||||
cnsDoc.NameFirst as CnsDocFirstName, cnsDoc.NameLast as CnsDocLastName')
|
cnsDoc.NameFirst as CnsDocFirstName, cnsDoc.NameLast as CnsDocLastName')
|
||||||
->join('location', 'location.LocationID = patvisitadt.LocationID', 'left')
|
->join('location', 'location.LocationID = patvisitadt.LocationID', 'left')
|
||||||
->join('contact attDoc', 'attDoc.ContactID = patvisitadt.AttDoc', 'left')
|
->join('contact attDoc', 'attDoc.ContactID = patvisitadt.AttDoc', 'left')
|
||||||
->join('contact refDoc', 'refDoc.ContactID = patvisitadt.RefDoc', 'left')
|
->join('contact refDoc', 'refDoc.ContactID = patvisitadt.RefDoc', 'left')
|
||||||
->join('contact admDoc', 'admDoc.ContactID = patvisitadt.AdmDoc', 'left')
|
->join('contact admDoc', 'admDoc.ContactID = patvisitadt.AdmDoc', 'left')
|
||||||
->join('contact cnsDoc', 'cnsDoc.ContactID = patvisitadt.CnsDoc', 'left')
|
->join('contact cnsDoc', 'cnsDoc.ContactID = patvisitadt.CnsDoc', 'left')
|
||||||
->where('patvisitadt.PVADTID', $PVADTID)
|
->where('patvisitadt.PVADTID', $PVADTID)
|
||||||
->where('patvisitadt.DelDate', null)
|
->where('patvisitadt.DelDate', null)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond(['status' => 'success', 'message' => 'ADT record not found', 'data' => []], 200);
|
return $this->respond(['status' => 'success', 'message' => 'ADT record not found', 'data' => []], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond(['status' => 'success', 'message' => 'ADT record retrieved', 'data' => $row], 200);
|
return $this->respond(['status' => 'success', 'message' => 'ADT record retrieved', 'data' => $row], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteADT() {
|
public function deleteADT() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
try {
|
try {
|
||||||
if (!isset($input["PVADTID"]) || !is_numeric($input["PVADTID"])) {
|
if (!isset($input["PVADTID"]) || !is_numeric($input["PVADTID"])) {
|
||||||
return $this->respond(['status' => 'error', 'message' => 'Invalid or missing PVADTID'], 400);
|
return $this->respond(['status' => 'error', 'message' => 'Invalid or missing PVADTID'], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$modelPVA = new PatVisitADTModel();
|
$modelPVA = new PatVisitADTModel();
|
||||||
$adt = $modelPVA->find($input["PVADTID"]);
|
$adt = $modelPVA->find($input["PVADTID"]);
|
||||||
if (!$adt) {
|
if (!$adt) {
|
||||||
return $this->respond(['status' => 'error', 'message' => 'ADT record not found'], 404);
|
return $this->respond(['status' => 'error', 'message' => 'ADT record not found'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $modelPVA->delete($input["PVADTID"]);
|
$result = $modelPVA->delete($input["PVADTID"]);
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
return $this->respond(['status' => 'success', 'message' => 'ADT record deleted successfully'], 200);
|
return $this->respond(['status' => 'success', 'message' => 'ADT record deleted successfully'], 200);
|
||||||
} else {
|
} else {
|
||||||
return $this->respond(['status' => 'error', 'message' => 'Failed to delete ADT record'], 500);
|
return $this->respond(['status' => 'error', 'message' => 'Failed to delete ADT record'], 500);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,227 +1,227 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers\Patient;
|
namespace App\Controllers\Patient;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
use App\Libraries\ValueSet;
|
use App\Libraries\ValueSet;
|
||||||
use App\Models\Patient\PatientModel;
|
use App\Models\Patient\PatientModel;
|
||||||
|
|
||||||
class PatientController extends Controller {
|
class PatientController extends Controller {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $model;
|
protected $model;
|
||||||
protected $rules;
|
protected $rules;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new PatientModel();
|
$this->model = new PatientModel();
|
||||||
$this->rules = [
|
$this->rules = [
|
||||||
'PatientID' => 'required|regex_match[/^[A-Za-z0-9]+$/]|max_length[30]',
|
'PatientID' => 'required|regex_match[/^[A-Za-z0-9]+$/]|max_length[30]',
|
||||||
'AlternatePID' => 'permit_empty|regex_match[/^[A-Za-z0-9]+$/]|max_length[30]',
|
'AlternatePID' => 'permit_empty|regex_match[/^[A-Za-z0-9]+$/]|max_length[30]',
|
||||||
'Prefix' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|max_length[10]',
|
'Prefix' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|max_length[10]',
|
||||||
'Sex' => 'required',
|
'Sex' => 'required',
|
||||||
|
|
||||||
'NameFirst' => 'required|regex_match[/^[A-Za-z\'\. ]+$/]|min_length[1]|max_length[60]',
|
'NameFirst' => 'required|regex_match[/^[A-Za-z\'\. ]+$/]|min_length[1]|max_length[60]',
|
||||||
'NameMiddle' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|min_length[1]|max_length[60]',
|
'NameMiddle' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|min_length[1]|max_length[60]',
|
||||||
'NameMaiden' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|min_length[1]|max_length[60]',
|
'NameMaiden' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|min_length[1]|max_length[60]',
|
||||||
'NameLast' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|min_length[1]|max_length[60]',
|
'NameLast' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|min_length[1]|max_length[60]',
|
||||||
|
|
||||||
'Suffix' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|max_length[10]',
|
'Suffix' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|max_length[10]',
|
||||||
'PlaceOfBirth' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|max_length[100]',
|
'PlaceOfBirth' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|max_length[100]',
|
||||||
'Citizenship' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|max_length[100]',
|
'Citizenship' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|max_length[100]',
|
||||||
|
|
||||||
'Street_1' => 'permit_empty|regex_match[/^[A-Za-z0-9\'.,\/\- ]+$/]|max_length[255]',
|
'Street_1' => 'permit_empty|regex_match[/^[A-Za-z0-9\'.,\/\- ]+$/]|max_length[255]',
|
||||||
'Street_2' => 'permit_empty|regex_match[/^[A-Za-z0-9\'.,\/\- ]+$/]|max_length[255]',
|
'Street_2' => 'permit_empty|regex_match[/^[A-Za-z0-9\'.,\/\- ]+$/]|max_length[255]',
|
||||||
'Street_3' => 'permit_empty|regex_match[/^[A-Za-z0-9\'.,\/\- ]+$/]|max_length[255]',
|
'Street_3' => 'permit_empty|regex_match[/^[A-Za-z0-9\'.,\/\- ]+$/]|max_length[255]',
|
||||||
|
|
||||||
'EmailAddress1' => 'permit_empty|valid_email|max_length[100]',
|
'EmailAddress1' => 'permit_empty|valid_email|max_length[100]',
|
||||||
'EmailAddress2' => 'permit_empty|valid_email|max_length[100]',
|
'EmailAddress2' => 'permit_empty|valid_email|max_length[100]',
|
||||||
|
|
||||||
'Birthdate' => 'required',
|
'Birthdate' => 'required',
|
||||||
'PatIdt.IdentifierType' => 'permit_empty',
|
'PatIdt.IdentifierType' => 'permit_empty',
|
||||||
'PatIdt.Identifier' => 'permit_empty|max_length[255]',
|
'PatIdt.Identifier' => 'permit_empty|max_length[255]',
|
||||||
|
|
||||||
'ZIP' => 'permit_empty|is_natural|max_length[10]',
|
'ZIP' => 'permit_empty|is_natural|max_length[10]',
|
||||||
'Phone' => 'permit_empty|regex_match[/^\\+?[0-9]{8,15}$/]',
|
'Phone' => 'permit_empty|regex_match[/^\\+?[0-9]{8,15}$/]',
|
||||||
'MobilePhone' => 'permit_empty|regex_match[/^\\+?[0-9]{8,15}$/]'
|
'MobilePhone' => 'permit_empty|regex_match[/^\\+?[0-9]{8,15}$/]'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$filters = [
|
$filters = [
|
||||||
'InternalPID' => $this->request->getVar('InternalPID'),
|
'InternalPID' => $this->request->getVar('InternalPID'),
|
||||||
'PatientID' => $this->request->getVar('PatientID'),
|
'PatientID' => $this->request->getVar('PatientID'),
|
||||||
'Name' => $this->request->getVar('Name'),
|
'Name' => $this->request->getVar('Name'),
|
||||||
'Birthdate' => $this->request->getVar('Birthdate'),
|
'Birthdate' => $this->request->getVar('Birthdate'),
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$rows = $this->model->getPatients($filters);
|
$rows = $this->model->getPatients($filters);
|
||||||
|
|
||||||
$rows = ValueSet::transformLabels($rows, [
|
$rows = ValueSet::transformLabels($rows, [
|
||||||
'Sex' => 'sex',
|
'Sex' => 'sex',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Exception : '.$e->getMessage());
|
return $this->failServerError('Exception : '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($InternalPID = null) {
|
public function show($InternalPID = null) {
|
||||||
try {
|
try {
|
||||||
$row = $this->model->getPatient($InternalPID);
|
$row = $this->model->getPatient($InternalPID);
|
||||||
if (empty($row)) { return $this->respond([ 'status' => 'success', 'message' => "data not found.", 'data' => null ], 200); }
|
if (empty($row)) { return $this->respond([ 'status' => 'success', 'message' => "data not found.", 'data' => null ], 200); }
|
||||||
|
|
||||||
$row = ValueSet::transformLabels([$row], [
|
$row = ValueSet::transformLabels([$row], [
|
||||||
'Sex' => 'sex',
|
'Sex' => 'sex',
|
||||||
])[0];
|
])[0];
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "data fetched successfully", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "data fetched successfully", 'data' => $row ], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
|
|
||||||
// Khusus untuk Override PATIDT
|
// Khusus untuk Override PATIDT
|
||||||
$type = $input['PatIdt']['IdentifierType'] ?? null;
|
$type = $input['PatIdt']['IdentifierType'] ?? null;
|
||||||
$identifierRulesMap = [
|
$identifierRulesMap = [
|
||||||
'KTP' => 'required|regex_match[/^[0-9]{16}$/]', // 16 pas digit numeric
|
'KTP' => 'required|regex_match[/^[0-9]{16}$/]', // 16 pas digit numeric
|
||||||
'PASS' => 'required|regex_match[/^[A-Za-z0-9]{1,9}$/]', // alphanumeric max 9
|
'PASS' => 'required|regex_match[/^[A-Za-z0-9]{1,9}$/]', // alphanumeric max 9
|
||||||
'SSN' => 'required|regex_match[/^[0-9]{9}$/]', // numeric, pas 9 digit
|
'SSN' => 'required|regex_match[/^[0-9]{9}$/]', // numeric, pas 9 digit
|
||||||
'SIM' => 'required|regex_match[/^[0-9]{19,20}$/]', // numeric 19–20 digit
|
'SIM' => 'required|regex_match[/^[0-9]{19,20}$/]', // numeric 19–20 digit
|
||||||
'KTAS' => 'required|regex_match[/^[0-9]{11}$/]', // numeric, pas 11 digit
|
'KTAS' => 'required|regex_match[/^[0-9]{11}$/]', // numeric, pas 11 digit
|
||||||
];
|
];
|
||||||
if ($type === null || $type === '' || !is_string($type)) {
|
if ($type === null || $type === '' || !is_string($type)) {
|
||||||
$identifierRule = 'permit_empty|max_length[255]';
|
$identifierRule = 'permit_empty|max_length[255]';
|
||||||
$this->rules['PatIdt.IdentifierType'] = 'permit_empty';
|
$this->rules['PatIdt.IdentifierType'] = 'permit_empty';
|
||||||
$this->rules['PatIdt.Identifier'] = $identifierRule;
|
$this->rules['PatIdt.Identifier'] = $identifierRule;
|
||||||
} else {
|
} else {
|
||||||
$identifierRule = $identifierRulesMap[$type] ?? 'permit_empty|max_length[255]';
|
$identifierRule = $identifierRulesMap[$type] ?? 'permit_empty|max_length[255]';
|
||||||
$this->rules['PatIdt.IdentifierType'] = 'required';
|
$this->rules['PatIdt.IdentifierType'] = 'required';
|
||||||
$this->rules['PatIdt.Identifier'] = $identifierRule;
|
$this->rules['PatIdt.Identifier'] = $identifierRule;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$InternalPID = $this->model->createPatient($input);
|
$InternalPID = $this->model->createPatient($input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => "data $InternalPID created successfully" ]);
|
return $this->respondCreated([ 'status' => 'success', 'message' => "data $InternalPID created successfully" ]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
|
|
||||||
// Khusus untuk Override PATIDT
|
// Khusus untuk Override PATIDT
|
||||||
$type = $input['PatIdt']['IdentifierType'] ?? null;
|
$type = $input['PatIdt']['IdentifierType'] ?? null;
|
||||||
$identifierRulesMap = [
|
$identifierRulesMap = [
|
||||||
'KTP' => 'required|regex_match[/^[0-9]{16}$/]',
|
'KTP' => 'required|regex_match[/^[0-9]{16}$/]',
|
||||||
'PASS' => 'required|regex_match[/^[A-Za-z0-9]{6,9}$/]',
|
'PASS' => 'required|regex_match[/^[A-Za-z0-9]{6,9}$/]',
|
||||||
'SSN' => 'required|regex_match[/^[0-9]{3}-[0-9]{2}-[0-9]{4}$/]',
|
'SSN' => 'required|regex_match[/^[0-9]{3}-[0-9]{2}-[0-9]{4}$/]',
|
||||||
'SIM' => 'required|regex_match[/^[A-Za-z0-9]{12,14}$/]',
|
'SIM' => 'required|regex_match[/^[A-Za-z0-9]{12,14}$/]',
|
||||||
'KTAS' => 'required|regex_match[/^[A-Za-z0-9]{12,15}$/]',
|
'KTAS' => 'required|regex_match[/^[A-Za-z0-9]{12,15}$/]',
|
||||||
];
|
];
|
||||||
if ($type === null || $type === '' || !is_string($type)) {
|
if ($type === null || $type === '' || !is_string($type)) {
|
||||||
$identifierRule = 'permit_empty|max_length[255]';
|
$identifierRule = 'permit_empty|max_length[255]';
|
||||||
$this->rules['PatIdt.IdentifierType'] = 'permit_empty';
|
$this->rules['PatIdt.IdentifierType'] = 'permit_empty';
|
||||||
$this->rules['PatIdt.Identifier'] = $identifierRule;
|
$this->rules['PatIdt.Identifier'] = $identifierRule;
|
||||||
} else {
|
} else {
|
||||||
$identifierRule = $identifierRulesMap[$type] ?? 'permit_empty|max_length[255]';
|
$identifierRule = $identifierRulesMap[$type] ?? 'permit_empty|max_length[255]';
|
||||||
$this->rules['PatIdt.IdentifierType'] = 'required';
|
$this->rules['PatIdt.IdentifierType'] = 'required';
|
||||||
$this->rules['PatIdt.Identifier'] = $identifierRule;
|
$this->rules['PatIdt.Identifier'] = $identifierRule;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$InternalPID = $this->model->updatePatient($input);
|
$InternalPID = $this->model->updatePatient($input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => "data $InternalPID update successfully" ]);
|
return $this->respondCreated([ 'status' => 'success', 'message' => "data $InternalPID update successfully" ]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
try {
|
try {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$InternalPID = $input["InternalPID"];
|
$InternalPID = $input["InternalPID"];
|
||||||
|
|
||||||
// Mencegah Inputan 0, [], null, sql injection
|
// Mencegah Inputan 0, [], null, sql injection
|
||||||
if (empty($InternalPID) || !ctype_digit((string) $InternalPID)) {
|
if (empty($InternalPID) || !ctype_digit((string) $InternalPID)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => "Patient ID must be a valid integer."
|
'message' => "Patient ID must be a valid integer."
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$patient = $this->db->table('patient')->where('InternalPID', $InternalPID)->get()->getRow();
|
$patient = $this->db->table('patient')->where('InternalPID', $InternalPID)->get()->getRow();
|
||||||
|
|
||||||
if (!$patient) {
|
if (!$patient) {
|
||||||
return $this->failNotFound("Patient ID with {$InternalPID} not found.");
|
return $this->failNotFound("Patient ID with {$InternalPID} not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->table('patient')->where('InternalPID', $InternalPID)->update(['DelDate' => date('Y-m-d H:i:s')]);
|
$this->db->table('patient')->where('InternalPID', $InternalPID)->update(['DelDate' => date('Y-m-d H:i:s')]);
|
||||||
|
|
||||||
return $this->respondDeleted([
|
return $this->respondDeleted([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => "Patient ID with {$InternalPID} deleted successfully."
|
'message' => "Patient ID with {$InternalPID} deleted successfully."
|
||||||
]);
|
]);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError("Internal server error: " . $e->getMessage());
|
return $this->failServerError("Internal server error: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function patientCheck() {
|
public function patientCheck() {
|
||||||
try {
|
try {
|
||||||
$PatientID = $this->request->getVar('PatientID');
|
$PatientID = $this->request->getVar('PatientID');
|
||||||
$EmailAddress1 = $this->request->getVar('EmailAddress1');
|
$EmailAddress1 = $this->request->getVar('EmailAddress1');
|
||||||
|
|
||||||
$tableName = '';
|
$tableName = '';
|
||||||
$searchName = '';
|
$searchName = '';
|
||||||
|
|
||||||
if (!empty($PatientID)){
|
if (!empty($PatientID)){
|
||||||
$tableName = 'PatientID';
|
$tableName = 'PatientID';
|
||||||
$searchName = $PatientID;
|
$searchName = $PatientID;
|
||||||
} elseif (!empty($EmailAddress1)){
|
} elseif (!empty($EmailAddress1)){
|
||||||
$tableName = 'EmailAddress1';
|
$tableName = 'EmailAddress1';
|
||||||
$searchName = $EmailAddress1;
|
$searchName = $EmailAddress1;
|
||||||
} else {
|
} else {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => 'PatientID or EmailAddress1 parameter is required.',
|
'message' => 'PatientID or EmailAddress1 parameter is required.',
|
||||||
'data' => null
|
'data' => null
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$patient = $this->db->table('patient')
|
$patient = $this->db->table('patient')
|
||||||
->where($tableName, $searchName)
|
->where($tableName, $searchName)
|
||||||
->get()
|
->get()
|
||||||
->getRowArray();
|
->getRowArray();
|
||||||
|
|
||||||
if (!$patient) {
|
if (!$patient) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => "$tableName not found.",
|
'message' => "$tableName not found.",
|
||||||
'data' => true,
|
'data' => true,
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => "$tableName already exists.",
|
'message' => "$tableName already exists.",
|
||||||
'data' => false,
|
'data' => false,
|
||||||
], 200);
|
], 200);
|
||||||
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// Error Server Mengembalikan 500
|
// Error Server Mengembalikan 500
|
||||||
return $this->failServerError('Something went wrong.'.$e->getMessage());
|
return $this->failServerError('Something went wrong.'.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,75 +1,75 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
use App\Models\PatResultModel;
|
use App\Models\PatResultModel;
|
||||||
use App\Models\OrderTest\OrderTestModel;
|
use App\Models\OrderTest\OrderTestModel;
|
||||||
use App\Models\Patient\PatientModel;
|
use App\Models\Patient\PatientModel;
|
||||||
|
|
||||||
class ReportController extends Controller {
|
class ReportController extends Controller {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $resultModel;
|
protected $resultModel;
|
||||||
protected $orderModel;
|
protected $orderModel;
|
||||||
protected $patientModel;
|
protected $patientModel;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->resultModel = new PatResultModel();
|
$this->resultModel = new PatResultModel();
|
||||||
$this->orderModel = new OrderTestModel();
|
$this->orderModel = new OrderTestModel();
|
||||||
$this->patientModel = new PatientModel();
|
$this->patientModel = new PatientModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate HTML lab report for an order
|
* Generate HTML lab report for an order
|
||||||
* GET /api/reports/{orderID}
|
* GET /api/reports/{orderID}
|
||||||
*/
|
*/
|
||||||
public function view($orderID) {
|
public function view($orderID) {
|
||||||
try {
|
try {
|
||||||
// Get order details
|
// Get order details
|
||||||
$order = $this->orderModel->find((int)$orderID);
|
$order = $this->orderModel->find((int)$orderID);
|
||||||
|
|
||||||
if (!$order) {
|
if (!$order) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Order not found',
|
'message' => 'Order not found',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get patient details
|
// Get patient details
|
||||||
$patient = $this->patientModel->find($order['InternalPID']);
|
$patient = $this->patientModel->find($order['InternalPID']);
|
||||||
|
|
||||||
if (!$patient) {
|
if (!$patient) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Patient not found',
|
'message' => 'Patient not found',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get results for this order
|
// Get results for this order
|
||||||
$results = $this->resultModel->getByOrder((int)$orderID);
|
$results = $this->resultModel->getByOrder((int)$orderID);
|
||||||
|
|
||||||
// Prepare data for the view
|
// Prepare data for the view
|
||||||
$data = [
|
$data = [
|
||||||
'patient' => $patient,
|
'patient' => $patient,
|
||||||
'order' => $order,
|
'order' => $order,
|
||||||
'results' => $results,
|
'results' => $results,
|
||||||
'generatedAt' => date('Y-m-d H:i:s')
|
'generatedAt' => date('Y-m-d H:i:s')
|
||||||
];
|
];
|
||||||
|
|
||||||
// Return HTML view
|
// Return HTML view
|
||||||
return view('reports/lab_report', $data);
|
return view('reports/lab_report', $data);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
log_message('error', 'ReportController::view error: ' . $e->getMessage());
|
log_message('error', 'ReportController::view error: ' . $e->getMessage());
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Failed to generate report',
|
'message' => 'Failed to generate report',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,144 +1,144 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers\Result;
|
namespace App\Controllers\Result;
|
||||||
|
|
||||||
use App\Models\ValueSet\ValueSetModel;
|
use App\Models\ValueSet\ValueSetModel;
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
|
|
||||||
class ResultValueSetController extends \CodeIgniter\Controller
|
class ResultValueSetController extends \CodeIgniter\Controller
|
||||||
{
|
{
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $dbModel;
|
protected $dbModel;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->dbModel = new ValueSetModel();
|
$this->dbModel = new ValueSetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$search = $this->request->getGet('search') ?? $this->request->getGet('param') ?? null;
|
$search = $this->request->getGet('search') ?? $this->request->getGet('param') ?? null;
|
||||||
$VSetID = $this->request->getGet('VSetID') ?? null;
|
$VSetID = $this->request->getGet('VSetID') ?? null;
|
||||||
|
|
||||||
$rows = $this->dbModel->getValueSets($search, $VSetID);
|
$rows = $this->dbModel->getValueSets($search, $VSetID);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'data' => $rows
|
'data' => $rows
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id = null)
|
public function show($id = null)
|
||||||
{
|
{
|
||||||
$row = $this->dbModel->getValueSet($id);
|
$row = $this->dbModel->getValueSet($id);
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
return $this->failNotFound("ValueSet item not found: $id");
|
return $this->failNotFound("ValueSet item not found: $id");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'data' => $row
|
'data' => $row
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$input) {
|
if (!$input) {
|
||||||
return $this->failValidationErrors(['Invalid JSON input']);
|
return $this->failValidationErrors(['Invalid JSON input']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'SiteID' => $input['SiteID'] ?? 1,
|
'SiteID' => $input['SiteID'] ?? 1,
|
||||||
'VSetID' => $input['VSetID'] ?? null,
|
'VSetID' => $input['VSetID'] ?? null,
|
||||||
'VOrder' => $input['VOrder'] ?? 0,
|
'VOrder' => $input['VOrder'] ?? 0,
|
||||||
'VValue' => $input['VValue'] ?? '',
|
'VValue' => $input['VValue'] ?? '',
|
||||||
'VDesc' => $input['VDesc'] ?? '',
|
'VDesc' => $input['VDesc'] ?? '',
|
||||||
'VCategory' => $input['VCategory'] ?? null
|
'VCategory' => $input['VCategory'] ?? null
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($data['VSetID'] === null) {
|
if ($data['VSetID'] === null) {
|
||||||
return $this->failValidationErrors(['VSetID is required']);
|
return $this->failValidationErrors(['VSetID is required']);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$id = $this->dbModel->insert($data, true);
|
$id = $this->dbModel->insert($data, true);
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
return $this->failValidationErrors($this->dbModel->errors());
|
return $this->failValidationErrors($this->dbModel->errors());
|
||||||
}
|
}
|
||||||
|
|
||||||
$newRow = $this->dbModel->getValueSet($id);
|
$newRow = $this->dbModel->getValueSet($id);
|
||||||
return $this->respondCreated([
|
return $this->respondCreated([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'ValueSet item created',
|
'message' => 'ValueSet item created',
|
||||||
'data' => $newRow
|
'data' => $newRow
|
||||||
]);
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Failed to create: ' . $e->getMessage());
|
return $this->failServerError('Failed to create: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($id = null)
|
public function update($id = null)
|
||||||
{
|
{
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$input) {
|
if (!$input) {
|
||||||
return $this->failValidationErrors(['Invalid JSON input']);
|
return $this->failValidationErrors(['Invalid JSON input']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$existing = $this->dbModel->getValueSet($id);
|
$existing = $this->dbModel->getValueSet($id);
|
||||||
if (!$existing) {
|
if (!$existing) {
|
||||||
return $this->failNotFound("ValueSet item not found: $id");
|
return $this->failNotFound("ValueSet item not found: $id");
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
if (isset($input['VSetID'])) $data['VSetID'] = $input['VSetID'];
|
if (isset($input['VSetID'])) $data['VSetID'] = $input['VSetID'];
|
||||||
if (isset($input['VOrder'])) $data['VOrder'] = $input['VOrder'];
|
if (isset($input['VOrder'])) $data['VOrder'] = $input['VOrder'];
|
||||||
if (isset($input['VValue'])) $data['VValue'] = $input['VValue'];
|
if (isset($input['VValue'])) $data['VValue'] = $input['VValue'];
|
||||||
if (isset($input['VDesc'])) $data['VDesc'] = $input['VDesc'];
|
if (isset($input['VDesc'])) $data['VDesc'] = $input['VDesc'];
|
||||||
if (isset($input['SiteID'])) $data['SiteID'] = $input['SiteID'];
|
if (isset($input['SiteID'])) $data['SiteID'] = $input['SiteID'];
|
||||||
if (isset($input['VCategory'])) $data['VCategory'] = $input['VCategory'];
|
if (isset($input['VCategory'])) $data['VCategory'] = $input['VCategory'];
|
||||||
|
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'No changes to update',
|
'message' => 'No changes to update',
|
||||||
'data' => $existing
|
'data' => $existing
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$updated = $this->dbModel->update($id, $data);
|
$updated = $this->dbModel->update($id, $data);
|
||||||
if (!$updated) {
|
if (!$updated) {
|
||||||
return $this->failValidationErrors($this->dbModel->errors());
|
return $this->failValidationErrors($this->dbModel->errors());
|
||||||
}
|
}
|
||||||
|
|
||||||
$newRow = $this->dbModel->getValueSet($id);
|
$newRow = $this->dbModel->getValueSet($id);
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'ValueSet item updated',
|
'message' => 'ValueSet item updated',
|
||||||
'data' => $newRow
|
'data' => $newRow
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Failed to update: ' . $e->getMessage());
|
return $this->failServerError('Failed to update: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id = null)
|
public function delete($id = null)
|
||||||
{
|
{
|
||||||
$existing = $this->dbModel->getValueSet($id);
|
$existing = $this->dbModel->getValueSet($id);
|
||||||
if (!$existing) {
|
if (!$existing) {
|
||||||
return $this->failNotFound("ValueSet item not found: $id");
|
return $this->failNotFound("ValueSet item not found: $id");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->dbModel->delete($id);
|
$this->dbModel->delete($id);
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'ValueSet item deleted'
|
'message' => 'ValueSet item deleted'
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Failed to delete: ' . $e->getMessage());
|
return $this->failServerError('Failed to delete: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,179 +1,179 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
use App\Models\PatResultModel;
|
use App\Models\PatResultModel;
|
||||||
|
|
||||||
class ResultController extends Controller {
|
class ResultController extends Controller {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->model = new PatResultModel();
|
$this->model = new PatResultModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List results with optional filters
|
* List results with optional filters
|
||||||
* GET /api/results
|
* GET /api/results
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index() {
|
||||||
try {
|
try {
|
||||||
$orderID = $this->request->getGet('order_id');
|
$orderID = $this->request->getGet('order_id');
|
||||||
$patientID = $this->request->getGet('patient_id');
|
$patientID = $this->request->getGet('patient_id');
|
||||||
|
|
||||||
if ($orderID) {
|
if ($orderID) {
|
||||||
$results = $this->model->getByOrder((int)$orderID);
|
$results = $this->model->getByOrder((int)$orderID);
|
||||||
} elseif ($patientID) {
|
} elseif ($patientID) {
|
||||||
$results = $this->model->getByPatient((int)$patientID);
|
$results = $this->model->getByPatient((int)$patientID);
|
||||||
} else {
|
} else {
|
||||||
// Get all results with pagination
|
// Get all results with pagination
|
||||||
$page = (int)($this->request->getGet('page') ?? 1);
|
$page = (int)($this->request->getGet('page') ?? 1);
|
||||||
$perPage = (int)($this->request->getGet('per_page') ?? 20);
|
$perPage = (int)($this->request->getGet('per_page') ?? 20);
|
||||||
|
|
||||||
$results = $this->model
|
$results = $this->model
|
||||||
->where('DelDate', null)
|
->where('DelDate', null)
|
||||||
->orderBy('ResultID', 'DESC')
|
->orderBy('ResultID', 'DESC')
|
||||||
->paginate($perPage, 'default', $page);
|
->paginate($perPage, 'default', $page);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Results retrieved successfully',
|
'message' => 'Results retrieved successfully',
|
||||||
'data' => $results
|
'data' => $results
|
||||||
], 200);
|
], 200);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
log_message('error', 'ResultController::index error: ' . $e->getMessage());
|
log_message('error', 'ResultController::index error: ' . $e->getMessage());
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Failed to retrieve results',
|
'message' => 'Failed to retrieve results',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get single result
|
* Get single result
|
||||||
* GET /api/results/{id}
|
* GET /api/results/{id}
|
||||||
*/
|
*/
|
||||||
public function show($id) {
|
public function show($id) {
|
||||||
try {
|
try {
|
||||||
$result = $this->model->getWithRelations((int)$id);
|
$result = $this->model->getWithRelations((int)$id);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Result not found',
|
'message' => 'Result not found',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Result retrieved successfully',
|
'message' => 'Result retrieved successfully',
|
||||||
'data' => $result
|
'data' => $result
|
||||||
], 200);
|
], 200);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
log_message('error', 'ResultController::show error: ' . $e->getMessage());
|
log_message('error', 'ResultController::show error: ' . $e->getMessage());
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Failed to retrieve result',
|
'message' => 'Failed to retrieve result',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update result with validation
|
* Update result with validation
|
||||||
* PATCH /api/results/{id}
|
* PATCH /api/results/{id}
|
||||||
*/
|
*/
|
||||||
public function update($id) {
|
public function update($id) {
|
||||||
try {
|
try {
|
||||||
$data = $this->request->getJSON(true);
|
$data = $this->request->getJSON(true);
|
||||||
|
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'No data provided',
|
'message' => 'No data provided',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->model->updateWithValidation((int)$id, $data);
|
$result = $this->model->updateWithValidation((int)$id, $data);
|
||||||
|
|
||||||
if (!$result['success']) {
|
if (!$result['success']) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => $result['message'],
|
'message' => $result['message'],
|
||||||
'data' => []
|
'data' => []
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get updated result with relations
|
// Get updated result with relations
|
||||||
$updatedResult = $this->model->getWithRelations((int)$id);
|
$updatedResult = $this->model->getWithRelations((int)$id);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => $result['message'],
|
'message' => $result['message'],
|
||||||
'data' => [
|
'data' => [
|
||||||
'result' => $updatedResult,
|
'result' => $updatedResult,
|
||||||
'flag' => $result['flag']
|
'flag' => $result['flag']
|
||||||
]
|
]
|
||||||
], 200);
|
], 200);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
log_message('error', 'ResultController::update error: ' . $e->getMessage());
|
log_message('error', 'ResultController::update error: ' . $e->getMessage());
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Failed to update result',
|
'message' => 'Failed to update result',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Soft delete result
|
* Soft delete result
|
||||||
* DELETE /api/results/{id}
|
* DELETE /api/results/{id}
|
||||||
*/
|
*/
|
||||||
public function delete($id) {
|
public function delete($id) {
|
||||||
try {
|
try {
|
||||||
$result = $this->model->find((int)$id);
|
$result = $this->model->find((int)$id);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Result not found',
|
'message' => 'Result not found',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$deleted = $this->model->softDelete((int)$id);
|
$deleted = $this->model->softDelete((int)$id);
|
||||||
|
|
||||||
if (!$deleted) {
|
if (!$deleted) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Failed to delete result',
|
'message' => 'Failed to delete result',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Result deleted successfully',
|
'message' => 'Result deleted successfully',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 200);
|
], 200);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
log_message('error', 'ResultController::delete error: ' . $e->getMessage());
|
log_message('error', 'ResultController::delete error: ' . $e->getMessage());
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Failed to delete result',
|
'message' => 'Failed to delete result',
|
||||||
'data' => []
|
'data' => []
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,227 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Controllers\Rule;
|
|
||||||
|
|
||||||
use App\Controllers\BaseController;
|
|
||||||
use App\Models\Rule\RuleActionModel;
|
|
||||||
use App\Models\Rule\RuleDefModel;
|
|
||||||
use App\Models\Test\TestDefSiteModel;
|
|
||||||
use App\Traits\ResponseTrait;
|
|
||||||
|
|
||||||
class RuleActionController extends BaseController
|
|
||||||
{
|
|
||||||
use ResponseTrait;
|
|
||||||
|
|
||||||
protected RuleDefModel $ruleDefModel;
|
|
||||||
protected RuleActionModel $ruleActionModel;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->ruleDefModel = new RuleDefModel();
|
|
||||||
$this->ruleActionModel = new RuleActionModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index($ruleID = null)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
if (!$ruleID || !is_numeric($ruleID)) {
|
|
||||||
return $this->failValidationErrors('RuleID is required');
|
|
||||||
}
|
|
||||||
|
|
||||||
$rule = $this->ruleDefModel->where('EndDate', null)->find((int) $ruleID);
|
|
||||||
if (!$rule) {
|
|
||||||
return $this->respond([
|
|
||||||
'status' => 'failed',
|
|
||||||
'message' => 'Rule not found',
|
|
||||||
'data' => [],
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$rows = $this->ruleActionModel
|
|
||||||
->where('RuleID', (int) $ruleID)
|
|
||||||
->where('EndDate', null)
|
|
||||||
->orderBy('RuleActionID', 'ASC')
|
|
||||||
->findAll();
|
|
||||||
|
|
||||||
return $this->respond([
|
|
||||||
'status' => 'success',
|
|
||||||
'message' => 'fetch success',
|
|
||||||
'data' => $rows,
|
|
||||||
], 200);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
log_message('error', 'RuleActionController::index error: ' . $e->getMessage());
|
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function create($ruleID = null)
|
|
||||||
{
|
|
||||||
$input = $this->request->getJSON(true) ?? [];
|
|
||||||
|
|
||||||
if (!$ruleID || !is_numeric($ruleID)) {
|
|
||||||
$ruleID = $input['RuleID'] ?? null;
|
|
||||||
}
|
|
||||||
if (!$ruleID || !is_numeric($ruleID)) {
|
|
||||||
return $this->failValidationErrors('RuleID is required');
|
|
||||||
}
|
|
||||||
|
|
||||||
$rule = $this->ruleDefModel->where('EndDate', null)->find((int) $ruleID);
|
|
||||||
if (!$rule) {
|
|
||||||
return $this->respond([
|
|
||||||
'status' => 'failed',
|
|
||||||
'message' => 'Rule not found',
|
|
||||||
'data' => [],
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$validation = service('validation');
|
|
||||||
$validation->setRules([
|
|
||||||
'ActionType' => 'required|max_length[50]',
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (!$validation->run($input)) {
|
|
||||||
return $this->failValidationErrors($validation->getErrors());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Light validation for SET_RESULT params
|
|
||||||
$actionType = strtoupper((string) $input['ActionType']);
|
|
||||||
$params = $input['ActionParams'] ?? null;
|
|
||||||
if ($actionType === 'SET_RESULT') {
|
|
||||||
$decoded = is_array($params) ? $params : (is_string($params) ? json_decode($params, true) : null);
|
|
||||||
if (!is_array($decoded)) {
|
|
||||||
return $this->failValidationErrors(['ActionParams' => 'ActionParams must be JSON object for SET_RESULT']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($decoded['testSiteID']) && empty($decoded['testSiteCode'])) {
|
|
||||||
return $this->failValidationErrors(['ActionParams' => 'SET_RESULT requires testSiteID or testSiteCode']);
|
|
||||||
}
|
|
||||||
if (!array_key_exists('value', $decoded) && !array_key_exists('valueExpr', $decoded)) {
|
|
||||||
return $this->failValidationErrors(['ActionParams' => 'SET_RESULT requires value or valueExpr']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($decoded['testSiteID']) && is_numeric($decoded['testSiteID'])) {
|
|
||||||
$testDef = new TestDefSiteModel();
|
|
||||||
$exists = $testDef->where('EndDate', null)->find((int) $decoded['testSiteID']);
|
|
||||||
if (!$exists) {
|
|
||||||
return $this->failValidationErrors(['ActionParams' => 'testSiteID not found']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (is_array($params)) {
|
|
||||||
$params = json_encode($params);
|
|
||||||
}
|
|
||||||
|
|
||||||
$id = $this->ruleActionModel->insert([
|
|
||||||
'RuleID' => (int) $ruleID,
|
|
||||||
'ActionType' => $input['ActionType'],
|
|
||||||
'ActionParams' => is_string($params) ? $params : null,
|
|
||||||
], true);
|
|
||||||
|
|
||||||
return $this->respondCreated([
|
|
||||||
'status' => 'success',
|
|
||||||
'message' => 'Action created successfully',
|
|
||||||
'data' => ['RuleActionID' => $id],
|
|
||||||
], 201);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
log_message('error', 'RuleActionController::create error: ' . $e->getMessage());
|
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update($ruleID = null, $actionID = null)
|
|
||||||
{
|
|
||||||
$input = $this->request->getJSON(true) ?? [];
|
|
||||||
|
|
||||||
if (!$ruleID || !is_numeric($ruleID)) {
|
|
||||||
$ruleID = $input['RuleID'] ?? null;
|
|
||||||
}
|
|
||||||
if (!$actionID || !is_numeric($actionID)) {
|
|
||||||
$actionID = $input['RuleActionID'] ?? null;
|
|
||||||
}
|
|
||||||
if (!$ruleID || !is_numeric($ruleID) || !$actionID || !is_numeric($actionID)) {
|
|
||||||
return $this->failValidationErrors('RuleID and RuleActionID are required');
|
|
||||||
}
|
|
||||||
|
|
||||||
$rule = $this->ruleDefModel->where('EndDate', null)->find((int) $ruleID);
|
|
||||||
if (!$rule) {
|
|
||||||
return $this->respond([
|
|
||||||
'status' => 'failed',
|
|
||||||
'message' => 'Rule not found',
|
|
||||||
'data' => [],
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$existing = $this->ruleActionModel->where('EndDate', null)->find((int) $actionID);
|
|
||||||
if (!$existing || (int) ($existing['RuleID'] ?? 0) !== (int) $ruleID) {
|
|
||||||
return $this->respond([
|
|
||||||
'status' => 'failed',
|
|
||||||
'message' => 'Action not found',
|
|
||||||
'data' => [],
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$validation = service('validation');
|
|
||||||
$validation->setRules([
|
|
||||||
'ActionType' => 'permit_empty|max_length[50]',
|
|
||||||
]);
|
|
||||||
if (!$validation->run($input)) {
|
|
||||||
return $this->failValidationErrors($validation->getErrors());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$updateData = [];
|
|
||||||
foreach (['ActionType', 'ActionParams'] as $field) {
|
|
||||||
if (array_key_exists($field, $input)) {
|
|
||||||
$updateData[$field] = $input[$field];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isset($updateData['ActionParams']) && is_array($updateData['ActionParams'])) {
|
|
||||||
$updateData['ActionParams'] = json_encode($updateData['ActionParams']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($updateData)) {
|
|
||||||
$this->ruleActionModel->update((int) $actionID, $updateData);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->respond([
|
|
||||||
'status' => 'success',
|
|
||||||
'message' => 'Action updated successfully',
|
|
||||||
'data' => ['RuleActionID' => (int) $actionID],
|
|
||||||
], 200);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
log_message('error', 'RuleActionController::update error: ' . $e->getMessage());
|
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete($ruleID = null, $actionID = null)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
if (!$ruleID || !is_numeric($ruleID) || !$actionID || !is_numeric($actionID)) {
|
|
||||||
return $this->failValidationErrors('RuleID and RuleActionID are required');
|
|
||||||
}
|
|
||||||
|
|
||||||
$existing = $this->ruleActionModel->where('EndDate', null)->find((int) $actionID);
|
|
||||||
if (!$existing || (int) ($existing['RuleID'] ?? 0) !== (int) $ruleID) {
|
|
||||||
return $this->respond([
|
|
||||||
'status' => 'failed',
|
|
||||||
'message' => 'Action not found',
|
|
||||||
'data' => [],
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->ruleActionModel->delete((int) $actionID);
|
|
||||||
|
|
||||||
return $this->respondDeleted([
|
|
||||||
'status' => 'success',
|
|
||||||
'message' => 'Action deleted successfully',
|
|
||||||
'data' => ['RuleActionID' => (int) $actionID],
|
|
||||||
]);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
log_message('error', 'RuleActionController::delete error: ' . $e->getMessage());
|
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,146 +1,136 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers\Rule;
|
namespace App\Controllers\Rule;
|
||||||
|
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Models\Rule\RuleActionModel;
|
|
||||||
use App\Models\Rule\RuleDefModel;
|
use App\Models\Rule\RuleDefModel;
|
||||||
use App\Models\Test\TestDefSiteModel;
|
use App\Models\Test\TestDefSiteModel;
|
||||||
use App\Services\RuleExpressionService;
|
use App\Services\RuleExpressionService;
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
|
|
||||||
class RuleController extends BaseController
|
class RuleController extends BaseController
|
||||||
{
|
{
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected RuleDefModel $ruleDefModel;
|
protected RuleDefModel $ruleDefModel;
|
||||||
protected RuleActionModel $ruleActionModel;
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->ruleDefModel = new RuleDefModel();
|
$this->ruleDefModel = new RuleDefModel();
|
||||||
$this->ruleActionModel = new RuleActionModel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$eventCode = $this->request->getGet('EventCode');
|
$eventCode = $this->request->getGet('EventCode');
|
||||||
$testSiteID = $this->request->getGet('TestSiteID');
|
$testSiteID = $this->request->getGet('TestSiteID');
|
||||||
$search = $this->request->getGet('search');
|
$search = $this->request->getGet('search');
|
||||||
|
|
||||||
$builder = $this->ruleDefModel->where('ruledef.EndDate', null);
|
$builder = $this->ruleDefModel->where('ruledef.EndDate', null);
|
||||||
|
|
||||||
if ($eventCode !== null && $eventCode !== '') {
|
if ($eventCode !== null && $eventCode !== '') {
|
||||||
$builder->where('ruledef.EventCode', $eventCode);
|
$builder->where('ruledef.EventCode', $eventCode);
|
||||||
}
|
}
|
||||||
if ($search !== null && $search !== '') {
|
if ($search !== null && $search !== '') {
|
||||||
$builder->like('ruledef.RuleName', $search);
|
$builder->like('ruledef.RuleName', $search);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by TestSiteID - join with mapping table
|
// Filter by TestSiteID - join with mapping table
|
||||||
if ($testSiteID !== null && $testSiteID !== '' && is_numeric($testSiteID)) {
|
if ($testSiteID !== null && $testSiteID !== '' && is_numeric($testSiteID)) {
|
||||||
$builder->join('testrule', 'testrule.RuleID = ruledef.RuleID', 'inner');
|
$builder->join('testrule', 'testrule.RuleID = ruledef.RuleID', 'inner');
|
||||||
$builder->where('testrule.TestSiteID', (int) $testSiteID);
|
$builder->where('testrule.TestSiteID', (int) $testSiteID);
|
||||||
$builder->where('testrule.EndDate IS NULL');
|
$builder->where('testrule.EndDate IS NULL');
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = $builder
|
$rows = $builder
|
||||||
->orderBy('ruledef.RuleID', 'ASC')
|
->orderBy('ruledef.RuleID', 'ASC')
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'fetch success',
|
'message' => 'fetch success',
|
||||||
'data' => $rows,
|
'data' => $rows,
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
log_message('error', 'RuleController::index error: ' . $e->getMessage());
|
log_message('error', 'RuleController::index error: ' . $e->getMessage());
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Failed to fetch rules',
|
'message' => 'Failed to fetch rules',
|
||||||
'data' => [],
|
'data' => [],
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id = null)
|
public function show($id = null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (!$id || !is_numeric($id)) {
|
if (!$id || !is_numeric($id)) {
|
||||||
return $this->failValidationErrors('RuleID is required');
|
return $this->failValidationErrors('RuleID is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
$rule = $this->ruleDefModel->where('EndDate', null)->find((int) $id);
|
$rule = $this->ruleDefModel->where('EndDate', null)->find((int) $id);
|
||||||
if (!$rule) {
|
if (!$rule) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Rule not found',
|
'message' => 'Rule not found',
|
||||||
'data' => [],
|
'data' => [],
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$actions = $this->ruleActionModel
|
|
||||||
->where('RuleID', (int) $id)
|
|
||||||
->where('EndDate', null)
|
|
||||||
->orderBy('RuleActionID', 'ASC')
|
|
||||||
->findAll();
|
|
||||||
|
|
||||||
$linkedTests = $this->ruleDefModel->getLinkedTests((int) $id);
|
$linkedTests = $this->ruleDefModel->getLinkedTests((int) $id);
|
||||||
|
|
||||||
$rule['actions'] = $actions;
|
|
||||||
$rule['linkedTests'] = $linkedTests;
|
$rule['linkedTests'] = $linkedTests;
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'fetch success',
|
'message' => 'fetch success',
|
||||||
'data' => $rule,
|
'data' => $rule,
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
log_message('error', 'RuleController::show error: ' . $e->getMessage());
|
log_message('error', 'RuleController::show error: ' . $e->getMessage());
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Failed to fetch rule',
|
'message' => 'Failed to fetch rule',
|
||||||
'data' => [],
|
'data' => [],
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$input = $this->request->getJSON(true) ?? [];
|
$input = $this->request->getJSON(true) ?? [];
|
||||||
|
|
||||||
$validation = service('validation');
|
$validation = service('validation');
|
||||||
$validation->setRules([
|
$validation->setRules([
|
||||||
'RuleCode' => 'required|max_length[50]',
|
'RuleCode' => 'required|max_length[50]',
|
||||||
'RuleName' => 'required|max_length[100]',
|
'RuleName' => 'required|max_length[100]',
|
||||||
'EventCode' => 'required|max_length[50]',
|
'EventCode' => 'required|max_length[50]',
|
||||||
'TestSiteIDs' => 'required',
|
'TestSiteIDs' => 'required',
|
||||||
'TestSiteIDs.*' => 'is_natural_no_zero',
|
'TestSiteIDs.*' => 'is_natural_no_zero',
|
||||||
'ConditionExpr' => 'permit_empty|max_length[1000]',
|
'ConditionExpr' => 'permit_empty|max_length[1000]',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!$validation->run($input)) {
|
if (!$validation->run($input)) {
|
||||||
return $this->failValidationErrors($validation->getErrors());
|
return $this->failValidationErrors($validation->getErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
$testSiteIDs = $input['TestSiteIDs'] ?? [];
|
$testSiteIDs = $input['TestSiteIDs'] ?? [];
|
||||||
if (!is_array($testSiteIDs) || empty($testSiteIDs)) {
|
if (!is_array($testSiteIDs) || empty($testSiteIDs)) {
|
||||||
return $this->failValidationErrors(['TestSiteIDs' => 'At least one TestSiteID is required']);
|
return $this->failValidationErrors(['TestSiteIDs' => 'At least one TestSiteID is required']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate all TestSiteIDs exist
|
// Validate all TestSiteIDs exist
|
||||||
$testDef = new TestDefSiteModel();
|
$testDef = new TestDefSiteModel();
|
||||||
foreach ($testSiteIDs as $testSiteID) {
|
foreach ($testSiteIDs as $testSiteID) {
|
||||||
$exists = $testDef->where('EndDate', null)->find((int) $testSiteID);
|
$exists = $testDef->where('EndDate', null)->find((int) $testSiteID);
|
||||||
if (!$exists) {
|
if (!$exists) {
|
||||||
return $this->failValidationErrors(['TestSiteIDs' => "TestSiteID {$testSiteID} not found"]);
|
return $this->failValidationErrors(['TestSiteIDs' => "TestSiteID {$testSiteID} not found"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = \Config\Database::connect();
|
$db = \Config\Database::connect();
|
||||||
$db->transStart();
|
$db->transStart();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$ruleData = [
|
$ruleData = [
|
||||||
'RuleCode' => $input['RuleCode'],
|
'RuleCode' => $input['RuleCode'],
|
||||||
@ -150,253 +140,228 @@ class RuleController extends BaseController
|
|||||||
'ConditionExpr' => $input['ConditionExpr'] ?? null,
|
'ConditionExpr' => $input['ConditionExpr'] ?? null,
|
||||||
'ConditionExprCompiled' => $input['ConditionExprCompiled'] ?? null,
|
'ConditionExprCompiled' => $input['ConditionExprCompiled'] ?? null,
|
||||||
];
|
];
|
||||||
|
|
||||||
$ruleID = $this->ruleDefModel->insert($ruleData, true);
|
$ruleID = $this->ruleDefModel->insert($ruleData, true);
|
||||||
if (!$ruleID) {
|
if (!$ruleID) {
|
||||||
throw new \Exception('Failed to create rule');
|
throw new \Exception('Failed to create rule');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Link rule to test sites
|
// Link rule to test sites
|
||||||
foreach ($testSiteIDs as $testSiteID) {
|
foreach ($testSiteIDs as $testSiteID) {
|
||||||
$this->ruleDefModel->linkTest($ruleID, (int) $testSiteID);
|
$this->ruleDefModel->linkTest($ruleID, (int) $testSiteID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create actions if provided
|
|
||||||
if (isset($input['actions']) && is_array($input['actions'])) {
|
|
||||||
foreach ($input['actions'] as $action) {
|
|
||||||
if (!is_array($action)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$actionType = $action['ActionType'] ?? null;
|
|
||||||
if (!$actionType) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$params = $action['ActionParams'] ?? null;
|
|
||||||
if (is_array($params)) {
|
|
||||||
$params = json_encode($params);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->ruleActionModel->insert([
|
|
||||||
'RuleID' => $ruleID,
|
|
||||||
'ActionType' => $actionType,
|
|
||||||
'ActionParams' => is_string($params) ? $params : null,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->transComplete();
|
$db->transComplete();
|
||||||
if ($db->transStatus() === false) {
|
if ($db->transStatus() === false) {
|
||||||
throw new \Exception('Transaction failed');
|
throw new \Exception('Transaction failed');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respondCreated([
|
return $this->respondCreated([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Rule created successfully',
|
'message' => 'Rule created successfully',
|
||||||
'data' => ['RuleID' => $ruleID],
|
'data' => ['RuleID' => $ruleID],
|
||||||
], 201);
|
], 201);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$db->transRollback();
|
$db->transRollback();
|
||||||
log_message('error', 'RuleController::create error: ' . $e->getMessage());
|
log_message('error', 'RuleController::create error: ' . $e->getMessage());
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($id = null)
|
public function update($id = null)
|
||||||
{
|
{
|
||||||
$input = $this->request->getJSON(true) ?? [];
|
$input = $this->request->getJSON(true) ?? [];
|
||||||
|
|
||||||
if (!$id || !is_numeric($id)) {
|
if (!$id || !is_numeric($id)) {
|
||||||
$id = $input['RuleID'] ?? null;
|
$id = $input['RuleID'] ?? null;
|
||||||
}
|
}
|
||||||
if (!$id || !is_numeric($id)) {
|
if (!$id || !is_numeric($id)) {
|
||||||
return $this->failValidationErrors('RuleID is required');
|
return $this->failValidationErrors('RuleID is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
$existing = $this->ruleDefModel->where('EndDate', null)->find((int) $id);
|
$existing = $this->ruleDefModel->where('EndDate', null)->find((int) $id);
|
||||||
if (!$existing) {
|
if (!$existing) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Rule not found',
|
'message' => 'Rule not found',
|
||||||
'data' => [],
|
'data' => [],
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$validation = service('validation');
|
$validation = service('validation');
|
||||||
$validation->setRules([
|
$validation->setRules([
|
||||||
'RuleCode' => 'permit_empty|max_length[50]',
|
'RuleCode' => 'permit_empty|max_length[50]',
|
||||||
'RuleName' => 'permit_empty|max_length[100]',
|
'RuleName' => 'permit_empty|max_length[100]',
|
||||||
'EventCode' => 'permit_empty|max_length[50]',
|
'EventCode' => 'permit_empty|max_length[50]',
|
||||||
'TestSiteIDs' => 'permit_empty',
|
'TestSiteIDs' => 'permit_empty',
|
||||||
'TestSiteIDs.*' => 'is_natural_no_zero',
|
'TestSiteIDs.*' => 'is_natural_no_zero',
|
||||||
'ConditionExpr' => 'permit_empty|max_length[1000]',
|
'ConditionExpr' => 'permit_empty|max_length[1000]',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!$validation->run($input)) {
|
if (!$validation->run($input)) {
|
||||||
return $this->failValidationErrors($validation->getErrors());
|
return $this->failValidationErrors($validation->getErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = \Config\Database::connect();
|
$db = \Config\Database::connect();
|
||||||
$db->transStart();
|
$db->transStart();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$updateData = [];
|
$updateData = [];
|
||||||
foreach (['RuleCode', 'RuleName', 'Description', 'EventCode', 'ConditionExpr', 'ConditionExprCompiled'] as $field) {
|
foreach (['RuleCode', 'RuleName', 'Description', 'EventCode', 'ConditionExpr', 'ConditionExprCompiled'] as $field) {
|
||||||
if (array_key_exists($field, $input)) {
|
if (array_key_exists($field, $input)) {
|
||||||
$updateData[$field] = $input[$field];
|
$updateData[$field] = $input[$field];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($updateData)) {
|
if (!empty($updateData)) {
|
||||||
$this->ruleDefModel->update((int) $id, $updateData);
|
$this->ruleDefModel->update((int) $id, $updateData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update test site mappings if provided
|
// Update test site mappings if provided
|
||||||
if (isset($input['TestSiteIDs']) && is_array($input['TestSiteIDs'])) {
|
if (isset($input['TestSiteIDs']) && is_array($input['TestSiteIDs'])) {
|
||||||
$testSiteIDs = $input['TestSiteIDs'];
|
$testSiteIDs = $input['TestSiteIDs'];
|
||||||
|
|
||||||
// Validate all TestSiteIDs exist
|
// Validate all TestSiteIDs exist
|
||||||
$testDef = new TestDefSiteModel();
|
$testDef = new TestDefSiteModel();
|
||||||
foreach ($testSiteIDs as $testSiteID) {
|
foreach ($testSiteIDs as $testSiteID) {
|
||||||
$exists = $testDef->where('EndDate', null)->find((int) $testSiteID);
|
$exists = $testDef->where('EndDate', null)->find((int) $testSiteID);
|
||||||
if (!$exists) {
|
if (!$exists) {
|
||||||
throw new \Exception("TestSiteID {$testSiteID} not found");
|
throw new \Exception("TestSiteID {$testSiteID} not found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get current linked tests
|
// Get current linked tests
|
||||||
$currentLinks = $this->ruleDefModel->getLinkedTests((int) $id);
|
$currentLinks = $this->ruleDefModel->getLinkedTests((int) $id);
|
||||||
|
|
||||||
// Unlink tests that are no longer in the list
|
// Unlink tests that are no longer in the list
|
||||||
foreach ($currentLinks as $currentTestSiteID) {
|
foreach ($currentLinks as $currentTestSiteID) {
|
||||||
if (!in_array($currentTestSiteID, $testSiteIDs)) {
|
if (!in_array($currentTestSiteID, $testSiteIDs)) {
|
||||||
$this->ruleDefModel->unlinkTest((int) $id, $currentTestSiteID);
|
$this->ruleDefModel->unlinkTest((int) $id, $currentTestSiteID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Link new tests
|
// Link new tests
|
||||||
foreach ($testSiteIDs as $testSiteID) {
|
foreach ($testSiteIDs as $testSiteID) {
|
||||||
if (!in_array($testSiteID, $currentLinks)) {
|
if (!in_array($testSiteID, $currentLinks)) {
|
||||||
$this->ruleDefModel->linkTest((int) $id, (int) $testSiteID);
|
$this->ruleDefModel->linkTest((int) $id, (int) $testSiteID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->transComplete();
|
$db->transComplete();
|
||||||
if ($db->transStatus() === false) {
|
if ($db->transStatus() === false) {
|
||||||
throw new \Exception('Transaction failed');
|
throw new \Exception('Transaction failed');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Rule updated successfully',
|
'message' => 'Rule updated successfully',
|
||||||
'data' => ['RuleID' => (int) $id],
|
'data' => ['RuleID' => (int) $id],
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$db->transRollback();
|
$db->transRollback();
|
||||||
log_message('error', 'RuleController::update error: ' . $e->getMessage());
|
log_message('error', 'RuleController::update error: ' . $e->getMessage());
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id = null)
|
public function delete($id = null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (!$id || !is_numeric($id)) {
|
if (!$id || !is_numeric($id)) {
|
||||||
return $this->failValidationErrors('RuleID is required');
|
return $this->failValidationErrors('RuleID is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
$existing = $this->ruleDefModel->where('EndDate', null)->find((int) $id);
|
$existing = $this->ruleDefModel->where('EndDate', null)->find((int) $id);
|
||||||
if (!$existing) {
|
if (!$existing) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Rule not found',
|
'message' => 'Rule not found',
|
||||||
'data' => [],
|
'data' => [],
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->ruleDefModel->delete((int) $id);
|
$this->ruleDefModel->delete((int) $id);
|
||||||
|
|
||||||
return $this->respondDeleted([
|
return $this->respondDeleted([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Rule deleted successfully',
|
'message' => 'Rule deleted successfully',
|
||||||
'data' => ['RuleID' => (int) $id],
|
'data' => ['RuleID' => (int) $id],
|
||||||
]);
|
]);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
log_message('error', 'RuleController::delete error: ' . $e->getMessage());
|
log_message('error', 'RuleController::delete error: ' . $e->getMessage());
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateExpr()
|
public function validateExpr()
|
||||||
{
|
{
|
||||||
$input = $this->request->getJSON(true) ?? [];
|
$input = $this->request->getJSON(true) ?? [];
|
||||||
$expr = $input['expr'] ?? '';
|
$expr = $input['expr'] ?? '';
|
||||||
$context = $input['context'] ?? [];
|
$context = $input['context'] ?? [];
|
||||||
|
|
||||||
if (!is_string($expr) || trim($expr) === '') {
|
if (!is_string($expr) || trim($expr) === '') {
|
||||||
return $this->failValidationErrors(['expr' => 'expr is required']);
|
return $this->failValidationErrors(['expr' => 'expr is required']);
|
||||||
}
|
}
|
||||||
if (!is_array($context)) {
|
if (!is_array($context)) {
|
||||||
return $this->failValidationErrors(['context' => 'context must be an object']);
|
return $this->failValidationErrors(['context' => 'context must be an object']);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$svc = new RuleExpressionService();
|
$svc = new RuleExpressionService();
|
||||||
$result = $svc->evaluate($expr, $context);
|
$result = $svc->evaluate($expr, $context);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'data' => [
|
'data' => [
|
||||||
'valid' => true,
|
'valid' => true,
|
||||||
'result' => $result,
|
'result' => $result,
|
||||||
],
|
],
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'data' => [
|
'data' => [
|
||||||
'valid' => false,
|
'valid' => false,
|
||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage(),
|
||||||
],
|
],
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile DSL expression to engine-compatible structure.
|
* Compile DSL expression to engine-compatible structure.
|
||||||
* Frontend calls this when user clicks "Compile" button.
|
* Frontend calls this when user clicks "Compile" button.
|
||||||
*/
|
*/
|
||||||
public function compile()
|
public function compile()
|
||||||
{
|
{
|
||||||
$input = $this->request->getJSON(true) ?? [];
|
$input = $this->request->getJSON(true) ?? [];
|
||||||
$expr = $input['expr'] ?? '';
|
$expr = $input['expr'] ?? '';
|
||||||
|
|
||||||
if (!is_string($expr) || trim($expr) === '') {
|
if (!is_string($expr) || trim($expr) === '') {
|
||||||
return $this->failValidationErrors(['expr' => 'Expression is required']);
|
return $this->failValidationErrors(['expr' => 'Expression is required']);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$svc = new RuleExpressionService();
|
$svc = new RuleExpressionService();
|
||||||
$compiled = $svc->compile($expr);
|
$compiled = $svc->compile($expr);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'data' => [
|
'data' => [
|
||||||
'raw' => $expr,
|
'raw' => $expr,
|
||||||
'compiled' => $compiled,
|
'compiled' => $compiled,
|
||||||
'conditionExprCompiled' => json_encode($compiled),
|
'conditionExprCompiled' => json_encode($compiled),
|
||||||
],
|
],
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Compilation failed',
|
'message' => 'Compilation failed',
|
||||||
'data' => [
|
'data' => [
|
||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage(),
|
||||||
],
|
],
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,34 +1,34 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
|
|
||||||
use Firebase\JWT\JWT;
|
use Firebase\JWT\JWT;
|
||||||
use Firebase\JWT\Key;
|
use Firebase\JWT\Key;
|
||||||
use Firebase\JWT\ExpiredException;
|
use Firebase\JWT\ExpiredException;
|
||||||
use Firebase\JWT\SignatureInvalidException;
|
use Firebase\JWT\SignatureInvalidException;
|
||||||
use Firebase\JWT\BeforeValidException;
|
use Firebase\JWT\BeforeValidException;
|
||||||
use CodeIgniter\Cookie\Cookie;
|
use CodeIgniter\Cookie\Cookie;
|
||||||
|
|
||||||
class SampleController extends Controller {
|
class SampleController extends Controller {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
|
|
||||||
$token = $this->request->getCookie('token');
|
$token = $this->request->getCookie('token');
|
||||||
$key = getenv('JWT_SECRET');
|
$key = getenv('JWT_SECRET');
|
||||||
|
|
||||||
// Decode Token dengan Key yg ada di .env
|
// Decode Token dengan Key yg ada di .env
|
||||||
$decodedPayload = JWT::decode($token, new Key($key, 'HS256'));
|
$decodedPayload = JWT::decode($token, new Key($key, 'HS256'));
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'code' => 200,
|
'code' => 200,
|
||||||
'message' => 'Authenticated',
|
'message' => 'Authenticated',
|
||||||
'data' => $decodedPayload
|
'data' => $decodedPayload
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,87 +1,87 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers\Specimen;
|
namespace App\Controllers\Specimen;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Libraries\ValueSet;
|
use App\Libraries\ValueSet;
|
||||||
use App\Models\Specimen\ContainerDefModel;
|
use App\Models\Specimen\ContainerDefModel;
|
||||||
|
|
||||||
class ContainerDefController extends BaseController {
|
class ContainerDefController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $model;
|
protected $model;
|
||||||
protected $rules;
|
protected $rules;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new ContainerDefModel();
|
$this->model = new ContainerDefModel();
|
||||||
$this->rules = [
|
$this->rules = [
|
||||||
'ConCode' => 'required|max_length[50]',
|
'ConCode' => 'required|max_length[50]',
|
||||||
'ConName' => 'required|max_length[50]'
|
'ConName' => 'required|max_length[50]'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
try {
|
try {
|
||||||
$filter = [
|
$filter = [
|
||||||
'ConCode' => $this->request->getVar('ConCode'),
|
'ConCode' => $this->request->getVar('ConCode'),
|
||||||
'ConName' => $this->request->getVar('ConName')
|
'ConName' => $this->request->getVar('ConName')
|
||||||
];
|
];
|
||||||
$rows = $this->model->getContainers($filter);
|
$rows = $this->model->getContainers($filter);
|
||||||
|
|
||||||
$rows = ValueSet::transformLabels($rows, [
|
$rows = ValueSet::transformLabels($rows, [
|
||||||
'ConCategory' => 'container_class',
|
'ConCategory' => 'container_class',
|
||||||
'CapColor' => 'container_cap_color',
|
'CapColor' => 'container_cap_color',
|
||||||
'ConSize' => 'container_size',
|
'ConSize' => 'container_size',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Exception : '.$e->getMessage());
|
return $this->failServerError('Exception : '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($ConDefID) {
|
public function show($ConDefID) {
|
||||||
try {
|
try {
|
||||||
$row = $this->model->getContainer($ConDefID);
|
$row = $this->model->getContainer($ConDefID);
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = ValueSet::transformLabels([$row], [
|
$row = ValueSet::transformLabels([$row], [
|
||||||
'ConCategory' => 'container_class',
|
'ConCategory' => 'container_class',
|
||||||
'CapColor' => 'container_cap_color',
|
'CapColor' => 'container_cap_color',
|
||||||
'ConSize' => 'container_size',
|
'ConSize' => 'container_size',
|
||||||
])[0];
|
])[0];
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $row ], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Exception : '.$e->getMessage());
|
return $this->failServerError('Exception : '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$ConDefID = $this->model->insert($input);
|
$ConDefID = $this->model->insert($input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => "data $ConDefID created successfully", 'data' => $ConDefID ]);
|
return $this->respondCreated([ 'status' => 'success', 'message' => "data $ConDefID created successfully", 'data' => $ConDefID ]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$ConDefID = $this->model->update($input['ConDefID'], $input);
|
$ConDefID = $this->model->update($input['ConDefID'], $input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => "data $ConDefID updated successfully" ]);
|
return $this->respondCreated([ 'status' => 'success', 'message' => "data $ConDefID updated successfully" ]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,80 +1,80 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers\Specimen;
|
namespace App\Controllers\Specimen;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Libraries\ValueSet;
|
use App\Libraries\ValueSet;
|
||||||
use App\Models\Specimen\SpecimenCollectionModel;
|
use App\Models\Specimen\SpecimenCollectionModel;
|
||||||
|
|
||||||
class SpecimenCollectionController extends BaseController {
|
class SpecimenCollectionController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $model;
|
protected $model;
|
||||||
protected $rules;
|
protected $rules;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new SpecimenCollectionModel();
|
$this->model = new SpecimenCollectionModel();
|
||||||
$this->rules = [];
|
$this->rules = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
try {
|
try {
|
||||||
$rows = $this->model->findAll();
|
$rows = $this->model->findAll();
|
||||||
|
|
||||||
$rows = ValueSet::transformLabels($rows, [
|
$rows = ValueSet::transformLabels($rows, [
|
||||||
'CollectionMethod' => 'collection_method',
|
'CollectionMethod' => 'collection_method',
|
||||||
'Additive' => 'additive',
|
'Additive' => 'additive',
|
||||||
'SpecimenRole' => 'specimen_role',
|
'SpecimenRole' => 'specimen_role',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Exception : '.$e->getMessage());
|
return $this->failServerError('Exception : '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id) {
|
public function show($id) {
|
||||||
try {
|
try {
|
||||||
$row = $this->model->where('SpcColID', $id)->first();
|
$row = $this->model->where('SpcColID', $id)->first();
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = ValueSet::transformLabels([$row], [
|
$row = ValueSet::transformLabels([$row], [
|
||||||
'CollectionMethod' => 'collection_method',
|
'CollectionMethod' => 'collection_method',
|
||||||
'Additive' => 'additive',
|
'Additive' => 'additive',
|
||||||
'SpecimenRole' => 'specimen_role',
|
'SpecimenRole' => 'specimen_role',
|
||||||
])[0];
|
])[0];
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $row ], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Exception : '.$e->getMessage());
|
return $this->failServerError('Exception : '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$id = $this->model->insert($input);
|
$id = $this->model->insert($input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]);
|
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$id = $this->model->update($input['SpcColID'], $input);
|
$id = $this->model->update($input['SpcColID'], $input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]);
|
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,126 +1,126 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers\Specimen;
|
namespace App\Controllers\Specimen;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Libraries\ValueSet;
|
use App\Libraries\ValueSet;
|
||||||
use App\Models\Specimen\SpecimenModel;
|
use App\Models\Specimen\SpecimenModel;
|
||||||
|
|
||||||
class SpecimenController extends BaseController {
|
class SpecimenController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $model;
|
protected $model;
|
||||||
protected $rules;
|
protected $rules;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new SpecimenModel();
|
$this->model = new SpecimenModel();
|
||||||
$this->rules = [];
|
$this->rules = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
try {
|
try {
|
||||||
$rows = $this->model->findAll();
|
$rows = $this->model->findAll();
|
||||||
|
|
||||||
$rows = ValueSet::transformLabels($rows, [
|
$rows = ValueSet::transformLabels($rows, [
|
||||||
'SpecimenType' => 'specimen_type',
|
'SpecimenType' => 'specimen_type',
|
||||||
'SpecimenStatus' => 'specimen_status',
|
'SpecimenStatus' => 'specimen_status',
|
||||||
'BodySite' => 'body_site',
|
'BodySite' => 'body_site',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Exception : '.$e->getMessage());
|
return $this->failServerError('Exception : '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id) {
|
public function show($id) {
|
||||||
try {
|
try {
|
||||||
$row = $this->model->where('SID',$id)->first();
|
$row = $this->model->where('SID',$id)->first();
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = ValueSet::transformLabels([$row], [
|
$row = ValueSet::transformLabels([$row], [
|
||||||
'SpecimenType' => 'specimen_type',
|
'SpecimenType' => 'specimen_type',
|
||||||
'SpecimenStatus' => 'specimen_status',
|
'SpecimenStatus' => 'specimen_status',
|
||||||
'BodySite' => 'body_site',
|
'BodySite' => 'body_site',
|
||||||
])[0];
|
])[0];
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $row ], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Exception : '.$e->getMessage());
|
return $this->failServerError('Exception : '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$id = $this->model->insert($input);
|
$id = $this->model->insert($input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]);
|
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$id = $this->model->update($input['SID'], $input);
|
$id = $this->model->update($input['SID'], $input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]);
|
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a specimen (soft delete)
|
* Delete a specimen (soft delete)
|
||||||
* DELETE /api/specimen/(:num)
|
* DELETE /api/specimen/(:num)
|
||||||
*/
|
*/
|
||||||
public function delete($id) {
|
public function delete($id) {
|
||||||
try {
|
try {
|
||||||
// Check if specimen exists
|
// Check if specimen exists
|
||||||
$specimen = $this->model->where('SID', $id)->first();
|
$specimen = $this->model->where('SID', $id)->first();
|
||||||
|
|
||||||
if (empty($specimen)) {
|
if (empty($specimen)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Specimen not found',
|
'message' => 'Specimen not found',
|
||||||
'data' => null
|
'data' => null
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform soft delete (set DelDate)
|
// Perform soft delete (set DelDate)
|
||||||
$deleted = $this->model->update($id, [
|
$deleted = $this->model->update($id, [
|
||||||
'DelDate' => date('Y-m-d H:i:s')
|
'DelDate' => date('Y-m-d H:i:s')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!$deleted) {
|
if (!$deleted) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Failed to delete specimen',
|
'message' => 'Failed to delete specimen',
|
||||||
'data' => null
|
'data' => null
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Specimen deleted successfully',
|
'message' => 'Specimen deleted successfully',
|
||||||
'data' => ['SID' => $id]
|
'data' => ['SID' => $id]
|
||||||
], 200);
|
], 200);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
log_message('error', 'SpecimenController::delete error: ' . $e->getMessage());
|
log_message('error', 'SpecimenController::delete error: ' . $e->getMessage());
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Failed to delete specimen',
|
'message' => 'Failed to delete specimen',
|
||||||
'data' => null
|
'data' => null
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,65 +1,65 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers\Specimen;
|
namespace App\Controllers\Specimen;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Models\Specimen\SpecimenPrepModel;
|
use App\Models\Specimen\SpecimenPrepModel;
|
||||||
|
|
||||||
class SpecimenPrepController extends BaseController {
|
class SpecimenPrepController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $model;
|
protected $model;
|
||||||
protected $rules;
|
protected $rules;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new SpecimenPrepModel();
|
$this->model = new SpecimenPrepModel();
|
||||||
$this->rules = [];
|
$this->rules = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
try {
|
try {
|
||||||
$rows = $this->model->findAll();
|
$rows = $this->model->findAll();
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Exception : '.$e->getMessage());
|
return $this->failServerError('Exception : '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id) {
|
public function show($id) {
|
||||||
try {
|
try {
|
||||||
$row = $this->model->where('SpcPrpID', $id)->first();
|
$row = $this->model->where('SpcPrpID', $id)->first();
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200);
|
||||||
}
|
}
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $row ], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Exception : '.$e->getMessage());
|
return $this->failServerError('Exception : '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$id = $this->model->insert($input);
|
$id = $this->model->insert($input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]);
|
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$id = $this->model->update($input['SpcPrpID'], $input);
|
$id = $this->model->update($input['SpcPrpID'], $input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]);
|
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,78 +1,78 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers\Specimen;
|
namespace App\Controllers\Specimen;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Libraries\ValueSet;
|
use App\Libraries\ValueSet;
|
||||||
use App\Models\Specimen\SpecimenStatusModel;
|
use App\Models\Specimen\SpecimenStatusModel;
|
||||||
|
|
||||||
class ContainerDef extends BaseController {
|
class ContainerDef extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $model;
|
protected $model;
|
||||||
protected $rules;
|
protected $rules;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new SpecimenStatusModel();
|
$this->model = new SpecimenStatusModel();
|
||||||
$this->rules = [];
|
$this->rules = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
try {
|
try {
|
||||||
$rows = $this->model->findAll();
|
$rows = $this->model->findAll();
|
||||||
|
|
||||||
$rows = ValueSet::transformLabels($rows, [
|
$rows = ValueSet::transformLabels($rows, [
|
||||||
'Status' => 'specimen_status',
|
'Status' => 'specimen_status',
|
||||||
'Activity' => 'specimen_activity',
|
'Activity' => 'specimen_activity',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Exception : '.$e->getMessage());
|
return $this->failServerError('Exception : '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id) {
|
public function show($id) {
|
||||||
try {
|
try {
|
||||||
$row = $this->model->where('SpcStaID', $id)->first();
|
$row = $this->model->where('SpcStaID', $id)->first();
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = ValueSet::transformLabels([$row], [
|
$row = ValueSet::transformLabels([$row], [
|
||||||
'Status' => 'specimen_status',
|
'Status' => 'specimen_status',
|
||||||
'Activity' => 'specimen_activity',
|
'Activity' => 'specimen_activity',
|
||||||
])[0];
|
])[0];
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $row ], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Exception : '.$e->getMessage());
|
return $this->failServerError('Exception : '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$id = $this->model->insert($input);
|
$id = $this->model->insert($input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]);
|
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$id = $this->model->update($input['SpcStaID'], $input);
|
$id = $this->model->update($input['SpcStaID'], $input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]);
|
return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,85 +1,85 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers\Test;
|
namespace App\Controllers\Test;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
use App\Libraries\ValueSet;
|
use App\Libraries\ValueSet;
|
||||||
use App\Models\Patient\PatientModel;
|
use App\Models\Patient\PatientModel;
|
||||||
use App\Models\OrderTestModel;
|
use App\Models\OrderTestModel;
|
||||||
|
|
||||||
class DemoOrderController extends Controller {
|
class DemoOrderController extends Controller {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $patientModel;
|
protected $patientModel;
|
||||||
protected $orderModel;
|
protected $orderModel;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->patientModel = new PatientModel();
|
$this->patientModel = new PatientModel();
|
||||||
$this->orderModel = new OrderTestModel();
|
$this->orderModel = new OrderTestModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createDemoOrder() {
|
public function createDemoOrder() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
|
|
||||||
$patientData = [
|
$patientData = [
|
||||||
'PatientID' => $input['PatientID'] ?? 'DEMO' . time(),
|
'PatientID' => $input['PatientID'] ?? 'DEMO' . time(),
|
||||||
'Gender' => $input['Gender'] ?? '1',
|
'Gender' => $input['Gender'] ?? '1',
|
||||||
'NameFirst' => $input['NameFirst'] ?? 'Demo',
|
'NameFirst' => $input['NameFirst'] ?? 'Demo',
|
||||||
'NameLast' => $input['NameLast'] ?? 'Patient',
|
'NameLast' => $input['NameLast'] ?? 'Patient',
|
||||||
'Birthdate' => $input['Birthdate'] ?? '1990-01-01'
|
'Birthdate' => $input['Birthdate'] ?? '1990-01-01'
|
||||||
];
|
];
|
||||||
|
|
||||||
$patient = $this->patientModel->where('PatientID', $patientData['PatientID'])->findAll();
|
$patient = $this->patientModel->where('PatientID', $patientData['PatientID'])->findAll();
|
||||||
if (empty($patient)) {
|
if (empty($patient)) {
|
||||||
$internalPID = $this->patientModel->createPatient($patientData);
|
$internalPID = $this->patientModel->createPatient($patientData);
|
||||||
} else {
|
} else {
|
||||||
$internalPID = $patient[0]['InternalPID'];
|
$internalPID = $patient[0]['InternalPID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$orderData = [
|
$orderData = [
|
||||||
'InternalPID' => $internalPID,
|
'InternalPID' => $internalPID,
|
||||||
'PatVisitID' => $input['PatVisitID'] ?? null,
|
'PatVisitID' => $input['PatVisitID'] ?? null,
|
||||||
'Priority' => $input['Priority'] ?? 'R',
|
'Priority' => $input['Priority'] ?? 'R',
|
||||||
'OrderingProvider' => $input['OrderingProvider'] ?? 'Dr. Demo',
|
'OrderingProvider' => $input['OrderingProvider'] ?? 'Dr. Demo',
|
||||||
'DepartmentID' => $input['DepartmentID'] ?? 1,
|
'DepartmentID' => $input['DepartmentID'] ?? 1,
|
||||||
'Tests' => $input['Tests'] ?? []
|
'Tests' => $input['Tests'] ?? []
|
||||||
];
|
];
|
||||||
|
|
||||||
$orderID = $this->orderModel->createOrder($orderData);
|
$orderID = $this->orderModel->createOrder($orderData);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Demo order created successfully',
|
'message' => 'Demo order created successfully',
|
||||||
'data' => [
|
'data' => [
|
||||||
'PatientID' => $patientData['PatientID'],
|
'PatientID' => $patientData['PatientID'],
|
||||||
'InternalPID' => $internalPID,
|
'InternalPID' => $internalPID,
|
||||||
'OrderID' => $orderID,
|
'OrderID' => $orderID,
|
||||||
'OrderStatus' => 'ORD'
|
'OrderStatus' => 'ORD'
|
||||||
]
|
]
|
||||||
], 201);
|
], 201);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listDemoOrders() {
|
public function listDemoOrders() {
|
||||||
$orders = $this->db->table('ordertest ot')
|
$orders = $this->db->table('ordertest ot')
|
||||||
->select('ot.OrderID, ot.InternalPID, p.PatientID, ot.OrderDateTime, ot.Priority, ot.OrderStatus')
|
->select('ot.OrderID, ot.InternalPID, p.PatientID, ot.OrderDateTime, ot.Priority, ot.OrderStatus')
|
||||||
->join('patient p', 'p.InternalPID = ot.InternalPID')
|
->join('patient p', 'p.InternalPID = ot.InternalPID')
|
||||||
->where('ot.DelDate', null)
|
->where('ot.DelDate', null)
|
||||||
->orderBy('ot.OrderDateTime', 'DESC')
|
->orderBy('ot.OrderDateTime', 'DESC')
|
||||||
->limit(50)
|
->limit(50)
|
||||||
->get()
|
->get()
|
||||||
->getResultArray();
|
->getResultArray();
|
||||||
|
|
||||||
$orders = ValueSet::transformLabels($orders, [
|
$orders = ValueSet::transformLabels($orders, [
|
||||||
'Priority' => 'order_priority',
|
'Priority' => 'order_priority',
|
||||||
'OrderStatus' => 'order_status',
|
'OrderStatus' => 'order_status',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Data fetched successfully',
|
'message' => 'Data fetched successfully',
|
||||||
'data' => $orders
|
'data' => $orders
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,212 +1,212 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Controllers\Test;
|
namespace App\Controllers\Test;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Libraries\ValueSet;
|
use App\Libraries\ValueSet;
|
||||||
use App\Models\Test\TestMapModel;
|
use App\Models\Test\TestMapModel;
|
||||||
use App\Models\Test\TestMapDetailModel;
|
use App\Models\Test\TestMapDetailModel;
|
||||||
|
|
||||||
class TestMapController extends BaseController {
|
class TestMapController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $rules;
|
protected $rules;
|
||||||
protected $model;
|
protected $model;
|
||||||
protected $modelDetail;
|
protected $modelDetail;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new TestMapModel;
|
$this->model = new TestMapModel;
|
||||||
$this->modelDetail = new TestMapDetailModel;
|
$this->modelDetail = new TestMapDetailModel;
|
||||||
$this->rules = [
|
$this->rules = [
|
||||||
'TestCode' => 'required',
|
'TestCode' => 'required',
|
||||||
'HostID' => 'required|integer',
|
'HostID' => 'required|integer',
|
||||||
'ClientID' => 'required|integer',
|
'ClientID' => 'required|integer',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$rows = $this->model->getUniqueGroupings();
|
$rows = $this->model->getUniqueGroupings();
|
||||||
if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); }
|
if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); }
|
||||||
|
|
||||||
$rows = ValueSet::transformLabels($rows, [
|
$rows = ValueSet::transformLabels($rows, [
|
||||||
'HostType' => 'entity_type',
|
'HostType' => 'entity_type',
|
||||||
'ClientType' => 'entity_type',
|
'ClientType' => 'entity_type',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id = null) {
|
public function show($id = null) {
|
||||||
$row = $this->model->where('TestMapID',$id)->where('EndDate', null)->first();
|
$row = $this->model->where('TestMapID',$id)->where('EndDate', null)->first();
|
||||||
if (empty($row)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200); }
|
if (empty($row)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200); }
|
||||||
|
|
||||||
$row = ValueSet::transformLabels([$row], [
|
$row = ValueSet::transformLabels([$row], [
|
||||||
'HostType' => 'entity_type',
|
'HostType' => 'entity_type',
|
||||||
'ClientType' => 'entity_type',
|
'ClientType' => 'entity_type',
|
||||||
])[0];
|
])[0];
|
||||||
|
|
||||||
// Include testmapdetail records
|
// Include testmapdetail records
|
||||||
$row['details'] = $this->modelDetail->getDetailsByTestMap($id);
|
$row['details'] = $this->modelDetail->getDetailsByTestMap($id);
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $row ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$id = $this->model->insert($input);
|
$id = $this->model->insert($input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => "data created successfully", 'data' => $id ]);
|
return $this->respondCreated([ 'status' => 'success', 'message' => "data created successfully", 'data' => $id ]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$id = $input["TestMapID"];
|
$id = $input["TestMapID"];
|
||||||
if (!$id) { return $this->failValidationErrors('TestMapID is required.'); }
|
if (!$id) { return $this->failValidationErrors('TestMapID is required.'); }
|
||||||
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors( $this->validator->getErrors() ); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors( $this->validator->getErrors() ); }
|
||||||
try {
|
try {
|
||||||
$this->model->update($id,$input);
|
$this->model->update($id,$input);
|
||||||
return $this->respondCreated([ 'status' => 'success', 'message' => "data updated successfully", 'data' => $id ]);
|
return $this->respondCreated([ 'status' => 'success', 'message' => "data updated successfully", 'data' => $id ]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$id = $input["TestMapID"] ?? null;
|
$id = $input["TestMapID"] ?? null;
|
||||||
if (!$id) { return $this->failValidationErrors('TestMapID is required.'); }
|
if (!$id) { return $this->failValidationErrors('TestMapID is required.'); }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$row = $this->model->where('TestMapID', $id)->where('EndDate', null)->first();
|
$row = $this->model->where('TestMapID', $id)->where('EndDate', null)->first();
|
||||||
if (empty($row)) { return $this->respond([ 'status' => 'failed', 'message' => "Data not found or already deleted.", 'data' => null ], 404); }
|
if (empty($row)) { return $this->respond([ 'status' => 'failed', 'message' => "Data not found or already deleted.", 'data' => null ], 404); }
|
||||||
|
|
||||||
$this->db->transStart();
|
$this->db->transStart();
|
||||||
|
|
||||||
// Soft delete the testmap
|
// Soft delete the testmap
|
||||||
$this->model->update($id, ['EndDate' => date('Y-m-d H:i:s')]);
|
$this->model->update($id, ['EndDate' => date('Y-m-d H:i:s')]);
|
||||||
|
|
||||||
// Soft delete all related details
|
// Soft delete all related details
|
||||||
$this->modelDetail->where('TestMapID', $id)
|
$this->modelDetail->where('TestMapID', $id)
|
||||||
->where('EndDate', null)
|
->where('EndDate', null)
|
||||||
->set('EndDate', date('Y-m-d H:i:s'))
|
->set('EndDate', date('Y-m-d H:i:s'))
|
||||||
->update();
|
->update();
|
||||||
|
|
||||||
$this->db->transComplete();
|
$this->db->transComplete();
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "data deleted successfully", 'data' => $id ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "data deleted successfully", 'data' => $id ], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showByTestCode($testCode = null) {
|
public function showByTestCode($testCode = null) {
|
||||||
if (!$testCode) { return $this->failValidationErrors('TestCode is required.'); }
|
if (!$testCode) { return $this->failValidationErrors('TestCode is required.'); }
|
||||||
|
|
||||||
$rows = $this->model->getMappingsByTestCode($testCode);
|
$rows = $this->model->getMappingsByTestCode($testCode);
|
||||||
if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); }
|
if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); }
|
||||||
|
|
||||||
$rows = ValueSet::transformLabels($rows, [
|
$rows = ValueSet::transformLabels($rows, [
|
||||||
'HostType' => 'entity_type',
|
'HostType' => 'entity_type',
|
||||||
'ClientType' => 'entity_type',
|
'ClientType' => 'entity_type',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function batchCreate() {
|
public function batchCreate() {
|
||||||
$items = $this->request->getJSON(true);
|
$items = $this->request->getJSON(true);
|
||||||
if (!is_array($items)) { return $this->failValidationErrors('Expected array of items'); }
|
if (!is_array($items)) { return $this->failValidationErrors('Expected array of items'); }
|
||||||
|
|
||||||
$results = ['success' => [], 'failed' => []];
|
$results = ['success' => [], 'failed' => []];
|
||||||
$this->db->transStart();
|
$this->db->transStart();
|
||||||
|
|
||||||
foreach ($items as $index => $item) {
|
foreach ($items as $index => $item) {
|
||||||
if (!$this->validateData($item, $this->rules)) {
|
if (!$this->validateData($item, $this->rules)) {
|
||||||
$results['failed'][] = ['index' => $index, 'errors' => $this->validator->getErrors()];
|
$results['failed'][] = ['index' => $index, 'errors' => $this->validator->getErrors()];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$id = $this->model->insert($item);
|
$id = $this->model->insert($item);
|
||||||
$results['success'][] = ['index' => $index, 'TestMapID' => $id];
|
$results['success'][] = ['index' => $index, 'TestMapID' => $id];
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$results['failed'][] = ['index' => $index, 'error' => $e->getMessage()];
|
$results['failed'][] = ['index' => $index, 'error' => $e->getMessage()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->transComplete();
|
$this->db->transComplete();
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => empty($results['failed']) ? 'success' : 'partial',
|
'status' => empty($results['failed']) ? 'success' : 'partial',
|
||||||
'message' => 'Batch create completed',
|
'message' => 'Batch create completed',
|
||||||
'data' => $results
|
'data' => $results
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function batchUpdate() {
|
public function batchUpdate() {
|
||||||
$items = $this->request->getJSON(true);
|
$items = $this->request->getJSON(true);
|
||||||
if (!is_array($items)) { return $this->failValidationErrors('Expected array of items'); }
|
if (!is_array($items)) { return $this->failValidationErrors('Expected array of items'); }
|
||||||
|
|
||||||
$results = ['success' => [], 'failed' => []];
|
$results = ['success' => [], 'failed' => []];
|
||||||
$this->db->transStart();
|
$this->db->transStart();
|
||||||
|
|
||||||
foreach ($items as $index => $item) {
|
foreach ($items as $index => $item) {
|
||||||
$id = $item['TestMapID'] ?? null;
|
$id = $item['TestMapID'] ?? null;
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
$results['failed'][] = ['index' => $index, 'error' => 'TestMapID required'];
|
$results['failed'][] = ['index' => $index, 'error' => 'TestMapID required'];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!$this->validateData($item, $this->rules)) {
|
if (!$this->validateData($item, $this->rules)) {
|
||||||
$results['failed'][] = ['index' => $index, 'errors' => $this->validator->getErrors()];
|
$results['failed'][] = ['index' => $index, 'errors' => $this->validator->getErrors()];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$this->model->update($id, $item);
|
$this->model->update($id, $item);
|
||||||
$results['success'][] = ['index' => $index, 'TestMapID' => $id];
|
$results['success'][] = ['index' => $index, 'TestMapID' => $id];
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$results['failed'][] = ['index' => $index, 'error' => $e->getMessage()];
|
$results['failed'][] = ['index' => $index, 'error' => $e->getMessage()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->transComplete();
|
$this->db->transComplete();
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => empty($results['failed']) ? 'success' : 'partial',
|
'status' => empty($results['failed']) ? 'success' : 'partial',
|
||||||
'message' => 'Batch update completed',
|
'message' => 'Batch update completed',
|
||||||
'data' => $results
|
'data' => $results
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function batchDelete() {
|
public function batchDelete() {
|
||||||
$ids = $this->request->getJSON(true);
|
$ids = $this->request->getJSON(true);
|
||||||
if (!is_array($ids)) { return $this->failValidationErrors('Expected array of TestMapIDs'); }
|
if (!is_array($ids)) { return $this->failValidationErrors('Expected array of TestMapIDs'); }
|
||||||
|
|
||||||
$results = ['success' => [], 'failed' => []];
|
$results = ['success' => [], 'failed' => []];
|
||||||
$this->db->transStart();
|
$this->db->transStart();
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
try {
|
try {
|
||||||
$row = $this->model->where('TestMapID', $id)->where('EndDate', null)->first();
|
$row = $this->model->where('TestMapID', $id)->where('EndDate', null)->first();
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
$results['failed'][] = ['TestMapID' => $id, 'error' => 'Not found or already deleted'];
|
$results['failed'][] = ['TestMapID' => $id, 'error' => 'Not found or already deleted'];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$this->model->update($id, ['EndDate' => date('Y-m-d H:i:s')]);
|
$this->model->update($id, ['EndDate' => date('Y-m-d H:i:s')]);
|
||||||
$results['success'][] = $id;
|
$results['success'][] = $id;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$results['failed'][] = ['TestMapID' => $id, 'error' => $e->getMessage()];
|
$results['failed'][] = ['TestMapID' => $id, 'error' => $e->getMessage()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->transComplete();
|
$this->db->transComplete();
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => empty($results['failed']) ? 'success' : 'partial',
|
'status' => empty($results['failed']) ? 'success' : 'partial',
|
||||||
'message' => 'Batch delete completed',
|
'message' => 'Batch delete completed',
|
||||||
'data' => $results
|
'data' => $results
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,253 +1,253 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers\Test;
|
namespace App\Controllers\Test;
|
||||||
|
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Models\Test\TestMapDetailModel;
|
use App\Models\Test\TestMapDetailModel;
|
||||||
|
|
||||||
class TestMapDetailController extends BaseController {
|
class TestMapDetailController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $rules;
|
protected $rules;
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->model = new TestMapDetailModel;
|
$this->model = new TestMapDetailModel;
|
||||||
$this->rules = [
|
$this->rules = [
|
||||||
'TestMapID' => 'required|integer',
|
'TestMapID' => 'required|integer',
|
||||||
'HostTestCode' => 'permit_empty|max_length[10]',
|
'HostTestCode' => 'permit_empty|max_length[10]',
|
||||||
'HostTestName' => 'permit_empty|max_length[100]',
|
'HostTestName' => 'permit_empty|max_length[100]',
|
||||||
'ConDefID' => 'permit_empty|integer',
|
'ConDefID' => 'permit_empty|integer',
|
||||||
'ClientTestCode' => 'permit_empty|max_length[10]',
|
'ClientTestCode' => 'permit_empty|max_length[10]',
|
||||||
'ClientTestName' => 'permit_empty|max_length[100]',
|
'ClientTestName' => 'permit_empty|max_length[100]',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$testMapID = $this->request->getGet('TestMapID');
|
$testMapID = $this->request->getGet('TestMapID');
|
||||||
|
|
||||||
if ($testMapID) {
|
if ($testMapID) {
|
||||||
$rows = $this->model->getDetailsByTestMap($testMapID);
|
$rows = $this->model->getDetailsByTestMap($testMapID);
|
||||||
} else {
|
} else {
|
||||||
$rows = $this->model->where('EndDate', null)->findAll();
|
$rows = $this->model->where('EndDate', null)->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id = null) {
|
public function show($id = null) {
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
return $this->failValidationErrors('TestMapDetailID is required.');
|
return $this->failValidationErrors('TestMapDetailID is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = $this->model->where('TestMapDetailID', $id)->where('EndDate', null)->first();
|
$row = $this->model->where('TestMapDetailID', $id)->where('EndDate', null)->first();
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $row ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $row ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showByTestMap($testMapID = null) {
|
public function showByTestMap($testMapID = null) {
|
||||||
if (!$testMapID) {
|
if (!$testMapID) {
|
||||||
return $this->failValidationErrors('TestMapID is required.');
|
return $this->failValidationErrors('TestMapID is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = $this->model->getDetailsByTestMap($testMapID);
|
$rows = $this->model->getDetailsByTestMap($testMapID);
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
|
|
||||||
if (!$this->validateData($input, $this->rules)) {
|
if (!$this->validateData($input, $this->rules)) {
|
||||||
return $this->failValidationErrors($this->validator->getErrors());
|
return $this->failValidationErrors($this->validator->getErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$id = $this->model->insert($input);
|
$id = $this->model->insert($input);
|
||||||
return $this->respondCreated([
|
return $this->respondCreated([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => "data created successfully",
|
'message' => "data created successfully",
|
||||||
'data' => $id
|
'data' => $id
|
||||||
]);
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$id = $input["TestMapDetailID"] ?? null;
|
$id = $input["TestMapDetailID"] ?? null;
|
||||||
|
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
return $this->failValidationErrors('TestMapDetailID is required.');
|
return $this->failValidationErrors('TestMapDetailID is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->validateData($input, $this->rules)) {
|
if (!$this->validateData($input, $this->rules)) {
|
||||||
return $this->failValidationErrors($this->validator->getErrors());
|
return $this->failValidationErrors($this->validator->getErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->model->update($id, $input);
|
$this->model->update($id, $input);
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => "data updated successfully",
|
'message' => "data updated successfully",
|
||||||
'data' => $id
|
'data' => $id
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
$id = $input["TestMapDetailID"] ?? null;
|
$id = $input["TestMapDetailID"] ?? null;
|
||||||
|
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
return $this->failValidationErrors('TestMapDetailID is required.');
|
return $this->failValidationErrors('TestMapDetailID is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$row = $this->model->where('TestMapDetailID', $id)->where('EndDate', null)->first();
|
$row = $this->model->where('TestMapDetailID', $id)->where('EndDate', null)->first();
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => "Data not found or already deleted.",
|
'message' => "Data not found or already deleted.",
|
||||||
'data' => null
|
'data' => null
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->model->update($id, ['EndDate' => date('Y-m-d H:i:s')]);
|
$this->model->update($id, ['EndDate' => date('Y-m-d H:i:s')]);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => "data deleted successfully",
|
'message' => "data deleted successfully",
|
||||||
'data' => $id
|
'data' => $id
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function batchCreate() {
|
public function batchCreate() {
|
||||||
$items = $this->request->getJSON(true);
|
$items = $this->request->getJSON(true);
|
||||||
|
|
||||||
if (!is_array($items)) {
|
if (!is_array($items)) {
|
||||||
return $this->failValidationErrors('Expected array of items');
|
return $this->failValidationErrors('Expected array of items');
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = ['success' => [], 'failed' => []];
|
$results = ['success' => [], 'failed' => []];
|
||||||
$this->db->transStart();
|
$this->db->transStart();
|
||||||
|
|
||||||
foreach ($items as $index => $item) {
|
foreach ($items as $index => $item) {
|
||||||
if (!$this->validateData($item, $this->rules)) {
|
if (!$this->validateData($item, $this->rules)) {
|
||||||
$results['failed'][] = ['index' => $index, 'errors' => $this->validator->getErrors()];
|
$results['failed'][] = ['index' => $index, 'errors' => $this->validator->getErrors()];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$id = $this->model->insert($item);
|
$id = $this->model->insert($item);
|
||||||
$results['success'][] = ['index' => $index, 'TestMapDetailID' => $id];
|
$results['success'][] = ['index' => $index, 'TestMapDetailID' => $id];
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$results['failed'][] = ['index' => $index, 'error' => $e->getMessage()];
|
$results['failed'][] = ['index' => $index, 'error' => $e->getMessage()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->transComplete();
|
$this->db->transComplete();
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => empty($results['failed']) ? 'success' : 'partial',
|
'status' => empty($results['failed']) ? 'success' : 'partial',
|
||||||
'message' => 'Batch create completed',
|
'message' => 'Batch create completed',
|
||||||
'data' => $results
|
'data' => $results
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function batchUpdate() {
|
public function batchUpdate() {
|
||||||
$items = $this->request->getJSON(true);
|
$items = $this->request->getJSON(true);
|
||||||
|
|
||||||
if (!is_array($items)) {
|
if (!is_array($items)) {
|
||||||
return $this->failValidationErrors('Expected array of items');
|
return $this->failValidationErrors('Expected array of items');
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = ['success' => [], 'failed' => []];
|
$results = ['success' => [], 'failed' => []];
|
||||||
$this->db->transStart();
|
$this->db->transStart();
|
||||||
|
|
||||||
foreach ($items as $index => $item) {
|
foreach ($items as $index => $item) {
|
||||||
$id = $item['TestMapDetailID'] ?? null;
|
$id = $item['TestMapDetailID'] ?? null;
|
||||||
|
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
$results['failed'][] = ['index' => $index, 'error' => 'TestMapDetailID required'];
|
$results['failed'][] = ['index' => $index, 'error' => 'TestMapDetailID required'];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->validateData($item, $this->rules)) {
|
if (!$this->validateData($item, $this->rules)) {
|
||||||
$results['failed'][] = ['index' => $index, 'errors' => $this->validator->getErrors()];
|
$results['failed'][] = ['index' => $index, 'errors' => $this->validator->getErrors()];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->model->update($id, $item);
|
$this->model->update($id, $item);
|
||||||
$results['success'][] = ['index' => $index, 'TestMapDetailID' => $id];
|
$results['success'][] = ['index' => $index, 'TestMapDetailID' => $id];
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$results['failed'][] = ['index' => $index, 'error' => $e->getMessage()];
|
$results['failed'][] = ['index' => $index, 'error' => $e->getMessage()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->transComplete();
|
$this->db->transComplete();
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => empty($results['failed']) ? 'success' : 'partial',
|
'status' => empty($results['failed']) ? 'success' : 'partial',
|
||||||
'message' => 'Batch update completed',
|
'message' => 'Batch update completed',
|
||||||
'data' => $results
|
'data' => $results
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function batchDelete() {
|
public function batchDelete() {
|
||||||
$ids = $this->request->getJSON(true);
|
$ids = $this->request->getJSON(true);
|
||||||
|
|
||||||
if (!is_array($ids)) {
|
if (!is_array($ids)) {
|
||||||
return $this->failValidationErrors('Expected array of TestMapDetailIDs');
|
return $this->failValidationErrors('Expected array of TestMapDetailIDs');
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = ['success' => [], 'failed' => []];
|
$results = ['success' => [], 'failed' => []];
|
||||||
$this->db->transStart();
|
$this->db->transStart();
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
try {
|
try {
|
||||||
$row = $this->model->where('TestMapDetailID', $id)->where('EndDate', null)->first();
|
$row = $this->model->where('TestMapDetailID', $id)->where('EndDate', null)->first();
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
$results['failed'][] = ['TestMapDetailID' => $id, 'error' => 'Not found or already deleted'];
|
$results['failed'][] = ['TestMapDetailID' => $id, 'error' => 'Not found or already deleted'];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->model->update($id, ['EndDate' => date('Y-m-d H:i:s')]);
|
$this->model->update($id, ['EndDate' => date('Y-m-d H:i:s')]);
|
||||||
$results['success'][] = $id;
|
$results['success'][] = $id;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$results['failed'][] = ['TestMapDetailID' => $id, 'error' => $e->getMessage()];
|
$results['failed'][] = ['TestMapDetailID' => $id, 'error' => $e->getMessage()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->transComplete();
|
$this->db->transComplete();
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => empty($results['failed']) ? 'success' : 'partial',
|
'status' => empty($results['failed']) ? 'success' : 'partial',
|
||||||
'message' => 'Batch delete completed',
|
'message' => 'Batch delete completed',
|
||||||
'data' => $results
|
'data' => $results
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,195 +1,195 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Libraries\ValueSet;
|
use App\Libraries\ValueSet;
|
||||||
use App\Models\ValueSet\ValueSetModel;
|
use App\Models\ValueSet\ValueSetModel;
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
|
|
||||||
class ValueSetController extends \CodeIgniter\Controller
|
class ValueSetController extends \CodeIgniter\Controller
|
||||||
{
|
{
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $dbModel;
|
protected $dbModel;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->dbModel = new ValueSetModel();
|
$this->dbModel = new ValueSetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(?string $lookupName = null)
|
public function index(?string $lookupName = null)
|
||||||
{
|
{
|
||||||
$search = $this->request->getGet('search') ?? null;
|
$search = $this->request->getGet('search') ?? null;
|
||||||
|
|
||||||
if ($lookupName === null) {
|
if ($lookupName === null) {
|
||||||
$all = ValueSet::getAll();
|
$all = ValueSet::getAll();
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($all as $name => $entry) {
|
foreach ($all as $name => $entry) {
|
||||||
if ($search) {
|
if ($search) {
|
||||||
$nameLower = strtolower($name);
|
$nameLower = strtolower($name);
|
||||||
$labelLower = strtolower($entry['VSName'] ?? '');
|
$labelLower = strtolower($entry['VSName'] ?? '');
|
||||||
$searchLower = strtolower($search);
|
$searchLower = strtolower($search);
|
||||||
if (strpos($nameLower, $searchLower) === false && strpos($labelLower, $searchLower) === false) {
|
if (strpos($nameLower, $searchLower) === false && strpos($labelLower, $searchLower) === false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$count = count($entry['values'] ?? []);
|
$count = count($entry['values'] ?? []);
|
||||||
$result[] = [
|
$result[] = [
|
||||||
'value' => $name,
|
'value' => $name,
|
||||||
'label' => $entry['VSName'] ?? '',
|
'label' => $entry['VSName'] ?? '',
|
||||||
'count' => $count
|
'count' => $count
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'data' => $result
|
'data' => $result
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = ValueSet::get($lookupName);
|
$data = ValueSet::get($lookupName);
|
||||||
if (!$data) {
|
if (!$data) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => "ValueSet '$lookupName' not found"
|
'message' => "ValueSet '$lookupName' not found"
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'data' => $data
|
'data' => $data
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function refresh()
|
public function refresh()
|
||||||
{
|
{
|
||||||
ValueSet::clearCache();
|
ValueSet::clearCache();
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Cache cleared'
|
'message' => 'Cache cleared'
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function items()
|
public function items()
|
||||||
{
|
{
|
||||||
$search = $this->request->getGet('search') ?? $this->request->getGet('param') ?? null;
|
$search = $this->request->getGet('search') ?? $this->request->getGet('param') ?? null;
|
||||||
$VSetID = $this->request->getGet('VSetID') ?? null;
|
$VSetID = $this->request->getGet('VSetID') ?? null;
|
||||||
|
|
||||||
$rows = $this->dbModel->getValueSets($search, $VSetID);
|
$rows = $this->dbModel->getValueSets($search, $VSetID);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'data' => $rows
|
'data' => $rows
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showItem($id = null)
|
public function showItem($id = null)
|
||||||
{
|
{
|
||||||
$row = $this->dbModel->getValueSet($id);
|
$row = $this->dbModel->getValueSet($id);
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
return $this->failNotFound("ValueSet item not found: $id");
|
return $this->failNotFound("ValueSet item not found: $id");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'data' => $row
|
'data' => $row
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createItem()
|
public function createItem()
|
||||||
{
|
{
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$input) {
|
if (!$input) {
|
||||||
return $this->failValidationErrors(['Invalid JSON input']);
|
return $this->failValidationErrors(['Invalid JSON input']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'SiteID' => $input['SiteID'] ?? 1,
|
'SiteID' => $input['SiteID'] ?? 1,
|
||||||
'VSetID' => $input['VSetID'] ?? null,
|
'VSetID' => $input['VSetID'] ?? null,
|
||||||
'VOrder' => $input['VOrder'] ?? 0,
|
'VOrder' => $input['VOrder'] ?? 0,
|
||||||
'VValue' => $input['VValue'] ?? '',
|
'VValue' => $input['VValue'] ?? '',
|
||||||
'VDesc' => $input['VDesc'] ?? ''
|
'VDesc' => $input['VDesc'] ?? ''
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($data['VSetID'] === null) {
|
if ($data['VSetID'] === null) {
|
||||||
return $this->failValidationErrors(['VSetID is required']);
|
return $this->failValidationErrors(['VSetID is required']);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$id = $this->dbModel->insert($data, true);
|
$id = $this->dbModel->insert($data, true);
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
return $this->failValidationErrors($this->dbModel->errors());
|
return $this->failValidationErrors($this->dbModel->errors());
|
||||||
}
|
}
|
||||||
|
|
||||||
$newRow = $this->dbModel->getValueSet($id);
|
$newRow = $this->dbModel->getValueSet($id);
|
||||||
return $this->respondCreated([
|
return $this->respondCreated([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'ValueSet item created',
|
'message' => 'ValueSet item created',
|
||||||
'data' => $newRow
|
'data' => $newRow
|
||||||
]);
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Failed to create: ' . $e->getMessage());
|
return $this->failServerError('Failed to create: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateItem($id = null)
|
public function updateItem($id = null)
|
||||||
{
|
{
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$input) {
|
if (!$input) {
|
||||||
return $this->failValidationErrors(['Invalid JSON input']);
|
return $this->failValidationErrors(['Invalid JSON input']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$existing = $this->dbModel->getValueSet($id);
|
$existing = $this->dbModel->getValueSet($id);
|
||||||
if (!$existing) {
|
if (!$existing) {
|
||||||
return $this->failNotFound("ValueSet item not found: $id");
|
return $this->failNotFound("ValueSet item not found: $id");
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
if (isset($input['VSetID'])) $data['VSetID'] = $input['VSetID'];
|
if (isset($input['VSetID'])) $data['VSetID'] = $input['VSetID'];
|
||||||
if (isset($input['VOrder'])) $data['VOrder'] = $input['VOrder'];
|
if (isset($input['VOrder'])) $data['VOrder'] = $input['VOrder'];
|
||||||
if (isset($input['VValue'])) $data['VValue'] = $input['VValue'];
|
if (isset($input['VValue'])) $data['VValue'] = $input['VValue'];
|
||||||
if (isset($input['VDesc'])) $data['VDesc'] = $input['VDesc'];
|
if (isset($input['VDesc'])) $data['VDesc'] = $input['VDesc'];
|
||||||
if (isset($input['SiteID'])) $data['SiteID'] = $input['SiteID'];
|
if (isset($input['SiteID'])) $data['SiteID'] = $input['SiteID'];
|
||||||
|
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'No changes to update',
|
'message' => 'No changes to update',
|
||||||
'data' => $existing
|
'data' => $existing
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$updated = $this->dbModel->update($id, $data);
|
$updated = $this->dbModel->update($id, $data);
|
||||||
if (!$updated) {
|
if (!$updated) {
|
||||||
return $this->failValidationErrors($this->dbModel->errors());
|
return $this->failValidationErrors($this->dbModel->errors());
|
||||||
}
|
}
|
||||||
|
|
||||||
$newRow = $this->dbModel->getValueSet($id);
|
$newRow = $this->dbModel->getValueSet($id);
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'ValueSet item updated',
|
'message' => 'ValueSet item updated',
|
||||||
'data' => $newRow
|
'data' => $newRow
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Failed to update: ' . $e->getMessage());
|
return $this->failServerError('Failed to update: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteItem($id = null)
|
public function deleteItem($id = null)
|
||||||
{
|
{
|
||||||
$existing = $this->dbModel->getValueSet($id);
|
$existing = $this->dbModel->getValueSet($id);
|
||||||
if (!$existing) {
|
if (!$existing) {
|
||||||
return $this->failNotFound("ValueSet item not found: $id");
|
return $this->failNotFound("ValueSet item not found: $id");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->dbModel->delete($id);
|
$this->dbModel->delete($id);
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'ValueSet item deleted'
|
'message' => 'ValueSet item deleted'
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Failed to delete: ' . $e->getMessage());
|
return $this->failServerError('Failed to delete: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,152 +1,152 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Models\ValueSet\ValueSetDefModel;
|
use App\Models\ValueSet\ValueSetDefModel;
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
|
|
||||||
class ValueSetDefController extends \CodeIgniter\Controller
|
class ValueSetDefController extends \CodeIgniter\Controller
|
||||||
{
|
{
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->model = new ValueSetDefModel();
|
$this->model = new ValueSetDefModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$search = $this->request->getGet('search') ?? null;
|
$search = $this->request->getGet('search') ?? null;
|
||||||
$limit = (int) ($this->request->getGet('limit') ?? 100);
|
$limit = (int) ($this->request->getGet('limit') ?? 100);
|
||||||
$page = (int) ($this->request->getGet('page') ?? 1);
|
$page = (int) ($this->request->getGet('page') ?? 1);
|
||||||
$offset = ($page - 1) * $limit;
|
$offset = ($page - 1) * $limit;
|
||||||
|
|
||||||
$rows = $this->model->getValueSetDefs($search);
|
$rows = $this->model->getValueSetDefs($search);
|
||||||
|
|
||||||
$paged = array_slice($rows, $offset, $limit);
|
$paged = array_slice($rows, $offset, $limit);
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'data' => $paged,
|
'data' => $paged,
|
||||||
'meta' => [
|
'meta' => [
|
||||||
'total' => count($rows),
|
'total' => count($rows),
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
'limit' => $limit
|
'limit' => $limit
|
||||||
]
|
]
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id = null)
|
public function show($id = null)
|
||||||
{
|
{
|
||||||
$row = $this->model->find($id);
|
$row = $this->model->find($id);
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
return $this->failNotFound("ValueSet definition not found: $id");
|
return $this->failNotFound("ValueSet definition not found: $id");
|
||||||
}
|
}
|
||||||
|
|
||||||
$itemCount = $this->model->db->table('valueset')
|
$itemCount = $this->model->db->table('valueset')
|
||||||
->select('COUNT(*) as ItemCount')
|
->select('COUNT(*) as ItemCount')
|
||||||
->where('VSetID', $id)
|
->where('VSetID', $id)
|
||||||
->where('EndDate IS NULL')
|
->where('EndDate IS NULL')
|
||||||
->get()
|
->get()
|
||||||
->getRowArray()['ItemCount'] ?? 0;
|
->getRowArray()['ItemCount'] ?? 0;
|
||||||
|
|
||||||
$row['ItemCount'] = (int) $itemCount;
|
$row['ItemCount'] = (int) $itemCount;
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'data' => $row
|
'data' => $row
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$input) {
|
if (!$input) {
|
||||||
return $this->failValidationErrors(['Invalid JSON input']);
|
return $this->failValidationErrors(['Invalid JSON input']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'SiteID' => $input['SiteID'] ?? 1,
|
'SiteID' => $input['SiteID'] ?? 1,
|
||||||
'VSName' => $input['VSName'] ?? '',
|
'VSName' => $input['VSName'] ?? '',
|
||||||
'VSDesc' => $input['VSDesc'] ?? ''
|
'VSDesc' => $input['VSDesc'] ?? ''
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$id = $this->model->insert($data, true);
|
$id = $this->model->insert($data, true);
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
return $this->failValidationErrors($this->model->errors());
|
return $this->failValidationErrors($this->model->errors());
|
||||||
}
|
}
|
||||||
|
|
||||||
$newRow = $this->model->find($id);
|
$newRow = $this->model->find($id);
|
||||||
return $this->respondCreated([
|
return $this->respondCreated([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'ValueSet definition created',
|
'message' => 'ValueSet definition created',
|
||||||
'data' => $newRow
|
'data' => $newRow
|
||||||
]);
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Failed to create: ' . $e->getMessage());
|
return $this->failServerError('Failed to create: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($id = null)
|
public function update($id = null)
|
||||||
{
|
{
|
||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$input) {
|
if (!$input) {
|
||||||
return $this->failValidationErrors(['Invalid JSON input']);
|
return $this->failValidationErrors(['Invalid JSON input']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$existing = $this->model->find($id);
|
$existing = $this->model->find($id);
|
||||||
if (!$existing) {
|
if (!$existing) {
|
||||||
return $this->failNotFound("ValueSet definition not found: $id");
|
return $this->failNotFound("ValueSet definition not found: $id");
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
if (isset($input['VSName'])) $data['VSName'] = $input['VSName'];
|
if (isset($input['VSName'])) $data['VSName'] = $input['VSName'];
|
||||||
if (isset($input['VSDesc'])) $data['VSDesc'] = $input['VSDesc'];
|
if (isset($input['VSDesc'])) $data['VSDesc'] = $input['VSDesc'];
|
||||||
if (isset($input['SiteID'])) $data['SiteID'] = $input['SiteID'];
|
if (isset($input['SiteID'])) $data['SiteID'] = $input['SiteID'];
|
||||||
|
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'No changes to update',
|
'message' => 'No changes to update',
|
||||||
'data' => $existing
|
'data' => $existing
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$updated = $this->model->update($id, $data);
|
$updated = $this->model->update($id, $data);
|
||||||
if (!$updated) {
|
if (!$updated) {
|
||||||
return $this->failValidationErrors($this->model->errors());
|
return $this->failValidationErrors($this->model->errors());
|
||||||
}
|
}
|
||||||
|
|
||||||
$newRow = $this->model->find($id);
|
$newRow = $this->model->find($id);
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'ValueSet definition updated',
|
'message' => 'ValueSet definition updated',
|
||||||
'data' => $newRow
|
'data' => $newRow
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Failed to update: ' . $e->getMessage());
|
return $this->failServerError('Failed to update: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id = null)
|
public function delete($id = null)
|
||||||
{
|
{
|
||||||
$existing = $this->model->find($id);
|
$existing = $this->model->find($id);
|
||||||
if (!$existing) {
|
if (!$existing) {
|
||||||
return $this->failNotFound("ValueSet definition not found: $id");
|
return $this->failNotFound("ValueSet definition not found: $id");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->model->delete($id);
|
$this->model->delete($id);
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'ValueSet definition deleted'
|
'message' => 'ValueSet definition deleted'
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->failServerError('Failed to delete: ' . $e->getMessage());
|
return $this->failServerError('Failed to delete: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,95 +1,95 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Traits\ResponseTrait;
|
use App\Traits\ResponseTrait;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Models\SyncCRM\ZonesModel;
|
use App\Models\SyncCRM\ZonesModel;
|
||||||
|
|
||||||
class ZonesController extends BaseController {
|
class ZonesController extends BaseController {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->model = new ZonesModel();
|
$this->model = new ZonesModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
try {
|
try {
|
||||||
$rows = $this->model->getZones();
|
$rows = $this->model->getZones();
|
||||||
|
|
||||||
if(empty($rows)){return $this->respond(['status'=>'success', 'message'=>"no data found.", 'data'=>$rows], 200);}
|
if(empty($rows)){return $this->respond(['status'=>'success', 'message'=>"no data found.", 'data'=>$rows], 200);}
|
||||||
return $this->respond(['status'=>'success', 'message'=>"data fetched successfully", 'data'=>$rows], 200);
|
return $this->respond(['status'=>'success', 'message'=>"data fetched successfully", 'data'=>$rows], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->respond([ 'status' => 'error', 'message' => $e->getMessage() ], 200);
|
return $this->respond([ 'status' => 'error', 'message' => $e->getMessage() ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProvinces() {
|
public function getProvinces() {
|
||||||
$filters = [
|
$filters = [
|
||||||
'zoneid' => $this->request->getVar('zoneid') ?? null,
|
'zoneid' => $this->request->getVar('zoneid') ?? null,
|
||||||
'zonename' => $this->request->getVar('zonename') ?? null
|
'zonename' => $this->request->getVar('zonename') ?? null
|
||||||
];
|
];
|
||||||
|
|
||||||
$rows = $this->model->getProvinces();
|
$rows = $this->model->getProvinces();
|
||||||
|
|
||||||
if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => [] ], 200); }
|
if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => [] ], 200); }
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCities() {
|
public function getCities() {
|
||||||
$filter = [
|
$filter = [
|
||||||
'zoneid' => $this->request->getVar('zoneid') ?? null
|
'zoneid' => $this->request->getVar('zoneid') ?? null
|
||||||
];
|
];
|
||||||
|
|
||||||
$rows = $this->model->getCities($filter);
|
$rows = $this->model->getCities($filter);
|
||||||
|
|
||||||
if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => [] ], 200); }
|
if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => [] ], 200); }
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function synchronize() {
|
public function synchronize() {
|
||||||
$client = \Config\Services::curlrequest([
|
$client = \Config\Services::curlrequest([
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'User-Agent' => 'Mozilla/5.0 (CI4 cURL Request)',
|
'User-Agent' => 'Mozilla/5.0 (CI4 cURL Request)',
|
||||||
'Accept' => 'application/json',
|
'Accept' => 'application/json',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Ambil data dari API pusat (CRM)
|
// Ambil data dari API pusat (CRM)
|
||||||
$response = $client->get('http://services-summit.my.id/api/zones'); // Prod
|
$response = $client->get('http://services-summit.my.id/api/zones'); // Prod
|
||||||
// $response = $client->get('https://services-summit.my.id/api/zones'); // Dev
|
// $response = $client->get('https://services-summit.my.id/api/zones'); // Dev
|
||||||
$result = json_decode($response->getBody(), true);
|
$result = json_decode($response->getBody(), true);
|
||||||
|
|
||||||
if (!isset($result['data']) || !is_array($result['data'])) {
|
if (!isset($result['data']) || !is_array($result['data'])) {
|
||||||
return $this->response->setJSON([
|
return $this->response->setJSON([
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => 'Invalid or empty response from CRM API'
|
'message' => 'Invalid or empty response from CRM API'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$record = $this->model->synchronize($result['data']);
|
$record = $this->model->synchronize($result['data']);
|
||||||
|
|
||||||
return $this->response->setJSON([
|
return $this->response->setJSON([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Zones synchronized successfully',
|
'message' => 'Zones synchronized successfully',
|
||||||
'summary' => [
|
'summary' => [
|
||||||
'inserted' => $record['inserted'],
|
'inserted' => $record['inserted'],
|
||||||
'updated' => $record['updated'],
|
'updated' => $record['updated'],
|
||||||
'deleted' => $record['deleted'],
|
'deleted' => $record['deleted'],
|
||||||
'skipped' => $record['skipped']
|
'skipped' => $record['skipped']
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->response->setJSON([
|
return $this->response->setJSON([
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => $e->getMessage()
|
'message' => $e->getMessage()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,105 +1,105 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
use CodeIgniter\Database\Migration;
|
||||||
|
|
||||||
class CreateLookups extends Migration {
|
class CreateLookups extends Migration {
|
||||||
public function up() {
|
public function up() {
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'VID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
'VID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
||||||
'SiteID' => ['type' => 'INT', 'null' => true],
|
'SiteID' => ['type' => 'INT', 'null' => true],
|
||||||
'VSetID' => ['type' => 'INT', 'null' => true],
|
'VSetID' => ['type' => 'INT', 'null' => true],
|
||||||
'VOrder' => ['type' => 'INT', 'null' => true],
|
'VOrder' => ['type' => 'INT', 'null' => true],
|
||||||
'VValue' => ['type' => 'varchar', 'constraint' => 10],
|
'VValue' => ['type' => 'varchar', 'constraint' => 10],
|
||||||
'VDesc' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
'VDesc' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
||||||
'VCategory' => ['type' => 'int', 'null' => true],
|
'VCategory' => ['type' => 'int', 'null' => true],
|
||||||
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('VID', true);
|
$this->forge->addKey('VID', true);
|
||||||
$this->forge->createTable('valueset');
|
$this->forge->createTable('valueset');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'VSetID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
'VSetID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
||||||
'SiteID' => ['type' => 'INT', 'null' => true],
|
'SiteID' => ['type' => 'INT', 'null' => true],
|
||||||
'VSName' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
|
'VSName' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
|
||||||
'VSDesc' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
|
'VSDesc' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
|
||||||
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('VSetID', true);
|
$this->forge->addKey('VSetID', true);
|
||||||
$this->forge->createTable('valuesetdef');
|
$this->forge->createTable('valuesetdef');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'CounterID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
'CounterID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
||||||
'CounterValue' => ['type' => 'INT', 'null' => false],
|
'CounterValue' => ['type' => 'INT', 'null' => false],
|
||||||
'CounterStart' => ['type' => 'INT', 'null' => false],
|
'CounterStart' => ['type' => 'INT', 'null' => false],
|
||||||
'CounterEnd' => ['type' => 'INT', 'null' => false],
|
'CounterEnd' => ['type' => 'INT', 'null' => false],
|
||||||
'CounterName' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true, 'after' => 'CounterID' ],
|
'CounterName' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true, 'after' => 'CounterID' ],
|
||||||
'CounterDesc' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
'CounterDesc' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
||||||
'CounterReset' => ['type' => 'varchar', 'constraint' => 1, 'null' => true],
|
'CounterReset' => ['type' => 'varchar', 'constraint' => 1, 'null' => true],
|
||||||
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('CounterID', true);
|
$this->forge->addKey('CounterID', true);
|
||||||
$this->forge->createTable('counter');
|
$this->forge->createTable('counter');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'ConDefID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
'ConDefID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
||||||
'SiteID' => ['type' => 'INT', 'null' => true],
|
'SiteID' => ['type' => 'INT', 'null' => true],
|
||||||
'ConCode' => ['type' => 'VARCHAR', 'constraint' => 3, 'null' => false],
|
'ConCode' => ['type' => 'VARCHAR', 'constraint' => 3, 'null' => false],
|
||||||
'ConName' => ['type' => 'varchar', 'constraint' => 50, 'null' => true],
|
'ConName' => ['type' => 'varchar', 'constraint' => 50, 'null' => true],
|
||||||
'ConDesc' => ['type' => 'varchar', 'constraint' => 50, 'null' => true],
|
'ConDesc' => ['type' => 'varchar', 'constraint' => 50, 'null' => true],
|
||||||
'Additive' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'Additive' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'ConClass' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'ConClass' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'Color' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'Color' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('ConDefID', true);
|
$this->forge->addKey('ConDefID', true);
|
||||||
$this->forge->addUniqueKey('ConCode');
|
$this->forge->addUniqueKey('ConCode');
|
||||||
$this->forge->createTable('containerdef');
|
$this->forge->createTable('containerdef');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'OccupationID' => [ 'type' => 'INT', 'constraint' => 11, 'auto_increment' => true],
|
'OccupationID' => [ 'type' => 'INT', 'constraint' => 11, 'auto_increment' => true],
|
||||||
'OccCode' => [ 'type' => 'VARCHAR', 'constraint' => 5, 'null' => true ],
|
'OccCode' => [ 'type' => 'VARCHAR', 'constraint' => 5, 'null' => true ],
|
||||||
'OccText' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true ],
|
'OccText' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true ],
|
||||||
'Description' => [ 'type' => 'TEXT', 'null' => true ],
|
'Description' => [ 'type' => 'TEXT', 'null' => true ],
|
||||||
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('OccupationID', true);
|
$this->forge->addKey('OccupationID', true);
|
||||||
$this->forge->createTable('occupation');
|
$this->forge->createTable('occupation');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'SpecialtyID' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
'SpecialtyID' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
||||||
'SpecialtyText' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
'SpecialtyText' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
||||||
'Parent' => ['type' => 'int', 'null' => true],
|
'Parent' => ['type' => 'int', 'null' => true],
|
||||||
'Title' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false],
|
'Title' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false],
|
||||||
'CreateDate' => ['type' => 'datetime', 'null' => true],
|
'CreateDate' => ['type' => 'datetime', 'null' => true],
|
||||||
'EndDate' => ['type' => 'datetime', 'null' => true],
|
'EndDate' => ['type' => 'datetime', 'null' => true],
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('SpecialtyID', true);
|
$this->forge->addKey('SpecialtyID', true);
|
||||||
$this->forge->createTable('medicalspecialty');
|
$this->forge->createTable('medicalspecialty');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'AreaGeoID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
'AreaGeoID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
||||||
'AreaCode' => ['type' => 'varchar', 'constraint' => 20, 'null' => true],
|
'AreaCode' => ['type' => 'varchar', 'constraint' => 20, 'null' => true],
|
||||||
'Class' => ['type' => 'int', 'null' => true],
|
'Class' => ['type' => 'int', 'null' => true],
|
||||||
'AreaName' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false],
|
'AreaName' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false],
|
||||||
'Parent' => ['type' => 'int', 'null' => true],
|
'Parent' => ['type' => 'int', 'null' => true],
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('AreaGeoID', true);
|
$this->forge->addKey('AreaGeoID', true);
|
||||||
$this->forge->createTable('areageo');
|
$this->forge->createTable('areageo');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down() {
|
public function down() {
|
||||||
$this->forge->dropTable('areageo');
|
$this->forge->dropTable('areageo');
|
||||||
$this->forge->dropTable('medicalspecialty');
|
$this->forge->dropTable('medicalspecialty');
|
||||||
$this->forge->dropTable('occupation');
|
$this->forge->dropTable('occupation');
|
||||||
$this->forge->dropTable('containerdef');
|
$this->forge->dropTable('containerdef');
|
||||||
$this->forge->dropTable('counter');
|
$this->forge->dropTable('counter');
|
||||||
$this->forge->dropTable('valuesetdef');
|
$this->forge->dropTable('valuesetdef');
|
||||||
$this->forge->dropTable('valueset');
|
$this->forge->dropTable('valueset');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,129 +1,129 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
use CodeIgniter\Database\Migration;
|
||||||
|
|
||||||
class CreateOrganization extends Migration {
|
class CreateOrganization extends Migration {
|
||||||
public function up() {
|
public function up() {
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'AccountID' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
'AccountID' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
||||||
'Parent' => ['type' => 'INT', 'null' => true],
|
'Parent' => ['type' => 'INT', 'null' => true],
|
||||||
'AccountName' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false],
|
'AccountName' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false],
|
||||||
'Initial' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => false],
|
'Initial' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => false],
|
||||||
'Street_1' => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
|
'Street_1' => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
|
||||||
'Street_2' => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
|
'Street_2' => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
|
||||||
'Street_3' => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
|
'Street_3' => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
|
||||||
'City' => ['type' => 'varchar', 'constraint' => 150, 'null' => true],
|
'City' => ['type' => 'varchar', 'constraint' => 150, 'null' => true],
|
||||||
'Province' => ['type' => 'varchar', 'constraint' => 150, 'null' => true],
|
'Province' => ['type' => 'varchar', 'constraint' => 150, 'null' => true],
|
||||||
'ZIP' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'ZIP' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'Country' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'Country' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'AreaCode' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'AreaCode' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'EmailAddress1' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'EmailAddress1' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'EmailAddress2' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'EmailAddress2' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'Phone' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'Phone' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'Fax' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'Fax' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'CreateDate' => ['type' => 'datetime', 'null'=> true],
|
'CreateDate' => ['type' => 'datetime', 'null'=> true],
|
||||||
'EndDate' => ['type' => 'datetime', 'null'=> true]
|
'EndDate' => ['type' => 'datetime', 'null'=> true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('AccountID', true);
|
$this->forge->addKey('AccountID', true);
|
||||||
$this->forge->createTable('account');
|
$this->forge->createTable('account');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'SiteID' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
'SiteID' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
||||||
'ExtSiteID' => ['type' => 'int', 'null' => true],
|
'ExtSiteID' => ['type' => 'int', 'null' => true],
|
||||||
'SiteCode' => ['type' => 'VARCHAR', 'constraint' => 2, 'null' => false],
|
'SiteCode' => ['type' => 'VARCHAR', 'constraint' => 2, 'null' => false],
|
||||||
'SiteName' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false],
|
'SiteName' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false],
|
||||||
'AccountID' => ['type' => 'int', 'null' => true],
|
'AccountID' => ['type' => 'int', 'null' => true],
|
||||||
'SiteType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'SiteType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'Parent' => ['type' => 'int', 'null' => true],
|
'Parent' => ['type' => 'int', 'null' => true],
|
||||||
'SiteClass' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'SiteClass' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'ME' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'ME' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'CreateDate' => ['type' => 'datetime', 'null'=> true],
|
'CreateDate' => ['type' => 'datetime', 'null'=> true],
|
||||||
'EndDate' => ['type' => 'datetime', 'null'=> true]
|
'EndDate' => ['type' => 'datetime', 'null'=> true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('SiteID', true);
|
$this->forge->addKey('SiteID', true);
|
||||||
$this->forge->createTable('site');
|
$this->forge->createTable('site');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'LocationID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
'LocationID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
||||||
'SiteID' => ['type' => 'INT', 'null' => true],
|
'SiteID' => ['type' => 'INT', 'null' => true],
|
||||||
'LocCode' => ['type' => 'VARCHAR', 'constraint' => 6, 'null' => false],
|
'LocCode' => ['type' => 'VARCHAR', 'constraint' => 6, 'null' => false],
|
||||||
'Parent' => ['type' => 'INT', 'null' => true],
|
'Parent' => ['type' => 'INT', 'null' => true],
|
||||||
'LocFull' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
'LocFull' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
||||||
'Description' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
'Description' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
||||||
'LocType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'LocType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
||||||
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('LocationID', true);
|
$this->forge->addKey('LocationID', true);
|
||||||
$this->forge->createTable('location');
|
$this->forge->createTable('location');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'LocationID' => ['type' => 'INT', 'unsigned' => true],
|
'LocationID' => ['type' => 'INT', 'unsigned' => true],
|
||||||
'Street1' => ['type' => 'Varchar', 'constraint' => 255, 'null' => true],
|
'Street1' => ['type' => 'Varchar', 'constraint' => 255, 'null' => true],
|
||||||
'Street2' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
'Street2' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||||
'City' => ['type' => 'int', 'null' => true],
|
'City' => ['type' => 'int', 'null' => true],
|
||||||
'Province' => ['type' => 'int', 'null' => true],
|
'Province' => ['type' => 'int', 'null' => true],
|
||||||
'PostCode' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
'PostCode' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
||||||
'GeoLocationSystem' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
'GeoLocationSystem' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
||||||
'GeoLocationData' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
'GeoLocationData' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
||||||
'Phone' => ['type' => 'varchar', 'constraint' => 100, 'null' => true],
|
'Phone' => ['type' => 'varchar', 'constraint' => 100, 'null' => true],
|
||||||
'Email' => ['type' => 'varchar', 'constraint' => 150, 'null' => true],
|
'Email' => ['type' => 'varchar', 'constraint' => 150, 'null' => true],
|
||||||
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
||||||
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('LocationID', true);
|
$this->forge->addKey('LocationID', true);
|
||||||
$this->forge->createTable('locationaddress');
|
$this->forge->createTable('locationaddress');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'DisciplineID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
'DisciplineID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
||||||
'SiteID' => ['type' => 'int', 'null'=> false],
|
'SiteID' => ['type' => 'int', 'null'=> false],
|
||||||
'DisciplineCode' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> false],
|
'DisciplineCode' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> false],
|
||||||
'DisciplineName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
'DisciplineName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
||||||
'Parent' => ['type' => 'int', 'null'=> true],
|
'Parent' => ['type' => 'int', 'null'=> true],
|
||||||
'SeqScr' => ['type' => 'int', 'null' => true],
|
'SeqScr' => ['type' => 'int', 'null' => true],
|
||||||
'SeqRpt' => ['type' => 'int', 'null' => true],
|
'SeqRpt' => ['type' => 'int', 'null' => true],
|
||||||
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
||||||
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('DisciplineID', true);
|
$this->forge->addKey('DisciplineID', true);
|
||||||
$this->forge->createTable('discipline');
|
$this->forge->createTable('discipline');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'DepartmentID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
'DepartmentID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
||||||
'DisciplineID' => ['type' => 'int', 'null'=> false],
|
'DisciplineID' => ['type' => 'int', 'null'=> false],
|
||||||
'SiteID' => ['type' => 'int', 'null'=> false],
|
'SiteID' => ['type' => 'int', 'null'=> false],
|
||||||
'DepartmentCode' => ['type' => 'varchar', 'constraint'=>10, 'null'=> false],
|
'DepartmentCode' => ['type' => 'varchar', 'constraint'=>10, 'null'=> false],
|
||||||
'DepartmentName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
'DepartmentName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
||||||
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
||||||
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('DepartmentID', true);
|
$this->forge->addKey('DepartmentID', true);
|
||||||
$this->forge->createTable('department');
|
$this->forge->createTable('department');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'WorkstationID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
'WorkstationID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
||||||
'DepartmentID' => ['type' => 'int', 'null'=> false],
|
'DepartmentID' => ['type' => 'int', 'null'=> false],
|
||||||
'WorkstationCode' => ['type' => 'varchar', 'constraint'=>10, 'null'=> false],
|
'WorkstationCode' => ['type' => 'varchar', 'constraint'=>10, 'null'=> false],
|
||||||
'WorkstationName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
'WorkstationName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
||||||
'Type' => ['type' => 'VARCHAR', 'constraint' => 10, 'null'=> true],
|
'Type' => ['type' => 'VARCHAR', 'constraint' => 10, 'null'=> true],
|
||||||
'LinkTo' => ['type' => 'int', 'null'=> true],
|
'LinkTo' => ['type' => 'int', 'null'=> true],
|
||||||
'Enable' => ['type' => 'VARCHAR', 'constraint' => 10, 'null'=> true],
|
'Enable' => ['type' => 'VARCHAR', 'constraint' => 10, 'null'=> true],
|
||||||
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
||||||
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('WorkstationID', true);
|
$this->forge->addKey('WorkstationID', true);
|
||||||
$this->forge->createTable('workstation');
|
$this->forge->createTable('workstation');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down() {
|
public function down() {
|
||||||
$this->forge->dropTable('workstation');
|
$this->forge->dropTable('workstation');
|
||||||
$this->forge->dropTable('department');
|
$this->forge->dropTable('department');
|
||||||
$this->forge->dropTable('discipline');
|
$this->forge->dropTable('discipline');
|
||||||
$this->forge->dropTable('locationaddress');
|
$this->forge->dropTable('locationaddress');
|
||||||
$this->forge->dropTable('location');
|
$this->forge->dropTable('location');
|
||||||
$this->forge->dropTable('site');
|
$this->forge->dropTable('site');
|
||||||
$this->forge->dropTable('account');
|
$this->forge->dropTable('account');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,101 +1,101 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
use CodeIgniter\Database\Migration;
|
||||||
|
|
||||||
class CreateSecurity extends Migration {
|
class CreateSecurity extends Migration {
|
||||||
public function up() {
|
public function up() {
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'id' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
'id' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
||||||
'role_id' => ['type' => 'TINYINT', 'null' => false],
|
'role_id' => ['type' => 'TINYINT', 'null' => false],
|
||||||
'username' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'username' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'password' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
'password' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('id', true);
|
$this->forge->addKey('id', true);
|
||||||
$this->forge->createTable('users');
|
$this->forge->createTable('users');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'ContactID' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true ],
|
'ContactID' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true ],
|
||||||
'NameFirst' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
'NameFirst' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
||||||
'NameLast' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
'NameLast' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
||||||
'Title' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
'Title' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
||||||
'Initial' => [ 'type' => 'VARCHAR', 'constraint' => 10, 'null' => true ],
|
'Initial' => [ 'type' => 'VARCHAR', 'constraint' => 10, 'null' => true ],
|
||||||
'Birthdate' => [ 'type' => 'DATE', 'null' => true ],
|
'Birthdate' => [ 'type' => 'DATE', 'null' => true ],
|
||||||
'EmailAddress1' => [ 'type' => 'VARCHAR', 'constraint' => 150, 'null' => true ],
|
'EmailAddress1' => [ 'type' => 'VARCHAR', 'constraint' => 150, 'null' => true ],
|
||||||
'EmailAddress2' => [ 'type' => 'VARCHAR', 'constraint' => 150, 'null' => true ],
|
'EmailAddress2' => [ 'type' => 'VARCHAR', 'constraint' => 150, 'null' => true ],
|
||||||
'Phone' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
'Phone' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
||||||
'MobilePhone1' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
'MobilePhone1' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
||||||
'MobilePhone2' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
'MobilePhone2' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
||||||
'Specialty' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
'Specialty' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
||||||
'SubSpecialty' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
'SubSpecialty' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
||||||
'Password' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true ],
|
'Password' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true ],
|
||||||
'LockedAt' => [ 'type' => 'DATETIME', 'null' => true ],
|
'LockedAt' => [ 'type' => 'DATETIME', 'null' => true ],
|
||||||
'LockReason' => [ 'type' => 'VARCHAR', 'constraint' => 150, 'null' => true ],
|
'LockReason' => [ 'type' => 'VARCHAR', 'constraint' => 150, 'null' => true ],
|
||||||
'Role' => [ 'type' => "ENUM('admin','staff','user')", 'default' => 'user', 'null' => false ],
|
'Role' => [ 'type' => "ENUM('admin','staff','user')", 'default' => 'user', 'null' => false ],
|
||||||
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
||||||
'EndDate' => [ 'type' => 'DATETIME', 'null' => true ],
|
'EndDate' => [ 'type' => 'DATETIME', 'null' => true ],
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('ContactID', true);
|
$this->forge->addKey('ContactID', true);
|
||||||
$this->forge->addUniqueKey('EmailAddress1');
|
$this->forge->addUniqueKey('EmailAddress1');
|
||||||
$this->forge->createTable('contact');
|
$this->forge->createTable('contact');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'ContactDetID' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true ],
|
'ContactDetID' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true ],
|
||||||
'ContactID' => [ 'type' => 'INT', 'constraint' => 11 ],
|
'ContactID' => [ 'type' => 'INT', 'constraint' => 11 ],
|
||||||
'SiteID' => [ 'type' => 'INT', 'constraint' => 11, 'null' => true ],
|
'SiteID' => [ 'type' => 'INT', 'constraint' => 11, 'null' => true ],
|
||||||
'ContactCode' => [ 'type' => 'varchar', 'constraint' => 11, 'null' => false ],
|
'ContactCode' => [ 'type' => 'varchar', 'constraint' => 11, 'null' => false ],
|
||||||
'ContactEmail' => [ 'type' => 'VARCHAR', 'constraint' => 150, 'null' => true ],
|
'ContactEmail' => [ 'type' => 'VARCHAR', 'constraint' => 150, 'null' => true ],
|
||||||
'OccupationID' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
'OccupationID' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
||||||
'JobTitle' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
'JobTitle' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
||||||
'Department' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
'Department' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
||||||
'ContactStartDate' => [ 'type' => 'DATETIME', 'null' => true ],
|
'ContactStartDate' => [ 'type' => 'DATETIME', 'null' => true ],
|
||||||
'ContactEndDate' => [ 'type' => 'DATETIME ', 'null' => true ],
|
'ContactEndDate' => [ 'type' => 'DATETIME ', 'null' => true ],
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('ContactDetID', true);
|
$this->forge->addKey('ContactDetID', true);
|
||||||
$this->forge->addUniqueKey(['SiteID','ContactID']);
|
$this->forge->addUniqueKey(['SiteID','ContactID']);
|
||||||
$this->forge->createTable('contactdetail');
|
$this->forge->createTable('contactdetail');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'UserDeviceId' => ['type' => 'CHAR', 'constraint' => 36],
|
'UserDeviceId' => ['type' => 'CHAR', 'constraint' => 36],
|
||||||
'ContactID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
|
'ContactID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
|
||||||
'DeviceFingerprint' => ['type' => 'CHAR', 'constraint' => 64],
|
'DeviceFingerprint' => ['type' => 'CHAR', 'constraint' => 64],
|
||||||
'DeviceLabel' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
|
'DeviceLabel' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
|
||||||
'Browser' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'Browser' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'BrowserVersion' => ['type' => 'VARCHAR', 'constraint' => 20, 'null' => true],
|
'BrowserVersion' => ['type' => 'VARCHAR', 'constraint' => 20, 'null' => true],
|
||||||
'Platform' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'Platform' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
'Timezone' => ['type' => 'VARCHAR', 'constraint' => 50],
|
'Timezone' => ['type' => 'VARCHAR', 'constraint' => 50],
|
||||||
'Language' => ['type' => 'VARCHAR', 'constraint' => 10],
|
'Language' => ['type' => 'VARCHAR', 'constraint' => 10],
|
||||||
'IpAddress' => ['type' => 'VARCHAR', 'constraint' => 45],
|
'IpAddress' => ['type' => 'VARCHAR', 'constraint' => 45],
|
||||||
'FirstLoginAt' => ['type' => 'DATETIME'],
|
'FirstLoginAt' => ['type' => 'DATETIME'],
|
||||||
'LastLoginAt' => ['type' => 'DATETIME'],
|
'LastLoginAt' => ['type' => 'DATETIME'],
|
||||||
'IsActive' => ['type' => 'TINYINT', 'constraint' => 1, 'default' => 1],
|
'IsActive' => ['type' => 'TINYINT', 'constraint' => 1, 'default' => 1],
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('UserDeviceId', true);
|
$this->forge->addKey('UserDeviceId', true);
|
||||||
$this->forge->addKey(['ContactID', 'DeviceFingerprint'], false, true);
|
$this->forge->addKey(['ContactID', 'DeviceFingerprint'], false, true);
|
||||||
$this->forge->createTable('userdevices', true);
|
$this->forge->createTable('userdevices', true);
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'LoginAttemptId' => ['type' => 'BIGINT', 'unsigned' => true, 'auto_increment' => true],
|
'LoginAttemptId' => ['type' => 'BIGINT', 'unsigned' => true, 'auto_increment' => true],
|
||||||
'ContactID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
|
'ContactID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
|
||||||
'DeviceId' => ['type' => 'CHAR', 'constraint' => 36, 'null' => true],
|
'DeviceId' => ['type' => 'CHAR', 'constraint' => 36, 'null' => true],
|
||||||
'IpAddress' => ['type' => 'VARCHAR', 'constraint' => 45],
|
'IpAddress' => ['type' => 'VARCHAR', 'constraint' => 45],
|
||||||
'AttemptAt' => ['type' => 'DATETIME'],
|
'AttemptAt' => ['type' => 'DATETIME'],
|
||||||
'IsSuccess' => ['type' => 'TINYINT', 'constraint' => 1],
|
'IsSuccess' => ['type' => 'TINYINT', 'constraint' => 1],
|
||||||
'FailureReason' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
'FailureReason' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('LoginAttemptId', true);
|
$this->forge->addKey('LoginAttemptId', true);
|
||||||
$this->forge->addKey('ContactID');
|
$this->forge->addKey('ContactID');
|
||||||
$this->forge->addKey(['IpAddress', 'AttemptAt']);
|
$this->forge->addKey(['IpAddress', 'AttemptAt']);
|
||||||
$this->forge->addKey(['ContactID', 'AttemptAt']);
|
$this->forge->addKey(['ContactID', 'AttemptAt']);
|
||||||
$this->forge->createTable('loginattempts', true);
|
$this->forge->createTable('loginattempts', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down() {
|
public function down() {
|
||||||
$this->forge->dropTable('loginattempts');
|
$this->forge->dropTable('loginattempts');
|
||||||
$this->forge->dropTable('userdevices');
|
$this->forge->dropTable('userdevices');
|
||||||
$this->forge->dropTable('contactdetail');
|
$this->forge->dropTable('contactdetail');
|
||||||
$this->forge->dropTable('contact');
|
$this->forge->dropTable('contact');
|
||||||
$this->forge->dropTable('users');
|
$this->forge->dropTable('users');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,170 +1,170 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
use CodeIgniter\Database\Migration;
|
||||||
|
|
||||||
class CreateTestDefinitions extends Migration {
|
class CreateTestDefinitions extends Migration {
|
||||||
public function up() {
|
public function up() {
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'TestSiteID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
'TestSiteID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
||||||
'SiteID' => ['type' => 'INT', 'null' => false],
|
'SiteID' => ['type' => 'INT', 'null' => false],
|
||||||
'TestSiteCode' => ['type' => 'varchar', 'constraint'=> 6, 'null' => false],
|
'TestSiteCode' => ['type' => 'varchar', 'constraint'=> 6, 'null' => false],
|
||||||
'TestSiteName' => ['type' => 'varchar', 'constraint'=> 100, 'null' => false],
|
'TestSiteName' => ['type' => 'varchar', 'constraint'=> 100, 'null' => false],
|
||||||
'TestType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => false],
|
'TestType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => false],
|
||||||
'Description' => ['type' => 'varchar', 'constraint'=> 255, 'null' => true],
|
'Description' => ['type' => 'varchar', 'constraint'=> 255, 'null' => true],
|
||||||
'DisciplineID' => ['type' => 'INT', 'null' => true],
|
'DisciplineID' => ['type' => 'INT', 'null' => true],
|
||||||
'DepartmentID' => ['type' => 'INT', 'null' => true],
|
'DepartmentID' => ['type' => 'INT', 'null' => true],
|
||||||
'ResultType' => ['type' => 'VARCHAR', 'constraint'=> 20, 'null' => true],
|
'ResultType' => ['type' => 'VARCHAR', 'constraint'=> 20, 'null' => true],
|
||||||
'RefType' => ['type' => 'VARCHAR', 'constraint'=> 10, 'null' => true],
|
'RefType' => ['type' => 'VARCHAR', 'constraint'=> 10, 'null' => true],
|
||||||
'VSet' => ['type' => 'INT', 'null' => true],
|
'VSet' => ['type' => 'INT', 'null' => true],
|
||||||
'ReqQty' => ['type' => 'DECIMAL', 'constraint'=> '10,2', 'null' => true],
|
'ReqQty' => ['type' => 'DECIMAL', 'constraint'=> '10,2', 'null' => true],
|
||||||
'ReqQtyUnit' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
'ReqQtyUnit' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
||||||
'Unit1' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
'Unit1' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
||||||
'Factor' => ['type' => 'DECIMAL', 'constraint'=> '10,4', 'null' => true],
|
'Factor' => ['type' => 'DECIMAL', 'constraint'=> '10,4', 'null' => true],
|
||||||
'Unit2' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
'Unit2' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
||||||
'Decimal' => ['type' => 'int', 'null' => true, 'default' => 2],
|
'Decimal' => ['type' => 'int', 'null' => true, 'default' => 2],
|
||||||
'CollReq' => ['type' => 'varchar', 'constraint'=> 255, 'null' => true],
|
'CollReq' => ['type' => 'varchar', 'constraint'=> 255, 'null' => true],
|
||||||
'Method' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
'Method' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
||||||
'ExpectedTAT' => ['type' => 'INT', 'null' => true],
|
'ExpectedTAT' => ['type' => 'INT', 'null' => true],
|
||||||
'SeqScr' => ['type' => 'int', 'null' => true],
|
'SeqScr' => ['type' => 'int', 'null' => true],
|
||||||
'SeqRpt' => ['type' => 'int', 'null' => true],
|
'SeqRpt' => ['type' => 'int', 'null' => true],
|
||||||
'IndentLeft' => ['type' => 'int', 'null' => true, 'default' => 0],
|
'IndentLeft' => ['type' => 'int', 'null' => true, 'default' => 0],
|
||||||
'FontStyle' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
'FontStyle' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
||||||
'VisibleScr' => ['type' => 'int', 'null' => true, 'default' => 1],
|
'VisibleScr' => ['type' => 'int', 'null' => true, 'default' => 1],
|
||||||
'VisibleRpt' => ['type' => 'int', 'null' => true, 'default' => 1],
|
'VisibleRpt' => ['type' => 'int', 'null' => true, 'default' => 1],
|
||||||
'CountStat' => ['type' => 'int', 'null' => true, 'default' => 1],
|
'CountStat' => ['type' => 'int', 'null' => true, 'default' => 1],
|
||||||
'Level' => ['type' => 'int', 'null' => true],
|
'Level' => ['type' => 'int', 'null' => true],
|
||||||
'Requestable' => [ 'type' => 'TINYINT', 'constraint' => 1, 'null' => true, 'default' => 1, 'comment' => 'Flag indicating if test can be requested (1=yes, 0=no)' ],
|
'Requestable' => [ 'type' => 'TINYINT', 'constraint' => 1, 'null' => true, 'default' => 1, 'comment' => 'Flag indicating if test can be requested (1=yes, 0=no)' ],
|
||||||
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
'StartDate' => ['type' => 'Datetime', 'null' => true],
|
'StartDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
'EndDate' => ['type' => 'Datetime', 'null' => true],
|
'EndDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('TestSiteID', true);
|
$this->forge->addKey('TestSiteID', true);
|
||||||
$this->forge->createTable('testdefsite');
|
$this->forge->createTable('testdefsite');
|
||||||
|
|
||||||
// testdeftech table removed - merged into testdefsite
|
// testdeftech table removed - merged into testdefsite
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'TestCalID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
'TestCalID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
||||||
'TestSiteID' => ['type' => 'INT', 'unsigned' => true, 'null' => false],
|
'TestSiteID' => ['type' => 'INT', 'unsigned' => true, 'null' => false],
|
||||||
'DisciplineID' => ['type' => 'INT', 'null' => true],
|
'DisciplineID' => ['type' => 'INT', 'null' => true],
|
||||||
'DepartmentID' => ['type' => 'INT', 'null' => true],
|
'DepartmentID' => ['type' => 'INT', 'null' => true],
|
||||||
'FormulaCode' => ['type' => 'varchar', 'constraint'=> 255, 'null' => true],
|
'FormulaCode' => ['type' => 'varchar', 'constraint'=> 255, 'null' => true],
|
||||||
'RefType' => ['type' => 'varchar', 'constraint'=> 10, 'null' => true, 'default' => 'NMRC'],
|
'RefType' => ['type' => 'varchar', 'constraint'=> 10, 'null' => true, 'default' => 'NMRC'],
|
||||||
'Unit1' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
'Unit1' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
||||||
'Factor' => ['type' => 'DECIMAL', 'constraint'=> '10,4', 'null' => true],
|
'Factor' => ['type' => 'DECIMAL', 'constraint'=> '10,4', 'null' => true],
|
||||||
'Unit2' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
'Unit2' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
||||||
'Decimal' => ['type' => 'int', 'null' => true, 'default' => 2],
|
'Decimal' => ['type' => 'int', 'null' => true, 'default' => 2],
|
||||||
'Method' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
'Method' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
||||||
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
'EndDate' => ['type' => 'Datetime', 'null' => true]
|
'EndDate' => ['type' => 'Datetime', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('TestCalID', true);
|
$this->forge->addKey('TestCalID', true);
|
||||||
$this->forge->addForeignKey('TestSiteID', 'testdefsite', 'TestSiteID', 'CASCADE', 'CASCADE');
|
$this->forge->addForeignKey('TestSiteID', 'testdefsite', 'TestSiteID', 'CASCADE', 'CASCADE');
|
||||||
$this->forge->createTable('testdefcal');
|
$this->forge->createTable('testdefcal');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'TestGrpID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
'TestGrpID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
||||||
'TestSiteID' => ['type' => 'INT', 'unsigned' => true, 'null' => false],
|
'TestSiteID' => ['type' => 'INT', 'unsigned' => true, 'null' => false],
|
||||||
'Member' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
'Member' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
||||||
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
'EndDate' => ['type' => 'Datetime', 'null' => true]
|
'EndDate' => ['type' => 'Datetime', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('TestGrpID', true);
|
$this->forge->addKey('TestGrpID', true);
|
||||||
$this->forge->addForeignKey('TestSiteID', 'testdefsite', 'TestSiteID', 'CASCADE', 'CASCADE');
|
$this->forge->addForeignKey('TestSiteID', 'testdefsite', 'TestSiteID', 'CASCADE', 'CASCADE');
|
||||||
$this->forge->addForeignKey('Member', 'testdefsite', 'TestSiteID', 'CASCADE', 'CASCADE');
|
$this->forge->addForeignKey('Member', 'testdefsite', 'TestSiteID', 'CASCADE', 'CASCADE');
|
||||||
$this->forge->createTable('testdefgrp');
|
$this->forge->createTable('testdefgrp');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'RefNumID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
'RefNumID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
||||||
'SiteID' => ['type' => 'INT', 'null' => true],
|
'SiteID' => ['type' => 'INT', 'null' => true],
|
||||||
'TestSiteID' => ['type' => 'INT', 'null' => false],
|
'TestSiteID' => ['type' => 'INT', 'null' => false],
|
||||||
'SpcType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'SpcType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'Sex' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'Sex' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'Criteria' => ['type' => 'varchar', 'constraint'=>100, 'null' => true],
|
'Criteria' => ['type' => 'varchar', 'constraint'=>100, 'null' => true],
|
||||||
'AgeStart' => ['type' => 'INT', 'null' => true],
|
'AgeStart' => ['type' => 'INT', 'null' => true],
|
||||||
'AgeEnd' => ['type' => 'int', 'null' => true],
|
'AgeEnd' => ['type' => 'int', 'null' => true],
|
||||||
'NumRefType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'NumRefType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'RangeType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'RangeType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'LowSign' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'LowSign' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'Low' => ['type' => 'DECIMAL', 'constraint' => '10,2', 'null' => true],
|
'Low' => ['type' => 'DECIMAL', 'constraint' => '10,2', 'null' => true],
|
||||||
'HighSign' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'HighSign' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'High' => ['type' => 'DECIMAL', 'constraint' => '10,2', 'null' => true],
|
'High' => ['type' => 'DECIMAL', 'constraint' => '10,2', 'null' => true],
|
||||||
'Display' => ['type' => 'INT', 'null' => true],
|
'Display' => ['type' => 'INT', 'null' => true],
|
||||||
'Flag' => ['type' => 'varchar', 'constraint'=>10, 'null' => true],
|
'Flag' => ['type' => 'varchar', 'constraint'=>10, 'null' => true],
|
||||||
'Interpretation' => ['type' => 'varchar', 'constraint'=>255, 'null' => true],
|
'Interpretation' => ['type' => 'varchar', 'constraint'=>255, 'null' => true],
|
||||||
'Notes' => ['type' => 'varchar', 'constraint'=>255, 'null' => true],
|
'Notes' => ['type' => 'varchar', 'constraint'=>255, 'null' => true],
|
||||||
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
'StartDate' => ['type' => 'Datetime', 'null' => true],
|
'StartDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
'EndDate' => ['type' => 'Datetime', 'null' => true],
|
'EndDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('RefNumID', true);
|
$this->forge->addKey('RefNumID', true);
|
||||||
$this->forge->createTable('refnum');
|
$this->forge->createTable('refnum');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'RefTxtID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
'RefTxtID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
||||||
'SiteID' => ['type' => 'INT', 'null' => true],
|
'SiteID' => ['type' => 'INT', 'null' => true],
|
||||||
'TestSiteID' => ['type' => 'INT', 'null' => false],
|
'TestSiteID' => ['type' => 'INT', 'null' => false],
|
||||||
'SpcType' => ['type' => 'varchar', 'constraint'=> 10, 'null' => false],
|
'SpcType' => ['type' => 'varchar', 'constraint'=> 10, 'null' => false],
|
||||||
'Sex' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'Sex' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'Criteria' => ['type' => 'varchar', 'constraint'=>100, 'null' => true],
|
'Criteria' => ['type' => 'varchar', 'constraint'=>100, 'null' => true],
|
||||||
'AgeStart' => ['type' => 'INT', 'null' => true],
|
'AgeStart' => ['type' => 'INT', 'null' => true],
|
||||||
'AgeEnd' => ['type' => 'int', 'null' => true],
|
'AgeEnd' => ['type' => 'int', 'null' => true],
|
||||||
'TxtRefType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
'TxtRefType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
||||||
'RefTxt' => ['type' => 'varchar', 'constraint'=>255, 'null' => true],
|
'RefTxt' => ['type' => 'varchar', 'constraint'=>255, 'null' => true],
|
||||||
'Flag' => ['type' => 'varchar', 'constraint'=>10, 'null' => true],
|
'Flag' => ['type' => 'varchar', 'constraint'=>10, 'null' => true],
|
||||||
'Notes' => ['type' => 'varchar', 'constraint'=>255, 'null' => true],
|
'Notes' => ['type' => 'varchar', 'constraint'=>255, 'null' => true],
|
||||||
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
'StartDate' => ['type' => 'Datetime', 'null' => true],
|
'StartDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
'EndDate' => ['type' => 'Datetime', 'null' => true],
|
'EndDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('RefTxtID', true);
|
$this->forge->addKey('RefTxtID', true);
|
||||||
$this->forge->createTable('reftxt');
|
$this->forge->createTable('reftxt');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'FlagDefID' => ['type' => 'INT', 'auto_increment' => true],
|
'FlagDefID' => ['type' => 'INT', 'auto_increment' => true],
|
||||||
'InstrumentName' => ['type' => 'varchar', 'constraint' => 100, 'null' => true],
|
'InstrumentName' => ['type' => 'varchar', 'constraint' => 100, 'null' => true],
|
||||||
'Flag' => ['type' => 'varchar', 'constraint' => 50, 'null' => true],
|
'Flag' => ['type' => 'varchar', 'constraint' => 50, 'null' => true],
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('FlagDefID', true);
|
$this->forge->addKey('FlagDefID', true);
|
||||||
$this->forge->createTable('flagdef');
|
$this->forge->createTable('flagdef');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'TestMapID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
'TestMapID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
||||||
'HostType' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
'HostType' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
||||||
'HostID' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
'HostID' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
||||||
'ClientType' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
'ClientType' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
||||||
'ClientID' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
'ClientID' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
||||||
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
'EndDate' => ['type' => 'Datetime', 'null' => true]
|
'EndDate' => ['type' => 'Datetime', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('TestMapID', true);
|
$this->forge->addKey('TestMapID', true);
|
||||||
$this->forge->createTable('testmap');
|
$this->forge->createTable('testmap');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'TestMapDetailID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
'TestMapDetailID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
||||||
'TestMapID' => ['type' => 'INT'],
|
'TestMapID' => ['type' => 'INT'],
|
||||||
'HostTestCode' => ['type' => 'varchar', 'constraint'=> 10, 'null' => true],
|
'HostTestCode' => ['type' => 'varchar', 'constraint'=> 10, 'null' => true],
|
||||||
'HostTestName' => ['type' => 'varchar', 'constraint'=> 100, 'null' => true],
|
'HostTestName' => ['type' => 'varchar', 'constraint'=> 100, 'null' => true],
|
||||||
'ConDefID' => ['type' => 'INT', 'null' => true],
|
'ConDefID' => ['type' => 'INT', 'null' => true],
|
||||||
'ClientTestCode' => ['type' => 'varchar', 'constraint'=> 10, 'null' => true],
|
'ClientTestCode' => ['type' => 'varchar', 'constraint'=> 10, 'null' => true],
|
||||||
'ClientTestName' => ['type' => 'varchar', 'constraint'=> 100, 'null' => true],
|
'ClientTestName' => ['type' => 'varchar', 'constraint'=> 100, 'null' => true],
|
||||||
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
||||||
'EndDate' => ['type' => 'Datetime', 'null' => true]
|
'EndDate' => ['type' => 'Datetime', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('TestMapDetailID', true);
|
$this->forge->addKey('TestMapDetailID', true);
|
||||||
$this->forge->createTable('testmapdetail');
|
$this->forge->createTable('testmapdetail');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down() {
|
public function down() {
|
||||||
$this->forge->dropTable('testmapdetail');
|
$this->forge->dropTable('testmapdetail');
|
||||||
$this->forge->dropTable('testmap');
|
$this->forge->dropTable('testmap');
|
||||||
$this->forge->dropTable('flagdef');
|
$this->forge->dropTable('flagdef');
|
||||||
$this->forge->dropTable('reftxt');
|
$this->forge->dropTable('reftxt');
|
||||||
$this->forge->dropTable('refnum');
|
$this->forge->dropTable('refnum');
|
||||||
$this->forge->dropTable('testdefgrp');
|
$this->forge->dropTable('testdefgrp');
|
||||||
$this->forge->dropTable('testdefcal');
|
$this->forge->dropTable('testdefcal');
|
||||||
$this->forge->dropTable('testdefsite');
|
$this->forge->dropTable('testdefsite');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,66 +1,66 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
use CodeIgniter\Database\Migration;
|
||||||
|
|
||||||
class CreateLabInfrastructure extends Migration {
|
class CreateLabInfrastructure extends Migration {
|
||||||
public function up() {
|
public function up() {
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'EID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
'EID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
||||||
'IEID' => ['type' => 'varchar', 'constraint' => 50],
|
'IEID' => ['type' => 'varchar', 'constraint' => 50],
|
||||||
'DepartmentID' => ['type' => 'int', 'constraint'=> 10, 'null'=> false],
|
'DepartmentID' => ['type' => 'int', 'constraint'=> 10, 'null'=> false],
|
||||||
'InstrumentID' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
'InstrumentID' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
||||||
'InstrumentName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
'InstrumentName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
||||||
'WorkstationID' => ['type' => 'int', 'unsigned' => true ],
|
'WorkstationID' => ['type' => 'int', 'unsigned' => true ],
|
||||||
'Enable' => ['type' => 'bit', 'null'=> false],
|
'Enable' => ['type' => 'bit', 'null'=> false],
|
||||||
'EquipmentRole' => ['type' => 'varchar', 'constraint' => 1, 'null'=> false],
|
'EquipmentRole' => ['type' => 'varchar', 'constraint' => 1, 'null'=> false],
|
||||||
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
||||||
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('EID', true);
|
$this->forge->addKey('EID', true);
|
||||||
$this->forge->createTable('equipmentlist');
|
$this->forge->createTable('equipmentlist');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'InterfaceID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
'InterfaceID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
||||||
'InstrumentID' => ['type' => 'int', 'null'=> false],
|
'InstrumentID' => ['type' => 'int', 'null'=> false],
|
||||||
'SiteID' => ['type' => 'int', 'null'=> true],
|
'SiteID' => ['type' => 'int', 'null'=> true],
|
||||||
'InterfaceName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
'InterfaceName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
||||||
'InterfaceDesc' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
'InterfaceDesc' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
||||||
'Protocol' => ['type' => 'varchar', 'constraint'=> 50, 'null'=> true],
|
'Protocol' => ['type' => 'varchar', 'constraint'=> 50, 'null'=> true],
|
||||||
'IPAddress' => ['type' => 'varchar', 'constraint'=> 50, 'null'=> true],
|
'IPAddress' => ['type' => 'varchar', 'constraint'=> 50, 'null'=> true],
|
||||||
'Port' => ['type' => 'varchar', 'constraint'=> 25, 'null'=> true],
|
'Port' => ['type' => 'varchar', 'constraint'=> 25, 'null'=> true],
|
||||||
'COM' => ['type' => 'varchar', 'constraint'=> 5, 'null'=> true],
|
'COM' => ['type' => 'varchar', 'constraint'=> 5, 'null'=> true],
|
||||||
'Baud' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true],
|
'Baud' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true],
|
||||||
'Data' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true],
|
'Data' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true],
|
||||||
'Parity' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true],
|
'Parity' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true],
|
||||||
'Stop' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true],
|
'Stop' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true],
|
||||||
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
||||||
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('InterfaceID', true);
|
$this->forge->addKey('InterfaceID', true);
|
||||||
$this->forge->createTable('comparameters');
|
$this->forge->createTable('comparameters');
|
||||||
|
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'EquipmentID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
'EquipmentID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
||||||
'DeviceName' => ['type' => 'varchar', 'constraint' => 50,'null'=> false],
|
'DeviceName' => ['type' => 'varchar', 'constraint' => 50,'null'=> false],
|
||||||
'Description' => ['type' => 'varchar', 'constraint' => 50,'null'=> false],
|
'Description' => ['type' => 'varchar', 'constraint' => 50,'null'=> false],
|
||||||
'SiteID' => ['type' => 'int', 'null'=> true],
|
'SiteID' => ['type' => 'int', 'null'=> true],
|
||||||
'LocationID' => ['type' => 'int', 'null'=> true],
|
'LocationID' => ['type' => 'int', 'null'=> true],
|
||||||
'DIDType' => ['type' => 'varchar', 'constraint'=>10, 'null'=> true],
|
'DIDType' => ['type' => 'varchar', 'constraint'=>10, 'null'=> true],
|
||||||
'DID' => ['type' => 'varchar', 'constraint'=>100, 'null'=> true],
|
'DID' => ['type' => 'varchar', 'constraint'=>100, 'null'=> true],
|
||||||
'MachineID' => ['type' => 'varchar', 'constraint'=>100, 'null'=> true],
|
'MachineID' => ['type' => 'varchar', 'constraint'=>100, 'null'=> true],
|
||||||
'IPAddress' => ['type' => 'varchar', 'constraint'=>25, 'null'=> true],
|
'IPAddress' => ['type' => 'varchar', 'constraint'=>25, 'null'=> true],
|
||||||
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
||||||
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('EquipmentID', true);
|
$this->forge->addKey('EquipmentID', true);
|
||||||
$this->forge->createTable('devicelist');
|
$this->forge->createTable('devicelist');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down() {
|
public function down() {
|
||||||
$this->forge->dropTable('devicelist');
|
$this->forge->dropTable('devicelist');
|
||||||
$this->forge->dropTable('comparameters');
|
$this->forge->dropTable('comparameters');
|
||||||
$this->forge->dropTable('equipmentlist');
|
$this->forge->dropTable('equipmentlist');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user